{
  "version": 3,
  "sources": ["../../../../../src/lib/ui/hooks/clipboard/pasteUrl.ts"],
  "sourcesContent": ["import { Editor, TLExternalContentSource, TLShapeId, VecLike } from '@tldraw/editor'\nimport { getSelectedLinkShape } from '../../../utils/shapes/shapes'\nimport { putPastedExternalContent } from './putPastedContent'\n\nfunction getLinkTargetShapeId(editor: Editor, url: string): TLShapeId | undefined {\n\t// `new URL()` tolerates line breaks, so a `text/uri-list` holding several urls would otherwise\n\t// be written to the shape verbatim.\n\tif (/\\s/.test(url)) return undefined\n\n\treturn getSelectedLinkShape(editor)?.id\n}\n\n/**\n * When the clipboard has plain text that is a valid URL, create a bookmark shape and insert it into\n * the scene \u2014 or, when a single shape that can hold a link is selected, set that shape's link\n * instead.\n *\n * @param editor - The editor instance.\n * @param url - The URL to paste.\n * @param point - The point at which to paste the file.\n * @internal\n */\nexport async function pasteUrl(\n\teditor: Editor,\n\turl: string,\n\tpoint?: VecLike,\n\tsources?: TLExternalContentSource[],\n\tclipboardPasteSource: 'native-event' | 'clipboard-read' = 'native-event'\n) {\n\t// A `text/uri-list` terminates each url with a line break, and some apps leave one on a copied\n\t// plain text url too. `new URL()` accepts them, so they would otherwise reach the shape.\n\tconst trimmedUrl = url.trim()\n\n\teditor.markHistoryStoppingPoint('paste')\n\n\treturn await putPastedExternalContent(\n\t\teditor,\n\t\t{\n\t\t\ttype: 'url',\n\t\t\tpoint,\n\t\t\turl: trimmedUrl,\n\t\t\tsources,\n\t\t\tshapeId: getLinkTargetShapeId(editor, trimmedUrl),\n\t\t},\n\t\t{ source: clipboardPasteSource, point }\n\t)\n}\n"],
  "mappings": "AACA,SAAS,4BAA4B;AACrC,SAAS,gCAAgC;AAEzC,SAAS,qBAAqB,QAAgB,KAAoC;AAGjF,MAAI,KAAK,KAAK,GAAG,EAAG,QAAO;AAE3B,SAAO,qBAAqB,MAAM,GAAG;AACtC;AAYA,eAAsB,SACrB,QACA,KACA,OACA,SACA,uBAA0D,gBACzD;AAGD,QAAM,aAAa,IAAI,KAAK;AAE5B,SAAO,yBAAyB,OAAO;AAEvC,SAAO,MAAM;AAAA,IACZ;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN;AAAA,MACA,KAAK;AAAA,MACL;AAAA,MACA,SAAS,qBAAqB,QAAQ,UAAU;AAAA,IACjD;AAAA,IACA,EAAE,QAAQ,sBAAsB,MAAM;AAAA,EACvC;AACD;",
  "names": []
}
