var at=Object.defineProperty;var lt=(e,o,t)=>o in e?at(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t;var _=(e,o,t)=>(lt(e,typeof o!="symbol"?o+"":o,t),t),$=(e,o,t)=>{if(!o.has(e))throw TypeError("Cannot "+t)};var l=(e,o,t)=>($(e,o,"read from private field"),t?t.call(e):o.get(e)),u=(e,o,t)=>{if(o.has(e))throw TypeError("Cannot add the same private member more than once");o instanceof WeakSet?o.add(e):o.set(e,t)},a=(e,o,t,s)=>($(e,o,"write to private field"),s?s.call(e,t):o.set(e,t),t);var d=(e,o,t)=>($(e,o,"access private method"),t);import{c as ut}from"./vendor-react-ece1c85f.js";const ct="https://www.tiktok.com/player/v1",dt=/tiktok\.com\/(?:player\/v1\/|share\/video\/|@[^/]+\/video\/)([0-9]+)/,v={INIT:-1,ENDED:0,PLAYING:1,PAUSED:2,BUFFERING:3},ht={[v.INIT]:"emptied",[v.PAUSED]:"pause",[v.ENDED]:"ended",[v.PLAYING]:"play",[v.BUFFERING]:"waiting"};function K(e,o={}){const t={src:V(e,o),frameborder:0,width:"100%",height:"100%",allow:"accelerometer; autoplay; fullscreen; encrypted-media; gyroscope; picture-in-picture"};return o.config&&(t["data-config"]=JSON.stringify(o.config)),`
    <style>
      :host {
        display:inline-block;
        min-width: 300px;
        min-height: 150px;
        position: relative;
      }
      iframe {
        position:absolute;
        top:0;
        left:0;
        width:100%;
        height:100%;
        border:0;
      }
    </style>
    <iframe ${vt(t)} title="TikTok video"></iframe>
  `}function V(e,o={}){if(!e.src)return;const t=e.src.match(dt),s=t&&t[1],i={controls:e.controls===""?null:0,autoplay:e.autoplay,muted:e.muted,loop:e.loop,rel:0,...o.config};return`${ct}/${s}?${pt(i)}`}var k,M,w,L,N,A,b,R,E,C,g,T,D,tt,O,et,x,ot,F,st;const S=class S extends(globalThis.HTMLElement??class{}){constructor(){super();u(this,g);u(this,D);u(this,O);u(this,x);u(this,F);_(this,"loadComplete",new Q);u(this,k,void 0);u(this,M,void 0);u(this,w,!1);u(this,L,0);u(this,N,!0);u(this,A,null);u(this,b,100);u(this,R,0);u(this,E,void 0);u(this,C,t=>{var s;if(t.source!==((s=l(this,E))==null?void 0:s.contentWindow))return;const i=t.data;if(i!=null&&i["x-tiktok-player"])switch(i.type){case"onPlayerReady":this.loadComplete.resolve();break;case"onStateChange":{a(this,N,[v.INIT,v.PAUSED,v.ENDED].includes(i.value));const h=ht[i.value];h&&this.dispatchEvent(new Event(h));break}case"onCurrentTime":a(this,L,i.value.currentTime),a(this,R,i.value.duration),this.dispatchEvent(new Event("durationchange")),this.dispatchEvent(new Event("timeupdate"));break;case"onVolumeChange":a(this,b,i.value),this.dispatchEvent(new Event("volumechange"));break;case"onMute":a(this,w,!!i.value),a(this,b,i.value?0:l(this,b)),this.dispatchEvent(new Event("volumechange"));break;case"onError":this.dispatchEvent(new Event("error"));break;default:console.warn("Unhandled TikTok player message:",i);break}});d(this,F,st).call(this,"config")}static get observedAttributes(){return["src","controls","loop","autoplay","muted"]}async load(){if(l(this,k))return;this.shadowRoot||this.attachShadow(S.shadowRootOptions);const t=!l(this,M);if(l(this,M)&&(this.loadComplete=new Q),a(this,M,!0),await a(this,k,Promise.resolve()),a(this,k,null),a(this,L,0),a(this,w,!1),a(this,N,!0),!this.src){this.shadowRoot.innerHTML="",globalThis.removeEventListener("message",l(this,C));return}let s=this.shadowRoot.querySelector("iframe");const i=ft(this.attributes);t&&s&&a(this,A,JSON.parse(s.getAttribute("data-config")||"{}")),(!(s!=null&&s.src)||s.src!==V(i,this))&&(this.shadowRoot.innerHTML=K(i,this),s=this.shadowRoot.querySelector("iframe")),a(this,E,s),globalThis.addEventListener("message",l(this,C))}async attributeChangedCallback(t,s,i){if(s!==i)switch(t){case"muted":{await this.loadComplete,this.muted=i!=null;break}case"autoplay":case"controls":case"loop":case"src":{this.load();return}}}get config(){return l(this,A)}set config(t){a(this,A,t)}async play(){await this.loadComplete,d(this,g,T).call(this,"play")}async pause(){await this.loadComplete,d(this,g,T).call(this,"pause")}get volume(){return l(this,b)/100}set volume(t){console.warn("Volume control is not supported for TikTok videos.")}get currentTime(){return l(this,L)}set currentTime(t){d(this,D,tt).call(this,t)}get muted(){return l(this,w)}set muted(t){a(this,w,t),t?d(this,O,et).call(this):d(this,x,ot).call(this)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(t){this.toggleAttribute("muted",!!t)}get paused(){return l(this,N)}get duration(){return l(this,R)}get src(){return this.getAttribute("src")}set src(t){this.setAttribute("src",t??"")}};k=new WeakMap,M=new WeakMap,w=new WeakMap,L=new WeakMap,N=new WeakMap,A=new WeakMap,b=new WeakMap,R=new WeakMap,E=new WeakMap,C=new WeakMap,g=new WeakSet,T=function(t,s){var i;if(!((i=l(this,E))!=null&&i.contentWindow))return;const h={"x-tiktok-player":!0,type:t,...s!==void 0?{value:s}:{}};l(this,E).contentWindow.postMessage(h,"*")},D=new WeakSet,tt=async function(t){await this.loadComplete,d(this,g,T).call(this,"seekTo",Number(t))},O=new WeakSet,et=async function(){await this.loadComplete,d(this,g,T).call(this,"mute")},x=new WeakSet,ot=async function(){await this.loadComplete,d(this,g,T).call(this,"unMute")},F=new WeakSet,st=function(t){if(Object.prototype.hasOwnProperty.call(this,t)){const s=this[t];delete this[t],this[t]=s}},_(S,"getTemplateHTML",K),_(S,"shadowRootOptions",{mode:"open"});let H=S;class Q extends Promise{constructor(o=()=>{}){let t,s;super((i,h)=>{o(i,h),t=i,s=h}),this.resolve=t,this.reject=s}}function ft(e){let o={};for(let t of e)o[t.name]=t.value;return o}function mt(e){let o={};for(let t in e){let s=e[t];s===!0||s===""?o[t]=1:s===!1?o[t]=0:s!=null&&(o[t]=s)}return o}function pt(e){return String(new URLSearchParams(mt(e)))}function vt(e){let o="";for(const t in e){const s=e[t];s===""?o+=` ${j(t)}`:o+=` ${j(t)}="${j(`${s}`)}"`}return o}function j(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/`/g,"&#x60;")}globalThis.customElements&&!globalThis.customElements.get("tiktok-video")&&globalThis.customElements.define("tiktok-video",H);var gt=H,yt=new Set(["style","children","ref","key","suppressContentEditableWarning","suppressHydrationWarning","dangerouslySetInnerHTML"]),wt={className:"class",htmlFor:"for"};function it(e){return e.toLowerCase()}function X(e){if(typeof e=="boolean")return e?"":void 0;if(typeof e!="function"&&!(typeof e=="object"&&e!==null))return e}function bt({react:e,tagName:o,elementClass:t,events:s,displayName:i,defaultProps:h,toAttributeName:rt=it,toAttributeValue:nt=X}){const B=Number.parseInt(e.version)>=19,q=e.forwardRef((G,P)=>{var z,J;const f=e.useRef(null),U=e.useRef(new Map),W={},Y={},m={},I={};for(const[r,n]of Object.entries(G)){if(yt.has(r)){m[r]=n;continue}const c=rt(wt[r]??r);if(t.prototype&&r in t.prototype&&!(r in(((z=globalThis.HTMLElement)==null?void 0:z.prototype)??{}))&&!((J=t.observedAttributes)!=null&&J.some(y=>y===c))){I[r]=n;continue}if(r.startsWith("on")){W[r]=n;continue}const p=nt(n);if(c&&p!=null&&(Y[c]=String(p),B||(m[c]=p)),c&&B){const y=X(n);p!==y?m[c]=p:m[c]=n}}if(typeof window<"u"){for(const r in W){const n=W[r],c=r.endsWith("Capture"),p=((s==null?void 0:s[r])??r.slice(2).toLowerCase()).slice(0,c?-7:void 0);e.useLayoutEffect(()=>{const y=f==null?void 0:f.current;if(!(!y||typeof n!="function"))return y.addEventListener(p,n,c),()=>{y.removeEventListener(p,n,c)}},[f==null?void 0:f.current,n])}e.useLayoutEffect(()=>{if(f.current===null)return;const r=new Map;for(const n in I)Z(f.current,n,I[n]),U.current.delete(n),r.set(n,I[n]);for(const[n,c]of U.current)Z(f.current,n,void 0);U.current=r})}if(typeof window>"u"&&(t!=null&&t.getTemplateHTML)&&(t!=null&&t.shadowRootOptions)){const{mode:r,delegatesFocus:n}=t.shadowRootOptions,c=e.createElement("template",{shadowrootmode:r,shadowrootdelegatesfocus:n,dangerouslySetInnerHTML:{__html:t.getTemplateHTML(Y,G)},key:"ce-la-react-ssr-template-shadow-root"});m.children=[c,m.children]}return e.createElement(o,{...h,...m,ref:e.useCallback(r=>{f.current=r,typeof P=="function"?P(r):P!==null&&(P.current=r)},[P])},m.children)});return q.displayName=i??t.name,q}function Z(e,o,t){var s;e[o]=t,t==null&&o in(((s=globalThis.HTMLElement)==null?void 0:s.prototype)??{})&&e.removeAttribute(o)}var kt=bt({react:ut,tagName:"tiktok-video",elementClass:gt,toAttributeName(e){return e==="muted"?"":e==="defaultMuted"?"muted":it(e)}});/*! Bundled license information:

ce-la-react/dist/ce-la-react.js:
  (**
   * @license
   * Copyright 2018 Google LLC
   * SPDX-License-Identifier: BSD-3-Clause
   *
   * Modified version of `@lit/react` for vanilla custom elements with support for SSR.
   *)
*/export{kt as default};
