PageSourceSearch

https://app.zophous.ai/assets/RealLazyPreview-C2hXg0LR.js

js zophous.ai collected 2026-10-05 16:08:21 UTC 7,742 bytes, 1 lines download raw bytes

1import{r as i,j as s}from"./react-Ux6JKkVi.js";import{ar as Z,as as xe,at as ye,au as N,av as ee,aw as be,ax as ne,ay as se,g as ve,m as Se,az as ke,aA as L,aB as Me,aC as Pe,aD as Ee,aE as Re,aF as Ce,aG as Fe,aH as je}from"./opencut-77hmEi7z.js";import{loadEditorSession as _e}from"./session-BbE_N-SI.js";import{p as Ae,s as Ne}from"./bootstrap-BdpyyGbg.js";import{aO as Le,aE as Te}from"./index-BuVpVpcd.js";import{i as T,w as Be,t as te,c as ze,r as Ie}from"./previewOwner-D_IQH-7H.js";import{i as w}from"./coarsePointer-DRutzzb9.js";import"./helpers-Bpr93w1e.js";function qe(e){return e===null?"Loading preview…":`Loading preview… ${Math.round(e*100)}%`}const re=["pointerdown","keydown","touchend"];function Ge(e,l=window){let t=!1;const o=()=>{if(!t){t=!0;for(const c of re)l.removeEventListener(c,d)}};function d(){const c=e();c&&(c.state==="suspended"&&c.resume().catch(()=>{}),o())}for(const c of re)l.addEventListener(c,d);return o}function De({coarsePointer:e}){return e}const Oe=30;function We({fps:e,minFrameMs:l=0}){const t=e>0?e:Oe;let o=-1,d=-1/0;return{shouldRender(c,a){const u=Math.floor(c*t);return u===o||a-d<l?!1:(o=u,d=a,!0)},reset(){o=-1,d=-1/0}}}const Ue=33;function $e({slowFrameMs:e=Ue}={}){const l=[];return{recordRender(t){l.push(t)},summary(){const t=l.length;if(t===0)return{frames:0,avgRenderMs:0,p95RenderMs:0,maxRenderMs:0,slowFramePct:0};const o=[...l].sort((a,u)=>a-u),d=o.reduce((a,u)=>a+u,0),c=o.filter(a=>a>e).length;return{frames:t,avgRenderMs:Math.round(d/t),p95RenderMs:Math.round(o[Math.ceil(.95*t)-1]),maxRenderMs:Math.round(o[t-1]),slowFramePct:Math.round(c/t*100)}}}}function et(){ne();try{se()}catch{}}function tt({clipRef:e,onStopped:l}){const t=i.useRef(null),o=i.useRef(null),d=i.useRef(null),c=i.useRef(()=>{}),[a,u]=i.useState("loading"),[oe,ie]=i.useState(null),[ce,le]=i.useState(null),[M,de]=i.useState(!1),[B,ue]=i.useState(0),[P,me]=i.useState(0),[g,z]=i.useState(!1),[E,fe]=i.useState(0);i.useEffect(()=>{let r=!1,m=0,q=null;const f=Z.getInstance();let S=performance.now();const G=$e(),D=w()?720:null,n={outcome:"abandoned",error:void 0,loadMs:null,windowBytes:null,durationSec:null,fps:null,cardsSkipped:0};let O=!1;const he=()=>{if(O)return;O=!0;const p=G.summary();Fe({outcome:n.outcome,error:n.error,clip_kind:e.kind,load_ms:Math.round(n.loadMs??performance.now()-S),window_bytes:n.windowBytes,duration_sec:n.durationSec,fps:n.fps,coarse_pointer:w(),gpu_available:je(),decode_max_height:D,cards_skipped:n.cardsSkipped,frames:p.frames,avg_render_ms:p.avgRenderMs,p95_render_ms:p.p95RenderMs,max_render_ms:p.maxRenderMs,slow_frame_pct:p.slowFramePct})},W=()=>{r=!0,cancelAnimationFrame(m);try{f.playback.pause()}catch{}T()||N(),l()};return ze(W),(async()=>{try{if(T()){if(u("waiting"),await Be(),r)return;S=performance.now(),u("loading")}const p=xe();if(p&&!await ye())throw p;if(r)return;N(),ee(D),be(w()),await ne();try{se()}catch{}const y=ve(),U=x=>{r||le(x)},h=await _e({ref:e,deps:{supabase:y,fetchSignedUrl:Se,fetchEdit:x=>Te({ref:x,supabase:y}),cachedWindowBlob:await Le(e,U),onMediaProgress:U}});if(r)return;if(!h.editable||!h.sourceBlob)throw new Error(h.blockedReason??"Preview unavailable");n.windowBytes=h.sourceBlob.size;const $=De({coarsePointer:w()}),C=h.meta?.version===3?Ae(h.meta.cards,h.meta.theme).media.length:0;if(await te(Ne({session:h,skipMediaCards:$})),r)return;$&&C>0&&(n.cardsSkipped=C,fe(C));const b=f.project.getActive(),{width:H,height:K}=b.settings.canvasSize,F=new ke({width:H,height:K,fps:b.settings.fps});d.current=F;const v=F.getOutputCanvas();v.style.display="block",v.style.width="100%",v.style.height="100%",v.style.objectFit="contain",t.current?.appendChild(v);const j=f.timeline.getTotalDuration();me(L({time:j})),n.durationSec=Math.round(L({time:j}));const V=Me(b.settings.fps);n.fps=Math.round(V*100)/100;const we=Pe({tracks:f.scenes.getActiveScene().tracks,mediaAssets:f.media.getAssets(),duration:j,canvasSize:{width:H,height:K},background:b.settings.background,camera:b.settings.camera,isPreview:!0});let _=!1,J=0,Q=null;const X=We({fps:V,minFrameMs:w()?42:0});c.current=()=>X.reset();const Y=()=>{if(r)return;const x=Math.min(f.playback.getCurrentTime(),f.timeline.getLastFrameTime()),k=performance.now();k-J>250&&(J=k,ue(L({time:f.playback.getCurrentTime()})));const A=f.playback.getIsPlaying();if(A!==Q&&(Q=A,de(A)),!_&&X.shouldRender(x/Ee,k)){_=!0;const ge=k;te(F.render({node:we,time:x})).catch(()=>{}).finally(()=>{G.recordRender(performance.now()-ge),_=!1})}m=requestAnimationFrame(Y)};n.outcome="ready",n.loadMs=performance.now()-S,u("ready"),w()||(f.playback.play(),q=Ge(Re)),m=requestAnimationFrame(Y)}catch(p){if(r)return;const y=p instanceof Error?p.message:"Preview failed";n.outcome="error",n.error=y,n.loadMs=performance.now()-S,ie(y),u("error")}})(),()=>{Ie(W),r=!0,cancelAnimationFrame(m),he(),q?.();try{f.playback.pause()}catch{}d.current=null,T()||(ee(null),N())}},[]),i.useEffect(()=>{if(!g)return;const r=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=r}},[g]);const I=Z.getInstance(),R=()=>{a==="ready"&&I.playback.toggle()},pe=()=>{const r=o.current;if(r){if(document.fullscreenElement){document.exitFullscreen();return}if(typeof r.requestFullscreen=="function"){r.requestFullscreen().catch(()=>{z(m=>!m)});return}z(m=>!m)}};return s.jsxs("div",{ref:o,className:g?"fixed inset-0 z-[100] bg-black":"relative h-full w-full bg-black",children:[s.jsx("div",{ref:t,className:"h-full w-full",onClick:R}),a==="waiting"&&s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 p-3 text-center text-xs text-[#8888a8]",children:[s.jsx("span",{className:"h-5 w-5 animate-spin rounded-full border-2 border-[#7c3aed] border-t-transparent"}),"Preview starts when the video being prepared is done…"]}),a==="loading"&&s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 text-xs text-[#8888a8]",children:[s.jsx("span",{className:"h-5 w-5 animate-spin rounded-full border-2 border-[#7c3aed] border-t-transparent"}),qe(ce)]}),a==="error"&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-3 text-center text-xs text-[#8888a8]",children:oe}),a==="ready"&&w()&&s.jsx("span",{className:"pointer-events-none absolute left-2 top-2 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-medium text-white/80",children:E>0?`Preview quality — ${E===1?"1 graphic card":`${E} graphic cards`} shown in the download`:"Preview quality — exports render in full quality"}),a==="ready"&&!M&&s.jsx("button",{type:"button",onClick:R,className:"absolute inset-0 flex items-center justify-center","aria-label":"Play",children:s.jsx("span",{className:"flex h-14 w-14 items-center justify-center rounded-full bg-black/60 text-2xl text-white",children:"▶"})}),a==="ready"&&s.jsxs("div",{className:"absolute inset-x-0 bottom-0 flex items-center gap-2 bg-gradient-to-t from-black/80 to-transparent px-2 pb-1.5 pt-6",children:[s.jsx("button",{type:"button",onClick:R,className:"text-white","aria-label":M?"Pause":"Play",children:M?"❚❚":"▶"}),s.jsx("input",{type:"range",min:0,max:P||0,step:.05,value:Math.min(B,P),onChange:r=>{const m=Ce({seconds:Number(r.target.value)});m!==void 0&&I.playback.seek({time:m})},className:"h-1 min-w-0 flex-1 accent-[#7c3aed]"}),(g||!w())&&s.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-white/80",children:[ae(B),"/",ae(P)]}
1),s.jsx("button",{type:"button","aria-label":g?"Close":"Enlarge",className:"shrink-0 px-1 text-white/80 hover:text-white",onClick:pe,children:g?"✕":"⛶"})]})]})}function ae(e){const l=Math.floor(e/60),t=Math.floor(e%60);return`${l}:${String(t).padStart(2,"0")}`}export{tt as default,et as warmPreviewRuntime};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.