hyperframes 0.4.17 → 0.4.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +698 -562
- package/dist/hyperframe-runtime.js +5 -5
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +5 -5
- package/dist/studio/assets/index-D0VntLIQ.js +115 -0
- package/dist/studio/index.html +1 -1
- package/package.json +1 -1
- package/dist/studio/assets/index-JZr8f8y8.js +0 -115
package/dist/cli.js
CHANGED
|
@@ -54,7 +54,7 @@ var VERSION;
|
|
|
54
54
|
var init_version = __esm({
|
|
55
55
|
"src/version.ts"() {
|
|
56
56
|
"use strict";
|
|
57
|
-
VERSION = true ? "0.4.
|
|
57
|
+
VERSION = true ? "0.4.18" : "0.0.0-dev";
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
|
|
@@ -5994,7 +5994,7 @@ var RUNTIME_IIFE;
|
|
|
5994
5994
|
var init_runtime_inline = __esm({
|
|
5995
5995
|
"../core/src/generated/runtime-inline.ts"() {
|
|
5996
5996
|
"use strict";
|
|
5997
|
-
RUNTIME_IIFE = '"use strict";(()=>{function xe(e){try{window.parent.postMessage(e,"*")}catch{}}function At(e){let t=n=>{let o=n.data;if(!o||o.source!=="hf-parent"||o.type!=="control")return;let r=o.action;if(r==="play"){e.onPlay();return}if(r==="pause"){e.onPause();return}if(r==="seek"){e.onSeek(Number(o.frame??0),o.seekMode??"commit");return}if(r==="set-muted"){e.onSetMuted(!!o.muted);return}if(r==="set-media-output-muted"){e.onSetMediaOutputMuted(!!o.muted);return}if(r==="set-playback-rate"){e.onSetPlaybackRate(Number(o.playbackRate??1));return}if(r==="enable-pick-mode"){e.onEnablePickMode();return}if(r==="disable-pick-mode"){e.onDisablePickMode();return}if(r==="flash-elements"){let i=o.selectors,u=o.duration||800;i&&Nn(i,u)}};return window.addEventListener("message",t),t}function Nn(e,t){if(!document.getElementById("__hf-flash-styles")){let n=document.createElement("style");n.id="__hf-flash-styles",n.textContent=`\n .__hf-flash {\n outline: 2px solid rgba(59, 130, 246, 0.6) !important;\n outline-offset: 2px !important;\n animation: __hf-flash-pulse ${t}ms ease-out forwards !important;\n }\n @keyframes __hf-flash-pulse {\n 0% { outline-color: rgba(59, 130, 246, 0.8); }\n 100% { outline-color: transparent; }\n }\n `,document.head.appendChild(n)}for(let n of e)try{document.querySelectorAll(n).forEach(r=>{r.classList.add("__hf-flash"),setTimeout(()=>r.classList.remove("__hf-flash"),t)})}catch{}}var et=null;function Nt(e){et=e}function Pe(e,t){if(et)try{et({source:"hf-preview",type:"analytics",event:e,properties:t??{}})}catch{}}function Et(e){let t=[],n=d=>{if(typeof d.getAnimations!="function")return[];try{return d.getAnimations()}catch{return[]}},o=(d,c)=>{for(let s of d){try{s.currentTime=c}catch{}try{s.pause()}catch{}}},r=d=>{for(let c of d)try{c.play()}catch{}},i=d=>{for(let c of d)try{c.pause()}catch{}},u=d=>{d.baseDelay?d.el.style.animationDelay=d.baseDelay:d.el.style.removeProperty("animation-delay"),d.basePlayState?d.el.style.animationPlayState=d.basePlayState:d.el.style.removeProperty("animation-play-state")};return{name:"css",discover:()=>{t=[];let d=document.querySelectorAll("*");for(let c of d){if(!(c instanceof HTMLElement))continue;let s=window.getComputedStyle(c);!s.animationName||s.animationName==="none"||t.push({el:c,baseDelay:c.style.animationDelay||"",basePlayState:c.style.animationPlayState||""})}},seek:d=>{let c=Number(d.time)||0;for(let s of t){if(!s.el.isConnected)continue;let a=e?.resolveStartSeconds?e.resolveStartSeconds(s.el):Number.parseFloat(s.el.getAttribute("data-start")??"0")||0,m=Math.max(0,c-a)*1e3,p=n(s.el);if(p.length>0){o(p,m);continue}s.el.style.animationPlayState="paused",s.el.style.animationDelay=`-${(m/1e3).toFixed(3)}s`}},pause:()=>{for(let d of t){if(!d.el.isConnected)continue;let c=n(d.el);c.length>0&&i(c),u(d)}},play:()=>{for(let d of t)d.el.isConnected&&(u(d),r(n(d.el)))},revert:()=>{t=[]}}}function yt(e){return{name:"gsap",discover:()=>{},seek:t=>{let n=e.getTimeline();if(!n)return;n.pause();let o=Math.max(0,Number(t.time)||0);typeof n.totalTime=="function"?n.totalTime(o,!1):n.seek(o,!1)},pause:()=>{let t=e.getTimeline();t&&t.pause()}}}function Ct(){return{name:"lottie",discover:()=>{try{let e=window.lottie;if(e&&typeof e.getRegisteredAnimations=="function"){let t=e.getRegisteredAnimations();if(Array.isArray(t)&&t.length>0){let n=window.__hfLottie??[],o=new Set(n);for(let r of t)o.has(r)||n.push(r);window.__hfLottie=n}}}catch{}},seek:e=>{let t=Math.max(0,Number(e.time)||0),n=window.__hfLottie;if(!(!n||n.length===0))for(let o of n)try{if(bt(o))o.goToAndStop(t*1e3,!1);else if(Mt(o)){if(typeof o.setCurrentRawFrameValue=="function"){let r=o.totalFrames??0,i=o.frameRate??30,u=t*i;r>0&&o.setCurrentRawFrameValue(Math.min(u,r-1))}else if(typeof o.seek=="function"){let r=o.duration??1,i=Math.min(100,t/r*100);o.seek(i)}}}catch{}},pause:()=>{let e=window.__hfLottie;if(!(!e||e.length===0))for(let t of e)try{(bt(t)||Mt(t))&&t.pause()}catch{}},revert:()=>{}}}function bt(e){return typeof e=="object"&&e!==null&&typeof e.goToAndStop=="function"}function Mt(e){return typeof e=="object"&&e!==null&&typeof e.pause=="function"&&("totalFrames"in e||"duration"in e)}function Dt(){let e=null,t=0;return{name:"three",discover:()=>{},seek:n=>{e=Math.max(0,Number(n.time)||0),t=e,window.__hfThreeTime=e;try{window.dispatchEvent(new CustomEvent("hf-seek",{detail:{time:e}}))}catch{}},pause:()=>{e==null&&(e=Math.max(0,t))},play:()=>{e=null},revert:()=>{e=null,t=0}}}function kt(){return{name:"waapi",discover:()=>{},seek:e=>{if(!document.getAnimations)return;let t=Math.max(0,(Number(e.time)||0)*1e3);for(let n of document.getAnimations()){try{n.currentTime=t}catch{}try{n.pause()}catch{}}},pause:()=>{if(document.getAnimations)for(let e of document.getAnimations())try{e.pause()}catch{}}}}function Lt(e){let t=Array.from(document.querySelectorAll("video[data-start], audio[data-start]")),n=[],o=[],r=0;for(let i of t){let u=e?.resolveStartSeconds?e.resolveStartSeconds(i):Number.parseFloat(i.dataset.start??"0");if(!Number.isFinite(u))continue;let d=Number.parseFloat(i.dataset.playbackStart??i.dataset.mediaStart??"0")||0,c=i.defaultPlaybackRate,s=Number.isFinite(c)&&c>0?Math.max(.1,Math.min(5,c)):1,a=i.loop,m=Number.isFinite(i.duration)&&i.duration>0?i.duration:null,p=Number.parseFloat(i.dataset.duration??"");(!Number.isFinite(p)||p<=0)&&m!=null&&(p=Math.max(0,(m-d)/s));let F=Number.isFinite(p)&&p>0?u+p:Number.POSITIVE_INFINITY,D=Number.parseFloat(i.dataset.volume??""),C={el:i,start:u,mediaStart:d,duration:Number.isFinite(p)&&p>0?p:Number.POSITIVE_INFINITY,end:F,volume:Number.isFinite(D)?D:null,playbackRate:s,loop:a,sourceDuration:m};n.push(C),i.tagName==="VIDEO"&&o.push(C),Number.isFinite(F)&&(r=Math.max(r,F))}return{timedMediaEls:t,mediaClips:n,videoClips:o,maxMediaEnd:r}}var tt=new WeakMap,Oe=new WeakSet;function En(e){if(Oe.has(e))return;Oe.add(e);let t=()=>Oe.delete(e);e.addEventListener("playing",t,{once:!0}),e.addEventListener("pause",t,{once:!0}),e.addEventListener("error",t,{once:!0})}function Tt(e){let t=!!(e.outputMuted||e.userMuted);for(let n of e.clips){let{el:o}=n;if(!o.isConnected)continue;let r=(e.timeSeconds-n.start)*n.playbackRate+n.mediaStart;if(e.timeSeconds>=n.start&&e.timeSeconds<n.end&&r>=0){if(n.loop&&n.sourceDuration!=null&&n.sourceDuration>0){let F=n.sourceDuration-n.mediaStart;F>0&&r>=n.sourceDuration&&(r=n.mediaStart+(r-n.mediaStart)%F)}n.volume!=null&&(o.volume=n.volume),t&&(o.muted=!0);try{o.playbackRate=n.playbackRate*e.playbackRate}catch{}let u=o.currentTime||0,d=Math.abs(u-r),c=r-u,s=tt.get(o);tt.set(o,c);let a=s===void 0,m=!a&&Math.abs(c-s)>.5,p=d>3;if(d>.5&&(a||m||p))try{o.currentTime=r}catch{}e.playing&&o.paused&&!Oe.has(o)?(o.preload!=="auto"&&(o.preload="auto"),En(o),o.play().catch(F=>{Oe.delete(o),(F&&typeof F=="object"&&"name"in F?String(F.name??""):"")==="NotAllowedError"&&e.onAutoplayBlocked?.()})):!e.playing&&!o.paused&&o.pause();continue}tt.delete(o),o.paused||o.pause()}}function wt(e){let t=!1,n=null,o=null,r=null,i=null;function u(S,x){try{window.dispatchEvent(new CustomEvent(S,{detail:x}))}catch{}}function d(S){r=S,u("hyperframe:picker:hovered",{elementInfo:r,isPickMode:t,timestamp:Date.now()})}function c(S){i=S,u("hyperframe:picker:selected",{elementInfo:i,isPickMode:t,timestamp:Date.now()})}function s(S){if(!S||S===document.body||S===document.documentElement)return!1;let x=S.tagName.toLowerCase();return!(x==="script"||x==="style"||x==="link"||x==="meta"||S.classList.contains("__hf-pick-highlight"))}function a(S){let x=S;if(x.id)return`#${x.id}`;let g=S.getAttribute("data-composition-id");if(g)return`[data-composition-id="${g}"]`;let E=S.getAttribute("data-composition-src");if(E)return`[data-composition-src="${E}"]`;let b=S.getAttribute("data-track-index");if(b)return`[data-track-index="${b}"]`;let y=S.tagName.toLowerCase(),v=S.parentElement;if(!v)return y;let _=v.querySelectorAll(`:scope > ${y}`);if(_.length===1)return y;for(let O=0;O<_.length;O+=1)if(_[O]===S)return`${y}:nth-of-type(${O+1})`;return y}function m(S){let x=S.tagName.toLowerCase(),g=(S.textContent??"").trim().replace(/\\s+/g," "),E=(b,y)=>b.length>y?`${b.slice(0,y-1)}\\u2026`:b;return x==="h1"||x==="h2"||x==="h3"?"Heading":x==="p"||x==="span"||x==="div"?g.length>0?E(g,56):"Text":x==="img"?"Image":x==="video"?"Video":x==="audio"?"Audio":x==="svg"?"Shape":S.getAttribute("data-composition-src")?"Composition":x==="section"?"Section":`${x.charAt(0).toUpperCase()}${x.slice(1)}`}function p(S,x,g){let E=typeof g=="number"&&g>0?g:8,b=[];if(document.elementsFromPoint)b=document.elementsFromPoint(S,x);else if(document.elementFromPoint){let _=document.elementFromPoint(S,x);b=_?[_]:[]}let y={},v=[];for(let _=0;_<b.length;_+=1){let O=b[_];if(!s(O))continue;let V=`${O.tagName}::${O.id||""}::${_}`;if(!y[V]&&(y[V]=!0,v.push(O),v.length>=E))break}return v}function F(S){let x=S.getBoundingClientRect(),g={};for(let b=0;b<S.attributes.length;b+=1){let y=S.attributes[b];y.name.startsWith("data-")&&(g[y.name]=y.value)}return{id:S.id||null,tagName:S.tagName.toLowerCase(),selector:a(S),label:m(S),boundingBox:{x:x.left,y:x.top,width:x.width,height:x.height},textContent:S.textContent?S.textContent.trim().slice(0,200):null,src:S.getAttribute("src")||S.getAttribute("data-composition-src")||null,dataAttributes:g}}function D(S,x,g){return p(S,x,g).map(F)}function C(S){if(!t)return;let g=p(S.clientX,S.clientY,1)[0]??(S.target instanceof Element?S.target:null);if(!s(g)||n===g)return;n&&n.classList.remove("__hf-pick-highlight"),n=g,g.classList.add("__hf-pick-highlight");let E=F(g);d(E),e.postMessage({source:"hf-preview",type:"element-hovered",elementInfo:E})}function T(S){if(!t)return;S.preventDefault(),S.stopPropagation(),S.stopImmediatePropagation();let x=D(S.clientX,S.clientY,8);x.length!==0&&(d(x[0]??null),e.postMessage({source:"hf-preview",type:"element-pick-candidates",candidates:x,selectedIndex:0,point:{x:S.clientX,y:S.clientY}}))}function U(S){S.key==="Escape"&&(k(),e.postMessage({source:"hf-preview",type:"pick-mode-cancelled"}))}function z(){t||(t=!0,o=document.createElement("style"),o.textContent=[".__hf-pick-highlight { outline: 2px solid #4f8cf7 !important; outline-offset: 2px; cursor: crosshair !important; }",".__hf-pick-active * { cursor: crosshair !important; }"].join(`\n`),document.head.appendChild(o),document.body.classList.add("__hf-pick-active"),document.addEventListener("mousemove",C,!0),document.addEventListener("click",T,!0),document.addEventListener("keydown",U,!0),u("hyperframe:picker:mode",{isPickMode:!0,timestamp:Date.now()}))}function k(){t&&(t=!1,n&&(n.classList.remove("__hf-pick-highlight"),n=null),o&&(o.remove(),o=null),document.body.classList.remove("__hf-pick-active"),document.removeEventListener("mousemove",C,!0),document.removeEventListener("click",T,!0),document.removeEventListener("keydown",U,!0),u("hyperframe:picker:mode",{isPickMode:!1,timestamp:Date.now()}))}function Q(){window.__HF_PICKER_API={enable:z,disable:k,isActive:()=>t,getHovered:()=>r,getSelected:()=>i,getCandidatesAtPoint:(S,x,g)=>Number.isFinite(S)&&Number.isFinite(x)?D(S,x,g):[],pickAtPoint:(S,x,g)=>{if(!Number.isFinite(S)||!Number.isFinite(x))return null;let E=D(S,x,8);if(!E.length)return null;let b=Math.max(0,Math.min(E.length-1,Number(g??0))),y=E[b]??null;return y?(c(y),e.postMessage({source:"hf-preview",type:"element-picked",elementInfo:y}),k(),y):null},pickManyAtPoint:(S,x,g)=>{if(!Number.isFinite(S)||!Number.isFinite(x))return[];let E=D(S,x,8);if(!E.length)return[];let b=[],y=Array.isArray(g)?g:[0];for(let v of y){let _=Math.max(0,Math.min(E.length-1,Math.floor(Number(v)))),O=E[_];if(!O)continue;b.some(w=>w.selector===O.selector&&w.tagName===O.tagName)||b.push(O)}return b.length?(c(b[0]??null),e.postMessage({source:"hf-preview",type:"element-picked-many",elementInfos:b}),k(),b):[]}},u("hyperframe:picker:api-ready",{hasApi:!0,timestamp:Date.now()})}return{enablePickMode:z,disablePickMode:k,installPickerApi:Q}}function nt(e,t){let n=Number.isFinite(t)&&t>0?t:30,o=Number.isFinite(e)&&e>0?e:0;return Math.floor(o*n+1e-9)/n}function Ue(e,t,n){if(e){for(let o of Object.values(e))if(!(!o||o===t))try{n(o)}catch{}}}function Bt(e,t,n){let o=nt(t,n);return e.pause(),typeof e.totalTime=="function"?e.totalTime(o,!1):e.seek(o,!1),o}function yn(e,t,n,o){let r=[];Ue(e,t,i=>{i.play(),r.push(i)});try{return Bt(t,n,o)}finally{for(let i of r)try{i.pause()}catch{}}}function bn(e,t){Ue(e,t,n=>{n.play()})}function Rt(e){return{_timeline:null,play:()=>{let t=e.getTimeline();if(!t||e.getIsPlaying())return;let n=Math.max(0,Number(e.getSafeDuration?.()??t.duration()??0)||0);n>0&&Math.max(0,Number(t.time())||0)>=n&&(t.pause(),t.seek(0,!1),e.onDeterministicSeek(0),e.setIsPlaying(!1),e.onSyncMedia(0,!1),e.onRenderFrameSeek(0)),typeof t.timeScale=="function"&&t.timeScale(e.getPlaybackRate()),t.play(),Ue(e.getTimelineRegistry?.(),t,o=>{typeof o.timeScale=="function"&&o.timeScale(e.getPlaybackRate()),o.play()}),e.onDeterministicPlay(),e.setIsPlaying(!0),e.onShowNativeVideos(),e.onStatePost(!0)},pause:()=>{let t=e.getTimeline();if(!t)return;t.pause(),Ue(e.getTimelineRegistry?.(),t,o=>{o.pause()});let n=Math.max(0,Number(t.time())||0);e.onDeterministicSeek(n),e.onDeterministicPause(),e.setIsPlaying(!1),e.onSyncMedia(n,!1),e.onRenderFrameSeek(n),e.onStatePost(!0)},seek:t=>{let n=e.getTimeline();if(!n)return;let o=Math.max(0,Number(t)||0),r=yn(e.getTimelineRegistry?.(),n,o,e.getCanonicalFps());e.onDeterministicSeek(r),e.setIsPlaying(!1),e.onSyncMedia(r,!1),e.onRenderFrameSeek(r),e.onStatePost(!0)},renderSeek:t=>{let n=e.getTimeline(),o=e.getCanonicalFps(),r=n?(bn(e.getTimelineRegistry?.(),n),Bt(n,t,o)):nt(Math.max(0,Number(t)||0),o);e.onDeterministicSeek(r),e.setIsPlaying(!1),e.onSyncMedia(r,!1),e.onRenderFrameSeek(r),e.onStatePost(!0)},getTime:()=>Number(e.getTimeline()?.time()??0),getDuration:()=>Number(e.getTimeline()?.duration()??0),isPlaying:()=>e.getIsPlaying(),setPlaybackRate:t=>e.setPlaybackRate(t),getPlaybackRate:()=>e.getPlaybackRate()}}function vt(){return{capturedTimeline:null,isPlaying:!1,rafId:null,currentTime:0,deterministicAdapters:[],parityModeEnabled:!0,canonicalFps:30,bridgeMuted:!1,mediaOutputMuted:!1,mediaAutoplayBlockedPosted:!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}}var Mn="data-hf-authored-duration",Cn="data-hf-authored-end";function De(e){if(e==null||e==="")return null;let t=Number(e);return Number.isFinite(t)?t:null}function Dn(e){return De(e.getAttribute("data-duration"))}function kn(e){return De(e.getAttribute("data-end"))}function Ln(e){return De(e.getAttribute(Mn))}function Tn(e){return De(e.getAttribute(Cn))}function wn(e){let t=(e??"").trim();if(!t)return null;let n=De(t);if(n!=null)return{kind:"absolute",value:n};let o=t.match(/^([A-Za-z0-9_.:-]+)(?:\\s*([+-])\\s*([0-9]*\\.?[0-9]+))?$/);if(!o)return null;let r=(o[1]??"").trim();if(!r)return null;let i=o[2]??"+",u=o[3]??"0",d=Number.parseFloat(u),c=Number.isFinite(d)?Math.max(0,d):0,s=i==="-"?-c:c;return{kind:"reference",refId:r,offset:s}}function we(e){let t=e.timelineRegistry??{},n=e.includeAuthoredTimingAttrs??!1,o=new WeakMap,r=new WeakMap,i=new Set,u=a=>{let m=document.getElementById(a);return m||(document.querySelector(`[data-composition-id="${CSS.escape(a)}"]`)??null)},d=a=>{let m=r.get(a);if(m!==void 0)return m;let p=null,F=Dn(a)??(n?Ln(a):null);if(F!=null&&F>0&&(p=F),p==null||p<=0){let D=kn(a)??(n?Tn(a):null);if(D!=null){let C=s(a,0),T=D-C;Number.isFinite(T)&&T>0&&(p=T)}}if((p==null||p<=0)&&a instanceof HTMLMediaElement){let D=De(a.getAttribute("data-playback-start"))??De(a.getAttribute("data-media-start"))??0;Number.isFinite(a.duration)&&a.duration>D&&(p=a.duration-D)}if(p==null||p<=0){let D=a.getAttribute("data-composition-id");if(D){let C=t[D]??null;if(C&&typeof C.duration=="function")try{let T=Number(C.duration());Number.isFinite(T)&&T>0&&(p=T)}catch{}}}return p!=null&&Number.isFinite(p)&&p>0?(r.set(a,p),p):(r.set(a,null),null)},c=(a,m)=>{if(a.hasAttribute("data-composition-id")){let F=a.parentElement?.closest("[data-composition-id]");return F?s(F,m):0}let p=a.closest("[data-composition-id]");return p?s(p,m):0},s=(a,m)=>{let p=o.get(a);if(p!==void 0)return p??m;if(i.has(a))return m;i.add(a);try{let F=wn(a.getAttribute("data-start"));if(!F){if(a.hasAttribute("data-composition-id")){let z=a.parentElement;if(z&&(z.hasAttribute("data-composition-src")||z.hasAttribute("data-composition-id"))){let k=s(z,m);return o.set(a,k),k}}return o.set(a,m),m}if(F.kind==="absolute"){let z=Math.max(0,F.value),k=Math.max(0,c(a,m)+z);return o.set(a,k),k}let D=u(F.refId);if(!D)return o.set(a,m),m;let C=s(D,0),T=d(D);if(T==null||T<=0){let z=Math.max(0,C+F.offset);return o.set(a,z),z}let U=Math.max(0,C+T+F.offset);return o.set(a,U),U}finally{i.delete(a)}};return{resolveStartForElement:(a,m=0)=>s(a,Math.max(0,m)),resolveDurationForElement:a=>d(a)}}var Bn="data-hf-authored-duration",Rn="data-hf-authored-end";function fe(e){if(e==null||e==="")return null;let t=Number(e);return Number.isFinite(t)?t:null}function it(e){return fe(e.getAttribute("data-duration"))??fe(e.getAttribute(Bn))}function It(e){return fe(e.getAttribute("data-end"))??fe(e.getAttribute(Rn))}function ot(...e){let t=e.filter(n=>Number.isFinite(n??null));return t.length===0?null:Math.max(...t)}var Pt={composition:0,video:1,image:2,element:3,audio:4};function vn(e){if(e.length===0)return;let t=new Map;for(let u of e){let d=t.get(u.track)??new Set;d.add(u.kind),t.set(u.track,d)}if(!Array.from(t.values()).some(u=>u.size>1))return;let o=0,r=new Map,i=[...t.keys()].sort((u,d)=>u-d);for(let u of i){let d=t.get(u);if(d.size===1)r.set(`${u}:${[...d][0]}`,o++);else{let c=[...d].sort((s,a)=>(Pt[s]??99)-(Pt[a]??99));for(let s of c)r.set(`${u}:${s}`,o++)}}for(let u of e){let d=`${u.track}:${u.kind}`,c=r.get(d);c!=null&&(u.track=c)}}function _e(e){let t=String(e??"").trim();if(!t)return null;let n=t.toLowerCase();if(n.startsWith("data:")||n.startsWith("javascript:"))return null;try{return new URL(t,document.baseURI).toString()}catch{return t}}function In(e){let t=e.getAttribute("src")??e.getAttribute("data-src");if(t)return _e(t);let n=e.getAttribute("data-composition-src");if(n)return _e(n);let o=e.querySelector("img[src], video[src], audio[src], source[src]");return o?_e(o.getAttribute("src")):null}function Ot(e){let n=window.__timelines??{},o=we({timelineRegistry:n,includeAuthoredTimingAttrs:!0}),r=B=>{if(!B)return null;let M=n[B]??null;if(!M||typeof M.duration!="function")return null;try{let L=Number(M.duration());return Number.isFinite(L)&&L>0?L:null}catch{return null}},i=B=>{let M=fe(B.getAttribute("data-duration"));if(M!=null&&M>0)return M;let L=fe(B.getAttribute("data-playback-start"))??fe(B.getAttribute("data-media-start"))??0;return Number.isFinite(B.duration)&&B.duration>L?Math.max(0,B.duration-L):null},u=()=>{let B=Array.from(document.querySelectorAll("video[data-start], audio[data-start]"));if(B.length===0)return null;let M=0;for(let L of B){let J=o.resolveStartForElement(L,0);if(!Number.isFinite(J))continue;let X=i(L);X==null||X<=0||(M=Math.max(M,Math.max(0,J)+X))}return M>0?M:null},d=B=>{let M=B.trim().toLowerCase();return!(!M||M==="main"||M.includes("caption")||M.includes("ambient"))},c=(B,M)=>{let L=[],J=null,X=null,I=null,P=B.parentElement;for(;P;){let H=P.getAttribute("data-composition-id");H&&(L.push(H),!I&&P!==M&&(I=H),J==null&&(J=o.resolveStartForElement(P,0)),X==null&&(X=fe(P.getAttribute("data-duration"))??r(H)??null)),P=P.parentElement}return{parentCompositionId:I,compositionAncestors:L.reverse(),inheritedStart:J,inheritedDuration:X}},s=document.querySelector("[data-composition-id]"),a=Array.from(document.querySelectorAll("[data-composition-id]")),m=s?.getAttribute("data-composition-id")??null,p=s?o.resolveStartForElement(s,0):0,F=u(),D=F!=null?Math.max(0,F-Math.max(0,p)):null,C=r(m),T=it(s??document.body),U=ot(...a.filter(B=>B!==s).map(B=>{let M=o.resolveStartForElement(B,0),L=o.resolveDurationForElement(B)??r(B.getAttribute("data-composition-id"))??null;return!Number.isFinite(M)||L==null||L<=0?null:Math.max(0,M)+L})),z=U!=null?Math.max(0,U-Math.max(0,p)):null,k=typeof C=="number"&&Number.isFinite(C)&&C>0?C:null,Q=typeof T=="number"&&Number.isFinite(T)&&T>0?T:null,S=typeof D=="number"&&Number.isFinite(D)&&D>0?D:null,x=typeof z=="number"&&Number.isFinite(z)&&z>0?z:null,g=ot(S,x),E=k!=null&&g!=null&&k>g+1,b=Q??(E?g:ot(k,S,x)),y=b!=null?Math.min(b,e.maxTimelineDurationSeconds):null,_=(y!=null?p+y:null)??(typeof F=="number"&&Number.isFinite(F)&&F>0?F:null),O=(B,M)=>!Number.isFinite(M)||M<=0?0:_==null||!Number.isFinite(_)?M:!Number.isFinite(B)||B>=_?0:Math.max(0,Math.min(M,_-B)),V=[],w=[],K=Array.from(document.querySelectorAll("[data-start], [data-track-index], [data-composition-id], video, audio, img")),Z=0;for(let B=0;B<K.length;B+=1){let M=K[B];if(M===s||["SCRIPT","STYLE","LINK","META","TEMPLATE","NOSCRIPT"].includes(M.tagName))continue;let L=c(M,s),J=o.resolveStartForElement(M,L.inheritedStart??0),X=M.getAttribute("data-composition-id"),I=it(M);if((I==null||I<=0)&&X&&X!==m&&(I=r(X)),(I==null||I<=0)&&M instanceof HTMLMediaElement){let de=fe(M.getAttribute("data-playback-start"))??fe(M.getAttribute("data-media-start"))??0;Number.isFinite(M.duration)&&M.duration>0&&(I=Math.max(0,M.duration-de))}if(I==null||I<=0){let de=L.inheritedDuration;if(de!=null&&de>0){let he=(L.inheritedStart??0)+de;I=Math.max(0,he-J)}}if(I==null||I<=0||(I=O(J,I),I<=0))continue;let P=J+I;Z=Math.max(Z,P);let H=M.tagName.toLowerCase(),ce=X&&X!==m?"composition":H==="video"?"video":H==="audio"?"audio":H==="img"?"image":"element";V.push({id:M.id||X||`__node__index_${B}`,label:M.getAttribute("data-timeline-label")??M.getAttribute("data-label")??M.getAttribute("aria-label")??X??M.id??M.className?.split(" ")[0]??ce,start:J,duration:I,track:Number.parseInt(M.getAttribute("data-track-index")??M.getAttribute("data-track")??String(B),10)||0,kind:ce,tagName:H,compositionId:M.getAttribute("data-composition-id"),compositionAncestors:L.compositionAncestors,parentCompositionId:L.parentCompositionId,nodePath:null,compositionSrc:_e(M.getAttribute("data-composition-src")),assetUrl:In(M),timelineRole:M.getAttribute("data-timeline-role"),timelineLabel:M.getAttribute("data-timeline-label"),timelineGroup:M.getAttribute("data-timeline-group"),timelinePriority:fe(M.getAttribute("data-timeline-priority"))})}let W=new Set(V.map(B=>B.id)),j=s?.getAttribute("data-composition-id")??null,R=j?n[j]??null:null;if(R&&s){let B=R;if(typeof B.getChildren=="function")try{let M=B.getChildren(!0,!0,!1)??[],L=new Map;for(let I of s.children){let P=I;if(!P.id)continue;let H=P.tagName.toLowerCase();H==="script"||H==="style"||H==="link"||L.set(P,{id:P.id,start:1/0,end:-1/0})}let J=I=>{let P=I;for(;P;){if(L.has(P))return P;if(P===s)return null;P=P.parentElement}return null};for(let I of M){if(typeof I.targets!="function"||typeof I.startTime!="function"||typeof I.duration!="function")continue;let P=I.startTime(),H=I.parent;for(;H&&typeof H.startTime=="function";)P+=H.startTime(),H=H.parent;let ce=P+I.duration();if(!(!Number.isFinite(P)||!Number.isFinite(ce)))for(let de of I.targets()){if(!(de instanceof Element))continue;let Ne=J(de);if(!Ne)continue;let he=L.get(Ne);he&&(he.start=Math.min(he.start,P),he.end=Math.max(he.end,ce))}}let X=V.length>0?Math.max(...V.map(I=>I.track))+1:0;for(let[I,P]of L){if(P.start===1/0||P.end===-1/0)continue;let H=I;if(W.has(H.id))continue;let ce=Math.max(0,P.end-P.start);if(ce<=0)continue;let de=O(P.start,ce);de<=0||(Z=Math.max(Z,P.start+de),V.push({id:H.id,label:H.getAttribute("data-timeline-label")??H.getAttribute("data-label")??H.getAttribute("aria-label")??H.id,start:P.start,duration:de,track:Number.parseInt(H.getAttribute("data-track-index")??H.getAttribute("data-track")??"",10)||X,kind:"element",tagName:H.tagName.toLowerCase(),compositionId:H.getAttribute("data-composition-id"),compositionAncestors:j?[j]:[],parentCompositionId:j,nodePath:null,compositionSrc:null,assetUrl:null,timelineRole:H.getAttribute("data-timeline-role"),timelineLabel:H.getAttribute("data-timeline-label"),timelineGroup:H.getAttribute("data-timeline-group"),timelinePriority:fe(H.getAttribute("data-timeline-priority"))}),W.add(H.id))}}catch{}}if(s&&y!=null&&y>0){let B=V.length>0?Math.max(...V.map(M=>M.track))+1:0;for(let M of s.children){let L=M;if(!L.id||W.has(L.id))continue;let J=L.getAttribute("data-timeline-role");if(J!=="overlay"&&J!=="persistent-overlay")continue;let X=L.tagName.toLowerCase();if(X==="script"||X==="style"||X==="link"||X==="meta"||window.getComputedStyle(L).display==="none")continue;let P=O(0,y);P<=0||(Z=Math.max(Z,P),V.push({id:L.id,label:L.getAttribute("data-timeline-label")??L.getAttribute("data-label")??L.getAttribute("aria-label")??L.id,start:0,duration:P,track:Number.parseInt(L.getAttribute("data-track-index")??L.getAttribute("data-track")??"",10)||B,kind:"element",tagName:X,compositionId:L.getAttribute("data-composition-id"),compositionAncestors:j?[j]:[],parentCompositionId:j,nodePath:null,compositionSrc:null,assetUrl:null,timelineRole:J,timelineLabel:L.getAttribute("data-timeline-label"),timelineGroup:L.getAttribute("data-timeline-group"),timelinePriority:fe(L.getAttribute("data-timeline-priority"))}),W.add(L.id))}}vn(V);for(let B of a){if(B===s)continue;let M=B.getAttribute("data-composition-id");if(!M||!d(M))continue;let L=o.resolveStartForElement(B,0),J=it(B);if((J==null||J<=0)&&It(B)!=null){let H=It(B);J=Math.max(0,H-L)}let X=r(M),I=J&&J>0?J:X;if(I==null||I<=0)continue;let P=O(L,I);P<=0||w.push({id:M,label:B.getAttribute("data-label")??M,start:L,duration:P,thumbnailUrl:_e(B.getAttribute("data-thumbnail-url")),avatarName:null})}let $=Math.max(1,Math.min(Math.max(Z||1,y??0),e.maxTimelineDurationSeconds));return{source:"hf-preview",type:"timeline",durationInFrames:E&&Q==null?Number.POSITIVE_INFINITY:Math.max(1,Math.round($*Math.max(1,e.canonicalFps))),clips:V,scenes:w,compositionWidth:fe(s?.getAttribute("data-width"))??1920,compositionHeight:fe(s?.getAttribute("data-height"))??1080}}var Pn=/^(?![a-zA-Z][a-zA-Z\\d+\\-.]*:)(?!\\/\\/)(?!\\/)(?!\\.\\.?\\/).+/,On=e=>new Promise(t=>{let n=!1,o=Date.now(),r=null,i=u=>{n||(n=!0,r!=null&&window.clearTimeout(r),t({status:u,elapsedMs:Math.max(0,Date.now()-o)}))};e.addEventListener("load",()=>i("load"),{once:!0}),e.addEventListener("error",()=>i("error"),{once:!0}),r=window.setTimeout(()=>i("timeout"),8e3)});function rt(e){for(;e.firstChild;)e.removeChild(e.firstChild);e.textContent=""}function _t(e,t){let n=e.trim();if(!n)return e;try{return Pn.test(n)?new URL(n,document.baseURI).toString():t?new URL(n,t).toString():new URL(n,document.baseURI).toString()}catch{return e}}async function st(e){let t=null;e.hostCompositionId&&(t=Array.from(e.sourceNode.querySelectorAll("[data-composition-id]")).find(s=>s.getAttribute("data-composition-id")===e.hostCompositionId)??null);let n=t??e.sourceNode;if(e.headStyles)for(let c of e.headStyles){let s=c.cloneNode(!0);s instanceof HTMLStyleElement&&(document.head.appendChild(s),e.injectedStyles.push(s))}let o=Array.from(n.querySelectorAll("style"));for(let c of o){let s=c.cloneNode(!0);s instanceof HTMLStyleElement&&(document.head.appendChild(s),e.injectedStyles.push(s))}let r=[];if(e.headScripts)for(let c of e.headScripts){let s=c.getAttribute("type")?.trim()??"",a=c.getAttribute("src")?.trim()??"";if(a){let m=_t(a,e.compositionUrl);r.push({kind:"external",src:m,type:s})}else{let m=c.textContent?.trim()??"";m&&r.push({kind:"inline",content:m,type:s})}}let i=Array.from(n.querySelectorAll("script")),u=[...r];for(let c of i){let s=c.getAttribute("type")?.trim()??"",a=c.getAttribute("src")?.trim()??"";if(a){let m=_t(a,e.compositionUrl);u.push({kind:"external",src:m,type:s})}else{let m=c.textContent?.trim()??"";m&&u.push({kind:"inline",content:m,type:s})}c.parentNode?.removeChild(c)}let d=Array.from(n.querySelectorAll("style"));for(let c of d)c.parentNode?.removeChild(c);if(t){let c=document.importNode(t,!0),s=t.getAttribute("data-width"),a=t.getAttribute("data-height"),m=e.parseDimensionPx(s),p=e.parseDimensionPx(a);c.style.position="relative",c.style.width=m||"100%",c.style.height=p||"100%",m&&c.style.setProperty("--comp-width",m),p&&c.style.setProperty("--comp-height",p),s&&e.host.setAttribute("data-width",s),a&&e.host.setAttribute("data-height",a),m&&e.host instanceof HTMLElement&&(e.host.style.width=m),p&&e.host instanceof HTMLElement&&(e.host.style.height=p),e.host.appendChild(c)}else e.hasTemplate?e.host.appendChild(document.importNode(n,!0)):e.host.innerHTML=e.fallbackBodyInnerHtml;for(let c of u){let s=document.createElement("script");if(c.type&&(s.type=c.type),s.async=!1,c.kind==="external"?s.src=c.src:c.type.toLowerCase()==="module"?s.textContent=c.content:s.textContent=`(function(){${c.content}})();`,document.body.appendChild(s),e.injectedScripts.push(s),c.kind==="external"){let a=await On(s);a.status!=="load"&&e.onDiagnostic?.({code:"external_composition_script_load_issue",details:{hostCompositionId:e.hostCompositionId,hostCompositionSrc:e.hostCompositionSrc,resolvedScriptSrc:c.src,loadStatus:a.status,elapsedMs:a.elapsedMs}})}}}async function Wt(e){let t=Array.from(document.querySelectorAll("[data-composition-id]:not([data-composition-src])")).filter(n=>{if(n.children.length>0)return!1;let o=n.getAttribute("data-composition-id");return o?!!document.querySelector(`template#${CSS.escape(o)}-template`):!1});if(t.length!==0)for(let n of t){let o=n.getAttribute("data-composition-id"),r=document.querySelector(`template#${CSS.escape(o)}-template`);rt(n),await st({host:n,hostCompositionId:o,hostCompositionSrc:`template#${o}-template`,sourceNode:r.content,hasTemplate:!0,fallbackBodyInnerHtml:"",compositionUrl:null,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,parseDimensionPx:e.parseDimensionPx,onDiagnostic:e.onDiagnostic})}}async function Ht(e){let t=Array.from(document.querySelectorAll("[data-composition-src]"));t.length!==0&&await Promise.all(t.map(async n=>{let o=n.getAttribute("data-composition-src");if(!o)return;let r=null;try{r=new URL(o,document.baseURI)}catch{r=null}rt(n);try{let i=n.getAttribute("data-composition-id"),u=i!=null?document.querySelector(`template#${CSS.escape(i)}-template`):null;if(u){await st({host:n,hostCompositionId:i,hostCompositionSrc:o,sourceNode:u.content,hasTemplate:!0,fallbackBodyInnerHtml:"",compositionUrl:r,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,parseDimensionPx:e.parseDimensionPx,onDiagnostic:e.onDiagnostic});return}let d=await fetch(o);if(!d.ok)throw new Error(`HTTP ${d.status}`);let c=await d.text(),a=new DOMParser().parseFromString(c,"text/html"),m=(i?a.querySelector(`template#${CSS.escape(i)}-template`):null)??a.querySelector("template"),p=m?m.content:a.body,F=m?void 0:Array.from(a.head.querySelectorAll("style")),D=m?void 0:Array.from(a.head.querySelectorAll("script"));await st({host:n,hostCompositionId:i,hostCompositionSrc:o,sourceNode:p,hasTemplate:!!m,fallbackBodyInnerHtml:a.body.innerHTML,compositionUrl:r,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,parseDimensionPx:e.parseDimensionPx,headStyles:F,headScripts:D,onDiagnostic:e.onDiagnostic})}catch(i){e.onDiagnostic?.({code:"external_composition_load_failed",details:{hostCompositionId:n.getAttribute("data-composition-id"),hostCompositionSrc:o,errorMessage:i instanceof Error?i.message:"unknown_error"}}),rt(n)}}))}function at(){let e=window.gsap;e&&document.querySelectorAll(".caption-group").length!==0&&fetch("caption-overrides.json").then(t=>t.ok?t.json():null).then(t=>{if(!t||!Array.isArray(t)||t.length===0)return;let n=[],o=document.querySelectorAll(".caption-group");for(let r of o){let i=r.querySelectorAll(":scope > span");for(let u of i)n.push(u)}for(let r of t){let i=null;if(r.wordId&&(i=document.getElementById(r.wordId)),!i&&r.wordIndex!==void 0&&(i=n[r.wordIndex]??null),!i||!(i instanceof HTMLElement))continue;let u={},d={};if(r.x!==void 0&&(u.x=r.x),r.y!==void 0&&(u.y=r.y),r.scale!==void 0&&(u.scale=r.scale),r.rotation!==void 0&&(u.rotation=r.rotation),r.opacity!==void 0&&(d.opacity=r.opacity),r.fontSize!==void 0&&(d.fontSize=`${r.fontSize}px`),r.fontWeight!==void 0&&(d.fontWeight=r.fontWeight),r.fontFamily!==void 0&&(d.fontFamily=r.fontFamily),r.activeColor||r.dimColor){let s=e.getTweensOf(i).filter(m=>m.vars.color!==void 0).sort((m,p)=>m.startTime()-p.startTime()),a=s.length>0?String(s[0].vars.color):"";for(let m of s)String(m.vars.color)===a?r.dimColor&&(m.vars.color=r.dimColor):r.activeColor&&(m.vars.color=r.activeColor);r.dimColor&&e.set(i,{color:r.dimColor})}if(Object.keys(d).length>0&&e.set(i,d),Object.keys(u).length>0){let c=document.createElement("span");c.style.display="inline-block",c.dataset.captionWrapper="true",i.parentNode?.insertBefore(c,i),c.appendChild(i),e.set(c,u)}}}).catch(()=>{})}var jt="data-hf-authored-duration",zt="data-hf-authored-end";function Ut(){let e=vt(),t=window,n=null,o=null,r=[],i=new Set,u=null;if(typeof t.__hfRuntimeTeardown=="function")try{t.__hfRuntimeTeardown()}catch{}document.documentElement&&(document.documentElement.style.margin="0",document.documentElement.style.padding="0",document.documentElement.style.overflow="hidden"),document.body&&(document.body.style.margin="0",document.body.style.padding="0",document.body.style.overflow="hidden"),window.__timelines=window.__timelines||{};let d=l=>{r.push(l)},c=(l,h,f)=>{let N=f??`${l}:${JSON.stringify(h)}`;i.has(N)||(i.add(N),xe({source:"hf-preview",type:"diagnostic",code:l,details:h}))},s=l=>{let h={scale:1,focusX:960,focusY:540},f=[],N=[],A={time:l.getTime(),duration:l.getDuration(),isPlaying:l.isPlaying(),renderMode:!1,timelineDirty:!1};return{play:l.play,pause:l.pause,seek:l.seek,getTime:l.getTime,getDuration:l.getDuration,isPlaying:l.isPlaying,getMainTimeline:()=>null,getElementBounds:()=>{},getElementsAtPoint:()=>{},setElementPosition:()=>{},previewElementPosition:()=>{},setElementKeyframes:()=>{},setElementScale:()=>{},setElementFontSize:()=>{},setElementTextContent:()=>{},setElementTextColor:()=>{},setElementTextShadow:()=>{},setElementTextFontWeight:()=>{},setElementTextFontFamily:()=>{},setElementTextOutline:()=>{},setElementTextHighlight:()=>{},setElementVolume:()=>{},setStageZoom:()=>{},getStageZoom:()=>h,setStageZoomKeyframes:()=>{},getStageZoomKeyframes:()=>f,addElement:()=>!1,removeElement:()=>!1,updateElementTiming:()=>!1,setElementTiming:()=>{},updateElementSrc:()=>!1,updateElementLayer:()=>!1,updateElementBasePosition:()=>!1,markTimelineDirty:()=>{},isTimelineDirty:()=>!1,rebuildTimeline:()=>{},ensureTimeline:()=>{},enableRenderMode:()=>{},disableRenderMode:()=>{},renderSeek:l.renderSeek,getElementVisibility:()=>({visible:!1}),getVisibleElements:()=>N,getRenderState:()=>({...A,time:l.getTime(),duration:l.getDuration(),isPlaying:l.isPlaying()})}},a=1/60,m=.75,p=.75,F=.35,D=900,C=3,T=2,U=.05,z=100,k=240,Q=l=>{if(l instanceof Error)return l.message||String(l);if(typeof l=="string")return l;try{return JSON.stringify(l)}catch{return String(l??"")}},S=l=>{let h=l.toLowerCase();return h.includes("cannot read properties of null")||h.includes("cannot set properties of null")?{code:"runtime_null_dom_access",category:"dom-null-access"}:h.includes("failed to execute \'queryselector\'")?{code:"runtime_invalid_selector",category:"selector-invalid"}:h.includes("is not defined")?{code:"runtime_reference_missing",category:"reference-missing"}:{code:"runtime_script_error",category:"script-error"}},x=l=>{if(l==null||l.trim()==="")return null;let h=Number.parseFloat(l);return!Number.isFinite(h)||h<=0?null:`${h}px`},g=()=>{let l=document.querySelector(\'[data-composition-id][data-root="true"]\');if(l instanceof HTMLElement)return l;let h=Array.from(document.querySelectorAll("[data-composition-id]"));return h.length===0?null:h.find(f=>!f.parentElement?.closest("[data-composition-id]"))??h[0]??null},E=()=>{let l=g();if(!l)return;let h=x(l.getAttribute("data-width")),f=x(l.getAttribute("data-height"));h&&(l.style.width=h),f&&(l.style.height=f),h&&l.style.setProperty("--comp-width",h),f&&l.style.setProperty("--comp-height",f)},b=()=>{let l=g(),h=Array.from(document.querySelectorAll("[data-composition-id]")).filter(f=>f.hasAttribute("data-duration")||f.hasAttribute("data-end"));for(let f of h){if(l&&f===l)continue;let N=f.getAttribute("data-duration"),A=f.getAttribute("data-end");N!=null&&!f.hasAttribute(jt)&&f.setAttribute(jt,N),A!=null&&!f.hasAttribute(zt)&&f.setAttribute(zt,A),f.removeAttribute("data-duration"),f.removeAttribute("data-end")}},y=()=>{let l=g();if(!l)return;l.style.position||(l.style.position="relative"),l.style.overflow="hidden";let h=x(l.getAttribute("data-width")),f=x(l.getAttribute("data-height"));h&&(l.style.width=h),f&&(l.style.height=f);let N=Array.from(l.children);for(let A of N){let te=A.tagName.toLowerCase();if(te==="script"||te==="style"||te==="link"||te==="meta"||!A.hasAttribute("data-start"))continue;let le=(A.style.top==="0px"||A.style.top==="0")&&(A.style.left==="0px"||A.style.left==="0")&&A.style.width==="100%"&&A.style.height==="100%",Me=/translate\\(\\s*-50%\\s*,\\s*-50%\\s*\\)/.test(A.style.transform);if(le&&Me&&!A.hasAttribute("data-width")&&!A.hasAttribute("data-height")){let ge=A.style.top,Y=A.style.left,G=A.style.width,ee=A.style.height;A.style.top="",A.style.left="",A.style.width="",A.style.height="";let q=window.getComputedStyle(A);q.top!=="auto"||q.bottom!=="auto"||q.left!=="auto"||q.right!=="auto"||q.width!=="0px"||q.height!=="0px"||(A.style.top=ge,A.style.left=Y,A.style.width=G,A.style.height=ee)}let oe=window.getComputedStyle(A),ie=oe.position;if(ie!=="absolute"&&ie!=="fixed"&&(A.style.position="absolute"),!!A.style.top||!!A.style.bottom||oe.top!=="auto"||oe.bottom!=="auto"||(A.style.top="0"),!!A.style.left||!!A.style.right||oe.left!=="auto"||oe.right!=="auto"||(A.style.left="0"),te!=="audio"){let ge=x(A.getAttribute("data-width")),Y=x(A.getAttribute("data-height")),G=oe.width!=="0px"&&oe.width!=="auto",ee=oe.height!=="0px"&&oe.height!=="auto";ge?!A.style.width&&!G&&(A.style.width=ge):!A.style.width&&oe.width==="0px"&&(A.style.width="100%"),Y?!A.style.height&&!ee&&(A.style.height=Y):!A.style.height&&oe.height==="0px"&&(A.style.height="100%")}}},v=(l,h=0)=>we({timelineRegistry:window.__timelines??{}}).resolveStartForElement(l,h),_=l=>we({timelineRegistry:window.__timelines??{},includeAuthoredTimingAttrs:!0}).resolveDurationForElement(l),O=!!document.querySelector("[data-composition-src]"),V=!1;{let l=document.querySelectorAll("[data-composition-id]:not([data-composition-src])");for(let h of l){let f=h.getAttribute("data-composition-id");if(f&&h.children.length===0&&document.querySelector(`template#${CSS.escape(f)}-template`)){V=!0;break}}}let w=!O&&!V,K=l=>{if(!l||typeof l.duration!="function")return null;try{let h=Number(l.duration());return Number.isFinite(h)?Math.max(0,h):null}catch{return null}},Z=l=>typeof l=="number"&&Number.isFinite(l)&&l>a,W=l=>{let h=Number(l.getAttribute("data-duration"));if(Number.isFinite(h)&&h>0)return h;let f=Number(l.getAttribute("data-playback-start")??l.getAttribute("data-media-start")??"0"),N=Number.isFinite(f)?Math.max(0,f):0;return Number.isFinite(l.duration)&&l.duration>N?Math.max(0,l.duration-N):null},j=()=>{let l=Array.from(document.querySelectorAll("video[data-start], audio[data-start]"));if(l.length===0)return null;let h=0;for(let f of l){let N=v(f,0);if(!Number.isFinite(N))continue;let A=W(f);A==null||A<=a||(h=Math.max(h,Math.max(0,N)+A))}return h>a?h:null},R=()=>{let l=j();return typeof l!="number"||!Number.isFinite(l)||l<=a?null:l},$=l=>Z(l)?Math.max(a,l*m):a,pe=(l,h=0)=>{let f=K(l),N=R(),A=Number.isFinite(h)&&h>a?h:0,te=0;Z(f)?te=Math.max(f,A):Z(N)?te=Math.max(N,A):te=A;let le=Math.max(1,Number(e.maxTimelineDurationSeconds)||1800);return te>0?Math.max(0,Math.min(te,le)):0},ue=()=>{let l=window.__timelines??{},h=we({timelineRegistry:l}),f=R(),N=$(f),A=Y=>{let G=document.querySelector(`[data-composition-id="${CSS.escape(Y)}"]`);return G?h.resolveStartForElement(G,0):0},te=Y=>{let G=window.gsap;if(!G||typeof G.timeline!="function")return null;let ee=G.timeline({paused:!0});for(let q of Y)ee.add(q.timeline,A(q.compositionId));return ee},le=(Y,G)=>{if(!Z(Y))return null;let ee=window.gsap;if(!ee||typeof ee.timeline!="function")return null;let q=ee.timeline({paused:!0});if(G)try{q.add(G,0)}catch{}let ne=q;if(typeof ne.to=="function")try{ne.to({},{duration:Y})}catch{}return q},Me=(Y,G)=>{let ee=Y;if(typeof ee.getChildren!="function")return[];try{let q=ee.getChildren(!0,!0,!0)??[];if(!Array.isArray(q))return[];let ne=[];for(let se of G)if(!q.some(Ce=>Ce===se.timeline))try{let Ce=A(se.compositionId);Y.add(se.timeline,Ce),ne.push(se.compositionId)}catch{}return ne}catch{return[]}},oe=g(),ie=oe?.getAttribute("data-composition-id")??null;if(!ie)return{timeline:null};let me=l[ie]??null,re=(()=>{if(!oe)return[];let Y=new Set,G=Array.from(oe.querySelectorAll("[data-composition-id]")),ee=[];for(let q of G){let ne=q.getAttribute("data-composition-id");if(!ne||ne===ie||Y.has(ne))continue;Y.add(ne);let se=l[ne]??null;if(!se||typeof se.play!="function"||typeof se.pause!="function")continue;let Te=K(se);ee.push({compositionId:ne,timeline:se,durationSeconds:Te??0})}return ee})(),ge=Y=>{for(let G of Y){let ee=G.timeline;if(typeof ee.paused=="function")try{ee.paused(!1)}catch{}}};if(re.length>0&&ge(re),me){let Y=re.length>0?Me(me,re):[];if((re.length>0||!document.querySelector("[data-composition-id]:not([data-composition-id=\'"+ie+"\'])"))&&(M=!0),Y.length>0)try{let q=me.time();me.seek(q,!1)}catch{}let G=K(me);if(!Z(G)&&re.length>0){let q=re.map(An=>An.compositionId),ne=te(re),se=K(ne);if(ne&&Z(se))return{timeline:ne,selectedTimelineIds:q,selectedDurationSeconds:se,mediaDurationFloorSeconds:f,diagnostics:{code:"root_timeline_unusable_fallback",details:{rootCompositionId:ie,rootDurationSeconds:G,fallbackKind:"composite_by_root_children",minCandidateDurationSeconds:N,selectedDurationSeconds:se,mediaDurationFloorSeconds:f,selectedTimelineIds:q,autoNestedChildren:Y}}};let Te=le(f??0,me),Ce=K(Te);if(Te&&Z(Ce))return{timeline:Te,selectedTimelineIds:[ie],selectedDurationSeconds:Ce,mediaDurationFloorSeconds:f,diagnostics:{code:"root_timeline_unusable_media_floor_fallback",details:{rootCompositionId:ie,rootDurationSeconds:G,fallbackKind:"media_duration_floor",mediaDurationFloorSeconds:f,selectedDurationSeconds:Ce,selectedTimelineIds:[ie],autoNestedChildren:Y}}}}if(!Z(G)&&re.length===0){let q=le(f??0,me),ne=K(q);if(q&&Z(ne))return{timeline:q,selectedTimelineIds:[ie],selectedDurationSeconds:ne,mediaDurationFloorSeconds:f,diagnostics:{code:"root_timeline_unusable_media_floor_fallback",details:{rootCompositionId:ie,rootDurationSeconds:G,fallbackKind:"media_duration_floor",mediaDurationFloorSeconds:f,selectedDurationSeconds:ne,selectedTimelineIds:[ie]}}}}let ee=oe?.getAttribute("data-duration");if(ee){let q=parseFloat(ee);if(Z(q)&&Z(G)&&q>=G+.5){let ne=me;if(typeof ne.to=="function")try{ne.to({},{duration:0},q)}catch{}let se=K(me);if(Z(se))return{timeline:me,selectedTimelineIds:[ie],selectedDurationSeconds:se,mediaDurationFloorSeconds:f,diagnostics:{code:"root_timeline_padded_to_declared_duration",details:{rootCompositionId:ie,rootDurationSeconds:G,rootDeclaredDur:q,newDur:se}}}}}return{timeline:me,selectedTimelineIds:[ie],selectedDurationSeconds:G,mediaDurationFloorSeconds:f,diagnostics:Y.length>0?{code:"root_timeline_auto_nested_children",details:{rootCompositionId:ie,selectedDurationSeconds:G,autoNestedChildren:Y}}:void 0}}if(re.length>0){let Y=re.map(q=>q.compositionId),G=te(re),ee=K(G);if(G)return{timeline:G,selectedTimelineIds:Y,selectedDurationSeconds:ee,mediaDurationFloorSeconds:f,diagnostics:{code:"root_timeline_missing_fallback",details:{rootCompositionId:ie,fallbackKind:"composite_by_root_children",minCandidateDurationSeconds:N,selectedDurationSeconds:ee,mediaDurationFloorSeconds:f,selectedTimelineIds:Y}}}}return{timeline:null}},B=()=>{let l=e.capturedTimeline;if(!l||typeof l.time!="function")return;let h=Number(l.time());Number.isFinite(h)&&(e.currentTime=Math.max(0,h))},M=!1,L=()=>{if(!w)return!1;let l=e.capturedTimeline,h=K(l),f=Z(h);if(l&&f&&M)return!1;let N=ue();return N.timeline?l&&l===N.timeline?(typeof l.timeScale=="function"&&l.timeScale(e.playbackRate),!1):(e.capturedTimeline=N.timeline,typeof e.capturedTimeline.timeScale=="function"&&e.capturedTimeline.timeScale(e.playbackRate),N.diagnostics&&xe({source:"hf-preview",type:"diagnostic",code:N.diagnostics.code,details:N.diagnostics.details}),xe({source:"hf-preview",type:"diagnostic",code:"timeline_bound",details:{selectedTimelineIds:N.selectedTimelineIds??[],selectedDurationSeconds:N.selectedDurationSeconds??null,mediaDurationFloorSeconds:N.mediaDurationFloorSeconds??null}}),!0):!1},J=()=>{let l=g();if(!(l instanceof HTMLElement))return;let h=l.getBoundingClientRect(),f=Number(l.getAttribute("data-width")),N=Number(l.getAttribute("data-height")),A=window.getComputedStyle(l),te=Number.isFinite(f)&&f>0&&Number.isFinite(N)&&N>0,le=h.width<=0||h.height<=0||l.clientWidth<=0||l.clientHeight<=0;!te||!le||c("root_stage_layout_zero",{compositionId:l.getAttribute("data-composition-id")??null,declaredWidth:f,declaredHeight:N,rectWidth:Math.round(h.width),rectHeight:Math.round(h.height),clientWidth:l.clientWidth,clientHeight:l.clientHeight,display:A.display,visibility:A.visibility,overflow:A.overflow},`root-stage-layout-zero:${l.getAttribute("data-composition-id")??"unknown"}`)},X=()=>{e.tornDown||(u!=null&&window.cancelAnimationFrame(u),u=window.requestAnimationFrame(()=>{u=null,J()}))},I=()=>{n=l=>{let h=Q(l.error??l.message).slice(0,k);if(!h)return;let f=S(h);xe({source:"hf-preview",type:"diagnostic",code:f.code,details:{category:f.category,message:h,filename:l.filename||null,line:Number.isFinite(l.lineno)?l.lineno:null,column:Number.isFinite(l.colno)?l.colno:null}})},o=l=>{let h=Q(l.reason).slice(0,k);if(!h)return;let f=S(h);xe({source:"hf-preview",type:"diagnostic",code:`${f.code}_unhandled_rejection`,details:{category:`${f.category}-unhandled-rejection`,message:h}})},window.addEventListener("error",n),window.addEventListener("unhandledrejection",o)},P=()=>{let l=Array.from(document.querySelectorAll("img, video, audio, source, link[rel=\'stylesheet\']"));for(let f of l){let N=()=>{if(!(f instanceof Element))return;let A=f.tagName.toLowerCase(),te=f.getAttribute("src")??f.getAttribute("href")??f.getAttribute("poster")??null,le=A==="link"?"runtime_stylesheet_load_failed":"runtime_asset_load_failed";c(le,{tagName:A,assetUrl:te,currentSrc:(f instanceof HTMLImageElement||f instanceof HTMLMediaElement)&&f.currentSrc||null,readyState:f instanceof HTMLMediaElement?f.readyState:null,networkState:f instanceof HTMLMediaElement?f.networkState:null},`${le}:${A}:${te??"unknown"}`)};f.addEventListener("error",N),d(()=>{f.removeEventListener("error",N)})}let h=document.fonts;h&&h.ready.then(()=>{if(e.tornDown)return;let f=Array.from(h).filter(N=>N.status==="error").map(N=>N.family).filter(N=>!!N).slice(0,10);f.length!==0&&c("runtime_font_load_issue",{failedFamilies:f,totalFaces:Array.from(h).length},`runtime-font-load-issue:${f.join("|")}`)}).catch(()=>{})},H=(l,h)=>{if(!l.timeline)return!1;let f=e.capturedTimeline;if(f&&f===l.timeline)return!1;let N=Math.max(0,e.currentTime||0),A=e.isPlaying;e.capturedTimeline=l.timeline,typeof e.capturedTimeline.timeScale=="function"&&e.capturedTimeline.timeScale(e.playbackRate);try{e.capturedTimeline.pause(),e.capturedTimeline.seek(N,!1),A&&e.capturedTimeline.play()}catch{}return xe({source:"hf-preview",type:"diagnostic",code:"timeline_loop_guard_rebind",details:{reason:h,previousTime:N,selectedTimelineIds:l.selectedTimelineIds??[],selectedDurationSeconds:l.selectedDurationSeconds??null,mediaDurationFloorSeconds:l.mediaDurationFloorSeconds??null}}),!0},ce=null,de=!1,Ne=new Set,he=()=>{e.tornDown||(ce!=null&&window.clearTimeout(ce),ce=window.setTimeout(()=>{if(e.tornDown)return;ce=null;let l=ue();if(!l.timeline||!Z(l.mediaDurationFloorSeconds??null))return;if(!e.capturedTimeline){L()&&(ke(),Ee(!0));return}if(de)return;let f=K(e.capturedTimeline),N=l.selectedDurationSeconds??K(l.timeline);Z(N)&&(!Z(f)||N>=f+U)&&H(l,"manual")&&(de=!0,xe({source:"hf-preview",type:"diagnostic",code:"timeline_rebind_after_media_metadata",details:{previousDurationSeconds:f??null,selectedDurationSeconds:N??null,selectedTimelineIds:l.selectedTimelineIds??[],mediaDurationFloorSeconds:l.mediaDurationFloorSeconds??null}}),ke(),Ee(!0))},z))},gn=()=>{for(let l of Ne)l.removeEventListener("loadedmetadata",he),l.removeEventListener("durationchange",he);Ne.clear()},Je=()=>{if(e.tornDown)return;let l=Array.from(document.querySelectorAll("video, audio"));for(let h of l)Ne.has(h)||(Ne.add(h),h.addEventListener("loadedmetadata",he),h.addEventListener("durationchange",he),h.preload!=="auto"&&(h.preload="auto"),h.readyState<HTMLMediaElement.HAVE_FUTURE_DATA&&h.load())},ht=()=>{let l=Lt({resolveStartSeconds:N=>v(N,0)});Tt({clips:l.mediaClips,timeSeconds:e.currentTime,playing:e.isPlaying,playbackRate:e.playbackRate,outputMuted:e.mediaOutputMuted,userMuted:e.bridgeMuted,onAutoplayBlocked:()=>{e.mediaAutoplayBlockedPosted||(e.mediaAutoplayBlockedPosted=!0,xe({source:"hf-preview",type:"media-autoplay-blocked"}))}});let h=document.querySelector("[data-composition-id]")?.getAttribute("data-composition-id")??null,f=Array.from(document.querySelectorAll("[data-start]"));for(let N of f){if(!(N instanceof HTMLElement))continue;let A=N.tagName.toLowerCase();if(A==="script"||A==="style"||A==="link"||A==="meta")continue;if(!N.getAttribute("data-composition-id")){let ge=N.closest("[data-composition-id]")?.getAttribute("data-composition-id")??null;if(ge&&ge!==h)continue}let le=v(N,0),Me=_(N),oe=Me!=null&&Me>0?le+Me:Number.POSITIVE_INFINITY,ie=oe,me=N.getAttribute("data-composition-id");if(me&&!Number.isFinite(oe)){let re=(window.__timelines??{})[me];if(re&&typeof re.duration=="function"){let ge=re.duration();ge>0&&(ie=le+ge)}}let Xe=e.currentTime>=le&&(Number.isFinite(ie)?e.currentTime<ie:!0);N.style.visibility=Xe?"visible":"hidden"}},Ee=l=>{B();let h=Math.max(0,Math.round((e.currentTime||0)*e.canonicalFps)),f=Date.now();(l||h!==e.bridgeLastPostedFrame||e.isPlaying!==e.bridgeLastPostedPlaying||e.bridgeMuted!==e.bridgeLastPostedMuted||f-e.bridgeLastPostedAt>=e.bridgeMaxPostIntervalMs)&&(e.bridgeLastPostedFrame=h,e.bridgeLastPostedPlaying=e.isPlaying,e.bridgeLastPostedMuted=e.bridgeMuted,e.bridgeLastPostedAt=f,xe({source:"hf-preview",type:"state",frame:h,isPlaying:e.isPlaying,muted:e.bridgeMuted,playbackRate:e.playbackRate}))},ke=()=>{b(),E(),y();let l=g();if(l){let f=x(l.getAttribute("data-width")),N=x(l.getAttribute("data-height")),A=f?parseInt(f,10):0,te=N?parseInt(N,10):0;A>0&&te>0&&xe({source:"hf-preview",type:"stage-size",width:A,height:te})}L();let h=Ot({canonicalFps:e.canonicalFps,maxTimelineDurationSeconds:e.maxTimelineDurationSeconds});window.__clipManifest=h,xe(h),X()},Ie=(l,h=0)=>{for(let f of e.deterministicAdapters){try{l==="discover"&&f.discover(),l==="pause"&&f.pause(),l==="play"&&f.play&&f.play()}catch{}if(l==="discover")try{f.seek({time:h})}catch{}}};if(w)at();else{let l={injectedStyles:e.injectedCompStyles,injectedScripts:e.injectedCompScripts,parseDimensionPx:x,onDiagnostic:({code:h,details:f})=>{xe({source:"hf-preview",type:"diagnostic",code:h,details:f})}};Ht(l).then(()=>Wt(l)).finally(()=>{w=!0,Ie("discover",e.currentTime),Je(),P(),at(),ke(),Ee(!0)})}let je=wt({postMessage:l=>xe(l)});je.installPickerApi();let gt=l=>{let h=Number(l);!Number.isFinite(h)||h<=0?e.playbackRate=1:e.playbackRate=Math.max(.1,Math.min(5,h)),e.capturedTimeline&&typeof e.capturedTimeline.timeScale=="function"&&e.capturedTimeline.timeScale(e.playbackRate);let f=document.querySelectorAll("video, audio");for(let N of f)if(N instanceof HTMLMediaElement)try{N.playbackRate=e.playbackRate}catch{}},ae=Rt({getTimeline:()=>e.capturedTimeline,setTimeline:l=>{e.capturedTimeline=l},getTimelineRegistry:()=>window.__timelines??{},getIsPlaying:()=>e.isPlaying,setIsPlaying:l=>{e.isPlaying=l},getPlaybackRate:()=>e.playbackRate,setPlaybackRate:gt,getCanonicalFps:()=>e.canonicalFps,onSyncMedia:(l,h)=>{e.currentTime=Math.max(0,Number(l)||0),e.isPlaying=h,ht()},onStatePost:Ee,onDeterministicSeek:l=>{for(let h of e.deterministicAdapters)try{h.seek({time:Number(l)||0})}catch{}},onDeterministicPause:()=>Ie("pause"),onDeterministicPlay:()=>Ie("play"),onRenderFrameSeek:()=>{},onShowNativeVideos:()=>{},getSafeDuration:()=>pe(e.capturedTimeline,0)});window.__player=s(ae),window.__playerReady=!0,window.__renderReady=!0,Nt(xe),Pe("composition_loaded",{duration:ae.getDuration(),compositionId:document.querySelector("[data-composition-id]")?.getAttribute("data-composition-id")??null}),e.controlBridgeHandler=At({onPlay:()=>{ae.play(),Pe("composition_played",{time:ae.getTime()})},onPause:()=>{ae.pause(),Pe("composition_paused",{time:ae.getTime()})},onSeek:(l,h)=>{let f=Math.max(0,l)/e.canonicalFps;ae.seek(f),Pe("composition_seeked",{time:f})},onSetMuted:l=>{e.bridgeMuted=l;let h=l||e.mediaOutputMuted,f=document.querySelectorAll("video, audio");for(let N of f)N instanceof HTMLMediaElement&&(N.muted=h)},onSetMediaOutputMuted:l=>{e.mediaOutputMuted=l;let h=l||e.bridgeMuted,f=document.querySelectorAll("video, audio");for(let N of f)N instanceof HTMLMediaElement&&(N.muted=h)},onSetPlaybackRate:l=>gt(l),onEnablePickMode:()=>je.enablePickMode(),onDisablePickMode:()=>je.disablePickMode()}),L(),e.capturedTimeline&&(ae._timeline=e.capturedTimeline),w&&setTimeout(()=>{let l=e.capturedTimeline;L()&&e.capturedTimeline!==l&&(ae._timeline=e.capturedTimeline),Ie("discover",e.currentTime),ke(),Ee(!0)},0),e.deterministicAdapters=[kt(),Et({resolveStartSeconds:l=>v(l,0)}),Ct(),Dt(),yt({getTimeline:()=>e.capturedTimeline})],I(),Ie("discover"),Je(),e.timelinePollIntervalId&&clearInterval(e.timelinePollIntervalId);let Qe=0,ze=null,St=0,Ze=!1,Le=0,Ft=()=>{St=Date.now(),Ze=!1,Le=0};e.timelinePollIntervalId=setInterval(()=>{Qe+=1;let h=e.isPlaying&&e.capturedTimeline!=null&&Math.max(0,e.currentTime||0)<T?!1:L();if(e.capturedTimeline&&!ae._timeline&&(ae._timeline=e.capturedTimeline),(h||Qe%20===0)&&ke(),Qe%10===0&&Je(),B(),e.isPlaying&&e.capturedTimeline){let f=Math.max(0,e.currentTime||0),N=ze,A=pe(e.capturedTimeline,0);if(A>0&&f>=A){ae.pause(),ae.seek(A),ze=A,Le=0,Ee(!0);return}if(N!=null&&N>=p&&f<=F?Le+=1:Le=0,!Ze&&Le>=C&&Date.now()-St>D){let le=ue();H(le,"loop_guard")&&(Ze=!0,Le=0)}ze=Math.max(0,e.currentTime||0)}else ze=Math.max(0,e.currentTime||0);e.isPlaying&&ht(),Ee(!1)},50),ke(),Ee(!0);let Sn=ae.seek;ae.seek=l=>{Ft(),Sn(l)};let Fn=ae.renderSeek;ae.renderSeek=l=>{Ft(),Fn(l)};let Ye=()=>{if(!e.tornDown){e.tornDown=!0,e.timelinePollIntervalId&&(clearInterval(e.timelinePollIntervalId),e.timelinePollIntervalId=null),ce!=null&&(window.clearTimeout(ce),ce=null),u!=null&&(window.cancelAnimationFrame(u),u=null),gn(),e.controlBridgeHandler&&(window.removeEventListener("message",e.controlBridgeHandler),e.controlBridgeHandler=null),n&&(window.removeEventListener("error",n),n=null),o&&(window.removeEventListener("unhandledrejection",o),o=null),e.beforeUnloadHandler&&(window.removeEventListener("beforeunload",e.beforeUnloadHandler),e.beforeUnloadHandler=null),je.disablePickMode();for(let l of e.deterministicAdapters)if(!(!l||typeof l.revert!="function"))try{l.revert()}catch{}e.deterministicAdapters=[];for(let l of r.splice(0))try{l()}catch{}for(let l of e.injectedCompStyles)try{l.remove()}catch{}e.injectedCompStyles=[];for(let l of e.injectedCompScripts)try{l.remove()}catch{}e.injectedCompScripts=[],e.capturedTimeline=null,t.__hfRuntimeTeardown===Ye&&(t.__hfRuntimeTeardown=null)}};t.__hfRuntimeTeardown=Ye,e.beforeUnloadHandler=Ye,window.addEventListener("beforeunload",e.beforeUnloadHandler)}var Gt=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","BN","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],lt=[[697,698,"ON"],[706,719,"ON"],[722,735,"ON"],[741,749,"ON"],[751,767,"ON"],[768,879,"NSM"],[884,885,"ON"],[894,894,"ON"],[900,901,"ON"],[903,903,"ON"],[1014,1014,"ON"],[1155,1161,"NSM"],[1418,1418,"ON"],[1421,1422,"ON"],[1423,1423,"ET"],[1424,1424,"R"],[1425,1469,"NSM"],[1470,1470,"R"],[1471,1471,"NSM"],[1472,1472,"R"],[1473,1474,"NSM"],[1475,1475,"R"],[1476,1477,"NSM"],[1478,1478,"R"],[1479,1479,"NSM"],[1480,1535,"R"],[1536,1541,"AN"],[1542,1543,"ON"],[1544,1544,"AL"],[1545,1546,"ET"],[1547,1547,"AL"],[1548,1548,"CS"],[1549,1549,"AL"],[1550,1551,"ON"],[1552,1562,"NSM"],[1563,1610,"AL"],[1611,1631,"NSM"],[1632,1641,"AN"],[1642,1642,"ET"],[1643,1644,"AN"],[1645,1647,"AL"],[1648,1648,"NSM"],[1649,1749,"AL"],[1750,1756,"NSM"],[1757,1757,"AN"],[1758,1758,"ON"],[1759,1764,"NSM"],[1765,1766,"AL"],[1767,1768,"NSM"],[1769,1769,"ON"],[1770,1773,"NSM"],[1774,1775,"AL"],[1776,1785,"EN"],[1786,1808,"AL"],[1809,1809,"NSM"],[1810,1839,"AL"],[1840,1866,"NSM"],[1867,1957,"AL"],[1958,1968,"NSM"],[1969,1983,"AL"],[1984,2026,"R"],[2027,2035,"NSM"],[2036,2037,"R"],[2038,2041,"ON"],[2042,2044,"R"],[2045,2045,"NSM"],[2046,2069,"R"],[2070,2073,"NSM"],[2074,2074,"R"],[2075,2083,"NSM"],[2084,2084,"R"],[2085,2087,"NSM"],[2088,2088,"R"],[2089,2093,"NSM"],[2094,2136,"R"],[2137,2139,"NSM"],[2140,2143,"R"],[2144,2191,"AL"],[2192,2193,"AN"],[2194,2198,"AL"],[2199,2207,"NSM"],[2208,2249,"AL"],[2250,2273,"NSM"],[2274,2274,"AN"],[2275,2306,"NSM"],[2362,2362,"NSM"],[2364,2364,"NSM"],[2369,2376,"NSM"],[2381,2381,"NSM"],[2385,2391,"NSM"],[2402,2403,"NSM"],[2433,2433,"NSM"],[2492,2492,"NSM"],[2497,2500,"NSM"],[2509,2509,"NSM"],[2530,2531,"NSM"],[2546,2547,"ET"],[2555,2555,"ET"],[2558,2558,"NSM"],[2561,2562,"NSM"],[2620,2620,"NSM"],[2625,2626,"NSM"],[2631,2632,"NSM"],[2635,2637,"NSM"],[2641,2641,"NSM"],[2672,2673,"NSM"],[2677,2677,"NSM"],[2689,2690,"NSM"],[2748,2748,"NSM"],[2753,2757,"NSM"],[2759,2760,"NSM"],[2765,2765,"NSM"],[2786,2787,"NSM"],[2801,2801,"ET"],[2810,2815,"NSM"],[2817,2817,"NSM"],[2876,2876,"NSM"],[2879,2879,"NSM"],[2881,2884,"NSM"],[2893,2893,"NSM"],[2901,2902,"NSM"],[2914,2915,"NSM"],[2946,2946,"NSM"],[3008,3008,"NSM"],[3021,3021,"NSM"],[3059,3064,"ON"],[3065,3065,"ET"],[3066,3066,"ON"],[3072,3072,"NSM"],[3076,3076,"NSM"],[3132,3132,"NSM"],[3134,3136,"NSM"],[3142,3144,"NSM"],[3146,3149,"NSM"],[3157,3158,"NSM"],[3170,3171,"NSM"],[3192,3198,"ON"],[3201,3201,"NSM"],[3260,3260,"NSM"],[3276,3277,"NSM"],[3298,3299,"NSM"],[3328,3329,"NSM"],[3387,3388,"NSM"],[3393,3396,"NSM"],[3405,3405,"NSM"],[3426,3427,"NSM"],[3457,3457,"NSM"],[3530,3530,"NSM"],[3538,3540,"NSM"],[3542,3542,"NSM"],[3633,3633,"NSM"],[3636,3642,"NSM"],[3647,3647,"ET"],[3655,3662,"NSM"],[3761,3761,"NSM"],[3764,3772,"NSM"],[3784,3790,"NSM"],[3864,3865,"NSM"],[3893,3893,"NSM"],[3895,3895,"NSM"],[3897,3897,"NSM"],[3898,3901,"ON"],[3953,3966,"NSM"],[3968,3972,"NSM"],[3974,3975,"NSM"],[3981,3991,"NSM"],[3993,4028,"NSM"],[4038,4038,"NSM"],[4141,4144,"NSM"],[4146,4151,"NSM"],[4153,4154,"NSM"],[4157,4158,"NSM"],[4184,4185,"NSM"],[4190,4192,"NSM"],[4209,4212,"NSM"],[4226,4226,"NSM"],[4229,4230,"NSM"],[4237,4237,"NSM"],[4253,4253,"NSM"],[4957,4959,"NSM"],[5008,5017,"ON"],[5120,5120,"ON"],[5760,5760,"WS"],[5787,5788,"ON"],[5906,5908,"NSM"],[5938,5939,"NSM"],[5970,5971,"NSM"],[6002,6003,"NSM"],[6068,6069,"NSM"],[6071,6077,"NSM"],[6086,6086,"NSM"],[6089,6099,"NSM"],[6107,6107,"ET"],[6109,6109,"NSM"],[6128,6137,"ON"],[6144,6154,"ON"],[6155,6157,"NSM"],[6158,6158,"BN"],[6159,6159,"NSM"],[6277,6278,"NSM"],[6313,6313,"NSM"],[6432,6434,"NSM"],[6439,6440,"NSM"],[6450,6450,"NSM"],[6457,6459,"NSM"],[6464,6464,"ON"],[6468,6469,"ON"],[6622,6655,"ON"],[6679,6680,"NSM"],[6683,6683,"NSM"],[6742,6742,"NSM"],[6744,6750,"NSM"],[6752,6752,"NSM"],[6754,6754,"NSM"],[6757,6764,"NSM"],[6771,6780,"NSM"],[6783,6783,"NSM"],[6832,6877,"NSM"],[6880,6891,"NSM"],[6912,6915,"NSM"],[6964,6964,"NSM"],[6966,6970,"NSM"],[6972,6972,"NSM"],[6978,6978,"NSM"],[7019,7027,"NSM"],[7040,7041,"NSM"],[7074,7077,"NSM"],[7080,7081,"NSM"],[7083,7085,"NSM"],[7142,7142,"NSM"],[7144,7145,"NSM"],[7149,7149,"NSM"],[7151,7153,"NSM"],[7212,7219,"NSM"],[7222,7223,"NSM"],[7376,7378,"NSM"],[7380,7392,"NSM"],[7394,7400,"NSM"],[7405,7405,"NSM"],[7412,7412,"NSM"],[7416,7417,"NSM"],[7616,7679,"NSM"],[8125,8125,"ON"],[8127,8129,"ON"],[8141,8143,"ON"],[8157,8159,"ON"],[8173,8175,"ON"],[8189,8190,"ON"],[8192,8202,"WS"],[8203,8205,"BN"],[8207,8207,"R"],[8208,8231,"ON"],[8232,8232,"WS"],[8233,8233,"B"],[8234,8238,"BN"],[8239,8239,"CS"],[8240,8244,"ET"],[8245,8259,"ON"],[8260,8260,"CS"],[8261,8286,"ON"],[8287,8287,"WS"],[8288,8303,"BN"],[8304,8304,"EN"],[8308,8313,"EN"],[8314,8315,"ES"],[8316,8318,"ON"],[8320,8329,"EN"],[8330,8331,"ES"],[8332,8334,"ON"],[8352,8399,"ET"],[8400,8432,"NSM"],[8448,8449,"ON"],[8451,8454,"ON"],[8456,8457,"ON"],[8468,8468,"ON"],[8470,8472,"ON"],[8478,8483,"ON"],[8485,8485,"ON"],[8487,8487,"ON"],[8489,8489,"ON"],[8494,8494,"ET"],[8506,8507,"ON"],[8512,8516,"ON"],[8522,8525,"ON"],[8528,8543,"ON"],[8585,8587,"ON"],[8592,8721,"ON"],[8722,8722,"ES"],[8723,8723,"ET"],[8724,9013,"ON"],[9083,9108,"ON"],[9110,9257,"ON"],[9280,9290,"ON"],[9312,9351,"ON"],[9352,9371,"EN"],[9450,9899,"ON"],[9901,10239,"ON"],[10496,11123,"ON"],[11126,11263,"ON"],[11493,11498,"ON"],[11503,11505,"NSM"],[11513,11519,"ON"],[11647,11647,"NSM"],[11744,11775,"NSM"],[11776,11869,"ON"],[11904,11929,"ON"],[11931,12019,"ON"],[12032,12245,"ON"],[12272,12287,"ON"],[12288,12288,"WS"],[12289,12292,"ON"],[12296,12320,"ON"],[12330,12333,"NSM"],[12336,12336,"ON"],[12342,12343,"ON"],[12349,12351,"ON"],[12441,12442,"NSM"],[12443,12444,"ON"],[12448,12448,"ON"],[12539,12539,"ON"],[12736,12773,"ON"],[12783,12783,"ON"],[12829,12830,"ON"],[12880,12895,"ON"],[12924,12926,"ON"],[12977,12991,"ON"],[13004,13007,"ON"],[13175,13178,"ON"],[13278,13279,"ON"],[13311,13311,"ON"],[19904,19967,"ON"],[42128,42182,"ON"],[42509,42511,"ON"],[42607,42610,"NSM"],[42611,42611,"ON"],[42612,42621,"NSM"],[42622,42623,"ON"],[42654,42655,"NSM"],[42736,42737,"NSM"],[42752,42785,"ON"],[42888,42888,"ON"],[43010,43010,"NSM"],[43014,43014,"NSM"],[43019,43019,"NSM"],[43045,43046,"NSM"],[43048,43051,"ON"],[43052,43052,"NSM"],[43064,43065,"ET"],[43124,43127,"ON"],[43204,43205,"NSM"],[43232,43249,"NSM"],[43263,43263,"NSM"],[43302,43309,"NSM"],[43335,43345,"NSM"],[43392,43394,"NSM"],[43443,43443,"NSM"],[43446,43449,"NSM"],[43452,43453,"NSM"],[43493,43493,"NSM"],[43561,43566,"NSM"],[43569,43570,"NSM"],[43573,43574,"NSM"],[43587,43587,"NSM"],[43596,43596,"NSM"],[43644,43644,"NSM"],[43696,43696,"NSM"],[43698,43700,"NSM"],[43703,43704,"NSM"],[43710,43711,"NSM"],[43713,43713,"NSM"],[43756,43757,"NSM"],[43766,43766,"NSM"],[43882,43883,"ON"],[44005,44005,"NSM"],[44008,44008,"NSM"],[44013,44013,"NSM"],[64285,64285,"R"],[64286,64286,"NSM"],[64287,64296,"R"],[64297,64297,"ES"],[64298,64335,"R"],[64336,64450,"AL"],[64451,64466,"ON"],[64467,64829,"AL"],[64830,64847,"ON"],[64848,64911,"AL"],[64912,64913,"ON"],[64914,64967,"AL"],[64968,64975,"ON"],[64976,65007,"BN"],[65008,65020,"AL"],[65021,65023,"ON"],[65024,65039,"NSM"],[65040,65049,"ON"],[65056,65071,"NSM"],[65072,65103,"ON"],[65104,65104,"CS"],[65105,65105,"ON"],[65106,65106,"CS"],[65108,65108,"ON"],[65109,65109,"CS"],[65110,65118,"ON"],[65119,65119,"ET"],[65120,65121,"ON"],[65122,65123,"ES"],[65124,65126,"ON"],[65128,65128,"ON"],[65129,65130,"ET"],[65131,65131,"ON"],[65136,65278,"AL"],[65279,65279,"BN"],[65281,65282,"ON"],[65283,65285,"ET"],[65286,65290,"ON"],[65291,65291,"ES"],[65292,65292,"CS"],[65293,65293,"ES"],[65294,65295,"CS"],[65296,65305,"EN"],[65306,65306,"CS"],[65307,65312,"ON"],[65339,65344,"ON"],[65371,65381,"ON"],[65504,65505,"ET"],[65506,65508,"ON"],[65509,65510,"ET"],[65512,65518,"ON"],[65520,65528,"BN"],[65529,65533,"ON"],[65534,65535,"BN"],[65793,65793,"ON"],[65856,65932,"ON"],[65936,65948,"ON"],[65952,65952,"ON"],[66045,66045,"NSM"],[66272,66272,"NSM"],[66273,66299,"EN"],[66422,66426,"NSM"],[67584,67870,"R"],[67871,67871,"ON"],[67872,68096,"R"],[68097,68099,"NSM"],[68100,68100,"R"],[68101,68102,"NSM"],[68103,68107,"R"],[68108,68111,"NSM"],[68112,68151,"R"],[68152,68154,"NSM"],[68155,68158,"R"],[68159,68159,"NSM"],[68160,68324,"R"],[68325,68326,"NSM"],[68327,68408,"R"],[68409,68415,"ON"],[68416,68863,"R"],[68864,68899,"AL"],[68900,68903,"NSM"],[68904,68911,"AL"],[68912,68921,"AN"],[68922,68927,"AL"],[68928,68937,"AN"],[68938,68968,"R"],[68969,68973,"NSM"],[68974,68974,"ON"],[68975,69215,"R"],[69216,69246,"AN"],[69247,69290,"R"],[69291,69292,"NSM"],[69293,69311,"R"],[69312,69327,"AL"],[69328,69336,"ON"],[69337,69369,"AL"],[69370,69375,"NSM"],[69376,69423,"R"],[69424,69445,"AL"],[69446,69456,"NSM"],[69457,69487,"AL"],[69488,69505,"R"],[69506,69509,"NSM"],[69510,69631,"R"],[69633,69633,"NSM"],[69688,69702,"NSM"],[69714,69733,"ON"],[69744,69744,"NSM"],[69747,69748,"NSM"],[69759,69761,"NSM"],[69811,69814,"NSM"],[69817,69818,"NSM"],[69826,69826,"NSM"],[69888,69890,"NSM"],[69927,69931,"NSM"],[69933,69940,"NSM"],[70003,70003,"NSM"],[70016,70017,"NSM"],[70070,70078,"NSM"],[70089,70092,"NSM"],[70095,70095,"NSM"],[70191,70193,"NSM"],[70196,70196,"NSM"],[70198,70199,"NSM"],[70206,70206,"NSM"],[70209,70209,"NSM"],[70367,70367,"NSM"],[70371,70378,"NSM"],[70400,70401,"NSM"],[70459,70460,"NSM"],[70464,70464,"NSM"],[70502,70508,"NSM"],[70512,70516,"NSM"],[70587,70592,"NSM"],[70606,70606,"NSM"],[70608,70608,"NSM"],[70610,70610,"NSM"],[70625,70626,"NSM"],[70712,70719,"NSM"],[70722,70724,"NSM"],[70726,70726,"NSM"],[70750,70750,"NSM"],[70835,70840,"NSM"],[70842,70842,"NSM"],[70847,70848,"NSM"],[70850,70851,"NSM"],[71090,71093,"NSM"],[71100,71101,"NSM"],[71103,71104,"NSM"],[71132,71133,"NSM"],[71219,71226,"NSM"],[71229,71229,"NSM"],[71231,71232,"NSM"],[71264,71276,"ON"],[71339,71339,"NSM"],[71341,71341,"NSM"],[71344,71349,"NSM"],[71351,71351,"NSM"],[71453,71453,"NSM"],[71455,71455,"NSM"],[71458,71461,"NSM"],[71463,71467,"NSM"],[71727,71735,"NSM"],[71737,71738,"NSM"],[71995,71996,"NSM"],[71998,71998,"NSM"],[72003,72003,"NSM"],[72148,72151,"NSM"],[72154,72155,"NSM"],[72160,72160,"NSM"],[72193,72198,"NSM"],[72201,72202,"NSM"],[72243,72248,"NSM"],[72251,72254,"NSM"],[72263,72263,"NSM"],[72273,72278,"NSM"],[72281,72283,"NSM"],[72330,72342,"NSM"],[72344,72345,"NSM"],[72544,72544,"NSM"],[72546,72548,"NSM"],[72550,72550,"NSM"],[72752,72758,"NSM"],[72760,72765,"NSM"],[72850,72871,"NSM"],[72874,72880,"NSM"],[72882,72883,"NSM"],[72885,72886,"NSM"],[73009,73014,"NSM"],[73018,73018,"NSM"],[73020,73021,"NSM"],[73023,73029,"NSM"],[73031,73031,"NSM"],[73104,73105,"NSM"],[73109,73109,"NSM"],[73111,73111,"NSM"],[73459,73460,"NSM"],[73472,73473,"NSM"],[73526,73530,"NSM"],[73536,73536,"NSM"],[73538,73538,"NSM"],[73562,73562,"NSM"],[73685,73692,"ON"],[73693,73696,"ET"],[73697,73713,"ON"],[78912,78912,"NSM"],[78919,78933,"NSM"],[90398,90409,"NSM"],[90413,90415,"NSM"],[92912,92916,"NSM"],[92976,92982,"NSM"],[94031,94031,"NSM"],[94095,94098,"NSM"],[94178,94178,"ON"],[94180,94180,"NSM"],[113821,113822,"NSM"],[113824,113827,"BN"],[117760,117973,"ON"],[118e3,118009,"EN"],[118010,118012,"ON"],[118016,118451,"ON"],[118458,118480,"ON"],[118496,118512,"ON"],[118528,118573,"NSM"],[118576,118598,"NSM"],[119143,119145,"NSM"],[119155,119162,"BN"],[119163,119170,"NSM"],[119173,119179,"NSM"],[119210,119213,"NSM"],[119273,119274,"ON"],[119296,119361,"ON"],[119362,119364,"NSM"],[119365,119365,"ON"],[119552,119638,"ON"],[120513,120513,"ON"],[120539,120539,"ON"],[120571,120571,"ON"],[120597,120597,"ON"],[120629,120629,"ON"],[120655,120655,"ON"],[120687,120687,"ON"],[120713,120713,"ON"],[120745,120745,"ON"],[120771,120771,"ON"],[120782,120831,"EN"],[121344,121398,"NSM"],[121403,121452,"NSM"],[121461,121461,"NSM"],[121476,121476,"NSM"],[121499,121503,"NSM"],[121505,121519,"NSM"],[122880,122886,"NSM"],[122888,122904,"NSM"],[122907,122913,"NSM"],[122915,122916,"NSM"],[122918,122922,"NSM"],[123023,123023,"NSM"],[123184,123190,"NSM"],[123566,123566,"NSM"],[123628,123631,"NSM"],[123647,123647,"ET"],[124140,124143,"NSM"],[124398,124399,"NSM"],[124643,124643,"NSM"],[124646,124646,"NSM"],[124654,124655,"NSM"],[124661,124661,"NSM"],[124928,125135,"R"],[125136,125142,"NSM"],[125143,125251,"R"],[125252,125258,"NSM"],[125259,126063,"R"],[126064,126143,"AL"],[126144,126207,"R"],[126208,126287,"AL"],[126288,126463,"R"],[126464,126703,"AL"],[126704,126705,"ON"],[126706,126719,"AL"],[126720,126975,"R"],[126976,127019,"ON"],[127024,127123,"ON"],[127136,127150,"ON"],[127153,127167,"ON"],[127169,127183,"ON"],[127185,127221,"ON"],[127232,127242,"EN"],[127243,127247,"ON"],[127279,127279,"ON"],[127338,127343,"ON"],[127405,127405,"ON"],[127584,127589,"ON"],[127744,128728,"ON"],[128732,128748,"ON"],[128752,128764,"ON"],[128768,128985,"ON"],[128992,129003,"ON"],[129008,129008,"ON"],[129024,129035,"ON"],[129040,129095,"ON"],[129104,129113,"ON"],[129120,129159,"ON"],[129168,129197,"ON"],[129200,129211,"ON"],[129216,129217,"ON"],[129232,129240,"ON"],[129280,129623,"ON"],[129632,129645,"ON"],[129648,129660,"ON"],[129664,129674,"ON"],[129678,129734,"ON"],[129736,129736,"ON"],[129741,129756,"ON"],[129759,129770,"ON"],[129775,129784,"ON"],[129792,129938,"ON"],[129940,130031,"ON"],[130032,130041,"EN"],[130042,130042,"ON"],[131070,131071,"BN"],[196606,196607,"BN"],[262142,262143,"BN"],[327678,327679,"BN"],[393214,393215,"BN"],[458750,458751,"BN"],[524286,524287,"BN"],[589822,589823,"BN"],[655358,655359,"BN"],[720894,720895,"BN"],[786430,786431,"BN"],[851966,851967,"BN"],[917502,917759,"BN"],[917760,917999,"NSM"],[918e3,921599,"BN"],[983038,983039,"BN"],[1048574,1048575,"BN"],[1114110,1114111,"BN"]];function _n(e){if(e<=255)return Gt[e];let t=0,n=lt.length-1;for(;t<=n;){let o=t+n>>1,r=lt[o];if(e<r[0]){n=o-1;continue}if(e>r[1]){t=o+1;continue}return r[2]}return"L"}function Wn(e){let t=e.length;if(t===0)return null;let n=new Array(t),o=!1;for(let s=0;s<t;){let a=e.charCodeAt(s),m=a,p=1;if(a>=55296&&a<=56319&&s+1<t){let D=e.charCodeAt(s+1);D>=56320&&D<=57343&&(m=(a-55296<<10)+(D-56320)+65536,p=2)}let F=_n(m);(F==="R"||F==="AL"||F==="AN")&&(o=!0);for(let D=0;D<p;D++)n[s+D]=F;s+=p}if(!o)return null;let r=0;for(let s=0;s<t;s++){let a=n[s];if(a==="L"){r=0;break}if(a==="R"||a==="AL"){r=1;break}}let i=new Int8Array(t);for(let s=0;s<t;s++)i[s]=r;let u=r&1?"R":"L",d=u,c=d;for(let s=0;s<t;s++)n[s]==="NSM"?n[s]=c:c=n[s];c=d;for(let s=0;s<t;s++){let a=n[s];a==="EN"?n[s]=c==="AL"?"AN":"EN":(a==="R"||a==="L"||a==="AL")&&(c=a)}for(let s=0;s<t;s++)n[s]==="AL"&&(n[s]="R");for(let s=1;s<t-1;s++)n[s]==="ES"&&n[s-1]==="EN"&&n[s+1]==="EN"&&(n[s]="EN"),n[s]==="CS"&&(n[s-1]==="EN"||n[s-1]==="AN")&&n[s+1]===n[s-1]&&(n[s]=n[s-1]);for(let s=0;s<t;s++){if(n[s]!=="EN")continue;let a;for(a=s-1;a>=0&&n[a]==="ET";a--)n[a]="EN";for(a=s+1;a<t&&n[a]==="ET";a++)n[a]="EN"}for(let s=0;s<t;s++){let a=n[s];(a==="WS"||a==="ES"||a==="ET"||a==="CS")&&(n[s]="ON")}c=d;for(let s=0;s<t;s++){let a=n[s];a==="EN"?n[s]=c==="L"?"L":"EN":(a==="R"||a==="L")&&(c=a)}for(let s=0;s<t;s++){if(n[s]!=="ON")continue;let a=s+1;for(;a<t&&n[a]==="ON";)a++;let m=s>0?n[s-1]:d,p=a<t?n[a]:d,F=m!=="L"?"R":"L";if(F===(p!=="L"?"R":"L"))for(let C=s;C<a;C++)n[C]=F;s=a-1}for(let s=0;s<t;s++)n[s]==="ON"&&(n[s]=u);for(let s=0;s<t;s++){let a=n[s];(i[s]&1)===0?a==="R"?i[s]++:(a==="AN"||a==="EN")&&(i[s]+=2):(a==="L"||a==="AN"||a==="EN")&&i[s]++}return i}function qt(e,t){let n=Wn(e);if(n===null)return null;let o=new Int8Array(t.length);for(let r=0;r<t.length;r++)o[r]=n[t[r]];return o}var Hn=/[ \\t\\n\\r\\f]+/g,jn=/[\\t\\n\\r\\f]| {2,}|^ | $/;function zn(e){let t=e??"normal";return t==="pre-wrap"?{mode:t,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:t,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function Un(e){if(!jn.test(e))return e;let t=e.replace(Hn," ");return t.charCodeAt(0)===32&&(t=t.slice(1)),t.length>0&&t.charCodeAt(t.length-1)===32&&(t=t.slice(0,-1)),t}function Gn(e){return/[\\r\\f]/.test(e)?e.replace(/\\r\\n/g,`\n`).replace(/[\\r\\f]/g,`\n`):e.replace(/\\r\\n/g,`\n`)}var ut=null,qn;function $n(){return ut===null&&(ut=new Intl.Segmenter(qn,{granularity:"word"})),ut}var Kn=/\\p{Script=Arabic}/u,Ge=/\\p{M}/u,Xt=/\\p{Nd}/u;function $t(e){return Kn.test(e)}function Kt(e){return e>=19968&&e<=40959||e>=13312&&e<=19903||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=183984&&e<=191471||e>=191472&&e<=192093||e>=194560&&e<=195103||e>=196608&&e<=201551||e>=201552&&e<=205743||e>=205744&&e<=210041||e>=63744&&e<=64255||e>=12288&&e<=12351||e>=12352&&e<=12447||e>=12448&&e<=12543||e>=44032&&e<=55215||e>=65280&&e<=65519}function Fe(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(!(n<12288)){if(n>=55296&&n<=56319&&t+1<e.length){let o=e.charCodeAt(t+1);if(o>=56320&&o<=57343){let r=(n-55296<<10)+(o-56320)+65536;if(Kt(r))return!0;t++;continue}}if(Kt(n))return!0}}return!1}function Vn(e){let t=Ke(e);return t!==null&&($e.has(t)||ye.has(t))}var Jn=new Set(["\\xA0","\\u202F","\\u2060","\\uFEFF"]);function Qn(e){return Fe(e)}function Zn(e){let t=Ke(e);return t!==null&&Jn.has(t)}function qe(e){return!Vn(e)&&!Zn(e)}var $e=new Set(["\\uFF0C","\\uFF0E","\\uFF01","\\uFF1A","\\uFF1B","\\uFF1F","\\u3001","\\u3002","\\u30FB","\\uFF09","\\u3015","\\u3009","\\u300B","\\u300D","\\u300F","\\u3011","\\u3017","\\u3019","\\u301B","\\u30FC","\\u3005","\\u303B","\\u309D","\\u309E","\\u30FD","\\u30FE"]),He=new Set([\'"\',"(","[","{","\\u201C","\\u2018","\\xAB","\\u2039","\\uFF08","\\u3014","\\u3008","\\u300A","\\u300C","\\u300E","\\u3010","\\u3016","\\u3018","\\u301A"]),dt=new Set(["\'","\\u2019"]),ye=new Set([".",",","!","?",":",";","\\u060C","\\u061B","\\u061F","\\u0964","\\u0965","\\u104A","\\u104B","\\u104C","\\u104D","\\u104F",")","]","}","%",\'"\',"\\u201D","\\u2019","\\xBB","\\u203A","\\u2026"]),Yn=new Set([":",".","\\u060C","\\u061B"]),Xn=new Set(["\\u104F"]),ei=new Set(["\\u201D","\\u2019","\\xBB","\\u203A","\\u300D","\\u300F","\\u3011","\\u300B","\\u3009","\\u3015","\\uFF09"]);function ti(e){if(mt(e))return!0;let t=!1;for(let n of e){if(ye.has(n)){t=!0;continue}if(!(t&&Ge.test(n)))return!1}return t}function ni(e){for(let t of e)if(!$e.has(t)&&!ye.has(t))return!1;return e.length>0}function ii(e){if(mt(e))return!0;for(let t of e)if(!He.has(t)&&!dt.has(t)&&!Ge.test(t))return!1;return e.length>0}function mt(e){let t=!1;for(let n of e)if(!(n==="\\\\"||Ge.test(n))){if(He.has(n)||ye.has(n)||dt.has(n)){t=!0;continue}return!1}return t}function en(e,t){let n=t-1;if(n<=0)return Math.max(n,0);let o=e.charCodeAt(n);if(o<56320||o>57343)return n;let r=n-1;if(r<0)return n;let i=e.charCodeAt(r);return i>=55296&&i<=56319?r:n}function Ke(e){if(e.length===0)return null;let t=en(e,e.length);return e.slice(t)}function oi(e){let t=Array.from(e),n=t.length;for(;n>0;){let o=t[n-1];if(Ge.test(o)){n--;continue}if(He.has(o)||dt.has(o)){n--;continue}break}return n<=0||n===t.length?null:{head:t.slice(0,n).join(""),tail:t.slice(n).join("")}}function ri(e,t,n){return n==="text"&&!t&&e.length===1&&e!=="-"&&e!=="\\u2014"?e:null}function Vt(e,t,n,o){let r=t[o],i=e[o];if(r==null)return i;let u=n[o];if(i.length===u)return i;let d=r.repeat(u);return e[o]=d,d}function Jt(e,t){return e&&t!==null&&Yn.has(t)}function si(e){let t=Ke(e);return t!==null&&Xn.has(t)}function ai(e){if(e.length<2||e[0]!==" ")return null;let t=e.slice(1);return/^\\p{M}+$/u.test(t)?{space:" ",marks:t}:null}function Ve(e){let t=e.length;for(;t>0;){let n=en(e,t),o=e.slice(n,t);if(ei.has(o))return!0;if(!ye.has(o))return!1;t=n}return!1}function li(e,t){if(t.preserveOrdinarySpaces||t.preserveHardBreaks){if(e===" ")return"preserved-space";if(e===" ")return"tab";if(t.preserveHardBreaks&&e===`\n`)return"hard-break"}return e===" "?"space":e==="\\xA0"||e==="\\u202F"||e==="\\u2060"||e==="\\uFEFF"?"glue":e==="\\u200B"?"zero-width-break":e==="\\xAD"?"soft-hyphen":"text"}var ui=/[\\x20\\t\\n\\xA0\\xAD\\u200B\\u202F\\u2060\\uFEFF]/;function Se(e){return e.length===1?e[0]:e.join("")}function ci(e,t){let n=[];for(let o=e.length-1;o>=0;o--)n.push(e[o]);return n.push(t),Se(n)}function di(e,t,n,o){if(!ui.test(e))return[{text:e,isWordLike:t,kind:"text",start:n}];let r=[],i=null,u=[],d=n,c=!1,s=0;for(let a of e){let m=li(a,o),p=m==="text"&&t;if(i!==null&&m===i&&p===c){u.push(a),s+=a.length;continue}i!==null&&r.push({text:Se(u),isWordLike:c,kind:i,start:d}),i=m,u=[a],d=n+s,c=p,s+=a.length}return i!==null&&r.push({text:Se(u),isWordLike:c,kind:i,start:d}),r}function ct(e){return e==="space"||e==="preserved-space"||e==="zero-width-break"||e==="hard-break"}var mi=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function xi(e,t){let n=e.texts[t];return n.startsWith("www.")?!0:mi.test(n)&&t+1<e.len&&e.kinds[t+1]==="text"&&e.texts[t+1]==="//"}function fi(e){return e.includes("?")&&(e.includes("://")||e.startsWith("www."))}function pi(e){let t=e.texts.slice(),n=e.isWordLike.slice(),o=e.kinds.slice(),r=e.starts.slice();for(let u=0;u<e.len;u++){if(o[u]!=="text"||!xi(e,u))continue;let d=[t[u]],c=u+1;for(;c<e.len&&!ct(o[c]);){d.push(t[c]),n[u]=!0;let s=t[c].includes("?");if(o[c]="text",t[c]="",c++,s)break}t[u]=Se(d)}let i=0;for(let u=0;u<t.length;u++){let d=t[u];d.length!==0&&(i!==u&&(t[i]=d,n[i]=n[u],o[i]=o[u],r[i]=r[u]),i++)}return t.length=i,n.length=i,o.length=i,r.length=i,{len:i,texts:t,isWordLike:n,kinds:o,starts:r}}function hi(e){let t=[],n=[],o=[],r=[];for(let i=0;i<e.len;i++){let u=e.texts[i];if(t.push(u),n.push(e.isWordLike[i]),o.push(e.kinds[i]),r.push(e.starts[i]),!fi(u))continue;let d=i+1;if(d>=e.len||ct(e.kinds[d]))continue;let c=[],s=e.starts[d],a=d;for(;a<e.len&&!ct(e.kinds[a]);)c.push(e.texts[a]),a++;c.length>0&&(t.push(Se(c)),n.push(!0),o.push("text"),r.push(s),i=a-1)}return{len:t.length,texts:t,isWordLike:n,kinds:o,starts:r}}var gi=new Set([":","-","/","\\xD7",",",".","+","\\u2013","\\u2014"]),Qt=/^[A-Za-z0-9_]+[,:;]*$/,Zt=/[,:;]+$/;function tn(e){for(let t of e)if(Xt.test(t))return!0;return!1}function We(e){if(e.length===0)return!1;for(let t of e)if(!(Xt.test(t)||gi.has(t)))return!1;return!0}function Si(e){let t=[],n=[],o=[],r=[];for(let i=0;i<e.len;i++){let u=e.texts[i],d=e.kinds[i];if(d==="text"&&We(u)&&tn(u)){let c=[u],s=i+1;for(;s<e.len&&e.kinds[s]==="text"&&We(e.texts[s]);)c.push(e.texts[s]),s++;t.push(Se(c)),n.push(!0),o.push("text"),r.push(e.starts[i]),i=s-1;continue}t.push(u),n.push(e.isWordLike[i]),o.push(d),r.push(e.starts[i])}return{len:t.length,texts:t,isWordLike:n,kinds:o,starts:r}}function Fi(e){let t=[],n=[],o=[],r=[];for(let i=0;i<e.len;i++){let u=e.texts[i],d=e.kinds[i],c=e.isWordLike[i];if(d==="text"&&c&&Qt.test(u)){let s=[u],a=Zt.test(u),m=i+1;for(;a&&m<e.len&&e.kinds[m]==="text"&&e.isWordLike[m]&&Qt.test(e.texts[m]);){let p=e.texts[m];s.push(p),a=Zt.test(p),m++}t.push(Se(s)),n.push(!0),o.push("text"),r.push(e.starts[i]),i=m-1;continue}t.push(u),n.push(c),o.push(d),r.push(e.starts[i])}return{len:t.length,texts:t,isWordLike:n,kinds:o,starts:r}}function Ai(e){let t=[],n=[],o=[],r=[];for(let i=0;i<e.len;i++){let u=e.texts[i];if(e.kinds[i]==="text"&&u.includes("-")){let d=u.split("-"),c=d.length>1;for(let s=0;s<d.length;s++){let a=d[s];if(!c)break;(a.length===0||!tn(a)||!We(a))&&(c=!1)}if(c){let s=0;for(let a=0;a<d.length;a++){let m=d[a],p=a<d.length-1?`${m}-`:m;t.push(p),n.push(!0),o.push("text"),r.push(e.starts[i]+s),s+=p.length}continue}}t.push(u),n.push(e.isWordLike[i]),o.push(e.kinds[i]),r.push(e.starts[i])}return{len:t.length,texts:t,isWordLike:n,kinds:o,starts:r}}function Ni(e){let t=[],n=[],o=[],r=[],i=0;for(;i<e.len;){let u=[e.texts[i]],d=e.isWordLike[i],c=e.kinds[i],s=e.starts[i];if(c==="glue"){let a=[u[0]],m=s;for(i++;i<e.len&&e.kinds[i]==="glue";)a.push(e.texts[i]),i++;let p=Se(a);if(i<e.len&&e.kinds[i]==="text")u[0]=p,u.push(e.texts[i]),d=e.isWordLike[i],c="text",s=m,i++;else{t.push(p),n.push(!1),o.push("glue"),r.push(m);continue}}else i++;if(c==="text")for(;i<e.len&&e.kinds[i]==="glue";){let a=[];for(;i<e.len&&e.kinds[i]==="glue";)a.push(e.texts[i]),i++;let m=Se(a);if(i<e.len&&e.kinds[i]==="text"){u.push(m,e.texts[i]),d=d||e.isWordLike[i],i++;continue}u.push(m)}t.push(Se(u)),n.push(d),o.push(c),r.push(s)}return{len:t.length,texts:t,isWordLike:n,kinds:o,starts:r}}function Ei(e){let t=e.texts.slice(),n=e.isWordLike.slice(),o=e.kinds.slice(),r=e.starts.slice();for(let i=0;i<t.length-1;i++){if(o[i]!=="text"||o[i+1]!=="text"||!Fe(t[i])||!Fe(t[i+1]))continue;let u=oi(t[i]);u!==null&&(t[i]=u.head,t[i+1]=u.tail+t[i+1],r[i+1]=r[i]+u.head.length)}return{len:t.length,texts:t,isWordLike:n,kinds:o,starts:r}}function Yt(e,t,n){let o=$n(),r=0,i=[],u=[],d=[],c=[],s=[],a=[],m=[],p=[],F=[],D=[],C=[],T=[];for(let x of o.segment(e))for(let g of di(x.segment,x.isWordLike??!1,x.index,n)){let K=function(){a[w]!==null&&(u[w]=[Vt(i,a,m,w)],a[w]=null),u[w].push(g.text),d[w]=d[w]||g.isWordLike,p[w]=p[w]||y,F[w]=F[w]||v,D[w]=O,C[w]=V,T[w]=Jt(F[w],_)},E=g.kind==="text",b=ri(g.text,g.isWordLike,g.kind),y=Fe(g.text),v=$t(g.text),_=Ke(g.text),O=Ve(g.text),V=si(g.text),w=r-1;t.carryCJKAfterClosingQuote&&E&&r>0&&c[w]==="text"&&y&&p[w]&&D[w]||E&&r>0&&c[w]==="text"&&ni(g.text)&&p[w]||E&&r>0&&c[w]==="text"&&C[w]?K():E&&r>0&&c[w]==="text"&&g.isWordLike&&v&&T[w]?(K(),d[w]=!0):b!==null&&r>0&&c[w]==="text"&&a[w]===b?m[w]=(m[w]??1)+1:E&&!g.isWordLike&&r>0&&c[w]==="text"&&(ti(g.text)||g.text==="-"&&d[w])?K():(i[r]=g.text,u[r]=[g.text],d[r]=g.isWordLike,c[r]=g.kind,s[r]=g.start,a[r]=b,m[r]=b===null?0:1,p[r]=y,F[r]=v,D[r]=O,C[r]=V,T[r]=Jt(v,_),r++)}for(let x=0;x<r;x++){if(a[x]!==null){i[x]=Vt(i,a,m,x);continue}i[x]=Se(u[x])}for(let x=1;x<r;x++)c[x]==="text"&&!d[x]&&mt(i[x])&&c[x-1]==="text"&&(i[x-1]+=i[x],d[x-1]=d[x-1]||d[x],i[x]="");let U=Array.from({length:r},()=>null),z=-1;for(let x=r-1;x>=0;x--){let g=i[x];if(g.length!==0){if(c[x]==="text"&&!d[x]&&ii(g)&&z>=0&&c[z]==="text"){let E=U[z]??[];E.push(g),U[z]=E,s[z]=s[x],i[x]="";continue}z=x}}for(let x=0;x<r;x++){let g=U[x];g!=null&&(i[x]=ci(g,i[x]))}let k=0;for(let x=0;x<r;x++){let g=i[x];g.length!==0&&(k!==x&&(i[k]=g,d[k]=d[x],c[k]=c[x],s[k]=s[x]),k++)}i.length=k,d.length=k,c.length=k,s.length=k;let Q=Ni({len:k,texts:i,isWordLike:d,kinds:c,starts:s}),S=Ei(Fi(Ai(Si(hi(pi(Q))))));for(let x=0;x<S.len-1;x++){let g=ai(S.texts[x]);g!==null&&(S.kinds[x]!=="space"&&S.kinds[x]!=="preserved-space"||S.kinds[x+1]!=="text"||!$t(S.texts[x+1])||(S.texts[x]=g.space,S.isWordLike[x]=!1,S.kinds[x]=S.kinds[x]==="preserved-space"?"preserved-space":"space",S.texts[x+1]=g.marks+S.texts[x+1],S.starts[x+1]=S.starts[x]+g.space.length))}return S}function yi(e,t){if(e.len===0)return[];if(!t.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:e.len,consumedEndSegmentIndex:e.len}];let n=[],o=0;for(let r=0;r<e.len;r++)e.kinds[r]==="hard-break"&&(n.push({startSegmentIndex:o,endSegmentIndex:r,consumedEndSegmentIndex:r+1}),o=r+1);return o<e.len&&n.push({startSegmentIndex:o,endSegmentIndex:e.len,consumedEndSegmentIndex:e.len}),n}function bi(e){if(e.len<=1)return e;let t=[],n=[],o=[],r=[],i=null,u=!1,d=0,c=!1,s=!1;function a(){i!==null&&(t.push(Se(i)),n.push(u),o.push("text"),r.push(d),i=null)}for(let m=0;m<e.len;m++){let p=e.texts[m],F=e.kinds[m],D=e.isWordLike[m],C=e.starts[m];if(F==="text"){let T=Qn(p),U=qe(p);if(i!==null&&c&&s){i.push(p),u=u||D,c=c||T,s=U;continue}a(),i=[p],u=D,d=C,c=T,s=U;continue}a(),t.push(p),n.push(D),o.push(F),r.push(C)}return a(),{len:t.length,texts:t,isWordLike:n,kinds:o,starts:r}}function nn(e,t,n="normal",o="normal"){let r=zn(n),i=r.mode==="pre-wrap"?Gn(e):Un(e);if(i.length===0)return{normalized:i,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let u=o==="keep-all"?bi(Yt(i,t,r)):Yt(i,t,r);return{normalized:i,chunks:yi(u,r),...u}}var Be=null,on=new Map,Re=null,Mi=96,Ci=/\\p{Emoji_Presentation}/u,Di=/[\\p{Emoji_Presentation}\\p{Extended_Pictographic}\\p{Regional_Indicator}\\uFE0F\\u20E3]/u,xt=null,rn=new Map;function ft(){if(Be!==null)return Be;if(typeof OffscreenCanvas<"u")return Be=new OffscreenCanvas(1,1).getContext("2d"),Be;if(typeof document<"u")return Be=document.createElement("canvas").getContext("2d"),Be;throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function ki(e){let t=on.get(e);return t||(t=new Map,on.set(e,t)),t}function Ae(e,t){let n=t.get(e);return n===void 0&&(n={width:ft().measureText(e).width,containsCJK:Fe(e)},t.set(e,n)),n}function ve(){if(Re!==null)return Re;if(typeof navigator>"u")return Re={lineFitEpsilon:.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},Re;let e=navigator.userAgent,n=navigator.vendor==="Apple Computer, Inc."&&e.includes("Safari/")&&!e.includes("Chrome/")&&!e.includes("Chromium/")&&!e.includes("CriOS/")&&!e.includes("FxiOS/")&&!e.includes("EdgiOS/"),o=e.includes("Chrome/")||e.includes("Chromium/")||e.includes("CriOS/")||e.includes("Edg/");return Re={lineFitEpsilon:n?1/64:.005,carryCJKAfterClosingQuote:o,preferPrefixWidthsForBreakableRuns:n,preferEarlySoftHyphenBreak:n},Re}function Li(e){let t=e.match(/(\\d+(?:\\.\\d+)?)\\s*px/);return t?parseFloat(t[1]):16}function sn(){return xt===null&&(xt=new Intl.Segmenter(void 0,{granularity:"grapheme"})),xt}function Ti(e){return Ci.test(e)||e.includes("\\uFE0F")}function an(e){return Di.test(e)}function wi(e,t){let n=rn.get(e);if(n!==void 0)return n;let o=ft();o.font=e;let r=o.measureText("\\u{1F600}").width;if(n=0,r>t+.5&&typeof document<"u"&&document.body!==null){let i=document.createElement("span");i.style.font=e,i.style.display="inline-block",i.style.visibility="hidden",i.style.position="absolute",i.textContent="\\u{1F600}",document.body.appendChild(i);let u=i.getBoundingClientRect().width;document.body.removeChild(i),r-u>.5&&(n=r-u)}return rn.set(e,n),n}function Bi(e){let t=0,n=sn();for(let o of n.segment(e))Ti(o.segment)&&t++;return t}function Ri(e,t){return t.emojiCount===void 0&&(t.emojiCount=Bi(e)),t.emojiCount}function be(e,t,n){return n===0?t.width:t.width-Ri(e,t)*n}function ln(e,t,n,o,r){if(t.breakableFitAdvances!==void 0)return t.breakableFitAdvances;let i=sn(),u=[];for(let a of i.segment(e))u.push(a.segment);if(u.length<=1)return t.breakableFitAdvances=null,t.breakableFitAdvances;if(r==="sum-graphemes"){let a=[];for(let m of u){let p=Ae(m,n);a.push(be(m,p,o))}return t.breakableFitAdvances=a,t.breakableFitAdvances}if(r==="pair-context"||u.length>Mi){let a=[],m=null,p=0;for(let F of u){let D=Ae(F,n),C=be(F,D,o);if(m===null)a.push(C);else{let T=m+F,U=Ae(T,n);a.push(be(T,U,o)-p)}m=F,p=C}return t.breakableFitAdvances=a,t.breakableFitAdvances}let d=[],c="",s=0;for(let a of u){c+=a;let m=Ae(c,n),p=be(c,m,o);d.push(p-s),s=p}return t.breakableFitAdvances=d,t.breakableFitAdvances}function un(e,t){let n=ft();n.font=e;let o=ki(e),r=Li(e),i=t?wi(e,r):0;return{cache:o,fontSize:r,emojiCorrection:i}}function vi(e,t){for(;t<e.widths.length;){let n=e.kinds[t];if(n!=="space"&&n!=="zero-width-break"&&n!=="soft-hyphen")break;t++}return t}function Ii(e,t){if(t<=0)return 0;let n=e%t;return Math.abs(n)<=1e-6?t:t-n}function Pi(e,t,n,o,r){let i=0,u=t;for(;i<e.length;){let d=u+e[i];if((i+1<e.length?d+r:d)>n+o)break;u=d,i++}return{fitCount:i,fittedWidth:u}}function cn(e,t){return e.simpleLineWalkFastPath?dn(e,t):mn(e,t)}function dn(e,t,n){let{widths:o,kinds:r,breakableFitAdvances:i}=e;if(o.length===0)return 0;let d=ve().lineFitEpsilon,c=t+d,s=0,a=0,m=!1,p=0,F=0,D=0,C=0,T=-1,U=0;function z(){T=-1,U=0}function k(b=D,y=C,v=a){s++,n?.({startSegmentIndex:p,startGraphemeIndex:F,endSegmentIndex:b,endGraphemeIndex:y,width:v}),a=0,m=!1,z()}function Q(b,y){m=!0,p=b,F=0,D=b+1,C=0,a=y}function S(b,y,v){m=!0,p=b,F=y,D=b,C=y+1,a=v}function x(b,y){if(!m){Q(b,y);return}a+=y,D=b+1,C=0}function g(b,y){let v=i[b];for(let _=y;_<v.length;_++){let O=v[_];m?a+O>c?(k(),S(b,_,O)):(a+=O,D=b,C=_+1):S(b,_,O)}m&&D===b&&C===v.length&&(D=b+1,C=0)}let E=0;for(;E<o.length&&!(!m&&(E=vi(e,E),E>=o.length));){let b=o[E],y=r[E],v=y==="space"||y==="preserved-space"||y==="tab"||y==="zero-width-break"||y==="soft-hyphen";if(!m){b>t&&i[E]!==null?g(E,0):Q(E,b),v&&(T=E+1,U=a-b),E++;continue}if(a+b>c){if(v){x(E,b),k(E+1,0,a-b),E++;continue}if(T>=0){if(D>T||D===T&&C>0){k();continue}k(T,0,U);continue}if(b>t&&i[E]!==null){k(),g(E,0),E++;continue}k();continue}x(E,b),v&&(T=E+1,U=a-b),E++}return m&&k(),s}function mn(e,t,n){if(e.simpleLineWalkFastPath)return dn(e,t,n);let{widths:o,lineEndFitAdvances:r,lineEndPaintAdvances:i,kinds:u,breakableFitAdvances:d,discretionaryHyphenWidth:c,tabStopAdvance:s,chunks:a}=e;if(o.length===0||a.length===0)return 0;let m=ve(),p=m.lineFitEpsilon,F=t+p,D=0,C=0,T=!1,U=0,z=0,k=0,Q=0,S=-1,x=0,g=0,E=null;function b(){S=-1,x=0,g=0,E=null}function y(W=k,j=Q,R=C){D++,n?.({startSegmentIndex:U,startGraphemeIndex:z,endSegmentIndex:W,endGraphemeIndex:j,width:R}),C=0,T=!1,b()}function v(W,j){T=!0,U=W,z=0,k=W+1,Q=0,C=j}function _(W,j,R){T=!0,U=W,z=j,k=W,Q=j+1,C=R}function O(W,j){if(!T){v(W,j);return}C+=j,k=W+1,Q=0}function V(W,j,R,$){if(!j)return;let pe=W==="tab"?0:r[R],ue=W==="tab"?$:i[R];S=R+1,x=C-$+pe,g=C-$+ue,E=W}function w(W,j){let R=d[W];for(let $=j;$<R.length;$++){let pe=R[$];T?C+pe>F?(y(),_(W,$,pe)):(C+=pe,k=W,Q=$+1):_(W,$,pe)}T&&k===W&&Q===R.length&&(k=W+1,Q=0)}function K(W){if(E!=="soft-hyphen")return!1;let j=d[W];if(j==null)return!1;let{fitCount:R,fittedWidth:$}=Pi(j,C,t,p,c);return R===0?!1:(C=$,k=W,Q=R,b(),R===j.length?(k=W+1,Q=0,!0):(y(W,R,$+c),w(W,R),!0))}function Z(W){D++,n?.({startSegmentIndex:W.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:W.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),b()}for(let W=0;W<a.length;W++){let j=a[W];if(j.startSegmentIndex===j.endSegmentIndex){Z(j);continue}T=!1,C=0,U=j.startSegmentIndex,z=0,k=j.startSegmentIndex,Q=0,b();let R=j.startSegmentIndex;for(;R<j.endSegmentIndex;){let $=u[R],pe=$==="space"||$==="preserved-space"||$==="tab"||$==="zero-width-break"||$==="soft-hyphen",ue=$==="tab"?Ii(C,s):o[R];if($==="soft-hyphen"){T&&(k=R+1,Q=0,S=R+1,x=C+c,g=C+c,E=$),R++;continue}if(!T){ue>t&&d[R]!==null?w(R,0):v(R,ue),V($,pe,R,ue),R++;continue}if(C+ue>F){let M=C+($==="tab"?0:r[R]),L=C+($==="tab"?ue:i[R]);if(E==="soft-hyphen"&&m.preferEarlySoftHyphenBreak&&x<=F){y(S,0,g);continue}if(E==="soft-hyphen"&&K(R)){R++;continue}if(pe&&M<=F){O(R,ue),y(R+1,0,L),R++;continue}if(S>=0&&x<=F){if(k>S||k===S&&Q>0){y();continue}let J=S;y(J,0,g),R=J;continue}if(ue>t&&d[R]!==null){y(),w(R,0),R++;continue}y();continue}O(R,ue),V($,pe,R,ue),R++}if(T){let $=S===j.consumedEndSegmentIndex?g:C;y(j.consumedEndSegmentIndex,0,$)}}return D}var pt=null;function Oi(){return pt===null&&(pt=new Intl.Segmenter(void 0,{granularity:"grapheme"})),pt}function _i(e){return e?{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]}:{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function Wi(e,t){let n=[],o=[],r=0,i=!1,u=!1,d=!1;function c(){o.length!==0&&(n.push({text:o.length===1?o[0]:o.join(""),start:r}),o=[],i=!1,u=!1,d=!1)}function s(m,p,F){o=[m],r=p,i=F,u=Ve(m),d=He.has(m)}function a(m,p){o.push(m),i=i||p;let F=Ve(m);m.length===1&&ye.has(m)?u=u||F:u=F,d=!1}for(let m of Oi().segment(e)){let p=m.segment,F=Fe(p);if(o.length===0){s(p,m.index,F);continue}if(d||$e.has(p)||ye.has(p)||t.carryCJKAfterClosingQuote&&F&&u){a(p,F);continue}if(!i&&!F){a(p,F);continue}c(),s(p,m.index,F)}return c(),n}function Hi(e){if(e.length<=1)return e;let t=[],n=[e[0].text],o=e[0].start,r=Fe(e[0].text),i=qe(e[0].text);function u(){t.push({text:n.length===1?n[0]:n.join(""),start:o})}for(let d=1;d<e.length;d++){let c=e[d],s=Fe(c.text),a=qe(c.text);if(r&&i){n.push(c.text),r=r||s,i=a;continue}u(),n=[c.text],o=c.start,r=s,i=a}return u(),t}function ji(e,t,n,o){let r=ve(),{cache:i,emojiCorrection:u}=un(t,an(e.normalized)),d=be("-",Ae("-",i),u),s=be(" ",Ae(" ",i),u)*8;if(e.len===0)return _i(n);let a=[],m=[],p=[],F=[],D=e.chunks.length<=1,C=n?[]:null,T=[],U=n?[]:null,z=Array.from({length:e.len});function k(g,E,b,y,v,_,O){v!=="text"&&v!=="space"&&v!=="zero-width-break"&&(D=!1),a.push(E),m.push(b),p.push(y),F.push(v),C?.push(_),T.push(O),U!==null&&U.push(g)}function Q(g,E,b,y,v){let _=Ae(g,i),O=be(g,_,u),V=E==="space"||E==="preserved-space"||E==="zero-width-break"?0:O,w=E==="space"||E==="zero-width-break"?0:O;if(v&&y&&g.length>1){let K="sum-graphemes";We(g)?K="pair-context":r.preferPrefixWidthsForBreakableRuns&&(K="segment-prefixes");let Z=ln(g,_,i,u,K);k(g,O,V,w,E,b,Z);return}k(g,O,V,w,E,b,null)}for(let g=0;g<e.len;g++){z[g]=a.length;let E=e.texts[g],b=e.isWordLike[g],y=e.kinds[g],v=e.starts[g];if(y==="soft-hyphen"){k(E,0,d,d,y,v,null);continue}if(y==="hard-break"){k(E,0,0,0,y,v,null);continue}if(y==="tab"){k(E,0,0,0,y,v,null);continue}let _=Ae(E,i);if(y==="text"&&_.containsCJK){let O=Wi(E,r),V=o==="keep-all"?Hi(O):O;for(let w=0;w<V.length;w++){let K=V[w];Q(K.text,"text",v+K.start,b,o==="keep-all"||!Fe(K.text))}continue}Q(E,y,v,b,!0)}let S=zi(e.chunks,z,a.length),x=C===null?null:qt(e.normalized,C);return U!==null?{widths:a,lineEndFitAdvances:m,lineEndPaintAdvances:p,kinds:F,simpleLineWalkFastPath:D,segLevels:x,breakableFitAdvances:T,discretionaryHyphenWidth:d,tabStopAdvance:s,chunks:S,segments:U}:{widths:a,lineEndFitAdvances:m,lineEndPaintAdvances:p,kinds:F,simpleLineWalkFastPath:D,segLevels:x,breakableFitAdvances:T,discretionaryHyphenWidth:d,tabStopAdvance:s,chunks:S}}function zi(e,t,n){let o=[];for(let r=0;r<e.length;r++){let i=e[r],u=i.startSegmentIndex<t.length?t[i.startSegmentIndex]:n,d=i.endSegmentIndex<t.length?t[i.endSegmentIndex]:n,c=i.consumedEndSegmentIndex<t.length?t[i.consumedEndSegmentIndex]:n;o.push({startSegmentIndex:u,endSegmentIndex:d,consumedEndSegmentIndex:c})}return o}function Ui(e,t,n,o){let r=o?.wordBreak??"normal",i=nn(e,ve(),o?.whiteSpace,r);return ji(i,t,n,r)}function xn(e,t,n){return Ui(e,t,!1,n)}function fn(e,t,n){let o=cn(e,t);return{lineCount:o,height:o*n}}var Gi={maxWidth:1600,baseFontSize:78,minFontSize:42,fontWeight:900,fontFamily:"Outfit",step:2};function pn(e,t){let n={...Gi,...t},o=1.2;for(let r=n.baseFontSize;r>=n.minFontSize;r-=n.step){let i=`${n.fontWeight} ${r}px ${n.fontFamily}`,u=xn(e,i),{lineCount:d}=fn(u,n.maxWidth,r*o);if(d<=1)return{fontSize:r,fits:!0}}return{fontSize:n.minFontSize,fits:!1}}window.__timelines=window.__timelines||{};window.__hyperframes={fitTextFontSize:pn};function hn(){let e=window;e.__hyperframeRuntimeBootstrapped||(e.__hyperframeRuntimeBootstrapped=!0,Ut())}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",hn,{once:!0}):hn();})();\n';
|
|
5997
|
+
RUNTIME_IIFE = '"use strict";(()=>{function me(e){try{window.parent.postMessage(e,"*")}catch{}}function At(e){let t=n=>{let o=n.data;if(!o||o.source!=="hf-parent"||o.type!=="control")return;let r=o.action;if(r==="play"){e.onPlay();return}if(r==="pause"){e.onPause();return}if(r==="seek"){e.onSeek(Number(o.frame??0),o.seekMode??"commit");return}if(r==="set-muted"){e.onSetMuted(!!o.muted);return}if(r==="set-media-output-muted"){e.onSetMediaOutputMuted(!!o.muted);return}if(r==="set-playback-rate"){e.onSetPlaybackRate(Number(o.playbackRate??1));return}if(r==="enable-pick-mode"){e.onEnablePickMode();return}if(r==="disable-pick-mode"){e.onDisablePickMode();return}if(r==="flash-elements"){let i=o.selectors,u=o.duration||800;i&&Nn(i,u)}};return window.addEventListener("message",t),t}function Nn(e,t){if(!document.getElementById("__hf-flash-styles")){let n=document.createElement("style");n.id="__hf-flash-styles",n.textContent=`\n .__hf-flash {\n outline: 2px solid rgba(59, 130, 246, 0.6) !important;\n outline-offset: 2px !important;\n animation: __hf-flash-pulse ${t}ms ease-out forwards !important;\n }\n @keyframes __hf-flash-pulse {\n 0% { outline-color: rgba(59, 130, 246, 0.8); }\n 100% { outline-color: transparent; }\n }\n `,document.head.appendChild(n)}for(let n of e)try{document.querySelectorAll(n).forEach(r=>{r.classList.add("__hf-flash"),setTimeout(()=>r.classList.remove("__hf-flash"),t)})}catch{}}var et=null;function Nt(e){et=e}function Oe(e,t){if(et)try{et({source:"hf-preview",type:"analytics",event:e,properties:t??{}})}catch{}}function Et(e){let t=[],n=d=>{if(typeof d.getAnimations!="function")return[];try{return d.getAnimations()}catch{return[]}},o=(d,c)=>{for(let s of d){try{s.currentTime=c}catch{}try{s.pause()}catch{}}},r=d=>{for(let c of d)try{c.play()}catch{}},i=d=>{for(let c of d)try{c.pause()}catch{}},u=d=>{d.baseDelay?d.el.style.animationDelay=d.baseDelay:d.el.style.removeProperty("animation-delay"),d.basePlayState?d.el.style.animationPlayState=d.basePlayState:d.el.style.removeProperty("animation-play-state")};return{name:"css",discover:()=>{t=[];let d=document.querySelectorAll("*");for(let c of d){if(!(c instanceof HTMLElement))continue;let s=window.getComputedStyle(c);!s.animationName||s.animationName==="none"||t.push({el:c,baseDelay:c.style.animationDelay||"",basePlayState:c.style.animationPlayState||""})}},seek:d=>{let c=Number(d.time)||0;for(let s of t){if(!s.el.isConnected)continue;let a=e?.resolveStartSeconds?e.resolveStartSeconds(s.el):Number.parseFloat(s.el.getAttribute("data-start")??"0")||0,m=Math.max(0,c-a)*1e3,p=n(s.el);if(p.length>0){o(p,m);continue}s.el.style.animationPlayState="paused",s.el.style.animationDelay=`-${(m/1e3).toFixed(3)}s`}},pause:()=>{for(let d of t){if(!d.el.isConnected)continue;let c=n(d.el);c.length>0&&i(c),u(d)}},play:()=>{for(let d of t)d.el.isConnected&&(u(d),r(n(d.el)))},revert:()=>{t=[]}}}function yt(e){return{name:"gsap",discover:()=>{},seek:t=>{let n=e.getTimeline();if(!n)return;n.pause();let o=Math.max(0,Number(t.time)||0);typeof n.totalTime=="function"?n.totalTime(o,!1):n.seek(o,!1)},pause:()=>{let t=e.getTimeline();t&&t.pause()}}}function Ct(){return{name:"lottie",discover:()=>{try{let e=window.lottie;if(e&&typeof e.getRegisteredAnimations=="function"){let t=e.getRegisteredAnimations();if(Array.isArray(t)&&t.length>0){let n=window.__hfLottie??[],o=new Set(n);for(let r of t)o.has(r)||n.push(r);window.__hfLottie=n}}}catch{}},seek:e=>{let t=Math.max(0,Number(e.time)||0),n=window.__hfLottie;if(!(!n||n.length===0))for(let o of n)try{if(bt(o))o.goToAndStop(t*1e3,!1);else if(Mt(o)){if(typeof o.setCurrentRawFrameValue=="function"){let r=o.totalFrames??0,i=o.frameRate??30,u=t*i;r>0&&o.setCurrentRawFrameValue(Math.min(u,r-1))}else if(typeof o.seek=="function"){let r=o.duration??1,i=Math.min(100,t/r*100);o.seek(i)}}}catch{}},pause:()=>{let e=window.__hfLottie;if(!(!e||e.length===0))for(let t of e)try{(bt(t)||Mt(t))&&t.pause()}catch{}},revert:()=>{}}}function bt(e){return typeof e=="object"&&e!==null&&typeof e.goToAndStop=="function"}function Mt(e){return typeof e=="object"&&e!==null&&typeof e.pause=="function"&&("totalFrames"in e||"duration"in e)}function Dt(){let e=null,t=0;return{name:"three",discover:()=>{},seek:n=>{e=Math.max(0,Number(n.time)||0),t=e,window.__hfThreeTime=e;try{window.dispatchEvent(new CustomEvent("hf-seek",{detail:{time:e}}))}catch{}},pause:()=>{e==null&&(e=Math.max(0,t))},play:()=>{e=null},revert:()=>{e=null,t=0}}}function kt(){return{name:"waapi",discover:()=>{},seek:e=>{if(!document.getAnimations)return;let t=Math.max(0,(Number(e.time)||0)*1e3);for(let n of document.getAnimations()){try{n.currentTime=t}catch{}try{n.pause()}catch{}}},pause:()=>{if(document.getAnimations)for(let e of document.getAnimations())try{e.pause()}catch{}}}}function Lt(e){let t=Array.from(document.querySelectorAll("video[data-start], audio[data-start]")),n=[],o=[],r=0;for(let i of t){let u=e?.resolveStartSeconds?e.resolveStartSeconds(i):Number.parseFloat(i.dataset.start??"0");if(!Number.isFinite(u))continue;let d=Number.parseFloat(i.dataset.playbackStart??i.dataset.mediaStart??"0")||0,c=i.defaultPlaybackRate,s=Number.isFinite(c)&&c>0?Math.max(.1,Math.min(5,c)):1,a=i.loop,m=Number.isFinite(i.duration)&&i.duration>0?i.duration:null,p=Number.parseFloat(i.dataset.duration??"");(!Number.isFinite(p)||p<=0)&&m!=null&&(p=Math.max(0,(m-d)/s));let F=Number.isFinite(p)&&p>0?u+p:Number.POSITIVE_INFINITY,D=Number.parseFloat(i.dataset.volume??""),C={el:i,start:u,mediaStart:d,duration:Number.isFinite(p)&&p>0?p:Number.POSITIVE_INFINITY,end:F,volume:Number.isFinite(D)?D:null,playbackRate:s,loop:a,sourceDuration:m};n.push(C),i.tagName==="VIDEO"&&o.push(C),Number.isFinite(F)&&(r=Math.max(r,F))}return{timedMediaEls:t,mediaClips:n,videoClips:o,maxMediaEnd:r}}var tt=new WeakMap,_e=new WeakSet;function En(e){if(_e.has(e))return;_e.add(e);let t=()=>_e.delete(e);e.addEventListener("playing",t,{once:!0}),e.addEventListener("pause",t,{once:!0}),e.addEventListener("error",t,{once:!0})}function Tt(e){let t=!!(e.outputMuted||e.userMuted);for(let n of e.clips){let{el:o}=n;if(!o.isConnected)continue;let r=(e.timeSeconds-n.start)*n.playbackRate+n.mediaStart;if(e.timeSeconds>=n.start&&e.timeSeconds<n.end&&r>=0){if(n.loop&&n.sourceDuration!=null&&n.sourceDuration>0){let F=n.sourceDuration-n.mediaStart;F>0&&r>=n.sourceDuration&&(r=n.mediaStart+(r-n.mediaStart)%F)}n.volume!=null&&(o.volume=n.volume),t&&(o.muted=!0);try{o.playbackRate=n.playbackRate*e.playbackRate}catch{}let u=o.currentTime||0,d=Math.abs(u-r),c=r-u,s=tt.get(o);tt.set(o,c);let a=s===void 0,m=!a&&Math.abs(c-s)>.5,p=d>3;if(d>.5&&(a||m||p))try{o.currentTime=r}catch{}e.playing&&o.paused&&!_e.has(o)?(o.preload!=="auto"&&(o.preload="auto"),En(o),o.play().catch(F=>{_e.delete(o),(F&&typeof F=="object"&&"name"in F?String(F.name??""):"")==="NotAllowedError"&&e.onAutoplayBlocked?.()})):!e.playing&&!o.paused&&o.pause();continue}tt.delete(o),o.paused||o.pause()}}function wt(e){let t=!1,n=null,o=null,r=null,i=null;function u(S,x){try{window.dispatchEvent(new CustomEvent(S,{detail:x}))}catch{}}function d(S){r=S,u("hyperframe:picker:hovered",{elementInfo:r,isPickMode:t,timestamp:Date.now()})}function c(S){i=S,u("hyperframe:picker:selected",{elementInfo:i,isPickMode:t,timestamp:Date.now()})}function s(S){if(!S||S===document.body||S===document.documentElement)return!1;let x=S.tagName.toLowerCase();return!(x==="script"||x==="style"||x==="link"||x==="meta"||S.classList.contains("__hf-pick-highlight"))}function a(S){let x=S;if(x.id)return`#${x.id}`;let g=S.getAttribute("data-composition-id");if(g)return`[data-composition-id="${g}"]`;let E=S.getAttribute("data-composition-src");if(E)return`[data-composition-src="${E}"]`;let b=S.getAttribute("data-track-index");if(b)return`[data-track-index="${b}"]`;let y=S.tagName.toLowerCase(),v=S.parentElement;if(!v)return y;let _=v.querySelectorAll(`:scope > ${y}`);if(_.length===1)return y;for(let O=0;O<_.length;O+=1)if(_[O]===S)return`${y}:nth-of-type(${O+1})`;return y}function m(S){let x=S.tagName.toLowerCase(),g=(S.textContent??"").trim().replace(/\\s+/g," "),E=(b,y)=>b.length>y?`${b.slice(0,y-1)}\\u2026`:b;return x==="h1"||x==="h2"||x==="h3"?"Heading":x==="p"||x==="span"||x==="div"?g.length>0?E(g,56):"Text":x==="img"?"Image":x==="video"?"Video":x==="audio"?"Audio":x==="svg"?"Shape":S.getAttribute("data-composition-src")?"Composition":x==="section"?"Section":`${x.charAt(0).toUpperCase()}${x.slice(1)}`}function p(S,x,g){let E=typeof g=="number"&&g>0?g:8,b=[];if(document.elementsFromPoint)b=document.elementsFromPoint(S,x);else if(document.elementFromPoint){let _=document.elementFromPoint(S,x);b=_?[_]:[]}let y={},v=[];for(let _=0;_<b.length;_+=1){let O=b[_];if(!s(O))continue;let V=`${O.tagName}::${O.id||""}::${_}`;if(!y[V]&&(y[V]=!0,v.push(O),v.length>=E))break}return v}function F(S){let x=S.getBoundingClientRect(),g={};for(let b=0;b<S.attributes.length;b+=1){let y=S.attributes[b];y.name.startsWith("data-")&&(g[y.name]=y.value)}return{id:S.id||null,tagName:S.tagName.toLowerCase(),selector:a(S),label:m(S),boundingBox:{x:x.left,y:x.top,width:x.width,height:x.height},textContent:S.textContent?S.textContent.trim().slice(0,200):null,src:S.getAttribute("src")||S.getAttribute("data-composition-src")||null,dataAttributes:g}}function D(S,x,g){return p(S,x,g).map(F)}function C(S){if(!t)return;let g=p(S.clientX,S.clientY,1)[0]??(S.target instanceof Element?S.target:null);if(!s(g)||n===g)return;n&&n.classList.remove("__hf-pick-highlight"),n=g,g.classList.add("__hf-pick-highlight");let E=F(g);d(E),e.postMessage({source:"hf-preview",type:"element-hovered",elementInfo:E})}function T(S){if(!t)return;S.preventDefault(),S.stopPropagation(),S.stopImmediatePropagation();let x=D(S.clientX,S.clientY,8);x.length!==0&&(d(x[0]??null),e.postMessage({source:"hf-preview",type:"element-pick-candidates",candidates:x,selectedIndex:0,point:{x:S.clientX,y:S.clientY}}))}function U(S){S.key==="Escape"&&(k(),e.postMessage({source:"hf-preview",type:"pick-mode-cancelled"}))}function z(){t||(t=!0,o=document.createElement("style"),o.textContent=[".__hf-pick-highlight { outline: 2px solid #4f8cf7 !important; outline-offset: 2px; cursor: crosshair !important; }",".__hf-pick-active * { cursor: crosshair !important; }"].join(`\n`),document.head.appendChild(o),document.body.classList.add("__hf-pick-active"),document.addEventListener("mousemove",C,!0),document.addEventListener("click",T,!0),document.addEventListener("keydown",U,!0),u("hyperframe:picker:mode",{isPickMode:!0,timestamp:Date.now()}))}function k(){t&&(t=!1,n&&(n.classList.remove("__hf-pick-highlight"),n=null),o&&(o.remove(),o=null),document.body.classList.remove("__hf-pick-active"),document.removeEventListener("mousemove",C,!0),document.removeEventListener("click",T,!0),document.removeEventListener("keydown",U,!0),u("hyperframe:picker:mode",{isPickMode:!1,timestamp:Date.now()}))}function Q(){window.__HF_PICKER_API={enable:z,disable:k,isActive:()=>t,getHovered:()=>r,getSelected:()=>i,getCandidatesAtPoint:(S,x,g)=>Number.isFinite(S)&&Number.isFinite(x)?D(S,x,g):[],pickAtPoint:(S,x,g)=>{if(!Number.isFinite(S)||!Number.isFinite(x))return null;let E=D(S,x,8);if(!E.length)return null;let b=Math.max(0,Math.min(E.length-1,Number(g??0))),y=E[b]??null;return y?(c(y),e.postMessage({source:"hf-preview",type:"element-picked",elementInfo:y}),k(),y):null},pickManyAtPoint:(S,x,g)=>{if(!Number.isFinite(S)||!Number.isFinite(x))return[];let E=D(S,x,8);if(!E.length)return[];let b=[],y=Array.isArray(g)?g:[0];for(let v of y){let _=Math.max(0,Math.min(E.length-1,Math.floor(Number(v)))),O=E[_];if(!O)continue;b.some(w=>w.selector===O.selector&&w.tagName===O.tagName)||b.push(O)}return b.length?(c(b[0]??null),e.postMessage({source:"hf-preview",type:"element-picked-many",elementInfos:b}),k(),b):[]}},u("hyperframe:picker:api-ready",{hasApi:!0,timestamp:Date.now()})}return{enablePickMode:z,disablePickMode:k,installPickerApi:Q}}function nt(e,t){let n=Number.isFinite(t)&&t>0?t:30,o=Number.isFinite(e)&&e>0?e:0;return Math.floor(o*n+1e-9)/n}function Ge(e,t,n){if(e){for(let o of Object.values(e))if(!(!o||o===t))try{n(o)}catch{}}}function Bt(e,t,n){let o=nt(t,n);return e.pause(),typeof e.totalTime=="function"?e.totalTime(o,!1):e.seek(o,!1),o}function yn(e,t,n,o){let r=[];Ge(e,t,i=>{i.play(),r.push(i)});try{return Bt(t,n,o)}finally{for(let i of r)try{i.pause()}catch{}}}function bn(e,t){Ge(e,t,n=>{n.play()})}function Rt(e){return{_timeline:null,play:()=>{let t=e.getTimeline();if(!t||e.getIsPlaying())return;let n=Math.max(0,Number(e.getSafeDuration?.()??t.duration()??0)||0);n>0&&Math.max(0,Number(t.time())||0)>=n&&(t.pause(),t.seek(0,!1),e.onDeterministicSeek(0),e.setIsPlaying(!1),e.onSyncMedia(0,!1),e.onRenderFrameSeek(0)),typeof t.timeScale=="function"&&t.timeScale(e.getPlaybackRate()),t.play(),Ge(e.getTimelineRegistry?.(),t,o=>{typeof o.timeScale=="function"&&o.timeScale(e.getPlaybackRate()),o.play()}),e.onDeterministicPlay(),e.setIsPlaying(!0),e.onShowNativeVideos(),e.onStatePost(!0)},pause:()=>{let t=e.getTimeline();if(!t)return;t.pause(),Ge(e.getTimelineRegistry?.(),t,o=>{o.pause()});let n=Math.max(0,Number(t.time())||0);e.onDeterministicSeek(n),e.onDeterministicPause(),e.setIsPlaying(!1),e.onSyncMedia(n,!1),e.onRenderFrameSeek(n),e.onStatePost(!0)},seek:t=>{let n=e.getTimeline();if(!n)return;let o=Math.max(0,Number(t)||0),r=yn(e.getTimelineRegistry?.(),n,o,e.getCanonicalFps());e.onDeterministicSeek(r),e.setIsPlaying(!1),e.onSyncMedia(r,!1),e.onRenderFrameSeek(r),e.onStatePost(!0)},renderSeek:t=>{let n=e.getTimeline(),o=e.getCanonicalFps(),r=n?(bn(e.getTimelineRegistry?.(),n),Bt(n,t,o)):nt(Math.max(0,Number(t)||0),o);e.onDeterministicSeek(r),e.setIsPlaying(!1),e.onSyncMedia(r,!1),e.onRenderFrameSeek(r),e.onStatePost(!0)},getTime:()=>Number(e.getTimeline()?.time()??0),getDuration:()=>Number(e.getTimeline()?.duration()??0),isPlaying:()=>e.getIsPlaying(),setPlaybackRate:t=>e.setPlaybackRate(t),getPlaybackRate:()=>e.getPlaybackRate()}}function vt(){return{capturedTimeline:null,isPlaying:!1,rafId:null,currentTime:0,deterministicAdapters:[],parityModeEnabled:!0,canonicalFps:30,bridgeMuted:!1,mediaOutputMuted:!1,mediaAutoplayBlockedPosted:!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}}var Mn="data-hf-authored-duration",Cn="data-hf-authored-end";function De(e){if(e==null||e==="")return null;let t=Number(e);return Number.isFinite(t)?t:null}function Dn(e){return De(e.getAttribute("data-duration"))}function kn(e){return De(e.getAttribute("data-end"))}function Ln(e){return De(e.getAttribute(Mn))}function Tn(e){return De(e.getAttribute(Cn))}function wn(e){let t=(e??"").trim();if(!t)return null;let n=De(t);if(n!=null)return{kind:"absolute",value:n};let o=t.match(/^([A-Za-z0-9_.:-]+)(?:\\s*([+-])\\s*([0-9]*\\.?[0-9]+))?$/);if(!o)return null;let r=(o[1]??"").trim();if(!r)return null;let i=o[2]??"+",u=o[3]??"0",d=Number.parseFloat(u),c=Number.isFinite(d)?Math.max(0,d):0,s=i==="-"?-c:c;return{kind:"reference",refId:r,offset:s}}function Be(e){let t=e.timelineRegistry??{},n=e.includeAuthoredTimingAttrs??!1,o=new WeakMap,r=new WeakMap,i=new Set,u=a=>{let m=document.getElementById(a);return m||(document.querySelector(`[data-composition-id="${CSS.escape(a)}"]`)??null)},d=a=>{let m=r.get(a);if(m!==void 0)return m;let p=null,F=Dn(a)??(n?Ln(a):null);if(F!=null&&F>0&&(p=F),p==null||p<=0){let D=kn(a)??(n?Tn(a):null);if(D!=null){let C=s(a,0),T=D-C;Number.isFinite(T)&&T>0&&(p=T)}}if((p==null||p<=0)&&a instanceof HTMLMediaElement){let D=De(a.getAttribute("data-playback-start"))??De(a.getAttribute("data-media-start"))??0;Number.isFinite(a.duration)&&a.duration>D&&(p=a.duration-D)}if(p==null||p<=0){let D=a.getAttribute("data-composition-id");if(D){let C=t[D]??null;if(C&&typeof C.duration=="function")try{let T=Number(C.duration());Number.isFinite(T)&&T>0&&(p=T)}catch{}}}return p!=null&&Number.isFinite(p)&&p>0?(r.set(a,p),p):(r.set(a,null),null)},c=(a,m)=>{if(a.hasAttribute("data-composition-id")){let F=a.parentElement?.closest("[data-composition-id]");return F?s(F,m):0}let p=a.closest("[data-composition-id]");return p?s(p,m):0},s=(a,m)=>{let p=o.get(a);if(p!==void 0)return p??m;if(i.has(a))return m;i.add(a);try{let F=wn(a.getAttribute("data-start"));if(!F){if(a.hasAttribute("data-composition-id")){let z=a.parentElement;if(z&&(z.hasAttribute("data-composition-src")||z.hasAttribute("data-composition-id"))){let k=s(z,m);return o.set(a,k),k}}return o.set(a,m),m}if(F.kind==="absolute"){let z=Math.max(0,F.value),k=Math.max(0,c(a,m)+z);return o.set(a,k),k}let D=u(F.refId);if(!D)return o.set(a,m),m;let C=s(D,0),T=d(D);if(T==null||T<=0){let z=Math.max(0,C+F.offset);return o.set(a,z),z}let U=Math.max(0,C+T+F.offset);return o.set(a,U),U}finally{i.delete(a)}};return{resolveStartForElement:(a,m=0)=>s(a,Math.max(0,m)),resolveDurationForElement:a=>d(a)}}var Bn="data-hf-authored-duration",Rn="data-hf-authored-end";function xe(e){if(e==null||e==="")return null;let t=Number(e);return Number.isFinite(t)?t:null}function it(e){return xe(e.getAttribute("data-duration"))??xe(e.getAttribute(Bn))}function It(e){return xe(e.getAttribute("data-end"))??xe(e.getAttribute(Rn))}function ot(...e){let t=e.filter(n=>Number.isFinite(n??null));return t.length===0?null:Math.max(...t)}var Pt={composition:0,video:1,image:2,element:3,audio:4};function vn(e){if(e.length===0)return;let t=new Map;for(let u of e){let d=t.get(u.track)??new Set;d.add(u.kind),t.set(u.track,d)}if(!Array.from(t.values()).some(u=>u.size>1))return;let o=0,r=new Map,i=[...t.keys()].sort((u,d)=>u-d);for(let u of i){let d=t.get(u);if(d.size===1)r.set(`${u}:${[...d][0]}`,o++);else{let c=[...d].sort((s,a)=>(Pt[s]??99)-(Pt[a]??99));for(let s of c)r.set(`${u}:${s}`,o++)}}for(let u of e){let d=`${u.track}:${u.kind}`,c=r.get(d);c!=null&&(u.track=c)}}function We(e){let t=String(e??"").trim();if(!t)return null;let n=t.toLowerCase();if(n.startsWith("data:")||n.startsWith("javascript:"))return null;try{return new URL(t,document.baseURI).toString()}catch{return t}}function In(e){let t=e.getAttribute("src")??e.getAttribute("data-src");if(t)return We(t);let n=e.getAttribute("data-composition-src");if(n)return We(n);let o=e.querySelector("img[src], video[src], audio[src], source[src]");return o?We(o.getAttribute("src")):null}function Ot(e){let n=window.__timelines??{},o=Be({timelineRegistry:n,includeAuthoredTimingAttrs:!0}),r=B=>{if(!B)return null;let M=n[B]??null;if(!M||typeof M.duration!="function")return null;try{let L=Number(M.duration());return Number.isFinite(L)&&L>0?L:null}catch{return null}},i=B=>{let M=xe(B.getAttribute("data-duration"));if(M!=null&&M>0)return M;let L=xe(B.getAttribute("data-playback-start"))??xe(B.getAttribute("data-media-start"))??0;return Number.isFinite(B.duration)&&B.duration>L?Math.max(0,B.duration-L):null},u=()=>{let B=Array.from(document.querySelectorAll("video[data-start], audio[data-start]"));if(B.length===0)return null;let M=0;for(let L of B){let J=o.resolveStartForElement(L,0);if(!Number.isFinite(J))continue;let X=i(L);X==null||X<=0||(M=Math.max(M,Math.max(0,J)+X))}return M>0?M:null},d=B=>{let M=B.trim().toLowerCase();return!(!M||M==="main"||M.includes("caption")||M.includes("ambient"))},c=(B,M)=>{let L=[],J=null,X=null,I=null,P=B.parentElement;for(;P;){let H=P.getAttribute("data-composition-id");H&&(L.push(H),!I&&P!==M&&(I=H),J==null&&(J=o.resolveStartForElement(P,0)),X==null&&(X=xe(P.getAttribute("data-duration"))??r(H)??null)),P=P.parentElement}return{parentCompositionId:I,compositionAncestors:L.reverse(),inheritedStart:J,inheritedDuration:X}},s=document.querySelector("[data-composition-id]"),a=Array.from(document.querySelectorAll("[data-composition-id]")),m=s?.getAttribute("data-composition-id")??null,p=s?o.resolveStartForElement(s,0):0,F=u(),D=F!=null?Math.max(0,F-Math.max(0,p)):null,C=r(m),T=it(s??document.body),U=ot(...a.filter(B=>B!==s).map(B=>{let M=o.resolveStartForElement(B,0),L=o.resolveDurationForElement(B)??r(B.getAttribute("data-composition-id"))??null;return!Number.isFinite(M)||L==null||L<=0?null:Math.max(0,M)+L})),z=U!=null?Math.max(0,U-Math.max(0,p)):null,k=typeof C=="number"&&Number.isFinite(C)&&C>0?C:null,Q=typeof T=="number"&&Number.isFinite(T)&&T>0?T:null,S=typeof D=="number"&&Number.isFinite(D)&&D>0?D:null,x=typeof z=="number"&&Number.isFinite(z)&&z>0?z:null,g=ot(S,x),E=k!=null&&g!=null&&k>g+1,b=Q??(E?g:ot(k,S,x)),y=b!=null?Math.min(b,e.maxTimelineDurationSeconds):null,_=(y!=null?p+y:null)??(typeof F=="number"&&Number.isFinite(F)&&F>0?F:null),O=(B,M)=>!Number.isFinite(M)||M<=0?0:_==null||!Number.isFinite(_)?M:!Number.isFinite(B)||B>=_?0:Math.max(0,Math.min(M,_-B)),V=[],w=[],K=Array.from(document.querySelectorAll("[data-start], [data-track-index], [data-composition-id], video, audio, img")),Z=0;for(let B=0;B<K.length;B+=1){let M=K[B];if(M===s||["SCRIPT","STYLE","LINK","META","TEMPLATE","NOSCRIPT"].includes(M.tagName))continue;let L=c(M,s),J=o.resolveStartForElement(M,L.inheritedStart??0),X=M.getAttribute("data-composition-id"),I=it(M);if((I==null||I<=0)&&X&&X!==m&&(I=r(X)),(I==null||I<=0)&&M instanceof HTMLMediaElement){let de=xe(M.getAttribute("data-playback-start"))??xe(M.getAttribute("data-media-start"))??0;Number.isFinite(M.duration)&&M.duration>0&&(I=Math.max(0,M.duration-de))}if(I==null||I<=0){let de=L.inheritedDuration;if(de!=null&&de>0){let ge=(L.inheritedStart??0)+de;I=Math.max(0,ge-J)}}if(I==null||I<=0||(I=O(J,I),I<=0))continue;let P=J+I;Z=Math.max(Z,P);let H=M.tagName.toLowerCase(),ue=X&&X!==m?"composition":H==="video"?"video":H==="audio"?"audio":H==="img"?"image":"element";V.push({id:M.id||X||`__node__index_${B}`,label:M.getAttribute("data-timeline-label")??M.getAttribute("data-label")??M.getAttribute("aria-label")??X??M.id??M.className?.split(" ")[0]??ue,start:J,duration:I,track:Number.parseInt(M.getAttribute("data-track-index")??M.getAttribute("data-track")??String(B),10)||0,kind:ue,tagName:H,compositionId:M.getAttribute("data-composition-id"),compositionAncestors:L.compositionAncestors,parentCompositionId:L.parentCompositionId,nodePath:null,compositionSrc:We(M.getAttribute("data-composition-src")),assetUrl:In(M),timelineRole:M.getAttribute("data-timeline-role"),timelineLabel:M.getAttribute("data-timeline-label"),timelineGroup:M.getAttribute("data-timeline-group"),timelinePriority:xe(M.getAttribute("data-timeline-priority"))})}let W=new Set(V.map(B=>B.id)),j=s?.getAttribute("data-composition-id")??null,R=j?n[j]??null:null;if(R&&s){let B=R;if(typeof B.getChildren=="function")try{let M=B.getChildren(!0,!0,!1)??[],L=new Map;for(let I of s.children){let P=I;if(!P.id)continue;let H=P.tagName.toLowerCase();H==="script"||H==="style"||H==="link"||L.set(P,{id:P.id,start:1/0,end:-1/0})}let J=I=>{let P=I;for(;P;){if(L.has(P))return P;if(P===s)return null;P=P.parentElement}return null};for(let I of M){if(typeof I.targets!="function"||typeof I.startTime!="function"||typeof I.duration!="function")continue;let P=I.startTime(),H=I.parent;for(;H&&typeof H.startTime=="function";)P+=H.startTime(),H=H.parent;let ue=P+I.duration();if(!(!Number.isFinite(P)||!Number.isFinite(ue)))for(let de of I.targets()){if(!(de instanceof Element))continue;let Ee=J(de);if(!Ee)continue;let ge=L.get(Ee);ge&&(ge.start=Math.min(ge.start,P),ge.end=Math.max(ge.end,ue))}}let X=V.length>0?Math.max(...V.map(I=>I.track))+1:0;for(let[I,P]of L){if(P.start===1/0||P.end===-1/0)continue;let H=I;if(W.has(H.id))continue;let ue=Math.max(0,P.end-P.start);if(ue<=0)continue;let de=O(P.start,ue);de<=0||(Z=Math.max(Z,P.start+de),V.push({id:H.id,label:H.getAttribute("data-timeline-label")??H.getAttribute("data-label")??H.getAttribute("aria-label")??H.id,start:P.start,duration:de,track:Number.parseInt(H.getAttribute("data-track-index")??H.getAttribute("data-track")??"",10)||X,kind:"element",tagName:H.tagName.toLowerCase(),compositionId:H.getAttribute("data-composition-id"),compositionAncestors:j?[j]:[],parentCompositionId:j,nodePath:null,compositionSrc:null,assetUrl:null,timelineRole:H.getAttribute("data-timeline-role"),timelineLabel:H.getAttribute("data-timeline-label"),timelineGroup:H.getAttribute("data-timeline-group"),timelinePriority:xe(H.getAttribute("data-timeline-priority"))}),W.add(H.id))}}catch{}}if(s&&y!=null&&y>0){let B=V.length>0?Math.max(...V.map(M=>M.track))+1:0;for(let M of s.children){let L=M;if(!L.id||W.has(L.id))continue;let J=L.getAttribute("data-timeline-role");if(J!=="overlay"&&J!=="persistent-overlay")continue;let X=L.tagName.toLowerCase();if(X==="script"||X==="style"||X==="link"||X==="meta"||window.getComputedStyle(L).display==="none")continue;let P=O(0,y);P<=0||(Z=Math.max(Z,P),V.push({id:L.id,label:L.getAttribute("data-timeline-label")??L.getAttribute("data-label")??L.getAttribute("aria-label")??L.id,start:0,duration:P,track:Number.parseInt(L.getAttribute("data-track-index")??L.getAttribute("data-track")??"",10)||B,kind:"element",tagName:X,compositionId:L.getAttribute("data-composition-id"),compositionAncestors:j?[j]:[],parentCompositionId:j,nodePath:null,compositionSrc:null,assetUrl:null,timelineRole:J,timelineLabel:L.getAttribute("data-timeline-label"),timelineGroup:L.getAttribute("data-timeline-group"),timelinePriority:xe(L.getAttribute("data-timeline-priority"))}),W.add(L.id))}}vn(V);for(let B of a){if(B===s)continue;let M=B.getAttribute("data-composition-id");if(!M||!d(M))continue;let L=o.resolveStartForElement(B,0),J=it(B);if((J==null||J<=0)&&It(B)!=null){let H=It(B);J=Math.max(0,H-L)}let X=r(M),I=J&&J>0?J:X;if(I==null||I<=0)continue;let P=O(L,I);P<=0||w.push({id:M,label:B.getAttribute("data-label")??M,start:L,duration:P,thumbnailUrl:We(B.getAttribute("data-thumbnail-url")),avatarName:null})}let $=Math.max(1,Math.min(Math.max(Z||1,y??0),e.maxTimelineDurationSeconds));return{source:"hf-preview",type:"timeline",durationInFrames:E&&Q==null?Number.POSITIVE_INFINITY:Math.max(1,Math.round($*Math.max(1,e.canonicalFps))),clips:V,scenes:w,compositionWidth:xe(s?.getAttribute("data-width"))??1920,compositionHeight:xe(s?.getAttribute("data-height"))??1080}}var Pn=/^(?![a-zA-Z][a-zA-Z\\d+\\-.]*:)(?!\\/\\/)(?!\\/)(?!\\.\\.?\\/).+/,On=e=>new Promise(t=>{let n=!1,o=Date.now(),r=null,i=u=>{n||(n=!0,r!=null&&window.clearTimeout(r),t({status:u,elapsedMs:Math.max(0,Date.now()-o)}))};e.addEventListener("load",()=>i("load"),{once:!0}),e.addEventListener("error",()=>i("error"),{once:!0}),r=window.setTimeout(()=>i("timeout"),8e3)});function rt(e){for(;e.firstChild;)e.removeChild(e.firstChild);e.textContent=""}function _t(e,t){let n=e.trim();if(!n)return e;try{return Pn.test(n)?new URL(n,document.baseURI).toString():t?new URL(n,t).toString():new URL(n,document.baseURI).toString()}catch{return e}}async function st(e){let t=null;e.hostCompositionId&&(t=Array.from(e.sourceNode.querySelectorAll("[data-composition-id]")).find(s=>s.getAttribute("data-composition-id")===e.hostCompositionId)??null);let n=t??e.sourceNode;if(e.headStyles)for(let c of e.headStyles){let s=c.cloneNode(!0);s instanceof HTMLStyleElement&&(document.head.appendChild(s),e.injectedStyles.push(s))}let o=Array.from(n.querySelectorAll("style"));for(let c of o){let s=c.cloneNode(!0);s instanceof HTMLStyleElement&&(document.head.appendChild(s),e.injectedStyles.push(s))}let r=[];if(e.headScripts)for(let c of e.headScripts){let s=c.getAttribute("type")?.trim()??"",a=c.getAttribute("src")?.trim()??"";if(a){let m=_t(a,e.compositionUrl);r.push({kind:"external",src:m,type:s})}else{let m=c.textContent?.trim()??"";m&&r.push({kind:"inline",content:m,type:s})}}let i=Array.from(n.querySelectorAll("script")),u=[...r];for(let c of i){let s=c.getAttribute("type")?.trim()??"",a=c.getAttribute("src")?.trim()??"";if(a){let m=_t(a,e.compositionUrl);u.push({kind:"external",src:m,type:s})}else{let m=c.textContent?.trim()??"";m&&u.push({kind:"inline",content:m,type:s})}c.parentNode?.removeChild(c)}let d=Array.from(n.querySelectorAll("style"));for(let c of d)c.parentNode?.removeChild(c);if(t){let c=document.importNode(t,!0),s=t.getAttribute("data-width"),a=t.getAttribute("data-height"),m=e.parseDimensionPx(s),p=e.parseDimensionPx(a);c.style.position="relative",c.style.width=m||"100%",c.style.height=p||"100%",m&&c.style.setProperty("--comp-width",m),p&&c.style.setProperty("--comp-height",p),s&&e.host.setAttribute("data-width",s),a&&e.host.setAttribute("data-height",a),m&&e.host instanceof HTMLElement&&(e.host.style.width=m),p&&e.host instanceof HTMLElement&&(e.host.style.height=p),e.host.appendChild(c)}else e.hasTemplate?e.host.appendChild(document.importNode(n,!0)):e.host.innerHTML=e.fallbackBodyInnerHtml;for(let c of u){let s=document.createElement("script");if(c.type&&(s.type=c.type),s.async=!1,c.kind==="external"?s.src=c.src:c.type.toLowerCase()==="module"?s.textContent=c.content:s.textContent=`(function(){${c.content}})();`,document.body.appendChild(s),e.injectedScripts.push(s),c.kind==="external"){let a=await On(s);a.status!=="load"&&e.onDiagnostic?.({code:"external_composition_script_load_issue",details:{hostCompositionId:e.hostCompositionId,hostCompositionSrc:e.hostCompositionSrc,resolvedScriptSrc:c.src,loadStatus:a.status,elapsedMs:a.elapsedMs}})}}}async function Wt(e){let t=Array.from(document.querySelectorAll("[data-composition-id]:not([data-composition-src])")).filter(n=>{if(n.children.length>0)return!1;let o=n.getAttribute("data-composition-id");return o?!!document.querySelector(`template#${CSS.escape(o)}-template`):!1});if(t.length!==0)for(let n of t){let o=n.getAttribute("data-composition-id"),r=document.querySelector(`template#${CSS.escape(o)}-template`);rt(n),await st({host:n,hostCompositionId:o,hostCompositionSrc:`template#${o}-template`,sourceNode:r.content,hasTemplate:!0,fallbackBodyInnerHtml:"",compositionUrl:null,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,parseDimensionPx:e.parseDimensionPx,onDiagnostic:e.onDiagnostic})}}async function Ht(e){let t=Array.from(document.querySelectorAll("[data-composition-src]"));t.length!==0&&await Promise.all(t.map(async n=>{let o=n.getAttribute("data-composition-src");if(!o)return;let r=null;try{r=new URL(o,document.baseURI)}catch{r=null}rt(n);try{let i=n.getAttribute("data-composition-id"),u=i!=null?document.querySelector(`template#${CSS.escape(i)}-template`):null;if(u){await st({host:n,hostCompositionId:i,hostCompositionSrc:o,sourceNode:u.content,hasTemplate:!0,fallbackBodyInnerHtml:"",compositionUrl:r,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,parseDimensionPx:e.parseDimensionPx,onDiagnostic:e.onDiagnostic});return}let d=await fetch(o);if(!d.ok)throw new Error(`HTTP ${d.status}`);let c=await d.text(),a=new DOMParser().parseFromString(c,"text/html"),m=(i?a.querySelector(`template#${CSS.escape(i)}-template`):null)??a.querySelector("template"),p=m?m.content:a.body,F=m?void 0:Array.from(a.head.querySelectorAll("style")),D=m?void 0:Array.from(a.head.querySelectorAll("script"));await st({host:n,hostCompositionId:i,hostCompositionSrc:o,sourceNode:p,hasTemplate:!!m,fallbackBodyInnerHtml:a.body.innerHTML,compositionUrl:r,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,parseDimensionPx:e.parseDimensionPx,headStyles:F,headScripts:D,onDiagnostic:e.onDiagnostic})}catch(i){e.onDiagnostic?.({code:"external_composition_load_failed",details:{hostCompositionId:n.getAttribute("data-composition-id"),hostCompositionSrc:o,errorMessage:i instanceof Error?i.message:"unknown_error"}}),rt(n)}}))}function at(){let e=window.gsap;e&&document.querySelectorAll(".caption-group").length!==0&&fetch("caption-overrides.json").then(t=>t.ok?t.json():null).then(t=>{if(!t||!Array.isArray(t)||t.length===0)return;let n=[],o=document.querySelectorAll(".caption-group");for(let r of o){let i=r.querySelectorAll(":scope > span");for(let u of i)n.push(u)}for(let r of t){let i=null;if(r.wordId&&(i=document.getElementById(r.wordId)),!i&&r.wordIndex!==void 0&&(i=n[r.wordIndex]??null),!i||!(i instanceof HTMLElement))continue;let u={},d={};if(r.x!==void 0&&(u.x=r.x),r.y!==void 0&&(u.y=r.y),r.scale!==void 0&&(u.scale=r.scale),r.rotation!==void 0&&(u.rotation=r.rotation),r.opacity!==void 0&&(d.opacity=r.opacity),r.fontSize!==void 0&&(d.fontSize=`${r.fontSize}px`),r.fontWeight!==void 0&&(d.fontWeight=r.fontWeight),r.fontFamily!==void 0&&(d.fontFamily=r.fontFamily),r.activeColor||r.dimColor){let s=e.getTweensOf(i).filter(m=>m.vars.color!==void 0).sort((m,p)=>m.startTime()-p.startTime()),a=s.length>0?String(s[0].vars.color):"";for(let m of s)String(m.vars.color)===a?r.dimColor&&(m.vars.color=r.dimColor):r.activeColor&&(m.vars.color=r.activeColor);r.dimColor&&e.set(i,{color:r.dimColor})}if(Object.keys(d).length>0&&e.set(i,d),Object.keys(u).length>0){let c=document.createElement("span");c.style.display="inline-block",c.dataset.captionWrapper="true",i.parentNode?.insertBefore(c,i),c.appendChild(i),e.set(c,u)}}}).catch(()=>{})}var jt="data-hf-authored-duration",zt="data-hf-authored-end";function Ut(){let e=vt(),t=window,n=null,o=null,r=[],i=new Set,u=null;if(typeof t.__hfRuntimeTeardown=="function")try{t.__hfRuntimeTeardown()}catch{}document.documentElement&&(document.documentElement.style.margin="0",document.documentElement.style.padding="0",document.documentElement.style.overflow="hidden"),document.body&&(document.body.style.margin="0",document.body.style.padding="0",document.body.style.overflow="hidden"),window.__timelines=window.__timelines||{};let d=l=>{r.push(l)},c=(l,h,f)=>{let N=f??`${l}:${JSON.stringify(h)}`;i.has(N)||(i.add(N),me({source:"hf-preview",type:"diagnostic",code:l,details:h}))},s=l=>{let h={scale:1,focusX:960,focusY:540},f=[],N=[],A={time:l.getTime(),duration:l.getDuration(),isPlaying:l.isPlaying(),renderMode:!1,timelineDirty:!1};return{play:l.play,pause:l.pause,seek:l.seek,getTime:l.getTime,getDuration:l.getDuration,isPlaying:l.isPlaying,getMainTimeline:()=>null,getElementBounds:()=>{},getElementsAtPoint:()=>{},setElementPosition:()=>{},previewElementPosition:()=>{},setElementKeyframes:()=>{},setElementScale:()=>{},setElementFontSize:()=>{},setElementTextContent:()=>{},setElementTextColor:()=>{},setElementTextShadow:()=>{},setElementTextFontWeight:()=>{},setElementTextFontFamily:()=>{},setElementTextOutline:()=>{},setElementTextHighlight:()=>{},setElementVolume:()=>{},setStageZoom:()=>{},getStageZoom:()=>h,setStageZoomKeyframes:()=>{},getStageZoomKeyframes:()=>f,addElement:()=>!1,removeElement:()=>!1,updateElementTiming:()=>!1,setElementTiming:()=>{},updateElementSrc:()=>!1,updateElementLayer:()=>!1,updateElementBasePosition:()=>!1,markTimelineDirty:()=>{},isTimelineDirty:()=>!1,rebuildTimeline:()=>{},ensureTimeline:()=>{},enableRenderMode:()=>{},disableRenderMode:()=>{},renderSeek:l.renderSeek,getElementVisibility:()=>({visible:!1}),getVisibleElements:()=>N,getRenderState:()=>({...A,time:l.getTime(),duration:l.getDuration(),isPlaying:l.isPlaying()})}},a=1/60,m=.75,p=.75,F=.35,D=900,C=3,T=2,U=.05,z=100,k=240,Q=l=>{if(l instanceof Error)return l.message||String(l);if(typeof l=="string")return l;try{return JSON.stringify(l)}catch{return String(l??"")}},S=l=>{let h=l.toLowerCase();return h.includes("cannot read properties of null")||h.includes("cannot set properties of null")?{code:"runtime_null_dom_access",category:"dom-null-access"}:h.includes("failed to execute \'queryselector\'")?{code:"runtime_invalid_selector",category:"selector-invalid"}:h.includes("is not defined")?{code:"runtime_reference_missing",category:"reference-missing"}:{code:"runtime_script_error",category:"script-error"}},x=l=>{if(l==null||l.trim()==="")return null;let h=Number.parseFloat(l);return!Number.isFinite(h)||h<=0?null:`${h}px`},g=()=>{let l=document.querySelector(\'[data-composition-id][data-root="true"]\');if(l instanceof HTMLElement)return l;let h=Array.from(document.querySelectorAll("[data-composition-id]"));return h.length===0?null:h.find(f=>!f.parentElement?.closest("[data-composition-id]"))??h[0]??null},E=()=>{let l=g();if(!l)return;let h=x(l.getAttribute("data-width")),f=x(l.getAttribute("data-height"));h&&(l.style.width=h),f&&(l.style.height=f),h&&l.style.setProperty("--comp-width",h),f&&l.style.setProperty("--comp-height",f)},b=()=>{let l=g(),h=Array.from(document.querySelectorAll("[data-composition-id]")).filter(f=>f.hasAttribute("data-duration")||f.hasAttribute("data-end"));for(let f of h){if(l&&f===l)continue;let N=f.getAttribute("data-duration"),A=f.getAttribute("data-end");N!=null&&!f.hasAttribute(jt)&&f.setAttribute(jt,N),A!=null&&!f.hasAttribute(zt)&&f.setAttribute(zt,A),f.removeAttribute("data-duration"),f.removeAttribute("data-end")}},y=()=>{let l=g();if(!l)return;l.style.position||(l.style.position="relative"),l.style.overflow="hidden";let h=x(l.getAttribute("data-width")),f=x(l.getAttribute("data-height"));h&&(l.style.width=h),f&&(l.style.height=f);let N=Array.from(l.children);for(let A of N){let te=A.tagName.toLowerCase();if(te==="script"||te==="style"||te==="link"||te==="meta"||!A.hasAttribute("data-start"))continue;let ce=(A.style.top==="0px"||A.style.top==="0")&&(A.style.left==="0px"||A.style.left==="0")&&A.style.width==="100%"&&A.style.height==="100%",pe=/translate\\(\\s*-50%\\s*,\\s*-50%\\s*\\)/.test(A.style.transform);if(ce&&pe&&!A.hasAttribute("data-width")&&!A.hasAttribute("data-height")){let Ae=A.style.top,Y=A.style.left,G=A.style.width,ee=A.style.height;A.style.top="",A.style.left="",A.style.width="",A.style.height="";let q=window.getComputedStyle(A);q.top!=="auto"||q.bottom!=="auto"||q.left!=="auto"||q.right!=="auto"||q.width!=="0px"||q.height!=="0px"||(A.style.top=Ae,A.style.left=Y,A.style.width=G,A.style.height=ee)}let re=window.getComputedStyle(A),ie=re.position;if(ie!=="absolute"&&ie!=="fixed"&&(A.style.position="absolute"),!!A.style.top||!!A.style.bottom||re.top!=="auto"||re.bottom!=="auto"||(A.style.top="0"),!!A.style.left||!!A.style.right||re.left!=="auto"||re.right!=="auto"||(A.style.left="0"),te!=="audio"){let Ae=x(A.getAttribute("data-width")),Y=x(A.getAttribute("data-height")),G=re.width!=="0px"&&re.width!=="auto",ee=re.height!=="0px"&&re.height!=="auto";Ae?!A.style.width&&!G&&(A.style.width=Ae):!A.style.width&&re.width==="0px"&&(A.style.width="100%"),Y?!A.style.height&&!ee&&(A.style.height=Y):!A.style.height&&re.height==="0px"&&(A.style.height="100%")}}},v=(l,h=0)=>Be({timelineRegistry:window.__timelines??{}}).resolveStartForElement(l,h),_=(l,h)=>Be({timelineRegistry:window.__timelines??{},includeAuthoredTimingAttrs:h?.includeAuthoredTimingAttrs??!0}).resolveDurationForElement(l),O=!!document.querySelector("[data-composition-src]"),V=!1;{let l=document.querySelectorAll("[data-composition-id]:not([data-composition-src])");for(let h of l){let f=h.getAttribute("data-composition-id");if(f&&h.children.length===0&&document.querySelector(`template#${CSS.escape(f)}-template`)){V=!0;break}}}let w=!O&&!V,K=l=>{if(!l||typeof l.duration!="function")return null;try{let h=Number(l.duration());return Number.isFinite(h)?Math.max(0,h):null}catch{return null}},Z=l=>typeof l=="number"&&Number.isFinite(l)&&l>a,W=l=>{let h=Number(l.getAttribute("data-duration"));if(Number.isFinite(h)&&h>0)return h;let f=Number(l.getAttribute("data-playback-start")??l.getAttribute("data-media-start")??"0"),N=Number.isFinite(f)?Math.max(0,f):0;return Number.isFinite(l.duration)&&l.duration>N?Math.max(0,l.duration-N):null},j=()=>{let l=Array.from(document.querySelectorAll("video[data-start], audio[data-start]"));if(l.length===0)return null;let h=0;for(let f of l){let N=v(f,0);if(!Number.isFinite(N))continue;let A=W(f);A==null||A<=a||(h=Math.max(h,Math.max(0,N)+A))}return h>a?h:null},R=()=>{let l=j();return typeof l!="number"||!Number.isFinite(l)||l<=a?null:l},$=l=>Z(l)?Math.max(a,l*m):a,fe=(l,h=0)=>{let f=K(l),N=R(),A=Number.isFinite(h)&&h>a?h:0,te=0;Z(f)?te=Math.max(f,A):Z(N)?te=Math.max(N,A):te=A;let ce=Math.max(1,Number(e.maxTimelineDurationSeconds)||1800);return te>0?Math.max(0,Math.min(te,ce)):0},le=()=>{let l=window.__timelines??{},h=Be({timelineRegistry:l}),f=R(),N=$(f),A=Y=>{let G=document.querySelector(`[data-composition-id="${CSS.escape(Y)}"]`);return G?h.resolveStartForElement(G,0):0},te=Y=>{let G=window.gsap;if(!G||typeof G.timeline!="function")return null;let ee=G.timeline({paused:!0});for(let q of Y)ee.add(q.timeline,A(q.compositionId));return ee},ce=(Y,G)=>{if(!Z(Y))return null;let ee=window.gsap;if(!ee||typeof ee.timeline!="function")return null;let q=ee.timeline({paused:!0});if(G)try{q.add(G,0)}catch{}let ne=q;if(typeof ne.to=="function")try{ne.to({},{duration:Y})}catch{}return q},pe=(Y,G)=>{let ee=Y;if(typeof ee.getChildren!="function")return[];try{let q=ee.getChildren(!0,!0,!0)??[];if(!Array.isArray(q))return[];let ne=[];for(let se of G)if(!q.some(Ce=>Ce===se.timeline))try{let Ce=A(se.compositionId);Y.add(se.timeline,Ce),ne.push(se.compositionId)}catch{}return ne}catch{return[]}},re=g(),ie=re?.getAttribute("data-composition-id")??null;if(!ie)return{timeline:null};let he=l[ie]??null,oe=(()=>{if(!re)return[];let Y=new Set,G=Array.from(re.querySelectorAll("[data-composition-id]")),ee=[];for(let q of G){let ne=q.getAttribute("data-composition-id");if(!ne||ne===ie||Y.has(ne))continue;Y.add(ne);let se=l[ne]??null;if(!se||typeof se.play!="function"||typeof se.pause!="function")continue;let we=K(se);ee.push({compositionId:ne,timeline:se,durationSeconds:we??0})}return ee})(),Ae=Y=>{for(let G of Y){let ee=G.timeline;if(typeof ee.paused=="function")try{ee.paused(!1)}catch{}}};if(oe.length>0&&Ae(oe),he){let Y=oe.length>0?pe(he,oe):[];if((oe.length>0||!document.querySelector("[data-composition-id]:not([data-composition-id=\'"+ie+"\'])"))&&(M=!0),Y.length>0)try{let q=he.time();he.seek(q,!1)}catch{}let G=K(he);if(!Z(G)&&oe.length>0){let q=oe.map(An=>An.compositionId),ne=te(oe),se=K(ne);if(ne&&Z(se))return{timeline:ne,selectedTimelineIds:q,selectedDurationSeconds:se,mediaDurationFloorSeconds:f,diagnostics:{code:"root_timeline_unusable_fallback",details:{rootCompositionId:ie,rootDurationSeconds:G,fallbackKind:"composite_by_root_children",minCandidateDurationSeconds:N,selectedDurationSeconds:se,mediaDurationFloorSeconds:f,selectedTimelineIds:q,autoNestedChildren:Y}}};let we=ce(f??0,he),Ce=K(we);if(we&&Z(Ce))return{timeline:we,selectedTimelineIds:[ie],selectedDurationSeconds:Ce,mediaDurationFloorSeconds:f,diagnostics:{code:"root_timeline_unusable_media_floor_fallback",details:{rootCompositionId:ie,rootDurationSeconds:G,fallbackKind:"media_duration_floor",mediaDurationFloorSeconds:f,selectedDurationSeconds:Ce,selectedTimelineIds:[ie],autoNestedChildren:Y}}}}if(!Z(G)&&oe.length===0){let q=ce(f??0,he),ne=K(q);if(q&&Z(ne))return{timeline:q,selectedTimelineIds:[ie],selectedDurationSeconds:ne,mediaDurationFloorSeconds:f,diagnostics:{code:"root_timeline_unusable_media_floor_fallback",details:{rootCompositionId:ie,rootDurationSeconds:G,fallbackKind:"media_duration_floor",mediaDurationFloorSeconds:f,selectedDurationSeconds:ne,selectedTimelineIds:[ie]}}}}let ee=re?.getAttribute("data-duration");if(ee){let q=parseFloat(ee);if(Z(q)&&Z(G)&&q>=G+.5){let ne=he;if(typeof ne.to=="function")try{ne.to({},{duration:0},q)}catch{}let se=K(he);if(Z(se))return{timeline:he,selectedTimelineIds:[ie],selectedDurationSeconds:se,mediaDurationFloorSeconds:f,diagnostics:{code:"root_timeline_padded_to_declared_duration",details:{rootCompositionId:ie,rootDurationSeconds:G,rootDeclaredDur:q,newDur:se}}}}}return{timeline:he,selectedTimelineIds:[ie],selectedDurationSeconds:G,mediaDurationFloorSeconds:f,diagnostics:Y.length>0?{code:"root_timeline_auto_nested_children",details:{rootCompositionId:ie,selectedDurationSeconds:G,autoNestedChildren:Y}}:void 0}}if(oe.length>0){let Y=oe.map(q=>q.compositionId),G=te(oe),ee=K(G);if(G)return{timeline:G,selectedTimelineIds:Y,selectedDurationSeconds:ee,mediaDurationFloorSeconds:f,diagnostics:{code:"root_timeline_missing_fallback",details:{rootCompositionId:ie,fallbackKind:"composite_by_root_children",minCandidateDurationSeconds:N,selectedDurationSeconds:ee,mediaDurationFloorSeconds:f,selectedTimelineIds:Y}}}}return{timeline:null}},B=()=>{let l=e.capturedTimeline;if(!l||typeof l.time!="function")return;let h=Number(l.time());Number.isFinite(h)&&(e.currentTime=Math.max(0,h))},M=!1,L=()=>{if(!w)return!1;let l=e.capturedTimeline,h=K(l),f=Z(h);if(l&&f&&M)return!1;let N=le();return N.timeline?l&&l===N.timeline?(typeof l.timeScale=="function"&&l.timeScale(e.playbackRate),!1):(e.capturedTimeline=N.timeline,typeof e.capturedTimeline.timeScale=="function"&&e.capturedTimeline.timeScale(e.playbackRate),N.diagnostics&&me({source:"hf-preview",type:"diagnostic",code:N.diagnostics.code,details:N.diagnostics.details}),me({source:"hf-preview",type:"diagnostic",code:"timeline_bound",details:{selectedTimelineIds:N.selectedTimelineIds??[],selectedDurationSeconds:N.selectedDurationSeconds??null,mediaDurationFloorSeconds:N.mediaDurationFloorSeconds??null}}),!0):!1},J=()=>{let l=g();if(!(l instanceof HTMLElement))return;let h=l.getBoundingClientRect(),f=Number(l.getAttribute("data-width")),N=Number(l.getAttribute("data-height")),A=window.getComputedStyle(l),te=Number.isFinite(f)&&f>0&&Number.isFinite(N)&&N>0,ce=h.width<=0||h.height<=0||l.clientWidth<=0||l.clientHeight<=0;!te||!ce||c("root_stage_layout_zero",{compositionId:l.getAttribute("data-composition-id")??null,declaredWidth:f,declaredHeight:N,rectWidth:Math.round(h.width),rectHeight:Math.round(h.height),clientWidth:l.clientWidth,clientHeight:l.clientHeight,display:A.display,visibility:A.visibility,overflow:A.overflow},`root-stage-layout-zero:${l.getAttribute("data-composition-id")??"unknown"}`)},X=()=>{e.tornDown||(u!=null&&window.cancelAnimationFrame(u),u=window.requestAnimationFrame(()=>{u=null,J()}))},I=()=>{n=l=>{let h=Q(l.error??l.message).slice(0,k);if(!h)return;let f=S(h);me({source:"hf-preview",type:"diagnostic",code:f.code,details:{category:f.category,message:h,filename:l.filename||null,line:Number.isFinite(l.lineno)?l.lineno:null,column:Number.isFinite(l.colno)?l.colno:null}})},o=l=>{let h=Q(l.reason).slice(0,k);if(!h)return;let f=S(h);me({source:"hf-preview",type:"diagnostic",code:`${f.code}_unhandled_rejection`,details:{category:`${f.category}-unhandled-rejection`,message:h}})},window.addEventListener("error",n),window.addEventListener("unhandledrejection",o)},P=()=>{let l=Array.from(document.querySelectorAll("img, video, audio, source, link[rel=\'stylesheet\']"));for(let f of l){let N=()=>{if(!(f instanceof Element))return;let A=f.tagName.toLowerCase(),te=f.getAttribute("src")??f.getAttribute("href")??f.getAttribute("poster")??null,ce=A==="link"?"runtime_stylesheet_load_failed":"runtime_asset_load_failed";c(ce,{tagName:A,assetUrl:te,currentSrc:(f instanceof HTMLImageElement||f instanceof HTMLMediaElement)&&f.currentSrc||null,readyState:f instanceof HTMLMediaElement?f.readyState:null,networkState:f instanceof HTMLMediaElement?f.networkState:null},`${ce}:${A}:${te??"unknown"}`)};f.addEventListener("error",N),d(()=>{f.removeEventListener("error",N)})}let h=document.fonts;h&&h.ready.then(()=>{if(e.tornDown)return;let f=Array.from(h).filter(N=>N.status==="error").map(N=>N.family).filter(N=>!!N).slice(0,10);f.length!==0&&c("runtime_font_load_issue",{failedFamilies:f,totalFaces:Array.from(h).length},`runtime-font-load-issue:${f.join("|")}`)}).catch(()=>{})},H=(l,h)=>{if(!l.timeline)return!1;let f=e.capturedTimeline;if(f&&f===l.timeline)return!1;let N=Math.max(0,e.currentTime||0),A=e.isPlaying;e.capturedTimeline=l.timeline,typeof e.capturedTimeline.timeScale=="function"&&e.capturedTimeline.timeScale(e.playbackRate);try{e.capturedTimeline.pause(),e.capturedTimeline.seek(N,!1),A&&e.capturedTimeline.play()}catch{}return me({source:"hf-preview",type:"diagnostic",code:"timeline_loop_guard_rebind",details:{reason:h,previousTime:N,selectedTimelineIds:l.selectedTimelineIds??[],selectedDurationSeconds:l.selectedDurationSeconds??null,mediaDurationFloorSeconds:l.mediaDurationFloorSeconds??null}}),!0},ue=null,de=!1,Ee=new Set,ge=()=>{e.tornDown||(ue!=null&&window.clearTimeout(ue),ue=window.setTimeout(()=>{if(e.tornDown)return;ue=null;let l=le();if(!l.timeline||!Z(l.mediaDurationFloorSeconds??null))return;if(!e.capturedTimeline){L()&&(ke(),ye(!0));return}if(de)return;let f=K(e.capturedTimeline),N=l.selectedDurationSeconds??K(l.timeline);Z(N)&&(!Z(f)||N>=f+U)&&H(l,"manual")&&(de=!0,me({source:"hf-preview",type:"diagnostic",code:"timeline_rebind_after_media_metadata",details:{previousDurationSeconds:f??null,selectedDurationSeconds:N??null,selectedTimelineIds:l.selectedTimelineIds??[],mediaDurationFloorSeconds:l.mediaDurationFloorSeconds??null}}),ke(),ye(!0))},z))},gn=()=>{for(let l of Ee)l.removeEventListener("loadedmetadata",ge),l.removeEventListener("durationchange",ge);Ee.clear()},Qe=()=>{if(e.tornDown)return;let l=Array.from(document.querySelectorAll("video, audio"));for(let h of l)Ee.has(h)||(Ee.add(h),h.addEventListener("loadedmetadata",ge),h.addEventListener("durationchange",ge),h.preload!=="auto"&&(h.preload="auto"),h.readyState<HTMLMediaElement.HAVE_FUTURE_DATA&&h.load())},ht=()=>{let l=Lt({resolveStartSeconds:N=>v(N,0)});Tt({clips:l.mediaClips,timeSeconds:e.currentTime,playing:e.isPlaying,playbackRate:e.playbackRate,outputMuted:e.mediaOutputMuted,userMuted:e.bridgeMuted,onAutoplayBlocked:()=>{e.mediaAutoplayBlockedPosted||(e.mediaAutoplayBlockedPosted=!0,me({source:"hf-preview",type:"media-autoplay-blocked"}))}});let h=document.querySelector("[data-composition-id]")?.getAttribute("data-composition-id")??null,f=Array.from(document.querySelectorAll("[data-start]"));for(let N of f){if(!(N instanceof HTMLElement))continue;let A=N.tagName.toLowerCase();if(A==="script"||A==="style"||A==="link"||A==="meta")continue;if(!N.getAttribute("data-composition-id")){let oe=N.closest("[data-composition-id]")?.getAttribute("data-composition-id")??null;if(oe&&oe!==h)continue}let ce=v(N,0),pe=_(N),re=N.getAttribute("data-composition-id");if(re){let Te=(window.__timelines??{})[re],oe=null;if(Te&&typeof Te.duration=="function"){let Ae=Number(Te.duration());Number.isFinite(Ae)&&Ae>0&&(oe=Ae)}pe!=null&&pe>0&&oe!=null?pe=Math.min(pe,oe):(pe==null||pe<=0)&&oe!=null&&(pe=oe)}let ie=pe!=null&&pe>0?ce+pe:Number.POSITIVE_INFINITY,he=e.currentTime>=ce&&(Number.isFinite(ie)?e.currentTime<ie:!0);N.style.visibility=he?"visible":"hidden"}},ye=l=>{B();let h=Math.max(0,Math.round((e.currentTime||0)*e.canonicalFps)),f=Date.now();(l||h!==e.bridgeLastPostedFrame||e.isPlaying!==e.bridgeLastPostedPlaying||e.bridgeMuted!==e.bridgeLastPostedMuted||f-e.bridgeLastPostedAt>=e.bridgeMaxPostIntervalMs)&&(e.bridgeLastPostedFrame=h,e.bridgeLastPostedPlaying=e.isPlaying,e.bridgeLastPostedMuted=e.bridgeMuted,e.bridgeLastPostedAt=f,me({source:"hf-preview",type:"state",frame:h,isPlaying:e.isPlaying,muted:e.bridgeMuted,playbackRate:e.playbackRate}))},ke=()=>{b(),E(),y();let l=g();if(l){let f=x(l.getAttribute("data-width")),N=x(l.getAttribute("data-height")),A=f?parseInt(f,10):0,te=N?parseInt(N,10):0;A>0&&te>0&&me({source:"hf-preview",type:"stage-size",width:A,height:te})}L();let h=Ot({canonicalFps:e.canonicalFps,maxTimelineDurationSeconds:e.maxTimelineDurationSeconds});window.__clipManifest=h,me(h),X()},Pe=(l,h=0)=>{for(let f of e.deterministicAdapters){try{l==="discover"&&f.discover(),l==="pause"&&f.pause(),l==="play"&&f.play&&f.play()}catch{}if(l==="discover")try{f.seek({time:h})}catch{}}};if(w)at();else{let l={injectedStyles:e.injectedCompStyles,injectedScripts:e.injectedCompScripts,parseDimensionPx:x,onDiagnostic:({code:h,details:f})=>{me({source:"hf-preview",type:"diagnostic",code:h,details:f})}};Ht(l).then(()=>Wt(l)).finally(()=>{w=!0,Pe("discover",e.currentTime),Qe(),P(),at(),ke(),ye(!0)})}let ze=wt({postMessage:l=>me(l)});ze.installPickerApi();let gt=l=>{let h=Number(l);!Number.isFinite(h)||h<=0?e.playbackRate=1:e.playbackRate=Math.max(.1,Math.min(5,h)),e.capturedTimeline&&typeof e.capturedTimeline.timeScale=="function"&&e.capturedTimeline.timeScale(e.playbackRate);let f=document.querySelectorAll("video, audio");for(let N of f)if(N instanceof HTMLMediaElement)try{N.playbackRate=e.playbackRate}catch{}},ae=Rt({getTimeline:()=>e.capturedTimeline,setTimeline:l=>{e.capturedTimeline=l},getTimelineRegistry:()=>window.__timelines??{},getIsPlaying:()=>e.isPlaying,setIsPlaying:l=>{e.isPlaying=l},getPlaybackRate:()=>e.playbackRate,setPlaybackRate:gt,getCanonicalFps:()=>e.canonicalFps,onSyncMedia:(l,h)=>{e.currentTime=Math.max(0,Number(l)||0),e.isPlaying=h,ht()},onStatePost:ye,onDeterministicSeek:l=>{for(let h of e.deterministicAdapters)try{h.seek({time:Number(l)||0})}catch{}},onDeterministicPause:()=>Pe("pause"),onDeterministicPlay:()=>Pe("play"),onRenderFrameSeek:()=>{},onShowNativeVideos:()=>{},getSafeDuration:()=>fe(e.capturedTimeline,0)});window.__player=s(ae),window.__playerReady=!0,window.__renderReady=!0,Nt(me),Oe("composition_loaded",{duration:ae.getDuration(),compositionId:document.querySelector("[data-composition-id]")?.getAttribute("data-composition-id")??null}),e.controlBridgeHandler=At({onPlay:()=>{ae.play(),Oe("composition_played",{time:ae.getTime()})},onPause:()=>{ae.pause(),Oe("composition_paused",{time:ae.getTime()})},onSeek:(l,h)=>{let f=Math.max(0,l)/e.canonicalFps;ae.seek(f),Oe("composition_seeked",{time:f})},onSetMuted:l=>{e.bridgeMuted=l;let h=l||e.mediaOutputMuted,f=document.querySelectorAll("video, audio");for(let N of f)N instanceof HTMLMediaElement&&(N.muted=h)},onSetMediaOutputMuted:l=>{e.mediaOutputMuted=l;let h=l||e.bridgeMuted,f=document.querySelectorAll("video, audio");for(let N of f)N instanceof HTMLMediaElement&&(N.muted=h)},onSetPlaybackRate:l=>gt(l),onEnablePickMode:()=>ze.enablePickMode(),onDisablePickMode:()=>ze.disablePickMode()}),L(),e.capturedTimeline&&(ae._timeline=e.capturedTimeline),w&&setTimeout(()=>{let l=e.capturedTimeline;L()&&e.capturedTimeline!==l&&(ae._timeline=e.capturedTimeline),Pe("discover",e.currentTime),ke(),ye(!0)},0),e.deterministicAdapters=[kt(),Et({resolveStartSeconds:l=>v(l,0)}),Ct(),Dt(),yt({getTimeline:()=>e.capturedTimeline})],I(),Pe("discover"),Qe(),e.timelinePollIntervalId&&clearInterval(e.timelinePollIntervalId);let Ze=0,Ue=null,St=0,Ye=!1,Le=0,Ft=()=>{St=Date.now(),Ye=!1,Le=0};e.timelinePollIntervalId=setInterval(()=>{Ze+=1;let h=e.isPlaying&&e.capturedTimeline!=null&&Math.max(0,e.currentTime||0)<T?!1:L();if(e.capturedTimeline&&!ae._timeline&&(ae._timeline=e.capturedTimeline),(h||Ze%20===0)&&ke(),Ze%10===0&&Qe(),B(),e.isPlaying&&e.capturedTimeline){let f=Math.max(0,e.currentTime||0),N=Ue,A=fe(e.capturedTimeline,0);if(A>0&&f>=A){ae.pause(),ae.seek(A),Ue=A,Le=0,ye(!0);return}if(N!=null&&N>=p&&f<=F?Le+=1:Le=0,!Ye&&Le>=C&&Date.now()-St>D){let ce=le();H(ce,"loop_guard")&&(Ye=!0,Le=0)}Ue=Math.max(0,e.currentTime||0)}else Ue=Math.max(0,e.currentTime||0);e.isPlaying&&ht(),ye(!1)},50),ke(),ye(!0);let Sn=ae.seek;ae.seek=l=>{Ft(),Sn(l)};let Fn=ae.renderSeek;ae.renderSeek=l=>{Ft(),Fn(l)};let Xe=()=>{if(!e.tornDown){e.tornDown=!0,e.timelinePollIntervalId&&(clearInterval(e.timelinePollIntervalId),e.timelinePollIntervalId=null),ue!=null&&(window.clearTimeout(ue),ue=null),u!=null&&(window.cancelAnimationFrame(u),u=null),gn(),e.controlBridgeHandler&&(window.removeEventListener("message",e.controlBridgeHandler),e.controlBridgeHandler=null),n&&(window.removeEventListener("error",n),n=null),o&&(window.removeEventListener("unhandledrejection",o),o=null),e.beforeUnloadHandler&&(window.removeEventListener("beforeunload",e.beforeUnloadHandler),e.beforeUnloadHandler=null),ze.disablePickMode();for(let l of e.deterministicAdapters)if(!(!l||typeof l.revert!="function"))try{l.revert()}catch{}e.deterministicAdapters=[];for(let l of r.splice(0))try{l()}catch{}for(let l of e.injectedCompStyles)try{l.remove()}catch{}e.injectedCompStyles=[];for(let l of e.injectedCompScripts)try{l.remove()}catch{}e.injectedCompScripts=[],e.capturedTimeline=null,t.__hfRuntimeTeardown===Xe&&(t.__hfRuntimeTeardown=null)}};t.__hfRuntimeTeardown=Xe,e.beforeUnloadHandler=Xe,window.addEventListener("beforeunload",e.beforeUnloadHandler)}var Gt=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","BN","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],lt=[[697,698,"ON"],[706,719,"ON"],[722,735,"ON"],[741,749,"ON"],[751,767,"ON"],[768,879,"NSM"],[884,885,"ON"],[894,894,"ON"],[900,901,"ON"],[903,903,"ON"],[1014,1014,"ON"],[1155,1161,"NSM"],[1418,1418,"ON"],[1421,1422,"ON"],[1423,1423,"ET"],[1424,1424,"R"],[1425,1469,"NSM"],[1470,1470,"R"],[1471,1471,"NSM"],[1472,1472,"R"],[1473,1474,"NSM"],[1475,1475,"R"],[1476,1477,"NSM"],[1478,1478,"R"],[1479,1479,"NSM"],[1480,1535,"R"],[1536,1541,"AN"],[1542,1543,"ON"],[1544,1544,"AL"],[1545,1546,"ET"],[1547,1547,"AL"],[1548,1548,"CS"],[1549,1549,"AL"],[1550,1551,"ON"],[1552,1562,"NSM"],[1563,1610,"AL"],[1611,1631,"NSM"],[1632,1641,"AN"],[1642,1642,"ET"],[1643,1644,"AN"],[1645,1647,"AL"],[1648,1648,"NSM"],[1649,1749,"AL"],[1750,1756,"NSM"],[1757,1757,"AN"],[1758,1758,"ON"],[1759,1764,"NSM"],[1765,1766,"AL"],[1767,1768,"NSM"],[1769,1769,"ON"],[1770,1773,"NSM"],[1774,1775,"AL"],[1776,1785,"EN"],[1786,1808,"AL"],[1809,1809,"NSM"],[1810,1839,"AL"],[1840,1866,"NSM"],[1867,1957,"AL"],[1958,1968,"NSM"],[1969,1983,"AL"],[1984,2026,"R"],[2027,2035,"NSM"],[2036,2037,"R"],[2038,2041,"ON"],[2042,2044,"R"],[2045,2045,"NSM"],[2046,2069,"R"],[2070,2073,"NSM"],[2074,2074,"R"],[2075,2083,"NSM"],[2084,2084,"R"],[2085,2087,"NSM"],[2088,2088,"R"],[2089,2093,"NSM"],[2094,2136,"R"],[2137,2139,"NSM"],[2140,2143,"R"],[2144,2191,"AL"],[2192,2193,"AN"],[2194,2198,"AL"],[2199,2207,"NSM"],[2208,2249,"AL"],[2250,2273,"NSM"],[2274,2274,"AN"],[2275,2306,"NSM"],[2362,2362,"NSM"],[2364,2364,"NSM"],[2369,2376,"NSM"],[2381,2381,"NSM"],[2385,2391,"NSM"],[2402,2403,"NSM"],[2433,2433,"NSM"],[2492,2492,"NSM"],[2497,2500,"NSM"],[2509,2509,"NSM"],[2530,2531,"NSM"],[2546,2547,"ET"],[2555,2555,"ET"],[2558,2558,"NSM"],[2561,2562,"NSM"],[2620,2620,"NSM"],[2625,2626,"NSM"],[2631,2632,"NSM"],[2635,2637,"NSM"],[2641,2641,"NSM"],[2672,2673,"NSM"],[2677,2677,"NSM"],[2689,2690,"NSM"],[2748,2748,"NSM"],[2753,2757,"NSM"],[2759,2760,"NSM"],[2765,2765,"NSM"],[2786,2787,"NSM"],[2801,2801,"ET"],[2810,2815,"NSM"],[2817,2817,"NSM"],[2876,2876,"NSM"],[2879,2879,"NSM"],[2881,2884,"NSM"],[2893,2893,"NSM"],[2901,2902,"NSM"],[2914,2915,"NSM"],[2946,2946,"NSM"],[3008,3008,"NSM"],[3021,3021,"NSM"],[3059,3064,"ON"],[3065,3065,"ET"],[3066,3066,"ON"],[3072,3072,"NSM"],[3076,3076,"NSM"],[3132,3132,"NSM"],[3134,3136,"NSM"],[3142,3144,"NSM"],[3146,3149,"NSM"],[3157,3158,"NSM"],[3170,3171,"NSM"],[3192,3198,"ON"],[3201,3201,"NSM"],[3260,3260,"NSM"],[3276,3277,"NSM"],[3298,3299,"NSM"],[3328,3329,"NSM"],[3387,3388,"NSM"],[3393,3396,"NSM"],[3405,3405,"NSM"],[3426,3427,"NSM"],[3457,3457,"NSM"],[3530,3530,"NSM"],[3538,3540,"NSM"],[3542,3542,"NSM"],[3633,3633,"NSM"],[3636,3642,"NSM"],[3647,3647,"ET"],[3655,3662,"NSM"],[3761,3761,"NSM"],[3764,3772,"NSM"],[3784,3790,"NSM"],[3864,3865,"NSM"],[3893,3893,"NSM"],[3895,3895,"NSM"],[3897,3897,"NSM"],[3898,3901,"ON"],[3953,3966,"NSM"],[3968,3972,"NSM"],[3974,3975,"NSM"],[3981,3991,"NSM"],[3993,4028,"NSM"],[4038,4038,"NSM"],[4141,4144,"NSM"],[4146,4151,"NSM"],[4153,4154,"NSM"],[4157,4158,"NSM"],[4184,4185,"NSM"],[4190,4192,"NSM"],[4209,4212,"NSM"],[4226,4226,"NSM"],[4229,4230,"NSM"],[4237,4237,"NSM"],[4253,4253,"NSM"],[4957,4959,"NSM"],[5008,5017,"ON"],[5120,5120,"ON"],[5760,5760,"WS"],[5787,5788,"ON"],[5906,5908,"NSM"],[5938,5939,"NSM"],[5970,5971,"NSM"],[6002,6003,"NSM"],[6068,6069,"NSM"],[6071,6077,"NSM"],[6086,6086,"NSM"],[6089,6099,"NSM"],[6107,6107,"ET"],[6109,6109,"NSM"],[6128,6137,"ON"],[6144,6154,"ON"],[6155,6157,"NSM"],[6158,6158,"BN"],[6159,6159,"NSM"],[6277,6278,"NSM"],[6313,6313,"NSM"],[6432,6434,"NSM"],[6439,6440,"NSM"],[6450,6450,"NSM"],[6457,6459,"NSM"],[6464,6464,"ON"],[6468,6469,"ON"],[6622,6655,"ON"],[6679,6680,"NSM"],[6683,6683,"NSM"],[6742,6742,"NSM"],[6744,6750,"NSM"],[6752,6752,"NSM"],[6754,6754,"NSM"],[6757,6764,"NSM"],[6771,6780,"NSM"],[6783,6783,"NSM"],[6832,6877,"NSM"],[6880,6891,"NSM"],[6912,6915,"NSM"],[6964,6964,"NSM"],[6966,6970,"NSM"],[6972,6972,"NSM"],[6978,6978,"NSM"],[7019,7027,"NSM"],[7040,7041,"NSM"],[7074,7077,"NSM"],[7080,7081,"NSM"],[7083,7085,"NSM"],[7142,7142,"NSM"],[7144,7145,"NSM"],[7149,7149,"NSM"],[7151,7153,"NSM"],[7212,7219,"NSM"],[7222,7223,"NSM"],[7376,7378,"NSM"],[7380,7392,"NSM"],[7394,7400,"NSM"],[7405,7405,"NSM"],[7412,7412,"NSM"],[7416,7417,"NSM"],[7616,7679,"NSM"],[8125,8125,"ON"],[8127,8129,"ON"],[8141,8143,"ON"],[8157,8159,"ON"],[8173,8175,"ON"],[8189,8190,"ON"],[8192,8202,"WS"],[8203,8205,"BN"],[8207,8207,"R"],[8208,8231,"ON"],[8232,8232,"WS"],[8233,8233,"B"],[8234,8238,"BN"],[8239,8239,"CS"],[8240,8244,"ET"],[8245,8259,"ON"],[8260,8260,"CS"],[8261,8286,"ON"],[8287,8287,"WS"],[8288,8303,"BN"],[8304,8304,"EN"],[8308,8313,"EN"],[8314,8315,"ES"],[8316,8318,"ON"],[8320,8329,"EN"],[8330,8331,"ES"],[8332,8334,"ON"],[8352,8399,"ET"],[8400,8432,"NSM"],[8448,8449,"ON"],[8451,8454,"ON"],[8456,8457,"ON"],[8468,8468,"ON"],[8470,8472,"ON"],[8478,8483,"ON"],[8485,8485,"ON"],[8487,8487,"ON"],[8489,8489,"ON"],[8494,8494,"ET"],[8506,8507,"ON"],[8512,8516,"ON"],[8522,8525,"ON"],[8528,8543,"ON"],[8585,8587,"ON"],[8592,8721,"ON"],[8722,8722,"ES"],[8723,8723,"ET"],[8724,9013,"ON"],[9083,9108,"ON"],[9110,9257,"ON"],[9280,9290,"ON"],[9312,9351,"ON"],[9352,9371,"EN"],[9450,9899,"ON"],[9901,10239,"ON"],[10496,11123,"ON"],[11126,11263,"ON"],[11493,11498,"ON"],[11503,11505,"NSM"],[11513,11519,"ON"],[11647,11647,"NSM"],[11744,11775,"NSM"],[11776,11869,"ON"],[11904,11929,"ON"],[11931,12019,"ON"],[12032,12245,"ON"],[12272,12287,"ON"],[12288,12288,"WS"],[12289,12292,"ON"],[12296,12320,"ON"],[12330,12333,"NSM"],[12336,12336,"ON"],[12342,12343,"ON"],[12349,12351,"ON"],[12441,12442,"NSM"],[12443,12444,"ON"],[12448,12448,"ON"],[12539,12539,"ON"],[12736,12773,"ON"],[12783,12783,"ON"],[12829,12830,"ON"],[12880,12895,"ON"],[12924,12926,"ON"],[12977,12991,"ON"],[13004,13007,"ON"],[13175,13178,"ON"],[13278,13279,"ON"],[13311,13311,"ON"],[19904,19967,"ON"],[42128,42182,"ON"],[42509,42511,"ON"],[42607,42610,"NSM"],[42611,42611,"ON"],[42612,42621,"NSM"],[42622,42623,"ON"],[42654,42655,"NSM"],[42736,42737,"NSM"],[42752,42785,"ON"],[42888,42888,"ON"],[43010,43010,"NSM"],[43014,43014,"NSM"],[43019,43019,"NSM"],[43045,43046,"NSM"],[43048,43051,"ON"],[43052,43052,"NSM"],[43064,43065,"ET"],[43124,43127,"ON"],[43204,43205,"NSM"],[43232,43249,"NSM"],[43263,43263,"NSM"],[43302,43309,"NSM"],[43335,43345,"NSM"],[43392,43394,"NSM"],[43443,43443,"NSM"],[43446,43449,"NSM"],[43452,43453,"NSM"],[43493,43493,"NSM"],[43561,43566,"NSM"],[43569,43570,"NSM"],[43573,43574,"NSM"],[43587,43587,"NSM"],[43596,43596,"NSM"],[43644,43644,"NSM"],[43696,43696,"NSM"],[43698,43700,"NSM"],[43703,43704,"NSM"],[43710,43711,"NSM"],[43713,43713,"NSM"],[43756,43757,"NSM"],[43766,43766,"NSM"],[43882,43883,"ON"],[44005,44005,"NSM"],[44008,44008,"NSM"],[44013,44013,"NSM"],[64285,64285,"R"],[64286,64286,"NSM"],[64287,64296,"R"],[64297,64297,"ES"],[64298,64335,"R"],[64336,64450,"AL"],[64451,64466,"ON"],[64467,64829,"AL"],[64830,64847,"ON"],[64848,64911,"AL"],[64912,64913,"ON"],[64914,64967,"AL"],[64968,64975,"ON"],[64976,65007,"BN"],[65008,65020,"AL"],[65021,65023,"ON"],[65024,65039,"NSM"],[65040,65049,"ON"],[65056,65071,"NSM"],[65072,65103,"ON"],[65104,65104,"CS"],[65105,65105,"ON"],[65106,65106,"CS"],[65108,65108,"ON"],[65109,65109,"CS"],[65110,65118,"ON"],[65119,65119,"ET"],[65120,65121,"ON"],[65122,65123,"ES"],[65124,65126,"ON"],[65128,65128,"ON"],[65129,65130,"ET"],[65131,65131,"ON"],[65136,65278,"AL"],[65279,65279,"BN"],[65281,65282,"ON"],[65283,65285,"ET"],[65286,65290,"ON"],[65291,65291,"ES"],[65292,65292,"CS"],[65293,65293,"ES"],[65294,65295,"CS"],[65296,65305,"EN"],[65306,65306,"CS"],[65307,65312,"ON"],[65339,65344,"ON"],[65371,65381,"ON"],[65504,65505,"ET"],[65506,65508,"ON"],[65509,65510,"ET"],[65512,65518,"ON"],[65520,65528,"BN"],[65529,65533,"ON"],[65534,65535,"BN"],[65793,65793,"ON"],[65856,65932,"ON"],[65936,65948,"ON"],[65952,65952,"ON"],[66045,66045,"NSM"],[66272,66272,"NSM"],[66273,66299,"EN"],[66422,66426,"NSM"],[67584,67870,"R"],[67871,67871,"ON"],[67872,68096,"R"],[68097,68099,"NSM"],[68100,68100,"R"],[68101,68102,"NSM"],[68103,68107,"R"],[68108,68111,"NSM"],[68112,68151,"R"],[68152,68154,"NSM"],[68155,68158,"R"],[68159,68159,"NSM"],[68160,68324,"R"],[68325,68326,"NSM"],[68327,68408,"R"],[68409,68415,"ON"],[68416,68863,"R"],[68864,68899,"AL"],[68900,68903,"NSM"],[68904,68911,"AL"],[68912,68921,"AN"],[68922,68927,"AL"],[68928,68937,"AN"],[68938,68968,"R"],[68969,68973,"NSM"],[68974,68974,"ON"],[68975,69215,"R"],[69216,69246,"AN"],[69247,69290,"R"],[69291,69292,"NSM"],[69293,69311,"R"],[69312,69327,"AL"],[69328,69336,"ON"],[69337,69369,"AL"],[69370,69375,"NSM"],[69376,69423,"R"],[69424,69445,"AL"],[69446,69456,"NSM"],[69457,69487,"AL"],[69488,69505,"R"],[69506,69509,"NSM"],[69510,69631,"R"],[69633,69633,"NSM"],[69688,69702,"NSM"],[69714,69733,"ON"],[69744,69744,"NSM"],[69747,69748,"NSM"],[69759,69761,"NSM"],[69811,69814,"NSM"],[69817,69818,"NSM"],[69826,69826,"NSM"],[69888,69890,"NSM"],[69927,69931,"NSM"],[69933,69940,"NSM"],[70003,70003,"NSM"],[70016,70017,"NSM"],[70070,70078,"NSM"],[70089,70092,"NSM"],[70095,70095,"NSM"],[70191,70193,"NSM"],[70196,70196,"NSM"],[70198,70199,"NSM"],[70206,70206,"NSM"],[70209,70209,"NSM"],[70367,70367,"NSM"],[70371,70378,"NSM"],[70400,70401,"NSM"],[70459,70460,"NSM"],[70464,70464,"NSM"],[70502,70508,"NSM"],[70512,70516,"NSM"],[70587,70592,"NSM"],[70606,70606,"NSM"],[70608,70608,"NSM"],[70610,70610,"NSM"],[70625,70626,"NSM"],[70712,70719,"NSM"],[70722,70724,"NSM"],[70726,70726,"NSM"],[70750,70750,"NSM"],[70835,70840,"NSM"],[70842,70842,"NSM"],[70847,70848,"NSM"],[70850,70851,"NSM"],[71090,71093,"NSM"],[71100,71101,"NSM"],[71103,71104,"NSM"],[71132,71133,"NSM"],[71219,71226,"NSM"],[71229,71229,"NSM"],[71231,71232,"NSM"],[71264,71276,"ON"],[71339,71339,"NSM"],[71341,71341,"NSM"],[71344,71349,"NSM"],[71351,71351,"NSM"],[71453,71453,"NSM"],[71455,71455,"NSM"],[71458,71461,"NSM"],[71463,71467,"NSM"],[71727,71735,"NSM"],[71737,71738,"NSM"],[71995,71996,"NSM"],[71998,71998,"NSM"],[72003,72003,"NSM"],[72148,72151,"NSM"],[72154,72155,"NSM"],[72160,72160,"NSM"],[72193,72198,"NSM"],[72201,72202,"NSM"],[72243,72248,"NSM"],[72251,72254,"NSM"],[72263,72263,"NSM"],[72273,72278,"NSM"],[72281,72283,"NSM"],[72330,72342,"NSM"],[72344,72345,"NSM"],[72544,72544,"NSM"],[72546,72548,"NSM"],[72550,72550,"NSM"],[72752,72758,"NSM"],[72760,72765,"NSM"],[72850,72871,"NSM"],[72874,72880,"NSM"],[72882,72883,"NSM"],[72885,72886,"NSM"],[73009,73014,"NSM"],[73018,73018,"NSM"],[73020,73021,"NSM"],[73023,73029,"NSM"],[73031,73031,"NSM"],[73104,73105,"NSM"],[73109,73109,"NSM"],[73111,73111,"NSM"],[73459,73460,"NSM"],[73472,73473,"NSM"],[73526,73530,"NSM"],[73536,73536,"NSM"],[73538,73538,"NSM"],[73562,73562,"NSM"],[73685,73692,"ON"],[73693,73696,"ET"],[73697,73713,"ON"],[78912,78912,"NSM"],[78919,78933,"NSM"],[90398,90409,"NSM"],[90413,90415,"NSM"],[92912,92916,"NSM"],[92976,92982,"NSM"],[94031,94031,"NSM"],[94095,94098,"NSM"],[94178,94178,"ON"],[94180,94180,"NSM"],[113821,113822,"NSM"],[113824,113827,"BN"],[117760,117973,"ON"],[118e3,118009,"EN"],[118010,118012,"ON"],[118016,118451,"ON"],[118458,118480,"ON"],[118496,118512,"ON"],[118528,118573,"NSM"],[118576,118598,"NSM"],[119143,119145,"NSM"],[119155,119162,"BN"],[119163,119170,"NSM"],[119173,119179,"NSM"],[119210,119213,"NSM"],[119273,119274,"ON"],[119296,119361,"ON"],[119362,119364,"NSM"],[119365,119365,"ON"],[119552,119638,"ON"],[120513,120513,"ON"],[120539,120539,"ON"],[120571,120571,"ON"],[120597,120597,"ON"],[120629,120629,"ON"],[120655,120655,"ON"],[120687,120687,"ON"],[120713,120713,"ON"],[120745,120745,"ON"],[120771,120771,"ON"],[120782,120831,"EN"],[121344,121398,"NSM"],[121403,121452,"NSM"],[121461,121461,"NSM"],[121476,121476,"NSM"],[121499,121503,"NSM"],[121505,121519,"NSM"],[122880,122886,"NSM"],[122888,122904,"NSM"],[122907,122913,"NSM"],[122915,122916,"NSM"],[122918,122922,"NSM"],[123023,123023,"NSM"],[123184,123190,"NSM"],[123566,123566,"NSM"],[123628,123631,"NSM"],[123647,123647,"ET"],[124140,124143,"NSM"],[124398,124399,"NSM"],[124643,124643,"NSM"],[124646,124646,"NSM"],[124654,124655,"NSM"],[124661,124661,"NSM"],[124928,125135,"R"],[125136,125142,"NSM"],[125143,125251,"R"],[125252,125258,"NSM"],[125259,126063,"R"],[126064,126143,"AL"],[126144,126207,"R"],[126208,126287,"AL"],[126288,126463,"R"],[126464,126703,"AL"],[126704,126705,"ON"],[126706,126719,"AL"],[126720,126975,"R"],[126976,127019,"ON"],[127024,127123,"ON"],[127136,127150,"ON"],[127153,127167,"ON"],[127169,127183,"ON"],[127185,127221,"ON"],[127232,127242,"EN"],[127243,127247,"ON"],[127279,127279,"ON"],[127338,127343,"ON"],[127405,127405,"ON"],[127584,127589,"ON"],[127744,128728,"ON"],[128732,128748,"ON"],[128752,128764,"ON"],[128768,128985,"ON"],[128992,129003,"ON"],[129008,129008,"ON"],[129024,129035,"ON"],[129040,129095,"ON"],[129104,129113,"ON"],[129120,129159,"ON"],[129168,129197,"ON"],[129200,129211,"ON"],[129216,129217,"ON"],[129232,129240,"ON"],[129280,129623,"ON"],[129632,129645,"ON"],[129648,129660,"ON"],[129664,129674,"ON"],[129678,129734,"ON"],[129736,129736,"ON"],[129741,129756,"ON"],[129759,129770,"ON"],[129775,129784,"ON"],[129792,129938,"ON"],[129940,130031,"ON"],[130032,130041,"EN"],[130042,130042,"ON"],[131070,131071,"BN"],[196606,196607,"BN"],[262142,262143,"BN"],[327678,327679,"BN"],[393214,393215,"BN"],[458750,458751,"BN"],[524286,524287,"BN"],[589822,589823,"BN"],[655358,655359,"BN"],[720894,720895,"BN"],[786430,786431,"BN"],[851966,851967,"BN"],[917502,917759,"BN"],[917760,917999,"NSM"],[918e3,921599,"BN"],[983038,983039,"BN"],[1048574,1048575,"BN"],[1114110,1114111,"BN"]];function _n(e){if(e<=255)return Gt[e];let t=0,n=lt.length-1;for(;t<=n;){let o=t+n>>1,r=lt[o];if(e<r[0]){n=o-1;continue}if(e>r[1]){t=o+1;continue}return r[2]}return"L"}function Wn(e){let t=e.length;if(t===0)return null;let n=new Array(t),o=!1;for(let s=0;s<t;){let a=e.charCodeAt(s),m=a,p=1;if(a>=55296&&a<=56319&&s+1<t){let D=e.charCodeAt(s+1);D>=56320&&D<=57343&&(m=(a-55296<<10)+(D-56320)+65536,p=2)}let F=_n(m);(F==="R"||F==="AL"||F==="AN")&&(o=!0);for(let D=0;D<p;D++)n[s+D]=F;s+=p}if(!o)return null;let r=0;for(let s=0;s<t;s++){let a=n[s];if(a==="L"){r=0;break}if(a==="R"||a==="AL"){r=1;break}}let i=new Int8Array(t);for(let s=0;s<t;s++)i[s]=r;let u=r&1?"R":"L",d=u,c=d;for(let s=0;s<t;s++)n[s]==="NSM"?n[s]=c:c=n[s];c=d;for(let s=0;s<t;s++){let a=n[s];a==="EN"?n[s]=c==="AL"?"AN":"EN":(a==="R"||a==="L"||a==="AL")&&(c=a)}for(let s=0;s<t;s++)n[s]==="AL"&&(n[s]="R");for(let s=1;s<t-1;s++)n[s]==="ES"&&n[s-1]==="EN"&&n[s+1]==="EN"&&(n[s]="EN"),n[s]==="CS"&&(n[s-1]==="EN"||n[s-1]==="AN")&&n[s+1]===n[s-1]&&(n[s]=n[s-1]);for(let s=0;s<t;s++){if(n[s]!=="EN")continue;let a;for(a=s-1;a>=0&&n[a]==="ET";a--)n[a]="EN";for(a=s+1;a<t&&n[a]==="ET";a++)n[a]="EN"}for(let s=0;s<t;s++){let a=n[s];(a==="WS"||a==="ES"||a==="ET"||a==="CS")&&(n[s]="ON")}c=d;for(let s=0;s<t;s++){let a=n[s];a==="EN"?n[s]=c==="L"?"L":"EN":(a==="R"||a==="L")&&(c=a)}for(let s=0;s<t;s++){if(n[s]!=="ON")continue;let a=s+1;for(;a<t&&n[a]==="ON";)a++;let m=s>0?n[s-1]:d,p=a<t?n[a]:d,F=m!=="L"?"R":"L";if(F===(p!=="L"?"R":"L"))for(let C=s;C<a;C++)n[C]=F;s=a-1}for(let s=0;s<t;s++)n[s]==="ON"&&(n[s]=u);for(let s=0;s<t;s++){let a=n[s];(i[s]&1)===0?a==="R"?i[s]++:(a==="AN"||a==="EN")&&(i[s]+=2):(a==="L"||a==="AN"||a==="EN")&&i[s]++}return i}function qt(e,t){let n=Wn(e);if(n===null)return null;let o=new Int8Array(t.length);for(let r=0;r<t.length;r++)o[r]=n[t[r]];return o}var Hn=/[ \\t\\n\\r\\f]+/g,jn=/[\\t\\n\\r\\f]| {2,}|^ | $/;function zn(e){let t=e??"normal";return t==="pre-wrap"?{mode:t,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:t,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function Un(e){if(!jn.test(e))return e;let t=e.replace(Hn," ");return t.charCodeAt(0)===32&&(t=t.slice(1)),t.length>0&&t.charCodeAt(t.length-1)===32&&(t=t.slice(0,-1)),t}function Gn(e){return/[\\r\\f]/.test(e)?e.replace(/\\r\\n/g,`\n`).replace(/[\\r\\f]/g,`\n`):e.replace(/\\r\\n/g,`\n`)}var ut=null,qn;function $n(){return ut===null&&(ut=new Intl.Segmenter(qn,{granularity:"word"})),ut}var Kn=/\\p{Script=Arabic}/u,qe=/\\p{M}/u,Xt=/\\p{Nd}/u;function $t(e){return Kn.test(e)}function Kt(e){return e>=19968&&e<=40959||e>=13312&&e<=19903||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=183984&&e<=191471||e>=191472&&e<=192093||e>=194560&&e<=195103||e>=196608&&e<=201551||e>=201552&&e<=205743||e>=205744&&e<=210041||e>=63744&&e<=64255||e>=12288&&e<=12351||e>=12352&&e<=12447||e>=12448&&e<=12543||e>=44032&&e<=55215||e>=65280&&e<=65519}function Fe(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(!(n<12288)){if(n>=55296&&n<=56319&&t+1<e.length){let o=e.charCodeAt(t+1);if(o>=56320&&o<=57343){let r=(n-55296<<10)+(o-56320)+65536;if(Kt(r))return!0;t++;continue}}if(Kt(n))return!0}}return!1}function Vn(e){let t=Ve(e);return t!==null&&(Ke.has(t)||be.has(t))}var Jn=new Set(["\\xA0","\\u202F","\\u2060","\\uFEFF"]);function Qn(e){return Fe(e)}function Zn(e){let t=Ve(e);return t!==null&&Jn.has(t)}function $e(e){return!Vn(e)&&!Zn(e)}var Ke=new Set(["\\uFF0C","\\uFF0E","\\uFF01","\\uFF1A","\\uFF1B","\\uFF1F","\\u3001","\\u3002","\\u30FB","\\uFF09","\\u3015","\\u3009","\\u300B","\\u300D","\\u300F","\\u3011","\\u3017","\\u3019","\\u301B","\\u30FC","\\u3005","\\u303B","\\u309D","\\u309E","\\u30FD","\\u30FE"]),je=new Set([\'"\',"(","[","{","\\u201C","\\u2018","\\xAB","\\u2039","\\uFF08","\\u3014","\\u3008","\\u300A","\\u300C","\\u300E","\\u3010","\\u3016","\\u3018","\\u301A"]),dt=new Set(["\'","\\u2019"]),be=new Set([".",",","!","?",":",";","\\u060C","\\u061B","\\u061F","\\u0964","\\u0965","\\u104A","\\u104B","\\u104C","\\u104D","\\u104F",")","]","}","%",\'"\',"\\u201D","\\u2019","\\xBB","\\u203A","\\u2026"]),Yn=new Set([":",".","\\u060C","\\u061B"]),Xn=new Set(["\\u104F"]),ei=new Set(["\\u201D","\\u2019","\\xBB","\\u203A","\\u300D","\\u300F","\\u3011","\\u300B","\\u3009","\\u3015","\\uFF09"]);function ti(e){if(mt(e))return!0;let t=!1;for(let n of e){if(be.has(n)){t=!0;continue}if(!(t&&qe.test(n)))return!1}return t}function ni(e){for(let t of e)if(!Ke.has(t)&&!be.has(t))return!1;return e.length>0}function ii(e){if(mt(e))return!0;for(let t of e)if(!je.has(t)&&!dt.has(t)&&!qe.test(t))return!1;return e.length>0}function mt(e){let t=!1;for(let n of e)if(!(n==="\\\\"||qe.test(n))){if(je.has(n)||be.has(n)||dt.has(n)){t=!0;continue}return!1}return t}function en(e,t){let n=t-1;if(n<=0)return Math.max(n,0);let o=e.charCodeAt(n);if(o<56320||o>57343)return n;let r=n-1;if(r<0)return n;let i=e.charCodeAt(r);return i>=55296&&i<=56319?r:n}function Ve(e){if(e.length===0)return null;let t=en(e,e.length);return e.slice(t)}function oi(e){let t=Array.from(e),n=t.length;for(;n>0;){let o=t[n-1];if(qe.test(o)){n--;continue}if(je.has(o)||dt.has(o)){n--;continue}break}return n<=0||n===t.length?null:{head:t.slice(0,n).join(""),tail:t.slice(n).join("")}}function ri(e,t,n){return n==="text"&&!t&&e.length===1&&e!=="-"&&e!=="\\u2014"?e:null}function Vt(e,t,n,o){let r=t[o],i=e[o];if(r==null)return i;let u=n[o];if(i.length===u)return i;let d=r.repeat(u);return e[o]=d,d}function Jt(e,t){return e&&t!==null&&Yn.has(t)}function si(e){let t=Ve(e);return t!==null&&Xn.has(t)}function ai(e){if(e.length<2||e[0]!==" ")return null;let t=e.slice(1);return/^\\p{M}+$/u.test(t)?{space:" ",marks:t}:null}function Je(e){let t=e.length;for(;t>0;){let n=en(e,t),o=e.slice(n,t);if(ei.has(o))return!0;if(!be.has(o))return!1;t=n}return!1}function li(e,t){if(t.preserveOrdinarySpaces||t.preserveHardBreaks){if(e===" ")return"preserved-space";if(e===" ")return"tab";if(t.preserveHardBreaks&&e===`\n`)return"hard-break"}return e===" "?"space":e==="\\xA0"||e==="\\u202F"||e==="\\u2060"||e==="\\uFEFF"?"glue":e==="\\u200B"?"zero-width-break":e==="\\xAD"?"soft-hyphen":"text"}var ui=/[\\x20\\t\\n\\xA0\\xAD\\u200B\\u202F\\u2060\\uFEFF]/;function Se(e){return e.length===1?e[0]:e.join("")}function ci(e,t){let n=[];for(let o=e.length-1;o>=0;o--)n.push(e[o]);return n.push(t),Se(n)}function di(e,t,n,o){if(!ui.test(e))return[{text:e,isWordLike:t,kind:"text",start:n}];let r=[],i=null,u=[],d=n,c=!1,s=0;for(let a of e){let m=li(a,o),p=m==="text"&&t;if(i!==null&&m===i&&p===c){u.push(a),s+=a.length;continue}i!==null&&r.push({text:Se(u),isWordLike:c,kind:i,start:d}),i=m,u=[a],d=n+s,c=p,s+=a.length}return i!==null&&r.push({text:Se(u),isWordLike:c,kind:i,start:d}),r}function ct(e){return e==="space"||e==="preserved-space"||e==="zero-width-break"||e==="hard-break"}var mi=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function xi(e,t){let n=e.texts[t];return n.startsWith("www.")?!0:mi.test(n)&&t+1<e.len&&e.kinds[t+1]==="text"&&e.texts[t+1]==="//"}function fi(e){return e.includes("?")&&(e.includes("://")||e.startsWith("www."))}function pi(e){let t=e.texts.slice(),n=e.isWordLike.slice(),o=e.kinds.slice(),r=e.starts.slice();for(let u=0;u<e.len;u++){if(o[u]!=="text"||!xi(e,u))continue;let d=[t[u]],c=u+1;for(;c<e.len&&!ct(o[c]);){d.push(t[c]),n[u]=!0;let s=t[c].includes("?");if(o[c]="text",t[c]="",c++,s)break}t[u]=Se(d)}let i=0;for(let u=0;u<t.length;u++){let d=t[u];d.length!==0&&(i!==u&&(t[i]=d,n[i]=n[u],o[i]=o[u],r[i]=r[u]),i++)}return t.length=i,n.length=i,o.length=i,r.length=i,{len:i,texts:t,isWordLike:n,kinds:o,starts:r}}function hi(e){let t=[],n=[],o=[],r=[];for(let i=0;i<e.len;i++){let u=e.texts[i];if(t.push(u),n.push(e.isWordLike[i]),o.push(e.kinds[i]),r.push(e.starts[i]),!fi(u))continue;let d=i+1;if(d>=e.len||ct(e.kinds[d]))continue;let c=[],s=e.starts[d],a=d;for(;a<e.len&&!ct(e.kinds[a]);)c.push(e.texts[a]),a++;c.length>0&&(t.push(Se(c)),n.push(!0),o.push("text"),r.push(s),i=a-1)}return{len:t.length,texts:t,isWordLike:n,kinds:o,starts:r}}var gi=new Set([":","-","/","\\xD7",",",".","+","\\u2013","\\u2014"]),Qt=/^[A-Za-z0-9_]+[,:;]*$/,Zt=/[,:;]+$/;function tn(e){for(let t of e)if(Xt.test(t))return!0;return!1}function He(e){if(e.length===0)return!1;for(let t of e)if(!(Xt.test(t)||gi.has(t)))return!1;return!0}function Si(e){let t=[],n=[],o=[],r=[];for(let i=0;i<e.len;i++){let u=e.texts[i],d=e.kinds[i];if(d==="text"&&He(u)&&tn(u)){let c=[u],s=i+1;for(;s<e.len&&e.kinds[s]==="text"&&He(e.texts[s]);)c.push(e.texts[s]),s++;t.push(Se(c)),n.push(!0),o.push("text"),r.push(e.starts[i]),i=s-1;continue}t.push(u),n.push(e.isWordLike[i]),o.push(d),r.push(e.starts[i])}return{len:t.length,texts:t,isWordLike:n,kinds:o,starts:r}}function Fi(e){let t=[],n=[],o=[],r=[];for(let i=0;i<e.len;i++){let u=e.texts[i],d=e.kinds[i],c=e.isWordLike[i];if(d==="text"&&c&&Qt.test(u)){let s=[u],a=Zt.test(u),m=i+1;for(;a&&m<e.len&&e.kinds[m]==="text"&&e.isWordLike[m]&&Qt.test(e.texts[m]);){let p=e.texts[m];s.push(p),a=Zt.test(p),m++}t.push(Se(s)),n.push(!0),o.push("text"),r.push(e.starts[i]),i=m-1;continue}t.push(u),n.push(c),o.push(d),r.push(e.starts[i])}return{len:t.length,texts:t,isWordLike:n,kinds:o,starts:r}}function Ai(e){let t=[],n=[],o=[],r=[];for(let i=0;i<e.len;i++){let u=e.texts[i];if(e.kinds[i]==="text"&&u.includes("-")){let d=u.split("-"),c=d.length>1;for(let s=0;s<d.length;s++){let a=d[s];if(!c)break;(a.length===0||!tn(a)||!He(a))&&(c=!1)}if(c){let s=0;for(let a=0;a<d.length;a++){let m=d[a],p=a<d.length-1?`${m}-`:m;t.push(p),n.push(!0),o.push("text"),r.push(e.starts[i]+s),s+=p.length}continue}}t.push(u),n.push(e.isWordLike[i]),o.push(e.kinds[i]),r.push(e.starts[i])}return{len:t.length,texts:t,isWordLike:n,kinds:o,starts:r}}function Ni(e){let t=[],n=[],o=[],r=[],i=0;for(;i<e.len;){let u=[e.texts[i]],d=e.isWordLike[i],c=e.kinds[i],s=e.starts[i];if(c==="glue"){let a=[u[0]],m=s;for(i++;i<e.len&&e.kinds[i]==="glue";)a.push(e.texts[i]),i++;let p=Se(a);if(i<e.len&&e.kinds[i]==="text")u[0]=p,u.push(e.texts[i]),d=e.isWordLike[i],c="text",s=m,i++;else{t.push(p),n.push(!1),o.push("glue"),r.push(m);continue}}else i++;if(c==="text")for(;i<e.len&&e.kinds[i]==="glue";){let a=[];for(;i<e.len&&e.kinds[i]==="glue";)a.push(e.texts[i]),i++;let m=Se(a);if(i<e.len&&e.kinds[i]==="text"){u.push(m,e.texts[i]),d=d||e.isWordLike[i],i++;continue}u.push(m)}t.push(Se(u)),n.push(d),o.push(c),r.push(s)}return{len:t.length,texts:t,isWordLike:n,kinds:o,starts:r}}function Ei(e){let t=e.texts.slice(),n=e.isWordLike.slice(),o=e.kinds.slice(),r=e.starts.slice();for(let i=0;i<t.length-1;i++){if(o[i]!=="text"||o[i+1]!=="text"||!Fe(t[i])||!Fe(t[i+1]))continue;let u=oi(t[i]);u!==null&&(t[i]=u.head,t[i+1]=u.tail+t[i+1],r[i+1]=r[i]+u.head.length)}return{len:t.length,texts:t,isWordLike:n,kinds:o,starts:r}}function Yt(e,t,n){let o=$n(),r=0,i=[],u=[],d=[],c=[],s=[],a=[],m=[],p=[],F=[],D=[],C=[],T=[];for(let x of o.segment(e))for(let g of di(x.segment,x.isWordLike??!1,x.index,n)){let K=function(){a[w]!==null&&(u[w]=[Vt(i,a,m,w)],a[w]=null),u[w].push(g.text),d[w]=d[w]||g.isWordLike,p[w]=p[w]||y,F[w]=F[w]||v,D[w]=O,C[w]=V,T[w]=Jt(F[w],_)},E=g.kind==="text",b=ri(g.text,g.isWordLike,g.kind),y=Fe(g.text),v=$t(g.text),_=Ve(g.text),O=Je(g.text),V=si(g.text),w=r-1;t.carryCJKAfterClosingQuote&&E&&r>0&&c[w]==="text"&&y&&p[w]&&D[w]||E&&r>0&&c[w]==="text"&&ni(g.text)&&p[w]||E&&r>0&&c[w]==="text"&&C[w]?K():E&&r>0&&c[w]==="text"&&g.isWordLike&&v&&T[w]?(K(),d[w]=!0):b!==null&&r>0&&c[w]==="text"&&a[w]===b?m[w]=(m[w]??1)+1:E&&!g.isWordLike&&r>0&&c[w]==="text"&&(ti(g.text)||g.text==="-"&&d[w])?K():(i[r]=g.text,u[r]=[g.text],d[r]=g.isWordLike,c[r]=g.kind,s[r]=g.start,a[r]=b,m[r]=b===null?0:1,p[r]=y,F[r]=v,D[r]=O,C[r]=V,T[r]=Jt(v,_),r++)}for(let x=0;x<r;x++){if(a[x]!==null){i[x]=Vt(i,a,m,x);continue}i[x]=Se(u[x])}for(let x=1;x<r;x++)c[x]==="text"&&!d[x]&&mt(i[x])&&c[x-1]==="text"&&(i[x-1]+=i[x],d[x-1]=d[x-1]||d[x],i[x]="");let U=Array.from({length:r},()=>null),z=-1;for(let x=r-1;x>=0;x--){let g=i[x];if(g.length!==0){if(c[x]==="text"&&!d[x]&&ii(g)&&z>=0&&c[z]==="text"){let E=U[z]??[];E.push(g),U[z]=E,s[z]=s[x],i[x]="";continue}z=x}}for(let x=0;x<r;x++){let g=U[x];g!=null&&(i[x]=ci(g,i[x]))}let k=0;for(let x=0;x<r;x++){let g=i[x];g.length!==0&&(k!==x&&(i[k]=g,d[k]=d[x],c[k]=c[x],s[k]=s[x]),k++)}i.length=k,d.length=k,c.length=k,s.length=k;let Q=Ni({len:k,texts:i,isWordLike:d,kinds:c,starts:s}),S=Ei(Fi(Ai(Si(hi(pi(Q))))));for(let x=0;x<S.len-1;x++){let g=ai(S.texts[x]);g!==null&&(S.kinds[x]!=="space"&&S.kinds[x]!=="preserved-space"||S.kinds[x+1]!=="text"||!$t(S.texts[x+1])||(S.texts[x]=g.space,S.isWordLike[x]=!1,S.kinds[x]=S.kinds[x]==="preserved-space"?"preserved-space":"space",S.texts[x+1]=g.marks+S.texts[x+1],S.starts[x+1]=S.starts[x]+g.space.length))}return S}function yi(e,t){if(e.len===0)return[];if(!t.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:e.len,consumedEndSegmentIndex:e.len}];let n=[],o=0;for(let r=0;r<e.len;r++)e.kinds[r]==="hard-break"&&(n.push({startSegmentIndex:o,endSegmentIndex:r,consumedEndSegmentIndex:r+1}),o=r+1);return o<e.len&&n.push({startSegmentIndex:o,endSegmentIndex:e.len,consumedEndSegmentIndex:e.len}),n}function bi(e){if(e.len<=1)return e;let t=[],n=[],o=[],r=[],i=null,u=!1,d=0,c=!1,s=!1;function a(){i!==null&&(t.push(Se(i)),n.push(u),o.push("text"),r.push(d),i=null)}for(let m=0;m<e.len;m++){let p=e.texts[m],F=e.kinds[m],D=e.isWordLike[m],C=e.starts[m];if(F==="text"){let T=Qn(p),U=$e(p);if(i!==null&&c&&s){i.push(p),u=u||D,c=c||T,s=U;continue}a(),i=[p],u=D,d=C,c=T,s=U;continue}a(),t.push(p),n.push(D),o.push(F),r.push(C)}return a(),{len:t.length,texts:t,isWordLike:n,kinds:o,starts:r}}function nn(e,t,n="normal",o="normal"){let r=zn(n),i=r.mode==="pre-wrap"?Gn(e):Un(e);if(i.length===0)return{normalized:i,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};let u=o==="keep-all"?bi(Yt(i,t,r)):Yt(i,t,r);return{normalized:i,chunks:yi(u,r),...u}}var Re=null,on=new Map,ve=null,Mi=96,Ci=/\\p{Emoji_Presentation}/u,Di=/[\\p{Emoji_Presentation}\\p{Extended_Pictographic}\\p{Regional_Indicator}\\uFE0F\\u20E3]/u,xt=null,rn=new Map;function ft(){if(Re!==null)return Re;if(typeof OffscreenCanvas<"u")return Re=new OffscreenCanvas(1,1).getContext("2d"),Re;if(typeof document<"u")return Re=document.createElement("canvas").getContext("2d"),Re;throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function ki(e){let t=on.get(e);return t||(t=new Map,on.set(e,t)),t}function Ne(e,t){let n=t.get(e);return n===void 0&&(n={width:ft().measureText(e).width,containsCJK:Fe(e)},t.set(e,n)),n}function Ie(){if(ve!==null)return ve;if(typeof navigator>"u")return ve={lineFitEpsilon:.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},ve;let e=navigator.userAgent,n=navigator.vendor==="Apple Computer, Inc."&&e.includes("Safari/")&&!e.includes("Chrome/")&&!e.includes("Chromium/")&&!e.includes("CriOS/")&&!e.includes("FxiOS/")&&!e.includes("EdgiOS/"),o=e.includes("Chrome/")||e.includes("Chromium/")||e.includes("CriOS/")||e.includes("Edg/");return ve={lineFitEpsilon:n?1/64:.005,carryCJKAfterClosingQuote:o,preferPrefixWidthsForBreakableRuns:n,preferEarlySoftHyphenBreak:n},ve}function Li(e){let t=e.match(/(\\d+(?:\\.\\d+)?)\\s*px/);return t?parseFloat(t[1]):16}function sn(){return xt===null&&(xt=new Intl.Segmenter(void 0,{granularity:"grapheme"})),xt}function Ti(e){return Ci.test(e)||e.includes("\\uFE0F")}function an(e){return Di.test(e)}function wi(e,t){let n=rn.get(e);if(n!==void 0)return n;let o=ft();o.font=e;let r=o.measureText("\\u{1F600}").width;if(n=0,r>t+.5&&typeof document<"u"&&document.body!==null){let i=document.createElement("span");i.style.font=e,i.style.display="inline-block",i.style.visibility="hidden",i.style.position="absolute",i.textContent="\\u{1F600}",document.body.appendChild(i);let u=i.getBoundingClientRect().width;document.body.removeChild(i),r-u>.5&&(n=r-u)}return rn.set(e,n),n}function Bi(e){let t=0,n=sn();for(let o of n.segment(e))Ti(o.segment)&&t++;return t}function Ri(e,t){return t.emojiCount===void 0&&(t.emojiCount=Bi(e)),t.emojiCount}function Me(e,t,n){return n===0?t.width:t.width-Ri(e,t)*n}function ln(e,t,n,o,r){if(t.breakableFitAdvances!==void 0)return t.breakableFitAdvances;let i=sn(),u=[];for(let a of i.segment(e))u.push(a.segment);if(u.length<=1)return t.breakableFitAdvances=null,t.breakableFitAdvances;if(r==="sum-graphemes"){let a=[];for(let m of u){let p=Ne(m,n);a.push(Me(m,p,o))}return t.breakableFitAdvances=a,t.breakableFitAdvances}if(r==="pair-context"||u.length>Mi){let a=[],m=null,p=0;for(let F of u){let D=Ne(F,n),C=Me(F,D,o);if(m===null)a.push(C);else{let T=m+F,U=Ne(T,n);a.push(Me(T,U,o)-p)}m=F,p=C}return t.breakableFitAdvances=a,t.breakableFitAdvances}let d=[],c="",s=0;for(let a of u){c+=a;let m=Ne(c,n),p=Me(c,m,o);d.push(p-s),s=p}return t.breakableFitAdvances=d,t.breakableFitAdvances}function un(e,t){let n=ft();n.font=e;let o=ki(e),r=Li(e),i=t?wi(e,r):0;return{cache:o,fontSize:r,emojiCorrection:i}}function vi(e,t){for(;t<e.widths.length;){let n=e.kinds[t];if(n!=="space"&&n!=="zero-width-break"&&n!=="soft-hyphen")break;t++}return t}function Ii(e,t){if(t<=0)return 0;let n=e%t;return Math.abs(n)<=1e-6?t:t-n}function Pi(e,t,n,o,r){let i=0,u=t;for(;i<e.length;){let d=u+e[i];if((i+1<e.length?d+r:d)>n+o)break;u=d,i++}return{fitCount:i,fittedWidth:u}}function cn(e,t){return e.simpleLineWalkFastPath?dn(e,t):mn(e,t)}function dn(e,t,n){let{widths:o,kinds:r,breakableFitAdvances:i}=e;if(o.length===0)return 0;let d=Ie().lineFitEpsilon,c=t+d,s=0,a=0,m=!1,p=0,F=0,D=0,C=0,T=-1,U=0;function z(){T=-1,U=0}function k(b=D,y=C,v=a){s++,n?.({startSegmentIndex:p,startGraphemeIndex:F,endSegmentIndex:b,endGraphemeIndex:y,width:v}),a=0,m=!1,z()}function Q(b,y){m=!0,p=b,F=0,D=b+1,C=0,a=y}function S(b,y,v){m=!0,p=b,F=y,D=b,C=y+1,a=v}function x(b,y){if(!m){Q(b,y);return}a+=y,D=b+1,C=0}function g(b,y){let v=i[b];for(let _=y;_<v.length;_++){let O=v[_];m?a+O>c?(k(),S(b,_,O)):(a+=O,D=b,C=_+1):S(b,_,O)}m&&D===b&&C===v.length&&(D=b+1,C=0)}let E=0;for(;E<o.length&&!(!m&&(E=vi(e,E),E>=o.length));){let b=o[E],y=r[E],v=y==="space"||y==="preserved-space"||y==="tab"||y==="zero-width-break"||y==="soft-hyphen";if(!m){b>t&&i[E]!==null?g(E,0):Q(E,b),v&&(T=E+1,U=a-b),E++;continue}if(a+b>c){if(v){x(E,b),k(E+1,0,a-b),E++;continue}if(T>=0){if(D>T||D===T&&C>0){k();continue}k(T,0,U);continue}if(b>t&&i[E]!==null){k(),g(E,0),E++;continue}k();continue}x(E,b),v&&(T=E+1,U=a-b),E++}return m&&k(),s}function mn(e,t,n){if(e.simpleLineWalkFastPath)return dn(e,t,n);let{widths:o,lineEndFitAdvances:r,lineEndPaintAdvances:i,kinds:u,breakableFitAdvances:d,discretionaryHyphenWidth:c,tabStopAdvance:s,chunks:a}=e;if(o.length===0||a.length===0)return 0;let m=Ie(),p=m.lineFitEpsilon,F=t+p,D=0,C=0,T=!1,U=0,z=0,k=0,Q=0,S=-1,x=0,g=0,E=null;function b(){S=-1,x=0,g=0,E=null}function y(W=k,j=Q,R=C){D++,n?.({startSegmentIndex:U,startGraphemeIndex:z,endSegmentIndex:W,endGraphemeIndex:j,width:R}),C=0,T=!1,b()}function v(W,j){T=!0,U=W,z=0,k=W+1,Q=0,C=j}function _(W,j,R){T=!0,U=W,z=j,k=W,Q=j+1,C=R}function O(W,j){if(!T){v(W,j);return}C+=j,k=W+1,Q=0}function V(W,j,R,$){if(!j)return;let fe=W==="tab"?0:r[R],le=W==="tab"?$:i[R];S=R+1,x=C-$+fe,g=C-$+le,E=W}function w(W,j){let R=d[W];for(let $=j;$<R.length;$++){let fe=R[$];T?C+fe>F?(y(),_(W,$,fe)):(C+=fe,k=W,Q=$+1):_(W,$,fe)}T&&k===W&&Q===R.length&&(k=W+1,Q=0)}function K(W){if(E!=="soft-hyphen")return!1;let j=d[W];if(j==null)return!1;let{fitCount:R,fittedWidth:$}=Pi(j,C,t,p,c);return R===0?!1:(C=$,k=W,Q=R,b(),R===j.length?(k=W+1,Q=0,!0):(y(W,R,$+c),w(W,R),!0))}function Z(W){D++,n?.({startSegmentIndex:W.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:W.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),b()}for(let W=0;W<a.length;W++){let j=a[W];if(j.startSegmentIndex===j.endSegmentIndex){Z(j);continue}T=!1,C=0,U=j.startSegmentIndex,z=0,k=j.startSegmentIndex,Q=0,b();let R=j.startSegmentIndex;for(;R<j.endSegmentIndex;){let $=u[R],fe=$==="space"||$==="preserved-space"||$==="tab"||$==="zero-width-break"||$==="soft-hyphen",le=$==="tab"?Ii(C,s):o[R];if($==="soft-hyphen"){T&&(k=R+1,Q=0,S=R+1,x=C+c,g=C+c,E=$),R++;continue}if(!T){le>t&&d[R]!==null?w(R,0):v(R,le),V($,fe,R,le),R++;continue}if(C+le>F){let M=C+($==="tab"?0:r[R]),L=C+($==="tab"?le:i[R]);if(E==="soft-hyphen"&&m.preferEarlySoftHyphenBreak&&x<=F){y(S,0,g);continue}if(E==="soft-hyphen"&&K(R)){R++;continue}if(fe&&M<=F){O(R,le),y(R+1,0,L),R++;continue}if(S>=0&&x<=F){if(k>S||k===S&&Q>0){y();continue}let J=S;y(J,0,g),R=J;continue}if(le>t&&d[R]!==null){y(),w(R,0),R++;continue}y();continue}O(R,le),V($,fe,R,le),R++}if(T){let $=S===j.consumedEndSegmentIndex?g:C;y(j.consumedEndSegmentIndex,0,$)}}return D}var pt=null;function Oi(){return pt===null&&(pt=new Intl.Segmenter(void 0,{granularity:"grapheme"})),pt}function _i(e){return e?{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]}:{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function Wi(e,t){let n=[],o=[],r=0,i=!1,u=!1,d=!1;function c(){o.length!==0&&(n.push({text:o.length===1?o[0]:o.join(""),start:r}),o=[],i=!1,u=!1,d=!1)}function s(m,p,F){o=[m],r=p,i=F,u=Je(m),d=je.has(m)}function a(m,p){o.push(m),i=i||p;let F=Je(m);m.length===1&&be.has(m)?u=u||F:u=F,d=!1}for(let m of Oi().segment(e)){let p=m.segment,F=Fe(p);if(o.length===0){s(p,m.index,F);continue}if(d||Ke.has(p)||be.has(p)||t.carryCJKAfterClosingQuote&&F&&u){a(p,F);continue}if(!i&&!F){a(p,F);continue}c(),s(p,m.index,F)}return c(),n}function Hi(e){if(e.length<=1)return e;let t=[],n=[e[0].text],o=e[0].start,r=Fe(e[0].text),i=$e(e[0].text);function u(){t.push({text:n.length===1?n[0]:n.join(""),start:o})}for(let d=1;d<e.length;d++){let c=e[d],s=Fe(c.text),a=$e(c.text);if(r&&i){n.push(c.text),r=r||s,i=a;continue}u(),n=[c.text],o=c.start,r=s,i=a}return u(),t}function ji(e,t,n,o){let r=Ie(),{cache:i,emojiCorrection:u}=un(t,an(e.normalized)),d=Me("-",Ne("-",i),u),s=Me(" ",Ne(" ",i),u)*8;if(e.len===0)return _i(n);let a=[],m=[],p=[],F=[],D=e.chunks.length<=1,C=n?[]:null,T=[],U=n?[]:null,z=Array.from({length:e.len});function k(g,E,b,y,v,_,O){v!=="text"&&v!=="space"&&v!=="zero-width-break"&&(D=!1),a.push(E),m.push(b),p.push(y),F.push(v),C?.push(_),T.push(O),U!==null&&U.push(g)}function Q(g,E,b,y,v){let _=Ne(g,i),O=Me(g,_,u),V=E==="space"||E==="preserved-space"||E==="zero-width-break"?0:O,w=E==="space"||E==="zero-width-break"?0:O;if(v&&y&&g.length>1){let K="sum-graphemes";He(g)?K="pair-context":r.preferPrefixWidthsForBreakableRuns&&(K="segment-prefixes");let Z=ln(g,_,i,u,K);k(g,O,V,w,E,b,Z);return}k(g,O,V,w,E,b,null)}for(let g=0;g<e.len;g++){z[g]=a.length;let E=e.texts[g],b=e.isWordLike[g],y=e.kinds[g],v=e.starts[g];if(y==="soft-hyphen"){k(E,0,d,d,y,v,null);continue}if(y==="hard-break"){k(E,0,0,0,y,v,null);continue}if(y==="tab"){k(E,0,0,0,y,v,null);continue}let _=Ne(E,i);if(y==="text"&&_.containsCJK){let O=Wi(E,r),V=o==="keep-all"?Hi(O):O;for(let w=0;w<V.length;w++){let K=V[w];Q(K.text,"text",v+K.start,b,o==="keep-all"||!Fe(K.text))}continue}Q(E,y,v,b,!0)}let S=zi(e.chunks,z,a.length),x=C===null?null:qt(e.normalized,C);return U!==null?{widths:a,lineEndFitAdvances:m,lineEndPaintAdvances:p,kinds:F,simpleLineWalkFastPath:D,segLevels:x,breakableFitAdvances:T,discretionaryHyphenWidth:d,tabStopAdvance:s,chunks:S,segments:U}:{widths:a,lineEndFitAdvances:m,lineEndPaintAdvances:p,kinds:F,simpleLineWalkFastPath:D,segLevels:x,breakableFitAdvances:T,discretionaryHyphenWidth:d,tabStopAdvance:s,chunks:S}}function zi(e,t,n){let o=[];for(let r=0;r<e.length;r++){let i=e[r],u=i.startSegmentIndex<t.length?t[i.startSegmentIndex]:n,d=i.endSegmentIndex<t.length?t[i.endSegmentIndex]:n,c=i.consumedEndSegmentIndex<t.length?t[i.consumedEndSegmentIndex]:n;o.push({startSegmentIndex:u,endSegmentIndex:d,consumedEndSegmentIndex:c})}return o}function Ui(e,t,n,o){let r=o?.wordBreak??"normal",i=nn(e,Ie(),o?.whiteSpace,r);return ji(i,t,n,r)}function xn(e,t,n){return Ui(e,t,!1,n)}function fn(e,t,n){let o=cn(e,t);return{lineCount:o,height:o*n}}var Gi={maxWidth:1600,baseFontSize:78,minFontSize:42,fontWeight:900,fontFamily:"Outfit",step:2};function pn(e,t){let n={...Gi,...t},o=1.2;for(let r=n.baseFontSize;r>=n.minFontSize;r-=n.step){let i=`${n.fontWeight} ${r}px ${n.fontFamily}`,u=xn(e,i),{lineCount:d}=fn(u,n.maxWidth,r*o);if(d<=1)return{fontSize:r,fits:!0}}return{fontSize:n.minFontSize,fits:!1}}window.__timelines=window.__timelines||{};window.__hyperframes={fitTextFontSize:pn};function hn(){let e=window;e.__hyperframeRuntimeBootstrapped||(e.__hyperframeRuntimeBootstrapped=!0,Ut())}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",hn,{once:!0}):hn();})();\n';
|
|
5998
5998
|
}
|
|
5999
5999
|
});
|
|
6000
6000
|
|
|
@@ -11270,256 +11270,64 @@ var init_projects = __esm({
|
|
|
11270
11270
|
}
|
|
11271
11271
|
});
|
|
11272
11272
|
|
|
11273
|
-
// ../core/src/studio-api/
|
|
11274
|
-
import {
|
|
11275
|
-
import {
|
|
11276
|
-
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
|
|
11295
|
-
return { error: c2.json({ error: "forbidden" }, 403) };
|
|
11296
|
-
}
|
|
11297
|
-
const absPath = resolve9(project.dir, filePath);
|
|
11298
|
-
if (!isSafePath(project.dir, absPath)) {
|
|
11299
|
-
return { error: c2.json({ error: "forbidden" }, 403) };
|
|
11273
|
+
// ../core/src/studio-api/helpers/mediaValidation.ts
|
|
11274
|
+
import { spawnSync } from "child_process";
|
|
11275
|
+
import { mkdtempSync, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
|
|
11276
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
11277
|
+
import { basename, join as join11 } from "path";
|
|
11278
|
+
function validateUploadedMedia(filePath, runner = spawnSync) {
|
|
11279
|
+
const isVideo2 = VIDEO_EXT.test(filePath);
|
|
11280
|
+
const isAudio = AUDIO_EXT.test(filePath);
|
|
11281
|
+
if (!isVideo2 && !isAudio) {
|
|
11282
|
+
return { ok: true };
|
|
11283
|
+
}
|
|
11284
|
+
const result = runner("ffprobe", [
|
|
11285
|
+
"-v",
|
|
11286
|
+
"error",
|
|
11287
|
+
"-show_entries",
|
|
11288
|
+
"stream=codec_type",
|
|
11289
|
+
"-of",
|
|
11290
|
+
"json",
|
|
11291
|
+
filePath
|
|
11292
|
+
]);
|
|
11293
|
+
if (result.error?.code === "ENOENT") {
|
|
11294
|
+
return { ok: true };
|
|
11300
11295
|
}
|
|
11301
|
-
if (
|
|
11302
|
-
return {
|
|
11296
|
+
if (result.status !== 0) {
|
|
11297
|
+
return { ok: false, reason: "ffprobe failed to read the media file" };
|
|
11303
11298
|
}
|
|
11304
|
-
|
|
11305
|
-
}
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
const ext = originalPath.includes(".") ? "." + originalPath.split(".").pop() : "";
|
|
11312
|
-
const base = ext ? originalPath.slice(0, -ext.length) : originalPath;
|
|
11313
|
-
const copyMatch = base.match(/ \(copy(?: (\d+))?\)$/);
|
|
11314
|
-
const cleanBase = copyMatch ? base.slice(0, -copyMatch[0].length) : base;
|
|
11315
|
-
let num = copyMatch ? copyMatch[1] ? parseInt(copyMatch[1]) + 1 : 2 : 1;
|
|
11316
|
-
let candidate = num === 1 ? `${cleanBase} (copy)${ext}` : `${cleanBase} (copy ${num})${ext}`;
|
|
11317
|
-
while (existsSync9(resolve9(projectDir, candidate))) {
|
|
11318
|
-
num++;
|
|
11319
|
-
candidate = `${cleanBase} (copy ${num})${ext}`;
|
|
11320
|
-
}
|
|
11321
|
-
return candidate;
|
|
11322
|
-
}
|
|
11323
|
-
function walkFiles(dir, filter2) {
|
|
11324
|
-
const results = [];
|
|
11325
|
-
for (const entry of readdirSync4(dir, { withFileTypes: true })) {
|
|
11326
|
-
const full = join11(dir, entry.name);
|
|
11327
|
-
if (entry.isDirectory()) {
|
|
11328
|
-
if (entry.name === "node_modules" || entry.name === ".thumbnails" || entry.name === "renders")
|
|
11329
|
-
continue;
|
|
11330
|
-
results.push(...walkFiles(full, filter2));
|
|
11331
|
-
} else if (filter2(entry.name)) {
|
|
11332
|
-
results.push(full);
|
|
11299
|
+
try {
|
|
11300
|
+
const parsed = JSON.parse(String(result.stdout || "{}"));
|
|
11301
|
+
const streams = parsed.streams ?? [];
|
|
11302
|
+
const hasVideo = streams.some((stream) => stream.codec_type === "video");
|
|
11303
|
+
const hasAudio = streams.some((stream) => stream.codec_type === "audio");
|
|
11304
|
+
if (isVideo2 && !hasVideo) {
|
|
11305
|
+
return { ok: false, reason: "no supported video stream found" };
|
|
11333
11306
|
}
|
|
11334
|
-
|
|
11335
|
-
|
|
11336
|
-
}
|
|
11337
|
-
function updateReferences(projectDir, oldPath, newPath) {
|
|
11338
|
-
const textFiles = walkFiles(
|
|
11339
|
-
projectDir,
|
|
11340
|
-
(name) => /\.(html|css|js|jsx|ts|tsx|json|mjs|cjs|md|mdx)$/i.test(name)
|
|
11341
|
-
);
|
|
11342
|
-
let updatedCount = 0;
|
|
11343
|
-
for (const file of textFiles) {
|
|
11344
|
-
const content = readFileSync9(file, "utf-8");
|
|
11345
|
-
if (!content.includes(oldPath)) continue;
|
|
11346
|
-
const updated = content.split(oldPath).join(newPath);
|
|
11347
|
-
if (updated !== content) {
|
|
11348
|
-
writeFileSync5(file, updated, "utf-8");
|
|
11349
|
-
updatedCount++;
|
|
11307
|
+
if (isAudio && !hasAudio) {
|
|
11308
|
+
return { ok: false, reason: "no supported audio stream found" };
|
|
11350
11309
|
}
|
|
11310
|
+
return { ok: true };
|
|
11311
|
+
} catch {
|
|
11312
|
+
return { ok: false, reason: "ffprobe returned unreadable media metadata" };
|
|
11351
11313
|
}
|
|
11352
|
-
return updatedCount;
|
|
11353
11314
|
}
|
|
11354
|
-
function
|
|
11355
|
-
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
|
|
11359
|
-
return
|
|
11360
|
-
}
|
|
11361
|
-
|
|
11362
|
-
const res = await resolveProjectFile(c2, adapter2);
|
|
11363
|
-
if ("error" in res) return res.error;
|
|
11364
|
-
ensureDir(res.absPath);
|
|
11365
|
-
const body = await c2.req.text();
|
|
11366
|
-
writeFileSync5(res.absPath, body, "utf-8");
|
|
11367
|
-
return c2.json({ ok: true });
|
|
11368
|
-
});
|
|
11369
|
-
api.post("/projects/:id/files/*", async (c2) => {
|
|
11370
|
-
const res = await resolveProjectFile(c2, adapter2);
|
|
11371
|
-
if ("error" in res) return res.error;
|
|
11372
|
-
if (existsSync9(res.absPath)) {
|
|
11373
|
-
return c2.json({ error: "already exists" }, 409);
|
|
11374
|
-
}
|
|
11375
|
-
ensureDir(res.absPath);
|
|
11376
|
-
const body = await c2.req.text().catch(() => "");
|
|
11377
|
-
writeFileSync5(res.absPath, body, "utf-8");
|
|
11378
|
-
return c2.json({ ok: true, path: res.filePath }, 201);
|
|
11379
|
-
});
|
|
11380
|
-
api.delete("/projects/:id/files/*", async (c2) => {
|
|
11381
|
-
const res = await resolveProjectFile(c2, adapter2, { mustExist: true });
|
|
11382
|
-
if ("error" in res) return res.error;
|
|
11383
|
-
const stat3 = statSync(res.absPath);
|
|
11384
|
-
if (stat3.isDirectory()) {
|
|
11385
|
-
rmSync2(res.absPath, { recursive: true });
|
|
11386
|
-
} else {
|
|
11387
|
-
unlinkSync3(res.absPath);
|
|
11388
|
-
}
|
|
11389
|
-
return c2.json({ ok: true });
|
|
11390
|
-
});
|
|
11391
|
-
api.patch("/projects/:id/files/*", async (c2) => {
|
|
11392
|
-
const res = await resolveProjectFile(c2, adapter2, { mustExist: true });
|
|
11393
|
-
if ("error" in res) return res.error;
|
|
11394
|
-
const body = await c2.req.json();
|
|
11395
|
-
if (!body.newPath || body.newPath.includes("\0")) {
|
|
11396
|
-
return c2.json({ error: "newPath required" }, 400);
|
|
11397
|
-
}
|
|
11398
|
-
const newAbs = resolve9(res.project.dir, body.newPath);
|
|
11399
|
-
if (!isSafePath(res.project.dir, newAbs)) {
|
|
11400
|
-
return c2.json({ error: "forbidden" }, 403);
|
|
11401
|
-
}
|
|
11402
|
-
if (existsSync9(newAbs)) {
|
|
11403
|
-
return c2.json({ error: "already exists" }, 409);
|
|
11404
|
-
}
|
|
11405
|
-
ensureDir(newAbs);
|
|
11406
|
-
renameSync2(res.absPath, newAbs);
|
|
11407
|
-
const updatedFiles = updateReferences(res.project.dir, res.filePath, body.newPath);
|
|
11408
|
-
return c2.json({ ok: true, path: body.newPath, updatedReferences: updatedFiles });
|
|
11409
|
-
});
|
|
11410
|
-
api.post("/projects/:id/duplicate-file", async (c2) => {
|
|
11411
|
-
const project = await adapter2.resolveProject(c2.req.param("id"));
|
|
11412
|
-
if (!project) return c2.json({ error: "not found" }, 404);
|
|
11413
|
-
const body = await c2.req.json();
|
|
11414
|
-
if (!body.path || body.path.includes("\0")) {
|
|
11415
|
-
return c2.json({ error: "path required" }, 400);
|
|
11416
|
-
}
|
|
11417
|
-
const srcAbs = resolve9(project.dir, body.path);
|
|
11418
|
-
if (!isSafePath(project.dir, srcAbs) || !existsSync9(srcAbs)) {
|
|
11419
|
-
return c2.json({ error: "not found" }, 404);
|
|
11420
|
-
}
|
|
11421
|
-
const copyPath = generateCopyPath(project.dir, body.path);
|
|
11422
|
-
const destAbs = resolve9(project.dir, copyPath);
|
|
11423
|
-
if (!isSafePath(project.dir, destAbs)) {
|
|
11424
|
-
return c2.json({ error: "forbidden" }, 403);
|
|
11425
|
-
}
|
|
11426
|
-
ensureDir(destAbs);
|
|
11427
|
-
writeFileSync5(destAbs, readFileSync9(srcAbs));
|
|
11428
|
-
return c2.json({ ok: true, path: copyPath }, 201);
|
|
11429
|
-
});
|
|
11430
|
-
const MAX_UPLOAD_BYTES = 500 * 1024 * 1024;
|
|
11431
|
-
api.post(
|
|
11432
|
-
"/projects/:id/upload",
|
|
11433
|
-
bodyLimit({
|
|
11434
|
-
maxSize: MAX_UPLOAD_BYTES,
|
|
11435
|
-
onError: (c2) => c2.json({ error: "payload too large" }, 413)
|
|
11436
|
-
}),
|
|
11437
|
-
async (c2) => {
|
|
11438
|
-
const project = await adapter2.resolveProject(c2.req.param("id"));
|
|
11439
|
-
if (!project) return c2.json({ error: "not found" }, 404);
|
|
11440
|
-
const subDir = c2.req.query("dir") ?? "";
|
|
11441
|
-
const targetDir = subDir ? resolve9(project.dir, subDir) : project.dir;
|
|
11442
|
-
if (!isSafePath(project.dir, targetDir)) return c2.json({ error: "forbidden" }, 403);
|
|
11443
|
-
if (subDir && !existsSync9(targetDir)) mkdirSync5(targetDir, { recursive: true });
|
|
11444
|
-
const formData = await c2.req.formData();
|
|
11445
|
-
const uploaded = [];
|
|
11446
|
-
const skipped = [];
|
|
11447
|
-
for (const [, value] of formData.entries()) {
|
|
11448
|
-
if (!(value instanceof File)) continue;
|
|
11449
|
-
const name = value.name.split("/").pop()?.split("\\").pop() ?? "";
|
|
11450
|
-
if (!name || name.includes("\0") || name.includes("..")) continue;
|
|
11451
|
-
if (value.size > MAX_UPLOAD_BYTES) {
|
|
11452
|
-
skipped.push(name);
|
|
11453
|
-
continue;
|
|
11454
|
-
}
|
|
11455
|
-
const destPath = resolve9(targetDir, name);
|
|
11456
|
-
if (!isSafePath(project.dir, destPath)) continue;
|
|
11457
|
-
let finalPath = destPath;
|
|
11458
|
-
let finalName = name;
|
|
11459
|
-
if (existsSync9(finalPath)) {
|
|
11460
|
-
const dotIdx = name.indexOf(".", name.startsWith(".") ? 1 : 0);
|
|
11461
|
-
const ext = dotIdx > 0 ? name.slice(dotIdx) : "";
|
|
11462
|
-
const base = dotIdx > 0 ? name.slice(0, dotIdx) : name;
|
|
11463
|
-
let n = 2;
|
|
11464
|
-
while (n < 1e4 && existsSync9(resolve9(targetDir, `${base} (${n})${ext}`))) n++;
|
|
11465
|
-
if (n >= 1e4) {
|
|
11466
|
-
skipped.push(name);
|
|
11467
|
-
continue;
|
|
11468
|
-
}
|
|
11469
|
-
finalName = `${base} (${n})${ext}`;
|
|
11470
|
-
finalPath = resolve9(targetDir, finalName);
|
|
11471
|
-
}
|
|
11472
|
-
const buffer = Buffer.from(await value.arrayBuffer());
|
|
11473
|
-
writeFileSync5(finalPath, buffer);
|
|
11474
|
-
uploaded.push(subDir ? join11(subDir, finalName) : finalName);
|
|
11475
|
-
}
|
|
11476
|
-
return c2.json({ ok: true, files: uploaded, skipped }, 201);
|
|
11477
|
-
}
|
|
11478
|
-
);
|
|
11479
|
-
}
|
|
11480
|
-
var init_files = __esm({
|
|
11481
|
-
"../core/src/studio-api/routes/files.ts"() {
|
|
11482
|
-
"use strict";
|
|
11483
|
-
init_safePath();
|
|
11315
|
+
function validateUploadedMediaBuffer(fileName, buffer, runner = spawnSync) {
|
|
11316
|
+
const tempDir = mkdtempSync(join11(tmpdir2(), "hyperframes-upload-"));
|
|
11317
|
+
const tempPath = join11(tempDir, basename(fileName));
|
|
11318
|
+
try {
|
|
11319
|
+
writeFileSync5(tempPath, buffer);
|
|
11320
|
+
return validateUploadedMedia(tempPath, runner);
|
|
11321
|
+
} finally {
|
|
11322
|
+
rmSync2(tempDir, { recursive: true, force: true });
|
|
11484
11323
|
}
|
|
11485
|
-
});
|
|
11486
|
-
|
|
11487
|
-
// ../core/src/studio-api/helpers/mime.ts
|
|
11488
|
-
function getMimeType(path2) {
|
|
11489
|
-
const ext = path2.slice(path2.lastIndexOf(".")).toLowerCase();
|
|
11490
|
-
return MIME_TYPES[ext] || "application/octet-stream";
|
|
11491
11324
|
}
|
|
11492
|
-
var
|
|
11493
|
-
var
|
|
11494
|
-
"../core/src/studio-api/helpers/
|
|
11325
|
+
var VIDEO_EXT, AUDIO_EXT;
|
|
11326
|
+
var init_mediaValidation = __esm({
|
|
11327
|
+
"../core/src/studio-api/helpers/mediaValidation.ts"() {
|
|
11495
11328
|
"use strict";
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
".css": "text/css",
|
|
11499
|
-
".js": "text/javascript",
|
|
11500
|
-
".mjs": "text/javascript",
|
|
11501
|
-
".json": "application/json",
|
|
11502
|
-
".svg": "image/svg+xml",
|
|
11503
|
-
".png": "image/png",
|
|
11504
|
-
".jpg": "image/jpeg",
|
|
11505
|
-
".jpeg": "image/jpeg",
|
|
11506
|
-
".gif": "image/gif",
|
|
11507
|
-
".webp": "image/webp",
|
|
11508
|
-
".ico": "image/x-icon",
|
|
11509
|
-
".mp4": "video/mp4",
|
|
11510
|
-
".mov": "video/quicktime",
|
|
11511
|
-
".webm": "video/webm",
|
|
11512
|
-
".mp3": "audio/mpeg",
|
|
11513
|
-
".wav": "audio/wav",
|
|
11514
|
-
".ogg": "audio/ogg",
|
|
11515
|
-
".m4a": "audio/mp4",
|
|
11516
|
-
".woff": "font/woff",
|
|
11517
|
-
".woff2": "font/woff2",
|
|
11518
|
-
".ttf": "font/ttf",
|
|
11519
|
-
".otf": "font/otf",
|
|
11520
|
-
".txt": "text/plain",
|
|
11521
|
-
".md": "text/markdown"
|
|
11522
|
-
};
|
|
11329
|
+
VIDEO_EXT = /\.(mp4|webm|mov)$/i;
|
|
11330
|
+
AUDIO_EXT = /\.(mp3|wav|ogg|m4a|aac)$/i;
|
|
11523
11331
|
}
|
|
11524
11332
|
});
|
|
11525
11333
|
|
|
@@ -23361,7 +23169,7 @@ var init_html_classes = __esm({
|
|
|
23361
23169
|
|
|
23362
23170
|
// ../../node_modules/.bun/linkedom@0.18.12/node_modules/linkedom/esm/shared/mime.js
|
|
23363
23171
|
var voidElements2, Mime;
|
|
23364
|
-
var
|
|
23172
|
+
var init_mime = __esm({
|
|
23365
23173
|
"../../node_modules/.bun/linkedom@0.18.12/node_modules/linkedom/esm/shared/mime.js"() {
|
|
23366
23174
|
"use strict";
|
|
23367
23175
|
voidElements2 = { test: () => true };
|
|
@@ -23626,7 +23434,7 @@ var init_document = __esm({
|
|
|
23626
23434
|
init_symbols();
|
|
23627
23435
|
init_facades();
|
|
23628
23436
|
init_html_classes();
|
|
23629
|
-
|
|
23437
|
+
init_mime();
|
|
23630
23438
|
init_utils2();
|
|
23631
23439
|
init_object();
|
|
23632
23440
|
init_non_element_parent_node();
|
|
@@ -24124,11 +23932,339 @@ var init_esm10 = __esm({
|
|
|
24124
23932
|
}
|
|
24125
23933
|
});
|
|
24126
23934
|
|
|
23935
|
+
// ../core/src/studio-api/helpers/sourceMutation.ts
|
|
23936
|
+
function parseSourceDocument(source) {
|
|
23937
|
+
const hasDocumentShell = /<!doctype|<html[\s>]/i.test(source);
|
|
23938
|
+
if (hasDocumentShell) {
|
|
23939
|
+
return { document: parseHTML(source).document, wrappedFragment: false };
|
|
23940
|
+
}
|
|
23941
|
+
return {
|
|
23942
|
+
document: parseHTML(`<!DOCTYPE html><html><head></head><body>${source}</body></html>`).document,
|
|
23943
|
+
wrappedFragment: true
|
|
23944
|
+
};
|
|
23945
|
+
}
|
|
23946
|
+
function findTargetElement(document2, target) {
|
|
23947
|
+
if (target.id) {
|
|
23948
|
+
const byId = document2.getElementById(target.id);
|
|
23949
|
+
if (byId) return byId;
|
|
23950
|
+
}
|
|
23951
|
+
if (!target.selector) return null;
|
|
23952
|
+
try {
|
|
23953
|
+
const matches2 = Array.from(document2.querySelectorAll(target.selector));
|
|
23954
|
+
return matches2[target.selectorIndex ?? 0] ?? null;
|
|
23955
|
+
} catch {
|
|
23956
|
+
return null;
|
|
23957
|
+
}
|
|
23958
|
+
}
|
|
23959
|
+
function removeElementFromHtml2(source, target) {
|
|
23960
|
+
const { document: document2, wrappedFragment } = parseSourceDocument(source);
|
|
23961
|
+
const element = findTargetElement(document2, target);
|
|
23962
|
+
if (!element) return source;
|
|
23963
|
+
element.remove();
|
|
23964
|
+
return wrappedFragment ? document2.body.innerHTML || "" : document2.toString();
|
|
23965
|
+
}
|
|
23966
|
+
var init_sourceMutation = __esm({
|
|
23967
|
+
"../core/src/studio-api/helpers/sourceMutation.ts"() {
|
|
23968
|
+
"use strict";
|
|
23969
|
+
init_esm10();
|
|
23970
|
+
}
|
|
23971
|
+
});
|
|
23972
|
+
|
|
23973
|
+
// ../core/src/studio-api/routes/files.ts
|
|
23974
|
+
import { bodyLimit } from "hono/body-limit";
|
|
23975
|
+
import {
|
|
23976
|
+
existsSync as existsSync9,
|
|
23977
|
+
readFileSync as readFileSync9,
|
|
23978
|
+
writeFileSync as writeFileSync6,
|
|
23979
|
+
mkdirSync as mkdirSync5,
|
|
23980
|
+
unlinkSync as unlinkSync3,
|
|
23981
|
+
rmSync as rmSync3,
|
|
23982
|
+
statSync,
|
|
23983
|
+
renameSync as renameSync2,
|
|
23984
|
+
readdirSync as readdirSync4
|
|
23985
|
+
} from "fs";
|
|
23986
|
+
import { resolve as resolve9, dirname as dirname5, join as join12 } from "path";
|
|
23987
|
+
async function resolveProjectFile(c2, adapter2, opts) {
|
|
23988
|
+
const id = c2.req.param("id");
|
|
23989
|
+
const project = await adapter2.resolveProject(id);
|
|
23990
|
+
if (!project) {
|
|
23991
|
+
return { error: c2.json({ error: "not found" }, 404) };
|
|
23992
|
+
}
|
|
23993
|
+
const filePath = decodeURIComponent(c2.req.path.replace(`/projects/${project.id}/files/`, ""));
|
|
23994
|
+
if (filePath.includes("\0")) {
|
|
23995
|
+
return { error: c2.json({ error: "forbidden" }, 403) };
|
|
23996
|
+
}
|
|
23997
|
+
const absPath = resolve9(project.dir, filePath);
|
|
23998
|
+
if (!isSafePath(project.dir, absPath)) {
|
|
23999
|
+
return { error: c2.json({ error: "forbidden" }, 403) };
|
|
24000
|
+
}
|
|
24001
|
+
if (opts?.mustExist && !existsSync9(absPath)) {
|
|
24002
|
+
return { error: c2.json({ error: "not found" }, 404) };
|
|
24003
|
+
}
|
|
24004
|
+
return { project, filePath, absPath };
|
|
24005
|
+
}
|
|
24006
|
+
function ensureDir(filePath) {
|
|
24007
|
+
const dir = dirname5(filePath);
|
|
24008
|
+
if (!existsSync9(dir)) mkdirSync5(dir, { recursive: true });
|
|
24009
|
+
}
|
|
24010
|
+
function generateCopyPath(projectDir, originalPath) {
|
|
24011
|
+
const ext = originalPath.includes(".") ? "." + originalPath.split(".").pop() : "";
|
|
24012
|
+
const base = ext ? originalPath.slice(0, -ext.length) : originalPath;
|
|
24013
|
+
const copyMatch = base.match(/ \(copy(?: (\d+))?\)$/);
|
|
24014
|
+
const cleanBase = copyMatch ? base.slice(0, -copyMatch[0].length) : base;
|
|
24015
|
+
let num = copyMatch ? copyMatch[1] ? parseInt(copyMatch[1]) + 1 : 2 : 1;
|
|
24016
|
+
let candidate = num === 1 ? `${cleanBase} (copy)${ext}` : `${cleanBase} (copy ${num})${ext}`;
|
|
24017
|
+
while (existsSync9(resolve9(projectDir, candidate))) {
|
|
24018
|
+
num++;
|
|
24019
|
+
candidate = `${cleanBase} (copy ${num})${ext}`;
|
|
24020
|
+
}
|
|
24021
|
+
return candidate;
|
|
24022
|
+
}
|
|
24023
|
+
function walkFiles(dir, filter2) {
|
|
24024
|
+
const results = [];
|
|
24025
|
+
for (const entry of readdirSync4(dir, { withFileTypes: true })) {
|
|
24026
|
+
const full = join12(dir, entry.name);
|
|
24027
|
+
if (entry.isDirectory()) {
|
|
24028
|
+
if (entry.name === "node_modules" || entry.name === ".thumbnails" || entry.name === "renders")
|
|
24029
|
+
continue;
|
|
24030
|
+
results.push(...walkFiles(full, filter2));
|
|
24031
|
+
} else if (filter2(entry.name)) {
|
|
24032
|
+
results.push(full);
|
|
24033
|
+
}
|
|
24034
|
+
}
|
|
24035
|
+
return results;
|
|
24036
|
+
}
|
|
24037
|
+
function updateReferences(projectDir, oldPath, newPath) {
|
|
24038
|
+
const textFiles = walkFiles(
|
|
24039
|
+
projectDir,
|
|
24040
|
+
(name) => /\.(html|css|js|jsx|ts|tsx|json|mjs|cjs|md|mdx)$/i.test(name)
|
|
24041
|
+
);
|
|
24042
|
+
let updatedCount = 0;
|
|
24043
|
+
for (const file of textFiles) {
|
|
24044
|
+
const content = readFileSync9(file, "utf-8");
|
|
24045
|
+
if (!content.includes(oldPath)) continue;
|
|
24046
|
+
const updated = content.split(oldPath).join(newPath);
|
|
24047
|
+
if (updated !== content) {
|
|
24048
|
+
writeFileSync6(file, updated, "utf-8");
|
|
24049
|
+
updatedCount++;
|
|
24050
|
+
}
|
|
24051
|
+
}
|
|
24052
|
+
return updatedCount;
|
|
24053
|
+
}
|
|
24054
|
+
function registerFileRoutes(api, adapter2) {
|
|
24055
|
+
api.get("/projects/:id/files/*", async (c2) => {
|
|
24056
|
+
const res = await resolveProjectFile(c2, adapter2, { mustExist: true });
|
|
24057
|
+
if ("error" in res) return res.error;
|
|
24058
|
+
const content = readFileSync9(res.absPath, "utf-8");
|
|
24059
|
+
return c2.json({ filename: res.filePath, content });
|
|
24060
|
+
});
|
|
24061
|
+
api.put("/projects/:id/files/*", async (c2) => {
|
|
24062
|
+
const res = await resolveProjectFile(c2, adapter2);
|
|
24063
|
+
if ("error" in res) return res.error;
|
|
24064
|
+
ensureDir(res.absPath);
|
|
24065
|
+
const body = await c2.req.text();
|
|
24066
|
+
writeFileSync6(res.absPath, body, "utf-8");
|
|
24067
|
+
return c2.json({ ok: true });
|
|
24068
|
+
});
|
|
24069
|
+
api.post("/projects/:id/files/*", async (c2) => {
|
|
24070
|
+
const res = await resolveProjectFile(c2, adapter2);
|
|
24071
|
+
if ("error" in res) return res.error;
|
|
24072
|
+
if (existsSync9(res.absPath)) {
|
|
24073
|
+
return c2.json({ error: "already exists" }, 409);
|
|
24074
|
+
}
|
|
24075
|
+
ensureDir(res.absPath);
|
|
24076
|
+
const body = await c2.req.text().catch(() => "");
|
|
24077
|
+
writeFileSync6(res.absPath, body, "utf-8");
|
|
24078
|
+
return c2.json({ ok: true, path: res.filePath }, 201);
|
|
24079
|
+
});
|
|
24080
|
+
api.delete("/projects/:id/files/*", async (c2) => {
|
|
24081
|
+
const res = await resolveProjectFile(c2, adapter2, { mustExist: true });
|
|
24082
|
+
if ("error" in res) return res.error;
|
|
24083
|
+
const stat3 = statSync(res.absPath);
|
|
24084
|
+
if (stat3.isDirectory()) {
|
|
24085
|
+
rmSync3(res.absPath, { recursive: true });
|
|
24086
|
+
} else {
|
|
24087
|
+
unlinkSync3(res.absPath);
|
|
24088
|
+
}
|
|
24089
|
+
return c2.json({ ok: true });
|
|
24090
|
+
});
|
|
24091
|
+
api.post("/projects/:id/file-mutations/remove-element/*", async (c2) => {
|
|
24092
|
+
const id = c2.req.param("id");
|
|
24093
|
+
const project = await adapter2.resolveProject(id);
|
|
24094
|
+
if (!project) return c2.json({ error: "not found" }, 404);
|
|
24095
|
+
const filePath = decodeURIComponent(
|
|
24096
|
+
c2.req.path.replace(`/projects/${project.id}/file-mutations/remove-element/`, "")
|
|
24097
|
+
);
|
|
24098
|
+
if (filePath.includes("\0")) {
|
|
24099
|
+
return c2.json({ error: "forbidden" }, 403);
|
|
24100
|
+
}
|
|
24101
|
+
const absPath = resolve9(project.dir, filePath);
|
|
24102
|
+
if (!isSafePath(project.dir, absPath)) {
|
|
24103
|
+
return c2.json({ error: "forbidden" }, 403);
|
|
24104
|
+
}
|
|
24105
|
+
if (!existsSync9(absPath)) {
|
|
24106
|
+
return c2.json({ error: "not found" }, 404);
|
|
24107
|
+
}
|
|
24108
|
+
const body = await c2.req.json().catch(() => null);
|
|
24109
|
+
if (!body?.target) {
|
|
24110
|
+
return c2.json({ error: "target required" }, 400);
|
|
24111
|
+
}
|
|
24112
|
+
const originalContent = readFileSync9(absPath, "utf-8");
|
|
24113
|
+
const patchedContent = removeElementFromHtml2(originalContent, body.target);
|
|
24114
|
+
if (patchedContent === originalContent) {
|
|
24115
|
+
return c2.json({ ok: true, changed: false, content: originalContent });
|
|
24116
|
+
}
|
|
24117
|
+
writeFileSync6(absPath, patchedContent, "utf-8");
|
|
24118
|
+
return c2.json({ ok: true, changed: true, content: patchedContent });
|
|
24119
|
+
});
|
|
24120
|
+
api.patch("/projects/:id/files/*", async (c2) => {
|
|
24121
|
+
const res = await resolveProjectFile(c2, adapter2, { mustExist: true });
|
|
24122
|
+
if ("error" in res) return res.error;
|
|
24123
|
+
const body = await c2.req.json();
|
|
24124
|
+
if (!body.newPath || body.newPath.includes("\0")) {
|
|
24125
|
+
return c2.json({ error: "newPath required" }, 400);
|
|
24126
|
+
}
|
|
24127
|
+
const newAbs = resolve9(res.project.dir, body.newPath);
|
|
24128
|
+
if (!isSafePath(res.project.dir, newAbs)) {
|
|
24129
|
+
return c2.json({ error: "forbidden" }, 403);
|
|
24130
|
+
}
|
|
24131
|
+
if (existsSync9(newAbs)) {
|
|
24132
|
+
return c2.json({ error: "already exists" }, 409);
|
|
24133
|
+
}
|
|
24134
|
+
ensureDir(newAbs);
|
|
24135
|
+
renameSync2(res.absPath, newAbs);
|
|
24136
|
+
const updatedFiles = updateReferences(res.project.dir, res.filePath, body.newPath);
|
|
24137
|
+
return c2.json({ ok: true, path: body.newPath, updatedReferences: updatedFiles });
|
|
24138
|
+
});
|
|
24139
|
+
api.post("/projects/:id/duplicate-file", async (c2) => {
|
|
24140
|
+
const project = await adapter2.resolveProject(c2.req.param("id"));
|
|
24141
|
+
if (!project) return c2.json({ error: "not found" }, 404);
|
|
24142
|
+
const body = await c2.req.json();
|
|
24143
|
+
if (!body.path || body.path.includes("\0")) {
|
|
24144
|
+
return c2.json({ error: "path required" }, 400);
|
|
24145
|
+
}
|
|
24146
|
+
const srcAbs = resolve9(project.dir, body.path);
|
|
24147
|
+
if (!isSafePath(project.dir, srcAbs) || !existsSync9(srcAbs)) {
|
|
24148
|
+
return c2.json({ error: "not found" }, 404);
|
|
24149
|
+
}
|
|
24150
|
+
const copyPath = generateCopyPath(project.dir, body.path);
|
|
24151
|
+
const destAbs = resolve9(project.dir, copyPath);
|
|
24152
|
+
if (!isSafePath(project.dir, destAbs)) {
|
|
24153
|
+
return c2.json({ error: "forbidden" }, 403);
|
|
24154
|
+
}
|
|
24155
|
+
ensureDir(destAbs);
|
|
24156
|
+
writeFileSync6(destAbs, readFileSync9(srcAbs));
|
|
24157
|
+
return c2.json({ ok: true, path: copyPath }, 201);
|
|
24158
|
+
});
|
|
24159
|
+
const MAX_UPLOAD_BYTES = 500 * 1024 * 1024;
|
|
24160
|
+
api.post(
|
|
24161
|
+
"/projects/:id/upload",
|
|
24162
|
+
bodyLimit({
|
|
24163
|
+
maxSize: MAX_UPLOAD_BYTES,
|
|
24164
|
+
onError: (c2) => c2.json({ error: "payload too large" }, 413)
|
|
24165
|
+
}),
|
|
24166
|
+
async (c2) => {
|
|
24167
|
+
const project = await adapter2.resolveProject(c2.req.param("id"));
|
|
24168
|
+
if (!project) return c2.json({ error: "not found" }, 404);
|
|
24169
|
+
const subDir = c2.req.query("dir") ?? "";
|
|
24170
|
+
const targetDir = subDir ? resolve9(project.dir, subDir) : project.dir;
|
|
24171
|
+
if (!isSafePath(project.dir, targetDir)) return c2.json({ error: "forbidden" }, 403);
|
|
24172
|
+
if (subDir && !existsSync9(targetDir)) mkdirSync5(targetDir, { recursive: true });
|
|
24173
|
+
const formData = await c2.req.formData();
|
|
24174
|
+
const uploaded = [];
|
|
24175
|
+
const skipped = [];
|
|
24176
|
+
const invalid = [];
|
|
24177
|
+
for (const [, value] of formData.entries()) {
|
|
24178
|
+
if (!(value instanceof File)) continue;
|
|
24179
|
+
const name = value.name.split("/").pop()?.split("\\").pop() ?? "";
|
|
24180
|
+
if (!name || name.includes("\0") || name.includes("..")) continue;
|
|
24181
|
+
if (value.size > MAX_UPLOAD_BYTES) {
|
|
24182
|
+
skipped.push(name);
|
|
24183
|
+
continue;
|
|
24184
|
+
}
|
|
24185
|
+
const destPath = resolve9(targetDir, name);
|
|
24186
|
+
if (!isSafePath(project.dir, destPath)) continue;
|
|
24187
|
+
let finalPath = destPath;
|
|
24188
|
+
let finalName = name;
|
|
24189
|
+
if (existsSync9(finalPath)) {
|
|
24190
|
+
const dotIdx = name.indexOf(".", name.startsWith(".") ? 1 : 0);
|
|
24191
|
+
const ext = dotIdx > 0 ? name.slice(dotIdx) : "";
|
|
24192
|
+
const base = dotIdx > 0 ? name.slice(0, dotIdx) : name;
|
|
24193
|
+
let n = 2;
|
|
24194
|
+
while (n < 1e4 && existsSync9(resolve9(targetDir, `${base} (${n})${ext}`))) n++;
|
|
24195
|
+
if (n >= 1e4) {
|
|
24196
|
+
skipped.push(name);
|
|
24197
|
+
continue;
|
|
24198
|
+
}
|
|
24199
|
+
finalName = `${base} (${n})${ext}`;
|
|
24200
|
+
finalPath = resolve9(targetDir, finalName);
|
|
24201
|
+
}
|
|
24202
|
+
const buffer = Buffer.from(await value.arrayBuffer());
|
|
24203
|
+
const validation = validateUploadedMediaBuffer(finalName, buffer);
|
|
24204
|
+
if (!validation.ok) {
|
|
24205
|
+
invalid.push({ name: finalName, reason: validation.reason });
|
|
24206
|
+
continue;
|
|
24207
|
+
}
|
|
24208
|
+
writeFileSync6(finalPath, buffer);
|
|
24209
|
+
uploaded.push(subDir ? join12(subDir, finalName) : finalName);
|
|
24210
|
+
}
|
|
24211
|
+
return c2.json({ ok: true, files: uploaded, skipped, invalid }, 201);
|
|
24212
|
+
}
|
|
24213
|
+
);
|
|
24214
|
+
}
|
|
24215
|
+
var init_files = __esm({
|
|
24216
|
+
"../core/src/studio-api/routes/files.ts"() {
|
|
24217
|
+
"use strict";
|
|
24218
|
+
init_mediaValidation();
|
|
24219
|
+
init_safePath();
|
|
24220
|
+
init_sourceMutation();
|
|
24221
|
+
}
|
|
24222
|
+
});
|
|
24223
|
+
|
|
24224
|
+
// ../core/src/studio-api/helpers/mime.ts
|
|
24225
|
+
function getMimeType(path2) {
|
|
24226
|
+
const ext = path2.slice(path2.lastIndexOf(".")).toLowerCase();
|
|
24227
|
+
return MIME_TYPES[ext] || "application/octet-stream";
|
|
24228
|
+
}
|
|
24229
|
+
var MIME_TYPES;
|
|
24230
|
+
var init_mime2 = __esm({
|
|
24231
|
+
"../core/src/studio-api/helpers/mime.ts"() {
|
|
24232
|
+
"use strict";
|
|
24233
|
+
MIME_TYPES = {
|
|
24234
|
+
".html": "text/html",
|
|
24235
|
+
".css": "text/css",
|
|
24236
|
+
".js": "text/javascript",
|
|
24237
|
+
".mjs": "text/javascript",
|
|
24238
|
+
".json": "application/json",
|
|
24239
|
+
".svg": "image/svg+xml",
|
|
24240
|
+
".png": "image/png",
|
|
24241
|
+
".jpg": "image/jpeg",
|
|
24242
|
+
".jpeg": "image/jpeg",
|
|
24243
|
+
".gif": "image/gif",
|
|
24244
|
+
".webp": "image/webp",
|
|
24245
|
+
".ico": "image/x-icon",
|
|
24246
|
+
".mp4": "video/mp4",
|
|
24247
|
+
".mov": "video/quicktime",
|
|
24248
|
+
".webm": "video/webm",
|
|
24249
|
+
".mp3": "audio/mpeg",
|
|
24250
|
+
".wav": "audio/wav",
|
|
24251
|
+
".ogg": "audio/ogg",
|
|
24252
|
+
".m4a": "audio/mp4",
|
|
24253
|
+
".woff": "font/woff",
|
|
24254
|
+
".woff2": "font/woff2",
|
|
24255
|
+
".ttf": "font/ttf",
|
|
24256
|
+
".otf": "font/otf",
|
|
24257
|
+
".txt": "text/plain",
|
|
24258
|
+
".md": "text/markdown"
|
|
24259
|
+
};
|
|
24260
|
+
}
|
|
24261
|
+
});
|
|
24262
|
+
|
|
24127
24263
|
// ../core/src/studio-api/helpers/subComposition.ts
|
|
24128
24264
|
import { existsSync as existsSync10, readFileSync as readFileSync10 } from "fs";
|
|
24129
|
-
import { join as
|
|
24265
|
+
import { join as join13 } from "path";
|
|
24130
24266
|
function buildSubCompositionHtml(projectDir, compPath, runtimeUrl, baseHref) {
|
|
24131
|
-
const compFile =
|
|
24267
|
+
const compFile = join13(projectDir, compPath);
|
|
24132
24268
|
if (!existsSync10(compFile)) return null;
|
|
24133
24269
|
const rawComp = readFileSync10(compFile, "utf-8");
|
|
24134
24270
|
const templateMatch = rawComp.match(/<template[^>]*>([\s\S]*)<\/template>/i);
|
|
@@ -24148,7 +24284,7 @@ function buildSubCompositionHtml(projectDir, compPath, runtimeUrl, baseHref) {
|
|
|
24148
24284
|
styleEl.textContent = rewriteCssAssetUrls(styleEl.textContent || "", compPath);
|
|
24149
24285
|
}
|
|
24150
24286
|
const rewrittenContent = contentDoc.body.innerHTML || content;
|
|
24151
|
-
const indexPath =
|
|
24287
|
+
const indexPath = join13(projectDir, "index.html");
|
|
24152
24288
|
let headContent = "";
|
|
24153
24289
|
if (existsSync10(indexPath)) {
|
|
24154
24290
|
const indexHtml = readFileSync10(indexPath, "utf-8");
|
|
@@ -24278,14 +24414,14 @@ var init_preview = __esm({
|
|
|
24278
24414
|
"../core/src/studio-api/routes/preview.ts"() {
|
|
24279
24415
|
"use strict";
|
|
24280
24416
|
init_safePath();
|
|
24281
|
-
|
|
24417
|
+
init_mime2();
|
|
24282
24418
|
init_subComposition();
|
|
24283
24419
|
}
|
|
24284
24420
|
});
|
|
24285
24421
|
|
|
24286
24422
|
// ../core/src/studio-api/routes/lint.ts
|
|
24287
24423
|
import { readFileSync as readFileSync12 } from "fs";
|
|
24288
|
-
import { join as
|
|
24424
|
+
import { join as join14 } from "path";
|
|
24289
24425
|
function registerLintRoutes(api, adapter2) {
|
|
24290
24426
|
api.get("/projects/:id/lint", async (c2) => {
|
|
24291
24427
|
const project = await adapter2.resolveProject(c2.req.param("id"));
|
|
@@ -24294,7 +24430,7 @@ function registerLintRoutes(api, adapter2) {
|
|
|
24294
24430
|
const htmlFiles = walkDir(project.dir).filter((f3) => f3.endsWith(".html"));
|
|
24295
24431
|
const allFindings = [];
|
|
24296
24432
|
for (const file of htmlFiles) {
|
|
24297
|
-
const content = readFileSync12(
|
|
24433
|
+
const content = readFileSync12(join14(project.dir, file), "utf-8");
|
|
24298
24434
|
const result = await adapter2.lint(content, { filePath: file });
|
|
24299
24435
|
if (result?.findings) {
|
|
24300
24436
|
for (const f3 of result.findings) {
|
|
@@ -24319,7 +24455,7 @@ var init_lint2 = __esm({
|
|
|
24319
24455
|
// ../core/src/studio-api/routes/render.ts
|
|
24320
24456
|
import { streamSSE } from "hono/streaming";
|
|
24321
24457
|
import { existsSync as existsSync12, readFileSync as readFileSync13, mkdirSync as mkdirSync6, unlinkSync as unlinkSync4, readdirSync as readdirSync5, statSync as statSync3 } from "fs";
|
|
24322
|
-
import { join as
|
|
24458
|
+
import { join as join15 } from "path";
|
|
24323
24459
|
function registerRenderRoutes(api, adapter2) {
|
|
24324
24460
|
const renderJobs = /* @__PURE__ */ new Map();
|
|
24325
24461
|
const TTL_MS = 3e5;
|
|
@@ -24358,7 +24494,7 @@ function registerRenderRoutes(api, adapter2) {
|
|
|
24358
24494
|
const rendersDir = adapter2.rendersDir(project);
|
|
24359
24495
|
if (!existsSync12(rendersDir)) mkdirSync6(rendersDir, { recursive: true });
|
|
24360
24496
|
const ext = FORMAT_EXT2[format] ?? ".mp4";
|
|
24361
|
-
const outputPath =
|
|
24497
|
+
const outputPath = join15(rendersDir, `${jobId}${ext}`);
|
|
24362
24498
|
const jobState = adapter2.startRender({
|
|
24363
24499
|
project,
|
|
24364
24500
|
outputPath,
|
|
@@ -24460,7 +24596,7 @@ function registerRenderRoutes(api, adapter2) {
|
|
|
24460
24596
|
if (state.id === jobId && state.outputPath) {
|
|
24461
24597
|
const dir = state.outputPath.replace(/\/[^/]+$/, "");
|
|
24462
24598
|
for (const ext of [".mp4", ".webm", ".mov", ".meta.json"]) {
|
|
24463
|
-
const fp =
|
|
24599
|
+
const fp = join15(dir, `${jobId}${ext}`);
|
|
24464
24600
|
if (existsSync12(fp)) unlinkSync4(fp);
|
|
24465
24601
|
}
|
|
24466
24602
|
break;
|
|
@@ -24475,7 +24611,7 @@ function registerRenderRoutes(api, adapter2) {
|
|
|
24475
24611
|
const filename = c2.req.path.split("/renders/file/")[1];
|
|
24476
24612
|
if (!filename) return c2.json({ error: "missing filename" }, 400);
|
|
24477
24613
|
const rendersDir = adapter2.rendersDir(project);
|
|
24478
|
-
const fp =
|
|
24614
|
+
const fp = join15(rendersDir, filename);
|
|
24479
24615
|
if (!existsSync12(fp)) return c2.json({ error: "not found" }, 404);
|
|
24480
24616
|
const contentType = renderContentType(fp);
|
|
24481
24617
|
const content = readFileSync13(fp);
|
|
@@ -24494,10 +24630,10 @@ function registerRenderRoutes(api, adapter2) {
|
|
|
24494
24630
|
const rendersDir = adapter2.rendersDir(project);
|
|
24495
24631
|
if (!existsSync12(rendersDir)) return c2.json({ renders: [] });
|
|
24496
24632
|
const files = readdirSync5(rendersDir).filter((f3) => f3.endsWith(".mp4") || f3.endsWith(".webm") || f3.endsWith(".mov")).map((f3) => {
|
|
24497
|
-
const fp =
|
|
24633
|
+
const fp = join15(rendersDir, f3);
|
|
24498
24634
|
const stat3 = statSync3(fp);
|
|
24499
24635
|
const rid = f3.replace(/\.(mp4|webm|mov)$/, "");
|
|
24500
|
-
const metaPath =
|
|
24636
|
+
const metaPath = join15(rendersDir, `${rid}.meta.json`);
|
|
24501
24637
|
let status = "complete";
|
|
24502
24638
|
let durationMs;
|
|
24503
24639
|
if (existsSync12(metaPath)) {
|
|
@@ -24523,7 +24659,7 @@ function registerRenderRoutes(api, adapter2) {
|
|
|
24523
24659
|
id: file.id,
|
|
24524
24660
|
status: file.status,
|
|
24525
24661
|
progress: 100,
|
|
24526
|
-
outputPath:
|
|
24662
|
+
outputPath: join15(rendersDir, file.filename),
|
|
24527
24663
|
createdAt: file.createdAt
|
|
24528
24664
|
});
|
|
24529
24665
|
}
|
|
@@ -24538,8 +24674,8 @@ var init_render = __esm({
|
|
|
24538
24674
|
});
|
|
24539
24675
|
|
|
24540
24676
|
// ../core/src/studio-api/routes/thumbnail.ts
|
|
24541
|
-
import { existsSync as existsSync13, readFileSync as readFileSync14, writeFileSync as
|
|
24542
|
-
import { join as
|
|
24677
|
+
import { existsSync as existsSync13, readFileSync as readFileSync14, writeFileSync as writeFileSync7, mkdirSync as mkdirSync7 } from "fs";
|
|
24678
|
+
import { join as join16 } from "path";
|
|
24543
24679
|
function registerThumbnailRoutes(api, adapter2) {
|
|
24544
24680
|
api.get("/projects/:id/thumbnail/*", async (c2) => {
|
|
24545
24681
|
if (!adapter2.generateThumbnail) {
|
|
@@ -24559,7 +24695,7 @@ function registerThumbnailRoutes(api, adapter2) {
|
|
|
24559
24695
|
let compW = vpWidth || 1920;
|
|
24560
24696
|
let compH = vpHeight || 1080;
|
|
24561
24697
|
if (!vpWidth) {
|
|
24562
|
-
const htmlFile =
|
|
24698
|
+
const htmlFile = join16(project.dir, compPath);
|
|
24563
24699
|
if (existsSync13(htmlFile)) {
|
|
24564
24700
|
const html = readFileSync14(htmlFile, "utf-8");
|
|
24565
24701
|
const wMatch = html.match(/data-width=["'](\d+)["']/);
|
|
@@ -24569,10 +24705,10 @@ function registerThumbnailRoutes(api, adapter2) {
|
|
|
24569
24705
|
}
|
|
24570
24706
|
}
|
|
24571
24707
|
const previewUrl = compPath === "index.html" ? `http://${c2.req.header("host")}/api/projects/${project.id}/preview` : `http://${c2.req.header("host")}/api/projects/${project.id}/preview/comp/${compPath}`;
|
|
24572
|
-
const cacheDir =
|
|
24708
|
+
const cacheDir = join16(project.dir, ".thumbnails");
|
|
24573
24709
|
const selectorKey = selector ? `_${selector.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 80)}` : "";
|
|
24574
24710
|
const cacheKey = `${THUMBNAIL_CACHE_VERSION}_${compPath.replace(/\//g, "_")}_${seekTime.toFixed(2)}${selectorKey}.jpg`;
|
|
24575
|
-
const cachePath2 =
|
|
24711
|
+
const cachePath2 = join16(cacheDir, cacheKey);
|
|
24576
24712
|
if (existsSync13(cachePath2)) {
|
|
24577
24713
|
return new Response(new Uint8Array(readFileSync14(cachePath2)), {
|
|
24578
24714
|
headers: { "Content-Type": "image/jpeg", "Cache-Control": "public, max-age=60" }
|
|
@@ -24592,7 +24728,7 @@ function registerThumbnailRoutes(api, adapter2) {
|
|
|
24592
24728
|
return c2.json({ error: "Thumbnail generation returned null" }, 500);
|
|
24593
24729
|
}
|
|
24594
24730
|
if (!existsSync13(cacheDir)) mkdirSync7(cacheDir, { recursive: true });
|
|
24595
|
-
|
|
24731
|
+
writeFileSync7(cachePath2, buffer);
|
|
24596
24732
|
return new Response(new Uint8Array(buffer), {
|
|
24597
24733
|
headers: { "Content-Type": "image/jpeg", "Cache-Control": "public, max-age=60" }
|
|
24598
24734
|
});
|
|
@@ -24649,7 +24785,7 @@ var init_studio_api = __esm({
|
|
|
24649
24785
|
"use strict";
|
|
24650
24786
|
init_createStudioApi();
|
|
24651
24787
|
init_safePath();
|
|
24652
|
-
|
|
24788
|
+
init_mime2();
|
|
24653
24789
|
init_subComposition();
|
|
24654
24790
|
}
|
|
24655
24791
|
});
|
|
@@ -24665,9 +24801,9 @@ __export(manager_exports2, {
|
|
|
24665
24801
|
setBrowserPath: () => setBrowserPath
|
|
24666
24802
|
});
|
|
24667
24803
|
import { execSync } from "child_process";
|
|
24668
|
-
import { existsSync as existsSync14, rmSync as
|
|
24804
|
+
import { existsSync as existsSync14, rmSync as rmSync4 } from "fs";
|
|
24669
24805
|
import { homedir as homedir4 } from "os";
|
|
24670
|
-
import { join as
|
|
24806
|
+
import { join as join17 } from "path";
|
|
24671
24807
|
import { Browser, detectBrowserPlatform, getInstalledBrowsers, install } from "@puppeteer/browsers";
|
|
24672
24808
|
function setBrowserPath(path2) {
|
|
24673
24809
|
_browserPathOverride = path2;
|
|
@@ -24746,7 +24882,7 @@ function clearBrowser() {
|
|
|
24746
24882
|
if (!existsSync14(CACHE_DIR2)) {
|
|
24747
24883
|
return false;
|
|
24748
24884
|
}
|
|
24749
|
-
|
|
24885
|
+
rmSync4(CACHE_DIR2, { recursive: true, force: true });
|
|
24750
24886
|
return true;
|
|
24751
24887
|
}
|
|
24752
24888
|
var CHROME_VERSION, CACHE_DIR2, _browserPathOverride, SYSTEM_CHROME_PATHS;
|
|
@@ -24754,7 +24890,7 @@ var init_manager2 = __esm({
|
|
|
24754
24890
|
"src/browser/manager.ts"() {
|
|
24755
24891
|
"use strict";
|
|
24756
24892
|
CHROME_VERSION = "131.0.6778.85";
|
|
24757
|
-
CACHE_DIR2 =
|
|
24893
|
+
CACHE_DIR2 = join17(homedir4(), ".cache", "hyperframes", "chrome");
|
|
24758
24894
|
SYSTEM_CHROME_PATHS = process.platform === "darwin" ? ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"] : [
|
|
24759
24895
|
"/usr/bin/google-chrome",
|
|
24760
24896
|
"/usr/bin/google-chrome-stable",
|
|
@@ -24881,7 +25017,7 @@ var init_config2 = __esm({
|
|
|
24881
25017
|
|
|
24882
25018
|
// ../engine/src/services/browserManager.ts
|
|
24883
25019
|
import { existsSync as existsSync15, readdirSync as readdirSync6 } from "fs";
|
|
24884
|
-
import { join as
|
|
25020
|
+
import { join as join18 } from "path";
|
|
24885
25021
|
import { homedir as homedir5 } from "os";
|
|
24886
25022
|
async function getPuppeteer() {
|
|
24887
25023
|
if (_puppeteer) return _puppeteer;
|
|
@@ -24902,16 +25038,16 @@ function resolveHeadlessShellPath(config) {
|
|
|
24902
25038
|
if (process.env.PRODUCER_HEADLESS_SHELL_PATH) {
|
|
24903
25039
|
return process.env.PRODUCER_HEADLESS_SHELL_PATH;
|
|
24904
25040
|
}
|
|
24905
|
-
const baseDir =
|
|
25041
|
+
const baseDir = join18(homedir5(), ".cache", "puppeteer", "chrome-headless-shell");
|
|
24906
25042
|
if (!existsSync15(baseDir)) return void 0;
|
|
24907
25043
|
try {
|
|
24908
25044
|
const versions = readdirSync6(baseDir).sort().reverse();
|
|
24909
25045
|
for (const version of versions) {
|
|
24910
25046
|
const candidates = [
|
|
24911
|
-
|
|
24912
|
-
|
|
24913
|
-
|
|
24914
|
-
|
|
25047
|
+
join18(baseDir, version, "chrome-headless-shell-linux64", "chrome-headless-shell"),
|
|
25048
|
+
join18(baseDir, version, "chrome-headless-shell-mac-arm64", "chrome-headless-shell"),
|
|
25049
|
+
join18(baseDir, version, "chrome-headless-shell-mac-x64", "chrome-headless-shell"),
|
|
25050
|
+
join18(baseDir, version, "chrome-headless-shell-win64", "chrome-headless-shell.exe")
|
|
24915
25051
|
];
|
|
24916
25052
|
for (const binary of candidates) {
|
|
24917
25053
|
if (existsSync15(binary)) return binary;
|
|
@@ -25377,8 +25513,8 @@ var init_screenshotService = __esm({
|
|
|
25377
25513
|
});
|
|
25378
25514
|
|
|
25379
25515
|
// ../engine/src/services/frameCapture.ts
|
|
25380
|
-
import { existsSync as existsSync16, mkdirSync as mkdirSync8, writeFileSync as
|
|
25381
|
-
import { join as
|
|
25516
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync8, writeFileSync as writeFileSync8 } from "fs";
|
|
25517
|
+
import { join as join19 } from "path";
|
|
25382
25518
|
async function createCaptureSession(serverUrl, outputDir, options, onBeforeCapture = null, config) {
|
|
25383
25519
|
if (!existsSync16(outputDir)) mkdirSync8(outputDir, { recursive: true });
|
|
25384
25520
|
const headlessShell = resolveHeadlessShellPath(config);
|
|
@@ -25580,13 +25716,13 @@ async function initializeSession(session) {
|
|
|
25580
25716
|
}
|
|
25581
25717
|
async function captureFrameErrorDiagnostics(session, frameIndex, time, error) {
|
|
25582
25718
|
try {
|
|
25583
|
-
const diagnosticsDir =
|
|
25719
|
+
const diagnosticsDir = join19(session.outputDir, "diagnostics");
|
|
25584
25720
|
if (!existsSync16(diagnosticsDir)) mkdirSync8(diagnosticsDir, { recursive: true });
|
|
25585
|
-
const base =
|
|
25721
|
+
const base = join19(diagnosticsDir, `frame-error-${frameIndex}`);
|
|
25586
25722
|
await session.page.screenshot({ path: `${base}.png`, type: "png", fullPage: true });
|
|
25587
25723
|
const html = await session.page.content();
|
|
25588
|
-
|
|
25589
|
-
|
|
25724
|
+
writeFileSync8(`${base}.html`, html, "utf-8");
|
|
25725
|
+
writeFileSync8(
|
|
25590
25726
|
`${base}.json`,
|
|
25591
25727
|
JSON.stringify(
|
|
25592
25728
|
{
|
|
@@ -25680,8 +25816,8 @@ async function captureFrame(session, frameIndex, time) {
|
|
|
25680
25816
|
);
|
|
25681
25817
|
const ext = options.format === "png" ? "png" : "jpg";
|
|
25682
25818
|
const frameName = `frame_${String(frameIndex).padStart(6, "0")}.${ext}`;
|
|
25683
|
-
const framePath =
|
|
25684
|
-
|
|
25819
|
+
const framePath = join19(outputDir, frameName);
|
|
25820
|
+
writeFileSync8(framePath, buffer);
|
|
25685
25821
|
return { frameIndex, time: quantizedTime, path: framePath, captureTimeMs };
|
|
25686
25822
|
}
|
|
25687
25823
|
async function captureFrameToBuffer(session, frameIndex, time) {
|
|
@@ -25939,8 +26075,8 @@ var init_runFfmpeg = __esm({
|
|
|
25939
26075
|
|
|
25940
26076
|
// ../engine/src/services/chunkEncoder.ts
|
|
25941
26077
|
import { spawn as spawn4 } from "child_process";
|
|
25942
|
-
import { copyFileSync, existsSync as existsSync17, mkdirSync as mkdirSync9, readdirSync as readdirSync7, statSync as statSync4, writeFileSync as
|
|
25943
|
-
import { join as
|
|
26078
|
+
import { copyFileSync, existsSync as existsSync17, mkdirSync as mkdirSync9, readdirSync as readdirSync7, statSync as statSync4, writeFileSync as writeFileSync9 } from "fs";
|
|
26079
|
+
import { join as join20, dirname as dirname6 } from "path";
|
|
25944
26080
|
function getEncoderPreset(quality, format = "mp4", hdr) {
|
|
25945
26081
|
const base = ENCODER_PRESETS[quality];
|
|
25946
26082
|
if (format === "webm") {
|
|
@@ -26108,7 +26244,7 @@ async function encodeFramesFromDir(framesDir, framePattern, outputPath, options,
|
|
|
26108
26244
|
if (options.useGpu) {
|
|
26109
26245
|
gpuEncoder = await getCachedGpuEncoder();
|
|
26110
26246
|
}
|
|
26111
|
-
const inputPath =
|
|
26247
|
+
const inputPath = join20(framesDir, framePattern);
|
|
26112
26248
|
const inputArgs = ["-framerate", String(options.fps), "-i", inputPath];
|
|
26113
26249
|
const args = buildEncoderArgs(options, inputArgs, outputPath, gpuEncoder);
|
|
26114
26250
|
return new Promise((resolve38) => {
|
|
@@ -26189,7 +26325,7 @@ async function encodeFramesChunkedConcat(framesDir, framePattern, outputPath, op
|
|
|
26189
26325
|
}
|
|
26190
26326
|
const chunkSize = Math.max(30, Math.floor(chunkSizeFrames));
|
|
26191
26327
|
const chunkCount = Math.ceil(files.length / chunkSize);
|
|
26192
|
-
const chunkDir =
|
|
26328
|
+
const chunkDir = join20(dirname6(outputPath), "chunk-encode");
|
|
26193
26329
|
if (!existsSync17(chunkDir)) mkdirSync9(chunkDir, { recursive: true });
|
|
26194
26330
|
const chunkPaths = [];
|
|
26195
26331
|
for (let i2 = 0; i2 < chunkCount; i2++) {
|
|
@@ -26206,8 +26342,8 @@ async function encodeFramesChunkedConcat(framesDir, framePattern, outputPath, op
|
|
|
26206
26342
|
const startNumber = i2 * chunkSize;
|
|
26207
26343
|
const framesInChunk = Math.min(chunkSize, files.length - startNumber);
|
|
26208
26344
|
const ext = outputPath.endsWith(".webm") ? ".webm" : outputPath.endsWith(".mov") ? ".mov" : ".mp4";
|
|
26209
|
-
const chunkPath =
|
|
26210
|
-
const inputPath =
|
|
26345
|
+
const chunkPath = join20(chunkDir, `chunk_${String(i2).padStart(4, "0")}${ext}`);
|
|
26346
|
+
const inputPath = join20(framesDir, framePattern);
|
|
26211
26347
|
const inputArgs = [
|
|
26212
26348
|
"-framerate",
|
|
26213
26349
|
String(options.fps),
|
|
@@ -26247,9 +26383,9 @@ async function encodeFramesChunkedConcat(framesDir, framePattern, outputPath, op
|
|
|
26247
26383
|
}
|
|
26248
26384
|
chunkPaths.push(chunkPath);
|
|
26249
26385
|
}
|
|
26250
|
-
const concatListPath =
|
|
26386
|
+
const concatListPath = join20(chunkDir, "concat-list.txt");
|
|
26251
26387
|
const concatInput = chunkPaths.map((path2) => `file '${path2.replace(/'/g, "'\\''")}'`).join("\n");
|
|
26252
|
-
|
|
26388
|
+
writeFileSync9(concatListPath, concatInput, "utf-8");
|
|
26253
26389
|
const concatArgs = [
|
|
26254
26390
|
"-f",
|
|
26255
26391
|
"concat",
|
|
@@ -26922,7 +27058,7 @@ var init_ffprobe = __esm({
|
|
|
26922
27058
|
// ../engine/src/utils/urlDownloader.ts
|
|
26923
27059
|
import { createWriteStream as createWriteStream2, existsSync as existsSync19, mkdirSync as mkdirSync11 } from "fs";
|
|
26924
27060
|
import { createHash } from "crypto";
|
|
26925
|
-
import { join as
|
|
27061
|
+
import { join as join21, extname as extname5 } from "path";
|
|
26926
27062
|
import { Readable } from "stream";
|
|
26927
27063
|
import { finished } from "stream/promises";
|
|
26928
27064
|
function getFilenameFromUrl(url) {
|
|
@@ -26944,7 +27080,7 @@ async function downloadToTemp(url, destDir, timeoutMs = 3e5) {
|
|
|
26944
27080
|
mkdirSync11(destDir, { recursive: true });
|
|
26945
27081
|
}
|
|
26946
27082
|
const filename = getFilenameFromUrl(url);
|
|
26947
|
-
const localPath =
|
|
27083
|
+
const localPath = join21(destDir, filename);
|
|
26948
27084
|
if (existsSync19(localPath)) {
|
|
26949
27085
|
downloadPathCache.set(url, localPath);
|
|
26950
27086
|
return localPath;
|
|
@@ -26993,8 +27129,8 @@ var init_urlDownloader = __esm({
|
|
|
26993
27129
|
|
|
26994
27130
|
// ../engine/src/services/videoFrameExtractor.ts
|
|
26995
27131
|
import { spawn as spawn7 } from "child_process";
|
|
26996
|
-
import { existsSync as existsSync20, mkdirSync as mkdirSync12, readdirSync as readdirSync8, rmSync as
|
|
26997
|
-
import { isAbsolute as isAbsolute2, join as
|
|
27132
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync12, readdirSync as readdirSync8, rmSync as rmSync5 } from "fs";
|
|
27133
|
+
import { isAbsolute as isAbsolute2, join as join22 } from "path";
|
|
26998
27134
|
function parseVideoElements(html) {
|
|
26999
27135
|
const videos = [];
|
|
27000
27136
|
const { document: document2 } = parseHTML(html);
|
|
@@ -27063,11 +27199,11 @@ function parseImageElements(html) {
|
|
|
27063
27199
|
async function extractVideoFramesRange(videoPath, videoId, startTime, duration, options, signal, config) {
|
|
27064
27200
|
const ffmpegProcessTimeout = config?.ffmpegProcessTimeout ?? DEFAULT_CONFIG2.ffmpegProcessTimeout;
|
|
27065
27201
|
const { fps, outputDir, quality = 95, format = "jpg" } = options;
|
|
27066
|
-
const videoOutputDir =
|
|
27202
|
+
const videoOutputDir = join22(outputDir, videoId);
|
|
27067
27203
|
if (!existsSync20(videoOutputDir)) mkdirSync12(videoOutputDir, { recursive: true });
|
|
27068
27204
|
const metadata = await extractMediaMetadata(videoPath);
|
|
27069
27205
|
const framePattern = `frame_%05d.${format}`;
|
|
27070
|
-
const outputPattern =
|
|
27206
|
+
const outputPattern = join22(videoOutputDir, framePattern);
|
|
27071
27207
|
const isHdr = isHdrColorSpace(metadata.colorSpace);
|
|
27072
27208
|
const isMacOS = process.platform === "darwin";
|
|
27073
27209
|
const args = [];
|
|
@@ -27117,7 +27253,7 @@ async function extractVideoFramesRange(videoPath, videoId, startTime, duration,
|
|
|
27117
27253
|
const framePaths = /* @__PURE__ */ new Map();
|
|
27118
27254
|
const files = readdirSync8(videoOutputDir).filter((f3) => f3.startsWith("frame_") && f3.endsWith(`.${format}`)).sort();
|
|
27119
27255
|
files.forEach((file, index) => {
|
|
27120
|
-
framePaths.set(index,
|
|
27256
|
+
framePaths.set(index, join22(videoOutputDir, file));
|
|
27121
27257
|
});
|
|
27122
27258
|
resolve38({
|
|
27123
27259
|
videoId,
|
|
@@ -27215,11 +27351,11 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
|
|
|
27215
27351
|
try {
|
|
27216
27352
|
let videoPath = video.src;
|
|
27217
27353
|
if (!isAbsolute2(videoPath) && !isHttpUrl(videoPath)) {
|
|
27218
|
-
const fromCompiled = compiledDir ?
|
|
27219
|
-
videoPath = fromCompiled && existsSync20(fromCompiled) ? fromCompiled :
|
|
27354
|
+
const fromCompiled = compiledDir ? join22(compiledDir, videoPath) : null;
|
|
27355
|
+
videoPath = fromCompiled && existsSync20(fromCompiled) ? fromCompiled : join22(baseDir, videoPath);
|
|
27220
27356
|
}
|
|
27221
27357
|
if (isHttpUrl(videoPath)) {
|
|
27222
|
-
const downloadDir =
|
|
27358
|
+
const downloadDir = join22(options.outputDir, "_downloads");
|
|
27223
27359
|
mkdirSync12(downloadDir, { recursive: true });
|
|
27224
27360
|
videoPath = await downloadToTemp(videoPath, downloadDir);
|
|
27225
27361
|
}
|
|
@@ -27241,7 +27377,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
|
|
|
27241
27377
|
const hdrInfo = analyzeCompositionHdr(videoColorSpaces);
|
|
27242
27378
|
if (hdrInfo.hasHdr && hdrInfo.dominantTransfer) {
|
|
27243
27379
|
const targetTransfer = hdrInfo.dominantTransfer;
|
|
27244
|
-
const convertDir =
|
|
27380
|
+
const convertDir = join22(options.outputDir, "_hdr_normalized");
|
|
27245
27381
|
mkdirSync12(convertDir, { recursive: true });
|
|
27246
27382
|
for (let i2 = 0; i2 < resolvedVideos.length; i2++) {
|
|
27247
27383
|
if (signal?.aborted) break;
|
|
@@ -27249,7 +27385,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
|
|
|
27249
27385
|
if (!isHdrColorSpace(cs)) {
|
|
27250
27386
|
const entry = resolvedVideos[i2];
|
|
27251
27387
|
if (!entry) continue;
|
|
27252
|
-
const convertedPath =
|
|
27388
|
+
const convertedPath = join22(convertDir, `${entry.video.id}_hdr.mp4`);
|
|
27253
27389
|
try {
|
|
27254
27390
|
await convertSdrToHdr(entry.videoPath, convertedPath, targetTransfer, signal, config);
|
|
27255
27391
|
entry.videoPath = convertedPath;
|
|
@@ -27262,7 +27398,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
|
|
|
27262
27398
|
}
|
|
27263
27399
|
}
|
|
27264
27400
|
}
|
|
27265
|
-
const vfrNormDir =
|
|
27401
|
+
const vfrNormDir = join22(options.outputDir, "_vfr_normalized");
|
|
27266
27402
|
for (let i2 = 0; i2 < resolvedVideos.length; i2++) {
|
|
27267
27403
|
if (signal?.aborted) break;
|
|
27268
27404
|
const entry = resolvedVideos[i2];
|
|
@@ -27275,7 +27411,7 @@ async function extractAllVideoFrames(videos, baseDir, options, signal, config, c
|
|
|
27275
27411
|
segDuration = sourceRemaining > 0 ? sourceRemaining : metadata.durationSeconds;
|
|
27276
27412
|
}
|
|
27277
27413
|
mkdirSync12(vfrNormDir, { recursive: true });
|
|
27278
|
-
const normalizedPath =
|
|
27414
|
+
const normalizedPath = join22(vfrNormDir, `${entry.video.id}_cfr.mp4`);
|
|
27279
27415
|
try {
|
|
27280
27416
|
await convertVfrToCfr(
|
|
27281
27417
|
entry.videoPath,
|
|
@@ -27455,7 +27591,7 @@ var init_videoFrameExtractor = __esm({
|
|
|
27455
27591
|
cleanup() {
|
|
27456
27592
|
for (const video of this.videos.values()) {
|
|
27457
27593
|
if (existsSync20(video.extracted.outputDir)) {
|
|
27458
|
-
|
|
27594
|
+
rmSync5(video.extracted.outputDir, { recursive: true, force: true });
|
|
27459
27595
|
}
|
|
27460
27596
|
}
|
|
27461
27597
|
this.videos.clear();
|
|
@@ -27762,8 +27898,8 @@ var init_videoFrameInjector = __esm({
|
|
|
27762
27898
|
});
|
|
27763
27899
|
|
|
27764
27900
|
// ../engine/src/services/audioMixer.ts
|
|
27765
|
-
import { existsSync as existsSync21, mkdirSync as mkdirSync13, rmSync as
|
|
27766
|
-
import { isAbsolute as isAbsolute3, join as
|
|
27901
|
+
import { existsSync as existsSync21, mkdirSync as mkdirSync13, rmSync as rmSync6 } from "fs";
|
|
27902
|
+
import { isAbsolute as isAbsolute3, join as join23, dirname as dirname8 } from "path";
|
|
27767
27903
|
function parseAudioElements(html) {
|
|
27768
27904
|
const elements = [];
|
|
27769
27905
|
const { document: document2 } = parseHTML(html);
|
|
@@ -27991,8 +28127,8 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
|
|
|
27991
28127
|
try {
|
|
27992
28128
|
let srcPath = element.src;
|
|
27993
28129
|
if (!isAbsolute3(srcPath) && !isHttpUrl(srcPath)) {
|
|
27994
|
-
const fromCompiled = compiledDir ?
|
|
27995
|
-
srcPath = fromCompiled && existsSync21(fromCompiled) ? fromCompiled :
|
|
28130
|
+
const fromCompiled = compiledDir ? join23(compiledDir, srcPath) : null;
|
|
28131
|
+
srcPath = fromCompiled && existsSync21(fromCompiled) ? fromCompiled : join23(baseDir, srcPath);
|
|
27996
28132
|
}
|
|
27997
28133
|
if (isHttpUrl(srcPath)) {
|
|
27998
28134
|
try {
|
|
@@ -28015,7 +28151,7 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
|
|
|
28015
28151
|
}
|
|
28016
28152
|
let audioSrcPath = srcPath;
|
|
28017
28153
|
if (element.type === "video") {
|
|
28018
|
-
const extractedPath =
|
|
28154
|
+
const extractedPath = join23(workDir, `${element.id}-extracted.wav`);
|
|
28019
28155
|
const extractResult = await extractAudioFromVideo(
|
|
28020
28156
|
srcPath,
|
|
28021
28157
|
extractedPath,
|
|
@@ -28032,7 +28168,7 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
|
|
|
28032
28168
|
}
|
|
28033
28169
|
audioSrcPath = extractedPath;
|
|
28034
28170
|
} else {
|
|
28035
|
-
const trimmedPath =
|
|
28171
|
+
const trimmedPath = join23(workDir, `${element.id}-trimmed.wav`);
|
|
28036
28172
|
const prepResult = await prepareAudioTrack(
|
|
28037
28173
|
srcPath,
|
|
28038
28174
|
trimmedPath,
|
|
@@ -28063,7 +28199,7 @@ async function processCompositionAudio(elements, baseDir, workDir, outputPath, t
|
|
|
28063
28199
|
);
|
|
28064
28200
|
const mixResult = await mixAudioTracks(tracks, outputPath, totalDuration, signal, config);
|
|
28065
28201
|
try {
|
|
28066
|
-
|
|
28202
|
+
rmSync6(workDir, { recursive: true, force: true });
|
|
28067
28203
|
} catch {
|
|
28068
28204
|
}
|
|
28069
28205
|
return {
|
|
@@ -28087,7 +28223,7 @@ var init_audioMixer = __esm({
|
|
|
28087
28223
|
import { cpus as cpus2, freemem, totalmem as totalmem2 } from "os";
|
|
28088
28224
|
import { existsSync as existsSync22, mkdirSync as mkdirSync14, readdirSync as readdirSync9 } from "fs";
|
|
28089
28225
|
import { copyFile, rename } from "fs/promises";
|
|
28090
|
-
import { join as
|
|
28226
|
+
import { join as join24 } from "path";
|
|
28091
28227
|
function calculateOptimalWorkers(totalFrames, requested, config) {
|
|
28092
28228
|
const effectiveMaxWorkers = (() => {
|
|
28093
28229
|
const concurrency = config?.concurrency ?? DEFAULT_CONFIG2.concurrency;
|
|
@@ -28130,7 +28266,7 @@ function distributeFrames(totalFrames, workerCount, workDir) {
|
|
|
28130
28266
|
workerId: i2,
|
|
28131
28267
|
startFrame,
|
|
28132
28268
|
endFrame,
|
|
28133
|
-
outputDir:
|
|
28269
|
+
outputDir: join24(workDir, `worker-${i2}`)
|
|
28134
28270
|
});
|
|
28135
28271
|
}
|
|
28136
28272
|
return tasks;
|
|
@@ -28237,8 +28373,8 @@ async function mergeWorkerFrames(workDir, tasks, outputDir) {
|
|
|
28237
28373
|
}
|
|
28238
28374
|
const files = readdirSync9(task.outputDir).filter((f3) => f3.startsWith("frame_") && (f3.endsWith(".jpg") || f3.endsWith(".png"))).sort();
|
|
28239
28375
|
const copyTasks = files.map(async (file) => {
|
|
28240
|
-
const sourcePath =
|
|
28241
|
-
const targetPath =
|
|
28376
|
+
const sourcePath = join24(task.outputDir, file);
|
|
28377
|
+
const targetPath = join24(outputDir, file);
|
|
28242
28378
|
try {
|
|
28243
28379
|
await rename(sourcePath, targetPath);
|
|
28244
28380
|
} catch {
|
|
@@ -28276,7 +28412,7 @@ var init_parallelCoordinator = __esm({
|
|
|
28276
28412
|
import { Hono as Hono2 } from "hono";
|
|
28277
28413
|
import { serve } from "@hono/node-server";
|
|
28278
28414
|
import { readFileSync as readFileSync16, existsSync as existsSync23, statSync as statSync6 } from "fs";
|
|
28279
|
-
import { join as
|
|
28415
|
+
import { join as join25, extname as extname6 } from "path";
|
|
28280
28416
|
function stripEmbeddedRuntimeScripts(html) {
|
|
28281
28417
|
if (!html) return html;
|
|
28282
28418
|
const scriptRe = /<script\b[^>]*>[\s\S]*?<\/script>/gi;
|
|
@@ -28345,11 +28481,11 @@ function createFileServer(options) {
|
|
|
28345
28481
|
let requestPath = c2.req.path;
|
|
28346
28482
|
if (requestPath === "/") requestPath = "/index.html";
|
|
28347
28483
|
const relativePath = requestPath.replace(/^\//, "");
|
|
28348
|
-
const compiledPath = compiledDir ?
|
|
28484
|
+
const compiledPath = compiledDir ? join25(compiledDir, relativePath) : null;
|
|
28349
28485
|
const hasCompiledFile = Boolean(
|
|
28350
28486
|
compiledPath && existsSync23(compiledPath) && statSync6(compiledPath).isFile()
|
|
28351
28487
|
);
|
|
28352
|
-
const filePath = hasCompiledFile ? compiledPath :
|
|
28488
|
+
const filePath = hasCompiledFile ? compiledPath : join25(projectDir, relativePath);
|
|
28353
28489
|
if (!existsSync23(filePath) || !statSync6(filePath).isFile()) {
|
|
28354
28490
|
return c2.text("Not found", 404);
|
|
28355
28491
|
}
|
|
@@ -29629,7 +29765,7 @@ var init_shaderTransitions = __esm({
|
|
|
29629
29765
|
|
|
29630
29766
|
// ../engine/src/services/hdrCapture.ts
|
|
29631
29767
|
import { existsSync as existsSync24, readdirSync as readdirSync10 } from "fs";
|
|
29632
|
-
import { join as
|
|
29768
|
+
import { join as join26 } from "path";
|
|
29633
29769
|
import { homedir as homedir6 } from "os";
|
|
29634
29770
|
function linearToPQ(L2) {
|
|
29635
29771
|
const Lp = Math.max(0, L2 * SDR_NITS / PQ_MAX_NITS);
|
|
@@ -29745,12 +29881,12 @@ function float16ToPqRgb(rawBuffer, bytesPerRow, width, height) {
|
|
|
29745
29881
|
return output;
|
|
29746
29882
|
}
|
|
29747
29883
|
function resolveHeadedChromePath() {
|
|
29748
|
-
const baseDir =
|
|
29884
|
+
const baseDir = join26(homedir6(), ".cache", "puppeteer", "chrome");
|
|
29749
29885
|
if (!existsSync24(baseDir)) return void 0;
|
|
29750
29886
|
const versions = readdirSync10(baseDir).sort().reverse();
|
|
29751
29887
|
for (const version of versions) {
|
|
29752
29888
|
const candidates = [
|
|
29753
|
-
|
|
29889
|
+
join26(
|
|
29754
29890
|
baseDir,
|
|
29755
29891
|
version,
|
|
29756
29892
|
"chrome-mac-arm64",
|
|
@@ -29759,7 +29895,7 @@ function resolveHeadedChromePath() {
|
|
|
29759
29895
|
"MacOS",
|
|
29760
29896
|
"Google Chrome for Testing"
|
|
29761
29897
|
),
|
|
29762
|
-
|
|
29898
|
+
join26(
|
|
29763
29899
|
baseDir,
|
|
29764
29900
|
version,
|
|
29765
29901
|
"chrome-mac-x64",
|
|
@@ -29768,8 +29904,8 @@ function resolveHeadedChromePath() {
|
|
|
29768
29904
|
"MacOS",
|
|
29769
29905
|
"Google Chrome for Testing"
|
|
29770
29906
|
),
|
|
29771
|
-
|
|
29772
|
-
|
|
29907
|
+
join26(baseDir, version, "chrome-linux64", "chrome"),
|
|
29908
|
+
join26(baseDir, version, "chrome-win64", "chrome.exe")
|
|
29773
29909
|
];
|
|
29774
29910
|
for (const binary of candidates) {
|
|
29775
29911
|
if (existsSync24(binary)) return binary;
|
|
@@ -30044,7 +30180,7 @@ var init_staticGuard = __esm({
|
|
|
30044
30180
|
|
|
30045
30181
|
// ../core/src/compiler/htmlBundler.ts
|
|
30046
30182
|
import { readFileSync as readFileSync17, existsSync as existsSync25 } from "fs";
|
|
30047
|
-
import { join as
|
|
30183
|
+
import { join as join27, resolve as resolve12, isAbsolute as isAbsolute4, sep as sep2 } from "path";
|
|
30048
30184
|
import { transformSync } from "esbuild";
|
|
30049
30185
|
function parseHTMLContent(html) {
|
|
30050
30186
|
const trimmed = html.trimStart().toLowerCase();
|
|
@@ -30313,7 +30449,7 @@ function stripJsCommentsParserSafe(source) {
|
|
|
30313
30449
|
}
|
|
30314
30450
|
}
|
|
30315
30451
|
async function bundleToSingleHtml(projectDir, options) {
|
|
30316
|
-
const indexPath =
|
|
30452
|
+
const indexPath = join27(projectDir, "index.html");
|
|
30317
30453
|
if (!existsSync25(indexPath)) throw new Error("index.html not found in project directory");
|
|
30318
30454
|
const rawHtml = readFileSync17(indexPath, "utf-8");
|
|
30319
30455
|
const compiled = await compileHtml(rawHtml, projectDir, options?.probeMediaDuration);
|
|
@@ -30671,7 +30807,7 @@ var init_hyperframeRuntimeLoader = __esm({
|
|
|
30671
30807
|
import { Hono as Hono3 } from "hono";
|
|
30672
30808
|
import { serve as serve2 } from "@hono/node-server";
|
|
30673
30809
|
import { readFileSync as readFileSync19, existsSync as existsSync27, realpathSync, statSync as statSync7 } from "fs";
|
|
30674
|
-
import { join as
|
|
30810
|
+
import { join as join28, extname as extname7, resolve as resolve14, sep as sep3 } from "path";
|
|
30675
30811
|
function isPathInside(child, parent, options = {}) {
|
|
30676
30812
|
const { resolveSymlinks = false, pathModule } = options;
|
|
30677
30813
|
const resolveFn = pathModule?.resolve ?? resolve14;
|
|
@@ -30768,13 +30904,13 @@ function createFileServer2(options) {
|
|
|
30768
30904
|
const relativePath = requestPath.replace(/^\//, "");
|
|
30769
30905
|
let filePath = null;
|
|
30770
30906
|
if (compiledDir) {
|
|
30771
|
-
const candidate =
|
|
30907
|
+
const candidate = join28(compiledDir, relativePath);
|
|
30772
30908
|
if (existsSync27(candidate) && isPathInside(candidate, compiledDir, { resolveSymlinks: true }) && statSync7(candidate).isFile()) {
|
|
30773
30909
|
filePath = candidate;
|
|
30774
30910
|
}
|
|
30775
30911
|
}
|
|
30776
30912
|
if (!filePath) {
|
|
30777
|
-
const candidate =
|
|
30913
|
+
const candidate = join28(projectDir, relativePath);
|
|
30778
30914
|
if (existsSync27(candidate) && isPathInside(candidate, projectDir, { resolveSymlinks: true }) && statSync7(candidate).isFile()) {
|
|
30779
30915
|
filePath = candidate;
|
|
30780
30916
|
}
|
|
@@ -31149,7 +31285,7 @@ var init_ffprobe2 = __esm({
|
|
|
31149
31285
|
});
|
|
31150
31286
|
|
|
31151
31287
|
// ../producer/src/utils/paths.ts
|
|
31152
|
-
import { resolve as resolve15, basename, join as
|
|
31288
|
+
import { resolve as resolve15, basename as basename2, join as join29, relative as relative2, isAbsolute as isAbsolute5 } from "path";
|
|
31153
31289
|
function isPathInside2(childPath, parentPath) {
|
|
31154
31290
|
const absChild = resolve15(childPath);
|
|
31155
31291
|
const absParent = resolve15(parentPath);
|
|
@@ -31169,8 +31305,8 @@ function toExternalAssetKey(absPath) {
|
|
|
31169
31305
|
}
|
|
31170
31306
|
function resolveRenderPaths(projectDir, outputPath, rendersDir = DEFAULT_RENDERS_DIR) {
|
|
31171
31307
|
const absoluteProjectDir = resolve15(projectDir);
|
|
31172
|
-
const projectName =
|
|
31173
|
-
const resolvedOutputPath = outputPath ??
|
|
31308
|
+
const projectName = basename2(absoluteProjectDir);
|
|
31309
|
+
const resolvedOutputPath = outputPath ?? join29(rendersDir, `${projectName}.mp4`);
|
|
31174
31310
|
const absoluteOutputPath = resolve15(resolvedOutputPath);
|
|
31175
31311
|
return { absoluteProjectDir, absoluteOutputPath };
|
|
31176
31312
|
}
|
|
@@ -31243,9 +31379,9 @@ var init_fontData_generated = __esm({
|
|
|
31243
31379
|
});
|
|
31244
31380
|
|
|
31245
31381
|
// ../producer/src/services/deterministicFonts.ts
|
|
31246
|
-
import { existsSync as existsSync28, mkdirSync as mkdirSync15, readFileSync as readFileSync20, writeFileSync as
|
|
31382
|
+
import { existsSync as existsSync28, mkdirSync as mkdirSync15, readFileSync as readFileSync20, writeFileSync as writeFileSync10 } from "fs";
|
|
31247
31383
|
import { homedir as homedir7 } from "os";
|
|
31248
|
-
import { join as
|
|
31384
|
+
import { join as join30 } from "path";
|
|
31249
31385
|
function normalizeFamilyName(family) {
|
|
31250
31386
|
return family.trim().replace(/^['"]|['"]$/g, "").trim().toLowerCase();
|
|
31251
31387
|
}
|
|
@@ -31356,14 +31492,14 @@ function fontSlug(familyName) {
|
|
|
31356
31492
|
return familyName.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
31357
31493
|
}
|
|
31358
31494
|
function fontCacheDir(slug) {
|
|
31359
|
-
const dir =
|
|
31495
|
+
const dir = join30(GOOGLE_FONTS_CACHE_DIR, slug);
|
|
31360
31496
|
if (!existsSync28(dir)) {
|
|
31361
31497
|
mkdirSync15(dir, { recursive: true });
|
|
31362
31498
|
}
|
|
31363
31499
|
return dir;
|
|
31364
31500
|
}
|
|
31365
31501
|
function cachedWoff2Path(slug, weight, style) {
|
|
31366
|
-
return
|
|
31502
|
+
return join30(fontCacheDir(slug), `${weight}-${style}.woff2`);
|
|
31367
31503
|
}
|
|
31368
31504
|
async function fetchGoogleFont(familyName) {
|
|
31369
31505
|
const slug = fontSlug(familyName);
|
|
@@ -31394,7 +31530,7 @@ async function fetchGoogleFont(familyName) {
|
|
|
31394
31530
|
const fontRes = await fetch(woff2Url);
|
|
31395
31531
|
if (!fontRes.ok) continue;
|
|
31396
31532
|
const buffer = Buffer.from(await fontRes.arrayBuffer());
|
|
31397
|
-
|
|
31533
|
+
writeFileSync10(cachePath2, buffer);
|
|
31398
31534
|
} catch {
|
|
31399
31535
|
continue;
|
|
31400
31536
|
}
|
|
@@ -31575,14 +31711,14 @@ var init_deterministicFonts = __esm({
|
|
|
31575
31711
|
poppins: "poppins",
|
|
31576
31712
|
"segoe ui": "roboto"
|
|
31577
31713
|
};
|
|
31578
|
-
GOOGLE_FONTS_CACHE_DIR =
|
|
31714
|
+
GOOGLE_FONTS_CACHE_DIR = join30(homedir7(), ".cache", "hyperframes", "fonts");
|
|
31579
31715
|
WOFF2_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36";
|
|
31580
31716
|
}
|
|
31581
31717
|
});
|
|
31582
31718
|
|
|
31583
31719
|
// ../producer/src/services/htmlCompiler.ts
|
|
31584
31720
|
import { readFileSync as readFileSync21, existsSync as existsSync29, mkdirSync as mkdirSync16 } from "fs";
|
|
31585
|
-
import { join as
|
|
31721
|
+
import { join as join31, dirname as dirname10, resolve as resolve16 } from "path";
|
|
31586
31722
|
import postcss from "postcss";
|
|
31587
31723
|
function dedupeElementsById(elements) {
|
|
31588
31724
|
const deduped = /* @__PURE__ */ new Map();
|
|
@@ -31640,7 +31776,7 @@ async function resolveMediaDuration(src, mediaStart, baseDir, downloadDir, tagNa
|
|
|
31640
31776
|
return { duration: 0, resolvedPath: src };
|
|
31641
31777
|
}
|
|
31642
31778
|
} else if (!filePath.startsWith("/")) {
|
|
31643
|
-
filePath =
|
|
31779
|
+
filePath = join31(baseDir, filePath);
|
|
31644
31780
|
}
|
|
31645
31781
|
if (!existsSync29(filePath)) {
|
|
31646
31782
|
return { duration: 0, resolvedPath: filePath };
|
|
@@ -32428,14 +32564,14 @@ var init_logger = __esm({
|
|
|
32428
32564
|
import {
|
|
32429
32565
|
existsSync as existsSync30,
|
|
32430
32566
|
mkdirSync as mkdirSync17,
|
|
32431
|
-
rmSync as
|
|
32567
|
+
rmSync as rmSync7,
|
|
32432
32568
|
readFileSync as readFileSync22,
|
|
32433
32569
|
readdirSync as readdirSync11,
|
|
32434
|
-
writeFileSync as
|
|
32570
|
+
writeFileSync as writeFileSync11,
|
|
32435
32571
|
copyFileSync as copyFileSync2,
|
|
32436
32572
|
appendFileSync
|
|
32437
32573
|
} from "fs";
|
|
32438
|
-
import { join as
|
|
32574
|
+
import { join as join32, dirname as dirname11, resolve as resolve17 } from "path";
|
|
32439
32575
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
32440
32576
|
import { freemem as freemem2 } from "os";
|
|
32441
32577
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
@@ -32522,16 +32658,16 @@ function installDebugLogger(logPath, log2 = defaultLogger) {
|
|
|
32522
32658
|
};
|
|
32523
32659
|
}
|
|
32524
32660
|
function writeCompiledArtifacts(compiled, workDir, includeSummary) {
|
|
32525
|
-
const compileDir =
|
|
32661
|
+
const compileDir = join32(workDir, "compiled");
|
|
32526
32662
|
mkdirSync17(compileDir, { recursive: true });
|
|
32527
|
-
|
|
32663
|
+
writeFileSync11(join32(compileDir, "index.html"), compiled.html, "utf-8");
|
|
32528
32664
|
for (const [srcPath, html] of compiled.subCompositions) {
|
|
32529
|
-
const outPath =
|
|
32665
|
+
const outPath = join32(compileDir, srcPath);
|
|
32530
32666
|
mkdirSync17(dirname11(outPath), { recursive: true });
|
|
32531
|
-
|
|
32667
|
+
writeFileSync11(outPath, html, "utf-8");
|
|
32532
32668
|
}
|
|
32533
32669
|
for (const [relativePath, absolutePath] of compiled.externalAssets) {
|
|
32534
|
-
const outPath = resolve17(
|
|
32670
|
+
const outPath = resolve17(join32(compileDir, relativePath));
|
|
32535
32671
|
if (!isPathInside2(outPath, compileDir)) {
|
|
32536
32672
|
console.warn(`[Render] Skipping external asset with unsafe path: ${relativePath}`);
|
|
32537
32673
|
continue;
|
|
@@ -32561,7 +32697,7 @@ function writeCompiledArtifacts(compiled, workDir, includeSummary) {
|
|
|
32561
32697
|
subCompositions: Array.from(compiled.subCompositions.keys()),
|
|
32562
32698
|
renderModeHints: compiled.renderModeHints
|
|
32563
32699
|
};
|
|
32564
|
-
|
|
32700
|
+
writeFileSync11(join32(compileDir, "summary.json"), JSON.stringify(summary, null, 2), "utf-8");
|
|
32565
32701
|
}
|
|
32566
32702
|
}
|
|
32567
32703
|
function applyRenderModeHints(cfg, compiled, log2 = defaultLogger) {
|
|
@@ -32582,7 +32718,7 @@ function blitHdrVideoLayer(canvas, el, time, fps, hdrFrameDirs, hdrStartTimes, w
|
|
|
32582
32718
|
if (videoFrameIndex < 1) return;
|
|
32583
32719
|
const maxIndex = getMaxFrameIndex(frameDir);
|
|
32584
32720
|
const effectiveIndex = maxIndex > 0 ? Math.min(videoFrameIndex, maxIndex) : videoFrameIndex;
|
|
32585
|
-
const framePath =
|
|
32721
|
+
const framePath = join32(frameDir, `frame_${String(effectiveIndex).padStart(4, "0")}.png`);
|
|
32586
32722
|
if (!existsSync30(framePath)) {
|
|
32587
32723
|
return;
|
|
32588
32724
|
}
|
|
@@ -32768,7 +32904,7 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
|
|
|
32768
32904
|
const startTime = hdrVideoStartTimes.get(layer.element.id) ?? 0;
|
|
32769
32905
|
const localTime = time - startTime;
|
|
32770
32906
|
const frameNum = Math.floor(localTime * fps) + 1;
|
|
32771
|
-
const expectedFrame = frameDir ?
|
|
32907
|
+
const expectedFrame = frameDir ? join32(frameDir, `frame_${String(frameNum).padStart(4, "0")}.png`) : null;
|
|
32772
32908
|
log2.info("[diag] hdr layer blit", {
|
|
32773
32909
|
frame: debugFrameIndex,
|
|
32774
32910
|
layerIdx,
|
|
@@ -32805,8 +32941,8 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
|
|
|
32805
32941
|
if (shouldLog && debugDumpDir) {
|
|
32806
32942
|
const after2 = countNonZeroRgb48(canvas);
|
|
32807
32943
|
const dumpName = `frame_${String(debugFrameIndex).padStart(4, "0")}_layer_${String(layerIdx).padStart(2, "0")}_dom.png`;
|
|
32808
|
-
const dumpPath =
|
|
32809
|
-
|
|
32944
|
+
const dumpPath = join32(debugDumpDir, dumpName);
|
|
32945
|
+
writeFileSync11(dumpPath, domPng);
|
|
32810
32946
|
log2.info("[diag] dom layer blit", {
|
|
32811
32947
|
frame: debugFrameIndex,
|
|
32812
32948
|
layerIdx,
|
|
@@ -32879,8 +33015,8 @@ function extractStandaloneEntryFromIndex(indexHtml, entryFile) {
|
|
|
32879
33015
|
async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSignal) {
|
|
32880
33016
|
const moduleDir = dirname11(fileURLToPath3(import.meta.url));
|
|
32881
33017
|
const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve17(process.env.PRODUCER_RENDERS_DIR, "..") : resolve17(moduleDir, "../..");
|
|
32882
|
-
const debugDir =
|
|
32883
|
-
const workDir = job.config.debug ?
|
|
33018
|
+
const debugDir = join32(producerRoot, ".debug");
|
|
33019
|
+
const workDir = job.config.debug ? join32(debugDir, job.id) : join32(dirname11(outputPath), `work-${job.id}`);
|
|
32884
33020
|
const pipelineStart = Date.now();
|
|
32885
33021
|
const log2 = job.config.logger ?? defaultLogger;
|
|
32886
33022
|
let fileServer = null;
|
|
@@ -32892,7 +33028,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
32892
33028
|
videoExtractionFailures: 0,
|
|
32893
33029
|
imageDecodeFailures: 0
|
|
32894
33030
|
};
|
|
32895
|
-
const perfOutputPath =
|
|
33031
|
+
const perfOutputPath = join32(workDir, "perf-summary.json");
|
|
32896
33032
|
const cfg = { ...job.config.producerConfig ?? resolveConfig() };
|
|
32897
33033
|
const outputFormat = job.config.format ?? "mp4";
|
|
32898
33034
|
const isWebm = outputFormat === "webm";
|
|
@@ -32927,19 +33063,19 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
32927
33063
|
assertNotAborted();
|
|
32928
33064
|
if (!existsSync30(workDir)) mkdirSync17(workDir, { recursive: true });
|
|
32929
33065
|
if (job.config.debug) {
|
|
32930
|
-
const logPath =
|
|
33066
|
+
const logPath = join32(workDir, "render.log");
|
|
32931
33067
|
restoreLogger = installDebugLogger(logPath, log2);
|
|
32932
33068
|
}
|
|
32933
33069
|
const entryFile = job.config.entryFile || "index.html";
|
|
32934
|
-
let htmlPath =
|
|
33070
|
+
let htmlPath = join32(projectDir, entryFile);
|
|
32935
33071
|
if (!existsSync30(htmlPath)) {
|
|
32936
33072
|
throw new Error(`Entry file not found: ${htmlPath}`);
|
|
32937
33073
|
}
|
|
32938
33074
|
assertNotAborted();
|
|
32939
33075
|
const rawEntry = readFileSync22(htmlPath, "utf-8");
|
|
32940
33076
|
if (entryFile !== "index.html" && rawEntry.trimStart().startsWith("<template")) {
|
|
32941
|
-
const wrapperPath =
|
|
32942
|
-
const projectIndexPath =
|
|
33077
|
+
const wrapperPath = join32(workDir, "standalone-entry.html");
|
|
33078
|
+
const projectIndexPath = join32(projectDir, "index.html");
|
|
32943
33079
|
if (!existsSync30(projectIndexPath)) {
|
|
32944
33080
|
throw new Error(
|
|
32945
33081
|
`Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
|
|
@@ -32954,7 +33090,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
32954
33090
|
`Entry file "${entryFile}" is not mounted from index.html via data-composition-src, so it cannot be rendered independently.`
|
|
32955
33091
|
);
|
|
32956
33092
|
}
|
|
32957
|
-
|
|
33093
|
+
writeFileSync11(wrapperPath, standaloneHtml, "utf-8");
|
|
32958
33094
|
htmlPath = wrapperPath;
|
|
32959
33095
|
log2.info("Extracted standalone entry from index.html host context", {
|
|
32960
33096
|
entryFile
|
|
@@ -32963,7 +33099,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
32963
33099
|
const stage1Start = Date.now();
|
|
32964
33100
|
updateJobStatus(job, "preprocessing", "Compiling composition", 5, onProgress);
|
|
32965
33101
|
const compileStart = Date.now();
|
|
32966
|
-
let compiled = await compileForRender(projectDir, htmlPath,
|
|
33102
|
+
let compiled = await compileForRender(projectDir, htmlPath, join32(workDir, "downloads"));
|
|
32967
33103
|
assertNotAborted();
|
|
32968
33104
|
perfStages.compileOnlyMs = Date.now() - compileStart;
|
|
32969
33105
|
applyRenderModeHints(cfg, compiled, log2);
|
|
@@ -32995,7 +33131,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
32995
33131
|
reasons.push(`${compiled.unresolvedCompositions.length} unresolved composition(s)`);
|
|
32996
33132
|
fileServer = await createFileServer2({
|
|
32997
33133
|
projectDir,
|
|
32998
|
-
compiledDir:
|
|
33134
|
+
compiledDir: join32(workDir, "compiled"),
|
|
32999
33135
|
port: 0,
|
|
33000
33136
|
preHeadScripts: [VIRTUAL_TIME_SHIM]
|
|
33001
33137
|
});
|
|
@@ -33009,7 +33145,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
33009
33145
|
};
|
|
33010
33146
|
probeSession = await createCaptureSession(
|
|
33011
33147
|
fileServer.url,
|
|
33012
|
-
|
|
33148
|
+
join32(workDir, "probe"),
|
|
33013
33149
|
captureOpts,
|
|
33014
33150
|
null,
|
|
33015
33151
|
cfg
|
|
@@ -33041,7 +33177,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
33041
33177
|
compiled,
|
|
33042
33178
|
resolutions,
|
|
33043
33179
|
projectDir,
|
|
33044
|
-
|
|
33180
|
+
join32(workDir, "downloads")
|
|
33045
33181
|
);
|
|
33046
33182
|
assertNotAborted();
|
|
33047
33183
|
composition.videos = compiled.videos;
|
|
@@ -33181,7 +33317,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
33181
33317
|
const stage2Start = Date.now();
|
|
33182
33318
|
updateJobStatus(job, "preprocessing", "Extracting video frames", 10, onProgress);
|
|
33183
33319
|
let frameLookup = null;
|
|
33184
|
-
const compiledDir =
|
|
33320
|
+
const compiledDir = join32(workDir, "compiled");
|
|
33185
33321
|
let extractionResult = null;
|
|
33186
33322
|
const nativeHdrVideoIds = /* @__PURE__ */ new Set();
|
|
33187
33323
|
const videoTransfers = /* @__PURE__ */ new Map();
|
|
@@ -33190,7 +33326,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
33190
33326
|
composition.videos.map(async (v) => {
|
|
33191
33327
|
let videoPath = v.src;
|
|
33192
33328
|
if (!videoPath.startsWith("/")) {
|
|
33193
|
-
const fromCompiled = existsSync30(
|
|
33329
|
+
const fromCompiled = existsSync30(join32(compiledDir, videoPath)) ? join32(compiledDir, videoPath) : join32(projectDir, videoPath);
|
|
33194
33330
|
videoPath = fromCompiled;
|
|
33195
33331
|
}
|
|
33196
33332
|
if (!existsSync30(videoPath)) return;
|
|
@@ -33211,7 +33347,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
33211
33347
|
composition.images.map(async (img) => {
|
|
33212
33348
|
let imgPath = img.src;
|
|
33213
33349
|
if (!imgPath.startsWith("/")) {
|
|
33214
|
-
const fromCompiled = existsSync30(
|
|
33350
|
+
const fromCompiled = existsSync30(join32(compiledDir, imgPath)) ? join32(compiledDir, imgPath) : join32(projectDir, imgPath);
|
|
33215
33351
|
imgPath = fromCompiled;
|
|
33216
33352
|
}
|
|
33217
33353
|
if (!existsSync30(imgPath)) return null;
|
|
@@ -33230,7 +33366,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
33230
33366
|
extractionResult = await extractAllVideoFrames(
|
|
33231
33367
|
composition.videos,
|
|
33232
33368
|
projectDir,
|
|
33233
|
-
{ fps: job.config.fps, outputDir:
|
|
33369
|
+
{ fps: job.config.fps, outputDir: join32(workDir, "video-frames") },
|
|
33234
33370
|
abortSignal,
|
|
33235
33371
|
void 0,
|
|
33236
33372
|
compiledDir
|
|
@@ -33288,13 +33424,13 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
33288
33424
|
}
|
|
33289
33425
|
const stage3Start = Date.now();
|
|
33290
33426
|
updateJobStatus(job, "preprocessing", "Processing audio tracks", 20, onProgress);
|
|
33291
|
-
const audioOutputPath =
|
|
33427
|
+
const audioOutputPath = join32(workDir, "audio.aac");
|
|
33292
33428
|
let hasAudio = false;
|
|
33293
33429
|
if (composition.audios.length > 0) {
|
|
33294
33430
|
const audioResult = await processCompositionAudio(
|
|
33295
33431
|
composition.audios,
|
|
33296
33432
|
projectDir,
|
|
33297
|
-
|
|
33433
|
+
join32(workDir, "audio-work"),
|
|
33298
33434
|
audioOutputPath,
|
|
33299
33435
|
job.duration,
|
|
33300
33436
|
abortSignal,
|
|
@@ -33312,13 +33448,13 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
33312
33448
|
if (!fileServer) {
|
|
33313
33449
|
fileServer = await createFileServer2({
|
|
33314
33450
|
projectDir,
|
|
33315
|
-
compiledDir:
|
|
33451
|
+
compiledDir: join32(workDir, "compiled"),
|
|
33316
33452
|
port: 0,
|
|
33317
33453
|
preHeadScripts: [VIRTUAL_TIME_SHIM]
|
|
33318
33454
|
});
|
|
33319
33455
|
assertNotAborted();
|
|
33320
33456
|
}
|
|
33321
|
-
const framesDir =
|
|
33457
|
+
const framesDir = join32(workDir, "captured-frames");
|
|
33322
33458
|
if (!existsSync30(framesDir)) mkdirSync17(framesDir, { recursive: true });
|
|
33323
33459
|
const captureOptions = {
|
|
33324
33460
|
width,
|
|
@@ -33334,7 +33470,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
33334
33470
|
const workerCount = calculateOptimalWorkers(totalFrames, job.config.workers, cfg);
|
|
33335
33471
|
const FORMAT_EXT2 = { mp4: ".mp4", webm: ".webm", mov: ".mov" };
|
|
33336
33472
|
const videoExt = FORMAT_EXT2[outputFormat] ?? ".mp4";
|
|
33337
|
-
const videoOnlyPath =
|
|
33473
|
+
const videoOnlyPath = join32(workDir, `video-only${videoExt}`);
|
|
33338
33474
|
const nativeHdrIds = /* @__PURE__ */ new Set([...nativeHdrVideoIds, ...nativeHdrImageIds]);
|
|
33339
33475
|
const hasHdrContent = effectiveHdr && nativeHdrIds.size > 0;
|
|
33340
33476
|
const encoderHdr = hasHdrContent ? effectiveHdr : void 0;
|
|
@@ -33356,8 +33492,8 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
33356
33492
|
if (!hdrVideoIds.includes(v.id)) continue;
|
|
33357
33493
|
let srcPath = v.src;
|
|
33358
33494
|
if (!srcPath.startsWith("/")) {
|
|
33359
|
-
const fromCompiled =
|
|
33360
|
-
srcPath = existsSync30(fromCompiled) ? fromCompiled :
|
|
33495
|
+
const fromCompiled = join32(compiledDir, srcPath);
|
|
33496
|
+
srcPath = existsSync30(fromCompiled) ? fromCompiled : join32(projectDir, srcPath);
|
|
33361
33497
|
}
|
|
33362
33498
|
hdrVideoSrcPaths.set(v.id, srcPath);
|
|
33363
33499
|
}
|
|
@@ -33487,7 +33623,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
33487
33623
|
for (const [videoId, srcPath] of hdrVideoSrcPaths) {
|
|
33488
33624
|
const video = composition.videos.find((v) => v.id === videoId);
|
|
33489
33625
|
if (!video) continue;
|
|
33490
|
-
const frameDir =
|
|
33626
|
+
const frameDir = join32(framesDir, `hdr_${videoId}`);
|
|
33491
33627
|
mkdirSync17(frameDir, { recursive: true });
|
|
33492
33628
|
const duration = video.end - video.start;
|
|
33493
33629
|
const dims = hdrExtractionDims.get(videoId) ?? { width, height };
|
|
@@ -33507,7 +33643,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
33507
33643
|
"-c:v",
|
|
33508
33644
|
"png",
|
|
33509
33645
|
"-y",
|
|
33510
|
-
|
|
33646
|
+
join32(frameDir, "frame_%04d.png")
|
|
33511
33647
|
];
|
|
33512
33648
|
const result = await runFfmpeg(ffmpegArgs, { signal: abortSignal });
|
|
33513
33649
|
if (!result.success) {
|
|
@@ -33575,7 +33711,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
33575
33711
|
}
|
|
33576
33712
|
}
|
|
33577
33713
|
const debugDumpEnabled = process.env.KEEP_TEMP === "1";
|
|
33578
|
-
const debugDumpDir = debugDumpEnabled ?
|
|
33714
|
+
const debugDumpDir = debugDumpEnabled ? join32(framesDir, "debug-composite") : null;
|
|
33579
33715
|
if (debugDumpDir && !existsSync30(debugDumpDir)) {
|
|
33580
33716
|
mkdirSync17(debugDumpDir, { recursive: true });
|
|
33581
33717
|
}
|
|
@@ -33717,11 +33853,11 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
33717
33853
|
i2
|
|
33718
33854
|
);
|
|
33719
33855
|
if (debugDumpEnabled && debugDumpDir && i2 % 30 === 0) {
|
|
33720
|
-
const previewPath =
|
|
33856
|
+
const previewPath = join32(
|
|
33721
33857
|
debugDumpDir,
|
|
33722
33858
|
`frame_${String(i2).padStart(4, "0")}_final_rgb48le.bin`
|
|
33723
33859
|
);
|
|
33724
|
-
|
|
33860
|
+
writeFileSync11(previewPath, normalCanvas);
|
|
33725
33861
|
}
|
|
33726
33862
|
hdrEncoder.writeFrame(normalCanvas);
|
|
33727
33863
|
}
|
|
@@ -33733,7 +33869,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
33733
33869
|
const frameDir = hdrFrameDirs.get(videoId);
|
|
33734
33870
|
if (frameDir) {
|
|
33735
33871
|
try {
|
|
33736
|
-
|
|
33872
|
+
rmSync7(frameDir, { recursive: true, force: true });
|
|
33737
33873
|
} catch (err) {
|
|
33738
33874
|
log2.warn("Failed to clean up HDR frame directory", {
|
|
33739
33875
|
videoId,
|
|
@@ -34086,7 +34222,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
34086
34222
|
job.perfSummary = perfSummary;
|
|
34087
34223
|
if (job.config.debug) {
|
|
34088
34224
|
try {
|
|
34089
|
-
|
|
34225
|
+
writeFileSync11(perfOutputPath, JSON.stringify(perfSummary, null, 2), "utf-8");
|
|
34090
34226
|
} catch (err) {
|
|
34091
34227
|
log2.debug("Failed to write perf summary", {
|
|
34092
34228
|
perfOutputPath,
|
|
@@ -34096,7 +34232,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
34096
34232
|
}
|
|
34097
34233
|
if (job.config.debug) {
|
|
34098
34234
|
if (existsSync30(outputPath)) {
|
|
34099
|
-
const debugOutput =
|
|
34235
|
+
const debugOutput = join32(workDir, `output${videoExt}`);
|
|
34100
34236
|
copyFileSync2(outputPath, debugOutput);
|
|
34101
34237
|
}
|
|
34102
34238
|
} else if (process.env.KEEP_TEMP === "1") {
|
|
@@ -34105,7 +34241,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
34105
34241
|
await safeCleanup(
|
|
34106
34242
|
"remove workDir",
|
|
34107
34243
|
() => {
|
|
34108
|
-
|
|
34244
|
+
rmSync7(workDir, { recursive: true, force: true });
|
|
34109
34245
|
},
|
|
34110
34246
|
log2
|
|
34111
34247
|
);
|
|
@@ -34133,7 +34269,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
34133
34269
|
await safeCleanup(
|
|
34134
34270
|
"remove workDir (cancel)",
|
|
34135
34271
|
() => {
|
|
34136
|
-
|
|
34272
|
+
rmSync7(workDir, { recursive: true, force: true });
|
|
34137
34273
|
},
|
|
34138
34274
|
log2
|
|
34139
34275
|
);
|
|
@@ -34182,7 +34318,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
34182
34318
|
await safeCleanup(
|
|
34183
34319
|
"remove workDir (error)",
|
|
34184
34320
|
() => {
|
|
34185
|
-
if (existsSync30(workDir))
|
|
34321
|
+
if (existsSync30(workDir)) rmSync7(workDir, { recursive: true, force: true });
|
|
34186
34322
|
},
|
|
34187
34323
|
log2
|
|
34188
34324
|
);
|
|
@@ -34242,7 +34378,7 @@ var init_config3 = __esm({
|
|
|
34242
34378
|
|
|
34243
34379
|
// ../producer/src/services/hyperframeLint.ts
|
|
34244
34380
|
import { existsSync as existsSync31, readFileSync as readFileSync23, statSync as statSync8 } from "fs";
|
|
34245
|
-
import { resolve as resolve18, join as
|
|
34381
|
+
import { resolve as resolve18, join as join33 } from "path";
|
|
34246
34382
|
function isStringRecord(value) {
|
|
34247
34383
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
34248
34384
|
return false;
|
|
@@ -34290,7 +34426,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile) {
|
|
|
34290
34426
|
}
|
|
34291
34427
|
}
|
|
34292
34428
|
return {
|
|
34293
|
-
error: `No HTML entry file found in project directory: ${
|
|
34429
|
+
error: `No HTML entry file found in project directory: ${join33(absProjectDir, preferredEntryFile || "index.html")}`
|
|
34294
34430
|
};
|
|
34295
34431
|
}
|
|
34296
34432
|
function prepareHyperframeLintBody(body) {
|
|
@@ -34381,13 +34517,13 @@ import {
|
|
|
34381
34517
|
existsSync as existsSync32,
|
|
34382
34518
|
mkdirSync as mkdirSync18,
|
|
34383
34519
|
statSync as statSync9,
|
|
34384
|
-
mkdtempSync,
|
|
34385
|
-
writeFileSync as
|
|
34386
|
-
rmSync as
|
|
34520
|
+
mkdtempSync as mkdtempSync2,
|
|
34521
|
+
writeFileSync as writeFileSync12,
|
|
34522
|
+
rmSync as rmSync8,
|
|
34387
34523
|
createReadStream
|
|
34388
34524
|
} from "fs";
|
|
34389
|
-
import { resolve as resolve19, dirname as dirname12, join as
|
|
34390
|
-
import { tmpdir as
|
|
34525
|
+
import { resolve as resolve19, dirname as dirname12, join as join34 } from "path";
|
|
34526
|
+
import { tmpdir as tmpdir3 } from "os";
|
|
34391
34527
|
import { parseArgs as parseArgs2 } from "util";
|
|
34392
34528
|
import crypto2 from "crypto";
|
|
34393
34529
|
import { Hono as Hono4 } from "hono";
|
|
@@ -34437,9 +34573,9 @@ async function prepareRenderBody(body) {
|
|
|
34437
34573
|
};
|
|
34438
34574
|
}
|
|
34439
34575
|
}
|
|
34440
|
-
const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR ||
|
|
34441
|
-
const tempProjectDir =
|
|
34442
|
-
|
|
34576
|
+
const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir3();
|
|
34577
|
+
const tempProjectDir = mkdtempSync2(join34(tempRoot, "producer-project-"));
|
|
34578
|
+
writeFileSync12(join34(tempProjectDir, "index.html"), htmlContent, "utf-8");
|
|
34443
34579
|
return {
|
|
34444
34580
|
prepared: {
|
|
34445
34581
|
input: {
|
|
@@ -34490,7 +34626,7 @@ function createArtifactStore(ttlMs) {
|
|
|
34490
34626
|
function cleanupTempDir(dir, log2) {
|
|
34491
34627
|
if (!dir) return;
|
|
34492
34628
|
try {
|
|
34493
|
-
|
|
34629
|
+
rmSync8(dir, { recursive: true, force: true });
|
|
34494
34630
|
} catch (error) {
|
|
34495
34631
|
log2.warn("Failed to cleanup temp project dir", {
|
|
34496
34632
|
cleanupProjectDir: dir,
|
|
@@ -34914,8 +35050,8 @@ __export(studioServer_exports, {
|
|
|
34914
35050
|
});
|
|
34915
35051
|
import { Hono as Hono5 } from "hono";
|
|
34916
35052
|
import { streamSSE as streamSSE3 } from "hono/streaming";
|
|
34917
|
-
import { existsSync as existsSync33, readFileSync as readFileSync24, writeFileSync as
|
|
34918
|
-
import { resolve as resolve20, join as
|
|
35053
|
+
import { existsSync as existsSync33, readFileSync as readFileSync24, writeFileSync as writeFileSync13, statSync as statSync10 } from "fs";
|
|
35054
|
+
import { resolve as resolve20, join as join35, basename as basename3 } from "path";
|
|
34919
35055
|
function resolveDistDir() {
|
|
34920
35056
|
const builtPath = resolve20(__dirname, "studio");
|
|
34921
35057
|
if (existsSync33(resolve20(builtPath, "index.html"))) return builtPath;
|
|
@@ -34972,7 +35108,7 @@ async function getThumbnailBrowser() {
|
|
|
34972
35108
|
}
|
|
34973
35109
|
function createStudioServer(options) {
|
|
34974
35110
|
const { projectDir, projectName } = options;
|
|
34975
|
-
const projectId = projectName ||
|
|
35111
|
+
const projectId = projectName || basename3(projectDir);
|
|
34976
35112
|
const studioDir = resolveDistDir();
|
|
34977
35113
|
const runtimePath = resolveRuntimePath();
|
|
34978
35114
|
const watcher = createProjectWatcher(projectDir);
|
|
@@ -34999,7 +35135,7 @@ function createStudioServer(options) {
|
|
|
34999
35135
|
return lintHyperframeHtml2(html, opts);
|
|
35000
35136
|
},
|
|
35001
35137
|
runtimeUrl: "/api/runtime.js",
|
|
35002
|
-
rendersDir: () =>
|
|
35138
|
+
rendersDir: () => join35(projectDir, "renders"),
|
|
35003
35139
|
startRender(opts) {
|
|
35004
35140
|
const state = {
|
|
35005
35141
|
id: opts.jobId,
|
|
@@ -35032,7 +35168,7 @@ function createStudioServer(options) {
|
|
|
35032
35168
|
state.status = "complete";
|
|
35033
35169
|
state.progress = 100;
|
|
35034
35170
|
const metaPath = opts.outputPath.replace(/\.(mp4|webm|mov)$/, ".meta.json");
|
|
35035
|
-
|
|
35171
|
+
writeFileSync13(
|
|
35036
35172
|
metaPath,
|
|
35037
35173
|
JSON.stringify({ status: "complete", durationMs: Date.now() - startTime })
|
|
35038
35174
|
);
|
|
@@ -35041,7 +35177,7 @@ function createStudioServer(options) {
|
|
|
35041
35177
|
state.error = err instanceof Error ? err.message : String(err);
|
|
35042
35178
|
try {
|
|
35043
35179
|
const metaPath = opts.outputPath.replace(/\.(mp4|webm|mov)$/, ".meta.json");
|
|
35044
|
-
|
|
35180
|
+
writeFileSync13(metaPath, JSON.stringify({ status: "failed" }));
|
|
35045
35181
|
} catch {
|
|
35046
35182
|
}
|
|
35047
35183
|
}
|
|
@@ -35194,15 +35330,15 @@ __export(preview_exports, {
|
|
|
35194
35330
|
});
|
|
35195
35331
|
import { spawn as spawn8 } from "child_process";
|
|
35196
35332
|
import { existsSync as existsSync34, lstatSync, symlinkSync, unlinkSync as unlinkSync5, readlinkSync, mkdirSync as mkdirSync19 } from "fs";
|
|
35197
|
-
import { resolve as resolve21, dirname as dirname13, basename as
|
|
35333
|
+
import { resolve as resolve21, dirname as dirname13, basename as basename4, join as join36 } from "path";
|
|
35198
35334
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
35199
35335
|
import { createRequire } from "module";
|
|
35200
35336
|
async function runDevMode(dir, projectName) {
|
|
35201
35337
|
const thisFile = fileURLToPath4(import.meta.url);
|
|
35202
35338
|
const repoRoot = resolve21(dirname13(thisFile), "..", "..", "..", "..");
|
|
35203
|
-
const projectsDir =
|
|
35204
|
-
const pName = projectName ??
|
|
35205
|
-
const symlinkPath =
|
|
35339
|
+
const projectsDir = join36(repoRoot, "packages", "studio", "data", "projects");
|
|
35340
|
+
const pName = projectName ?? basename4(dir);
|
|
35341
|
+
const symlinkPath = join36(projectsDir, pName);
|
|
35206
35342
|
mkdirSync19(projectsDir, { recursive: true });
|
|
35207
35343
|
let createdSymlink = false;
|
|
35208
35344
|
if (dir !== symlinkPath) {
|
|
@@ -35226,7 +35362,7 @@ async function runDevMode(dir, projectName) {
|
|
|
35226
35362
|
Wt2(c.bold("hyperframes preview"));
|
|
35227
35363
|
const s2 = be();
|
|
35228
35364
|
s2.start("Starting studio...");
|
|
35229
|
-
const studioPkgDir =
|
|
35365
|
+
const studioPkgDir = join36(repoRoot, "packages", "studio");
|
|
35230
35366
|
const child = spawn8("pnpm", ["exec", "vite"], {
|
|
35231
35367
|
cwd: studioPkgDir,
|
|
35232
35368
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -35271,7 +35407,7 @@ async function runDevMode(dir, projectName) {
|
|
|
35271
35407
|
}
|
|
35272
35408
|
function hasLocalStudio(dir) {
|
|
35273
35409
|
try {
|
|
35274
|
-
const req = createRequire(
|
|
35410
|
+
const req = createRequire(join36(dir, "package.json"));
|
|
35275
35411
|
req.resolve("@hyperframes/studio/package.json");
|
|
35276
35412
|
return true;
|
|
35277
35413
|
} catch {
|
|
@@ -35279,11 +35415,11 @@ function hasLocalStudio(dir) {
|
|
|
35279
35415
|
}
|
|
35280
35416
|
}
|
|
35281
35417
|
async function runLocalStudioMode(dir, projectName) {
|
|
35282
|
-
const req = createRequire(
|
|
35418
|
+
const req = createRequire(join36(dir, "package.json"));
|
|
35283
35419
|
const studioPkgPath = dirname13(req.resolve("@hyperframes/studio/package.json"));
|
|
35284
|
-
const pName = projectName ??
|
|
35285
|
-
const projectsDir =
|
|
35286
|
-
const symlinkPath =
|
|
35420
|
+
const pName = projectName ?? basename4(dir);
|
|
35421
|
+
const projectsDir = join36(studioPkgPath, "data", "projects");
|
|
35422
|
+
const symlinkPath = join36(projectsDir, pName);
|
|
35287
35423
|
mkdirSync19(projectsDir, { recursive: true });
|
|
35288
35424
|
let createdSymlink = false;
|
|
35289
35425
|
if (dir !== symlinkPath) {
|
|
@@ -35342,7 +35478,7 @@ async function runLocalStudioMode(dir, projectName) {
|
|
|
35342
35478
|
}
|
|
35343
35479
|
async function runEmbeddedMode(dir, startPort, projectName, forceNew = false) {
|
|
35344
35480
|
const { createStudioServer: createStudioServer2 } = await Promise.resolve().then(() => (init_studioServer(), studioServer_exports));
|
|
35345
|
-
const pName = projectName ??
|
|
35481
|
+
const pName = projectName ?? basename4(dir);
|
|
35346
35482
|
const { app } = createStudioServer2({ projectDir: dir, projectName: pName });
|
|
35347
35483
|
Wt2(c.bold("hyperframes preview"));
|
|
35348
35484
|
const s2 = be();
|
|
@@ -35470,8 +35606,8 @@ var init_preview2 = __esm({
|
|
|
35470
35606
|
const rawArg = args.dir;
|
|
35471
35607
|
const dir = resolve21(rawArg ?? ".");
|
|
35472
35608
|
const isImplicitCwd = !rawArg || rawArg === "." || rawArg === "./";
|
|
35473
|
-
const projectName = isImplicitCwd ?
|
|
35474
|
-
const indexPath =
|
|
35609
|
+
const projectName = isImplicitCwd ? basename4(process.env.PWD ?? dir) : basename4(dir);
|
|
35610
|
+
const indexPath = join36(dir, "index.html");
|
|
35475
35611
|
if (existsSync34(indexPath)) {
|
|
35476
35612
|
const project = { dir, name: projectName, indexPath };
|
|
35477
35613
|
const lintResult = lintProject(project);
|
|
@@ -35505,11 +35641,11 @@ import {
|
|
|
35505
35641
|
mkdirSync as mkdirSync20,
|
|
35506
35642
|
copyFileSync as copyFileSync3,
|
|
35507
35643
|
cpSync,
|
|
35508
|
-
writeFileSync as
|
|
35644
|
+
writeFileSync as writeFileSync14,
|
|
35509
35645
|
readFileSync as readFileSync25,
|
|
35510
35646
|
readdirSync as readdirSync12
|
|
35511
35647
|
} from "fs";
|
|
35512
|
-
import { resolve as resolve22, basename as
|
|
35648
|
+
import { resolve as resolve22, basename as basename5, join as join37, dirname as dirname14 } from "path";
|
|
35513
35649
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
35514
35650
|
import { execFileSync as execFileSync4, spawn as spawn9 } from "child_process";
|
|
35515
35651
|
function probeVideo(filePath) {
|
|
@@ -35590,7 +35726,7 @@ function getSharedTemplateDir() {
|
|
|
35590
35726
|
return resolveAssetDir(["..", "templates", "_shared"], ["templates", "_shared"]);
|
|
35591
35727
|
}
|
|
35592
35728
|
function patchVideoSrc(dir, videoFilename, durationSeconds) {
|
|
35593
|
-
const htmlFiles = readdirSync12(dir, { withFileTypes: true, recursive: true }).filter((e2) => e2.isFile() && e2.name.endsWith(".html")).map((e2) =>
|
|
35729
|
+
const htmlFiles = readdirSync12(dir, { withFileTypes: true, recursive: true }).filter((e2) => e2.isFile() && e2.name.endsWith(".html")).map((e2) => join37(e2.parentPath ?? e2.path, e2.name));
|
|
35594
35730
|
for (const file of htmlFiles) {
|
|
35595
35731
|
let content = readFileSync25(file, "utf-8");
|
|
35596
35732
|
if (videoFilename) {
|
|
@@ -35603,7 +35739,7 @@ function patchVideoSrc(dir, videoFilename, durationSeconds) {
|
|
|
35603
35739
|
}
|
|
35604
35740
|
const dur = durationSeconds ? String(Math.round(durationSeconds * 100) / 100) : "10";
|
|
35605
35741
|
content = content.replaceAll("__VIDEO_DURATION__", dur);
|
|
35606
|
-
|
|
35742
|
+
writeFileSync14(file, content, "utf-8");
|
|
35607
35743
|
}
|
|
35608
35744
|
}
|
|
35609
35745
|
async function patchTranscript(dir, transcriptPath) {
|
|
@@ -35615,7 +35751,7 @@ async function patchTranscript(dir, transcriptPath) {
|
|
|
35615
35751
|
async function handleVideoFile(videoPath, destDir, interactive) {
|
|
35616
35752
|
const probed = probeVideo(videoPath);
|
|
35617
35753
|
let meta = { ...DEFAULT_META };
|
|
35618
|
-
let localVideoName =
|
|
35754
|
+
let localVideoName = basename5(videoPath);
|
|
35619
35755
|
if (probed) {
|
|
35620
35756
|
meta = probed;
|
|
35621
35757
|
if (interactive) {
|
|
@@ -35703,7 +35839,7 @@ async function scaffoldProject(destDir, name, templateId, localVideoName, durati
|
|
|
35703
35839
|
await fetchRemoteTemplate(templateId, destDir);
|
|
35704
35840
|
}
|
|
35705
35841
|
patchVideoSrc(destDir, localVideoName, durationSeconds);
|
|
35706
|
-
|
|
35842
|
+
writeFileSync14(
|
|
35707
35843
|
resolve22(destDir, "meta.json"),
|
|
35708
35844
|
JSON.stringify(
|
|
35709
35845
|
{
|
|
@@ -35723,7 +35859,7 @@ async function scaffoldProject(destDir, name, templateId, localVideoName, durati
|
|
|
35723
35859
|
const sharedDir = getSharedTemplateDir();
|
|
35724
35860
|
if (existsSync35(sharedDir)) {
|
|
35725
35861
|
for (const entry of readdirSync12(sharedDir, { withFileTypes: true })) {
|
|
35726
|
-
const src =
|
|
35862
|
+
const src = join37(sharedDir, entry.name);
|
|
35727
35863
|
const dest = resolve22(destDir, entry.name);
|
|
35728
35864
|
if (entry.isFile() || entry.isSymbolicLink()) {
|
|
35729
35865
|
copyFileSync3(src, dest);
|
|
@@ -35870,8 +36006,8 @@ var init_init = __esm({
|
|
|
35870
36006
|
process.exit(1);
|
|
35871
36007
|
}
|
|
35872
36008
|
sourceFilePath2 = audioPath;
|
|
35873
|
-
copyFileSync3(audioPath, resolve22(destDir2,
|
|
35874
|
-
console.log(`Audio: ${
|
|
36009
|
+
copyFileSync3(audioPath, resolve22(destDir2, basename5(audioPath)));
|
|
36010
|
+
console.log(`Audio: ${basename5(audioPath)}`);
|
|
35875
36011
|
}
|
|
35876
36012
|
if (sourceFilePath2 && !skipTranscribe) {
|
|
35877
36013
|
try {
|
|
@@ -35895,7 +36031,7 @@ var init_init = __esm({
|
|
|
35895
36031
|
try {
|
|
35896
36032
|
await scaffoldProject(
|
|
35897
36033
|
destDir2,
|
|
35898
|
-
|
|
36034
|
+
basename5(destDir2),
|
|
35899
36035
|
templateId2,
|
|
35900
36036
|
localVideoName2,
|
|
35901
36037
|
videoDuration2
|
|
@@ -35997,8 +36133,8 @@ var init_init = __esm({
|
|
|
35997
36133
|
}
|
|
35998
36134
|
mkdirSync20(destDir, { recursive: true });
|
|
35999
36135
|
sourceFilePath = audioPath;
|
|
36000
|
-
copyFileSync3(audioPath, resolve22(destDir,
|
|
36001
|
-
R2.info(`Audio copied to ${c.accent(
|
|
36136
|
+
copyFileSync3(audioPath, resolve22(destDir, basename5(audioPath)));
|
|
36137
|
+
R2.info(`Audio copied to ${c.accent(basename5(audioPath))}`);
|
|
36002
36138
|
}
|
|
36003
36139
|
if (sourceFilePath) {
|
|
36004
36140
|
const transcribeChoice = await Rt({
|
|
@@ -36114,7 +36250,7 @@ ${c.dim("Use --example blank for offline use.")}`
|
|
|
36114
36250
|
});
|
|
36115
36251
|
|
|
36116
36252
|
// src/utils/clipboard.ts
|
|
36117
|
-
import { spawnSync } from "child_process";
|
|
36253
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
36118
36254
|
import { platform as platform3 } from "os";
|
|
36119
36255
|
function detectProvider() {
|
|
36120
36256
|
const os = platform3();
|
|
@@ -36132,7 +36268,7 @@ function detectProvider() {
|
|
|
36132
36268
|
];
|
|
36133
36269
|
const cmd = process.platform === "win32" ? "where" : "which";
|
|
36134
36270
|
for (const p of candidates) {
|
|
36135
|
-
const result =
|
|
36271
|
+
const result = spawnSync2(cmd, [p.cmd], { stdio: "ignore" });
|
|
36136
36272
|
if (result.status === 0) return p;
|
|
36137
36273
|
}
|
|
36138
36274
|
return void 0;
|
|
@@ -36142,7 +36278,7 @@ function copyToClipboard(text) {
|
|
|
36142
36278
|
const provider = cachedProvider;
|
|
36143
36279
|
if (!provider) return false;
|
|
36144
36280
|
try {
|
|
36145
|
-
const res =
|
|
36281
|
+
const res = spawnSync2(provider.cmd, provider.args, {
|
|
36146
36282
|
input: text,
|
|
36147
36283
|
encoding: "utf-8"
|
|
36148
36284
|
});
|
|
@@ -36509,10 +36645,10 @@ var init_format = __esm({
|
|
|
36509
36645
|
|
|
36510
36646
|
// src/utils/project.ts
|
|
36511
36647
|
import { existsSync as existsSync37, statSync as statSync11 } from "fs";
|
|
36512
|
-
import { resolve as resolve25, basename as
|
|
36648
|
+
import { resolve as resolve25, basename as basename6 } from "path";
|
|
36513
36649
|
function resolveProject(dirArg) {
|
|
36514
36650
|
const dir = resolve25(dirArg ?? ".");
|
|
36515
|
-
const name =
|
|
36651
|
+
const name = basename6(dir);
|
|
36516
36652
|
const indexPath = resolve25(dir, "index.html");
|
|
36517
36653
|
if (!existsSync37(dir) || !statSync11(dir).isDirectory()) {
|
|
36518
36654
|
errorBox("Not a directory: " + dir);
|
|
@@ -36748,7 +36884,7 @@ var init_play = __esm({
|
|
|
36748
36884
|
});
|
|
36749
36885
|
|
|
36750
36886
|
// src/utils/publishProject.ts
|
|
36751
|
-
import { basename as
|
|
36887
|
+
import { basename as basename7, join as join38, relative as relative4 } from "path";
|
|
36752
36888
|
import { readdirSync as readdirSync13, readFileSync as readFileSync27, statSync as statSync12 } from "fs";
|
|
36753
36889
|
import AdmZip from "adm-zip";
|
|
36754
36890
|
function shouldIgnoreSegment(segment) {
|
|
@@ -36757,7 +36893,7 @@ function shouldIgnoreSegment(segment) {
|
|
|
36757
36893
|
function collectProjectFiles(rootDir, currentDir, paths) {
|
|
36758
36894
|
for (const entry of readdirSync13(currentDir, { withFileTypes: true })) {
|
|
36759
36895
|
if (shouldIgnoreSegment(entry.name)) continue;
|
|
36760
|
-
const absolutePath =
|
|
36896
|
+
const absolutePath = join38(currentDir, entry.name);
|
|
36761
36897
|
const relativePath = relative4(rootDir, absolutePath).replaceAll("\\", "/");
|
|
36762
36898
|
if (!relativePath) continue;
|
|
36763
36899
|
if (entry.isDirectory()) {
|
|
@@ -36776,7 +36912,7 @@ function createPublishArchive(projectDir) {
|
|
|
36776
36912
|
}
|
|
36777
36913
|
const archive = new AdmZip();
|
|
36778
36914
|
for (const filePath of filePaths) {
|
|
36779
|
-
archive.addFile(filePath, readFileSync27(
|
|
36915
|
+
archive.addFile(filePath, readFileSync27(join38(projectDir, filePath)));
|
|
36780
36916
|
}
|
|
36781
36917
|
return {
|
|
36782
36918
|
buffer: archive.toBuffer(),
|
|
@@ -36787,7 +36923,7 @@ function getPublishApiBaseUrl() {
|
|
|
36787
36923
|
return (process.env["HYPERFRAMES_PUBLISHED_PROJECTS_API_URL"] || process.env["HEYGEN_API_URL"] || "https://api2.heygen.com").replace(/\/$/, "");
|
|
36788
36924
|
}
|
|
36789
36925
|
async function publishProjectArchive(projectDir) {
|
|
36790
|
-
const title =
|
|
36926
|
+
const title = basename7(projectDir);
|
|
36791
36927
|
const archive = createPublishArchive(projectDir);
|
|
36792
36928
|
const archiveBytes = new Uint8Array(archive.buffer.byteLength);
|
|
36793
36929
|
archiveBytes.set(archive.buffer);
|
|
@@ -36831,9 +36967,9 @@ __export(publish_exports, {
|
|
|
36831
36967
|
default: () => publish_default,
|
|
36832
36968
|
examples: () => examples6
|
|
36833
36969
|
});
|
|
36834
|
-
import { basename as
|
|
36970
|
+
import { basename as basename8, resolve as resolve27 } from "path";
|
|
36835
36971
|
import { existsSync as existsSync39 } from "fs";
|
|
36836
|
-
import { join as
|
|
36972
|
+
import { join as join39 } from "path";
|
|
36837
36973
|
var examples6, publish_default;
|
|
36838
36974
|
var init_publish = __esm({
|
|
36839
36975
|
"src/commands/publish.ts"() {
|
|
@@ -36867,8 +37003,8 @@ var init_publish = __esm({
|
|
|
36867
37003
|
const rawArg = args.dir;
|
|
36868
37004
|
const dir = resolve27(rawArg ?? ".");
|
|
36869
37005
|
const isImplicitCwd = !rawArg || rawArg === "." || rawArg === "./";
|
|
36870
|
-
const projectName = isImplicitCwd ?
|
|
36871
|
-
const indexPath =
|
|
37006
|
+
const projectName = isImplicitCwd ? basename8(process.env["PWD"] ?? dir) : basename8(dir);
|
|
37007
|
+
const indexPath = join39(dir, "index.html");
|
|
36872
37008
|
if (existsSync39(indexPath)) {
|
|
36873
37009
|
const lintResult = lintProject({ dir, name: projectName, indexPath });
|
|
36874
37010
|
if (lintResult.totalErrors > 0 || lintResult.totalWarnings > 0) {
|
|
@@ -37040,9 +37176,9 @@ __export(render_exports, {
|
|
|
37040
37176
|
default: () => render_default,
|
|
37041
37177
|
examples: () => examples7
|
|
37042
37178
|
});
|
|
37043
|
-
import { mkdirSync as mkdirSync21, readFileSync as readFileSync28, statSync as statSync13, writeFileSync as
|
|
37044
|
-
import { cpus as cpus3, freemem as freemem3, tmpdir as
|
|
37045
|
-
import { resolve as resolve28, dirname as dirname16, join as
|
|
37179
|
+
import { mkdirSync as mkdirSync21, readFileSync as readFileSync28, statSync as statSync13, writeFileSync as writeFileSync15, rmSync as rmSync9 } from "fs";
|
|
37180
|
+
import { cpus as cpus3, freemem as freemem3, tmpdir as tmpdir4 } from "os";
|
|
37181
|
+
import { resolve as resolve28, dirname as dirname16, join as join40, basename as basename9 } from "path";
|
|
37046
37182
|
import { execFileSync as execFileSync5, spawn as spawn10 } from "child_process";
|
|
37047
37183
|
function defaultWorkerCount() {
|
|
37048
37184
|
return Math.max(1, Math.min(Math.floor(CPU_CORE_COUNT * 3 / 4), 8));
|
|
@@ -37079,9 +37215,9 @@ function ensureDockerImage(version, quiet) {
|
|
|
37079
37215
|
}
|
|
37080
37216
|
if (!quiet) console.log(c.dim(` Building Docker image: ${tag}...`));
|
|
37081
37217
|
const dockerfilePath = resolveDockerfilePath();
|
|
37082
|
-
const tmpDir =
|
|
37218
|
+
const tmpDir = join40(tmpdir4(), `hyperframes-docker-${Date.now()}`);
|
|
37083
37219
|
mkdirSync21(tmpDir, { recursive: true });
|
|
37084
|
-
|
|
37220
|
+
writeFileSync15(join40(tmpDir, "Dockerfile"), readFileSync28(dockerfilePath));
|
|
37085
37221
|
try {
|
|
37086
37222
|
execFileSync5(
|
|
37087
37223
|
"docker",
|
|
@@ -37101,7 +37237,7 @@ function ensureDockerImage(version, quiet) {
|
|
|
37101
37237
|
const message = error instanceof Error ? error.message : String(error);
|
|
37102
37238
|
throw new Error(`Failed to build Docker image: ${message}`);
|
|
37103
37239
|
} finally {
|
|
37104
|
-
|
|
37240
|
+
rmSync9(tmpDir, { recursive: true, force: true });
|
|
37105
37241
|
}
|
|
37106
37242
|
if (!quiet) console.log(c.dim(` Docker image: ${tag} (built)`));
|
|
37107
37243
|
return tag;
|
|
@@ -37126,7 +37262,7 @@ async function renderDocker(projectDir, outputPath, options) {
|
|
|
37126
37262
|
process.exit(1);
|
|
37127
37263
|
}
|
|
37128
37264
|
const outputDir = dirname16(outputPath);
|
|
37129
|
-
const outputFilename =
|
|
37265
|
+
const outputFilename = basename9(outputPath);
|
|
37130
37266
|
const dockerArgs = buildDockerRunArgs({
|
|
37131
37267
|
imageTag,
|
|
37132
37268
|
projectDir: resolve28(projectDir),
|
|
@@ -37410,7 +37546,7 @@ var init_render2 = __esm({
|
|
|
37410
37546
|
const now = /* @__PURE__ */ new Date();
|
|
37411
37547
|
const datePart = now.toISOString().slice(0, 10);
|
|
37412
37548
|
const timePart = now.toTimeString().slice(0, 8).replace(/:/g, "-");
|
|
37413
|
-
const outputPath = args.output ? resolve28(args.output) :
|
|
37549
|
+
const outputPath = args.output ? resolve28(args.output) : join40(rendersDir, `${project.name}_${datePart}_${timePart}${ext}`);
|
|
37414
37550
|
mkdirSync21(dirname16(outputPath), { recursive: true });
|
|
37415
37551
|
const useDocker = args.docker ?? false;
|
|
37416
37552
|
const useGpu = args.gpu ?? false;
|
|
@@ -37759,11 +37895,11 @@ __export(info_exports, {
|
|
|
37759
37895
|
examples: () => examples9
|
|
37760
37896
|
});
|
|
37761
37897
|
import { readFileSync as readFileSync29, readdirSync as readdirSync14, statSync as statSync14 } from "fs";
|
|
37762
|
-
import { join as
|
|
37898
|
+
import { join as join41 } from "path";
|
|
37763
37899
|
function totalSize(dir) {
|
|
37764
37900
|
let total = 0;
|
|
37765
37901
|
for (const entry of readdirSync14(dir, { withFileTypes: true })) {
|
|
37766
|
-
const path2 =
|
|
37902
|
+
const path2 = join41(dir, entry.name);
|
|
37767
37903
|
if (entry.isDirectory()) {
|
|
37768
37904
|
total += totalSize(path2);
|
|
37769
37905
|
} else {
|
|
@@ -37999,7 +38135,7 @@ __export(benchmark_exports, {
|
|
|
37999
38135
|
examples: () => examples11
|
|
38000
38136
|
});
|
|
38001
38137
|
import { existsSync as existsSync41, statSync as statSync15 } from "fs";
|
|
38002
|
-
import { resolve as resolve30, join as
|
|
38138
|
+
import { resolve as resolve30, join as join42 } from "path";
|
|
38003
38139
|
var examples11, DEFAULT_CONFIGS, benchmark_default;
|
|
38004
38140
|
var init_benchmark = __esm({
|
|
38005
38141
|
"src/commands/benchmark.ts"() {
|
|
@@ -38074,7 +38210,7 @@ var init_benchmark = __esm({
|
|
|
38074
38210
|
s2?.start(`Benchmarking ${config.label}...`);
|
|
38075
38211
|
for (let i2 = 0; i2 < runsPerConfig; i2++) {
|
|
38076
38212
|
s2?.message(`${config.label} \u2014 run ${i2 + 1}/${runsPerConfig}`);
|
|
38077
|
-
const outputPath =
|
|
38213
|
+
const outputPath = join42(
|
|
38078
38214
|
benchDir,
|
|
38079
38215
|
`${config.label.replace(/[^a-zA-Z0-9]/g, "_")}_run${i2}.mp4`
|
|
38080
38216
|
);
|
|
@@ -38304,8 +38440,8 @@ __export(transcribe_exports2, {
|
|
|
38304
38440
|
default: () => transcribe_default,
|
|
38305
38441
|
examples: () => examples13
|
|
38306
38442
|
});
|
|
38307
|
-
import { existsSync as existsSync42, writeFileSync as
|
|
38308
|
-
import { resolve as resolve31, join as
|
|
38443
|
+
import { existsSync as existsSync42, writeFileSync as writeFileSync16 } from "fs";
|
|
38444
|
+
import { resolve as resolve31, join as join43, extname as extname8 } from "path";
|
|
38309
38445
|
async function importTranscript(inputPath, dir, json) {
|
|
38310
38446
|
const { loadTranscript: loadTranscript2, patchCaptionHtml: patchCaptionHtml2 } = await Promise.resolve().then(() => (init_normalize(), normalize_exports));
|
|
38311
38447
|
const { words, format } = loadTranscript2(inputPath);
|
|
@@ -38313,8 +38449,8 @@ async function importTranscript(inputPath, dir, json) {
|
|
|
38313
38449
|
console.error(c.error("No words found in transcript."));
|
|
38314
38450
|
process.exit(1);
|
|
38315
38451
|
}
|
|
38316
|
-
const outPath =
|
|
38317
|
-
|
|
38452
|
+
const outPath = join43(dir, "transcript.json");
|
|
38453
|
+
writeFileSync16(outPath, JSON.stringify(words, null, 2));
|
|
38318
38454
|
patchCaptionHtml2(dir, words);
|
|
38319
38455
|
if (json) {
|
|
38320
38456
|
console.log(
|
|
@@ -38349,7 +38485,7 @@ async function transcribeAudio(inputPath, dir, opts) {
|
|
|
38349
38485
|
);
|
|
38350
38486
|
}
|
|
38351
38487
|
}
|
|
38352
|
-
|
|
38488
|
+
writeFileSync16(result.transcriptPath, JSON.stringify(words, null, 2));
|
|
38353
38489
|
patchCaptionHtml2(dir, words);
|
|
38354
38490
|
if (opts.json) {
|
|
38355
38491
|
console.log(
|
|
@@ -38453,7 +38589,7 @@ var init_transcribe2 = __esm({
|
|
|
38453
38589
|
// src/tts/manager.ts
|
|
38454
38590
|
import { existsSync as existsSync43, mkdirSync as mkdirSync22 } from "fs";
|
|
38455
38591
|
import { homedir as homedir8 } from "os";
|
|
38456
|
-
import { join as
|
|
38592
|
+
import { join as join44 } from "path";
|
|
38457
38593
|
function inferLangFromVoiceId(voiceId) {
|
|
38458
38594
|
const first = voiceId.charAt(0).toLowerCase();
|
|
38459
38595
|
return VOICE_PREFIX_LANG[first] ?? "en-us";
|
|
@@ -38462,7 +38598,7 @@ function isSupportedLang(value) {
|
|
|
38462
38598
|
return SUPPORTED_LANGS.includes(value);
|
|
38463
38599
|
}
|
|
38464
38600
|
async function ensureModel2(model = DEFAULT_MODEL2, options) {
|
|
38465
|
-
const modelPath =
|
|
38601
|
+
const modelPath = join44(MODELS_DIR2, `${model}.onnx`);
|
|
38466
38602
|
if (existsSync43(modelPath)) return modelPath;
|
|
38467
38603
|
const url = MODEL_URLS[model];
|
|
38468
38604
|
if (!url) {
|
|
@@ -38479,7 +38615,7 @@ async function ensureModel2(model = DEFAULT_MODEL2, options) {
|
|
|
38479
38615
|
return modelPath;
|
|
38480
38616
|
}
|
|
38481
38617
|
async function ensureVoices(options) {
|
|
38482
|
-
const voicesPath =
|
|
38618
|
+
const voicesPath = join44(VOICES_DIR, "voices-v1.0.bin");
|
|
38483
38619
|
if (existsSync43(voicesPath)) return voicesPath;
|
|
38484
38620
|
mkdirSync22(VOICES_DIR, { recursive: true });
|
|
38485
38621
|
options?.onProgress?.("Downloading voice data (~27 MB)...");
|
|
@@ -38494,9 +38630,9 @@ var init_manager3 = __esm({
|
|
|
38494
38630
|
"src/tts/manager.ts"() {
|
|
38495
38631
|
"use strict";
|
|
38496
38632
|
init_download();
|
|
38497
|
-
CACHE_DIR3 =
|
|
38498
|
-
MODELS_DIR2 =
|
|
38499
|
-
VOICES_DIR =
|
|
38633
|
+
CACHE_DIR3 = join44(homedir8(), ".cache", "hyperframes", "tts");
|
|
38634
|
+
MODELS_DIR2 = join44(CACHE_DIR3, "models");
|
|
38635
|
+
VOICES_DIR = join44(CACHE_DIR3, "voices");
|
|
38500
38636
|
DEFAULT_MODEL2 = "kokoro-v1.0";
|
|
38501
38637
|
MODEL_URLS = {
|
|
38502
38638
|
"kokoro-v1.0": "https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/kokoro-v1.0.onnx"
|
|
@@ -38557,8 +38693,8 @@ __export(synthesize_exports, {
|
|
|
38557
38693
|
synthesize: () => synthesize
|
|
38558
38694
|
});
|
|
38559
38695
|
import { execFileSync as execFileSync6 } from "child_process";
|
|
38560
|
-
import { existsSync as existsSync44, writeFileSync as
|
|
38561
|
-
import { join as
|
|
38696
|
+
import { existsSync as existsSync44, writeFileSync as writeFileSync17, mkdirSync as mkdirSync23, readdirSync as readdirSync15, unlinkSync as unlinkSync6 } from "fs";
|
|
38697
|
+
import { join as join45, dirname as dirname18, basename as basename10 } from "path";
|
|
38562
38698
|
import { homedir as homedir9 } from "os";
|
|
38563
38699
|
function findPython() {
|
|
38564
38700
|
for (const name of ["python3", "python"]) {
|
|
@@ -38596,13 +38732,13 @@ function hasPythonPackage(python, pkg) {
|
|
|
38596
38732
|
function ensureSynthScript() {
|
|
38597
38733
|
if (!existsSync44(SCRIPT_PATH)) {
|
|
38598
38734
|
mkdirSync23(SCRIPT_DIR, { recursive: true });
|
|
38599
|
-
|
|
38600
|
-
const currentName =
|
|
38735
|
+
writeFileSync17(SCRIPT_PATH, SYNTH_SCRIPT);
|
|
38736
|
+
const currentName = basename10(SCRIPT_PATH);
|
|
38601
38737
|
try {
|
|
38602
38738
|
for (const entry of readdirSync15(SCRIPT_DIR)) {
|
|
38603
38739
|
if (entry !== currentName && /^synth(-v\d+)?\.py$/.test(entry)) {
|
|
38604
38740
|
try {
|
|
38605
|
-
unlinkSync6(
|
|
38741
|
+
unlinkSync6(join45(SCRIPT_DIR, entry));
|
|
38606
38742
|
} catch {
|
|
38607
38743
|
}
|
|
38608
38744
|
}
|
|
@@ -38712,8 +38848,8 @@ print(json.dumps({
|
|
|
38712
38848
|
"langApplied": bool(lang and supports_lang),
|
|
38713
38849
|
}))
|
|
38714
38850
|
`;
|
|
38715
|
-
SCRIPT_DIR =
|
|
38716
|
-
SCRIPT_PATH =
|
|
38851
|
+
SCRIPT_DIR = join45(homedir9(), ".cache", "hyperframes", "tts");
|
|
38852
|
+
SCRIPT_PATH = join45(SCRIPT_DIR, "synth-v2.py");
|
|
38717
38853
|
}
|
|
38718
38854
|
});
|
|
38719
38855
|
|
|
@@ -38927,7 +39063,7 @@ __export(docs_exports, {
|
|
|
38927
39063
|
examples: () => examples15
|
|
38928
39064
|
});
|
|
38929
39065
|
import { readFileSync as readFileSync32, existsSync as existsSync46 } from "fs";
|
|
38930
|
-
import { resolve as resolve33, dirname as dirname19, join as
|
|
39066
|
+
import { resolve as resolve33, dirname as dirname19, join as join46 } from "path";
|
|
38931
39067
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
38932
39068
|
function docsDir() {
|
|
38933
39069
|
const thisFile = fileURLToPath6(import.meta.url);
|
|
@@ -39031,7 +39167,7 @@ var init_docs = __esm({
|
|
|
39031
39167
|
}
|
|
39032
39168
|
process.exit(1);
|
|
39033
39169
|
}
|
|
39034
|
-
const filePath =
|
|
39170
|
+
const filePath = join46(docsDir(), entry.file);
|
|
39035
39171
|
if (!existsSync46(filePath)) {
|
|
39036
39172
|
console.error(c.error(`Doc file not found: ${filePath}`));
|
|
39037
39173
|
process.exit(1);
|
|
@@ -39463,7 +39599,7 @@ __export(validate_exports, {
|
|
|
39463
39599
|
default: () => validate_default
|
|
39464
39600
|
});
|
|
39465
39601
|
import { existsSync as existsSync47, readFileSync as readFileSync33 } from "fs";
|
|
39466
|
-
import { resolve as resolve34, join as
|
|
39602
|
+
import { resolve as resolve34, join as join47, dirname as dirname20 } from "path";
|
|
39467
39603
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
39468
39604
|
async function getCompositionDuration2(page) {
|
|
39469
39605
|
return page.evaluate(() => {
|
|
@@ -39534,7 +39670,7 @@ async function validateInBrowser(projectDir, opts) {
|
|
|
39534
39670
|
res.end(html);
|
|
39535
39671
|
return;
|
|
39536
39672
|
}
|
|
39537
|
-
const filePath =
|
|
39673
|
+
const filePath = join47(projectDir, decodeURIComponent(url));
|
|
39538
39674
|
if (existsSync47(filePath)) {
|
|
39539
39675
|
res.writeHead(200, { "Content-Type": getMimeType2(filePath) });
|
|
39540
39676
|
res.end(readFileSync33(filePath));
|
|
@@ -39728,13 +39864,13 @@ __export(snapshot_exports, {
|
|
|
39728
39864
|
examples: () => examples19
|
|
39729
39865
|
});
|
|
39730
39866
|
import { spawn as spawn11 } from "child_process";
|
|
39731
|
-
import { existsSync as existsSync48, mkdtempSync as
|
|
39732
|
-
import { tmpdir as
|
|
39733
|
-
import { resolve as resolve35, join as
|
|
39867
|
+
import { existsSync as existsSync48, mkdtempSync as mkdtempSync3, readFileSync as readFileSync34, mkdirSync as mkdirSync24, rmSync as rmSync10 } from "fs";
|
|
39868
|
+
import { tmpdir as tmpdir5 } from "os";
|
|
39869
|
+
import { resolve as resolve35, join as join48, dirname as dirname21, relative as relative5, isAbsolute as isAbsolute6 } from "path";
|
|
39734
39870
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
39735
39871
|
async function extractVideoFrameToBuffer(videoPath, timeSeconds) {
|
|
39736
|
-
const tmp =
|
|
39737
|
-
const outPath =
|
|
39872
|
+
const tmp = mkdtempSync3(join48(tmpdir5(), "hf-snapshot-frame-"));
|
|
39873
|
+
const outPath = join48(tmp, "frame.png");
|
|
39738
39874
|
try {
|
|
39739
39875
|
const result = await new Promise(
|
|
39740
39876
|
(resolvePromise) => {
|
|
@@ -39776,7 +39912,7 @@ async function extractVideoFrameToBuffer(videoPath, timeSeconds) {
|
|
|
39776
39912
|
return readFileSync34(outPath);
|
|
39777
39913
|
} finally {
|
|
39778
39914
|
try {
|
|
39779
|
-
|
|
39915
|
+
rmSync10(tmp, { recursive: true, force: true });
|
|
39780
39916
|
} catch {
|
|
39781
39917
|
}
|
|
39782
39918
|
}
|
|
@@ -39893,7 +40029,7 @@ async function captureSnapshots(projectDir, opts) {
|
|
|
39893
40029
|
return [];
|
|
39894
40030
|
}
|
|
39895
40031
|
const positions = opts.at?.length ? opts.at : numFrames === 1 ? [duration / 2] : Array.from({ length: numFrames }, (_2, i2) => i2 / (numFrames - 1) * duration);
|
|
39896
|
-
const snapshotDir =
|
|
40032
|
+
const snapshotDir = join48(projectDir, "snapshots");
|
|
39897
40033
|
mkdirSync24(snapshotDir, { recursive: true });
|
|
39898
40034
|
let injectVideoFramesBatch2 = null;
|
|
39899
40035
|
let syncVideoFrameVisibility2 = null;
|
|
@@ -39980,7 +40116,7 @@ async function captureSnapshots(projectDir, opts) {
|
|
|
39980
40116
|
}
|
|
39981
40117
|
const timeLabel = opts.at?.length ? `${time.toFixed(1)}s` : `${Math.round(time / duration * 100)}pct`;
|
|
39982
40118
|
const filename = `frame-${String(i2).padStart(2, "0")}-at-${timeLabel}.png`;
|
|
39983
|
-
const framePath =
|
|
40119
|
+
const framePath = join48(snapshotDir, filename);
|
|
39984
40120
|
await page.screenshot({ path: framePath, type: "png" });
|
|
39985
40121
|
savedPaths.push(`snapshots/${filename}`);
|
|
39986
40122
|
}
|
|
@@ -40065,14 +40201,14 @@ ${c.error("\u2717")} Snapshot failed: ${msg}`);
|
|
|
40065
40201
|
});
|
|
40066
40202
|
|
|
40067
40203
|
// src/capture/assetDownloader.ts
|
|
40068
|
-
import { writeFileSync as
|
|
40069
|
-
import { join as
|
|
40204
|
+
import { writeFileSync as writeFileSync18, mkdirSync as mkdirSync25 } from "fs";
|
|
40205
|
+
import { join as join49, extname as extname10 } from "path";
|
|
40070
40206
|
async function downloadAssets(tokens, outputDir, catalogedAssets, faviconLinks) {
|
|
40071
|
-
const assetsDir =
|
|
40207
|
+
const assetsDir = join49(outputDir, "assets");
|
|
40072
40208
|
mkdirSync25(assetsDir, { recursive: true });
|
|
40073
40209
|
const assets = [];
|
|
40074
40210
|
const downloadedUrls = /* @__PURE__ */ new Set();
|
|
40075
|
-
mkdirSync25(
|
|
40211
|
+
mkdirSync25(join49(outputDir, "assets", "svgs"), { recursive: true });
|
|
40076
40212
|
for (let i2 = 0; i2 < tokens.svgs.length && i2 < 30; i2++) {
|
|
40077
40213
|
const svg = tokens.svgs[i2];
|
|
40078
40214
|
if (!svg.outerHTML || svg.outerHTML.length < 50) continue;
|
|
@@ -40080,7 +40216,7 @@ async function downloadAssets(tokens, outputDir, catalogedAssets, faviconLinks)
|
|
|
40080
40216
|
const name = label2 ? slugify(label2) + ".svg" : svg.isLogo ? `logo-${i2}.svg` : `icon-${i2}.svg`;
|
|
40081
40217
|
const localPath = `assets/svgs/${name}`;
|
|
40082
40218
|
try {
|
|
40083
|
-
|
|
40219
|
+
writeFileSync18(join49(outputDir, localPath), svg.outerHTML, "utf-8");
|
|
40084
40220
|
assets.push({ url: "", localPath, type: "svg" });
|
|
40085
40221
|
} catch {
|
|
40086
40222
|
}
|
|
@@ -40093,7 +40229,7 @@ async function downloadAssets(tokens, outputDir, catalogedAssets, faviconLinks)
|
|
|
40093
40229
|
const localPath = `assets/${name}`;
|
|
40094
40230
|
const buffer = await fetchBuffer(icon.href);
|
|
40095
40231
|
if (buffer) {
|
|
40096
|
-
|
|
40232
|
+
writeFileSync18(join49(outputDir, localPath), buffer);
|
|
40097
40233
|
assets.push({ url: icon.href, localPath, type: "favicon" });
|
|
40098
40234
|
break;
|
|
40099
40235
|
}
|
|
@@ -40150,7 +40286,7 @@ async function downloadAssets(tokens, outputDir, catalogedAssets, faviconLinks)
|
|
|
40150
40286
|
const slug = isMeaningful ? slugify(rawName) : `${prefix}-${imgIdx}`;
|
|
40151
40287
|
const name = `${slug}${ext}`;
|
|
40152
40288
|
const localPath = `assets/${name}`;
|
|
40153
|
-
|
|
40289
|
+
writeFileSync18(join49(outputDir, localPath), buffer);
|
|
40154
40290
|
assets.push({ url, localPath, type: "image" });
|
|
40155
40291
|
imgIdx++;
|
|
40156
40292
|
} catch {
|
|
@@ -40163,7 +40299,7 @@ async function downloadAssets(tokens, outputDir, catalogedAssets, faviconLinks)
|
|
|
40163
40299
|
const localPath = `assets/og-image${ext}`;
|
|
40164
40300
|
const buffer = await fetchBuffer(tokens.ogImage);
|
|
40165
40301
|
if (buffer && buffer.length > 5e3) {
|
|
40166
|
-
|
|
40302
|
+
writeFileSync18(join49(outputDir, localPath), buffer);
|
|
40167
40303
|
assets.push({ url: tokens.ogImage, localPath, type: "image" });
|
|
40168
40304
|
}
|
|
40169
40305
|
} catch {
|
|
@@ -40186,7 +40322,7 @@ function normalizeUrl(u) {
|
|
|
40186
40322
|
}
|
|
40187
40323
|
}
|
|
40188
40324
|
async function downloadAndRewriteFonts(css, outputDir) {
|
|
40189
|
-
const assetsDir =
|
|
40325
|
+
const assetsDir = join49(outputDir, "assets", "fonts");
|
|
40190
40326
|
mkdirSync25(assetsDir, { recursive: true });
|
|
40191
40327
|
const fontUrlRegex = /url\(['"]?(https?:\/\/[^'")\s]+\.(?:woff2?|ttf|otf)[^'")\s]*?)['"]?\)/g;
|
|
40192
40328
|
const fontUrls = /* @__PURE__ */ new Set();
|
|
@@ -40222,11 +40358,11 @@ async function downloadAndRewriteFonts(css, outputDir) {
|
|
|
40222
40358
|
try {
|
|
40223
40359
|
const urlObj = new URL(fontUrl);
|
|
40224
40360
|
const filename = urlObj.pathname.split("/").pop() || `font-${count}.woff2`;
|
|
40225
|
-
const localPath =
|
|
40361
|
+
const localPath = join49(assetsDir, filename);
|
|
40226
40362
|
const relativePath = `assets/fonts/${filename}`;
|
|
40227
40363
|
const buffer = await fetchBuffer(fontUrl);
|
|
40228
40364
|
if (buffer) {
|
|
40229
|
-
|
|
40365
|
+
writeFileSync18(localPath, buffer);
|
|
40230
40366
|
rewritten = rewritten.split(fontUrl).join(relativePath);
|
|
40231
40367
|
familyCounts.set(family, familyCount + 1);
|
|
40232
40368
|
count++;
|
|
@@ -41019,8 +41155,8 @@ var init_animationCataloger = __esm({
|
|
|
41019
41155
|
});
|
|
41020
41156
|
|
|
41021
41157
|
// src/capture/mediaCapture.ts
|
|
41022
|
-
import { mkdirSync as mkdirSync26, writeFileSync as
|
|
41023
|
-
import { join as
|
|
41158
|
+
import { mkdirSync as mkdirSync26, writeFileSync as writeFileSync19, readdirSync as readdirSync16, readFileSync as readFileSync35, statSync as statSync16 } from "fs";
|
|
41159
|
+
import { join as join50 } from "path";
|
|
41024
41160
|
async function saveLottieAnimations(discoveredLotties, lottieDir) {
|
|
41025
41161
|
let savedCount = 0;
|
|
41026
41162
|
const savedHashes = /* @__PURE__ */ new Set();
|
|
@@ -41053,7 +41189,7 @@ async function saveLottieAnimations(discoveredLotties, lottieDir) {
|
|
|
41053
41189
|
const hash2 = buf.toString("base64").slice(0, 100);
|
|
41054
41190
|
if (savedHashes.has(hash2)) continue;
|
|
41055
41191
|
savedHashes.add(hash2);
|
|
41056
|
-
|
|
41192
|
+
writeFileSync19(join50(lottieDir, `animation-${savedCount}.lottie`), buf);
|
|
41057
41193
|
savedCount++;
|
|
41058
41194
|
continue;
|
|
41059
41195
|
}
|
|
@@ -41071,7 +41207,7 @@ async function saveLottieAnimations(discoveredLotties, lottieDir) {
|
|
|
41071
41207
|
} catch {
|
|
41072
41208
|
continue;
|
|
41073
41209
|
}
|
|
41074
|
-
|
|
41210
|
+
writeFileSync19(join50(lottieDir, `animation-${savedCount}.json`), jsonData, "utf-8");
|
|
41075
41211
|
savedCount++;
|
|
41076
41212
|
}
|
|
41077
41213
|
} catch {
|
|
@@ -41081,22 +41217,22 @@ async function saveLottieAnimations(discoveredLotties, lottieDir) {
|
|
|
41081
41217
|
}
|
|
41082
41218
|
async function renderLottiePreviews(chromeBrowser, lottieDir, outputDir) {
|
|
41083
41219
|
const manifest = [];
|
|
41084
|
-
const previewDir =
|
|
41220
|
+
const previewDir = join50(lottieDir, "previews");
|
|
41085
41221
|
mkdirSync26(previewDir, { recursive: true });
|
|
41086
41222
|
for (const file of readdirSync16(lottieDir)) {
|
|
41087
41223
|
if (!file.endsWith(".json")) continue;
|
|
41088
41224
|
try {
|
|
41089
|
-
const raw = JSON.parse(readFileSync35(
|
|
41225
|
+
const raw = JSON.parse(readFileSync35(join50(lottieDir, file), "utf-8"));
|
|
41090
41226
|
const fr = raw.fr || 30;
|
|
41091
41227
|
const dur = ((raw.op || 0) - (raw.ip || 0)) / fr;
|
|
41092
41228
|
const previewName = file.replace(".json", "-preview.png");
|
|
41093
|
-
const fileSize = statSync16(
|
|
41229
|
+
const fileSize = statSync16(join50(lottieDir, file)).size;
|
|
41094
41230
|
if (fileSize > 2e6) continue;
|
|
41095
41231
|
let previewPage;
|
|
41096
41232
|
try {
|
|
41097
41233
|
previewPage = await chromeBrowser.newPage();
|
|
41098
41234
|
await previewPage.setViewport({ width: 400, height: 400 });
|
|
41099
|
-
const animData = JSON.parse(readFileSync35(
|
|
41235
|
+
const animData = JSON.parse(readFileSync35(join50(lottieDir, file), "utf-8"));
|
|
41100
41236
|
const midFrame = Math.floor(((raw.op || 0) - (raw.ip || 0)) * 0.3);
|
|
41101
41237
|
await previewPage.setContent(
|
|
41102
41238
|
`<!DOCTYPE html>
|
|
@@ -41126,7 +41262,7 @@ async function renderLottiePreviews(chromeBrowser, lottieDir, outputDir) {
|
|
|
41126
41262
|
await previewPage.waitForFunction(() => window.__READY === true, { timeout: 5e3 }).catch(() => {
|
|
41127
41263
|
});
|
|
41128
41264
|
await previewPage.screenshot({
|
|
41129
|
-
path:
|
|
41265
|
+
path: join50(previewDir, previewName),
|
|
41130
41266
|
type: "png",
|
|
41131
41267
|
omitBackground: true
|
|
41132
41268
|
});
|
|
@@ -41149,8 +41285,8 @@ async function renderLottiePreviews(chromeBrowser, lottieDir, outputDir) {
|
|
|
41149
41285
|
}
|
|
41150
41286
|
}
|
|
41151
41287
|
if (manifest.length > 0) {
|
|
41152
|
-
|
|
41153
|
-
|
|
41288
|
+
writeFileSync19(
|
|
41289
|
+
join50(outputDir, "extracted", "lottie-manifest.json"),
|
|
41154
41290
|
JSON.stringify(manifest, null, 2),
|
|
41155
41291
|
"utf-8"
|
|
41156
41292
|
);
|
|
@@ -41212,15 +41348,15 @@ async function captureVideoManifest(page, outputDir, progress) {
|
|
|
41212
41348
|
return true;
|
|
41213
41349
|
});
|
|
41214
41350
|
if (uniqueVideos.length > 0) {
|
|
41215
|
-
const videoManifestDir =
|
|
41351
|
+
const videoManifestDir = join50(outputDir, "assets", "videos");
|
|
41216
41352
|
mkdirSync26(videoManifestDir, { recursive: true });
|
|
41217
|
-
const previewDir =
|
|
41353
|
+
const previewDir = join50(videoManifestDir, "previews");
|
|
41218
41354
|
mkdirSync26(previewDir, { recursive: true });
|
|
41219
41355
|
const videoManifest = [];
|
|
41220
41356
|
for (let vi = 0; vi < uniqueVideos.length && vi < 20; vi++) {
|
|
41221
41357
|
const v = uniqueVideos[vi];
|
|
41222
41358
|
const previewName = `video-${vi}-preview.png`;
|
|
41223
|
-
const previewPath =
|
|
41359
|
+
const previewPath = join50(previewDir, previewName);
|
|
41224
41360
|
try {
|
|
41225
41361
|
await page.evaluate(`window.scrollTo(0, ${Math.max(0, v.top - 100)})`);
|
|
41226
41362
|
await new Promise((r2) => setTimeout(r2, 300));
|
|
@@ -41258,8 +41394,8 @@ async function captureVideoManifest(page, outputDir, progress) {
|
|
|
41258
41394
|
});
|
|
41259
41395
|
}
|
|
41260
41396
|
if (videoManifest.length > 0) {
|
|
41261
|
-
|
|
41262
|
-
|
|
41397
|
+
writeFileSync19(
|
|
41398
|
+
join50(outputDir, "extracted", "video-manifest.json"),
|
|
41263
41399
|
JSON.stringify(videoManifest, null, 2),
|
|
41264
41400
|
"utf-8"
|
|
41265
41401
|
);
|
|
@@ -48214,7 +48350,7 @@ var require_node_domexception = __commonJS({
|
|
|
48214
48350
|
|
|
48215
48351
|
// ../../node_modules/.bun/fetch-blob@3.2.0/node_modules/fetch-blob/from.js
|
|
48216
48352
|
import { statSync as statSync17, createReadStream as createReadStream2, promises as fs2 } from "fs";
|
|
48217
|
-
import { basename as
|
|
48353
|
+
import { basename as basename11 } from "path";
|
|
48218
48354
|
var import_node_domexception, stat, blobFromSync, blobFrom, fileFrom, fileFromSync, fromBlob, fromFile, BlobDataItem;
|
|
48219
48355
|
var init_from = __esm({
|
|
48220
48356
|
"../../node_modules/.bun/fetch-blob@3.2.0/node_modules/fetch-blob/from.js"() {
|
|
@@ -48238,7 +48374,7 @@ var init_from = __esm({
|
|
|
48238
48374
|
size: stat3.size,
|
|
48239
48375
|
lastModified: stat3.mtimeMs,
|
|
48240
48376
|
start: 0
|
|
48241
|
-
})],
|
|
48377
|
+
})], basename11(path2), { type, lastModified: stat3.mtimeMs });
|
|
48242
48378
|
BlobDataItem = class _BlobDataItem {
|
|
48243
48379
|
#path;
|
|
48244
48380
|
#start;
|
|
@@ -81715,7 +81851,7 @@ ${underline2}`);
|
|
|
81715
81851
|
|
|
81716
81852
|
// src/capture/contentExtractor.ts
|
|
81717
81853
|
import { readdirSync as readdirSync17, statSync as statSync18, readFileSync as readFileSync36 } from "fs";
|
|
81718
|
-
import { join as
|
|
81854
|
+
import { join as join51 } from "path";
|
|
81719
81855
|
async function detectLibraries(page, capturedShaders) {
|
|
81720
81856
|
let detectedLibraries = [];
|
|
81721
81857
|
try {
|
|
@@ -81835,7 +81971,7 @@ async function captionImagesWithGemini(outputDir, progress, warnings) {
|
|
|
81835
81971
|
try {
|
|
81836
81972
|
const { GoogleGenAI: GoogleGenAI2 } = await Promise.resolve().then(() => (init_node4(), node_exports));
|
|
81837
81973
|
const ai = new GoogleGenAI2({ apiKey: geminiKey });
|
|
81838
|
-
const imageFiles = readdirSync17(
|
|
81974
|
+
const imageFiles = readdirSync17(join51(outputDir, "assets")).filter(
|
|
81839
81975
|
(f3) => /\.(png|jpg|jpeg|webp|gif)$/i.test(f3)
|
|
81840
81976
|
);
|
|
81841
81977
|
const model = process.env.HYPERFRAMES_GEMINI_MODEL || "gemini-3.1-flash-lite-preview";
|
|
@@ -81844,7 +81980,7 @@ async function captionImagesWithGemini(outputDir, progress, warnings) {
|
|
|
81844
81980
|
const batch = imageFiles.slice(i2, i2 + BATCH_SIZE);
|
|
81845
81981
|
const results = await Promise.allSettled(
|
|
81846
81982
|
batch.map(async (file) => {
|
|
81847
|
-
const filePath =
|
|
81983
|
+
const filePath = join51(outputDir, "assets", file);
|
|
81848
81984
|
const stat3 = statSync18(filePath);
|
|
81849
81985
|
if (stat3.size > 4e6) return { file, caption: "" };
|
|
81850
81986
|
const buffer = readFileSync36(filePath);
|
|
@@ -81893,11 +82029,11 @@ function generateAssetDescriptions(outputDir, tokens, catalogedAssets, geminiCap
|
|
|
81893
82029
|
const uncaptionedLines = [];
|
|
81894
82030
|
const svgLines = [];
|
|
81895
82031
|
const fontLines = [];
|
|
81896
|
-
const assetsPath =
|
|
82032
|
+
const assetsPath = join51(outputDir, "assets");
|
|
81897
82033
|
try {
|
|
81898
82034
|
for (const file of readdirSync17(assetsPath)) {
|
|
81899
82035
|
if (file === "svgs" || file === "fonts" || file === "lottie" || file === "videos") continue;
|
|
81900
|
-
const filePath =
|
|
82036
|
+
const filePath = join51(assetsPath, file);
|
|
81901
82037
|
const stat3 = statSync18(filePath);
|
|
81902
82038
|
if (!stat3.isFile()) continue;
|
|
81903
82039
|
const sizeKb = Math.round(stat3.size / 1024);
|
|
@@ -81926,7 +82062,7 @@ function generateAssetDescriptions(outputDir, tokens, catalogedAssets, geminiCap
|
|
|
81926
82062
|
} catch {
|
|
81927
82063
|
}
|
|
81928
82064
|
try {
|
|
81929
|
-
const svgsPath =
|
|
82065
|
+
const svgsPath = join51(assetsPath, "svgs");
|
|
81930
82066
|
for (const file of readdirSync17(svgsPath)) {
|
|
81931
82067
|
if (!file.endsWith(".svg")) continue;
|
|
81932
82068
|
const svgMatch = tokens.svgs.find(
|
|
@@ -81941,7 +82077,7 @@ function generateAssetDescriptions(outputDir, tokens, catalogedAssets, geminiCap
|
|
|
81941
82077
|
} catch {
|
|
81942
82078
|
}
|
|
81943
82079
|
try {
|
|
81944
|
-
const fontsPath =
|
|
82080
|
+
const fontsPath = join51(assetsPath, "fonts");
|
|
81945
82081
|
for (const file of readdirSync17(fontsPath)) {
|
|
81946
82082
|
fontLines.push(`fonts/${file} \u2014 font file`);
|
|
81947
82083
|
}
|
|
@@ -81960,13 +82096,13 @@ var agentPromptGenerator_exports = {};
|
|
|
81960
82096
|
__export(agentPromptGenerator_exports, {
|
|
81961
82097
|
generateAgentPrompt: () => generateAgentPrompt
|
|
81962
82098
|
});
|
|
81963
|
-
import { writeFileSync as
|
|
81964
|
-
import { join as
|
|
82099
|
+
import { writeFileSync as writeFileSync20 } from "fs";
|
|
82100
|
+
import { join as join52 } from "path";
|
|
81965
82101
|
function generateAgentPrompt(outputDir, url, tokens, _animations, hasScreenshot, hasLottie, hasShaders, _catalogedAssets, detectedLibraries) {
|
|
81966
82102
|
const prompt = buildPrompt(url, tokens, hasScreenshot, hasLottie, hasShaders, detectedLibraries);
|
|
81967
|
-
|
|
81968
|
-
|
|
81969
|
-
|
|
82103
|
+
writeFileSync20(join52(outputDir, "AGENTS.md"), prompt, "utf-8");
|
|
82104
|
+
writeFileSync20(join52(outputDir, "CLAUDE.md"), prompt, "utf-8");
|
|
82105
|
+
writeFileSync20(join52(outputDir, ".cursorrules"), prompt, "utf-8");
|
|
81970
82106
|
}
|
|
81971
82107
|
function buildPrompt(url, tokens, hasScreenshot, hasLottie, hasShaders, detectedLibraries) {
|
|
81972
82108
|
const title = tokens.title || new URL(url).hostname.replace(/^www\./, "");
|
|
@@ -82033,8 +82169,8 @@ var init_agentPromptGenerator = __esm({
|
|
|
82033
82169
|
});
|
|
82034
82170
|
|
|
82035
82171
|
// src/capture/scaffolding.ts
|
|
82036
|
-
import { existsSync as existsSync49, writeFileSync as
|
|
82037
|
-
import { join as
|
|
82172
|
+
import { existsSync as existsSync49, writeFileSync as writeFileSync21, readFileSync as readFileSync37 } from "fs";
|
|
82173
|
+
import { join as join53, resolve as resolve36 } from "path";
|
|
82038
82174
|
function loadEnvFile(startDir) {
|
|
82039
82175
|
try {
|
|
82040
82176
|
let dir = resolve36(startDir);
|
|
@@ -82060,10 +82196,10 @@ function loadEnvFile(startDir) {
|
|
|
82060
82196
|
}
|
|
82061
82197
|
}
|
|
82062
82198
|
async function generateProjectScaffold(outputDir, url, tokens, animationCatalog, hasScreenshots, hasLotties, hasShaders, catalogedAssets, progress, warnings, detectedLibraries) {
|
|
82063
|
-
const metaPath =
|
|
82199
|
+
const metaPath = join53(outputDir, "meta.json");
|
|
82064
82200
|
if (!existsSync49(metaPath)) {
|
|
82065
82201
|
const hostname = new URL(url).hostname.replace(/^www\./, "");
|
|
82066
|
-
|
|
82202
|
+
writeFileSync21(
|
|
82067
82203
|
metaPath,
|
|
82068
82204
|
JSON.stringify({ id: hostname + "-video", name: tokens.title || hostname }, null, 2),
|
|
82069
82205
|
"utf-8"
|
|
@@ -82098,10 +82234,10 @@ var screenshotCapture_exports = {};
|
|
|
82098
82234
|
__export(screenshotCapture_exports, {
|
|
82099
82235
|
captureScrollScreenshots: () => captureScrollScreenshots
|
|
82100
82236
|
});
|
|
82101
|
-
import { writeFileSync as
|
|
82102
|
-
import { join as
|
|
82237
|
+
import { writeFileSync as writeFileSync22, mkdirSync as mkdirSync27 } from "fs";
|
|
82238
|
+
import { join as join54 } from "path";
|
|
82103
82239
|
async function captureScrollScreenshots(page, outputDir) {
|
|
82104
|
-
const screenshotsDir =
|
|
82240
|
+
const screenshotsDir = join54(outputDir, "screenshots");
|
|
82105
82241
|
mkdirSync27(screenshotsDir, { recursive: true });
|
|
82106
82242
|
const MAX_SCREENSHOTS = 20;
|
|
82107
82243
|
const filePaths = [];
|
|
@@ -82135,9 +82271,9 @@ async function captureScrollScreenshots(page, outputDir) {
|
|
|
82135
82271
|
finalPositions[i2] / Math.max(1, scrollHeight - viewportHeight) * 100
|
|
82136
82272
|
);
|
|
82137
82273
|
const filename = `scroll-${String(Math.min(pct, 100)).padStart(3, "0")}.png`;
|
|
82138
|
-
const filePath =
|
|
82274
|
+
const filePath = join54(screenshotsDir, filename);
|
|
82139
82275
|
const buffer = await page.screenshot({ type: "png" });
|
|
82140
|
-
|
|
82276
|
+
writeFileSync22(filePath, buffer);
|
|
82141
82277
|
filePaths.push(`screenshots/${filename}`);
|
|
82142
82278
|
}
|
|
82143
82279
|
await page.evaluate(`window.scrollTo(0, 0)`);
|
|
@@ -82448,8 +82584,8 @@ var capture_exports = {};
|
|
|
82448
82584
|
__export(capture_exports, {
|
|
82449
82585
|
captureWebsite: () => captureWebsite
|
|
82450
82586
|
});
|
|
82451
|
-
import { mkdirSync as mkdirSync28, writeFileSync as
|
|
82452
|
-
import { join as
|
|
82587
|
+
import { mkdirSync as mkdirSync28, writeFileSync as writeFileSync23, existsSync as existsSync50 } from "fs";
|
|
82588
|
+
import { join as join55 } from "path";
|
|
82453
82589
|
async function captureWebsite(opts, onProgress) {
|
|
82454
82590
|
const {
|
|
82455
82591
|
url,
|
|
@@ -82466,9 +82602,9 @@ async function captureWebsite(opts, onProgress) {
|
|
|
82466
82602
|
onProgress?.(stage, detail);
|
|
82467
82603
|
};
|
|
82468
82604
|
loadEnvFile(outputDir);
|
|
82469
|
-
mkdirSync28(
|
|
82470
|
-
mkdirSync28(
|
|
82471
|
-
mkdirSync28(
|
|
82605
|
+
mkdirSync28(join55(outputDir, "extracted"), { recursive: true });
|
|
82606
|
+
mkdirSync28(join55(outputDir, "screenshots"), { recursive: true });
|
|
82607
|
+
mkdirSync28(join55(outputDir, "assets"), { recursive: true });
|
|
82472
82608
|
progress("browser", "Launching headless Chrome...");
|
|
82473
82609
|
const { ensureBrowser: ensureBrowser2 } = await Promise.resolve().then(() => (init_manager2(), manager_exports2));
|
|
82474
82610
|
const browser = await ensureBrowser2();
|
|
@@ -82624,7 +82760,7 @@ async function captureWebsite(opts, onProgress) {
|
|
|
82624
82760
|
} catch {
|
|
82625
82761
|
}
|
|
82626
82762
|
if (discoveredLotties.length > 0) {
|
|
82627
|
-
const lottieDir =
|
|
82763
|
+
const lottieDir = join55(outputDir, "assets", "lottie");
|
|
82628
82764
|
mkdirSync28(lottieDir, { recursive: true });
|
|
82629
82765
|
const savedCount = await saveLottieAnimations(discoveredLotties, lottieDir);
|
|
82630
82766
|
if (savedCount > 0) {
|
|
@@ -82643,8 +82779,8 @@ async function captureWebsite(opts, onProgress) {
|
|
|
82643
82779
|
return true;
|
|
82644
82780
|
});
|
|
82645
82781
|
capturedShaders = unique;
|
|
82646
|
-
|
|
82647
|
-
|
|
82782
|
+
writeFileSync23(
|
|
82783
|
+
join55(outputDir, "extracted", "shaders.json"),
|
|
82648
82784
|
JSON.stringify(unique, null, 2),
|
|
82649
82785
|
"utf-8"
|
|
82650
82786
|
);
|
|
@@ -82654,8 +82790,8 @@ async function captureWebsite(opts, onProgress) {
|
|
|
82654
82790
|
}
|
|
82655
82791
|
progress("tokens", "Extracting design tokens...");
|
|
82656
82792
|
const tokens = await extractTokens(page1);
|
|
82657
|
-
|
|
82658
|
-
|
|
82793
|
+
writeFileSync23(
|
|
82794
|
+
join55(outputDir, "extracted", "tokens.json"),
|
|
82659
82795
|
JSON.stringify(tokens, null, 2),
|
|
82660
82796
|
"utf-8"
|
|
82661
82797
|
);
|
|
@@ -82728,8 +82864,8 @@ async function captureWebsite(opts, onProgress) {
|
|
|
82728
82864
|
scrollTriggeredElements: (animationCatalog.scrollTargets || []).length,
|
|
82729
82865
|
representativeAnimations: representativeAnims
|
|
82730
82866
|
};
|
|
82731
|
-
|
|
82732
|
-
|
|
82867
|
+
writeFileSync23(
|
|
82868
|
+
join55(outputDir, "extracted", "animations.json"),
|
|
82733
82869
|
JSON.stringify(leanCatalog, null, 2),
|
|
82734
82870
|
"utf-8"
|
|
82735
82871
|
);
|
|
@@ -82740,18 +82876,18 @@ async function captureWebsite(opts, onProgress) {
|
|
|
82740
82876
|
assets = await downloadAssets(tokens, outputDir, catalogedAssets, faviconLinks);
|
|
82741
82877
|
}
|
|
82742
82878
|
if (visibleTextContent) {
|
|
82743
|
-
|
|
82879
|
+
writeFileSync23(join55(outputDir, "extracted", "visible-text.txt"), visibleTextContent, "utf-8");
|
|
82744
82880
|
}
|
|
82745
82881
|
if (catalogedAssets.length > 0) {
|
|
82746
|
-
|
|
82747
|
-
|
|
82882
|
+
writeFileSync23(
|
|
82883
|
+
join55(outputDir, "extracted", "assets-catalog.json"),
|
|
82748
82884
|
JSON.stringify(catalogedAssets, null, 2),
|
|
82749
82885
|
"utf-8"
|
|
82750
82886
|
);
|
|
82751
82887
|
}
|
|
82752
82888
|
if (detectedLibraries.length > 0) {
|
|
82753
|
-
|
|
82754
|
-
|
|
82889
|
+
writeFileSync23(
|
|
82890
|
+
join55(outputDir, "extracted", "detected-libraries.json"),
|
|
82755
82891
|
JSON.stringify(detectedLibraries, null, 2),
|
|
82756
82892
|
"utf-8"
|
|
82757
82893
|
);
|
|
@@ -82761,8 +82897,8 @@ async function captureWebsite(opts, onProgress) {
|
|
|
82761
82897
|
try {
|
|
82762
82898
|
const lines = generateAssetDescriptions(outputDir, tokens, catalogedAssets, geminiCaptions);
|
|
82763
82899
|
if (lines.length > 0) {
|
|
82764
|
-
|
|
82765
|
-
|
|
82900
|
+
writeFileSync23(
|
|
82901
|
+
join55(outputDir, "extracted", "asset-descriptions.md"),
|
|
82766
82902
|
"# Asset Descriptions\n\nOne line per file. Read this instead of opening every image individually.\n\n" + lines.map((l) => "- " + l).join("\n") + "\n",
|
|
82767
82903
|
"utf-8"
|
|
82768
82904
|
);
|
|
@@ -82778,7 +82914,7 @@ async function captureWebsite(opts, onProgress) {
|
|
|
82778
82914
|
animationCatalog,
|
|
82779
82915
|
screenshots.length > 0,
|
|
82780
82916
|
discoveredLotties.length > 0,
|
|
82781
|
-
existsSync50(
|
|
82917
|
+
existsSync50(join55(outputDir, "extracted", "shaders.json")),
|
|
82782
82918
|
catalogedAssets,
|
|
82783
82919
|
progress,
|
|
82784
82920
|
warnings,
|
|
@@ -82957,11 +83093,11 @@ var init_capture2 = __esm({
|
|
|
82957
83093
|
} catch (err) {
|
|
82958
83094
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
82959
83095
|
try {
|
|
82960
|
-
const { mkdirSync: mkdirSync30, writeFileSync:
|
|
83096
|
+
const { mkdirSync: mkdirSync30, writeFileSync: writeFileSync24 } = await import("fs");
|
|
82961
83097
|
mkdirSync30(outputDir, { recursive: true });
|
|
82962
83098
|
const isTimeout = /timeout|timed out/i.test(errMsg);
|
|
82963
83099
|
const reason = isTimeout ? "Page navigation timed out \u2014 the site may be blocking headless browsers or requires authentication." : `Capture failed: ${errMsg}`;
|
|
82964
|
-
|
|
83100
|
+
writeFileSync24(
|
|
82965
83101
|
`${outputDir}/BLOCKED.md`,
|
|
82966
83102
|
`# Capture Failed
|
|
82967
83103
|
|
|
@@ -83127,7 +83263,7 @@ __export(autoUpdate_exports, {
|
|
|
83127
83263
|
import { spawn as spawn12 } from "child_process";
|
|
83128
83264
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync29, openSync } from "fs";
|
|
83129
83265
|
import { homedir as homedir10 } from "os";
|
|
83130
|
-
import { join as
|
|
83266
|
+
import { join as join56 } from "path";
|
|
83131
83267
|
import { compareVersions as compareVersions2 } from "compare-versions";
|
|
83132
83268
|
function isAutoInstallDisabled() {
|
|
83133
83269
|
if (isDevMode()) return true;
|
|
@@ -83150,7 +83286,7 @@ function log(line) {
|
|
|
83150
83286
|
}
|
|
83151
83287
|
function launchDetachedInstall(installCommand, version) {
|
|
83152
83288
|
mkdirSync29(CONFIG_DIR2, { recursive: true, mode: 448 });
|
|
83153
|
-
const configFile =
|
|
83289
|
+
const configFile = join56(CONFIG_DIR2, "config.json");
|
|
83154
83290
|
const nodeScript = `
|
|
83155
83291
|
const { exec } = require("node:child_process");
|
|
83156
83292
|
const { readFileSync, renameSync, writeFileSync } = require("node:fs");
|
|
@@ -83269,8 +83405,8 @@ var init_autoUpdate = __esm({
|
|
|
83269
83405
|
init_config();
|
|
83270
83406
|
init_env();
|
|
83271
83407
|
init_installerDetection();
|
|
83272
|
-
CONFIG_DIR2 =
|
|
83273
|
-
LOG_FILE =
|
|
83408
|
+
CONFIG_DIR2 = join56(homedir10(), ".hyperframes");
|
|
83409
|
+
LOG_FILE = join56(CONFIG_DIR2, "auto-update.log");
|
|
83274
83410
|
PENDING_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
83275
83411
|
}
|
|
83276
83412
|
});
|