social-embeds 0.5.3 → 0.6.1

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 CHANGED
@@ -273,7 +273,7 @@ A component checks an `embed` before using it: its `url` must be the exact URL `
273
273
  | `onError` | `(error: Error) => void` | | Called on invalid input, a script that fails to load, or a post that does not render. Components never throw. |
274
274
  | `...rest` | `ComponentProps<'div'>` | | Passed to the wrapper `div` (`className`, `style`, `data-*`, …). |
275
275
 
276
- Script-based embeds try to render three times, waiting 15 s each time, 1 s and then 2 s apart, before `onError` reports the failure. Telegram, Reddit, Bluesky and Tumblr frames that report no height within 15 s show at their starting height, and `onError` reports it. Frames report their height only once painted, so the 15 s start when the embed comes near the viewport, also with `lazy={false}`.
276
+ Script-based embeds try to render three times, waiting 15 s each time, 1 s and then 2 s apart, before `onError` reports the failure. Iframe embeds get 15 s, counted from when the embed comes near the viewport, also with `lazy={false}`. Telegram, Reddit, Bluesky and Tumblr frames that report no height by then show at their starting height; other frames that have not loaded by then show as they are, such as a frame the browser blocked. `onError` reports both, and a frame that loads or reports its height later still calls `onLoad`.
277
277
 
278
278
  ## Platforms
279
279
 
@@ -454,6 +454,74 @@ URL shapes, each tested against Facebook's plugins on `www.facebook.com`, `faceb
454
454
  - Facebook group posts.
455
455
  - Fetching embed code from oEmbed endpoints, consent gating and HTML sanitising: these stay with the host.
456
456
 
457
+ ## Without React
458
+
459
+ `social-embeds/element` defines `<social-embed>`, a custom element for plain HTML, CMS templates, Vue, Svelte and Angular. It is one self-contained file with no React in it, about 20 KB gzipped.
460
+
461
+ ```html
462
+ <script
463
+ type="module"
464
+ src="https://cdn.jsdelivr.net/npm/social-embeds@0.6.0/dist/element.js"
465
+ integrity="sha384-…"
466
+ crossorigin="anonymous"
467
+ ></script>
468
+
469
+ <social-embed url="https://www.youtube.com/watch?v=jNQXAC9IVRw"></social-embed>
470
+ ```
471
+
472
+ Copy the real `integrity` hash from the file's page on jsDelivr (the package page's "Copy HTML + SRI" button). From npm, import it once: `import 'social-embeds/element'`. Importing defines the tag where `customElements` exists; in Node it does not throw and defines nothing. In a server-rendered app (React or Next.js, Vue or Nuxt, SvelteKit), import it after hydration, in `useEffect` or `onMounted` as the playground's `/element` page does: the upgrade rewrites the element's light DOM, which hydration expects to match the server HTML. The module exports the class as `SocialEmbedElement`.
473
+
474
+ Embed code goes in a `<template>`, which keeps the platform's own `<script>` from running:
475
+
476
+ ```html
477
+ <social-embed max-width="540">
478
+ <template>
479
+ <!-- the platform's embed code, exactly as given -->
480
+ </template>
481
+ </social-embed>
482
+ ```
483
+
484
+ | Attribute / property | Meaning |
485
+ | -------------------------- | ------------------------------------------------------------------------------- |
486
+ | `url` | A post URL. |
487
+ | `width` | A number means pixels; otherwise any CSS length. |
488
+ | `max-width` / `maxWidth` | Pixels: `400` or `400px`. |
489
+ | `height` | Pixels: `400` or `400px`. Reaches only iframe-based platforms, as in React. |
490
+ | `max-height` / `maxHeight` | Pixels: `400` or `400px`. Reaches only iframe-based platforms, as in React. |
491
+ | `eager` | Load at once instead of when near the viewport (the inverse of React's `lazy`). |
492
+
493
+ Each property reflects its attribute, so framework property bindings such as Angular's `[url]` work. `url` and the size properties take a string, and `null` removes the attribute; `eager` takes a boolean.
494
+
495
+ The `html` property takes embed code from script. From a framework, pass embed code this way: a `<template>` the framework renders keeps its children in `childNodes`, not in `content`, where the element reads them. When several inputs are set, `html` wins over the `<template>`, and the `<template>` wins over `url`. Options come only from the embed code, as with `<SocialEmbed>`, and the element renders into the light DOM. The element has no `playerId`, so Dailymotion needs embed code that names a Player ID; a Dailymotion URL alone fires `error`.
496
+
497
+ Child elements other than `<template>` are the placeholder until the embed loads; without any, a neutral skeleton shows. They are read once, when the element first connects; children added later are not a placeholder. If the element connects while the document is still loading, it waits for `DOMContentLoaded` before reading its children.
498
+
499
+ It dispatches `load` (an `Event`) when the platform has rendered, and `error` (an `ErrorEvent`) when it cannot. `error.error` is an `Error` with the same message as React's `onError`. Neither event bubbles, both fire in a microtask, and only while the element is connected.
500
+
501
+ Events dispatch in a microtask after the element connects or changes, so add `load` and `error` listeners before inserting the element, or in the same task. In React, attach them before the element module is imported (as the playground's `/element` page does), or use the React components.
502
+
503
+ ```js
504
+ const embed = document.querySelector('social-embed');
505
+ embed.addEventListener('load', () => console.log('rendered'));
506
+ embed.addEventListener('error', (event) => console.warn(event.error.message));
507
+ embed.html = post.embedCode;
508
+ ```
509
+
510
+ Platform defaults (maximum width, height, rounded corners, placeholder) are shared with the React components, so the element looks the same.
511
+
512
+ Tell Vue and Angular that `social-embed` is a custom element:
513
+
514
+ ```ts
515
+ // Vue, Vite plugin: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag === 'social-embed' } } })
516
+ // Vue, at runtime:
517
+ app.config.compilerOptions.isCustomElement = (tag) => tag === 'social-embed';
518
+
519
+ // Angular: add CUSTOM_ELEMENTS_SCHEMA to the component's (or module's) schemas
520
+ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
521
+
522
+ @Component({ schemas: [CUSTOM_ELEMENTS_SCHEMA] /* … */ })
523
+ ```
524
+
457
525
  ## Next.js
458
526
 
459
527
  The `social-embeds` entry starts with `'use client'`, so its components can be rendered straight from a Server Component, with props that can be serialised:
@@ -0,0 +1,32 @@
1
+ declare const Base: {
2
+ new (): HTMLElement;
3
+ prototype: HTMLElement;
4
+ };
5
+ export declare class SocialEmbedElement extends Base {
6
+ #private;
7
+ static observedAttributes: string[];
8
+ constructor();
9
+ get html(): string | null;
10
+ set html(value: string | null);
11
+ get url(): string | null;
12
+ set url(value: string | null);
13
+ get width(): string | null;
14
+ set width(value: string | null);
15
+ get maxWidth(): string | null;
16
+ set maxWidth(value: string | null);
17
+ get height(): string | null;
18
+ set height(value: string | null);
19
+ get maxHeight(): string | null;
20
+ set maxHeight(value: string | null);
21
+ get eager(): boolean;
22
+ set eager(value: boolean | null | undefined);
23
+ connectedCallback(): void;
24
+ disconnectedCallback(): void;
25
+ attributeChangedCallback(): void;
26
+ }
27
+ declare global {
28
+ interface HTMLElementTagNameMap {
29
+ 'social-embed': SocialEmbedElement;
30
+ }
31
+ }
32
+ export {};
@@ -0,0 +1 @@
1
+ const e=`autoplay *; encrypted-media *; fullscreen *; clipboard-write`,t=`allow-forms allow-popups allow-same-origin allow-scripts allow-storage-access-by-user-activation allow-top-navigation-by-user-activation`;function n(n){let r=n.url.slice(23),i=r.includes(`/song/`)||r.includes(`?i=`);return{kind:`iframe`,src:`https://embed.music.apple.com${r}`,title:`Apple Music player`,allow:e,sandbox:t,ratio:{width:16,height:9},height:n.size?.height??(i?175:450),maxWidth:660,borderRadius:10}}function r(n){let r=n.url.slice(26);return{kind:`iframe`,src:`https://embed.podcasts.apple.com${r}`,title:`Apple Podcasts player`,allow:e,sandbox:t,ratio:{width:16,height:9},height:n.size?.height??(r.includes(`?i=`)?160:450),maxWidth:640,borderRadius:12}}function i(e,t){return Object.entries(e).filter(([e])=>!t.includes(e.toLowerCase()))}function a(...e){let t=/* @__PURE__ */ new Map;for(let n of e)for(let[e,r]of n??[])t.set(e,String(r));let n=[...t].map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`);return n.length>0?`?${n.join(`&`)}`:``}function o(e,t){let n=[];for(let[r,i]of Object.entries(t)){let t=e[r];typeof t==`boolean`?n.push([i,+!!t]):(typeof t==`string`||typeof t==`number`)&&n.push([i,t])}return n}const s={origin:`https://embed.bsky.app`,read(e){let t=e?.height;return typeof t==`number`?t:void 0}};function c(e,t){let n=t.colorMode??e.options.colorMode;return{kind:`iframe`,src:`https://embed.bsky.app/embed/${e.id}${a(typeof n==`string`?[[`colorMode`,n]]:void 0)}`,title:`Bluesky post`,allow:``,scrolling:`no`,ratio:{width:1,height:1},messageHeight:s,startHeight:300,maxWidth:600,fallbackHtml:e.fallbackHtml}}const l=/^x[a-z0-9]{3,12}$/;function u(e,t){let{playerId:n,mute:r,startTime:o,loop:s}=t,{playerId:c,...u}=e.options,d=n??c;if(d===void 0)return{kind:`error`,message:`social-embeds: a Dailymotion embed needs a Player ID: pass playerId to DailymotionEmbed`};if(typeof d!=`string`||!l.test(d))return{kind:`error`,message:`social-embeds: not a Dailymotion Player ID: ${String(d)}`};let f=[];return r!==void 0&&f.push([`mute`,String(r)]),o!==void 0&&f.push([`startTime`,o]),s!==void 0&&f.push([`loop`,String(s)]),{kind:`iframe`,src:`https://geo.dailymotion.com/player/${d}.html${a([[`video`,e.id]],i(u,[`video`,`playlist`]),f)}`,title:`Dailymotion video player`,allow:`autoplay; fullscreen; picture-in-picture; web-share`,ratio:{width:16,height:9},size:e.size}}const d=15e3,f=/* @__PURE__ */ new Map;function p(e){if(typeof document>`u`)return Promise.reject(/* @__PURE__ */ Error(`social-embeds: platform scripts load only in the browser`));let t=f.get(e.key);return t||(t=m(e).catch(t=>{throw f.delete(e.key),t}),f.set(e.key,t)),t}async function m(e){e.isPresent()||await([...document.querySelectorAll(`script[src]`)].some(t=>e.isOwn(t.src))?v(e):g(e)),await e.whenPresent?.()}var h=class extends Error{};async function g(e){let t=e.readyCallback?.();for(let t=1;;t++)try{let n=await _(e);if(t>=3||!e.skipped?.())break;n.remove()}catch(e){if(!(e instanceof h)||t>=3)throw e;await b(1e3*2**(t-1))}await(t?y(t,`${e.url} did not report ready`):v(e))}async function _(e){let t=e.prepare?.(),n=document.createElement(`script`),r=new Promise((t,r)=>{n.src=e.url,n.async=!0,e.crossOrigin&&(n.crossOrigin=e.crossOrigin),n.addEventListener(`load`,()=>{t()}),n.addEventListener(`error`,()=>{n.remove(),r(new h(`social-embeds: could not load ${e.url}`))}),document.head.appendChild(n)});try{await y(r,`${e.url} did not load`)}finally{t?.()}return n}function v(e){return new Promise((t,n)=>{let r=Date.now()+d,i=()=>{e.isPresent()?t():Date.now()>=r?n(/* @__PURE__ */ Error(`social-embeds: ${e.url} did not initialise`)):setTimeout(i,50)};i()})}function y(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>{r(/* @__PURE__ */ Error(`social-embeds: ${t}`))},d);e.then(()=>{clearTimeout(i),n()},e=>{clearTimeout(i),r(e instanceof Error?e:Error(String(e)))})})}function b(e){return new Promise(t=>setTimeout(t,e))}const x=()=>window,ee=`v26.0`,te=/^[a-z]{2,3}_[A-Z]{2}$/;function ne(e){return()=>{let t=x().instgrm?.Embeds;return t?.registeredEmbedSDKs?.[e]===!0&&typeof t.process==`function`}}const re={key:`x`,url:`https://platform.twitter.com/widgets.js`,isOwn:e=>/^https?:\/\/platform\.(?:twitter|x)\.com\/widgets\.js(?:[?#]|$)/.test(e),isPresent:()=>typeof x().twttr?.widgets?.load==`function`,whenPresent:()=>new Promise(e=>{let t=x().twttr?.ready;t?t(()=>{e()}):e()})};function ie(){let e=x().FB;return!e||e.__buffer?()=>{}:(e.__buffer=!0,()=>{delete e.__buffer})}function ae(e){let t=ne(e);return()=>{let e=x().FB;return!t()&&e!==void 0&&!e.__buffer}}const oe={key:`instagram`,url:`https://www.instagram.com/embed.js`,isOwn:e=>/^https?:\/\/www\.instagram\.com\/embed\.js(?:[?#]|$)/.test(e),isPresent:ne(`instagram`),prepare:ie,skipped:ae(`instagram`)},se={key:`threads`,url:`https://www.threads.com/embed.js`,isOwn:e=>/^https?:\/\/www\.threads\.(?:com|net)\/embed\.js(?:[?#]|$)/.test(e),isPresent:ne(`threads`),prepare:ie,skipped:ae(`threads`)};function ce(e){return{key:`facebook`,url:`https://connect.facebook.net/${e}/sdk.js#xfbml=0&version=${ee}`,crossOrigin:`anonymous`,isOwn:e=>/^https?:\/\/connect\.facebook\.net\/[a-z]{2,3}_[A-Z]{2}\/(?:sdk(?:\/debug)?|all)\.js(?:[?#]|$)/.test(e),isPresent:()=>typeof x().FB?.XFBML?.parse==`function`,readyCallback:()=>new Promise(e=>{let t=x().fbAsyncInit;x().fbAsyncInit=()=>{t?.(),e()}})}}const le={key:`pinterest`,url:`https://assets.pinterest.com/js/pinit_main.js`,isOwn:e=>/^https?:\/\/assets\.pinterest\.com\/js\/pinit(?:_main)?\.js(?:[?#]|$)/.test(e),isPresent:()=>typeof x().PinUtils?.build==`function`};function S(e,{locale:t=`en_US`}={}){switch(e){case`x`:return p(re);case`instagram`:return p(oe);case`threads`:return p(se);case`pinterest`:return p(le);case`facebook`:return te.test(t)?p(ce(t)):Promise.reject(/* @__PURE__ */ Error(`social-embeds: invalid Facebook locale "${t}"`))}}const C=()=>window;function w(e,t,n){if(t(e))return n(),()=>{};let r=new MutationObserver(()=>{t(e)&&(r.disconnect(),n())});return r.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`class`,`style`,`height`]}),()=>{r.disconnect()}}function T(e,t){let n=e.querySelector(`blockquote`);n&&!n.hasAttribute(`class`)&&n.classList.add(t)}function ue(e){return[...e.querySelectorAll(`iframe`)].some(e=>Number.parseFloat(e.style.height)>0)}const de={load:()=>S(`x`),render(e,t){let n=C().twttr,r=n=>{n.target instanceof Node&&e.contains(n.target)&&t()};n?.events?.bind?.(`rendered`,r);let i=w(e,ue,t);return T(e,`twitter-tweet`),n?.widgets?.load?.(e),()=>{n?.events?.unbind?.(`rendered`,r),i()}}};function fe(){let e=C().instgrm?.Embeds?.process;if(!e)throw Error(`social-embeds: instgrm.Embeds.process is missing`);e()}const pe={load:()=>S(`instagram`),render(e,t){let n=w(e,e=>e.querySelector(`iframe.instagram-media-rendered`)!==null,t);return T(e,`instagram-media`),fe(),n}},me={load:()=>S(`threads`),render(e,t){let n=w(e,e=>e.querySelector(`iframe`)!==null&&e.querySelector(`blockquote`)===null,t);return T(e,`text-post-media`),fe(),n}},he=/* @__PURE__ */ new Map;function ge(e){let t=he.get(e);return t||(t={load:()=>S(`facebook`,{locale:e}),render(e,t){let n=C().FB,r=n?.XFBML?.parse;if(!n||!r)throw Error(`social-embeds: FB.XFBML.parse is missing`);let i=()=>{r(e,t)};try{i()}catch(e){if(!(e instanceof Error)||!/init not called/.test(e.message))throw e;n.init?.({xfbml:!1,version:ee}),i()}return()=>{}}},he.set(e,t)),t}const _e={load:()=>S(`pinterest`),render(e,t){let n=C().PinUtils?.build;if(!n)throw Error(`social-embeds: PinUtils.build is missing`);let r=w(e,e=>e.querySelector(`span[data-pin-id]`)!==null,t),i=e.querySelector(`a`);return i&&!i.hasAttribute(`data-pin-do`)&&i.setAttribute(`data-pin-do`,`embedPin`),n(e),r}},ve=/* @__PURE__ */ new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`source`,`track`,`wbr`]),ye=/* @__PURE__ */ new Map([[`script`,/<\/script\s*>/giu],[`style`,/<\/style\s*>/giu]]),E=/<([a-zA-Z][a-zA-Z0-9-]*)/y,be=/\s+([^\s"'>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/y,D=/\s*(\/?)>/y,O=/<\/([a-zA-Z][a-zA-Z0-9-]*)\s*>/y,xe=/* @__PURE__ */ new Map([[`amp`,`&`],[`lt`,`<`],[`gt`,`>`],[`quot`,`"`],[`apos`,`'`],[`nbsp`,`\xA0`]]);function Se(e){let t={type:`element`,tag:``,attrs:/* @__PURE__ */ new Map,children:[]},n=[t],r=0;for(;r<e.length;){let i=n[n.length-1]??t,a=e.indexOf(`<`,r),o=a===-1?e.length:a;if(o>r&&i.children.push({type:`text`,raw:e.slice(r,o)}),a===-1)break;if(e.startsWith(`<!--`,a)){let t=e.indexOf(`-->`,a+4);if(t===-1)return null;i.children.push({type:`comment`}),r=t+3;continue}O.lastIndex=a;let s=O.exec(e);if(s){if(i===t||i.tag!==s[1]?.toLowerCase())return null;n.pop(),r=O.lastIndex;continue}let c=Ce(e,a);if(!c)return null;let{element:l}=c;i.children.push(l),r=c.end;let u=c.selfClosing?void 0:ye.get(l.tag);if(u){u.lastIndex=r;let t=u.exec(e);if(!t)return null;t.index>r&&l.children.push({type:`text`,raw:e.slice(r,t.index)}),r=u.lastIndex}else if(!c.selfClosing&&!ve.has(l.tag)){if(n.length>100)return null;n.push(l)}}return n.length===1?t.children:null}function Ce(e,t){E.lastIndex=t;let n=E.exec(e)?.[1];if(n===void 0)return null;let r=/* @__PURE__ */ new Map,i=E.lastIndex;for(;;){D.lastIndex=i;let t=D.exec(e);if(t)return{element:{type:`element`,tag:n.toLowerCase(),attrs:r,children:[]},selfClosing:t[1]===`/`,end:D.lastIndex};be.lastIndex=i;let a=be.exec(e);if(!a)return null;let[,o=``,s,c,l]=a,u=o.toLowerCase();r.has(u)||r.set(u,we(s??c??l??``)),i=be.lastIndex}}function we(e){return e.replace(/&(#[0-9]{1,7}|#[xX][0-9a-fA-F]{1,6}|[a-zA-Z]+);/g,(e,t)=>{if(!t.startsWith(`#`))return xe.get(t)??e;let n=t[1]===`x`||t[1]===`X`,r=Number.parseInt(t.slice(n?2:1),n?16:10);return r>0&&r<=1114111&&(r<55296||r>57343)?String.fromCodePoint(r):e})}function k(e,t){return(e.attrs.get(`class`)??``).split(/\s+/).includes(t)}function A(e){let t=[];for(let n of e)n.type===`element`&&t.push(n,...A(n.children));return t}const Te=/* @__PURE__ */ new Set([`href`,`cite`]),Ee=/^https?:\/\//i;function j(e,t){let n=``;for(let r of e){if(r.type===`text`){n+=r.raw;continue}if(r.type!==`element`)continue;let e=t.get(r.tag);if(e){n+=`<${r.tag}`;for(let t of e){let e=typeof t==`string`?t:t.name,i=r.attrs.get(e);i===void 0||typeof t!=`string`&&!t.value.test(i)||Te.has(e)&&!Ee.test(i)||(n+=` ${e}="${M(i)}"`)}n+=`>`,ve.has(r.tag)||(n+=`${j(r.children,t)}</${r.tag}>`)}}return n}function M(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function De(e){let t=``;for(let[n,r]of Object.entries(e))r!==void 0&&(t+=r===!0?` ${n}`:` ${n}="${M(String(r))}"`);return t}function Oe(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=t[r];e!==void 0&&(n[i]=String(e))}return De(n)}function N(e,t){let n={...e};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function P(e){return e!==void 0&&e.trim()!==``}const ke={width:`data-width`,showText:`data-show-text`,lazy:`data-lazy`,allowfullscreen:`data-allowfullscreen`,autoplay:`data-autoplay`,showCaptions:`data-show-captions`},Ae={showText:`show_text`,allowfullscreen:`allowfullscreen`,autoplay:`autoplay`,showCaptions:`show_captions`},je={post:300,video:200};function Me(e){let t=Object.entries(e.options).filter(([e])=>e!==`href`);return{kind:`iframe`,src:`https://www.facebook.com/plugins/video.php${a([[`href`,e.url]],t)}`,title:`Facebook video player`,allow:`autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share`,scrolling:`no`,ratio:{width:16,height:9},size:e.size}}function Ne(e,t){if(e.variant===`iframe`)return Me(e);let n=N(e.options,{showText:t.showText,allowfullscreen:t.allowfullscreen,autoplay:t.autoplay,showCaptions:t.showCaptions}),{size:r}=e;if(e.kind===`video`&&n.showText===!1&&r?.width!==void 0&&r.height!==void 0){let t={};for(let[e,r]of Object.entries(Ae)){let i=n[e];i!==void 0&&(t[r]=i)}return t.width=r.width,t.height=r.height,Me({...e,options:t})}let i=t.locale??(typeof n.locale==`string`?n.locale:`en_US`),a=`<div class="${e.kind===`video`?`fb-video`:`fb-post`}" data-href="${M(e.url)}"${Oe(ke,n)}>${e.fallbackHtml??``}</div>`;return{kind:`script`,key:`${i} ${a}`,markup:a,driver:ge(i),minHeight:je[e.kind],label:`Facebook`,hasFallback:P(e.fallbackHtml),maxWidth:e.kind===`post`?750:void 0}}function Pe(e){return{kind:`iframe`,src:`https://giphy.com/embed/${e.id}`,title:`Giphy GIF`,allow:`fullscreen`,ratio:{width:1,height:1},size:e.size}}function Fe(e,t){let n=N(e.options,{captioned:t.captioned}),r=`<blockquote${De({"data-instgrm-permalink":e.url,"data-instgrm-version":n.version,"data-instgrm-captioned":n.captioned===!0||void 0,style:`width:calc(100% - 2px)`})}>${e.fallbackHtml??``}</blockquote>`;return{kind:`script`,key:r,markup:r,driver:pe,minHeight:680,label:`Instagram`,hasFallback:P(e.fallbackHtml),maxWidth:540}}const Ie=/* @__PURE__ */ new Set([`autoplay`,`muted`]);function Le(e,t){let n=[];return t.autoplay!==void 0&&n.push([`autoplay`,t.autoplay]),t.muted!==void 0&&n.push([`muted`,t.muted]),{kind:`iframe`,src:`https://player.kick.com/${e.id}${a(Object.entries(e.options).filter(([e])=>Ie.has(e)),n)}`,title:`Kick player`,allow:`autoplay; fullscreen`,scrolling:`no`,ratio:{width:16,height:9},size:e.size}}function Re(e,t){let n=new Map(Object.entries(e.options));return t.collapsed===!0&&n.set(`collapsed`,1),t.collapsed===!1&&n.delete(`collapsed`),{kind:`iframe`,src:`https://www.linkedin.com/embed/feed/update/${e.id}${a(n)}`,title:`LinkedIn post`,allow:``,ratio:{width:504,height:670},height:e.size?.height??670,maxWidth:e.size?.width??504}}const ze={width:`data-pin-width`,lang:`data-pin-lang`,terse:`data-pin-terse`},Be={small:236,medium:345,large:600};function Ve(e,t){let n=N(e.options,{width:t.pinWidth}),r=`<a href="${M(e.url)}"${Oe(ze,n)}></a>`;return{kind:`script`,key:r,markup:r,driver:_e,minHeight:270,label:`Pinterest`,hasFallback:!1,maxWidth:Be[String(n.width)]??236}}const He={theme:`theme`,showMedia:`showmedia`,showTitle:`showtitle`,showUsername:`showusername`,locale:`locale`,depth:`depth`},Ue={origin:`https://embed.reddit.com`,read(e){if(typeof e!=`string`)return;let t=JSON.parse(e);return t.type===`resize.embed`&&typeof t.data==`number`?t.data:void 0}};function We(e,t){let n=[];for(let[e,r]of Object.entries(He)){let i=t[e];i!==void 0&&n.push([r,i])}return{kind:`iframe`,src:`https://embed.reddit.com${e.url.slice(22)}${a([[`embed`,!0]],Object.entries(e.options),n)}`,title:`Reddit post`,allow:`clipboard-read; clipboard-write`,sandbox:`allow-scripts allow-same-origin allow-popups`,scrolling:`no`,ratio:{width:1,height:1},messageHeight:Ue,startHeight:e.size?.height??316,maxWidth:640}}function Ge(e){let t=e.options.title;return{kind:`iframe`,src:`${e.url}/embed`,title:typeof t==`string`&&t!==``?t:`Snapchat`,allow:`autoplay; camera; microphone; clipboard-write;`,scrolling:`no`,ratio:{width:416,height:692},size:e.size,maxWidth:416}}const Ke={visual:`visual`,color:`color`,autoPlay:`auto_play`,hideRelated:`hide_related`,showComments:`show_comments`,showUser:`show_user`,showReposts:`show_reposts`,showTeaser:`show_teaser`,showArtwork:`show_artwork`};function qe(e,t){let n=[];for(let[e,r]of Object.entries(Ke)){let i=t[e];i!==void 0&&n.push([r,i])}let r=e.size===void 0;return{kind:`iframe`,src:`https://w.soundcloud.com/player/${a([[`url`,e.url]],r?[[`visual`,!0]]:void 0,i(e.options,[`url`,`secret_token`]),n)}`,title:`SoundCloud player`,allow:`autoplay; encrypted-media`,scrolling:`no`,ratio:{width:16,height:9},height:e.size?.height??400}}const Je=/* @__PURE__ */ new Set([`track`,`episode`]);function Ye(e,t){let n=new URL(e.url).pathname.split(`/`)[1]??``,r=e.kind===`video`,i=a(Object.entries(e.options),t.theme===void 0?void 0:[[`theme`,t.theme]]);return{kind:`iframe`,src:`https://open.spotify.com/embed/${n}/${e.id}${r?`/video`:``}${i}`,title:`Spotify Embed`,allow:`autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture`,ratio:{width:16,height:9},size:r?e.size:void 0,borderRadius:12,height:r?void 0:e.size?.height??(Je.has(n)?152:352)}}const Xe=[[`comment`,`comment`],[`userpic`,`userpic`],[`mode`,`mode`],[`single`,`single`],[`color`,`color`],[`dark`,`dark`],[`darkColor`,`dark_color`]];function Ze(e,t){return typeof t==`boolean`?e===`userpic`?String(t):e===`single`?t?1:void 0:+!!t:typeof t==`string`||typeof t==`number`?t:void 0}const Qe={origin:`https://t.me`,read(e){if(typeof e!=`string`)return;let t=JSON.parse(e);return t.event===`resize`&&typeof t.height==`number`?t.height:void 0}};function $e(e,t){let{userpic:n,color:r,dark:i,darkColor:o}=t,s={...e.options,...n===void 0?{}:{userpic:n},...r===void 0?{}:{color:r},...i===void 0?{}:{dark:i},...o===void 0?{}:{darkColor:o}},c=[[`embed`,1]];for(let[e,t]of Xe){let n=Ze(t,s[e]);n!==void 0&&c.push([t,n])}return{kind:`iframe`,src:`${e.url}${a(c)}`,title:`Telegram post`,allow:``,scrolling:`no`,ratio:{width:1,height:1},messageHeight:Qe,startHeight:300,maxWidth:500}}function et(e,t){let n=N(e.options,{theme:t.theme}),r=`<blockquote${De({"data-text-post-permalink":e.url,"data-text-post-version":n.version??0,id:`ig-tp-${e.id}`,"data-theme":n.theme})}>${e.fallbackHtml??``}</blockquote>`;return{kind:`script`,key:r,markup:r,driver:me,minHeight:240,label:`Threads`,hasFallback:P(e.fallbackHtml),maxWidth:658}}const tt={controls:`controls`,progressBar:`progress_bar`,playButton:`play_button`,volumeControl:`volume_control`,fullscreenButton:`fullscreen_button`,timestamp:`timestamp`,loop:`loop`,autoplay:`autoplay`,musicInfo:`music_info`,description:`description`,rel:`rel`,nativeContextMenu:`native_context_menu`,closedCaption:`closed_caption`,forceMuted:`force_muted`};function nt(e,t){let n=o(t,tt);return{kind:`iframe`,src:`https://www.tiktok.com/player/v1/${e.id}${a(Object.entries(e.options),n)}`,title:`TikTok video player`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share`,ratio:{width:9,height:16},size:e.size,maxWidth:325}}const rt={origin:`https://embed.tumblr.com`,read(e){if(typeof e!=`string`)return;let t=JSON.parse(e),[n]=Array.isArray(t.args)?t.args:[];return t.method===`tumblr-post:sizeChange`&&typeof n==`number`?n:void 0}};function it(e){return{kind:`iframe`,src:`https://embed.tumblr.com/embed/post/${e.url.slice(23).split(`/`)[0]??``}/${e.id}/v2`,title:`Tumblr post`,allow:``,scrolling:`no`,ratio:{width:1,height:1},messageHeight:rt,startHeight:400,maxWidth:540}}const at=[`channel`,`video`,`collection`,`clip`,`parent`];function ot(e,t){let{hostname:n,pathname:r}=new URL(e);if(n===`clips.twitch.tv`)return[`https://clips.twitch.tv/embed`,[`clip`,t]];let i=r.split(`/`)[1];return[`https://player.twitch.tv/`,i===`videos`?[`video`,`v${t}`]:i===`collections`?[`collection`,t]:[`channel`,t]]}function st(e,t){let{autoplay:n,muted:r,time:o}=t,s=[];n!==void 0&&s.push([`autoplay`,String(n)]),r!==void 0&&s.push([`muted`,String(r)]),o!==void 0&&s.push([`time`,o]);let[c,l]=ot(e.url,e.id);return{kind:`iframe`,src:`${c}${a([l],i(e.options,at),s)}`,title:`Twitch player`,allow:``,ratio:{width:16,height:9},size:e.size,hostParam:`parent`}}const ct={autopause:`autopause`,autoplay:`autoplay`,background:`background`,byline:`byline`,color:`color`,controls:`controls`,dnt:`dnt`,keyboard:`keyboard`,loop:`loop`,muted:`muted`,pip:`pip`,playsinline:`playsinline`,portrait:`portrait`,quality:`quality`,speed:`speed`,title:`title`,transparent:`transparent`};function lt(e,t){let{t:n,...r}=t,{t:s,...c}=e.options,l=new URL(e.url).pathname.split(`/`)[2],u=o(r,ct),d=n??s;return{kind:`iframe`,src:`https://player.vimeo.com/video/${e.id}${a(l?[[`h`,l]]:void 0,i(c,[`h`]),u)}${d===void 0?``:`#t=${encodeURIComponent(String(d))}`}`,title:`Vimeo video player`,allow:`autoplay; fullscreen; picture-in-picture; clipboard-write; encrypted-media; web-share`,referrerPolicy:`strict-origin-when-cross-origin`,ratio:{width:16,height:9},size:e.size}}const ut={theme:`data-theme`,conversation:`data-conversation`,cards:`data-cards`,align:`data-align`,lang:`data-lang`,dnt:`data-dnt`,width:`data-width`};function dt(e,t){let n=N(e.options,{...t}),r=e.fallbackHtml??`<a href="${M(e.url)}"></a>`,i=`<blockquote${Oe(ut,n)}>${r}</blockquote>`;return{kind:`script`,key:i,markup:i,driver:de,minHeight:250,label:`X`,hasFallback:P(e.fallbackHtml),maxWidth:550}}const ft={autoplay:`autoplay`,ccLangPref:`cc_lang_pref`,ccLoadPolicy:`cc_load_policy`,color:`color`,controls:`controls`,disablekb:`disablekb`,enablejsapi:`enablejsapi`,end:`end`,fs:`fs`,hl:`hl`,ivLoadPolicy:`iv_load_policy`,list:`list`,listType:`listType`,loop:`loop`,origin:`origin`,playlist:`playlist`,playsinline:`playsinline`,rel:`rel`,start:`start`,widgetReferrer:`widget_referrer`};function pt(e,t){let{nocookie:n,...r}=t,{nocookie:i,...s}=e.options,c=n??i===!0?`https://www.youtube-nocookie.com`:`https://www.youtube.com`,l=o(r,ft);return{kind:`iframe`,src:`${c}/embed/${e.id}${a(Object.entries(s),l)}`,title:`YouTube video player`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share`,referrerPolicy:`strict-origin-when-cross-origin`,ratio:e.url.includes(`/shorts/`)?{width:9,height:16}:{width:16,height:9},size:e.size}}function mt(e){switch(e.platform){case`x`:return dt(e,{});case`instagram`:return Fe(e,{});case`threads`:return et(e,{});case`facebook`:return Ne(e,{});case`tiktok`:return nt(e,{});case`youtube`:return pt(e,{});case`telegram`:return $e(e,{});case`snapchat`:return Ge(e);case`linkedin`:return Re(e,{});case`reddit`:return We(e,{});case`pinterest`:return Ve(e,{});case`spotify`:return Ye(e,{});case`vimeo`:return lt(e,{});case`twitch`:return st(e,{});case`dailymotion`:return u(e,{});case`bluesky`:return c(e,{});case`soundcloud`:return qe(e,{});case`applemusic`:return n(e);case`applepodcasts`:return r(e);case`tumblr`:return it(e);case`kick`:return Le(e,{});case`giphy`:return Pe(e);default:return e.platform}}const ht=/^(?:https?:)?\/\/([^/?#\s@]+)((?:\/[^?#\s]*)?)(?:\?([^#\s]*))?(?:#(\S*))?$/i;function F(e){let t=ht.exec(e.trim());if(!t)return null;let[,n=``,r=``,i=``,a]=t,o=/* @__PURE__ */ new Map;for(let e of i.split(`&`)){if(e===``)continue;let t=e.indexOf(`=`),n=gt(t===-1?e:e.slice(0,t)),r=gt(t===-1?``:e.slice(t+1));if(n===null||r===null)return null;o.has(n)||o.set(n,r)}return{host:n.toLowerCase(),path:r,query:o,...a?{fragment:a}:{}}}function gt(e){try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return null}}function I(e){return e===`true`?!0:e===`false`?!1:/^(?:0|[1-9]\d{0,14})$/.test(e)?Number(e):e}function L(e){return e!==void 0&&/^[1-9]\d{0,5}$/.test(e)?Number(e):void 0}function R(e,t,n){let r={};for(let[i,a]of t){let t=e.attrs.get(i);t!==void 0&&!(a in r)&&(r[a]=n(t))}return r}function z(e){let t=L(e.attrs.get(`width`)),n=L(e.attrs.get(`height`));if(t!==void 0||n!==void 0)return{...t===void 0?{}:{width:t},...n===void 0?{}:{height:n}}}function B(e,t){return t?{...e,size:t}:e}function _t(e,t){if(e.tag!==`div`||e.attrs.size!==1)return null;let[,n]=t.exec(e.attrs.get(`style`)??``)??[];if(n===void 0)return null;let r;for(let t of e.children)if(!(t.type===`text`&&/^\s*$/.test(t.raw))){if(t.type!==`element`||t.tag!==`iframe`||r)return null;r=t}let i=Math.round(Number(n)*100);if(!r||!(i>0&&i<=1e5))return null;let a=vt(1e4,i);return{iframe:r,size:{width:1e4/a,height:i/a}}}function vt(e,t){return t===0?e:vt(t,e%t)}const yt=/^\/([a-z]{2})\/(album|song|playlist)\/(?:[^/]{1,200}\/)?(\d{1,15}|pl\.[A-Za-z0-9-]{1,64})\/?$/,bt=/^\d{1,15}$/;function xt(e,t){if(e?.host!==t)return null;let[,n,r,i]=yt.exec(e.path)??[];if(n===void 0||r===void 0||i===void 0||(r===`playlist`?!i.startsWith(`pl.`):!bt.test(i)))return null;let a=r===`album`?e.query.get(`i`):void 0;return a!==void 0&&!bt.test(a)?null:{kind:`post`,url:`https://music.apple.com/${n}/${r}/${i}${a?`?i=${a}`:``}`,id:a??i,variant:`iframe`}}const St={platform:`applemusic`,parse(e){if(e.tag!==`iframe`)return null;let t=xt(F(e.attrs.get(`src`)??``),`embed.music.apple.com`);if(!t)return null;let{height:n}=z(e)??{};return B({platform:`applemusic`,...t,options:{}},n===void 0?void 0:{height:n})},isOwnScript:()=>!1,match(e){let t=xt(e,`music.apple.com`);return t&&{platform:`applemusic`,...t,options:{}}}},Ct=/^\/([a-z]{2})\/podcast\/(?:[^/]{1,200}\/)?(?:id)?(\d{1,15})\/?$/,wt=/^\d{1,15}$/;function Tt(e,t){if(e?.host!==t)return null;let[,n,r]=Ct.exec(e.path)??[];if(n===void 0||r===void 0)return null;let i=e.query.get(`i`);return i!==void 0&&!wt.test(i)?null:{platform:`applepodcasts`,kind:`post`,url:`https://podcasts.apple.com/${n}/podcast/id${r}${i?`?i=${i}`:``}`,id:i??r,variant:`iframe`}}const Et={platform:`applepodcasts`,parse(e){if(e.tag!==`iframe`)return null;let t=Tt(F(e.attrs.get(`src`)??``),`embed.podcasts.apple.com`);return t&&B({...t,options:{}},z(e))},isOwnScript:()=>!1,match(e){let t=Tt(e,`podcasts.apple.com`);return t&&{...t,options:{}}}},Dt=`(did:(?:plc:[a-z2-7]{24}|web:[a-z0-9.-]{1,253}))`,Ot=`((?!\\.{1,2}(?:/|$))[A-Za-z0-9._~:-]{1,512})`,kt=/* @__PURE__ */ new Set([`bsky.app`,`www.bsky.app`]),At=RegExp(`^/profile/${Dt}/post/${Ot}/?$`),jt=RegExp(`^at://${Dt}/app\\.bsky\\.feed\\.post/${Ot}$`),Mt=/^[a-z2-7]{20,100}$/,Nt=/* @__PURE__ */ new Set([`light`,`dark`,`system`]),Pt=/^(?:https?:)?\/\/embed\.bsky\.app\/static\/embed\.js$/,Ft=/* @__PURE__ */ new Map([[`p`,[`lang`]],[`a`,[`href`]],[`br`,[]]]);function It(e,t){return{platform:`bluesky`,kind:`post`,url:`https://bsky.app/profile/${e}/post/${t}`,id:`${e}/app.bsky.feed.post/${t}`,variant:`iframe`}}function Lt(e){if(!e||!kt.has(e.host))return null;let[,t,n]=At.exec(e.path)??[];return t===void 0||n===void 0?null:It(t,n)}const Rt={platform:`bluesky`,fallback:Ft,parse(e){if(e.tag!==`blockquote`||!k(e,`bluesky-embed`))return null;let[,t,n]=jt.exec(e.attrs.get(`data-bluesky-uri`)??``)??[];if(t===void 0||n===void 0)return null;let r=It(t,n);if(A(e.children).reverse().map(e=>e.tag===`a`?Lt(F(e.attrs.get(`href`)??``)):null).find(e=>e!==null)?.id!==r.id)return null;let i={},a=e.attrs.get(`data-bluesky-cid`);a!==void 0&&Mt.test(a)&&(i.cid=a);let o=e.attrs.get(`data-bluesky-embed-color-mode`);return o!==void 0&&Nt.has(o)&&(i.colorMode=o),{...r,options:i,fallbackHtml:j(e.children,Ft)}},isOwnScript:e=>Pt.test(e),match(e){let t=Lt(e);return t&&{...t,options:{}}}},zt=/^x[a-z0-9]{4,12}$/,Bt=/^x[a-z0-9]{3,12}$/,Vt=/^position:\s*relative;\s*padding-bottom:\s*(\d{1,3}(?:\.\d{1,4})?)%;\s*height:\s*0;\s*overflow:\s*hidden;?$/,Ht=/* @__PURE__ */ new Set([`dailymotion.com`,`www.dailymotion.com`]);function Ut(e,t){return{platform:`dailymotion`,kind:`video`,url:`https://www.dailymotion.com/video/${e}`,id:e,variant:`iframe`,options:t}}function Wt(e){if(e.host!==`geo.dailymotion.com`||e.query.has(`playlist`))return null;let t=/^\/player(?:\/([a-z0-9]+))?\.html$/.exec(e.path);if(!t)return null;let[,n]=t,r=e.query.get(`video`)??``;if(!zt.test(r)||n!==void 0&&!Bt.test(n))return null;let i=Object.fromEntries([...e.query].filter(([e])=>e!==`video`).map(([e,t])=>[e,I(t)]));return n!==void 0&&(i.playerId=n),Ut(r,i)}function Gt(e){if(e.host===`dai.ly`){let t=e.path.replace(/^\/|\/$/g,``);return zt.test(t)?Ut(t,{}):null}if(!Ht.has(e.host))return null;let[,t]=/^(?:\/embed)?\/video\/([a-z0-9]+)\/?$/.exec(e.path)??[];return t!==void 0&&zt.test(t)?Ut(t,{}):null}const Kt={platform:`dailymotion`,parse(e){let t=_t(e,Vt),n=t?.iframe??e;if(n.tag!==`iframe`)return null;let r=F(n.attrs.get(`src`)??``);if(!r)return null;let i=Wt(r)??Gt(r);return i&&B(i,t?.size??z(n))},isOwnScript:()=>!1,match(e){return Wt(e)??Gt(e)}},qt=/* @__PURE__ */ new Set([`facebook.com`,`www.facebook.com`,`m.facebook.com`]),Jt=/* @__PURE__ */ new Set([`facebook.com`,`www.facebook.com`]),V=`https://www.facebook.com`,H=`[A-Za-z0-9.\\-]{1,80}`,Yt=`(?:\\d{1,25}|pfbid[A-Za-z0-9]{10,120})`,Xt=RegExp(`^/(${H})/posts/(${Yt})/?$`),Zt=RegExp(`^/(${H})/photos/([A-Za-z0-9.]{1,40})/(\\d{1,25})/?$`),Qt=RegExp(`^/(${H})/videos/(?:[^/]{1,200}/)?(\\d{1,25})/?$`),$t=/^\/reel\/(\d{1,25})\/?$/,en=/* @__PURE__ */ new Set([`/permalink.php`,`/story.php`]),tn=/* @__PURE__ */ new Set([`/photo.php`,`/photo/`,`/photo`]),nn=RegExp(`^${Yt}$`),U=/^\d{1,25}$/,rn=/^(?:https?:)?\/\/connect\.facebook\.net\/([a-z]{2,3}_[A-Z]{2})\/sdk\.js(?:[?#].*)?$/,an=[[`data-width`,`width`],[`data-show-text`,`showText`],[`data-lazy`,`lazy`],[`data-allowfullscreen`,`allowfullscreen`],[`data-autoplay`,`autoplay`],[`data-show-captions`,`showCaptions`]],on=[[`show_text`,`showText`],[`allowfullscreen`,`allowfullscreen`],[`autoplay`,`autoplay`],[`show_captions`,`showCaptions`]],sn={name:`class`,value:/^fb-xfbml-parse-ignore$/},cn=/* @__PURE__ */ new Map([[`div`,[sn]],[`blockquote`,[`cite`,sn]],[`a`,[`href`]],[`p`,[]]]);function W(e){if(!e||!qt.has(e.host))return null;let{path:t,query:n}=e,[,r,i]=Xt.exec(t)??[];if(r!==void 0&&i!==void 0)return{kind:`post`,id:i,url:`${V}/${r}/posts/${i}`};if(en.has(t)){let e=n.get(`story_fbid`);if(e===void 0||!nn.test(e))return null;let r=n.get(`id`),i=r!==void 0&&U.test(r)?`&id=${r}`:``;return{kind:`post`,id:e,url:`${V}${t}?story_fbid=${e}${i}`}}if(tn.has(t)){let e=n.get(`fbid`);return e===void 0||!U.test(e)?null:{kind:`post`,id:e,url:`${V}${t}?fbid=${e}`}}let[,a,o,s]=Zt.exec(t)??[];if(a!==void 0&&o!==void 0&&s!==void 0)return{kind:`post`,id:s,url:`${V}/${a}/photos/${o}/${s}/`};let[,c,l]=Qt.exec(t)??[];if(c!==void 0&&l!==void 0)return{kind:`video`,id:l,url:`${V}/${c}/videos/${l}/`};if(t===`/watch`||t===`/watch/`||t===`/video.php`){let e=n.get(`v`);return e===void 0||!U.test(e)?null:{kind:`video`,id:e,url:`${V}${t===`/video.php`?t:`/watch/`}?v=${e}`}}let[,u]=$t.exec(t)??[];return u===void 0?null:{kind:`video`,id:u,url:`${V}/reel/${u}`}}function G(e,t,n,r){return{platform:`facebook`,kind:t,url:e.url,id:e.id,variant:n,options:r}}const ln={platform:`facebook`,fallback:cn,parse(e){if(e.tag===`div`){let t=k(e,`fb-post`)?`post`:k(e,`fb-video`)?`video`:null,n=W(F(e.attrs.get(`data-href`)??``));return!t||!n?null:{...G(n,t,`sdk`,R(e,an,I)),fallbackHtml:j(e.children,cn)}}if(e.tag!==`iframe`)return null;let t=F(e.attrs.get(`src`)??``);if(!t||!Jt.has(t.host))return null;let n=W(F(t.query.get(`href`)??``));if(!n)return null;if(t.path===`/plugins/post.php`){let e={},r=t.query.get(`show_text`),i=t.query.get(`width`);return r!==void 0&&(e.showText=I(r)),i!==void 0&&(e.width=I(i)),G(n,`post`,`sdk`,e)}if(t.path===`/plugins/video.php`){let r=I(t.query.get(`show_text`)??``);if(r===!0||r===1){let e={};for(let[n,r]of on){let i=t.query.get(n);i!==void 0&&(e[r]=I(i))}let r=L(t.query.get(`width`)),i=L(t.query.get(`height`));return B(G(n,`video`,`sdk`,{...e,showText:!0}),r===void 0||i===void 0?void 0:{width:r,height:i})}return B(G(n,`video`,`iframe`,Object.fromEntries([...t.query].filter(([e])=>e!==`href`).map(([e,t])=>[e,I(t)]))),z(e))}return null},isOwnScript:e=>rn.test(e),scriptOptions(e){let[,t]=rn.exec(e)??[];return t===void 0?{}:{locale:t}},allowsFbRoot:!0,match(e){let t=W(e);return t&&G(t,t.kind,`sdk`,{})}},K=`([A-Za-z0-9]{6,40})`,q=/* @__PURE__ */ new Set([`giphy.com`,`www.giphy.com`]),un=RegExp(`^/gifs/(?:[A-Za-z0-9-]{0,200}-)?${K}/?$`),dn=RegExp(`^/embed/${K}/?$`),fn=/^media\d?\.giphy\.com$/,pn=RegExp(`^/media/${K}/giphy\\.(?:gif|webp|mp4)$`),mn=/^width:\s*100%;\s*height:\s*0;\s*padding-bottom:\s*(\d{1,3}(?:\.\d{1,4})?)%;\s*position:\s*relative;?$/;function hn(e){return{platform:`giphy`,kind:`video`,url:`https://giphy.com/gifs/${e}`,id:e,variant:`iframe`}}function gn(e){if(e){if(q.has(e.host))return(un.exec(e.path)??dn.exec(e.path))?.[1];if(fn.test(e.host))return pn.exec(e.path)?.[1]}}function _n(e){if(e.tag!==`iframe`)return null;let t=F(e.attrs.get(`src`)??``);if(!t||!q.has(t.host))return null;let[,n]=dn.exec(t.path)??[];return n===void 0?null:hn(n)}function vn(e,t){if(e.tag!==`p`||e.attrs.size!==0)return!1;let[n,...r]=e.children;if(r.length>0||n?.type!==`element`||n.tag!==`a`||n.attrs.size!==1)return!1;let i=F(n.attrs.get(`href`)??``);if(!i||!q.has(i.host)||un.exec(i.path)?.[1]!==t.id)return!1;let[a,...o]=n.children;return o.length===0&&a?.type===`text`&&a.raw.trim()===`via GIPHY`}const yn={platform:`giphy`,parse(e){let t=_t(e,mn),n=t?.iframe??e,r=_n(n);return r?B({...r,options:{}},t?.size??z(n)):null},isOwnScript:()=>!1,isOwnExtra:vn,match(e){let t=gn(e);return t===void 0?null:{...hn(t),options:{}}}},bn=/* @__PURE__ */ new Set([`instagram.com`,`www.instagram.com`]),xn=/^\/(?:([A-Za-z0-9._]{1,30})\/)?(p|reel|reels|tv)\/([A-Za-z0-9_-]{1,64})\/?$/,Sn=/* @__PURE__ */ new Set([`p`,`reel`,`reels`,`tv`]),Cn=/* @__PURE__ */ new Set([`p`,`reel`]),wn=/^(?:https?:)?\/\/www\.instagram\.com\/embed\.js$/,Tn=/* @__PURE__ */ new Map([[`div`,[]],[`a`,[`href`]],[`p`,[]]]);function En(e){if(!e||!bn.has(e.host))return null;let[,t,n,r]=xn.exec(e.path)??[];return n===void 0||r===void 0||t!==void 0&&(Sn.has(t)||!Cn.has(n))?null:{platform:`instagram`,kind:`post`,url:`https://www.instagram.com/${n===`reels`?`reel`:n}/${r}/`,id:r,variant:`sdk`}}const Dn={platform:`instagram`,fallback:Tn,parse(e){if(e.tag!==`blockquote`||!k(e,`instagram-media`))return null;let t=e.attrs.get(`data-instgrm-permalink`),n=t===void 0?A(e.children).reverse().map(e=>e.tag===`a`?En(F(e.attrs.get(`href`)??``)):null).find(e=>e!==null):En(F(t));if(!n)return null;let r={};e.attrs.has(`data-instgrm-captioned`)&&(r.captioned=!0);let i=e.attrs.get(`data-instgrm-version`);return i!==void 0&&(r.version=I(i)),{...n,options:r,fallbackHtml:j(e.children,Tn)}},isOwnScript:e=>wn.test(e),match(e){let t=En(e);return t&&{...t,options:{}}}},On=/* @__PURE__ */ new Set([`kick.com`,`www.kick.com`]),kn=/^\/([A-Za-z0-9_-]{1,32})\/?$/,An=/* @__PURE__ */ new Set([`browse`,`categories`,`category`,`clips`,`video`,`videos`,`following`,`search`,`settings`,`dashboard`,`subscriptions`,`privacy-policy`,`terms-of-service`,`community-guidelines`,`help`]),jn=/* @__PURE__ */ new Set([`autoplay`,`muted`]);function Mn(e,t){if(!e||!t.has(e.host))return null;let[,n]=kn.exec(e.path)??[];if(n===void 0||An.has(n.toLowerCase()))return null;let r=n.toLowerCase();return{platform:`kick`,kind:`video`,url:`https://kick.com/${r}`,id:r,variant:`iframe`}}const Nn=/* @__PURE__ */ new Set([`player.kick.com`]),Pn={platform:`kick`,parse(e){if(e.tag!==`iframe`)return null;let t=F(e.attrs.get(`src`)??``),n=Mn(t,Nn);if(!n||!t)return null;let r=Object.fromEntries([...t.query].filter(([e])=>jn.has(e)).map(([e,t])=>[e,I(t)]));return B({...n,options:r},z(e))},isOwnScript:()=>!1,match(e){let t=Mn(e,On)??Mn(e,Nn);return t&&{...t,options:{}}}},Fn=/^(?:www\.|[a-z]{2}\.)?linkedin\.com$/,In=`(activity|share|ugcPost):(\\d{19})`,Ln=RegExp(`^(?:/embed)?/feed/update/urn:li:${In}/?$`),Rn=/* @__PURE__ */ RegExp(`^/posts/[^/]{1,300}-(activity|share|ugcPost)-(\\d{19})-[A-Za-z0-9_-]{1,8}/?$`),zn=RegExp(`^/embed/feed/update/urn:li:${In}$`);function Bn(e,t,n={}){let r=`urn:li:${e}:${t}`;return{platform:`linkedin`,kind:`post`,url:`https://www.linkedin.com/feed/update/${r}/`,id:r,variant:`iframe`,options:n}}const Vn=e=>e.replace(/%3A/gi,`:`),Hn={platform:`linkedin`,parse(e){if(e.tag!==`iframe`)return null;let t=F(e.attrs.get(`src`)??``);if(t?.host!==`www.linkedin.com`)return null;let[,n,r]=zn.exec(t.path)??[];return n===void 0||r===void 0?null:B(Bn(n,r,Object.fromEntries([...t.query].map(([e,t])=>[e,I(t)]))),z(e))},isOwnScript:()=>!1,match(e){if(!Fn.test(e.host))return null;let t=Vn(e.path),[,n,r]=Ln.exec(t)??Rn.exec(t)??[];return n===void 0||r===void 0?null:Bn(n,r)}},Un=/^(?:(?:www|[a-z]{2})\.)?pinterest\.(?:[a-z]{2,3}|co\.[a-z]{2}|com\.[a-z]{2})$/,Wn=/^\/pin\/(?:[A-Za-z0-9-]{0,200}--)?(\d{1,25})\/?$/,Gn=/^\d{1,25}$/,Kn=/^(?:https?:)?\/\/assets\.pinterest\.com\/js\/pinit(?:_main)?\.js$/,qn=[[`data-pin-width`,`width`],[`data-pin-lang`,`lang`],[`data-pin-terse`,`terse`]];function Jn(e){return{platform:`pinterest`,kind:`post`,url:`https://www.pinterest.com/pin/${e}/`,id:e,variant:`sdk`}}function Yn(e){if(!e||!Un.test(e.host))return null;let[,t]=Wn.exec(e.path)??[];return t===void 0?null:Jn(t)}const Xn={platform:`pinterest`,parse(e){if(e.tag===`a`){if(e.attrs.get(`data-pin-do`)!==`embedPin`||e.children.some(e=>e.type===`element`))return null;let t=Yn(F(e.attrs.get(`href`)??``));return t&&{...t,options:R(e,qn,I)}}if(e.tag!==`iframe`)return null;let t=F(e.attrs.get(`src`)??``);if(t?.host!==`assets.pinterest.com`||t.path!==`/ext/embed.html`)return null;let n=t.query.get(`id`);return n!==void 0&&Gn.test(n)?{...Jn(n),options:{}}:null},isOwnScript:e=>Kn.test(e),match(e){let t=Yn(e);return t&&{...t,options:{}}}},Zn=/* @__PURE__ */ new Set([`reddit.com`,`www.reddit.com`,`old.reddit.com`,`new.reddit.com`]),Qn=/^\/r\/([A-Za-z0-9_]{2,21})\/comments\/([a-z0-9]{1,12})(?:\/([^/]{1,300}))?(?:\/([a-z0-9]{1,16}))?\/?$/,$n=/^(?:https?:)?\/\/embed\.reddit\.com\/widgets\.js$/,er=[`depth`,`style`,`theme`,`showmedia`,`showtitle`,`showedits`,`created`,`locale`,`showusername`,`snippet`].map(e=>[`data-embed-${e}`,e]);function tr(e){if(!e||!Zn.has(e.host))return null;let[,t,n,r,i]=Qn.exec(e.path)??[];if(t===void 0||n===void 0)return null;let a={platform:`reddit`,kind:`post`,variant:`iframe`},o=`https://www.reddit.com/r/${t}/comments/${n}/`;return i===void 0?{...a,url:o,id:n}:r===void 0?null:{...a,url:`${o}comment/${i}/`,id:i}}const nr={platform:`reddit`,parse(e){if(e.tag!==`blockquote`||!k(e,`reddit-embed-bq`))return null;let t=A(e.children).map(e=>e.tag===`a`?tr(F(e.attrs.get(`href`)??``)):null).find(e=>e!==null);if(!t)return null;let n=L(e.attrs.get(`data-embed-height`));return B({...t,options:R(e,er,I)},n===void 0?void 0:{height:n})},isOwnScript:e=>$n.test(e),match(e){let t=tr(e);return t&&{...t,options:{}}}},rr=/* @__PURE__ */ new Set([`snapchat.com`,`www.snapchat.com`]),ir=`([A-Za-z][A-Za-z0-9._-]{1,29})`,ar=RegExp(`^(?:/@${ir})?/spotlight/([A-Za-z0-9_-]{20,120})$`),or=RegExp(`^/(?:@|add/)${ir}$`),sr=/^\/lens\/([0-9a-f]{32}|\d{1,20})$/,cr=RegExp(`^/@${ir}/highlight/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$`),lr=/^(?:https?:)?\/\/www\.snapchat\.com\/embed\.js$/;function ur(e){if(!e||!rr.has(e.host))return null;let t=e.path.replace(/\/$/,``),n={platform:`snapchat`,variant:`iframe`},[,r,i]=ar.exec(t)??[];if(i!==void 0){let e=r===void 0?``:`/@${r}`;return{...n,kind:`video`,url:`https://www.snapchat.com${e}/spotlight/${i}`,id:i}}let[,a]=or.exec(t)??[];if(a!==void 0)return{...n,kind:`post`,url:`https://www.snapchat.com/@${a}`,id:a};let[,o]=sr.exec(t)??[];if(o!==void 0)return{...n,kind:`post`,url:`https://www.snapchat.com/lens/${o}`,id:o};let[,s,c]=cr.exec(t)??[];return s!==void 0&&c!==void 0?{...n,kind:`post`,url:`https://www.snapchat.com/@${s}/highlight/${c}`,id:c}:null}const dr={platform:`snapchat`,parse(e){if(e.tag!==`blockquote`||!k(e,`snapchat-embed`))return null;let t=F(e.attrs.get(`data-snapchat-embed-url`)??``);if(!t?.path.endsWith(`/embed`))return null;let n=ur({...t,path:t.path.slice(0,-6)});if(!n||!A(e.children).filter(e=>e.tag===`a`).every(e=>{let t=ur(F(e.attrs.get(`href`)??``));return t?.kind===n.kind&&t.id===n.id}))return null;let r=e.attrs.get(`data-snapchat-embed-title`),i=L(e.attrs.get(`data-snapchat-embed-width`)),a=L(e.attrs.get(`data-snapchat-embed-height`));return B({...n,options:r===void 0?{}:{title:r}},i===void 0||a===void 0?void 0:{width:i,height:a})},isOwnScript:e=>lr.test(e),match(e){let t=ur(e);return t&&{...t,options:{}}}},fr=/* @__PURE__ */ new Set([`soundcloud.com`,`www.soundcloud.com`,`m.soundcloud.com`]),pr=/^\/(tracks|playlists|users)\/(?:soundcloud%3A(?:tracks|playlists|users)%3A)?(\d{1,15})\/?$/i,mr=`[a-z0-9_-]{1,64}`,hr=`s-[A-Za-z0-9]{1,32}`,gr=RegExp(`^/(${mr})(?:/(sets/${mr}|${mr})(?:/(${hr}))?)?/?$`,`i`),_r=/* @__PURE__ */ new Set([`discover`,`search`,`stream`,`feed`,`you`,`upload`,`charts`,`pages`,`settings`,`messages`,`notifications`,`people`,`stations`,`library`,`terms-of-use`,`signin`]),vr=/* @__PURE__ */ new Set([`likes`,`tracks`,`sets`,`albums`,`reposts`,`popular-tracks`,`followers`,`following`,`comments`,`spotlight`,`toptracks`]),yr=RegExp(`^${hr}$`);function br(e,t){return{platform:`soundcloud`,kind:`post`,url:e,id:t,variant:`iframe`}}function xr(e){if(e?.host!==`api.soundcloud.com`)return null;let[,t,n]=pr.exec(e.path)??[];if(t===void 0||n===void 0)return null;let r=e.query.get(`secret_token`);if(r!==void 0&&!yr.test(r))return null;let i=r===void 0?``:`?secret_token=${r}`;return br(`https://api.soundcloud.com/${t.toLowerCase()}/${n}${i}`,n)}function Sr(e){if(!fr.has(e.host))return null;let[,t,n,r]=gr.exec(e.path)??[];if(t===void 0||_r.has(t.toLowerCase())||n!==void 0&&vr.has(n.toLowerCase()))return null;let i=[t,n,r].filter(Boolean).join(`/`);return br(`https://soundcloud.com/${i}`,i)}const Cr=/* @__PURE__ */ new Set([`href`,`title`,`target`,`style`]);function wr(e){if(e?.type!==`element`||e.tag!==`a`||[...e.attrs.keys()].some(e=>!Cr.has(e)))return!1;let[t,...n]=e.children;return n.length===0&&t?.type===`text`&&fr.has(F(e.attrs.get(`href`)??``)?.host??``)}function Tr(e){if(e.tag!==`div`||e.attrs.size!==1||!e.attrs.has(`style`))return!1;let[t,n,r,...i]=e.children;return i.length===0&&wr(t)&&n?.type===`text`&&/^\s*·\s*$/.test(n.raw)&&wr(r)}const Er={platform:`soundcloud`,parse(e){if(e.tag!==`iframe`)return null;let t=F(e.attrs.get(`src`)??``);if(t?.host!==`w.soundcloud.com`||!/^\/player\/?$/.test(t.path))return null;let n=xr(F(t.query.get(`url`)??``));if(!n)return null;let r=t.query.get(`secret_token`);if(r!==void 0){if(!yr.test(r))return null;n.url.includes(`?`)||(n={...n,url:`${n.url}?secret_token=${r}`})}let i=Object.fromEntries([...t.query].filter(([e])=>e!==`url`&&e!==`secret_token`).map(([e,t])=>[e,I(t)])),{height:a}=z(e)??{};return B({...n,options:i},a===void 0?void 0:{height:a})},isOwnScript:()=>!1,isOwnExtra:Tr,match(e){let t=xr(e)??Sr(e);return t&&{...t,options:{}}}},Dr=/* @__PURE__ */ RegExp(`^(?:/intl-[a-z]{2}(?:-[A-Za-z]{2})?)?(?:/embed)?/(track|album|playlist|artist|episode|show|audiobook|chapter)/([A-Za-z0-9]{22})(/video)?/?$`),Or=/* @__PURE__ */ new Set([`utm_source`,`si`]);function kr(e){if(e?.host!==`open.spotify.com`)return null;let[,t,n,r]=Dr.exec(e.path)??[];return t===void 0||n===void 0?null:{platform:`spotify`,kind:r?`video`:`post`,url:`https://open.spotify.com/${t}/${n}`,id:n,variant:`iframe`,query:e.query}}function Ar(e){return Object.fromEntries([...e].filter(([e])=>!Or.has(e)).map(([e,t])=>[e,I(t)]))}const jr={platform:`spotify`,parse(e){if(e.tag!==`iframe`)return null;let t=F(e.attrs.get(`src`)??``);if(!t?.path.startsWith(`/embed/`))return null;let n=kr(t);if(!n)return null;let{query:r,...i}=n;return B({...i,options:Ar(r)},z(e))},isOwnScript:()=>!1,match(e){let t=kr(e);return t&&{platform:t.platform,kind:`post`,url:t.url,id:t.id,variant:t.variant,options:{}}}},Mr=/* @__PURE__ */ new Set([`t.me`,`telegram.me`,`www.telegram.me`]),Nr=`[A-Za-z][A-Za-z0-9_]{2,31}`,Pr=RegExp(`^(${Nr})/(\\d{1,10})$`),Fr=RegExp(`^/(?:s/)?(${Nr})/(\\d{1,10})/?$`),Ir=/^(?:https?:)?\/\/telegram\.org\/js\/telegram-widget\.js(?:\?\d{1,3})?$/,Lr=[`data-telegram-login`,`data-telegram-discussion`,`data-telegram-share-url`],Rr=[[`data-width`,`width`],[`data-comment`,`comment`],[`data-userpic`,`userpic`],[`data-mode`,`mode`],[`data-color`,`color`],[`data-dark`,`dark`],[`data-dark-color`,`darkColor`]];function zr(e,t,n){return{platform:`telegram`,kind:`post`,url:`https://t.me/${e}/${t}`,id:`${e}/${t}`,variant:`iframe`,options:n}}const Br={platform:`telegram`,parse:()=>null,parseScript(e){if(!Ir.test(e.attrs.get(`src`)??``)||Lr.some(t=>e.attrs.has(t)))return null;let[,t,n]=Pr.exec(e.attrs.get(`data-telegram-post`)??``)??[];if(t===void 0||n===void 0)return null;let r=R(e,Rr,I);return e.attrs.has(`data-single`)&&(r.single=!0),zr(t,n,r)},isOwnScript:e=>Ir.test(e),match(e){if(!Mr.has(e.host))return null;let[,t,n]=Fr.exec(e.path)??[];if(t===void 0||n===void 0)return null;let r={};e.query.has(`single`)&&(r.single=!0);let i=e.query.get(`comment`);return i!==void 0&&/^\d{1,10}$/.test(i)&&(r.comment=Number(i)),zr(t,n,r)}},Vr=/* @__PURE__ */ new Set([`threads.com`,`www.threads.com`,`threads.net`,`www.threads.net`]),Hr=/^\/(?:@[A-Za-z0-9._]{1,30}\/post|t)\/([A-Za-z0-9_-]{1,64})\/?$/,Ur=/^(?:https?:)?\/\/www\.threads\.(?:com|net)\/embed\.js$/,Wr=[[`data-theme`,`theme`],[`data-text-post-version`,`version`]],Gr=/* @__PURE__ */ new Map([[`a`,[`href`]],[`div`,[]]]);function Kr(e){if(!e||!Vr.has(e.host))return null;let[,t]=Hr.exec(e.path)??[];return t===void 0?null:{platform:`threads`,kind:`post`,url:`https://www.threads.com/t/${t}`,id:t,variant:`sdk`}}const qr={platform:`threads`,fallback:Gr,parse(e){if(e.tag!==`blockquote`||!k(e,`text-post-media`))return null;let t=Kr(F(e.attrs.get(`data-text-post-permalink`)??``));if(!t)return null;let n=e.attrs.get(`id`);return n!==void 0&&n!==`ig-tp-${t.id}`?null:{...t,options:R(e,Wr,I),fallbackHtml:j(e.children,Gr)}},isOwnScript:e=>Ur.test(e),match(e){let t=Kr(e);return t&&{...t,options:{}}}},Jr=/* @__PURE__ */ new Set([`tiktok.com`,`www.tiktok.com`]),Yr=/^\/@([A-Za-z0-9._]{0,64})\/video\/(\d{1,25})\/?$/,Xr=/^\/player\/v1\/(\d{1,25})\/?$/,Zr=/^\d{1,25}$/,Qr=/^(?:https?:)?\/\/www\.tiktok\.com\/embed\.js$/;function $r(e,t=``,n={}){return{platform:`tiktok`,kind:`video`,url:`https://www.tiktok.com/@${t}/video/${e}`,id:e,variant:`iframe`,options:n}}const ei={platform:`tiktok`,parse(e){if(e.tag===`blockquote`&&k(e,`tiktok-embed`)){let t=F(e.attrs.get(`cite`)??``),[,n,r]=t&&Jr.has(t.host)?Yr.exec(t.path)??[]:[],i=e.attrs.get(`data-video-id`);if(i!==void 0&&!Zr.test(i)||i!==void 0&&r!==void 0&&i!==r)return null;let a=i??r;return a===void 0?null:$r(a,n)}if(e.tag!==`iframe`)return null;let t=F(e.attrs.get(`src`)??``);if(!t||!Jr.has(t.host))return null;let[,n]=Xr.exec(t.path)??[];return n===void 0?null:B($r(n,``,Object.fromEntries([...t.query].map(([e,t])=>[e,I(t)]))),z(e))},isOwnScript:e=>Qr.test(e),match(e){if(!Jr.has(e.host))return null;let[,t,n]=Yr.exec(e.path)??[];return t===void 0||n===void 0?null:$r(n,t)}},ti=`([a-z0-9-]{1,32})`,ni=`(\\d{1,20})`,ri=/* @__PURE__ */ new Set([`www.tumblr.com`,`tumblr.com`]),ii=RegExp(`^/${ti}/${ni}(?:/[^/]{1,200})?/?$`),ai=RegExp(`^${ti}\\.tumblr\\.com$`),oi=RegExp(`^/post/${ni}(?:/[^/]{1,200})?/?$`),si=RegExp(`^/embed/post/(?:t:[A-Za-z0-9_-]{1,64}|${ti})/${ni}/v2$`),ci=/* @__PURE__ */ new Set([`dashboard`,`explore`,`tagged`,`search`,`settings`,`blog`,`www`,`assets`,`embed`,`api`,`help`]),li=/^(?:https?:)?\/\/assets\.tumblr\.com\/post\.js(?:\?[^#]*)?$/;function ui(e){if(!e)return null;let t,n;return ri.has(e.host)?[,t,n]=ii.exec(e.path)??[]:([,t]=ai.exec(e.host)??[],[,n]=oi.exec(e.path)??[]),t===void 0||n===void 0||ci.has(t)?null:{platform:`tumblr`,kind:`post`,url:`https://www.tumblr.com/${t}/${n}`,id:n,variant:`iframe`}}const di={platform:`tumblr`,parse(e){if(e.tag!==`div`||!k(e,`tumblr-post`))return null;let t=F(e.attrs.get(`data-href`)??``);if(t?.host!==`embed.tumblr.com`)return null;let[,n,r]=si.exec(t.path)??[];if(r===void 0)return null;let[i,...a]=e.children.filter(e=>e.type!==`text`||e.raw.trim()!==``);if(a.length>0||i?.type!==`element`||i.tag!==`a`)return null;let o=ui(F(i.attrs.get(`href`)??``));return o?.id!==r||n!==void 0&&o.url!==`https://www.tumblr.com/${n}/${r}`?null:{...o,options:{}}},isOwnScript:e=>li.test(e),match(e){let t=ui(e);return t&&{...t,options:{}}}},fi=/* @__PURE__ */ new Set([`twitch.tv`,`www.twitch.tv`,`m.twitch.tv`]),pi=/^[A-Za-z0-9_]{3,25}$/,mi=/^v?(\d{1,12})$/,hi=/^[A-Za-z0-9_-]{6,30}$/,gi=/^[A-Za-z0-9_-]{6,100}$/,_i=/^(?:\d+h)?(?:\d+m)?(?:\d+s)?$/,vi=/* @__PURE__ */ new Set([`directory`,`videos`,`collections`,`settings`,`subscriptions`,`inventory`,`wallet`,`drops`,`search`,`downloads`,`jobs`,`turbo`,`p`,`login`,`signup`]),yi=[`autoplay`,`muted`,`time`];function J(e,t){return{platform:`twitch`,kind:`video`,url:e,id:t,variant:`iframe`}}const bi=e=>J(`https://www.twitch.tv/${e.toLowerCase()}`,e.toLowerCase()),xi=e=>J(`https://www.twitch.tv/videos/${e}`,e),Si=e=>J(`https://www.twitch.tv/collections/${e}`,e),Ci=e=>J(`https://clips.twitch.tv/${e}`,e);function wi(e){let t={};for(let n of yi){let r=e.get(n);r!==void 0&&(t[n]=I(r))}return t}function Ti(e){let t=e.query.get(`channel`);if(t!==void 0)return pi.test(t)?bi(t):null;let[,n]=mi.exec(e.query.get(`video`)??``)??[];if(n!==void 0)return xi(n);let r=e.query.get(`collection`);return r!==void 0&&hi.test(r)?Si(r):null}function Ei(e){if(e.host===`clips.twitch.tv`){let t=e.path.replace(/^\/|\/$/g,``);return gi.test(t)?{found:Ci(t),options:{}}:null}if(!fi.has(e.host))return null;let t=e.path.replace(/^\/|\/$/g,``).split(`/`),[n=``,r,i]=t;if(t.length===2&&n===`videos`){let[,t]=mi.exec(r??``)??[];if(t===void 0)return null;let n=e.query.get(`t`);return{found:xi(t),options:n!==void 0&&_i.test(n)&&n?{time:n}:{}}}return t.length===2&&n===`collections`?hi.test(r??``)?{found:Si(r??``),options:{}}:null:t.length===3&&r===`clip`?pi.test(n)&&gi.test(i??``)?{found:Ci(i??``),options:{}}:null:t.length===1&&pi.test(n)&&!vi.has(n.toLowerCase())?{found:bi(n),options:{}}:null}const Di={platform:`twitch`,parse(e){if(e.tag!==`iframe`)return null;let t=F(e.attrs.get(`src`)??``);if(!t)return null;let n=null;if(t.host===`player.twitch.tv`&&/^\/?$/.test(t.path)&&(n=Ti(t)),t.host===`clips.twitch.tv`&&t.path===`/embed`){let e=t.query.get(`clip`)??``;n=gi.test(e)?Ci(e):null}return n&&B({...n,options:wi(t.query)},z(e))},isOwnScript:()=>!1,match(e){let t=Ei(e);return t&&{...t.found,options:t.options}}},Oi=/* @__PURE__ */ new Set([`vimeo.com`,`www.vimeo.com`]),Y=`(\\d{1,12})`,ki=`([0-9a-f]{6,20})`,Ai=[RegExp(`^/${Y}(?:/${ki})?/?$`),RegExp(`^/channels/[A-Za-z0-9_-]{1,64}/${Y}/?$`),RegExp(`^/groups/[A-Za-z0-9_-]{1,64}/videos/${Y}/?$`),RegExp(`^/showcase/\\d{1,12}/video/${Y}/?$`)],ji=RegExp(`^/video/${Y}/?$`),Mi=/^padding:\s*(\d{1,3}(?:\.\d{1,4})?)% 0 0 0;\s*position:\s*relative;?$/,Ni=/^(?:https?:)?\/\/player\.vimeo\.com\/api\/player\.js$/,Pi=/* @__PURE__ */ new Set([`h`,`app_id`,`player_id`]),Fi=/^t=(\d+(?:\.\d+)?|(?:\d+h)?(?:\d+m)?(?:\d+s)?)$/;function Ii(e,t){return{platform:`vimeo`,kind:`video`,url:`https://vimeo.com/${e}${t?`/${t}`:``}`,id:e,variant:`iframe`}}function Li(e){let[,t]=Fi.exec(e.fragment??``)??[];return t?{t}:{}}function Ri(e){if(e?.host!==`player.vimeo.com`)return null;let[,t]=ji.exec(e.path)??[];if(t===void 0)return null;let n=e.query.get(`h`);if(n!==void 0&&!RegExp(`^${ki}$`).test(n))return null;let r=Object.fromEntries([...e.query].filter(([e])=>!Pi.has(e)).map(([e,t])=>[e,I(t)]));return{...Ii(t,n),options:{...r,...Li(e)}}}const zi={platform:`vimeo`,parse(e){let t=_t(e,Mi),n=t?.iframe??e;if(n.tag!==`iframe`)return null;let r=Ri(F(n.attrs.get(`src`)??``));return r&&B(r,t?.size??z(n))},isOwnScript:e=>Ni.test(e),match(e){let t=Ri(e);if(t)return t;if(!Oi.has(e.host))return null;for(let t of Ai){let[,n,r]=t.exec(e.path)??[];if(n!==void 0)return{...Ii(n,r),options:Li(e)}}return null}},Bi=/* @__PURE__ */ new Set([`x.com`,`www.x.com`,`mobile.x.com`,`twitter.com`,`www.twitter.com`,`mobile.twitter.com`]),Vi=/^\/([A-Za-z0-9_]{1,15})\/status\/(\d{1,20})\/?$/,Hi=/^(?:https?:)?\/\/platform\.(?:x|twitter)\.com\/widgets\.js$/,Ui=[[`data-theme`,`theme`],[`data-conversation`,`conversation`],[`data-cards`,`cards`],[`data-align`,`align`],[`align`,`align`],[`data-lang`,`lang`],[`data-dnt`,`dnt`],[`data-width`,`width`]],Wi=/* @__PURE__ */ new Map([[`p`,[`lang`,`dir`]],[`a`,[`href`]],[`br`,[]]]);function Gi(e){if(!e||!Bi.has(e.host))return null;let[,t,n]=Vi.exec(e.path)??[];return t===void 0||n===void 0?null:{platform:`x`,kind:`post`,url:`https://x.com/${t}/status/${n}`,id:n,variant:`sdk`}}const Ki={platform:`x`,fallback:Wi,parse(e){if(e.tag!==`blockquote`||!k(e,`twitter-tweet`))return null;let t=A(e.children).reverse().map(e=>e.tag===`a`?Gi(F(e.attrs.get(`href`)??``)):null).find(e=>e!==null);return t?{...t,options:R(e,Ui,I),fallbackHtml:j(e.children,Wi)}:null},isOwnScript:e=>Hi.test(e),match(e){let t=Gi(e);return t&&{...t,options:{}}}},qi=/* @__PURE__ */ new Set([`youtube.com`,`www.youtube.com`,`m.youtube.com`]),Ji=/* @__PURE__ */ new Set([`youtube-nocookie.com`,`www.youtube-nocookie.com`]),Yi=/^(?!videoseries)[A-Za-z0-9_-]{11}$/,Xi=/^\/embed\/((?!videoseries)[A-Za-z0-9_-]{11})\/?$/,Zi=/^\/(shorts|embed|live)\/((?!videoseries)[A-Za-z0-9_-]{11})\/?$/,Qi=/^\/([A-Za-z0-9_-]{11})\/?$/,$i=/^(?:(\d{1,5})h)?(?:(\d{1,6})m)?(?:(\d{1,7})s?)?$/;function ea(e){if(e===void 0||e===``)return;let t=$i.exec(e);if(!t)return;let[,n=`0`,r=`0`,i=`0`]=t;return Number(n)*3600+Number(r)*60+Number(i)}function ta(e){return ea(e.get(`start`))??ea(e.get(`t`))}function X(e,t=!1){return{platform:`youtube`,kind:`video`,url:t?`https://www.youtube.com/shorts/${e}`:`https://www.youtube.com/watch?v=${e}`,id:e,variant:`iframe`}}function na(e,t){let n=ta(e.query);return{...n===void 0?{}:{start:n},...t?{nocookie:!0}:{}}}const Z=[Ki,Dn,ln,qr,ei,{platform:`youtube`,parse(e){if(e.tag!==`iframe`)return null;let t=F(e.attrs.get(`src`)??``),n=t!==null&&Ji.has(t.host);if(!t||!(n||qi.has(t.host)))return null;let[,r]=Xi.exec(t.path)??[];if(r===void 0)return null;let i=[...t.query].filter(([e])=>e!==`t`).map(([e,t])=>[e,I(t)]),a=Object.fromEntries(i),o=ta(t.query);return o!==void 0&&(a.start=o),n&&(a.nocookie=!0),B({...X(r),options:a},z(e))},isOwnScript:()=>!1,match(e){if(e.host===`youtu.be`){let[,t]=Qi.exec(e.path)??[];return t===void 0?null:{...X(t),options:na(e,!1)}}let t=Ji.has(e.host);if(!t&&!qi.has(e.host))return null;if(!t&&/^\/watch\/?$/.test(e.path)){let t=e.query.get(`v`);return t!==void 0&&Yi.test(t)?{...X(t),options:na(e,!1)}:null}let[,n,r]=Zi.exec(e.path)??[];return n===void 0||r===void 0||t&&n!==`embed`?null:{...X(r,n===`shorts`),options:na(e,t)}}},Br,dr,Hn,nr,Xn,jr,zi,Di,Kt,Er,St,Et,Pn,yn,Rt,di];function ra(e){if(typeof e!=`string`)return null;let t=F(e);if(!t)return null;for(let e of Z){let n=e.match(t);if(n)return n}return null}function ia(e){if(typeof e!=`string`)return null;let t=Se(e);if(!t)return null;let n,r,i=[],a=!1;for(let e of t)if(e.type!==`comment`){if(e.type===`text`){if(/^\s*$/.test(e.raw))continue;return null}if(e.tag===`script`)i.push(e);else if(aa(e))a=!0;else if(n){if(r)return null;r=e}else n=e}if(!n){let[e]=i;if(a||i.length!==1||!e||e.children.length!==0)return null;for(let t of Z){let n=t.parseScript?.(e);if(n)return n}return null}for(let e of Z){let t=e.parse(n);if(!t)continue;if(a&&!e.allowsFbRoot||r&&!e.isOwnExtra?.(r,t))return null;let o=i.map(e=>e.children.length===0?e.attrs.get(`src`):void 0);if(!o.every(t=>t!==void 0&&e.isOwnScript(t)))return null;let s=o.map(t=>t===void 0?{}:e.scriptOptions?.(t)??{});return{...t,options:Object.assign({},...s,t.options)}}return null}function aa(e){return e.tag===`div`&&e.attrs.get(`id`)===`fb-root`&&e.attrs.size===1&&e.children.length===0}const oa=/* @__PURE__ */ new Set([`bsky.app`,`www.bsky.app`]),sa=/^\/profile\/([^/]{1,253})\/post\/[A-Za-z0-9._~:-]{1,512}\/?$/,ca=/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;function la(e){let t=typeof e==`string`?F(e):null;if(!t||!oa.has(t.host))return null;let[,n]=sa.exec(t.path)??[];return n!==void 0&&ca.test(n)?`bluesky`:null}const ua={x:[`post sdk`],instagram:[`post sdk`],threads:[`post sdk`],facebook:[`post sdk`,`video sdk`,`video iframe`],tiktok:[`video iframe`],youtube:[`video iframe`],telegram:[`post iframe`],snapchat:[`post iframe`,`video iframe`],linkedin:[`post iframe`],reddit:[`post iframe`],pinterest:[`post sdk`],spotify:[`post iframe`,`video iframe`],vimeo:[`video iframe`],twitch:[`video iframe`],dailymotion:[`video iframe`],bluesky:[`post iframe`],soundcloud:[`post iframe`],applemusic:[`post iframe`],applepodcasts:[`post iframe`],tumblr:[`post iframe`],kick:[`video iframe`],giphy:[`video iframe`]};function da(e){let t=ra(e.url);if(t?.platform!==e.platform||t.id!==e.id||t.url!==e.url||!ua[e.platform].includes(`${e.kind} ${e.variant}`))return null;if(e.fallbackHtml===void 0||fa(e,e.fallbackHtml))return e;let n={...e};return delete n.fallbackHtml,n}function fa(e,t){let n=Z.find(t=>t.platform===e.platform)?.fallback,r=Se(t);if(!n||!r||j(r,n)!==t)return!1;if(e.platform!==`x`)return!0;let[i]=Se(`<blockquote class="twitter-tweet">${t}</blockquote>`)??[];return i?.type===`element`&&Ki.parse(i)?.id===e.id}const Q={x:`X`,instagram:`Instagram`,facebook:`Facebook`,threads:`Threads`,tiktok:`TikTok`,youtube:`YouTube`,telegram:`Telegram`,snapchat:`Snapchat`,linkedin:`LinkedIn`,reddit:`Reddit`,pinterest:`Pinterest`,spotify:`Spotify`,vimeo:`Vimeo`,twitch:`Twitch`,dailymotion:`Dailymotion`,bluesky:`Bluesky`,soundcloud:`SoundCloud`,applemusic:`Apple Music`,applepodcasts:`Apple Podcasts`,tumblr:`Tumblr`,kick:`Kick`,giphy:`Giphy`};function pa(e){return`social-embeds: a ${Q[e]} URL needs a lookup: use the embed code`}function ma(e,t,n){let r=t??(e===void 0?null:ra(e));if(!r&&e!==void 0&&la(e)===n)return{error:pa(n)};if(!r)return{error:`social-embeds: not a ${Q[n]} post URL: ${String(e)}`};if(r.platform!==n)return{error:`social-embeds: expected a ${Q[n]} embed, got ${Q[r.platform]}`};let i=da(r);return i?{embed:i}:{error:`social-embeds: the ${Q[n]} embed's url and id do not match`}}function ha(e){if(`html`in e)return`social-embeds: unrecognised embed code`;let t=la(e.url);return t?pa(t):`social-embeds: not a supported post URL: ${e.url}`}function ga(e){if(e===null||e.trim()===``)return;let t=Number(e);return Number.isFinite(t)&&t>=0?t:void 0}function _a(e){return e===null?void 0:ga(e.trim().replace(/px$/i,``))}function va(e){for(let t of e.children)if(t instanceof HTMLTemplateElement)return t}function ya(e,t){let n=t??va(e)?.innerHTML,r=e.getAttribute(`url`),i=e.getAttribute(`width`);return{source:n===void 0?r===null?null:{url:r}:{html:n},layout:{width:ga(i)??(i?.trim()?i:void 0),maxWidth:_a(e.getAttribute(`max-width`)),height:_a(e.getAttribute(`height`)),maxHeight:_a(e.getAttribute(`max-height`))},eager:e.hasAttribute(`eager`)}}function ba(e,t,n){let{width:r=`100%`,maxHeight:i}=t,a=t.height??e.height,o=t.maxWidth??e.maxWidth,s=e.size?.width??e.ratio.width,c=e.size?.height??e.ratio.height,l=i===void 0||a!==void 0?void 0:Math.floor(i*s/c);return{position:`relative`,width:r,maxWidth:l===void 0||o!==void 0&&o<l?o:l,...e.messageHeight?{height:n??e.startHeight}:a===void 0?{aspectRatio:`${String(s)} / ${String(c)}`}:{height:a,maxHeight:i},...e.borderRadius===void 0?{}:{borderRadius:e.borderRadius,overflow:`hidden`}}}const xa=/* @__PURE__ */ new Set([`width`,`maxWidth`,`height`,`maxHeight`,`minHeight`,`borderRadius`]);function $(e,t){for(let[n,r]of Object.entries(t)){if(r===void 0)continue;let t=typeof r==`number`&&xa.has(n)?`${String(r)}px`:String(r);e.style.setProperty(n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),t)}}function Sa(e){let t=document.createElement(`div`);return t.setAttribute(`aria-hidden`,`true`),$(t,{width:`100%`,height:`100%`,minHeight:e,background:`rgba(128, 128, 128, 0.12)`}),t}function Ca(e,t,n){if(t||typeof IntersectionObserver>`u`)return n(),()=>{};let r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(r.disconnect(),n())},{rootMargin:`200px 0px`});return r.observe(e),()=>{r.disconnect()}}function wa(e,t){return`${e}${e.includes(`?`)?`&`:`?`}${encodeURIComponent(t)}=${encodeURIComponent(window.location.hostname)}`}function Ta(e){return e.style.position=`absolute`,e.style.setProperty(`inset`,`0`),e}function Ea(e,t,n){let{eager:r,placeholder:i,onLoad:a,onError:o,...s}=n,{messageHeight:c}=t,l=document.createElement(`div`);$(l,ba(t,s));let u=Ta(document.createElement(`div`)),d=Ta(document.createElement(`div`)),f=i.length>0?i:[t.fallbackHtml===void 0?Sa():Da(t.fallbackHtml)];d.append(...f),u.append(d),l.append(u),e.append(l);let p,m=!1,h,g=[],_=()=>{d.remove(),m||(m=!0,a())},v=e=>{if(!c||e.origin!==c.origin||!p||e.source!==p.contentWindow)return;let t;try{t=c.read(e.data)}catch{return}typeof t==`number`&&t>0&&t<=5e4&&($(l,{height:Math.ceil(t)}),_())},y=c?`did not report its height`:`did not load`,b=()=>{h=setTimeout(()=>{m||(d.remove(),o(/* @__PURE__ */ Error(`social-embeds: ${t.title} ${y}`)))},15e3)},x=()=>{let e=document.createElement(`iframe`);e.src=t.hostParam?wa(t.src,t.hostParam):t.src,e.title=t.title,e.setAttribute(`allow`,t.allow),e.setAttribute(`allowfullscreen`,``),t.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),t.scrolling&&e.setAttribute(`scrolling`,t.scrolling),t.sandbox!==void 0&&e.setAttribute(`sandbox`,t.sandbox),$(e,{display:`block`,width:`100%`,height:`100%`,border:0}),e.addEventListener(`load`,()=>{c||_()}),p=e,u.insertBefore(e,d),c&&window.addEventListener(`message`,v)};return r?(x(),g.push(Ca(u,!1,b))):g.push(Ca(u,!1,()=>{x(),b()})),()=>{for(let e of g)e();clearTimeout(h),window.removeEventListener(`message`,v),l.remove()}}function Da(e){let t=document.createElement(`blockquote`);return t.innerHTML=e,t}function Oa(e){return e instanceof Error?e:Error(String(e))}function ka(e,t,n){let{driver:r,label:i}=t,{eager:a,placeholder:o,onLoad:s,onError:c}=n,l=document.createElement(`div`);$(l,{width:n.width??`100%`,maxWidth:n.maxWidth??t.maxWidth});let u=document.createElement(`div`);$(u,{width:`100%`});let d=document.createElement(`div`);d.innerHTML=t.markup,u.append(d);let f=o.length>0?o:[Sa(t.minHeight)];t.hasFallback||u.append(...f),l.append(u),e.append(l);let p=!1,m=!1,h,g=()=>{},_=()=>{if(!(p||m)){m=!0,clearTimeout(h),g();for(let e of f)e.parentNode?.removeChild(e);s()}},v=(e,t)=>{p||m||(g(),g=()=>{},e>=3?c(t):h=setTimeout(()=>{y(e+1)},1e3*2**(e-1)))},y=e=>{if(!(p||m)){try{g=r.render(d,_)}catch(t){v(e,Oa(t));return}h=setTimeout(()=>{v(e,/* @__PURE__ */ Error(`social-embeds: the ${i} embed did not render`))},15e3)}},b=Ca(d,a,()=>{r.load().then(()=>{y(1)},e=>{p||c(Oa(e))})});return()=>{p=!0,b(),clearTimeout(h),g(),l.remove()}}const Aa=typeof HTMLElement>`u`?class{}:HTMLElement;function ja(e){let t=[];for(let n of[...e.childNodes])n instanceof HTMLTemplateElement||(e.removeChild(n),(n.nodeType===Node.ELEMENT_NODE||n.nodeType===Node.TEXT_NODE&&n.textContent?.trim())&&t.push(n));return t}const Ma=[`html`,`url`,`width`,`maxWidth`,`height`,`maxHeight`,`eager`];var Na=class extends Aa{static observedAttributes=[`url`,`width`,`max-width`,`height`,`max-height`,`eager`];#e=null;#t;#n;#r;#i=()=>{};#a=0;#o=!1;constructor(){super();for(let e of Ma){if(!Object.hasOwn(this,e))continue;let t=this[e];Reflect.deleteProperty(this,e),Reflect.set(this,e,t)}}get html(){return this.#e}set html(e){this.#e=typeof e==`string`?e:null,this.#l()}get url(){return this.getAttribute(`url`)}set url(e){this.#c(`url`,e)}get width(){return this.getAttribute(`width`)}set width(e){this.#c(`width`,e)}get maxWidth(){return this.getAttribute(`max-width`)}set maxWidth(e){this.#c(`max-width`,e)}get height(){return this.getAttribute(`height`)}set height(e){this.#c(`height`,e)}get maxHeight(){return this.getAttribute(`max-height`)}set maxHeight(e){this.#c(`max-height`,e)}get eager(){return this.hasAttribute(`eager`)}set eager(e){this.toggleAttribute(`eager`,!!e)}connectedCallback(){this.#t===void 0&&document.readyState===`loading`?this.#o||(this.#o=!0,document.addEventListener(`DOMContentLoaded`,()=>{this.#o=!1,this.isConnected&&this.connectedCallback()},{once:!0})):(this.#t??=ja(this),this.#n??=new MutationObserver(()=>{this.#s(),this.#l()}),this.#s(),this.#l())}disconnectedCallback(){queueMicrotask(()=>{this.isConnected||(this.#n?.disconnect(),this.#u(),this.#r=void 0)})}attributeChangedCallback(){this.#l()}#s(){let e=this.#n;if(e){e.disconnect(),e.observe(this,{childList:!0});for(let t of this.children)t instanceof HTMLTemplateElement&&e.observe(t.content,{childList:!0,subtree:!0,characterData:!0})}}#c(e,t){t==null?this.removeAttribute(e):this.setAttribute(e,t)}#l(){if(!this.isConnected||this.#t===void 0)return;let e=ya(this,this.#e),t=JSON.stringify(e);t!==this.#r&&(this.#u(),this.#r=t,this.#d(e,this.#t))}#u(){this.#a+=1;let e=this.#i;this.#i=()=>{},e()}#d(e,t){let{source:n,layout:r,eager:i}=e;if(!n)return;let a=this.#a,o=e=>{queueMicrotask(()=>{a===this.#a&&this.isConnected&&this.dispatchEvent(e)})},s=e=>{o(new ErrorEvent(`error`,{error:e,message:e.message}))},c=`html`in n?ia(n.html):ra(n.url);if(!c){s(Error(ha(n)));return}let l=ma(void 0,c,c.platform);if(l.error!==void 0){s(Error(l.error));return}let u=mt(l.embed);if(u.kind===`error`){s(Error(u.message));return}let d={...r,eager:i,placeholder:t.map(e=>e.cloneNode(!0)),onLoad:()=>{o(new Event(`load`))},onError:s};this.#i=u.kind===`iframe`?Ea(this,u,d):ka(this,u,d)}};typeof customElements<`u`&&!customElements.get(`social-embed`)&&customElements.define(`social-embed`,Na);export{Na as SocialEmbedElement};
package/dist/index.d.ts CHANGED
@@ -258,7 +258,7 @@ type SocialEmbedProps = SocialEmbedSource & Omit<FrameProps, PlatformOption> & {
258
258
  fallback?: (html: string) => ReactNode;
259
259
  };
260
260
  /** `height` and `maxHeight` reach only the iframe-based embeds: the others size themselves. */
261
- export declare function SocialEmbed(props: SocialEmbedProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
261
+ export declare function SocialEmbed(props: SocialEmbedProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
262
262
  type SnapchatEmbedProps = EmbedSource & FrameProps;
263
263
  /** At most 416px wide by default, the size of Snapchat's own embed code (docs/decisions.md D50). */
264
264
  export declare function SnapchatEmbed(props: SnapchatEmbedProps): import("react").JSX.Element | null;