@hyperframes/producer 0.1.6 → 0.1.7
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "0.1.0",
|
|
3
3
|
"buildId": "dev",
|
|
4
|
-
"sha256": "
|
|
4
|
+
"sha256": "714acde76db5bcdb5d577eb49b588df231fbe6956fa99a43bd2a54db0fb4fb61",
|
|
5
5
|
"artifacts": {
|
|
6
6
|
"iife": "hyperframe.runtime.iife.js",
|
|
7
7
|
"esm": "hyperframe.runtime.mjs"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{function
|
|
1
|
+
"use strict";(()=>{function ee(e){try{window.parent.postMessage(e,"*")}catch{}}function Be(e){let n=i=>{let a=i.data;if(!a||a.source!=="hf-parent"||a.type!=="control")return;let u=a.action;if(u==="play"){e.onPlay();return}if(u==="pause"){e.onPause();return}if(u==="seek"){e.onSeek(Number(a.frame??0),a.seekMode??"commit");return}if(u==="set-muted"){e.onSetMuted(!!a.muted);return}if(u==="set-playback-rate"){e.onSetPlaybackRate(Number(a.playbackRate??1));return}if(u==="enable-pick-mode"){e.onEnablePickMode();return}if(u==="disable-pick-mode"){e.onDisablePickMode();return}if(u==="flash-elements"){let p=a.selectors,b=a.duration||800;p&&mt(p,b)}};return window.addEventListener("message",n),n}function mt(e,n){if(!document.getElementById("__hf-flash-styles")){let i=document.createElement("style");i.id="__hf-flash-styles",i.textContent=`
|
|
2
2
|
.__hf-flash {
|
|
3
3
|
outline: 2px solid rgba(59, 130, 246, 0.6) !important;
|
|
4
4
|
outline-offset: 2px !important;
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
0% { outline-color: rgba(59, 130, 246, 0.8); }
|
|
9
9
|
100% { outline-color: transparent; }
|
|
10
10
|
}
|
|
11
|
-
`,document.head.appendChild(i)}for(let i of e)try{document.querySelectorAll(i).forEach(
|
|
12
|
-
`),document.head.appendChild(a),document.body.classList.add("__hf-pick-active"),document.addEventListener("mousemove",Z,!0),document.addEventListener("click",W,!0),document.addEventListener("keydown",oe,!0),y("hyperframe:picker:mode",{isPickMode:!0,timestamp:Date.now()}))}function ie(){n&&(n=!1,i&&(i.classList.remove("__hf-pick-highlight"),i=null),a&&(a.remove(),a=null),document.body.classList.remove("__hf-pick-active"),document.removeEventListener("mousemove",Z,!0),document.removeEventListener("click",W,!0),document.removeEventListener("keydown",oe,!0),y("hyperframe:picker:mode",{isPickMode:!1,timestamp:Date.now()}))}function se(){window.__HF_PICKER_API={enable:re,disable:ie,isActive:()=>n,getHovered:()=>c,getSelected:()=>p,getCandidatesAtPoint:(u,g,S)=>Number.isFinite(u)&&Number.isFinite(g)?P(u,g,S):[],pickAtPoint:(u,g,S)=>{if(!Number.isFinite(u)||!Number.isFinite(g))return null;let C=P(u,g,8);if(!C.length)return null;let v=Math.max(0,Math.min(C.length-1,Number(S??0))),w=C[v]??null;return w?(s(w),e.postMessage({source:"hf-preview",type:"element-picked",elementInfo:w}),ie(),w):null},pickManyAtPoint:(u,g,S)=>{if(!Number.isFinite(u)||!Number.isFinite(g))return[];let C=P(u,g,8);if(!C.length)return[];let v=[],w=Array.isArray(S)?S:[0];for(let G of w){let O=Math.max(0,Math.min(C.length-1,Math.floor(Number(G)))),I=C[O];if(!I)continue;v.some(q=>q.selector===I.selector&&q.tagName===I.tagName)||v.push(I)}return v.length?(s(v[0]??null),e.postMessage({source:"hf-preview",type:"element-picked-many",elementInfos:v}),ie(),v):[]}},y("hyperframe:picker:api-ready",{hasApi:!0,timestamp:Date.now()})}return{enablePickMode:re,disablePickMode:ie,installPickerApi:se}}function Xe(e,n){let i=Number.isFinite(n)&&n>0?n:30,a=Number.isFinite(e)&&e>0?e:0;return Math.floor(a*i+1e-9)/i}function Qe(e,n,i){let a=Xe(n,i);return e.pause(),typeof e.totalTime=="function"?e.totalTime(a,!1):e.seek(a,!1),a}function et(e){return{_timeline:null,play:()=>{let n=e.getTimeline();if(!n||e.getIsPlaying())return;let i=Math.max(0,Number(e.getSafeDuration?.()??n.duration()??0)||0);i>0&&Math.max(0,Number(n.time())||0)>=i&&(n.pause(),n.seek(0,!1),e.onDeterministicSeek(0),e.setIsPlaying(!1),e.onSyncMedia(0,!1),e.onRenderFrameSeek(0)),typeof n.timeScale=="function"&&n.timeScale(e.getPlaybackRate()),n.play(),e.onDeterministicPlay(),e.setIsPlaying(!0),e.onShowNativeVideos(),e.onStatePost(!0)},pause:()=>{let n=e.getTimeline();if(!n)return;n.pause();let i=Math.max(0,Number(n.time())||0);e.onDeterministicSeek(i),e.onDeterministicPause(),e.setIsPlaying(!1),e.onSyncMedia(i,!1),e.onRenderFrameSeek(i),e.onStatePost(!0)},seek:n=>{let i=e.getTimeline();if(!i)return;let a=Math.max(0,Number(n)||0),c=Qe(i,a,e.getCanonicalFps());e.onDeterministicSeek(c),e.setIsPlaying(!1),e.onSyncMedia(c,!1),e.onRenderFrameSeek(c),e.onStatePost(!0)},renderSeek:n=>{let i=e.getTimeline();if(!i)return;let a=Qe(i,n,e.getCanonicalFps());e.onDeterministicSeek(a),e.setIsPlaying(!1),e.onSyncMedia(a,!1),e.onRenderFrameSeek(a),e.onStatePost(!0)},getTime:()=>Number(e.getTimeline()?.time()??0),getDuration:()=>Number(e.getTimeline()?.duration()??0),isPlaying:()=>e.getIsPlaying(),setPlaybackRate:n=>e.setPlaybackRate(n),getPlaybackRate:()=>e.getPlaybackRate()}}function tt(){return{capturedTimeline:null,isPlaying:!1,rafId:null,currentTime:0,deterministicAdapters:[],parityModeEnabled:!0,canonicalFps:30,bridgeMuted:!1,playbackRate:1,bridgeLastPostedFrame:-1,bridgeLastPostedAt:0,bridgeLastPostedPlaying:!1,bridgeLastPostedMuted:!1,bridgeMaxPostIntervalMs:80,timelinePollIntervalId:null,controlBridgeHandler:null,clampDurationLoggedRaw:null,beforeUnloadHandler:null,domReadyHandler:null,injectedCompStyles:[],injectedCompScripts:[],cachedTimedMediaEls:[],cachedMediaClips:[],cachedVideoClips:[],cachedMediaTimelineDurationSeconds:0,tornDown:!1,maxTimelineDurationSeconds:1800,nativeVisualWatchdogTick:0}}function he(e){let n=Number(e);return Number.isFinite(n)?n:null}function ft(e){let n=(e??"").trim();if(!n)return null;let i=he(n);if(i!=null)return{kind:"absolute",value:i};let a=n.match(/^([A-Za-z0-9_.:-]+)(?:\s*([+-])\s*([0-9]*\.?[0-9]+))?$/);if(!a)return null;let c=(a[1]??"").trim();if(!c)return null;let p=a[2]??"+",y=a[3]??"0",f=Number.parseFloat(y),s=Number.isFinite(f)?Math.max(0,f):0,h=p==="-"?-s:s;return{kind:"reference",refId:c,offset:h}}function pe(e){let n=e.timelineRegistry??{},i=new WeakMap,a=new WeakMap,c=new Set,p=s=>{let h=document.getElementById(s);return h||(document.querySelector(`[data-composition-id="${CSS.escape(s)}"]`)??null)},y=s=>{let h=a.get(s);if(h!==void 0)return h;let b=null,R=he(s.getAttribute("data-duration"));if(R!=null&&R>0&&(b=R),b==null||b<=0){let T=he(s.getAttribute("data-end"));if(T!=null){let N=f(s,0),P=T-N;Number.isFinite(P)&&P>0&&(b=P)}}if((b==null||b<=0)&&s instanceof HTMLMediaElement){let T=he(s.getAttribute("data-playback-start"))??he(s.getAttribute("data-media-start"))??0;Number.isFinite(s.duration)&&s.duration>T&&(b=s.duration-T)}if(b==null||b<=0){let T=s.getAttribute("data-composition-id");if(T){let N=n[T]??null;if(N&&typeof N.duration=="function")try{let P=Number(N.duration());Number.isFinite(P)&&P>0&&(b=P)}catch{}}}return b!=null&&Number.isFinite(b)&&b>0?(a.set(s,b),b):(a.set(s,null),null)},f=(s,h)=>{let b=i.get(s);if(b!==void 0)return b??h;if(c.has(s))return h;c.add(s);try{let R=ft(s.getAttribute("data-start"));if(!R){if(s.hasAttribute("data-composition-id")){let W=s.parentElement;if(W&&(W.hasAttribute("data-composition-src")||W.hasAttribute("data-composition-id"))){let oe=f(W,h);return i.set(s,oe),oe}}return i.set(s,h),h}if(R.kind==="absolute"){let W=Math.max(0,R.value);return i.set(s,W),W}let T=p(R.refId);if(!T)return i.set(s,h),h;let N=f(T,0),P=y(T);if(P==null||P<=0){let W=Math.max(0,N+R.offset);return i.set(s,W),W}let Z=Math.max(0,N+P+R.offset);return i.set(s,Z),Z}finally{c.delete(s)}};return{resolveStartForElement:(s,h=0)=>f(s,Math.max(0,h)),resolveDurationForElement:s=>y(s)}}function ne(e){let n=Number(e);return Number.isFinite(n)?n:null}var nt={composition:0,video:1,image:2,element:3,audio:4};function pt(e){if(e.length===0)return;let n=new Map;for(let y of e){let f=n.get(y.track)??new Set;f.add(y.kind),n.set(y.track,f)}if(!Array.from(n.values()).some(y=>y.size>1))return;let a=0,c=new Map,p=[...n.keys()].sort((y,f)=>y-f);for(let y of p){let f=n.get(y);if(f.size===1)c.set(`${y}:${[...f][0]}`,a++);else{let s=[...f].sort((h,b)=>(nt[h]??99)-(nt[b]??99));for(let h of s)c.set(`${y}:${h}`,a++)}}for(let y of e){let f=`${y.track}:${y.kind}`,s=c.get(f);s!=null&&(y.track=s)}}function Se(e){let n=String(e??"").trim();if(!n)return null;let i=n.toLowerCase();if(i.startsWith("data:")||i.startsWith("javascript:"))return null;try{return new URL(n,document.baseURI).toString()}catch{return n}}function gt(e){let n=e.getAttribute("src")??e.getAttribute("data-src");if(n)return Se(n);let i=e.getAttribute("data-composition-src");if(i)return Se(i);let a=e.querySelector("img[src], video[src], audio[src], source[src]");return a?Se(a.getAttribute("src")):null}function it(e){let i=window.__timelines??{},a=pe({timelineRegistry:i}),c=E=>{if(!E)return null;let m=i[E]??null;if(!m||typeof m.duration!="function")return null;try{let x=Number(m.duration());return Number.isFinite(x)&&x>0?x:null}catch{return null}},p=E=>{let m=ne(E.getAttribute("data-duration"));if(m!=null&&m>0)return m;let x=ne(E.getAttribute("data-playback-start"))??ne(E.getAttribute("data-media-start"))??0;return Number.isFinite(E.duration)&&E.duration>x?Math.max(0,E.duration-x):null},y=()=>{let E=Array.from(document.querySelectorAll("video[data-start], audio[data-start]"));if(E.length===0)return null;let m=0;for(let x of E){let j=a.resolveStartForElement(x,0);if(!Number.isFinite(j))continue;let F=p(x);F==null||F<=0||(m=Math.max(m,Math.max(0,j)+F))}return m>0?m:null},f=E=>{let m=E.trim().toLowerCase();return!(!m||m==="main"||m.includes("caption")||m.includes("ambient"))},s=(E,m)=>{let x=[],j=null,F=null,D=null,Y=E.parentElement;for(;Y;){let J=Y.getAttribute("data-composition-id");J&&(x.push(J),!D&&Y!==m&&(D=J),j==null&&(j=a.resolveStartForElement(Y,0)),F==null&&(F=ne(Y.getAttribute("data-duration"))??c(J)??null)),Y=Y.parentElement}return{parentCompositionId:D,compositionAncestors:x.reverse(),inheritedStart:j,inheritedDuration:F}},h=document.querySelector("[data-composition-id]"),b=h?.getAttribute("data-composition-id")??null,R=h?a.resolveStartForElement(h,0):0,T=y(),N=T!=null?Math.max(0,T-Math.max(0,R)):null,P=c(b),Z=ne(h?.getAttribute("data-duration")),W=typeof P=="number"&&Number.isFinite(P)&&P>0?P:null,oe=typeof Z=="number"&&Number.isFinite(Z)&&Z>0?Z:null,re=typeof N=="number"&&Number.isFinite(N)&&N>0?N:null,ie=W!=null&&re!=null&&W>re+1,se=oe??(ie?re:W??re),u=se!=null?Math.min(se,e.maxTimelineDurationSeconds):null,S=(u!=null?R+u:null)??(typeof T=="number"&&Number.isFinite(T)&&T>0?T:null),C=(E,m)=>!Number.isFinite(m)||m<=0?0:S==null||!Number.isFinite(S)?m:!Number.isFinite(E)||E>=S?0:Math.max(0,Math.min(m,S-E)),v=Array.from(document.querySelectorAll("[data-composition-id]")),w=[],G=[],O=Array.from(document.querySelectorAll("*")),I=0;for(let E=0;E<O.length;E+=1){let m=O[E];if(m===h||["SCRIPT","STYLE","LINK","META","TEMPLATE","NOSCRIPT"].includes(m.tagName))continue;let x=s(m,h),j=a.resolveStartForElement(m,x.inheritedStart??0),F=m.getAttribute("data-composition-id"),D=ne(m.getAttribute("data-duration"));if((D==null||D<=0)&&F&&F!==b&&(D=c(F)),(D==null||D<=0)&&m instanceof HTMLMediaElement){let le=ne(m.getAttribute("data-playback-start"))??ne(m.getAttribute("data-media-start"))??0;Number.isFinite(m.duration)&&m.duration>0&&(D=Math.max(0,m.duration-le))}if(D==null||D<=0){let le=x.inheritedDuration;if(le!=null&&le>0){let ve=(x.inheritedStart??0)+le;D=Math.max(0,ve-j)}}if(D==null||D<=0||(D=C(j,D),D<=0))continue;let Y=j+D;I=Math.max(I,Y);let J=m.tagName.toLowerCase(),Te=F&&F!==b?"composition":J==="video"?"video":J==="audio"?"audio":J==="img"?"image":"element";w.push({id:m.id||F||`__node__index_${E}`,label:m.getAttribute("data-timeline-label")??m.getAttribute("data-label")??m.getAttribute("aria-label")??F??m.id??m.className?.split(" ")[0]??Te,start:j,duration:D,track:Number.parseInt(m.getAttribute("data-track-index")??m.getAttribute("data-track")??String(E),10)||0,kind:Te,tagName:J,compositionId:m.getAttribute("data-composition-id"),compositionAncestors:x.compositionAncestors,parentCompositionId:x.parentCompositionId,nodePath:null,compositionSrc:Se(m.getAttribute("data-composition-src")),assetUrl:gt(m),timelineRole:m.getAttribute("data-timeline-role"),timelineLabel:m.getAttribute("data-timeline-label"),timelineGroup:m.getAttribute("data-timeline-group"),timelinePriority:ne(m.getAttribute("data-timeline-priority"))})}pt(w);for(let E of v){if(E===h)continue;let m=E.getAttribute("data-composition-id");if(!m||!f(m))continue;let x=a.resolveStartForElement(E,0),j=ne(E.getAttribute("data-duration")),F=c(m),D=j&&j>0?j:F;if(D==null||D<=0)continue;let Y=C(x,D);Y<=0||G.push({id:m,label:E.getAttribute("data-label")??m,start:x,duration:Y,thumbnailUrl:Se(E.getAttribute("data-thumbnail-url")),avatarName:null})}let K=Math.max(1,Math.min(I||1,e.maxTimelineDurationSeconds));return{source:"hf-preview",type:"timeline",durationInFrames:ie&&oe==null?Number.POSITIVE_INFINITY:Math.max(1,Math.round(K*Math.max(1,e.canonicalFps))),clips:w,scenes:G,compositionWidth:ne(h?.getAttribute("data-width"))??1920,compositionHeight:ne(h?.getAttribute("data-height"))??1080}}var yt=/^(?![a-zA-Z][a-zA-Z\d+\-.]*:)(?!\/\/)(?!\/)(?!\.\.?\/).+/,bt=e=>new Promise(n=>{let i=!1,a=Date.now(),c=null,p=y=>{i||(i=!0,c!=null&&window.clearTimeout(c),n({status:y,elapsedMs:Math.max(0,Date.now()-a)}))};e.addEventListener("load",()=>p("load"),{once:!0}),e.addEventListener("error",()=>p("error"),{once:!0}),c=window.setTimeout(()=>p("timeout"),8e3)});function ot(e){for(;e.firstChild;)e.removeChild(e.firstChild);e.textContent=""}function ht(e,n){let i=e.trim();if(!i)return e;try{return yt.test(i)?new URL(i,document.baseURI).toString():n?new URL(i,n).toString():new URL(i,document.baseURI).toString()}catch{return e}}async function rt(e){let n=null;e.hostCompositionId&&(n=Array.from(e.sourceNode.querySelectorAll("[data-composition-id]")).find(s=>s.getAttribute("data-composition-id")===e.hostCompositionId)??null);let i=n??e.sourceNode,a=Array.from(i.querySelectorAll("style"));for(let f of a){let s=f.cloneNode(!0);s instanceof HTMLStyleElement&&(document.head.appendChild(s),e.injectedStyles.push(s))}let c=Array.from(i.querySelectorAll("script")),p=[];for(let f of c){let s=f.getAttribute("type")?.trim()??"",h=f.getAttribute("src")?.trim()??"";if(h){let b=ht(h,e.compositionUrl);p.push({kind:"external",src:b,type:s})}else{let b=f.textContent?.trim()??"";b&&p.push({kind:"inline",content:b,type:s})}f.parentNode?.removeChild(f)}let y=Array.from(i.querySelectorAll("style"));for(let f of y)f.parentNode?.removeChild(f);if(n){let f=document.importNode(n,!0),s=n.getAttribute("data-width"),h=n.getAttribute("data-height"),b=e.parseDimensionPx(s),R=e.parseDimensionPx(h);f.style.position="relative",f.style.width=b||"100%",f.style.height=R||"100%",b&&f.style.setProperty("--comp-width",b),R&&f.style.setProperty("--comp-height",R),s&&e.host.setAttribute("data-width",s),h&&e.host.setAttribute("data-height",h),b&&e.host instanceof HTMLElement&&(e.host.style.width=b),R&&e.host instanceof HTMLElement&&(e.host.style.height=R),e.host.appendChild(f)}else e.hasTemplate?e.host.appendChild(document.importNode(i,!0)):e.host.innerHTML=e.fallbackBodyInnerHtml;for(let f of p){let s=document.createElement("script");if(f.type&&(s.type=f.type),s.async=!1,f.kind==="external"?s.src=f.src:f.type.toLowerCase()==="module"?s.textContent=f.content:s.textContent=`(function(){${f.content}})();`,document.body.appendChild(s),e.injectedScripts.push(s),f.kind==="external"){let h=await bt(s);h.status!=="load"&&e.onDiagnostic?.({code:"external_composition_script_load_issue",details:{hostCompositionId:e.hostCompositionId,hostCompositionSrc:e.hostCompositionSrc,resolvedScriptSrc:f.src,loadStatus:h.status,elapsedMs:h.elapsedMs}})}}}async function at(e){let n=Array.from(document.querySelectorAll("[data-composition-src]"));n.length!==0&&await Promise.all(n.map(async i=>{let a=i.getAttribute("data-composition-src");if(!a)return;let c=null;try{c=new URL(a,document.baseURI)}catch{c=null}ot(i);try{let p=i.getAttribute("data-composition-id"),y=p!=null?document.querySelector(`template#${CSS.escape(p)}-template`):null;if(y){await rt({host:i,hostCompositionId:p,hostCompositionSrc:a,sourceNode:y.content,hasTemplate:!0,fallbackBodyInnerHtml:"",compositionUrl:c,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,parseDimensionPx:e.parseDimensionPx,onDiagnostic:e.onDiagnostic});return}let f=await fetch(a);if(!f.ok)throw new Error(`HTTP ${f.status}`);let s=await f.text(),b=new DOMParser().parseFromString(s,"text/html"),R=(p?b.querySelector(`template#${CSS.escape(p)}-template`):null)??b.querySelector("template"),T=R?R.content:b.body;await rt({host:i,hostCompositionId:p,hostCompositionSrc:a,sourceNode:T,hasTemplate:!!R,fallbackBodyInnerHtml:b.body.innerHTML,compositionUrl:c,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,parseDimensionPx:e.parseDimensionPx,onDiagnostic:e.onDiagnostic})}catch(p){e.onDiagnostic?.({code:"external_composition_load_failed",details:{hostCompositionId:i.getAttribute("data-composition-id"),hostCompositionSrc:a,errorMessage:p instanceof Error?p.message:"unknown_error"}}),ot(i)}}))}function st(){let e=tt(),n=window,i=null,a=null,c=[],p=new Set,y=null;if(typeof n.__hfRuntimeTeardown=="function")try{n.__hfRuntimeTeardown()}catch{}window.__timelines=window.__timelines||{};let f=t=>{c.push(t)},s=(t,r,o)=>{let d=o??`${t}:${JSON.stringify(r)}`;p.has(d)||(p.add(d),Q({source:"hf-preview",type:"diagnostic",code:t,details:r}))},h=t=>{let r={scale:1,focusX:960,focusY:540},o=[],d=[],l={time:t.getTime(),duration:t.getDuration(),isPlaying:t.isPlaying(),renderMode:!1,timelineDirty:!1};return{play:t.play,pause:t.pause,seek:t.seek,getTime:t.getTime,getDuration:t.getDuration,isPlaying:t.isPlaying,getMainTimeline:()=>null,getElementBounds:()=>{},getElementsAtPoint:()=>{},setElementPosition:()=>{},previewElementPosition:()=>{},setElementKeyframes:()=>{},setElementScale:()=>{},setElementFontSize:()=>{},setElementTextContent:()=>{},setElementTextColor:()=>{},setElementTextShadow:()=>{},setElementTextFontWeight:()=>{},setElementTextFontFamily:()=>{},setElementTextOutline:()=>{},setElementTextHighlight:()=>{},setElementVolume:()=>{},setStageZoom:()=>{},getStageZoom:()=>r,setStageZoomKeyframes:()=>{},getStageZoomKeyframes:()=>o,addElement:()=>!1,removeElement:()=>!1,updateElementTiming:()=>!1,setElementTiming:()=>{},updateElementSrc:()=>!1,updateElementLayer:()=>!1,updateElementBasePosition:()=>!1,markTimelineDirty:()=>{},isTimelineDirty:()=>!1,rebuildTimeline:()=>{},ensureTimeline:()=>{},enableRenderMode:()=>{},disableRenderMode:()=>{},renderSeek:t.renderSeek,getElementVisibility:()=>({visible:!1}),getVisibleElements:()=>d,getRenderState:()=>({...l,time:t.getTime(),duration:t.getDuration(),isPlaying:t.isPlaying()})}},b=1/60,R=.75,T=.75,N=.35,P=900,Z=3,W=2,oe=.05,re=100,ie=240,se=t=>{if(t instanceof Error)return t.message||String(t);if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t??"")}},u=t=>{let r=t.toLowerCase();return r.includes("cannot read properties of null")||r.includes("cannot set properties of null")?{code:"runtime_null_dom_access",category:"dom-null-access"}:r.includes("failed to execute 'queryselector'")?{code:"runtime_invalid_selector",category:"selector-invalid"}:r.includes("is not defined")?{code:"runtime_reference_missing",category:"reference-missing"}:{code:"runtime_script_error",category:"script-error"}},g=t=>{if(t==null||t.trim()==="")return null;let r=Number.parseFloat(t);return!Number.isFinite(r)||r<=0?null:`${r}px`},S=()=>{let t=document.querySelector('[data-composition-id][data-root="true"]');if(t instanceof HTMLElement)return t;let r=Array.from(document.querySelectorAll("[data-composition-id]"));return r.length===0?null:r.find(o=>!o.parentElement?.closest("[data-composition-id]"))??r[0]??null},C=()=>{let t=S();if(!t)return;let r=g(t.getAttribute("data-width")),o=g(t.getAttribute("data-height"));r&&(t.style.width=r),o&&(t.style.height=o),r&&t.style.setProperty("--comp-width",r),o&&t.style.setProperty("--comp-height",o)},v=()=>{let t=S(),r=Array.from(document.querySelectorAll("[data-composition-id]")).filter(o=>o.hasAttribute("data-duration")||o.hasAttribute("data-end"));for(let o of r)t&&o===t||(o.removeAttribute("data-duration"),o.removeAttribute("data-end"))},w=()=>{let t=S();if(!t)return;t.style.position||(t.style.position="relative"),t.style.overflow="hidden";let r=g(t.getAttribute("data-width")),o=g(t.getAttribute("data-height"));r&&(t.style.width=r),o&&(t.style.height=o);let d=Array.from(t.children);for(let l of d){let L=l.tagName.toLowerCase();if(L==="script"||L==="style"||L==="link"||L==="meta"||!l.hasAttribute("data-start"))continue;let $=(l.style.top==="0px"||l.style.top==="0")&&(l.style.left==="0px"||l.style.left==="0")&&l.style.width==="100%"&&l.style.height==="100%",ue=/translate\(\s*-50%\s*,\s*-50%\s*\)/.test(l.style.transform);if($&&ue&&!l.hasAttribute("data-width")&&!l.hasAttribute("data-height")){let te=l.style.top,k=l.style.left,M=l.style.width,A=l.style.height;l.style.top="",l.style.left="",l.style.width="",l.style.height="";let _=window.getComputedStyle(l);_.top!=="auto"||_.bottom!=="auto"||_.left!=="auto"||_.right!=="auto"||_.width!=="0px"||_.height!=="0px"||(l.style.top=te,l.style.left=k,l.style.width=M,l.style.height=A)}let B=window.getComputedStyle(l),H=B.position;if(H!=="absolute"&&H!=="fixed"&&(l.style.position="absolute"),!!l.style.top||!!l.style.bottom||B.top!=="auto"||B.bottom!=="auto"||(l.style.top="0"),!!l.style.left||!!l.style.right||B.left!=="auto"||B.right!=="auto"||(l.style.left="0"),L!=="audio"){let te=g(l.getAttribute("data-width")),k=g(l.getAttribute("data-height")),M=B.width!=="0px"&&B.width!=="auto",A=B.height!=="0px"&&B.height!=="auto";te?!l.style.width&&!M&&(l.style.width=te):!l.style.width&&B.width==="0px"&&(l.style.width="100%"),k?!l.style.height&&!A&&(l.style.height=k):!l.style.height&&B.height==="0px"&&(l.style.height="100%")}}},G=(t,r=0)=>pe({timelineRegistry:window.__timelines??{}}).resolveStartForElement(t,r),O=t=>pe({timelineRegistry:window.__timelines??{}}).resolveDurationForElement(t),I=!document.querySelector("[data-composition-src]"),K=t=>{if(!t||typeof t.duration!="function")return null;try{let r=Number(t.duration());return Number.isFinite(r)?Math.max(0,r):null}catch{return null}},q=t=>typeof t=="number"&&Number.isFinite(t)&&t>b,xe=t=>{let r=Number(t.getAttribute("data-duration"));if(Number.isFinite(r)&&r>0)return r;let o=Number(t.getAttribute("data-playback-start")??t.getAttribute("data-media-start")??"0"),d=Number.isFinite(o)?Math.max(0,o):0;return Number.isFinite(t.duration)&&t.duration>d?Math.max(0,t.duration-d):null},E=()=>{let t=Array.from(document.querySelectorAll("video[data-start], audio[data-start]"));if(t.length===0)return null;let r=0;for(let o of t){let d=G(o,0);if(!Number.isFinite(d))continue;let l=xe(o);l==null||l<=b||(r=Math.max(r,Math.max(0,d)+l))}return r>b?r:null},m=()=>{let t=E();return typeof t!="number"||!Number.isFinite(t)||t<=b?null:t},x=t=>q(t)?Math.max(b,t*R):b,j=(t,r=0)=>{let o=K(t),d=m(),l=Number.isFinite(r)&&r>b?r:0,L=0;q(o)?L=Math.max(o,l):q(d)?L=Math.max(d,l):L=l;let $=Math.max(1,Number(e.maxTimelineDurationSeconds)||1800);return L>0?Math.max(0,Math.min(L,$)):0},F=()=>{let t=window.__timelines??{},r=pe({timelineRegistry:t}),o=m(),d=x(o),l=k=>{let M=document.querySelector(`[data-composition-id="${CSS.escape(k)}"]`);return M?r.resolveStartForElement(M,0):0},L=k=>{let M=window.gsap;if(!M||typeof M.timeline!="function")return null;let A=M.timeline({paused:!0});for(let _ of k)A.add(_.timeline,l(_.compositionId));return A},$=(k,M)=>{if(!q(k))return null;let A=window.gsap;if(!A||typeof A.timeline!="function")return null;let _=A.timeline({paused:!0});if(M)try{_.add(M,0)}catch{}let z=_;if(typeof z.to=="function")try{z.to({},{duration:k})}catch{}return _},ue=(k,M)=>{let A=k;if(typeof A.getChildren!="function")return[];try{let _=A.getChildren(!0,!0,!0)??[];if(!Array.isArray(_))return[];let z=[];for(let X of M)if(!_.some(ye=>ye===X.timeline))try{let ye=l(X.compositionId);k.add(X.timeline,ye),z.push(X.compositionId)}catch{}return z}catch{return[]}},B=S(),H=B?.getAttribute("data-composition-id")??null;if(!H)return{timeline:null};let ee=t[H]??null,U=(()=>{if(!B)return[];let k=new Set,M=Array.from(B.querySelectorAll("[data-composition-id]")),A=[];for(let _ of M){let z=_.getAttribute("data-composition-id");if(!z||z===H||k.has(z))continue;k.add(z);let X=t[z]??null;if(!X||typeof X.play!="function"||typeof X.pause!="function")continue;let fe=K(X);A.push({compositionId:z,timeline:X,durationSeconds:fe??0})}return A})(),te=k=>{for(let M of k){let A=M.timeline;if(typeof A.paused=="function")try{A.paused(!1)}catch{}}};if(U.length>0&&te(U),ee){let k=U.length>0?ue(ee,U):[];if((U.length>0||!document.querySelector("[data-composition-id]:not([data-composition-id='"+H+"'])"))&&(Y=!0),k.length>0)try{let A=ee.time();ee.seek(A,!1)}catch{}let M=K(ee);if(!q(M)&&U.length>0){let A=U.map(ye=>ye.compositionId),_=L(U),z=K(_);if(_&&q(z))return{timeline:_,selectedTimelineIds:A,selectedDurationSeconds:z,mediaDurationFloorSeconds:o,diagnostics:{code:"root_timeline_unusable_fallback",details:{rootCompositionId:H,rootDurationSeconds:M,fallbackKind:"composite_by_root_children",minCandidateDurationSeconds:d,selectedDurationSeconds:z,mediaDurationFloorSeconds:o,selectedTimelineIds:A,autoNestedChildren:k}}};let X=$(o??0,ee),fe=K(X);if(X&&q(fe))return{timeline:X,selectedTimelineIds:[H],selectedDurationSeconds:fe,mediaDurationFloorSeconds:o,diagnostics:{code:"root_timeline_unusable_media_floor_fallback",details:{rootCompositionId:H,rootDurationSeconds:M,fallbackKind:"media_duration_floor",mediaDurationFloorSeconds:o,selectedDurationSeconds:fe,selectedTimelineIds:[H],autoNestedChildren:k}}}}if(!q(M)&&U.length===0){let A=$(o??0,ee),_=K(A);if(A&&q(_))return{timeline:A,selectedTimelineIds:[H],selectedDurationSeconds:_,mediaDurationFloorSeconds:o,diagnostics:{code:"root_timeline_unusable_media_floor_fallback",details:{rootCompositionId:H,rootDurationSeconds:M,fallbackKind:"media_duration_floor",mediaDurationFloorSeconds:o,selectedDurationSeconds:_,selectedTimelineIds:[H]}}}}return{timeline:ee,selectedTimelineIds:[H],selectedDurationSeconds:M,mediaDurationFloorSeconds:o,diagnostics:k.length>0?{code:"root_timeline_auto_nested_children",details:{rootCompositionId:H,selectedDurationSeconds:M,autoNestedChildren:k}}:void 0}}if(U.length>0){let k=U.map(_=>_.compositionId),M=L(U),A=K(M);if(M)return{timeline:M,selectedTimelineIds:k,selectedDurationSeconds:A,mediaDurationFloorSeconds:o,diagnostics:{code:"root_timeline_missing_fallback",details:{rootCompositionId:H,fallbackKind:"composite_by_root_children",minCandidateDurationSeconds:d,selectedDurationSeconds:A,mediaDurationFloorSeconds:o,selectedTimelineIds:k}}}}return{timeline:null}},D=()=>{let t=e.capturedTimeline;if(!t||typeof t.time!="function")return;let r=Number(t.time());Number.isFinite(r)&&(e.currentTime=Math.max(0,r))},Y=!1,J=()=>{if(!I)return!1;let t=e.capturedTimeline,r=K(t),o=q(r);if(t&&o&&Y)return!1;let d=F();return d.timeline?t&&t===d.timeline?(typeof t.timeScale=="function"&&t.timeScale(e.playbackRate),!1):(e.capturedTimeline=d.timeline,typeof e.capturedTimeline.timeScale=="function"&&e.capturedTimeline.timeScale(e.playbackRate),d.diagnostics&&Q({source:"hf-preview",type:"diagnostic",code:d.diagnostics.code,details:d.diagnostics.details}),Q({source:"hf-preview",type:"diagnostic",code:"timeline_bound",details:{selectedTimelineIds:d.selectedTimelineIds??[],selectedDurationSeconds:d.selectedDurationSeconds??null,mediaDurationFloorSeconds:d.mediaDurationFloorSeconds??null}}),!0):!1},Te=()=>{let t=S();if(!(t instanceof HTMLElement))return;let r=t.getBoundingClientRect(),o=Number(t.getAttribute("data-width")),d=Number(t.getAttribute("data-height")),l=window.getComputedStyle(t),L=Number.isFinite(o)&&o>0&&Number.isFinite(d)&&d>0,$=r.width<=0||r.height<=0||t.clientWidth<=0||t.clientHeight<=0;!L||!$||s("root_stage_layout_zero",{compositionId:t.getAttribute("data-composition-id")??null,declaredWidth:o,declaredHeight:d,rectWidth:Math.round(r.width),rectHeight:Math.round(r.height),clientWidth:t.clientWidth,clientHeight:t.clientHeight,display:l.display,visibility:l.visibility,overflow:l.overflow},`root-stage-layout-zero:${t.getAttribute("data-composition-id")??"unknown"}`)},le=()=>{e.tornDown||(y!=null&&window.cancelAnimationFrame(y),y=window.requestAnimationFrame(()=>{y=null,Te()}))},Ne=()=>{i=t=>{let r=se(t.error??t.message).slice(0,ie);if(!r)return;let o=u(r);Q({source:"hf-preview",type:"diagnostic",code:o.code,details:{category:o.category,message:r,filename:t.filename||null,line:Number.isFinite(t.lineno)?t.lineno:null,column:Number.isFinite(t.colno)?t.colno:null}})},a=t=>{let r=se(t.reason).slice(0,ie);if(!r)return;let o=u(r);Q({source:"hf-preview",type:"diagnostic",code:`${o.code}_unhandled_rejection`,details:{category:`${o.category}-unhandled-rejection`,message:r}})},window.addEventListener("error",i),window.addEventListener("unhandledrejection",a)},ve=()=>{let t=Array.from(document.querySelectorAll("img, video, audio, source, link[rel='stylesheet']"));for(let o of t){let d=()=>{if(!(o instanceof Element))return;let l=o.tagName.toLowerCase(),L=o.getAttribute("src")??o.getAttribute("href")??o.getAttribute("poster")??null,$=l==="link"?"runtime_stylesheet_load_failed":"runtime_asset_load_failed";s($,{tagName:l,assetUrl:L,currentSrc:(o instanceof HTMLImageElement||o instanceof HTMLMediaElement)&&o.currentSrc||null,readyState:o instanceof HTMLMediaElement?o.readyState:null,networkState:o instanceof HTMLMediaElement?o.networkState:null},`${$}:${l}:${L??"unknown"}`)};o.addEventListener("error",d),f(()=>{o.removeEventListener("error",d)})}let r=document.fonts;r&&r.ready.then(()=>{if(e.tornDown)return;let o=Array.from(r).filter(d=>d.status==="error").map(d=>d.family).filter(d=>!!d).slice(0,10);o.length!==0&&s("runtime_font_load_issue",{failedFamilies:o,totalFaces:Array.from(r).length},`runtime-font-load-issue:${o.join("|")}`)}).catch(()=>{})},Fe=(t,r)=>{if(!t.timeline)return!1;let o=e.capturedTimeline;if(o&&o===t.timeline)return!1;let d=Math.max(0,e.currentTime||0),l=e.isPlaying;e.capturedTimeline=t.timeline,typeof e.capturedTimeline.timeScale=="function"&&e.capturedTimeline.timeScale(e.playbackRate);try{e.capturedTimeline.pause(),e.capturedTimeline.seek(d,!1),l&&e.capturedTimeline.play()}catch{}return Q({source:"hf-preview",type:"diagnostic",code:"timeline_loop_guard_rebind",details:{reason:r,previousTime:d,selectedTimelineIds:t.selectedTimelineIds??[],selectedDurationSeconds:t.selectedDurationSeconds??null,mediaDurationFloorSeconds:t.mediaDurationFloorSeconds??null}}),!0},ce=null,He=!1,Ee=new Set,Re=()=>{e.tornDown||(ce!=null&&window.clearTimeout(ce),ce=window.setTimeout(()=>{if(e.tornDown)return;ce=null;let t=F();if(!t.timeline||!q(t.mediaDurationFloorSeconds??null))return;if(!e.capturedTimeline){J()&&(de(),ae(!0));return}if(He)return;let o=K(e.capturedTimeline),d=t.selectedDurationSeconds??K(t.timeline);q(d)&&(!q(o)||d>=o+oe)&&Fe(t,"manual")&&(He=!0,Q({source:"hf-preview",type:"diagnostic",code:"timeline_rebind_after_media_metadata",details:{previousDurationSeconds:o??null,selectedDurationSeconds:d??null,selectedTimelineIds:t.selectedTimelineIds??[],mediaDurationFloorSeconds:t.mediaDurationFloorSeconds??null}}),de(),ae(!0))},re))},ct=()=>{for(let t of Ee)t.removeEventListener("loadedmetadata",Re),t.removeEventListener("durationchange",Re);Ee.clear()},we=()=>{if(e.tornDown)return;let t=Array.from(document.querySelectorAll("video, audio"));for(let r of t)Ee.has(r)||(Ee.add(r),r.addEventListener("loadedmetadata",Re),r.addEventListener("durationchange",Re))},We=()=>{let t=Ze({resolveStartSeconds:d=>G(d,0)});Ye({clips:t.mediaClips,timeSeconds:e.currentTime,playing:e.isPlaying,playbackRate:e.playbackRate});let r=document.querySelector("[data-composition-id]")?.getAttribute("data-composition-id")??null,o=Array.from(document.querySelectorAll("[data-start]"));for(let d of o){if(!(d instanceof HTMLElement))continue;let l=d.tagName.toLowerCase();if(l==="script"||l==="style"||l==="link"||l==="meta")continue;if(!d.getAttribute("data-composition-id")){let te=d.closest("[data-composition-id]")?.getAttribute("data-composition-id")??null;if(te&&te!==r)continue}let $=G(d,0),ue=O(d),B=ue!=null&&ue>0?$+ue:Number.POSITIVE_INFINITY,H=B,ee=d.getAttribute("data-composition-id");if(ee&&!Number.isFinite(B)){let U=(window.__timelines??{})[ee];if(U&&typeof U.duration=="function"){let te=U.duration();te>0&&(H=$+te)}}let Pe=e.currentTime>=$&&(Number.isFinite(H)?e.currentTime<H:!0);d.style.visibility=Pe?"visible":"hidden"}},ae=t=>{D();let r=Math.max(0,Math.round((e.currentTime||0)*e.canonicalFps)),o=Date.now();(t||r!==e.bridgeLastPostedFrame||e.isPlaying!==e.bridgeLastPostedPlaying||e.bridgeMuted!==e.bridgeLastPostedMuted||o-e.bridgeLastPostedAt>=e.bridgeMaxPostIntervalMs)&&(e.bridgeLastPostedFrame=r,e.bridgeLastPostedPlaying=e.isPlaying,e.bridgeLastPostedMuted=e.bridgeMuted,e.bridgeLastPostedAt=o,Q({source:"hf-preview",type:"state",frame:r,isPlaying:e.isPlaying,muted:e.bridgeMuted,playbackRate:e.playbackRate}))},de=()=>{v(),C(),w();let t=S();if(t){let o=g(t.getAttribute("data-width")),d=g(t.getAttribute("data-height")),l=o?parseInt(o,10):0,L=d?parseInt(d,10):0;l>0&&L>0&&Q({source:"hf-preview",type:"stage-size",width:l,height:L})}J();let r=it({canonicalFps:e.canonicalFps,maxTimelineDurationSeconds:e.maxTimelineDurationSeconds});window.__clipManifest=r,Q(r),le()},ge=(t,r=0)=>{for(let o of e.deterministicAdapters){try{t==="discover"&&o.discover(),t==="pause"&&o.pause(),t==="play"&&o.play&&o.play()}catch{}if(t==="discover")try{o.seek({time:r})}catch{}}};I||at({injectedStyles:e.injectedCompStyles,injectedScripts:e.injectedCompScripts,parseDimensionPx:g,onDiagnostic:({code:t,details:r})=>{Q({source:"hf-preview",type:"diagnostic",code:t,details:r})}}).finally(()=>{I=!0,ge("discover",e.currentTime),we(),ve(),de(),ae(!0)});let Me=Je({postMessage:t=>Q(t)});Me.installPickerApi();let Oe=t=>{let r=Number(t);!Number.isFinite(r)||r<=0?e.playbackRate=1:e.playbackRate=Math.max(.1,Math.min(5,r)),e.capturedTimeline&&typeof e.capturedTimeline.timeScale=="function"&&e.capturedTimeline.timeScale(e.playbackRate);let o=document.querySelectorAll("video, audio");for(let d of o)if(d instanceof HTMLMediaElement)try{d.playbackRate=e.playbackRate}catch{}},V=et({getTimeline:()=>e.capturedTimeline,setTimeline:t=>{e.capturedTimeline=t},getIsPlaying:()=>e.isPlaying,setIsPlaying:t=>{e.isPlaying=t},getPlaybackRate:()=>e.playbackRate,setPlaybackRate:Oe,getCanonicalFps:()=>e.canonicalFps,onSyncMedia:(t,r)=>{e.currentTime=Math.max(0,Number(t)||0),e.isPlaying=r,We()},onStatePost:ae,onDeterministicSeek:t=>{for(let r of e.deterministicAdapters)try{r.seek({time:Number(t)||0})}catch{}},onDeterministicPause:()=>ge("pause"),onDeterministicPlay:()=>ge("play"),onRenderFrameSeek:()=>{},onShowNativeVideos:()=>{},getSafeDuration:()=>j(e.capturedTimeline,0)});window.__player=h(V),window.__playerReady=!0,window.__renderReady=!0,qe(Q),be("composition_loaded",{duration:V.getDuration(),compositionId:document.querySelector("[data-composition-id]")?.getAttribute("data-composition-id")??null}),e.controlBridgeHandler=Ue({onPlay:()=>{V.play(),be("composition_played",{time:V.getTime()})},onPause:()=>{V.pause(),be("composition_paused",{time:V.getTime()})},onSeek:(t,r)=>{let o=Math.max(0,t)/e.canonicalFps;V.seek(o),be("composition_seeked",{time:o})},onSetMuted:t=>{e.bridgeMuted=t;let r=document.querySelectorAll("video, audio");for(let o of r)o instanceof HTMLMediaElement&&(o.muted=t)},onSetPlaybackRate:t=>Oe(t),onEnablePickMode:()=>Me.enablePickMode(),onDisablePickMode:()=>Me.disablePickMode()}),J(),e.capturedTimeline&&(V._timeline=e.capturedTimeline),I&&setTimeout(()=>{let t=e.capturedTimeline;J()&&e.capturedTimeline!==t&&(V._timeline=e.capturedTimeline),ge("discover",e.currentTime),de(),ae(!0)},0),e.deterministicAdapters=[Ve({resolveStartSeconds:t=>G(t,0)}),Ke(),$e({getTimeline:()=>e.capturedTimeline}),Ge(),ze()],Ne(),ge("discover"),we(),e.timelinePollIntervalId&&clearInterval(e.timelinePollIntervalId);let ke=0,Ae=null,je=0,_e=!1,me=0,Be=()=>{je=Date.now(),_e=!1,me=0};e.timelinePollIntervalId=setInterval(()=>{ke+=1;let r=e.isPlaying&&e.capturedTimeline!=null&&Math.max(0,e.currentTime||0)<W?!1:J();if(e.capturedTimeline&&!V._timeline&&(V._timeline=e.capturedTimeline),(r||ke%20===0)&&de(),ke%10===0&&we(),D(),e.isPlaying&&e.capturedTimeline){let o=Math.max(0,e.currentTime||0),d=Ae,l=j(e.capturedTimeline,0);if(l>0&&o>=l){V.pause(),V.seek(l),Ae=l,me=0,ae(!0);return}if(d!=null&&d>=T&&o<=N?me+=1:me=0,!_e&&me>=Z&&Date.now()-je>P){let $=F();Fe($,"loop_guard")&&(_e=!0,me=0)}Ae=Math.max(0,e.currentTime||0)}else Ae=Math.max(0,e.currentTime||0);e.isPlaying&&We(),ae(!1)},50),de(),ae(!0);let ut=V.seek;V.seek=t=>{Be(),ut(t)};let dt=V.renderSeek;V.renderSeek=t=>{Be(),dt(t)};let De=()=>{if(!e.tornDown){e.tornDown=!0,e.timelinePollIntervalId&&(clearInterval(e.timelinePollIntervalId),e.timelinePollIntervalId=null),ce!=null&&(window.clearTimeout(ce),ce=null),y!=null&&(window.cancelAnimationFrame(y),y=null),ct(),e.controlBridgeHandler&&(window.removeEventListener("message",e.controlBridgeHandler),e.controlBridgeHandler=null),i&&(window.removeEventListener("error",i),i=null),a&&(window.removeEventListener("unhandledrejection",a),a=null),e.beforeUnloadHandler&&(window.removeEventListener("beforeunload",e.beforeUnloadHandler),e.beforeUnloadHandler=null),Me.disablePickMode();for(let t of e.deterministicAdapters)if(!(!t||typeof t.revert!="function"))try{t.revert()}catch{}e.deterministicAdapters=[];for(let t of c.splice(0))try{t()}catch{}for(let t of e.injectedCompStyles)try{t.remove()}catch{}e.injectedCompStyles=[];for(let t of e.injectedCompScripts)try{t.remove()}catch{}e.injectedCompScripts=[],e.capturedTimeline=null,n.__hfRuntimeTeardown===De&&(n.__hfRuntimeTeardown=null)}};n.__hfRuntimeTeardown=De,e.beforeUnloadHandler=De,window.addEventListener("beforeunload",e.beforeUnloadHandler)}window.__timelines=window.__timelines||{};function lt(){let e=window;e.__hyperframeRuntimeBootstrapped||(e.__hyperframeRuntimeBootstrapped=!0,st())}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",lt,{once:!0}):lt();})();
|
|
11
|
+
`,document.head.appendChild(i)}for(let i of e)try{document.querySelectorAll(i).forEach(u=>{u.classList.add("__hf-flash"),setTimeout(()=>u.classList.remove("__hf-flash"),n)})}catch{}}var xe=null;function qe(e){xe=e}function Se(e,n){if(xe)try{xe({source:"hf-preview",type:"analytics",event:e,properties:n??{}})}catch{}}function Ve(e){let n=[];return{name:"css",discover:()=>{n=[];let i=document.querySelectorAll("*");for(let a of i){if(!(a instanceof HTMLElement))continue;let u=window.getComputedStyle(a);!u.animationName||u.animationName==="none"||n.push({el:a,baseDelay:a.style.animationDelay||"",basePlayState:a.style.animationPlayState||""})}},seek:i=>{let a=Number(i.time)||0;for(let u of n){if(!u.el.isConnected)continue;let p=e?.resolveStartSeconds?e.resolveStartSeconds(u.el):Number.parseFloat(u.el.getAttribute("data-start")??"0")||0,b=Math.max(0,a-p);u.el.style.animationPlayState="paused",u.el.style.animationDelay=`-${b.toFixed(3)}s`}},pause:()=>{for(let i of n)i.el.isConnected&&(i.el.style.animationPlayState=i.basePlayState||"paused",i.baseDelay&&(i.el.style.animationDelay=i.baseDelay))},revert:()=>{n=[]}}}function $e(e){return{name:"gsap",discover:()=>{},seek:n=>{let i=e.getTimeline();if(!i)return;i.pause();let a=Math.max(0,Number(n.time)||0);typeof i.totalTime=="function"?i.totalTime(a,!1):i.seek(a,!1)},pause:()=>{let n=e.getTimeline();n&&n.pause()}}}function ze(){return{name:"lottie",discover:()=>{try{let e=window.lottie;if(e&&typeof e.getRegisteredAnimations=="function"){let n=e.getRegisteredAnimations();if(Array.isArray(n)&&n.length>0){let i=window.__hfLottie??[],a=new Set(i);for(let u of n)a.has(u)||i.push(u);window.__hfLottie=i}}}catch{}},seek:e=>{let n=Math.max(0,Number(e.time)||0),i=window.__hfLottie;if(!(!i||i.length===0))for(let a of i)try{if(Ne(a))a.goToAndStop(n*1e3,!1);else if(Fe(a)){if(typeof a.setCurrentRawFrameValue=="function"){let u=a.totalFrames??0,p=a.frameRate??30,b=n*p;u>0&&a.setCurrentRawFrameValue(Math.min(b,u-1))}else if(typeof a.seek=="function"){let u=a.duration??1,p=Math.min(100,n/u*100);a.seek(p)}}}catch{}},pause:()=>{let e=window.__hfLottie;if(!(!e||e.length===0))for(let n of e)try{(Ne(n)||Fe(n))&&n.pause()}catch{}},play:()=>{let e=window.__hfLottie;if(!(!e||e.length===0))for(let n of e)try{(Ne(n)||Fe(n))&&n.play()}catch{}},revert:()=>{}}}function Ne(e){return typeof e=="object"&&e!==null&&typeof e.goToAndStop=="function"}function Fe(e){return typeof e=="object"&&e!==null&&typeof e.pause=="function"&&("totalFrames"in e||"duration"in e)}function Ge(){let e=null,n=0;return{name:"three",discover:()=>{},seek:i=>{e=Math.max(0,Number(i.time)||0),n=e,window.__hfThreeTime=e;try{window.dispatchEvent(new CustomEvent("hf-seek",{detail:{time:e}}))}catch{}},pause:()=>{e==null&&(e=Math.max(0,n))},play:()=>{e=null},revert:()=>{e=null,n=0}}}function Ke(){return{name:"waapi",discover:()=>{},seek:e=>{if(!document.getAnimations)return;let n=Math.max(0,(Number(e.time)||0)*1e3);for(let i of document.getAnimations())try{i.pause(),i.currentTime=n}catch{}},pause:()=>{if(document.getAnimations)for(let e of document.getAnimations())try{e.pause()}catch{}}}}function Ze(e){let n=Array.from(document.querySelectorAll("video[data-start], audio[data-start]")),i=[],a=[],u=0;for(let p of n){let b=e?.resolveStartSeconds?e.resolveStartSeconds(p):Number.parseFloat(p.dataset.start??"0");if(!Number.isFinite(b))continue;let f=Number.parseFloat(p.dataset.playbackStart??p.dataset.mediaStart??"0")||0,s=p.defaultPlaybackRate,y=Number.isFinite(s)&&s>0?Math.max(.1,Math.min(5,s)):1,h=p.loop,v=Number.isFinite(p.duration)&&p.duration>0?p.duration:null,k=Number.parseFloat(p.dataset.duration??"");(!Number.isFinite(k)||k<=0)&&v!=null&&(k=Math.max(0,(v-f)/y));let U=Number.isFinite(k)&&k>0?b+k:Number.POSITIVE_INFINITY,x=Number.parseFloat(p.dataset.volume??""),J={el:p,start:b,mediaStart:f,duration:Number.isFinite(k)&&k>0?k:Number.POSITIVE_INFINITY,end:U,volume:Number.isFinite(x)?x:null,playbackRate:y,loop:h,sourceDuration:v};i.push(J),p.tagName==="VIDEO"&&a.push(J),Number.isFinite(U)&&(u=Math.max(u,U))}return{timedMediaEls:n,mediaClips:i,videoClips:a,maxMediaEnd:u}}function Ye(e){for(let n of e.clips){let{el:i}=n;if(!i.isConnected)continue;let a=(e.timeSeconds-n.start)*n.playbackRate+n.mediaStart;if(e.timeSeconds>=n.start&&e.timeSeconds<n.end&&a>=0){if(n.loop&&n.sourceDuration!=null&&n.sourceDuration>0){let p=n.sourceDuration-n.mediaStart;p>0&&a>=n.sourceDuration&&(a=n.mediaStart+(a-n.mediaStart)%p)}n.volume!=null&&(i.volume=n.volume);try{i.playbackRate=n.playbackRate*e.playbackRate}catch{}if(Math.abs((i.currentTime||0)-a)>.3)try{i.currentTime=a}catch{}e.playing&&i.paused?i.play().catch(()=>{}):!e.playing&&!i.paused&&i.pause();continue}i.paused||i.pause()}}function Je(e){let n=!1,i=null,a=null,u=null,p=null;function b(c,g){try{window.dispatchEvent(new CustomEvent(c,{detail:g}))}catch{}}function f(c){u=c,b("hyperframe:picker:hovered",{elementInfo:u,isPickMode:n,timestamp:Date.now()})}function s(c){p=c,b("hyperframe:picker:selected",{elementInfo:p,isPickMode:n,timestamp:Date.now()})}function y(c){if(!c||c===document.body||c===document.documentElement)return!1;let g=c.tagName.toLowerCase();return!(g==="script"||g==="style"||g==="link"||g==="meta"||c.classList.contains("__hf-pick-highlight"))}function h(c){let g=c;if(g.id)return`#${g.id}`;let A=c.getAttribute("data-composition-id");if(A)return`[data-composition-id="${A}"]`;let H=c.getAttribute("data-composition-src");if(H)return`[data-composition-src="${H}"]`;let L=c.getAttribute("data-track-index");if(L)return`[data-track-index="${L}"]`;let R=c.tagName.toLowerCase(),Y=c.parentElement;if(!Y)return R;let V=Y.querySelectorAll(`:scope > ${R}`);if(V.length===1)return R;for(let I=0;I<V.length;I+=1)if(V[I]===c)return`${R}:nth-of-type(${I+1})`;return R}function v(c){let g=c.tagName.toLowerCase(),A=(c.textContent??"").trim().replace(/\s+/g," "),H=(L,R)=>L.length>R?`${L.slice(0,R-1)}\u2026`:L;return g==="h1"||g==="h2"||g==="h3"?"Heading":g==="p"||g==="span"||g==="div"?A.length>0?H(A,56):"Text":g==="img"?"Image":g==="video"?"Video":g==="audio"?"Audio":g==="svg"?"Shape":c.getAttribute("data-composition-src")?"Composition":g==="section"?"Section":`${g.charAt(0).toUpperCase()}${g.slice(1)}`}function k(c,g,A){let H=typeof A=="number"&&A>0?A:8,L=[];if(document.elementsFromPoint)L=document.elementsFromPoint(c,g);else if(document.elementFromPoint){let V=document.elementFromPoint(c,g);L=V?[V]:[]}let R={},Y=[];for(let V=0;V<L.length;V+=1){let I=L[V];if(!y(I))continue;let q=`${I.tagName}::${I.id||""}::${V}`;if(!R[q]&&(R[q]=!0,Y.push(I),Y.length>=H))break}return Y}function U(c){let g=c.getBoundingClientRect(),A={};for(let L=0;L<c.attributes.length;L+=1){let R=c.attributes[L];R.name.startsWith("data-")&&(A[R.name]=R.value)}return{id:c.id||null,tagName:c.tagName.toLowerCase(),selector:h(c),label:v(c),boundingBox:{x:g.left,y:g.top,width:g.width,height:g.height},textContent:c.textContent?c.textContent.trim().slice(0,200):null,src:c.getAttribute("src")||c.getAttribute("data-composition-src")||null,dataAttributes:A}}function x(c,g,A){return k(c,g,A).map(U)}function J(c){if(!n)return;let A=k(c.clientX,c.clientY,1)[0]??(c.target instanceof Element?c.target:null);if(!y(A)||i===A)return;i&&i.classList.remove("__hf-pick-highlight"),i=A,A.classList.add("__hf-pick-highlight");let H=U(A);f(H),e.postMessage({source:"hf-preview",type:"element-hovered",elementInfo:H})}function B(c){if(!n)return;c.preventDefault(),c.stopPropagation(),c.stopImmediatePropagation();let g=x(c.clientX,c.clientY,8);g.length!==0&&(f(g[0]??null),e.postMessage({source:"hf-preview",type:"element-pick-candidates",candidates:g,selectedIndex:0,point:{x:c.clientX,y:c.clientY}}))}function ae(c){c.key==="Escape"&&(oe(),e.postMessage({source:"hf-preview",type:"pick-mode-cancelled"}))}function ce(){n||(n=!0,a=document.createElement("style"),a.textContent=[".__hf-pick-highlight { outline: 2px solid #4f8cf7 !important; outline-offset: 2px; cursor: crosshair !important; }",".__hf-pick-active * { cursor: crosshair !important; }"].join(`
|
|
12
|
+
`),document.head.appendChild(a),document.body.classList.add("__hf-pick-active"),document.addEventListener("mousemove",J,!0),document.addEventListener("click",B,!0),document.addEventListener("keydown",ae,!0),b("hyperframe:picker:mode",{isPickMode:!0,timestamp:Date.now()}))}function oe(){n&&(n=!1,i&&(i.classList.remove("__hf-pick-highlight"),i=null),a&&(a.remove(),a=null),document.body.classList.remove("__hf-pick-active"),document.removeEventListener("mousemove",J,!0),document.removeEventListener("click",B,!0),document.removeEventListener("keydown",ae,!0),b("hyperframe:picker:mode",{isPickMode:!1,timestamp:Date.now()}))}function de(){window.__HF_PICKER_API={enable:ce,disable:oe,isActive:()=>n,getHovered:()=>u,getSelected:()=>p,getCandidatesAtPoint:(c,g,A)=>Number.isFinite(c)&&Number.isFinite(g)?x(c,g,A):[],pickAtPoint:(c,g,A)=>{if(!Number.isFinite(c)||!Number.isFinite(g))return null;let H=x(c,g,8);if(!H.length)return null;let L=Math.max(0,Math.min(H.length-1,Number(A??0))),R=H[L]??null;return R?(s(R),e.postMessage({source:"hf-preview",type:"element-picked",elementInfo:R}),oe(),R):null},pickManyAtPoint:(c,g,A)=>{if(!Number.isFinite(c)||!Number.isFinite(g))return[];let H=x(c,g,8);if(!H.length)return[];let L=[],R=Array.isArray(A)?A:[0];for(let Y of R){let V=Math.max(0,Math.min(H.length-1,Math.floor(Number(Y)))),I=H[V];if(!I)continue;L.some(W=>W.selector===I.selector&&W.tagName===I.tagName)||L.push(I)}return L.length?(s(L[0]??null),e.postMessage({source:"hf-preview",type:"element-picked-many",elementInfos:L}),oe(),L):[]}},b("hyperframe:picker:api-ready",{hasApi:!0,timestamp:Date.now()})}return{enablePickMode:ce,disablePickMode:oe,installPickerApi:de}}function Xe(e,n){let i=Number.isFinite(n)&&n>0?n:30,a=Number.isFinite(e)&&e>0?e:0;return Math.floor(a*i+1e-9)/i}function Qe(e,n,i){let a=Xe(n,i);return e.pause(),typeof e.totalTime=="function"?e.totalTime(a,!1):e.seek(a,!1),a}function et(e){return{_timeline:null,play:()=>{let n=e.getTimeline();if(!n||e.getIsPlaying())return;let i=Math.max(0,Number(e.getSafeDuration?.()??n.duration()??0)||0);i>0&&Math.max(0,Number(n.time())||0)>=i&&(n.pause(),n.seek(0,!1),e.onDeterministicSeek(0),e.setIsPlaying(!1),e.onSyncMedia(0,!1),e.onRenderFrameSeek(0)),typeof n.timeScale=="function"&&n.timeScale(e.getPlaybackRate()),n.play(),e.onDeterministicPlay(),e.setIsPlaying(!0),e.onShowNativeVideos(),e.onStatePost(!0)},pause:()=>{let n=e.getTimeline();if(!n)return;n.pause();let i=Math.max(0,Number(n.time())||0);e.onDeterministicSeek(i),e.onDeterministicPause(),e.setIsPlaying(!1),e.onSyncMedia(i,!1),e.onRenderFrameSeek(i),e.onStatePost(!0)},seek:n=>{let i=e.getTimeline();if(!i)return;let a=Math.max(0,Number(n)||0),u=Qe(i,a,e.getCanonicalFps());e.onDeterministicSeek(u),e.setIsPlaying(!1),e.onSyncMedia(u,!1),e.onRenderFrameSeek(u),e.onStatePost(!0)},renderSeek:n=>{let i=e.getTimeline();if(!i)return;let a=Qe(i,n,e.getCanonicalFps());e.onDeterministicSeek(a),e.setIsPlaying(!1),e.onSyncMedia(a,!1),e.onRenderFrameSeek(a),e.onStatePost(!0)},getTime:()=>Number(e.getTimeline()?.time()??0),getDuration:()=>Number(e.getTimeline()?.duration()??0),isPlaying:()=>e.getIsPlaying(),setPlaybackRate:n=>e.setPlaybackRate(n),getPlaybackRate:()=>e.getPlaybackRate()}}function tt(){return{capturedTimeline:null,isPlaying:!1,rafId:null,currentTime:0,deterministicAdapters:[],parityModeEnabled:!0,canonicalFps:30,bridgeMuted:!1,playbackRate:1,bridgeLastPostedFrame:-1,bridgeLastPostedAt:0,bridgeLastPostedPlaying:!1,bridgeLastPostedMuted:!1,bridgeMaxPostIntervalMs:80,timelinePollIntervalId:null,controlBridgeHandler:null,clampDurationLoggedRaw:null,beforeUnloadHandler:null,domReadyHandler:null,injectedCompStyles:[],injectedCompScripts:[],cachedTimedMediaEls:[],cachedMediaClips:[],cachedVideoClips:[],cachedMediaTimelineDurationSeconds:0,tornDown:!1,maxTimelineDurationSeconds:1800,nativeVisualWatchdogTick:0}}function Te(e){let n=Number(e);return Number.isFinite(n)?n:null}function ft(e){let n=(e??"").trim();if(!n)return null;let i=Te(n);if(i!=null)return{kind:"absolute",value:i};let a=n.match(/^([A-Za-z0-9_.:-]+)(?:\s*([+-])\s*([0-9]*\.?[0-9]+))?$/);if(!a)return null;let u=(a[1]??"").trim();if(!u)return null;let p=a[2]??"+",b=a[3]??"0",f=Number.parseFloat(b),s=Number.isFinite(f)?Math.max(0,f):0,y=p==="-"?-s:s;return{kind:"reference",refId:u,offset:y}}function ye(e){let n=e.timelineRegistry??{},i=new WeakMap,a=new WeakMap,u=new Set,p=s=>{let y=document.getElementById(s);return y||(document.querySelector(`[data-composition-id="${CSS.escape(s)}"]`)??null)},b=s=>{let y=a.get(s);if(y!==void 0)return y;let h=null,v=Te(s.getAttribute("data-duration"));if(v!=null&&v>0&&(h=v),h==null||h<=0){let k=Te(s.getAttribute("data-end"));if(k!=null){let U=f(s,0),x=k-U;Number.isFinite(x)&&x>0&&(h=x)}}if((h==null||h<=0)&&s instanceof HTMLMediaElement){let k=Te(s.getAttribute("data-playback-start"))??Te(s.getAttribute("data-media-start"))??0;Number.isFinite(s.duration)&&s.duration>k&&(h=s.duration-k)}if(h==null||h<=0){let k=s.getAttribute("data-composition-id");if(k){let U=n[k]??null;if(U&&typeof U.duration=="function")try{let x=Number(U.duration());Number.isFinite(x)&&x>0&&(h=x)}catch{}}}return h!=null&&Number.isFinite(h)&&h>0?(a.set(s,h),h):(a.set(s,null),null)},f=(s,y)=>{let h=i.get(s);if(h!==void 0)return h??y;if(u.has(s))return y;u.add(s);try{let v=ft(s.getAttribute("data-start"));if(!v){if(s.hasAttribute("data-composition-id")){let B=s.parentElement;if(B&&(B.hasAttribute("data-composition-src")||B.hasAttribute("data-composition-id"))){let ae=f(B,y);return i.set(s,ae),ae}}return i.set(s,y),y}if(v.kind==="absolute"){let B=Math.max(0,v.value);return i.set(s,B),B}let k=p(v.refId);if(!k)return i.set(s,y),y;let U=f(k,0),x=b(k);if(x==null||x<=0){let B=Math.max(0,U+v.offset);return i.set(s,B),B}let J=Math.max(0,U+x+v.offset);return i.set(s,J),J}finally{u.delete(s)}};return{resolveStartForElement:(s,y=0)=>f(s,Math.max(0,y)),resolveDurationForElement:s=>b(s)}}function te(e){let n=Number(e);return Number.isFinite(n)?n:null}var nt={composition:0,video:1,image:2,element:3,audio:4};function pt(e){if(e.length===0)return;let n=new Map;for(let b of e){let f=n.get(b.track)??new Set;f.add(b.kind),n.set(b.track,f)}if(!Array.from(n.values()).some(b=>b.size>1))return;let a=0,u=new Map,p=[...n.keys()].sort((b,f)=>b-f);for(let b of p){let f=n.get(b);if(f.size===1)u.set(`${b}:${[...f][0]}`,a++);else{let s=[...f].sort((y,h)=>(nt[y]??99)-(nt[h]??99));for(let y of s)u.set(`${b}:${y}`,a++)}}for(let b of e){let f=`${b.track}:${b.kind}`,s=u.get(f);s!=null&&(b.track=s)}}function Ee(e){let n=String(e??"").trim();if(!n)return null;let i=n.toLowerCase();if(i.startsWith("data:")||i.startsWith("javascript:"))return null;try{return new URL(n,document.baseURI).toString()}catch{return n}}function gt(e){let n=e.getAttribute("src")??e.getAttribute("data-src");if(n)return Ee(n);let i=e.getAttribute("data-composition-src");if(i)return Ee(i);let a=e.querySelector("img[src], video[src], audio[src], source[src]");return a?Ee(a.getAttribute("src")):null}function it(e){let i=window.__timelines??{},a=ye({timelineRegistry:i}),u=E=>{if(!E)return null;let d=i[E]??null;if(!d||typeof d.duration!="function")return null;try{let S=Number(d.duration());return Number.isFinite(S)&&S>0?S:null}catch{return null}},p=E=>{let d=te(E.getAttribute("data-duration"));if(d!=null&&d>0)return d;let S=te(E.getAttribute("data-playback-start"))??te(E.getAttribute("data-media-start"))??0;return Number.isFinite(E.duration)&&E.duration>S?Math.max(0,E.duration-S):null},b=()=>{let E=Array.from(document.querySelectorAll("video[data-start], audio[data-start]"));if(E.length===0)return null;let d=0;for(let S of E){let N=a.resolveStartForElement(S,0);if(!Number.isFinite(N))continue;let F=p(S);F==null||F<=0||(d=Math.max(d,Math.max(0,N)+F))}return d>0?d:null},f=E=>{let d=E.trim().toLowerCase();return!(!d||d==="main"||d.includes("caption")||d.includes("ambient"))},s=(E,d)=>{let S=[],N=null,F=null,T=null,w=E.parentElement;for(;w;){let M=w.getAttribute("data-composition-id");M&&(S.push(M),!T&&w!==d&&(T=M),N==null&&(N=a.resolveStartForElement(w,0)),F==null&&(F=te(w.getAttribute("data-duration"))??u(M)??null)),w=w.parentElement}return{parentCompositionId:T,compositionAncestors:S.reverse(),inheritedStart:N,inheritedDuration:F}},y=document.querySelector("[data-composition-id]"),h=y?.getAttribute("data-composition-id")??null,v=y?a.resolveStartForElement(y,0):0,k=b(),U=k!=null?Math.max(0,k-Math.max(0,v)):null,x=u(h),J=te(y?.getAttribute("data-duration")),B=typeof x=="number"&&Number.isFinite(x)&&x>0?x:null,ae=typeof J=="number"&&Number.isFinite(J)&&J>0?J:null,ce=typeof U=="number"&&Number.isFinite(U)&&U>0?U:null,oe=B!=null&&ce!=null&&B>ce+1,de=ae??(oe?ce:B??ce),c=de!=null?Math.min(de,e.maxTimelineDurationSeconds):null,A=(c!=null?v+c:null)??(typeof k=="number"&&Number.isFinite(k)&&k>0?k:null),H=(E,d)=>!Number.isFinite(d)||d<=0?0:A==null||!Number.isFinite(A)?d:!Number.isFinite(E)||E>=A?0:Math.max(0,Math.min(d,A-E)),L=Array.from(document.querySelectorAll("[data-composition-id]")),R=[],Y=[],V=Array.from(document.querySelectorAll("[data-start], [data-track-index], [data-composition-id], video, audio, img")),I=0;for(let E=0;E<V.length;E+=1){let d=V[E];if(d===y||["SCRIPT","STYLE","LINK","META","TEMPLATE","NOSCRIPT"].includes(d.tagName))continue;let S=s(d,y),N=a.resolveStartForElement(d,S.inheritedStart??0),F=d.getAttribute("data-composition-id"),T=te(d.getAttribute("data-duration"));if((T==null||T<=0)&&F&&F!==h&&(T=u(F)),(T==null||T<=0)&&d instanceof HTMLMediaElement){let X=te(d.getAttribute("data-playback-start"))??te(d.getAttribute("data-media-start"))??0;Number.isFinite(d.duration)&&d.duration>0&&(T=Math.max(0,d.duration-X))}if(T==null||T<=0){let X=S.inheritedDuration;if(X!=null&&X>0){let le=(S.inheritedStart??0)+X;T=Math.max(0,le-N)}}if(T==null||T<=0||(T=H(N,T),T<=0))continue;let w=N+T;I=Math.max(I,w);let M=d.tagName.toLowerCase(),se=F&&F!==h?"composition":M==="video"?"video":M==="audio"?"audio":M==="img"?"image":"element";R.push({id:d.id||F||`__node__index_${E}`,label:d.getAttribute("data-timeline-label")??d.getAttribute("data-label")??d.getAttribute("aria-label")??F??d.id??d.className?.split(" ")[0]??se,start:N,duration:T,track:Number.parseInt(d.getAttribute("data-track-index")??d.getAttribute("data-track")??String(E),10)||0,kind:se,tagName:M,compositionId:d.getAttribute("data-composition-id"),compositionAncestors:S.compositionAncestors,parentCompositionId:S.parentCompositionId,nodePath:null,compositionSrc:Ee(d.getAttribute("data-composition-src")),assetUrl:gt(d),timelineRole:d.getAttribute("data-timeline-role"),timelineLabel:d.getAttribute("data-timeline-label"),timelineGroup:d.getAttribute("data-timeline-group"),timelinePriority:te(d.getAttribute("data-timeline-priority"))})}let q=new Set(R.map(E=>E.id)),W=y?.getAttribute("data-composition-id")??null,Ae=W?i[W]??null:null;if(Ae&&y){let E=Ae;if(typeof E.getChildren=="function")try{let d=E.getChildren(!0,!0,!1)??[],S=new Map;for(let T of y.children){let w=T;if(!w.id)continue;let M=w.tagName.toLowerCase();M==="script"||M==="style"||M==="link"||S.set(w,{id:w.id,start:1/0,end:-1/0})}let N=T=>{let w=T;for(;w;){if(S.has(w))return w;if(w===y)return null;w=w.parentElement}return null};for(let T of d){if(typeof T.targets!="function"||typeof T.startTime!="function"||typeof T.duration!="function")continue;let w=T.startTime(),M=T.parent;for(;M&&typeof M.startTime=="function";)w+=M.startTime(),M=M.parent;let se=w+T.duration();if(!(!Number.isFinite(w)||!Number.isFinite(se)))for(let X of T.targets()){if(!(X instanceof Element))continue;let re=N(X);if(!re)continue;let le=S.get(re);le&&(le.start=Math.min(le.start,w),le.end=Math.max(le.end,se))}}let F=R.length>0?Math.max(...R.map(T=>T.track))+1:0;for(let[T,w]of S){if(w.start===1/0||w.end===-1/0)continue;let M=T;if(q.has(M.id))continue;let se=Math.max(0,w.end-w.start);if(se<=0)continue;let X=H(w.start,se);X<=0||(I=Math.max(I,w.start+X),R.push({id:M.id,label:M.getAttribute("data-timeline-label")??M.getAttribute("data-label")??M.getAttribute("aria-label")??M.id,start:w.start,duration:X,track:Number.parseInt(M.getAttribute("data-track-index")??M.getAttribute("data-track")??"",10)||F,kind:"element",tagName:M.tagName.toLowerCase(),compositionId:M.getAttribute("data-composition-id"),compositionAncestors:W?[W]:[],parentCompositionId:W,nodePath:null,compositionSrc:null,assetUrl:null,timelineRole:M.getAttribute("data-timeline-role"),timelineLabel:M.getAttribute("data-timeline-label"),timelineGroup:M.getAttribute("data-timeline-group"),timelinePriority:te(M.getAttribute("data-timeline-priority"))}),q.add(M.id))}}catch{}}if(y&&c!=null&&c>0){let E=R.length>0?Math.max(...R.map(d=>d.track))+1:0;for(let d of y.children){let S=d;if(!S.id||q.has(S.id))continue;let N=S.tagName.toLowerCase();if(N==="script"||N==="style"||N==="link"||N==="meta"||window.getComputedStyle(S).display==="none")continue;let T=H(0,c);T<=0||(I=Math.max(I,T),R.push({id:S.id,label:S.getAttribute("data-timeline-label")??S.getAttribute("data-label")??S.getAttribute("aria-label")??S.id,start:0,duration:T,track:Number.parseInt(S.getAttribute("data-track-index")??S.getAttribute("data-track")??"",10)||E,kind:"element",tagName:N,compositionId:S.getAttribute("data-composition-id"),compositionAncestors:W?[W]:[],parentCompositionId:W,nodePath:null,compositionSrc:null,assetUrl:null,timelineRole:S.getAttribute("data-timeline-role"),timelineLabel:S.getAttribute("data-timeline-label"),timelineGroup:S.getAttribute("data-timeline-group"),timelinePriority:te(S.getAttribute("data-timeline-priority"))}),q.add(S.id))}}pt(R);for(let E of L){if(E===y)continue;let d=E.getAttribute("data-composition-id");if(!d||!f(d))continue;let S=a.resolveStartForElement(E,0),N=te(E.getAttribute("data-duration")),F=u(d),T=N&&N>0?N:F;if(T==null||T<=0)continue;let w=H(S,T);w<=0||Y.push({id:d,label:E.getAttribute("data-label")??d,start:S,duration:w,thumbnailUrl:Ee(E.getAttribute("data-thumbnail-url")),avatarName:null})}let ve=Math.max(1,Math.min(I||1,e.maxTimelineDurationSeconds));return{source:"hf-preview",type:"timeline",durationInFrames:oe&&ae==null?Number.POSITIVE_INFINITY:Math.max(1,Math.round(ve*Math.max(1,e.canonicalFps))),clips:R,scenes:Y,compositionWidth:te(y?.getAttribute("data-width"))??1920,compositionHeight:te(y?.getAttribute("data-height"))??1080}}var yt=/^(?![a-zA-Z][a-zA-Z\d+\-.]*:)(?!\/\/)(?!\/)(?!\.\.?\/).+/,bt=e=>new Promise(n=>{let i=!1,a=Date.now(),u=null,p=b=>{i||(i=!0,u!=null&&window.clearTimeout(u),n({status:b,elapsedMs:Math.max(0,Date.now()-a)}))};e.addEventListener("load",()=>p("load"),{once:!0}),e.addEventListener("error",()=>p("error"),{once:!0}),u=window.setTimeout(()=>p("timeout"),8e3)});function ot(e){for(;e.firstChild;)e.removeChild(e.firstChild);e.textContent=""}function ht(e,n){let i=e.trim();if(!i)return e;try{return yt.test(i)?new URL(i,document.baseURI).toString():n?new URL(i,n).toString():new URL(i,document.baseURI).toString()}catch{return e}}async function rt(e){let n=null;e.hostCompositionId&&(n=Array.from(e.sourceNode.querySelectorAll("[data-composition-id]")).find(s=>s.getAttribute("data-composition-id")===e.hostCompositionId)??null);let i=n??e.sourceNode,a=Array.from(i.querySelectorAll("style"));for(let f of a){let s=f.cloneNode(!0);s instanceof HTMLStyleElement&&(document.head.appendChild(s),e.injectedStyles.push(s))}let u=Array.from(i.querySelectorAll("script")),p=[];for(let f of u){let s=f.getAttribute("type")?.trim()??"",y=f.getAttribute("src")?.trim()??"";if(y){let h=ht(y,e.compositionUrl);p.push({kind:"external",src:h,type:s})}else{let h=f.textContent?.trim()??"";h&&p.push({kind:"inline",content:h,type:s})}f.parentNode?.removeChild(f)}let b=Array.from(i.querySelectorAll("style"));for(let f of b)f.parentNode?.removeChild(f);if(n){let f=document.importNode(n,!0),s=n.getAttribute("data-width"),y=n.getAttribute("data-height"),h=e.parseDimensionPx(s),v=e.parseDimensionPx(y);f.style.position="relative",f.style.width=h||"100%",f.style.height=v||"100%",h&&f.style.setProperty("--comp-width",h),v&&f.style.setProperty("--comp-height",v),s&&e.host.setAttribute("data-width",s),y&&e.host.setAttribute("data-height",y),h&&e.host instanceof HTMLElement&&(e.host.style.width=h),v&&e.host instanceof HTMLElement&&(e.host.style.height=v),e.host.appendChild(f)}else e.hasTemplate?e.host.appendChild(document.importNode(i,!0)):e.host.innerHTML=e.fallbackBodyInnerHtml;for(let f of p){let s=document.createElement("script");if(f.type&&(s.type=f.type),s.async=!1,f.kind==="external"?s.src=f.src:f.type.toLowerCase()==="module"?s.textContent=f.content:s.textContent=`(function(){${f.content}})();`,document.body.appendChild(s),e.injectedScripts.push(s),f.kind==="external"){let y=await bt(s);y.status!=="load"&&e.onDiagnostic?.({code:"external_composition_script_load_issue",details:{hostCompositionId:e.hostCompositionId,hostCompositionSrc:e.hostCompositionSrc,resolvedScriptSrc:f.src,loadStatus:y.status,elapsedMs:y.elapsedMs}})}}}async function at(e){let n=Array.from(document.querySelectorAll("[data-composition-src]"));n.length!==0&&await Promise.all(n.map(async i=>{let a=i.getAttribute("data-composition-src");if(!a)return;let u=null;try{u=new URL(a,document.baseURI)}catch{u=null}ot(i);try{let p=i.getAttribute("data-composition-id"),b=p!=null?document.querySelector(`template#${CSS.escape(p)}-template`):null;if(b){await rt({host:i,hostCompositionId:p,hostCompositionSrc:a,sourceNode:b.content,hasTemplate:!0,fallbackBodyInnerHtml:"",compositionUrl:u,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,parseDimensionPx:e.parseDimensionPx,onDiagnostic:e.onDiagnostic});return}let f=await fetch(a);if(!f.ok)throw new Error(`HTTP ${f.status}`);let s=await f.text(),h=new DOMParser().parseFromString(s,"text/html"),v=(p?h.querySelector(`template#${CSS.escape(p)}-template`):null)??h.querySelector("template"),k=v?v.content:h.body;await rt({host:i,hostCompositionId:p,hostCompositionSrc:a,sourceNode:k,hasTemplate:!!v,fallbackBodyInnerHtml:h.body.innerHTML,compositionUrl:u,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,parseDimensionPx:e.parseDimensionPx,onDiagnostic:e.onDiagnostic})}catch(p){e.onDiagnostic?.({code:"external_composition_load_failed",details:{hostCompositionId:i.getAttribute("data-composition-id"),hostCompositionSrc:a,errorMessage:p instanceof Error?p.message:"unknown_error"}}),ot(i)}}))}function st(){let e=tt(),n=window,i=null,a=null,u=[],p=new Set,b=null;if(typeof n.__hfRuntimeTeardown=="function")try{n.__hfRuntimeTeardown()}catch{}window.__timelines=window.__timelines||{};let f=t=>{u.push(t)},s=(t,r,o)=>{let m=o??`${t}:${JSON.stringify(r)}`;p.has(m)||(p.add(m),ee({source:"hf-preview",type:"diagnostic",code:t,details:r}))},y=t=>{let r={scale:1,focusX:960,focusY:540},o=[],m=[],l={time:t.getTime(),duration:t.getDuration(),isPlaying:t.isPlaying(),renderMode:!1,timelineDirty:!1};return{play:t.play,pause:t.pause,seek:t.seek,getTime:t.getTime,getDuration:t.getDuration,isPlaying:t.isPlaying,getMainTimeline:()=>null,getElementBounds:()=>{},getElementsAtPoint:()=>{},setElementPosition:()=>{},previewElementPosition:()=>{},setElementKeyframes:()=>{},setElementScale:()=>{},setElementFontSize:()=>{},setElementTextContent:()=>{},setElementTextColor:()=>{},setElementTextShadow:()=>{},setElementTextFontWeight:()=>{},setElementTextFontFamily:()=>{},setElementTextOutline:()=>{},setElementTextHighlight:()=>{},setElementVolume:()=>{},setStageZoom:()=>{},getStageZoom:()=>r,setStageZoomKeyframes:()=>{},getStageZoomKeyframes:()=>o,addElement:()=>!1,removeElement:()=>!1,updateElementTiming:()=>!1,setElementTiming:()=>{},updateElementSrc:()=>!1,updateElementLayer:()=>!1,updateElementBasePosition:()=>!1,markTimelineDirty:()=>{},isTimelineDirty:()=>!1,rebuildTimeline:()=>{},ensureTimeline:()=>{},enableRenderMode:()=>{},disableRenderMode:()=>{},renderSeek:t.renderSeek,getElementVisibility:()=>({visible:!1}),getVisibleElements:()=>m,getRenderState:()=>({...l,time:t.getTime(),duration:t.getDuration(),isPlaying:t.isPlaying()})}},h=1/60,v=.75,k=.75,U=.35,x=900,J=3,B=2,ae=.05,ce=100,oe=240,de=t=>{if(t instanceof Error)return t.message||String(t);if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t??"")}},c=t=>{let r=t.toLowerCase();return r.includes("cannot read properties of null")||r.includes("cannot set properties of null")?{code:"runtime_null_dom_access",category:"dom-null-access"}:r.includes("failed to execute 'queryselector'")?{code:"runtime_invalid_selector",category:"selector-invalid"}:r.includes("is not defined")?{code:"runtime_reference_missing",category:"reference-missing"}:{code:"runtime_script_error",category:"script-error"}},g=t=>{if(t==null||t.trim()==="")return null;let r=Number.parseFloat(t);return!Number.isFinite(r)||r<=0?null:`${r}px`},A=()=>{let t=document.querySelector('[data-composition-id][data-root="true"]');if(t instanceof HTMLElement)return t;let r=Array.from(document.querySelectorAll("[data-composition-id]"));return r.length===0?null:r.find(o=>!o.parentElement?.closest("[data-composition-id]"))??r[0]??null},H=()=>{let t=A();if(!t)return;let r=g(t.getAttribute("data-width")),o=g(t.getAttribute("data-height"));r&&(t.style.width=r),o&&(t.style.height=o),r&&t.style.setProperty("--comp-width",r),o&&t.style.setProperty("--comp-height",o)},L=()=>{let t=A(),r=Array.from(document.querySelectorAll("[data-composition-id]")).filter(o=>o.hasAttribute("data-duration")||o.hasAttribute("data-end"));for(let o of r)t&&o===t||(o.removeAttribute("data-duration"),o.removeAttribute("data-end"))},R=()=>{let t=A();if(!t)return;t.style.position||(t.style.position="relative"),t.style.overflow="hidden";let r=g(t.getAttribute("data-width")),o=g(t.getAttribute("data-height"));r&&(t.style.width=r),o&&(t.style.height=o);let m=Array.from(t.children);for(let l of m){let O=l.tagName.toLowerCase();if(O==="script"||O==="style"||O==="link"||O==="meta"||!l.hasAttribute("data-start"))continue;let K=(l.style.top==="0px"||l.style.top==="0")&&(l.style.left==="0px"||l.style.left==="0")&&l.style.width==="100%"&&l.style.height==="100%",me=/translate\(\s*-50%\s*,\s*-50%\s*\)/.test(l.style.transform);if(K&&me&&!l.hasAttribute("data-width")&&!l.hasAttribute("data-height")){let ie=l.style.top,D=l.style.left,_=l.style.width,P=l.style.height;l.style.top="",l.style.left="",l.style.width="",l.style.height="";let C=window.getComputedStyle(l);C.top!=="auto"||C.bottom!=="auto"||C.left!=="auto"||C.right!=="auto"||C.width!=="0px"||C.height!=="0px"||(l.style.top=ie,l.style.left=D,l.style.width=_,l.style.height=P)}let $=window.getComputedStyle(l),j=$.position;if(j!=="absolute"&&j!=="fixed"&&(l.style.position="absolute"),!!l.style.top||!!l.style.bottom||$.top!=="auto"||$.bottom!=="auto"||(l.style.top="0"),!!l.style.left||!!l.style.right||$.left!=="auto"||$.right!=="auto"||(l.style.left="0"),O!=="audio"){let ie=g(l.getAttribute("data-width")),D=g(l.getAttribute("data-height")),_=$.width!=="0px"&&$.width!=="auto",P=$.height!=="0px"&&$.height!=="auto";ie?!l.style.width&&!_&&(l.style.width=ie):!l.style.width&&$.width==="0px"&&(l.style.width="100%"),D?!l.style.height&&!P&&(l.style.height=D):!l.style.height&&$.height==="0px"&&(l.style.height="100%")}}},Y=(t,r=0)=>ye({timelineRegistry:window.__timelines??{}}).resolveStartForElement(t,r),V=t=>ye({timelineRegistry:window.__timelines??{}}).resolveDurationForElement(t),I=!document.querySelector("[data-composition-src]"),q=t=>{if(!t||typeof t.duration!="function")return null;try{let r=Number(t.duration());return Number.isFinite(r)?Math.max(0,r):null}catch{return null}},W=t=>typeof t=="number"&&Number.isFinite(t)&&t>h,Ae=t=>{let r=Number(t.getAttribute("data-duration"));if(Number.isFinite(r)&&r>0)return r;let o=Number(t.getAttribute("data-playback-start")??t.getAttribute("data-media-start")??"0"),m=Number.isFinite(o)?Math.max(0,o):0;return Number.isFinite(t.duration)&&t.duration>m?Math.max(0,t.duration-m):null},ve=()=>{let t=Array.from(document.querySelectorAll("video[data-start], audio[data-start]"));if(t.length===0)return null;let r=0;for(let o of t){let m=Y(o,0);if(!Number.isFinite(m))continue;let l=Ae(o);l==null||l<=h||(r=Math.max(r,Math.max(0,m)+l))}return r>h?r:null},_e=()=>{let t=ve();return typeof t!="number"||!Number.isFinite(t)||t<=h?null:t},He=t=>W(t)?Math.max(h,t*v):h,E=(t,r=0)=>{let o=q(t),m=_e(),l=Number.isFinite(r)&&r>h?r:0,O=0;W(o)?O=Math.max(o,l):W(m)?O=Math.max(m,l):O=l;let K=Math.max(1,Number(e.maxTimelineDurationSeconds)||1800);return O>0?Math.max(0,Math.min(O,K)):0},d=()=>{let t=window.__timelines??{},r=ye({timelineRegistry:t}),o=_e(),m=He(o),l=D=>{let _=document.querySelector(`[data-composition-id="${CSS.escape(D)}"]`);return _?r.resolveStartForElement(_,0):0},O=D=>{let _=window.gsap;if(!_||typeof _.timeline!="function")return null;let P=_.timeline({paused:!0});for(let C of D)P.add(C.timeline,l(C.compositionId));return P},K=(D,_)=>{if(!W(D))return null;let P=window.gsap;if(!P||typeof P.timeline!="function")return null;let C=P.timeline({paused:!0});if(_)try{C.add(_,0)}catch{}let Z=C;if(typeof Z.to=="function")try{Z.to({},{duration:D})}catch{}return C},me=(D,_)=>{let P=D;if(typeof P.getChildren!="function")return[];try{let C=P.getChildren(!0,!0,!0)??[];if(!Array.isArray(C))return[];let Z=[];for(let Q of _)if(!C.some(he=>he===Q.timeline))try{let he=l(Q.compositionId);D.add(Q.timeline,he),Z.push(Q.compositionId)}catch{}return Z}catch{return[]}},$=A(),j=$?.getAttribute("data-composition-id")??null;if(!j)return{timeline:null};let ne=t[j]??null,z=(()=>{if(!$)return[];let D=new Set,_=Array.from($.querySelectorAll("[data-composition-id]")),P=[];for(let C of _){let Z=C.getAttribute("data-composition-id");if(!Z||Z===j||D.has(Z))continue;D.add(Z);let Q=t[Z]??null;if(!Q||typeof Q.play!="function"||typeof Q.pause!="function")continue;let ge=q(Q);P.push({compositionId:Z,timeline:Q,durationSeconds:ge??0})}return P})(),ie=D=>{for(let _ of D){let P=_.timeline;if(typeof P.paused=="function")try{P.paused(!1)}catch{}}};if(z.length>0&&ie(z),ne){let D=z.length>0?me(ne,z):[];if((z.length>0||!document.querySelector("[data-composition-id]:not([data-composition-id='"+j+"'])"))&&(N=!0),D.length>0)try{let P=ne.time();ne.seek(P,!1)}catch{}let _=q(ne);if(!W(_)&&z.length>0){let P=z.map(he=>he.compositionId),C=O(z),Z=q(C);if(C&&W(Z))return{timeline:C,selectedTimelineIds:P,selectedDurationSeconds:Z,mediaDurationFloorSeconds:o,diagnostics:{code:"root_timeline_unusable_fallback",details:{rootCompositionId:j,rootDurationSeconds:_,fallbackKind:"composite_by_root_children",minCandidateDurationSeconds:m,selectedDurationSeconds:Z,mediaDurationFloorSeconds:o,selectedTimelineIds:P,autoNestedChildren:D}}};let Q=K(o??0,ne),ge=q(Q);if(Q&&W(ge))return{timeline:Q,selectedTimelineIds:[j],selectedDurationSeconds:ge,mediaDurationFloorSeconds:o,diagnostics:{code:"root_timeline_unusable_media_floor_fallback",details:{rootCompositionId:j,rootDurationSeconds:_,fallbackKind:"media_duration_floor",mediaDurationFloorSeconds:o,selectedDurationSeconds:ge,selectedTimelineIds:[j],autoNestedChildren:D}}}}if(!W(_)&&z.length===0){let P=K(o??0,ne),C=q(P);if(P&&W(C))return{timeline:P,selectedTimelineIds:[j],selectedDurationSeconds:C,mediaDurationFloorSeconds:o,diagnostics:{code:"root_timeline_unusable_media_floor_fallback",details:{rootCompositionId:j,rootDurationSeconds:_,fallbackKind:"media_duration_floor",mediaDurationFloorSeconds:o,selectedDurationSeconds:C,selectedTimelineIds:[j]}}}}return{timeline:ne,selectedTimelineIds:[j],selectedDurationSeconds:_,mediaDurationFloorSeconds:o,diagnostics:D.length>0?{code:"root_timeline_auto_nested_children",details:{rootCompositionId:j,selectedDurationSeconds:_,autoNestedChildren:D}}:void 0}}if(z.length>0){let D=z.map(C=>C.compositionId),_=O(z),P=q(_);if(_)return{timeline:_,selectedTimelineIds:D,selectedDurationSeconds:P,mediaDurationFloorSeconds:o,diagnostics:{code:"root_timeline_missing_fallback",details:{rootCompositionId:j,fallbackKind:"composite_by_root_children",minCandidateDurationSeconds:m,selectedDurationSeconds:P,mediaDurationFloorSeconds:o,selectedTimelineIds:D}}}}return{timeline:null}},S=()=>{let t=e.capturedTimeline;if(!t||typeof t.time!="function")return;let r=Number(t.time());Number.isFinite(r)&&(e.currentTime=Math.max(0,r))},N=!1,F=()=>{if(!I)return!1;let t=e.capturedTimeline,r=q(t),o=W(r);if(t&&o&&N)return!1;let m=d();return m.timeline?t&&t===m.timeline?(typeof t.timeScale=="function"&&t.timeScale(e.playbackRate),!1):(e.capturedTimeline=m.timeline,typeof e.capturedTimeline.timeScale=="function"&&e.capturedTimeline.timeScale(e.playbackRate),m.diagnostics&&ee({source:"hf-preview",type:"diagnostic",code:m.diagnostics.code,details:m.diagnostics.details}),ee({source:"hf-preview",type:"diagnostic",code:"timeline_bound",details:{selectedTimelineIds:m.selectedTimelineIds??[],selectedDurationSeconds:m.selectedDurationSeconds??null,mediaDurationFloorSeconds:m.mediaDurationFloorSeconds??null}}),!0):!1},T=()=>{let t=A();if(!(t instanceof HTMLElement))return;let r=t.getBoundingClientRect(),o=Number(t.getAttribute("data-width")),m=Number(t.getAttribute("data-height")),l=window.getComputedStyle(t),O=Number.isFinite(o)&&o>0&&Number.isFinite(m)&&m>0,K=r.width<=0||r.height<=0||t.clientWidth<=0||t.clientHeight<=0;!O||!K||s("root_stage_layout_zero",{compositionId:t.getAttribute("data-composition-id")??null,declaredWidth:o,declaredHeight:m,rectWidth:Math.round(r.width),rectHeight:Math.round(r.height),clientWidth:t.clientWidth,clientHeight:t.clientHeight,display:l.display,visibility:l.visibility,overflow:l.overflow},`root-stage-layout-zero:${t.getAttribute("data-composition-id")??"unknown"}`)},w=()=>{e.tornDown||(b!=null&&window.cancelAnimationFrame(b),b=window.requestAnimationFrame(()=>{b=null,T()}))},M=()=>{i=t=>{let r=de(t.error??t.message).slice(0,oe);if(!r)return;let o=c(r);ee({source:"hf-preview",type:"diagnostic",code:o.code,details:{category:o.category,message:r,filename:t.filename||null,line:Number.isFinite(t.lineno)?t.lineno:null,column:Number.isFinite(t.colno)?t.colno:null}})},a=t=>{let r=de(t.reason).slice(0,oe);if(!r)return;let o=c(r);ee({source:"hf-preview",type:"diagnostic",code:`${o.code}_unhandled_rejection`,details:{category:`${o.category}-unhandled-rejection`,message:r}})},window.addEventListener("error",i),window.addEventListener("unhandledrejection",a)},se=()=>{let t=Array.from(document.querySelectorAll("img, video, audio, source, link[rel='stylesheet']"));for(let o of t){let m=()=>{if(!(o instanceof Element))return;let l=o.tagName.toLowerCase(),O=o.getAttribute("src")??o.getAttribute("href")??o.getAttribute("poster")??null,K=l==="link"?"runtime_stylesheet_load_failed":"runtime_asset_load_failed";s(K,{tagName:l,assetUrl:O,currentSrc:(o instanceof HTMLImageElement||o instanceof HTMLMediaElement)&&o.currentSrc||null,readyState:o instanceof HTMLMediaElement?o.readyState:null,networkState:o instanceof HTMLMediaElement?o.networkState:null},`${K}:${l}:${O??"unknown"}`)};o.addEventListener("error",m),f(()=>{o.removeEventListener("error",m)})}let r=document.fonts;r&&r.ready.then(()=>{if(e.tornDown)return;let o=Array.from(r).filter(m=>m.status==="error").map(m=>m.family).filter(m=>!!m).slice(0,10);o.length!==0&&s("runtime_font_load_issue",{failedFamilies:o,totalFaces:Array.from(r).length},`runtime-font-load-issue:${o.join("|")}`)}).catch(()=>{})},X=(t,r)=>{if(!t.timeline)return!1;let o=e.capturedTimeline;if(o&&o===t.timeline)return!1;let m=Math.max(0,e.currentTime||0),l=e.isPlaying;e.capturedTimeline=t.timeline,typeof e.capturedTimeline.timeScale=="function"&&e.capturedTimeline.timeScale(e.playbackRate);try{e.capturedTimeline.pause(),e.capturedTimeline.seek(m,!1),l&&e.capturedTimeline.play()}catch{}return ee({source:"hf-preview",type:"diagnostic",code:"timeline_loop_guard_rebind",details:{reason:r,previousTime:m,selectedTimelineIds:t.selectedTimelineIds??[],selectedDurationSeconds:t.selectedDurationSeconds??null,mediaDurationFloorSeconds:t.mediaDurationFloorSeconds??null}}),!0},re=null,le=!1,we=new Set,Me=()=>{e.tornDown||(re!=null&&window.clearTimeout(re),re=window.setTimeout(()=>{if(e.tornDown)return;re=null;let t=d();if(!t.timeline||!W(t.mediaDurationFloorSeconds??null))return;if(!e.capturedTimeline){F()&&(fe(),ue(!0));return}if(le)return;let o=q(e.capturedTimeline),m=t.selectedDurationSeconds??q(t.timeline);W(m)&&(!W(o)||m>=o+ae)&&X(t,"manual")&&(le=!0,ee({source:"hf-preview",type:"diagnostic",code:"timeline_rebind_after_media_metadata",details:{previousDurationSeconds:o??null,selectedDurationSeconds:m??null,selectedTimelineIds:t.selectedTimelineIds??[],mediaDurationFloorSeconds:t.mediaDurationFloorSeconds??null}}),fe(),ue(!0))},ce))},ct=()=>{for(let t of we)t.removeEventListener("loadedmetadata",Me),t.removeEventListener("durationchange",Me);we.clear()},Pe=()=>{if(e.tornDown)return;let t=Array.from(document.querySelectorAll("video, audio"));for(let r of t)we.has(r)||(we.add(r),r.addEventListener("loadedmetadata",Me),r.addEventListener("durationchange",Me))},We=()=>{let t=Ze({resolveStartSeconds:m=>Y(m,0)});Ye({clips:t.mediaClips,timeSeconds:e.currentTime,playing:e.isPlaying,playbackRate:e.playbackRate});let r=document.querySelector("[data-composition-id]")?.getAttribute("data-composition-id")??null,o=Array.from(document.querySelectorAll("[data-start]"));for(let m of o){if(!(m instanceof HTMLElement))continue;let l=m.tagName.toLowerCase();if(l==="script"||l==="style"||l==="link"||l==="meta")continue;if(!m.getAttribute("data-composition-id")){let ie=m.closest("[data-composition-id]")?.getAttribute("data-composition-id")??null;if(ie&&ie!==r)continue}let K=Y(m,0),me=V(m),$=me!=null&&me>0?K+me:Number.POSITIVE_INFINITY,j=$,ne=m.getAttribute("data-composition-id");if(ne&&!Number.isFinite($)){let z=(window.__timelines??{})[ne];if(z&&typeof z.duration=="function"){let ie=z.duration();ie>0&&(j=K+ie)}}let Ie=e.currentTime>=K&&(Number.isFinite(j)?e.currentTime<j:!0);m.style.visibility=Ie?"visible":"hidden"}},ue=t=>{S();let r=Math.max(0,Math.round((e.currentTime||0)*e.canonicalFps)),o=Date.now();(t||r!==e.bridgeLastPostedFrame||e.isPlaying!==e.bridgeLastPostedPlaying||e.bridgeMuted!==e.bridgeLastPostedMuted||o-e.bridgeLastPostedAt>=e.bridgeMaxPostIntervalMs)&&(e.bridgeLastPostedFrame=r,e.bridgeLastPostedPlaying=e.isPlaying,e.bridgeLastPostedMuted=e.bridgeMuted,e.bridgeLastPostedAt=o,ee({source:"hf-preview",type:"state",frame:r,isPlaying:e.isPlaying,muted:e.bridgeMuted,playbackRate:e.playbackRate}))},fe=()=>{L(),H(),R();let t=A();if(t){let o=g(t.getAttribute("data-width")),m=g(t.getAttribute("data-height")),l=o?parseInt(o,10):0,O=m?parseInt(m,10):0;l>0&&O>0&&ee({source:"hf-preview",type:"stage-size",width:l,height:O})}F();let r=it({canonicalFps:e.canonicalFps,maxTimelineDurationSeconds:e.maxTimelineDurationSeconds});window.__clipManifest=r,ee(r),w()},be=(t,r=0)=>{for(let o of e.deterministicAdapters){try{t==="discover"&&o.discover(),t==="pause"&&o.pause(),t==="play"&&o.play&&o.play()}catch{}if(t==="discover")try{o.seek({time:r})}catch{}}};I||at({injectedStyles:e.injectedCompStyles,injectedScripts:e.injectedCompScripts,parseDimensionPx:g,onDiagnostic:({code:t,details:r})=>{ee({source:"hf-preview",type:"diagnostic",code:t,details:r})}}).finally(()=>{I=!0,be("discover",e.currentTime),Pe(),se(),fe(),ue(!0)});let ke=Je({postMessage:t=>ee(t)});ke.installPickerApi();let Oe=t=>{let r=Number(t);!Number.isFinite(r)||r<=0?e.playbackRate=1:e.playbackRate=Math.max(.1,Math.min(5,r)),e.capturedTimeline&&typeof e.capturedTimeline.timeScale=="function"&&e.capturedTimeline.timeScale(e.playbackRate);let o=document.querySelectorAll("video, audio");for(let m of o)if(m instanceof HTMLMediaElement)try{m.playbackRate=e.playbackRate}catch{}},G=et({getTimeline:()=>e.capturedTimeline,setTimeline:t=>{e.capturedTimeline=t},getIsPlaying:()=>e.isPlaying,setIsPlaying:t=>{e.isPlaying=t},getPlaybackRate:()=>e.playbackRate,setPlaybackRate:Oe,getCanonicalFps:()=>e.canonicalFps,onSyncMedia:(t,r)=>{e.currentTime=Math.max(0,Number(t)||0),e.isPlaying=r,We()},onStatePost:ue,onDeterministicSeek:t=>{for(let r of e.deterministicAdapters)try{r.seek({time:Number(t)||0})}catch{}},onDeterministicPause:()=>be("pause"),onDeterministicPlay:()=>be("play"),onRenderFrameSeek:()=>{},onShowNativeVideos:()=>{},getSafeDuration:()=>E(e.capturedTimeline,0)});window.__player=y(G),window.__playerReady=!0,window.__renderReady=!0,qe(ee),Se("composition_loaded",{duration:G.getDuration(),compositionId:document.querySelector("[data-composition-id]")?.getAttribute("data-composition-id")??null}),e.controlBridgeHandler=Be({onPlay:()=>{G.play(),Se("composition_played",{time:G.getTime()})},onPause:()=>{G.pause(),Se("composition_paused",{time:G.getTime()})},onSeek:(t,r)=>{let o=Math.max(0,t)/e.canonicalFps;G.seek(o),Se("composition_seeked",{time:o})},onSetMuted:t=>{e.bridgeMuted=t;let r=document.querySelectorAll("video, audio");for(let o of r)o instanceof HTMLMediaElement&&(o.muted=t)},onSetPlaybackRate:t=>Oe(t),onEnablePickMode:()=>ke.enablePickMode(),onDisablePickMode:()=>ke.disablePickMode()}),F(),e.capturedTimeline&&(G._timeline=e.capturedTimeline),I&&setTimeout(()=>{let t=e.capturedTimeline;F()&&e.capturedTimeline!==t&&(G._timeline=e.capturedTimeline),be("discover",e.currentTime),fe(),ue(!0)},0),e.deterministicAdapters=[Ve({resolveStartSeconds:t=>Y(t,0)}),Ke(),$e({getTimeline:()=>e.capturedTimeline}),Ge(),ze()],M(),be("discover"),Pe(),e.timelinePollIntervalId&&clearInterval(e.timelinePollIntervalId);let Le=0,Re=null,Ue=0,De=!1,pe=0,je=()=>{Ue=Date.now(),De=!1,pe=0};e.timelinePollIntervalId=setInterval(()=>{Le+=1;let r=e.isPlaying&&e.capturedTimeline!=null&&Math.max(0,e.currentTime||0)<B?!1:F();if(e.capturedTimeline&&!G._timeline&&(G._timeline=e.capturedTimeline),(r||Le%20===0)&&fe(),Le%10===0&&Pe(),S(),e.isPlaying&&e.capturedTimeline){let o=Math.max(0,e.currentTime||0),m=Re,l=E(e.capturedTimeline,0);if(l>0&&o>=l){G.pause(),G.seek(l),Re=l,pe=0,ue(!0);return}if(m!=null&&m>=k&&o<=U?pe+=1:pe=0,!De&&pe>=J&&Date.now()-Ue>x){let K=d();X(K,"loop_guard")&&(De=!0,pe=0)}Re=Math.max(0,e.currentTime||0)}else Re=Math.max(0,e.currentTime||0);e.isPlaying&&We(),ue(!1)},50),fe(),ue(!0);let ut=G.seek;G.seek=t=>{je(),ut(t)};let dt=G.renderSeek;G.renderSeek=t=>{je(),dt(t)};let Ce=()=>{if(!e.tornDown){e.tornDown=!0,e.timelinePollIntervalId&&(clearInterval(e.timelinePollIntervalId),e.timelinePollIntervalId=null),re!=null&&(window.clearTimeout(re),re=null),b!=null&&(window.cancelAnimationFrame(b),b=null),ct(),e.controlBridgeHandler&&(window.removeEventListener("message",e.controlBridgeHandler),e.controlBridgeHandler=null),i&&(window.removeEventListener("error",i),i=null),a&&(window.removeEventListener("unhandledrejection",a),a=null),e.beforeUnloadHandler&&(window.removeEventListener("beforeunload",e.beforeUnloadHandler),e.beforeUnloadHandler=null),ke.disablePickMode();for(let t of e.deterministicAdapters)if(!(!t||typeof t.revert!="function"))try{t.revert()}catch{}e.deterministicAdapters=[];for(let t of u.splice(0))try{t()}catch{}for(let t of e.injectedCompStyles)try{t.remove()}catch{}e.injectedCompStyles=[];for(let t of e.injectedCompScripts)try{t.remove()}catch{}e.injectedCompScripts=[],e.capturedTimeline=null,n.__hfRuntimeTeardown===Ce&&(n.__hfRuntimeTeardown=null)}};n.__hfRuntimeTeardown=Ce,e.beforeUnloadHandler=Ce,window.addEventListener("beforeunload",e.beforeUnloadHandler)}window.__timelines=window.__timelines||{};function lt(){let e=window;e.__hyperframeRuntimeBootstrapped||(e.__hyperframeRuntimeBootstrapped=!0,st())}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",lt,{once:!0}):lt();})();
|
|
13
13
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/producer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "HTML-to-video rendering engine using Chrome's BeginFrame API",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/heygen-com/hyperframes",
|
|
8
|
+
"directory": "packages/producer"
|
|
9
|
+
},
|
|
5
10
|
"files": [
|
|
6
11
|
"dist/"
|
|
7
12
|
],
|
|
@@ -38,8 +43,8 @@
|
|
|
38
43
|
"linkedom": "^0.18.12",
|
|
39
44
|
"puppeteer": "^24.0.0",
|
|
40
45
|
"puppeteer-core": "^24.39.1",
|
|
41
|
-
"@hyperframes/
|
|
42
|
-
"@hyperframes/
|
|
46
|
+
"@hyperframes/core": "^0.1.7",
|
|
47
|
+
"@hyperframes/engine": "^0.1.7"
|
|
43
48
|
},
|
|
44
49
|
"devDependencies": {
|
|
45
50
|
"@types/node": "^22.10.1",
|