@xsynaptic/share-kit 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -7
- package/dist/index.d.mts +351 -170
- package/dist/index.mjs +712 -438
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +11 -0
- package/package.json +1 -1
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/actions.ts","../src/assets.ts","../src/count.ts","../src/destinations.ts","../src/caption.ts","../src/dom.ts","../src/feedback.ts","../src/strings.ts","../src/payload.ts","../src/qr.ts","../src/render.ts","../src/sync.ts","../src/types.ts","../src/element.ts","../src/define.ts","../src/icons.ts"],"sourcesContent":["const shareCapabilities = ['files', 'link', 'copy-image', 'handheld'] as const;\n\nexport type ShareCapability = (typeof shareCapabilities)[number];\n\nexport interface ShareAssetSource {\n\tfilename: string;\n\tsrc: string;\n\ttype: string;\n}\n\nconst pngType = 'image/png';\n\nfunction canShareFiles() {\n\tif (!('canShare' in navigator)) return false;\n\n\treturn navigator.canShare({ files: [new File([], 'probe.jpg', { type: 'image/jpeg' })] });\n}\n\nfunction canCopyImage() {\n\tif (!('clipboard' in navigator) || !('ClipboardItem' in globalThis)) return false;\n\n\treturn 'supports' in ClipboardItem && ClipboardItem.supports(pngType);\n}\n\nconst capabilityTests = {\n\t'copy-image': canCopyImage,\n\tfiles: canShareFiles,\n\t// A phone's share sheet reaches its apps; a desktop's mostly reaches Mail and AirDrop\n\thandheld: () => matchMedia('(pointer: coarse)').matches,\n\tlink: () => 'share' in navigator,\n} as const satisfies Record<ShareCapability, () => boolean>;\n\nfunction isShareCapability(value: string): value is ShareCapability {\n\treturn shareCapabilities.some((capability) => capability === value);\n}\n\n// A list already on the element wins, so a page can show how the dialog looks on another device\nexport function getShareCapabilities(preset: string | undefined) {\n\tif (preset !== undefined) return preset.split(' ').filter(isShareCapability);\n\n\treturn shareCapabilities.filter((capability) => capabilityTests[capability]());\n}\n\nexport function isDomError(error: unknown, name: string) {\n\treturn error instanceof DOMException && error.name === name;\n}\n\n// `no-cache` revalidates a copy cached without CORS headers, which this fetch would reject\nexport async function fetchFile({ filename, src, type }: ShareAssetSource, signal: AbortSignal) {\n\tconst response = await fetch(src, { cache: 'no-cache', signal });\n\n\tif (!response.ok) throw new Error(`${String(response.status)} for ${src}`);\n\n\treturn new File([await response.blob()], filename, { type });\n}\n\n// `download` is ignored on a cross-origin href, so the file goes through an object URL\nexport function saveFile(file: File) {\n\tconst objectUrl = URL.createObjectURL(file);\n\tconst link = document.createElement('a');\n\n\tlink.download = file.name;\n\tlink.href = objectUrl;\n\tlink.hidden = true;\n\tdocument.body.append(link);\n\tlink.click();\n\tlink.remove();\n\n\treturn objectUrl;\n}\n\n// PNG is the only image type every browser's async clipboard accepts\nasync function toPngBlob(pending: Promise<File | undefined>) {\n\tconst file = await pending;\n\n\tif (!file) throw new Error('The image did not load');\n\n\tconst bitmap = await createImageBitmap(file);\n\tconst canvas = new OffscreenCanvas(bitmap.width, bitmap.height);\n\tconst context = canvas.getContext('2d');\n\n\tif (!context) throw new Error('No 2D context for the PNG conversion');\n\n\tcontext.drawImage(bitmap, 0, 0);\n\tbitmap.close();\n\n\treturn canvas.convertToBlob({ type: pngType });\n}\n\nexport function copyImage(file: Promise<File | undefined>) {\n\treturn navigator.clipboard.write([new ClipboardItem({ [pngType]: toPngBlob(file) })]);\n}\n\nexport function isOpenHash(openHash: string | undefined) {\n\treturn openHash !== undefined && location.hash === `#${openHash}`;\n}\n\n// Replacing the entry keeps the router's state and stops a reload or Back from reopening the dialog\nexport function clearOpenHash(openHash: string | undefined) {\n\tif (!isOpenHash(openHash)) return;\n\n\thistory.replaceState(history.state, '', `${location.pathname}${location.search}`);\n}\n","import type { ShareAssetSource } from './actions.js';\n\nimport { fetchFile, isDomError, saveFile } from './actions.js';\n\nexport type ShareOutcome = 'dismissed' | 'error' | 'retry' | 'saved' | 'shared' | 'unsaved';\n\ninterface ShareAssetFilesOptions {\n\tcanShare: boolean;\n\tgetSource: (tile: HTMLElement) => ShareAssetSource | undefined;\n\tsignal: AbortSignal;\n}\n\nfunction isFile(file: File | undefined): file is File {\n\treturn file !== undefined;\n}\n\nexport class ShareAssetFiles {\n\t#files = new Map<HTMLElement, File>();\n\t#loads = new Map<HTMLElement, Promise<File | undefined>>();\n\t#objectUrls = new Set<string>();\n\t#options: ShareAssetFilesOptions;\n\n\tconstructor(options: ShareAssetFilesOptions) {\n\t\tthis.#options = options;\n\t}\n\n\tdispose() {\n\t\tfor (const objectUrl of this.#objectUrls) URL.revokeObjectURL(objectUrl);\n\n\t\tthis.#objectUrls.clear();\n\t\tthis.#files.clear();\n\t\tthis.#loads.clear();\n\t}\n\n\tload(tile: HTMLElement) {\n\t\tconst pending = this.#loads.get(tile);\n\n\t\tif (pending) return pending;\n\n\t\tconst promise = this.#fetch(tile);\n\n\t\tthis.#loads.set(tile, promise);\n\n\t\treturn promise;\n\t}\n\n\tasync save(tile: HTMLElement): Promise<ShareOutcome> {\n\t\tconst file = await this.load(tile);\n\n\t\treturn file ? this.#saveFiles([file]) : 'unsaved';\n\t}\n\n\tasync share(tiles: Array<HTMLElement>): Promise<ShareOutcome> {\n\t\tconst ready = tiles.map((tile) => this.#files.get(tile));\n\n\t\t// Calling `share()` before any await keeps the tap's user activation valid\n\t\tif (ready.every(isFile)) return this.#shareFiles(ready);\n\n\t\tconst loaded = await Promise.all(tiles.map((tile) => this.load(tile)));\n\n\t\treturn loaded.every(isFile) ? this.#shareFiles(loaded) : 'error';\n\t}\n\n\t// Warming on hover lets the share call still start inside the tap\n\twarm(target: EventTarget | null) {\n\t\tif (!(target instanceof Element)) return;\n\n\t\tconst tile = target\n\t\t\t.closest('[data-share-kit-action=\"share\"]')\n\t\t\t?.closest<HTMLElement>('[data-share-kit-asset]');\n\n\t\tif (tile) void this.load(tile);\n\t}\n\n\t// A failed load is forgotten so the next tap tries again\n\tasync #fetch(tile: HTMLElement) {\n\t\tconst source = this.#options.getSource(tile);\n\n\t\tif (!source) return;\n\n\t\ttry {\n\t\t\tconst file = await fetchFile(source, this.#options.signal);\n\n\t\t\tthis.#files.set(tile, file);\n\n\t\t\treturn file;\n\t\t} catch {\n\t\t\tthis.#loads.delete(tile);\n\n\t\t\treturn;\n\t\t}\n\t}\n\n\t#saveFiles(files: Array<File>): ShareOutcome {\n\t\tfor (const file of files) this.#objectUrls.add(saveFile(file));\n\n\t\treturn 'saved';\n\t}\n\n\tasync #shareFiles(files: Array<File>): Promise<ShareOutcome> {\n\t\tif (!this.#options.canShare || !navigator.canShare({ files })) return this.#saveFiles(files);\n\n\t\ttry {\n\t\t\tawait navigator.share({ files });\n\n\t\t\treturn 'shared';\n\t\t} catch (error) {\n\t\t\tif (isDomError(error, 'AbortError') || this.#options.signal.aborted) return 'dismissed';\n\n\t\t\t// A slow load used up the tap's activation; the files are ready now, so another tap works\n\t\t\tif (isDomError(error, 'NotAllowedError')) return 'retry';\n\n\t\t\treturn this.#saveFiles(files);\n\t\t}\n\t}\n}\n","type ShareCounter = 'graphemes' | 'length' | 'stringz' | 'utf8' | 'weighted';\n\ntype ShareUrlCost = 'actual' | 'fixed' | 'shortened';\n\n// X and Mastodon both charge 23 for any link, whatever its length\nconst urlFixedCost = 23;\n\nconst urlPattern = /https?:\\/\\/[\\w!#$%&'()*+,./:;=?@~-]+/giu;\n\nconst urlTrailingPunctuation = /[!'),.:;?]+$/u;\n\nconst graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });\n\nconst utf8Encoder = new TextEncoder();\n\nconst latinCombiningMarkRanges = [\n\t[0x03_00, 0x03_6f],\n\t[0x1a_b0, 0x1a_ff],\n\t[0x1d_c0, 0x1d_ff],\n\t[0x20_d0, 0x20_ff],\n\t[0xfe_20, 0xfe_2f],\n] as const;\n\n// The `v` flag is newer than `Intl.Segmenter`; without it emoji are charged per code point, which only overcounts\nfunction getEmojiPattern() {\n\ttry {\n\t\treturn new RegExp(String.raw`^\\p{RGI_Emoji}$`, 'v');\n\t} catch {\n\t\treturn;\n\t}\n}\n\nconst emojiPattern = getEmojiPattern();\n\nexport function getGraphemes(text: string) {\n\treturn Array.from(graphemeSegmenter.segment(text), ({ segment }) => segment);\n}\n\n// twitter-text config v3; every code point outside these ranges weighs double\nfunction isLightCodePoint(codePoint: number) {\n\treturn (\n\t\tcodePoint <= 0x10_ff ||\n\t\t(codePoint >= 0x20_00 && codePoint <= 0x20_0d) ||\n\t\t(codePoint >= 0x20_10 && codePoint <= 0x20_1f) ||\n\t\t(codePoint >= 0x20_32 && codePoint <= 0x20_37)\n\t);\n}\n\nfunction getWeightedLength(text: string) {\n\tconst graphemes = getGraphemes(text.normalize('NFC'));\n\tlet total = 0;\n\n\tfor (const grapheme of graphemes) {\n\t\tif (emojiPattern?.test(grapheme)) {\n\t\t\ttotal += 2;\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const character of grapheme) {\n\t\t\ttotal += isLightCodePoint(character.codePointAt(0) ?? 0) ? 1 : 2;\n\t\t}\n\t}\n\n\treturn total;\n}\n\nfunction isLatinCombiningMark(codePoint: number) {\n\treturn latinCombiningMarkRanges.some(([start, end]) => codePoint >= start && codePoint <= end);\n}\n\n// Mirrors stringz, Mastodon's web composer counter: an emoji sequence is one, Latin combining marks are free, Thai marks count apart\nfunction getStringzLength(text: string) {\n\tlet total = 0;\n\n\tfor (const grapheme of getGraphemes(text)) {\n\t\tif (emojiPattern?.test(grapheme)) {\n\t\t\ttotal += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const character of grapheme) {\n\t\t\tif (!isLatinCombiningMark(character.codePointAt(0) ?? 0)) total += 1;\n\t\t}\n\t}\n\n\treturn total;\n}\n\n// Mirrors `toShortUrl` in bluesky-social/social-app, which the composer applies before it counts\nfunction getShortenedUrlLength(url: string) {\n\tif (!URL.canParse(url)) return getGraphemes(url).length;\n\n\tconst { hash, host, pathname, search } = new URL(url);\n\tconst path = `${pathname === '/' ? '' : pathname}${search}${hash}`;\n\n\treturn host.length + Math.min(path.length, 16);\n}\n\nconst textCounters = {\n\tgraphemes: (text: string) => getGraphemes(text).length,\n\tlength: (text: string) => text.length,\n\tstringz: getStringzLength,\n\tutf8: (text: string) => utf8Encoder.encode(text).length,\n\tweighted: getWeightedLength,\n} as const satisfies Record<ShareCounter, (text: string) => number>;\n\nfunction splitLinks(text: string) {\n\tconst links: Array<string> = [];\n\n\tconst rest = text.replaceAll(urlPattern, (match) => {\n\t\tconst trailing = urlTrailingPunctuation.exec(match)?.[0] ?? '';\n\n\t\tlinks.push(match.slice(0, match.length - trailing.length));\n\n\t\treturn trailing;\n\t});\n\n\treturn { links, rest };\n}\n\nexport interface ShareCountRule {\n\tcounter: ShareCounter;\n\turlCost: ShareUrlCost;\n}\n\nexport function countText(text: string, { counter, urlCost }: ShareCountRule) {\n\tconst count = textCounters[counter];\n\n\tif (urlCost === 'actual') return count(text);\n\n\tconst { links, rest } = splitLinks(text);\n\tlet total = count(rest);\n\n\tfor (const link of links) {\n\t\ttotal += urlCost === 'fixed' ? urlFixedCost : getShortenedUrlLength(link);\n\t}\n\n\treturn total;\n}\n","import type { ShareCountRule } from './count.js';\nimport type { ShareKitAssetRole } from './types.js';\n\ntype ShareCaptionShape = 'full' | 'text' | 'title' | 'url';\n\ninterface ShareComposerInput {\n\tmedia: string | undefined;\n\ttext: string;\n\turl: string;\n}\n\nexport interface ShareDestination extends ShareCountRule {\n\tassetRole: Exclude<ShareKitAssetRole, 'photo'>;\n\tgetComposerUrl?: (input: ShareComposerInput) => string | undefined;\n\t// The post is an image, so a phone hands the file to the share sheet rather than opening a composer\n\tisImagePost: boolean;\n\tisLinkOnly?: boolean;\n\tlimit?: number;\n\tshape: ShareCaptionShape;\n}\n\nfunction withQuery(base: string, parameters: Record<string, string | undefined>) {\n\tconst url = new URL(base);\n\n\tfor (const [name, value] of Object.entries(parameters)) {\n\t\tif (value) url.searchParams.set(name, value);\n\t}\n\n\treturn url.href;\n}\n\nexport const shareDestinationAny = 'any';\n\nexport const shareDestinations = {\n\tbluesky: {\n\t\tassetRole: 'portrait',\n\t\tcounter: 'graphemes',\n\t\tgetComposerUrl: ({ text }) => withQuery('https://bsky.app/intent/compose', { text }),\n\t\tisImagePost: true,\n\t\tlimit: 300,\n\t\tshape: 'full',\n\t\turlCost: 'shortened',\n\t},\n\tfacebook: {\n\t\tassetRole: 'landscape',\n\t\tcounter: 'length',\n\t\tgetComposerUrl: ({ url }) =>\n\t\t\twithQuery('https://www.facebook.com/sharer/sharer.php', { u: url }),\n\t\tisImagePost: false,\n\t\tisLinkOnly: true,\n\t\tlimit: 63_206,\n\t\tshape: 'full',\n\t\turlCost: 'actual',\n\t},\n\tinstagram: {\n\t\tassetRole: 'portrait',\n\t\tcounter: 'length',\n\t\tisImagePost: true,\n\t\tlimit: 2200,\n\t\tshape: 'text',\n\t\turlCost: 'actual',\n\t},\n\t'instagram-story': {\n\t\tassetRole: 'story',\n\t\tcounter: 'length',\n\t\tisImagePost: true,\n\t\tshape: 'url',\n\t\turlCost: 'actual',\n\t},\n\tlinkedin: {\n\t\tassetRole: 'landscape',\n\t\tcounter: 'length',\n\t\tgetComposerUrl: ({ url }) =>\n\t\t\twithQuery('https://www.linkedin.com/sharing/share-offsite/', { url }),\n\t\tisImagePost: false,\n\t\tisLinkOnly: true,\n\t\tlimit: 3000,\n\t\tshape: 'full',\n\t\turlCost: 'actual',\n\t},\n\t// Each reader posts from their own server, so there is no composer to open\n\tmastodon: {\n\t\tassetRole: 'portrait',\n\t\tcounter: 'stringz',\n\t\tisImagePost: true,\n\t\tlimit: 500,\n\t\tshape: 'full',\n\t\turlCost: 'fixed',\n\t},\n\tmessages: {\n\t\tassetRole: 'landscape',\n\t\tcounter: 'length',\n\t\tisImagePost: false,\n\t\tshape: 'full',\n\t\turlCost: 'actual',\n\t},\n\tpinterest: {\n\t\tassetRole: 'portrait',\n\t\tcounter: 'length',\n\t\tgetComposerUrl: ({ media, text, url }) =>\n\t\t\twithQuery('https://www.pinterest.com/pin/create/button/', {\n\t\t\t\tdescription: text,\n\t\t\t\tmedia,\n\t\t\t\turl,\n\t\t\t}),\n\t\tisImagePost: false,\n\t\tlimit: 800,\n\t\tshape: 'text',\n\t\turlCost: 'actual',\n\t},\n\treddit: {\n\t\tassetRole: 'landscape',\n\t\tcounter: 'length',\n\t\tgetComposerUrl: ({ text, url }) =>\n\t\t\twithQuery('https://www.reddit.com/submit', { title: text, url }),\n\t\tisImagePost: false,\n\t\tlimit: 300,\n\t\tshape: 'title',\n\t\turlCost: 'actual',\n\t},\n\t[shareDestinationAny]: {\n\t\tassetRole: 'landscape',\n\t\tcounter: 'length',\n\t\tisImagePost: false,\n\t\tshape: 'full',\n\t\turlCost: 'actual',\n\t},\n\t// Threads' docs give the limit in characters but count emoji in bytes; bytes is the reading that can't overshoot\n\tthreads: {\n\t\tassetRole: 'portrait',\n\t\tcounter: 'utf8',\n\t\tgetComposerUrl: ({ text }) => withQuery('https://www.threads.com/intent/post', { text }),\n\t\tisImagePost: true,\n\t\tlimit: 500,\n\t\tshape: 'full',\n\t\turlCost: 'actual',\n\t},\n\tx: {\n\t\tassetRole: 'landscape',\n\t\tcounter: 'weighted',\n\t\tgetComposerUrl: ({ text }) => withQuery('https://x.com/intent/tweet', { text }),\n\t\tisImagePost: false,\n\t\tlimit: 280,\n\t\tshape: 'full',\n\t\turlCost: 'fixed',\n\t},\n} as const satisfies Record<string, ShareDestination>;\n\nexport type ShareKitDestinationId = keyof typeof shareDestinations;\n\nexport function isShareDestinationId(id: string): id is ShareKitDestinationId {\n\treturn Object.hasOwn(shareDestinations, id);\n}\n\nexport function getShareDestination(id: ShareKitDestinationId): ShareDestination {\n\treturn shareDestinations[id];\n}\n\nexport function getDestinationUrl(\n\turl: string,\n\tid: ShareKitDestinationId,\n\tutmMedium: string | undefined,\n) {\n\tif (!utmMedium || id === shareDestinationAny || !URL.canParse(url)) return url;\n\n\treturn withQuery(url, { utm_medium: utmMedium, utm_source: id });\n}\n\nexport type SharePrimaryAction =\n\t'copy-caption' | 'open-composer' | 'share-image' | 'share-link' | 'share-text';\n\ninterface SharePrimaryActionInput {\n\tcanShareFiles: boolean;\n\tcanShareText: boolean;\n\thasComposerUrl: boolean;\n\tid: ShareKitDestinationId;\n\tisHandheld: boolean;\n}\n\n// A phone's share sheet reaches the platform's app, where the reader is signed in; its web composer often isn't\nfunction getHandheldAction({\n\tcanShareFiles,\n\tcanShareText,\n\tid,\n}: SharePrimaryActionInput): SharePrimaryAction | undefined {\n\tconst { isImagePost, isLinkOnly } = getShareDestination(id);\n\n\tif (isImagePost && canShareFiles) return 'share-image';\n\tif (isLinkOnly === true && canShareText) return 'share-link';\n\tif (id === shareDestinationAny && canShareText) return 'share-text';\n\n\treturn undefined;\n}\n\nexport function getPrimaryAction(input: SharePrimaryActionInput): SharePrimaryAction {\n\tconst handheldAction = input.isHandheld ? getHandheldAction(input) : undefined;\n\n\tif (handheldAction) return handheldAction;\n\tif (input.hasComposerUrl) return 'open-composer';\n\tif (input.id === 'messages' && input.canShareText) return 'share-text';\n\n\treturn 'copy-caption';\n}\n","import type { ShareKitDestinationId } from './destinations.js';\n\nimport { countText, getGraphemes } from './count.js';\nimport { getShareDestination } from './destinations.js';\n\nexport interface ShareCaptionFields {\n\tdescription?: string | undefined;\n\ttitle: string;\n\turl: string;\n}\n\nexport interface ShareCaption {\n\tcount: number;\n\tisTruncated: boolean;\n\tlimit: number | undefined;\n\ttext: string;\n}\n\nconst separator = '\\n\\n';\n\nconst ellipsis = '…';\n\n// The locale comes from the payload, and a malformed tag like `en_US` throws\nfunction createSegmenter(locale: string, granularity: 'sentence' | 'word') {\n\ttry {\n\t\treturn new Intl.Segmenter(locale, { granularity });\n\t} catch {\n\t\treturn new Intl.Segmenter(undefined, { granularity });\n\t}\n}\n\nfunction getSegmentEnds(text: string, granularity: 'sentence' | 'word', locale: string) {\n\tconst segments = createSegmenter(locale, granularity).segment(text);\n\n\treturn Array.from(segments, ({ index, segment }) => index + segment.length);\n}\n\nfunction getGraphemeEnds(text: string) {\n\tlet end = 0;\n\n\treturn getGraphemes(text).map((grapheme) => (end += grapheme.length));\n}\n\nfunction join(parts: Array<string | undefined>) {\n\treturn parts.filter(Boolean).join(separator);\n}\n\ninterface CutInput {\n\tcanFit: (candidate: string) => boolean;\n\tends: Array<number>;\n\tsuffix: string;\n\ttext: string;\n}\n\n// Counts grow with the cut, so the scan stops at the first miss\nfunction findCut({ canFit, ends, suffix, text }: CutInput) {\n\tlet fitted: string | undefined;\n\n\tfor (const end of ends) {\n\t\tconst cut = text.slice(0, end).trimEnd();\n\n\t\tif (cut.length === 0 || cut.length === text.length) continue;\n\n\t\tconst candidate = `${cut}${suffix}`;\n\n\t\tif (!canFit(candidate)) break;\n\n\t\tfitted = candidate;\n\t}\n\n\treturn fitted;\n}\n\ninterface FitInput {\n\tbody: string | undefined;\n\tcanFit: (text: string) => boolean;\n\tlink: string | undefined;\n\tlocale: string;\n\ttitle: string;\n}\n\nfunction fitBody({ body, canFit, link, locale, title }: FitInput) {\n\tif (!body) return;\n\n\tconst canFitBody = (candidate: string) => canFit(join([title, candidate, link]));\n\n\treturn (\n\t\tfindCut({\n\t\t\tcanFit: canFitBody,\n\t\t\tends: getSegmentEnds(body, 'sentence', locale),\n\t\t\tsuffix: '',\n\t\t\ttext: body,\n\t\t}) ??\n\t\tfindCut({\n\t\t\tcanFit: canFitBody,\n\t\t\tends: getSegmentEnds(body, 'word', locale),\n\t\t\tsuffix: ellipsis,\n\t\t\ttext: body,\n\t\t})\n\t);\n}\n\nfunction fitTitle({ canFit, link, locale, title }: FitInput) {\n\tconst canFitTitle = (candidate: string) => canFit(join([candidate, link]));\n\n\treturn (\n\t\tfindCut({\n\t\t\tcanFit: canFitTitle,\n\t\t\tends: getSegmentEnds(title, 'word', locale),\n\t\t\tsuffix: ellipsis,\n\t\t\ttext: title,\n\t\t}) ??\n\t\tfindCut({ canFit: canFitTitle, ends: getGraphemeEnds(title), suffix: ellipsis, text: title }) ??\n\t\ttitle\n\t);\n}\n\nfunction fitParts(input: FitInput) {\n\tconst { canFit, link, title } = input;\n\tconst body = fitBody(input);\n\n\tif (body) return join([title, body, link]);\n\n\tconst bare = join([title, link]);\n\n\treturn canFit(bare) ? bare : join([fitTitle(input), link]);\n}\n\nexport function countCaption(text: string, id: ShareKitDestinationId) {\n\treturn countText(text, getShareDestination(id));\n}\n\n// The link is kept whole, then the title; the description takes what is left, cut at a sentence end or failing that a word\n// A link too long to leave room for one grapheme of title comes back over the limit; nothing sensible fits\nexport function fitCaption(\n\t{ description, title, url }: ShareCaptionFields,\n\tid: ShareKitDestinationId,\n\tlocale = 'en',\n): ShareCaption {\n\tconst { limit, shape } = getShareDestination(id);\n\tconst link = shape === 'full' ? url : undefined;\n\tconst body = shape === 'title' ? undefined : description?.trim() || undefined;\n\tconst whole = shape === 'url' ? url : join([title, body, link]);\n\tconst canFit = (text: string) => limit === undefined || countCaption(text, id) <= limit;\n\tconst text = canFit(whole) ? whole : fitParts({ body, canFit, link, locale, title });\n\n\treturn { count: countCaption(text, id), isTruncated: text !== whole, limit, text };\n}\n","type Child = Node | string | undefined;\n\ntype Attributes = Record<string, string | undefined>;\n\nexport function createElement<Tag extends keyof HTMLElementTagNameMap>(\n\ttag: Tag,\n\tattributes: Attributes = {},\n\tchildren: Array<Child> = [],\n) {\n\tconst element = document.createElement(tag);\n\n\tfor (const [name, value] of Object.entries(attributes)) {\n\t\tif (value !== undefined) element.setAttribute(name, value);\n\t}\n\n\telement.append(...children.filter((child) => child !== undefined));\n\n\treturn element;\n}\n\nexport function joinClasses(...classes: Array<string | undefined>) {\n\treturn classes.filter(Boolean).join(' ');\n}\n\nconst svgNamespace = 'http://www.w3.org/2000/svg';\n\nexport function createIcon(path: string, size: number) {\n\tconst svg = document.createElementNS(svgNamespace, 'svg');\n\tconst shape = document.createElementNS(svgNamespace, 'path');\n\n\tsvg.setAttribute('aria-hidden', 'true');\n\tsvg.setAttribute('height', String(size));\n\tsvg.setAttribute('viewBox', '0 0 24 24');\n\tsvg.setAttribute('width', String(size));\n\tshape.setAttribute('d', path);\n\tshape.setAttribute('fill', 'currentColor');\n\tsvg.append(shape);\n\n\treturn svg;\n}\n\nfunction isOnBackdrop(dialog: HTMLDialogElement, event: PointerEvent) {\n\tif (event.target !== dialog) return false;\n\n\tconst rect = dialog.getBoundingClientRect();\n\n\treturn (\n\t\tevent.clientX < rect.left ||\n\t\tevent.clientX > rect.right ||\n\t\tevent.clientY < rect.top ||\n\t\tevent.clientY > rect.bottom\n\t);\n}\n\n// Checking both ends of the press means a drag that ends past the edge won't close the dialog\nexport function polyfillLightDismiss(dialog: HTMLDialogElement, signal: AbortSignal) {\n\tif ('closedBy' in HTMLDialogElement.prototype) return;\n\n\tlet isBackdropPress = false;\n\n\tdialog.addEventListener(\n\t\t'pointerdown',\n\t\t(event) => {\n\t\t\tisBackdropPress = isOnBackdrop(dialog, event);\n\t\t},\n\t\t{ signal },\n\t);\n\tdialog.addEventListener(\n\t\t'pointerup',\n\t\t(event) => {\n\t\t\tif (isBackdropPress && isOnBackdrop(dialog, event)) dialog.close();\n\n\t\t\tisBackdropPress = false;\n\t\t},\n\t\t{ signal },\n\t);\n}\n\nexport const radioKeys: Partial<Record<string, (index: number, count: number) => number>> = {\n\tArrowDown: (index, count) => (index + 1) % count,\n\tArrowLeft: (index, count) => (index - 1 + count) % count,\n\tArrowRight: (index, count) => (index + 1) % count,\n\tArrowUp: (index, count) => (index - 1 + count) % count,\n\tEnd: (_index, count) => count - 1,\n\tHome: () => 0,\n};\n","import type { ShareKitStrings } from './strings.js';\n\nimport { copyImage } from './actions.js';\n\nconst statusDurationMs = 4000;\n\nconst flashDurationMs = 2000;\n\nexport class ShareFeedback {\n\t#flashing = new WeakSet<HTMLElement>();\n\t#getStatus: () => HTMLElement | undefined;\n\t#strings: ShareKitStrings;\n\t#timeout: ReturnType<typeof setTimeout> | undefined;\n\n\tconstructor(getStatus: () => HTMLElement | undefined, strings: ShareKitStrings) {\n\t\tthis.#getStatus = getStatus;\n\t\tthis.#strings = strings;\n\t}\n\n\tannounce(message: string) {\n\t\tconst status = this.#getStatus();\n\n\t\tif (!status) return;\n\n\t\tstatus.textContent = message;\n\n\t\tclearTimeout(this.#timeout);\n\t\tthis.#timeout = setTimeout(() => {\n\t\t\tstatus.textContent = '';\n\t\t}, statusDurationMs);\n\t}\n\n\t// Safari only allows the clipboard write if it starts inside the click, before any await\n\tasync copyImage(file: Promise<File | undefined>, button: HTMLElement) {\n\t\ttry {\n\t\t\tawait copyImage(file);\n\t\t\tthis.#flash(button);\n\t\t} catch {\n\t\t\tthis.announce(this.#strings.error);\n\t\t}\n\t}\n\n\tasync copyText(text: string, button?: HTMLElement, fallback?: HTMLTextAreaElement) {\n\t\ttry {\n\t\t\tawait navigator.clipboard.writeText(text);\n\t\t\tthis.#flash(button);\n\t\t} catch {\n\t\t\tfallback?.select();\n\t\t\tthis.announce(fallback ? this.#strings.copyManual : this.#strings.error);\n\t\t}\n\t}\n\n\tdispose() {\n\t\tclearTimeout(this.#timeout);\n\t}\n\n\t#flash(button: HTMLElement | undefined) {\n\t\tthis.announce(this.#strings.copied);\n\n\t\tif (!button || this.#flashing.has(button)) return;\n\n\t\tconst label = button.textContent;\n\n\t\tthis.#flashing.add(button);\n\t\tbutton.textContent = this.#strings.copied;\n\n\t\tsetTimeout(() => {\n\t\t\tbutton.textContent = label;\n\t\t\tthis.#flashing.delete(button);\n\t\t}, flashDurationMs);\n\t}\n}\n","export const shareKitStringDefaults = {\n\tassetCopy: 'Copy',\n\tassetSave: 'Save',\n\tassetShare: 'Share',\n\tcaptionCopy: 'Copy caption',\n\tcaptionOver: '{count} over the limit for {destination}',\n\tcaptionReset: 'Reset',\n\tcaptionTitle: 'Caption',\n\tclose: 'Close',\n\tcopied: 'Copied',\n\tcopyManual: \"Couldn't copy. The caption is selected, so you can copy it yourself.\",\n\t'destination.any': 'Anywhere',\n\t'destination.bluesky': 'Bluesky',\n\t'destination.facebook': 'Facebook',\n\t'destination.instagram': 'Instagram',\n\t'destination.instagram-story': 'Story',\n\t'destination.linkedin': 'LinkedIn',\n\t'destination.mastodon': 'Mastodon',\n\t'destination.messages': 'Messages',\n\t'destination.pinterest': 'Pinterest',\n\t'destination.reddit': 'Reddit',\n\t'destination.threads': 'Threads',\n\t'destination.x': 'X',\n\tdestinationsMore: 'More',\n\tdestinationsTitle: 'Post to',\n\terror: 'Something went wrong. Try saving instead.',\n\t'hint.facebook':\n\t\t'Facebook only takes the link. Your caption is copied, so paste it into your post.',\n\t'hint.instagram':\n\t\t\"Links in Instagram captions aren't clickable. Point people to the link in your bio.\",\n\t'hint.instagram-story': 'Add the link to your Story with a link sticker.',\n\t'hint.linkedin':\n\t\t'LinkedIn only takes the link. Your caption is copied, so paste it into your post.',\n\t'hint.reddit': 'Reddit takes a title and the link.',\n\timagesTitle: 'Images',\n\tlinkCopy: 'Copy link',\n\tlinkTitle: 'Link',\n\tprimaryCopy: 'Copy caption',\n\tprimaryOpen: 'Open {destination}',\n\tprimaryShareImage: 'Share image',\n\tprimaryShareLink: 'Share link',\n\tprimaryShareText: 'Share',\n\tqrAlt: 'QR code for this page',\n\tqrTitle: 'Scan to continue on your phone',\n\tqrToggle: 'Continue on your phone',\n\tretry: 'Ready. Tap again to share.',\n\tsaved: 'Saved',\n\tsaveError: \"Couldn't save. Try again.\",\n\tsuggested: 'Suggested',\n\ttitle: 'Share this page',\n} as const;\n\nexport type ShareKitStringKey = keyof typeof shareKitStringDefaults;\n\nexport type ShareKitStrings = Record<ShareKitStringKey, string>;\n\nexport function isShareStringKey(key: string): key is ShareKitStringKey {\n\treturn Object.hasOwn(shareKitStringDefaults, key);\n}\n\nexport function formatShareString(template: string, values: Record<string, string>) {\n\treturn template.replaceAll(/\\{(\\w+)\\}/gu, (match, name: string) => values[name] ?? match);\n}\n","import type { ShareKitDestinationId } from './destinations.js';\nimport type { ShareKitStrings } from './strings.js';\nimport type { ShareKitPayload, ShareKitSettings } from './types.js';\n\nimport { isShareDestinationId, shareDestinationAny } from './destinations.js';\nimport { isShareStringKey, shareKitStringDefaults } from './strings.js';\n\nfunction isPayload(value: unknown): value is ShareKitPayload {\n\tif (typeof value !== 'object' || value === null) return false;\n\n\tconst { assets, settings, title, url }: Partial<Record<keyof ShareKitPayload, unknown>> = value;\n\n\treturn (\n\t\ttypeof title === 'string' &&\n\t\ttypeof url === 'string' &&\n\t\tArray.isArray(assets) &&\n\t\ttypeof settings === 'object' &&\n\t\tsettings !== null\n\t);\n}\n\n// `<` is escaped so a title or description can't close the script element early\nexport function serializeShareKitPayload(payload: ShareKitPayload) {\n\treturn JSON.stringify(payload).replaceAll('<', String.raw`\\u003c`);\n}\n\nexport function readSharePayload(host: HTMLElement) {\n\tconst source = host.querySelector(':scope > script[type=\"application/json\"]')?.textContent;\n\n\tif (!source) return;\n\n\ttry {\n\t\tconst value: unknown = JSON.parse(source);\n\n\t\treturn isPayload(value) ? value : undefined;\n\t} catch {\n\t\treturn;\n\t}\n}\n\nexport function getShareStrings(overrides: Partial<Record<string, string>> = {}): ShareKitStrings {\n\tconst strings: ShareKitStrings = { ...shareKitStringDefaults };\n\n\tfor (const [key, value] of Object.entries(overrides)) {\n\t\tif (value !== undefined && isShareStringKey(key)) strings[key] = value;\n\t}\n\n\treturn strings;\n}\n\nfunction getIds(value: unknown) {\n\tif (!Array.isArray(value)) return [];\n\n\treturn [...new Set<unknown>(value)].filter(\n\t\t(id): id is ShareKitDestinationId => typeof id === 'string' && isShareDestinationId(id),\n\t);\n}\n\n// The payload arrives as JSON, so ids are checked again; an empty row would leave the radio group unreachable\nexport function getDestinationLists({ destinations, destinationsMore }: ShareKitSettings) {\n\tconst shown = getIds(destinations);\n\tconst main: Array<ShareKitDestinationId> = shown.length > 0 ? shown : [shareDestinationAny];\n\tconst more = getIds(destinationsMore).filter((id) => !main.includes(id));\n\n\treturn { main, more };\n}\n","import type { ShareCapability } from './actions.js';\nimport type { ShareKitStrings } from './strings.js';\nimport type { ShareKitPayload } from './types.js';\n\nimport { createElement, createIcon, polyfillLightDismiss } from './dom.js';\n\ninterface ShareQrInput {\n\tcloseIcon: string | undefined;\n\tid: string;\n\tsignal: AbortSignal;\n\tstrings: Pick<ShareKitStrings, 'close' | 'qrAlt' | 'qrTitle'>;\n\turl: string;\n}\n\nconst iconSize = 24;\n\nconst qrSize = 200;\n\nasync function createQrSource(text: string) {\n\tconst [{ generate }, { toSvgDataURL }] = await Promise.all([\n\t\timport('lean-qr'),\n\t\timport('lean-qr/extras/svg'),\n\t]);\n\n\treturn toSvgDataURL(generate(text), { off: '#ffffff', on: '#000000', pad: 4, scale: 8 });\n}\n\n// Stacks over the share dialog rather than inside it, so opening the code moves nothing beneath\nclass ShareQrDialog {\n\treadonly dialog: HTMLDialogElement;\n\t#image: HTMLImageElement;\n\t#url: string;\n\n\tconstructor({ closeIcon, id, signal, strings, url }: ShareQrInput) {\n\t\tconst titleId = `${id}-title`;\n\n\t\tthis.#url = url;\n\t\tthis.#image = createElement('img', {\n\t\t\talt: strings.qrAlt,\n\t\t\tclass: 'share-kit-qr-image',\n\t\t\theight: String(qrSize),\n\t\t\twidth: String(qrSize),\n\t\t});\n\t\tthis.dialog = createElement(\n\t\t\t'dialog',\n\t\t\t{ 'aria-labelledby': titleId, class: 'share-kit-qr-dialog', closedby: 'any', id },\n\t\t\t[\n\t\t\t\tcreateElement('form', { class: 'share-kit-header', method: 'dialog' }, [\n\t\t\t\t\tcreateElement('h2', { class: 'share-kit-title', id: titleId }, [strings.qrTitle]),\n\t\t\t\t\tcreateElement(\n\t\t\t\t\t\t'button',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'aria-label': strings.close,\n\t\t\t\t\t\t\tclass: 'share-kit-icon-button',\n\t\t\t\t\t\t\ttitle: strings.close,\n\t\t\t\t\t\t\ttype: 'submit',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[closeIcon ? createIcon(closeIcon, iconSize) : '×'],\n\t\t\t\t\t),\n\t\t\t\t]),\n\t\t\t\tthis.#image,\n\t\t\t],\n\t\t);\n\n\t\tpolyfillLightDismiss(this.dialog, signal);\n\t}\n\n\tasync open() {\n\t\tif (!this.#image.getAttribute('src')) this.#image.src = await createQrSource(this.#url);\n\n\t\tthis.dialog.showModal();\n\t}\n}\n\ninterface ShareQrOptions extends Omit<ShareQrInput, 'url'> {\n\tcapabilities: ReadonlySet<ShareCapability>;\n\tpayload: ShareKitPayload;\n}\n\nfunction getQrUrl(url: string, openHash: string | undefined) {\n\tif (!openHash || !URL.canParse(url)) return url;\n\n\tconst target = new URL(url);\n\n\ttarget.hash = openHash;\n\n\treturn target.href;\n}\n\n// A phone is already where the code would lead, so it gets none\nexport function createShareQr({ capabilities, payload, ...input }: ShareQrOptions) {\n\tif (capabilities.has('handheld')) return;\n\n\treturn new ShareQrDialog({ ...input, url: getQrUrl(payload.url, payload.settings.openHash) });\n}\n","import type { ShareCapability } from './actions.js';\nimport type { ShareKitDestinationId } from './destinations.js';\nimport type { ShareKitIcons } from './icons.js';\nimport type { ShareKitStrings } from './strings.js';\nimport type { ShareKitAsset, ShareKitClassRole, ShareKitPayload } from './types.js';\n\nimport { createElement, createIcon, joinClasses } from './dom.js';\n\ninterface RenderInput {\n\tcapabilities: ReadonlySet<ShareCapability>;\n\tdestinations: Array<ShareKitDestinationId>;\n\tdestinationsMore: Array<ShareKitDestinationId>;\n\ticons: ShareKitIcons;\n\tid: string;\n\tpayload: ShareKitPayload;\n\tstrings: ShareKitStrings;\n}\n\ntype RenderContext = RenderInput & {\n\tclassNames: Partial<Record<ShareKitClassRole, string>>;\n};\n\nconst destinationIconSize = 24;\n\ninterface ActionInput {\n\taction: string;\n\tdescribedBy?: string;\n\tlabel: string;\n}\n\nfunction renderAction({ classNames }: RenderContext, { action, describedBy, label }: ActionInput) {\n\treturn createElement(\n\t\t'button',\n\t\t{\n\t\t\t'aria-describedby': describedBy,\n\t\t\tclass: joinClasses('share-kit-action', classNames.action),\n\t\t\t'data-share-kit-action': action,\n\t\t\ttype: 'button',\n\t\t},\n\t\t[label],\n\t);\n}\n\nfunction renderHeading({ classNames }: RenderContext, children: Array<Node | string>, id?: string) {\n\treturn createElement(\n\t\t'h3',\n\t\t{ class: joinClasses('share-kit-heading', classNames.heading), id },\n\t\tchildren,\n\t);\n}\n\ninterface IconButtonInput {\n\taction: string;\n\tattributes?: Record<string, string>;\n\tfallback: string;\n\ticon: string | undefined;\n\tlabel: string;\n}\n\nfunction renderIconButton({ action, attributes, fallback, icon, label }: IconButtonInput) {\n\treturn createElement(\n\t\t'button',\n\t\t{\n\t\t\t...attributes,\n\t\t\t'aria-label': label,\n\t\t\tclass: 'share-kit-icon-button',\n\t\t\t'data-share-kit-action': action,\n\t\t\ttitle: label,\n\t\t\ttype: 'button',\n\t\t},\n\t\t[icon ? createIcon(icon, destinationIconSize) : fallback],\n\t);\n}\n\nfunction renderHeader(context: RenderContext) {\n\tconst { capabilities, icons, id, strings } = context;\n\tconst heading = createElement(\n\t\t'h2',\n\t\t{ class: 'share-kit-title', id: `${id}-title`, tabindex: '-1' },\n\t\t[strings.title],\n\t);\n\tconst qrToggle = capabilities.has('handheld')\n\t\t? undefined\n\t\t: renderIconButton({\n\t\t\t\taction: 'qr',\n\t\t\t\tattributes: { 'aria-haspopup': 'dialog' },\n\t\t\t\tfallback: 'QR',\n\t\t\t\ticon: icons.qr,\n\t\t\t\tlabel: strings.qrToggle,\n\t\t\t});\n\tconst close = renderIconButton({\n\t\taction: 'close',\n\t\tfallback: '×',\n\t\ticon: icons.close,\n\t\tlabel: strings.close,\n\t});\n\n\treturn {\n\t\theader: createElement('header', { class: 'share-kit-header' }, [\n\t\t\theading,\n\t\t\tcreateElement('div', { class: 'share-kit-header-actions' }, [qrToggle, close]),\n\t\t]),\n\t\theading,\n\t};\n}\n\nfunction renderDestination(context: RenderContext, destination: ShareKitDestinationId) {\n\tconst { classNames, icons, strings } = context;\n\tconst icon = icons[destination];\n\n\treturn createElement(\n\t\t'button',\n\t\t{\n\t\t\t'aria-checked': 'false',\n\t\t\tclass: joinClasses('share-kit-destination', classNames.destination),\n\t\t\t'data-share-kit-action': 'destination',\n\t\t\t'data-share-kit-destination': destination,\n\t\t\trole: 'radio',\n\t\t\ttabindex: '-1',\n\t\t\ttype: 'button',\n\t\t},\n\t\t[\n\t\t\ticon ? createIcon(icon, destinationIconSize) : undefined,\n\t\t\tcreateElement('span', {}, [strings[`destination.${destination}`]]),\n\t\t],\n\t);\n}\n\nfunction renderDestinations(context: RenderContext) {\n\tconst { destinations, destinationsMore, icons, id, strings } = context;\n\tconst headingId = `${id}-destinations`;\n\tconst more =\n\t\tdestinationsMore.length > 0\n\t\t\t? createElement(\n\t\t\t\t\t'button',\n\t\t\t\t\t{\n\t\t\t\t\t\tclass: joinClasses('share-kit-destination', context.classNames.destination),\n\t\t\t\t\t\t'data-share-kit-action': 'more',\n\t\t\t\t\t\ttype: 'button',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\ticons.more ? createIcon(icons.more, destinationIconSize) : undefined,\n\t\t\t\t\t\tcreateElement('span', {}, [strings.destinationsMore]),\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t: undefined;\n\tconst extra = destinationsMore.map((destination) => {\n\t\tconst button = renderDestination(context, destination);\n\n\t\tbutton.hidden = true;\n\n\t\treturn button;\n\t});\n\tconst group = createElement(\n\t\t'div',\n\t\t{ 'aria-labelledby': headingId, class: 'share-kit-destinations', role: 'radiogroup' },\n\t\t[...destinations.map((destination) => renderDestination(context, destination)), ...extra],\n\t);\n\n\treturn {\n\t\tmore,\n\t\tsection: createElement('section', { class: 'share-kit-section' }, [\n\t\t\trenderHeading(context, [strings.destinationsTitle], headingId),\n\t\t\tcreateElement('div', { class: 'share-kit-destinations-row' }, [group, more]),\n\t\t]),\n\t};\n}\n\nfunction renderCaption(context: RenderContext) {\n\tconst { classNames, id, payload, strings } = context;\n\tconst captionId = `${id}-caption`;\n\tconst countId = `${id}-count`;\n\tconst hintId = `${id}-hint`;\n\tconst caption = createElement('textarea', {\n\t\t'aria-describedby': `${countId} ${hintId}`,\n\t\tclass: joinClasses('share-kit-caption', classNames.input),\n\t\tdir: 'auto',\n\t\tid: captionId,\n\t\tlang: payload.locale,\n\t\trows: '6',\n\t});\n\tconst count = createElement('span', { class: 'share-kit-count', id: countId });\n\tconst captionCopy = renderAction(context, { action: 'copy-caption', label: strings.captionCopy });\n\tconst hint = createElement('p', { class: 'share-kit-hint', id: hintId });\n\n\treturn {\n\t\tcaption,\n\t\tcaptionCopy,\n\t\tcount,\n\t\thint,\n\t\tsection: createElement('section', { class: 'share-kit-section' }, [\n\t\t\trenderHeading(context, [createElement('label', { for: captionId }, [strings.captionTitle])]),\n\t\t\tcaption,\n\t\t\tcreateElement('div', { class: 'share-kit-caption-meta' }, [\n\t\t\t\tcount,\n\t\t\t\tcreateElement('span', { class: 'share-kit-actions' }, [\n\t\t\t\t\trenderAction(context, { action: 'reset', label: strings.captionReset }),\n\t\t\t\t\tcaptionCopy,\n\t\t\t\t]),\n\t\t\t]),\n\t\t\thint,\n\t\t]),\n\t};\n}\n\ninterface TileInput {\n\tactions: Array<[action: string, label: string]>;\n\tasset: ShareKitAsset;\n\tkey: string;\n}\n\nfunction renderTile(context: RenderContext, { actions, asset, key }: TileInput) {\n\tconst labelId = `${context.id}-asset-${key}`;\n\tconst badge = createElement('span', { class: 'share-kit-badge' }, [context.strings.suggested]);\n\n\tbadge.hidden = true;\n\n\treturn createElement(\n\t\t'li',\n\t\t{\n\t\t\tclass: 'share-kit-tile',\n\t\t\t'data-share-kit-asset': key,\n\t\t\t'data-share-kit-role': asset.role,\n\t\t},\n\t\t[\n\t\t\tcreateElement('img', {\n\t\t\t\talt: asset.alt,\n\t\t\t\tclass: 'share-kit-preview',\n\t\t\t\tdecoding: 'async',\n\t\t\t\theight: String(asset.height),\n\t\t\t\tloading: 'lazy',\n\t\t\t\tsrc: asset.previewSrc,\n\t\t\t\twidth: String(asset.width),\n\t\t\t}),\n\t\t\tcreateElement('div', { class: 'share-kit-tile-label' }, [\n\t\t\t\tcreateElement('span', { id: labelId }, [asset.label]),\n\t\t\t\tbadge,\n\t\t\t]),\n\t\t\tcreateElement(\n\t\t\t\t'div',\n\t\t\t\t{ class: 'share-kit-actions' },\n\t\t\t\tactions.map(([action, label]) =>\n\t\t\t\t\trenderAction(context, { action, describedBy: labelId, label }),\n\t\t\t\t),\n\t\t\t),\n\t\t],\n\t);\n}\n\nfunction getAssetActions({ capabilities, strings }: RenderContext) {\n\tconst actions: Array<[string, string]> = [];\n\tconst canShare = capabilities.has('files');\n\n\tif (canShare) actions.push(['share', strings.assetShare]);\n\n\t// On a phone the share sheet already offers copying\n\tif (capabilities.has('copy-image') && !(canShare && capabilities.has('handheld'))) {\n\t\tactions.push(['copy', strings.assetCopy]);\n\t}\n\n\tactions.push(['save', strings.assetSave]);\n\n\treturn actions;\n}\n\nfunction renderImages(context: RenderContext) {\n\tconst { payload, strings } = context;\n\tconst actions = getAssetActions(context);\n\tconst counts = new Map<string, number>();\n\tconst assets = new Map<HTMLElement, ShareKitAsset>();\n\n\tfor (const asset of payload.assets) {\n\t\tconst number = (counts.get(asset.role) ?? 0) + 1;\n\t\tconst key = asset.role === 'photo' ? `photo-${String(number)}` : asset.role;\n\n\t\tcounts.set(asset.role, number);\n\t\tassets.set(renderTile(context, { actions, asset, key }), asset);\n\t}\n\n\tconst grid = createElement('ul', { class: 'share-kit-grid' }, [...assets.keys()]);\n\n\treturn {\n\t\tassets,\n\t\tgrid,\n\t\tsection: createElement('section', { class: 'share-kit-section' }, [\n\t\t\trenderHeading(context, [strings.imagesTitle]),\n\t\t\tgrid,\n\t\t]),\n\t};\n}\n\nfunction renderLink(context: RenderContext) {\n\tconst { payload, strings } = context;\n\n\treturn createElement('section', { class: 'share-kit-section' }, [\n\t\trenderHeading(context, [strings.linkTitle]),\n\t\tcreateElement('div', { class: 'share-kit-link-row' }, [\n\t\t\tcreateElement('p', { class: 'share-kit-link' }, [payload.url]),\n\t\t\trenderAction(context, { action: 'copy-link', label: strings.linkCopy }),\n\t\t]),\n\t]);\n}\n\nexport interface ShareKitParts {\n\tassets: ReadonlyMap<HTMLElement, ShareKitAsset>;\n\tcaption: HTMLTextAreaElement;\n\tcaptionCopy: HTMLElement;\n\tcount: HTMLElement;\n\tdialog: HTMLDialogElement;\n\tgrid: HTMLElement;\n\theading: HTMLElement;\n\thint: HTMLElement;\n\tmore: HTMLElement | undefined;\n\tprimary: HTMLButtonElement;\n\tstatus: HTMLElement;\n\ttiles: Array<HTMLElement>;\n}\n\nexport function renderShareKit(input: RenderInput): ShareKitParts {\n\tconst context: RenderContext = { ...input, classNames: input.payload.settings.classNames ?? {} };\n\tconst { header, heading } = renderHeader(context);\n\tconst destinations = renderDestinations(context);\n\tconst caption = renderCaption(context);\n\tconst images = renderImages(context);\n\tconst status = createElement('p', { class: 'share-kit-status', role: 'status' });\n\tconst primary = createElement('button', {\n\t\tclass: joinClasses('share-kit-primary', context.classNames.primary),\n\t\t'data-share-kit-action': 'primary',\n\t\ttype: 'button',\n\t});\n\tconst dialog = createElement(\n\t\t'dialog',\n\t\t{ 'aria-labelledby': heading.id, class: 'share-kit-dialog', closedby: 'any', id: input.id },\n\t\t[\n\t\t\tcreateElement('div', { class: 'share-kit-body' }, [\n\t\t\t\theader,\n\t\t\t\tcreateElement('div', { class: 'share-kit-scroll' }, [\n\t\t\t\t\tdestinations.section,\n\t\t\t\t\tcaption.section,\n\t\t\t\t\timages.section,\n\t\t\t\t\trenderLink(context),\n\t\t\t\t]),\n\t\t\t\tcreateElement('footer', { class: 'share-kit-footer' }, [status, primary]),\n\t\t\t]),\n\t\t],\n\t);\n\n\treturn {\n\t\tassets: images.assets,\n\t\tcaption: caption.caption,\n\t\tcaptionCopy: caption.captionCopy,\n\t\tcount: caption.count,\n\t\tdialog,\n\t\tgrid: images.grid,\n\t\theading,\n\t\thint: caption.hint,\n\t\tmore: destinations.more,\n\t\tprimary,\n\t\tstatus,\n\t\ttiles: [...images.assets.keys()],\n\t};\n}\n","import type { ShareKitDestinationId, SharePrimaryAction } from './destinations.js';\nimport type { ShareKitParts } from './render.js';\nimport type { ShareKitStrings } from './strings.js';\n\nimport { countCaption } from './caption.js';\nimport { getShareDestination } from './destinations.js';\nimport { formatShareString, isShareStringKey } from './strings.js';\n\nconst primaryLabels = {\n\t'copy-caption': 'primaryCopy',\n\t'open-composer': 'primaryOpen',\n\t'share-image': 'primaryShareImage',\n\t'share-link': 'primaryShareLink',\n\t'share-text': 'primaryShareText',\n} as const satisfies Record<SharePrimaryAction, keyof ShareKitStrings>;\n\nexport function getSuggestedAsset(assets: Array<HTMLElement>, destination: ShareKitDestinationId) {\n\tconst { assetRole } = getShareDestination(destination);\n\n\treturn (\n\t\tassets.find((asset) => asset.dataset.shareKitRole === assetRole) ??\n\t\tassets.find((asset) => asset.dataset.shareKitRole === 'landscape') ??\n\t\tassets[0]\n\t);\n}\n\ninterface SyncInput {\n\tdestination: ShareKitDestinationId;\n\tparts: ShareKitParts;\n\tstrings: ShareKitStrings;\n}\n\ninterface SyncCaptionInput extends SyncInput {\n\tprimaryAction: SharePrimaryAction;\n}\n\nexport function syncCaptionView({ destination, parts, primaryAction, strings }: SyncCaptionInput) {\n\tconst { limit } = getShareDestination(destination);\n\tconst count = countCaption(parts.caption.value, destination);\n\tconst isOver = limit !== undefined && count > limit;\n\tconst label = strings[`destination.${destination}`];\n\n\tparts.count.textContent =\n\t\tlimit === undefined ? String(count) : `${String(count)} / ${String(limit)}`;\n\tparts.count.toggleAttribute('data-share-kit-over', isOver);\n\tparts.caption.setAttribute('aria-invalid', String(isOver));\n\tparts.captionCopy.hidden = primaryAction === 'copy-caption';\n\tparts.primary.textContent = formatShareString(strings[primaryLabels[primaryAction]], {\n\t\tdestination: label,\n\t});\n\n\treturn {\n\t\tisOver,\n\t\tmessage: formatShareString(strings.captionOver, {\n\t\t\tcount: String(count - (limit ?? 0)),\n\t\t\tdestination: label,\n\t\t}),\n\t};\n}\n\ninterface SyncDestinationInput extends SyncInput {\n\tassets: Array<HTMLElement>;\n\tsuggested: HTMLElement | undefined;\n}\n\nexport function syncDestinationView({\n\tassets,\n\tdestination,\n\tparts,\n\tstrings,\n\tsuggested,\n}: SyncDestinationInput) {\n\tfor (const radio of parts.dialog.querySelectorAll<HTMLElement>('[role=\"radio\"]')) {\n\t\tconst isSelected = radio.dataset.shareKitDestination === destination;\n\n\t\tradio.setAttribute('aria-checked', String(isSelected));\n\t\tradio.tabIndex = isSelected ? 0 : -1;\n\t}\n\n\tconst hintKey = `hint.${destination}`;\n\n\tparts.hint.textContent = isShareStringKey(hintKey) ? strings[hintKey] : '';\n\tparts.hint.hidden = parts.hint.textContent === '';\n\n\tfor (const asset of assets) {\n\t\tconst badge = asset.querySelector<HTMLElement>('.share-kit-badge');\n\n\t\tif (badge) badge.hidden = asset !== suggested;\n\t}\n\n\tparts.grid.append(...parts.tiles);\n\n\tif (suggested) parts.grid.prepend(suggested);\n}\n","import type { ShareKitDestinationId } from './destinations.js';\nimport type { ShareKitStringKey } from './strings.js';\n\nexport type ShareKitAssetRole = 'landscape' | 'photo' | 'portrait' | 'story';\n\nexport interface ShareKitAsset {\n\talt: string;\n\tfilename: string;\n\theight: number;\n\tlabel: string;\n\tpreviewSrc: string;\n\trole: ShareKitAssetRole;\n\tsrc: string;\n\ttype: string;\n\twidth: number;\n}\n\nexport type ShareKitClassRole = 'action' | 'destination' | 'heading' | 'input' | 'primary';\n\nexport interface ShareKitSettings {\n\tclassNames?: Partial<Record<ShareKitClassRole, string>>;\n\tdestinations: ReadonlyArray<ShareKitDestinationId>;\n\tdestinationsMore?: ReadonlyArray<ShareKitDestinationId>;\n\topenHash?: string;\n\tutmMedium?: string;\n}\n\nexport interface ShareKitPayload {\n\tassets: ReadonlyArray<ShareKitAsset>;\n\tdescription?: string;\n\tlocale: string;\n\tsettings: ShareKitSettings;\n\tstrings?: Partial<Record<ShareKitStringKey, string>>;\n\ttitle: string;\n\turl: string;\n}\n\nexport const shareKitActionEventName = 'share-kit:action';\n\nexport type ShareKitAction =\n\t| 'copy'\n\t| 'copy-caption'\n\t| 'copy-link'\n\t| 'destination'\n\t| 'open'\n\t| 'open-composer'\n\t| 'qr'\n\t| 'save'\n\t| 'share'\n\t| 'share-link'\n\t| 'share-text';\n\nexport interface ShareKitActionDetail {\n\taction: ShareKitAction;\n\tasset?: string;\n\tdestination: ShareKitDestinationId;\n}\n\ndeclare global {\n\tinterface GlobalEventHandlersEventMap {\n\t\t[shareKitActionEventName]: CustomEvent<ShareKitActionDetail>;\n\t}\n}\n","import type { ShareCapability } from './actions.js';\nimport type { ShareOutcome } from './assets.js';\nimport type { ShareKitDestinationId, SharePrimaryAction } from './destinations.js';\nimport type { ShareKitIcons } from './icons.js';\nimport type { ShareKitParts } from './render.js';\nimport type { ShareKitStrings } from './strings.js';\nimport type { ShareKitAction, ShareKitActionDetail, ShareKitPayload } from './types.js';\n\nimport { clearOpenHash, getShareCapabilities, isDomError, isOpenHash } from './actions.js';\nimport { ShareAssetFiles } from './assets.js';\nimport { fitCaption } from './caption.js';\nimport {\n\tgetDestinationUrl,\n\tgetPrimaryAction,\n\tgetShareDestination,\n\tisShareDestinationId,\n\tshareDestinationAny,\n} from './destinations.js';\nimport { polyfillLightDismiss, radioKeys } from './dom.js';\nimport { ShareFeedback } from './feedback.js';\nimport { getDestinationLists, getShareStrings, readSharePayload } from './payload.js';\nimport { createShareQr } from './qr.js';\nimport { renderShareKit } from './render.js';\nimport { shareKitStringDefaults } from './strings.js';\nimport { getSuggestedAsset, syncCaptionView, syncDestinationView } from './sync.js';\nimport { shareKitActionEventName } from './types.js';\n\nconst outcomeMessages = {\n\terror: 'error',\n\tretry: 'retry',\n\tsaved: 'saved',\n\tunsaved: 'saveError',\n} as const satisfies Partial<Record<ShareOutcome, keyof ShareKitStrings>>;\n\nlet dialogCount = 0;\n\nfunction isKeyOf<Key extends string>(record: Record<Key, unknown>, key: string): key is Key {\n\treturn Object.hasOwn(record, key);\n}\n\n// Server rendering has no `HTMLElement`; the stand-in lets the module load there and is never constructed\nconst BaseElement =\n\ttypeof HTMLElement === 'undefined' ? (Object as unknown as typeof HTMLElement) : HTMLElement;\n\nexport class ShareKitElement extends BaseElement {\n\tprotected readonly icons: ShareKitIcons = {};\n\n\t#abortController: AbortController | undefined;\n\t#actions = {\n\t\tclose: () => {\n\t\t\tthis.#parts?.dialog.close();\n\t\t},\n\t\tcopy: (button: HTMLElement, tile?: HTMLElement) => {\n\t\t\tif (!tile) return;\n\n\t\t\tthis.#track('copy', tile);\n\t\t\tvoid this.#feedback?.copyImage(this.#files?.load(tile) ?? Promise.resolve(undefined), button);\n\t\t},\n\t\t'copy-caption': (button: HTMLElement) => {\n\t\t\tthis.#track('copy-caption');\n\t\t\tvoid this.#copyCaption(button);\n\t\t},\n\t\t'copy-link': (button: HTMLElement) => {\n\t\t\tthis.#track('copy-link');\n\t\t\tvoid this.#feedback?.copyText(this.#payload?.url ?? '', button);\n\t\t},\n\t\tdestination: (button: HTMLElement) => {\n\t\t\tconst id = button.dataset.shareKitDestination;\n\n\t\t\tif (!id || !isShareDestinationId(id)) return;\n\n\t\t\tthis.#selectDestination(id);\n\t\t\tthis.#track('destination');\n\t\t},\n\t\tmore: (button: HTMLElement) => {\n\t\t\tthis.#showMore(button);\n\t\t},\n\t\tprimary: () => {\n\t\t\tthis.#primaryActions[this.#getPrimaryAction()]();\n\t\t},\n\t\tqr: () => {\n\t\t\tvoid this.#openQr();\n\t\t},\n\t\treset: () => {\n\t\t\tthis.#isCaptionEdited = false;\n\t\t\tthis.#syncDestination();\n\t\t},\n\t\tsave: (_button: HTMLElement, tile?: HTMLElement) => {\n\t\t\tif (tile) void this.#saveAsset(tile);\n\t\t},\n\t\tshare: (_button: HTMLElement, tile?: HTMLElement) => {\n\t\t\tif (tile) void this.#shareAssets([tile]);\n\t\t},\n\t};\n\t#capabilities = new Set<ShareCapability>();\n\t#destination: ShareKitDestinationId = shareDestinationAny;\n\t#feedback: ShareFeedback | undefined;\n\t#files: ShareAssetFiles | undefined;\n\t#isCaptionEdited = false;\n\t#isOver = false;\n\t#parts: ShareKitParts | undefined;\n\t#payload: ShareKitPayload | undefined;\n\t#primaryActions = {\n\t\t'copy-caption': () => {\n\t\t\tthis.#track('copy-caption');\n\t\t\tvoid this.#copyCaption();\n\t\t},\n\t\t// The composer can't always take the text, so it rides along on the clipboard\n\t\t'open-composer': () => {\n\t\t\tconst url = this.#getComposerUrl();\n\n\t\t\tif (!url) return;\n\n\t\t\tthis.#track('open-composer');\n\t\t\tvoid this.#copyCaption();\n\t\t\twindow.open(url, '_blank', 'noopener');\n\t\t},\n\t\t// Both start inside the tap, before any await, or the browser refuses one of them\n\t\t'share-image': () => {\n\t\t\tconst tile = this.#getSuggestedAsset();\n\n\t\t\tif (!tile) return;\n\n\t\t\tvoid this.#copyCaption();\n\t\t\tvoid this.#shareAssets([tile]);\n\t\t},\n\t\t// The platform's app drops shared text too, so the caption rides on the clipboard as with an image\n\t\t'share-link': () => {\n\t\t\tvoid this.#copyCaption();\n\t\t\tvoid this.#shareData('share-link', { url: this.#getUrl() });\n\t\t},\n\t\t'share-text': () => {\n\t\t\tconst text = this.#parts?.caption.value;\n\n\t\t\tif (text) void this.#shareData('share-text', { text });\n\t\t},\n\t} satisfies Record<SharePrimaryAction, () => void>;\n\t#qr: ReturnType<typeof createShareQr>;\n\t#strings: ShareKitStrings = shareKitStringDefaults;\n\n\tconnectedCallback() {\n\t\tif (this.#abortController) return;\n\n\t\tconst payload = readSharePayload(this);\n\n\t\tif (!payload) {\n\t\t\tthis.#retryWhenParsed();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#abortController = new AbortController();\n\t\tthis.#payload = payload;\n\t\tthis.#strings = getShareStrings(payload.strings);\n\t\tthis.#feedback = new ShareFeedback(() => this.#parts?.status, this.#strings);\n\n\t\tconst { signal } = this.#abortController;\n\n\t\tthis.#capabilities = new Set(getShareCapabilities(this.dataset.can));\n\t\tthis.#files = new ShareAssetFiles({\n\t\t\tcanShare: this.#capabilities.has('files'),\n\t\t\tgetSource: (tile) => this.#parts?.assets.get(tile),\n\t\t\tsignal,\n\t\t});\n\n\t\tthis.addEventListener('click', this.#handleClick, { signal });\n\t\tthis.addEventListener('input', this.#handleInput, { signal });\n\t\tthis.addEventListener('keydown', this.#handleKeydown, { signal });\n\t\tthis.addEventListener('error', this.#handlePreviewError, { capture: true, signal });\n\t\tthis.addEventListener('pointerover', ({ target }) => this.#files?.warm(target), { signal });\n\t\twindow.addEventListener('hashchange', this.#handleHashChange, { signal });\n\t\t// The trigger ships disabled so a tap before this runs isn't silently lost\n\t\tthis.querySelector('[data-share-kit-trigger]')?.toggleAttribute('disabled', false);\n\n\t\t// Deferred so a listener added after `defineShareKit()` in the same task still hears `open`\n\t\tqueueMicrotask(() => {\n\t\t\tif (!signal.aborted && isOpenHash(payload.settings.openHash)) this.#open();\n\t\t});\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.#parts?.dialog.remove();\n\t\tthis.#parts = undefined;\n\t\tthis.#qr = undefined;\n\t\tthis.#abortController?.abort();\n\t\tthis.#abortController = undefined;\n\t\tthis.#feedback?.dispose();\n\t\tthis.#feedback = undefined;\n\t\tthis.#files?.dispose();\n\t\tthis.#files = undefined;\n\t\tthis.#destination = shareDestinationAny;\n\t\tthis.#isCaptionEdited = false;\n\t\tthis.#isOver = false;\n\t}\n\n\t// A failed write selects the caption, so it is ready to copy by hand once the reader is back\n\tasync #copyCaption(button?: HTMLElement) {\n\t\tconst caption = this.#parts?.caption;\n\n\t\tif (caption) await this.#feedback?.copyText(caption.value, button, caption);\n\t}\n\n\t#getAssets() {\n\t\treturn (this.#parts?.tiles ?? []).filter((tile) => tile.dataset.shareKitState !== 'failed');\n\t}\n\n\t#getComposerUrl() {\n\t\tconst parts = this.#parts;\n\n\t\tif (!parts) return;\n\n\t\tconst suggested = this.#getSuggestedAsset();\n\t\tconst media = suggested ? parts.assets.get(suggested)?.src : undefined;\n\n\t\treturn getShareDestination(this.#destination).getComposerUrl?.({\n\t\t\tmedia: media ? new URL(media, location.href).href : undefined,\n\t\t\ttext: parts.caption.value,\n\t\t\turl: this.#getUrl(),\n\t\t});\n\t}\n\n\t#getPrimaryAction() {\n\t\treturn getPrimaryAction({\n\t\t\tcanShareFiles: this.#capabilities.has('files') && this.#getSuggestedAsset() !== undefined,\n\t\t\tcanShareText: this.#capabilities.has('link'),\n\t\t\thasComposerUrl: this.#getComposerUrl() !== undefined,\n\t\t\tid: this.#destination,\n\t\t\tisHandheld: this.#capabilities.has('handheld'),\n\t\t});\n\t}\n\n\t#getSuggestedAsset() {\n\t\treturn getSuggestedAsset(this.#getAssets(), this.#destination);\n\t}\n\n\t#getUrl() {\n\t\tconst payload = this.#payload;\n\n\t\tif (!payload) return '';\n\n\t\treturn getDestinationUrl(payload.url, this.#destination, payload.settings.utmMedium);\n\t}\n\n\t#handleClick = (event: MouseEvent) => {\n\t\tif (!(event.target instanceof Element)) return;\n\n\t\tif (event.target.closest('[data-share-kit-trigger]')) {\n\t\t\tthis.#open();\n\t\t\treturn;\n\t\t}\n\n\t\tconst button = event.target.closest<HTMLElement>('[data-share-kit-action]');\n\t\tconst action = button?.dataset.shareKitAction;\n\n\t\tif (!button || !action || !isKeyOf(this.#actions, action)) return;\n\n\t\tthis.#actions[action](\n\t\t\tbutton,\n\t\t\tbutton.closest<HTMLElement>('[data-share-kit-asset]') ?? undefined,\n\t\t);\n\t};\n\n\t#handleClose = () => {\n\t\tclearOpenHash(this.#payload?.settings.openHash);\n\t};\n\n\t#handleHashChange = () => {\n\t\tif (isOpenHash(this.#payload?.settings.openHash)) this.#open();\n\t};\n\n\t#handleInput = (event: Event) => {\n\t\tif (event.target === this.#parts?.caption) this.#isCaptionEdited = true;\n\n\t\tthis.#syncCaption();\n\t};\n\n\t#handleKeydown = (event: KeyboardEvent) => {\n\t\tconst move = radioKeys[event.key];\n\n\t\tif (!move || !(event.target instanceof HTMLElement) || event.target.role !== 'radio') return;\n\n\t\tconst radios = [...this.querySelectorAll<HTMLElement>('[role=\"radio\"]:not([hidden])')];\n\t\tconst next = radios[move(radios.indexOf(event.target), radios.length)];\n\t\tconst id = next?.dataset.shareKitDestination;\n\n\t\tif (!next || !id || !isShareDestinationId(id)) return;\n\n\t\tevent.preventDefault();\n\t\tthis.#selectDestination(id);\n\t\tnext.focus();\n\t};\n\n\t#handlePreviewError = (event: Event) => {\n\t\tif (!(event.target instanceof HTMLImageElement)) return;\n\n\t\tconst tile = event.target.closest<HTMLElement>('[data-share-kit-asset]');\n\n\t\tif (!tile) return;\n\n\t\ttile.dataset.shareKitState = 'failed';\n\t\tthis.#syncDestination();\n\t};\n\n\t#open() {\n\t\tconst parts = this.#parts ?? this.#render();\n\n\t\tif (!parts || parts.dialog.open) return;\n\n\t\tparts.dialog.showModal();\n\t\t// Focusing the heading lets a screen reader start from the dialog's name\n\t\tparts.heading.focus();\n\t\tthis.#track('open');\n\t\t// Synced again once open, since a status written to a closed dialog goes unannounced\n\t\tthis.#isOver = false;\n\t\tthis.#syncCaption();\n\t}\n\n\tasync #openQr() {\n\t\tthis.#track('qr');\n\n\t\ttry {\n\t\t\tawait this.#qr?.open();\n\t\t} catch {\n\t\t\tthis.#feedback?.announce(this.#strings.error);\n\t\t}\n\t}\n\n\t// The primary button shares the suggested image on a phone, so only that file is fetched ahead\n\t#prefetch() {\n\t\tif (!this.#capabilities.has('files') || !this.#capabilities.has('handheld')) return;\n\n\t\tconst tile = this.#getSuggestedAsset();\n\n\t\tif (tile) void this.#files?.load(tile);\n\t}\n\n\t#render() {\n\t\tconst payload = this.#payload;\n\t\tconst signal = this.#abortController?.signal;\n\n\t\tif (!payload || !signal) return;\n\n\t\tconst { main, more } = getDestinationLists(payload.settings);\n\n\t\tdialogCount += 1;\n\n\t\tconst id = `share-kit-${String(dialogCount)}`;\n\t\tconst parts = renderShareKit({\n\t\t\tcapabilities: this.#capabilities,\n\t\t\tdestinations: main,\n\t\t\tdestinationsMore: more,\n\t\t\ticons: this.icons,\n\t\t\tid,\n\t\t\tpayload,\n\t\t\tstrings: this.#strings,\n\t\t});\n\n\t\tthis.#qr = createShareQr({\n\t\t\tcapabilities: this.#capabilities,\n\t\t\tcloseIcon: this.icons.close,\n\t\t\tid: `${id}-qr`,\n\t\t\tpayload,\n\t\t\tsignal,\n\t\t\tstrings: this.#strings,\n\t\t});\n\n\t\tif (this.#qr) parts.dialog.append(this.#qr.dialog);\n\n\t\tparts.dialog.addEventListener('close', this.#handleClose, { signal });\n\t\tpolyfillLightDismiss(parts.dialog, signal);\n\t\tthis.append(parts.dialog);\n\t\tthis.#parts = parts;\n\t\tthis.#destination = main[0] ?? shareDestinationAny;\n\t\tthis.#syncDestination();\n\n\t\treturn parts;\n\t}\n\n\t#report(outcome: ShareOutcome | undefined) {\n\t\tif (outcome && isKeyOf(outcomeMessages, outcome)) {\n\t\t\tthis.#feedback?.announce(this.#strings[outcomeMessages[outcome]]);\n\t\t}\n\t}\n\n\t// A classic script in the head defines the element before its children are parsed\n\t#retryWhenParsed() {\n\t\tif (document.readyState !== 'loading') return;\n\n\t\tdocument.addEventListener(\n\t\t\t'DOMContentLoaded',\n\t\t\t() => {\n\t\t\t\tif (this.isConnected) this.connectedCallback();\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t}\n\n\tasync #saveAsset(tile: HTMLElement) {\n\t\tthis.#track('save', tile);\n\t\tthis.#report(await this.#files?.save(tile));\n\t}\n\n\t// An edited caption keeps the reader's words but swaps in the new destination's tagged link\n\t#selectDestination(id: ShareKitDestinationId) {\n\t\tconst previousUrl = this.#getUrl();\n\t\tconst caption = this.#parts?.caption;\n\n\t\tthis.#destination = id;\n\n\t\tif (caption && this.#isCaptionEdited) {\n\t\t\tconst url = this.#getUrl();\n\n\t\t\tcaption.value = caption.value.replaceAll(previousUrl, () => url);\n\t\t}\n\n\t\tthis.#syncDestination();\n\t}\n\n\tasync #shareAssets(tiles: Array<HTMLElement>) {\n\t\tconst [first] = tiles;\n\n\t\tif (!first) return;\n\n\t\tthis.#track('share', first);\n\t\tthis.#report(await this.#files?.share(tiles));\n\t}\n\n\tasync #shareData(action: 'share-link' | 'share-text', data: ShareData) {\n\t\tthis.#track(action);\n\n\t\ttry {\n\t\t\tawait navigator.share(data);\n\t\t} catch (error) {\n\t\t\tif (!isDomError(error, 'AbortError')) this.#feedback?.announce(this.#strings.error);\n\t\t}\n\t}\n\n\t#showMore(button: HTMLElement) {\n\t\tconst hidden = [...this.querySelectorAll<HTMLElement>('[role=\"radio\"][hidden]')];\n\n\t\tfor (const radio of hidden) radio.hidden = false;\n\n\t\tbutton.hidden = true;\n\t\thidden[0]?.focus();\n\t}\n\n\t#syncCaption() {\n\t\tconst parts = this.#parts;\n\n\t\tif (!parts) return;\n\n\t\tconst { isOver, message } = syncCaptionView({\n\t\t\tdestination: this.#destination,\n\t\t\tparts,\n\t\t\tprimaryAction: this.#getPrimaryAction(),\n\t\t\tstrings: this.#strings,\n\t\t});\n\n\t\tif (isOver && !this.#isOver && parts.dialog.open) this.#feedback?.announce(message);\n\n\t\tthis.#isOver = isOver;\n\t}\n\n\t#syncDestination() {\n\t\tconst parts = this.#parts;\n\t\tconst payload = this.#payload;\n\n\t\tif (!parts || !payload) return;\n\n\t\tsyncDestinationView({\n\t\t\tassets: this.#getAssets(),\n\t\t\tdestination: this.#destination,\n\t\t\tparts,\n\t\t\tstrings: this.#strings,\n\t\t\tsuggested: this.#getSuggestedAsset(),\n\t\t});\n\n\t\tif (!this.#isCaptionEdited) {\n\t\t\tparts.caption.value = fitCaption(\n\t\t\t\t{ description: payload.description, title: payload.title, url: this.#getUrl() },\n\t\t\t\tthis.#destination,\n\t\t\t\tpayload.locale,\n\t\t\t).text;\n\t\t}\n\n\t\tthis.#syncCaption();\n\t\tthis.#prefetch();\n\t}\n\n\t#track(action: ShareKitAction, tile?: HTMLElement) {\n\t\tconst detail: ShareKitActionDetail = { action, destination: this.#destination };\n\n\t\tif (tile?.dataset.shareKitAsset) detail.asset = tile.dataset.shareKitAsset;\n\n\t\tthis.dispatchEvent(\n\t\t\tnew CustomEvent(shareKitActionEventName, { bubbles: true, composed: true, detail }),\n\t\t);\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'share-kit': ShareKitElement;\n\t}\n}\n","import type { ShareKitIcons } from './icons.js';\n\nimport { ShareKitElement } from './element.js';\n\nexport interface ShareKitOptions {\n\ticons?: ShareKitIcons;\n}\n\nconst tagName = 'share-kit';\n\n// An element name registers once per page, so the first call's options stand\nexport function defineShareKit({ icons = {} }: ShareKitOptions = {}) {\n\tif (customElements.get(tagName)) return;\n\n\tcustomElements.define(\n\t\ttagName,\n\t\tclass extends ShareKitElement {\n\t\t\tprotected override readonly icons = icons;\n\t\t},\n\t);\n}\n","import type { ShareKitDestinationId } from './destinations.js';\n\nexport type ShareKitIconName = 'close' | 'more' | 'qr' | ShareKitDestinationId;\n\nexport type ShareKitIcons = Partial<Record<ShareKitIconName, string>>;\n\nexport const shareKitInterfaceIcons = {\n\tany: 'M3.16 14.47L5.99 11.65A4.5 4.5 0 0 1 12.35 18.01L9.53 20.84A4.5 4.5 0 0 1 3.16 14.47ZM4.58 15.89A2.5 2.5 0 0 0 8.11 19.42L10.94 16.6A2.5 2.5 0 0 0 7.4 13.06ZM11.65 5.99L14.47 3.16A4.5 4.5 0 0 1 20.84 9.53L18.01 12.35A4.5 4.5 0 0 1 11.65 5.99ZM13.06 7.4A2.5 2.5 0 0 0 16.6 10.94L19.42 8.11A2.5 2.5 0 0 0 15.89 4.58ZM8.46 14.12L14.12 8.46L15.54 9.88L9.88 15.54Z',\n\tclose:\n\t\t'M6 7.41 7.41 6 12 10.59 16.59 6 18 7.41 13.41 12 18 16.59 16.59 18 12 13.41 7.41 18 6 16.59 10.59 12Z',\n\tmessages:\n\t\t'M5 4h14a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2ZM5 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ClB,KAAK,UAAU;CAChB;CAEA,OAAO,QAAwB,MAAoB;EAClD,MAAM,SAA+B;GAAE;GAAQ,aAAa,KAAK;EAAa;EAE9E,IAAI,MAAM,QAAQ,eAAe,OAAO,QAAQ,KAAK,QAAQ;EAE7D,KAAK,cACJ,IAAI,YAAY,yBAAyB;GAAE,SAAS;GAAM,UAAU;GAAM;EAAO,CAAC,CACnF;CACD;AACD;;ACzeA,MAAM,UAAU;AAGhB,SAAgB,eAAe,EAAE,QAAQ,CAAC,MAAuB,CAAC,GAAG;CACpE,IAAI,eAAe,IAAI,OAAO,GAAG;CAEjC,eAAe,OACd,SACA,cAAc,gBAAgB;EACD,QAAQ;CACrC,CACD;AACD;;ACdA,MAAa,yBAAyB;CACrC,KAAK;CACL,OACC;CACD,UACC;CACD,MAAM;CACN,IAAI;AACL"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/count.ts","../src/actions.ts","../src/assets.ts","../src/caption.ts","../src/formats.ts","../src/destinations.ts","../src/dom.ts","../src/feedback.ts","../src/icons.ts","../src/payload.ts","../src/qr.ts","../src/strings.ts","../src/render.ts","../src/sync.ts","../src/types.ts","../src/element.ts","../src/define.ts"],"sourcesContent":["const urlPattern = /https?:\\/\\/[\\w!#$%&'()*+,./:;=?@~-]+/giu;\n\n// X also treats a bare domain like `example.com` as a link; this short list of TLDs catches most of them\nexport const xLinkPattern =\n\t/https?:\\/\\/[\\w!#$%&'()*+,./:;=?@~-]+|(?<![\\w#./@-])(?:[\\da-z][\\da-z-]*\\.)+(?:[a-z]{2}|com|org|net|edu|gov|info|biz|app|dev|xyz|site|online|blog|news|shop|store|page|tech|art|link|live|social|club|world|asia)(?![\\w-])(?:\\/[\\w!#$%&'()*+,./:;=?@~-]*)?/giu;\n\nconst urlTrailingPunctuation = /[!'),.:;?]+$/u;\n\nconst graphemeSegmenter = new Intl.Segmenter(undefined, {\n\tgranularity: 'grapheme',\n});\n\nconst utf8Encoder = new TextEncoder();\n\nconst latinCombiningMarkRanges = [\n\t[0x03_00, 0x03_6f],\n\t[0x1a_b0, 0x1a_ff],\n\t[0x1d_c0, 0x1d_ff],\n\t[0x20_d0, 0x20_ff],\n\t[0xfe_20, 0xfe_2f],\n] as const;\n\n// The `v` flag is newer than `Intl.Segmenter`; without it emoji are charged per code point, which only overcounts\nfunction getEmojiPattern() {\n\ttry {\n\t\treturn new RegExp(String.raw`^\\p{RGI_Emoji}$`, 'v');\n\t} catch {\n\t\treturn;\n\t}\n}\n\nconst emojiPattern = getEmojiPattern();\n\nexport function getGraphemes(text: string) {\n\treturn Array.from(graphemeSegmenter.segment(text), ({ segment }) => segment);\n}\n\n// twitter-text config v3; every code point outside these ranges weighs double\nfunction isLightCodePoint(codePoint: number) {\n\treturn (\n\t\tcodePoint <= 0x10_ff ||\n\t\t(codePoint >= 0x20_00 && codePoint <= 0x20_0d) ||\n\t\t(codePoint >= 0x20_10 && codePoint <= 0x20_1f) ||\n\t\t(codePoint >= 0x20_32 && codePoint <= 0x20_37)\n\t);\n}\n\nexport function shareKitCountWeighted(text: string) {\n\tconst graphemes = getGraphemes(text.normalize('NFC'));\n\tlet total = 0;\n\n\tfor (const grapheme of graphemes) {\n\t\tif (emojiPattern?.test(grapheme)) {\n\t\t\ttotal += 2;\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const character of grapheme) {\n\t\t\ttotal += isLightCodePoint(character.codePointAt(0) ?? 0) ? 1 : 2;\n\t\t}\n\t}\n\n\treturn total;\n}\n\nfunction isLatinCombiningMark(codePoint: number) {\n\treturn latinCombiningMarkRanges.some(([start, end]) => codePoint >= start && codePoint <= end);\n}\n\n// Mirrors stringz, Mastodon's web composer counter: an emoji sequence is one, Latin combining marks are free, Thai marks count apart\nexport function shareKitCountStringz(text: string) {\n\tlet total = 0;\n\n\tfor (const grapheme of getGraphemes(text)) {\n\t\tif (emojiPattern?.test(grapheme)) {\n\t\t\ttotal += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const character of grapheme) {\n\t\t\tif (!isLatinCombiningMark(character.codePointAt(0) ?? 0)) total += 1;\n\t\t}\n\t}\n\n\treturn total;\n}\n\n// Mirrors `toShortUrl` in bluesky-social/social-app, which the composer applies before it counts\nexport function shareKitShortenedLinkCost(url: string) {\n\tif (!URL.canParse(url)) return getGraphemes(url).length;\n\n\tconst { hash, host, pathname, search } = new URL(url);\n\tconst path = `${pathname === '/' ? '' : pathname}${search}${hash}`;\n\n\treturn host.length + Math.min(path.length, 16);\n}\n\nexport function shareKitCountLength(text: string) {\n\treturn text.length;\n}\n\nexport function shareKitCountGraphemes(text: string) {\n\treturn getGraphemes(text).length;\n}\n\nexport function shareKitCountUtf8(text: string) {\n\treturn utf8Encoder.encode(text).length;\n}\n\nfunction splitLinks(text: string, pattern: RegExp) {\n\tconst links: Array<string> = [];\n\n\tconst rest = text.replaceAll(pattern, (match) => {\n\t\tconst trailing = urlTrailingPunctuation.exec(match)?.[0] ?? '';\n\n\t\tlinks.push(match.slice(0, match.length - trailing.length));\n\n\t\treturn trailing;\n\t});\n\n\treturn { links, rest };\n}\n\nexport type ShareKitCounter = (text: string) => number;\n\ntype LinkCost = ((link: string) => number) | number;\n\nexport function withLinkCost(\n\tcount: ShareKitCounter,\n\tcost: LinkCost,\n\tpattern: RegExp,\n): ShareKitCounter {\n\treturn (text) => {\n\t\tconst { links, rest } = splitLinks(text, pattern);\n\t\tlet total = count(rest);\n\n\t\tfor (const link of links) total += typeof cost === 'number' ? cost : cost(link);\n\n\t\treturn total;\n\t};\n}\n\nexport function shareKitWithLinkCost(count: ShareKitCounter, cost: LinkCost) {\n\treturn withLinkCost(count, cost, urlPattern);\n}\n","import type { ShareKitActionOutcome } from './types.js';\n\nconst shareCapabilities = ['files', 'link', 'copy-image', 'mobile'] as const;\n\nexport type ShareCapability = (typeof shareCapabilities)[number];\n\nexport interface ShareAssetSource {\n\tfilename: string;\n\tsrc: string;\n\ttype: string;\n}\n\nconst pngType = 'image/png';\n\nfunction canShareFiles() {\n\tif (!('canShare' in navigator)) return false;\n\n\treturn navigator.canShare({ files: [new File([], 'probe.jpg', { type: 'image/jpeg' })] });\n}\n\nfunction canCopyImage() {\n\tif (!('clipboard' in navigator) || !('ClipboardItem' in globalThis)) return false;\n\n\treturn 'supports' in ClipboardItem && ClipboardItem.supports(pngType);\n}\n\nconst capabilityTests = {\n\t'copy-image': canCopyImage,\n\tfiles: canShareFiles,\n\t// A phone's share sheet reaches its apps; a desktop's mostly reaches Mail and AirDrop\n\tlink: () => 'share' in navigator,\n\tmobile: () => matchMedia('(pointer: coarse)').matches,\n} as const satisfies Record<ShareCapability, () => boolean>;\n\nfunction isShareCapability(value: string): value is ShareCapability {\n\treturn shareCapabilities.some((capability) => capability === value);\n}\n\n// A list already on the element wins, so a page can show how the dialog looks on another device\nexport function getShareCapabilities(preset: string | undefined) {\n\tif (preset !== undefined) {\n\t\tconst tokens = preset.split(/\\s+/u).filter(Boolean);\n\t\tconst unknown = tokens.filter((token) => !isShareCapability(token));\n\n\t\tif (unknown.length > 0) {\n\t\t\tconsole.warn(`share-kit: unknown data-can tokens ignored: ${unknown.join(', ')}`);\n\t\t}\n\n\t\treturn tokens.filter(isShareCapability);\n\t}\n\n\treturn shareCapabilities.filter((capability) => capabilityTests[capability]());\n}\n\nexport function isDomError(error: unknown, name: string) {\n\treturn error instanceof DOMException && error.name === name;\n}\n\nexport async function shareData(data: ShareData): Promise<ShareKitActionOutcome> {\n\ttry {\n\t\tawait navigator.share(data);\n\n\t\treturn 'shared';\n\t} catch (error) {\n\t\treturn isDomError(error, 'AbortError') ? 'dismissed' : 'error';\n\t}\n}\n\n// `no-cache` revalidates a copy cached without CORS headers, which this fetch would reject\nexport async function fetchFile({ filename, src, type }: ShareAssetSource, signal: AbortSignal) {\n\tconst response = await fetch(src, { cache: 'no-cache', signal });\n\n\tif (!response.ok) throw new Error(`${String(response.status)} for ${src}`);\n\n\treturn new File([await response.blob()], filename, { type });\n}\n\n// `download` is ignored on a cross-origin href, so the file goes through an object URL\nexport function saveFile(file: File) {\n\tconst objectUrl = URL.createObjectURL(file);\n\tconst link = document.createElement('a');\n\n\tlink.download = file.name;\n\tlink.href = objectUrl;\n\tlink.hidden = true;\n\tdocument.body.append(link);\n\tlink.click();\n\tlink.remove();\n\n\treturn objectUrl;\n}\n\n// PNG is the only image type every browser's async clipboard accepts\nasync function toPngBlob(pending: Promise<File | undefined>) {\n\tconst file = await pending;\n\n\tif (!file) throw new Error('The image did not load');\n\n\tconst bitmap = await createImageBitmap(file);\n\tconst canvas = new OffscreenCanvas(bitmap.width, bitmap.height);\n\tconst context = canvas.getContext('2d');\n\n\tif (!context) throw new Error('No 2D context for the PNG conversion');\n\n\tcontext.drawImage(bitmap, 0, 0);\n\tbitmap.close();\n\n\treturn canvas.convertToBlob({ type: pngType });\n}\n\nexport function copyImage(file: Promise<File | undefined>) {\n\treturn navigator.clipboard.write([new ClipboardItem({ [pngType]: toPngBlob(file) })]);\n}\n\nexport function isOpenHash(openHash: string | undefined) {\n\treturn openHash !== undefined && location.hash === `#${openHash}`;\n}\n\n// Replacing the entry keeps the router's state and stops a reload or Back from reopening the dialog\nexport function clearOpenHash(openHash: string | undefined) {\n\tif (!isOpenHash(openHash)) return;\n\n\thistory.replaceState(history.state, '', `${location.pathname}${location.search}`);\n}\n\n// A `mailto:` href opened in a new tab would leave it blank\nexport function openComposer(href: string) {\n\tconst { protocol } = new URL(href, location.href);\n\n\tif (protocol !== 'http:' && protocol !== 'https:') {\n\t\tlocation.assign(href);\n\t\treturn;\n\t}\n\n\twindow.open(href, '_blank', 'noopener');\n}\n","import type { ShareAssetSource } from './actions.js';\nimport type { ShareKitActionOutcome } from './types.js';\n\nimport { fetchFile, isDomError, saveFile } from './actions.js';\n\nexport type ShareOutcome = 'unsaved' | ShareKitActionOutcome;\n\ninterface ShareAssetFilesOptions {\n\tcanShare: boolean;\n\tgetSource: (tile: HTMLElement) => ShareAssetSource | undefined;\n\tsignal: AbortSignal;\n}\n\nfunction isFile(file: File | undefined): file is File {\n\treturn file !== undefined;\n}\n\nexport class ShareAssetFiles {\n\t#files = new Map<HTMLElement, File>();\n\t#loads = new Map<HTMLElement, Promise<File | undefined>>();\n\t#objectUrls = new Set<string>();\n\t#options: ShareAssetFilesOptions;\n\n\tconstructor(options: ShareAssetFilesOptions) {\n\t\tthis.#options = options;\n\t}\n\n\tdispose() {\n\t\tfor (const objectUrl of this.#objectUrls) URL.revokeObjectURL(objectUrl);\n\n\t\tthis.#objectUrls.clear();\n\t\tthis.#files.clear();\n\t\tthis.#loads.clear();\n\t}\n\n\tload(tile: HTMLElement) {\n\t\tconst pending = this.#loads.get(tile);\n\n\t\tif (pending) return pending;\n\n\t\tconst promise = this.#fetch(tile);\n\n\t\tthis.#loads.set(tile, promise);\n\n\t\treturn promise;\n\t}\n\n\tasync save(tile: HTMLElement): Promise<ShareOutcome> {\n\t\tconst file = await this.load(tile);\n\n\t\treturn file ? this.#saveFiles([file]) : 'unsaved';\n\t}\n\n\tasync share(tiles: Array<HTMLElement>): Promise<ShareOutcome> {\n\t\tconst ready = tiles.map((tile) => this.#files.get(tile));\n\n\t\t// Calling `share()` before any await keeps the tap's user activation valid\n\t\tif (ready.every(isFile)) return this.#shareFiles(ready);\n\n\t\tconst loaded = await Promise.all(tiles.map((tile) => this.load(tile)));\n\n\t\treturn loaded.every(isFile) ? this.#shareFiles(loaded) : 'error';\n\t}\n\n\t// Warming on hover lets the share call still start inside the tap\n\twarm(target: EventTarget | null) {\n\t\tif (!(target instanceof Element)) return;\n\n\t\tconst tile = target\n\t\t\t.closest('[data-share-kit-action=\"share\"]')\n\t\t\t?.closest<HTMLElement>('[data-share-kit-asset]');\n\n\t\tif (tile) void this.load(tile);\n\t}\n\n\t// A failed load is forgotten so the next tap tries again\n\tasync #fetch(tile: HTMLElement) {\n\t\tconst source = this.#options.getSource(tile);\n\n\t\tif (!source) return;\n\n\t\ttry {\n\t\t\tconst file = await fetchFile(source, this.#options.signal);\n\n\t\t\tthis.#files.set(tile, file);\n\n\t\t\treturn file;\n\t\t} catch {\n\t\t\tthis.#loads.delete(tile);\n\n\t\t\treturn;\n\t\t}\n\t}\n\n\t#saveFiles(files: Array<File>): ShareOutcome {\n\t\tfor (const file of files) this.#objectUrls.add(saveFile(file));\n\n\t\treturn 'saved';\n\t}\n\n\tasync #shareFiles(files: Array<File>): Promise<ShareOutcome> {\n\t\tif (!this.#options.canShare || !navigator.canShare({ files })) return this.#saveFiles(files);\n\n\t\ttry {\n\t\t\tawait navigator.share({ files });\n\n\t\t\treturn 'shared';\n\t\t} catch (error) {\n\t\t\tif (isDomError(error, 'AbortError') || this.#options.signal.aborted) return 'dismissed';\n\n\t\t\t// A slow load used up the tap's activation; the files are ready now, so another tap works\n\t\t\tif (isDomError(error, 'NotAllowedError')) return 'retry';\n\n\t\t\treturn this.#saveFiles(files);\n\t\t}\n\t}\n}\n","import type { ShareKitDestination } from './destinations.js';\n\nimport { getGraphemes } from './count.js';\n\ntype CaptionDestination = Pick<ShareKitDestination<string>, 'count' | 'limit' | 'shape'>;\n\nexport interface ShareCaptionFields {\n\tdescription?: string | undefined;\n\ttitle: string;\n\turl: string;\n}\n\nexport interface ShareCaption {\n\tcount: number;\n\tisTruncated: boolean;\n\tlimit: number | undefined;\n\ttext: string;\n}\n\nconst separator = '\\n\\n';\n\nconst ellipsis = '…';\n\n// The locale comes from the payload, and a malformed tag like `en_US` throws\nfunction createSegmenter(locale: string, granularity: 'sentence' | 'word') {\n\ttry {\n\t\treturn new Intl.Segmenter(locale, { granularity });\n\t} catch {\n\t\treturn new Intl.Segmenter(undefined, { granularity });\n\t}\n}\n\nfunction getSegmentEnds(text: string, granularity: 'sentence' | 'word', locale: string) {\n\tconst segments = createSegmenter(locale, granularity).segment(text);\n\n\treturn Array.from(segments, ({ index, segment }) => index + segment.length);\n}\n\nfunction getGraphemeEnds(text: string) {\n\tlet end = 0;\n\n\treturn getGraphemes(text).map((grapheme) => (end += grapheme.length));\n}\n\nfunction join(parts: Array<string | undefined>) {\n\treturn parts.filter(Boolean).join(separator);\n}\n\ninterface CutInput {\n\tcanFit: (candidate: string) => boolean;\n\tends: Array<number>;\n\tsuffix: string;\n\ttext: string;\n}\n\n// Counts grow with the cut, so the scan stops at the first miss\nfunction findCut({ canFit, ends, suffix, text }: CutInput) {\n\tlet fitted: string | undefined;\n\n\tfor (const end of ends) {\n\t\tconst cut = text.slice(0, end).trimEnd();\n\n\t\tif (cut.length === 0 || cut.length === text.length) continue;\n\n\t\tconst candidate = `${cut}${suffix}`;\n\n\t\tif (!canFit(candidate)) break;\n\n\t\tfitted = candidate;\n\t}\n\n\treturn fitted;\n}\n\ninterface FitInput {\n\tbody: string | undefined;\n\tcanFit: (text: string) => boolean;\n\tlink: string | undefined;\n\tlocale: string;\n\ttitle: string;\n}\n\nfunction fitBody({ body, canFit, link, locale, title }: FitInput) {\n\tif (!body) return;\n\n\tconst canFitBody = (candidate: string) => canFit(join([title, candidate, link]));\n\n\treturn (\n\t\tfindCut({\n\t\t\tcanFit: canFitBody,\n\t\t\tends: getSegmentEnds(body, 'sentence', locale),\n\t\t\tsuffix: '',\n\t\t\ttext: body,\n\t\t}) ??\n\t\tfindCut({\n\t\t\tcanFit: canFitBody,\n\t\t\tends: getSegmentEnds(body, 'word', locale),\n\t\t\tsuffix: ellipsis,\n\t\t\ttext: body,\n\t\t})\n\t);\n}\n\nfunction fitTitle({ canFit, link, locale, title }: FitInput) {\n\tconst canFitTitle = (candidate: string) => canFit(join([candidate, link]));\n\n\treturn (\n\t\tfindCut({\n\t\t\tcanFit: canFitTitle,\n\t\t\tends: getSegmentEnds(title, 'word', locale),\n\t\t\tsuffix: ellipsis,\n\t\t\ttext: title,\n\t\t}) ??\n\t\tfindCut({ canFit: canFitTitle, ends: getGraphemeEnds(title), suffix: ellipsis, text: title }) ??\n\t\ttitle\n\t);\n}\n\nfunction fitParts(input: FitInput) {\n\tconst { canFit, link, title } = input;\n\tconst body = fitBody(input);\n\n\tif (body) return join([title, body, link]);\n\n\tconst bare = join([title, link]);\n\n\treturn canFit(bare) ? bare : join([fitTitle(input), link]);\n}\n\n// The link is kept whole, then the title; the description takes what is left, cut at a sentence end or failing that a word\n// A link too long to leave room for one grapheme of title comes back over the limit; nothing sensible fits\nexport function fitCaption(\n\t{ description, title, url }: ShareCaptionFields,\n\t{ count, limit, shape }: CaptionDestination,\n\tlocale = 'en',\n): ShareCaption {\n\tconst link = shape === 'full' ? url : undefined;\n\tconst body = shape === 'title' ? undefined : description?.trim() || undefined;\n\tconst whole = shape === 'url' ? url : join([title, body, link]);\n\tconst canFit = (text: string) => limit === undefined || count(text) <= limit;\n\tconst text = canFit(whole) ? whole : fitParts({ body, canFit, link, locale, title });\n\n\treturn { count: count(text), isTruncated: text !== whole, limit, text };\n}\n","export interface ShareKitImageFormat {\n\theight: number;\n\tid: string;\n\twidth: number;\n}\n\nexport const shareKitLandscapeFormat = {\n\theight: 630,\n\tid: 'landscape',\n\twidth: 1200,\n} as const satisfies ShareKitImageFormat;\n\nexport const shareKitPortraitFormat = {\n\theight: 1350,\n\tid: 'portrait',\n\twidth: 1080,\n} as const satisfies ShareKitImageFormat;\n\nexport const shareKitStoryFormat = {\n\theight: 1920,\n\tid: 'story',\n\twidth: 1080,\n} as const satisfies ShareKitImageFormat;\n\nexport const shareKitPinFormat = {\n\theight: 1500,\n\tid: 'pin',\n\twidth: 1000,\n} as const satisfies ShareKitImageFormat;\n\nexport type ShareKitImageFormats = readonly [ShareKitImageFormat, ...Array<ShareKitImageFormat>];\n\ninterface ShareImage {\n\theight: number;\n\tisSuggestable?: boolean;\n\twidth: number;\n}\n\nconst fitTolerance = 0.02;\n\nfunction getRatioDistance(\n\timage: Pick<ShareImage, 'height' | 'width'>,\n\tformat: ShareKitImageFormat,\n) {\n\treturn Math.abs(Math.log(image.width / image.height / (format.width / format.height)));\n}\n\nfunction isFormatFit(image: Pick<ShareImage, 'height' | 'width'>, format: ShareKitImageFormat) {\n\treturn getRatioDistance(image, format) <= fitTolerance;\n}\n\nexport function getSuggestedImage<Image extends ShareImage>(\n\timages: ReadonlyArray<Image>,\n\tformats: ShareKitImageFormats,\n) {\n\tconst candidates = images.filter((image) => image.isSuggestable !== false);\n\n\tfor (const format of formats) {\n\t\tconst match = candidates.find((image) => isFormatFit(image, format));\n\n\t\tif (match) return match;\n\t}\n\n\tlet nearest: Image | undefined;\n\tlet nearestDistance = Infinity;\n\n\tfor (const image of candidates) {\n\t\tconst distance = getRatioDistance(image, formats[0]);\n\n\t\t// Also skips a `NaN` distance from an image without dimensions\n\t\tif (!(distance < nearestDistance)) continue;\n\n\t\tnearest = image;\n\t\tnearestDistance = distance;\n\t}\n\n\treturn nearest;\n}\n\nexport function getShareKitImageFormats(\n\tdestinations: ReadonlyArray<{ images: ShareKitImageFormats }>,\n) {\n\tconst formats = new Map<string, ShareKitImageFormat>();\n\n\tfor (const { images } of destinations) {\n\t\tif (!formats.has(images[0].id)) formats.set(images[0].id, images[0]);\n\t}\n\n\treturn [...formats.values()];\n}\n","import type { ShareKitCounter } from './count.js';\nimport type { ShareKitImageFormats } from './formats.js';\n\nimport {\n\tshareKitCountGraphemes,\n\tshareKitCountLength,\n\tshareKitCountStringz,\n\tshareKitCountUtf8,\n\tshareKitCountWeighted,\n\tshareKitShortenedLinkCost,\n\tshareKitWithLinkCost,\n\twithLinkCost,\n\txLinkPattern,\n} from './count.js';\nimport {\n\tshareKitLandscapeFormat,\n\tshareKitPinFormat,\n\tshareKitPortraitFormat,\n\tshareKitStoryFormat,\n} from './formats.js';\n\nexport type ShareKitActionKind =\n\t'copy-caption' | 'open-composer' | 'share-image' | 'share-link' | 'share-text';\n\nexport type ShareKitDevice = 'desktop' | 'mobile';\n\nexport interface ShareKitComposerInput {\n\tdescription?: string;\n\tdevice: ShareKitDevice;\n\tmedia?: string;\n\ttext: string;\n\ttitle: string;\n\turl: string;\n}\n\nexport interface ShareKitDestination<Id extends string> {\n\tactions: Record<ShareKitDevice, ReadonlyArray<ShareKitActionKind>>;\n\tcomposer?: (input: ShareKitComposerInput) => string | undefined;\n\tcount: ShareKitCounter;\n\thint?: string;\n\tid: Id;\n\timages: ShareKitImageFormats;\n\tlabel: string;\n\tlimit?: number;\n\tshape: 'full' | 'text' | 'title' | 'url';\n\tutmSource?: false | string;\n}\n\nexport function defineShareKitDestination<const Id extends string>(\n\tdestination: ShareKitDestination<Id>,\n) {\n\treturn destination;\n}\n\n// A definition that widened its id to `string` would accept any id, so it accepts none instead\nexport type ShareKitDestinationIdOf<\n\tDestinations extends ReadonlyArray<ShareKitDestination<string>>,\n> = Destinations[number]['id'] extends infer Id extends string\n\t? string extends Id\n\t\t? never\n\t\t: Id\n\t: never;\n\nfunction withQuery(base: string, parameters: Record<string, string | undefined>) {\n\tconst url = new URL(base);\n\n\tfor (const [name, value] of Object.entries(parameters)) {\n\t\tif (value) url.searchParams.set(name, value);\n\t}\n\n\treturn url.href;\n}\n\n// X and Mastodon both charge 23 for any link, whatever its length\nconst fixedLinkCost = 23;\n\nexport const shareKitAnywhere = {\n\tactions: { desktop: [], mobile: ['share-text'] },\n\tcount: shareKitCountLength,\n\tid: 'any',\n\timages: [shareKitLandscapeFormat],\n\tlabel: 'Anywhere',\n\tshape: 'full',\n\tutmSource: false,\n} as const satisfies ShareKitDestination<'any'>;\n\nexport const shareKitBluesky = {\n\tactions: { desktop: ['open-composer'], mobile: ['share-image', 'open-composer'] },\n\tcomposer: ({ text }) => withQuery('https://bsky.app/intent/compose', { text }),\n\tcount: shareKitWithLinkCost(shareKitCountGraphemes, shareKitShortenedLinkCost),\n\tid: 'bluesky',\n\timages: [shareKitPortraitFormat],\n\tlabel: 'Bluesky',\n\tlimit: 300,\n\tshape: 'full',\n} as const satisfies ShareKitDestination<'bluesky'>;\n\nexport const shareKitFacebook = {\n\tactions: { desktop: ['open-composer'], mobile: ['share-link', 'open-composer'] },\n\tcomposer: ({ url }) => withQuery('https://www.facebook.com/sharer/sharer.php', { u: url }),\n\tcount: shareKitCountLength,\n\thint: 'Facebook only takes the link. Your caption is copied, so paste it into your post.',\n\tid: 'facebook',\n\timages: [shareKitLandscapeFormat, shareKitPortraitFormat],\n\tlabel: 'Facebook',\n\tlimit: 63_206,\n\tshape: 'full',\n} as const satisfies ShareKitDestination<'facebook'>;\n\nexport const shareKitInstagram = {\n\tactions: { desktop: [], mobile: ['share-image'] },\n\tcount: shareKitCountLength,\n\thint: \"Links in Instagram captions aren't clickable. Point people to the link in your bio.\",\n\tid: 'instagram',\n\timages: [shareKitPortraitFormat],\n\tlabel: 'Instagram',\n\tlimit: 2200,\n\tshape: 'text',\n} as const satisfies ShareKitDestination<'instagram'>;\n\nexport const shareKitInstagramStory = {\n\tactions: { desktop: [], mobile: ['share-image'] },\n\tcount: shareKitCountLength,\n\thint: 'Add the link to your Story with a link sticker.',\n\tid: 'instagram-story',\n\timages: [shareKitStoryFormat, shareKitPortraitFormat],\n\tlabel: 'Story',\n\tshape: 'url',\n} as const satisfies ShareKitDestination<'instagram-story'>;\n\nexport const shareKitLinkedin = {\n\tactions: { desktop: ['open-composer'], mobile: ['share-link', 'open-composer'] },\n\tcomposer: ({ url }) => withQuery('https://www.linkedin.com/sharing/share-offsite/', { url }),\n\tcount: shareKitCountLength,\n\thint: 'LinkedIn only takes the link. Your caption is copied, so paste it into your post.',\n\tid: 'linkedin',\n\timages: [shareKitLandscapeFormat],\n\tlabel: 'LinkedIn',\n\tlimit: 3000,\n\tshape: 'full',\n} as const satisfies ShareKitDestination<'linkedin'>;\n\n// LINE for PC ignores the `line.me/R` scheme, so a desktop gets the web share page instead\n// Encoded by hand because nobody has checked whether LINE reads `+` as a space\nexport const shareKitLine = {\n\tactions: { desktop: ['open-composer'], mobile: ['open-composer'] },\n\tcomposer: ({ device, text, url }) =>\n\t\tdevice === 'mobile'\n\t\t\t? `https://line.me/R/share?text=${encodeURIComponent(text)}`\n\t\t\t: `https://social-plugins.line.me/lineit/share?url=${encodeURIComponent(url)}&text=${encodeURIComponent(text)}`,\n\tcount: shareKitCountLength,\n\tid: 'line',\n\timages: [shareKitLandscapeFormat],\n\tlabel: 'LINE',\n\tshape: 'full',\n} as const satisfies ShareKitDestination<'line'>;\n\n// Each reader posts from their own server, so there is no composer to open\nexport const shareKitMastodon = {\n\tactions: { desktop: [], mobile: ['share-image'] },\n\tcount: shareKitWithLinkCost(shareKitCountStringz, fixedLinkCost),\n\tid: 'mastodon',\n\timages: [shareKitPortraitFormat],\n\tlabel: 'Mastodon',\n\tlimit: 500,\n\tshape: 'full',\n} as const satisfies ShareKitDestination<'mastodon'>;\n\nexport const shareKitMessages = {\n\tactions: { desktop: ['share-text'], mobile: ['share-text'] },\n\tcount: shareKitCountLength,\n\tid: 'messages',\n\timages: [shareKitLandscapeFormat],\n\tlabel: 'Messages',\n\tshape: 'full',\n} as const satisfies ShareKitDestination<'messages'>;\n\nexport const shareKitPinterest = {\n\tactions: { desktop: ['open-composer'], mobile: ['open-composer'] },\n\tcomposer: ({ media, text, url }) =>\n\t\twithQuery('https://www.pinterest.com/pin/create/button/', { description: text, media, url }),\n\tcount: shareKitCountLength,\n\tid: 'pinterest',\n\timages: [shareKitPinFormat, shareKitPortraitFormat],\n\tlabel: 'Pinterest',\n\tlimit: 800,\n\tshape: 'text',\n} as const satisfies ShareKitDestination<'pinterest'>;\n\nexport const shareKitReddit = {\n\tactions: { desktop: ['open-composer'], mobile: ['open-composer'] },\n\tcomposer: ({ text, url }) => withQuery('https://www.reddit.com/submit', { title: text, url }),\n\tcount: shareKitCountLength,\n\thint: 'Reddit takes a title and the link.',\n\tid: 'reddit',\n\timages: [shareKitLandscapeFormat],\n\tlabel: 'Reddit',\n\tlimit: 300,\n\tshape: 'title',\n} as const satisfies ShareKitDestination<'reddit'>;\n\n// Threads' docs give the limit in characters but count emoji in bytes; bytes is the reading that can't overshoot\nexport const shareKitThreads = {\n\tactions: { desktop: ['open-composer'], mobile: ['share-image', 'open-composer'] },\n\tcomposer: ({ text }) => withQuery('https://www.threads.com/intent/post', { text }),\n\tcount: shareKitCountUtf8,\n\tid: 'threads',\n\timages: [shareKitPortraitFormat],\n\tlabel: 'Threads',\n\tlimit: 500,\n\tshape: 'full',\n} as const satisfies ShareKitDestination<'threads'>;\n\nexport const shareKitX = {\n\tactions: { desktop: ['open-composer'], mobile: ['open-composer'] },\n\tcomposer: ({ text }) => withQuery('https://x.com/intent/tweet', { text }),\n\tcount: withLinkCost(shareKitCountWeighted, fixedLinkCost, xLinkPattern),\n\tid: 'x',\n\timages: [shareKitLandscapeFormat, shareKitPortraitFormat],\n\tlabel: 'X',\n\tlimit: 280,\n\tshape: 'full',\n} as const satisfies ShareKitDestination<'x'>;\n\nexport function getDestinationUrl(\n\turl: string,\n\t{ id, utmSource = id }: Pick<ShareKitDestination<string>, 'id' | 'utmSource'>,\n\tutmMedium: string | undefined,\n) {\n\tif (!utmMedium || utmSource === false || !URL.canParse(url)) return url;\n\n\treturn withQuery(url, { utm_medium: utmMedium, utm_source: utmSource });\n}\n\ninterface SharePrimaryActionInput {\n\tcanShareFiles: boolean;\n\tcanShareText: boolean;\n\tcomposerUrl: string | undefined;\n\thasSuggestedImage: boolean;\n}\n\nfunction canRun(action: ShareKitActionKind, input: SharePrimaryActionInput) {\n\tswitch (action) {\n\t\tcase 'copy-caption': {\n\t\t\treturn true;\n\t\t}\n\t\tcase 'open-composer': {\n\t\t\treturn Boolean(input.composerUrl);\n\t\t}\n\t\tcase 'share-image': {\n\t\t\treturn input.canShareFiles && input.hasSuggestedImage;\n\t\t}\n\t\tcase 'share-link':\n\t\tcase 'share-text': {\n\t\t\treturn input.canShareText;\n\t\t}\n\t}\n}\n\nexport function getPrimaryAction(\n\tactions: ReadonlyArray<ShareKitActionKind>,\n\tinput: SharePrimaryActionInput,\n): ShareKitActionKind {\n\treturn actions.find((action) => canRun(action, input)) ?? 'copy-caption';\n}\n","type Child = Node | string | undefined;\n\ntype Attributes = Record<string, string | undefined>;\n\nexport function createElement<Tag extends keyof HTMLElementTagNameMap>(\n\ttag: Tag,\n\tattributes: Attributes = {},\n\tchildren: Array<Child> = [],\n) {\n\tconst element = document.createElement(tag);\n\n\tfor (const [name, value] of Object.entries(attributes)) {\n\t\tif (value !== undefined) element.setAttribute(name, value);\n\t}\n\n\telement.append(...children.filter((child) => child !== undefined));\n\n\treturn element;\n}\n\nexport function joinClasses(...classes: Array<string | undefined>) {\n\treturn classes.filter(Boolean).join(' ');\n}\n\nconst svgNamespace = 'http://www.w3.org/2000/svg';\n\nconst iconSize = 24;\n\nfunction createIcon(path: string) {\n\tconst svg = document.createElementNS(svgNamespace, 'svg');\n\tconst shape = document.createElementNS(svgNamespace, 'path');\n\n\tsvg.setAttribute('aria-hidden', 'true');\n\tsvg.setAttribute('height', String(iconSize));\n\tsvg.setAttribute('viewBox', '0 0 24 24');\n\tsvg.setAttribute('width', String(iconSize));\n\tshape.setAttribute('d', path);\n\tshape.setAttribute('fill', 'currentColor');\n\tsvg.append(shape);\n\n\treturn svg;\n}\n\nexport function createIconSlot(name: string, path: string | undefined, fallback?: string) {\n\treturn createElement('span', { class: 'share-kit-icon', 'data-share-kit-icon': name }, [\n\t\tpath ? createIcon(path) : fallback,\n\t]);\n}\n\nexport function patchIcons(root: Element, icons: Partial<Record<string, string>>) {\n\tfor (const slot of root.querySelectorAll<HTMLElement>('[data-share-kit-icon]')) {\n\t\tconst path = slot.dataset.shareKitIcon ? icons[slot.dataset.shareKitIcon] : undefined;\n\n\t\tif (path && !slot.querySelector('svg')) slot.replaceChildren(createIcon(path));\n\t}\n}\n\nfunction isOnBackdrop(dialog: HTMLDialogElement, event: PointerEvent) {\n\tif (event.target !== dialog) return false;\n\n\tconst rect = dialog.getBoundingClientRect();\n\n\treturn (\n\t\tevent.clientX < rect.left ||\n\t\tevent.clientX > rect.right ||\n\t\tevent.clientY < rect.top ||\n\t\tevent.clientY > rect.bottom\n\t);\n}\n\n// Checking both ends of the press means a drag that ends past the edge won't close the dialog\nexport function polyfillLightDismiss(dialog: HTMLDialogElement, signal: AbortSignal) {\n\tif ('closedBy' in HTMLDialogElement.prototype) return;\n\n\tlet isBackdropPress = false;\n\n\tdialog.addEventListener(\n\t\t'pointerdown',\n\t\t(event) => {\n\t\t\tisBackdropPress = isOnBackdrop(dialog, event);\n\t\t},\n\t\t{ signal },\n\t);\n\tdialog.addEventListener(\n\t\t'pointerup',\n\t\t(event) => {\n\t\t\tif (isBackdropPress && isOnBackdrop(dialog, event)) dialog.close();\n\n\t\t\tisBackdropPress = false;\n\t\t},\n\t\t{ signal },\n\t);\n}\n\nexport const radioKeys: Partial<Record<string, (index: number, count: number) => number>> = {\n\tArrowDown: (index, count) => (index + 1) % count,\n\tArrowLeft: (index, count) => (index - 1 + count) % count,\n\tArrowRight: (index, count) => (index + 1) % count,\n\tArrowUp: (index, count) => (index - 1 + count) % count,\n\tEnd: (_index, count) => count - 1,\n\tHome: () => 0,\n};\n","import type { ShareKitStrings } from './strings.js';\n\nimport { copyImage } from './actions.js';\n\nconst statusDurationMs = 4000;\n\nconst flashDurationMs = 2000;\n\nexport class ShareFeedback {\n\t#flashing = new WeakSet<HTMLElement>();\n\t#getStatus: () => HTMLElement | undefined;\n\t#strings: ShareKitStrings<string>;\n\t#timeout: ReturnType<typeof setTimeout> | undefined;\n\n\tconstructor(getStatus: () => HTMLElement | undefined, strings: ShareKitStrings<string>) {\n\t\tthis.#getStatus = getStatus;\n\t\tthis.#strings = strings;\n\t}\n\n\tannounce(message: string) {\n\t\tconst status = this.#getStatus();\n\n\t\tif (!status) return;\n\n\t\tstatus.textContent = message;\n\n\t\tclearTimeout(this.#timeout);\n\t\tthis.#timeout = setTimeout(() => {\n\t\t\tstatus.textContent = '';\n\t\t}, statusDurationMs);\n\t}\n\n\t// Safari only allows the clipboard write if it starts inside the click, before any await\n\tasync copyImage(file: Promise<File | undefined>, button: HTMLElement) {\n\t\ttry {\n\t\t\tawait copyImage(file);\n\t\t\tthis.#flash(button);\n\t\t} catch {\n\t\t\tthis.announce(this.#strings.error);\n\t\t}\n\t}\n\n\tasync copyText(text: string, button?: HTMLElement, fallback?: HTMLTextAreaElement) {\n\t\ttry {\n\t\t\tawait navigator.clipboard.writeText(text);\n\t\t\tthis.#flash(button);\n\t\t} catch {\n\t\t\tfallback?.select();\n\t\t\tthis.announce(fallback ? this.#strings.copyManual : this.#strings.error);\n\t\t}\n\t}\n\n\tdispose() {\n\t\tclearTimeout(this.#timeout);\n\t}\n\n\t#flash(button: HTMLElement | undefined) {\n\t\tthis.announce(this.#strings.copied);\n\n\t\tif (!button || this.#flashing.has(button)) return;\n\n\t\tconst label = button.textContent;\n\n\t\tthis.#flashing.add(button);\n\t\tbutton.textContent = this.#strings.copied;\n\n\t\tsetTimeout(() => {\n\t\t\tbutton.textContent = label;\n\t\t\tthis.#flashing.delete(button);\n\t\t}, flashDurationMs);\n\t}\n}\n","export const shareKitInterfaceIconNames = ['close', 'more', 'qr'] as const;\n\nexport type ShareKitIconName<Id extends string> = (typeof shareKitInterfaceIconNames)[number] | Id;\n\nexport type ShareKitIcons<Id extends string> = Partial<Record<ShareKitIconName<Id>, string>>;\n\nexport type ShareKitIconsOption<Id extends string> =\n\t(() => Promise<ShareKitIcons<Id>>) | ShareKitIcons<Id>;\n\nexport const shareKitInterfaceIcons = {\n\tany: 'M3.16 14.47L5.99 11.65A4.5 4.5 0 0 1 12.35 18.01L9.53 20.84A4.5 4.5 0 0 1 3.16 14.47ZM4.58 15.89A2.5 2.5 0 0 0 8.11 19.42L10.94 16.6A2.5 2.5 0 0 0 7.4 13.06ZM11.65 5.99L14.47 3.16A4.5 4.5 0 0 1 20.84 9.53L18.01 12.35A4.5 4.5 0 0 1 11.65 5.99ZM13.06 7.4A2.5 2.5 0 0 0 16.6 10.94L19.42 8.11A2.5 2.5 0 0 0 15.89 4.58ZM8.46 14.12L14.12 8.46L15.54 9.88L9.88 15.54Z',\n\tclose:\n\t\t'M6 7.41 7.41 6 12 10.59 16.59 6 18 7.41 13.41 12 18 16.59 16.59 18 12 13.41 7.41 18 6 16.59 10.59 12Z',\n\tmessages:\n\t\t'M5 4h14a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2ZM5 6v9h14V6ZM7 17v4l4-4Z',\n\tmore: 'M4 12a2 2 0 1 0 4 0a2 2 0 1 0-4 0ZM10 12a2 2 0 1 0 4 0a2 2 0 1 0-4 0ZM16 12a2 2 0 1 0 4 0a2 2 0 1 0-4 0Z',\n\tqr: 'M3 3h7v7H3ZM4.5 4.5v4h4v-4ZM5.5 5.5h2v2h-2ZM14 3h7v7h-7ZM15.5 4.5v4h4v-4ZM16.5 5.5h2v2h-2ZM3 14h7v7H3ZM4.5 15.5v4h4v-4ZM5.5 16.5h2v2h-2ZM14 14h2v2h-2ZM18 14h3v2h-3ZM16 16h2v2h-2ZM14 18h2v3h-2ZM18 18h3v3h-3Z',\n} as const satisfies ShareKitIcons<'any' | 'messages'>;\n\nexport class ShareIconSource {\n\tget icons() {\n\t\treturn this.#icons;\n\t}\n\tget isLoading() {\n\t\treturn !this.#isSettled;\n\t}\n\t#icons: ShareKitIcons<string> = {};\n\t#isSettled = false;\n\n\t#loader: (() => Promise<ShareKitIcons<string>>) | undefined;\n\n\t#pending: Promise<ShareKitIcons<string>> | undefined;\n\n\tconstructor(option: ShareKitIconsOption<string>) {\n\t\tif (typeof option === 'function') {\n\t\t\tthis.#loader = option;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#icons = option;\n\t\tthis.#isSettled = true;\n\t}\n\n\tload() {\n\t\tif (!this.#pending) this.#pending = this.#load();\n\n\t\treturn this.#pending;\n\t}\n\n\tasync #load() {\n\t\tif (!this.#loader) return this.#icons;\n\n\t\ttry {\n\t\t\tthis.#icons = await this.#loader();\n\t\t} catch (error) {\n\t\t\tconsole.warn(\n\t\t\t\t'share-kit: the icons loader failed, so the dialog keeps its text labels',\n\t\t\t\terror,\n\t\t\t);\n\t\t}\n\n\t\tthis.#isSettled = true;\n\n\t\treturn this.#icons;\n\t}\n}\n","import type { ShareKitDestination } from './destinations.js';\nimport type { ShareKitAsset, ShareKitPayload, ShareKitSettings } from './types.js';\n\nfunction isPayload(value: unknown): value is ShareKitPayload<string> {\n\tif (typeof value !== 'object' || value === null) return false;\n\n\tconst { assets, settings, title, url }: Partial<Record<keyof ShareKitPayload<string>, unknown>> =\n\t\tvalue;\n\n\treturn (\n\t\ttypeof title === 'string' &&\n\t\ttypeof url === 'string' &&\n\t\tArray.isArray(assets) &&\n\t\ttypeof settings === 'object' &&\n\t\tsettings !== null\n\t);\n}\n\n// `<` is escaped so a title or description can't close the script element early\nexport function serializeShareKitPayload(payload: ShareKitPayload<string>) {\n\treturn JSON.stringify(payload).replaceAll('<', String.raw`\\u003c`);\n}\n\nexport function readSharePayload(host: HTMLElement) {\n\tconst source = host.querySelector(':scope > script[type=\"application/json\"]')?.textContent;\n\n\tif (!source) return;\n\n\ttry {\n\t\tconst value: unknown = JSON.parse(source);\n\n\t\treturn isPayload(value) ? value : undefined;\n\t} catch {\n\t\treturn;\n\t}\n}\n\ntype Catalogue = ReadonlyMap<string, ShareKitDestination<string>>;\n\nfunction getIds(value: unknown) {\n\tif (!Array.isArray(value)) return [];\n\n\treturn [...new Set<unknown>(value)];\n}\n\n// The payload arrives as JSON, so ids are checked again; an empty row would leave the radio group unreachable\nexport function getDestinationLists(\n\t{ destinations, destinationsMore }: ShareKitSettings<string>,\n\tcatalogue: Catalogue,\n) {\n\tconst unknown: Array<string> = [];\n\tconst resolve = (ids: Array<unknown>) =>\n\t\tids.flatMap((id) => {\n\t\t\tconst destination = typeof id === 'string' ? catalogue.get(id) : undefined;\n\n\t\t\tif (!destination) unknown.push(String(id));\n\n\t\t\treturn destination ? [destination] : [];\n\t\t});\n\tconst shown = resolve(getIds(destinations));\n\tconst rest = resolve(getIds(destinationsMore)).filter(\n\t\t(destination) => !shown.includes(destination),\n\t);\n\n\tif (unknown.length > 0) {\n\t\tconsole.warn(`share-kit: unregistered destinations dropped: ${unknown.join(', ')}`);\n\t}\n\n\tif (shown.length > 0) return { main: shown, more: rest };\n\tif (rest.length > 0) return { main: rest, more: [] };\n\n\tconsole.warn('share-kit: no registered destinations to show');\n\n\treturn;\n}\n\nexport function getShareAssets(assets: ReadonlyArray<ShareKitAsset>) {\n\tconst seen = new Set<string>();\n\tconst kept = assets.filter((asset) => {\n\t\tconst id: unknown = asset.id;\n\n\t\tif (typeof id !== 'string' || id === '' || seen.has(id)) return false;\n\n\t\tseen.add(id);\n\n\t\treturn true;\n\t});\n\n\tif (kept.length < assets.length) {\n\t\tconsole.warn('share-kit: images with an empty or repeated id dropped');\n\t}\n\n\treturn kept;\n}\n","import type { ShareCapability } from './actions.js';\nimport type { ShareKitStrings } from './strings.js';\nimport type { ShareKitPayload } from './types.js';\n\nimport { createElement, createIconSlot, polyfillLightDismiss } from './dom.js';\n\ninterface ShareQrInput {\n\tcloseIcon: string | undefined;\n\tid: string;\n\tsignal: AbortSignal;\n\tstrings: Pick<ShareKitStrings<string>, 'close' | 'qrAlt' | 'qrTitle'>;\n\turl: string;\n}\n\nconst qrSize = 200;\n\nasync function createQrSource(text: string) {\n\tconst [{ generate }, { toSvgDataURL }] = await Promise.all([\n\t\timport('lean-qr'),\n\t\timport('lean-qr/extras/svg'),\n\t]);\n\n\treturn toSvgDataURL(generate(text), { off: '#ffffff', on: '#000000', pad: 4, scale: 8 });\n}\n\n// Stacks over the share dialog rather than inside it, so opening the code moves nothing beneath\nclass ShareQrDialog {\n\treadonly dialog: HTMLDialogElement;\n\t#image: HTMLImageElement;\n\t#url: string;\n\n\tconstructor({ closeIcon, id, signal, strings, url }: ShareQrInput) {\n\t\tconst titleId = `${id}-title`;\n\n\t\tthis.#url = url;\n\t\tthis.#image = createElement('img', {\n\t\t\talt: strings.qrAlt,\n\t\t\tclass: 'share-kit-qr-image',\n\t\t\theight: String(qrSize),\n\t\t\twidth: String(qrSize),\n\t\t});\n\t\tthis.dialog = createElement(\n\t\t\t'dialog',\n\t\t\t{ 'aria-labelledby': titleId, class: 'share-kit-qr-dialog', closedby: 'any', id },\n\t\t\t[\n\t\t\t\tcreateElement('form', { class: 'share-kit-header', method: 'dialog' }, [\n\t\t\t\t\tcreateElement('h2', { class: 'share-kit-title', id: titleId }, [strings.qrTitle]),\n\t\t\t\t\tcreateElement(\n\t\t\t\t\t\t'button',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'aria-label': strings.close,\n\t\t\t\t\t\t\tclass: 'share-kit-icon-button',\n\t\t\t\t\t\t\ttitle: strings.close,\n\t\t\t\t\t\t\ttype: 'submit',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[createIconSlot('close', closeIcon, '×')],\n\t\t\t\t\t),\n\t\t\t\t]),\n\t\t\t\tthis.#image,\n\t\t\t],\n\t\t);\n\n\t\tpolyfillLightDismiss(this.dialog, signal);\n\t}\n\n\tasync open() {\n\t\tif (!this.#image.getAttribute('src')) this.#image.src = await createQrSource(this.#url);\n\n\t\tthis.dialog.showModal();\n\t}\n}\n\ninterface ShareQrOptions extends Omit<ShareQrInput, 'url'> {\n\tcapabilities: ReadonlySet<ShareCapability>;\n\tpayload: ShareKitPayload<string>;\n}\n\nfunction getQrUrl(url: string, openHash: string | undefined) {\n\tif (!openHash || !URL.canParse(url)) return url;\n\n\tconst target = new URL(url);\n\n\ttarget.hash = openHash;\n\n\treturn target.href;\n}\n\n// A phone is already where the code would lead, so it gets none\nexport function createShareQr({ capabilities, payload, ...input }: ShareQrOptions) {\n\tif (capabilities.has('mobile')) return;\n\n\treturn new ShareQrDialog({ ...input, url: getQrUrl(payload.url, payload.settings.openHash) });\n}\n","export const shareKitStringDefaults = {\n\tassetCopy: 'Copy',\n\tassetSave: 'Save',\n\tassetShare: 'Share',\n\tcaptionCopy: 'Copy caption',\n\tcaptionOver: '{count} over the limit for {destination}',\n\tcaptionReset: 'Reset',\n\tcaptionTitle: 'Caption',\n\tclose: 'Close',\n\tcopied: 'Copied',\n\tcopyManual: \"Couldn't copy. The caption is selected, so you can copy it yourself.\",\n\tdestinationsMore: 'More',\n\tdestinationsTitle: 'Post to',\n\terror: 'Something went wrong. Try saving instead.',\n\timagesTitle: 'Images',\n\tlinkCopy: 'Copy link',\n\tlinkTitle: 'Link',\n\tprimaryCopy: 'Copy caption',\n\tprimaryOpen: 'Open {destination}',\n\tprimaryShareImage: 'Share image',\n\tprimaryShareLink: 'Share link',\n\tprimaryShareText: 'Share',\n\tqrAlt: 'QR code for this page',\n\tqrTitle: 'Scan to continue on your phone',\n\tqrToggle: 'Continue on your phone',\n\tretry: 'Ready. Tap again to share.',\n\tsaved: 'Saved',\n\tsaveError: \"Couldn't save. Try again.\",\n\tsuggested: 'Suggested',\n\ttitle: 'Share this page',\n} as const;\n\nexport type ShareKitStringKey = keyof typeof shareKitStringDefaults;\n\ntype ShareKitDestinationStringKey<Id extends string> = `destination.${Id}` | `hint.${Id}`;\n\nexport type ShareKitStrings<Id extends string> = Partial<\n\tRecord<ShareKitDestinationStringKey<Id>, string>\n> &\n\tRecord<ShareKitStringKey, string>;\n\nconst destinationStringPattern = /^(?:destination|hint)\\.(.+)$/u;\n\nfunction isShareStringKey(key: string): key is ShareKitStringKey {\n\treturn Object.hasOwn(shareKitStringDefaults, key);\n}\n\nfunction isDestinationStringKey(\n\tkey: string,\n\tids: ReadonlySet<string>,\n): key is ShareKitDestinationStringKey<string> {\n\tconst id = destinationStringPattern.exec(key)?.[1];\n\n\treturn id !== undefined && ids.has(id);\n}\n\nexport function getShareStrings(\n\toverrides: Partial<Record<string, unknown>>,\n\tids: ReadonlySet<string>,\n): ShareKitStrings<string> {\n\tconst strings: ShareKitStrings<string> = { ...shareKitStringDefaults };\n\n\tfor (const [key, value] of Object.entries(overrides)) {\n\t\tif (typeof value !== 'string') continue;\n\t\tif (isShareStringKey(key) || isDestinationStringKey(key, ids)) strings[key] = value;\n\t}\n\n\treturn strings;\n}\n\ninterface LabelledDestination {\n\thint?: string;\n\tid: string;\n\tlabel: string;\n}\n\nexport function getDestinationLabel(\n\tstrings: ShareKitStrings<string>,\n\t{ id, label }: LabelledDestination,\n) {\n\treturn strings[`destination.${id}`] ?? label;\n}\n\nexport function getDestinationHint(\n\tstrings: ShareKitStrings<string>,\n\t{ hint, id }: LabelledDestination,\n) {\n\treturn strings[`hint.${id}`] ?? hint;\n}\n\nexport function formatShareString(template: string, values: Record<string, string>) {\n\treturn template.replaceAll(/\\{(\\w+)\\}/gu, (match, name: string) => values[name] ?? match);\n}\n","import type { ShareCapability } from './actions.js';\nimport type { ShareKitDestination } from './destinations.js';\nimport type { ShareKitIcons } from './icons.js';\nimport type { ShareKitStrings } from './strings.js';\nimport type { ShareKitAsset, ShareKitClassRole, ShareKitPayload } from './types.js';\n\nimport { createElement, createIconSlot, joinClasses } from './dom.js';\nimport { getDestinationLabel } from './strings.js';\n\ninterface RenderInput {\n\tcapabilities: ReadonlySet<ShareCapability>;\n\tdestinations: ReadonlyArray<ShareKitDestination<string>>;\n\tdestinationsMore: ReadonlyArray<ShareKitDestination<string>>;\n\ticons: ShareKitIcons<string>;\n\tid: string;\n\tisIconsLoading: boolean;\n\tpayload: ShareKitPayload<string>;\n\tstrings: ShareKitStrings<string>;\n}\n\ninterface RenderContext extends RenderInput {\n\tclassNames: Partial<Record<ShareKitClassRole, string>>;\n}\n\n// No slot for an icon that will never come\nfunction renderDestinationIcon({ icons, isIconsLoading }: RenderContext, name: string) {\n\tconst path = icons[name];\n\n\treturn path || isIconsLoading ? createIconSlot(name, path) : undefined;\n}\n\ninterface ActionInput {\n\taction: string;\n\tdescribedBy?: string;\n\tlabel: string;\n}\n\nfunction renderAction({ classNames }: RenderContext, { action, describedBy, label }: ActionInput) {\n\treturn createElement(\n\t\t'button',\n\t\t{\n\t\t\t'aria-describedby': describedBy,\n\t\t\tclass: joinClasses('share-kit-action', classNames.action),\n\t\t\t'data-share-kit-action': action,\n\t\t\ttype: 'button',\n\t\t},\n\t\t[label],\n\t);\n}\n\nfunction renderHeading({ classNames }: RenderContext, children: Array<Node | string>, id?: string) {\n\treturn createElement(\n\t\t'h3',\n\t\t{ class: joinClasses('share-kit-heading', classNames.heading), id },\n\t\tchildren,\n\t);\n}\n\ninterface IconButtonInput {\n\taction: string;\n\tattributes?: Record<string, string>;\n\tfallback: string;\n\ticon: string;\n\tlabel: string;\n}\n\nfunction renderIconButton(\n\t{ icons }: RenderContext,\n\t{ action, attributes, fallback, icon, label }: IconButtonInput,\n) {\n\treturn createElement(\n\t\t'button',\n\t\t{\n\t\t\t...attributes,\n\t\t\t'aria-label': label,\n\t\t\tclass: 'share-kit-icon-button',\n\t\t\t'data-share-kit-action': action,\n\t\t\ttitle: label,\n\t\t\ttype: 'button',\n\t\t},\n\t\t[createIconSlot(icon, icons[icon], fallback)],\n\t);\n}\n\nfunction renderHeader(context: RenderContext) {\n\tconst { capabilities, id, strings } = context;\n\tconst heading = createElement(\n\t\t'h2',\n\t\t{ class: 'share-kit-title', id: `${id}-title`, tabindex: '-1' },\n\t\t[strings.title],\n\t);\n\tconst qrToggle = capabilities.has('mobile')\n\t\t? undefined\n\t\t: renderIconButton(context, {\n\t\t\t\taction: 'qr',\n\t\t\t\tattributes: { 'aria-haspopup': 'dialog' },\n\t\t\t\tfallback: 'QR',\n\t\t\t\ticon: 'qr',\n\t\t\t\tlabel: strings.qrToggle,\n\t\t\t});\n\tconst close = renderIconButton(context, {\n\t\taction: 'close',\n\t\tfallback: '×',\n\t\ticon: 'close',\n\t\tlabel: strings.close,\n\t});\n\n\treturn {\n\t\theader: createElement('header', { class: 'share-kit-header' }, [\n\t\t\theading,\n\t\t\tcreateElement('div', { class: 'share-kit-header-actions' }, [qrToggle, close]),\n\t\t]),\n\t\theading,\n\t};\n}\n\nfunction renderDestination(context: RenderContext, destination: ShareKitDestination<string>) {\n\tconst { classNames, strings } = context;\n\n\treturn createElement(\n\t\t'button',\n\t\t{\n\t\t\t'aria-checked': 'false',\n\t\t\tclass: joinClasses('share-kit-destination', classNames.destination),\n\t\t\t'data-share-kit-action': 'destination',\n\t\t\t'data-share-kit-destination': destination.id,\n\t\t\trole: 'radio',\n\t\t\ttabindex: '-1',\n\t\t\ttype: 'button',\n\t\t},\n\t\t[\n\t\t\trenderDestinationIcon(context, destination.id),\n\t\t\tcreateElement('span', {}, [getDestinationLabel(strings, destination)]),\n\t\t],\n\t);\n}\n\nfunction renderDestinations(context: RenderContext) {\n\tconst { destinations, destinationsMore, id, strings } = context;\n\tconst headingId = `${id}-destinations`;\n\tconst more =\n\t\tdestinationsMore.length > 0\n\t\t\t? createElement(\n\t\t\t\t\t'button',\n\t\t\t\t\t{\n\t\t\t\t\t\tclass: joinClasses('share-kit-destination', context.classNames.destination),\n\t\t\t\t\t\t'data-share-kit-action': 'more',\n\t\t\t\t\t\ttype: 'button',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\trenderDestinationIcon(context, 'more'),\n\t\t\t\t\t\tcreateElement('span', {}, [strings.destinationsMore]),\n\t\t\t\t\t],\n\t\t\t\t)\n\t\t\t: undefined;\n\tconst extra = destinationsMore.map((destination) => {\n\t\tconst button = renderDestination(context, destination);\n\n\t\tbutton.hidden = true;\n\n\t\treturn button;\n\t});\n\tconst group = createElement(\n\t\t'div',\n\t\t{ 'aria-labelledby': headingId, class: 'share-kit-destinations', role: 'radiogroup' },\n\t\t[...destinations.map((destination) => renderDestination(context, destination)), ...extra],\n\t);\n\n\treturn {\n\t\tmore,\n\t\tsection: createElement('section', { class: 'share-kit-section' }, [\n\t\t\trenderHeading(context, [strings.destinationsTitle], headingId),\n\t\t\tcreateElement('div', { class: 'share-kit-destinations-row' }, [group, more]),\n\t\t]),\n\t};\n}\n\nfunction renderCaption(context: RenderContext) {\n\tconst { classNames, id, payload, strings } = context;\n\tconst captionId = `${id}-caption`;\n\tconst countId = `${id}-count`;\n\tconst hintId = `${id}-hint`;\n\tconst caption = createElement('textarea', {\n\t\t'aria-describedby': `${countId} ${hintId}`,\n\t\tclass: joinClasses('share-kit-caption', classNames.input),\n\t\tdir: 'auto',\n\t\tid: captionId,\n\t\tlang: payload.locale,\n\t\trows: '6',\n\t});\n\tconst count = createElement('span', { class: 'share-kit-count', id: countId });\n\tconst captionCopy = renderAction(context, { action: 'copy-caption', label: strings.captionCopy });\n\tconst hint = createElement('p', { class: 'share-kit-hint', id: hintId });\n\n\treturn {\n\t\tcaption,\n\t\tcaptionCopy,\n\t\tcount,\n\t\thint,\n\t\tsection: createElement('section', { class: 'share-kit-section' }, [\n\t\t\trenderHeading(context, [createElement('label', { for: captionId }, [strings.captionTitle])]),\n\t\t\tcaption,\n\t\t\tcreateElement('div', { class: 'share-kit-caption-meta' }, [\n\t\t\t\tcount,\n\t\t\t\tcreateElement('span', { class: 'share-kit-actions' }, [\n\t\t\t\t\trenderAction(context, { action: 'reset', label: strings.captionReset }),\n\t\t\t\t\tcaptionCopy,\n\t\t\t\t]),\n\t\t\t]),\n\t\t\thint,\n\t\t]),\n\t};\n}\n\ninterface TileInput {\n\tactions: Array<[action: string, label: string]>;\n\tasset: ShareKitAsset;\n\tindex: number;\n}\n\n// A host's image id may hold spaces, which would split `aria-describedby`\nfunction renderTile(context: RenderContext, { actions, asset, index }: TileInput) {\n\tconst labelId = `${context.id}-asset-${String(index)}`;\n\tconst badge = createElement('span', { class: 'share-kit-badge' }, [context.strings.suggested]);\n\n\tbadge.hidden = true;\n\n\treturn createElement('li', { class: 'share-kit-tile', 'data-share-kit-asset': asset.id }, [\n\t\tcreateElement('img', {\n\t\t\talt: asset.alt,\n\t\t\tclass: 'share-kit-preview',\n\t\t\tdecoding: 'async',\n\t\t\theight: String(asset.height),\n\t\t\tloading: 'lazy',\n\t\t\tsrc: asset.previewSrc,\n\t\t\twidth: String(asset.width),\n\t\t}),\n\t\tcreateElement('div', { class: 'share-kit-tile-label' }, [\n\t\t\tcreateElement('span', { id: labelId }, [asset.label]),\n\t\t\tbadge,\n\t\t]),\n\t\tcreateElement(\n\t\t\t'div',\n\t\t\t{ class: 'share-kit-actions' },\n\t\t\tactions.map(([action, label]) =>\n\t\t\t\trenderAction(context, { action, describedBy: labelId, label }),\n\t\t\t),\n\t\t),\n\t]);\n}\n\nfunction getAssetActions({ capabilities, strings }: RenderContext) {\n\tconst actions: Array<[string, string]> = [];\n\tconst canShare = capabilities.has('files');\n\n\tif (canShare) actions.push(['share', strings.assetShare]);\n\n\t// On a phone the share sheet already offers copying\n\tif (capabilities.has('copy-image') && !(canShare && capabilities.has('mobile'))) {\n\t\tactions.push(['copy', strings.assetCopy]);\n\t}\n\n\tactions.push(['save', strings.assetSave]);\n\n\treturn actions;\n}\n\nfunction renderImages(context: RenderContext) {\n\tconst { payload, strings } = context;\n\tconst actions = getAssetActions(context);\n\tconst assets = new Map<HTMLElement, ShareKitAsset>();\n\n\tfor (const [index, asset] of payload.assets.entries()) {\n\t\tassets.set(renderTile(context, { actions, asset, index }), asset);\n\t}\n\n\tconst grid = createElement('ul', { class: 'share-kit-grid' }, [...assets.keys()]);\n\n\treturn {\n\t\tassets,\n\t\tgrid,\n\t\tsection: createElement('section', { class: 'share-kit-section' }, [\n\t\t\trenderHeading(context, [strings.imagesTitle]),\n\t\t\tgrid,\n\t\t]),\n\t};\n}\n\nfunction renderLink(context: RenderContext) {\n\tconst { payload, strings } = context;\n\n\treturn createElement('section', { class: 'share-kit-section' }, [\n\t\trenderHeading(context, [strings.linkTitle]),\n\t\tcreateElement('div', { class: 'share-kit-link-row' }, [\n\t\t\tcreateElement('p', { class: 'share-kit-link' }, [payload.url]),\n\t\t\trenderAction(context, { action: 'copy-link', label: strings.linkCopy }),\n\t\t]),\n\t]);\n}\n\nexport interface ShareKitParts {\n\tassets: ReadonlyMap<HTMLElement, ShareKitAsset>;\n\tcaption: HTMLTextAreaElement;\n\tcaptionCopy: HTMLElement;\n\tcount: HTMLElement;\n\tdialog: HTMLDialogElement;\n\tgrid: HTMLElement;\n\theading: HTMLElement;\n\thint: HTMLElement;\n\tmore: HTMLElement | undefined;\n\tprimary: HTMLButtonElement;\n\tstatus: HTMLElement;\n\ttiles: Array<HTMLElement>;\n}\n\nexport function renderShareKit(input: RenderInput): ShareKitParts {\n\tconst context: RenderContext = { ...input, classNames: input.payload.settings.classNames ?? {} };\n\tconst { header, heading } = renderHeader(context);\n\tconst destinations = renderDestinations(context);\n\tconst caption = renderCaption(context);\n\tconst images = renderImages(context);\n\tconst status = createElement('p', { class: 'share-kit-status', role: 'status' });\n\tconst primary = createElement('button', {\n\t\tclass: joinClasses('share-kit-primary', context.classNames.primary),\n\t\t'data-share-kit-action': 'primary',\n\t\ttype: 'button',\n\t});\n\tconst dialog = createElement(\n\t\t'dialog',\n\t\t{ 'aria-labelledby': heading.id, class: 'share-kit-dialog', closedby: 'any', id: input.id },\n\t\t[\n\t\t\tcreateElement('div', { class: 'share-kit-body' }, [\n\t\t\t\theader,\n\t\t\t\tcreateElement('div', { class: 'share-kit-scroll' }, [\n\t\t\t\t\tdestinations.section,\n\t\t\t\t\tcaption.section,\n\t\t\t\t\trenderLink(context),\n\t\t\t\t\timages.section,\n\t\t\t\t]),\n\t\t\t\tcreateElement('footer', { class: 'share-kit-footer' }, [status, primary]),\n\t\t\t]),\n\t\t],\n\t);\n\n\treturn {\n\t\tassets: images.assets,\n\t\tcaption: caption.caption,\n\t\tcaptionCopy: caption.captionCopy,\n\t\tcount: caption.count,\n\t\tdialog,\n\t\tgrid: images.grid,\n\t\theading,\n\t\thint: caption.hint,\n\t\tmore: destinations.more,\n\t\tprimary,\n\t\tstatus,\n\t\ttiles: [...images.assets.keys()],\n\t};\n}\n","import type { ShareKitActionKind, ShareKitDestination } from './destinations.js';\nimport type { ShareKitParts } from './render.js';\nimport type { ShareKitStrings } from './strings.js';\n\nimport { formatShareString, getDestinationHint, getDestinationLabel } from './strings.js';\n\nconst primaryLabels = {\n\t'copy-caption': 'primaryCopy',\n\t'open-composer': 'primaryOpen',\n\t'share-image': 'primaryShareImage',\n\t'share-link': 'primaryShareLink',\n\t'share-text': 'primaryShareText',\n} as const satisfies Record<ShareKitActionKind, keyof ShareKitStrings<string>>;\n\ninterface SyncInput {\n\tdestination: ShareKitDestination<string>;\n\tparts: ShareKitParts;\n\tstrings: ShareKitStrings<string>;\n}\n\ninterface SyncCaptionInput extends SyncInput {\n\tprimaryAction: ShareKitActionKind;\n}\n\nexport function syncCaptionView({ destination, parts, primaryAction, strings }: SyncCaptionInput) {\n\tconst { limit } = destination;\n\tconst count = destination.count(parts.caption.value);\n\tconst isOver = limit !== undefined && count > limit;\n\tconst label = getDestinationLabel(strings, destination);\n\n\tparts.count.textContent =\n\t\tlimit === undefined ? String(count) : `${String(count)} / ${String(limit)}`;\n\tparts.count.toggleAttribute('data-share-kit-over', isOver);\n\tparts.caption.setAttribute('aria-invalid', String(isOver));\n\tparts.captionCopy.hidden = primaryAction === 'copy-caption';\n\tparts.primary.textContent = formatShareString(strings[primaryLabels[primaryAction]], {\n\t\tdestination: label,\n\t});\n\n\treturn {\n\t\tisOver,\n\t\tmessage: formatShareString(strings.captionOver, {\n\t\t\tcount: String(count - (limit ?? 0)),\n\t\t\tdestination: label,\n\t\t}),\n\t};\n}\n\ninterface SyncDestinationInput extends SyncInput {\n\tassets: Array<HTMLElement>;\n\tsuggested: HTMLElement | undefined;\n}\n\nexport function syncDestinationView({\n\tassets,\n\tdestination,\n\tparts,\n\tstrings,\n\tsuggested,\n}: SyncDestinationInput) {\n\tfor (const radio of parts.dialog.querySelectorAll<HTMLElement>('[role=\"radio\"]')) {\n\t\tconst isSelected = radio.dataset.shareKitDestination === destination.id;\n\n\t\tradio.setAttribute('aria-checked', String(isSelected));\n\t\tradio.tabIndex = isSelected ? 0 : -1;\n\t}\n\n\tparts.hint.textContent = getDestinationHint(strings, destination) ?? '';\n\tparts.hint.hidden = parts.hint.textContent === '';\n\n\tfor (const asset of assets) {\n\t\tconst badge = asset.querySelector<HTMLElement>('.share-kit-badge');\n\n\t\tif (badge) badge.hidden = asset !== suggested;\n\t}\n\n\tparts.grid.append(...parts.tiles);\n\n\tif (suggested) parts.grid.prepend(suggested);\n}\n","import type { ShareKitImageFormat } from './formats.js';\nimport type { ShareKitStrings } from './strings.js';\n\nexport interface ShareKitAsset extends ShareKitImageFormat {\n\talt: string;\n\tfilename: string;\n\tisSuggestable?: boolean;\n\tlabel: string;\n\tpreviewSrc: string;\n\tsrc: string;\n\ttype: string;\n}\n\nexport type ShareKitClassRole = 'action' | 'destination' | 'heading' | 'input' | 'primary';\n\nexport interface ShareKitSettings<Id extends string> {\n\tclassNames?: Partial<Record<ShareKitClassRole, string>>;\n\tdestinations: ReadonlyArray<Id>;\n\tdestinationsMore?: ReadonlyArray<Id>;\n\topenHash?: string;\n\tutmMedium?: string;\n}\n\nexport interface ShareKitPayload<Id extends string> {\n\tassets: ReadonlyArray<ShareKitAsset>;\n\tdescription?: string;\n\tlocale: string;\n\tsettings: ShareKitSettings<Id>;\n\tstrings?: Partial<ShareKitStrings<Id>>;\n\ttitle: string;\n\turl: string;\n}\n\nexport const shareKitActionEventName = 'share-kit:action';\n\nexport type ShareKitAction =\n\t| 'copy'\n\t| 'copy-caption'\n\t| 'copy-link'\n\t| 'destination'\n\t| 'open'\n\t| 'open-composer'\n\t| 'qr'\n\t| 'save'\n\t| 'share'\n\t| 'share-link'\n\t| 'share-text';\n\n// `shared` only means the share sheet took it: Windows resolves `navigator.share` when its picker opens, Android once an app takes over\nexport type ShareKitActionOutcome = 'dismissed' | 'error' | 'retry' | 'saved' | 'shared';\n\n// The global event map can't take the host's id type, so the destination is any string\nexport interface ShareKitActionDetail {\n\taction: ShareKitAction;\n\tasset?: string;\n\tdestination: string;\n\toutcome?: ShareKitActionOutcome;\n}\n\ndeclare global {\n\tinterface GlobalEventHandlersEventMap {\n\t\t[shareKitActionEventName]: CustomEvent<ShareKitActionDetail>;\n\t}\n}\n","import type { ShareCapability } from './actions.js';\nimport type { ShareOutcome } from './assets.js';\nimport type { ShareKitActionKind, ShareKitDestination } from './destinations.js';\nimport type { ShareKitParts } from './render.js';\nimport type { ShareKitStrings } from './strings.js';\nimport type { ShareKitAction, ShareKitActionDetail, ShareKitPayload } from './types.js';\n\nimport {\n\tclearOpenHash,\n\tgetShareCapabilities,\n\tisOpenHash,\n\topenComposer,\n\tshareData,\n} from './actions.js';\nimport { ShareAssetFiles } from './assets.js';\nimport { fitCaption } from './caption.js';\nimport { getDestinationUrl, getPrimaryAction } from './destinations.js';\nimport { patchIcons, polyfillLightDismiss, radioKeys } from './dom.js';\nimport { ShareFeedback } from './feedback.js';\nimport { getSuggestedImage } from './formats.js';\nimport { ShareIconSource } from './icons.js';\nimport { getDestinationLists, getShareAssets, readSharePayload } from './payload.js';\nimport { createShareQr } from './qr.js';\nimport { renderShareKit } from './render.js';\nimport { getShareStrings, shareKitStringDefaults } from './strings.js';\nimport { syncCaptionView, syncDestinationView } from './sync.js';\nimport { shareKitActionEventName } from './types.js';\n\ntype DestinationLists = NonNullable<ReturnType<typeof getDestinationLists>>;\n\ntype SettledAction = 'save' | 'share' | 'share-link' | 'share-text';\n\nconst iconIntentEvents = ['focusin', 'pointerdown', 'pointerover'] as const;\n\nconst outcomeMessages = {\n\terror: 'error',\n\tretry: 'retry',\n\tsaved: 'saved',\n\tunsaved: 'saveError',\n} as const satisfies Partial<Record<ShareOutcome, keyof ShareKitStrings<string>>>;\n\nlet dialogCount = 0;\n\nfunction isKeyOf<Key extends string>(record: Record<Key, unknown>, key: string): key is Key {\n\treturn Object.hasOwn(record, key);\n}\n\n// Server rendering has no `HTMLElement`; the stand-in lets the module load there and is never constructed\nconst BaseElement =\n\ttypeof HTMLElement === 'undefined' ? (Object as unknown as typeof HTMLElement) : HTMLElement;\n\nexport class ShareKitElement extends BaseElement {\n\tprotected readonly catalogue: ReadonlyMap<string, ShareKitDestination<string>> = new Map();\n\tprotected readonly iconSource = new ShareIconSource({});\n\n\t#abortController: AbortController | undefined;\n\t#actions = {\n\t\tclose: () => {\n\t\t\tthis.#parts?.dialog.close();\n\t\t},\n\t\tcopy: (button: HTMLElement, tile?: HTMLElement) => {\n\t\t\tif (!tile) return;\n\n\t\t\tthis.#track('copy', tile);\n\t\t\tvoid this.#feedback?.copyImage(this.#files?.load(tile) ?? Promise.resolve(undefined), button);\n\t\t},\n\t\t'copy-caption': (button: HTMLElement) => {\n\t\t\tthis.#track('copy-caption');\n\t\t\tvoid this.#copyCaption(button);\n\t\t},\n\t\t'copy-link': (button: HTMLElement) => {\n\t\t\tthis.#track('copy-link');\n\t\t\tvoid this.#feedback?.copyText(this.#payload?.url ?? '', button);\n\t\t},\n\t\tdestination: (button: HTMLElement) => {\n\t\t\tconst destination = this.#getRendered(button.dataset.shareKitDestination);\n\n\t\t\tif (!destination) return;\n\n\t\t\tthis.#selectDestination(destination);\n\t\t\tthis.#track('destination');\n\t\t},\n\t\tmore: (button: HTMLElement) => {\n\t\t\tthis.#showMore(button);\n\t\t},\n\t\tprimary: () => {\n\t\t\tthis.#primaryActions[this.#getPrimaryAction()]();\n\t\t},\n\t\tqr: () => {\n\t\t\tvoid this.#openQr();\n\t\t},\n\t\treset: () => {\n\t\t\tthis.#isCaptionEdited = false;\n\t\t\tthis.#syncDestination();\n\t\t},\n\t\tsave: (_button: HTMLElement, tile?: HTMLElement) => {\n\t\t\tif (tile) void this.#settle('save', this.#files?.save(tile), tile);\n\t\t},\n\t\tshare: (_button: HTMLElement, tile?: HTMLElement) => {\n\t\t\tif (tile) void this.#settle('share', this.#files?.share([tile]), tile);\n\t\t},\n\t};\n\t#capabilities = new Set<ShareCapability>();\n\t#destination: ShareKitDestination<string> | undefined;\n\t#feedback: ShareFeedback | undefined;\n\t#files: ShareAssetFiles | undefined;\n\t#isCaptionEdited = false;\n\t#isIconsRequested = false;\n\t#isOver = false;\n\t#lists: DestinationLists | undefined;\n\t#parts: ShareKitParts | undefined;\n\t#payload: ShareKitPayload<string> | undefined;\n\t#primaryActions = {\n\t\t'copy-caption': () => {\n\t\t\tthis.#track('copy-caption');\n\t\t\tvoid this.#copyCaption();\n\t\t},\n\t\t// The composer can't always take the text, so it rides along on the clipboard\n\t\t'open-composer': () => {\n\t\t\tconst href = this.#getComposerUrl();\n\n\t\t\tif (!href) return;\n\n\t\t\tthis.#track('open-composer');\n\t\t\tvoid this.#copyCaption();\n\t\t\topenComposer(href);\n\t\t},\n\t\t// Both start inside the tap, before any await, or the browser refuses one of them\n\t\t'share-image': () => {\n\t\t\tconst tile = this.#getSuggestedAsset();\n\n\t\t\tif (!tile) return;\n\n\t\t\tvoid this.#copyCaption();\n\t\t\tvoid this.#settle('share', this.#files?.share([tile]), tile);\n\t\t},\n\t\t// The platform's app drops shared text too, so the caption rides on the clipboard as with an image\n\t\t'share-link': () => {\n\t\t\tvoid this.#copyCaption();\n\t\t\tvoid this.#settle('share-link', shareData({ url: this.#getUrl() }));\n\t\t},\n\t\t'share-text': () => {\n\t\t\tconst text = this.#parts?.caption.value;\n\n\t\t\tif (text) void this.#settle('share-text', shareData({ text }));\n\t\t},\n\t} satisfies Record<ShareKitActionKind, () => void>;\n\t#qr: ReturnType<typeof createShareQr>;\n\t#strings: ShareKitStrings<string> = shareKitStringDefaults;\n\n\tconnectedCallback() {\n\t\tif (this.#abortController) return;\n\n\t\tconst payload = readSharePayload(this);\n\n\t\tif (!payload) {\n\t\t\tthis.#retryWhenParsed();\n\t\t\treturn;\n\t\t}\n\n\t\tconst lists = getDestinationLists(payload.settings, this.catalogue);\n\n\t\tif (!lists) return;\n\n\t\tthis.#abortController = new AbortController();\n\t\tthis.#lists = lists;\n\t\tthis.#payload = { ...payload, assets: getShareAssets(payload.assets) };\n\t\tthis.#strings = getShareStrings(payload.strings ?? {}, new Set(this.catalogue.keys()));\n\t\tthis.#feedback = new ShareFeedback(() => this.#parts?.status, this.#strings);\n\n\t\tconst { signal } = this.#abortController;\n\n\t\tthis.#capabilities = new Set(getShareCapabilities(this.dataset.can));\n\t\tthis.#files = new ShareAssetFiles({\n\t\t\tcanShare: this.#capabilities.has('files'),\n\t\t\tgetSource: (tile) => this.#parts?.assets.get(tile),\n\t\t\tsignal,\n\t\t});\n\n\t\tthis.addEventListener('click', this.#handleClick, { signal });\n\t\tthis.addEventListener('input', this.#handleInput, { signal });\n\t\tthis.addEventListener('keydown', this.#handleKeydown, { signal });\n\t\tthis.addEventListener('error', this.#handlePreviewError, { capture: true, signal });\n\t\tthis.addEventListener('pointerover', ({ target }) => this.#files?.warm(target), { signal });\n\n\t\tfor (const type of iconIntentEvents) {\n\t\t\tthis.addEventListener(type, this.#handleTriggerIntent, { signal });\n\t\t}\n\t\twindow.addEventListener('hashchange', this.#handleHashChange, { signal });\n\t\t// The trigger ships disabled so a tap before this runs isn't silently lost\n\t\tthis.querySelector('[data-share-kit-trigger]')?.toggleAttribute('disabled', false);\n\n\t\t// Deferred so a listener added after `defineShareKit()` in the same task still hears `open`\n\t\tqueueMicrotask(() => {\n\t\t\tif (!signal.aborted && isOpenHash(payload.settings.openHash)) this.#open();\n\t\t});\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.#parts?.dialog.remove();\n\t\tthis.#parts = undefined;\n\t\tthis.#qr = undefined;\n\t\tthis.#abortController?.abort();\n\t\tthis.#abortController = undefined;\n\t\tthis.#feedback?.dispose();\n\t\tthis.#feedback = undefined;\n\t\tthis.#files?.dispose();\n\t\tthis.#files = undefined;\n\t\tthis.#destination = undefined;\n\t\tthis.#lists = undefined;\n\t\tthis.#isCaptionEdited = false;\n\t\tthis.#isIconsRequested = false;\n\t\tthis.#isOver = false;\n\t}\n\n\t// A failed write selects the caption, so it is ready to copy by hand once the reader is back\n\tasync #copyCaption(button?: HTMLElement) {\n\t\tconst caption = this.#parts?.caption;\n\n\t\tif (caption) await this.#feedback?.copyText(caption.value, button, caption);\n\t}\n\n\t#dispatch(detail: ShareKitActionDetail) {\n\t\tthis.dispatchEvent(\n\t\t\tnew CustomEvent(shareKitActionEventName, { bubbles: true, composed: true, detail }),\n\t\t);\n\t}\n\n\t#getAssets() {\n\t\treturn (this.#parts?.tiles ?? []).filter((tile) => tile.dataset.shareKitState !== 'failed');\n\t}\n\n\t// `?:` rejects an explicit `undefined`, so the optional fields are spread in only when present\n\t#getComposerUrl() {\n\t\tconst parts = this.#parts;\n\t\tconst payload = this.#payload;\n\t\tconst composer = this.#destination?.composer;\n\n\t\tif (!parts || !payload || !composer) return;\n\n\t\tconst suggested = this.#getSuggestedAsset();\n\t\tconst media = suggested ? parts.assets.get(suggested)?.src : undefined;\n\n\t\treturn composer({\n\t\t\t...(payload.description === undefined ? {} : { description: payload.description }),\n\t\t\tdevice: this.#getDevice(),\n\t\t\t...(media === undefined ? {} : { media: new URL(media, location.href).href }),\n\t\t\ttext: parts.caption.value,\n\t\t\ttitle: payload.title,\n\t\t\turl: this.#getUrl(),\n\t\t});\n\t}\n\n\t#getDetail(action: ShareKitAction, tile?: HTMLElement) {\n\t\tif (!this.#destination) return;\n\n\t\tconst detail: ShareKitActionDetail = { action, destination: this.#destination.id };\n\n\t\tif (tile?.dataset.shareKitAsset) detail.asset = tile.dataset.shareKitAsset;\n\n\t\treturn detail;\n\t}\n\n\t#getDevice() {\n\t\treturn this.#capabilities.has('mobile') ? 'mobile' : 'desktop';\n\t}\n\n\t#getPrimaryAction() {\n\t\tconst destination = this.#destination;\n\n\t\tif (!destination) return 'copy-caption';\n\n\t\treturn getPrimaryAction(destination.actions[this.#getDevice()], {\n\t\t\tcanShareFiles: this.#capabilities.has('files'),\n\t\t\tcanShareText: this.#capabilities.has('link'),\n\t\t\tcomposerUrl: this.#getComposerUrl(),\n\t\t\thasSuggestedImage: this.#getSuggestedAsset() !== undefined,\n\t\t});\n\t}\n\n\t#getRendered(id: string | undefined) {\n\t\tconst lists = this.#lists;\n\n\t\tif (!id || !lists) return;\n\n\t\treturn [...lists.main, ...lists.more].find((destination) => destination.id === id);\n\t}\n\n\t#getSuggestedAsset() {\n\t\tconst parts = this.#parts;\n\t\tconst destination = this.#destination;\n\n\t\tif (!parts || !destination) return;\n\n\t\tconst tiles = this.#getAssets();\n\t\tconst assets = tiles.flatMap((tile) => parts.assets.get(tile) ?? []);\n\t\tconst suggested = getSuggestedImage(assets, destination.images);\n\n\t\treturn tiles.find((tile) => parts.assets.get(tile) === suggested);\n\t}\n\n\t#getUrl() {\n\t\tconst payload = this.#payload;\n\t\tconst destination = this.#destination;\n\n\t\tif (!payload || !destination) return payload?.url ?? '';\n\n\t\treturn getDestinationUrl(payload.url, destination, payload.settings.utmMedium);\n\t}\n\n\t#handleClick = (event: MouseEvent) => {\n\t\tif (!(event.target instanceof Element)) return;\n\n\t\tif (event.target.closest('[data-share-kit-trigger]')) {\n\t\t\tthis.#open();\n\t\t\treturn;\n\t\t}\n\n\t\tconst button = event.target.closest<HTMLElement>('[data-share-kit-action]');\n\t\tconst action = button?.dataset.shareKitAction;\n\n\t\tif (!button || !action || !isKeyOf(this.#actions, action)) return;\n\n\t\tthis.#actions[action](\n\t\t\tbutton,\n\t\t\tbutton.closest<HTMLElement>('[data-share-kit-asset]') ?? undefined,\n\t\t);\n\t};\n\n\t#handleClose = () => {\n\t\tclearOpenHash(this.#payload?.settings.openHash);\n\t};\n\n\t#handleHashChange = () => {\n\t\tif (isOpenHash(this.#payload?.settings.openHash)) this.#open();\n\t};\n\n\t#handleInput = (event: Event) => {\n\t\tif (event.target === this.#parts?.caption) this.#isCaptionEdited = true;\n\n\t\tthis.#syncCaption();\n\t};\n\n\t#handleKeydown = (event: KeyboardEvent) => {\n\t\tconst move = radioKeys[event.key];\n\n\t\tif (!move || !(event.target instanceof HTMLElement) || event.target.role !== 'radio') return;\n\n\t\tconst radios = [...this.querySelectorAll<HTMLElement>('[role=\"radio\"]:not([hidden])')];\n\t\tconst next = radios[move(radios.indexOf(event.target), radios.length)];\n\t\tconst destination = this.#getRendered(next?.dataset.shareKitDestination);\n\n\t\tif (!next || !destination) return;\n\n\t\tevent.preventDefault();\n\t\tthis.#selectDestination(destination);\n\t\tnext.focus();\n\t};\n\n\t#handlePreviewError = (event: Event) => {\n\t\tif (!(event.target instanceof HTMLImageElement)) return;\n\n\t\tconst tile = event.target.closest<HTMLElement>('[data-share-kit-asset]');\n\n\t\tif (!tile) return;\n\n\t\ttile.dataset.shareKitState = 'failed';\n\t\tthis.#syncDestination();\n\t};\n\n\t#handleTriggerIntent = ({ target }: Event) => {\n\t\tif (target instanceof Element && target.closest('[data-share-kit-trigger]')) this.#loadIcons();\n\t};\n\n\t#loadIcons() {\n\t\tconst signal = this.#abortController?.signal;\n\n\t\tif (!signal || this.#isIconsRequested) return;\n\n\t\tthis.#isIconsRequested = true;\n\t\tvoid this.iconSource.load().then((icons) => {\n\t\t\tif (!signal.aborted && this.#parts) patchIcons(this.#parts.dialog, icons);\n\t\t});\n\t}\n\n\t#open() {\n\t\tthis.#loadIcons();\n\n\t\tconst parts = this.#parts ?? this.#render();\n\n\t\tif (!parts || parts.dialog.open) return;\n\n\t\tparts.dialog.showModal();\n\t\t// Focusing the heading lets a screen reader start from the dialog's name\n\t\tparts.heading.focus();\n\t\tthis.#track('open');\n\t\t// Synced again once open, since a status written to a closed dialog goes unannounced\n\t\tthis.#isOver = false;\n\t\tthis.#syncCaption();\n\t}\n\n\tasync #openQr() {\n\t\tthis.#track('qr');\n\n\t\ttry {\n\t\t\tawait this.#qr?.open();\n\t\t} catch {\n\t\t\tthis.#feedback?.announce(this.#strings.error);\n\t\t}\n\t}\n\n\t// The primary button shares the suggested image on a phone, so only that file is fetched ahead\n\t#prefetch() {\n\t\tif (!this.#capabilities.has('files') || !this.#capabilities.has('mobile')) return;\n\n\t\tconst tile = this.#getSuggestedAsset();\n\n\t\tif (tile) void this.#files?.load(tile);\n\t}\n\n\t#render() {\n\t\tconst payload = this.#payload;\n\t\tconst lists = this.#lists;\n\t\tconst signal = this.#abortController?.signal;\n\n\t\tif (!payload || !lists || !signal) return;\n\n\t\tconst { main, more } = lists;\n\t\tconst { icons, isLoading } = this.iconSource;\n\n\t\tdialogCount += 1;\n\n\t\tconst id = `share-kit-${String(dialogCount)}`;\n\t\tconst parts = renderShareKit({\n\t\t\tcapabilities: this.#capabilities,\n\t\t\tdestinations: main,\n\t\t\tdestinationsMore: more,\n\t\t\ticons,\n\t\t\tid,\n\t\t\tisIconsLoading: isLoading,\n\t\t\tpayload,\n\t\t\tstrings: this.#strings,\n\t\t});\n\n\t\tthis.#qr = createShareQr({\n\t\t\tcapabilities: this.#capabilities,\n\t\t\tcloseIcon: icons.close,\n\t\t\tid: `${id}-qr`,\n\t\t\tpayload,\n\t\t\tsignal,\n\t\t\tstrings: this.#strings,\n\t\t});\n\n\t\tif (this.#qr) parts.dialog.append(this.#qr.dialog);\n\n\t\tparts.dialog.addEventListener('close', this.#handleClose, { signal });\n\t\tpolyfillLightDismiss(parts.dialog, signal);\n\t\tthis.append(parts.dialog);\n\t\tthis.#parts = parts;\n\t\tthis.#destination = main[0];\n\t\tthis.#syncDestination();\n\n\t\treturn parts;\n\t}\n\n\t#report(outcome: ShareOutcome | undefined) {\n\t\tif (outcome && isKeyOf(outcomeMessages, outcome)) {\n\t\t\tthis.#feedback?.announce(this.#strings[outcomeMessages[outcome]]);\n\t\t}\n\t}\n\n\t// A classic script in the head defines the element before its children are parsed\n\t#retryWhenParsed() {\n\t\tif (document.readyState !== 'loading') return;\n\n\t\tdocument.addEventListener(\n\t\t\t'DOMContentLoaded',\n\t\t\t() => {\n\t\t\t\tif (this.isConnected) this.connectedCallback();\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t}\n\n\t// An edited caption keeps the reader's words but swaps in the new destination's tagged link\n\t#selectDestination(destination: ShareKitDestination<string>) {\n\t\tconst previousUrl = this.#getUrl();\n\t\tconst caption = this.#parts?.caption;\n\n\t\tthis.#destination = destination;\n\n\t\tif (caption && this.#isCaptionEdited) {\n\t\t\tconst url = this.#getUrl();\n\n\t\t\tcaption.value = caption.value.replaceAll(previousUrl, () => url);\n\t\t}\n\n\t\tthis.#syncDestination();\n\t}\n\n\t// Read before the await, since the reader can pick another destination while a slow file loads\n\tasync #settle(\n\t\taction: SettledAction,\n\t\tpending: Promise<ShareOutcome> | undefined,\n\t\ttile?: HTMLElement,\n\t) {\n\t\tconst detail = this.#getDetail(action, tile);\n\t\tconst outcome = await pending;\n\n\t\tthis.#report(outcome);\n\n\t\tif (!detail || !outcome) return;\n\n\t\tthis.#dispatch({ ...detail, outcome: outcome === 'unsaved' ? 'error' : outcome });\n\t}\n\n\t#showMore(button: HTMLElement) {\n\t\tconst hidden = [...this.querySelectorAll<HTMLElement>('[role=\"radio\"][hidden]')];\n\n\t\tfor (const radio of hidden) radio.hidden = false;\n\n\t\tbutton.hidden = true;\n\t\thidden[0]?.focus();\n\t}\n\n\t#syncCaption() {\n\t\tconst parts = this.#parts;\n\t\tconst destination = this.#destination;\n\n\t\tif (!parts || !destination) return;\n\n\t\tconst { isOver, message } = syncCaptionView({\n\t\t\tdestination,\n\t\t\tparts,\n\t\t\tprimaryAction: this.#getPrimaryAction(),\n\t\t\tstrings: this.#strings,\n\t\t});\n\n\t\tif (isOver && !this.#isOver && parts.dialog.open) this.#feedback?.announce(message);\n\n\t\tthis.#isOver = isOver;\n\t}\n\n\t#syncDestination() {\n\t\tconst parts = this.#parts;\n\t\tconst payload = this.#payload;\n\t\tconst destination = this.#destination;\n\n\t\tif (!parts || !payload || !destination) return;\n\n\t\tsyncDestinationView({\n\t\t\tassets: this.#getAssets(),\n\t\t\tdestination,\n\t\t\tparts,\n\t\t\tstrings: this.#strings,\n\t\t\tsuggested: this.#getSuggestedAsset(),\n\t\t});\n\n\t\tif (!this.#isCaptionEdited) {\n\t\t\tparts.caption.value = fitCaption(\n\t\t\t\t{ description: payload.description, title: payload.title, url: this.#getUrl() },\n\t\t\t\tdestination,\n\t\t\t\tpayload.locale,\n\t\t\t).text;\n\t\t}\n\n\t\tthis.#syncCaption();\n\t\tthis.#prefetch();\n\t}\n\n\t#track(action: Exclude<ShareKitAction, SettledAction>, tile?: HTMLElement) {\n\t\tconst detail = this.#getDetail(action, tile);\n\n\t\tif (detail) this.#dispatch(detail);\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'share-kit': ShareKitElement;\n\t}\n}\n","import type { ShareKitDestination, ShareKitDestinationIdOf } from './destinations.js';\nimport type { ShareKitIconsOption } from './icons.js';\n\nimport { ShareKitElement } from './element.js';\nimport { ShareIconSource, shareKitInterfaceIconNames } from './icons.js';\n\nexport type ShareKitDestinationList = readonly [\n\tShareKitDestination<string>,\n\t...Array<ShareKitDestination<string>>,\n];\n\nexport interface ShareKitOptions<Destinations extends ShareKitDestinationList> {\n\tdestinations: Destinations;\n\ticons?: ShareKitIconsOption<ShareKitDestinationIdOf<Destinations>>;\n}\n\nconst tagName = 'share-kit';\n\nconst reservedIds = new Set<string>(shareKitInterfaceIconNames);\n\nfunction getCatalogue(destinations: ReadonlyArray<ShareKitDestination<string>>) {\n\tconst catalogue = new Map<string, ShareKitDestination<string>>();\n\n\tfor (const destination of destinations) {\n\t\tif (reservedIds.has(destination.id) || catalogue.has(destination.id)) {\n\t\t\tconsole.error(\n\t\t\t\t`share-kit: destination id \"${destination.id}\" is repeated or reserved for an icon, so <share-kit> is not defined`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tcatalogue.set(destination.id, destination);\n\t}\n\n\treturn catalogue;\n}\n\nfunction warnMissingComposers(destinations: ReadonlyArray<ShareKitDestination<string>>) {\n\tfor (const { actions, composer, id } of destinations) {\n\t\tconst hasComposerAction = [...actions.desktop, ...actions.mobile].includes('open-composer');\n\n\t\tif (hasComposerAction && !composer) {\n\t\t\tconsole.warn(`share-kit: \"${id}\" lists open-composer but has no composer`);\n\t\t}\n\t}\n}\n\nfunction createElementClass(\n\tcatalogue: ReadonlyMap<string, ShareKitDestination<string>>,\n\ticonSource: ShareIconSource,\n) {\n\treturn class extends ShareKitElement {\n\t\tprotected override readonly catalogue = catalogue;\n\t\tprotected override readonly iconSource = iconSource;\n\t};\n}\n\n// Logs rather than throws, since a throw here would stop every other script in the host's entry\n// An element name registers once per page, so the first call's options stand\nexport function defineShareKit<const Destinations extends ShareKitDestinationList>({\n\tdestinations,\n\ticons = {},\n}: ShareKitOptions<Destinations>) {\n\tif (customElements.get(tagName)) {\n\t\tconsole.warn(\n\t\t\t'share-kit: <share-kit> is already defined, so this defineShareKit call is ignored',\n\t\t);\n\t\treturn;\n\t}\n\n\tif (destinations.length === 0) {\n\t\tconsole.error('share-kit: no destinations registered, so <share-kit> is not defined');\n\t\treturn;\n\t}\n\n\tconst catalogue = getCatalogue(destinations);\n\n\tif (!catalogue) return;\n\n\twarnMissingComposers(destinations);\n\tcustomElements.define(tagName, createElementClass(catalogue, new ShareIconSource(icons)));\n}\n"],"mappings":";AAAA,MAAM,aAAa;AAGnB,MAAa,eACZ;AAED,MAAM,yBAAyB;AAE/B,MAAM,oBAAoB,IAAI,KAAK,UAAU,KAAA,GAAW,EACvD,aAAa,WACd,CAAC;AAED,MAAM,cAAc,IAAI,YAAY;AAEpC,MAAM,2BAA2B;CAChC,CAAC,KAAS,GAAO;CACjB,CAAC,MAAS,IAAO;CACjB,CAAC,MAAS,IAAO;CACjB,CAAC,MAAS,IAAO;CACjB,CAAC,OAAS,KAAO;AAClB;AAGA,SAAS,kBAAkB;CAC1B,IAAI;EACH,OAAO,IAAI,OAAO,OAAO,GAAG,mBAAmB,GAAG;CACnD,QAAQ;EACP;CACD;AACD;AAEA,MAAM,eAAe,gBAAgB;AAErC,SAAgB,aAAa,MAAc;CAC1C,OAAO,MAAM,KAAK,kBAAkB,QAAQ,IAAI,IAAI,EAAE,cAAc,OAAO;AAC5E;AAGA,SAAS,iBAAiB,WAAmB;CAC5C,OACC,aAAa,QACZ,aAAa,QAAW,aAAa,QACrC,aAAa,QAAW,aAAa,QACrC,aAAa,QAAW,aAAa;AAExC;AAEA,SAAgB,sBAAsB,MAAc;CACnD,MAAM,YAAY,aAAa,KAAK,UAAU,KAAK,CAAC;CACpD,IAAI,QAAQ;CAEZ,KAAK,MAAM,YAAY,WAAW;EACjC,IAAI,cAAc,KAAK,QAAQ,GAAG;GACjC,SAAS;GACT;EACD;EAEA,KAAK,MAAM,aAAa,UACvB,SAAS,iBAAiB,UAAU,YAAY,CAAC,KAAK,C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,17 @@ share-kit {
|
|
|
138
138
|
border-radius: calc(var(--share-kit-radius) * 0.5);
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
/* Sized before a lazy icon lands, so it shifts nothing */
|
|
142
|
+
.share-kit-icon {
|
|
143
|
+
display: inline-flex;
|
|
144
|
+
flex: none;
|
|
145
|
+
align-items: center;
|
|
146
|
+
justify-content: center;
|
|
147
|
+
width: 24px;
|
|
148
|
+
height: 24px;
|
|
149
|
+
line-height: 1;
|
|
150
|
+
}
|
|
151
|
+
|
|
141
152
|
.share-kit-scroll {
|
|
142
153
|
display: flex;
|
|
143
154
|
flex: 1;
|