cineview 0.0.1-beta → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -56
- package/README.zh-CN.md +74 -56
- package/dist/cineview-drag.umd.js +1 -1
- package/dist/cineview-scroll.umd.js +1 -1
- package/dist/cineview.es.mjs +1 -1
- package/dist/cineview.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&typeof module<"u"?t(exports,require("react"),require("framer-motion"),require("react/jsx-runtime"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","framer-motion","react/jsx-runtime","react-dom"],t):t((e=typeof globalThis<"u"?globalThis:e||self).Cineview={},e.React,e.FramerMotion,e.ReactJSXRuntime,e.ReactDOM)}(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var a,o,s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,g=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},m=(e,t)=>{let n={};for(var r in e)c(n,r,{get:e[r],enumerable:!0});return t||c(n,Symbol.toStringTag,{value:"Module"}),n};o=null!=(a=t)?s(d(a)):{},t=((e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var i,a=u(t),o=0,s=a.length;o<s;o++)i=a[o],!f.call(e,i)&&void 0!==i&&c(e,i,{get:(e=>t[e]).bind(null,i),enumerable:!(r=l(t,i))||r.enumerable});return e})(a&&a.__esModule&&f.call(a,"default")?o:c(o,"default",{value:a,enumerable:!0}),a);var p=(0,t.createContext)(null),h=({designSize:e,children:n})=>{const i=function(e){return void 0===e?750:Number.isFinite(e)&&e>0?e:(String(e),750)}(e),[a,o]=(0,t.useState)(typeof window<"u"?window.innerWidth:750),s=(0,t.useMemo)(()=>a/i,[a,i]),c=(0,t.useCallback)(e=>e*s,[s]);(0,t.useEffect)(()=>{if(typeof window>"u")return;const{debounced:e,cancel:t}=function(){let e=null;return{debounced:function(...t){e&&clearTimeout(e),e=setTimeout(()=>{(()=>{o(window.innerWidth)})(...t),e=null},150)},cancel:()=>{e&&(clearTimeout(e),e=null)}}}();return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e),t()}},[]);const l=(0,t.useMemo)(()=>({scale:s,convert:c}),[s,c]),u=(0,t.useMemo)(()=>({"--cineview-unit":`${s}px`}),[s]);return(0,r.jsx)(p.Provider,{value:l,children:(0,r.jsx)("div",{className:"cineview-responsive-container",style:u,children:n})})},v=()=>(0,t.useContext)(p),y=new Set,b=new Set;function S(e){if(!e)return;const t=y.has(e);y.add(e),t||b.forEach(t=>t(e))}var x=new Map,w=new Set,R=new Map,M=new Set,C=new Map,k=0,P=/\.(mp4|webm|mov|m4v|ogv|ogg)(\?|#|$)/i;function I(e){return P.test(e)?"video":null}function E(e){const t=x.get(e);if(t)return A(e),t.objectUrl}function A(e){const t=x.get(e);t&&(x.delete(e),x.set(e,t))}function D(e){typeof URL<"u"&&URL.revokeObjectURL&&URL.revokeObjectURL(e)}function T(e){for(const[t,n]of x){if(k<=134217728)break;t===e||(C.get(t)??0)>0||(x.delete(t),w.delete(t),k-=n.bytes,D(n.objectUrl))}}function j(e,t){if(!e||w.has(e))return Promise.resolve();const n=R.get(e);if(n)return n;if(typeof fetch>"u")return Promise.reject(new Error("preloadMedia requires fetch (client-side only)"));if(!(t??I(e)))return Promise.reject(new Error(`Cannot determine media type: ${e} (pass explicit kind)`));const r=async function(e){const t=typeof AbortController<"u"?new AbortController:null,n=t?setTimeout(()=>t.abort(),3e4):null;try{const n=await fetch(e,t?{signal:t.signal}:void 0);if(!n.ok)throw new Error(`Failed to preload media: ${e} (HTTP ${n.status})`);const r=await n.blob();if(!r)throw new Error(`Invalid blob response for media: ${e}`);(function(e,t){const n=x.get(e);n&&(k-=n.bytes,D(n.objectUrl)),x.set(e,t),k+=t.bytes,T(e)})(e,{kind:"video",objectUrl:URL.createObjectURL(r),bytes:r.size}),function(e){const t=w.has(e);w.add(e),t||M.forEach(t=>t(e))}(e)}catch(n){if(t?.signal.aborted){const t=new Error(`Media preload timed out after 30000ms: ${e}`);throw t.cause=n,t}throw n}finally{null!==n&&clearTimeout(n)}}(e).finally(()=>{R.delete(e)});return R.set(e,r),r}function V(e){return Array.from(new Set(e.filter(e=>e.length>0)))}function L(e,t,n,r){const i=V(e).filter(e=>!n.has(e)&&!r.has(e)),a=new Set(i);return{priorityBatch:i,backgroundBatch:V(t).filter(e=>!n.has(e)&&!r.has(e)&&!a.has(e))}}var O=new class{constructor(){this.frameCount=0,this.lastTime=performance.now(),this.frameTimes=[],this.memorySamples=[],this.lastMemorySampleTime=0,this.cachedMemoryUsage=void 0,this.cachedBundleSizeKb=0,this.rafId=null,this.isMonitoring=!1,this.measure=()=>{if(!this.isMonitoring)return;const e=performance.now(),t=e-this.lastTime;this.frameCount++,this.frameTimes.push(t),this.frameTimes.length>60&&this.frameTimes.shift(),this.sampleMemory(e),this.lastTime=e,this.rafId=requestAnimationFrame(this.measure)}}start(){this.isMonitoring||(this.isMonitoring=!0,this.frameCount=0,this.lastTime=performance.now(),this.frameTimes=[],this.memorySamples=[],this.lastMemorySampleTime=0,this.cachedMemoryUsage=void 0,this.cachedBundleSizeKb=this.estimateBundleSizeKb(),this.measure())}stop(){this.isMonitoring=!1,null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null)}getMetrics(){const e=this.calculateAvgFrameTime();if(0===this.frameTimes.length)return{fps:0,avgFrameTime:0,memoryUsage:this.getMemoryUsage(),bundleSize:this.getBundleSizeKb()};const t=1e3/Math.max(e,1);return{fps:Math.round(10*Math.min(Math.max(t,0),60))/10,avgFrameTime:Math.round(100*e)/100,memoryUsage:this.getMemoryUsage(),bundleSize:this.getBundleSizeKb()}}calculateAvgFrameTime(){return 0===this.frameTimes.length?0:this.frameTimes.reduce((e,t)=>e+t,0)/this.frameTimes.length}getMemoryUsage(){return this.sampleMemory(performance.now(),void 0===this.cachedMemoryUsage),this.cachedMemoryUsage}sampleMemory(e,t=!1){if(!performance.memory)return this.cachedMemoryUsage=void 0,void(this.memorySamples=[]);if(!t&&e-this.lastMemorySampleTime<1e3)return;const n=performance.memory.usedJSHeapSize/1048576;this.memorySamples.push(n),this.memorySamples.length>8&&this.memorySamples.shift();const r=[...this.memorySamples].sort((e,t)=>e-t),i=Math.floor(r.length/2),a=r.length%2==0?(r[i-1]+r[i])/2:r[i];this.cachedMemoryUsage=Math.round(10*a)/10,this.lastMemorySampleTime=e}getBundleSizeKb(){return this.cachedBundleSizeKb>0||(this.cachedBundleSizeKb=this.estimateBundleSizeKb()),this.cachedBundleSizeKb}estimateBundleSizeKb(){if(typeof performance>"u"||"function"!=typeof performance.getEntriesByType)return 0;const e=performance.getEntriesByType("resource");if(0===e.length)return 0;const t=e.reduce((e,t)=>{const n=t.name.toLowerCase();return n.endsWith(".js")||n.endsWith(".mjs")||n.endsWith(".css")||n.includes(".js?")||n.includes(".mjs?")||n.includes(".css?")?e+Math.max(t.decodedBodySize||0,t.transferSize||0):e},0);return Math.round(t/1024*10)/10}},$=0,F=O,z="time",N={time:10,percent:1},B={unit:z,scale:N[z]};function q(e,t,n){const r=function(e){return void 0!==e?.unit||void 0!==e?.scale}(t)?t:e,i=r?.unit;if(void 0!==i&&!function(e){return"time"===e||"percent"===e}(i))return n?.({field:"unit",value:i}),{unit:z,scale:N.time};const a=i??"time",o=r?.scale;return void 0!==o&&("number"!=typeof o||!Number.isFinite(o)||o<0)?(n?.({field:"scale",value:o}),{unit:a,scale:N[a]}):{unit:a,scale:o??N[a]}}function U(e,t,n){const r=Math.max(0,Number.isFinite(t)?t:0),i=Number.isFinite(n)?n:0,a="time"===e.unit?e.scale:r*e.scale/100;return Math.min(r,Math.max(0,i*a))}var Y=typeof document<"u"?t.useLayoutEffect:t.useEffect;function H(e,t){if(null!=e.key)return`key:${e.key}`;const{sceneId:n}=e.props;return void 0!==n?`scene:${n}`:`index:${t}`}function W({index:e,currentScene:n,totalScenes:i,direction:a,renderProgressMotion:o,style:s,sceneWrapperRefs:c,children:l}){const u=(0,t.useRef)(null);return Y(()=>{const t=t=>{const r=u.current;if(!r)return;let o=t;0===n&&t<0&&(o=0),n===i-1&&t>0&&(o=0);const s=100*(e-n-o);r.style.transform="y"===a?`translate3d(0, ${s}%, 0)`:`translate3d(${s}%, 0, 0)`};return t(o.get()),o.on("change",t)},[n,a,e,o,i]),(0,r.jsx)("div",{ref:t=>{u.current=t,c.current[e]=t},style:s,"data-scene-index":e,children:l})}var X=t.default.memo(function({scene:e,index:n,currentScene:i,totalScenes:a,mode:o,dragConfig:s,dragProgress:c,dragTimelineProgress:l,renderProgress:u,renderProgressMotion:d,timelineProgressMotion:f,isDragging:g,sharedTimelineDurationMs:m,dragRelease:p,sceneActivations:h,firstSceneEnterActive:v,firstSceneEnterReady:y,direction:b,isAnimating:S,viewportWidth:x,viewportHeight:w,sceneActions:R,sceneWrapperRefs:M,renderLaneRef:C,takeoverSnapshot:k,candidateSuspended:P,onCandidateSuspensionChange:I,onElementContinuationChange:E,onPointerSessionStart:A,dragTransaction:D,onPrepared:T,onPreparedInvalidated:j,onOwnershipRequest:V,onSceneChange:L,onDragProgressChange:O,onRenderProgressChange:$,onDragTimelineProgressChange:F,onDraggingChange:z,onSharedTimelineDurationChange:N,onDragRelease:B,onDragReset:U,onTransactionComplete:Y,onFirstSceneEnterComplete:H}){const X=n===i,K=e.props,G=s?.direction??K.slideDirection??"y",_=q(s,K.drag),Z={position:"absolute",inset:0,width:"100%",height:"100%"};if("drag"===o)Z.visibility="visible",Z.opacity=1,Z.pointerEvents=X||g||S||null!==D?"auto":"none",Z.contentVisibility="visible",Z.transition="none",Z.zIndex=X?10:1;else{const e=X||S&&"backward"===b&&(n===i||n===i+1)||S&&"forward"===b&&(n===i||n===i-1);Z.visibility=e?"visible":"hidden",Z.contentVisibility=e?"visible":"hidden",Z.zIndex=S?"backward"===b?n===i+1?2:n===i?1:0:n===i?2:n===i-1?1:0:X?1:0}const J=D?.targetSceneIndex===n?D:null,Q=t.default.useCallback(()=>{0===n&&v?H():R.completeDragTransition(),"settling"===J?.phase&&Y(J.transactionId)},[v,n,H,Y,R,J]),ee=t.default.useCallback(e=>{E(n,e)},[n,E]),te=t.default.useMemo(()=>t.default.cloneElement(e,{sceneRuntime:{mode:o,direction:G,isActive:X,sceneIndex:n,totalScenes:a,currentSceneIndex:i,transitionDirection:b,isSceneAnimating:S,sharedTimelineDurationMs:m,activationToken:h.get(n)?.token??0,activationKind:h.get(n)?.kind??null,viewportWidth:x,viewportHeight:w,firstSceneEnterActive:v&&0===n,firstSceneEnterReady:y&&0===n},dragRuntime:{progress:c,renderProgress:u,timelineProgress:l,renderProgressMotion:d,timelineProgressMotion:f,isDragging:g,release:p,threshold:s?.threshold,dragMappingConfig:_,transaction:J,onPrepared:T,onPreparedInvalidated:j,onOwnershipRequest:V,candidateSuspended:P,onCandidateSuspensionChange:I,takeoverSnapshot:k,onElementContinuationChange:ee,onPointerSessionStart:A,renderLane:C,onCommit:L,onReset:U,onActivationComplete:Q,onTransactionComplete:Y,onProgressChange:O,onRenderProgressChange:$,onTimelineProgressChange:F,onDraggingChange:z,onRelease:B,onSharedTimelineDurationChange:N},onSceneChange:L}),[e.type,e.key,o,G,X,n,a,i,b,S,m,h,x,w,v,y,c,u,l,d,f,g,p,s,_,J,T,j,V,P,I,k,ee,A,C,L,U,Q,Y,O,$,F,z,B,N]);return"drag"===o?(0,r.jsx)(W,{index:n,currentScene:i,totalScenes:a,direction:G,renderProgressMotion:d,style:Z,sceneWrapperRefs:M,children:te}):(0,r.jsx)("div",{ref:e=>{M.current[n]=e},style:Z,"data-scene-index":n,children:te})});function K({scenes:e,visibleSceneIndices:t,currentScene:n,totalScenes:i,mode:a,dragConfig:o,dragProgress:s,dragTimelineProgress:c,renderProgress:l,renderProgressMotion:u,timelineProgressMotion:d,isDragging:f,sharedTimelineDurationMs:g,dragRelease:m,sceneActivations:p,firstSceneEnterActive:h,firstSceneEnterReady:v,direction:y,isAnimating:b,viewportWidth:S,viewportHeight:x,sceneActions:w,sceneWrapperRefs:R,renderLaneRef:M,takeoverSnapshot:C,candidateSuspended:k,onCandidateSuspensionChange:P,onElementContinuationChange:I,onPointerSessionStart:E,dragTransaction:A,onPrepared:D,onPreparedInvalidated:T,onOwnershipRequest:j,onSceneChange:V,onDragProgressChange:L,onRenderProgressChange:O,onDragTimelineProgressChange:$,onDraggingChange:F,onSharedTimelineDurationChange:z,onDragRelease:N,onDragReset:B,onTransactionComplete:q,onFirstSceneEnterComplete:U}){return(0,r.jsx)(r.Fragment,{children:e.map((e,Y)=>t.has(Y)?(0,r.jsx)(X,{scene:e,index:Y,currentScene:n,totalScenes:i,mode:a,dragConfig:o,dragProgress:s,dragTimelineProgress:c,renderProgress:l,renderProgressMotion:u,timelineProgressMotion:d,isDragging:f,sharedTimelineDurationMs:g,dragRelease:m,sceneActivations:p,firstSceneEnterActive:h,firstSceneEnterReady:v,direction:y,isAnimating:b,viewportWidth:S,viewportHeight:x,sceneActions:w,sceneWrapperRefs:R,renderLaneRef:M,takeoverSnapshot:C,candidateSuspended:k,onCandidateSuspensionChange:P,onElementContinuationChange:I,onPointerSessionStart:E,dragTransaction:A,onPrepared:D,onPreparedInvalidated:T,onOwnershipRequest:j,onSceneChange:V,onDragProgressChange:L,onRenderProgressChange:O,onDragTimelineProgressChange:$,onDraggingChange:F,onSharedTimelineDurationChange:z,onDragRelease:N,onDragReset:B,onTransactionComplete:q,onFirstSceneEnterComplete:U},H(e,Y)):null)})}function G(e,t){return e===t||"visibility"===e&&"scroll"===t}var _=class{constructor(e){this.source=new Map(e),Object.freeze(this)}get size(){return this.source.size}get(e){return this.source.get(e)}has(e){return this.source.has(e)}forEach(e,t){this.source.forEach((n,r)=>e.call(t,n,r,this))}entries(){return this.source.entries()}keys(){return this.source.keys()}values(){return this.source.values()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"ImmutableMapView"}};function Z(e){return new _(e)}function J(e){switch(e.type){case"missing-dependency":return`${e.type}:${e.animateId}:${e.after}`;case"circular-dependency":return`${e.type}:${e.animateId}:${e.cycle.join(">")}`;case"duplicate-id":return`${e.type}:${e.animateId}`;case"incompatible-lane":return`${e.type}:${e.animateId}:${e.after}:${e.followerLane}:${e.leaderLane}`}}function Q(e,t){const n=J(t);e.some(e=>J(e)===n)||e.push(t)}function ee({baseDuration:e,registrations:t,declaredLanes:n=new Map,duplicateIds:r=[]}){const i=new Map,a=[],o=new Set,s=new Set;Array.from(r).forEach(e=>{Q(a,{type:"duplicate-id",animateId:e})});const c=(e,r)=>{const l=i.get(e);if(void 0!==l)return l;const u=t.get(e);if(o.has(e)){const t=r.indexOf(e),n=function(e){const t=e.slice(0,-1);let n=0;for(let e=1;e<t.length;e+=1)t[e]<t[n]&&(n=e);const r=t.slice(n).concat(t.slice(0,n));return r.concat(r[0])}(r.slice(t).concat(e));return n.slice(0,-1).forEach(e=>s.add(e)),Q(a,{type:"circular-dependency",animateId:n[0],cycle:n}),i.set(e,u.delay),u.delay}o.add(e);let d=u.delay;if(u.after){const i=t.get(u.after),o=n.get(u.after);if(i)if(void 0===u.lane||void 0===i.lane||G(u.lane,i.lane)){const t=c(u.after,r.concat(e));("visibility"!==u.lane||"scroll"!==i.lane)&&!s.has(e)&&(d+=t+i.duration)}else Q(a,{type:"incompatible-lane",animateId:e,after:u.after,followerLane:u.lane,leaderLane:i.lane});else void 0===u.lane||void 0===o||G(u.lane,o)?Q(a,{type:"missing-dependency",animateId:e,after:u.after}):Q(a,{type:"incompatible-lane",animateId:e,after:u.after,followerLane:u.lane,leaderLane:o})}return o.delete(e),i.set(e,d),d};t.forEach((e,t)=>{c(t,[])});let l=Math.max(e,0);return t.forEach((e,t)=>{const n=i.get(t);l=Math.max(l,n+e.duration)}),{registrations:new Map(t),calculatedDelays:i,issues:a,timelineDuration:l}}function te(e){return Math.max(0,Math.min(Number.isFinite(e)?e:0,1))}function ne(e){return Object.freeze({...e,mapping:Object.freeze({...e.mapping}),enterVariantsByAnimateId:Z(e.enterVariantsByAnimateId)})}var re=class{constructor(){this.preparedScenes=new Map,this.activeTransactions=new Map,this.transactionIdsByTarget=new Map}publishPrepared(e){const t=this.preparedScenes.get(e.sceneIndex);t&&t.instanceId===e.instanceId&&t.revision>e.revision||this.preparedScenes.set(e.sceneIndex,ne(e))}invalidatePrepared(e){const t=this.preparedScenes.get(e.sceneIndex);t?.instanceId===e.instanceId&&t.revision===e.revision&&this.preparedScenes.delete(e.sceneIndex)}getPrepared(e){return this.preparedScenes.get(e)??null}beginTransaction(e,t,n){const r=this.transactionIdsByTarget.get(e),i=r?this.activeTransactions.get(r):void 0;if(i){const e=function(e,t,n){const r=te(n);return Object.freeze({...e,phase:t,releaseSeed:Object.freeze({progressRatio:r,elapsedMs:U(e.mapping,e.registrySnapshot.timelineDuration,100*r)})})}(i,t,n);return this.activeTransactions.set(i.transactionId,e),e}const a=this.preparedScenes.get(e);if(!a)return null;const o=function(e,t,n){return function(e,t,n,r){const i=te(r),a=e.registrySnapshot.timelineDuration;return Object.freeze({transactionId:t,targetSceneIndex:e.sceneIndex,targetInstanceId:e.instanceId,targetRevision:e.revision,phase:n,mapping:e.mapping,registrySnapshot:e.registrySnapshot,enterVariantsByAnimateId:e.enterVariantsByAnimateId,releaseSeed:Object.freeze({progressRatio:i,elapsedMs:U(e.mapping,a,100*i)})})}(e,Symbol(`drag-transaction:${e.sceneIndex}:${e.revision}`),t,n)}(a,t,n);return this.activeTransactions.set(o.transactionId,o),this.transactionIdsByTarget.set(e,o.transactionId),o}getTransaction(e){return this.activeTransactions.get(e)??null}getTransactionForTarget(e){const t=this.transactionIdsByTarget.get(e);return t?this.activeTransactions.get(t)??null:null}releaseTransaction(e){const t=this.activeTransactions.get(e);t&&(this.activeTransactions.delete(e),this.transactionIdsByTarget.get(t.targetSceneIndex)===e&&this.transactionIdsByTarget.delete(t.targetSceneIndex))}clear(){this.preparedScenes.clear(),this.activeTransactions.clear(),this.transactionIdsByTarget.clear()}};function ie(e){return e.assets?.preloadImages??[]}var ae=(0,t.createContext)(null);function oe(){return(0,t.useContext)(ae)}var se="(prefers-reduced-motion: reduce)";function ce(){return typeof window<"u"&&"function"==typeof window.matchMedia&&window.matchMedia(se).matches}function le(e){if(typeof window>"u"||"function"!=typeof window.matchMedia)return()=>{};const t=window.matchMedia(se);return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}function ue(e,t,n){return Math.min(n,Math.max(t,e))}var de={position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},fe=(0,t.forwardRef)((e,i)=>{const{designWidth:a,mode:o,direction:s,transitionDuration:c,threshold:l,unit:u,scale:d,firstSceneTimeout:f,scrollbar:g,callbacks:m,monitor:p,children:v}=e,{designSize:y}=function(e){const t=e;return"number"==typeof t&&Number.isFinite(t)&&t>0?{designSize:t}:{designSize:750}}(a),b=(0,t.useMemo)(()=>({direction:s,transitionDuration:c,threshold:l,unit:u,scale:d,firstSceneTimeout:f}),[s,c,l,u,d,f]),x=(0,t.useRef)(null),w=(0,t.useRef)([]),R=(0,t.useRef)(0),M=(0,t.useRef)(null),C=(0,t.useRef)([]),k=(0,t.useRef)(null),P=(0,t.useRef)(new Set),[E,A]=(0,t.useMemo)(()=>{const e=[];return t.Children.forEach(v,n=>{(function(e){if(!(0,t.isValidElement)(e)||"string"==typeof e.type)return!1;let n=e.type;for(let e=0;e<6&&n;e+=1){if(("function"==typeof n||"object"==typeof n)&&null!==n&&!0===n.cineViewScene)return!0;if("object"==typeof n&&null!==n&&"type"in n)n=n.type;else{if("object"!=typeof n||null===n||!("render"in n))break;n=n.render}}return!1})(n)&&e.push(n)}),[e,!1]},[v]),D=E.length,T=(0,t.useMemo)(()=>function(e){return e??"drag"}(o),[o]),z=(0,t.useMemo)(()=>function(e){return e?{common:{onReady:e.onReady,onLoadProgress:e.onLoadProgress,onSceneEnter:e.onSceneEnter,onSceneLeave:e.onSceneLeave,onError:e.onError},drag:{onDragStart:e.onDragStart,onDragProgress:e.onDragProgress,onDragBlocked:e.onDragBlocked,onDragEnd:e.onDragEnd,onDragCancel:e.onDragCancel},scroll:{onZoneEnter:e.onZoneEnter,onZoneLeave:e.onZoneLeave,onZoneProgress:e.onZoneProgress,onSceneVisibilityChange:e.onSceneVisibilityChange}}:{common:{},drag:{},scroll:{}}}(m),[m]),N=(0,t.useRef)(z),B=(0,t.useRef)(!1),U=(0,t.useRef)(!1),[W,X]=(0,t.useState)(!1),G=(0,t.useRef)(new Set),_=(0,t.useRef)(new Set),Z=(0,t.useRef)(null),J=(0,t.useRef)(null),Q=(0,t.useRef)(0),ee=(0,t.useRef)(!1),te=(0,t.useRef)(new re),[ne,oe]=(0,t.useState)(null),se=(0,t.useRef)(null),fe=(0,t.useRef)(0),ge=(0,t.useRef)(null),me=(0,t.useRef)(new Set),pe=(0,t.useRef)(!1),he=(0,t.useRef)(null),ve=(0,t.useRef)(0),[ye,be]=(0,t.useState)(()=>new Map),Se=(0,t.useCallback)((e,t)=>{const n={token:++ve.current,kind:t};be(t=>{const r=new Map(t);return r.set(e,n),r})},[]);(0,t.useEffect)(()=>{N.current=z},[z]);const xe=(0,t.useCallback)((e,t,n)=>{N.current.common?.onError?.({code:e,message:t,context:n})},[]),we=(0,t.useCallback)((e,t,n)=>{let r=!1;return N.current.common?.onError?.({code:e,message:t,context:n,preventDefault:()=>{r=!0}}),r},[]),Re=(0,t.useCallback)(e=>{N.current.common?.onLoadProgress?.(e)},[]);(0,t.useEffect)(()=>{0===D&&xe("EMPTY_SCENES","Cineview requires at least one Scene child.",{mode:T})},[xe,T,D]),(0,t.useEffect)(()=>{"drag"===T&&E.forEach((e,t)=>{const n=e.props;q(b,n.drag,({field:e,value:n})=>{const r=`${t}:${e}`;me.current.has(r)||(me.current.add(r),xe("INVALID_DRAG_CONFIG",`Invalid drag ${e}; using the safe default.`,{sceneIndex:t,field:e,value:n}))});const r=n.drag?.enabled;if(void 0!==r&&"boolean"!=typeof r){const e=`${t}:enabled`;if(me.current.has(e))return;me.current.add(e),xe("INVALID_DRAG_CONFIG","Invalid drag enabled flag; using true.",{sceneIndex:t,field:"enabled",value:r})}})},[xe,b,T,E]);const[Me,Ce]=(0,t.useState)(0),[ke,Pe]=(0,t.useState)(0),Ie=(0,t.useCallback)((e,t)=>{M.current=e,z.common?.onSceneEnter?.({fromIndex:e,toIndex:t,direction:t>e?"forward":t<e?"backward":null})},[z]),Ee=(0,t.useCallback)((e,t)=>{const n=t??M.current??e;M.current=null,z.common?.onSceneLeave?.({fromIndex:n,toIndex:e,direction:n===e?null:e>n?"forward":e<n?"backward":null})},[z]),[Ae,De]=(e=>{const{totalScenes:n,initialScene:r=0,mode:i="drag",onBeforeChange:a,onCommit:o,onAfterChange:s}=e,[c,l]=(0,t.useState)(Math.max(0,Math.min(r,n-1))),[u,d]=(0,t.useState)(!1),[f,g]=(0,t.useState)(null),[m,p]=(0,t.useState)(0),[h,v]=(0,t.useState)(0),[y,b]=(0,t.useState)(0),[S,x]=(0,t.useState)(null),[w,R]=(0,t.useState)(0),[M,C]=(0,t.useState)(!1),[k,P]=(0,t.useState)(!1),[I,E]=(0,t.useState)(0),[A,D]=(0,t.useState)(null),T=(0,t.useRef)(0),[j,V]=(0,t.useState)(null),L=(0,t.useRef)(!1),O=(0,t.useRef)(c),$=(0,t.useRef)(null),F=(0,t.useRef)(!1),z=(0,t.useRef)(!1),N=(0,t.useRef)(null);O.current=c,(0,t.useEffect)(()=>{const e=Math.max(n-1,0);O.current<=e||(l(e),L.current&&(d(!1),L.current=!1,g(null),N.current=null))},[n]);const B=(0,t.useCallback)(()=>{$.current=null,F.current=!1,z.current=!1,p(0),v(0),E(0),D(null),g(null)},[]),q=(0,t.useCallback)(e=>{O.current=e,l(e),N.current=null,L.current=!1,d(!1),C(!1),R(0),B()},[B]),U=(0,t.useCallback)(e=>{if(null===e)return z.current=!1,void D(null);z.current="settle"===e.mode,T.current+=1,D({...e,token:T.current})},[]),Y=(0,t.useCallback)(()=>c<n-1,[c,n]),H=(0,t.useCallback)(()=>c>0,[c]),W=(0,t.useCallback)((e,t=!0)=>{if(!Number.isInteger(e)||e<0||e>=n)return;if(e===c)return;a?.(c,e);const r=e>c?"forward":"backward";g(r),l(e),o?.(e,c,"programmatic"),t?(d(!0),L.current=!0,N.current={fromScene:c,releaseToken:null},"drag"===i&&(T.current+=1,N.current.releaseToken=T.current,D({token:T.current,mode:"enter",direction:r,targetSceneIndex:e}))):(d(!1),L.current=!1,N.current=null,B(),s?.(e,c))},[c,n,i,a,o,s,B]),X=(0,t.useCallback)(()=>{Y()&&W(c+1)},[c,Y,W]),K=(0,t.useCallback)(()=>{H()&&W(c-1)},[c,H,W]),G=(0,t.useCallback)(e=>{if(d(e),L.current=e,!e){const e=N.current;N.current=null,e?s?.(c,e.fromScene):s?.(c),g(null);const t=e?.releaseToken;null!=t&&D(e=>null!==e&&e.token===t?null:e)}},[c,s]),_=(0,t.useCallback)(()=>{z.current&&null!==$.current||($.current=null,F.current=!1,z.current=!1,D(null)),p(0),v(0),R(0),C(!1),E(0)},[]),Z=(0,t.useCallback)(()=>{$.current=null,F.current=!1,z.current=!1,D(null),g(null),v(0),E(0)},[]),J=(0,t.useCallback)(()=>{b(0),x(null),P(!1),V(null)},[]),Q=(0,t.useCallback)((e,t,r,i)=>{const c=O.current,u="forward"===e?c+1:c-1,f=Math.max(0,Math.min(t,1));return f.toFixed(3),u<0||u>=n?(_(),g(null),d(!1),L.current=!1,!1):(a?.(c,u),g(e),v(f),$.current=c,l(u),o?.(u,c,"drag"),s?.(u,c),p(0),R(0),C(!1),d(!1),L.current=!1,f.toFixed(3),F.current&&B(),!0)},[B,s,a,o,_,n]),ee=(0,t.useCallback)(()=>{null===$.current?z.current&&(F.current=!0):B()},[B]),te=(0,t.useCallback)((e,t)=>{const r=O.current,i="forward"===e?r+1:r-1,o=Math.max(0,Math.min(t,1));if(o.toFixed(3),i<0||i>=n)return J(),g(null),d(!1),void(L.current=!1);a?.(r,i),g(e),x(e),b(o),V({fromScene:r,toScene:i,direction:e,progressRatio:o,startedAt:Date.now(),lastInputAt:Date.now(),isSettling:!1,settleDirection:null}),l(i),b(0),x(null),V(null),P(!1),d(!1),L.current=!1,s?.(i,r),o.toFixed(3)},[s,a,J,n]),ne=(0,t.useCallback)(()=>{y.toFixed(3),b(0),x(null),V(null)},[y]);return[{currentScene:c,isAnimating:u,direction:f,dragProgress:m,dragTimelineProgress:h,scrollProgress:y,scrollDirection:S,renderProgress:w,isDragging:M,isScrolling:k,sharedTimelineDurationMs:I,dragRelease:A,scrollTransitionSnapshot:j},{reconcileSceneList:q,goToScene:W,nextScene:X,prevScene:K,setAnimating:G,canGoNext:Y,canGoPrev:H,setDragProgress:p,setDragTimelineProgress:v,setScrollProgress:b,setScrollDirection:x,setScrollTransitionSnapshot:V,setRenderProgress:R,setIsDragging:C,setIsScrolling:P,setSharedTimelineDurationMs:E,setDragRelease:U,resetDragInteraction:_,abortDragContinuation:Z,resetScrollInteraction:J,commitDragSceneChange:Q,completeDragTransition:ee,commitScrollSceneChange:te,clearScrollTransitionSnapshot:ne}]})({totalScenes:D,initialScene:0,mode:T,onBeforeChange:Ie,onCommit:(e,t,n)=>{"drag"===T&&Se(e,"drag"===n?"commit":"programmatic")},onAfterChange:(e,t)=>{Ee(e,t??R.current)}}),Te=(0,t.useRef)(De);Te.current=De;const{currentScene:je,isAnimating:Ve,direction:Le,dragProgress:Oe,dragTimelineProgress:$e,renderProgress:Fe,isDragging:ze,sharedTimelineDurationMs:Ne,dragRelease:Be}=Ae,qe=(0,t.useMemo)(()=>E.map(H),[E]),[Ue,Ye]=(0,t.useState)(qe);if(Ue.length!==qe.length||Ue.some((e,t)=>e!==qe[t])){const e=qe.indexOf(Ue[je]),t=e>=0?e:ue(je,0,Math.max(0,D-1));Ye(qe),De.reconcileSceneList(t),be(e=>{const t=new Map;for(const[n,r]of e){const e=qe.indexOf(Ue[n]);e>=0&&t.set(e,r)}return t})}const He=(0,n.useMotionValue)(0),We=(0,n.useMotionValue)(0),Xe=(0,t.useSyncExternalStore)(le,ce,()=>!1),Ke=e.a11y?.label??"Scenes";R.current=je,C.current=E,Y(()=>{ee.current&&(ee.current=!1,He.set(0),We.set(0))},[je,We,He]);const Ge=E[je],_e=Ge?function(e,t,n){return Math.max("drag"===t?n??e.sceneTransitionDuration??800:e.sceneTransitionDuration??800,0)}(Ge.props,T,c):0;(0,t.useEffect)(()=>{if(!Ve||!C.current[je])return;const e=setTimeout(()=>{Te.current.setAnimating(!1)},_e),t=P.current;return t.add(e),()=>{clearTimeout(e),t.delete(e)}},[Ve,je,_e]),(0,t.useEffect)(()=>{if("drag"===T)return;B.current=!1,U.current=!1,X(!1),G.current.clear(),_.current.clear(),fe.current=0,ge.current=null;const e=se.current;e&&(te.current.releaseTransaction(e.transactionId),se.current=null,oe(null))},[T]);const Ze=(0,t.useCallback)(e=>{if(!e)return null;const t=se.current,n=!t||t.transactionId!==e.transactionId||t.phase!==e.phase;return t&&t.transactionId!==e.transactionId&&te.current.releaseTransaction(t.transactionId),se.current=e,n&&oe(e),e},[]),Je=(0,t.useCallback)(e=>{const t=se.current;!t||e&&t.transactionId!==e||(te.current.releaseTransaction(t.transactionId),se.current=null,oe(null))},[]),Qe=(0,t.useCallback)(e=>{te.current.publishPrepared(e)},[]),et=(0,t.useCallback)(e=>{te.current.invalidatePrepared(e)},[]),tt=(0,t.useCallback)((e,t)=>{t?G.current.add(e):G.current.delete(e)},[]),nt=(0,t.useCallback)(()=>{_.current.clear()},[]),rt=(0,t.useCallback)(e=>e?"drag"===T&&(null!==Z.current||G.current.size>0)&&(J.current={token:++Q.current,sceneIndices:[...G.current],staleRatio:We.get(),baseRatio:null},U.current=!0,X(!0),!0):(U.current=!1,X(!1),null===J.current?.baseRatio&&(J.current=null),!1),[We,T]),it=(0,t.useCallback)(e=>{const t=se.current;!t||t.targetSceneIndex===e||(De.abortDragContinuation(),G.current.delete(t.targetSceneIndex))},[De]),at=(0,t.useCallback)(e=>{if("drag"!==T)return!1;const t=U.current,n=B.current;if(n&&!t)return!1;const r=R.current,i=r+("forward"===e?1:-1);if(i<0||i>=D)t&&(it(null),Je());else{if(!1===E[i]?.props?.drag?.enabled)return _.current.has(e)||(_.current.add(e),N.current.drag?.onDragBlocked?.({fromIndex:r,targetSceneIndex:i,direction:e})),!1;if(!te.current.getPrepared(i))return!1;const t=te.current.beginTransaction(i,"driving",0);if(!t||(it(i),!Ze(t)))return!1}return U.current=!1,X(!1),n||(B.current=!0,fe.current=0,ge.current=null,N.current.drag?.onDragStart?.({sceneIndex:r,progress:0,direction:e})),!0},[it,Ze,Je,T,E,D]),ot=(0,t.useCallback)(e=>{if("drag"!==T||!B.current)return;const t=0===e?0:ue(e,-1,1);if(t!==fe.current){if(fe.current=t,0!==t){const e=R.current+(t>0?1:-1);if(e>=0&&e<D){const n=te.current.beginTransaction(e,"driving",Math.abs(t));n&&(it(e),Ze(n))}}N.current.drag?.onDragProgress?.({sceneIndex:R.current,progress:Math.abs(t),direction:t>0?"forward":t<0?"backward":null})}},[it,Ze,T,D]),st=(0,t.useCallback)(e=>{e||(J.current=null),De.setIsDragging(e)},[De]),ct=(0,t.useCallback)(e=>{"bounce"===e?.mode&&B.current?ge.current={sceneIndex:R.current,signedProgress:fe.current}:"bounce"!==e?.mode&&(ge.current=null),De.setDragRelease(e)},[De]);(0,t.useEffect)(()=>{if("drag"===T){if(Be)return void Ze(te.current.beginTransaction(Be.targetSceneIndex,"settle"===Be.mode?"settling":"bounce"===Be.mode?"bouncing":"programmatic","enter"===Be.mode?0:Be.progressRatio??0));"driving"!==se.current?.phase&&Je()}},[Ze,Be,Je,T]);const lt=(0,t.useCallback)(()=>{if("drag"===T&&B.current){const e=ge.current??{sceneIndex:R.current,signedProgress:fe.current};B.current=!1,fe.current=0,ge.current=null,N.current.drag?.onDragCancel?.({sceneIndex:e.sceneIndex,progress:Math.abs(e.signedProgress),direction:e.signedProgress>0?"forward":e.signedProgress<0?"backward":null})}"settling"!==se.current?.phase&&Je(),He.set(0),We.set(0),De.resetDragInteraction()},[We,Je,He,T,De]);(0,t.useEffect)(()=>{const e=x.current;if(!e)return;const t=e.ownerDocument?.defaultView??window,n=()=>{const t=e.getBoundingClientRect(),n=t.width,r=t.height;n>0&&Ce(n),r>0&&Pe(r)};k.current=n,n();const r=t.ResizeObserver??(typeof ResizeObserver<"u"?ResizeObserver:void 0),i=r?new r(()=>{n()}):null;return i?.observe(e),t.addEventListener("resize",n),()=>{k.current=null,i?.disconnect(),t.removeEventListener("resize",n)}},[]),(0,t.useEffect)(()=>{if(!g||!1===g.enabled)return;const e=x.current?.ownerDocument??(typeof document<"u"?document:null);if(!e)return;const t="cineview-scrollbar-style";let n=e.getElementById(t);return n||(n=e.createElement("style"),n.id=t,e.head.appendChild(n)),n.textContent='\n [data-cineview-container="true"] {\n scrollbar-width: none;\n -ms-overflow-style: none;\n }\n [data-cineview-container="true"]::-webkit-scrollbar {\n width: 0;\n height: 0;\n display: none;\n }\n ',()=>{n&&n.parentNode&&n.parentNode.removeChild(n)}},[g]);const ut=je,{priorityImages:dt,backgroundImages:ft}=(0,t.useMemo)(()=>function(e,t,n){if("scroll"===n){const n=e[ue(t,0,Math.max(e.length-1,0))],r=n?ie(n.props):[],i=new Set(r);return{priorityImages:r,backgroundImages:Array.from(new Set(e.flatMap(e=>ie(e.props).filter(e=>!i.has(e)))))}}const r=ue(t,0,Math.max(e.length-1,0)),i=[],a=[];e.forEach((e,t)=>{const n=ie(e.props);t===r?i.push(...n):a.push(...n)});const o=new Set(i);return{priorityImages:Array.from(new Set(i)),backgroundImages:Array.from(new Set(a.filter(e=>!o.has(e))))}}(E,ut,T),[E,ut,T]),[gt,mt]=((e={})=>{const{priorityUrls:n=[],backgroundUrls:r=[],onProgress:i,onComplete:a,onError:o}=e,[s,c]=(0,t.useState)(!1),[l,u]=(0,t.useState)(0),[d,f]=(0,t.useState)(0),[g,m]=(0,t.useState)(n.length+r.length),[p,h]=(0,t.useState)([]),[v,y]=(0,t.useState)(new Map),[b,x]=(0,t.useState)(!1),w=(0,t.useRef)([...n]),R=(0,t.useRef)([...r]),M=(0,t.useRef)(!1),C=(0,t.useRef)(new Map),k=(0,t.useRef)(0),P=(0,t.useRef)(null),E=(0,t.useRef)(new Set),A=(0,t.useRef)(new Set),D=(0,t.useRef)(0),T=(0,t.useRef)(0),O=(0,t.useRef)(i),$=(0,t.useRef)(a),F=(0,t.useRef)(o);(0,t.useEffect)(()=>{O.current=i,$.current=a,F.current=o},[i,a,o]);const z=(0,t.useCallback)((e,t)=>{const n=V(e).filter(e=>!E.current.has(e));if(0===n.length)return;const r=new Set(w.current),i=new Set(R.current),a=n.filter(e=>!r.has(e)&&!i.has(e));0!==a.length&&(t?w.current=[...w.current,...a]:R.current=[...R.current,...a])},[]);(0,t.useEffect)(()=>{z(n,!0),z(r,!1),M.current||m(w.current.length+R.current.length)},[n,r,z]);const N=(0,t.useCallback)((e,t)=>{const n=I(e);return n?j(e,n).then(()=>(S(e),{url:e,success:!0})).catch(n=>{const r=n instanceof Error?n:new Error(String(n));return k.current===t&&F.current?.(e,r),{url:e,success:!1,error:r}}):new Promise(n=>{const r=new Image,i=new AbortController;C.current.set(e,i);let a=!1,o=null;const s=t=>{a||(a=!0,null!==o&&(clearTimeout(o),o=null),C.current.delete(e),n(t))};r.onload=()=>{S(e),s({url:e,success:!0})},r.onerror=()=>{const n=new Error(`Failed to load image: ${e}`);k.current===t&&F.current?.(e,n),s({url:e,success:!1,error:n})},i.signal.addEventListener("abort",()=>{r.src="",s({url:e,success:!1,error:new Error("Image load aborted")})}),o=setTimeout(()=>{o=null,r.onload=null,r.onerror=null,r.src="";const n=new Error(`Image load timed out after 15000ms: ${e}`);k.current===t&&F.current?.(e,n),s({url:e,success:!1,error:n})},15e3),r.src=e})},[]),B=(0,t.useCallback)((e,t)=>{const n=Math.max(t,0),r=n>0?Math.min(Math.max(e,0),n):0,i=n>0?Math.round(r/n*100):100;u(i),f(r),O.current?.(i)},[]),q=(0,t.useCallback)(()=>{if(M.current)return P.current??Promise.resolve();const e=(async()=>{const e=k.current+1;k.current=e,M.current=!0,c(!0),u(0),f(0),h([]),y(new Map),x(!1),A.current=new Set,D.current=0,T.current=0;const t=L(w.current,R.current,E.current,A.current),n=t.priorityBatch.length+t.backgroundBatch.length;if(T.current=n,m(n),0===n)return B(0,0),k.current===e&&(c(!1),x(!0)),M.current=!1,void $.current?.([]);const r=new Set(t.priorityBatch);let i=0===r.size;i&&x(!0);const a=[],o=new Map,s=()=>{const e=L(w.current,R.current,E.current,A.current);return T.current=D.current+e.priorityBatch.length+e.backgroundBatch.length,m(T.current),e},l=(e,t)=>{a.push(t),A.current.add(e),D.current+=1,!t.success&&t.error?o.set(e,t.error):t.success&&E.current.add(e),B(D.current,T.current),i||(r.delete(e),0===r.size&&(i=!0,x(!0)))};for(;;){const{priorityBatch:t,backgroundBatch:n}=s();if(0===t.length&&0===n.length)break;if(await Promise.all(t.map(async t=>{const n=await N(t,e);k.current===e&&l(t,n)})),k.current!==e)return;const r=await Promise.all(n.map(async t=>({url:t,result:await N(t,e)})));if(k.current!==e)return;r.forEach(({url:e,result:t})=>{l(e,t)})}h(a),y(o),c(!1),M.current=!1,m(w.current.length+R.current.length),$.current?.(a)})();return P.current=e.finally(()=>{P.current===e&&(P.current=null)}),P.current},[N,B]),U=(0,t.useCallback)(()=>{k.current+=1,C.current.forEach(e=>{e.abort()}),C.current.clear(),c(!1),u(0),f(0),m(w.current.length+R.current.length),h([]),y(new Map),x(!1),E.current.clear(),A.current.clear(),D.current=0,T.current=0,M.current=!1,P.current=null},[]),Y=(0,t.useCallback)((e,t=!1)=>{z(e,t);const{priorityBatch:n,backgroundBatch:r}=L(w.current,R.current,E.current,A.current),i=M.current?D.current+n.length+r.length:n.length+r.length;M.current&&(T.current=i),m(i)},[z]);return(0,t.useEffect)(()=>{const e=C.current;return()=>{k.current+=1,M.current=!1,P.current=null,e.forEach(e=>{e.abort()}),e.clear()}},[]),[{isLoading:s,progress:l,loadedCount:d,totalCount:g,results:p,errors:v,priorityComplete:b},{startPreload:q,reset:U,addUrls:Y}]})({priorityUrls:dt,backgroundUrls:ft,onProgress:Re,onError:(e,t)=>{xe("IMAGE_LOAD_FAILED",t.message,{url:e})}}),pt=(0,t.useRef)(mt);pt.current=mt;const ht=(0,t.useRef)({loadedCount:0,totalCount:0});ht.current={loadedCount:gt.loadedCount,totalCount:gt.totalCount};const vt=Math.max(0,f??3e3),yt=(0,t.useCallback)(()=>({loadedCount:ht.current.loadedCount,totalCount:ht.current.totalCount}),[]),{firstSceneEnterActive:bt,firstSceneEnterReady:St,firstSceneActivationToken:xt,firstSceneActivationKind:wt,handleComplete:Rt}=function({enabled:e,hasFirstScene:n,priorityComplete:r,timeoutMs:i,preemptSignal:a=!1,emitRecoverableError:o,getPreloadCounts:s}){const[c,l]=(0,t.useState)(()=>e),[u,d]=(0,t.useState)(!1),[f,g]=(0,t.useState)(0),[m,p]=(0,t.useState)(null),h=(0,t.useRef)(!1),v=(0,t.useRef)(null),y=Math.max(0,i),b=(0,t.useRef)(o);b.current=o;const S=(0,t.useRef)(s);return S.current=s,(0,t.useEffect)(()=>{if(!e||h.current||!n)return;const t=e=>{p(e),g(e=>e+1)};return r?(h.current=!0,d(!0),void t("ready")):(null===v.current&&(v.current=setTimeout(()=>{v.current=null,h.current=!0;const e=S.current();b.current("FIRST_SCENE_TIMEOUT",`First scene priority assets did not load within ${y}ms.`,{sceneIndex:0,timeoutMs:y,loadedCount:e.loadedCount,totalCount:e.totalCount})||(h.current=!0,d(!1),l(!1),t("static"))},y)),()=>{v.current&&(clearTimeout(v.current),v.current=null)})},[e,n,r,y]),(0,t.useEffect)(()=>{a&&(h.current=!0,v.current&&(clearTimeout(v.current),v.current=null),d(!1),l(!1))},[a]),{firstSceneEnterActive:c,firstSceneEnterReady:u,firstSceneActivationToken:f,firstSceneActivationKind:m,handleComplete:(0,t.useCallback)(()=>{l(!1)},[])}}({enabled:E.length>0,hasFirstScene:!!E[0],priorityComplete:gt.priorityComplete,timeoutMs:vt,preemptSignal:ze,emitRecoverableError:we,getPreloadCounts:yt}),Mt=(0,t.useRef)(0);(0,t.useEffect)(()=>{"drag"!==T||xt<=Mt.current||null===wt||(Mt.current=xt,Se(0,wt))},[Se,wt,xt,T]),(0,t.useEffect)(()=>{const e=P.current;return mt.startPreload(),()=>{e.forEach(e=>{clearTimeout(e)}),e.clear()}},[i]),(0,t.useEffect)(()=>{if(p)return(()=>{1===($+=1)&&O.start();let e=!1;return()=>{e||(e=!0,0===($=Math.max($-1,0))&&O.stop())}})()},[p]),(0,t.useEffect)(()=>{const e=`${dt.join("|")}::${ft.join("|")}`;if(he.current!==e){if(he.current=e,mt.addUrls(dt,!0),mt.addUrls(ft,!1),!pe.current)return void(pe.current=!0);gt.isLoading||mt.startPreload()}},[dt,ft,mt,gt.isLoading]);const Ct=(0,t.useMemo)(()=>{const e=new Set;return e.add(je),"drag"===T&&(je>0&&e.add(je-1),je<D-1&&e.add(je+1)),e},[T,je,D]);!function({ref:e,currentSceneRef:n,scenesRef:r,sceneActionsRef:i,preloadActionsRef:a,measureViewportRef:o,resolvedCallbacksRef:s}){const c=(0,t.useCallback)((e,t=!0)=>{const a=n.current;e>=0&&e<r.current.length&&e!==a&&s.current.drag?.onDragEnd?.({sceneIndex:a,targetSceneIndex:e,progress:1,direction:e>a?"forward":"backward",elapsedMs:0,timelineDurationMs:0}),i.current.goToScene(e,t)},[n,s,i,r]),l=(0,t.useCallback)(()=>{o.current?.()},[o]),u=(0,t.useCallback)(async e=>{const t=function(e,t,n={}){if(!t||0===t.length)return[];const r=n.includeZoneIds??!1,i=new Set,a=[],o=e=>{e&&ie(e.props).forEach(e=>{!e||i.has(e)||(i.add(e),a.push(e))})};return t.forEach(t=>{"number"!=typeof t?t&&e.forEach(e=>{e.props.sceneId!==t?r&&e.props.scroll?.zoneId===t&&o(e):o(e)}):Number.isInteger(t)&&t>=0&&t<e.length&&o(e[t])}),a}(r.current,e,{includeZoneIds:!0});t.length>0&&a.current.addUrls(t,!0),await a.current.startPreload()},[a,r]),d=(0,t.useCallback)(()=>n.current,[n]),f=(0,t.useCallback)(()=>F.getMetrics(),[]),g=(0,t.useRef)(null);g.current||(g.current={goToScene:(e,t=!0)=>c(e,t),refreshLayout:()=>l(),preload:e=>u(e),getCurrentIndex:()=>d(),getPerformanceMetrics:()=>f()});const m=g.current;(0,t.useImperativeHandle)(e,()=>m,[m]);const p=(0,t.useRef)(!1);(0,t.useEffect)(()=>{p.current||(p.current=!0,s.current.common?.onReady?.(m))},[s,m])}({ref:i,currentSceneRef:R,scenesRef:C,sceneActionsRef:Te,preloadActionsRef:pt,measureViewportRef:k,resolvedCallbacksRef:N});const kt=(0,t.useCallback)((e,t,n,r)=>{const i=je,a="forward"===e?i+1:i-1;if("drag"!==T)return void("forward"===e?De.nextScene():De.prevScene());const o=se.current,s=o?.targetSceneIndex===a?o:null,c=s?s.releaseSeed.progressRatio:Math.max(0,Math.min(t??We.get(),1)),l=s?s.releaseSeed.elapsedMs:Math.max(0,n??0),u=s?s.registrySnapshot.timelineDuration:Math.max(0,r??0);B.current=!1,fe.current=0,ge.current=null,N.current.drag?.onDragEnd?.({sceneIndex:i,targetSceneIndex:a,progress:c,direction:e,elapsedMs:l,timelineDurationMs:u}),ee.current=!0,De.commitDragSceneChange(e,c,l,u)||(ee.current=!1)},[De,je,We,T]);(0,t.useEffect)(()=>{},[A,D]);const Pt=(0,t.useCallback)(e=>{if("drag"!==T||e.target!==e.currentTarget)return;const t=Math.max(0,C.current.length-1),n="x"===s?"ArrowRight":"ArrowDown",r="x"===s?"ArrowLeft":"ArrowUp";let i=null;if("PageDown"===e.key||e.key===n?i=R.current+1:"PageUp"===e.key||e.key===r?i=R.current-1:"Home"===e.key?i=0:"End"===e.key&&(i=t),null===i)return;e.preventDefault();const a=Math.max(0,Math.min(i,t));a!==R.current&&De.goToScene(a,!0)},[s,T,De]),It=D>0?`${je+1} / ${D}`:"",Et=(0,t.useMemo)(()=>({mode:T,scrollEnterMargin:void 0,scrollExitMargin:void 0,prefersReducedMotion:Xe,reportError:e=>{xe(e.code,e.message,e.context)}}),[T,xe,Xe]);return(0,r.jsx)(h,{designSize:y,children:(0,r.jsx)(ae.Provider,{value:Et,children:(0,r.jsxs)("div",{ref:x,style:{position:"relative",width:"100%",height:"100vh",minHeight:"100vh",overflowX:"hidden",overflowY:"hidden",background:"#0d1624"},className:"cineview-container","data-cineview-container":"true",role:"drag"===T?"region":void 0,"aria-roledescription":"drag"===T?"carousel":void 0,"aria-label":"drag"===T?Ke:void 0,tabIndex:"drag"===T?0:void 0,onKeyDown:"drag"===T?Pt:void 0,children:[(0,r.jsx)("div",{style:{opacity:1,pointerEvents:"auto"},children:(0,r.jsx)(K,{scenes:E,visibleSceneIndices:Ct,currentScene:je,totalScenes:D,mode:T,dragConfig:b,dragProgress:Oe,dragTimelineProgress:$e,renderProgress:Fe,renderProgressMotion:He,timelineProgressMotion:We,isDragging:ze,sharedTimelineDurationMs:Ne,dragRelease:Be,sceneActivations:ye,firstSceneEnterActive:bt,firstSceneEnterReady:St,direction:Le,isAnimating:Ve,viewportWidth:Me,viewportHeight:ke,sceneActions:De,sceneWrapperRefs:w,renderLaneRef:Z,takeoverSnapshot:J,candidateSuspended:W,onCandidateSuspensionChange:rt,onElementContinuationChange:tt,onPointerSessionStart:nt,dragTransaction:ne,onPrepared:Qe,onPreparedInvalidated:et,onOwnershipRequest:at,onTransactionComplete:Je,onSceneChange:kt,onDragProgressChange:ot,onRenderProgressChange:void 0,onDragTimelineProgressChange:e=>We.set(e),onDraggingChange:st,onSharedTimelineDurationChange:De.setSharedTimelineDurationMs,onDragRelease:ct,onDragReset:lt,onFirstSceneEnterComplete:Rt})}),"drag"===T?(0,r.jsx)("div",{role:"status","aria-live":"polite",style:de,children:It}):null]})})})});fe.displayName="CineviewDrag";var ge,me,pe,he,ve,ye,be,Se,xe,we,Re,Me=fe,Ce=m({fadeAnimations:()=>ge}),ke=g(()=>{ge={fade:{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},"fade-in":{initial:{opacity:0},animate:{opacity:1},exit:{opacity:1}},"fade-out":{initial:{opacity:1},animate:{opacity:1},exit:{opacity:0}}}}),Pe=m({slideAnimations:()=>me}),Ie=g(()=>{me={"slide-up":{initial:{y:"100%",opacity:0},animate:{y:0,opacity:1},exit:{y:"-100%",opacity:0}},"slide-down":{initial:{y:"-100%",opacity:0},animate:{y:0,opacity:1},exit:{y:"100%",opacity:0}},"slide-left":{initial:{x:"100%",opacity:0},animate:{x:0,opacity:1},exit:{x:"-100%",opacity:0}},"slide-right":{initial:{x:"-100%",opacity:0},animate:{x:0,opacity:1},exit:{x:"100%",opacity:0}}}}),Ee=m({zoomAnimations:()=>pe}),Ae=g(()=>{pe={"zoom-in":{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0}},"zoom-out":{initial:{scale:1.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:1.5,opacity:0}},"scale-up":{initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:1.5,opacity:0}},"scale-down":{initial:{scale:1.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.5,opacity:0}}}}),De=m({rotateAnimations:()=>he}),Te=g(()=>{he={rotate:{initial:{rotate:-180,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:180,opacity:0}},"rotate-in":{initial:{rotate:-180,scale:0,opacity:0},animate:{rotate:0,scale:1,opacity:1},exit:{rotate:0,scale:1,opacity:1}},"rotate-out":{initial:{rotate:0,scale:1,opacity:1},animate:{rotate:0,scale:1,opacity:1},exit:{rotate:180,scale:0,opacity:0}},spin:{initial:{rotate:0,opacity:0},animate:{rotate:360,opacity:1},exit:{rotate:720,opacity:0}}}}),je=m({flipAnimations:()=>ve}),Ve=g(()=>{ve={flip:{initial:{rotateY:-180,opacity:0},animate:{rotateY:0,opacity:1},exit:{rotateY:180,opacity:0}},"flip-x":{initial:{rotateX:-180,opacity:0},animate:{rotateX:0,opacity:1},exit:{rotateX:180,opacity:0}},"flip-y":{initial:{rotateY:-180,opacity:0},animate:{rotateY:0,opacity:1},exit:{rotateY:180,opacity:0}}}}),Le=m({bounceAnimations:()=>ye}),Oe=g(()=>{ye={bounce:{initial:{y:-100,opacity:0},animate:{y:0,opacity:1,transition:{type:"spring",bounce:.5,duration:.8}},exit:{y:100,opacity:0}},"bounce-in":{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1,transition:{type:"spring",bounce:.6,duration:.8}},exit:{scale:1,opacity:1}},"bounce-out":{initial:{scale:1,opacity:1},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0,transition:{type:"spring",bounce:.6,duration:.6}}}}}),$e=m({blinkAnimations:()=>be}),Fe=g(()=>{be={blink:{initial:{opacity:1},animate:{opacity:[1,0,1,0,1],transition:{duration:1,times:[0,.25,.5,.75,1]}},exit:{opacity:0}},flash:{initial:{opacity:0},animate:{opacity:[0,1,0,1],transition:{duration:.8,times:[0,.25,.5,1]}},exit:{opacity:0}},pulse:{initial:{scale:1,opacity:1},animate:{scale:[1,1.05,1],opacity:[1,.8,1],transition:{duration:1,times:[0,.5,1]}},exit:{scale:1,opacity:0}}}}),ze=m({shakeAnimations:()=>Se}),Ne=g(()=>{Se={shake:{initial:{x:0},animate:{x:[0,-10,10,-10,10,0],transition:{duration:.6,times:[0,.2,.4,.6,.8,1]}},exit:{x:0,opacity:0}},"shake-x":{initial:{x:0},animate:{x:[0,-15,15,-15,15,0],transition:{duration:.8,times:[0,.2,.4,.6,.8,1]}},exit:{x:0,opacity:0}},"shake-y":{initial:{y:0},animate:{y:[0,-15,15,-15,15,0],transition:{duration:.8,times:[0,.2,.4,.6,.8,1]}},exit:{y:0,opacity:0}},vibrate:{initial:{x:0,y:0},animate:{x:[0,-2,2,-2,2,0],y:[0,-2,2,-2,2,0],transition:{duration:.4,times:[0,.2,.4,.6,.8,1]}},exit:{x:0,y:0,opacity:0}},jello:{initial:{skewX:0,skewY:0},animate:{skewX:[0,-12.5,6.25,-3.125,1.5625,0],skewY:[0,-12.5,6.25,-3.125,1.5625,0],transition:{duration:1,times:[0,.222,.444,.666,.888,1]}},exit:{skewX:0,skewY:0,opacity:0}}}}),Be=m({blurAnimations:()=>xe}),qe=g(()=>{xe={"blur-in":{initial:{filter:"blur(10px)",opacity:0},animate:{filter:"blur(0px)",opacity:1},exit:{filter:"blur(0px)",opacity:1}},"blur-out":{initial:{filter:"blur(0px)",opacity:1},animate:{filter:"blur(0px)",opacity:1},exit:{filter:"blur(10px)",opacity:0}},"focus-in":{initial:{filter:"blur(20px)",scale:.8,opacity:0},animate:{filter:"blur(0px)",scale:1,opacity:1},exit:{filter:"blur(0px)",scale:1,opacity:1}}}}),Ue=m({elasticAnimations:()=>we}),Ye=g(()=>{we={elastic:{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1,transition:{type:"spring",stiffness:300,damping:10}},exit:{scale:0,opacity:0}},"rubber-band":{initial:{scale:1},animate:{scale:[1,1.25,.75,1.15,.95,1],transition:{duration:1,times:[0,.3,.4,.5,.65,1]}},exit:{scale:0,opacity:0}},wobble:{initial:{x:0,rotate:0},animate:{x:[0,-25,20,-15,10,-5,0],rotate:[0,-5,3,-3,2,-1,0],transition:{duration:1,times:[0,.15,.3,.45,.6,.75,1]}},exit:{x:0,rotate:0,opacity:0}},swing:{initial:{rotate:0,transformOrigin:"top center"},animate:{rotate:[0,15,-10,5,-5,0],transformOrigin:"top center",transition:{duration:1,times:[0,.2,.4,.6,.8,1]}},exit:{rotate:0,opacity:0}}}}),He=m({specialAnimations:()=>Re}),We=g(()=>{Re={heartbeat:{initial:{scale:1},animate:{scale:[1,1.3,1,1.3,1],transition:{duration:1.3,times:[0,.14,.28,.42,1]}},exit:{scale:0,opacity:0}},tada:{initial:{scale:1,rotate:0},animate:{scale:[1,.9,.9,1.1,1.1,1.1,1.1,1.1,1.1,1],rotate:[0,-3,-3,3,-3,3,-3,3,-3,0],transition:{duration:1,times:[0,.1,.2,.3,.4,.5,.6,.7,.8,1]}},exit:{scale:0,rotate:0,opacity:0}},wave:{initial:{rotate:0,transformOrigin:"bottom center"},animate:{rotate:[0,14,-8,14,-4,10,0],transformOrigin:"bottom center",transition:{duration:1,times:[0,.1,.2,.3,.4,.5,1]}},exit:{rotate:0,opacity:0}},"roll-in":{initial:{x:"-100%",rotate:-120,opacity:0},animate:{x:0,rotate:0,opacity:1},exit:{x:0,rotate:0,opacity:1}},"roll-out":{initial:{x:0,rotate:0,opacity:1},animate:{x:0,rotate:0,opacity:1},exit:{x:"100%",rotate:120,opacity:0}},hinge:{initial:{rotate:0,transformOrigin:"top left"},animate:{rotate:0,transformOrigin:"top left"},exit:{rotate:[0,80,60,80,60,60],y:[0,0,0,0,0,700],opacity:[1,1,1,1,1,0],transformOrigin:"top left",transition:{duration:2,times:[0,.2,.4,.6,.8,1]}}},"jack-in-the-box":{initial:{scale:.1,rotate:30,transformOrigin:"center bottom",opacity:0},animate:{scale:1,rotate:0,transformOrigin:"center bottom",opacity:1,transition:{type:"spring",stiffness:500,damping:15}},exit:{scale:0,opacity:0}}}}),Xe=class extends Error{constructor(e,t,n){super(t),this.code=e,this.permanent=n.permanent,this.category=n.category,this.presetName=n.presetName,this.cause=n.cause,this.name="PresetLoadError"}};function Ke(e){return e instanceof Xe}var Ge={fade:"fade","fade-in":"fade","fade-out":"fade","slide-up":"slide","slide-down":"slide","slide-left":"slide","slide-right":"slide","zoom-in":"zoom","zoom-out":"zoom","scale-up":"zoom","scale-down":"zoom",rotate:"rotate","rotate-in":"rotate","rotate-out":"rotate",spin:"rotate",flip:"flip","flip-x":"flip","flip-y":"flip",bounce:"bounce","bounce-in":"bounce","bounce-out":"bounce",blink:"blink",flash:"blink",pulse:"blink",shake:"shake","shake-x":"shake","shake-y":"shake",vibrate:"shake",jello:"shake","blur-in":"blur","blur-out":"blur","focus-in":"blur",elastic:"elastic","rubber-band":"elastic",wobble:"elastic",swing:"elastic",heartbeat:"special",tada:"special",wave:"special","roll-in":"special","roll-out":"special",hinge:"special","jack-in-the-box":"special"},_e=["fade","slide","zoom","rotate","flip","bounce","blink","shake","blur","elastic","special"],Ze=new Map,Je=new Map,Qe=new Map,et=new Map,tt=new Map,nt={left:"0%",center:"50%",right:"100%"},rt={top:"0%",center:"50%",bottom:"100%"},it={center:"50% 50%","top center":"50% 0%","center top":"50% 0%","bottom center":"50% 100%","center bottom":"50% 100%","top left":"0% 0%","left top":"0% 0%","top right":"100% 0%","right top":"100% 0%","bottom left":"0% 100%","left bottom":"0% 100%","bottom right":"100% 100%","right bottom":"100% 100%","center left":"0% 50%","left center":"0% 50%","center right":"100% 50%","right center":"100% 50%"};function at(e,t){return Array.isArray(t)?t.map(t=>at(e,t)):t&&"object"==typeof t?ot(t):"transformOrigin"===e&&"string"==typeof t?function(e){const t=e.trim().toLowerCase().replace(/\s+/g," "),n=it[t];if(n)return n;const r=t.split(" ");if(1===r.length){const t=nt[r[0]],n=rt[r[0]];return t&&n?`${t} ${n}`:t?`${t} 50%`:n?`50% ${n}`:e}if(2===r.length){const[e,t]=r,n=nt[e]??nt[t],i=rt[e]??rt[t];if(n&&i)return`${n} ${i}`}return e}(t):t}function ot(e){const t={};return Object.entries(e).forEach(([e,n])=>{t[e]=at(e,n)}),t}function st(e){return{initial:ot(e.initial||{}),animate:ot(e.animate||{}),exit:ot(e.exit||{})}}var ct=async e=>"string"==typeof e?await(async e=>st(await async function(e){const t=tt.get(e);if(t)throw t;const n=Ge[e];if(!n){const t=new Xe("INVALID_ANIMATION",`Unknown preset animation: ${e}`,{permanent:!0,presetName:e});throw tt.set(e,t),t}const r=(await function(e){const t=Ze.get(e);if(t)return Promise.resolve(t);const n=et.get(e);if(n)return Promise.reject(n);if(!function(e){return _e.includes(e)}(e)){const t=new Xe("INVALID_ANIMATION",`Unknown animation category: ${e}`,{permanent:!0,category:e});return et.set(e,t),Qe.set(e,"failed-permanent"),Promise.reject(t)}const r=Je.get(e);if(r)return r;Qe.set(e,"pending");const i=function(e,t){return new Promise((n,r)=>{const i=setTimeout(()=>{r(new Xe("ANIMATION_ASSET_LOAD_FAILED",`Timed out loading animation category "${t}".`,{permanent:!1,category:t}))},3e3);e.then(e=>{clearTimeout(i),n(e)},e=>{clearTimeout(i),r(e)})})}(async function(e){switch(e){case"fade":return(await Promise.resolve().then(()=>(ke(),Ce))).fadeAnimations;case"slide":return(await Promise.resolve().then(()=>(Ie(),Pe))).slideAnimations;case"zoom":return(await Promise.resolve().then(()=>(Ae(),Ee))).zoomAnimations;case"rotate":return(await Promise.resolve().then(()=>(Te(),De))).rotateAnimations;case"flip":return(await Promise.resolve().then(()=>(Ve(),je))).flipAnimations;case"bounce":return(await Promise.resolve().then(()=>(Oe(),Le))).bounceAnimations;case"blink":return(await Promise.resolve().then(()=>(Fe(),$e))).blinkAnimations;case"shake":return(await Promise.resolve().then(()=>(Ne(),ze))).shakeAnimations;case"blur":return(await Promise.resolve().then(()=>(qe(),Be))).blurAnimations;case"elastic":return(await Promise.resolve().then(()=>(Ye(),Ue))).elasticAnimations;case"special":return(await Promise.resolve().then(()=>(We(),He))).specialAnimations;default:throw new Xe("INVALID_ANIMATION",`Unknown animation category: ${e}`,{permanent:!0,category:e})}}(e),e).then(t=>(Ze.set(e,t),Qe.set(e,"success"),t)).catch(t=>{const n=function(e,t){return Ke(t)?t:new Xe("ANIMATION_ASSET_LOAD_FAILED",`Failed to load animation category "${e}".`,{permanent:!1,category:e,cause:t})}(e,t);throw Qe.set(e,n.permanent?"failed-permanent":"failed-transient"),n.permanent&&et.set(e,n),n}).finally(()=>{Je.get(e)===i&&Je.delete(e)});return Je.set(e,i),i}(n))[e];if(r)return r;const i=new Xe("INVALID_ANIMATION",`Preset animation "${e}" is missing from category "${n}".`,{permanent:!0,category:n,presetName:e});throw tt.set(e,i),i}(e)))(e):"object"==typeof e?(e=>{if(!(e=>{if(!e||"object"!=typeof e)return!1;const t=new Set(["initial","animate","exit"]),n=Object.entries(e);return 0!==n.length&&!n.some(([e])=>!t.has(e))&&n.some(([,e])=>null!=e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).length>0)})(e))return null;try{return(e=>st({initial:e.initial??{},animate:e.animate??{},exit:e.exit??{}}))(e)}catch(e){return null}})(e):null,lt=e=>{const t={};return e.forEach(e=>{Object.assign(t,e)}),t},ut=async e=>{const t=[];for(let n=0;n<e.length;n++){const r=await ct(e[n]);r&&t.push({variant:r,sourceIndex:n})}return t},dt=e=>{const{transition:t,...n}=e.animate;return{values:n,transition:t||{}}},ft=e=>{const t={},n={};return e.forEach(({values:e,transition:r})=>{Object.entries(e).forEach(([e,i])=>{t[e]=i,n[e]=r})}),t.transition=n,t};async function gt(e,t,n,r){if(!e)return null;try{const i=await(async e=>"object"==typeof e&&"mode"in e&&"animations"in e?await(async e=>{if(!(e=>!!(e&&"object"==typeof e&&e.mode&&["sequential","parallel"].includes(e.mode)&&Array.isArray(e.animations)&&0!==e.animations.length))(e))return null;try{const{mode:t,animations:n,delays:r=[]}=e;return"sequential"===t?await(async(e,t=[])=>{const n=await ut(e);if(0===n.length)throw new Error("No valid animations in sequential composition");const r=n[0].variant.initial,i=n[n.length-1].variant.exit;let a=0;const o=n.map(({variant:e,sourceIndex:n})=>{const r=t[n]||0,{values:i,transition:o}=dt(e),s={...o,delay:a+r/1e3};return a+=("number"==typeof o.duration?o.duration:1)+r/1e3,{values:i,transition:s}});return{initial:r,animate:ft(o),exit:i}})(n,r):"parallel"===t?await(async(e,t=[])=>{const n=await ut(e);if(0===n.length)throw new Error("No valid animations in parallel composition");const r=n.map(({variant:e})=>e.initial),i=n.map(({variant:e,sourceIndex:n})=>{const r=t[n]||0,{values:i,transition:a}=dt(e);return{values:i,transition:{...a,delay:r/1e3}}}),a=n.map(({variant:e})=>e.exit);return{initial:lt(r),animate:ft(i),exit:lt(a)}})(n,r):null}catch(e){if(Ke(e))throw e;return null}})(e):await ct(e))(e);if(i)return i;const a=`Failed to parse ${n} animation for "${t}".`;r?.({code:"INVALID_ANIMATION",message:a,context:{componentId:t,animationType:n,animation:e}})}catch(i){const a=Ke(i)?{code:i.code,message:i.message,context:{componentId:t,animationType:n,animation:e,category:i.category,presetName:i.presetName}}:{code:"INVALID_ANIMATION",message:`Error parsing ${n} animation for "${t}".`,context:{componentId:t,animationType:n,animation:e}};r?.(a)}return null}function mt(e){return"string"==typeof e&&!e.includes("(")&&e.trim().includes(" ")}function pt(e,t,n){const r={};return new Set([...Object.keys(e),...Object.keys(t)]).forEach(i=>{if("transition"===i)return;const a=e[i],o=t[i];if(void 0===o)return void(r[i]=a);if(a===o)return void(r[i]=o);const s=void 0!==a?a:"opacity"===i?1:"number"==typeof o?0:"0";if(mt(s)||mt(o))r[i]=n>.5?o:s;else if("number"!=typeof o||"number"!=typeof s){if("number"==typeof s&&"string"==typeof o){if(o.includes("px"))return void(r[i]=`${s+((parseFloat(o)||0)-s)*n}px`);if(o.includes("%"))return void(r[i]=`${s+((parseFloat(o)||0)-s)*n}%`);if(o.includes("deg"))return void(r[i]=`${s+((parseFloat(o)||0)-s)*n}deg`)}if("string"==typeof s&&"number"==typeof o){if(s.includes("px")){const e=parseFloat(s)||0;return void(r[i]=`${e+(o-e)*n}px`)}if(s.includes("%")){const e=parseFloat(s)||0;return void(r[i]=`${e+(o-e)*n}%`)}if(s.includes("deg")){const e=parseFloat(s)||0;return void(r[i]=`${e+(o-e)*n}deg`)}}if("string"==typeof o&&"string"==typeof s){if(o.includes("px")||s.includes("px")){const e=parseFloat(s)||0;return void(r[i]=`${e+((parseFloat(o)||0)-e)*n}px`)}if(o.includes("%")||s.includes("%")){const e=parseFloat(s)||0;return void(r[i]=`${e+((parseFloat(o)||0)-e)*n}%`)}if(o.includes("deg")||s.includes("deg")){const e=parseFloat(s)||0;return void(r[i]=`${e+((parseFloat(o)||0)-e)*n}deg`)}if(o.includes("(")&&o.includes(")")||s.includes("(")&&s.includes(")")){const e=String(s).match(/([a-zA-Z]+)\(([^)]+)\)/),t=o.match(/([a-zA-Z]+)\(([^)]+)\)/);if(e&&t&&e[1]===t[1]){const a=e[1],o=e[2],s=t[2];if(!isNaN(parseFloat(o))&&!isNaN(parseFloat(s))){const e=parseFloat(o),t=e+(parseFloat(s)-e)*n;return void(r[i]=`${a}(${t})`)}}}}r[i]=n>.5?o:s}else r[i]=s+(o-s)*n}),r}function ht(e,t,n){for(let n=t;n>=0;n-=1){const t=e[n];if("number"==typeof t||"string"==typeof t)return t}return n}function vt(e,t,n){return Math.min(n,Math.max(t,e))}function yt(e,t,n){return e+(t-e)*n}function bt(e,t,n){if("number"==typeof e&&"number"==typeof t)return yt(e,t,n);const r=String(e),i=String(t),a=r.match(/^([-\d.]+)(.*)$/),o=i.match(/^([-\d.]+)(.*)$/);if(a&&o){const e=parseFloat(a[1]),t=parseFloat(o[1]),r=o[2]||a[2]||"",i=yt(e,t,n);return r?`${i}${r}`:i}const s=r.match(/^([a-zA-Z]+)\(([-\d.]+)(.*)\)$/),c=i.match(/^([a-zA-Z]+)\(([-\d.]+)(.*)\)$/);if(s&&c&&s[1]===c[1]){const e=parseFloat(s[2]),t=parseFloat(c[2]),r=c[3]||s[3]||"",i=yt(e,t,n);return`${c[1]}(${i}${r})`}return n>=1?t:e}function St(e,t,n,r,i){const a=t[n]??r,o=vt(i,0,1);if(!Array.isArray(a))return bt(e,a,o);if(0===a.length)return e;const s=function(e,t,n){const r=e.transition,i=r?.[t],a=(i&&!Array.isArray(i)?i.times:null)??r?.times;return Array.isArray(a)&&a.length===n?a:null}(t,n,a.length);if(1===a.length||o<=(s?.[0]??0))return ht(a,0,e);for(let t=1;t<a.length;t+=1){const n=s?.[t]??t/(a.length-1);if(o>n)continue;const r=s?.[t-1]??(t-1)/(a.length-1),i=n-r,c=i<=0?1:(o-r)/i;return bt(ht(a,t-1,e),ht(a,t,e),c)}return ht(a,a.length-1,e)}function xt(e,t,n){const r=e[t]??n;return Array.isArray(r)?ht(r,r.length-1,n):r}function wt(e,t){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){const t=parseFloat(e);if(Number.isFinite(t))return t}return t}function Rt(e,t){switch(e){case"opacity":return"initial"===t||"exit"===t?0:1;case"scale":return 1;case"filter":return"none";default:return 0}}function Mt(e,t,n){const r=e[t];return void 0===r?n:r}function Ct(e,t,r,i){return(0,n.useTransform)(e,e=>i(e,t.current,r))}function kt(e,t,r,i,a){return(0,n.useTransform)(e,e=>{const n=wt(Rt(r,"animate"),0);return wt((a??i)(e,t.current,r),n)})}function Pt(e,t,n,r){const i=kt(e,t,"opacity",n,r),a=Ct(e,t,"x",n),o=Ct(e,t,"y",n),s=kt(e,t,"scale",n,r),c=Ct(e,t,"rotate",n),l=Ct(e,t,"rotateX",n),u=Ct(e,t,"rotateY",n),d=Ct(e,t,"skewX",n),f=Ct(e,t,"skewY",n),g=Ct(e,t,"filter",n);return{style:{opacity:i,x:a,y:o,scale:s,rotate:c,rotateX:l,rotateY:u,skewX:d,skewY:f,filter:g},opacity:i,x:a,y:o,scale:s,rotate:c,rotateX:l,rotateY:u,skewX:d,skewY:f,filter:g}}var It=.001;function Et(e){return e.renderProgressMotion?.get()??e.renderProgress??0}function At(e){return e.dragTransaction?e.dragTransaction:!0===e.firstSceneEnterActive?e.preparedSnapshot??null:null}function Dt(e){return At(e)?.registrySnapshot.timelineDuration??e.getTimelineDuration?.()??e.sceneTransitionDuration}function Tt(e,t,n,r,i,a){const o=function(e,t,n,r){const i=function(e){return Et(e)>=0?"forward":"backward"}(e),a=function(e){return Math.max(0,e.sharedElapsedMotion?.get()??0)}(e),o=function(e){const t=e.dragTimelineProgress;return vt("number"==typeof t?t:Math.abs(Et(e)),0,1)}(e),s=function(e){const t=Dt(e);if(At(e))return t;const n=e.sharedTimelineDurationMs??0;return n>0?n:t}(e),c=Dt(e),l=Math.abs(Et(e)),u=function(e,t,n){return n<=0?e>=t-It?1:0:e<=t?0:vt((e-t)/n,0,1)}(a,t,n),d={direction:i,transitionProgress:o,sharedElapsedMs:a,projectedSceneElapsedMs:a,sharedTimelineDurationMs:s,sceneTimelineDurationMs:c,sceneOffset:e.sceneOffset};if(0===e.sceneOffset&&e.isActive){const t=!0===e.firstSceneEnterActive||"settle"===e.dragRelease?.mode||"enter"===e.dragRelease?.mode;if(e.isDragging||l>It){if(l<=It&&t)return{...d,mode:"enter",localProgress:u};const n=Math.max(r,1),i=l*e.sceneTransitionDuration;return{...d,mode:"outgoing",localProgress:vt(i/n,0,1)}}return t?{...d,mode:"enter",localProgress:u}:{...d,mode:"rest",projectedSceneElapsedMs:c,localProgress:1}}return("forward"===i&&1===e.sceneOffset||"backward"===i&&-1===e.sceneOffset)&&(e.isDragging||l>It)?{...d,mode:"enter",localProgress:u}:{...d,mode:"hidden",projectedSceneElapsedMs:0,localProgress:0}}(e,t,n,r);return a?{...o,mode:"hidden",localProgress:0,projectedSceneElapsedMs:0}:i?{...o,mode:"rest",localProgress:1,projectedSceneElapsedMs:o.sceneTimelineDurationMs}:o}function jt(e,t,n){return e?function(e,t,n){const r=xt(t.enterInitial,n,Rt(n,"initial")),i=xt(t.enterAnimate,n,Rt(n,"animate"));switch(e.mode){case"rest":default:return i;case"hidden":return r;case"enter":return St(r,t.enterAnimate,n,Rt(n,"animate"),e.localProgress);case"outgoing":return 0===Object.keys(t.exitTarget).length?i:"forward"===e.direction?St(i,t.exitTarget,n,Rt(n,"exit"),e.localProgress):St(r,t.enterAnimate,n,Rt(n,"animate"),1-e.localProgress)}}(e,t,n):xt(t.enterAnimate,n,Rt(n,"animate"))}var Vt=new WeakMap,Lt=new WeakMap;function Ot(e,t){return"entered"===e&&t}function $t(e,t,n,r){return void 0===e?t:n+(r-n)*vt(e,0,1)}function Ft(e,t,n){return bt(Mt(t.initial,n,Rt(n,"initial")),Mt(t.animate,n,Rt(n,"animate")),e)}function zt(e,t,n){const r=wt(Rt(n,"animate"),0),i=wt(Mt(t.initial,n,Rt(n,"initial")),r);return i+(wt(Mt(t.animate,n,Rt(n,"animate")),r)-i)*e}function Nt(e,t){switch(e){case"hidden":default:return"idle";case"outgoing":return"exiting";case"rest":return"entered";case"enter":return t>=.999?"entered":"entering"}}function Bt(e){return e<=0?0:e>=1?1:e}function qt(e,t){return{enterProgress:Bt(t),phase:e}}function Ut(e,t){const n=t<=0?0:t>=1?1:t;return{enterProgress:n,phase:Nt(e,n)}}var Yt={enterProgress:0,phase:"idle"};function Ht({signedVisual:e,phaseMotion:i,render:a}){const[o,s]=(0,t.useState)(()=>qt(i.get(),e.get()));return(0,n.useMotionValueEvent)(e,"change",e=>{s(qt(i.get(),e))}),(0,n.useMotionValueEvent)(i,"change",t=>{s(qt(t,e.get()))}),(0,r.jsx)(r.Fragment,{children:a(o)})}function Wt({visualState:e,render:i}){const[a,o]=(0,t.useState)(()=>{const t=e.get();return t?Ut(t.mode,t.localProgress):Yt});return(0,n.useMotionValueEvent)(e,"change",e=>{o(e?Ut(e.mode,e.localProgress):Yt)}),(0,r.jsx)(r.Fragment,{children:i(a)})}function Xt(e){if("string"==typeof e){const t=n.motion[e];if(t)return t}return n.motion.div}function Kt(e,t,n){return"last"===n?t-1-e:"center"===n?Math.abs(e-(t-1)/2):e}function Gt(e){return t.Children.toArray(e.props.children).filter(t.isValidElement)}function _t(e){return Gt(e).length}function Zt(e,t,n,r,i,a="animate"){const o=e[a]?.transition?.duration,s="number"==typeof o&&Number.isFinite(o)?Math.max(1e3*o,0):Math.max(t,0),c=Math.max(n,0);let l=0;for(let e=0;e<i;e+=1)l=Math.max(l,Kt(e,i,r));const u=l*c;return{itemDurationMs:s,tailDurationMs:u,effectiveDurationMs:Math.max(t,u+s)}}function Jt(e,t,n,r,i){return Zt(e,t??0,n,r,_t(i)).effectiveDurationMs}function Qt(e,r){const i=r(e.get()),a=(0,t.useRef)(i),[o,s]=(0,t.useState)(()=>({phase:i,revision:0}));return(0,n.useMotionValueEvent)(e,"change",e=>{const t=r(e);t!==a.current&&(a.current=t,s(e=>({phase:t,revision:e.revision+1})))}),[o.phase,o.revision]}function en(e,n,r=0){const i=(0,t.useRef)(Math.max(n,0)),[a,o]=(0,t.useState)(null);return(0,t.useEffect)(()=>{i.current=Math.max(n,0)},[n]),(0,t.useEffect)(()=>{if("animate"!==e)return;const t=i.current;if(0===t)return void o(r);const n=window.setTimeout(()=>o(r),t);return()=>window.clearTimeout(n)},[e,r]),"animate"===e&&a===r}function tn(e,n,i,a,o,s,c,l,u=!1){const d=t.Children.toArray(e.props.children),f=Gt(e).length,g=Math.max(i,0)/1e3,m="boolean"==typeof o?o?"animate":"initial":o,p=n.animate.transition??{},h={initial:n.initial,animate:e=>({...n.animate,transition:u?{...p,duration:0,delay:0}:{...p,...void 0===p.duration&&void 0!==s?{duration:Math.max(s,0)/1e3}:{},delay:Kt(e,f,a)*g}}),exit:e=>{const t=c?.exit??n.initial,r=t.transition??{};return{...t,transition:{...r,...void 0===r.duration&&void 0!==l?{duration:Math.max(l,0)/1e3}:{},delay:Kt(e,f,a)*g}}}};let v=0;const y=d.map((e,n)=>{if(!(0,t.isValidElement)(e))return e;const i=v;v+=1;const a=Xt(e.type);return(0,r.jsx)(a,{custom:i,variants:h,className:e.props.className,style:e.props.style,children:e.props.children},e.key??n)}),b=Xt(e.type),{children:S,...x}=e.props;return(0,r.jsx)(b,{...x,initial:"initial",animate:m,variants:{initial:{},animate:{},exit:{}},children:y})}function nn({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,exitVariant:o,exitItemDurationMs:s,signedVisual:c}){const[l,u]=Qt(c,e=>e>0?"animate":e<0&&o?"exit":"initial");return tn(e,t,n,r,l,i,o,s,en(l,a??Jt(t,i,n,r,e),u))}function rn({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,phaseMotion:o,staticReveal:s}){const[c,l]=Qt(o,e=>"entering"===e||"entered"===e?"animate":"initial"),u=en(c,a??Jt(t,i,n,r,e),l);return tn(e,t,n,r,c,i,void 0,void 0,s||u)}function an({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,exitVariant:o,exitItemDurationMs:s,visualState:c}){const[l,u]=Qt(c,e=>"outgoing"===e?.mode&&o?"exit":e&&("enter"===e.mode&&e.localProgress>0||"rest"===e.mode)?"animate":"initial");return tn(e,t,n,r,l,i,o,s,en(l,a??Jt(t,i,n,r,e),u))}var on=(0,t.createContext)(null);function sn({value:e,children:t}){return(0,r.jsx)(on.Provider,{value:e,children:t})}function cn(){const e=(0,t.useContext)(on);if(!e)throw new Error("useAnimateTimeline must be used inside an <Animate> child.");return e}var ln=Object.freeze({progress:0,signedProgress:0,phase:"idle",source:"idle"});function un(e,t){if(!t)return"idle";switch(e?.dragTransaction?.phase){case"driving":return"gesture";case"settling":case"bouncing":return"continuation";case"programmatic":return"programmatic"}return"settle"===e?.dragRelease?.mode||"bounce"===e?.dragRelease?.mode?"continuation":"enter"===e?.dragRelease?.mode||e?.firstSceneEnterActive?"programmatic":"idle"}var dn=(0,t.createContext)(null),fn=(0,t.createContext)(null),gn=(0,t.createContext)(null);function mn(e){if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function pn(e,t,n,r){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1}else if(!mn(e)||!mn(t))return!1;const i=e,a=t,o=n.get(i),s=r.get(a);if(o||s)return o===a&&s===i;n.set(i,a),r.set(a,i);try{if(Array.isArray(e)&&Array.isArray(t))return e.every((e,i)=>pn(e,t[i],n,r));const i=e,a=t,o=Object.keys(i).sort(),s=Object.keys(a).sort();if(o.length!==s.length)return!1;for(let e=0;e<o.length;e+=1){const t=o[e];if(t!==s[e]||!pn(i[t],a[t],n,r))return!1}return!0}finally{n.delete(i),r.delete(a)}}function hn(e){const n=(0,t.useRef)(e);return pn(n.current,e,new WeakMap,new WeakMap)||(n.current=e),n.current}var vn=(0,t.createContext)(null),yn=Object.freeze({opacity:1}),bn=0,Sn=({enterAnimation:e,exitAnimation:i,loopAnimation:a,animateId:o,duration:s,timeline:c,visibility:l,stagger:u,enterRef:d,exitRef:f,children:g})=>{const m=(0,t.useRef)(o||"animate-"+ ++bn).current,p=(0,t.useContext)(vn),h=oe(),y=h?.reportError,b=!0===h?.prefersReducedMotion,S=(0,t.useContext)(dn),x=(0,t.useContext)(gn),[w,R]=(0,t.useState)(null),[M,C]=(0,t.useState)(null),[k,P]=(0,t.useState)(null),[I,E]=(0,t.useState)(0),A=(0,t.useRef)(0),D=(0,t.useRef)(null),T=(0,t.useRef)(new Set),j=(0,t.useRef)(null),V=(0,t.useRef)(new Set),L=hn(e),O=hn(i),$=hn(a),F=(0,n.useAnimation)(),z=(0,n.useAnimation)(),N=(0,t.useMemo)(()=>function({duration:e,timeline:t,visibility:n}){return{duration:{enter:e?.enter??600,exit:e?.exit??600},timeline:{driver:t?.driver??"scene",delay:t?.delay??0,after:t?.after,phase:{start:t?.phase?.start,end:t?.phase?.end}},visibility:{replay:n?.replay??!0,enterMargin:n?.enterMargin,exitMargin:n?.exitMargin}}}({duration:s,timeline:c,visibility:l}),[s,c,l]),B=p?.mode??h?.mode??"drag",q="drag"===B&&"clock"===N.timeline.driver,U=(0,t.useRef)(null),Y="drag"===B&&p?.isActive?p.activationToken??0:0;(null===U.current||U.current.mode!==B||U.current.token!==Y||0===Y&&U.current.arrival!==q)&&(U.current={token:Y,mode:B,arrival:q});const H="drag"===B&&U.current.arrival,W=p?.beginPreparation,X=p?.declareAnimateLane,K=(0,t.useMemo)(()=>{const{driver:e,...t}=N.timeline;return{...t,lane:"scroll"===B&&"scene"===e&&x?"scroll":"visibility"}},[x,B,N.timeline]),G=N.duration.enter,_=N.duration.exit,Z=K.delay,J=K.after,Q=(0,t.useContext)(fn),ee=H&&p?.isActive?p.activationToken??0:0,te=I>0&&D.current?.enterAnimation===L&&D.current?.exitAnimation===O&&D.current?.loopAnimation===$,ne=(0,t.useRef)(null),re=ne.current;H&&(0===ee||null===re||re.token!==ee)&&(ne.current={token:ee,ready:te,enterVariant:te?w:null,exitVariant:te?M:null,infiniteVariant:te?k:null,hasAuthoredEnterAnimation:!!L,enterDuration:G,exitDuration:_,delay:Z,stagger:u,enterAnimation:L,exitAnimation:O,loopAnimation:$});const ie=H?ne.current:null;ie&&!ie.ready&&I>0&&D.current?.enterAnimation===ie.enterAnimation&&D.current?.exitAnimation===ie.exitAnimation&&D.current?.loopAnimation===ie.loopAnimation&&(ie.ready=!0,ie.enterVariant=w,ie.exitVariant=M,ie.infiniteVariant=k);const ae=ie?ie.enterAnimation:L,se=ie?ie.exitAnimation:O,ce=ie?ie.loopAnimation:$,le=ie?.ready?ie.enterVariant:H?null:w,ue=ie?.ready?ie.exitVariant:H?null:M,de=ie?.ready?ie.infiniteVariant:H?null:k,fe=ie?.enterDuration??G,ge=ie?.exitDuration??_,me=ie?.delay??Z,pe=ie?ie.stagger:u;(0,t.useEffect)(()=>{if(!H)return;const e=X?.(m,"visibility");return()=>e?.dispose()},[X,m,H]),(0,t.useEffect)(()=>{if(!H)return;const e=(e,t)=>{const n=`${m}:${e}`;T.current.has(n)||(T.current.add(n),y?.({code:"INVALID_ANIMATION",message:t,context:{componentId:m,field:e,lane:"visibility",mode:"drag"}}))};J&&e("after",`Animate "${m}" ignores after in drag mode when timeline.driver is 'clock'.`),O&&e("exitAnimation",`Animate "${m}" ignores exitAnimation in drag mode when timeline.driver is 'clock'.`)},[m,H,J,y,O]);const he="function"==typeof g,ve=!(!ae&&!ce||(H?ie?.ready??te:te)||le||ue||de),ye="drag"===B?!H:"scroll"===K.lane,be="scroll"===B&&!ye,Se=(0,t.useRef)(new Set);(0,t.useEffect)(()=>{if(!d&&!f)return;const e=(e,t)=>{const n=`${m}:${e}`;Se.current.has(n)||(Se.current.add(n),y?.({code:"INVALID_ANIMATION",message:t,context:{componentId:m,field:e,mode:B,scrub:ye}}))};if(ye){const t="drag"===B?"the Scene element track (drag)":"the zone scroll budget (scroll takeover)";return d&&e("enterRef",`Animate "${m}" ignores enterRef: this element is driven by ${t}, whose progress has a single owner. Use timeline.driver:'clock' (drag) or move it outside the takeover zone (scroll) for manual control.`),void(f&&e("exitRef",`Animate "${m}" ignores exitRef: this element is driven by ${t}, whose progress has a single owner. Use timeline.driver:'clock' (drag) or move it outside the takeover zone (scroll) for manual control.`))}H&&f&&e("exitRef",`Animate "${m}" ignores exitRef in drag mode when timeline.driver is 'clock': this lane has no exit pass (it also ignores exitAnimation).`)},[d,f,m,H,ye,B,y]);const xe=H?pe:u,we=xe&&!he&&le&&(0,t.isValidElement)(g)?g:null,Re=!!we,Me=xe?.each??40,Ce=xe?.from??"first",ke=(0,t.useMemo)(()=>we&&le?Zt(le,fe,Me,Ce,_t(we)):null,[fe,le,we,Me,Ce]),Pe=(0,t.useMemo)(()=>we&&ue?Zt(ue,ge,Me,Ce,_t(we),"exit"):null,[ge,ue,we,Me,Ce]),Ie=ke?.effectiveDurationMs??fe,Ee=Pe?.effectiveDurationMs??ge,Ae=(0,t.useMemo)(()=>S?{...S,zoneStates:Q?.zoneStates??{},store:Q?.store}:null,[S,Q?.store,Q?.zoneStates]);(0,t.useEffect)(()=>{const e=V.current,t=++A.current,n=()=>A.current===t;j.current?.lease.cancel(),j.current=null;const r="drag"!==B||H?void 0:W?.();r&&e.add(r),j.current=r?{generation:t,lease:r}:null;const i=e=>{n()&&y?.(e)};return R(null),C(null),P(null),E(0),ae||ce?((async()=>{const[e,n,r]=await Promise.all([gt(ae,m,"enter",i),gt(se,m,"exit",i),gt(ce,m,"loop",i)]);A.current===t&&(D.current={enterAnimation:ae,exitAnimation:se,loopAnimation:ce},R(e??null),C(n??null),P(r??null),E(t))})(),()=>{e.forEach(e=>e.cancel()),e.clear(),n()&&(A.current+=1)}):(y?.({code:"INVALID_ANIMATION",message:`Animate "${m}" requires enterAnimation or loopAnimation.`,context:{componentId:m,hasExitAnimation:!!se}}),(()=>{const n=j.current;!n||n.generation!==t||(n.lease.complete(),e.delete(n.lease),j.current=null)})(),()=>{e.forEach(e=>e.cancel()),e.clear(),n()&&(A.current+=1)})},[m,B,H,y,W,ae,se,ce]),(0,t.useEffect)(()=>{!H||0===ee||!ie||(ie.enterAnimation!==L||ie.exitAnimation!==O||ie.loopAnimation!==$)&&Promise.all([gt(L,m,"enter"),gt(O,m,"exit"),gt($,m,"loop")])},[ie,ee,m,H,L,O,$]);const De=function({sceneContext:e,enterVariant:r,exitVariant:i,componentId:a,delay:o,enterDuration:s,exitDuration:c,after:l,variantsPending:u=!1}){const d=e?At(e):null,f=d?.registrySnapshot.registrations.get(a),g=d?.enterVariantsByAnimateId.get(a)??null,m=!(!d||f&&g),p=f?.duration??s,h=d?.registrySnapshot.calculatedDelays.get(a)??0,v=g??r,y=(0,t.useRef)(h),b=(0,t.useRef)(d);b.current=d;const S=(0,t.useRef)({enterInitial:v?.initial||{},enterAnimate:v?.animate||{},exitTarget:i?.exit||{}}),x=e?Tt(e,y.current,p,c,m,u):null,w=x?"outgoing"===x.mode?("forward"===x.direction?1:-1)*x.localProgress:x.localProgress:0,R=(0,n.useMotionValue)(w),M=(0,n.useMotionValue)(x),[C,k]=(0,t.useState)(!1),P=((0,t.useRef)(null),(0,t.useRef)(null)),I=(0,t.useRef)(null);(0,t.useRef)({identity:null,categories:new Set}),(0,t.useEffect)(()=>{},[a,o,s,r,g,f,m,d,e?.isActive,e?.sceneOffset,l]),(0,t.useEffect)(()=>{S.current={enterInitial:v?.initial||{},enterAnimate:v?.animate||{},exitTarget:i?.exit||{}},d&&(y.current=h)},[i,h,d,v]),(0,t.useEffect)(()=>{const t=e?.registerAnimate,n=e?.unregisterAnimate,i=e?.getCalculatedDelay;if(!t||!i||!r)return;const c=t(a,{delay:o,duration:s,after:l,lane:"drag"});return c?.setEnterVariant?.(r),b.current||(y.current=c?.getCalculatedDelay?.()??i(a)),()=>{c?.dispose?c.dispose():n?.(a)}},[e?.registerAnimate,e?.unregisterAnimate,e?.getCalculatedDelay,r,a,o,s,l]),(0,t.useEffect)(()=>{if(!e)return;const t=()=>{if(d)y.current=h;else{const t=e.getCalculatedDelay?.(a);"number"==typeof t&&(y.current=t)}const t=Tt(e,y.current,p,c,m,u),n="outgoing"===t.mode?("forward"===t.direction?1:-1)*t.localProgress:t.localProgress,r=[t.mode,t.direction,e.sceneOffset,e.isActive?"active":"inactive",e.isDragging?"dragging":"idle"].join(":"),i=P.current!==r;if(R.set(n),M.set(t),P.current=r,i&&(t.mode,t.direction,e.sceneOffset,e.isActive,e.isDragging,e.sceneState,Et(e).toFixed(3),t.transitionProgress.toFixed(3),t.sharedElapsedMs.toFixed(1),t.projectedSceneElapsedMs.toFixed(1),t.sharedTimelineDurationMs,t.sceneTimelineDurationMs,t.localProgress.toFixed(3),y.current),"enter"===t.mode){const n=t.localProgress<=.001?"before-delay":t.localProgress>=.999?"enter-complete":"enter-active";I.current!==`${t.mode}:${n}`&&(t.mode,t.sharedElapsedMs.toFixed(1),t.projectedSceneElapsedMs.toFixed(1),t.sharedTimelineDurationMs,t.sceneTimelineDurationMs,t.transitionProgress.toFixed(3),y.current,t.localProgress.toFixed(3),Et(e).toFixed(3),e.sceneOffset,I.current=`${t.mode}:${n}`)}};t();const n=[e.sharedElapsedMotion?.on("change",t),e.renderProgressMotion?.on("change",t)].filter(e=>"function"==typeof e);return()=>{n.forEach(e=>e())}},[e,R,M,a,s,c,m,u,h,p,d,e?.renderProgressMotion,e?.renderProgress,e?.isDragging,e?.isActive,e?.sceneOffset,e?.sceneState,e?.dragRelease,e?.firstSceneEnterActive]);const E=Pt(M,S,jt);return(0,t.useEffect)(()=>{if(!e)return void k(!1);const t=()=>{const t=Tt(e,y.current,p,c,m,u);k(e.isActive&&0===e.sceneOffset&&!e.isDragging&&("rest"===t.mode||"enter"===t.mode)&&t.localProgress>=.999)};t();const n=[e.sharedElapsedMotion?.on("change",t),e.renderProgressMotion?.on("change",t)].filter(e=>"function"==typeof e);return()=>{n.forEach(e=>e())}},[e,p,m,u,c,e?.isActive,e?.sceneOffset,e?.isDragging,e?.renderProgressMotion,e?.renderProgress,e?.dragRelease,e?.firstSceneEnterActive]),{style:E.style,opacity:E.opacity,x:E.x,y:E.y,scale:E.scale,rotate:E.rotate,useInteractiveStyles:!0,shouldRunInfinite:C,visualState:M}}({sceneContext:"drag"!==B||H?null:p,enterVariant:w,exitVariant:M,componentId:m,delay:Z,enterDuration:Ie,exitDuration:Ee,after:J,variantsPending:ve}),Te=function({enabled:e,sceneContext:r,enterVariant:i,hasAuthoredEnterAnimation:a,parseReady:o,delay:s,enterDuration:c,enterRef:l}){const u=(0,t.useRef)({initial:{},animate:{}}),d=!!l&&s<=0,f=(0,t.useRef)({delay:s,enterDuration:c,hasAuthoredEnterAnimation:a,parseReady:o,enterVariant:i,autoEnterSuppressed:d});f.current={delay:s,enterDuration:c,hasAuthoredEnterAnimation:a,parseReady:o,enterVariant:i,autoEnterSuppressed:d};const g=(0,n.useMotionValue)(a?0:1),m=(0,n.useMotionValue)(a?"idle":"entered"),[p,h]=(0,t.useState)(!1),[v,y]=(0,t.useState)(!1),b=(0,t.useRef)(null),S=(0,t.useRef)(null),x=(0,t.useRef)(0),w=(0,t.useRef)(0),R=(0,t.useRef)(null),M=(0,t.useRef)(!1),C=(0,t.useRef)(0===(r?.activationToken??0)),k=(0,t.useRef)(r);k.current=r;const P=(0,t.useCallback)(()=>{b.current?.stop(),b.current=null,null!==S.current&&(clearTimeout(S.current),S.current=null)},[]),I=(0,t.useCallback)(()=>{const e=f.current;P(),x.current=0,w.current=0,R.current=null,M.current=!1,h(!1),y(!1),m.set(e.hasAuthoredEnterAnimation?"idle":"entered"),g.set(e.hasAuthoredEnterAnimation?0:1)},[m,P,g]),E=(0,t.useCallback)((e,t)=>{const r=k.current,i=f.current;if(!r?.isActive||(r.activationToken??0)!==e||e<=0)return;if(i.hasAuthoredEnterAnimation&&!i.parseReady)return void(w.current=e);if(x.current===e)return;w.current=0,x.current=e,P(),R.current=null,h(!1),u.current={initial:i.enterVariant?.initial??{},animate:i.enterVariant?.animate??{}};const a="static"===t&&C.current;y(a);const o=()=>{const t=k.current;return!(!t?.isActive||(t.activationToken??0)!==e)},s=()=>{o()&&h(!0)};if(!i.hasAuthoredEnterAnimation||null===i.enterVariant||a)return m.set("entered"),g.set(1),void(()=>{const e=Math.max(i.delay,0);e<=0?s():S.current=setTimeout(()=>{S.current=null,s()},e)})();m.set("waiting"),g.set(0);const c=()=>{if(S.current=null,!o())return;m.set("entering");const e=Math.max(i.enterDuration,0);if(e<=0)return m.set("entered"),g.set(1),void h(!0);b.current=(0,n.animate)(g,1,{duration:e/1e3,ease:"easeInOut",onComplete:()=>{b.current=null,o()&&(m.set("entered"),g.set(1),h(!0))}})},l=Math.max(i.delay,0);if(i.autoEnterSuppressed)return R.current=c,void(M.current&&(M.current=!1,R.current=null,c()));l>0?S.current=setTimeout(c,l):c()},[m,P,g]),A=e&&r?.isActive?r.activationToken??0:0,D=r?.activationKind??null;(0,t.useEffect)(()=>{A<=0?I():E(A,D)},[D,A,I,E]),(0,t.useEffect)(()=>{const e=w.current;e<=0||!o||E(e,k.current?.activationKind??null)},[i,o,E]),(0,t.useEffect)(()=>()=>{P(),x.current=0,w.current=0},[P]);const T=(0,t.useCallback)(()=>{const e=R.current;e?(R.current=null,M.current=!1,null!==S.current&&(clearTimeout(S.current),S.current=null),e()):M.current=!0},[]);return(0,t.useEffect)(()=>{if(l&&e)return l.current=T,()=>{l.current===T&&(l.current=null)}},[e,l,T]),{style:Pt(g,u,Ft,zt).style,visualMotion:g,phaseMotion:m,shouldRunInfinite:p,staticReveal:v}}({enabled:H,sceneContext:"drag"===B?p:null,enterVariant:le,hasAuthoredEnterAnimation:ie?.hasAuthoredEnterAnimation??!!e,parseReady:ie?.ready??I>0,delay:me,enterDuration:Ie,enterRef:H?d:void 0}),je=function({sceneContext:e,zoneRuntime:r,zoneId:i,enterVariant:a,exitVariant:o,hasAuthoredEnterAnimation:s,hasAuthoredExitAnimation:c,hasInfiniteAnimation:l=!1,componentId:u,duration:d,timeline:f,visibility:g,globalEnterMargin:m,globalExitMargin:p,enterRef:h,exitRef:y,variantsPending:b=!1}){const S=d.enter,x=d.exit,w=!0===oe()?.prefersReducedMotion,R=w?0:S,M=w?0:x,C=f.delay,k=f.after,P="scroll"===f.lane,I=f.phase?.start,E=f.phase?.end,A=g.replay,D=v()?.scale??1,T=g.enterMargin??m??50,j=g.exitMargin??p??50,V=Math.max(0,T*D),L=Math.max(0,j*D),O=(0,t.useRef)({enterInitial:{},enterAnimate:{},exitTarget:{}}),$=(0,n.useMotionValue)(0),F=(0,n.useMotionValue)(i&&r?r.store?.getKeySnapshot(i)??r.zoneStates[i]??null:null),[z,N]=(0,t.useState)(!1),B=(0,t.useRef)(null),[q,U]=(0,t.useState)(0),Y=r?.registerZoneAnimation,H=r?.unregisterZoneAnimation,W=!!(a?.animate&&Object.keys(a.animate).length>0)||!!s,X=function(e,t){return!!(t>0&&e?.exit&&Object.keys(e.exit).length>0)}(o,x)||!!c;(0,t.useEffect)(()=>{O.current={enterInitial:a?.initial||{},enterAnimate:a?.animate||{},exitTarget:o?.exit||{}}},[a,o]);const K=(0,t.useRef)("idle"),G=(0,n.useMotionValue)("idle"),_=(0,t.useCallback)(e=>{K.current=e,G.set(e)},[G]),Z=(0,t.useRef)(null),J=(0,t.useRef)(null),Q=(0,t.useRef)(0),ee=(0,t.useRef)(!1),te=(0,t.useRef)(null),ne=(0,t.useRef)(null),re=(0,t.useRef)(null),ie=(0,t.useRef)(()=>{}),ae=(0,t.useRef)(0),se=(0,t.useRef)(null),ce=(0,t.useRef)(!1),le=(0,t.useRef)(!1),ue=(0,t.useRef)(!1),de=(0,t.useCallback)(()=>r&&i?r.store?.getKeySnapshot(i)??r.zoneStates[i]??null:null,[i,r]);(0,t.useEffect)(()=>{if(!P||!r||!i)return void F.set(null);const e=()=>{F.set(de())};return e(),r.store?.subscribeKey(i,e)},[P,de,i,r,F]);const fe=!!h&&!P&&!(k||C>0),ge=!!y&&!P,me=(0,t.useRef)(!1),pe=(0,t.useRef)(!1),he=(0,t.useCallback)(e=>{e?.publishEnterCompleted()},[]),ve=(0,t.useCallback)(()=>{ae.current+=1,se.current=null,te.current&&(clearTimeout(te.current),te.current=null),ne.current&&(ne.current(),ne.current=null),re.current&&(re.current(),re.current=null)},[]),ye=(0,t.useCallback)(()=>{Q.current+=1,J.current&&(J.current.stop(),J.current=null),ve()},[ve]),be=(0,t.useCallback)(()=>{const e=B.current?.ownerDocument?.defaultView;e&&(re.current?.(),re.current=function(e,t){let n=Lt.get(e);if(!n){const t=e.requestAnimationFrame?.bind(e)??(t=>e.setTimeout(()=>t(Date.now()),16)),r=e.cancelAnimationFrame?.bind(e)??(t=>e.clearTimeout(t));n={callbacks:new Map,frame:null,requestFrame:t,cancelFrame:r},Lt.set(e,n)}const r=n,i=r.callbacks.get(t)??{callback:t,cancelled:!1};return r.callbacks.set(t,i),null===r.frame&&(r.frame=r.requestFrame(()=>{r.frame=null;const t=[...r.callbacks.values()];r.callbacks.clear(),t.forEach(e=>{e.cancelled||e.callback()}),0===r.callbacks.size&&null===r.frame&&Lt.get(e)===r&&Lt.delete(e)})),()=>{i.cancelled=!0,r.callbacks.get(t)===i&&r.callbacks.delete(t),0===r.callbacks.size&&null!==r.frame&&(r.cancelFrame(r.frame),r.frame=null,Lt.get(e)===r&&Lt.delete(e))}}(e,()=>{re.current=null,ie.current()}))},[]),Se=(0,t.useCallback)(()=>{ve(),_("entering"),$.get()<0&&$.set(0);const e=Z.current,t=++Q.current,r=(0,n.animate)($,1,{duration:Math.max(R,0)/1e3,ease:"easeInOut",onComplete:()=>{Q.current===t&&(J.current=null,_("entered"),he(e),be())}});J.current=r},[ve,R,he,be,_,$]),xe=(0,t.useCallback)((e=!1)=>{const t=K.current,n="exited"===t?"exited":"exiting"===t?"exiting":"idle";ye();const r={token:++ae.current,origin:n,dependencyReady:!k,delayStarted:!1,delayReady:!1,coldStartBypass:e};se.current=r,_("waiting"),N(!1);const i=e=>{se.current?.token!==r.token||"pending"===e.kind||(r.dependencyReady=!0,ne.current=null,be())};if(!k)return;const a=Z.current;a?ne.current=a.observeAfter(i):i({kind:"invalid",leaderId:k,reason:"missing"})},[be,_,ye,k]),we=(0,t.useCallback)(()=>{const e=se.current;if(e&&e.dependencyReady){if(!e.delayStarted){if(e.delayStarted=!0,C>0){const t=e.token;return void(te.current=setTimeout(()=>{te.current=null,se.current?.token===t&&(e.delayReady=!0,be())},C))}e.delayReady=!0}e.delayReady&&Se()}},[C,Se,be]),Re=(0,t.useCallback)(()=>{ye(),_("exiting"),N(!1),$.get()>=0&&$.set(-1e-6);const e=++Q.current,t=(0,n.animate)($,-1,{duration:Math.max(M,0)/1e3,ease:"easeInOut",onComplete:()=>{Q.current===e&&(J.current=null,_("exited"))}});J.current=t},[M,ye,_,$]),Me=(0,t.useCallback)(t=>{if(P||b)return;const n=B.current;if(!(n instanceof HTMLElement))return;const r=e?.firstSceneEnterGateKnown,i=e?.firstSceneEnterReady,a=e?.firstSceneEnterActive;if(!1===r)return ye(),_("idle"),$.set(0),void N(!1);if(!1===i&&!0===a)return le.current=!1,ye(),_("idle"),$.set(0),void N(!1);const o=!1===i&&!1===a&&!le.current&&!fe;o&&(le.current=!0,ce.current=!0,ye(),_("entered"),$.set(1),he(Z.current));const s=n.getBoundingClientRect();if(!(s.width>0||s.height>0||s.bottom!==s.top))return;const c=n.closest('[data-cineview-container="true"]'),l=t?.top??(c?c.getBoundingClientRect().top:0),u=(t?.height??c?.clientHeight??0)||window.innerHeight||1,d=s.top-l,f=s.bottom-l,g=Math.max(s.height,f-d,0)>u-V,m=g?d<=u/2:d>=0&&f<=u-V,p=g?f<=.7*u:d<=L||f>=u-L,h=g?m&&!p:m,v=f<=0,y=f>0&&d<u;if(o)return v&&(ue.current=!1),void N(Ot("entered",y));if(!ce.current){if(ce.current=!0,fe)return void N(!1);if(v)return ye(),_("entered"),$.set(1),he(Z.current),N(Ot("entered",!1)),void(ue.current=!1);if(!0===i&&!g&&d>=0&&f<=u)return xe(!0),void we()}if("waiting"===K.current){const e=se.current;if(e&&(!0===e?.coldStartBypass&&!0===i&&!g&&d>=0&&f<=u||h&&!p))we();else{const t=e?.origin??"idle";ve(),_(t)}}else{const e=function(e,t,n,r){switch(e){case"idle":return t&&!n?"enter":null;case"entering":case"entered":return n&&!t&&r.hasExplicitExit?"exit":null;case"exiting":case"exited":return t&&!n&&r.replay?"enter":null;default:return null}}(K.current,h,p,{hasExplicitExit:X,replay:A});y&&!ue.current&&(ue.current=!0),"enter"!==e||fe||me.current||pe.current?"exit"===e&&!ge&&(!ue.current&&v||Re()):(xe(),we())}N(Ot(K.current,y))},[we,fe,ge,xe,ve,V,L,X,P,he,A,Re,e?.firstSceneEnterGateKnown,e?.firstSceneEnterActive,e?.firstSceneEnterReady,_,ye,b,$]);ie.current=Me;const Ce=(0,t.useCallback)(()=>{me.current=!0,pe.current=!1,ce.current=!0,le.current=!0,Se()},[Se]),ke=(0,t.useCallback)(()=>{pe.current=!0,Re()},[Re]);(0,t.useEffect)(()=>{if(h&&!P)return h.current=Ce,()=>{h.current===Ce&&(h.current=null)}},[h,P,Ce]),(0,t.useEffect)(()=>{if(y&&!P)return y.current=ke,()=>{y.current===ke&&(y.current=null)}},[y,P,ke]),(0,t.useEffect)(()=>{const t=e?.registerAnimate,n=e?.unregisterAnimate;if(!t||!W&&!X)return;const r=t(u,{delay:C,duration:W?S:x,after:k,lane:P?"scroll":"visibility"});return Z.current=r??null,ee.current=!1,()=>{ve(),Z.current===r&&(Z.current=null),r?.dispose?r.dispose():n?.(u)}},[e?.registerAnimate,e?.unregisterAnimate,ve,u,C,S,x,k,W,X,P]),(0,t.useEffect)(()=>{if(typeof document>"u"||b||B.current?.isConnected)return;const e=document.querySelector(`[data-cineview-animate-host="${u}"]`)??document.querySelector(`[data-cineview-animate-id="${u}"]`);e instanceof HTMLElement&&B.current!==e&&(B.current=e,U(e=>e+1))},[u,a,o,b]),(0,t.useEffect)(()=>{if(!(P&&Y&&H&&i&&(W||X)))return;const e=Y(i,{animateId:u,delay:C,enterDuration:S,exitDuration:X?x:0,after:k,...void 0!==I||void 0!==E?{phase:{start:I,end:E}}:{}});return()=>{H(i,u,e)}},[u,C,S,x,X,W,P,E,I,i,k,Y,H]);const Pe=(0,t.useCallback)(e=>{if(!W&&!X)return"entered"!==K.current&&_("entered"),void(1!==$.get()&&$.set(1));if(!r||!i)return void(0!==$.get()&&$.set(0));const t=e?.sequence.budgets[u];if(!e||!t)return void(0!==$.get()&&$.set(0));const n=vt(e.progressPx,0,e.totalBudgetPx),a=t.enterStartPx,o=Math.max(t.enterEndPx,t.enterStartPx+1),s="number"==typeof t.phaseStartPx?t.phaseStartPx:$t(I,a,a,o),c=Math.max("number"==typeof t.phaseEndPx?t.phaseEndPx:$t(E,o,a,o),s+1);if(n>=c&&!ee.current&&(ee.current=!0,he(Z.current)),n<=s)return void(0!==$.get()&&$.set(0));if(!t.hasExit)return n>=c?void(1!==$.get()&&$.set(1)):void $.set(vt((n-s)/Math.max(c-s,1),0,1));const l=t.exitStartPx??c,d=t.exitEndPx??l+1;n<=c?$.set(vt((n-s)/Math.max(c-s,1),0,1)):n<=l?1!==$.get()&&$.set(1):n>=d?-1!==$.get()&&$.set(-1):$.set(-vt((n-l)/Math.max(d-l,1),0,1))},[u,W,X,E,I,he,_,$,i,r]);(0,t.useEffect)(()=>{if(!P)return;const e=()=>Pe(F.get());return e(),W||X?F.on("change",e):void 0},[Pe,W,X,P,F]),(0,t.useEffect)(()=>{P||Me()},[q,P,Me,e?.scrollProgress,e?.scrollTimelineState]),(0,t.useEffect)(()=>{if(P)return;const e=B.current;return e instanceof HTMLElement&&!(typeof window>"u")?function(e,t){const n=function(e){const t=Vt.get(e);if(t)return t;const n=function(e){return typeof window<"u"&&e===window||typeof Window<"u"&&e instanceof Window}(e),r=n?e:e.ownerDocument?.defaultView??window,i=r.requestAnimationFrame?.bind(r)??(e=>r.setTimeout(()=>e(Date.now()),16)),a=r.cancelAnimationFrame?.bind(r)??(e=>r.clearTimeout(e)),o={subscribers:new Set,frame:null,requestFrame:i,cancelFrame:a,schedule:()=>{null===o.frame&&(o.frame=o.requestFrame(()=>{o.frame=null;const t=n?{top:0,height:e.innerHeight||1}:{top:e.getBoundingClientRect().top,height:e.clientHeight||r.innerHeight||1};[...o.subscribers].forEach(e=>e(t))}))},cleanup:()=>{e.removeEventListener("scroll",o.schedule),n||r.removeEventListener("resize",o.schedule),null!==o.frame&&(o.cancelFrame(o.frame),o.frame=null)}};return e.addEventListener("scroll",o.schedule,{passive:!0}),n||r.addEventListener("resize",o.schedule,{passive:!0}),Vt.set(e,o),o}(e);return n.subscribers.add(t),n.schedule(),()=>{n.subscribers.delete(t),0===n.subscribers.size&&(n.cleanup(),Vt.delete(e))}}(e.closest('[data-cineview-container="true"]')??window,Me):void 0},[q,P,Me]),(0,t.useEffect)(()=>ye,[ye]);const Ie=(0,t.useRef)(!1),Ee=(0,t.useCallback)(t=>{if(!(l&&P&&r&&i))return void(Ie.current&&(Ie.current=!1,N(!1)));const n=e?.runtimeState,a=void 0===n||"covered"!==n&&"inactive"!==n&&"parked"!==n&&"exiting"!==n;if(!W&&!X)return void(Ie.current!==a&&(Ie.current=a,N(a)));const o=t?.sequence.budgets[u];if(!t||!o||!a)return void(Ie.current&&(Ie.current=!1,N(!1)));const s=vt(t.progressPx,0,t.totalBudgetPx),c=o.enterStartPx,d=Math.max(o.enterEndPx,o.enterStartPx+1),f="number"==typeof o.phaseStartPx?o.phaseStartPx:$t(I,c,c,d),g=Math.max("number"==typeof o.phaseEndPx?o.phaseEndPx:$t(E,d,c,d),f+1),m=W?s>=g-.5:s>.5,p=!o.hasExit||null===o.exitStartPx||s<=o.exitStartPx+.5,h=m&&p;Ie.current!==h&&(Ie.current=h,N(h))},[u,W,X,l,P,E,I,e?.runtimeState,N,i,r]);return(0,t.useEffect)(()=>{if(P&&l)return Ee(F.get()),W||X?F.on("change",Ee):void 0;Ee(null)},[W,X,l,P,Ee,F]),{style:Pt($,O,(e,t,n)=>function(e,t,n){const r=n>=0,i=r?e.enterAnimate:e.exitTarget;return St(xt(r?e.enterInitial:e.enterAnimate,t,Rt(t,r?"initial":"animate")),i,t,Rt(t,r?"animate":"exit"),r?n:Math.abs(n))}(t,n,e)).style,shouldRunInfinite:z,visualMotion:$,phaseMotion:G}}({sceneContext:"scroll"===B?p:null,zoneRuntime:"scroll"===B?Ae:null,zoneId:x,enterVariant:w,exitVariant:M,hasAuthoredEnterAnimation:!!e,hasAuthoredExitAnimation:!!i,hasInfiniteAnimation:!!k,componentId:m,duration:{enter:Ie,exit:Ee},timeline:K,visibility:N.visibility,globalEnterMargin:h?.scrollEnterMargin,globalExitMargin:h?.scrollExitMargin,enterRef:be?d:void 0,exitRef:be?f:void 0,variantsPending:ve});(0,t.useEffect)(()=>{if("drag"!==B||0===I)return;const e=j.current;!e||e.generation!==I||(e.lease.complete(),j.current=null)},[B,I]);const Ve=function({mode:e,isDragArrival:r,timelineLane:i,sceneContext:a,arrivalVisualMotion:o,arrivalPhaseMotion:s,scrollVisualMotion:c,scrollPhaseMotion:l,dragVisualState:u}){const d=(0,n.useMotionValue)(0),f=(0,n.useMotionValue)(0),g=(0,n.useMotionValue)("idle"),m=(0,n.useMotionValue)(ln);return(0,t.useEffect)(()=>{const t="scroll"===e||r?i:"drag",n=e=>{d.set(e.progress),f.set(e.signedProgress),g.set(e.phase),m.set(e)};if("scroll"===e||r){const e=r?o:c,i=r?s:l,a=()=>{const r=e.get();n({progress:Bt(r),signedProgress:r,phase:i.get(),source:"scroll"===t?"scroll":"visibility"})};a();const u=e.on("change",a),d=i.on("change",a);return()=>{u(),d()}}const p=e=>{if(!e)return void n(ln);const t=Math.max(0,Math.min(1,e.localProgress)),r="outgoing"===e.mode?("forward"===e.direction?1:-1)*t:t;n({progress:t,signedProgress:r,phase:Nt(e.mode,t),source:un(a,e)})};return p(u.get()),u.on("change",p)},[s,o,u,r,e,m,g,d,f,i,a,l,c]),(0,t.useMemo)(()=>({mode:e,lane:"scroll"===e||r?i:"drag",progress:d,signedProgress:f,phase:g,frame:m}),[r,e,m,g,d,f,i])}({mode:B,isDragArrival:H,timelineLane:"scroll"===B||H?K.lane:"drag",sceneContext:p,arrivalVisualMotion:Te.visualMotion,arrivalPhaseMotion:Te.phaseMotion,scrollVisualMotion:je.visualMotion,scrollPhaseMotion:je.phaseMotion,dragVisualState:De.visualState});(0,t.useEffect)(()=>{const e=H?de:k;if("drag"===B&&e){if(b||!(H?Te.shouldRunInfinite:De.shouldRunInfinite))return void F.stop();F.start({...e.animate,transition:{...e.animate.transition||{},repeat:1/0}})}},[Te.shouldRunInfinite,F,De.shouldRunInfinite,k,H,B,b,de]),(0,t.useEffect)(()=>{if("scroll"===B&&k){if(b||!je.shouldRunInfinite)return void z.stop();z.start({...k.animate,transition:{...k.animate.transition||{},repeat:1/0}})}},[B,k,b,je.shouldRunInfinite,z]);const Le=he?g:void 0,Oe=he?null:g,$e=(0,r.jsx)(sn,{value:Ve,children:Re?we&&le?"scroll"===B?(0,r.jsx)(nn,{container:we,variant:le,each:Me,from:Ce,itemDurationMs:ke?.itemDurationMs,effectiveDurationMs:ke?.effectiveDurationMs,exitVariant:ue,exitItemDurationMs:Pe?.itemDurationMs,signedVisual:je.visualMotion}):H?(0,r.jsx)(rn,{container:we,variant:le,each:Me,from:Ce,itemDurationMs:ke?.itemDurationMs,effectiveDurationMs:ke?.effectiveDurationMs,phaseMotion:Te.phaseMotion,staticReveal:Te.staticReveal}):(0,r.jsx)(an,{container:we,variant:le,each:Me,from:Ce,itemDurationMs:ke?.itemDurationMs,effectiveDurationMs:ke?.effectiveDurationMs,exitVariant:ue,exitItemDurationMs:Pe?.itemDurationMs,visualState:De.visualState}):null:Le?"scroll"===B||H?(0,r.jsx)(Ht,{signedVisual:H?Te.visualMotion:je.visualMotion,phaseMotion:H?Te.phaseMotion:je.phaseMotion,render:Le}):(0,r.jsx)(Wt,{visualState:De.visualState,render:Le}):Oe}),Fe=Re?yn:je.style,ze=Re?yn:H?Te.style:De.style;return le||ue||de||ve?"scroll"===B?de?(0,r.jsx)("div",{"data-cineview-animate-host":m,children:(0,r.jsx)(n.motion.div,{style:Fe,className:"cineview-animate","data-cineview-animate-id":m,children:(0,r.jsx)(n.motion.div,{animate:z,children:$e})})}):(0,r.jsx)("div",{"data-cineview-animate-host":m,children:(0,r.jsx)(n.motion.div,{style:Fe,className:"cineview-animate","data-cineview-animate-id":m,children:$e})}):de?(0,r.jsx)(n.motion.div,{style:ze,className:"cineview-animate","data-cineview-animate-id":m,children:(0,r.jsx)(n.motion.div,{animate:F,children:$e})}):(0,r.jsx)(n.motion.div,{style:ze,className:"cineview-animate","data-cineview-animate-id":m,children:$e}):(0,r.jsx)(sn,{value:Ve,children:Le?Le(Yt):Oe})};Sn.displayName="Animate";var xn=(0,t.createContext)({lastX:0,lastY:0}),wn=(0,t.createContext)(null),Rn=(0,t.forwardRef)(function({at:e,x:n,y:a,offsetX:o,offsetY:s,fixed:c=!1,children:l,style:u,className:d,...f},g){const m=v(),p=oe(),h=(0,t.useContext)(xn),y=(0,t.useContext)(wn),b=e?.x??n,S=e?.y??a,x=e?.offsetX??o,w=e?.offsetY??s,R=c,M=e?.anchor,C="center"===M||"center-x"===M,k="center"===M||"center-y"===M,P=R&&"scroll"===p?.mode&&!y,{finalLeft:I,finalTop:E,finalX:A,finalY:D}=(0,t.useMemo)(()=>{const e=m?.convert??(e=>e);if(void 0!==b||void 0!==S){const t=void 0!==b?b:0,n=void 0!==S?S:0;return{finalLeft:e(t),finalTop:e(n),finalX:t,finalY:n}}if(void 0!==x||void 0!==w){const t=h.lastX+(void 0!==x?x:0),n=h.lastY+(void 0!==w?w:0);return{finalLeft:e(t),finalTop:e(n),finalX:t,finalY:n}}return{finalLeft:0,finalTop:0,finalX:0,finalY:0}},[m,h,x,w,b,S]),{leftStyle:T,topStyle:j,centerTransform:V}=(0,t.useMemo)(()=>{const e=m?.convert??(e=>e),t=[];let n=I;if(C){const r=e(b??0);n=0===r?"50%":`calc(50% + ${r}px)`,t.push("translateX(-50%)")}let r=E;if(k){const n=e(S??0);r=0===n?"50%":`calc(50% + ${n}px)`,t.push("translateY(-50%)")}return{leftStyle:n,topStyle:r,centerTransform:t.length>0?t.join(" "):void 0}},[m,C,k,b,S,I,E]),L=(0,t.useMemo)(()=>({lastX:A,lastY:D}),[A,D]),O=(0,t.useMemo)(()=>{const e=[V,u?.transform].filter(Boolean).join(" ")||void 0;return{...u,position:P?"sticky":"absolute",left:T,top:j,pointerEvents:R?u?.pointerEvents??"auto":u?.pointerEvents,transform:e}},[P,R,T,j,V,u]),$=(0,r.jsx)(xn.Provider,{value:L,children:(0,r.jsx)("div",{ref:g,style:O,className:d,...f,children:l})});return R&&y&&!P?(0,i.createPortal)($,y):$});Rn.displayName="Position";var Mn={opacity:1,x:0,y:0,scale:1,rotate:0};function Cn(e,t){return function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}(e)?{...t,...e}:t}function kn(e){return Math.max(0,Math.min(e,1))}function Pn(e,t){return"drag"!==e?"auto":"y"===t?"pan-x pinch-zoom":"pan-y pinch-zoom"}function In({effectiveMode:e,isActive:t,globalScrollTimelineState:n,hasExitAnimation:r}){if("scroll"!==e||!n)return t?1:0;switch(n.phase){case"before":default:return 0;case"enter":return n.enterProgress;case"hold":return 1;case"exit":return r?1-n.exitProgress:1;case"after":return r?0:1}}function En({onVisibilityChange:e,sceneVisibilityCallback:t,sceneIndex:n,visible:r,progress:i}){e?.(r,i),t?.({sceneIndex:n,visible:r,progress:i})}function An({effectiveMode:e,effectiveDirection:t,globalScrollTimelineState:n,globalScrollViewportOffset:r,globalViewportWidth:i,globalViewportHeight:a}){if("scroll"!==e)return{visible:!1,isHorizontal:!1,hostOffset:0,hostSpan:0,clipWidth:0,clipHeight:0};const o=n?.rangeStart??0,s=n?.rangeEnd??o,c="x"===t,l=Math.max(s-o,0),u=Math.max(c?i:a,0),d=o-r,f=s-r,g=Math.max(Math.min(u,Math.max(l,1)),1),m=function(e,t,n){return Math.min(n,Math.max(0,e))}(r-o,0,Math.max(l-g,0));return{visible:l>0&&f>0&&d<u,isHorizontal:c,hostOffset:m,hostSpan:g,clipWidth:c?l:0,clipHeight:c?0:l}}function Dn({sceneIndex:e,metrics:n,setHostRef:i,frameStore:a,direction:o="y",viewportWidth:s=0,viewportHeight:c=0}){const l=(0,t.useRef)(null),u=(0,t.useRef)(null);return(0,t.useEffect)(()=>{if(!a||"number"!=typeof e)return;const t=()=>{const t=a.getKeySnapshot(e);if(!t)return;const n=An({effectiveMode:"scroll",effectiveDirection:o,globalScrollTimelineState:t.timelineState,globalScrollViewportOffset:t.visualViewportOffset,globalViewportWidth:s,globalViewportHeight:c}),r=l.current,i=u.current;!r||!i||(r.style.width=n.clipWidth>0?`${n.clipWidth}px`:"100%",r.style.height=n.clipHeight>0?`${n.clipHeight}px`:"100%",r.style.opacity=n.visible?"1":"0",r.style.visibility=n.visible?"visible":"hidden",i.style.top=n.isHorizontal?"0px":`${n.hostOffset}px`,i.style.left=n.isHorizontal?`${n.hostOffset}px`:"0px",i.style.width=n.isHorizontal&&n.hostSpan>0?`${n.hostSpan}px`:"100%",i.style.height=n.isHorizontal?"100%":n.hostSpan>0?`${n.hostSpan}px`:"100%")};return t(),a.subscribeKey(e,t)},[o,a,e,c,s]),(0,r.jsx)("div",{ref:l,"data-scene-fixed-layer":e,"data-scene-fixed-role":"clip",style:{position:"absolute",inset:0,width:n.clipWidth>0?n.clipWidth:"100%",height:n.clipHeight>0?n.clipHeight:"100%",overflow:"hidden",pointerEvents:"none",opacity:n.visible?1:0,visibility:n.visible?"visible":"hidden",zIndex:20},children:(0,r.jsx)("div",{ref:u,"data-scene-fixed-layer":e,"data-scene-fixed-role":"frame",style:{position:"absolute",top:n.isHorizontal?0:n.hostOffset,left:n.isHorizontal?n.hostOffset:0,width:n.isHorizontal&&n.hostSpan>0?n.hostSpan:"100%",height:n.isHorizontal?"100%":n.hostSpan>0?n.hostSpan:"100%",pointerEvents:"none"},children:(0,r.jsx)("div",{ref:i,"data-scene-fixed-layer":e,"data-scene-fixed-host":e,"data-scene-fixed-role":"host",style:{position:"relative",width:"100%",height:"100%",pointerEvents:"none"}})})})}function Tn(e){switch(e.type){case"missing-dependency":return`${e.type}:${e.animateId}:${e.after}`;case"circular-dependency":return`${e.type}:${e.animateId}:${e.cycle.join(">")}`;case"duplicate-id":return`${e.type}:${e.animateId}`;case"incompatible-lane":return`${e.type}:${e.animateId}:${e.after}:${e.followerLane}:${e.leaderLane}`}}function jn(e){let t;return e.forEach(e=>{t=e}),t}function Vn(e,t,n=Object.is){if(e.size!==t.size)return!1;for(const[r,i]of e){const e=t.get(r);if(void 0===e||!n(i,e))return!1}return!0}function Ln(){return typeof performance<"u"?performance.now():Date.now()}function On(e,t,n){const r=e.panInfo??{point:{x:0,y:0},delta:{x:0,y:0},offset:{x:0,y:0},velocity:{x:0,y:0}};return r.point.x=t,r.point.y=n,r.delta.x=t-e.lastX,r.delta.y=n-e.lastY,r.offset.x=t-e.startX,r.offset.y=n-e.startY,r.velocity.x=e.velocityX,r.velocity.y=e.velocityY,e.panInfo=r,r}var $n=t.default.createContext(null),Fn=new Set(["children","sceneId","layout","stack","transition","assets","drag","scroll","callbacks","runtimeMode","runtimeDirection","isActive","sceneIndex","totalScenes","currentSceneIndex","sceneRuntime","dragRuntime","scrollRuntime","onDragGestureEnd","onDragReset","onActivationComplete","onDragProgressChange","onRenderProgressChange","onDragTimelineProgressChange","onSharedElapsedMsChange","onDraggingChange","onSharedTimelineDurationChange","onDragRelease","onScrollProgressChange","onScrollDirectionChange","onScrollingChange","onScrollCommit","onScrollReset","onSceneChange","mode","slideDirection","slideDuration","sceneTransitionDuration","enterAnimation","exitAnimation","exitDuration","sceneWidth","sceneHeight","sceneAnchor","sceneZIndex","sceneOverflow","sceneStackMode","scrollSpeed","scrollControlled","scrollCommitThreshold","scrollReleaseDuration","scrollLockToSingleScene","scrollEnterLength","scrollHoldLength","scrollExitLength","onVisibilityChange","preloadImages"]),zn=t.default.forwardRef(function(e,i){const{children:a,className:o,style:s,onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:d}=e,{effectiveMode:f,effectiveDirection:g,isActive:m,sceneIndex:p,totalScenes:h,currentSceneIndex:y,globalDirection:b,globalSharedTimelineDurationMs:S,globalActivationToken:x,globalActivationKind:w,globalFirstSceneEnterGateKnown:R,globalFirstSceneEnterActive:M,globalFirstSceneEnterReady:C,globalViewportWidth:k,globalViewportHeight:P,globalDragProgress:I,globalRenderProgress:E,globalDragTimelineProgress:A,globalIsDragging:D,globalDragRelease:T,globalScrollProgress:j,globalIsScrolling:V,globalScrollDirection:L,globalScrollTransitionSnapshot:O,globalScrollBackdropActive:$,globalScrollTimelineState:F,globalScrollViewportOffset:z,resolvedSceneWidth:N,resolvedSceneHeight:Y,resolvedSceneAnchor:H,resolvedSceneOverflow:W,resolvedSceneZIndex:X,effectiveSceneStackMode:K,resolvedSceneTransitionDuration:_,resolvedEnterAnimation:J,resolvedExitAnimation:Q,sceneVisibilityCallback:te,onVisibilityChange:re,onSceneChange:ie,dragRuntime:ae,onActivationComplete:se,onDragProgressChange:ce,onRenderProgressChange:le,onDragTimelineProgressChange:ue,onDraggingChange:de,onSharedTimelineDurationChange:fe,onDragRelease:ge,onDragGestureEnd:me,onDragReset:pe,slideDuration:he,compatFields:ve}=function(e){const t=e.sceneRuntime?.mode??e.runtimeMode??e.mode??"drag";return{effectiveMode:t,effectiveDirection:e.sceneRuntime?.direction??e.runtimeDirection??e.slideDirection??"y",isActive:e.sceneRuntime?.isActive??e.isActive??!1,sceneIndex:e.sceneRuntime?.sceneIndex??e.sceneIndex??0,totalScenes:e.sceneRuntime?.totalScenes??e.totalScenes??1,currentSceneIndex:e.sceneRuntime?.currentSceneIndex??e.currentSceneIndex??0,globalDirection:e.sceneRuntime?.transitionDirection??null,globalIsSceneAnimating:e.sceneRuntime?.isSceneAnimating??!1,globalSharedTimelineDurationMs:e.sceneRuntime?.sharedTimelineDurationMs??0,globalActivationToken:e.sceneRuntime?.activationToken??0,globalActivationKind:e.sceneRuntime?.activationKind??null,globalFirstSceneEnterGateKnown:e.sceneRuntime?.firstSceneEnterGateKnown??!0,globalFirstSceneEnterActive:e.sceneRuntime?.firstSceneEnterActive??!1,globalFirstSceneEnterReady:e.sceneRuntime?.firstSceneEnterReady??!1,globalViewportWidth:e.sceneRuntime?.viewportWidth??0,globalViewportHeight:e.sceneRuntime?.viewportHeight??0,globalDragProgress:e.dragRuntime?.progress??0,globalRenderProgress:e.dragRuntime?.renderProgress??0,globalDragTimelineProgress:e.dragRuntime?.timelineProgress??0,globalIsDragging:e.dragRuntime?.isDragging??!1,globalDragRelease:e.dragRuntime?.release??null,globalScrollProgress:e.scrollRuntime?.progress??0,globalIsScrolling:e.scrollRuntime?.isScrolling??!1,globalScrollDirection:e.scrollRuntime?.direction??null,globalScrollTransitionSnapshot:e.scrollRuntime?.transitionSnapshot??null,globalScrollBackdropActive:e.scrollRuntime?.backdropActive??!1,globalScrollTimelineState:e.scrollRuntime?.timelineState??null,globalScrollActiveSceneIndex:e.scrollRuntime?.activeSceneIndex??0,globalScrollViewportOffset:e.scrollRuntime?.viewportOffset??0,resolvedSceneWidth:e.layout?.width??e.sceneWidth??"100vw",resolvedSceneHeight:e.layout?.height??e.sceneHeight??("scroll"===t?"auto":"100vh"),resolvedSceneAnchor:e.layout?.anchor??e.sceneAnchor??"top-left",resolvedSceneOverflow:e.layout?.overflow??e.sceneOverflow??"hidden",resolvedSceneZIndex:e.layout?.zIndex??e.sceneZIndex,effectiveSceneStackMode:e.layout?.overlap??e.sceneStackMode??("scroll"===t?"cover":"replace"),resolvedSceneTransitionDuration:e.sceneTransitionDuration??e.transition?.exitDuration??e.exitDuration??800,resolvedEnterAnimation:e.transition?.enterAnimation??e.enterAnimation,resolvedExitAnimation:e.transition?.exitAnimation??e.exitAnimation,sceneVisibilityCallback:e.callbacks?.onVisibilityChange,onVisibilityChange:e.onVisibilityChange,onSceneChange:e.onSceneChange,scrollCommitThreshold:e.scrollCommitThreshold??.42,scrollReleaseDuration:e.scrollReleaseDuration??220,scrollLockToSingleScene:e.scrollLockToSingleScene??!0,scrollRuntime:e.scrollRuntime,dragRuntime:e.dragRuntime,onActivationComplete:e.onActivationComplete,onDragProgressChange:e.onDragProgressChange,onRenderProgressChange:e.onRenderProgressChange,onDragTimelineProgressChange:e.onDragTimelineProgressChange,onSharedElapsedMsChange:e.onSharedElapsedMsChange,onDraggingChange:e.onDraggingChange,onSharedTimelineDurationChange:e.onSharedTimelineDurationChange,onDragRelease:e.onDragRelease,onDragGestureEnd:e.onDragGestureEnd,onDragReset:e.onDragReset,onScrollProgressChange:e.onScrollProgressChange,onScrollDirectionChange:e.onScrollDirectionChange,onScrollingChange:e.onScrollingChange,onScrollCommit:e.onScrollCommit,onScrollReset:e.onScrollReset,slideDuration:e.slideDuration??800,compatFields:[e.mode,e.slideDirection,e.scrollSpeed,e.scrollControlled,e.scrollCommitThreshold,e.scrollReleaseDuration,e.scrollLockToSingleScene,e.runtimeMode,e.runtimeDirection,e.isActive,e.sceneIndex,e.totalScenes,e.currentSceneIndex,e.onActivationComplete,e.onDragProgressChange,e.onRenderProgressChange,e.onDragTimelineProgressChange,e.onSharedElapsedMsChange,e.onDraggingChange,e.onSharedTimelineDurationChange,e.onDragGestureEnd,e.onDragReset,e.onScrollProgressChange,e.onScrollDirectionChange,e.onScrollingChange,e.onScrollCommit,e.onScrollReset,e.scrollRuntime,e.dragRuntime,e.sceneRuntime]}}(e),ye=e.scrollRuntime?.frameStore,be=e.scrollRuntime?.sceneIndex??p,Se=v(),xe=oe(),we=xe?.reportError,Re=(0,n.useAnimation)(),[Me,Ce]=(0,t.useState)(null),[ke,Pe]=(0,t.useState)(null),Ie=(0,t.useRef)(0);(0,t.useRef)(null);const Ee=hn(J),Ae=hn(Q),De=!!(ae||e.onDragProgressChange||e.onRenderProgressChange||e.onDragTimelineProgressChange||e.onDraggingChange||e.onSharedTimelineDurationChange||e.onDragGestureEnd||e.onDragReset),[Te,je]=(0,t.useState)(I),[Ve,Le]=(0,t.useState)(E),[Oe,$e]=(0,t.useState)(A),[Fe,ze]=(0,t.useState)(D),[Ne,Be]=(0,t.useState)(S),[qe,Ue]=(0,t.useState)(T),Ye=(0,t.useRef)(0),He=(0,t.useCallback)(e=>{null!==e?(Ye.current+=1,Ue({...e,token:Ye.current})):Ue(null)},[]),We=De?I:Te,Xe=De?E:Ve,Ke=De?A:Oe,Ge=De?D:Fe,_e=De?S:Ne,Ze=De?T:qe,Je=Ge,Qe=(0,n.useMotionValue)(We),et=ae?.renderProgressMotion??Qe,tt=(0,n.useMotionValue)(Ke),nt=ae?.timelineProgressMotion??tt,rt=(0,n.useMotionValue)(0),[it,at]=(0,t.useState)("initial"),ot=p-y,[st,ct]=(0,t.useState)(!1),lt=(0,t.useRef)(Symbol(`scene:${p}`)),ut=(0,t.useRef)(null),dt=(0,t.useRef)(ae?.onPreparedInvalidated);dt.current=ae?.onPreparedInvalidated;const[ft,mt]=(0,t.useState)(null),ht=(0,t.useMemo)(()=>ae?.dragMappingConfig??q(void 0,e.drag),[ae?.dragMappingConfig,e.drag]),vt=(0,t.useCallback)((t,n,r)=>{if("drag"!==f)return;const i=ne({sceneIndex:p,instanceId:lt.current,revision:n,enabled:!1!==e.drag?.enabled,mapping:ht,registrySnapshot:t,enterVariantsByAnimateId:r});ut.current=i,mt(i),ae?.onPrepared?.(i)},[ae,f,ht,e.drag?.enabled,p]),{timelineDuration:yt,beginPreparation:bt,registerAnimate:St,declareAnimateLane:xt,unregisterAnimate:wt,getCalculatedDelay:Rt,getTimelineDuration:Mt}=function({sceneIndex:e,baseDuration:n,reportError:r,onStableSnapshot:i}){const a=(0,t.useRef)(new Map),o=(0,t.useRef)(new Map),s=(0,t.useRef)(new Map),c=(0,t.useRef)(new Map),l=(0,t.useRef)(new Set),u=(0,t.useRef)(ee({baseDuration:n,registrations:s.current})),d=(0,t.useRef)(new Set),f=(0,t.useRef)(null),g=(0,t.useRef)(new Map),m=(0,t.useRef)(0),p=(0,t.useRef)(0),h=(0,t.useRef)(0),v=(0,t.useRef)(null),y=(0,t.useRef)(null),b=(0,t.useRef)(!0),S=(0,t.useRef)(r);S.current=r;const x=(0,t.useRef)(i);x.current=i;const w=(0,t.useRef)(n),[R,M]=(0,t.useState)(n),[C,k]=(0,t.useState)(!1),P=(0,t.useCallback)(()=>{b.current&&k(!1)},[]),I=(0,t.useCallback)(t=>{t.forEach(t=>{const n=Tn(t);if(d.current.has(n))return;let r,i;d.current.add(n),"missing-dependency"===t.type?(r="INVALID_ANIMATION",i=`Animate "${t.animateId}" references non-existent component "${t.after}" via after in Scene ${e}.`):"circular-dependency"===t.type?(r="CIRCULAR_DEPENDENCY",i=`Animate after chain contains a cycle in Scene ${e}: ${t.cycle.join(" -> ")}.`):"duplicate-id"===t.type?(r="INVALID_COMPONENT_HIERARCHY",i=`More than one Animate component registered animateId "${t.animateId}" in Scene ${e}.`):(r="INVALID_ANIMATION",i=`Animate "${t.animateId}" uses ${t.followerLane} after "${t.after}" driven by ${t.leaderLane} in Scene ${e}; this dependency direction is incompatible.`),S.current?.({code:r,message:i,context:{sceneIndex:e}})})},[e]),E=(0,t.useCallback)(()=>{s.current.clear(),c.current.clear(),l.current.clear(),a.current.forEach((e,t)=>{const n=jn(e);n&&s.current.set(t,n.info),e.size>1&&l.current.add(t)}),o.current.forEach((e,t)=>{let n;e.forEach(e=>{e.disposed||(n=e)}),n&&c.current.set(t,n.lane)})},[]),A=(0,t.useCallback)(()=>{E();const e=ee({baseDuration:n,registrations:s.current,declaredLanes:c.current,duplicateIds:l.current});return u.current=e,w.current=e.timelineDuration,b.current&&M(t=>t===e.timelineDuration?t:e.timelineDuration),e},[n,E]),D=(0,t.useCallback)(e=>u.current.issues.some(t=>"circular-dependency"===t.type&&t.cycle.includes(e)),[]),T=(0,t.useCallback)((e,t)=>{const{follower:n,leaderId:r}=e,i=a.current.get(r),o=c.current.get(r);if(!i||0===i.size)return t&&void 0!==o&&void 0!==n.info.lane&&!G(n.info.lane,o)?(e.sawLeader=!0,{kind:"invalid",leaderId:r,reason:"incompatible-lane"}):t?{kind:"invalid",leaderId:r,reason:e.sawLeader?"leader-unregistered":"missing"}:{kind:"pending",leaderId:r};e.sawLeader=!0;const s=jn(i);return t&&D(n.id)?{kind:"invalid",leaderId:r,reason:"cycle"}:t&&i.size>1?{kind:"invalid",leaderId:r,reason:"duplicate"}:t&&void 0!==n.info.lane&&void 0!==s.info.lane&&!G(n.info.lane,s.info.lane)?{kind:"invalid",leaderId:r,reason:"incompatible-lane"}:s.enterCompleted?{kind:"satisfied",source:"completed",leaderId:r,generation:s.generation}:{kind:"pending",leaderId:r,generation:s.generation}},[D]),j=(0,t.useCallback)((e,t)=>{if(e.terminal)return;const n=function(e){return"invalid"===e.kind?`${e.kind}:${e.leaderId}:${e.reason}`:`${e.kind}:${e.leaderId??""}:${e.generation??""}:${"satisfied"===e.kind?e.source:""}`}(t);e.lastSignature!==n&&(e.lastSignature=n,e.listener(t),"pending"!==t.kind&&(e.terminal=!0))},[]),V=(0,t.useCallback)(e=>{g.current.forEach(t=>{[...t].forEach(n=>{n.follower.disposed||n.terminal?t.delete(n):(j(n,T(n,e)),n.terminal&&t.delete(n))})}),g.current.forEach((e,t)=>{0===e.size&&g.current.delete(t)})},[j,T]),L=(0,t.useCallback)(e=>{if(0!==p.current||!b.current)return;const t=new Map;a.current.forEach((e,n)=>{const r=jn(e);r?.enterVariant&&t.set(n,r.enterVariant)});const n=v.current,r=y.current,i=null!==n&&null!==r&&function(e,t){return e.timelineDuration===t.timelineDuration&&Vn(e.registrations,t.registrations,(e,t)=>e.delay===t.delay&&e.duration===t.duration&&e.after===t.after&&e.lane===t.lane)&&Vn(e.calculatedDelays,t.calculatedDelays)&&e.issues.length===t.issues.length&&e.issues.every((e,n)=>Tn(e)===Tn(t.issues[n]))}(n,e)&&Vn(r,t);k(!0),!i&&(h.current+=1,v.current=e,y.current=new Map(t),x.current?.(function(e){const t=[];return e.registrations.forEach((e,n)=>{t.push([n,Object.freeze({...e})])}),Object.freeze({registrations:Z(t),calculatedDelays:Z(e.calculatedDelays),issues:Object.freeze([...e.issues]),timelineDuration:e.timelineDuration})}(e),h.current,t))},[]),O=(0,t.useCallback)(()=>{if(0!==p.current||!b.current)return;null!==f.current&&(clearTimeout(f.current),f.current=null);const e=A();I(e.issues),V(!0),L(e)},[L,A,V,I]),$=(0,t.useCallback)(()=>{P(),null!==f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,O()},0)},[O,P]),F=(0,t.useCallback)(()=>{p.current+=1,P();let e=!1;const t=()=>!e&&(e=!0,p.current=Math.max(0,p.current-1),0===p.current);return{complete:()=>{t()&&O()},cancel:()=>{t()&&$()}}},[O,P,$]),z=(0,t.useCallback)(e=>{g.current.forEach((t,n)=>{t.forEach(n=>{n.follower.token===e.token&&t.delete(n)}),0===t.size&&g.current.delete(n)})},[]),N=(0,t.useCallback)(e=>{if(e.disposed)return;e.disposed=!0,z(e);const t=a.current.get(e.id);t?.delete(e.token),0===t?.size&&a.current.delete(e.id),A(),$()},[A,z,$]),B=(0,t.useCallback)((e,t)=>{const n={token:Symbol(e),id:e,generation:++m.current,info:t,enterVariant:null,enterCompleted:!1,disposed:!1};let r=a.current.get(e);return r||(r=new Map,a.current.set(e,r)),r.set(n.token,n),A(),$(),s.current.size>100&&s.current.size,{animateId:e,generation:n.generation,getCalculatedDelay:()=>u.current.calculatedDelays.get(e)??n.info.delay,setEnterVariant:t=>{n.disposed||a.current.get(e)?.has(n.token)&&(n.enterVariant=t,$())},observeAfter:e=>{if(!n.info.after)return e({kind:"satisfied",source:"none"}),()=>{};const t={follower:n,listener:e,leaderId:n.info.after,sawLeader:!1,lastSignature:null,terminal:!1};let r=g.current.get(t.leaderId);return r||(r=new Set,g.current.set(t.leaderId,r)),r.add(t),j(t,T(t,0===p.current&&null===f.current)),()=>{t.terminal=!0,r?.delete(t),0===r?.size&&g.current.delete(t.leaderId)}},publishEnterCompleted:()=>{n.disposed||n.enterCompleted||a.current.get(e)?.has(n.token)&&(n.enterCompleted=!0,V(!1))},dispose:()=>N(n)}},[N,j,T,A,V,e,$]),q=(0,t.useCallback)((e,t)=>{const n={token:Symbol(e),id:e,lane:t,disposed:!1};let r=o.current.get(e);return r||(r=new Map,o.current.set(e,r)),r.set(n.token,n),A(),$(),{dispose:()=>{if(n.disposed)return;n.disposed=!0;const t=o.current.get(e);t?.delete(n.token),0===t?.size&&o.current.delete(e),A(),$()}}},[A,$]),U=(0,t.useCallback)(e=>{const t=a.current.get(e),n=t?jn(t):void 0;n&&N(n)},[N]),Y=(0,t.useCallback)(e=>u.current.calculatedDelays.get(e)??s.current.get(e)?.delay??0,[]),H=(0,t.useCallback)(()=>w.current,[]);return(0,t.useEffect)(()=>{$()},[n,$]),(0,t.useEffect)(()=>{b.current=!0;const e=a.current,t=o.current,n=s.current,r=c.current,i=l.current,u=d.current,m=g.current;return()=>{b.current=!1,null!==f.current&&(clearTimeout(f.current),f.current=null),p.current=0,e.clear(),t.clear(),n.clear(),r.clear(),i.clear(),u.clear(),m.clear()}},[]),{timelineDuration:R,isStable:C,beginPreparation:F,registerAnimate:B,declareAnimateLane:q,unregisterAnimate:U,getCalculatedDelay:Y,getTimelineDuration:H}}({sceneIndex:p,baseDuration:"drag"===f?0:_,reportError:xe?.reportError,onStableSnapshot:vt}),Ct=(0,t.useRef)(!1);(0,t.useEffect)(()=>{Ct.current||t.default.Children.count(a)>0||(Ct.current=!0,we?.({code:"EMPTY_SCENES",message:`Scene ${p} has no children; it renders an empty full-screen layer.`,context:{scope:"scene",sceneIndex:p}}))},[a,we,p]),(0,t.useEffect)(()=>()=>{const e=ut.current;e&&dt.current?.({sceneIndex:e.sceneIndex,instanceId:e.instanceId,revision:e.revision})},[]);const kt=(0,t.useRef)(null),Pt=(0,t.useCallback)(e=>{kt.current=e,"function"==typeof i?i(e):i&&(i.current=e)},[i]),[It,Et]=(0,t.useState)(null),At=(0,t.useCallback)(e=>{Et(t=>t===e?t:e)},[]),Dt=function({sceneId:e,sceneIndex:n,mode:r,scroll:i,elementRef:a}){const o=(0,t.useContext)(dn),s=(0,t.useId)(),c=i?.zoneId??e??`scene-zone-${s}`,l=o?.registerZone,u=o?.unregisterZone,d=o?.setZoneElement,f=!!i;return(0,t.useEffect)(()=>{if("scroll"===r&&f&&l&&u)return l(c,{sceneIndex:n}),()=>{u(c,n)}},[r,f,l,u,c,n]),(0,t.useEffect)(()=>{if("scroll"===r&&f&&d)return d(c,n,a.current),()=>{d(c,n,null)}},[a,r,f,n,d,c]),"scroll"===r&&i?c:null}({sceneId:e.sceneId,sceneIndex:p,mode:f,scroll:e.scroll,elementRef:kt});(0,t.useEffect)(()=>{ae?.renderProgressMotion||Qe.set(We)},[We,ae?.renderProgressMotion,Qe]),(0,t.useEffect)(()=>{ae?.timelineProgressMotion||tt.set(Ke)},[Ke,ae?.timelineProgressMotion,tt]),(0,t.useEffect)(()=>{De&&(je(I),Le(E),$e(A),ze(D),Be(S),Ue(T))},[De,I,E,A,D,S,T]);const Tt=(0,t.useCallback)(e=>"drag"!==f?0:!De&&h<=1?Math.max(-1,Math.min(1,e)):0===y&&e<0||y===h-1&&e>0?0:Math.max(-1,Math.min(1,e)),[f,De,y,h]);(0,t.useEffect)(()=>{},[Se,p]),(0,t.useEffect)(()=>{"scroll"!==f&&Et(null)},[f]),(0,t.useEffect)(()=>{const e=++Ie.current,t=()=>Ie.current===e,n=e=>{t()&&we?.(e)};return Ce(null),Pe(null),"scroll"!==f?((Ee||Ae)&&[Ee?"enterAnimation":null,Ae?"exitAnimation":null].filter(Boolean).join(","),()=>{t()&&(Ie.current+=1)}):Ee||Ae?((async()=>{const[e,r]=await Promise.all([gt(Ee,`Scene ${p}`,"enter",n),gt(Ae,`Scene ${p}`,"exit",n)]);t()&&(Ce(e??null),Pe(r??null))})(),()=>{t()&&(Ie.current+=1)}):()=>{t()&&(Ie.current+=1)}},[f,we,p,Ee,Ae]);const jt=function({slideMode:e,sceneState:n,isActive:r,sceneOffset:i,globalScrollProgress:a,globalScrollDirection:o,globalIsScrolling:s,globalScrollBackdropActive:c,hasExitAnimation:l,scrollTimelineState:u}){return(0,t.useMemo)(()=>"drag"===e?"exiting"===n?"exiting":"entering"===n?"entering":r?"active":0===i?"inactive":"parked":"scroll"===e?u?"enter"===u.phase?"entering":"exit"===u.phase?l?"exiting":"covered":"hold"===u.phase?r?"active":"covered":"after"===u.phase?l?"parked":"covered":r?"active":c?"covered":0===i?"inactive":"parked":r&&s&&a>.001?l?"exiting":"covered":c?"covered":("forward"===o&&1===i||"backward"===o&&-1===i)&&a>.001?"entering":r?"active":0===i?"inactive":"parked":r?"active":"inactive",[e,n,r,i,a,o,s,c,l,u])}({slideMode:f,sceneState:it,isActive:m,sceneOffset:ot,globalScrollProgress:j,globalScrollDirection:L,globalIsScrolling:V,globalScrollBackdropActive:$,hasExitAnimation:!!Q,scrollTimelineState:F}),Vt=(0,t.useMemo)(()=>In({effectiveMode:f,isActive:m,globalScrollTimelineState:F,hasExitAnimation:!!Q}),[f,m,F,Q]),Lt=Vt>.001,Ot=(0,t.useRef)(re),$t=(0,t.useRef)(te);(0,t.useEffect)(()=>{Ot.current=re,$t.current=te},[re,te]),(0,t.useEffect)(()=>{"scroll"===f&&ye||En({onVisibilityChange:Ot.current,sceneVisibilityCallback:$t.current,sceneIndex:p,visible:Lt,progress:Vt})},[f,p,Lt,Vt,ye]),(0,t.useEffect)(()=>{if("scroll"!==f||!ye)return;const e=()=>{const e=ye.getKeySnapshot(be)??null,t=In({effectiveMode:f,isActive:e?.isCurrent??m,globalScrollTimelineState:e?.timelineState??null,hasExitAnimation:!!Q});En({onVisibilityChange:Ot.current,sceneVisibilityCallback:$t.current,sceneIndex:p,visible:t>.001,progress:t})};return e(),ye.subscribeKey(be,e)},[f,ye,m,Q,p,te,be]),(0,t.useEffect)(()=>{"drag"!==f||!m||((ae?.onSharedTimelineDurationChange??fe)?.(Mt()),De||Be(Mt()))},[f,m,Mt,yt,ae,fe,it,De]);const Ft="drag"===f?C&&null!==ft:C,zt=(0,t.useMemo)(()=>({mode:f,isActive:m,isDragging:!1,dragProgressMotion:et,runtimeState:jt,sceneState:it,sceneOffset:ot,activationToken:x,activationKind:w,firstSceneEnterGateKnown:0===p?R:void 0,firstSceneEnterActive:0===p?M:void 0,firstSceneEnterReady:0===p?Ft:void 0,sceneTransitionDuration:_,getTimelineDuration:Mt,beginPreparation:bt,registerAnimate:St,declareAnimateLane:xt,unregisterAnimate:wt,getCalculatedDelay:Rt,enterDuration:he}),[bt,xt,f,Ft,Rt,w,x,M,R,Mt,m,et,St,_,p,ot,it,he,wt,jt]),Nt=(0,t.useMemo)(()=>({...zt,isDragging:Je,dragProgressMotion:et,renderProgressMotion:et,dragTransaction:ae?.transaction??null,preparedSnapshot:ft,dragTimelineProgress:Ke,sharedElapsedMotion:rt,renderProgress:Xe,dragRelease:Ze,sharedTimelineDurationMs:_e,firstSceneEnterActive:M}),[Ze,Ke,Xe,_e,et,ae?.transaction,rt,M,Je,ft,zt]),Bt="drag"===f?Nt:zt;!function({slideMode:e,isActive:n,sceneOffset:r,sceneStackMode:i,controls:a,enterVariant:o,exitVariant:s,globalIsScrolling:c,globalScrollProgress:l,globalScrollDirection:u,globalScrollTransitionSnapshot:d,globalScrollBackdropActive:f,globalScrollTimelineState:g,scrollFrameStore:m,scrollFrameSceneIndex:p,setSceneState:h}){const v=(0,t.useRef)(null);v.current={slideMode:e,isActive:n,sceneOffset:r,sceneStackMode:i,controls:a,enterVariant:o,exitVariant:s,globalIsScrolling:c,globalScrollProgress:l,globalScrollDirection:u,globalScrollTransitionSnapshot:d,globalScrollBackdropActive:f,globalScrollTimelineState:g,setSceneState:h};const y=(0,t.useRef)(null),b=(0,t.useRef)(null),S=(0,t.useCallback)(e=>{const t=v.current;if(!t||"scroll"!==t.slideMode)return;const n=null!==e,r=n?e.timelineState:t.globalScrollTimelineState,i=n?e.isCurrent:t.isActive,a=n?e.isScrolling:t.globalIsScrolling,o=n?e.isBackdropActive:t.globalScrollBackdropActive,s=n?e.scrollDirection:t.globalScrollDirection,c=n?e.progress:t.globalScrollProgress,l=t.globalScrollTransitionSnapshot?.direction??s,u="forward"===l&&1===t.sceneOffset||"backward"===l&&-1===t.sceneOffset,d=i&&a&&c>.001,f=!i&&"cover"===t.sceneStackMode&&o&&(0===t.sceneOffset||-1===t.sceneOffset),g=Cn(t.enterVariant?.animate,Mn),m=Cn(t.enterVariant?.initial,g),p=Cn(t.exitVariant?.exit,g),h=e=>{y.current!==e&&(y.current=e,t.setSceneState(e))},S=(e,n,r)=>{const i=b.current;i&&i.kind===e&&i.progress===n&&i.enterVariant===t.enterVariant&&i.exitVariant===t.exitVariant&&i.controls===t.controls||(b.current={kind:e,progress:n,enterVariant:t.enterVariant,exitVariant:t.exitVariant,controls:t.controls},t.controls.set(r))};if(r){if("before"===r.phase)return h("initial"),void S("before",0,m);if("enter"===r.phase){const e=kn(r.enterProgress);return h("entering"),void S("enter",e,pt(m,g,e))}if("hold"===r.phase)return h("active"),void S("hold",1,g);if("exit"===r.phase){const e=kn(r.exitProgress);return h(t.exitVariant?.exit?"exiting":"active"),void S("exit",e,t.exitVariant?.exit?pt(g,p,e):g)}h(f?t.exitVariant?.exit?"exiting":"active":t.exitVariant?.exit?"exiting":i?"active":"initial"),S("after",1,t.exitVariant?.exit?p:g)}else if(u){h("entering");const e=kn(c);S("fallback-enter",e,pt(m,g,e))}else if(d||f){h(t.exitVariant?.exit?"exiting":"active");const e=kn(c);S("fallback-exit",e,t.exitVariant?.exit?pt(g,p,e):g)}else h(i?"active":"initial"),S(i?"fallback-active":"fallback-initial",i?1:0,i?g:m)},[]);(0,t.useEffect)(()=>{if("scroll"===e){if(m&&"number"==typeof p){const e=()=>{S(m.getKeySnapshot(p)??null)};return e(),m.subscribeKey(p,e)}S(null)}},[S,o,s,f,u,l,g,d,c,n,r,i,p,m,e])}({slideMode:f,isActive:m,sceneOffset:ot,sceneStackMode:K,controls:Re,enterVariant:Me,exitVariant:ke,globalIsScrolling:V,globalScrollProgress:j,globalScrollDirection:L,globalScrollTransitionSnapshot:O,globalScrollBackdropActive:$,globalScrollTimelineState:F,scrollFrameStore:ye,scrollFrameSceneIndex:be,setSceneState:at});const qt=function({slideMode:e,isActive:r,sceneIndex:i,sceneOffset:a,globalDirection:o,globalIsDragging:s,candidateSuspended:c=!1,globalRenderProgress:l,globalDragTimelineProgress:u,renderProgressMotion:d,dragTimelineProgressMotion:f,dragRelease:g,firstSceneEnterReady:m,elementElapsedMotion:p,getTimelineDuration:h,timelineDurationState:v,dragTransaction:y,preparedSnapshot:b,requirePreparedSnapshot:S=!1,dragMappingConfig:x,takeoverSnapshot:w,onElementContinuationChange:R,onSettleComplete:M,onColdStartComplete:C}){const k=(0,t.useRef)(null),P=(0,t.useRef)(null),I=(0,t.useRef)(0),E=(0,t.useRef)(null),A=(0,t.useRef)(null),D=(0,t.useRef)(!1),T=(0,t.useRef)(0),j=(0,t.useRef)(!1),V=(0,t.useRef)(h);V.current=h;const L=(0,t.useRef)(y);L.current=y;const O=(0,t.useRef)(b);O.current=b;const $=(0,t.useRef)(S);$.current=S;const F=(0,t.useRef)(null),z=()=>L.current||($.current?null:O.current??null),N=e=>e?.registrySnapshot.timelineDuration??V.current(),q=e=>e?.mapping??ee.current,Y=(0,t.useRef)(M);Y.current=M;const H=(0,t.useRef)(C);H.current=C;const W=(0,t.useRef)(R);W.current=R;const X=(0,t.useRef)(!1),K=e=>{X.current!==e&&(X.current=e,W.current?.(e))},G=(0,t.useRef)(p);G.current=p;const _=(0,t.useRef)(null),Z=(0,t.useRef)(null),J=(0,t.useRef)(null),Q=(0,t.useRef)(null),ee=(0,t.useRef)(x??B);ee.current=x??B;const te=(0,t.useRef)(f?.get()??u);return te.current=f?.get()??u,(0,t.useEffect)(()=>{if("drag"===e&&c&&k.current){if(X.current){_.current=Math.max(0,G.current.get());const e=w?.current,t=e?.sceneIndices.includes(i)??!1;J.current=t?e.token:null,Z.current=t?e.baseRatio:null,Q.current=null}I.current+=1,k.current.stop(),k.current=null,P.current=null}},[c,i,e,w]),(0,t.useEffect)(()=>{if(c||s)return;const e=J.current,t=w?.current;null!==e&&t?.token===e&&null!==t.baseRatio||(_.current=null,Z.current=null,J.current=null,Q.current=null)},[c,s,w]),(0,t.useEffect)(()=>{if("drag"!==e||!s)return;k.current&&(k.current.stop(),k.current=null,P.current=null),K(!1),D.current=!0,j.current=!1;const t=e=>{te.current=e;const t=d?.get()??l,n=t>1e-4?"forward":t<-1e-4?"backward":o;if(!("forward"===n&&1===a||"backward"===n&&-1===a))return;const r=z();if($.current&&!r)return;const s=N(r),c=Math.max(0,Math.min(e,1)),u=q(r),f=_.current;if(null!==f){const e=w?.current,n=J.current;if(null!==n&&e?.token===n&&e.sceneIndices.includes(i)&&null!==e.baseRatio){const r=e.baseRatio;if(Z.current=r,Q.current!==n&&Math.abs(Math.abs(t)-r)<=1e-6&&Math.abs(c-e.staleRatio)<=1e-6&&Math.abs(c-r)>1e-6)return void(Q.current=n);const i=U(u,s,100*r),a=U(u,s,100*c);return void G.current.set(Math.max(0,Math.min(s,f+a-i)))}const r=Z.current;if(null===r)return void(Z.current=c);const a=U(u,s,100*r),o=U(u,s,100*c);return void G.current.set(Math.max(0,Math.min(s,f+o-a)))}G.current.set(U(u,s,100*c))};return t(f?.get()??u),f?f.on("change",t):void 0},[e,s,u,l,f,d,o,a,i,w,y?.transactionId]),(0,t.useEffect)(()=>{if("drag"!==e||c)return;const t=g;if(!t||t.targetSceneIndex!==i)return;const r=z();if($.current&&!r||E.current===t.token)return;E.current=t.token;const a=++I.current;k.current?.stop(),k.current=null,K(!1);const o=G.current,s=N(r),l="number"==typeof t.progressRatio?t.progressRatio:te.current,u=r&&"releaseSeed"in r?r.releaseSeed.elapsedMs:U(q(r),s,100*Math.max(0,Math.min(l,1))),d=Math.max(0,o.get(),u);if(d>o.get()&&o.set(d),"enter"===t.mode){if(o.set(0),s<=.001)return void o.set(s);P.current="cold-start",k.current=(0,n.animate)(o,s,{duration:s/1e3,ease:"linear",onUpdate:e=>{I.current===a&&o.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,o.set(s))}})}else if("settle"===t.mode){const e=s-d;if(e<=.001)return K(!1),o.set(s),A.current=t.token,void Y.current?.();P.current="settle",K(!0),k.current=(0,n.animate)(o,s,{duration:e/1e3,ease:"linear",onUpdate:e=>{I.current===a&&o.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,K(!1),o.set(s),A.current=t.token,Y.current?.())}})}else{if(d<=.001)return K(!1),void o.set(0);const e=Math.min(.5*Math.max(d,0),300);P.current="bounce",K(!0),k.current=(0,n.animate)(o,0,{duration:e/1e3,ease:"easeOut",onUpdate:e=>{I.current===a&&o.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,K(!1),o.set(0))}})}},[e,g?.token,i,y?.transactionId]),(0,t.useEffect)(()=>{if("drag"!==e||c||s)return;const t=g;if(!t||"enter"===t.mode||t.targetSceneIndex!==i||E.current!==t.token||"settle"===t.mode&&A.current===t.token||k.current)return;const r=z();if($.current&&!r)return;const a=G.current,o=Math.max(0,a.get());if("bounce"===t.mode){if(o<=.001)return K(!1),void a.set(0);const e=++I.current;return P.current="bounce",K(!0),void(k.current=(0,n.animate)(a,0,{duration:Math.min(.5*o,300)/1e3,ease:"easeOut",onUpdate:t=>{I.current===e&&a.set(t)},onComplete:()=>{I.current===e&&(k.current=null,P.current=null,K(!1),a.set(0))}}))}const l=N(r),u=l-o;if(u<=.001)return K(!1),a.set(l),A.current=t.token,void Y.current?.();const d=++I.current;P.current="settle",K(!0),k.current=(0,n.animate)(a,l,{duration:u/1e3,ease:"linear",onUpdate:e=>{I.current===d&&a.set(e)},onComplete:()=>{I.current===d&&(k.current=null,P.current=null,K(!1),a.set(l),A.current=t.token,Y.current?.())}})},[e,c,s,g?.token,i]),(0,t.useEffect)(()=>{if("drag"!==e||0!==i||!m||s)return;const t=G.current;if(!D.current){const e=O.current??null;if($.current&&!e)return;F.current=e;const r=N(e);D.current=!0,j.current=null===e,T.current=r;const i=r-Math.max(0,t.get());if(i<=.001)return t.set(r),void H.current?.();const a=++I.current;return P.current="cold-start",void(k.current=(0,n.animate)(t,r,{duration:i/1e3,ease:"linear",onUpdate:e=>{I.current===a&&t.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,t.set(T.current),H.current?.())}}))}if(!j.current||F.current)return;const r=V.current();if(r<=T.current+.001)return;k.current?.stop(),T.current=r;const a=r-Math.max(0,t.get());if(a<=.001)return t.set(r),k.current=null,P.current=null,void H.current?.();const o=++I.current;P.current="cold-start",k.current=(0,n.animate)(t,r,{duration:a/1e3,ease:"linear",onUpdate:e=>{I.current===o&&t.set(e)},onComplete:()=>{I.current===o&&(k.current=null,P.current=null,t.set(T.current),H.current?.())}})},[e,i,m,s,v,b?.revision]),(0,t.useEffect)(()=>()=>{k.current?.stop(),k.current=null,K(!1)},[]),{completeImmediately:(0,t.useCallback)(()=>{I.current+=1,k.current?.stop(),k.current=null,P.current=null,K(!1),G.current.set(V.current())},[]),resetImmediately:(0,t.useCallback)(()=>{I.current+=1,k.current?.stop(),k.current=null,P.current=null,K(!1),G.current.set(0)},[])}}({slideMode:f,isActive:m,sceneIndex:p,sceneOffset:ot,globalDirection:b,globalRenderProgress:Xe,renderProgressMotion:et,globalIsDragging:Ge,candidateSuspended:ae?.candidateSuspended??!1,globalDragTimelineProgress:Ke,dragTimelineProgressMotion:nt,dragRelease:Ze,firstSceneEnterReady:C,elementElapsedMotion:rt,getTimelineDuration:Mt,timelineDurationState:yt,dragTransaction:ae?.transaction??null,preparedSnapshot:ft,requirePreparedSnapshot:De,dragMappingConfig:ae?.dragMappingConfig,takeoverSnapshot:ae?.takeoverSnapshot,onElementContinuationChange:ae?.onElementContinuationChange,onSettleComplete:ae?.onActivationComplete??se,onColdStartComplete:ae?.onActivationComplete??se}),{handleCandidateSuspend:Ut,handleCandidateResume:Yt,handleDragStart:Ht,handlePan:Wt,handlePanEnd:Xt}=function({slideMode:e,isActive:r,sceneIndex:i,currentSceneIndex:a,totalScenes:o,slideDirection:s,slideDuration:c,sceneTransitionDuration:l,sceneOffset:u,sceneState:d,globalDirection:f,globalRenderProgress:g,globalIsDragging:m,globalDragProgress:p,globalDragTimelineProgress:h,controls:v,dragProgressMotion:y,setSceneState:b,setIsAnimating:S,resolveDragProgress:x,getTimelineDuration:w,onDragProgressChange:R,onRenderProgressChange:M,onDragTimelineProgressChange:C,onOwnershipRequest:k,onCandidateSuspensionChange:P,takeoverSnapshot:I,onDraggingChange:E,onDragRelease:A,renderLaneRef:D,completeReleaseImmediately:T=!1,onDragEnd:j,onDragReset:V,thresholdConfig:L}){(0,t.useRef)(null);const O=(0,t.useRef)(null),$=(0,t.useRef)(0),F=(0,t.useRef)(null),z=D??F,N=(0,t.useRef)(!1),B=(0,t.useRef)(0),q=(0,t.useRef)(!1),U=(0,t.useRef)(!1);return(0,t.useEffect)(()=>{if("drag"!==e)return;v.set({opacity:1,x:0,y:0,scale:1,rotate:0});const t=g,n=m||Math.abs(t)>.001,i=t>0?"forward":t<0?"backward":f,a=r?n?"exiting":"active":"forward"===i&&1===u||"backward"===i&&-1===u?"entering":"initial";d!==a&&b(a)},[e,v,r,d,i,g,m,u,f,b]),(0,t.useEffect)(()=>()=>{$.current+=1;const e=z.current;e&&e.ownerSceneIndex===i&&(e.stop(),z.current=null),N.current=!1,q.current=!1},[z,i]),{handleCandidateSuspend:(0,t.useCallback)(()=>{if("drag"!==e)return!1;const t=z.current,n=!!t?.suspend;q.current=n,t?.suspend?.();const r=P?.(!0)??!1;return n||r},[z,P,e]),handleCandidateResume:(0,t.useCallback)(()=>{z.current?.resume?.(),q.current=!1,P?.(!1)},[z,P]),handleDragStart:(0,t.useCallback)(t=>{if("drag"!==e)return!1;const n=z.current;if(!r&&!n||k&&!k(t))return!1;const i=n&&q.current?n.getCurrent?.()??g:g,a=I?.current;return a&&null===a.baseRatio&&(I.current={...a,baseRatio:Math.abs(i)}),P?.(!1),n?(n.preempt?n.preempt():n.stop(),z.current=null,q.current=!1,B.current=i,U.current=!0,y.set(i),R?.(i),C?.(Math.abs(i)),n.kind,i.toFixed(3)):(B.current=0,U.current=!1),N.current=!0,p.toFixed(3),h.toFixed(3),E?.(!0),!0},[e,r,z,k,y,R,C,E,i,a,o,p,h,g,P,I]),handlePan:(0,t.useCallback)((t,n)=>{if("drag"!==e||!r&&!N.current)return;const i="y"===s?n.offset.y:n.offset.x,a=x(B.current-i/("y"===s?window.innerHeight:window.innerWidth)),o=Math.abs(a);y.set(a),R?.(a),C?.(o),M?.(a)},[e,r,s,i,R,C,M,y,x]),handlePanEnd:(0,t.useCallback)((t,o)=>{if("drag"!==e||!r&&!N.current)return;N.current=!1;const l="pointercancel"===t.type;$.current+=1,z.current?.stop(),z.current=null;const u=y.get(),d=w(),f=function(e,t){const n="y"===e?t.velocity.y:t.velocity.x;return Number.isFinite(n)?-n:0}(s,o),g=Math.abs(f),m=Math.abs(u),p=(e,t)=>{let r=null,a=y.get(),o=0,s=!1,c=!1;const l=e/Math.max(Math.abs(a),1e-6),u=()=>{c||s||z.current!==g||(z.current=null,r?.stop(),a=0,y.set(0),R?.(0),C?.(0),M?.(0),t())},d=()=>{if(c||s||z.current!==g)return;const e=Math.abs(a)*l;if(e<=1e-6)return void u();const t=++o;r=(0,n.animate)(y,0,{duration:e,ease:"easeOut",onUpdate:e=>{t!==o||c||s||(a=e,y.set(e),R?.(e),C?.(Math.abs(e)),M?.(e))},onComplete:()=>{t===o&&(a=0,u())}})},f=()=>{c=!0,s=!1,o+=1,r?.stop()},g={kind:"bounce",ownerSceneIndex:i,stop:f,suspend:()=>{c||s||(a=y.get(),s=!0,o+=1,r?.stop())},resume:()=>{c||!s||(a=y.get(),s=!1,d())},preempt:f,getCurrent:()=>a};z.current=g,d()};if(m<.001){if(u.toFixed(3),V?.(),U.current){const e=B.current>=0?"forward":"backward";A?.({mode:"bounce",direction:e,targetSceneIndex:"forward"===e?a+1:a-1})}return E?.(!1),void(r&&b("active"))}const h=u>0?"forward":"backward",v="forward"===h?a+1:a-1;if(0===x(u)&&0!==u)return S(!0),u.toFixed(3),g.toFixed(1),E?.(!1),A?.({mode:"bounce",direction:h,targetSceneIndex:v}),void p(.15,()=>{V?.(),b("active"),S(!1)});const k=T?.5:function(e,t){const n=t?.minVelocity??0,r=t?.maxVelocity??1e3,i=t?.minRatio??.15,a=t?.maxRatio??.3;if(!Number.isFinite(e))return a;const o=r-n;return o<=0?a:a-(Math.max(n,Math.min(r,e))-n)/o*(a-i)}(g,L);g.toFixed(1),k.toFixed(3),m.toFixed(3);const P=!l&&m>k&&(T||!(m>.001&&u*f<0&&g>600));if(u.toFixed(3),m.toFixed(3),k.toFixed(3),g.toFixed(1),f.toFixed(1),P){if(S(!0),E?.(!1),T)return j?.(h,1,d,d),void S(!1);const e=++$.current,t="forward"===h?1:-1,r=Math.abs(t-u),a=Math.max(r*(c/1e3),0),o=Math.min(m,1);A?.({mode:"settle",direction:h,targetSceneIndex:v,progressRatio:m});let s=null,l=u,f=0,g=!1,p=!1;const b=()=>{p||g||z.current!==R||(z.current=null,s?.stop(),o.toFixed(3),(1e3*a).toFixed(1),j?.(h,o,o*d,d),M?.(0),S(!1))},x=()=>{if(p||g||z.current!==R)return;const r=Math.abs(t-l)*(c/1e3);if(r<=1e-6)return void b();const i=++f;s=(0,n.animate)(l,t,{duration:r,ease:"easeOut",onUpdate:n=>{if(i===f&&!p&&!g&&$.current===e&&(l=n,Math.abs(n-t)>1e-6&&y.set(n),M?.(n),0)){const e=Math.round(10*Math.abs(n))/10;O.current!==e&&(O.current=e)}},onComplete:()=>{i===f&&(l=t,b())}})},w=()=>{p=!0,g=!1,f+=1,s?.stop()},R={kind:"settle",ownerSceneIndex:i,stop:w,suspend:()=>{p||g||(g=!0,f+=1,s?.stop())},resume:()=>{p||!g||(g=!1,x())},preempt:w,getCurrent:()=>l};u.toFixed(3),(1e3*a).toFixed(1),o.toFixed(3),z.current=R,x()}else{S(!0);const e=Math.min(m*c,300)/1e3;u.toFixed(3),(1e3*e).toFixed(1),E?.(!1),A?.({mode:"bounce",direction:h,targetSceneIndex:v}),p(e,()=>{V?.(),S(!1)})}},[e,r,z,s,i,a,c,y,R,C,M,A,j,V,E,x,w,l,S,b,T,L])}}({slideMode:f,isActive:m,sceneIndex:p,currentSceneIndex:y,totalScenes:h,slideDirection:g,slideDuration:he,sceneTransitionDuration:_,sceneOffset:ot,sceneState:it,globalDirection:b,globalRenderProgress:Xe,globalIsDragging:Ge,globalDragProgress:We,globalDragTimelineProgress:Ke,controls:Re,dragProgressMotion:et,setSceneState:at,setIsAnimating:ct,resolveDragProgress:Tt,getTimelineDuration:Mt,onOwnershipRequest:ae?.onOwnershipRequest,onCandidateSuspensionChange:ae?.onCandidateSuspensionChange,takeoverSnapshot:ae?.takeoverSnapshot,onDragProgressChange:ae?.onProgressChange??ce,onRenderProgressChange:ae?.onRenderProgressChange??le,onDragTimelineProgressChange:ae?.onTimelineProgressChange??ue??(De?void 0:e=>tt.set(e)),onDraggingChange:ae?.onDraggingChange??de??(De?void 0:ze),onDragRelease:ae?.onRelease??ge??(De?void 0:He),renderLaneRef:ae?.renderLane,completeReleaseImmediately:!De,thresholdConfig:ae?.threshold,onDragEnd:ae?.onCommit??me??(De?void 0:(e,t,n,r)=>{je(0),Le(0),$e(0),ze(!1),Be(r??0),Ue(null),qt.completeImmediately(),ie?.(e)}),onDragReset:ae?.onReset??pe??(De?void 0:()=>{je(0),Le(0),$e(0),ze(!1),Ue(null),qt.resetImmediately()})}),Kt="drag"===f&&(m||!!ae?.renderLane?.current||!!Ze),{onPointerDown:Gt,onPointerMove:_t,onPointerUp:Zt,onPointerCancel:Jt,onFramerPanStart:Qt,onFramerPan:en,onFramerPanEnd:tn}=function({enabled:e,axis:n,onCandidateStart:r,onCandidateEnd:i,onPointerSessionStart:a,onDragStart:o,onPan:s,onPanEnd:c,authoredPointerDown:l,authoredPointerMove:u,authoredPointerUp:d,authoredPointerCancel:f}){const g=function({enabled:e,axis:n,onCandidateStart:r,onCandidateEnd:i,onPointerSessionStart:a,onStart:o,onPan:s,onEnd:c}){const l=(0,t.useRef)(null),u=(0,t.useRef)(!1),d=(0,t.useRef)(0),f=(0,t.useRef)(null),g=(0,t.useRef)(null),m=(0,t.useRef)(r);m.current=r;const p=(0,t.useRef)(i);p.current=i;const h=(0,t.useRef)(a);h.current=a;const v=(0,t.useRef)(o);v.current=o;const y=(0,t.useRef)(s);y.current=s;const b=(0,t.useRef)(c);b.current=c;const S=(0,t.useCallback)(()=>{g.current?.(),g.current=null},[]),x=(0,t.useCallback)(()=>{null!==f.current&&(window.clearTimeout(f.current),f.current=null)},[]),w=(0,t.useCallback)(e=>{const t=l.current;if(!t||t.pointerId!==e.pointerId)return;const n=t.target;S(),l.current=null,t.ownsGesture?(Ln()-t.lastTime>100&&(t.velocityX=0,t.velocityY=0),n.releasePointerCapture?.(t.pointerId),b.current(e,On(t,e.clientX,e.clientY))):t.candidateSuspended&&p.current?.(),x();const r=d.current;u.current=!0;const i=window.setTimeout(()=>{f.current===i&&(f.current=null,d.current===r&&(u.current=!1))},0);f.current=i},[S,x]),R=(0,t.useCallback)(t=>{if(!e||!1===t.isPrimary||void 0!==t.button&&0!==t.button||function(e){return e instanceof Element&&!!e.closest('a,button,input,textarea,select,option,summary,[contenteditable="true"],[data-cineview-ignore-drag]')}(t.target))return;const n=l.current;n&&(n.target.releasePointerCapture?.(n.pointerId),!n.ownsGesture&&n.candidateSuspended&&p.current?.()),S(),x(),d.current+=1;const r=t.currentTarget;h.current?.();const i=m.current?.()??!1;l.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,lastTime:Ln(),velocityX:0,velocityY:0,target:r,ownsGesture:!1,candidateSuspended:i,rejectedDirections:new Set,panInfo:null},u.current=!0;const a=e=>{w(e)};window.addEventListener("pointerup",a),window.addEventListener("pointercancel",a),document.addEventListener("pointerup",a),document.addEventListener("pointercancel",a),g.current=()=>{window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",a),document.removeEventListener("pointerup",a),document.removeEventListener("pointercancel",a)}},[S,x,e,w]),M=(0,t.useCallback)(e=>{const t=l.current;if(!t||t.pointerId!==e.pointerId)return;const r=Ln();if(!t.ownsGesture){const i="y"===n?e.clientY-t.startY:e.clientX-t.startX,a="y"===n?e.clientX-t.startX:e.clientY-t.startY;if(Math.abs(i)<1||Math.abs(i)<=Math.abs(a))return;const o=i<0?"forward":"backward";if(t.rejectedDirections.has(o))return;return t.candidateSuspended||(t.candidateSuspended=m.current?.()??!1),v.current(o)?(t.ownsGesture=!0,t.startX=e.clientX,t.startY=e.clientY,t.lastX=e.clientX,t.lastY=e.clientY,t.lastTime=r,t.velocityX=0,t.velocityY=0,t.target.setPointerCapture?.(t.pointerId),void(e.cancelable&&e.preventDefault())):(t.rejectedDirections.add(o),void(t.candidateSuspended&&(p.current?.(),t.candidateSuspended=!1)))}const i=Math.max(r-t.lastTime,1);t.velocityX=(e.clientX-t.lastX)/i*1e3,t.velocityY=(e.clientY-t.lastY)/i*1e3,y.current(e.nativeEvent,On(t,e.clientX,e.clientY)),t.lastX=e.clientX,t.lastY=e.clientY,t.lastTime=r,e.cancelable&&e.preventDefault()},[n]),C=(0,t.useCallback)(e=>w(e.nativeEvent),[w]);return(0,t.useEffect)(()=>()=>{const e=l.current;e&&!e.ownsGesture&&e.candidateSuspended&&p.current?.(),S(),x(),d.current+=1,l.current=null,u.current=!1},[S,x]),{onPointerDown:R,onPointerMove:M,onPointerUp:C,onPointerCancel:C,isActiveRef:u}}({enabled:e,axis:n,onCandidateStart:r,onCandidateEnd:i,onPointerSessionStart:a,onStart:o,onPan:s,onEnd:c}),{onPointerDown:m,onPointerMove:p,onPointerUp:h,onPointerCancel:v}=g,y=(0,t.useCallback)(e=>{l?.(e),e.defaultPrevented||m(e)},[l,m]),b=(0,t.useCallback)(e=>{u?.(e),e.defaultPrevented||p(e)},[u,p]),S=(0,t.useCallback)(e=>{d?.(e),h(e)},[d,h]),x=(0,t.useCallback)(e=>{f?.(e),v(e)},[f,v]),w=(0,t.useRef)({ownsGesture:!1,candidateSuspended:!1,baseline:0,rejectedDirections:new Set}),R=(0,t.useRef)(i);R.current=i;const M=(0,t.useCallback)(e=>{const t=w.current;e&&!t.ownsGesture&&t.candidateSuspended&&R.current?.(),w.current={ownsGesture:!1,candidateSuspended:!1,baseline:0,rejectedDirections:new Set}},[]),C=(0,t.useCallback)(()=>{g.isActiveRef.current?M(!0):(M(!0),a?.(),w.current={ownsGesture:!1,candidateSuspended:r?.()??!1,baseline:0,rejectedDirections:new Set})},[M,g.isActiveRef,r,a]),k=(0,t.useCallback)((e,t)=>{if(g.isActiveRef.current)return void M(!0);const a=w.current,c="y"===n?t.offset.y:t.offset.x,l="y"===n?t.offset.x:t.offset.y;if(!a.ownsGesture){if(Math.abs(c)<1||Math.abs(c)<=Math.abs(l))return;const e=c<0?"forward":"backward";if(a.rejectedDirections.has(e))return;return a.candidateSuspended||(a.candidateSuspended=r?.()??!1),o(e)?(a.ownsGesture=!0,void(a.baseline=c)):(a.rejectedDirections.add(e),void(a.candidateSuspended&&(i?.(),a.candidateSuspended=!1)))}const u=c-a.baseline;s(e,{...t,offset:"y"===n?{x:t.offset.x,y:u}:{x:u,y:t.offset.y}})},[n,M,g.isActiveRef,i,r,o,s]),P=(0,t.useCallback)((e,t)=>{if(g.isActiveRef.current)return void M(!0);const r=w.current;if(!r.ownsGesture)return void M(!0);const i=("y"===n?t.offset.y:t.offset.x)-r.baseline;c(e,{...t,offset:"y"===n?{x:t.offset.x,y:i}:{x:i,y:t.offset.y}}),M(!1)},[n,M,g.isActiveRef,c]);return(0,t.useEffect)(()=>()=>M(!0),[M]),{onPointerDown:y,onPointerMove:b,onPointerUp:S,onPointerCancel:x,onFramerPanStart:C,onFramerPan:k,onFramerPanEnd:P}}({axis:g,enabled:Kt,onCandidateStart:Ut,onCandidateEnd:Yt,onPointerSessionStart:ae?.onPointerSessionStart,onDragStart:Ht,onPan:Wt,onPanEnd:Xt,authoredPointerDown:c,authoredPointerMove:l,authoredPointerUp:u,authoredPointerCancel:d}),nn=(0,t.useMemo)(()=>"drag"===f?{opacity:1}:Me?Me.initial:{opacity:1},[Me,f]),rn=(0,t.useMemo)(()=>"drag"===f?"none":"translateZ(0)",[f]),an=(0,t.useMemo)(()=>function(e){switch(e){case"top-left":default:return{top:0,left:0};case"top-center":return{top:0,left:"50%",transform:"translateX(-50%)"};case"top-right":return{top:0,right:0};case"center-left":return{top:"50%",left:0,transform:"translateY(-50%)"};case"center":return{top:"50%",left:"50%",transform:"translate(-50%, -50%)"};case"center-right":return{top:"50%",right:0,transform:"translateY(-50%)"};case"bottom-left":return{bottom:0,left:0};case"bottom-center":return{bottom:0,left:"50%",transform:"translateX(-50%)"};case"bottom-right":return{bottom:0,right:0}}}(H),[H]),on=(0,t.useMemo)(()=>function(e){switch(e){case"top-right":case"center-right":case"bottom-right":return{marginLeft:"auto",marginRight:0};case"top-center":case"center":case"bottom-center":return{marginLeft:"auto",marginRight:"auto"};default:return{marginLeft:0,marginRight:"auto"}}}(H),[H]),sn=(0,t.useMemo)(()=>An({effectiveMode:f,effectiveDirection:g,globalScrollTimelineState:F,globalScrollViewportOffset:z,globalViewportWidth:k,globalViewportHeight:P}),[f,g,F,z,k,P]),cn=!Kt&&("covered"===jt||"parked"===jt||"inactive"===jt),ln=cn?{"aria-hidden":!0}:void 0,un=cn||!0===e.inert;(0,t.useEffect)(()=>{const e=kt.current;e&&(e.inert=un)},[un]);const fn=(0,t.useMemo)(()=>({width:N,height:Y,position:"scroll"===f?"relative":"absolute",overflow:W,willChange:st||Je||V?"transform, opacity":"auto",contain:"drag"===f?"layout style":"layout style paint",transform:rn,userSelect:"drag"===f&&Je?"none":void 0,WebkitUserSelect:"drag"===f&&Je?"none":void 0,touchAction:Pn(f,g),zIndex:X,pointerEvents:Kt||"covered"!==jt&&"parked"!==jt&&"inactive"!==jt?"auto":"none",..."scroll"===f?on:an}),[st,Je,V,Kt,rn,f,g,N,Y,W,X,jt,on,an]);return(0,r.jsx)($n.Provider,{value:p,children:(0,r.jsx)(vn.Provider,{value:Bt,children:(0,r.jsx)(wn.Provider,{value:"scroll"===f?It:null,children:(0,r.jsx)(gn.Provider,{value:"scroll"===f?Dt:null,children:(0,r.jsxs)(n.motion.div,{ref:Pt,"data-cineview-scroll-zone":"scroll"===f?Dt??e.sceneId??void 0:void 0,initial:nn,animate:Re,...Object.fromEntries(Object.entries(e).filter(([e])=>!Fn.has(e))),className:o,style:{...s,...fn},...ln,inert:un,onPanStart:"drag"===f?Qt:void 0,onPan:"drag"===f?en:void 0,onPanEnd:"drag"===f?tn:void 0,onPointerDown:"drag"===f?Gt:c,onPointerMove:"drag"===f?_t:l,onPointerUp:"drag"===f?Zt:u,onPointerCancel:"drag"===f?Jt:d,children:["scroll"===f?(0,r.jsx)(Dn,{sceneIndex:p,metrics:sn,setHostRef:At,frameStore:ye,direction:g,viewportWidth:k,viewportHeight:P}):null,a]})})})})})}),Nn=Object.assign(zn,{cineViewScene:!0});Nn.displayName="Scene";var Bn=new Set(["width","minWidth","maxWidth","height","minHeight","maxHeight","top","bottom","left","right","inset","insetInline","insetInlineStart","insetInlineEnd","insetBlock","insetBlockStart","insetBlockEnd","margin","marginTop","marginBottom","marginLeft","marginRight","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd","borderWidth","borderTopWidth","borderBottomWidth","borderLeftWidth","borderRightWidth","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","gap","columnGap","rowGap","fontSize","letterSpacing","outlineWidth","outlineOffset"]),qn=(e,t)=>{if(!e||!t)return e;let n=!1;const r={};return Object.entries(e).forEach(([e,i])=>{const a=((e,t,n)=>n&&"number"==typeof t&&Number.isFinite(t)&&!e.startsWith("--")&&Bn.has(e)?n.convert(t):t)(e,i,t);r[e]=a,n||(n=a!==i)}),n?r:e},Un=(0,t.forwardRef)(function({width:e,height:n,children:i,style:a,className:o,...s},c){const l=v(),u=(0,t.useMemo)(()=>{if(!l)return a;const t=qn(a,l),r=void 0!==e?l.convert(e):void 0,i=void 0!==n?l.convert(n):void 0;return{...t,...void 0!==e?{width:r}:{},...void 0!==n?{height:i}:{}}},[l,e,n,a]);return(0,r.jsx)("div",{ref:c,style:u,className:o,...s,children:i})});Un.displayName="Container";var Yn=(0,t.forwardRef)(function({src:e,alt:n,width:i,height:a,style:o,loading:s,preload:c,...l},u){const d=v(),f=(0,t.useMemo)(()=>"number"!=typeof i?i:d?.convert(i)??i,[d,i]),g=(0,t.useMemo)(()=>"number"!=typeof a?a:d?.convert(a)??a,[d,a]),m=(0,t.useMemo)(()=>qn(o,d),[d,o]),p="lazy"!==s&&(c??!0),h=s??(p?"eager":"lazy");return(0,t.useEffect)(()=>{if(!p||!e||typeof window>"u"||function(e){return e.length>0&&y.has(e)}(e))return;const t=new window.Image,n=()=>{S(e)};return t.addEventListener("load",n),t.src=e,()=>{t.removeEventListener("load",n)}},[p,e]),(0,r.jsx)("img",{ref:u,...l,src:e,alt:n,width:f,height:g,style:m,loading:h})});Yn.displayName="Image";var Hn=1e-4;function Wn(e,t,n){return Math.min(n,Math.max(t,e))}function Xn(e,t){return function(e){return Number.isFinite(e)&&e>0}(e)?t?[Number.isFinite(t[0])?Wn(t[0],0,e):0,Number.isFinite(t[1])?Wn(t[1],0,e):e]:[0,e]:null}function Kn(e){return{activationId:e,status:"framework-scrub",activePlayRequestId:null,settledPlayRequestId:null,nextPlayRequestId:1,lastSeekTime:null,endpointLatched:!1,outgoingLatched:!1,frameworkPlayBlocked:!1,frameworkPausePending:!1}}function Gn(e,t=[]){return{state:e,commands:t}}function _n(e,t){return{...Kn(t),nextPlayRequestId:e.nextPlayRequestId}}function Zn(e,t){switch(t.type){case"timeline-frame":return function(e,t){const{frame:n}=t;if("exiting"===n.phase||"exited"===n.phase){if(e.outgoingLatched)return Gn(e);const t="native-playback"===e.status||"play-pending"===e.status,n=null!==e.activePlayRequestId||null!==e.settledPlayRequestId;return Gn({...e,status:"framework-scrub",activePlayRequestId:null,lastSeekTime:null,outgoingLatched:!0,frameworkPlayBlocked:e.frameworkPlayBlocked||t||n,frameworkPausePending:t},t?[{type:"pause"}]:[])}if(!e.outgoingLatched&&!function(e){return"gesture"===e||"continuation"===e||"programmatic"===e||"scroll"===e||"visibility"===e}(n.source)||!function(e,t){return"ended"!==e.status&&"play-rejected"!==e.status||("gesture"===t.source||"scroll"===t.source||"visibility"===t.source)&&t.progress<.98}(e,n))return Gn(e);const r=function(e,t,n){const r=Xn(t,n);if(!r)return null;const i=Wn(Number.isFinite(e)?e:0,0,1);return r[0]+i*(r[1]-r[0])}(n.progress,t.duration,t.scrubRange);if(null===r)return Gn(e);if(function(e){return"native-playback"===e||"native-paused"===e||"play-pending"===e}(e.status)){if(!function(e,t){return!(e.endpointLatched&&t.progress>=.98)&&("scroll"===t.source||"visibility"===t.source||"gesture"===t.source&&t.progress<.98)}(e,n))return Gn(e);const t=[],i="native-playback"===e.status||"play-pending"===e.status;return i&&t.push({type:"pause"}),(null===e.lastSeekTime||Math.abs(e.lastSeekTime-r)>Hn)&&t.push({type:"seek",time:r}),Gn({...e,status:"framework-scrub",activePlayRequestId:null,lastSeekTime:r,endpointLatched:!1,outgoingLatched:!1,frameworkPlayBlocked:!0,frameworkPausePending:i},t)}const i=[];if((null===e.lastSeekTime||Math.abs(e.lastSeekTime-r)>Hn)&&i.push({type:"seek",time:r}),function(e,t){if(!e.scrubRange||t||e.frame.progress<.999)return!1;const n=Xn(e.duration,e.scrubRange);return!!n&&n[1]<e.duration-Hn}(t,e.endpointLatched)){const t=e.nextPlayRequestId;return i.push({type:"play",requestId:t}),Gn({...e,status:"play-pending",activePlayRequestId:t,settledPlayRequestId:null,nextPlayRequestId:t+1,lastSeekTime:r,endpointLatched:!0,outgoingLatched:!1,frameworkPlayBlocked:!1},i)}const a=!!(t.scrubRange&&n.progress>=.999),o=n.progress<.98;return Gn({...e,status:"framework-scrub",activePlayRequestId:null,lastSeekTime:r,endpointLatched:!!a||!o&&e.endpointLatched,outgoingLatched:!1},i)}(e,t);case"media-play":return t.activationId!==e.activationId?Gn(e):void 0!==t.requestId?e.activePlayRequestId===t.requestId||"native-playback"===e.status&&!e.frameworkPlayBlocked&&e.settledPlayRequestId===t.requestId?Gn({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:t.requestId,frameworkPausePending:!1,frameworkPlayBlocked:!1}):Gn({...e,frameworkPausePending:!0,frameworkPlayBlocked:!0},[{type:"pause"}]):e.frameworkPlayBlocked?Gn({...e,frameworkPausePending:!0},[{type:"pause"}]):Gn({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:null,frameworkPausePending:!1,frameworkPlayBlocked:!1});case"media-pause":return t.activationId!==e.activationId?Gn(e):e.frameworkPausePending?Gn({...e,frameworkPausePending:!1}):Gn({...e,status:"ended"===e.status?"ended":"native-paused",activePlayRequestId:null,settledPlayRequestId:"ended"===e.status?e.settledPlayRequestId:null,frameworkPlayBlocked:"ended"===e.status&&e.frameworkPlayBlocked});case"media-ended":return t.activationId!==e.activationId?Gn(e):Gn({...e,status:"ended",activePlayRequestId:null,endpointLatched:!0,frameworkPausePending:!1});case"play-resolved":return e.activePlayRequestId!==t.requestId?Gn(e):Gn({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:t.requestId,frameworkPlayBlocked:!1,frameworkPausePending:!1});case"play-rejected":return e.activePlayRequestId!==t.requestId?Gn(e):Gn({...e,status:"play-rejected",activePlayRequestId:null,settledPlayRequestId:null,frameworkPlayBlocked:!1,frameworkPausePending:!1});case"activate":return e.activationId===t.activationId?Gn(e):Gn(_n(e,t.activationId));case"reset":return Gn(_n(e,t.activationId))}}var Jn=!0,Qn=(0,t.forwardRef)(function({src:e,progress:n,timelineFrame:i,scrubRange:a,width:o,height:s,style:c,"aria-label":l,preload:u=!0,poster:d,playbackRate:f,onEnded:g,onPlay:m,onPause:p,onTimeUpdate:h,onError:y,controlRef:b},S){const R=v(),k=(0,t.useRef)(null),[P,I]=(0,t.useState)(()=>({src:e,url:E(e)??null})),D=P.src===e?P.url:null,V=(0,t.useRef)([]),L=(0,t.useRef)(Kn(0)),O=(0,t.useRef)(0),$=(0,t.useRef)(void 0),F=(0,t.useRef)(0),z=(0,t.useRef)({src:e,objectUrl:D}),N=(0,t.useRef)(null),B=(0,t.useRef)(()=>{}),q=(0,t.useRef)(new WeakMap),U=(0,t.useRef)(null),H=(0,t.useRef)(null),W=(0,t.useCallback)((e,t)=>{const n=N.current,r=F.current;if(n&&(n.video!==e||n.activationId!==t||n.generation!==r)&&(n.video.removeEventListener("loadstart",n.loadStart,Jn),n.video.removeEventListener("play",n.play,Jn),n.video.removeEventListener("pause",n.pause,Jn),n.video.removeEventListener("ended",n.ended,Jn),N.current=null),!e||N.current)return;const i=()=>O.current===t&&F.current===r,a=()=>i()&&U.current===r,o=()=>{i()&&(U.current=r)},s=e=>{q.current.set(e,{generation:r,activationId:t})},c=e=>{if(!a())return;const n=$.current,i=n?.generation===r&&n.activationId===t?n.requestId:void 0,o=L.current,c=void 0!==i&&(!o.frameworkPlayBlocked&&o.activePlayRequestId===i||"native-playback"===o.status&&!o.frameworkPlayBlocked&&o.settledPlayRequestId===i),l=void 0===i&&!o.frameworkPlayBlocked;void 0!==i&&($.current=void 0),c||l?(s(e),B.current({type:"media-play",requestId:i,activationId:t})):B.current({type:"media-play",requestId:i,activationId:t})},l=e=>{a()&&(L.current.frameworkPausePending||($.current=void 0),s(e),B.current({type:"media-pause",activationId:t}))},u=e=>{a()&&(s(e),B.current({type:"media-ended",activationId:t}))};e.addEventListener("loadstart",o,Jn),e.addEventListener("play",c,Jn),e.addEventListener("pause",l,Jn),e.addEventListener("ended",u,Jn),N.current={video:e,generation:r,activationId:t,loadStart:o,play:c,pause:l,ended:u}},[]),[X,K]=(0,t.useState)(!1),[G,_]=(0,t.useState)(0),[Z,J]=(0,t.useState)(0),Q=(0,t.useCallback)((e=!0)=>{O.current+=1,L.current=Zn(L.current,{type:"reset",activationId:O.current}).state,$.current=void 0,V.current=[],W(e?k.current:null,O.current)},[W]);(0,t.useEffect)(()=>{const e={release:()=>{const e=k.current;K(!0),e&&(e.pause(),H.current=e.getAttribute("src"),e.removeAttribute("src"),e.load()),Q(!1)},warmUp:()=>{const e=k.current;if(e&&!e.getAttribute("src")){const t=H.current;t&&(e.src=t,H.current=null)}K(!1),_(e=>e+1),Q(!1)}};return b&&(b.current=e),()=>{b&&(b.current=null)}},[b,Q]);const ee=(0,t.useCallback)(e=>{e||W(null,O.current),k.current=e,e&&W(e,O.current),function(e,t){"function"==typeof e?e(t):e&&(e.current=t)}(S,e)},[W,S]),te=(0,t.useMemo)(()=>"number"==typeof o?R?.convert(o)??o:o,[R,o]),ne=(0,t.useMemo)(()=>"number"==typeof s?R?.convert(s)??s:s,[R,s]),re=(0,t.useMemo)(()=>qn(c,R??null),[R,c]);(0,t.useEffect)(()=>{if(typeof window>"u"||!e)return void I({src:e,url:null});let t=!0,n=!1;const r=()=>{const t=function(e){const t=x.get(e);if(t)return A(e),C.set(e,(C.get(e)??0)+1),t.objectUrl}(e);return!!t&&(n=!0,I({src:e,url:t}),!0)};let i=()=>{};return r()||(I({src:e,url:null}),i=function(e){return M.add(e),()=>{M.delete(e)}}(i=>{i===e&&t&&!n&&r()})),()=>{t=!1,i(),n&&function(e){const t=C.get(e)??0;t<=1?C.delete(e):C.set(e,t-1),T("")}(e)}},[e]),(0,t.useEffect)(()=>{typeof window>"u"||!e||!u||function(e){return e.length>0&&w.has(e)}(e)||j(e,"video").catch(()=>{})},[u,e]),(0,t.useEffect)(()=>{K(!1),_(e=>e+1)},[e]),Y(()=>{const e=k.current;e&&(e.playbackRate=f??1)},[Z,D,f,X,e]);const ie=(0,t.useCallback)((e,t)=>{e.currentTime=t},[e]),ae=(0,t.useCallback)(e=>{const t=k.current;if(!t)return;const n=Zn(L.current,e);L.current=n.state,n.commands.forEach(e=>{switch(e.type){case"pause":return void t.pause();case"seek":return void ie(t,e.time);case"play":{const n={requestId:e.requestId,generation:F.current,activationId:L.current.activationId,settled:!1};$.current=n;const r=t=>{if($.current===n&&!n.settled){if(n.settled=!0,"play-rejected"===t&&($.current=void 0),F.current!==n.generation||L.current.activationId!==n.activationId)return void($.current=void 0);ae({type:t,requestId:e.requestId})}};let i;try{i=t.play()}catch{return void r("play-rejected")}return void Promise.resolve(i).then(()=>r("play-resolved"),()=>r("play-rejected"))}}})},[ie]);Y(()=>{B.current=ae;const t=z.current;let n=!1;(t.src!==e||t.objectUrl!==D)&&(z.current={src:e,objectUrl:D},F.current+=1,U.current=null,Q(),n=!0),!n&&k.current&&k.current.readyState>=1&&(U.current=F.current),W(k.current,O.current)},[W,ae,G,D,Q,e]),(0,t.useEffect)(()=>()=>W(null,O.current),[W]),(0,t.useEffect)(()=>{if(!i)return;const e=k.current;if(!e||typeof window>"u")return;let t=i.get();const n=n=>{t=n;const r=L.current;if("entering"===n.phase&&("ended"===r.status||r.outgoingLatched))return O.current+=1,W(null,O.current),ae({type:"activate",activationId:O.current}),void J(e=>e+1);!Number.isFinite(e.duration)||e.duration<=0||ae({type:"timeline-frame",frame:n,duration:e.duration,scrubRange:a})},r=()=>n(t),o=i.on("change",n);return e.readyState>=1?r():e.addEventListener("loadedmetadata",r,{once:!0}),()=>{o(),e.removeEventListener("loadedmetadata",r)}},[W,ae,G,Z,D,a,i]),(0,t.useEffect)(()=>{if(i)return;const e=k.current;if(!e||typeof window>"u")return;const t="object"==typeof n?n:null,r=t=>{const n=e.duration;!Number.isFinite(n)||n<=0||ie(e,(t<0?0:t>1?1:t)*n)},a=()=>r(t?.get()??n),o=t?.on("change",r);return e.readyState>=1?a():e.addEventListener("loadedmetadata",a,{once:!0}),()=>{o?.(),e.removeEventListener("loadedmetadata",a)}},[G,D,n,ie,i]);const oe=e=>{const t=q.current.get(e);return q.current.delete(e),!(!t||t.generation!==F.current||t.activationId!==O.current)},se=X&&P.src===e,ce=JSON.stringify([e,D,Z,se?"released":"active"]);return(0,r.jsx)("video",{ref:ee,src:(se?void 0:D??e)||void 0,muted:!0,playsInline:!0,preload:se?"none":u?"auto":D?"metadata":"none","aria-label":l,width:te,height:ne,style:re,poster:d||void 0,onPlay:e=>{oe(e.nativeEvent)&&m?.(e)},onPause:e=>{oe(e.nativeEvent)&&p?.(e)},onEnded:e=>{oe(e.nativeEvent)&&g?.(e)},onTimeUpdate:h,onError:y},ce)});Qn.displayName="VideoFrameRenderer";var er={initial:{opacity:1},animate:{opacity:1}},tr=(0,t.forwardRef)(function({src:e,"aria-label":n,width:i,height:a,style:o,preload:s,poster:c,playbackRate:l,scrubRange:u,releaseOnLeave:d,onEnded:f,onPlay:g,onPause:m,onTimeUpdate:p,onError:h},v){const y=cn(),b=function(e,n){const r=(0,t.useRef)(null),i=cn(),a=(0,t.useContext)(gn),o=function(e,n=!0){return function(e,n,r){const i=(0,t.useContext)(fn),a=r(e?i?.zoneStates?.[e]??null:null),o=n&&e?i?.store:void 0,s=(0,t.useCallback)(t=>o&&e?o.subscribeKey(e,t):()=>{},[o,e]),c=(0,t.useCallback)(()=>r(o&&e?o.getKeySnapshot(e)??null:e?i?.zoneStates?.[e]??null:null),[r,o,i?.zoneStates,e]);return(0,t.useSyncExternalStore)(s,c,()=>a)}(e,n,(0,t.useCallback)(e=>e?.approach??null,[]))}(e?a:null,!0===e),s=(0,t.useRef)(!1),c=(0,t.useRef)(!!e),l=i.progress;return(0,t.useEffect)(()=>{s.current=!1},[n]),(0,t.useEffect)(()=>{if(!e)return;const t=e=>{Math.abs(e)>1e-4&&(s.current=!0)};return t(l.get()),l.on("change",t)},[l,e]),(0,t.useEffect)(()=>{const t=c.current;if(c.current=!!e,e){if(o){if("far"===o)return void(s.current&&r.current?.release());r.current?.warmUp()}}else t&&r.current?.warmUp()},[o,e]),r}(d,e);return(0,r.jsx)(Qn,{ref:v,controlRef:b,src:e,progress:y.progress,timelineFrame:y.frame,"aria-label":n,width:i,height:a,style:o,preload:s,poster:c,playbackRate:l,scrubRange:u,onEnded:f,onPlay:g,onPause:m,onTimeUpdate:p,onError:h})}),nr=(0,t.forwardRef)(function({src:e,"aria-label":t,width:n,height:i,style:a,preload:o,poster:s,playbackRate:c,scrubRange:l,animateId:u,duration:d,enterAnimation:f,exitAnimation:g,timeline:m,visibility:p,releaseOnLeave:h,onEnded:v,onPlay:y,onPause:b,onTimeUpdate:S,onError:x},w){return(0,r.jsx)(Sn,{animateId:u,enterAnimation:f??er,exitAnimation:g,duration:{enter:d?.enter,exit:d?.exit},timeline:m,visibility:p,children:(0,r.jsx)(tr,{ref:w,src:e,"aria-label":t,width:n,height:i,style:a,preload:o,poster:s,playbackRate:c,scrubRange:l,releaseOnLeave:h,onEnded:v,onPlay:y,onPause:b,onTimeUpdate:S,onError:x})})});nr.displayName="AnimateVideo";var rr=Sn,ir=Rn,ar=Nn,or=(0,t.forwardRef)((e,n)=>{const r=e.mode;if(void 0!==r&&"drag"!==r)throw new Error(`[Cineview] This artifact (cineview.umd.js / "cineview/drag") contains only the drag engine and does not support mode="${r}". For scroll mode, load cineview-scroll.umd.js (or import "cineview/scroll"); for runtime mode switching, use the full entry import "cineview".`);return(0,t.createElement)(Me,{...e,mode:"drag",ref:n})});or.displayName="CineviewDragOnly";var sr=or;e.Animate=rr,e.AnimateVideo=nr,e.Cineview=sr,e.Container=Un,e.Image=Yn,e.Position=ir,e.Scene=ar,e.useAnimateTimeline=cn});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&typeof module<"u"?t(exports,require("react"),require("framer-motion"),require("react/jsx-runtime"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","framer-motion","react/jsx-runtime","react-dom"],t):t((e=typeof globalThis<"u"?globalThis:e||self).Cineview={},e.React,e.FramerMotion,e.ReactJSXRuntime,e.ReactDOM)}(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var a,o,s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,g=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},m=(e,t)=>{let n={};for(var r in e)c(n,r,{get:e[r],enumerable:!0});return t||c(n,Symbol.toStringTag,{value:"Module"}),n};o=null!=(a=t)?s(d(a)):{},t=((e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var i,a=u(t),o=0,s=a.length;o<s;o++)i=a[o],!f.call(e,i)&&void 0!==i&&c(e,i,{get:(e=>t[e]).bind(null,i),enumerable:!(r=l(t,i))||r.enumerable});return e})(a&&a.__esModule&&f.call(a,"default")?o:c(o,"default",{value:a,enumerable:!0}),a);var p=(0,t.createContext)(null),h=({designSize:e,children:n})=>{const i=function(e){return void 0===e?750:Number.isFinite(e)&&e>0?e:(String(e),750)}(e),[a,o]=(0,t.useState)(typeof window<"u"?window.innerWidth:750),s=(0,t.useMemo)(()=>a/i,[a,i]),c=(0,t.useCallback)(e=>e*s,[s]);(0,t.useEffect)(()=>{if(typeof window>"u")return;const{debounced:e,cancel:t}=function(){let e=null;return{debounced:function(...t){e&&clearTimeout(e),e=setTimeout(()=>{(()=>{o(window.innerWidth)})(...t),e=null},150)},cancel:()=>{e&&(clearTimeout(e),e=null)}}}();return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e),t()}},[]);const l=(0,t.useMemo)(()=>({scale:s,convert:c}),[s,c]),u=(0,t.useMemo)(()=>({"--cineview-unit":`${s}px`}),[s]);return(0,r.jsx)(p.Provider,{value:l,children:(0,r.jsx)("div",{className:"cineview-responsive-container",style:u,children:n})})},v=()=>(0,t.useContext)(p),y=new Set,b=new Set;function S(e){if(!e)return;const t=y.has(e);y.add(e),t||b.forEach(t=>t(e))}var x=new Map,w=new Set,R=new Map,M=new Set,C=new Map,k=0,P=/\.(mp4|webm|mov|m4v|ogv|ogg)(\?|#|$)/i;function I(e){return P.test(e)?"video":null}function E(e){const t=x.get(e);if(t)return A(e),t.objectUrl}function A(e){const t=x.get(e);t&&(x.delete(e),x.set(e,t))}function D(e){typeof URL<"u"&&URL.revokeObjectURL&&URL.revokeObjectURL(e)}function T(e){for(const[t,n]of x){if(k<=134217728)break;t===e||(C.get(t)??0)>0||(x.delete(t),w.delete(t),k-=n.bytes,D(n.objectUrl))}}function j(e,t){if(!e||w.has(e))return Promise.resolve();const n=R.get(e);if(n)return n;if(typeof fetch>"u")return Promise.reject(new Error("preloadMedia requires fetch (client-side only)"));if(!(t??I(e)))return Promise.reject(new Error(`Cannot determine media type: ${e} (pass explicit kind)`));const r=async function(e){const t=typeof AbortController<"u"?new AbortController:null,n=t?setTimeout(()=>t.abort(),3e4):null;try{const n=await fetch(e,t?{signal:t.signal}:void 0);if(!n.ok)throw new Error(`Failed to preload media: ${e} (HTTP ${n.status})`);const r=await n.blob();if(!r)throw new Error(`Invalid blob response for media: ${e}`);(function(e,t){const n=x.get(e);n&&(k-=n.bytes,D(n.objectUrl)),x.set(e,t),k+=t.bytes,T(e)})(e,{kind:"video",objectUrl:URL.createObjectURL(r),bytes:r.size}),function(e){const t=w.has(e);w.add(e),t||M.forEach(t=>t(e))}(e)}catch(n){if(t?.signal.aborted){const t=new Error(`Media preload timed out after 30000ms: ${e}`);throw t.cause=n,t}throw n}finally{null!==n&&clearTimeout(n)}}(e).finally(()=>{R.delete(e)});return R.set(e,r),r}function V(e){return Array.from(new Set(e.filter(e=>e.length>0)))}function L(e,t,n,r){const i=V(e).filter(e=>!n.has(e)&&!r.has(e)),a=new Set(i);return{priorityBatch:i,backgroundBatch:V(t).filter(e=>!n.has(e)&&!r.has(e)&&!a.has(e))}}var O=new class{constructor(){this.frameCount=0,this.lastTime=performance.now(),this.frameTimes=[],this.memorySamples=[],this.lastMemorySampleTime=0,this.cachedMemoryUsage=void 0,this.cachedBundleSizeKb=0,this.rafId=null,this.isMonitoring=!1,this.measure=()=>{if(!this.isMonitoring)return;const e=performance.now(),t=e-this.lastTime;this.frameCount++,this.frameTimes.push(t),this.frameTimes.length>60&&this.frameTimes.shift(),this.sampleMemory(e),this.lastTime=e,this.rafId=requestAnimationFrame(this.measure)}}start(){this.isMonitoring||(this.isMonitoring=!0,this.frameCount=0,this.lastTime=performance.now(),this.frameTimes=[],this.memorySamples=[],this.lastMemorySampleTime=0,this.cachedMemoryUsage=void 0,this.cachedBundleSizeKb=this.estimateBundleSizeKb(),this.measure())}stop(){this.isMonitoring=!1,null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null)}getMetrics(){const e=this.calculateAvgFrameTime();if(0===this.frameTimes.length)return{fps:0,avgFrameTime:0,memoryUsage:this.getMemoryUsage(),bundleSize:this.getBundleSizeKb()};const t=1e3/Math.max(e,1);return{fps:Math.round(10*Math.min(Math.max(t,0),60))/10,avgFrameTime:Math.round(100*e)/100,memoryUsage:this.getMemoryUsage(),bundleSize:this.getBundleSizeKb()}}calculateAvgFrameTime(){return 0===this.frameTimes.length?0:this.frameTimes.reduce((e,t)=>e+t,0)/this.frameTimes.length}getMemoryUsage(){return this.sampleMemory(performance.now(),void 0===this.cachedMemoryUsage),this.cachedMemoryUsage}sampleMemory(e,t=!1){if(!performance.memory)return this.cachedMemoryUsage=void 0,void(this.memorySamples=[]);if(!t&&e-this.lastMemorySampleTime<1e3)return;const n=performance.memory.usedJSHeapSize/1048576;this.memorySamples.push(n),this.memorySamples.length>8&&this.memorySamples.shift();const r=[...this.memorySamples].sort((e,t)=>e-t),i=Math.floor(r.length/2),a=r.length%2==0?(r[i-1]+r[i])/2:r[i];this.cachedMemoryUsage=Math.round(10*a)/10,this.lastMemorySampleTime=e}getBundleSizeKb(){return this.cachedBundleSizeKb>0||(this.cachedBundleSizeKb=this.estimateBundleSizeKb()),this.cachedBundleSizeKb}estimateBundleSizeKb(){if(typeof performance>"u"||"function"!=typeof performance.getEntriesByType)return 0;const e=performance.getEntriesByType("resource");if(0===e.length)return 0;const t=e.reduce((e,t)=>{const n=t.name.toLowerCase();return n.endsWith(".js")||n.endsWith(".mjs")||n.endsWith(".css")||n.includes(".js?")||n.includes(".mjs?")||n.includes(".css?")?e+Math.max(t.decodedBodySize||0,t.transferSize||0):e},0);return Math.round(t/1024*10)/10}},$=0,F=O,z="time",N={time:10,percent:1},B={unit:z,scale:N[z]};function q(e,t,n){const r=function(e){return void 0!==e?.unit||void 0!==e?.scale}(t)?t:e,i=r?.unit;if(void 0!==i&&!function(e){return"time"===e||"percent"===e}(i))return n?.({field:"unit",value:i}),{unit:z,scale:N.time};const a=i??"time",o=r?.scale;return void 0!==o&&("number"!=typeof o||!Number.isFinite(o)||o<0)?(n?.({field:"scale",value:o}),{unit:a,scale:N[a]}):{unit:a,scale:o??N[a]}}function U(e,t,n){const r=Math.max(0,Number.isFinite(t)?t:0),i=Number.isFinite(n)?n:0,a="time"===e.unit?e.scale:r*e.scale/100;return Math.min(r,Math.max(0,i*a))}var Y=typeof document<"u"?t.useLayoutEffect:t.useEffect;function H(e,t){if(null!=e.key)return`key:${e.key}`;const{sceneId:n}=e.props;return void 0!==n?`scene:${n}`:`index:${t}`}function W({index:e,currentScene:n,totalScenes:i,direction:a,renderProgressMotion:o,style:s,sceneWrapperRefs:c,children:l}){const u=(0,t.useRef)(null);return Y(()=>{const t=t=>{const r=u.current;if(!r)return;let o=t;0===n&&t<0&&(o=0),n===i-1&&t>0&&(o=0);const s=100*(e-n-o);r.style.transform="y"===a?`translate3d(0, ${s}%, 0)`:`translate3d(${s}%, 0, 0)`};return t(o.get()),o.on("change",t)},[n,a,e,o,i]),(0,r.jsx)("div",{ref:t=>{u.current=t,c.current[e]=t},style:s,"data-scene-index":e,children:l})}var X=t.default.memo(function({scene:e,index:n,currentScene:i,totalScenes:a,mode:o,dragConfig:s,dragProgress:c,dragTimelineProgress:l,renderProgress:u,renderProgressMotion:d,timelineProgressMotion:f,isDragging:g,sharedTimelineDurationMs:m,dragRelease:p,sceneActivations:h,firstSceneEnterActive:v,firstSceneEnterReady:y,direction:b,isAnimating:S,viewportWidth:x,viewportHeight:w,sceneActions:R,sceneWrapperRefs:M,renderLaneRef:C,takeoverSnapshot:k,candidateSuspended:P,onCandidateSuspensionChange:I,onElementContinuationChange:E,onPointerSessionStart:A,dragTransaction:D,onPrepared:T,onPreparedInvalidated:j,onOwnershipRequest:V,onSceneChange:L,onDragProgressChange:O,onRenderProgressChange:$,onDragTimelineProgressChange:F,onDraggingChange:z,onSharedTimelineDurationChange:N,onDragRelease:B,onDragReset:U,onTransactionComplete:Y,onFirstSceneEnterComplete:H}){const X=n===i,K=e.props,G=s?.direction??K.slideDirection??"y",_=q(s,K.drag),Z={position:"absolute",inset:0,width:"100%",height:"100%"};if("drag"===o)Z.visibility="visible",Z.opacity=1,Z.pointerEvents=X||g||S||null!==D?"auto":"none",Z.contentVisibility="visible",Z.transition="none",Z.zIndex=X?10:1;else{const e=X||S&&"backward"===b&&(n===i||n===i+1)||S&&"forward"===b&&(n===i||n===i-1);Z.visibility=e?"visible":"hidden",Z.contentVisibility=e?"visible":"hidden",Z.zIndex=S?"backward"===b?n===i+1?2:n===i?1:0:n===i?2:n===i-1?1:0:X?1:0}const J=D?.targetSceneIndex===n?D:null,Q=t.default.useCallback(()=>{0===n&&v?H():R.completeDragTransition(),"settling"===J?.phase&&Y(J.transactionId)},[v,n,H,Y,R,J]),ee=t.default.useCallback(e=>{E(n,e)},[n,E]),te=t.default.useMemo(()=>t.default.cloneElement(e,{sceneRuntime:{mode:o,direction:G,isActive:X,sceneIndex:n,totalScenes:a,currentSceneIndex:i,transitionDirection:b,isSceneAnimating:S,sharedTimelineDurationMs:m,activationToken:h.get(n)?.token??0,activationKind:h.get(n)?.kind??null,viewportWidth:x,viewportHeight:w,firstSceneEnterActive:v&&0===n,firstSceneEnterReady:y&&0===n},dragRuntime:{progress:c,renderProgress:u,timelineProgress:l,renderProgressMotion:d,timelineProgressMotion:f,isDragging:g,release:p,threshold:s?.threshold,dragMappingConfig:_,transaction:J,onPrepared:T,onPreparedInvalidated:j,onOwnershipRequest:V,candidateSuspended:P,onCandidateSuspensionChange:I,takeoverSnapshot:k,onElementContinuationChange:ee,onPointerSessionStart:A,renderLane:C,onCommit:L,onReset:U,onActivationComplete:Q,onTransactionComplete:Y,onProgressChange:O,onRenderProgressChange:$,onTimelineProgressChange:F,onDraggingChange:z,onRelease:B,onSharedTimelineDurationChange:N},onSceneChange:L}),[e,o,G,X,n,a,i,b,S,m,h,x,w,v,y,c,u,l,d,f,g,p,s,_,J,T,j,V,P,I,k,ee,A,C,L,U,Q,Y,O,$,F,z,B,N]);return"drag"===o?(0,r.jsx)(W,{index:n,currentScene:i,totalScenes:a,direction:G,renderProgressMotion:d,style:Z,sceneWrapperRefs:M,children:te}):(0,r.jsx)("div",{ref:e=>{M.current[n]=e},style:Z,"data-scene-index":n,children:te})});function K({scenes:e,visibleSceneIndices:t,currentScene:n,totalScenes:i,mode:a,dragConfig:o,dragProgress:s,dragTimelineProgress:c,renderProgress:l,renderProgressMotion:u,timelineProgressMotion:d,isDragging:f,sharedTimelineDurationMs:g,dragRelease:m,sceneActivations:p,firstSceneEnterActive:h,firstSceneEnterReady:v,direction:y,isAnimating:b,viewportWidth:S,viewportHeight:x,sceneActions:w,sceneWrapperRefs:R,renderLaneRef:M,takeoverSnapshot:C,candidateSuspended:k,onCandidateSuspensionChange:P,onElementContinuationChange:I,onPointerSessionStart:E,dragTransaction:A,onPrepared:D,onPreparedInvalidated:T,onOwnershipRequest:j,onSceneChange:V,onDragProgressChange:L,onRenderProgressChange:O,onDragTimelineProgressChange:$,onDraggingChange:F,onSharedTimelineDurationChange:z,onDragRelease:N,onDragReset:B,onTransactionComplete:q,onFirstSceneEnterComplete:U}){return(0,r.jsx)(r.Fragment,{children:e.map((e,Y)=>t.has(Y)?(0,r.jsx)(X,{scene:e,index:Y,currentScene:n,totalScenes:i,mode:a,dragConfig:o,dragProgress:s,dragTimelineProgress:c,renderProgress:l,renderProgressMotion:u,timelineProgressMotion:d,isDragging:f,sharedTimelineDurationMs:g,dragRelease:m,sceneActivations:p,firstSceneEnterActive:h,firstSceneEnterReady:v,direction:y,isAnimating:b,viewportWidth:S,viewportHeight:x,sceneActions:w,sceneWrapperRefs:R,renderLaneRef:M,takeoverSnapshot:C,candidateSuspended:k,onCandidateSuspensionChange:P,onElementContinuationChange:I,onPointerSessionStart:E,dragTransaction:A,onPrepared:D,onPreparedInvalidated:T,onOwnershipRequest:j,onSceneChange:V,onDragProgressChange:L,onRenderProgressChange:O,onDragTimelineProgressChange:$,onDraggingChange:F,onSharedTimelineDurationChange:z,onDragRelease:N,onDragReset:B,onTransactionComplete:q,onFirstSceneEnterComplete:U},H(e,Y)):null)})}function G(e,t){return e===t||"visibility"===e&&"scroll"===t}var _=class{constructor(e){this.source=new Map(e),Object.freeze(this)}get size(){return this.source.size}get(e){return this.source.get(e)}has(e){return this.source.has(e)}forEach(e,t){this.source.forEach((n,r)=>e.call(t,n,r,this))}entries(){return this.source.entries()}keys(){return this.source.keys()}values(){return this.source.values()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"ImmutableMapView"}};function Z(e){return new _(e)}function J(e){switch(e.type){case"missing-dependency":return`${e.type}:${e.animateId}:${e.after}`;case"circular-dependency":return`${e.type}:${e.animateId}:${e.cycle.join(">")}`;case"duplicate-id":return`${e.type}:${e.animateId}`;case"incompatible-lane":return`${e.type}:${e.animateId}:${e.after}:${e.followerLane}:${e.leaderLane}`}}function Q(e,t){const n=J(t);e.some(e=>J(e)===n)||e.push(t)}function ee({baseDuration:e,registrations:t,declaredLanes:n=new Map,duplicateIds:r=[]}){const i=new Map,a=[],o=new Set,s=new Set;Array.from(r).forEach(e=>{Q(a,{type:"duplicate-id",animateId:e})});const c=(e,r)=>{const l=i.get(e);if(void 0!==l)return l;const u=t.get(e);if(o.has(e)){const t=r.indexOf(e),n=function(e){const t=e.slice(0,-1);let n=0;for(let e=1;e<t.length;e+=1)t[e]<t[n]&&(n=e);const r=t.slice(n).concat(t.slice(0,n));return r.concat(r[0])}(r.slice(t).concat(e));return n.slice(0,-1).forEach(e=>s.add(e)),Q(a,{type:"circular-dependency",animateId:n[0],cycle:n}),i.set(e,u.delay),u.delay}o.add(e);let d=u.delay;if(u.after){const i=t.get(u.after),o=n.get(u.after);if(i)if(void 0===u.lane||void 0===i.lane||G(u.lane,i.lane)){const t=c(u.after,r.concat(e));("visibility"!==u.lane||"scroll"!==i.lane)&&!s.has(e)&&(d+=t+i.duration)}else Q(a,{type:"incompatible-lane",animateId:e,after:u.after,followerLane:u.lane,leaderLane:i.lane});else void 0===u.lane||void 0===o||G(u.lane,o)?Q(a,{type:"missing-dependency",animateId:e,after:u.after}):Q(a,{type:"incompatible-lane",animateId:e,after:u.after,followerLane:u.lane,leaderLane:o})}return o.delete(e),i.set(e,d),d};t.forEach((e,t)=>{c(t,[])});let l=Math.max(e,0);return t.forEach((e,t)=>{const n=i.get(t);l=Math.max(l,n+e.duration)}),{registrations:new Map(t),calculatedDelays:i,issues:a,timelineDuration:l}}function te(e){return Math.max(0,Math.min(Number.isFinite(e)?e:0,1))}function ne(e){return Object.freeze({...e,mapping:Object.freeze({...e.mapping}),enterVariantsByAnimateId:Z(e.enterVariantsByAnimateId)})}var re=class{constructor(){this.preparedScenes=new Map,this.activeTransactions=new Map,this.transactionIdsByTarget=new Map}publishPrepared(e){const t=this.preparedScenes.get(e.sceneIndex);t&&t.instanceId===e.instanceId&&t.revision>e.revision||this.preparedScenes.set(e.sceneIndex,ne(e))}invalidatePrepared(e){const t=this.preparedScenes.get(e.sceneIndex);t?.instanceId===e.instanceId&&t.revision===e.revision&&this.preparedScenes.delete(e.sceneIndex)}getPrepared(e){return this.preparedScenes.get(e)??null}beginTransaction(e,t,n){const r=this.transactionIdsByTarget.get(e),i=r?this.activeTransactions.get(r):void 0;if(i){const e=function(e,t,n){const r=te(n);return Object.freeze({...e,phase:t,releaseSeed:Object.freeze({progressRatio:r,elapsedMs:U(e.mapping,e.registrySnapshot.timelineDuration,100*r)})})}(i,t,n);return this.activeTransactions.set(i.transactionId,e),e}const a=this.preparedScenes.get(e);if(!a)return null;const o=function(e,t,n){return function(e,t,n,r){const i=te(r),a=e.registrySnapshot.timelineDuration;return Object.freeze({transactionId:t,targetSceneIndex:e.sceneIndex,targetInstanceId:e.instanceId,targetRevision:e.revision,phase:n,mapping:e.mapping,registrySnapshot:e.registrySnapshot,enterVariantsByAnimateId:e.enterVariantsByAnimateId,releaseSeed:Object.freeze({progressRatio:i,elapsedMs:U(e.mapping,a,100*i)})})}(e,Symbol(`drag-transaction:${e.sceneIndex}:${e.revision}`),t,n)}(a,t,n);return this.activeTransactions.set(o.transactionId,o),this.transactionIdsByTarget.set(e,o.transactionId),o}getTransaction(e){return this.activeTransactions.get(e)??null}getTransactionForTarget(e){const t=this.transactionIdsByTarget.get(e);return t?this.activeTransactions.get(t)??null:null}releaseTransaction(e){const t=this.activeTransactions.get(e);t&&(this.activeTransactions.delete(e),this.transactionIdsByTarget.get(t.targetSceneIndex)===e&&this.transactionIdsByTarget.delete(t.targetSceneIndex))}clear(){this.preparedScenes.clear(),this.activeTransactions.clear(),this.transactionIdsByTarget.clear()}};function ie(e){return e.assets?.preloadImages??[]}var ae=(0,t.createContext)(null);function oe(){return(0,t.useContext)(ae)}var se="(prefers-reduced-motion: reduce)";function ce(){return typeof window<"u"&&"function"==typeof window.matchMedia&&window.matchMedia(se).matches}function le(e){if(typeof window>"u"||"function"!=typeof window.matchMedia)return()=>{};const t=window.matchMedia(se);return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}function ue(e,t,n){return Math.min(n,Math.max(t,e))}var de={position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},fe=(0,t.forwardRef)((e,i)=>{const{designWidth:a,mode:o,direction:s,transitionDuration:c,threshold:l,unit:u,scale:d,firstSceneTimeout:f,scrollbar:g,callbacks:m,monitor:p,children:v}=e,{designSize:y}=function(e){const t=e;return"number"==typeof t&&Number.isFinite(t)&&t>0?{designSize:t}:{designSize:750}}(a),b=(0,t.useMemo)(()=>({direction:s,transitionDuration:c,threshold:l,unit:u,scale:d,firstSceneTimeout:f}),[s,c,l,u,d,f]),x=(0,t.useRef)(null),w=(0,t.useRef)([]),R=(0,t.useRef)(0),M=(0,t.useRef)(null),C=(0,t.useRef)([]),k=(0,t.useRef)(null),P=(0,t.useRef)(new Set),[E,A]=(0,t.useMemo)(()=>{const e=[];return t.Children.forEach(v,n=>{(function(e){if(!(0,t.isValidElement)(e)||"string"==typeof e.type)return!1;let n=e.type;for(let e=0;e<6&&n;e+=1){if(("function"==typeof n||"object"==typeof n)&&null!==n&&!0===n.cineViewScene)return!0;if("object"==typeof n&&null!==n&&"type"in n)n=n.type;else{if("object"!=typeof n||null===n||!("render"in n))break;n=n.render}}return!1})(n)&&e.push(n)}),[e,!1]},[v]),D=E.length,T=(0,t.useMemo)(()=>function(e){return e??"drag"}(o),[o]),z=(0,t.useMemo)(()=>function(e){return e?{common:{onReady:e.onReady,onLoadProgress:e.onLoadProgress,onSceneEnter:e.onSceneEnter,onSceneLeave:e.onSceneLeave,onError:e.onError},drag:{onDragStart:e.onDragStart,onDragProgress:e.onDragProgress,onDragBlocked:e.onDragBlocked,onDragEnd:e.onDragEnd,onDragCancel:e.onDragCancel},scroll:{onZoneEnter:e.onZoneEnter,onZoneLeave:e.onZoneLeave,onZoneProgress:e.onZoneProgress,onSceneVisibilityChange:e.onSceneVisibilityChange}}:{common:{},drag:{},scroll:{}}}(m),[m]),N=(0,t.useRef)(z),B=(0,t.useRef)(!1),U=(0,t.useRef)(!1),[W,X]=(0,t.useState)(!1),G=(0,t.useRef)(new Set),_=(0,t.useRef)(new Set),Z=(0,t.useRef)(null),J=(0,t.useRef)(null),Q=(0,t.useRef)(0),ee=(0,t.useRef)(!1),te=(0,t.useRef)(new re),[ne,oe]=(0,t.useState)(null),se=(0,t.useRef)(null),fe=(0,t.useRef)(0),ge=(0,t.useRef)(null),me=(0,t.useRef)(new Set),pe=(0,t.useRef)(!1),he=(0,t.useRef)(null),ve=(0,t.useRef)(0),[ye,be]=(0,t.useState)(()=>new Map),Se=(0,t.useCallback)((e,t)=>{const n={token:++ve.current,kind:t};be(t=>{const r=new Map(t);return r.set(e,n),r})},[]);(0,t.useEffect)(()=>{N.current=z},[z]);const xe=(0,t.useCallback)((e,t,n)=>{N.current.common?.onError?.({code:e,message:t,context:n})},[]),we=(0,t.useCallback)((e,t,n)=>{let r=!1;return N.current.common?.onError?.({code:e,message:t,context:n,preventDefault:()=>{r=!0}}),r},[]),Re=(0,t.useCallback)(e=>{N.current.common?.onLoadProgress?.(e)},[]);(0,t.useEffect)(()=>{0===D&&xe("EMPTY_SCENES","Cineview requires at least one Scene child.",{mode:T})},[xe,T,D]),(0,t.useEffect)(()=>{"drag"===T&&E.forEach((e,t)=>{const n=e.props;q(b,n.drag,({field:e,value:n})=>{const r=`${t}:${e}`;me.current.has(r)||(me.current.add(r),xe("INVALID_DRAG_CONFIG",`Invalid drag ${e}; using the safe default.`,{sceneIndex:t,field:e,value:n}))});const r=n.drag?.enabled;if(void 0!==r&&"boolean"!=typeof r){const e=`${t}:enabled`;if(me.current.has(e))return;me.current.add(e),xe("INVALID_DRAG_CONFIG","Invalid drag enabled flag; using true.",{sceneIndex:t,field:"enabled",value:r})}})},[xe,b,T,E]);const[Me,Ce]=(0,t.useState)(0),[ke,Pe]=(0,t.useState)(0),Ie=(0,t.useCallback)((e,t)=>{M.current=e,z.common?.onSceneEnter?.({fromIndex:e,toIndex:t,direction:t>e?"forward":t<e?"backward":null})},[z]),Ee=(0,t.useCallback)((e,t)=>{const n=t??M.current??e;M.current=null,z.common?.onSceneLeave?.({fromIndex:n,toIndex:e,direction:n===e?null:e>n?"forward":e<n?"backward":null})},[z]),[Ae,De]=(e=>{const{totalScenes:n,initialScene:r=0,mode:i="drag",onBeforeChange:a,onCommit:o,onAfterChange:s}=e,[c,l]=(0,t.useState)(Math.max(0,Math.min(r,n-1))),[u,d]=(0,t.useState)(!1),[f,g]=(0,t.useState)(null),[m,p]=(0,t.useState)(0),[h,v]=(0,t.useState)(0),[y,b]=(0,t.useState)(0),[S,x]=(0,t.useState)(null),[w,R]=(0,t.useState)(0),[M,C]=(0,t.useState)(!1),[k,P]=(0,t.useState)(!1),[I,E]=(0,t.useState)(0),[A,D]=(0,t.useState)(null),T=(0,t.useRef)(0),[j,V]=(0,t.useState)(null),L=(0,t.useRef)(!1),O=(0,t.useRef)(c),$=(0,t.useRef)(null),F=(0,t.useRef)(!1),z=(0,t.useRef)(!1),N=(0,t.useRef)(null);O.current=c,(0,t.useEffect)(()=>{const e=Math.max(n-1,0);O.current<=e||(l(e),L.current&&(d(!1),L.current=!1,g(null),N.current=null))},[n]);const B=(0,t.useCallback)(()=>{$.current=null,F.current=!1,z.current=!1,p(0),v(0),E(0),D(null),g(null)},[]),q=(0,t.useCallback)(e=>{O.current=e,l(e),N.current=null,L.current=!1,d(!1),C(!1),R(0),B()},[B]),U=(0,t.useCallback)(e=>{if(null===e)return z.current=!1,void D(null);z.current="settle"===e.mode,T.current+=1,D({...e,token:T.current})},[]),Y=(0,t.useCallback)(()=>c<n-1,[c,n]),H=(0,t.useCallback)(()=>c>0,[c]),W=(0,t.useCallback)((e,t=!0)=>{if(!Number.isInteger(e)||e<0||e>=n)return;if(e===c)return;a?.(c,e);const r=e>c?"forward":"backward";g(r),l(e),o?.(e,c,"programmatic"),t?(d(!0),L.current=!0,N.current={fromScene:c,releaseToken:null},"drag"===i&&(T.current+=1,N.current.releaseToken=T.current,D({token:T.current,mode:"enter",direction:r,targetSceneIndex:e}))):(d(!1),L.current=!1,N.current=null,B(),s?.(e,c))},[c,n,i,a,o,s,B]),X=(0,t.useCallback)(()=>{Y()&&W(c+1)},[c,Y,W]),K=(0,t.useCallback)(()=>{H()&&W(c-1)},[c,H,W]),G=(0,t.useCallback)(e=>{if(d(e),L.current=e,!e){const e=N.current;N.current=null,e?s?.(c,e.fromScene):s?.(c),g(null);const t=e?.releaseToken;null!=t&&D(e=>null!==e&&e.token===t?null:e)}},[c,s]),_=(0,t.useCallback)(()=>{z.current&&null!==$.current||($.current=null,F.current=!1,z.current=!1,D(null)),p(0),v(0),R(0),C(!1),E(0)},[]),Z=(0,t.useCallback)(()=>{$.current=null,F.current=!1,z.current=!1,D(null),g(null),v(0),E(0)},[]),J=(0,t.useCallback)(()=>{b(0),x(null),P(!1),V(null)},[]),Q=(0,t.useCallback)((e,t,r,i)=>{const c=O.current,u="forward"===e?c+1:c-1,f=Math.max(0,Math.min(t,1));return f.toFixed(3),u<0||u>=n?(_(),g(null),d(!1),L.current=!1,!1):(a?.(c,u),g(e),v(f),$.current=c,l(u),o?.(u,c,"drag"),s?.(u,c),p(0),R(0),C(!1),d(!1),L.current=!1,f.toFixed(3),F.current&&B(),!0)},[B,s,a,o,_,n]),ee=(0,t.useCallback)(()=>{null===$.current?z.current&&(F.current=!0):B()},[B]),te=(0,t.useCallback)((e,t)=>{const r=O.current,i="forward"===e?r+1:r-1,o=Math.max(0,Math.min(t,1));if(o.toFixed(3),i<0||i>=n)return J(),g(null),d(!1),void(L.current=!1);a?.(r,i),g(e),x(e),b(o),V({fromScene:r,toScene:i,direction:e,progressRatio:o,startedAt:Date.now(),lastInputAt:Date.now(),isSettling:!1,settleDirection:null}),l(i),b(0),x(null),V(null),P(!1),d(!1),L.current=!1,s?.(i,r),o.toFixed(3)},[s,a,J,n]),ne=(0,t.useCallback)(()=>{y.toFixed(3),b(0),x(null),V(null)},[y]);return[{currentScene:c,isAnimating:u,direction:f,dragProgress:m,dragTimelineProgress:h,scrollProgress:y,scrollDirection:S,renderProgress:w,isDragging:M,isScrolling:k,sharedTimelineDurationMs:I,dragRelease:A,scrollTransitionSnapshot:j},{reconcileSceneList:q,goToScene:W,nextScene:X,prevScene:K,setAnimating:G,canGoNext:Y,canGoPrev:H,setDragProgress:p,setDragTimelineProgress:v,setScrollProgress:b,setScrollDirection:x,setScrollTransitionSnapshot:V,setRenderProgress:R,setIsDragging:C,setIsScrolling:P,setSharedTimelineDurationMs:E,setDragRelease:U,resetDragInteraction:_,abortDragContinuation:Z,resetScrollInteraction:J,commitDragSceneChange:Q,completeDragTransition:ee,commitScrollSceneChange:te,clearScrollTransitionSnapshot:ne}]})({totalScenes:D,initialScene:0,mode:T,onBeforeChange:Ie,onCommit:(e,t,n)=>{"drag"===T&&Se(e,"drag"===n?"commit":"programmatic")},onAfterChange:(e,t)=>{Ee(e,t??R.current)}}),Te=(0,t.useRef)(De);Te.current=De;const{currentScene:je,isAnimating:Ve,direction:Le,dragProgress:Oe,dragTimelineProgress:$e,renderProgress:Fe,isDragging:ze,sharedTimelineDurationMs:Ne,dragRelease:Be}=Ae,qe=(0,t.useMemo)(()=>E.map(H),[E]),[Ue,Ye]=(0,t.useState)(qe);if(Ue.length!==qe.length||Ue.some((e,t)=>e!==qe[t])){const e=qe.indexOf(Ue[je]),t=e>=0?e:ue(je,0,Math.max(0,D-1));Ye(qe),De.reconcileSceneList(t),be(e=>{const t=new Map;for(const[n,r]of e){const e=qe.indexOf(Ue[n]);e>=0&&t.set(e,r)}return t})}const He=(0,n.useMotionValue)(0),We=(0,n.useMotionValue)(0),Xe=(0,t.useSyncExternalStore)(le,ce,()=>!1),Ke=e.a11y?.label??"Scenes";R.current=je,C.current=E,Y(()=>{ee.current&&(ee.current=!1,He.set(0),We.set(0))},[je,We,He]);const Ge=E[je],_e=Ge?function(e,t,n){return Math.max("drag"===t?n??e.sceneTransitionDuration??800:e.sceneTransitionDuration??800,0)}(Ge.props,T,c):0;(0,t.useEffect)(()=>{if(!Ve||!C.current[je])return;const e=setTimeout(()=>{Te.current.setAnimating(!1)},_e),t=P.current;return t.add(e),()=>{clearTimeout(e),t.delete(e)}},[Ve,je,_e]),(0,t.useEffect)(()=>{if("drag"===T)return;B.current=!1,U.current=!1,X(!1),G.current.clear(),_.current.clear(),fe.current=0,ge.current=null;const e=se.current;e&&(te.current.releaseTransaction(e.transactionId),se.current=null,oe(null))},[T]);const Ze=(0,t.useCallback)(e=>{if(!e)return null;const t=se.current,n=!t||t.transactionId!==e.transactionId||t.phase!==e.phase;return t&&t.transactionId!==e.transactionId&&te.current.releaseTransaction(t.transactionId),se.current=e,n&&oe(e),e},[]),Je=(0,t.useCallback)(e=>{const t=se.current;!t||e&&t.transactionId!==e||(te.current.releaseTransaction(t.transactionId),se.current=null,oe(null))},[]),Qe=(0,t.useCallback)(e=>{te.current.publishPrepared(e)},[]),et=(0,t.useCallback)(e=>{te.current.invalidatePrepared(e)},[]),tt=(0,t.useCallback)((e,t)=>{t?G.current.add(e):G.current.delete(e)},[]),nt=(0,t.useCallback)(()=>{_.current.clear()},[]),rt=(0,t.useCallback)(e=>e?"drag"===T&&(null!==Z.current||G.current.size>0)&&(J.current={token:++Q.current,sceneIndices:[...G.current],staleRatio:We.get(),baseRatio:null},U.current=!0,X(!0),!0):(U.current=!1,X(!1),null===J.current?.baseRatio&&(J.current=null),!1),[We,T]),it=(0,t.useCallback)(e=>{const t=se.current;!t||t.targetSceneIndex===e||(De.abortDragContinuation(),G.current.delete(t.targetSceneIndex))},[De]),at=(0,t.useCallback)(e=>{if("drag"!==T)return!1;const t=U.current,n=B.current;if(n&&!t)return!1;const r=R.current,i=r+("forward"===e?1:-1);if(i<0||i>=D)t&&(it(null),Je());else{if(!1===E[i]?.props?.drag?.enabled)return _.current.has(e)||(_.current.add(e),N.current.drag?.onDragBlocked?.({fromIndex:r,targetSceneIndex:i,direction:e})),!1;if(!te.current.getPrepared(i))return!1;const t=te.current.beginTransaction(i,"driving",0);if(!t||(it(i),!Ze(t)))return!1}return U.current=!1,X(!1),n||(B.current=!0,fe.current=0,ge.current=null,N.current.drag?.onDragStart?.({sceneIndex:r,progress:0,direction:e})),!0},[it,Ze,Je,T,E,D]),ot=(0,t.useCallback)(e=>{if("drag"!==T||!B.current)return;const t=0===e?0:ue(e,-1,1);if(t!==fe.current){if(fe.current=t,0!==t){const e=R.current+(t>0?1:-1);if(e>=0&&e<D){const n=te.current.beginTransaction(e,"driving",Math.abs(t));n&&(it(e),Ze(n))}}N.current.drag?.onDragProgress?.({sceneIndex:R.current,progress:Math.abs(t),direction:t>0?"forward":t<0?"backward":null})}},[it,Ze,T,D]),st=(0,t.useCallback)(e=>{e||(J.current=null),De.setIsDragging(e)},[De]),ct=(0,t.useCallback)(e=>{"bounce"===e?.mode&&B.current?ge.current={sceneIndex:R.current,signedProgress:fe.current}:"bounce"!==e?.mode&&(ge.current=null),De.setDragRelease(e)},[De]);(0,t.useEffect)(()=>{if("drag"===T){if(Be)return void Ze(te.current.beginTransaction(Be.targetSceneIndex,"settle"===Be.mode?"settling":"bounce"===Be.mode?"bouncing":"programmatic","enter"===Be.mode?0:Be.progressRatio??0));"driving"!==se.current?.phase&&Je()}},[Ze,Be,Je,T]);const lt=(0,t.useCallback)(()=>{if("drag"===T&&B.current){const e=ge.current??{sceneIndex:R.current,signedProgress:fe.current};B.current=!1,fe.current=0,ge.current=null,N.current.drag?.onDragCancel?.({sceneIndex:e.sceneIndex,progress:Math.abs(e.signedProgress),direction:e.signedProgress>0?"forward":e.signedProgress<0?"backward":null})}"settling"!==se.current?.phase&&Je(),He.set(0),We.set(0),De.resetDragInteraction()},[We,Je,He,T,De]);(0,t.useEffect)(()=>{const e=x.current;if(!e)return;const t=e.ownerDocument?.defaultView??window,n=()=>{const t=e.getBoundingClientRect(),n=t.width,r=t.height;n>0&&Ce(n),r>0&&Pe(r)};k.current=n,n();const r=t.ResizeObserver??(typeof ResizeObserver<"u"?ResizeObserver:void 0),i=r?new r(()=>{n()}):null;return i?.observe(e),t.addEventListener("resize",n),()=>{k.current=null,i?.disconnect(),t.removeEventListener("resize",n)}},[]),(0,t.useEffect)(()=>{if(!g||!1===g.enabled)return;const e=x.current?.ownerDocument??(typeof document<"u"?document:null);if(!e)return;const t="cineview-scrollbar-style";let n=e.getElementById(t);return n||(n=e.createElement("style"),n.id=t,e.head.appendChild(n)),n.textContent='\n [data-cineview-container="true"] {\n scrollbar-width: none;\n -ms-overflow-style: none;\n }\n [data-cineview-container="true"]::-webkit-scrollbar {\n width: 0;\n height: 0;\n display: none;\n }\n ',()=>{n&&n.parentNode&&n.parentNode.removeChild(n)}},[g]);const ut=je,{priorityImages:dt,backgroundImages:ft}=(0,t.useMemo)(()=>function(e,t,n){if("scroll"===n){const n=e[ue(t,0,Math.max(e.length-1,0))],r=n?ie(n.props):[],i=new Set(r);return{priorityImages:r,backgroundImages:Array.from(new Set(e.flatMap(e=>ie(e.props).filter(e=>!i.has(e)))))}}const r=ue(t,0,Math.max(e.length-1,0)),i=[],a=[];e.forEach((e,t)=>{const n=ie(e.props);t===r?i.push(...n):a.push(...n)});const o=new Set(i);return{priorityImages:Array.from(new Set(i)),backgroundImages:Array.from(new Set(a.filter(e=>!o.has(e))))}}(E,ut,T),[E,ut,T]),[gt,mt]=((e={})=>{const{priorityUrls:n=[],backgroundUrls:r=[],onProgress:i,onComplete:a,onError:o}=e,[s,c]=(0,t.useState)(!1),[l,u]=(0,t.useState)(0),[d,f]=(0,t.useState)(0),[g,m]=(0,t.useState)(n.length+r.length),[p,h]=(0,t.useState)([]),[v,y]=(0,t.useState)(new Map),[b,x]=(0,t.useState)(!1),w=(0,t.useRef)([...n]),R=(0,t.useRef)([...r]),M=(0,t.useRef)(!1),C=(0,t.useRef)(new Map),k=(0,t.useRef)(0),P=(0,t.useRef)(null),E=(0,t.useRef)(new Set),A=(0,t.useRef)(new Set),D=(0,t.useRef)(0),T=(0,t.useRef)(0),O=(0,t.useRef)(i),$=(0,t.useRef)(a),F=(0,t.useRef)(o);(0,t.useEffect)(()=>{O.current=i,$.current=a,F.current=o},[i,a,o]);const z=(0,t.useCallback)((e,t)=>{const n=V(e).filter(e=>!E.current.has(e));if(0===n.length)return;const r=new Set(w.current),i=new Set(R.current),a=n.filter(e=>!r.has(e)&&!i.has(e));0!==a.length&&(t?w.current=[...w.current,...a]:R.current=[...R.current,...a])},[]);(0,t.useEffect)(()=>{z(n,!0),z(r,!1),M.current||m(w.current.length+R.current.length)},[n,r,z]);const N=(0,t.useCallback)((e,t)=>{const n=I(e);return n?j(e,n).then(()=>(S(e),{url:e,success:!0})).catch(n=>{const r=n instanceof Error?n:new Error(String(n));return k.current===t&&F.current?.(e,r),{url:e,success:!1,error:r}}):new Promise(n=>{const r=new Image,i=new AbortController;C.current.set(e,i);let a=!1,o=null;const s=t=>{a||(a=!0,null!==o&&(clearTimeout(o),o=null),C.current.delete(e),n(t))};r.onload=()=>{S(e),s({url:e,success:!0})},r.onerror=()=>{const n=new Error(`Failed to load image: ${e}`);k.current===t&&F.current?.(e,n),s({url:e,success:!1,error:n})},i.signal.addEventListener("abort",()=>{r.src="",s({url:e,success:!1,error:new Error("Image load aborted")})}),o=setTimeout(()=>{o=null,r.onload=null,r.onerror=null,r.src="";const n=new Error(`Image load timed out after 15000ms: ${e}`);k.current===t&&F.current?.(e,n),s({url:e,success:!1,error:n})},15e3),r.src=e})},[]),B=(0,t.useCallback)((e,t)=>{const n=Math.max(t,0),r=n>0?Math.min(Math.max(e,0),n):0,i=n>0?Math.round(r/n*100):100;u(i),f(r),O.current?.(i)},[]),q=(0,t.useCallback)(()=>{if(M.current)return P.current??Promise.resolve();const e=(async()=>{const e=k.current+1;k.current=e,M.current=!0,c(!0),u(0),f(0),h([]),y(new Map),x(!1),A.current=new Set,D.current=0,T.current=0;const t=L(w.current,R.current,E.current,A.current),n=t.priorityBatch.length+t.backgroundBatch.length;if(T.current=n,m(n),0===n)return B(0,0),k.current===e&&(c(!1),x(!0)),M.current=!1,void $.current?.([]);const r=new Set(t.priorityBatch);let i=0===r.size;i&&x(!0);const a=[],o=new Map,s=()=>{const e=L(w.current,R.current,E.current,A.current);return T.current=D.current+e.priorityBatch.length+e.backgroundBatch.length,m(T.current),e},l=(e,t)=>{a.push(t),A.current.add(e),D.current+=1,!t.success&&t.error?o.set(e,t.error):t.success&&E.current.add(e),B(D.current,T.current),i||(r.delete(e),0===r.size&&(i=!0,x(!0)))};for(;;){const{priorityBatch:t,backgroundBatch:n}=s();if(0===t.length&&0===n.length)break;if(await Promise.all(t.map(async t=>{const n=await N(t,e);k.current===e&&l(t,n)})),k.current!==e)return;const r=await Promise.all(n.map(async t=>({url:t,result:await N(t,e)})));if(k.current!==e)return;r.forEach(({url:e,result:t})=>{l(e,t)})}h(a),y(o),c(!1),M.current=!1,m(w.current.length+R.current.length),$.current?.(a)})();return P.current=e.finally(()=>{P.current===e&&(P.current=null)}),P.current},[N,B]),U=(0,t.useCallback)(()=>{k.current+=1,C.current.forEach(e=>{e.abort()}),C.current.clear(),c(!1),u(0),f(0),m(w.current.length+R.current.length),h([]),y(new Map),x(!1),E.current.clear(),A.current.clear(),D.current=0,T.current=0,M.current=!1,P.current=null},[]),Y=(0,t.useCallback)((e,t=!1)=>{z(e,t);const{priorityBatch:n,backgroundBatch:r}=L(w.current,R.current,E.current,A.current),i=M.current?D.current+n.length+r.length:n.length+r.length;M.current&&(T.current=i),m(i)},[z]);return(0,t.useEffect)(()=>{const e=C.current;return()=>{k.current+=1,M.current=!1,P.current=null,e.forEach(e=>{e.abort()}),e.clear()}},[]),[{isLoading:s,progress:l,loadedCount:d,totalCount:g,results:p,errors:v,priorityComplete:b},{startPreload:q,reset:U,addUrls:Y}]})({priorityUrls:dt,backgroundUrls:ft,onProgress:Re,onError:(e,t)=>{xe("IMAGE_LOAD_FAILED",t.message,{url:e})}}),pt=(0,t.useRef)(mt);pt.current=mt;const ht=(0,t.useRef)({loadedCount:0,totalCount:0});ht.current={loadedCount:gt.loadedCount,totalCount:gt.totalCount};const vt=Math.max(0,f??3e3),yt=(0,t.useCallback)(()=>({loadedCount:ht.current.loadedCount,totalCount:ht.current.totalCount}),[]),{firstSceneEnterActive:bt,firstSceneEnterReady:St,firstSceneActivationToken:xt,firstSceneActivationKind:wt,handleComplete:Rt}=function({enabled:e,hasFirstScene:n,priorityComplete:r,timeoutMs:i,preemptSignal:a=!1,emitRecoverableError:o,getPreloadCounts:s}){const[c,l]=(0,t.useState)(()=>e),[u,d]=(0,t.useState)(!1),[f,g]=(0,t.useState)(0),[m,p]=(0,t.useState)(null),h=(0,t.useRef)(!1),v=(0,t.useRef)(null),y=Math.max(0,i),b=(0,t.useRef)(o);b.current=o;const S=(0,t.useRef)(s);return S.current=s,(0,t.useEffect)(()=>{if(!e||h.current||!n)return;const t=e=>{p(e),g(e=>e+1)};return r?(h.current=!0,d(!0),void t("ready")):(null===v.current&&(v.current=setTimeout(()=>{v.current=null,h.current=!0;const e=S.current();b.current("FIRST_SCENE_TIMEOUT",`First scene priority assets did not load within ${y}ms.`,{sceneIndex:0,timeoutMs:y,loadedCount:e.loadedCount,totalCount:e.totalCount})||(h.current=!0,d(!1),l(!1),t("static"))},y)),()=>{v.current&&(clearTimeout(v.current),v.current=null)})},[e,n,r,y]),(0,t.useEffect)(()=>{a&&(h.current=!0,v.current&&(clearTimeout(v.current),v.current=null),d(!1),l(!1))},[a]),{firstSceneEnterActive:c,firstSceneEnterReady:u,firstSceneActivationToken:f,firstSceneActivationKind:m,handleComplete:(0,t.useCallback)(()=>{l(!1)},[])}}({enabled:E.length>0,hasFirstScene:!!E[0],priorityComplete:gt.priorityComplete,timeoutMs:vt,preemptSignal:ze,emitRecoverableError:we,getPreloadCounts:yt}),Mt=(0,t.useRef)(0);(0,t.useEffect)(()=>{"drag"!==T||xt<=Mt.current||null===wt||(Mt.current=xt,Se(0,wt))},[Se,wt,xt,T]),(0,t.useEffect)(()=>{const e=P.current;return mt.startPreload(),()=>{e.forEach(e=>{clearTimeout(e)}),e.clear()}},[i]),(0,t.useEffect)(()=>{if(p)return(()=>{1===($+=1)&&O.start();let e=!1;return()=>{e||(e=!0,0===($=Math.max($-1,0))&&O.stop())}})()},[p]),(0,t.useEffect)(()=>{const e=`${dt.join("|")}::${ft.join("|")}`;if(he.current!==e){if(he.current=e,mt.addUrls(dt,!0),mt.addUrls(ft,!1),!pe.current)return void(pe.current=!0);gt.isLoading||mt.startPreload()}},[dt,ft,mt,gt.isLoading]);const Ct=(0,t.useMemo)(()=>{const e=new Set;return e.add(je),"drag"===T&&(je>0&&e.add(je-1),je<D-1&&e.add(je+1)),e},[T,je,D]);!function({ref:e,currentSceneRef:n,scenesRef:r,sceneActionsRef:i,preloadActionsRef:a,measureViewportRef:o,resolvedCallbacksRef:s}){const c=(0,t.useCallback)((e,t=!0)=>{const a=n.current;e>=0&&e<r.current.length&&e!==a&&s.current.drag?.onDragEnd?.({sceneIndex:a,targetSceneIndex:e,progress:1,direction:e>a?"forward":"backward",elapsedMs:0,timelineDurationMs:0}),i.current.goToScene(e,t)},[n,s,i,r]),l=(0,t.useCallback)(()=>{o.current?.()},[o]),u=(0,t.useCallback)(async e=>{const t=function(e,t,n={}){if(!t||0===t.length)return[];const r=n.includeZoneIds??!1,i=new Set,a=[],o=e=>{e&&ie(e.props).forEach(e=>{!e||i.has(e)||(i.add(e),a.push(e))})};return t.forEach(t=>{"number"!=typeof t?t&&e.forEach(e=>{e.props.sceneId!==t?r&&e.props.scroll?.zoneId===t&&o(e):o(e)}):Number.isInteger(t)&&t>=0&&t<e.length&&o(e[t])}),a}(r.current,e,{includeZoneIds:!0});t.length>0&&a.current.addUrls(t,!0),await a.current.startPreload()},[a,r]),d=(0,t.useCallback)(()=>n.current,[n]),f=(0,t.useCallback)(()=>F.getMetrics(),[]),g=(0,t.useRef)(null);g.current||(g.current={goToScene:(e,t=!0)=>c(e,t),refreshLayout:()=>l(),preload:e=>u(e),getCurrentIndex:()=>d(),getPerformanceMetrics:()=>f()});const m=g.current;(0,t.useImperativeHandle)(e,()=>m,[m]);const p=(0,t.useRef)(!1);(0,t.useEffect)(()=>{p.current||(p.current=!0,s.current.common?.onReady?.(m))},[s,m])}({ref:i,currentSceneRef:R,scenesRef:C,sceneActionsRef:Te,preloadActionsRef:pt,measureViewportRef:k,resolvedCallbacksRef:N});const kt=(0,t.useCallback)((e,t,n,r)=>{const i=je,a="forward"===e?i+1:i-1;if("drag"!==T)return void("forward"===e?De.nextScene():De.prevScene());const o=se.current,s=o?.targetSceneIndex===a?o:null,c=s?s.releaseSeed.progressRatio:Math.max(0,Math.min(t??We.get(),1)),l=s?s.releaseSeed.elapsedMs:Math.max(0,n??0),u=s?s.registrySnapshot.timelineDuration:Math.max(0,r??0);B.current=!1,fe.current=0,ge.current=null,N.current.drag?.onDragEnd?.({sceneIndex:i,targetSceneIndex:a,progress:c,direction:e,elapsedMs:l,timelineDurationMs:u}),ee.current=!0,De.commitDragSceneChange(e,c,l,u)||(ee.current=!1)},[De,je,We,T]);(0,t.useEffect)(()=>{},[A,D]);const Pt=(0,t.useCallback)(e=>{if("drag"!==T||e.target!==e.currentTarget)return;const t=Math.max(0,C.current.length-1),n="x"===s?"ArrowRight":"ArrowDown",r="x"===s?"ArrowLeft":"ArrowUp";let i=null;if("PageDown"===e.key||e.key===n?i=R.current+1:"PageUp"===e.key||e.key===r?i=R.current-1:"Home"===e.key?i=0:"End"===e.key&&(i=t),null===i)return;e.preventDefault();const a=Math.max(0,Math.min(i,t));a!==R.current&&De.goToScene(a,!0)},[s,T,De]),It=D>0?`${je+1} / ${D}`:"",Et=(0,t.useMemo)(()=>({mode:T,scrollEnterMargin:void 0,scrollExitMargin:void 0,prefersReducedMotion:Xe,reportError:e=>{xe(e.code,e.message,e.context)}}),[T,xe,Xe]);return(0,r.jsx)(h,{designSize:y,children:(0,r.jsx)(ae.Provider,{value:Et,children:(0,r.jsxs)("div",{ref:x,style:{position:"relative",width:"100%",height:"100vh",minHeight:"100vh",overflowX:"hidden",overflowY:"hidden",background:"#0d1624"},className:"cineview-container","data-cineview-container":"true",role:"drag"===T?"region":void 0,"aria-roledescription":"drag"===T?"carousel":void 0,"aria-label":"drag"===T?Ke:void 0,tabIndex:"drag"===T?0:void 0,onKeyDown:"drag"===T?Pt:void 0,children:[(0,r.jsx)("div",{style:{opacity:1,pointerEvents:"auto"},children:(0,r.jsx)(K,{scenes:E,visibleSceneIndices:Ct,currentScene:je,totalScenes:D,mode:T,dragConfig:b,dragProgress:Oe,dragTimelineProgress:$e,renderProgress:Fe,renderProgressMotion:He,timelineProgressMotion:We,isDragging:ze,sharedTimelineDurationMs:Ne,dragRelease:Be,sceneActivations:ye,firstSceneEnterActive:bt,firstSceneEnterReady:St,direction:Le,isAnimating:Ve,viewportWidth:Me,viewportHeight:ke,sceneActions:De,sceneWrapperRefs:w,renderLaneRef:Z,takeoverSnapshot:J,candidateSuspended:W,onCandidateSuspensionChange:rt,onElementContinuationChange:tt,onPointerSessionStart:nt,dragTransaction:ne,onPrepared:Qe,onPreparedInvalidated:et,onOwnershipRequest:at,onTransactionComplete:Je,onSceneChange:kt,onDragProgressChange:ot,onRenderProgressChange:void 0,onDragTimelineProgressChange:e=>We.set(e),onDraggingChange:st,onSharedTimelineDurationChange:De.setSharedTimelineDurationMs,onDragRelease:ct,onDragReset:lt,onFirstSceneEnterComplete:Rt})}),"drag"===T?(0,r.jsx)("div",{role:"status","aria-live":"polite",style:de,children:It}):null]})})})});fe.displayName="CineviewDrag";var ge,me,pe,he,ve,ye,be,Se,xe,we,Re,Me=fe,Ce=m({fadeAnimations:()=>ge}),ke=g(()=>{ge={fade:{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},"fade-in":{initial:{opacity:0},animate:{opacity:1},exit:{opacity:1}},"fade-out":{initial:{opacity:1},animate:{opacity:1},exit:{opacity:0}}}}),Pe=m({slideAnimations:()=>me}),Ie=g(()=>{me={"slide-up":{initial:{y:"100%",opacity:0},animate:{y:0,opacity:1},exit:{y:"-100%",opacity:0}},"slide-down":{initial:{y:"-100%",opacity:0},animate:{y:0,opacity:1},exit:{y:"100%",opacity:0}},"slide-left":{initial:{x:"100%",opacity:0},animate:{x:0,opacity:1},exit:{x:"-100%",opacity:0}},"slide-right":{initial:{x:"-100%",opacity:0},animate:{x:0,opacity:1},exit:{x:"100%",opacity:0}}}}),Ee=m({zoomAnimations:()=>pe}),Ae=g(()=>{pe={"zoom-in":{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0}},"zoom-out":{initial:{scale:1.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:1.5,opacity:0}},"scale-up":{initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:1.5,opacity:0}},"scale-down":{initial:{scale:1.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.5,opacity:0}}}}),De=m({rotateAnimations:()=>he}),Te=g(()=>{he={rotate:{initial:{rotate:-180,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:180,opacity:0}},"rotate-in":{initial:{rotate:-180,scale:0,opacity:0},animate:{rotate:0,scale:1,opacity:1},exit:{rotate:0,scale:1,opacity:1}},"rotate-out":{initial:{rotate:0,scale:1,opacity:1},animate:{rotate:0,scale:1,opacity:1},exit:{rotate:180,scale:0,opacity:0}},spin:{initial:{rotate:0,opacity:0},animate:{rotate:360,opacity:1},exit:{rotate:720,opacity:0}}}}),je=m({flipAnimations:()=>ve}),Ve=g(()=>{ve={flip:{initial:{rotateY:-180,opacity:0},animate:{rotateY:0,opacity:1},exit:{rotateY:180,opacity:0}},"flip-x":{initial:{rotateX:-180,opacity:0},animate:{rotateX:0,opacity:1},exit:{rotateX:180,opacity:0}},"flip-y":{initial:{rotateY:-180,opacity:0},animate:{rotateY:0,opacity:1},exit:{rotateY:180,opacity:0}}}}),Le=m({bounceAnimations:()=>ye}),Oe=g(()=>{ye={bounce:{initial:{y:-100,opacity:0},animate:{y:0,opacity:1,transition:{type:"spring",bounce:.5,duration:.8}},exit:{y:100,opacity:0}},"bounce-in":{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1,transition:{type:"spring",bounce:.6,duration:.8}},exit:{scale:1,opacity:1}},"bounce-out":{initial:{scale:1,opacity:1},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0,transition:{type:"spring",bounce:.6,duration:.6}}}}}),$e=m({blinkAnimations:()=>be}),Fe=g(()=>{be={blink:{initial:{opacity:1},animate:{opacity:[1,0,1,0,1],transition:{duration:1,times:[0,.25,.5,.75,1]}},exit:{opacity:0}},flash:{initial:{opacity:0},animate:{opacity:[0,1,0,1],transition:{duration:.8,times:[0,.25,.5,1]}},exit:{opacity:0}},pulse:{initial:{scale:1,opacity:1},animate:{scale:[1,1.05,1],opacity:[1,.8,1],transition:{duration:1,times:[0,.5,1]}},exit:{scale:1,opacity:0}}}}),ze=m({shakeAnimations:()=>Se}),Ne=g(()=>{Se={shake:{initial:{x:0},animate:{x:[0,-10,10,-10,10,0],transition:{duration:.6,times:[0,.2,.4,.6,.8,1]}},exit:{x:0,opacity:0}},"shake-x":{initial:{x:0},animate:{x:[0,-15,15,-15,15,0],transition:{duration:.8,times:[0,.2,.4,.6,.8,1]}},exit:{x:0,opacity:0}},"shake-y":{initial:{y:0},animate:{y:[0,-15,15,-15,15,0],transition:{duration:.8,times:[0,.2,.4,.6,.8,1]}},exit:{y:0,opacity:0}},vibrate:{initial:{x:0,y:0},animate:{x:[0,-2,2,-2,2,0],y:[0,-2,2,-2,2,0],transition:{duration:.4,times:[0,.2,.4,.6,.8,1]}},exit:{x:0,y:0,opacity:0}},jello:{initial:{skewX:0,skewY:0},animate:{skewX:[0,-12.5,6.25,-3.125,1.5625,0],skewY:[0,-12.5,6.25,-3.125,1.5625,0],transition:{duration:1,times:[0,.222,.444,.666,.888,1]}},exit:{skewX:0,skewY:0,opacity:0}}}}),Be=m({blurAnimations:()=>xe}),qe=g(()=>{xe={"blur-in":{initial:{filter:"blur(10px)",opacity:0},animate:{filter:"blur(0px)",opacity:1},exit:{filter:"blur(0px)",opacity:1}},"blur-out":{initial:{filter:"blur(0px)",opacity:1},animate:{filter:"blur(0px)",opacity:1},exit:{filter:"blur(10px)",opacity:0}},"focus-in":{initial:{filter:"blur(20px)",scale:.8,opacity:0},animate:{filter:"blur(0px)",scale:1,opacity:1},exit:{filter:"blur(0px)",scale:1,opacity:1}}}}),Ue=m({elasticAnimations:()=>we}),Ye=g(()=>{we={elastic:{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1,transition:{type:"spring",stiffness:300,damping:10}},exit:{scale:0,opacity:0}},"rubber-band":{initial:{scale:1},animate:{scale:[1,1.25,.75,1.15,.95,1],transition:{duration:1,times:[0,.3,.4,.5,.65,1]}},exit:{scale:0,opacity:0}},wobble:{initial:{x:0,rotate:0},animate:{x:[0,-25,20,-15,10,-5,0],rotate:[0,-5,3,-3,2,-1,0],transition:{duration:1,times:[0,.15,.3,.45,.6,.75,1]}},exit:{x:0,rotate:0,opacity:0}},swing:{initial:{rotate:0,transformOrigin:"top center"},animate:{rotate:[0,15,-10,5,-5,0],transformOrigin:"top center",transition:{duration:1,times:[0,.2,.4,.6,.8,1]}},exit:{rotate:0,opacity:0}}}}),He=m({specialAnimations:()=>Re}),We=g(()=>{Re={heartbeat:{initial:{scale:1},animate:{scale:[1,1.3,1,1.3,1],transition:{duration:1.3,times:[0,.14,.28,.42,1]}},exit:{scale:0,opacity:0}},tada:{initial:{scale:1,rotate:0},animate:{scale:[1,.9,.9,1.1,1.1,1.1,1.1,1.1,1.1,1],rotate:[0,-3,-3,3,-3,3,-3,3,-3,0],transition:{duration:1,times:[0,.1,.2,.3,.4,.5,.6,.7,.8,1]}},exit:{scale:0,rotate:0,opacity:0}},wave:{initial:{rotate:0,transformOrigin:"bottom center"},animate:{rotate:[0,14,-8,14,-4,10,0],transformOrigin:"bottom center",transition:{duration:1,times:[0,.1,.2,.3,.4,.5,1]}},exit:{rotate:0,opacity:0}},"roll-in":{initial:{x:"-100%",rotate:-120,opacity:0},animate:{x:0,rotate:0,opacity:1},exit:{x:0,rotate:0,opacity:1}},"roll-out":{initial:{x:0,rotate:0,opacity:1},animate:{x:0,rotate:0,opacity:1},exit:{x:"100%",rotate:120,opacity:0}},hinge:{initial:{rotate:0,transformOrigin:"top left"},animate:{rotate:0,transformOrigin:"top left"},exit:{rotate:[0,80,60,80,60,60],y:[0,0,0,0,0,700],opacity:[1,1,1,1,1,0],transformOrigin:"top left",transition:{duration:2,times:[0,.2,.4,.6,.8,1]}}},"jack-in-the-box":{initial:{scale:.1,rotate:30,transformOrigin:"center bottom",opacity:0},animate:{scale:1,rotate:0,transformOrigin:"center bottom",opacity:1,transition:{type:"spring",stiffness:500,damping:15}},exit:{scale:0,opacity:0}}}}),Xe=class extends Error{constructor(e,t,n){super(t),this.code=e,this.permanent=n.permanent,this.category=n.category,this.presetName=n.presetName,this.cause=n.cause,this.name="PresetLoadError"}};function Ke(e){return e instanceof Xe}var Ge={fade:"fade","fade-in":"fade","fade-out":"fade","slide-up":"slide","slide-down":"slide","slide-left":"slide","slide-right":"slide","zoom-in":"zoom","zoom-out":"zoom","scale-up":"zoom","scale-down":"zoom",rotate:"rotate","rotate-in":"rotate","rotate-out":"rotate",spin:"rotate",flip:"flip","flip-x":"flip","flip-y":"flip",bounce:"bounce","bounce-in":"bounce","bounce-out":"bounce",blink:"blink",flash:"blink",pulse:"blink",shake:"shake","shake-x":"shake","shake-y":"shake",vibrate:"shake",jello:"shake","blur-in":"blur","blur-out":"blur","focus-in":"blur",elastic:"elastic","rubber-band":"elastic",wobble:"elastic",swing:"elastic",heartbeat:"special",tada:"special",wave:"special","roll-in":"special","roll-out":"special",hinge:"special","jack-in-the-box":"special"},_e=["fade","slide","zoom","rotate","flip","bounce","blink","shake","blur","elastic","special"],Ze=new Map,Je=new Map,Qe=new Map,et=new Map,tt=new Map,nt={left:"0%",center:"50%",right:"100%"},rt={top:"0%",center:"50%",bottom:"100%"},it={center:"50% 50%","top center":"50% 0%","center top":"50% 0%","bottom center":"50% 100%","center bottom":"50% 100%","top left":"0% 0%","left top":"0% 0%","top right":"100% 0%","right top":"100% 0%","bottom left":"0% 100%","left bottom":"0% 100%","bottom right":"100% 100%","right bottom":"100% 100%","center left":"0% 50%","left center":"0% 50%","center right":"100% 50%","right center":"100% 50%"};function at(e,t){return Array.isArray(t)?t.map(t=>at(e,t)):t&&"object"==typeof t?ot(t):"transformOrigin"===e&&"string"==typeof t?function(e){const t=e.trim().toLowerCase().replace(/\s+/g," "),n=it[t];if(n)return n;const r=t.split(" ");if(1===r.length){const t=nt[r[0]],n=rt[r[0]];return t&&n?`${t} ${n}`:t?`${t} 50%`:n?`50% ${n}`:e}if(2===r.length){const[e,t]=r,n=nt[e]??nt[t],i=rt[e]??rt[t];if(n&&i)return`${n} ${i}`}return e}(t):t}function ot(e){const t={};return Object.entries(e).forEach(([e,n])=>{t[e]=at(e,n)}),t}function st(e){return{initial:ot(e.initial||{}),animate:ot(e.animate||{}),exit:ot(e.exit||{})}}var ct=async e=>"string"==typeof e?await(async e=>st(await async function(e){const t=tt.get(e);if(t)throw t;const n=Ge[e];if(!n){const t=new Xe("INVALID_ANIMATION",`Unknown preset animation: ${e}`,{permanent:!0,presetName:e});throw tt.set(e,t),t}const r=(await function(e){const t=Ze.get(e);if(t)return Promise.resolve(t);const n=et.get(e);if(n)return Promise.reject(n);if(!function(e){return _e.includes(e)}(e)){const t=new Xe("INVALID_ANIMATION",`Unknown animation category: ${e}`,{permanent:!0,category:e});return et.set(e,t),Qe.set(e,"failed-permanent"),Promise.reject(t)}const r=Je.get(e);if(r)return r;Qe.set(e,"pending");const i=function(e,t){return new Promise((n,r)=>{const i=setTimeout(()=>{r(new Xe("ANIMATION_ASSET_LOAD_FAILED",`Timed out loading animation category "${t}".`,{permanent:!1,category:t}))},3e3);e.then(e=>{clearTimeout(i),n(e)},e=>{clearTimeout(i),r(e)})})}(async function(e){switch(e){case"fade":return(await Promise.resolve().then(()=>(ke(),Ce))).fadeAnimations;case"slide":return(await Promise.resolve().then(()=>(Ie(),Pe))).slideAnimations;case"zoom":return(await Promise.resolve().then(()=>(Ae(),Ee))).zoomAnimations;case"rotate":return(await Promise.resolve().then(()=>(Te(),De))).rotateAnimations;case"flip":return(await Promise.resolve().then(()=>(Ve(),je))).flipAnimations;case"bounce":return(await Promise.resolve().then(()=>(Oe(),Le))).bounceAnimations;case"blink":return(await Promise.resolve().then(()=>(Fe(),$e))).blinkAnimations;case"shake":return(await Promise.resolve().then(()=>(Ne(),ze))).shakeAnimations;case"blur":return(await Promise.resolve().then(()=>(qe(),Be))).blurAnimations;case"elastic":return(await Promise.resolve().then(()=>(Ye(),Ue))).elasticAnimations;case"special":return(await Promise.resolve().then(()=>(We(),He))).specialAnimations;default:throw new Xe("INVALID_ANIMATION",`Unknown animation category: ${e}`,{permanent:!0,category:e})}}(e),e).then(t=>(Ze.set(e,t),Qe.set(e,"success"),t)).catch(t=>{const n=function(e,t){return Ke(t)?t:new Xe("ANIMATION_ASSET_LOAD_FAILED",`Failed to load animation category "${e}".`,{permanent:!1,category:e,cause:t})}(e,t);throw Qe.set(e,n.permanent?"failed-permanent":"failed-transient"),n.permanent&&et.set(e,n),n}).finally(()=>{Je.get(e)===i&&Je.delete(e)});return Je.set(e,i),i}(n))[e];if(r)return r;const i=new Xe("INVALID_ANIMATION",`Preset animation "${e}" is missing from category "${n}".`,{permanent:!0,category:n,presetName:e});throw tt.set(e,i),i}(e)))(e):"object"==typeof e?(e=>{if(!(e=>{if(!e||"object"!=typeof e)return!1;const t=new Set(["initial","animate","exit"]),n=Object.entries(e);return 0!==n.length&&!n.some(([e])=>!t.has(e))&&n.some(([,e])=>null!=e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).length>0)})(e))return null;try{return(e=>st({initial:e.initial??{},animate:e.animate??{},exit:e.exit??{}}))(e)}catch(e){return null}})(e):null,lt=e=>{const t={};return e.forEach(e=>{Object.assign(t,e)}),t},ut=async e=>{const t=[];for(let n=0;n<e.length;n++){const r=await ct(e[n]);r&&t.push({variant:r,sourceIndex:n})}return t},dt=e=>{const{transition:t,...n}=e.animate;return{values:n,transition:t||{}}},ft=e=>{const t={},n={};return e.forEach(({values:e,transition:r})=>{Object.entries(e).forEach(([e,i])=>{t[e]=i,n[e]=r})}),t.transition=n,t};async function gt(e,t,n,r){if(!e)return null;try{const i=await(async e=>"object"==typeof e&&"mode"in e&&"animations"in e?await(async e=>{if(!(e=>!!(e&&"object"==typeof e&&e.mode&&["sequential","parallel"].includes(e.mode)&&Array.isArray(e.animations)&&0!==e.animations.length))(e))return null;try{const{mode:t,animations:n,delays:r=[]}=e;return"sequential"===t?await(async(e,t=[])=>{const n=await ut(e);if(0===n.length)throw new Error("No valid animations in sequential composition");const r=n[0].variant.initial,i=n[n.length-1].variant.exit;let a=0;const o=n.map(({variant:e,sourceIndex:n})=>{const r=t[n]||0,{values:i,transition:o}=dt(e),s={...o,delay:a+r/1e3};return a+=("number"==typeof o.duration?o.duration:1)+r/1e3,{values:i,transition:s}});return{initial:r,animate:ft(o),exit:i}})(n,r):"parallel"===t?await(async(e,t=[])=>{const n=await ut(e);if(0===n.length)throw new Error("No valid animations in parallel composition");const r=n.map(({variant:e})=>e.initial),i=n.map(({variant:e,sourceIndex:n})=>{const r=t[n]||0,{values:i,transition:a}=dt(e);return{values:i,transition:{...a,delay:r/1e3}}}),a=n.map(({variant:e})=>e.exit);return{initial:lt(r),animate:ft(i),exit:lt(a)}})(n,r):null}catch(e){if(Ke(e))throw e;return null}})(e):await ct(e))(e);if(i)return i;const a=`Failed to parse ${n} animation for "${t}".`;r?.({code:"INVALID_ANIMATION",message:a,context:{componentId:t,animationType:n,animation:e}})}catch(i){const a=Ke(i)?{code:i.code,message:i.message,context:{componentId:t,animationType:n,animation:e,category:i.category,presetName:i.presetName}}:{code:"INVALID_ANIMATION",message:`Error parsing ${n} animation for "${t}".`,context:{componentId:t,animationType:n,animation:e}};r?.(a)}return null}function mt(e){return"string"==typeof e&&!e.includes("(")&&e.trim().includes(" ")}function pt(e,t,n){const r={};return new Set([...Object.keys(e),...Object.keys(t)]).forEach(i=>{if("transition"===i)return;const a=e[i],o=t[i];if(void 0===o)return void(r[i]=a);if(a===o)return void(r[i]=o);const s=void 0!==a?a:"opacity"===i?1:"number"==typeof o?0:"0";if(mt(s)||mt(o))r[i]=n>.5?o:s;else if("number"!=typeof o||"number"!=typeof s){if("number"==typeof s&&"string"==typeof o){if(o.includes("px"))return void(r[i]=`${s+((parseFloat(o)||0)-s)*n}px`);if(o.includes("%"))return void(r[i]=`${s+((parseFloat(o)||0)-s)*n}%`);if(o.includes("deg"))return void(r[i]=`${s+((parseFloat(o)||0)-s)*n}deg`)}if("string"==typeof s&&"number"==typeof o){if(s.includes("px")){const e=parseFloat(s)||0;return void(r[i]=`${e+(o-e)*n}px`)}if(s.includes("%")){const e=parseFloat(s)||0;return void(r[i]=`${e+(o-e)*n}%`)}if(s.includes("deg")){const e=parseFloat(s)||0;return void(r[i]=`${e+(o-e)*n}deg`)}}if("string"==typeof o&&"string"==typeof s){if(o.includes("px")||s.includes("px")){const e=parseFloat(s)||0;return void(r[i]=`${e+((parseFloat(o)||0)-e)*n}px`)}if(o.includes("%")||s.includes("%")){const e=parseFloat(s)||0;return void(r[i]=`${e+((parseFloat(o)||0)-e)*n}%`)}if(o.includes("deg")||s.includes("deg")){const e=parseFloat(s)||0;return void(r[i]=`${e+((parseFloat(o)||0)-e)*n}deg`)}if(o.includes("(")&&o.includes(")")||s.includes("(")&&s.includes(")")){const e=String(s).match(/([a-zA-Z]+)\(([^)]+)\)/),t=o.match(/([a-zA-Z]+)\(([^)]+)\)/);if(e&&t&&e[1]===t[1]){const a=e[1],o=e[2],s=t[2];if(!isNaN(parseFloat(o))&&!isNaN(parseFloat(s))){const e=parseFloat(o),t=e+(parseFloat(s)-e)*n;return void(r[i]=`${a}(${t})`)}}}}r[i]=n>.5?o:s}else r[i]=s+(o-s)*n}),r}function ht(e,t,n){for(let n=t;n>=0;n-=1){const t=e[n];if("number"==typeof t||"string"==typeof t)return t}return n}function vt(e,t,n){return Math.min(n,Math.max(t,e))}function yt(e,t,n){return e+(t-e)*n}function bt(e,t,n){if("number"==typeof e&&"number"==typeof t)return yt(e,t,n);const r=String(e),i=String(t),a=r.match(/^([-\d.]+)(.*)$/),o=i.match(/^([-\d.]+)(.*)$/);if(a&&o){const e=parseFloat(a[1]),t=parseFloat(o[1]),r=o[2]||a[2]||"",i=yt(e,t,n);return r?`${i}${r}`:i}const s=r.match(/^([a-zA-Z]+)\(([-\d.]+)(.*)\)$/),c=i.match(/^([a-zA-Z]+)\(([-\d.]+)(.*)\)$/);if(s&&c&&s[1]===c[1]){const e=parseFloat(s[2]),t=parseFloat(c[2]),r=c[3]||s[3]||"",i=yt(e,t,n);return`${c[1]}(${i}${r})`}return n>=1?t:e}function St(e,t,n,r,i){const a=t[n]??r,o=vt(i,0,1);if(!Array.isArray(a))return bt(e,a,o);if(0===a.length)return e;const s=function(e,t,n){const r=e.transition,i=r?.[t],a=(i&&!Array.isArray(i)?i.times:null)??r?.times;return Array.isArray(a)&&a.length===n?a:null}(t,n,a.length);if(1===a.length||o<=(s?.[0]??0))return ht(a,0,e);for(let t=1;t<a.length;t+=1){const n=s?.[t]??t/(a.length-1);if(o>n)continue;const r=s?.[t-1]??(t-1)/(a.length-1),i=n-r,c=i<=0?1:(o-r)/i;return bt(ht(a,t-1,e),ht(a,t,e),c)}return ht(a,a.length-1,e)}function xt(e,t,n){const r=e[t]??n;return Array.isArray(r)?ht(r,r.length-1,n):r}function wt(e,t){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){const t=parseFloat(e);if(Number.isFinite(t))return t}return t}function Rt(e,t){switch(e){case"opacity":return"initial"===t||"exit"===t?0:1;case"scale":return 1;case"filter":return"none";default:return 0}}function Mt(e,t,n){const r=e[t];return void 0===r?n:r}function Ct(e,t,r,i){return(0,n.useTransform)(e,e=>i(e,t.current,r))}function kt(e,t,r,i,a){return(0,n.useTransform)(e,e=>{const n=wt(Rt(r,"animate"),0);return wt((a??i)(e,t.current,r),n)})}function Pt(e,t,n,r){const i=kt(e,t,"opacity",n,r),a=Ct(e,t,"x",n),o=Ct(e,t,"y",n),s=kt(e,t,"scale",n,r),c=Ct(e,t,"rotate",n),l=Ct(e,t,"rotateX",n),u=Ct(e,t,"rotateY",n),d=Ct(e,t,"skewX",n),f=Ct(e,t,"skewY",n),g=Ct(e,t,"filter",n);return{style:{opacity:i,x:a,y:o,scale:s,rotate:c,rotateX:l,rotateY:u,skewX:d,skewY:f,filter:g},opacity:i,x:a,y:o,scale:s,rotate:c,rotateX:l,rotateY:u,skewX:d,skewY:f,filter:g}}var It=.001;function Et(e){return e.renderProgressMotion?.get()??e.renderProgress??0}function At(e){return e.dragTransaction?e.dragTransaction:!0===e.firstSceneEnterActive?e.preparedSnapshot??null:null}function Dt(e){return At(e)?.registrySnapshot.timelineDuration??e.getTimelineDuration?.()??e.sceneTransitionDuration}function Tt(e,t,n,r,i,a){const o=function(e,t,n,r){const i=function(e){return Et(e)>=0?"forward":"backward"}(e),a=function(e){return Math.max(0,e.sharedElapsedMotion?.get()??0)}(e),o=function(e){const t=e.dragTimelineProgress;return vt("number"==typeof t?t:Math.abs(Et(e)),0,1)}(e),s=function(e){const t=Dt(e);if(At(e))return t;const n=e.sharedTimelineDurationMs??0;return n>0?n:t}(e),c=Dt(e),l=Math.abs(Et(e)),u=function(e,t,n){return n<=0?e>=t-It?1:0:e<=t?0:vt((e-t)/n,0,1)}(a,t,n),d={direction:i,transitionProgress:o,sharedElapsedMs:a,projectedSceneElapsedMs:a,sharedTimelineDurationMs:s,sceneTimelineDurationMs:c,sceneOffset:e.sceneOffset};if(0===e.sceneOffset&&e.isActive){const t=!0===e.firstSceneEnterActive||"settle"===e.dragRelease?.mode||"enter"===e.dragRelease?.mode;if(e.isDragging||l>It){if(l<=It&&t)return{...d,mode:"enter",localProgress:u};const n=Math.max(r,1),i=l*e.sceneTransitionDuration;return{...d,mode:"outgoing",localProgress:vt(i/n,0,1)}}return t?{...d,mode:"enter",localProgress:u}:{...d,mode:"rest",projectedSceneElapsedMs:c,localProgress:1}}return("forward"===i&&1===e.sceneOffset||"backward"===i&&-1===e.sceneOffset)&&(e.isDragging||l>It)?{...d,mode:"enter",localProgress:u}:{...d,mode:"hidden",projectedSceneElapsedMs:0,localProgress:0}}(e,t,n,r);return a?{...o,mode:"hidden",localProgress:0,projectedSceneElapsedMs:0}:i?{...o,mode:"rest",localProgress:1,projectedSceneElapsedMs:o.sceneTimelineDurationMs}:o}function jt(e,t,n){return e?function(e,t,n){const r=xt(t.enterInitial,n,Rt(n,"initial")),i=xt(t.enterAnimate,n,Rt(n,"animate"));switch(e.mode){case"rest":default:return i;case"hidden":return r;case"enter":return St(r,t.enterAnimate,n,Rt(n,"animate"),e.localProgress);case"outgoing":return 0===Object.keys(t.exitTarget).length?i:"forward"===e.direction?St(i,t.exitTarget,n,Rt(n,"exit"),e.localProgress):St(r,t.enterAnimate,n,Rt(n,"animate"),1-e.localProgress)}}(e,t,n):xt(t.enterAnimate,n,Rt(n,"animate"))}var Vt=new WeakMap,Lt=new WeakMap;function Ot(e,t){return"entered"===e&&t}function $t(e,t,n,r){return void 0===e?t:n+(r-n)*vt(e,0,1)}function Ft(e,t,n){return bt(Mt(t.initial,n,Rt(n,"initial")),Mt(t.animate,n,Rt(n,"animate")),e)}function zt(e,t,n){const r=wt(Rt(n,"animate"),0),i=wt(Mt(t.initial,n,Rt(n,"initial")),r);return i+(wt(Mt(t.animate,n,Rt(n,"animate")),r)-i)*e}function Nt(e,t){switch(e){case"hidden":default:return"idle";case"outgoing":return"exiting";case"rest":return"entered";case"enter":return t>=.999?"entered":"entering"}}function Bt(e){return e<=0?0:e>=1?1:e}function qt(e,t){return{enterProgress:Bt(t),phase:e}}function Ut(e,t){const n=t<=0?0:t>=1?1:t;return{enterProgress:n,phase:Nt(e,n)}}var Yt={enterProgress:0,phase:"idle"};function Ht({signedVisual:e,phaseMotion:i,render:a}){const[o,s]=(0,t.useState)(()=>qt(i.get(),e.get()));return(0,n.useMotionValueEvent)(e,"change",e=>{s(qt(i.get(),e))}),(0,n.useMotionValueEvent)(i,"change",t=>{s(qt(t,e.get()))}),(0,r.jsx)(r.Fragment,{children:a(o)})}function Wt({visualState:e,render:i}){const[a,o]=(0,t.useState)(()=>{const t=e.get();return t?Ut(t.mode,t.localProgress):Yt});return(0,n.useMotionValueEvent)(e,"change",e=>{o(e?Ut(e.mode,e.localProgress):Yt)}),(0,r.jsx)(r.Fragment,{children:i(a)})}function Xt(e){if("string"==typeof e){const t=n.motion[e];if(t)return t}return n.motion.div}function Kt(e,t,n){return"last"===n?t-1-e:"center"===n?Math.abs(e-(t-1)/2):e}function Gt(e){return t.Children.toArray(e.props.children).filter(t.isValidElement)}function _t(e){return Gt(e).length}function Zt(e,t,n,r,i,a="animate"){const o=e[a]?.transition?.duration,s="number"==typeof o&&Number.isFinite(o)?Math.max(1e3*o,0):Math.max(t,0),c=Math.max(n,0);let l=0;for(let e=0;e<i;e+=1)l=Math.max(l,Kt(e,i,r));const u=l*c;return{itemDurationMs:s,tailDurationMs:u,effectiveDurationMs:Math.max(t,u+s)}}function Jt(e,t,n,r,i){return Zt(e,t??0,n,r,_t(i)).effectiveDurationMs}function Qt(e,r){const i=r(e.get()),a=(0,t.useRef)(i),[o,s]=(0,t.useState)(()=>({phase:i,revision:0}));return(0,n.useMotionValueEvent)(e,"change",e=>{const t=r(e);t!==a.current&&(a.current=t,s(e=>({phase:t,revision:e.revision+1})))}),[o.phase,o.revision]}function en(e,n,r=0){const i=(0,t.useRef)(Math.max(n,0)),[a,o]=(0,t.useState)(null);return(0,t.useEffect)(()=>{i.current=Math.max(n,0)},[n]),(0,t.useEffect)(()=>{if("animate"!==e)return;const t=i.current;if(0===t)return void o(r);const n=window.setTimeout(()=>o(r),t);return()=>window.clearTimeout(n)},[e,r]),"animate"===e&&a===r}function tn(e,n,i,a,o,s,c,l,u=!1){const d=t.Children.toArray(e.props.children),f=Gt(e).length,g=Math.max(i,0)/1e3,m="boolean"==typeof o?o?"animate":"initial":o,p=n.animate.transition??{},h={initial:n.initial,animate:e=>({...n.animate,transition:u?{...p,duration:0,delay:0}:{...p,...void 0===p.duration&&void 0!==s?{duration:Math.max(s,0)/1e3}:{},delay:Kt(e,f,a)*g}}),exit:e=>{const t=c?.exit??n.initial,r=t.transition??{};return{...t,transition:{...r,...void 0===r.duration&&void 0!==l?{duration:Math.max(l,0)/1e3}:{},delay:Kt(e,f,a)*g}}}};let v=0;const y=d.map((e,n)=>{if(!(0,t.isValidElement)(e))return e;const i=v;v+=1;const a=Xt(e.type);return(0,r.jsx)(a,{custom:i,variants:h,className:e.props.className,style:e.props.style,children:e.props.children},e.key??n)}),b=Xt(e.type),{children:S,...x}=e.props;return(0,r.jsx)(b,{...x,initial:"initial",animate:m,variants:{initial:{},animate:{},exit:{}},children:y})}function nn({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,exitVariant:o,exitItemDurationMs:s,signedVisual:c}){const[l,u]=Qt(c,e=>e>0?"animate":e<0&&o?"exit":"initial");return tn(e,t,n,r,l,i,o,s,en(l,a??Jt(t,i,n,r,e),u))}function rn({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,phaseMotion:o,staticReveal:s}){const[c,l]=Qt(o,e=>"entering"===e||"entered"===e?"animate":"initial"),u=en(c,a??Jt(t,i,n,r,e),l);return tn(e,t,n,r,c,i,void 0,void 0,s||u)}function an({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,exitVariant:o,exitItemDurationMs:s,visualState:c}){const[l,u]=Qt(c,e=>"outgoing"===e?.mode&&o?"exit":e&&("enter"===e.mode&&e.localProgress>0||"rest"===e.mode)?"animate":"initial");return tn(e,t,n,r,l,i,o,s,en(l,a??Jt(t,i,n,r,e),u))}var on=(0,t.createContext)(null);function sn({value:e,children:t}){return(0,r.jsx)(on.Provider,{value:e,children:t})}function cn(){const e=(0,t.useContext)(on);if(!e)throw new Error("useAnimateTimeline must be used inside an <Animate> child.");return e}var ln=Object.freeze({progress:0,signedProgress:0,phase:"idle",source:"idle"});function un(e,t){if(!t)return"idle";switch(e?.dragTransaction?.phase){case"driving":return"gesture";case"settling":case"bouncing":return"continuation";case"programmatic":return"programmatic"}return"settle"===e?.dragRelease?.mode||"bounce"===e?.dragRelease?.mode?"continuation":"enter"===e?.dragRelease?.mode||e?.firstSceneEnterActive?"programmatic":"idle"}var dn=(0,t.createContext)(null),fn=(0,t.createContext)(null),gn=(0,t.createContext)(null);function mn(e){if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function pn(e,t,n,r){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1}else if(!mn(e)||!mn(t))return!1;const i=e,a=t,o=n.get(i),s=r.get(a);if(o||s)return o===a&&s===i;n.set(i,a),r.set(a,i);try{if(Array.isArray(e)&&Array.isArray(t))return e.every((e,i)=>pn(e,t[i],n,r));const i=e,a=t,o=Object.keys(i).sort(),s=Object.keys(a).sort();if(o.length!==s.length)return!1;for(let e=0;e<o.length;e+=1){const t=o[e];if(t!==s[e]||!pn(i[t],a[t],n,r))return!1}return!0}finally{n.delete(i),r.delete(a)}}function hn(e){const n=(0,t.useRef)(e);return pn(n.current,e,new WeakMap,new WeakMap)||(n.current=e),n.current}var vn=(0,t.createContext)(null),yn=Object.freeze({opacity:1}),bn=0,Sn=({enterAnimation:e,exitAnimation:i,loopAnimation:a,animateId:o,duration:s,timeline:c,visibility:l,stagger:u,enterRef:d,exitRef:f,children:g})=>{const m=(0,t.useRef)(o||"animate-"+ ++bn).current,p=(0,t.useContext)(vn),h=oe(),y=h?.reportError,b=!0===h?.prefersReducedMotion,S=(0,t.useContext)(dn),x=(0,t.useContext)(gn),[w,R]=(0,t.useState)(null),[M,C]=(0,t.useState)(null),[k,P]=(0,t.useState)(null),[I,E]=(0,t.useState)(0),A=(0,t.useRef)(0),D=(0,t.useRef)(null),T=(0,t.useRef)(new Set),j=(0,t.useRef)(null),V=(0,t.useRef)(new Set),L=hn(e),O=hn(i),$=hn(a),F=(0,n.useAnimation)(),z=(0,n.useAnimation)(),N=(0,t.useMemo)(()=>function({duration:e,timeline:t,visibility:n}){return{duration:{enter:e?.enter??600,exit:e?.exit??600},timeline:{driver:t?.driver??"scene",delay:t?.delay??0,after:t?.after,phase:{start:t?.phase?.start,end:t?.phase?.end}},visibility:{replay:n?.replay??!0,enterMargin:n?.enterMargin,exitMargin:n?.exitMargin}}}({duration:s,timeline:c,visibility:l}),[s,c,l]),B=p?.mode??h?.mode??"drag",q="drag"===B&&"clock"===N.timeline.driver,U=(0,t.useRef)(null),Y="drag"===B&&p?.isActive?p.activationToken??0:0;(null===U.current||U.current.mode!==B||U.current.token!==Y||0===Y&&U.current.arrival!==q)&&(U.current={token:Y,mode:B,arrival:q});const H="drag"===B&&U.current.arrival,W=p?.beginPreparation,X=p?.declareAnimateLane,K=(0,t.useMemo)(()=>{const{driver:e,...t}=N.timeline;return{...t,lane:"scroll"===B&&"scene"===e&&x?"scroll":"visibility"}},[x,B,N.timeline]),G=N.duration.enter,_=N.duration.exit,Z=K.delay,J=K.after,Q=(0,t.useContext)(fn),ee=H&&p?.isActive?p.activationToken??0:0,te=I>0&&D.current?.enterAnimation===L&&D.current?.exitAnimation===O&&D.current?.loopAnimation===$,ne=(0,t.useRef)(null),re=ne.current;H&&(0===ee||null===re||re.token!==ee)&&(ne.current={token:ee,ready:te,enterVariant:te?w:null,exitVariant:te?M:null,infiniteVariant:te?k:null,hasAuthoredEnterAnimation:!!L,enterDuration:G,exitDuration:_,delay:Z,stagger:u,enterAnimation:L,exitAnimation:O,loopAnimation:$});const ie=H?ne.current:null;ie&&!ie.ready&&I>0&&D.current?.enterAnimation===ie.enterAnimation&&D.current?.exitAnimation===ie.exitAnimation&&D.current?.loopAnimation===ie.loopAnimation&&(ie.ready=!0,ie.enterVariant=w,ie.exitVariant=M,ie.infiniteVariant=k);const ae=ie?ie.enterAnimation:L,se=ie?ie.exitAnimation:O,ce=ie?ie.loopAnimation:$,le=ie?.ready?ie.enterVariant:H?null:w,ue=ie?.ready?ie.exitVariant:H?null:M,de=ie?.ready?ie.infiniteVariant:H?null:k,fe=ie?.enterDuration??G,ge=ie?.exitDuration??_,me=ie?.delay??Z,pe=ie?ie.stagger:u;(0,t.useEffect)(()=>{if(!H)return;const e=X?.(m,"visibility");return()=>e?.dispose()},[X,m,H]),(0,t.useEffect)(()=>{if(!H)return;const e=(e,t)=>{const n=`${m}:${e}`;T.current.has(n)||(T.current.add(n),y?.({code:"INVALID_ANIMATION",message:t,context:{componentId:m,field:e,lane:"visibility",mode:"drag"}}))};J&&e("after",`Animate "${m}" ignores after in drag mode when timeline.driver is 'clock'.`),O&&e("exitAnimation",`Animate "${m}" ignores exitAnimation in drag mode when timeline.driver is 'clock'.`)},[m,H,J,y,O]);const he="function"==typeof g,ve=!(!ae&&!ce||(H?ie?.ready??te:te)||le||ue||de),ye="drag"===B?!H:"scroll"===K.lane,be="scroll"===B&&!ye,Se=(0,t.useRef)(new Set);(0,t.useEffect)(()=>{if(!d&&!f)return;const e=(e,t)=>{const n=`${m}:${e}`;Se.current.has(n)||(Se.current.add(n),y?.({code:"INVALID_ANIMATION",message:t,context:{componentId:m,field:e,mode:B,scrub:ye}}))};if(ye){const t="drag"===B?"the Scene element track (drag)":"the zone scroll budget (scroll takeover)";return d&&e("enterRef",`Animate "${m}" ignores enterRef: this element is driven by ${t}, whose progress has a single owner. Use timeline.driver:'clock' (drag) or move it outside the takeover zone (scroll) for manual control.`),void(f&&e("exitRef",`Animate "${m}" ignores exitRef: this element is driven by ${t}, whose progress has a single owner. Use timeline.driver:'clock' (drag) or move it outside the takeover zone (scroll) for manual control.`))}H&&f&&e("exitRef",`Animate "${m}" ignores exitRef in drag mode when timeline.driver is 'clock': this lane has no exit pass (it also ignores exitAnimation).`)},[d,f,m,H,ye,B,y]);const xe=H?pe:u,we=xe&&!he&&le&&(0,t.isValidElement)(g)?g:null,Re=!!we,Me=xe?.each??40,Ce=xe?.from??"first",ke=(0,t.useMemo)(()=>we&&le?Zt(le,fe,Me,Ce,_t(we)):null,[fe,le,we,Me,Ce]),Pe=(0,t.useMemo)(()=>we&&ue?Zt(ue,ge,Me,Ce,_t(we),"exit"):null,[ge,ue,we,Me,Ce]),Ie=ke?.effectiveDurationMs??fe,Ee=Pe?.effectiveDurationMs??ge,Ae=(0,t.useMemo)(()=>S?{...S,zoneStates:Q?.zoneStates??{},store:Q?.store}:null,[S,Q?.store,Q?.zoneStates]);(0,t.useEffect)(()=>{const e=V.current,t=++A.current,n=()=>A.current===t;j.current?.lease.cancel(),j.current=null;const r="drag"!==B||H?void 0:W?.();r&&e.add(r),j.current=r?{generation:t,lease:r}:null;const i=e=>{n()&&y?.(e)};return R(null),C(null),P(null),E(0),ae||ce?((async()=>{const[e,n,r]=await Promise.all([gt(ae,m,"enter",i),gt(se,m,"exit",i),gt(ce,m,"loop",i)]);A.current===t&&(D.current={enterAnimation:ae,exitAnimation:se,loopAnimation:ce},R(e??null),C(n??null),P(r??null),E(t))})(),()=>{e.forEach(e=>e.cancel()),e.clear(),n()&&(A.current+=1)}):(y?.({code:"INVALID_ANIMATION",message:`Animate "${m}" requires enterAnimation or loopAnimation.`,context:{componentId:m,hasExitAnimation:!!se}}),(()=>{const n=j.current;!n||n.generation!==t||(n.lease.complete(),e.delete(n.lease),j.current=null)})(),()=>{e.forEach(e=>e.cancel()),e.clear(),n()&&(A.current+=1)})},[m,B,H,y,W,ae,se,ce]),(0,t.useEffect)(()=>{!H||0===ee||!ie||(ie.enterAnimation!==L||ie.exitAnimation!==O||ie.loopAnimation!==$)&&Promise.all([gt(L,m,"enter"),gt(O,m,"exit"),gt($,m,"loop")])},[ie,ee,m,H,L,O,$]);const De=function({sceneContext:e,enterVariant:r,exitVariant:i,componentId:a,delay:o,enterDuration:s,exitDuration:c,after:l,variantsPending:u=!1}){const d=e?At(e):null,f=d?.registrySnapshot.registrations.get(a),g=d?.enterVariantsByAnimateId.get(a)??null,m=!(!d||f&&g),p=f?.duration??s,h=d?.registrySnapshot.calculatedDelays.get(a)??0,v=g??r,y=(0,t.useRef)(h),b=(0,t.useRef)(d);b.current=d;const S=(0,t.useRef)({enterInitial:v?.initial||{},enterAnimate:v?.animate||{},exitTarget:i?.exit||{}}),x=e?Tt(e,y.current,p,c,m,u):null,w=x?"outgoing"===x.mode?("forward"===x.direction?1:-1)*x.localProgress:x.localProgress:0,R=(0,n.useMotionValue)(w),M=(0,n.useMotionValue)(x),[C,k]=(0,t.useState)(!1),P=((0,t.useRef)(null),(0,t.useRef)(null)),I=(0,t.useRef)(null);(0,t.useRef)({identity:null,categories:new Set}),(0,t.useEffect)(()=>{},[a,o,s,r,g,f,m,d,e?.isActive,e?.sceneOffset,l]),(0,t.useEffect)(()=>{S.current={enterInitial:v?.initial||{},enterAnimate:v?.animate||{},exitTarget:i?.exit||{}},d&&(y.current=h)},[i,h,d,v]),(0,t.useEffect)(()=>{const t=e?.registerAnimate,n=e?.unregisterAnimate,i=e?.getCalculatedDelay;if(!t||!i||!r)return;const c=t(a,{delay:o,duration:s,after:l,lane:"drag"});return c?.setEnterVariant?.(r),b.current||(y.current=c?.getCalculatedDelay?.()??i(a)),()=>{c?.dispose?c.dispose():n?.(a)}},[e?.registerAnimate,e?.unregisterAnimate,e?.getCalculatedDelay,r,a,o,s,l]),(0,t.useEffect)(()=>{if(!e)return;const t=()=>{if(d)y.current=h;else{const t=e.getCalculatedDelay?.(a);"number"==typeof t&&(y.current=t)}const t=Tt(e,y.current,p,c,m,u),n="outgoing"===t.mode?("forward"===t.direction?1:-1)*t.localProgress:t.localProgress,r=[t.mode,t.direction,e.sceneOffset,e.isActive?"active":"inactive",e.isDragging?"dragging":"idle"].join(":"),i=P.current!==r;if(R.set(n),M.set(t),P.current=r,i&&(t.mode,t.direction,e.sceneOffset,e.isActive,e.isDragging,e.sceneState,Et(e).toFixed(3),t.transitionProgress.toFixed(3),t.sharedElapsedMs.toFixed(1),t.projectedSceneElapsedMs.toFixed(1),t.sharedTimelineDurationMs,t.sceneTimelineDurationMs,t.localProgress.toFixed(3),y.current),"enter"===t.mode){const n=t.localProgress<=.001?"before-delay":t.localProgress>=.999?"enter-complete":"enter-active";I.current!==`${t.mode}:${n}`&&(t.mode,t.sharedElapsedMs.toFixed(1),t.projectedSceneElapsedMs.toFixed(1),t.sharedTimelineDurationMs,t.sceneTimelineDurationMs,t.transitionProgress.toFixed(3),y.current,t.localProgress.toFixed(3),Et(e).toFixed(3),e.sceneOffset,I.current=`${t.mode}:${n}`)}};t();const n=[e.sharedElapsedMotion?.on("change",t),e.renderProgressMotion?.on("change",t)].filter(e=>"function"==typeof e);return()=>{n.forEach(e=>e())}},[e,R,M,a,s,c,m,u,h,p,d,e?.renderProgressMotion,e?.renderProgress,e?.isDragging,e?.isActive,e?.sceneOffset,e?.sceneState,e?.dragRelease,e?.firstSceneEnterActive]);const E=Pt(M,S,jt);return(0,t.useEffect)(()=>{if(!e)return void k(!1);const t=()=>{const t=Tt(e,y.current,p,c,m,u);k(e.isActive&&0===e.sceneOffset&&!e.isDragging&&("rest"===t.mode||"enter"===t.mode)&&t.localProgress>=.999)};t();const n=[e.sharedElapsedMotion?.on("change",t),e.renderProgressMotion?.on("change",t)].filter(e=>"function"==typeof e);return()=>{n.forEach(e=>e())}},[e,p,m,u,c,e?.isActive,e?.sceneOffset,e?.isDragging,e?.renderProgressMotion,e?.renderProgress,e?.dragRelease,e?.firstSceneEnterActive]),{style:E.style,opacity:E.opacity,x:E.x,y:E.y,scale:E.scale,rotate:E.rotate,useInteractiveStyles:!0,shouldRunInfinite:C,visualState:M}}({sceneContext:"drag"!==B||H?null:p,enterVariant:w,exitVariant:M,componentId:m,delay:Z,enterDuration:Ie,exitDuration:Ee,after:J,variantsPending:ve}),Te=function({enabled:e,sceneContext:r,enterVariant:i,hasAuthoredEnterAnimation:a,parseReady:o,delay:s,enterDuration:c,enterRef:l}){const u=(0,t.useRef)({initial:{},animate:{}}),d=!!l&&s<=0,f=(0,t.useRef)({delay:s,enterDuration:c,hasAuthoredEnterAnimation:a,parseReady:o,enterVariant:i,autoEnterSuppressed:d});f.current={delay:s,enterDuration:c,hasAuthoredEnterAnimation:a,parseReady:o,enterVariant:i,autoEnterSuppressed:d};const g=(0,n.useMotionValue)(a?0:1),m=(0,n.useMotionValue)(a?"idle":"entered"),[p,h]=(0,t.useState)(!1),[v,y]=(0,t.useState)(!1),b=(0,t.useRef)(null),S=(0,t.useRef)(null),x=(0,t.useRef)(0),w=(0,t.useRef)(0),R=(0,t.useRef)(null),M=(0,t.useRef)(!1),C=(0,t.useRef)(0===(r?.activationToken??0)),k=(0,t.useRef)(r);k.current=r;const P=(0,t.useCallback)(()=>{b.current?.stop(),b.current=null,null!==S.current&&(clearTimeout(S.current),S.current=null)},[]),I=(0,t.useCallback)(()=>{const e=f.current;P(),x.current=0,w.current=0,R.current=null,M.current=!1,h(!1),y(!1),m.set(e.hasAuthoredEnterAnimation?"idle":"entered"),g.set(e.hasAuthoredEnterAnimation?0:1)},[m,P,g]),E=(0,t.useCallback)((e,t)=>{const r=k.current,i=f.current;if(!r?.isActive||(r.activationToken??0)!==e||e<=0)return;if(i.hasAuthoredEnterAnimation&&!i.parseReady)return void(w.current=e);if(x.current===e)return;w.current=0,x.current=e,P(),R.current=null,h(!1),u.current={initial:i.enterVariant?.initial??{},animate:i.enterVariant?.animate??{}};const a="static"===t&&C.current;y(a);const o=()=>{const t=k.current;return!(!t?.isActive||(t.activationToken??0)!==e)},s=()=>{o()&&h(!0)};if(!i.hasAuthoredEnterAnimation||null===i.enterVariant||a)return m.set("entered"),g.set(1),void(()=>{const e=Math.max(i.delay,0);e<=0?s():S.current=setTimeout(()=>{S.current=null,s()},e)})();m.set("waiting"),g.set(0);const c=()=>{if(S.current=null,!o())return;m.set("entering");const e=Math.max(i.enterDuration,0);if(e<=0)return m.set("entered"),g.set(1),void h(!0);b.current=(0,n.animate)(g,1,{duration:e/1e3,ease:"easeInOut",onComplete:()=>{b.current=null,o()&&(m.set("entered"),g.set(1),h(!0))}})},l=Math.max(i.delay,0);if(i.autoEnterSuppressed)return R.current=c,void(M.current&&(M.current=!1,R.current=null,c()));l>0?S.current=setTimeout(c,l):c()},[m,P,g]),A=e&&r?.isActive?r.activationToken??0:0,D=r?.activationKind??null;(0,t.useEffect)(()=>{A<=0?I():E(A,D)},[D,A,I,E]),(0,t.useEffect)(()=>{const e=w.current;e<=0||!o||E(e,k.current?.activationKind??null)},[i,o,E]),(0,t.useEffect)(()=>()=>{P(),x.current=0,w.current=0},[P]);const T=(0,t.useCallback)(()=>{const e=R.current;e?(R.current=null,M.current=!1,null!==S.current&&(clearTimeout(S.current),S.current=null),e()):M.current=!0},[]);return(0,t.useEffect)(()=>{if(l&&e)return l.current=T,()=>{l.current===T&&(l.current=null)}},[e,l,T]),{style:Pt(g,u,Ft,zt).style,visualMotion:g,phaseMotion:m,shouldRunInfinite:p,staticReveal:v}}({enabled:H,sceneContext:"drag"===B?p:null,enterVariant:le,hasAuthoredEnterAnimation:ie?.hasAuthoredEnterAnimation??!!e,parseReady:ie?.ready??I>0,delay:me,enterDuration:Ie,enterRef:H?d:void 0}),je=function({sceneContext:e,zoneRuntime:r,zoneId:i,enterVariant:a,exitVariant:o,hasAuthoredEnterAnimation:s,hasAuthoredExitAnimation:c,hasInfiniteAnimation:l=!1,componentId:u,duration:d,timeline:f,visibility:g,globalEnterMargin:m,globalExitMargin:p,enterRef:h,exitRef:y,variantsPending:b=!1}){const S=d.enter,x=d.exit,w=!0===oe()?.prefersReducedMotion,R=w?0:S,M=w?0:x,C=f.delay,k=f.after,P="scroll"===f.lane,I=f.phase?.start,E=f.phase?.end,A=g.replay,D=v()?.scale??1,T=g.enterMargin??m??50,j=g.exitMargin??p??50,V=Math.max(0,T*D),L=Math.max(0,j*D),O=(0,t.useRef)({enterInitial:{},enterAnimate:{},exitTarget:{}}),$=(0,n.useMotionValue)(0),F=(0,n.useMotionValue)(i&&r?r.store?.getKeySnapshot(i)??r.zoneStates[i]??null:null),[z,N]=(0,t.useState)(!1),B=(0,t.useRef)(null),[q,U]=(0,t.useState)(0),Y=r?.registerZoneAnimation,H=r?.unregisterZoneAnimation,W=!!(a?.animate&&Object.keys(a.animate).length>0)||!!s,X=function(e,t){return!!(t>0&&e?.exit&&Object.keys(e.exit).length>0)}(o,x)||!!c;(0,t.useEffect)(()=>{O.current={enterInitial:a?.initial||{},enterAnimate:a?.animate||{},exitTarget:o?.exit||{}}},[a,o]);const K=(0,t.useRef)("idle"),G=(0,n.useMotionValue)("idle"),_=(0,t.useCallback)(e=>{K.current=e,G.set(e)},[G]),Z=(0,t.useRef)(null),J=(0,t.useRef)(null),Q=(0,t.useRef)(0),ee=(0,t.useRef)(!1),te=(0,t.useRef)(null),ne=(0,t.useRef)(null),re=(0,t.useRef)(null),ie=(0,t.useRef)(()=>{}),ae=(0,t.useRef)(0),se=(0,t.useRef)(null),ce=(0,t.useRef)(!1),le=(0,t.useRef)(!1),ue=(0,t.useRef)(!1),de=(0,t.useCallback)(()=>r&&i?r.store?.getKeySnapshot(i)??r.zoneStates[i]??null:null,[i,r]);(0,t.useEffect)(()=>{if(!P||!r||!i)return void F.set(null);const e=()=>{F.set(de())};return e(),r.store?.subscribeKey(i,e)},[P,de,i,r,F]);const fe=!!h&&!P&&!(k||C>0),ge=!!y&&!P,me=(0,t.useRef)(!1),pe=(0,t.useRef)(!1),he=(0,t.useCallback)(e=>{e?.publishEnterCompleted()},[]),ve=(0,t.useCallback)(()=>{ae.current+=1,se.current=null,te.current&&(clearTimeout(te.current),te.current=null),ne.current&&(ne.current(),ne.current=null),re.current&&(re.current(),re.current=null)},[]),ye=(0,t.useCallback)(()=>{Q.current+=1,J.current&&(J.current.stop(),J.current=null),ve()},[ve]),be=(0,t.useCallback)(()=>{const e=B.current?.ownerDocument?.defaultView;e&&(re.current?.(),re.current=function(e,t){let n=Lt.get(e);if(!n){const t=e.requestAnimationFrame?.bind(e)??(t=>e.setTimeout(()=>t(Date.now()),16)),r=e.cancelAnimationFrame?.bind(e)??(t=>e.clearTimeout(t));n={callbacks:new Map,frame:null,requestFrame:t,cancelFrame:r},Lt.set(e,n)}const r=n,i=r.callbacks.get(t)??{callback:t,cancelled:!1};return r.callbacks.set(t,i),null===r.frame&&(r.frame=r.requestFrame(()=>{r.frame=null;const t=[...r.callbacks.values()];r.callbacks.clear(),t.forEach(e=>{e.cancelled||e.callback()}),0===r.callbacks.size&&null===r.frame&&Lt.get(e)===r&&Lt.delete(e)})),()=>{i.cancelled=!0,r.callbacks.get(t)===i&&r.callbacks.delete(t),0===r.callbacks.size&&null!==r.frame&&(r.cancelFrame(r.frame),r.frame=null,Lt.get(e)===r&&Lt.delete(e))}}(e,()=>{re.current=null,ie.current()}))},[]),Se=(0,t.useCallback)(()=>{ve(),_("entering"),$.get()<0&&$.set(0);const e=Z.current,t=++Q.current,r=(0,n.animate)($,1,{duration:Math.max(R,0)/1e3,ease:"easeInOut",onComplete:()=>{Q.current===t&&(J.current=null,_("entered"),he(e),be())}});J.current=r},[ve,R,he,be,_,$]),xe=(0,t.useCallback)((e=!1)=>{const t=K.current,n="exited"===t?"exited":"exiting"===t?"exiting":"idle";ye();const r={token:++ae.current,origin:n,dependencyReady:!k,delayStarted:!1,delayReady:!1,coldStartBypass:e};se.current=r,_("waiting"),N(!1);const i=e=>{se.current?.token!==r.token||"pending"===e.kind||(r.dependencyReady=!0,ne.current=null,be())};if(!k)return;const a=Z.current;a?ne.current=a.observeAfter(i):i({kind:"invalid",leaderId:k,reason:"missing"})},[be,_,ye,k]),we=(0,t.useCallback)(()=>{const e=se.current;if(e&&e.dependencyReady){if(!e.delayStarted){if(e.delayStarted=!0,C>0){const t=e.token;return void(te.current=setTimeout(()=>{te.current=null,se.current?.token===t&&(e.delayReady=!0,be())},C))}e.delayReady=!0}e.delayReady&&Se()}},[C,Se,be]),Re=(0,t.useCallback)(()=>{ye(),_("exiting"),N(!1),$.get()>=0&&$.set(-1e-6);const e=++Q.current,t=(0,n.animate)($,-1,{duration:Math.max(M,0)/1e3,ease:"easeInOut",onComplete:()=>{Q.current===e&&(J.current=null,_("exited"))}});J.current=t},[M,ye,_,$]),Me=(0,t.useCallback)(t=>{if(P||b)return;const n=B.current;if(!(n instanceof HTMLElement))return;const r=e?.firstSceneEnterGateKnown,i=e?.firstSceneEnterReady,a=e?.firstSceneEnterActive;if(!1===r)return ye(),_("idle"),$.set(0),void N(!1);if(!1===i&&!0===a)return le.current=!1,ye(),_("idle"),$.set(0),void N(!1);const o=!1===i&&!1===a&&!le.current&&!fe;o&&(le.current=!0,ce.current=!0,ye(),_("entered"),$.set(1),he(Z.current));const s=n.getBoundingClientRect();if(!(s.width>0||s.height>0||s.bottom!==s.top))return;const c=n.closest('[data-cineview-container="true"]'),l=t?.top??(c?c.getBoundingClientRect().top:0),u=(t?.height??c?.clientHeight??0)||window.innerHeight||1,d=s.top-l,f=s.bottom-l,g=Math.max(s.height,f-d,0)>u-V,m=g?d<=u/2:d>=0&&f<=u-V,p=g?f<=.7*u:d<=L||f>=u-L,h=g?m&&!p:m,v=f<=0,y=f>0&&d<u;if(o)return v&&(ue.current=!1),void N(Ot("entered",y));if(!ce.current){if(ce.current=!0,fe)return void N(!1);if(v)return ye(),_("entered"),$.set(1),he(Z.current),N(Ot("entered",!1)),void(ue.current=!1);if(!0===i&&!g&&d>=0&&f<=u)return xe(!0),void we()}if("waiting"===K.current){const e=se.current;if(e&&(!0===e?.coldStartBypass&&!0===i&&!g&&d>=0&&f<=u||h&&!p))we();else{const t=e?.origin??"idle";ve(),_(t)}}else{const e=function(e,t,n,r){switch(e){case"idle":return t&&!n?"enter":null;case"entering":case"entered":return n&&!t&&r.hasExplicitExit?"exit":null;case"exiting":case"exited":return t&&!n&&r.replay?"enter":null;default:return null}}(K.current,h,p,{hasExplicitExit:X,replay:A});y&&!ue.current&&(ue.current=!0),"enter"!==e||fe||me.current||pe.current?"exit"===e&&!ge&&(!ue.current&&v||Re()):(xe(),we())}N(Ot(K.current,y))},[we,fe,ge,xe,ve,V,L,X,P,he,A,Re,e?.firstSceneEnterGateKnown,e?.firstSceneEnterActive,e?.firstSceneEnterReady,_,ye,b,$]);ie.current=Me;const Ce=(0,t.useCallback)(()=>{me.current=!0,pe.current=!1,ce.current=!0,le.current=!0,Se()},[Se]),ke=(0,t.useCallback)(()=>{pe.current=!0,Re()},[Re]);(0,t.useEffect)(()=>{if(h&&!P)return h.current=Ce,()=>{h.current===Ce&&(h.current=null)}},[h,P,Ce]),(0,t.useEffect)(()=>{if(y&&!P)return y.current=ke,()=>{y.current===ke&&(y.current=null)}},[y,P,ke]),(0,t.useEffect)(()=>{const t=e?.registerAnimate,n=e?.unregisterAnimate;if(!t||!W&&!X)return;const r=t(u,{delay:C,duration:W?S:x,after:k,lane:P?"scroll":"visibility"});return Z.current=r??null,ee.current=!1,()=>{ve(),Z.current===r&&(Z.current=null),r?.dispose?r.dispose():n?.(u)}},[e?.registerAnimate,e?.unregisterAnimate,ve,u,C,S,x,k,W,X,P]),(0,t.useEffect)(()=>{if(typeof document>"u"||b||B.current?.isConnected)return;const e=document.querySelector(`[data-cineview-animate-host="${u}"]`)??document.querySelector(`[data-cineview-animate-id="${u}"]`);e instanceof HTMLElement&&B.current!==e&&(B.current=e,U(e=>e+1))},[u,a,o,b]),(0,t.useEffect)(()=>{if(!(P&&Y&&H&&i&&(W||X)))return;const e=Y(i,{animateId:u,delay:C,enterDuration:S,exitDuration:X?x:0,after:k,...void 0!==I||void 0!==E?{phase:{start:I,end:E}}:{}});return()=>{H(i,u,e)}},[u,C,S,x,X,W,P,E,I,i,k,Y,H]);const Pe=(0,t.useCallback)(e=>{if(!W&&!X)return"entered"!==K.current&&_("entered"),void(1!==$.get()&&$.set(1));if(!r||!i)return void(0!==$.get()&&$.set(0));const t=e?.sequence.budgets[u];if(!e||!t)return void(0!==$.get()&&$.set(0));const n=vt(e.progressPx,0,e.totalBudgetPx),a=t.enterStartPx,o=Math.max(t.enterEndPx,t.enterStartPx+1),s="number"==typeof t.phaseStartPx?t.phaseStartPx:$t(I,a,a,o),c=Math.max("number"==typeof t.phaseEndPx?t.phaseEndPx:$t(E,o,a,o),s+1);if(n>=c&&!ee.current&&(ee.current=!0,he(Z.current)),n<=s)return void(0!==$.get()&&$.set(0));if(!t.hasExit)return n>=c?void(1!==$.get()&&$.set(1)):void $.set(vt((n-s)/Math.max(c-s,1),0,1));const l=t.exitStartPx??c,d=t.exitEndPx??l+1;n<=c?$.set(vt((n-s)/Math.max(c-s,1),0,1)):n<=l?1!==$.get()&&$.set(1):n>=d?-1!==$.get()&&$.set(-1):$.set(-vt((n-l)/Math.max(d-l,1),0,1))},[u,W,X,E,I,he,_,$,i,r]);(0,t.useEffect)(()=>{if(!P)return;const e=()=>Pe(F.get());return e(),W||X?F.on("change",e):void 0},[Pe,W,X,P,F]),(0,t.useEffect)(()=>{P||Me()},[q,P,Me,e?.scrollProgress,e?.scrollTimelineState]),(0,t.useEffect)(()=>{if(P)return;const e=B.current;return e instanceof HTMLElement&&!(typeof window>"u")?function(e,t){const n=function(e){const t=Vt.get(e);if(t)return t;const n=function(e){return typeof window<"u"&&e===window||typeof Window<"u"&&e instanceof Window}(e),r=n?e:e.ownerDocument?.defaultView??window,i=r.requestAnimationFrame?.bind(r)??(e=>r.setTimeout(()=>e(Date.now()),16)),a=r.cancelAnimationFrame?.bind(r)??(e=>r.clearTimeout(e)),o={subscribers:new Set,frame:null,requestFrame:i,cancelFrame:a,schedule:()=>{null===o.frame&&(o.frame=o.requestFrame(()=>{o.frame=null;const t=n?{top:0,height:e.innerHeight||1}:{top:e.getBoundingClientRect().top,height:e.clientHeight||r.innerHeight||1};[...o.subscribers].forEach(e=>e(t))}))},cleanup:()=>{e.removeEventListener("scroll",o.schedule),n||r.removeEventListener("resize",o.schedule),null!==o.frame&&(o.cancelFrame(o.frame),o.frame=null)}};return e.addEventListener("scroll",o.schedule,{passive:!0}),n||r.addEventListener("resize",o.schedule,{passive:!0}),Vt.set(e,o),o}(e);return n.subscribers.add(t),n.schedule(),()=>{n.subscribers.delete(t),0===n.subscribers.size&&(n.cleanup(),Vt.delete(e))}}(e.closest('[data-cineview-container="true"]')??window,Me):void 0},[q,P,Me]),(0,t.useEffect)(()=>ye,[ye]);const Ie=(0,t.useRef)(!1),Ee=(0,t.useCallback)(t=>{if(!(l&&P&&r&&i))return void(Ie.current&&(Ie.current=!1,N(!1)));const n=e?.runtimeState,a=void 0===n||"covered"!==n&&"inactive"!==n&&"parked"!==n&&"exiting"!==n;if(!W&&!X)return void(Ie.current!==a&&(Ie.current=a,N(a)));const o=t?.sequence.budgets[u];if(!t||!o||!a)return void(Ie.current&&(Ie.current=!1,N(!1)));const s=vt(t.progressPx,0,t.totalBudgetPx),c=o.enterStartPx,d=Math.max(o.enterEndPx,o.enterStartPx+1),f="number"==typeof o.phaseStartPx?o.phaseStartPx:$t(I,c,c,d),g=Math.max("number"==typeof o.phaseEndPx?o.phaseEndPx:$t(E,d,c,d),f+1),m=W?s>=g-.5:s>.5,p=!o.hasExit||null===o.exitStartPx||s<=o.exitStartPx+.5,h=m&&p;Ie.current!==h&&(Ie.current=h,N(h))},[u,W,X,l,P,E,I,e?.runtimeState,N,i,r]);return(0,t.useEffect)(()=>{if(P&&l)return Ee(F.get()),W||X?F.on("change",Ee):void 0;Ee(null)},[W,X,l,P,Ee,F]),{style:Pt($,O,(e,t,n)=>function(e,t,n){const r=n>=0,i=r?e.enterAnimate:e.exitTarget;return St(xt(r?e.enterInitial:e.enterAnimate,t,Rt(t,r?"initial":"animate")),i,t,Rt(t,r?"animate":"exit"),r?n:Math.abs(n))}(t,n,e)).style,shouldRunInfinite:z,visualMotion:$,phaseMotion:G}}({sceneContext:"scroll"===B?p:null,zoneRuntime:"scroll"===B?Ae:null,zoneId:x,enterVariant:w,exitVariant:M,hasAuthoredEnterAnimation:!!e,hasAuthoredExitAnimation:!!i,hasInfiniteAnimation:!!k,componentId:m,duration:{enter:Ie,exit:Ee},timeline:K,visibility:N.visibility,globalEnterMargin:h?.scrollEnterMargin,globalExitMargin:h?.scrollExitMargin,enterRef:be?d:void 0,exitRef:be?f:void 0,variantsPending:ve});(0,t.useEffect)(()=>{if("drag"!==B||0===I)return;const e=j.current;!e||e.generation!==I||(e.lease.complete(),j.current=null)},[B,I]);const Ve=function({mode:e,isDragArrival:r,timelineLane:i,sceneContext:a,arrivalVisualMotion:o,arrivalPhaseMotion:s,scrollVisualMotion:c,scrollPhaseMotion:l,dragVisualState:u}){const d=(0,n.useMotionValue)(0),f=(0,n.useMotionValue)(0),g=(0,n.useMotionValue)("idle"),m=(0,n.useMotionValue)(ln);return(0,t.useEffect)(()=>{const t="scroll"===e||r?i:"drag",n=e=>{d.set(e.progress),f.set(e.signedProgress),g.set(e.phase),m.set(e)};if("scroll"===e||r){const e=r?o:c,i=r?s:l,a=()=>{const r=e.get();n({progress:Bt(r),signedProgress:r,phase:i.get(),source:"scroll"===t?"scroll":"visibility"})};a();const u=e.on("change",a),d=i.on("change",a);return()=>{u(),d()}}const p=e=>{if(!e)return void n(ln);const t=Math.max(0,Math.min(1,e.localProgress)),r="outgoing"===e.mode?("forward"===e.direction?1:-1)*t:t;n({progress:t,signedProgress:r,phase:Nt(e.mode,t),source:un(a,e)})};return p(u.get()),u.on("change",p)},[s,o,u,r,e,m,g,d,f,i,a,l,c]),(0,t.useMemo)(()=>({mode:e,lane:"scroll"===e||r?i:"drag",progress:d,signedProgress:f,phase:g,frame:m}),[r,e,m,g,d,f,i])}({mode:B,isDragArrival:H,timelineLane:"scroll"===B||H?K.lane:"drag",sceneContext:p,arrivalVisualMotion:Te.visualMotion,arrivalPhaseMotion:Te.phaseMotion,scrollVisualMotion:je.visualMotion,scrollPhaseMotion:je.phaseMotion,dragVisualState:De.visualState});(0,t.useEffect)(()=>{const e=H?de:k;if("drag"===B&&e){if(b||!(H?Te.shouldRunInfinite:De.shouldRunInfinite))return void F.stop();F.start({...e.animate,transition:{...e.animate.transition||{},repeat:1/0}})}},[Te.shouldRunInfinite,F,De.shouldRunInfinite,k,H,B,b,de]),(0,t.useEffect)(()=>{if("scroll"===B&&k){if(b||!je.shouldRunInfinite)return void z.stop();z.start({...k.animate,transition:{...k.animate.transition||{},repeat:1/0}})}},[B,k,b,je.shouldRunInfinite,z]);const Le=he?g:void 0,Oe=he?null:g,$e=(0,r.jsx)(sn,{value:Ve,children:Re?we&&le?"scroll"===B?(0,r.jsx)(nn,{container:we,variant:le,each:Me,from:Ce,itemDurationMs:ke?.itemDurationMs,effectiveDurationMs:ke?.effectiveDurationMs,exitVariant:ue,exitItemDurationMs:Pe?.itemDurationMs,signedVisual:je.visualMotion}):H?(0,r.jsx)(rn,{container:we,variant:le,each:Me,from:Ce,itemDurationMs:ke?.itemDurationMs,effectiveDurationMs:ke?.effectiveDurationMs,phaseMotion:Te.phaseMotion,staticReveal:Te.staticReveal}):(0,r.jsx)(an,{container:we,variant:le,each:Me,from:Ce,itemDurationMs:ke?.itemDurationMs,effectiveDurationMs:ke?.effectiveDurationMs,exitVariant:ue,exitItemDurationMs:Pe?.itemDurationMs,visualState:De.visualState}):null:Le?"scroll"===B||H?(0,r.jsx)(Ht,{signedVisual:H?Te.visualMotion:je.visualMotion,phaseMotion:H?Te.phaseMotion:je.phaseMotion,render:Le}):(0,r.jsx)(Wt,{visualState:De.visualState,render:Le}):Oe}),Fe=Re?yn:je.style,ze=Re?yn:H?Te.style:De.style;return le||ue||de||ve?"scroll"===B?de?(0,r.jsx)("div",{"data-cineview-animate-host":m,children:(0,r.jsx)(n.motion.div,{style:Fe,className:"cineview-animate","data-cineview-animate-id":m,children:(0,r.jsx)(n.motion.div,{animate:z,children:$e})})}):(0,r.jsx)("div",{"data-cineview-animate-host":m,children:(0,r.jsx)(n.motion.div,{style:Fe,className:"cineview-animate","data-cineview-animate-id":m,children:$e})}):de?(0,r.jsx)(n.motion.div,{style:ze,className:"cineview-animate","data-cineview-animate-id":m,children:(0,r.jsx)(n.motion.div,{animate:F,children:$e})}):(0,r.jsx)(n.motion.div,{style:ze,className:"cineview-animate","data-cineview-animate-id":m,children:$e}):(0,r.jsx)(sn,{value:Ve,children:Le?Le(Yt):Oe})};Sn.displayName="Animate";var xn=(0,t.createContext)({lastX:0,lastY:0}),wn=(0,t.createContext)(null),Rn=(0,t.forwardRef)(function({at:e,x:n,y:a,offsetX:o,offsetY:s,fixed:c=!1,children:l,style:u,className:d,...f},g){const m=v(),p=oe(),h=(0,t.useContext)(xn),y=(0,t.useContext)(wn),b=e?.x??n,S=e?.y??a,x=e?.offsetX??o,w=e?.offsetY??s,R=c,M=e?.anchor,C="center"===M||"center-x"===M,k="center"===M||"center-y"===M,P=R&&"scroll"===p?.mode&&!y,{finalLeft:I,finalTop:E,finalX:A,finalY:D}=(0,t.useMemo)(()=>{const e=m?.convert??(e=>e);if(void 0!==b||void 0!==S){const t=void 0!==b?b:0,n=void 0!==S?S:0;return{finalLeft:e(t),finalTop:e(n),finalX:t,finalY:n}}if(void 0!==x||void 0!==w){const t=h.lastX+(void 0!==x?x:0),n=h.lastY+(void 0!==w?w:0);return{finalLeft:e(t),finalTop:e(n),finalX:t,finalY:n}}return{finalLeft:0,finalTop:0,finalX:0,finalY:0}},[m,h,x,w,b,S]),{leftStyle:T,topStyle:j,centerTransform:V}=(0,t.useMemo)(()=>{const e=m?.convert??(e=>e),t=[];let n=I;if(C){const r=e(b??0);n=0===r?"50%":`calc(50% + ${r}px)`,t.push("translateX(-50%)")}let r=E;if(k){const n=e(S??0);r=0===n?"50%":`calc(50% + ${n}px)`,t.push("translateY(-50%)")}return{leftStyle:n,topStyle:r,centerTransform:t.length>0?t.join(" "):void 0}},[m,C,k,b,S,I,E]),L=(0,t.useMemo)(()=>({lastX:A,lastY:D}),[A,D]),O=(0,t.useMemo)(()=>{const e=[V,u?.transform].filter(Boolean).join(" ")||void 0;return{...u,position:P?"sticky":"absolute",left:T,top:j,pointerEvents:R?u?.pointerEvents??"auto":u?.pointerEvents,transform:e}},[P,R,T,j,V,u]),$=(0,r.jsx)(xn.Provider,{value:L,children:(0,r.jsx)("div",{ref:g,style:O,className:d,...f,children:l})});return R&&y&&!P?(0,i.createPortal)($,y):$});Rn.displayName="Position";var Mn={opacity:1,x:0,y:0,scale:1,rotate:0};function Cn(e,t){return function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}(e)?{...t,...e}:t}function kn(e){return Math.max(0,Math.min(e,1))}function Pn(e,t){return"drag"!==e?"auto":"y"===t?"pan-x pinch-zoom":"pan-y pinch-zoom"}function In({effectiveMode:e,isActive:t,globalScrollTimelineState:n,hasExitAnimation:r}){if("scroll"!==e||!n)return t?1:0;switch(n.phase){case"before":default:return 0;case"enter":return n.enterProgress;case"hold":return 1;case"exit":return r?1-n.exitProgress:1;case"after":return r?0:1}}function En({onVisibilityChange:e,sceneVisibilityCallback:t,sceneIndex:n,visible:r,progress:i}){e?.(r,i),t?.({sceneIndex:n,visible:r,progress:i})}function An({effectiveMode:e,effectiveDirection:t,globalScrollTimelineState:n,globalScrollViewportOffset:r,globalViewportWidth:i,globalViewportHeight:a}){if("scroll"!==e)return{visible:!1,isHorizontal:!1,hostOffset:0,hostSpan:0,clipWidth:0,clipHeight:0};const o=n?.rangeStart??0,s=n?.rangeEnd??o,c="x"===t,l=Math.max(s-o,0),u=Math.max(c?i:a,0),d=o-r,f=s-r,g=Math.max(Math.min(u,Math.max(l,1)),1),m=function(e,t,n){return Math.min(n,Math.max(0,e))}(r-o,0,Math.max(l-g,0));return{visible:l>0&&f>0&&d<u,isHorizontal:c,hostOffset:m,hostSpan:g,clipWidth:c?l:0,clipHeight:c?0:l}}function Dn({sceneIndex:e,metrics:n,setHostRef:i,frameStore:a,direction:o="y",viewportWidth:s=0,viewportHeight:c=0}){const l=(0,t.useRef)(null),u=(0,t.useRef)(null);return(0,t.useEffect)(()=>{if(!a||"number"!=typeof e)return;const t=()=>{const t=a.getKeySnapshot(e);if(!t)return;const n=An({effectiveMode:"scroll",effectiveDirection:o,globalScrollTimelineState:t.timelineState,globalScrollViewportOffset:t.visualViewportOffset,globalViewportWidth:s,globalViewportHeight:c}),r=l.current,i=u.current;!r||!i||(r.style.width=n.clipWidth>0?`${n.clipWidth}px`:"100%",r.style.height=n.clipHeight>0?`${n.clipHeight}px`:"100%",r.style.opacity=n.visible?"1":"0",r.style.visibility=n.visible?"visible":"hidden",i.style.top=n.isHorizontal?"0px":`${n.hostOffset}px`,i.style.left=n.isHorizontal?`${n.hostOffset}px`:"0px",i.style.width=n.isHorizontal&&n.hostSpan>0?`${n.hostSpan}px`:"100%",i.style.height=n.isHorizontal?"100%":n.hostSpan>0?`${n.hostSpan}px`:"100%")};return t(),a.subscribeKey(e,t)},[o,a,e,c,s]),(0,r.jsx)("div",{ref:l,"data-scene-fixed-layer":e,"data-scene-fixed-role":"clip",style:{position:"absolute",inset:0,width:n.clipWidth>0?n.clipWidth:"100%",height:n.clipHeight>0?n.clipHeight:"100%",overflow:"hidden",pointerEvents:"none",opacity:n.visible?1:0,visibility:n.visible?"visible":"hidden",zIndex:20},children:(0,r.jsx)("div",{ref:u,"data-scene-fixed-layer":e,"data-scene-fixed-role":"frame",style:{position:"absolute",top:n.isHorizontal?0:n.hostOffset,left:n.isHorizontal?n.hostOffset:0,width:n.isHorizontal&&n.hostSpan>0?n.hostSpan:"100%",height:n.isHorizontal?"100%":n.hostSpan>0?n.hostSpan:"100%",pointerEvents:"none"},children:(0,r.jsx)("div",{ref:i,"data-scene-fixed-layer":e,"data-scene-fixed-host":e,"data-scene-fixed-role":"host",style:{position:"relative",width:"100%",height:"100%",pointerEvents:"none"}})})})}function Tn(e){switch(e.type){case"missing-dependency":return`${e.type}:${e.animateId}:${e.after}`;case"circular-dependency":return`${e.type}:${e.animateId}:${e.cycle.join(">")}`;case"duplicate-id":return`${e.type}:${e.animateId}`;case"incompatible-lane":return`${e.type}:${e.animateId}:${e.after}:${e.followerLane}:${e.leaderLane}`}}function jn(e){let t;return e.forEach(e=>{t=e}),t}function Vn(e,t,n=Object.is){if(e.size!==t.size)return!1;for(const[r,i]of e){const e=t.get(r);if(void 0===e||!n(i,e))return!1}return!0}function Ln(){return typeof performance<"u"?performance.now():Date.now()}function On(e,t,n){const r=e.panInfo??{point:{x:0,y:0},delta:{x:0,y:0},offset:{x:0,y:0},velocity:{x:0,y:0}};return r.point.x=t,r.point.y=n,r.delta.x=t-e.lastX,r.delta.y=n-e.lastY,r.offset.x=t-e.startX,r.offset.y=n-e.startY,r.velocity.x=e.velocityX,r.velocity.y=e.velocityY,e.panInfo=r,r}var $n=t.default.createContext(null),Fn=new Set(["children","sceneId","layout","stack","transition","assets","drag","scroll","callbacks","runtimeMode","runtimeDirection","isActive","sceneIndex","totalScenes","currentSceneIndex","sceneRuntime","dragRuntime","scrollRuntime","onDragGestureEnd","onDragReset","onActivationComplete","onDragProgressChange","onRenderProgressChange","onDragTimelineProgressChange","onSharedElapsedMsChange","onDraggingChange","onSharedTimelineDurationChange","onDragRelease","onScrollProgressChange","onScrollDirectionChange","onScrollingChange","onScrollCommit","onScrollReset","onSceneChange","mode","slideDirection","slideDuration","sceneTransitionDuration","enterAnimation","exitAnimation","exitDuration","sceneWidth","sceneHeight","sceneAnchor","sceneZIndex","sceneOverflow","sceneStackMode","scrollSpeed","scrollControlled","scrollCommitThreshold","scrollReleaseDuration","scrollLockToSingleScene","scrollEnterLength","scrollHoldLength","scrollExitLength","onVisibilityChange","preloadImages"]),zn=t.default.forwardRef(function(e,i){const{children:a,className:o,style:s,onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:d}=e,{effectiveMode:f,effectiveDirection:g,isActive:m,sceneIndex:p,totalScenes:h,currentSceneIndex:y,globalDirection:b,globalSharedTimelineDurationMs:S,globalActivationToken:x,globalActivationKind:w,globalFirstSceneEnterGateKnown:R,globalFirstSceneEnterActive:M,globalFirstSceneEnterReady:C,globalViewportWidth:k,globalViewportHeight:P,globalDragProgress:I,globalRenderProgress:E,globalDragTimelineProgress:A,globalIsDragging:D,globalDragRelease:T,globalScrollProgress:j,globalIsScrolling:V,globalScrollDirection:L,globalScrollTransitionSnapshot:O,globalScrollBackdropActive:$,globalScrollTimelineState:F,globalScrollViewportOffset:z,resolvedSceneWidth:N,resolvedSceneHeight:Y,resolvedSceneAnchor:H,resolvedSceneOverflow:W,resolvedSceneZIndex:X,effectiveSceneStackMode:K,resolvedSceneTransitionDuration:_,resolvedEnterAnimation:J,resolvedExitAnimation:Q,sceneVisibilityCallback:te,onVisibilityChange:re,onSceneChange:ie,dragRuntime:ae,onActivationComplete:se,onDragProgressChange:ce,onRenderProgressChange:le,onDragTimelineProgressChange:ue,onDraggingChange:de,onSharedTimelineDurationChange:fe,onDragRelease:ge,onDragGestureEnd:me,onDragReset:pe,slideDuration:he,compatFields:ve}=function(e){const t=e.sceneRuntime?.mode??e.runtimeMode??e.mode??"drag";return{effectiveMode:t,effectiveDirection:e.sceneRuntime?.direction??e.runtimeDirection??e.slideDirection??"y",isActive:e.sceneRuntime?.isActive??e.isActive??!1,sceneIndex:e.sceneRuntime?.sceneIndex??e.sceneIndex??0,totalScenes:e.sceneRuntime?.totalScenes??e.totalScenes??1,currentSceneIndex:e.sceneRuntime?.currentSceneIndex??e.currentSceneIndex??0,globalDirection:e.sceneRuntime?.transitionDirection??null,globalIsSceneAnimating:e.sceneRuntime?.isSceneAnimating??!1,globalSharedTimelineDurationMs:e.sceneRuntime?.sharedTimelineDurationMs??0,globalActivationToken:e.sceneRuntime?.activationToken??0,globalActivationKind:e.sceneRuntime?.activationKind??null,globalFirstSceneEnterGateKnown:e.sceneRuntime?.firstSceneEnterGateKnown??!0,globalFirstSceneEnterActive:e.sceneRuntime?.firstSceneEnterActive??!1,globalFirstSceneEnterReady:e.sceneRuntime?.firstSceneEnterReady??!1,globalViewportWidth:e.sceneRuntime?.viewportWidth??0,globalViewportHeight:e.sceneRuntime?.viewportHeight??0,globalDragProgress:e.dragRuntime?.progress??0,globalRenderProgress:e.dragRuntime?.renderProgress??0,globalDragTimelineProgress:e.dragRuntime?.timelineProgress??0,globalIsDragging:e.dragRuntime?.isDragging??!1,globalDragRelease:e.dragRuntime?.release??null,globalScrollProgress:e.scrollRuntime?.progress??0,globalIsScrolling:e.scrollRuntime?.isScrolling??!1,globalScrollDirection:e.scrollRuntime?.direction??null,globalScrollTransitionSnapshot:e.scrollRuntime?.transitionSnapshot??null,globalScrollBackdropActive:e.scrollRuntime?.backdropActive??!1,globalScrollTimelineState:e.scrollRuntime?.timelineState??null,globalScrollActiveSceneIndex:e.scrollRuntime?.activeSceneIndex??0,globalScrollViewportOffset:e.scrollRuntime?.viewportOffset??0,resolvedSceneWidth:e.layout?.width??e.sceneWidth??"100vw",resolvedSceneHeight:e.layout?.height??e.sceneHeight??("scroll"===t?"auto":"100vh"),resolvedSceneAnchor:e.layout?.anchor??e.sceneAnchor??"top-left",resolvedSceneOverflow:e.layout?.overflow??e.sceneOverflow??"hidden",resolvedSceneZIndex:e.layout?.zIndex??e.sceneZIndex,effectiveSceneStackMode:e.layout?.overlap??e.sceneStackMode??("scroll"===t?"cover":"replace"),resolvedSceneTransitionDuration:e.sceneTransitionDuration??e.transition?.exitDuration??e.exitDuration??800,resolvedEnterAnimation:e.transition?.enterAnimation??e.enterAnimation,resolvedExitAnimation:e.transition?.exitAnimation??e.exitAnimation,sceneVisibilityCallback:e.callbacks?.onVisibilityChange,onVisibilityChange:e.onVisibilityChange,onSceneChange:e.onSceneChange,scrollCommitThreshold:e.scrollCommitThreshold??.42,scrollReleaseDuration:e.scrollReleaseDuration??220,scrollLockToSingleScene:e.scrollLockToSingleScene??!0,scrollRuntime:e.scrollRuntime,dragRuntime:e.dragRuntime,onActivationComplete:e.onActivationComplete,onDragProgressChange:e.onDragProgressChange,onRenderProgressChange:e.onRenderProgressChange,onDragTimelineProgressChange:e.onDragTimelineProgressChange,onSharedElapsedMsChange:e.onSharedElapsedMsChange,onDraggingChange:e.onDraggingChange,onSharedTimelineDurationChange:e.onSharedTimelineDurationChange,onDragRelease:e.onDragRelease,onDragGestureEnd:e.onDragGestureEnd,onDragReset:e.onDragReset,onScrollProgressChange:e.onScrollProgressChange,onScrollDirectionChange:e.onScrollDirectionChange,onScrollingChange:e.onScrollingChange,onScrollCommit:e.onScrollCommit,onScrollReset:e.onScrollReset,slideDuration:e.slideDuration??800,compatFields:[e.mode,e.slideDirection,e.scrollSpeed,e.scrollControlled,e.scrollCommitThreshold,e.scrollReleaseDuration,e.scrollLockToSingleScene,e.runtimeMode,e.runtimeDirection,e.isActive,e.sceneIndex,e.totalScenes,e.currentSceneIndex,e.onActivationComplete,e.onDragProgressChange,e.onRenderProgressChange,e.onDragTimelineProgressChange,e.onSharedElapsedMsChange,e.onDraggingChange,e.onSharedTimelineDurationChange,e.onDragGestureEnd,e.onDragReset,e.onScrollProgressChange,e.onScrollDirectionChange,e.onScrollingChange,e.onScrollCommit,e.onScrollReset,e.scrollRuntime,e.dragRuntime,e.sceneRuntime]}}(e),ye=e.scrollRuntime?.frameStore,be=e.scrollRuntime?.sceneIndex??p,Se=v(),xe=oe(),we=xe?.reportError,Re=(0,n.useAnimation)(),[Me,Ce]=(0,t.useState)(null),[ke,Pe]=(0,t.useState)(null),Ie=(0,t.useRef)(0);(0,t.useRef)(null);const Ee=hn(J),Ae=hn(Q),De=!!(ae||e.onDragProgressChange||e.onRenderProgressChange||e.onDragTimelineProgressChange||e.onDraggingChange||e.onSharedTimelineDurationChange||e.onDragGestureEnd||e.onDragReset),[Te,je]=(0,t.useState)(I),[Ve,Le]=(0,t.useState)(E),[Oe,$e]=(0,t.useState)(A),[Fe,ze]=(0,t.useState)(D),[Ne,Be]=(0,t.useState)(S),[qe,Ue]=(0,t.useState)(T),Ye=(0,t.useRef)(0),He=(0,t.useCallback)(e=>{null!==e?(Ye.current+=1,Ue({...e,token:Ye.current})):Ue(null)},[]),We=De?I:Te,Xe=De?E:Ve,Ke=De?A:Oe,Ge=De?D:Fe,_e=De?S:Ne,Ze=De?T:qe,Je=Ge,Qe=(0,n.useMotionValue)(We),et=ae?.renderProgressMotion??Qe,tt=(0,n.useMotionValue)(Ke),nt=ae?.timelineProgressMotion??tt,rt=(0,n.useMotionValue)(0),[it,at]=(0,t.useState)("initial"),ot=p-y,[st,ct]=(0,t.useState)(!1),lt=(0,t.useRef)(Symbol(`scene:${p}`)),ut=(0,t.useRef)(null),dt=(0,t.useRef)(ae?.onPreparedInvalidated);dt.current=ae?.onPreparedInvalidated;const[ft,mt]=(0,t.useState)(null),ht=(0,t.useMemo)(()=>ae?.dragMappingConfig??q(void 0,e.drag),[ae?.dragMappingConfig,e.drag]),vt=(0,t.useCallback)((t,n,r)=>{if("drag"!==f)return;const i=ne({sceneIndex:p,instanceId:lt.current,revision:n,enabled:!1!==e.drag?.enabled,mapping:ht,registrySnapshot:t,enterVariantsByAnimateId:r});ut.current=i,mt(i),ae?.onPrepared?.(i)},[ae,f,ht,e.drag?.enabled,p]),{timelineDuration:yt,beginPreparation:bt,registerAnimate:St,declareAnimateLane:xt,unregisterAnimate:wt,getCalculatedDelay:Rt,getTimelineDuration:Mt}=function({sceneIndex:e,baseDuration:n,reportError:r,onStableSnapshot:i}){const a=(0,t.useRef)(new Map),o=(0,t.useRef)(new Map),s=(0,t.useRef)(new Map),c=(0,t.useRef)(new Map),l=(0,t.useRef)(new Set),u=(0,t.useRef)(ee({baseDuration:n,registrations:s.current})),d=(0,t.useRef)(new Set),f=(0,t.useRef)(null),g=(0,t.useRef)(new Map),m=(0,t.useRef)(0),p=(0,t.useRef)(0),h=(0,t.useRef)(0),v=(0,t.useRef)(null),y=(0,t.useRef)(null),b=(0,t.useRef)(!0),S=(0,t.useRef)(r);S.current=r;const x=(0,t.useRef)(i);x.current=i;const w=(0,t.useRef)(n),[R,M]=(0,t.useState)(n),[C,k]=(0,t.useState)(!1),P=(0,t.useCallback)(()=>{b.current&&k(!1)},[]),I=(0,t.useCallback)(t=>{t.forEach(t=>{const n=Tn(t);if(d.current.has(n))return;let r,i;d.current.add(n),"missing-dependency"===t.type?(r="INVALID_ANIMATION",i=`Animate "${t.animateId}" references non-existent component "${t.after}" via after in Scene ${e}.`):"circular-dependency"===t.type?(r="CIRCULAR_DEPENDENCY",i=`Animate after chain contains a cycle in Scene ${e}: ${t.cycle.join(" -> ")}.`):"duplicate-id"===t.type?(r="INVALID_COMPONENT_HIERARCHY",i=`More than one Animate component registered animateId "${t.animateId}" in Scene ${e}.`):(r="INVALID_ANIMATION",i=`Animate "${t.animateId}" uses ${t.followerLane} after "${t.after}" driven by ${t.leaderLane} in Scene ${e}; this dependency direction is incompatible.`),S.current?.({code:r,message:i,context:{sceneIndex:e}})})},[e]),E=(0,t.useCallback)(()=>{s.current.clear(),c.current.clear(),l.current.clear(),a.current.forEach((e,t)=>{const n=jn(e);n&&s.current.set(t,n.info),e.size>1&&l.current.add(t)}),o.current.forEach((e,t)=>{let n;e.forEach(e=>{e.disposed||(n=e)}),n&&c.current.set(t,n.lane)})},[]),A=(0,t.useCallback)(()=>{E();const e=ee({baseDuration:n,registrations:s.current,declaredLanes:c.current,duplicateIds:l.current});return u.current=e,w.current=e.timelineDuration,b.current&&M(t=>t===e.timelineDuration?t:e.timelineDuration),e},[n,E]),D=(0,t.useCallback)(e=>u.current.issues.some(t=>"circular-dependency"===t.type&&t.cycle.includes(e)),[]),T=(0,t.useCallback)((e,t)=>{const{follower:n,leaderId:r}=e,i=a.current.get(r),o=c.current.get(r);if(!i||0===i.size)return t&&void 0!==o&&void 0!==n.info.lane&&!G(n.info.lane,o)?(e.sawLeader=!0,{kind:"invalid",leaderId:r,reason:"incompatible-lane"}):t?{kind:"invalid",leaderId:r,reason:e.sawLeader?"leader-unregistered":"missing"}:{kind:"pending",leaderId:r};e.sawLeader=!0;const s=jn(i);return t&&D(n.id)?{kind:"invalid",leaderId:r,reason:"cycle"}:t&&i.size>1?{kind:"invalid",leaderId:r,reason:"duplicate"}:t&&void 0!==n.info.lane&&void 0!==s.info.lane&&!G(n.info.lane,s.info.lane)?{kind:"invalid",leaderId:r,reason:"incompatible-lane"}:s.enterCompleted?{kind:"satisfied",source:"completed",leaderId:r,generation:s.generation}:{kind:"pending",leaderId:r,generation:s.generation}},[D]),j=(0,t.useCallback)((e,t)=>{if(e.terminal)return;const n=function(e){return"invalid"===e.kind?`${e.kind}:${e.leaderId}:${e.reason}`:`${e.kind}:${e.leaderId??""}:${e.generation??""}:${"satisfied"===e.kind?e.source:""}`}(t);e.lastSignature!==n&&(e.lastSignature=n,e.listener(t),"pending"!==t.kind&&(e.terminal=!0))},[]),V=(0,t.useCallback)(e=>{g.current.forEach(t=>{[...t].forEach(n=>{n.follower.disposed||n.terminal?t.delete(n):(j(n,T(n,e)),n.terminal&&t.delete(n))})}),g.current.forEach((e,t)=>{0===e.size&&g.current.delete(t)})},[j,T]),L=(0,t.useCallback)(e=>{if(0!==p.current||!b.current)return;const t=new Map;a.current.forEach((e,n)=>{const r=jn(e);r?.enterVariant&&t.set(n,r.enterVariant)});const n=v.current,r=y.current,i=null!==n&&null!==r&&function(e,t){return e.timelineDuration===t.timelineDuration&&Vn(e.registrations,t.registrations,(e,t)=>e.delay===t.delay&&e.duration===t.duration&&e.after===t.after&&e.lane===t.lane)&&Vn(e.calculatedDelays,t.calculatedDelays)&&e.issues.length===t.issues.length&&e.issues.every((e,n)=>Tn(e)===Tn(t.issues[n]))}(n,e)&&Vn(r,t);k(!0),!i&&(h.current+=1,v.current=e,y.current=new Map(t),x.current?.(function(e){const t=[];return e.registrations.forEach((e,n)=>{t.push([n,Object.freeze({...e})])}),Object.freeze({registrations:Z(t),calculatedDelays:Z(e.calculatedDelays),issues:Object.freeze([...e.issues]),timelineDuration:e.timelineDuration})}(e),h.current,t))},[]),O=(0,t.useCallback)(()=>{if(0!==p.current||!b.current)return;null!==f.current&&(clearTimeout(f.current),f.current=null);const e=A();I(e.issues),V(!0),L(e)},[L,A,V,I]),$=(0,t.useCallback)(()=>{P(),null!==f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,O()},0)},[O,P]),F=(0,t.useCallback)(()=>{p.current+=1,P();let e=!1;const t=()=>!e&&(e=!0,p.current=Math.max(0,p.current-1),0===p.current);return{complete:()=>{t()&&O()},cancel:()=>{t()&&$()}}},[O,P,$]),z=(0,t.useCallback)(e=>{g.current.forEach((t,n)=>{t.forEach(n=>{n.follower.token===e.token&&t.delete(n)}),0===t.size&&g.current.delete(n)})},[]),N=(0,t.useCallback)(e=>{if(e.disposed)return;e.disposed=!0,z(e);const t=a.current.get(e.id);t?.delete(e.token),0===t?.size&&a.current.delete(e.id),A(),$()},[A,z,$]),B=(0,t.useCallback)((e,t)=>{const n={token:Symbol(e),id:e,generation:++m.current,info:t,enterVariant:null,enterCompleted:!1,disposed:!1};let r=a.current.get(e);return r||(r=new Map,a.current.set(e,r)),r.set(n.token,n),A(),$(),s.current.size>100&&s.current.size,{animateId:e,generation:n.generation,getCalculatedDelay:()=>u.current.calculatedDelays.get(e)??n.info.delay,setEnterVariant:t=>{n.disposed||a.current.get(e)?.has(n.token)&&(n.enterVariant=t,$())},observeAfter:e=>{if(!n.info.after)return e({kind:"satisfied",source:"none"}),()=>{};const t={follower:n,listener:e,leaderId:n.info.after,sawLeader:!1,lastSignature:null,terminal:!1};let r=g.current.get(t.leaderId);return r||(r=new Set,g.current.set(t.leaderId,r)),r.add(t),j(t,T(t,0===p.current&&null===f.current)),()=>{t.terminal=!0,r?.delete(t),0===r?.size&&g.current.delete(t.leaderId)}},publishEnterCompleted:()=>{n.disposed||n.enterCompleted||a.current.get(e)?.has(n.token)&&(n.enterCompleted=!0,V(!1))},dispose:()=>N(n)}},[N,j,T,A,V,e,$]),q=(0,t.useCallback)((e,t)=>{const n={token:Symbol(e),id:e,lane:t,disposed:!1};let r=o.current.get(e);return r||(r=new Map,o.current.set(e,r)),r.set(n.token,n),A(),$(),{dispose:()=>{if(n.disposed)return;n.disposed=!0;const t=o.current.get(e);t?.delete(n.token),0===t?.size&&o.current.delete(e),A(),$()}}},[A,$]),U=(0,t.useCallback)(e=>{const t=a.current.get(e),n=t?jn(t):void 0;n&&N(n)},[N]),Y=(0,t.useCallback)(e=>u.current.calculatedDelays.get(e)??s.current.get(e)?.delay??0,[]),H=(0,t.useCallback)(()=>w.current,[]);return(0,t.useEffect)(()=>{$()},[n,$]),(0,t.useEffect)(()=>{b.current=!0;const e=a.current,t=o.current,n=s.current,r=c.current,i=l.current,u=d.current,m=g.current;return()=>{b.current=!1,null!==f.current&&(clearTimeout(f.current),f.current=null),p.current=0,e.clear(),t.clear(),n.clear(),r.clear(),i.clear(),u.clear(),m.clear()}},[]),{timelineDuration:R,isStable:C,beginPreparation:F,registerAnimate:B,declareAnimateLane:q,unregisterAnimate:U,getCalculatedDelay:Y,getTimelineDuration:H}}({sceneIndex:p,baseDuration:"drag"===f?0:_,reportError:xe?.reportError,onStableSnapshot:vt}),Ct=(0,t.useRef)(!1);(0,t.useEffect)(()=>{Ct.current||t.default.Children.count(a)>0||(Ct.current=!0,we?.({code:"EMPTY_SCENES",message:`Scene ${p} has no children; it renders an empty full-screen layer.`,context:{scope:"scene",sceneIndex:p}}))},[a,we,p]),(0,t.useEffect)(()=>()=>{const e=ut.current;e&&dt.current?.({sceneIndex:e.sceneIndex,instanceId:e.instanceId,revision:e.revision})},[]);const kt=(0,t.useRef)(null),Pt=(0,t.useCallback)(e=>{kt.current=e,"function"==typeof i?i(e):i&&(i.current=e)},[i]),[It,Et]=(0,t.useState)(null),At=(0,t.useCallback)(e=>{Et(t=>t===e?t:e)},[]),Dt=function({sceneId:e,sceneIndex:n,mode:r,scroll:i,elementRef:a}){const o=(0,t.useContext)(dn),s=(0,t.useId)(),c=i?.zoneId??e??`scene-zone-${s}`,l=o?.registerZone,u=o?.unregisterZone,d=o?.setZoneElement,f=!!i;return(0,t.useEffect)(()=>{if("scroll"===r&&f&&l&&u)return l(c,{sceneIndex:n}),()=>{u(c,n)}},[r,f,l,u,c,n]),(0,t.useEffect)(()=>{if("scroll"===r&&f&&d)return d(c,n,a.current),()=>{d(c,n,null)}},[a,r,f,n,d,c]),"scroll"===r&&i?c:null}({sceneId:e.sceneId,sceneIndex:p,mode:f,scroll:e.scroll,elementRef:kt});(0,t.useEffect)(()=>{ae?.renderProgressMotion||Qe.set(We)},[We,ae?.renderProgressMotion,Qe]),(0,t.useEffect)(()=>{ae?.timelineProgressMotion||tt.set(Ke)},[Ke,ae?.timelineProgressMotion,tt]),(0,t.useEffect)(()=>{De&&(je(I),Le(E),$e(A),ze(D),Be(S),Ue(T))},[De,I,E,A,D,S,T]);const Tt=(0,t.useCallback)(e=>"drag"!==f?0:!De&&h<=1?Math.max(-1,Math.min(1,e)):0===y&&e<0||y===h-1&&e>0?0:Math.max(-1,Math.min(1,e)),[f,De,y,h]);(0,t.useEffect)(()=>{},[Se,p]),(0,t.useEffect)(()=>{"scroll"!==f&&Et(null)},[f]),(0,t.useEffect)(()=>{const e=++Ie.current,t=()=>Ie.current===e,n=e=>{t()&&we?.(e)};return Ce(null),Pe(null),"scroll"!==f?((Ee||Ae)&&[Ee?"enterAnimation":null,Ae?"exitAnimation":null].filter(Boolean).join(","),()=>{t()&&(Ie.current+=1)}):Ee||Ae?((async()=>{const[e,r]=await Promise.all([gt(Ee,`Scene ${p}`,"enter",n),gt(Ae,`Scene ${p}`,"exit",n)]);t()&&(Ce(e??null),Pe(r??null))})(),()=>{t()&&(Ie.current+=1)}):()=>{t()&&(Ie.current+=1)}},[f,we,p,Ee,Ae]);const jt=function({slideMode:e,sceneState:n,isActive:r,sceneOffset:i,globalScrollProgress:a,globalScrollDirection:o,globalIsScrolling:s,globalScrollBackdropActive:c,hasExitAnimation:l,scrollTimelineState:u}){return(0,t.useMemo)(()=>"drag"===e?"exiting"===n?"exiting":"entering"===n?"entering":r?"active":0===i?"inactive":"parked":"scroll"===e?u?"enter"===u.phase?"entering":"exit"===u.phase?l?"exiting":"covered":"hold"===u.phase?r?"active":"covered":"after"===u.phase?l?"parked":"covered":r?"active":c?"covered":0===i?"inactive":"parked":r&&s&&a>.001?l?"exiting":"covered":c?"covered":("forward"===o&&1===i||"backward"===o&&-1===i)&&a>.001?"entering":r?"active":0===i?"inactive":"parked":r?"active":"inactive",[e,n,r,i,a,o,s,c,l,u])}({slideMode:f,sceneState:it,isActive:m,sceneOffset:ot,globalScrollProgress:j,globalScrollDirection:L,globalIsScrolling:V,globalScrollBackdropActive:$,hasExitAnimation:!!Q,scrollTimelineState:F}),Vt=(0,t.useMemo)(()=>In({effectiveMode:f,isActive:m,globalScrollTimelineState:F,hasExitAnimation:!!Q}),[f,m,F,Q]),Lt=Vt>.001,Ot=(0,t.useRef)(re),$t=(0,t.useRef)(te);(0,t.useEffect)(()=>{Ot.current=re,$t.current=te},[re,te]),(0,t.useEffect)(()=>{"scroll"===f&&ye||En({onVisibilityChange:Ot.current,sceneVisibilityCallback:$t.current,sceneIndex:p,visible:Lt,progress:Vt})},[f,p,Lt,Vt,ye]),(0,t.useEffect)(()=>{if("scroll"!==f||!ye)return;const e=()=>{const e=ye.getKeySnapshot(be)??null,t=In({effectiveMode:f,isActive:e?.isCurrent??m,globalScrollTimelineState:e?.timelineState??null,hasExitAnimation:!!Q});En({onVisibilityChange:Ot.current,sceneVisibilityCallback:$t.current,sceneIndex:p,visible:t>.001,progress:t})};return e(),ye.subscribeKey(be,e)},[f,ye,m,Q,p,te,be]),(0,t.useEffect)(()=>{"drag"!==f||!m||((ae?.onSharedTimelineDurationChange??fe)?.(Mt()),De||Be(Mt()))},[f,m,Mt,yt,ae,fe,it,De]);const Ft="drag"===f?C&&null!==ft:C,zt=(0,t.useMemo)(()=>({mode:f,isActive:m,isDragging:!1,dragProgressMotion:et,runtimeState:jt,sceneState:it,sceneOffset:ot,activationToken:x,activationKind:w,firstSceneEnterGateKnown:0===p?R:void 0,firstSceneEnterActive:0===p?M:void 0,firstSceneEnterReady:0===p?Ft:void 0,sceneTransitionDuration:_,getTimelineDuration:Mt,beginPreparation:bt,registerAnimate:St,declareAnimateLane:xt,unregisterAnimate:wt,getCalculatedDelay:Rt,enterDuration:he}),[bt,xt,f,Ft,Rt,w,x,M,R,Mt,m,et,St,_,p,ot,it,he,wt,jt]),Nt=(0,t.useMemo)(()=>({...zt,isDragging:Je,dragProgressMotion:et,renderProgressMotion:et,dragTransaction:ae?.transaction??null,preparedSnapshot:ft,dragTimelineProgress:Ke,sharedElapsedMotion:rt,renderProgress:Xe,dragRelease:Ze,sharedTimelineDurationMs:_e,firstSceneEnterActive:M}),[Ze,Ke,Xe,_e,et,ae?.transaction,rt,M,Je,ft,zt]),Bt="drag"===f?Nt:zt;!function({slideMode:e,isActive:n,sceneOffset:r,sceneStackMode:i,controls:a,enterVariant:o,exitVariant:s,globalIsScrolling:c,globalScrollProgress:l,globalScrollDirection:u,globalScrollTransitionSnapshot:d,globalScrollBackdropActive:f,globalScrollTimelineState:g,scrollFrameStore:m,scrollFrameSceneIndex:p,setSceneState:h}){const v=(0,t.useRef)(null);v.current={slideMode:e,isActive:n,sceneOffset:r,sceneStackMode:i,controls:a,enterVariant:o,exitVariant:s,globalIsScrolling:c,globalScrollProgress:l,globalScrollDirection:u,globalScrollTransitionSnapshot:d,globalScrollBackdropActive:f,globalScrollTimelineState:g,setSceneState:h};const y=(0,t.useRef)(null),b=(0,t.useRef)(null),S=(0,t.useCallback)(e=>{const t=v.current;if(!t||"scroll"!==t.slideMode)return;const n=null!==e,r=n?e.timelineState:t.globalScrollTimelineState,i=n?e.isCurrent:t.isActive,a=n?e.isScrolling:t.globalIsScrolling,o=n?e.isBackdropActive:t.globalScrollBackdropActive,s=n?e.scrollDirection:t.globalScrollDirection,c=n?e.progress:t.globalScrollProgress,l=t.globalScrollTransitionSnapshot?.direction??s,u="forward"===l&&1===t.sceneOffset||"backward"===l&&-1===t.sceneOffset,d=i&&a&&c>.001,f=!i&&"cover"===t.sceneStackMode&&o&&(0===t.sceneOffset||-1===t.sceneOffset),g=Cn(t.enterVariant?.animate,Mn),m=Cn(t.enterVariant?.initial,g),p=Cn(t.exitVariant?.exit,g),h=e=>{y.current!==e&&(y.current=e,t.setSceneState(e))},S=(e,n,r)=>{const i=b.current;i&&i.kind===e&&i.progress===n&&i.enterVariant===t.enterVariant&&i.exitVariant===t.exitVariant&&i.controls===t.controls||(b.current={kind:e,progress:n,enterVariant:t.enterVariant,exitVariant:t.exitVariant,controls:t.controls},t.controls.set(r))};if(r){if("before"===r.phase)return h("initial"),void S("before",0,m);if("enter"===r.phase){const e=kn(r.enterProgress);return h("entering"),void S("enter",e,pt(m,g,e))}if("hold"===r.phase)return h("active"),void S("hold",1,g);if("exit"===r.phase){const e=kn(r.exitProgress);return h(t.exitVariant?.exit?"exiting":"active"),void S("exit",e,t.exitVariant?.exit?pt(g,p,e):g)}h(f?t.exitVariant?.exit?"exiting":"active":t.exitVariant?.exit?"exiting":i?"active":"initial"),S("after",1,t.exitVariant?.exit?p:g)}else if(u){h("entering");const e=kn(c);S("fallback-enter",e,pt(m,g,e))}else if(d||f){h(t.exitVariant?.exit?"exiting":"active");const e=kn(c);S("fallback-exit",e,t.exitVariant?.exit?pt(g,p,e):g)}else h(i?"active":"initial"),S(i?"fallback-active":"fallback-initial",i?1:0,i?g:m)},[]);(0,t.useEffect)(()=>{if("scroll"===e){if(m&&"number"==typeof p){const e=()=>{S(m.getKeySnapshot(p)??null)};return e(),m.subscribeKey(p,e)}S(null)}},[S,o,s,f,u,l,g,d,c,n,r,i,p,m,e])}({slideMode:f,isActive:m,sceneOffset:ot,sceneStackMode:K,controls:Re,enterVariant:Me,exitVariant:ke,globalIsScrolling:V,globalScrollProgress:j,globalScrollDirection:L,globalScrollTransitionSnapshot:O,globalScrollBackdropActive:$,globalScrollTimelineState:F,scrollFrameStore:ye,scrollFrameSceneIndex:be,setSceneState:at});const qt=function({slideMode:e,isActive:r,sceneIndex:i,sceneOffset:a,globalDirection:o,globalIsDragging:s,candidateSuspended:c=!1,globalRenderProgress:l,globalDragTimelineProgress:u,renderProgressMotion:d,dragTimelineProgressMotion:f,dragRelease:g,firstSceneEnterReady:m,elementElapsedMotion:p,getTimelineDuration:h,timelineDurationState:v,dragTransaction:y,preparedSnapshot:b,requirePreparedSnapshot:S=!1,dragMappingConfig:x,takeoverSnapshot:w,onElementContinuationChange:R,onSettleComplete:M,onColdStartComplete:C}){const k=(0,t.useRef)(null),P=(0,t.useRef)(null),I=(0,t.useRef)(0),E=(0,t.useRef)(null),A=(0,t.useRef)(null),D=(0,t.useRef)(!1),T=(0,t.useRef)(0),j=(0,t.useRef)(!1),V=(0,t.useRef)(h);V.current=h;const L=(0,t.useRef)(y);L.current=y;const O=(0,t.useRef)(b);O.current=b;const $=(0,t.useRef)(S);$.current=S;const F=(0,t.useRef)(null),z=()=>L.current||($.current?null:O.current??null),N=e=>e?.registrySnapshot.timelineDuration??V.current(),q=e=>e?.mapping??ee.current,Y=(0,t.useRef)(M);Y.current=M;const H=(0,t.useRef)(C);H.current=C;const W=(0,t.useRef)(R);W.current=R;const X=(0,t.useRef)(!1),K=e=>{X.current!==e&&(X.current=e,W.current?.(e))},G=(0,t.useRef)(p);G.current=p;const _=(0,t.useRef)(null),Z=(0,t.useRef)(null),J=(0,t.useRef)(null),Q=(0,t.useRef)(null),ee=(0,t.useRef)(x??B);ee.current=x??B;const te=(0,t.useRef)(f?.get()??u);return te.current=f?.get()??u,(0,t.useEffect)(()=>{if("drag"===e&&c&&k.current){if(X.current){_.current=Math.max(0,G.current.get());const e=w?.current,t=e?.sceneIndices.includes(i)??!1;J.current=t?e.token:null,Z.current=t?e.baseRatio:null,Q.current=null}I.current+=1,k.current.stop(),k.current=null,P.current=null}},[c,i,e,w]),(0,t.useEffect)(()=>{if(c||s)return;const e=J.current,t=w?.current;null!==e&&t?.token===e&&null!==t.baseRatio||(_.current=null,Z.current=null,J.current=null,Q.current=null)},[c,s,w]),(0,t.useEffect)(()=>{if("drag"!==e||!s)return;k.current&&(k.current.stop(),k.current=null,P.current=null),K(!1),D.current=!0,j.current=!1;const t=e=>{te.current=e;const t=d?.get()??l,n=t>1e-4?"forward":t<-1e-4?"backward":o;if(!("forward"===n&&1===a||"backward"===n&&-1===a))return;const r=z();if($.current&&!r)return;const s=N(r),c=Math.max(0,Math.min(e,1)),u=q(r),f=_.current;if(null!==f){const e=w?.current,n=J.current;if(null!==n&&e?.token===n&&e.sceneIndices.includes(i)&&null!==e.baseRatio){const r=e.baseRatio;if(Z.current=r,Q.current!==n&&Math.abs(Math.abs(t)-r)<=1e-6&&Math.abs(c-e.staleRatio)<=1e-6&&Math.abs(c-r)>1e-6)return void(Q.current=n);const i=U(u,s,100*r),a=U(u,s,100*c);return void G.current.set(Math.max(0,Math.min(s,f+a-i)))}const r=Z.current;if(null===r)return void(Z.current=c);const a=U(u,s,100*r),o=U(u,s,100*c);return void G.current.set(Math.max(0,Math.min(s,f+o-a)))}G.current.set(U(u,s,100*c))};return t(f?.get()??u),f?f.on("change",t):void 0},[e,s,u,l,f,d,o,a,i,w,y?.transactionId]),(0,t.useEffect)(()=>{if("drag"!==e||c)return;const t=g;if(!t||t.targetSceneIndex!==i)return;const r=z();if($.current&&!r||E.current===t.token)return;E.current=t.token;const a=++I.current;k.current?.stop(),k.current=null,K(!1);const o=G.current,s=N(r),l="number"==typeof t.progressRatio?t.progressRatio:te.current,u=r&&"releaseSeed"in r?r.releaseSeed.elapsedMs:U(q(r),s,100*Math.max(0,Math.min(l,1))),d=Math.max(0,o.get(),u);if(d>o.get()&&o.set(d),"enter"===t.mode){if(o.set(0),s<=.001)return void o.set(s);P.current="cold-start",k.current=(0,n.animate)(o,s,{duration:s/1e3,ease:"linear",onUpdate:e=>{I.current===a&&o.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,o.set(s))}})}else if("settle"===t.mode){const e=s-d;if(e<=.001)return K(!1),o.set(s),A.current=t.token,void Y.current?.();P.current="settle",K(!0),k.current=(0,n.animate)(o,s,{duration:e/1e3,ease:"linear",onUpdate:e=>{I.current===a&&o.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,K(!1),o.set(s),A.current=t.token,Y.current?.())}})}else{if(d<=.001)return K(!1),void o.set(0);const e=Math.min(.5*Math.max(d,0),300);P.current="bounce",K(!0),k.current=(0,n.animate)(o,0,{duration:e/1e3,ease:"easeOut",onUpdate:e=>{I.current===a&&o.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,K(!1),o.set(0))}})}},[e,g?.token,i,y?.transactionId]),(0,t.useEffect)(()=>{if("drag"!==e||c||s)return;const t=g;if(!t||"enter"===t.mode||t.targetSceneIndex!==i||E.current!==t.token||"settle"===t.mode&&A.current===t.token||k.current)return;const r=z();if($.current&&!r)return;const a=G.current,o=Math.max(0,a.get());if("bounce"===t.mode){if(o<=.001)return K(!1),void a.set(0);const e=++I.current;return P.current="bounce",K(!0),void(k.current=(0,n.animate)(a,0,{duration:Math.min(.5*o,300)/1e3,ease:"easeOut",onUpdate:t=>{I.current===e&&a.set(t)},onComplete:()=>{I.current===e&&(k.current=null,P.current=null,K(!1),a.set(0))}}))}const l=N(r),u=l-o;if(u<=.001)return K(!1),a.set(l),A.current=t.token,void Y.current?.();const d=++I.current;P.current="settle",K(!0),k.current=(0,n.animate)(a,l,{duration:u/1e3,ease:"linear",onUpdate:e=>{I.current===d&&a.set(e)},onComplete:()=>{I.current===d&&(k.current=null,P.current=null,K(!1),a.set(l),A.current=t.token,Y.current?.())}})},[e,c,s,g?.token,i]),(0,t.useEffect)(()=>{if("drag"!==e||0!==i||!m||s)return;const t=G.current;if(!D.current){const e=O.current??null;if($.current&&!e)return;F.current=e;const r=N(e);D.current=!0,j.current=null===e,T.current=r;const i=r-Math.max(0,t.get());if(i<=.001)return t.set(r),void H.current?.();const a=++I.current;return P.current="cold-start",void(k.current=(0,n.animate)(t,r,{duration:i/1e3,ease:"linear",onUpdate:e=>{I.current===a&&t.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,t.set(T.current),H.current?.())}}))}if(!j.current||F.current)return;const r=V.current();if(r<=T.current+.001)return;k.current?.stop(),T.current=r;const a=r-Math.max(0,t.get());if(a<=.001)return t.set(r),k.current=null,P.current=null,void H.current?.();const o=++I.current;P.current="cold-start",k.current=(0,n.animate)(t,r,{duration:a/1e3,ease:"linear",onUpdate:e=>{I.current===o&&t.set(e)},onComplete:()=>{I.current===o&&(k.current=null,P.current=null,t.set(T.current),H.current?.())}})},[e,i,m,s,v,b?.revision]),(0,t.useEffect)(()=>()=>{k.current?.stop(),k.current=null,K(!1)},[]),{completeImmediately:(0,t.useCallback)(()=>{I.current+=1,k.current?.stop(),k.current=null,P.current=null,K(!1),G.current.set(V.current())},[]),resetImmediately:(0,t.useCallback)(()=>{I.current+=1,k.current?.stop(),k.current=null,P.current=null,K(!1),G.current.set(0)},[])}}({slideMode:f,isActive:m,sceneIndex:p,sceneOffset:ot,globalDirection:b,globalRenderProgress:Xe,renderProgressMotion:et,globalIsDragging:Ge,candidateSuspended:ae?.candidateSuspended??!1,globalDragTimelineProgress:Ke,dragTimelineProgressMotion:nt,dragRelease:Ze,firstSceneEnterReady:C,elementElapsedMotion:rt,getTimelineDuration:Mt,timelineDurationState:yt,dragTransaction:ae?.transaction??null,preparedSnapshot:ft,requirePreparedSnapshot:De,dragMappingConfig:ae?.dragMappingConfig,takeoverSnapshot:ae?.takeoverSnapshot,onElementContinuationChange:ae?.onElementContinuationChange,onSettleComplete:ae?.onActivationComplete??se,onColdStartComplete:ae?.onActivationComplete??se}),{handleCandidateSuspend:Ut,handleCandidateResume:Yt,handleDragStart:Ht,handlePan:Wt,handlePanEnd:Xt}=function({slideMode:e,isActive:r,sceneIndex:i,currentSceneIndex:a,totalScenes:o,slideDirection:s,slideDuration:c,sceneTransitionDuration:l,sceneOffset:u,sceneState:d,globalDirection:f,globalRenderProgress:g,globalIsDragging:m,globalDragProgress:p,globalDragTimelineProgress:h,controls:v,dragProgressMotion:y,setSceneState:b,setIsAnimating:S,resolveDragProgress:x,getTimelineDuration:w,onDragProgressChange:R,onRenderProgressChange:M,onDragTimelineProgressChange:C,onOwnershipRequest:k,onCandidateSuspensionChange:P,takeoverSnapshot:I,onDraggingChange:E,onDragRelease:A,renderLaneRef:D,completeReleaseImmediately:T=!1,onDragEnd:j,onDragReset:V,thresholdConfig:L}){(0,t.useRef)(null);const O=(0,t.useRef)(null),$=(0,t.useRef)(0),F=(0,t.useRef)(null),z=D??F,N=(0,t.useRef)(!1),B=(0,t.useRef)(0),q=(0,t.useRef)(!1),U=(0,t.useRef)(!1);return(0,t.useEffect)(()=>{if("drag"!==e)return;v.set({opacity:1,x:0,y:0,scale:1,rotate:0});const t=g,n=m||Math.abs(t)>.001,i=t>0?"forward":t<0?"backward":f,a=r?n?"exiting":"active":"forward"===i&&1===u||"backward"===i&&-1===u?"entering":"initial";d!==a&&b(a)},[e,v,r,d,i,g,m,u,f,b]),(0,t.useEffect)(()=>()=>{$.current+=1;const e=z.current;e&&e.ownerSceneIndex===i&&(e.stop(),z.current=null),N.current=!1,q.current=!1},[z,i]),{handleCandidateSuspend:(0,t.useCallback)(()=>{if("drag"!==e)return!1;const t=z.current,n=!!t?.suspend;q.current=n,t?.suspend?.();const r=P?.(!0)??!1;return n||r},[z,P,e]),handleCandidateResume:(0,t.useCallback)(()=>{z.current?.resume?.(),q.current=!1,P?.(!1)},[z,P]),handleDragStart:(0,t.useCallback)(t=>{if("drag"!==e)return!1;const n=z.current;if(!r&&!n||k&&!k(t))return!1;const i=n&&q.current?n.getCurrent?.()??g:g,a=I?.current;return a&&null===a.baseRatio&&(I.current={...a,baseRatio:Math.abs(i)}),P?.(!1),n?(n.preempt?n.preempt():n.stop(),z.current=null,q.current=!1,B.current=i,U.current=!0,y.set(i),R?.(i),C?.(Math.abs(i)),n.kind,i.toFixed(3)):(B.current=0,U.current=!1),N.current=!0,p.toFixed(3),h.toFixed(3),E?.(!0),!0},[e,r,z,k,y,R,C,E,i,a,o,p,h,g,P,I]),handlePan:(0,t.useCallback)((t,n)=>{if("drag"!==e||!r&&!N.current)return;const i="y"===s?n.offset.y:n.offset.x,a=x(B.current-i/("y"===s?window.innerHeight:window.innerWidth)),o=Math.abs(a);y.set(a),R?.(a),C?.(o),M?.(a)},[e,r,s,i,R,C,M,y,x]),handlePanEnd:(0,t.useCallback)((t,o)=>{if("drag"!==e||!r&&!N.current)return;N.current=!1;const l="pointercancel"===t.type;$.current+=1,z.current?.stop(),z.current=null;const u=y.get(),d=w(),f=function(e,t){const n="y"===e?t.velocity.y:t.velocity.x;return Number.isFinite(n)?-n:0}(s,o),g=Math.abs(f),m=Math.abs(u),p=(e,t)=>{let r=null,a=y.get(),o=0,s=!1,c=!1;const l=e/Math.max(Math.abs(a),1e-6),u=()=>{c||s||z.current!==g||(z.current=null,r?.stop(),a=0,y.set(0),R?.(0),C?.(0),M?.(0),t())},d=()=>{if(c||s||z.current!==g)return;const e=Math.abs(a)*l;if(e<=1e-6)return void u();const t=++o;r=(0,n.animate)(y,0,{duration:e,ease:"easeOut",onUpdate:e=>{t!==o||c||s||(a=e,y.set(e),R?.(e),C?.(Math.abs(e)),M?.(e))},onComplete:()=>{t===o&&(a=0,u())}})},f=()=>{c=!0,s=!1,o+=1,r?.stop()},g={kind:"bounce",ownerSceneIndex:i,stop:f,suspend:()=>{c||s||(a=y.get(),s=!0,o+=1,r?.stop())},resume:()=>{c||!s||(a=y.get(),s=!1,d())},preempt:f,getCurrent:()=>a};z.current=g,d()};if(m<.001){if(u.toFixed(3),V?.(),U.current){const e=B.current>=0?"forward":"backward";A?.({mode:"bounce",direction:e,targetSceneIndex:"forward"===e?a+1:a-1})}return E?.(!1),void(r&&b("active"))}const h=u>0?"forward":"backward",v="forward"===h?a+1:a-1;if(0===x(u)&&0!==u)return S(!0),u.toFixed(3),g.toFixed(1),E?.(!1),A?.({mode:"bounce",direction:h,targetSceneIndex:v}),void p(.15,()=>{V?.(),b("active"),S(!1)});const k=T?.5:function(e,t){const n=t?.minVelocity??0,r=t?.maxVelocity??1e3,i=t?.minRatio??.15,a=t?.maxRatio??.3;if(!Number.isFinite(e))return a;const o=r-n;return o<=0?a:a-(Math.max(n,Math.min(r,e))-n)/o*(a-i)}(g,L);g.toFixed(1),k.toFixed(3),m.toFixed(3);const P=!l&&m>k&&(T||!(m>.001&&u*f<0&&g>600));if(u.toFixed(3),m.toFixed(3),k.toFixed(3),g.toFixed(1),f.toFixed(1),P){if(S(!0),E?.(!1),T)return j?.(h,1,d,d),void S(!1);const e=++$.current,t="forward"===h?1:-1,r=Math.abs(t-u),a=Math.max(r*(c/1e3),0),o=Math.min(m,1);A?.({mode:"settle",direction:h,targetSceneIndex:v,progressRatio:m});let s=null,l=u,f=0,g=!1,p=!1;const b=()=>{p||g||z.current!==R||(z.current=null,s?.stop(),o.toFixed(3),(1e3*a).toFixed(1),j?.(h,o,o*d,d),M?.(0),S(!1))},x=()=>{if(p||g||z.current!==R)return;const r=Math.abs(t-l)*(c/1e3);if(r<=1e-6)return void b();const i=++f;s=(0,n.animate)(l,t,{duration:r,ease:"easeOut",onUpdate:n=>{if(i===f&&!p&&!g&&$.current===e&&(l=n,Math.abs(n-t)>1e-6&&y.set(n),M?.(n),0)){const e=Math.round(10*Math.abs(n))/10;O.current!==e&&(O.current=e)}},onComplete:()=>{i===f&&(l=t,b())}})},w=()=>{p=!0,g=!1,f+=1,s?.stop()},R={kind:"settle",ownerSceneIndex:i,stop:w,suspend:()=>{p||g||(g=!0,f+=1,s?.stop())},resume:()=>{p||!g||(g=!1,x())},preempt:w,getCurrent:()=>l};u.toFixed(3),(1e3*a).toFixed(1),o.toFixed(3),z.current=R,x()}else{S(!0);const e=Math.min(m*c,300)/1e3;u.toFixed(3),(1e3*e).toFixed(1),E?.(!1),A?.({mode:"bounce",direction:h,targetSceneIndex:v}),p(e,()=>{V?.(),S(!1)})}},[e,r,z,s,i,a,c,y,R,C,M,A,j,V,E,x,w,l,S,b,T,L])}}({slideMode:f,isActive:m,sceneIndex:p,currentSceneIndex:y,totalScenes:h,slideDirection:g,slideDuration:he,sceneTransitionDuration:_,sceneOffset:ot,sceneState:it,globalDirection:b,globalRenderProgress:Xe,globalIsDragging:Ge,globalDragProgress:We,globalDragTimelineProgress:Ke,controls:Re,dragProgressMotion:et,setSceneState:at,setIsAnimating:ct,resolveDragProgress:Tt,getTimelineDuration:Mt,onOwnershipRequest:ae?.onOwnershipRequest,onCandidateSuspensionChange:ae?.onCandidateSuspensionChange,takeoverSnapshot:ae?.takeoverSnapshot,onDragProgressChange:ae?.onProgressChange??ce,onRenderProgressChange:ae?.onRenderProgressChange??le,onDragTimelineProgressChange:ae?.onTimelineProgressChange??ue??(De?void 0:e=>tt.set(e)),onDraggingChange:ae?.onDraggingChange??de??(De?void 0:ze),onDragRelease:ae?.onRelease??ge??(De?void 0:He),renderLaneRef:ae?.renderLane,completeReleaseImmediately:!De,thresholdConfig:ae?.threshold,onDragEnd:ae?.onCommit??me??(De?void 0:(e,t,n,r)=>{je(0),Le(0),$e(0),ze(!1),Be(r??0),Ue(null),qt.completeImmediately(),ie?.(e)}),onDragReset:ae?.onReset??pe??(De?void 0:()=>{je(0),Le(0),$e(0),ze(!1),Ue(null),qt.resetImmediately()})}),Kt="drag"===f&&(m||!!ae?.renderLane?.current||!!Ze),{onPointerDown:Gt,onPointerMove:_t,onPointerUp:Zt,onPointerCancel:Jt,onFramerPanStart:Qt,onFramerPan:en,onFramerPanEnd:tn}=function({enabled:e,axis:n,onCandidateStart:r,onCandidateEnd:i,onPointerSessionStart:a,onDragStart:o,onPan:s,onPanEnd:c,authoredPointerDown:l,authoredPointerMove:u,authoredPointerUp:d,authoredPointerCancel:f}){const g=function({enabled:e,axis:n,onCandidateStart:r,onCandidateEnd:i,onPointerSessionStart:a,onStart:o,onPan:s,onEnd:c}){const l=(0,t.useRef)(null),u=(0,t.useRef)(!1),d=(0,t.useRef)(0),f=(0,t.useRef)(null),g=(0,t.useRef)(null),m=(0,t.useRef)(r);m.current=r;const p=(0,t.useRef)(i);p.current=i;const h=(0,t.useRef)(a);h.current=a;const v=(0,t.useRef)(o);v.current=o;const y=(0,t.useRef)(s);y.current=s;const b=(0,t.useRef)(c);b.current=c;const S=(0,t.useCallback)(()=>{g.current?.(),g.current=null},[]),x=(0,t.useCallback)(()=>{null!==f.current&&(window.clearTimeout(f.current),f.current=null)},[]),w=(0,t.useCallback)(e=>{const t=l.current;if(!t||t.pointerId!==e.pointerId)return;const n=t.target;S(),l.current=null,t.ownsGesture?(Ln()-t.lastTime>100&&(t.velocityX=0,t.velocityY=0),n.releasePointerCapture?.(t.pointerId),b.current(e,On(t,e.clientX,e.clientY))):t.candidateSuspended&&p.current?.(),x();const r=d.current;u.current=!0;const i=window.setTimeout(()=>{f.current===i&&(f.current=null,d.current===r&&(u.current=!1))},0);f.current=i},[S,x]),R=(0,t.useCallback)(t=>{if(!e||!1===t.isPrimary||void 0!==t.button&&0!==t.button||function(e){return e instanceof Element&&!!e.closest('a,button,input,textarea,select,option,summary,[contenteditable="true"],[data-cineview-ignore-drag]')}(t.target))return;const n=l.current;n&&(n.target.releasePointerCapture?.(n.pointerId),!n.ownsGesture&&n.candidateSuspended&&p.current?.()),S(),x(),d.current+=1;const r=t.currentTarget;h.current?.();const i=m.current?.()??!1;l.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,lastTime:Ln(),velocityX:0,velocityY:0,target:r,ownsGesture:!1,candidateSuspended:i,rejectedDirections:new Set,panInfo:null},u.current=!0;const a=e=>{w(e)};window.addEventListener("pointerup",a),window.addEventListener("pointercancel",a),document.addEventListener("pointerup",a),document.addEventListener("pointercancel",a),g.current=()=>{window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",a),document.removeEventListener("pointerup",a),document.removeEventListener("pointercancel",a)}},[S,x,e,w]),M=(0,t.useCallback)(e=>{const t=l.current;if(!t||t.pointerId!==e.pointerId)return;const r=Ln();if(!t.ownsGesture){const i="y"===n?e.clientY-t.startY:e.clientX-t.startX,a="y"===n?e.clientX-t.startX:e.clientY-t.startY;if(Math.abs(i)<1||Math.abs(i)<=Math.abs(a))return;const o=i<0?"forward":"backward";if(t.rejectedDirections.has(o))return;return t.candidateSuspended||(t.candidateSuspended=m.current?.()??!1),v.current(o)?(t.ownsGesture=!0,t.startX=e.clientX,t.startY=e.clientY,t.lastX=e.clientX,t.lastY=e.clientY,t.lastTime=r,t.velocityX=0,t.velocityY=0,t.target.setPointerCapture?.(t.pointerId),void(e.cancelable&&e.preventDefault())):(t.rejectedDirections.add(o),void(t.candidateSuspended&&(p.current?.(),t.candidateSuspended=!1)))}const i=Math.max(r-t.lastTime,1);t.velocityX=(e.clientX-t.lastX)/i*1e3,t.velocityY=(e.clientY-t.lastY)/i*1e3,y.current(e.nativeEvent,On(t,e.clientX,e.clientY)),t.lastX=e.clientX,t.lastY=e.clientY,t.lastTime=r,e.cancelable&&e.preventDefault()},[n]),C=(0,t.useCallback)(e=>w(e.nativeEvent),[w]);return(0,t.useEffect)(()=>()=>{const e=l.current;e&&!e.ownsGesture&&e.candidateSuspended&&p.current?.(),S(),x(),d.current+=1,l.current=null,u.current=!1},[S,x]),{onPointerDown:R,onPointerMove:M,onPointerUp:C,onPointerCancel:C,isActiveRef:u}}({enabled:e,axis:n,onCandidateStart:r,onCandidateEnd:i,onPointerSessionStart:a,onStart:o,onPan:s,onEnd:c}),{onPointerDown:m,onPointerMove:p,onPointerUp:h,onPointerCancel:v}=g,y=(0,t.useCallback)(e=>{l?.(e),e.defaultPrevented||m(e)},[l,m]),b=(0,t.useCallback)(e=>{u?.(e),e.defaultPrevented||p(e)},[u,p]),S=(0,t.useCallback)(e=>{d?.(e),h(e)},[d,h]),x=(0,t.useCallback)(e=>{f?.(e),v(e)},[f,v]),w=(0,t.useRef)({ownsGesture:!1,candidateSuspended:!1,baseline:0,rejectedDirections:new Set}),R=(0,t.useRef)(i);R.current=i;const M=(0,t.useCallback)(e=>{const t=w.current;e&&!t.ownsGesture&&t.candidateSuspended&&R.current?.(),w.current={ownsGesture:!1,candidateSuspended:!1,baseline:0,rejectedDirections:new Set}},[]),C=(0,t.useCallback)(()=>{g.isActiveRef.current?M(!0):(M(!0),a?.(),w.current={ownsGesture:!1,candidateSuspended:r?.()??!1,baseline:0,rejectedDirections:new Set})},[M,g.isActiveRef,r,a]),k=(0,t.useCallback)((e,t)=>{if(g.isActiveRef.current)return void M(!0);const a=w.current,c="y"===n?t.offset.y:t.offset.x,l="y"===n?t.offset.x:t.offset.y;if(!a.ownsGesture){if(Math.abs(c)<1||Math.abs(c)<=Math.abs(l))return;const e=c<0?"forward":"backward";if(a.rejectedDirections.has(e))return;return a.candidateSuspended||(a.candidateSuspended=r?.()??!1),o(e)?(a.ownsGesture=!0,void(a.baseline=c)):(a.rejectedDirections.add(e),void(a.candidateSuspended&&(i?.(),a.candidateSuspended=!1)))}const u=c-a.baseline;s(e,{...t,offset:"y"===n?{x:t.offset.x,y:u}:{x:u,y:t.offset.y}})},[n,M,g.isActiveRef,i,r,o,s]),P=(0,t.useCallback)((e,t)=>{if(g.isActiveRef.current)return void M(!0);const r=w.current;if(!r.ownsGesture)return void M(!0);const i=("y"===n?t.offset.y:t.offset.x)-r.baseline;c(e,{...t,offset:"y"===n?{x:t.offset.x,y:i}:{x:i,y:t.offset.y}}),M(!1)},[n,M,g.isActiveRef,c]);return(0,t.useEffect)(()=>()=>M(!0),[M]),{onPointerDown:y,onPointerMove:b,onPointerUp:S,onPointerCancel:x,onFramerPanStart:C,onFramerPan:k,onFramerPanEnd:P}}({axis:g,enabled:Kt,onCandidateStart:Ut,onCandidateEnd:Yt,onPointerSessionStart:ae?.onPointerSessionStart,onDragStart:Ht,onPan:Wt,onPanEnd:Xt,authoredPointerDown:c,authoredPointerMove:l,authoredPointerUp:u,authoredPointerCancel:d}),nn=(0,t.useMemo)(()=>"drag"===f?{opacity:1}:Me?Me.initial:{opacity:1},[Me,f]),rn=(0,t.useMemo)(()=>"drag"===f?"none":"translateZ(0)",[f]),an=(0,t.useMemo)(()=>function(e){switch(e){case"top-left":default:return{top:0,left:0};case"top-center":return{top:0,left:"50%",transform:"translateX(-50%)"};case"top-right":return{top:0,right:0};case"center-left":return{top:"50%",left:0,transform:"translateY(-50%)"};case"center":return{top:"50%",left:"50%",transform:"translate(-50%, -50%)"};case"center-right":return{top:"50%",right:0,transform:"translateY(-50%)"};case"bottom-left":return{bottom:0,left:0};case"bottom-center":return{bottom:0,left:"50%",transform:"translateX(-50%)"};case"bottom-right":return{bottom:0,right:0}}}(H),[H]),on=(0,t.useMemo)(()=>function(e){switch(e){case"top-right":case"center-right":case"bottom-right":return{marginLeft:"auto",marginRight:0};case"top-center":case"center":case"bottom-center":return{marginLeft:"auto",marginRight:"auto"};default:return{marginLeft:0,marginRight:"auto"}}}(H),[H]),sn=(0,t.useMemo)(()=>An({effectiveMode:f,effectiveDirection:g,globalScrollTimelineState:F,globalScrollViewportOffset:z,globalViewportWidth:k,globalViewportHeight:P}),[f,g,F,z,k,P]),cn=!Kt&&("covered"===jt||"parked"===jt||"inactive"===jt),ln=cn?{"aria-hidden":!0}:void 0,un=cn||!0===e.inert;(0,t.useEffect)(()=>{const e=kt.current;e&&(e.inert=un)},[un]);const fn=(0,t.useMemo)(()=>({width:N,height:Y,position:"scroll"===f?"relative":"absolute",overflow:W,willChange:st||Je||V?"transform, opacity":"auto",contain:"drag"===f?"layout style":"layout style paint",transform:rn,userSelect:"drag"===f&&Je?"none":void 0,WebkitUserSelect:"drag"===f&&Je?"none":void 0,touchAction:Pn(f,g),zIndex:X,pointerEvents:Kt||"covered"!==jt&&"parked"!==jt&&"inactive"!==jt?"auto":"none",..."scroll"===f?on:an}),[st,Je,V,Kt,rn,f,g,N,Y,W,X,jt,on,an]);return(0,r.jsx)($n.Provider,{value:p,children:(0,r.jsx)(vn.Provider,{value:Bt,children:(0,r.jsx)(wn.Provider,{value:"scroll"===f?It:null,children:(0,r.jsx)(gn.Provider,{value:"scroll"===f?Dt:null,children:(0,r.jsxs)(n.motion.div,{ref:Pt,"data-cineview-scroll-zone":"scroll"===f?Dt??e.sceneId??void 0:void 0,initial:nn,animate:Re,...Object.fromEntries(Object.entries(e).filter(([e])=>!Fn.has(e))),className:o,style:{...s,...fn},...ln,inert:un,onPanStart:"drag"===f?Qt:void 0,onPan:"drag"===f?en:void 0,onPanEnd:"drag"===f?tn:void 0,onPointerDown:"drag"===f?Gt:c,onPointerMove:"drag"===f?_t:l,onPointerUp:"drag"===f?Zt:u,onPointerCancel:"drag"===f?Jt:d,children:["scroll"===f?(0,r.jsx)(Dn,{sceneIndex:p,metrics:sn,setHostRef:At,frameStore:ye,direction:g,viewportWidth:k,viewportHeight:P}):null,a]})})})})})}),Nn=Object.assign(zn,{cineViewScene:!0});Nn.displayName="Scene";var Bn=new Set(["width","minWidth","maxWidth","height","minHeight","maxHeight","top","bottom","left","right","inset","insetInline","insetInlineStart","insetInlineEnd","insetBlock","insetBlockStart","insetBlockEnd","margin","marginTop","marginBottom","marginLeft","marginRight","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd","borderWidth","borderTopWidth","borderBottomWidth","borderLeftWidth","borderRightWidth","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","gap","columnGap","rowGap","fontSize","letterSpacing","outlineWidth","outlineOffset"]),qn=(e,t)=>{if(!e||!t)return e;let n=!1;const r={};return Object.entries(e).forEach(([e,i])=>{const a=((e,t,n)=>n&&"number"==typeof t&&Number.isFinite(t)&&!e.startsWith("--")&&Bn.has(e)?n.convert(t):t)(e,i,t);r[e]=a,n||(n=a!==i)}),n?r:e},Un=(0,t.forwardRef)(function({width:e,height:n,children:i,style:a,className:o,...s},c){const l=v(),u=(0,t.useMemo)(()=>{if(!l)return a;const t=qn(a,l),r=void 0!==e?l.convert(e):void 0,i=void 0!==n?l.convert(n):void 0;return{...t,...void 0!==e?{width:r}:{},...void 0!==n?{height:i}:{}}},[l,e,n,a]);return(0,r.jsx)("div",{ref:c,style:u,className:o,...s,children:i})});Un.displayName="Container";var Yn=(0,t.forwardRef)(function({src:e,alt:n,width:i,height:a,style:o,loading:s,preload:c,...l},u){const d=v(),f=(0,t.useMemo)(()=>"number"!=typeof i?i:d?.convert(i)??i,[d,i]),g=(0,t.useMemo)(()=>"number"!=typeof a?a:d?.convert(a)??a,[d,a]),m=(0,t.useMemo)(()=>qn(o,d),[d,o]),p="lazy"!==s&&(c??!0),h=s??(p?"eager":"lazy");return(0,t.useEffect)(()=>{if(!p||!e||typeof window>"u"||function(e){return e.length>0&&y.has(e)}(e))return;const t=new window.Image,n=()=>{S(e)};return t.addEventListener("load",n),t.src=e,()=>{t.removeEventListener("load",n)}},[p,e]),(0,r.jsx)("img",{ref:u,...l,src:e,alt:n,width:f,height:g,style:m,loading:h})});Yn.displayName="Image";var Hn=1e-4;function Wn(e,t,n){return Math.min(n,Math.max(t,e))}function Xn(e,t){return function(e){return Number.isFinite(e)&&e>0}(e)?t?[Number.isFinite(t[0])?Wn(t[0],0,e):0,Number.isFinite(t[1])?Wn(t[1],0,e):e]:[0,e]:null}function Kn(e){return{activationId:e,status:"framework-scrub",activePlayRequestId:null,settledPlayRequestId:null,nextPlayRequestId:1,lastSeekTime:null,endpointLatched:!1,outgoingLatched:!1,frameworkPlayBlocked:!1,frameworkPausePending:!1}}function Gn(e,t=[]){return{state:e,commands:t}}function _n(e,t){return{...Kn(t),nextPlayRequestId:e.nextPlayRequestId}}function Zn(e,t){switch(t.type){case"timeline-frame":return function(e,t){const{frame:n}=t;if("exiting"===n.phase||"exited"===n.phase){if(e.outgoingLatched)return Gn(e);const t="native-playback"===e.status||"play-pending"===e.status,n=null!==e.activePlayRequestId||null!==e.settledPlayRequestId;return Gn({...e,status:"framework-scrub",activePlayRequestId:null,lastSeekTime:null,outgoingLatched:!0,frameworkPlayBlocked:e.frameworkPlayBlocked||t||n,frameworkPausePending:t},t?[{type:"pause"}]:[])}if(!e.outgoingLatched&&!function(e){return"gesture"===e||"continuation"===e||"programmatic"===e||"scroll"===e||"visibility"===e}(n.source)||!function(e,t){return"ended"!==e.status&&"play-rejected"!==e.status||("gesture"===t.source||"scroll"===t.source||"visibility"===t.source)&&t.progress<.98}(e,n))return Gn(e);const r=function(e,t,n){const r=Xn(t,n);if(!r)return null;const i=Wn(Number.isFinite(e)?e:0,0,1);return r[0]+i*(r[1]-r[0])}(n.progress,t.duration,t.scrubRange);if(null===r)return Gn(e);if(function(e){return"native-playback"===e||"native-paused"===e||"play-pending"===e}(e.status)){if(!function(e,t){return!(e.endpointLatched&&t.progress>=.98)&&("scroll"===t.source||"visibility"===t.source||"gesture"===t.source&&t.progress<.98)}(e,n))return Gn(e);const t=[],i="native-playback"===e.status||"play-pending"===e.status;return i&&t.push({type:"pause"}),(null===e.lastSeekTime||Math.abs(e.lastSeekTime-r)>Hn)&&t.push({type:"seek",time:r}),Gn({...e,status:"framework-scrub",activePlayRequestId:null,lastSeekTime:r,endpointLatched:!1,outgoingLatched:!1,frameworkPlayBlocked:!0,frameworkPausePending:i},t)}const i=[];if((null===e.lastSeekTime||Math.abs(e.lastSeekTime-r)>Hn)&&i.push({type:"seek",time:r}),function(e,t){if(!e.scrubRange||t||e.frame.progress<.999)return!1;const n=Xn(e.duration,e.scrubRange);return!!n&&n[1]<e.duration-Hn}(t,e.endpointLatched)){const t=e.nextPlayRequestId;return i.push({type:"play",requestId:t}),Gn({...e,status:"play-pending",activePlayRequestId:t,settledPlayRequestId:null,nextPlayRequestId:t+1,lastSeekTime:r,endpointLatched:!0,outgoingLatched:!1,frameworkPlayBlocked:!1},i)}const a=!!(t.scrubRange&&n.progress>=.999),o=n.progress<.98;return Gn({...e,status:"framework-scrub",activePlayRequestId:null,lastSeekTime:r,endpointLatched:!!a||!o&&e.endpointLatched,outgoingLatched:!1},i)}(e,t);case"media-play":return t.activationId!==e.activationId?Gn(e):void 0!==t.requestId?e.activePlayRequestId===t.requestId||"native-playback"===e.status&&!e.frameworkPlayBlocked&&e.settledPlayRequestId===t.requestId?Gn({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:t.requestId,frameworkPausePending:!1,frameworkPlayBlocked:!1}):Gn({...e,frameworkPausePending:!0,frameworkPlayBlocked:!0},[{type:"pause"}]):e.frameworkPlayBlocked?Gn({...e,frameworkPausePending:!0},[{type:"pause"}]):Gn({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:null,frameworkPausePending:!1,frameworkPlayBlocked:!1});case"media-pause":return t.activationId!==e.activationId?Gn(e):e.frameworkPausePending?Gn({...e,frameworkPausePending:!1}):Gn({...e,status:"ended"===e.status?"ended":"native-paused",activePlayRequestId:null,settledPlayRequestId:"ended"===e.status?e.settledPlayRequestId:null,frameworkPlayBlocked:"ended"===e.status&&e.frameworkPlayBlocked});case"media-ended":return t.activationId!==e.activationId?Gn(e):Gn({...e,status:"ended",activePlayRequestId:null,endpointLatched:!0,frameworkPausePending:!1});case"play-resolved":return e.activePlayRequestId!==t.requestId?Gn(e):Gn({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:t.requestId,frameworkPlayBlocked:!1,frameworkPausePending:!1});case"play-rejected":return e.activePlayRequestId!==t.requestId?Gn(e):Gn({...e,status:"play-rejected",activePlayRequestId:null,settledPlayRequestId:null,frameworkPlayBlocked:!1,frameworkPausePending:!1});case"activate":return e.activationId===t.activationId?Gn(e):Gn(_n(e,t.activationId));case"reset":return Gn(_n(e,t.activationId))}}var Jn=!0,Qn=(0,t.forwardRef)(function({src:e,progress:n,timelineFrame:i,scrubRange:a,width:o,height:s,style:c,"aria-label":l,preload:u=!0,poster:d,playbackRate:f,onEnded:g,onPlay:m,onPause:p,onTimeUpdate:h,onError:y,controlRef:b},S){const R=v(),k=(0,t.useRef)(null),[P,I]=(0,t.useState)(()=>({src:e,url:E(e)??null})),D=P.src===e?P.url:null,V=(0,t.useRef)([]),L=(0,t.useRef)(Kn(0)),O=(0,t.useRef)(0),$=(0,t.useRef)(void 0),F=(0,t.useRef)(0),z=(0,t.useRef)({src:e,objectUrl:D}),N=(0,t.useRef)(null),B=(0,t.useRef)(()=>{}),q=(0,t.useRef)(new WeakMap),U=(0,t.useRef)(null),H=(0,t.useRef)(null),W=(0,t.useCallback)((e,t)=>{const n=N.current,r=F.current;if(n&&(n.video!==e||n.activationId!==t||n.generation!==r)&&(n.video.removeEventListener("loadstart",n.loadStart,Jn),n.video.removeEventListener("play",n.play,Jn),n.video.removeEventListener("pause",n.pause,Jn),n.video.removeEventListener("ended",n.ended,Jn),N.current=null),!e||N.current)return;const i=()=>O.current===t&&F.current===r,a=()=>i()&&U.current===r,o=()=>{i()&&(U.current=r)},s=e=>{q.current.set(e,{generation:r,activationId:t})},c=e=>{if(!a())return;const n=$.current,i=n?.generation===r&&n.activationId===t?n.requestId:void 0,o=L.current,c=void 0!==i&&(!o.frameworkPlayBlocked&&o.activePlayRequestId===i||"native-playback"===o.status&&!o.frameworkPlayBlocked&&o.settledPlayRequestId===i),l=void 0===i&&!o.frameworkPlayBlocked;void 0!==i&&($.current=void 0),c||l?(s(e),B.current({type:"media-play",requestId:i,activationId:t})):B.current({type:"media-play",requestId:i,activationId:t})},l=e=>{a()&&(L.current.frameworkPausePending||($.current=void 0),s(e),B.current({type:"media-pause",activationId:t}))},u=e=>{a()&&(s(e),B.current({type:"media-ended",activationId:t}))};e.addEventListener("loadstart",o,Jn),e.addEventListener("play",c,Jn),e.addEventListener("pause",l,Jn),e.addEventListener("ended",u,Jn),N.current={video:e,generation:r,activationId:t,loadStart:o,play:c,pause:l,ended:u}},[]),[X,K]=(0,t.useState)(!1),[G,_]=(0,t.useState)(0),[Z,J]=(0,t.useState)(0),Q=(0,t.useCallback)((e=!0)=>{O.current+=1,L.current=Zn(L.current,{type:"reset",activationId:O.current}).state,$.current=void 0,V.current=[],W(e?k.current:null,O.current)},[W]);(0,t.useEffect)(()=>{const e={release:()=>{const e=k.current;K(!0),e&&(e.pause(),H.current=e.getAttribute("src"),e.removeAttribute("src"),e.load()),Q(!1)},warmUp:()=>{const e=k.current;if(e&&!e.getAttribute("src")){const t=H.current;t&&(e.src=t,H.current=null)}K(!1),_(e=>e+1),Q(!1)}};return b&&(b.current=e),()=>{b&&(b.current=null)}},[b,Q]);const ee=(0,t.useCallback)(e=>{e||W(null,O.current),k.current=e,e&&W(e,O.current),function(e,t){"function"==typeof e?e(t):e&&(e.current=t)}(S,e)},[W,S]),te=(0,t.useMemo)(()=>"number"==typeof o?R?.convert(o)??o:o,[R,o]),ne=(0,t.useMemo)(()=>"number"==typeof s?R?.convert(s)??s:s,[R,s]),re=(0,t.useMemo)(()=>qn(c,R??null),[R,c]);(0,t.useEffect)(()=>{if(typeof window>"u"||!e)return void I({src:e,url:null});let t=!0,n=!1;const r=()=>{const t=function(e){const t=x.get(e);if(t)return A(e),C.set(e,(C.get(e)??0)+1),t.objectUrl}(e);return!!t&&(n=!0,I({src:e,url:t}),!0)};let i=()=>{};return r()||(I({src:e,url:null}),i=function(e){return M.add(e),()=>{M.delete(e)}}(i=>{i===e&&t&&!n&&r()})),()=>{t=!1,i(),n&&function(e){const t=C.get(e)??0;t<=1?C.delete(e):C.set(e,t-1),T("")}(e)}},[e]),(0,t.useEffect)(()=>{typeof window>"u"||!e||!u||function(e){return e.length>0&&w.has(e)}(e)||j(e,"video").catch(()=>{})},[u,e]),(0,t.useEffect)(()=>{K(!1),_(e=>e+1)},[e]),Y(()=>{const e=k.current;e&&(e.playbackRate=f??1)},[Z,D,f,X,e]);const ie=(0,t.useCallback)((e,t)=>{e.currentTime=t},[e]),ae=(0,t.useCallback)(e=>{const t=k.current;if(!t)return;const n=Zn(L.current,e);L.current=n.state,n.commands.forEach(e=>{switch(e.type){case"pause":return void t.pause();case"seek":return void ie(t,e.time);case"play":{const n={requestId:e.requestId,generation:F.current,activationId:L.current.activationId,settled:!1};$.current=n;const r=t=>{if($.current===n&&!n.settled){if(n.settled=!0,"play-rejected"===t&&($.current=void 0),F.current!==n.generation||L.current.activationId!==n.activationId)return void($.current=void 0);ae({type:t,requestId:e.requestId})}};let i;try{i=t.play()}catch{return void r("play-rejected")}return void Promise.resolve(i).then(()=>r("play-resolved"),()=>r("play-rejected"))}}})},[ie]);Y(()=>{B.current=ae;const t=z.current;let n=!1;(t.src!==e||t.objectUrl!==D)&&(z.current={src:e,objectUrl:D},F.current+=1,U.current=null,Q(),n=!0),!n&&k.current&&k.current.readyState>=1&&(U.current=F.current),W(k.current,O.current)},[W,ae,G,D,Q,e]),(0,t.useEffect)(()=>()=>W(null,O.current),[W]),(0,t.useEffect)(()=>{if(!i)return;const e=k.current;if(!e||typeof window>"u")return;let t=i.get();const n=n=>{t=n;const r=L.current;if("entering"===n.phase&&("ended"===r.status||r.outgoingLatched))return O.current+=1,W(null,O.current),ae({type:"activate",activationId:O.current}),void J(e=>e+1);!Number.isFinite(e.duration)||e.duration<=0||ae({type:"timeline-frame",frame:n,duration:e.duration,scrubRange:a})},r=()=>n(t),o=i.on("change",n);return e.readyState>=1?r():e.addEventListener("loadedmetadata",r,{once:!0}),()=>{o(),e.removeEventListener("loadedmetadata",r)}},[W,ae,G,Z,D,a,i]),(0,t.useEffect)(()=>{if(i)return;const e=k.current;if(!e||typeof window>"u")return;const t="object"==typeof n?n:null,r=t=>{const n=e.duration;!Number.isFinite(n)||n<=0||ie(e,(t<0?0:t>1?1:t)*n)},a=()=>r(t?.get()??n),o=t?.on("change",r);return e.readyState>=1?a():e.addEventListener("loadedmetadata",a,{once:!0}),()=>{o?.(),e.removeEventListener("loadedmetadata",a)}},[G,D,n,ie,i]);const oe=e=>{const t=q.current.get(e);return q.current.delete(e),!(!t||t.generation!==F.current||t.activationId!==O.current)},se=X&&P.src===e,ce=JSON.stringify([e,D,Z,se?"released":"active"]);return(0,r.jsx)("video",{ref:ee,src:(se?void 0:D??e)||void 0,muted:!0,playsInline:!0,preload:se?"none":u?"auto":D?"metadata":"none","aria-label":l,width:te,height:ne,style:re,poster:d||void 0,onPlay:e=>{oe(e.nativeEvent)&&m?.(e)},onPause:e=>{oe(e.nativeEvent)&&p?.(e)},onEnded:e=>{oe(e.nativeEvent)&&g?.(e)},onTimeUpdate:h,onError:y},ce)});Qn.displayName="VideoFrameRenderer";var er={initial:{opacity:1},animate:{opacity:1}},tr=(0,t.forwardRef)(function({src:e,"aria-label":n,width:i,height:a,style:o,preload:s,poster:c,playbackRate:l,scrubRange:u,releaseOnLeave:d,onEnded:f,onPlay:g,onPause:m,onTimeUpdate:p,onError:h},v){const y=cn(),b=function(e,n){const r=(0,t.useRef)(null),i=cn(),a=(0,t.useContext)(gn),o=function(e,n=!0){return function(e,n,r){const i=(0,t.useContext)(fn),a=r(e?i?.zoneStates?.[e]??null:null),o=n&&e?i?.store:void 0,s=(0,t.useCallback)(t=>o&&e?o.subscribeKey(e,t):()=>{},[o,e]),c=(0,t.useCallback)(()=>r(o&&e?o.getKeySnapshot(e)??null:e?i?.zoneStates?.[e]??null:null),[r,o,i?.zoneStates,e]);return(0,t.useSyncExternalStore)(s,c,()=>a)}(e,n,(0,t.useCallback)(e=>e?.approach??null,[]))}(e?a:null,!0===e),s=(0,t.useRef)(!1),c=(0,t.useRef)(!!e),l=i.progress;return(0,t.useEffect)(()=>{s.current=!1},[n]),(0,t.useEffect)(()=>{if(!e)return;const t=e=>{Math.abs(e)>1e-4&&(s.current=!0)};return t(l.get()),l.on("change",t)},[l,e]),(0,t.useEffect)(()=>{const t=c.current;if(c.current=!!e,e){if(o){if("far"===o)return void(s.current&&r.current?.release());r.current?.warmUp()}}else t&&r.current?.warmUp()},[o,e]),r}(d,e);return(0,r.jsx)(Qn,{ref:v,controlRef:b,src:e,progress:y.progress,timelineFrame:y.frame,"aria-label":n,width:i,height:a,style:o,preload:s,poster:c,playbackRate:l,scrubRange:u,onEnded:f,onPlay:g,onPause:m,onTimeUpdate:p,onError:h})}),nr=(0,t.forwardRef)(function({src:e,"aria-label":t,width:n,height:i,style:a,preload:o,poster:s,playbackRate:c,scrubRange:l,animateId:u,duration:d,enterAnimation:f,exitAnimation:g,timeline:m,visibility:p,releaseOnLeave:h,onEnded:v,onPlay:y,onPause:b,onTimeUpdate:S,onError:x},w){return(0,r.jsx)(Sn,{animateId:u,enterAnimation:f??er,exitAnimation:g,duration:{enter:d?.enter,exit:d?.exit},timeline:m,visibility:p,children:(0,r.jsx)(tr,{ref:w,src:e,"aria-label":t,width:n,height:i,style:a,preload:o,poster:s,playbackRate:c,scrubRange:l,releaseOnLeave:h,onEnded:v,onPlay:y,onPause:b,onTimeUpdate:S,onError:x})})});nr.displayName="AnimateVideo";var rr=Sn,ir=Rn,ar=Nn,or=(0,t.forwardRef)((e,n)=>{const r=e.mode;if(void 0!==r&&"drag"!==r)throw new Error(`[Cineview] This artifact (cineview.umd.js / "cineview/drag") contains only the drag engine and does not support mode="${r}". For scroll mode, load cineview-scroll.umd.js (or import "cineview/scroll"); for runtime mode switching, use the full entry import "cineview".`);return(0,t.createElement)(Me,{...e,mode:"drag",ref:n})});or.displayName="CineviewDragOnly";var sr=or;e.Animate=rr,e.AnimateVideo=nr,e.Cineview=sr,e.Container=Un,e.Image=Yn,e.Position=ir,e.Scene=ar,e.useAnimateTimeline=cn});
|
|
2
2
|
//# sourceMappingURL=cineview-drag.umd.js.map
|