cineview 1.0.0 → 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.
Files changed (52) hide show
  1. package/README.md +87 -251
  2. package/README.zh-CN.md +87 -251
  3. package/dist/animations/presets/index.d.ts +1 -1
  4. package/dist/artifacts.json +2 -2
  5. package/dist/cineview-dev.es.mjs +1 -1
  6. package/dist/cineview-drag.umd.js +1 -1
  7. package/dist/cineview-scroll.umd.js +1 -1
  8. package/dist/cineview.es.mjs +1 -1
  9. package/dist/cineview.umd.js +1 -1
  10. package/dist/components/Animate/animateSemantics.d.ts +0 -1
  11. package/dist/components/{CineView/CineView.d.ts → Cineview/Cineview.d.ts} +3 -5
  12. package/dist/components/Cineview/CineviewDispatch.d.ts +2 -0
  13. package/dist/components/Cineview/DirectScrollCineview.d.ts +8 -0
  14. package/dist/components/{CineView → Cineview}/directScrollHelpers.d.ts +4 -2
  15. package/dist/components/Cineview/index.d.ts +5 -0
  16. package/dist/components/{CineView → Cineview}/preloadTargets.d.ts +2 -2
  17. package/dist/components/{CineView → Cineview}/regroupCallbacks.d.ts +5 -5
  18. package/dist/components/{CineView/useCineViewImperativeApi.d.ts → Cineview/useCineviewImperativeApi.d.ts} +3 -3
  19. package/dist/components/{CineView → Cineview}/useScrollZoneRegistry.d.ts +3 -2
  20. package/dist/components/Scene/sceneScrollBudget.d.ts +2 -0
  21. package/dist/components/Scene/sceneScrollRuntime.d.ts +0 -1
  22. package/dist/components/Scene/useSceneAnimationRegistry.d.ts +2 -2
  23. package/dist/components/Scene/useSceneScrollTakeover.d.ts +0 -1
  24. package/dist/components/runtime/runtimeContext.d.ts +3 -3
  25. package/dist/components/runtime/scrollSceneFrameStore.d.ts +1 -1
  26. package/dist/context/{CineViewContext.d.ts → CineviewContext.d.ts} +8 -8
  27. package/dist/dev/PerfPanel.d.ts +1 -1
  28. package/dist/dev/usePerfMonitor.d.ts +4 -4
  29. package/dist/entry-drag.d.ts +5 -5
  30. package/dist/entry-scroll.d.ts +5 -5
  31. package/dist/hooks/useFirstSceneEnter.d.ts +3 -3
  32. package/dist/hooks/usePrefersReducedMotion.d.ts +1 -1
  33. package/dist/hooks/useSceneManager.d.ts +1 -0
  34. package/dist/index.d.ts +1 -1
  35. package/dist/public-api.d.ts +1 -1
  36. package/dist/types/index.d.ts +39 -42
  37. package/dist/utils/animationHelpers.d.ts +2 -2
  38. package/dist/utils/devLog.d.ts +1 -1
  39. package/dist/utils/performanceMonitor.d.ts +1 -1
  40. package/package.json +17 -13
  41. package/dist/components/CineView/CineViewDispatch.d.ts +0 -2
  42. package/dist/components/CineView/DirectScrollCineView.d.ts +0 -5
  43. package/dist/components/CineView/index.d.ts +0 -5
  44. /package/dist/components/{CineView → Cineview}/DragSceneStack.d.ts +0 -0
  45. /package/dist/components/{CineView → Cineview}/ScrollSceneSlot.d.ts +0 -0
  46. /package/dist/components/{CineView → Cineview}/ScrollSceneStack.d.ts +0 -0
  47. /package/dist/components/{CineView → Cineview}/ScrollbarOverlay.d.ts +0 -0
  48. /package/dist/components/{CineView → Cineview}/useNativeScrollController.d.ts +0 -0
  49. /package/dist/components/{CineView → Cineview}/useScrollInputBindings.d.ts +0 -0
  50. /package/dist/components/{CineView → Cineview}/useScrollSceneLayout.d.ts +0 -0
  51. /package/dist/components/{CineView → Cineview}/useScrollSceneSnapshots.d.ts +0 -0
  52. /package/dist/components/{CineView → Cineview}/useScrollViewport.d.ts +0 -0
@@ -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,h,v,S,y,x,b,w,R,M,E,k=m({fadeAnimations:()=>p}),I=g(()=>{p={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}}}}),P=m({slideAnimations:()=>h}),C=g(()=>{h={"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}}}}),D=m({zoomAnimations:()=>v}),A=g(()=>{v={"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}}}}),T=m({rotateAnimations:()=>S}),L=g(()=>{S={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}}}}),O=m({flipAnimations:()=>y}),V=g(()=>{y={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}}}}),j=m({bounceAnimations:()=>x}),z=g(()=>{x={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}}}}}),F=m({blinkAnimations:()=>b}),N=g(()=>{b={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}}}}),$=m({shakeAnimations:()=>w}),B=g(()=>{w={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}}}}),W=m({blurAnimations:()=>R}),H=g(()=>{R={"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}}}}),q=m({elasticAnimations:()=>M}),U=g(()=>{M={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}}}}),Y=m({specialAnimations:()=>E}),X=g(()=>{E={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}}}}),K=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 Z(e){return e instanceof K}var _={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"},G=["fade","slide","zoom","rotate","flip","bounce","blink","shake","blur","elastic","special"],J=new Map,Q=new Map,ee=new Map,te=new Map,ne=new Map,re={left:"0%",center:"50%",right:"100%"},ie={top:"0%",center:"50%",bottom:"100%"},ae={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 oe(e,t){return Array.isArray(t)?t.map(t=>oe(e,t)):t&&"object"==typeof t?se(t):"transformOrigin"===e&&"string"==typeof t?function(e){const t=e.trim().toLowerCase().replace(/\s+/g," "),n=ae[t];if(n)return n;const r=t.split(" ");if(1===r.length){const t=re[r[0]],n=ie[r[0]];return t&&n?`${t} ${n}`:t?`${t} 50%`:n?`50% ${n}`:e}if(2===r.length){const[e,t]=r,n=re[e]??re[t],i=ie[e]??ie[t];if(n&&i)return`${n} ${i}`}return e}(t):t}function se(e){const t={};return Object.entries(e).forEach(([e,n])=>{t[e]=oe(e,n)}),t}function ce(e){return{initial:se(e.initial||{}),animate:se(e.animate||{}),exit:se(e.exit||{})}}var le=async e=>"string"==typeof e?await(async e=>ce(await async function(e){const t=ne.get(e);if(t)throw t;const n=_[e];if(!n){const t=new K("INVALID_ANIMATION",`Unknown preset animation: ${e}`,{permanent:!0,presetName:e});throw ne.set(e,t),t}const r=(await function(e){const t=J.get(e);if(t)return Promise.resolve(t);const n=te.get(e);if(n)return Promise.reject(n);if(!function(e){return G.includes(e)}(e)){const t=new K("INVALID_ANIMATION",`Unknown animation category: ${e}`,{permanent:!0,category:e});return te.set(e,t),ee.set(e,"failed-permanent"),Promise.reject(t)}const r=Q.get(e);if(r)return r;ee.set(e,"pending");const i=function(e,t){return new Promise((n,r)=>{const i=setTimeout(()=>{r(new K("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(()=>(I(),k))).fadeAnimations;case"slide":return(await Promise.resolve().then(()=>(C(),P))).slideAnimations;case"zoom":return(await Promise.resolve().then(()=>(A(),D))).zoomAnimations;case"rotate":return(await Promise.resolve().then(()=>(L(),T))).rotateAnimations;case"flip":return(await Promise.resolve().then(()=>(V(),O))).flipAnimations;case"bounce":return(await Promise.resolve().then(()=>(z(),j))).bounceAnimations;case"blink":return(await Promise.resolve().then(()=>(N(),F))).blinkAnimations;case"shake":return(await Promise.resolve().then(()=>(B(),$))).shakeAnimations;case"blur":return(await Promise.resolve().then(()=>(H(),W))).blurAnimations;case"elastic":return(await Promise.resolve().then(()=>(U(),q))).elasticAnimations;case"special":return(await Promise.resolve().then(()=>(X(),Y))).specialAnimations;default:throw new K("INVALID_ANIMATION",`Unknown animation category: ${e}`,{permanent:!0,category:e})}}(e),e).then(t=>(J.set(e,t),ee.set(e,"success"),t)).catch(t=>{const n=function(e,t){return Z(t)?t:new K("ANIMATION_ASSET_LOAD_FAILED",`Failed to load animation category "${e}".`,{permanent:!1,category:e,cause:t})}(e,t);throw ee.set(e,n.permanent?"failed-permanent":"failed-transient"),n.permanent&&te.set(e,n),n}).finally(()=>{Q.get(e)===i&&Q.delete(e)});return Q.set(e,i),i}(n))[e];if(r)return r;const i=new K("INVALID_ANIMATION",`Preset animation "${e}" is missing from category "${n}".`,{permanent:!0,category:n,presetName:e});throw ne.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=>ce({initial:e.initial??{},animate:e.animate??{},exit:e.exit??{}}))(e)}catch(e){return null}})(e):null,ue=e=>{const t={};return e.forEach(e=>{Object.assign(t,e)}),t},de=async e=>{const t=[];for(let n=0;n<e.length;n++){const r=await le(e[n]);r&&t.push({variant:r,sourceIndex:n})}return t},fe=e=>{const{transition:t,...n}=e.animate;return{values:n,transition:t||{}}},ge=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 me(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 de(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}=fe(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:ge(o),exit:i}})(n,r):"parallel"===t?await(async(e,t=[])=>{const n=await de(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}=fe(e);return{values:i,transition:{...a,delay:r/1e3}}}),a=n.map(({variant:e})=>e.exit);return{initial:ue(r),animate:ge(i),exit:ue(a)}})(n,r):null}catch(e){if(Z(e))throw e;return null}})(e):await le(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=Z(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 pe(e){return"string"==typeof e&&!e.includes("(")&&e.trim().includes(" ")}function he(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(pe(s)||pe(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 ve(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 Se(e,t,n){return Math.min(n,Math.max(t,e))}function ye(e,t,n){return e+(t-e)*n}function xe(e,t,n){if("number"==typeof e&&"number"==typeof t)return ye(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=ye(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=ye(e,t,n);return`${c[1]}(${i}${r})`}return n>=1?t:e}function be(e,t,n,r,i){const a=t[n]??r,o=Se(i,0,1);if(!Array.isArray(a))return xe(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 ve(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 xe(ve(a,t-1,e),ve(a,t,e),c)}return ve(a,a.length-1,e)}function we(e,t,n){const r=e[t]??n;return Array.isArray(r)?ve(r,r.length-1,n):r}function Re(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 Me(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 Ee(e,t,n){const r=e[t];return void 0===r?n:r}function ke(e,t,r,i){return(0,n.useTransform)(e,e=>i(e,t.current,r))}function Ie(e,t,r,i,a){return(0,n.useTransform)(e,e=>{const n=Re(Me(r,"animate"),0);return Re((a??i)(e,t.current,r),n)})}function Pe(e,t,n,r){const i=Ie(e,t,"opacity",n,r),a=ke(e,t,"x",n),o=ke(e,t,"y",n),s=Ie(e,t,"scale",n,r),c=ke(e,t,"rotate",n),l=ke(e,t,"rotateX",n),u=ke(e,t,"rotateY",n),d=ke(e,t,"skewX",n),f=ke(e,t,"skewY",n),g=ke(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 Ce=.001;function De(e){return e.renderProgressMotion?.get()??e.renderProgress??0}function Ae(e){return e.dragTransaction?e.dragTransaction:!0===e.firstSceneEnterActive?e.preparedSnapshot??null:null}function Te(e){return Ae(e)?.registrySnapshot.timelineDuration??e.getTimelineDuration?.()??e.sceneTransitionDuration}function Le(e,t,n,r,i,a){const o=function(e,t,n,r){const i=function(e){return De(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 Se("number"==typeof t?t:Math.abs(De(e)),0,1)}(e),s=function(e){const t=Te(e);if(Ae(e))return t;const n=e.sharedTimelineDurationMs??0;return n>0?n:t}(e),c=Te(e),l=Math.abs(De(e)),u=function(e,t,n){return n<=0?e>=t-Ce?1:0:e<=t?0:Se((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>Ce){if(l<=Ce&&t)return{...d,mode:"enter",localProgress:u};const n=Math.max(r,1),i=l*e.sceneTransitionDuration;return{...d,mode:"outgoing",localProgress:Se(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>Ce)?{...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 Oe(e,t,n){return e?function(e,t,n){const r=we(t.enterInitial,n,Me(n,"initial")),i=we(t.enterAnimate,n,Me(n,"animate"));switch(e.mode){case"rest":default:return i;case"hidden":return r;case"enter":return be(r,t.enterAnimate,n,Me(n,"animate"),e.localProgress);case"outgoing":return 0===Object.keys(t.exitTarget).length?i:"forward"===e.direction?be(i,t.exitTarget,n,Me(n,"exit"),e.localProgress):be(r,t.enterAnimate,n,Me(n,"animate"),1-e.localProgress)}}(e,t,n):we(t.enterAnimate,n,Me(n,"animate"))}var Ve=(0,t.createContext)(null),je=({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)(Ve.Provider,{value:l,children:(0,r.jsx)("div",{className:"cineview-responsive-container",style:u,children:n})})},ze=()=>(0,t.useContext)(Ve),Fe=(0,t.createContext)(null);function Ne(){return(0,t.useContext)(Fe)}var $e=new WeakMap,Be=new WeakMap;function We(e,t){return"entered"===e&&t}function He(e,t,n,r){return void 0===e?t:n+(r-n)*Se(e,0,1)}function qe(e,t,n){return xe(Ee(t.initial,n,Me(n,"initial")),Ee(t.animate,n,Me(n,"animate")),e)}function Ue(e,t,n){const r=Re(Me(n,"animate"),0),i=Re(Ee(t.initial,n,Me(n,"initial")),r);return i+(Re(Ee(t.animate,n,Me(n,"animate")),r)-i)*e}function Ye(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 Xe(e){return e<=0?0:e>=1?1:e}function Ke(e,t){return{enterProgress:Xe(t),phase:e}}function Ze(e,t){const n=t<=0?0:t>=1?1:t;return{enterProgress:n,phase:Ye(e,n)}}var _e={enterProgress:0,phase:"idle"};function Ge({signedVisual:e,phaseMotion:i,render:a}){const[o,s]=(0,t.useState)(()=>Ke(i.get(),e.get()));return(0,n.useMotionValueEvent)(e,"change",e=>{s(Ke(i.get(),e))}),(0,n.useMotionValueEvent)(i,"change",t=>{s(Ke(t,e.get()))}),(0,r.jsx)(r.Fragment,{children:a(o)})}function Je({visualState:e,render:i}){const[a,o]=(0,t.useState)(()=>{const t=e.get();return t?Ze(t.mode,t.localProgress):_e});return(0,n.useMotionValueEvent)(e,"change",e=>{o(e?Ze(e.mode,e.localProgress):_e)}),(0,r.jsx)(r.Fragment,{children:i(a)})}function Qe(e){if("string"==typeof e){const t=n.motion[e];if(t)return t}return n.motion.div}function et(e,t,n){return"last"===n?t-1-e:"center"===n?Math.abs(e-(t-1)/2):e}function tt(e){return t.Children.toArray(e.props.children).filter(t.isValidElement)}function nt(e){return tt(e).length}function rt(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,et(e,i,r));const u=l*c;return{itemDurationMs:s,tailDurationMs:u,effectiveDurationMs:Math.max(t,u+s)}}function it(e,t,n,r,i){return rt(e,t??0,n,r,nt(i)).effectiveDurationMs}function at(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 ot(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 st(e,n,i,a,o,s,c,l,u=!1){const d=t.Children.toArray(e.props.children),f=tt(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:et(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:et(e,f,a)*g}}}};let v=0;const S=d.map((e,n)=>{if(!(0,t.isValidElement)(e))return e;const i=v;v+=1;const a=Qe(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)}),y=Qe(e.type),{children:x,...b}=e.props;return(0,r.jsx)(y,{...b,initial:"initial",animate:m,variants:{initial:{},animate:{},exit:{}},children:S})}function ct({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,exitVariant:o,exitItemDurationMs:s,signedVisual:c}){const[l,u]=at(c,e=>e>0?"animate":e<0&&o?"exit":"initial");return st(e,t,n,r,l,i,o,s,ot(l,a??it(t,i,n,r,e),u))}function lt({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,phaseMotion:o,staticReveal:s}){const[c,l]=at(o,e=>"entering"===e||"entered"===e?"animate":"initial"),u=ot(c,a??it(t,i,n,r,e),l);return st(e,t,n,r,c,i,void 0,void 0,s||u)}function ut({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,exitVariant:o,exitItemDurationMs:s,visualState:c}){const[l,u]=at(c,e=>"outgoing"===e?.mode&&o?"exit":e&&("enter"===e.mode&&e.localProgress>0||"rest"===e.mode)?"animate":"initial");return st(e,t,n,r,l,i,o,s,ot(l,a??it(t,i,n,r,e),u))}var dt=(0,t.createContext)(null);function ft({value:e,children:t}){return(0,r.jsx)(dt.Provider,{value:e,children:t})}function gt(){const e=(0,t.useContext)(dt);if(!e)throw new Error("useAnimateTimeline must be used inside an <Animate> child.");return e}var mt=Object.freeze({progress:0,signedProgress:0,phase:"idle",source:"idle"});function pt(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 ht=(0,t.createContext)(null),vt=(0,t.createContext)(null),St=(0,t.createContext)(null);function yt(e){if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function xt(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(!yt(e)||!yt(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)=>xt(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]||!xt(i[t],a[t],n,r))return!1}return!0}finally{n.delete(i),r.delete(a)}}function bt(e){const n=(0,t.useRef)(e);return xt(n.current,e,new WeakMap,new WeakMap)||(n.current=e),n.current}var wt=(0,t.createContext)(null),Rt=Object.freeze({opacity:1}),Mt=0,Et=({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-"+ ++Mt).current,p=(0,t.useContext)(wt),h=Ne(),v=h?.reportError,S=!0===h?.prefersReducedMotion,y=(0,t.useContext)(ht),x=(0,t.useContext)(St),[b,w]=(0,t.useState)(null),[R,M]=(0,t.useState)(null),[E,k]=(0,t.useState)(null),[I,P]=(0,t.useState)(0),C=(0,t.useRef)(0),D=(0,t.useRef)(null),A=(0,t.useRef)(new Set),T=(0,t.useRef)(null),L=(0,t.useRef)(new Set),O=bt(e),V=bt(i),j=bt(a),z=(0,n.useAnimation)(),F=(0,n.useAnimation)(),N=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,zoneId:t?.zoneId,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}),$=p?.mode??h?.mode??"drag",B="drag"===$&&"clock"===N.timeline.driver,W=(0,t.useRef)(null),H="drag"===$&&p?.isActive?p.activationToken??0:0;(null===W.current||W.current.mode!==$||W.current.token!==H||0===H&&W.current.arrival!==B)&&(W.current={token:H,mode:$,arrival:B});const q="drag"===$&&W.current.arrival,U=p?.beginPreparation,Y=p?.declareAnimateLane,X=(0,t.useMemo)(()=>{const{driver:e,...t}=N.timeline;return{...t,lane:"scroll"===$&&"scene"===e&&x?"scroll":"visibility"}},[x,$,N.timeline]),K=N.duration.enter,Z=N.duration.exit,_=X.delay,G=X.after,J=X.zoneId??x,Q=(0,t.useContext)(vt),ee=q&&p?.isActive?p.activationToken??0:0,te=I>0&&D.current?.enterAnimation===O&&D.current?.exitAnimation===V&&D.current?.loopAnimation===j,ne=(0,t.useRef)(null),re=ne.current;q&&(0===ee||null===re||re.token!==ee)&&(ne.current={token:ee,ready:te,enterVariant:te?b:null,exitVariant:te?R:null,infiniteVariant:te?E:null,hasAuthoredEnterAnimation:!!O,enterDuration:K,exitDuration:Z,delay:_,stagger:u,enterAnimation:O,exitAnimation:V,loopAnimation:j});const ie=q?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=b,ie.exitVariant=R,ie.infiniteVariant=E);const ae=ie?ie.enterAnimation:O,oe=ie?ie.exitAnimation:V,se=ie?ie.loopAnimation:j,ce=ie?.ready?ie.enterVariant:q?null:b,le=ie?.ready?ie.exitVariant:q?null:R,ue=ie?.ready?ie.infiniteVariant:q?null:E,de=ie?.enterDuration??K,fe=ie?.exitDuration??Z,ge=ie?.delay??_,pe=ie?ie.stagger:u;(0,t.useEffect)(()=>{if(!q)return;const e=Y?.(m,"visibility");return()=>e?.dispose()},[Y,m,q]),(0,t.useEffect)(()=>{if(!q)return;const e=(e,t)=>{const n=`${m}:${e}`;A.current.has(n)||(A.current.add(n),v?.({code:"INVALID_ANIMATION",message:t,context:{componentId:m,field:e,lane:"visibility",mode:"drag"}}))};G&&e("after",`Animate "${m}" ignores after in drag mode when timeline.driver is 'clock'.`),V&&e("exitAnimation",`Animate "${m}" ignores exitAnimation in drag mode when timeline.driver is 'clock'.`)},[m,q,G,v,V]);const he="function"==typeof g,ve=!(!ae&&!se||(q?ie?.ready??te:te)||ce||le||ue),ye="drag"===$?!q:"scroll"===X.lane,xe="scroll"===$&&!ye,Re=(0,t.useRef)(new Set);(0,t.useEffect)(()=>{if(!d&&!f)return;const e=(e,t)=>{const n=`${m}:${e}`;Re.current.has(n)||(Re.current.add(n),v?.({code:"INVALID_ANIMATION",message:t,context:{componentId:m,field:e,mode:$,scrub:ye}}))};if(ye){const t="drag"===$?"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.`))}q&&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,q,ye,$,v]);const Ee=q?pe:u,ke=Ee&&!he&&ce&&(0,t.isValidElement)(g)?g:null,Ie=!!ke,Ce=Ee?.each??40,Te=Ee?.from??"first",Ve=(0,t.useMemo)(()=>ke&&ce?rt(ce,de,Ce,Te,nt(ke)):null,[de,ce,ke,Ce,Te]),je=(0,t.useMemo)(()=>ke&&le?rt(le,fe,Ce,Te,nt(ke),"exit"):null,[fe,le,ke,Ce,Te]),Fe=Ve?.effectiveDurationMs??de,Ke=je?.effectiveDurationMs??fe,Ze=(0,t.useMemo)(()=>y?{...y,zoneStates:Q?.zoneStates??{},store:Q?.store}:null,[y,Q?.store,Q?.zoneStates]);(0,t.useEffect)(()=>{const e=L.current,t=++C.current,n=()=>C.current===t;T.current?.lease.cancel(),T.current=null;const r="drag"!==$||q?void 0:U?.();r&&e.add(r),T.current=r?{generation:t,lease:r}:null;const i=e=>{n()&&v?.(e)};return w(null),M(null),k(null),P(0),ae||se?((async()=>{const[e,n,r]=await Promise.all([me(ae,m,"enter",i),me(oe,m,"exit",i),me(se,m,"loop",i)]);C.current===t&&(D.current={enterAnimation:ae,exitAnimation:oe,loopAnimation:se},w(e??null),M(n??null),k(r??null),P(t))})(),()=>{e.forEach(e=>e.cancel()),e.clear(),n()&&(C.current+=1)}):(v?.({code:"INVALID_ANIMATION",message:`Animate "${m}" requires enterAnimation or loopAnimation.`,context:{componentId:m,hasExitAnimation:!!oe}}),(()=>{const n=T.current;!n||n.generation!==t||(n.lease.complete(),e.delete(n.lease),T.current=null)})(),()=>{e.forEach(e=>e.cancel()),e.clear(),n()&&(C.current+=1)})},[m,$,q,v,U,ae,oe,se]),(0,t.useEffect)(()=>{!q||0===ee||!ie||(ie.enterAnimation!==O||ie.exitAnimation!==V||ie.loopAnimation!==j)&&Promise.all([me(O,m,"enter"),me(V,m,"exit"),me(j,m,"loop")])},[ie,ee,m,q,O,V,j]);const Qe=function({sceneContext:e,enterVariant:r,exitVariant:i,componentId:a,delay:o,enterDuration:s,exitDuration:c,after:l,variantsPending:u=!1}){const d=e?Ae(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,S=(0,t.useRef)(h),y=(0,t.useRef)(d);y.current=d;const x=(0,t.useRef)({enterInitial:v?.initial||{},enterAnimate:v?.animate||{},exitTarget:i?.exit||{}}),b=e?Le(e,S.current,p,c,m,u):null,w=b?"outgoing"===b.mode?("forward"===b.direction?1:-1)*b.localProgress:b.localProgress:0,R=(0,n.useMotionValue)(w),M=(0,n.useMotionValue)(b),[E,k]=(0,t.useState)(!1),I=((0,t.useRef)(null),(0,t.useRef)(null)),P=(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)(()=>{x.current={enterInitial:v?.initial||{},enterAnimate:v?.animate||{},exitTarget:i?.exit||{}},d&&(S.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),y.current||(S.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)S.current=h;else{const t=e.getCalculatedDelay?.(a);"number"==typeof t&&(S.current=t)}const t=Le(e,S.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=I.current!==r;if(R.set(n),M.set(t),I.current=r,i&&(t.mode,t.direction,e.sceneOffset,e.isActive,e.isDragging,e.sceneState,De(e).toFixed(3),t.transitionProgress.toFixed(3),t.sharedElapsedMs.toFixed(1),t.projectedSceneElapsedMs.toFixed(1),t.sharedTimelineDurationMs,t.sceneTimelineDurationMs,t.localProgress.toFixed(3),S.current),"enter"===t.mode){const n=t.localProgress<=.001?"before-delay":t.localProgress>=.999?"enter-complete":"enter-active";P.current!==`${t.mode}:${n}`&&(t.mode,t.sharedElapsedMs.toFixed(1),t.projectedSceneElapsedMs.toFixed(1),t.sharedTimelineDurationMs,t.sceneTimelineDurationMs,t.transitionProgress.toFixed(3),S.current,t.localProgress.toFixed(3),De(e).toFixed(3),e.sceneOffset,P.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 C=Pe(M,x,Oe);return(0,t.useEffect)(()=>{if(!e)return void k(!1);const t=()=>{const t=Le(e,S.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:C.style,opacity:C.opacity,x:C.x,y:C.y,scale:C.scale,rotate:C.rotate,useInteractiveStyles:!0,shouldRunInfinite:E,visualState:M}}({sceneContext:"drag"!==$||q?null:p,enterVariant:b,exitVariant:R,componentId:m,delay:_,enterDuration:Fe,exitDuration:Ke,after:G,variantsPending:ve}),et=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,S]=(0,t.useState)(!1),y=(0,t.useRef)(null),x=(0,t.useRef)(null),b=(0,t.useRef)(0),w=(0,t.useRef)(0),R=(0,t.useRef)(null),M=(0,t.useRef)(!1),E=(0,t.useRef)(0===(r?.activationToken??0)),k=(0,t.useRef)(r);k.current=r;const I=(0,t.useCallback)(()=>{y.current?.stop(),y.current=null,null!==x.current&&(clearTimeout(x.current),x.current=null)},[]),P=(0,t.useCallback)(()=>{const e=f.current;I(),b.current=0,w.current=0,R.current=null,M.current=!1,h(!1),S(!1),m.set(e.hasAuthoredEnterAnimation?"idle":"entered"),g.set(e.hasAuthoredEnterAnimation?0:1)},[m,I,g]),C=(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(b.current===e)return;w.current=0,b.current=e,I(),R.current=null,h(!1),u.current={initial:i.enterVariant?.initial??{},animate:i.enterVariant?.animate??{}};const a="static"===t&&E.current;S(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():x.current=setTimeout(()=>{x.current=null,s()},e)})();m.set("waiting"),g.set(0);const c=()=>{if(x.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);y.current=(0,n.animate)(g,1,{duration:e/1e3,ease:"easeInOut",onComplete:()=>{y.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?x.current=setTimeout(c,l):c()},[m,I,g]),D=e&&r?.isActive?r.activationToken??0:0,A=r?.activationKind??null;(0,t.useEffect)(()=>{D<=0?P():C(D,A)},[A,D,P,C]),(0,t.useEffect)(()=>{const e=w.current;e<=0||!o||C(e,k.current?.activationKind??null)},[i,o,C]),(0,t.useEffect)(()=>()=>{I(),b.current=0,w.current=0},[I]);const T=(0,t.useCallback)(()=>{const e=R.current;e?(R.current=null,M.current=!1,null!==x.current&&(clearTimeout(x.current),x.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:Pe(g,u,qe,Ue).style,visualMotion:g,phaseMotion:m,shouldRunInfinite:p,staticReveal:v}}({enabled:q,sceneContext:"drag"===$?p:null,enterVariant:ce,hasAuthoredEnterAnimation:ie?.hasAuthoredEnterAnimation??!!e,parseReady:ie?.ready??I>0,delay:ge,enterDuration:Fe,enterRef:q?d:void 0}),tt=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:v,variantsPending:S=!1}){const y=d.enter,x=d.exit,b=!0===Ne()?.prefersReducedMotion,w=b?0:y,R=b?0:x,M=f.delay,E=f.after,k="scroll"===f.lane,I=f.phase?.start,P=f.phase?.end,C=g.replay,D=ze()?.scale??1,A=g.enterMargin??m??50,T=g.exitMargin??p??50,L=Math.max(0,A*D),O=Math.max(0,T*D),V=(0,t.useRef)({enterInitial:{},enterAnimate:{},exitTarget:{}}),j=(0,n.useMotionValue)(0),z=(0,n.useMotionValue)(i&&r?r.store?.getKeySnapshot(i)??r.zoneStates[i]??null:null),[F,N]=(0,t.useState)(!1),$=(0,t.useRef)(null),[B,W]=(0,t.useState)(0),H=r?.registerZoneAnimation,q=r?.unregisterZoneAnimation,U=!!(a?.animate&&Object.keys(a.animate).length>0)||!!s,Y=function(e,t){return!!(t>0&&e?.exit&&Object.keys(e.exit).length>0)}(o,x)||!!c;(0,t.useEffect)(()=>{V.current={enterInitial:a?.initial||{},enterAnimate:a?.animate||{},exitTarget:o?.exit||{}}},[a,o]);const X=(0,t.useRef)("idle"),K=(0,n.useMotionValue)("idle"),Z=(0,t.useCallback)(e=>{X.current=e,K.set(e)},[K]),_=(0,t.useRef)(null),G=(0,t.useRef)(null),J=(0,t.useRef)(0),Q=(0,t.useRef)(!1),ee=(0,t.useRef)(null),te=(0,t.useRef)(null),ne=(0,t.useRef)(null),re=(0,t.useRef)(()=>{}),ie=(0,t.useRef)(0),ae=(0,t.useRef)(null),oe=(0,t.useRef)(!1),se=(0,t.useRef)(!1),ce=(0,t.useRef)(!1),le=(0,t.useCallback)(()=>r&&i?r.store?.getKeySnapshot(i)??r.zoneStates[i]??null:null,[i,r]);(0,t.useEffect)(()=>{if(!k||!r||!i)return void z.set(null);const e=()=>{z.set(le())};return e(),r.store?.subscribeKey(i,e)},[k,le,i,r,z]);const ue=!!h&&!k&&!(E||M>0),de=!!v&&!k,fe=(0,t.useRef)(!1),ge=(0,t.useRef)(!1),me=(0,t.useCallback)(e=>{e?.publishEnterCompleted()},[]),pe=(0,t.useCallback)(()=>{ie.current+=1,ae.current=null,ee.current&&(clearTimeout(ee.current),ee.current=null),te.current&&(te.current(),te.current=null),ne.current&&(ne.current(),ne.current=null)},[]),he=(0,t.useCallback)(()=>{J.current+=1,G.current&&(G.current.stop(),G.current=null),pe()},[pe]),ve=(0,t.useCallback)(()=>{const e=$.current?.ownerDocument?.defaultView;e&&(ne.current?.(),ne.current=function(e,t){let n=Be.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},Be.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&&Be.get(e)===r&&Be.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,Be.get(e)===r&&Be.delete(e))}}(e,()=>{ne.current=null,re.current()}))},[]),ye=(0,t.useCallback)(()=>{pe(),Z("entering"),j.get()<0&&j.set(0);const e=_.current,t=++J.current,r=(0,n.animate)(j,1,{duration:Math.max(w,0)/1e3,ease:"easeInOut",onComplete:()=>{J.current===t&&(G.current=null,Z("entered"),me(e),ve())}});G.current=r},[pe,w,me,ve,Z,j]),xe=(0,t.useCallback)((e=!1)=>{const t=X.current,n="exited"===t?"exited":"exiting"===t?"exiting":"idle";he();const r={token:++ie.current,origin:n,dependencyReady:!E,delayStarted:!1,delayReady:!1,coldStartBypass:e};ae.current=r,Z("waiting"),N(!1);const i=e=>{ae.current?.token!==r.token||"pending"===e.kind||(r.dependencyReady=!0,te.current=null,ve())};if(!E)return;const a=_.current;a?te.current=a.observeAfter(i):i({kind:"invalid",leaderId:E,reason:"missing"})},[ve,Z,he,E]),Re=(0,t.useCallback)(()=>{const e=ae.current;if(e&&e.dependencyReady){if(!e.delayStarted){if(e.delayStarted=!0,M>0){const t=e.token;return void(ee.current=setTimeout(()=>{ee.current=null,ae.current?.token===t&&(e.delayReady=!0,ve())},M))}e.delayReady=!0}e.delayReady&&ye()}},[M,ye,ve]),Ee=(0,t.useCallback)(()=>{he(),Z("exiting"),N(!1),j.get()>=0&&j.set(-1e-6);const e=++J.current,t=(0,n.animate)(j,-1,{duration:Math.max(R,0)/1e3,ease:"easeInOut",onComplete:()=>{J.current===e&&(G.current=null,Z("exited"))}});G.current=t},[R,he,Z,j]),ke=(0,t.useCallback)(t=>{if(k||S)return;const n=$.current;if(!(n instanceof HTMLElement))return;const r=e?.firstSceneEnterGateKnown,i=e?.firstSceneEnterReady,a=e?.firstSceneEnterActive;if(!1===r)return he(),Z("idle"),j.set(0),void N(!1);if(!1===i&&!0===a)return se.current=!1,he(),Z("idle"),j.set(0),void N(!1);const o=!1===i&&!1===a&&!se.current&&!ue;o&&(se.current=!0,oe.current=!0,he(),Z("entered"),j.set(1),me(_.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-L,m=g?d<=u/2:d>=0&&f<=u-L,p=g?f<=.7*u:d<=O||f>=u-O,h=g?m&&!p:m,v=f<=0,y=f>0&&d<u;if(o)return v&&(ce.current=!1),void N(We("entered",y));if(!oe.current){if(oe.current=!0,ue)return void N(!1);if(v)return he(),Z("entered"),j.set(1),me(_.current),N(We("entered",!1)),void(ce.current=!1);if(!0===i&&!g&&d>=0&&f<=u)return xe(!0),void Re()}if("waiting"===X.current){const e=ae.current;if(e&&(!0===e?.coldStartBypass&&!0===i&&!g&&d>=0&&f<=u||h&&!p))Re();else{const t=e?.origin??"idle";pe(),Z(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}}(X.current,h,p,{hasExplicitExit:Y,replay:C});y&&!ce.current&&(ce.current=!0),"enter"!==e||ue||fe.current||ge.current?"exit"===e&&!de&&(!ce.current&&v||Ee()):(xe(),Re())}N(We(X.current,y))},[Re,ue,de,xe,pe,L,O,Y,k,me,C,Ee,e?.firstSceneEnterGateKnown,e?.firstSceneEnterActive,e?.firstSceneEnterReady,Z,he,S,j]);re.current=ke;const Ie=(0,t.useCallback)(()=>{fe.current=!0,ge.current=!1,oe.current=!0,se.current=!0,ye()},[ye]),Ce=(0,t.useCallback)(()=>{ge.current=!0,Ee()},[Ee]);(0,t.useEffect)(()=>{if(h&&!k)return h.current=Ie,()=>{h.current===Ie&&(h.current=null)}},[h,k,Ie]),(0,t.useEffect)(()=>{if(v&&!k)return v.current=Ce,()=>{v.current===Ce&&(v.current=null)}},[v,k,Ce]),(0,t.useEffect)(()=>{const t=e?.registerAnimate,n=e?.unregisterAnimate;if(!t||!U&&!Y)return;const r=t(u,{delay:M,duration:U?y:x,after:E,lane:k?"scroll":"visibility"});return _.current=r??null,Q.current=!1,()=>{pe(),_.current===r&&(_.current=null),r?.dispose?r.dispose():n?.(u)}},[e?.registerAnimate,e?.unregisterAnimate,pe,u,M,y,x,E,U,Y,k]),(0,t.useEffect)(()=>{if(typeof document>"u"||S||$.current?.isConnected)return;const e=document.querySelector(`[data-cineview-animate-host="${u}"]`)??document.querySelector(`[data-cineview-animate-id="${u}"]`);e instanceof HTMLElement&&$.current!==e&&($.current=e,W(e=>e+1))},[u,a,o,S]),(0,t.useEffect)(()=>{if(!(k&&H&&q&&i&&(U||Y)))return;const e=H(i,{animateId:u,delay:M,enterDuration:y,exitDuration:Y?x:0,after:E,...void 0!==I||void 0!==P?{phase:{start:I,end:P}}:{}});return()=>{q(i,u,e)}},[u,M,y,x,Y,U,k,P,I,i,E,H,q]);const De=(0,t.useCallback)(e=>{if(!U&&!Y)return"entered"!==X.current&&Z("entered"),void(1!==j.get()&&j.set(1));if(!r||!i)return void(0!==j.get()&&j.set(0));const t=e?.sequence.budgets[u];if(!e||!t)return void(0!==j.get()&&j.set(0));const n=Se(e.progressPx,0,e.totalBudgetPx),a=t.enterStartPx,o=Math.max(t.enterEndPx,t.enterStartPx+1),s="number"==typeof t.phaseStartPx?t.phaseStartPx:He(I,a,a,o),c=Math.max("number"==typeof t.phaseEndPx?t.phaseEndPx:He(P,o,a,o),s+1);if(n>=c&&!Q.current&&(Q.current=!0,me(_.current)),n<=s)return void(0!==j.get()&&j.set(0));if(!t.hasExit)return n>=c?void(1!==j.get()&&j.set(1)):void j.set(Se((n-s)/Math.max(c-s,1),0,1));const l=t.exitStartPx??c,d=t.exitEndPx??l+1;n<=c?j.set(Se((n-s)/Math.max(c-s,1),0,1)):n<=l?1!==j.get()&&j.set(1):n>=d?-1!==j.get()&&j.set(-1):j.set(-Se((n-l)/Math.max(d-l,1),0,1))},[u,U,Y,P,I,me,Z,j,i,r]);(0,t.useEffect)(()=>{if(!k)return;const e=()=>De(z.get());return e(),U||Y?z.on("change",e):void 0},[De,U,Y,k,z]),(0,t.useEffect)(()=>{k||ke()},[B,k,ke,e?.scrollProgress,e?.scrollTimelineState]),(0,t.useEffect)(()=>{if(k)return;const e=$.current;return e instanceof HTMLElement&&!(typeof window>"u")?function(e,t){const n=function(e){const t=$e.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}),$e.set(e,o),o}(e);return n.subscribers.add(t),n.schedule(),()=>{n.subscribers.delete(t),0===n.subscribers.size&&(n.cleanup(),$e.delete(e))}}(e.closest('[data-cineview-container="true"]')??window,ke):void 0},[B,k,ke]),(0,t.useEffect)(()=>he,[he]);const Ae=(0,t.useRef)(!1),Te=(0,t.useCallback)(t=>{if(!(l&&k&&r&&i))return void(Ae.current&&(Ae.current=!1,N(!1)));const n=e?.runtimeState,a=void 0===n||"covered"!==n&&"inactive"!==n&&"parked"!==n&&"exiting"!==n;if(!U&&!Y)return void(Ae.current!==a&&(Ae.current=a,N(a)));const o=t?.sequence.budgets[u];if(!t||!o||!a)return void(Ae.current&&(Ae.current=!1,N(!1)));const s=Se(t.progressPx,0,t.totalBudgetPx),c=o.enterStartPx,d=Math.max(o.enterEndPx,o.enterStartPx+1),f="number"==typeof o.phaseStartPx?o.phaseStartPx:He(I,c,c,d),g=Math.max("number"==typeof o.phaseEndPx?o.phaseEndPx:He(P,d,c,d),f+1),m=U?s>=g-.5:s>.5,p=!o.hasExit||null===o.exitStartPx||s<=o.exitStartPx+.5,h=m&&p;Ae.current!==h&&(Ae.current=h,N(h))},[u,U,Y,l,k,P,I,e?.runtimeState,N,i,r]);return(0,t.useEffect)(()=>{if(k&&l)return Te(z.get()),U||Y?z.on("change",Te):void 0;Te(null)},[U,Y,l,k,Te,z]),{style:Pe(j,V,(e,t,n)=>function(e,t,n){const r=n>=0,i=r?e.enterAnimate:e.exitTarget;return be(we(r?e.enterInitial:e.enterAnimate,t,Me(t,r?"initial":"animate")),i,t,Me(t,r?"animate":"exit"),r?n:Math.abs(n))}(t,n,e)).style,shouldRunInfinite:F,visualMotion:j,phaseMotion:K}}({sceneContext:"scroll"===$?p:null,zoneRuntime:"scroll"===$?Ze:null,zoneId:J,enterVariant:b,exitVariant:R,hasAuthoredEnterAnimation:!!e,hasAuthoredExitAnimation:!!i,hasInfiniteAnimation:!!E,componentId:m,duration:{enter:Fe,exit:Ke},timeline:X,visibility:N.visibility,globalEnterMargin:h?.scrollEnterMargin,globalExitMargin:h?.scrollExitMargin,enterRef:xe?d:void 0,exitRef:xe?f:void 0,variantsPending:ve});(0,t.useEffect)(()=>{if("drag"!==$||0===I)return;const e=T.current;!e||e.generation!==I||(e.lease.complete(),T.current=null)},[$,I]);const it=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)(mt);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:Xe(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(mt);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:Ye(e.mode,t),source:pt(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:$,isDragArrival:q,timelineLane:"scroll"===$||q?X.lane:"drag",sceneContext:p,arrivalVisualMotion:et.visualMotion,arrivalPhaseMotion:et.phaseMotion,scrollVisualMotion:tt.visualMotion,scrollPhaseMotion:tt.phaseMotion,dragVisualState:Qe.visualState});(0,t.useEffect)(()=>{const e=q?ue:E;if("drag"===$&&e){if(S||!(q?et.shouldRunInfinite:Qe.shouldRunInfinite))return void z.stop();z.start({...e.animate,transition:{...e.animate.transition||{},repeat:1/0}})}},[et.shouldRunInfinite,z,Qe.shouldRunInfinite,E,q,$,S,ue]),(0,t.useEffect)(()=>{if("scroll"===$&&E){if(S||!tt.shouldRunInfinite)return void F.stop();F.start({...E.animate,transition:{...E.animate.transition||{},repeat:1/0}})}},[$,E,S,tt.shouldRunInfinite,F]);const at=he?g:void 0,ot=he?null:g,st=(0,r.jsx)(ft,{value:it,children:Ie?ke&&ce?"scroll"===$?(0,r.jsx)(ct,{container:ke,variant:ce,each:Ce,from:Te,itemDurationMs:Ve?.itemDurationMs,effectiveDurationMs:Ve?.effectiveDurationMs,exitVariant:le,exitItemDurationMs:je?.itemDurationMs,signedVisual:tt.visualMotion}):q?(0,r.jsx)(lt,{container:ke,variant:ce,each:Ce,from:Te,itemDurationMs:Ve?.itemDurationMs,effectiveDurationMs:Ve?.effectiveDurationMs,phaseMotion:et.phaseMotion,staticReveal:et.staticReveal}):(0,r.jsx)(ut,{container:ke,variant:ce,each:Ce,from:Te,itemDurationMs:Ve?.itemDurationMs,effectiveDurationMs:Ve?.effectiveDurationMs,exitVariant:le,exitItemDurationMs:je?.itemDurationMs,visualState:Qe.visualState}):null:at?"scroll"===$||q?(0,r.jsx)(Ge,{signedVisual:q?et.visualMotion:tt.visualMotion,phaseMotion:q?et.phaseMotion:tt.phaseMotion,render:at}):(0,r.jsx)(Je,{visualState:Qe.visualState,render:at}):ot}),dt=Ie?Rt:tt.style,gt=Ie?Rt:q?et.style:Qe.style;return ce||le||ue||ve?"scroll"===$?ue?(0,r.jsx)("div",{"data-cineview-animate-host":m,children:(0,r.jsx)(n.motion.div,{style:dt,className:"cineview-animate","data-cineview-animate-id":m,children:(0,r.jsx)(n.motion.div,{animate:F,children:st})})}):(0,r.jsx)("div",{"data-cineview-animate-host":m,children:(0,r.jsx)(n.motion.div,{style:dt,className:"cineview-animate","data-cineview-animate-id":m,children:st})}):ue?(0,r.jsx)(n.motion.div,{style:gt,className:"cineview-animate","data-cineview-animate-id":m,children:(0,r.jsx)(n.motion.div,{animate:z,children:st})}):(0,r.jsx)(n.motion.div,{style:gt,className:"cineview-animate","data-cineview-animate-id":m,children:st}):(0,r.jsx)(ft,{value:it,children:at?at(_e):ot})};Et.displayName="Animate";var kt=(0,t.createContext)({lastX:0,lastY:0}),It=(0,t.createContext)(null),Pt=(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=ze(),p=Ne(),h=(0,t.useContext)(kt),v=(0,t.useContext)(It),S=e?.x??n,y=e?.y??a,x=e?.offsetX??o,b=e?.offsetY??s,w=c,R=e?.anchor,M="center"===R||"center-x"===R,E="center"===R||"center-y"===R,k=w&&"scroll"===p?.mode&&!v,{finalLeft:I,finalTop:P,finalX:C,finalY:D}=(0,t.useMemo)(()=>{const e=m?.convert??(e=>e);if(void 0!==S||void 0!==y){const t=void 0!==S?S:0,n=void 0!==y?y:0;return{finalLeft:e(t),finalTop:e(n),finalX:t,finalY:n}}if(void 0!==x||void 0!==b){const t=h.lastX+(void 0!==x?x:0),n=h.lastY+(void 0!==b?b:0);return{finalLeft:e(t),finalTop:e(n),finalX:t,finalY:n}}return{finalLeft:0,finalTop:0,finalX:0,finalY:0}},[m,h,x,b,S,y]),{leftStyle:A,topStyle:T,centerTransform:L}=(0,t.useMemo)(()=>{const e=m?.convert??(e=>e),t=[];let n=I;if(M){const r=e(S??0);n=0===r?"50%":`calc(50% + ${r}px)`,t.push("translateX(-50%)")}let r=P;if(E){const n=e(y??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,M,E,S,y,I,P]),O=(0,t.useMemo)(()=>({lastX:C,lastY:D}),[C,D]),V=(0,t.useMemo)(()=>{const e=[L,u?.transform].filter(Boolean).join(" ")||void 0;return{...u,position:k?"sticky":"absolute",left:A,top:T,pointerEvents:w?u?.pointerEvents??"auto":u?.pointerEvents,transform:e}},[k,w,A,T,L,u]),j=(0,r.jsx)(kt.Provider,{value:O,children:(0,r.jsx)("div",{ref:g,style:V,className:d,...f,children:l})});return w&&v&&!k?(0,i.createPortal)(j,v):j});Pt.displayName="Position";var Ct={opacity:1,x:0,y:0,scale:1,rotate:0};function Dt(e,t){return function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}(e)?{...t,...e}:t}function At(e){return Math.max(0,Math.min(e,1))}var Tt="time",Lt={time:10,percent:1},Ot={unit:Tt,scale:Lt[Tt]};function Vt(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:Tt,scale:Lt.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:Lt[a]}):{unit:a,scale:o??Lt[a]}}function jt(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))}function zt(e,t){return"drag"!==e?"auto":"y"===t?"pan-x pinch-zoom":"pan-y pinch-zoom"}function Ft({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 Nt({onVisibilityChange:e,sceneVisibilityCallback:t,sceneIndex:n,visible:r,progress:i}){e?.(r,i),t?.({sceneIndex:n,visible:r,progress:i})}function $t({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 Bt({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=$t({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 Wt(e,t){return e===t||"visibility"===e&&"scroll"===t}var Ht=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 qt(e){return new Ht(e)}function Ut(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 Yt(e,t){const n=Ut(t);e.some(e=>Ut(e)===n)||e.push(t)}function Xt({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=>{Yt(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)),Yt(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||Wt(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 Yt(a,{type:"incompatible-lane",animateId:e,after:u.after,followerLane:u.lane,leaderLane:i.lane});else void 0===u.lane||void 0===o||Wt(u.lane,o)?Yt(a,{type:"missing-dependency",animateId:e,after:u.after}):Yt(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 Kt(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 Zt(e){let t;return e.forEach(e=>{t=e}),t}function _t(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 Gt(){return typeof performance<"u"?performance.now():Date.now()}function Jt(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}function Qt(e){return Math.max(0,Math.min(Number.isFinite(e)?e:0,1))}function en(e){return Object.freeze({...e,mapping:Object.freeze({...e.mapping}),enterVariantsByAnimateId:qt(e.enterVariantsByAnimateId)})}var tn=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,en(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=Qt(n);return Object.freeze({...e,phase:t,releaseSeed:Object.freeze({progressRatio:r,elapsedMs:jt(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=Qt(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:jt(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()}},nn=t.default.createContext(null),rn=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"]),an=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:v,globalDirection:S,globalSharedTimelineDurationMs:y,globalActivationToken:x,globalActivationKind:b,globalFirstSceneEnterGateKnown:w,globalFirstSceneEnterActive:R,globalFirstSceneEnterReady:M,globalViewportWidth:E,globalViewportHeight:k,globalDragProgress:I,globalRenderProgress:P,globalDragTimelineProgress:C,globalIsDragging:D,globalDragRelease:A,globalScrollProgress:T,globalIsScrolling:L,globalScrollDirection:O,globalScrollTransitionSnapshot:V,globalScrollBackdropActive:j,globalScrollTimelineState:z,globalScrollViewportOffset:F,resolvedSceneWidth:N,resolvedSceneHeight:$,resolvedSceneAnchor:B,resolvedSceneOverflow:W,resolvedSceneZIndex:H,effectiveSceneStackMode:q,resolvedSceneTransitionDuration:U,resolvedEnterAnimation:Y,resolvedExitAnimation:X,sceneVisibilityCallback:K,onVisibilityChange:Z,onSceneChange:_,dragRuntime:G,onActivationComplete:J,onDragProgressChange:Q,onRenderProgressChange:ee,onDragTimelineProgressChange:te,onDraggingChange:ne,onSharedTimelineDurationChange:re,onDragRelease:ie,onDragGestureEnd:ae,onDragReset:oe,slideDuration:se,compatFields:ce}=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),le=e.scrollRuntime?.frameStore,ue=e.scrollRuntime?.sceneIndex??p,de=ze(),fe=Ne(),ge=fe?.reportError,pe=(0,n.useAnimation)(),[ve,Se]=(0,t.useState)(null),[ye,xe]=(0,t.useState)(null),be=(0,t.useRef)(0);(0,t.useRef)(null);const we=bt(Y),Re=bt(X),Me=!!(G||e.onDragProgressChange||e.onRenderProgressChange||e.onDragTimelineProgressChange||e.onDraggingChange||e.onSharedTimelineDurationChange||e.onDragGestureEnd||e.onDragReset),[Ee,ke]=(0,t.useState)(I),[Ie,Pe]=(0,t.useState)(P),[Ce,De]=(0,t.useState)(C),[Ae,Te]=(0,t.useState)(D),[Le,Oe]=(0,t.useState)(y),[Ve,je]=(0,t.useState)(A),Fe=(0,t.useRef)(0),$e=(0,t.useCallback)(e=>{null!==e?(Fe.current+=1,je({...e,token:Fe.current})):je(null)},[]),Be=Me?I:Ee,We=Me?P:Ie,He=Me?C:Ce,qe=Me?D:Ae,Ue=Me?y:Le,Ye=Me?A:Ve,Xe=qe,Ke=(0,n.useMotionValue)(Be),Ze=G?.renderProgressMotion??Ke,_e=(0,n.useMotionValue)(He),Ge=G?.timelineProgressMotion??_e,Je=(0,n.useMotionValue)(0),[Qe,et]=(0,t.useState)("initial"),tt=p-v,[nt,rt]=(0,t.useState)(!1),it=(0,t.useRef)(Symbol(`scene:${p}`)),at=(0,t.useRef)(null),ot=(0,t.useRef)(G?.onPreparedInvalidated);ot.current=G?.onPreparedInvalidated;const[st,ct]=(0,t.useState)(null),lt=(0,t.useMemo)(()=>G?.dragMappingConfig??Vt(void 0,e.drag),[G?.dragMappingConfig,e.drag]),ut=(0,t.useCallback)((t,n,r)=>{if("drag"!==f)return;const i=en({sceneIndex:p,instanceId:it.current,revision:n,enabled:!1!==e.drag?.enabled,mapping:lt,registrySnapshot:t,enterVariantsByAnimateId:r});at.current=i,ct(i),G?.onPrepared?.(i)},[G,f,lt,e.drag?.enabled,p]),{timelineDuration:dt,beginPreparation:ft,registerAnimate:gt,declareAnimateLane:mt,unregisterAnimate:pt,getCalculatedDelay:vt,getTimelineDuration:yt}=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)(Xt({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),S=(0,t.useRef)(null),y=(0,t.useRef)(!0),x=(0,t.useRef)(r);x.current=r;const b=(0,t.useRef)(i);b.current=i;const w=(0,t.useRef)(n),[R,M]=(0,t.useState)(n),[E,k]=(0,t.useState)(!1),I=(0,t.useCallback)(()=>{y.current&&k(!1)},[]),P=(0,t.useCallback)(t=>{t.forEach(t=>{const n=Kt(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.`),x.current?.({code:r,message:i,context:{sceneIndex:e}})})},[e]),C=(0,t.useCallback)(()=>{s.current.clear(),c.current.clear(),l.current.clear(),a.current.forEach((e,t)=>{const n=Zt(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)})},[]),D=(0,t.useCallback)(()=>{C();const e=Xt({baseDuration:n,registrations:s.current,declaredLanes:c.current,duplicateIds:l.current});return u.current=e,w.current=e.timelineDuration,y.current&&M(t=>t===e.timelineDuration?t:e.timelineDuration),e},[n,C]),A=(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&&!Wt(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=Zt(i);return t&&A(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&&!Wt(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}},[A]),L=(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))},[]),O=(0,t.useCallback)(e=>{g.current.forEach(t=>{[...t].forEach(n=>{n.follower.disposed||n.terminal?t.delete(n):(L(n,T(n,e)),n.terminal&&t.delete(n))})}),g.current.forEach((e,t)=>{0===e.size&&g.current.delete(t)})},[L,T]),V=(0,t.useCallback)(e=>{if(0!==p.current||!y.current)return;const t=new Map;a.current.forEach((e,n)=>{const r=Zt(e);r?.enterVariant&&t.set(n,r.enterVariant)});const n=v.current,r=S.current,i=null!==n&&null!==r&&function(e,t){return e.timelineDuration===t.timelineDuration&&_t(e.registrations,t.registrations,(e,t)=>e.delay===t.delay&&e.duration===t.duration&&e.after===t.after&&e.lane===t.lane)&&_t(e.calculatedDelays,t.calculatedDelays)&&e.issues.length===t.issues.length&&e.issues.every((e,n)=>Kt(e)===Kt(t.issues[n]))}(n,e)&&_t(r,t);k(!0),!i&&(h.current+=1,v.current=e,S.current=new Map(t),b.current?.(function(e){const t=[];return e.registrations.forEach((e,n)=>{t.push([n,Object.freeze({...e})])}),Object.freeze({registrations:qt(t),calculatedDelays:qt(e.calculatedDelays),issues:Object.freeze([...e.issues]),timelineDuration:e.timelineDuration})}(e),h.current,t))},[]),j=(0,t.useCallback)(()=>{if(0!==p.current||!y.current)return;null!==f.current&&(clearTimeout(f.current),f.current=null);const e=D();P(e.issues),O(!0),V(e)},[V,D,O,P]),z=(0,t.useCallback)(()=>{I(),null!==f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,j()},0)},[j,I]),F=(0,t.useCallback)(()=>{p.current+=1,I();let e=!1;const t=()=>!e&&(e=!0,p.current=Math.max(0,p.current-1),0===p.current);return{complete:()=>{t()&&j()},cancel:()=>{t()&&z()}}},[j,I,z]),N=(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)})},[]),$=(0,t.useCallback)(e=>{if(e.disposed)return;e.disposed=!0,N(e);const t=a.current.get(e.id);t?.delete(e.token),0===t?.size&&a.current.delete(e.id),D(),z()},[D,N,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),D(),z(),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,z())},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),L(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,O(!1))},dispose:()=>$(n)}},[$,L,T,D,O,e,z]),W=(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),D(),z(),{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),D(),z()}}},[D,z]),H=(0,t.useCallback)(e=>{const t=a.current.get(e),n=t?Zt(t):void 0;n&&$(n)},[$]),q=(0,t.useCallback)(e=>u.current.calculatedDelays.get(e)??s.current.get(e)?.delay??0,[]),U=(0,t.useCallback)(()=>w.current,[]);return(0,t.useEffect)(()=>{z()},[n,z]),(0,t.useEffect)(()=>{y.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()=>{y.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:E,beginPreparation:F,registerAnimate:B,declareAnimateLane:W,unregisterAnimate:H,getCalculatedDelay:q,getTimelineDuration:U}}({sceneIndex:p,baseDuration:"drag"===f?0:U,reportError:fe?.reportError,onStableSnapshot:ut}),xt=(0,t.useRef)(!1);(0,t.useEffect)(()=>{xt.current||t.default.Children.count(a)>0||(xt.current=!0,ge?.({code:"EMPTY_SCENES",message:`Scene ${p} has no children; it renders an empty full-screen layer.`,context:{scope:"scene",sceneIndex:p}}))},[a,ge,p]),(0,t.useEffect)(()=>()=>{const e=at.current;e&&ot.current?.({sceneIndex:e.sceneIndex,instanceId:e.instanceId,revision:e.revision})},[]);const Rt=(0,t.useRef)(null),Mt=(0,t.useCallback)(e=>{Rt.current=e,"function"==typeof i?i(e):i&&(i.current=e)},[i]),[Et,kt]=(0,t.useState)(null),Pt=(0,t.useCallback)(e=>{kt(t=>t===e?t:e)},[]),Tt=function({sceneId:e,sceneIndex:n,mode:r,scroll:i,elementRef:a}){const o=(0,t.useContext)(ht),s=(0,t.useId)(),c=i?.zoneId??e??`scene-zone-${s}`,l=o?.registerZone,u=o?.unregisterZone,d=o?.setZoneElement,f=!!i,g=i?.trigger??"center-lock";return(0,t.useEffect)(()=>{if("scroll"===r&&f&&l&&u)return l(c,{sceneIndex:n,trigger:g}),()=>{u(c,n)}},[r,f,l,u,c,n,g]),(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:Rt});(0,t.useEffect)(()=>{G?.renderProgressMotion||Ke.set(Be)},[Be,G?.renderProgressMotion,Ke]),(0,t.useEffect)(()=>{G?.timelineProgressMotion||_e.set(He)},[He,G?.timelineProgressMotion,_e]),(0,t.useEffect)(()=>{Me&&(ke(I),Pe(P),De(C),Te(D),Oe(y),je(A))},[Me,I,P,C,D,y,A]);const Lt=(0,t.useCallback)(e=>"drag"!==f?0:!Me&&h<=1?Math.max(-1,Math.min(1,e)):0===v&&e<0||v===h-1&&e>0?0:Math.max(-1,Math.min(1,e)),[f,Me,v,h]);(0,t.useEffect)(()=>{},[de,p]),(0,t.useEffect)(()=>{"scroll"!==f&&kt(null)},[f]),(0,t.useEffect)(()=>{const e=++be.current,t=()=>be.current===e,n=e=>{t()&&ge?.(e)};return Se(null),xe(null),"scroll"!==f?((we||Re)&&[we?"enterAnimation":null,Re?"exitAnimation":null].filter(Boolean).join(","),()=>{t()&&(be.current+=1)}):we||Re?((async()=>{const[e,r]=await Promise.all([me(we,`Scene ${p}`,"enter",n),me(Re,`Scene ${p}`,"exit",n)]);t()&&(Se(e??null),xe(r??null))})(),()=>{t()&&(be.current+=1)}):()=>{t()&&(be.current+=1)}},[f,ge,p,we,Re]);const Ht=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:Qe,isActive:m,sceneOffset:tt,globalScrollProgress:T,globalScrollDirection:O,globalIsScrolling:L,globalScrollBackdropActive:j,hasExitAnimation:!!X,scrollTimelineState:z}),Ut=(0,t.useMemo)(()=>Ft({effectiveMode:f,isActive:m,globalScrollTimelineState:z,hasExitAnimation:!!X}),[f,m,z,X]),Yt=Ut>.001,Qt=(0,t.useRef)(Z),tn=(0,t.useRef)(K);(0,t.useEffect)(()=>{Qt.current=Z,tn.current=K},[Z,K]),(0,t.useEffect)(()=>{"scroll"===f&&le||Nt({onVisibilityChange:Qt.current,sceneVisibilityCallback:tn.current,sceneIndex:p,visible:Yt,progress:Ut})},[f,p,Yt,Ut,le]),(0,t.useEffect)(()=>{if("scroll"!==f||!le)return;const e=()=>{const e=le.getKeySnapshot(ue)??null,t=Ft({effectiveMode:f,isActive:e?.isCurrent??m,globalScrollTimelineState:e?.timelineState??null,hasExitAnimation:!!X});Nt({onVisibilityChange:Qt.current,sceneVisibilityCallback:tn.current,sceneIndex:p,visible:t>.001,progress:t})};return e(),le.subscribeKey(ue,e)},[f,le,m,X,p,K,ue]),(0,t.useEffect)(()=>{"drag"!==f||!m||((G?.onSharedTimelineDurationChange??re)?.(yt()),Me||Oe(yt()))},[f,m,yt,dt,G,re,Qe,Me]);const an="drag"===f?M&&null!==st:M,on=(0,t.useMemo)(()=>({mode:f,isActive:m,isDragging:!1,dragProgressMotion:Ze,runtimeState:Ht,sceneState:Qe,sceneOffset:tt,activationToken:x,activationKind:b,firstSceneEnterGateKnown:0===p?w:void 0,firstSceneEnterActive:0===p?R:void 0,firstSceneEnterReady:0===p?an:void 0,sceneTransitionDuration:U,getTimelineDuration:yt,beginPreparation:ft,registerAnimate:gt,declareAnimateLane:mt,unregisterAnimate:pt,getCalculatedDelay:vt,enterDuration:se}),[ft,mt,f,an,vt,b,x,R,w,yt,m,Ze,gt,U,p,tt,Qe,se,pt,Ht]),sn=(0,t.useMemo)(()=>({...on,isDragging:Xe,dragProgressMotion:Ze,renderProgressMotion:Ze,dragTransaction:G?.transaction??null,preparedSnapshot:st,dragTimelineProgress:He,sharedElapsedMotion:Je,renderProgress:We,dragRelease:Ye,sharedTimelineDurationMs:Ue,firstSceneEnterActive:R}),[Ye,He,We,Ue,Ze,G?.transaction,Je,R,Xe,st,on]),cn="drag"===f?sn:on;!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 S=(0,t.useRef)(null),y=(0,t.useRef)(null),x=(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=Dt(t.enterVariant?.animate,Ct),m=Dt(t.enterVariant?.initial,g),p=Dt(t.exitVariant?.exit,g),h=e=>{S.current!==e&&(S.current=e,t.setSceneState(e))},x=(e,n,r)=>{const i=y.current;i&&i.kind===e&&i.progress===n&&i.enterVariant===t.enterVariant&&i.exitVariant===t.exitVariant&&i.controls===t.controls||(y.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 x("before",0,m);if("enter"===r.phase){const e=At(r.enterProgress);return h("entering"),void x("enter",e,he(m,g,e))}if("hold"===r.phase)return h("active"),void x("hold",1,g);if("exit"===r.phase){const e=At(r.exitProgress);return h(t.exitVariant?.exit?"exiting":"active"),void x("exit",e,t.exitVariant?.exit?he(g,p,e):g)}h(f?t.exitVariant?.exit?"exiting":"active":t.exitVariant?.exit?"exiting":i?"active":"initial"),x("after",1,t.exitVariant?.exit?p:g)}else if(u){h("entering");const e=At(c);x("fallback-enter",e,he(m,g,e))}else if(d||f){h(t.exitVariant?.exit?"exiting":"active");const e=At(c);x("fallback-exit",e,t.exitVariant?.exit?he(g,p,e):g)}else h(i?"active":"initial"),x(i?"fallback-active":"fallback-initial",i?1:0,i?g:m)},[]);(0,t.useEffect)(()=>{if("scroll"===e){if(m&&"number"==typeof p){const e=()=>{x(m.getKeySnapshot(p)??null)};return e(),m.subscribeKey(p,e)}x(null)}},[x,o,s,f,u,l,g,d,c,n,r,i,p,m,e])}({slideMode:f,isActive:m,sceneOffset:tt,sceneStackMode:q,controls:pe,enterVariant:ve,exitVariant:ye,globalIsScrolling:L,globalScrollProgress:T,globalScrollDirection:O,globalScrollTransitionSnapshot:V,globalScrollBackdropActive:j,globalScrollTimelineState:z,scrollFrameStore:le,scrollFrameSceneIndex:ue,setSceneState:et});const ln=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:S,preparedSnapshot:y,requirePreparedSnapshot:x=!1,dragMappingConfig:b,takeoverSnapshot:w,onElementContinuationChange:R,onSettleComplete:M,onColdStartComplete:E}){const k=(0,t.useRef)(null),I=(0,t.useRef)(null),P=(0,t.useRef)(0),C=(0,t.useRef)(null),D=(0,t.useRef)(null),A=(0,t.useRef)(!1),T=(0,t.useRef)(0),L=(0,t.useRef)(!1),O=(0,t.useRef)(h);O.current=h;const V=(0,t.useRef)(S);V.current=S;const j=(0,t.useRef)(y);j.current=y;const z=(0,t.useRef)(x);z.current=x;const F=(0,t.useRef)(null),N=()=>V.current||(z.current?null:j.current??null),$=e=>e?.registrySnapshot.timelineDuration??O.current(),B=e=>e?.mapping??J.current,W=(0,t.useRef)(M);W.current=M;const H=(0,t.useRef)(E);H.current=E;const q=(0,t.useRef)(R);q.current=R;const U=(0,t.useRef)(!1),Y=e=>{U.current!==e&&(U.current=e,q.current?.(e))},X=(0,t.useRef)(p);X.current=p;const K=(0,t.useRef)(null),Z=(0,t.useRef)(null),_=(0,t.useRef)(null),G=(0,t.useRef)(null),J=(0,t.useRef)(b??Ot);J.current=b??Ot;const Q=(0,t.useRef)(f?.get()??u);return Q.current=f?.get()??u,(0,t.useEffect)(()=>{if("drag"===e&&c&&k.current){if(U.current){K.current=Math.max(0,X.current.get());const e=w?.current,t=e?.sceneIndices.includes(i)??!1;_.current=t?e.token:null,Z.current=t?e.baseRatio:null,G.current=null}P.current+=1,k.current.stop(),k.current=null,I.current=null}},[c,i,e,w]),(0,t.useEffect)(()=>{if(c||s)return;const e=_.current,t=w?.current;null!==e&&t?.token===e&&null!==t.baseRatio||(K.current=null,Z.current=null,_.current=null,G.current=null)},[c,s,w]),(0,t.useEffect)(()=>{if("drag"!==e||!s)return;k.current&&(k.current.stop(),k.current=null,I.current=null),Y(!1),A.current=!0,L.current=!1;const t=e=>{Q.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=N();if(z.current&&!r)return;const s=$(r),c=Math.max(0,Math.min(e,1)),u=B(r),f=K.current;if(null!==f){const e=w?.current,n=_.current;if(null!==n&&e?.token===n&&e.sceneIndices.includes(i)&&null!==e.baseRatio){const r=e.baseRatio;if(Z.current=r,G.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(G.current=n);const i=jt(u,s,100*r),a=jt(u,s,100*c);return void X.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=jt(u,s,100*r),o=jt(u,s,100*c);return void X.current.set(Math.max(0,Math.min(s,f+o-a)))}X.current.set(jt(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,S?.transactionId]),(0,t.useEffect)(()=>{if("drag"!==e||c)return;const t=g;if(!t||t.targetSceneIndex!==i)return;const r=N();if(z.current&&!r||C.current===t.token)return;C.current=t.token;const a=++P.current;k.current?.stop(),k.current=null,Y(!1);const o=X.current,s=$(r),l="number"==typeof t.progressRatio?t.progressRatio:Q.current,u=r&&"releaseSeed"in r?r.releaseSeed.elapsedMs:jt(B(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);I.current="cold-start",k.current=(0,n.animate)(o,s,{duration:s/1e3,ease:"linear",onUpdate:e=>{P.current===a&&o.set(e)},onComplete:()=>{P.current===a&&(k.current=null,I.current=null,o.set(s))}})}else if("settle"===t.mode){const e=s-d;if(e<=.001)return Y(!1),o.set(s),D.current=t.token,void W.current?.();I.current="settle",Y(!0),k.current=(0,n.animate)(o,s,{duration:e/1e3,ease:"linear",onUpdate:e=>{P.current===a&&o.set(e)},onComplete:()=>{P.current===a&&(k.current=null,I.current=null,Y(!1),o.set(s),D.current=t.token,W.current?.())}})}else{if(d<=.001)return Y(!1),void o.set(0);const e=Math.min(.5*Math.max(d,0),300);I.current="bounce",Y(!0),k.current=(0,n.animate)(o,0,{duration:e/1e3,ease:"easeOut",onUpdate:e=>{P.current===a&&o.set(e)},onComplete:()=>{P.current===a&&(k.current=null,I.current=null,Y(!1),o.set(0))}})}},[e,g?.token,i,S?.transactionId]),(0,t.useEffect)(()=>{if("drag"!==e||c||s)return;const t=g;if(!t||"enter"===t.mode||t.targetSceneIndex!==i||C.current!==t.token||"settle"===t.mode&&D.current===t.token||k.current)return;const r=N();if(z.current&&!r)return;const a=X.current,o=Math.max(0,a.get());if("bounce"===t.mode){if(o<=.001)return Y(!1),void a.set(0);const e=++P.current;return I.current="bounce",Y(!0),void(k.current=(0,n.animate)(a,0,{duration:Math.min(.5*o,300)/1e3,ease:"easeOut",onUpdate:t=>{P.current===e&&a.set(t)},onComplete:()=>{P.current===e&&(k.current=null,I.current=null,Y(!1),a.set(0))}}))}const l=$(r),u=l-o;if(u<=.001)return Y(!1),a.set(l),D.current=t.token,void W.current?.();const d=++P.current;I.current="settle",Y(!0),k.current=(0,n.animate)(a,l,{duration:u/1e3,ease:"linear",onUpdate:e=>{P.current===d&&a.set(e)},onComplete:()=>{P.current===d&&(k.current=null,I.current=null,Y(!1),a.set(l),D.current=t.token,W.current?.())}})},[e,c,s,g?.token,i]),(0,t.useEffect)(()=>{if("drag"!==e||0!==i||!m||s)return;const t=X.current;if(!A.current){const e=j.current??null;if(z.current&&!e)return;F.current=e;const r=$(e);A.current=!0,L.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=++P.current;return I.current="cold-start",void(k.current=(0,n.animate)(t,r,{duration:i/1e3,ease:"linear",onUpdate:e=>{P.current===a&&t.set(e)},onComplete:()=>{P.current===a&&(k.current=null,I.current=null,t.set(T.current),H.current?.())}}))}if(!L.current||F.current)return;const r=O.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,I.current=null,void H.current?.();const o=++P.current;I.current="cold-start",k.current=(0,n.animate)(t,r,{duration:a/1e3,ease:"linear",onUpdate:e=>{P.current===o&&t.set(e)},onComplete:()=>{P.current===o&&(k.current=null,I.current=null,t.set(T.current),H.current?.())}})},[e,i,m,s,v,y?.revision]),(0,t.useEffect)(()=>()=>{k.current?.stop(),k.current=null,Y(!1)},[]),{completeImmediately:(0,t.useCallback)(()=>{P.current+=1,k.current?.stop(),k.current=null,I.current=null,Y(!1),X.current.set(O.current())},[]),resetImmediately:(0,t.useCallback)(()=>{P.current+=1,k.current?.stop(),k.current=null,I.current=null,Y(!1),X.current.set(0)},[])}}({slideMode:f,isActive:m,sceneIndex:p,sceneOffset:tt,globalDirection:S,globalRenderProgress:We,renderProgressMotion:Ze,globalIsDragging:qe,candidateSuspended:G?.candidateSuspended??!1,globalDragTimelineProgress:He,dragTimelineProgressMotion:Ge,dragRelease:Ye,firstSceneEnterReady:M,elementElapsedMotion:Je,getTimelineDuration:yt,timelineDurationState:dt,dragTransaction:G?.transaction??null,preparedSnapshot:st,requirePreparedSnapshot:Me,dragMappingConfig:G?.dragMappingConfig,takeoverSnapshot:G?.takeoverSnapshot,onElementContinuationChange:G?.onElementContinuationChange,onSettleComplete:G?.onActivationComplete??J,onColdStartComplete:G?.onActivationComplete??J}),{handleCandidateSuspend:un,handleCandidateResume:dn,handleDragStart:fn,handlePan:gn,handlePanEnd:mn}=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:S,setSceneState:y,setIsAnimating:x,resolveDragProgress:b,getTimelineDuration:w,onDragProgressChange:R,onRenderProgressChange:M,onDragTimelineProgressChange:E,onOwnershipRequest:k,onCandidateSuspensionChange:I,takeoverSnapshot:P,onDraggingChange:C,onDragRelease:D,renderLaneRef:A,completeReleaseImmediately:T=!1,onDragEnd:L,onDragReset:O,thresholdConfig:V}){(0,t.useRef)(null);const j=(0,t.useRef)(null),z=(0,t.useRef)(0),F=(0,t.useRef)(null),N=A??F,$=(0,t.useRef)(!1),B=(0,t.useRef)(0),W=(0,t.useRef)(!1),H=(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&&y(a)},[e,v,r,d,i,g,m,u,f,y]),(0,t.useEffect)(()=>()=>{z.current+=1;const e=N.current;e&&e.ownerSceneIndex===i&&(e.stop(),N.current=null),$.current=!1,W.current=!1},[N,i]),{handleCandidateSuspend:(0,t.useCallback)(()=>{if("drag"!==e)return!1;const t=N.current,n=!!t?.suspend;W.current=n,t?.suspend?.();const r=I?.(!0)??!1;return n||r},[N,I,e]),handleCandidateResume:(0,t.useCallback)(()=>{N.current?.resume?.(),W.current=!1,I?.(!1)},[N,I]),handleDragStart:(0,t.useCallback)(t=>{if("drag"!==e)return!1;const n=N.current;if(!r&&!n||k&&!k(t))return!1;const i=n&&W.current?n.getCurrent?.()??g:g,a=P?.current;return a&&null===a.baseRatio&&(P.current={...a,baseRatio:Math.abs(i)}),I?.(!1),n?(n.preempt?n.preempt():n.stop(),N.current=null,W.current=!1,B.current=i,H.current=!0,S.set(i),R?.(i),E?.(Math.abs(i)),n.kind,i.toFixed(3)):(B.current=0,H.current=!1),$.current=!0,p.toFixed(3),h.toFixed(3),C?.(!0),!0},[e,r,N,k,S,R,E,C,i,a,o,p,h,g,I,P]),handlePan:(0,t.useCallback)((t,n)=>{if("drag"!==e||!r&&!$.current)return;const i="y"===s?n.offset.y:n.offset.x,a=b(B.current-i/("y"===s?window.innerHeight:window.innerWidth)),o=Math.abs(a);S.set(a),R?.(a),E?.(o),M?.(a)},[e,r,s,i,R,E,M,S,b]),handlePanEnd:(0,t.useCallback)((t,o)=>{if("drag"!==e||!r&&!$.current)return;$.current=!1;const l="pointercancel"===t.type;z.current+=1,N.current?.stop(),N.current=null;const u=S.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=S.get(),o=0,s=!1,c=!1;const l=e/Math.max(Math.abs(a),1e-6),u=()=>{c||s||N.current!==g||(N.current=null,r?.stop(),a=0,S.set(0),R?.(0),E?.(0),M?.(0),t())},d=()=>{if(c||s||N.current!==g)return;const e=Math.abs(a)*l;if(e<=1e-6)return void u();const t=++o;r=(0,n.animate)(S,0,{duration:e,ease:"easeOut",onUpdate:e=>{t!==o||c||s||(a=e,S.set(e),R?.(e),E?.(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=S.get(),s=!0,o+=1,r?.stop())},resume:()=>{c||!s||(a=S.get(),s=!1,d())},preempt:f,getCurrent:()=>a};N.current=g,d()};if(m<.001){if(u.toFixed(3),O?.(),H.current){const e=B.current>=0?"forward":"backward";D?.({mode:"bounce",direction:e,targetSceneIndex:"forward"===e?a+1:a-1})}return C?.(!1),void(r&&y("active"))}const h=u>0?"forward":"backward",v="forward"===h?a+1:a-1;if(0===b(u)&&0!==u)return x(!0),u.toFixed(3),g.toFixed(1),C?.(!1),D?.({mode:"bounce",direction:h,targetSceneIndex:v}),void p(.15,()=>{O?.(),y("active"),x(!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,V);g.toFixed(1),k.toFixed(3),m.toFixed(3);const I=!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),I){if(x(!0),C?.(!1),T)return L?.(h,1,d,d),void x(!1);const e=++z.current,t="forward"===h?1:-1,r=Math.abs(t-u),a=Math.max(r*(c/1e3),0),o=Math.min(m,1);D?.({mode:"settle",direction:h,targetSceneIndex:v,progressRatio:m});let s=null,l=u,f=0,g=!1,p=!1;const y=()=>{p||g||N.current!==R||(N.current=null,s?.stop(),o.toFixed(3),(1e3*a).toFixed(1),L?.(h,o,o*d,d),M?.(0),x(!1))},b=()=>{if(p||g||N.current!==R)return;const r=Math.abs(t-l)*(c/1e3);if(r<=1e-6)return void y();const i=++f;s=(0,n.animate)(l,t,{duration:r,ease:"easeOut",onUpdate:n=>{if(i===f&&!p&&!g&&z.current===e&&(l=n,Math.abs(n-t)>1e-6&&S.set(n),M?.(n),0)){const e=Math.round(10*Math.abs(n))/10;j.current!==e&&(j.current=e)}},onComplete:()=>{i===f&&(l=t,y())}})},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,b())},preempt:w,getCurrent:()=>l};u.toFixed(3),(1e3*a).toFixed(1),o.toFixed(3),N.current=R,b()}else{x(!0);const e=Math.min(m*c,300)/1e3;u.toFixed(3),(1e3*e).toFixed(1),C?.(!1),D?.({mode:"bounce",direction:h,targetSceneIndex:v}),p(e,()=>{O?.(),x(!1)})}},[e,r,N,s,i,a,c,S,R,E,M,D,L,O,C,b,w,l,x,y,T,V])}}({slideMode:f,isActive:m,sceneIndex:p,currentSceneIndex:v,totalScenes:h,slideDirection:g,slideDuration:se,sceneTransitionDuration:U,sceneOffset:tt,sceneState:Qe,globalDirection:S,globalRenderProgress:We,globalIsDragging:qe,globalDragProgress:Be,globalDragTimelineProgress:He,controls:pe,dragProgressMotion:Ze,setSceneState:et,setIsAnimating:rt,resolveDragProgress:Lt,getTimelineDuration:yt,onOwnershipRequest:G?.onOwnershipRequest,onCandidateSuspensionChange:G?.onCandidateSuspensionChange,takeoverSnapshot:G?.takeoverSnapshot,onDragProgressChange:G?.onProgressChange??Q,onRenderProgressChange:G?.onRenderProgressChange??ee,onDragTimelineProgressChange:G?.onTimelineProgressChange??te??(Me?void 0:e=>_e.set(e)),onDraggingChange:G?.onDraggingChange??ne??(Me?void 0:Te),onDragRelease:G?.onRelease??ie??(Me?void 0:$e),renderLaneRef:G?.renderLane,completeReleaseImmediately:!Me,thresholdConfig:G?.threshold,onDragEnd:G?.onCommit??ae??(Me?void 0:(e,t,n,r)=>{ke(0),Pe(0),De(0),Te(!1),Oe(r??0),je(null),ln.completeImmediately(),_?.(e)}),onDragReset:G?.onReset??oe??(Me?void 0:()=>{ke(0),Pe(0),De(0),Te(!1),je(null),ln.resetImmediately()})}),pn="drag"===f&&(m||!!G?.renderLane?.current||!!Ye),{onPointerDown:hn,onPointerMove:vn,onPointerUp:Sn,onPointerCancel:yn,onFramerPanStart:xn,onFramerPan:bn,onFramerPanEnd:wn}=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 S=(0,t.useRef)(s);S.current=s;const y=(0,t.useRef)(c);y.current=c;const x=(0,t.useCallback)(()=>{g.current?.(),g.current=null},[]),b=(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;x(),l.current=null,t.ownsGesture?(n.releasePointerCapture?.(t.pointerId),y.current(e,Jt(t,e.clientX,e.clientY))):t.candidateSuspended&&p.current?.(),b();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},[x,b]),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?.()),x(),b(),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:Gt(),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)}},[x,b,e,w]),M=(0,t.useCallback)(e=>{const t=l.current;if(!t||t.pointerId!==e.pointerId)return;const r=Gt();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,S.current(e.nativeEvent,Jt(t,e.clientX,e.clientY)),t.lastX=e.clientX,t.lastY=e.clientY,t.lastTime=r,e.cancelable&&e.preventDefault()},[n]),E=(0,t.useCallback)(e=>w(e.nativeEvent),[w]);return(0,t.useEffect)(()=>()=>{const e=l.current;e&&!e.ownsGesture&&e.candidateSuspended&&p.current?.(),x(),b(),d.current+=1,l.current=null,u.current=!1},[x,b]),{onPointerDown:R,onPointerMove:M,onPointerUp:E,onPointerCancel:E,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,S=(0,t.useCallback)(e=>{l?.(e),e.defaultPrevented||m(e)},[l,m]),y=(0,t.useCallback)(e=>{u?.(e),e.defaultPrevented||p(e)},[u,p]),x=(0,t.useCallback)(e=>{d?.(e),h(e)},[d,h]),b=(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}},[]),E=(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]),I=(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:S,onPointerMove:y,onPointerUp:x,onPointerCancel:b,onFramerPanStart:E,onFramerPan:k,onFramerPanEnd:I}}({axis:g,enabled:pn,onCandidateStart:un,onCandidateEnd:dn,onPointerSessionStart:G?.onPointerSessionStart,onDragStart:fn,onPan:gn,onPanEnd:mn,authoredPointerDown:c,authoredPointerMove:l,authoredPointerUp:u,authoredPointerCancel:d}),Rn=(0,t.useMemo)(()=>"drag"===f?{opacity:1}:ve?ve.initial:{opacity:1},[ve,f]),Mn=(0,t.useMemo)(()=>"drag"===f?"none":"translateZ(0)",[f]),En=(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}}}(B),[B]),kn=(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"}}}(B),[B]),In=(0,t.useMemo)(()=>$t({effectiveMode:f,effectiveDirection:g,globalScrollTimelineState:z,globalScrollViewportOffset:F,globalViewportWidth:E,globalViewportHeight:k}),[f,g,z,F,E,k]),Pn=!pn&&("covered"===Ht||"parked"===Ht||"inactive"===Ht),Cn=Pn?{"aria-hidden":!0}:void 0,Dn=Pn||!0===e.inert;(0,t.useEffect)(()=>{const e=Rt.current;e&&(e.inert=Dn)},[Dn]);const An=(0,t.useMemo)(()=>({width:N,height:$,position:"scroll"===f?"relative":"absolute",overflow:W,willChange:nt||Xe||L?"transform, opacity":"auto",contain:"drag"===f?"layout style":"layout style paint",transform:Mn,userSelect:"drag"===f&&Xe?"none":void 0,WebkitUserSelect:"drag"===f&&Xe?"none":void 0,touchAction:zt(f,g),zIndex:H,pointerEvents:pn||"covered"!==Ht&&"parked"!==Ht&&"inactive"!==Ht?"auto":"none",..."scroll"===f?kn:En}),[nt,Xe,L,pn,Mn,f,g,N,$,W,H,Ht,kn,En]);return(0,r.jsx)(nn.Provider,{value:p,children:(0,r.jsx)(wt.Provider,{value:cn,children:(0,r.jsx)(It.Provider,{value:"scroll"===f?Et:null,children:(0,r.jsx)(St.Provider,{value:"scroll"===f?Tt:null,children:(0,r.jsxs)(n.motion.div,{ref:Mt,"data-cineview-scroll-zone":"scroll"===f?Tt??e.sceneId??void 0:void 0,initial:Rn,animate:pe,...Object.fromEntries(Object.entries(e).filter(([e])=>!rn.has(e))),className:o,style:{...s,...An},...Cn,inert:Dn,onPanStart:"drag"===f?xn:void 0,onPan:"drag"===f?bn:void 0,onPanEnd:"drag"===f?wn:void 0,onPointerDown:"drag"===f?hn:c,onPointerMove:"drag"===f?vn:l,onPointerUp:"drag"===f?Sn:u,onPointerCancel:"drag"===f?yn:d,children:["scroll"===f?(0,r.jsx)(Bt,{sceneIndex:p,metrics:In,setHostRef:Pt,frameStore:le,direction:g,viewportWidth:E,viewportHeight:k}):null,a]})})})})})}),on=Object.assign(an,{cineViewScene:!0});on.displayName="Scene";var sn=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"]),cn=(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("--")&&sn.has(e)?n.convert(t):t)(e,i,t);r[e]=a,n||(n=a!==i)}),n?r:e},ln=(0,t.forwardRef)(function({width:e,height:n,children:i,style:a,className:o,...s},c){const l=ze(),u=(0,t.useMemo)(()=>{if(!l)return a;const t=cn(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})});ln.displayName="Container";var un=new Set,dn=new Set;function fn(e){if(!e)return;const t=un.has(e);un.add(e),t||dn.forEach(t=>t(e))}var gn=(0,t.forwardRef)(function({src:e,alt:n,width:i,height:a,style:o,loading:s,preload:c,...l},u){const d=ze(),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)(()=>cn(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&&un.has(e)}(e))return;const t=new window.Image,n=()=>{fn(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})});gn.displayName="Image";var mn=new Map,pn=new Set,hn=new Map,vn=new Set,Sn=new Map,yn=0,xn=/\.(mp4|webm|mov|m4v|ogv|ogg)(\?|#|$)/i;function bn(e){return xn.test(e)?"video":null}function wn(e){const t=mn.get(e);if(t)return Rn(e),t.objectUrl}function Rn(e){const t=mn.get(e);t&&(mn.delete(e),mn.set(e,t))}function Mn(e){typeof URL<"u"&&URL.revokeObjectURL&&URL.revokeObjectURL(e)}function En(e){for(const[t,n]of mn){if(yn<=134217728)break;t===e||(Sn.get(t)??0)>0||(mn.delete(t),pn.delete(t),yn-=n.bytes,Mn(n.objectUrl))}}function kn(e,t){if(!e||pn.has(e))return Promise.resolve();const n=hn.get(e);if(n)return n;if(typeof fetch>"u")return Promise.reject(new Error("preloadMedia requires fetch (client-side only)"));if(!(t??bn(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=mn.get(e);n&&(yn-=n.bytes,Mn(n.objectUrl)),mn.set(e,t),yn+=t.bytes,En(e)})(e,{kind:"video",objectUrl:URL.createObjectURL(r),bytes:r.size}),function(e){const t=pn.has(e);pn.add(e),t||vn.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(()=>{hn.delete(e)});return hn.set(e,r),r}var In=1e-4;function Pn(e,t,n){return Math.min(n,Math.max(t,e))}function Cn(e,t){return function(e){return Number.isFinite(e)&&e>0}(e)?t?[Number.isFinite(t[0])?Pn(t[0],0,e):0,Number.isFinite(t[1])?Pn(t[1],0,e):e]:[0,e]:null}function Dn(e){return{activationId:e,status:"framework-scrub",activePlayRequestId:null,settledPlayRequestId:null,nextPlayRequestId:1,lastSeekTime:null,endpointLatched:!1,outgoingLatched:!1,frameworkPlayBlocked:!1,frameworkPausePending:!1}}function An(e,t=[]){return{state:e,commands:t}}function Tn(e,t){return{...Dn(t),nextPlayRequestId:e.nextPlayRequestId}}function Ln(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 An(e);const t="native-playback"===e.status||"play-pending"===e.status,n=null!==e.activePlayRequestId||null!==e.settledPlayRequestId;return An({...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 An(e);const r=function(e,t,n){const r=Cn(t,n);if(!r)return null;const i=Pn(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 An(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 An(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)>In)&&t.push({type:"seek",time:r}),An({...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)>In)&&i.push({type:"seek",time:r}),function(e,t){if(!e.scrubRange||t||e.frame.progress<.999)return!1;const n=Cn(e.duration,e.scrubRange);return!!n&&n[1]<e.duration-In}(t,e.endpointLatched)){const t=e.nextPlayRequestId;return i.push({type:"play",requestId:t}),An({...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 An({...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?An(e):void 0!==t.requestId?e.activePlayRequestId===t.requestId||"native-playback"===e.status&&!e.frameworkPlayBlocked&&e.settledPlayRequestId===t.requestId?An({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:t.requestId,frameworkPausePending:!1,frameworkPlayBlocked:!1}):An({...e,frameworkPausePending:!0,frameworkPlayBlocked:!0},[{type:"pause"}]):e.frameworkPlayBlocked?An({...e,frameworkPausePending:!0},[{type:"pause"}]):An({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:null,frameworkPausePending:!1,frameworkPlayBlocked:!1});case"media-pause":return t.activationId!==e.activationId?An(e):e.frameworkPausePending?An({...e,frameworkPausePending:!1}):An({...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?An(e):An({...e,status:"ended",activePlayRequestId:null,endpointLatched:!0,frameworkPausePending:!1});case"play-resolved":return e.activePlayRequestId!==t.requestId?An(e):An({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:t.requestId,frameworkPlayBlocked:!1,frameworkPausePending:!1});case"play-rejected":return e.activePlayRequestId!==t.requestId?An(e):An({...e,status:"play-rejected",activePlayRequestId:null,settledPlayRequestId:null,frameworkPlayBlocked:!1,frameworkPausePending:!1});case"activate":return e.activationId===t.activationId?An(e):An(Tn(e,t.activationId));case"reset":return An(Tn(e,t.activationId))}}var On=typeof document<"u"?t.useLayoutEffect:t.useEffect,Vn=!0,jn=(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:v,controlRef:S},y){const x=ze(),b=(0,t.useRef)(null),[w,R]=(0,t.useState)(()=>({src:e,url:wn(e)??null})),M=w.src===e?w.url:null,E=(0,t.useRef)([]),k=(0,t.useRef)(Dn(0)),I=(0,t.useRef)(0),P=(0,t.useRef)(void 0),C=(0,t.useRef)(0),D=(0,t.useRef)({src:e,objectUrl:M}),A=(0,t.useRef)(null),T=(0,t.useRef)(()=>{}),L=(0,t.useRef)(new WeakMap),O=(0,t.useRef)(null),V=(0,t.useRef)(null),j=(0,t.useCallback)((e,t)=>{const n=A.current,r=C.current;if(n&&(n.video!==e||n.activationId!==t||n.generation!==r)&&(n.video.removeEventListener("loadstart",n.loadStart,Vn),n.video.removeEventListener("play",n.play,Vn),n.video.removeEventListener("pause",n.pause,Vn),n.video.removeEventListener("ended",n.ended,Vn),A.current=null),!e||A.current)return;const i=()=>I.current===t&&C.current===r,a=()=>i()&&O.current===r,o=()=>{i()&&(O.current=r)},s=e=>{L.current.set(e,{generation:r,activationId:t})},c=e=>{if(!a())return;const n=P.current,i=n?.generation===r&&n.activationId===t?n.requestId:void 0,o=k.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&&(P.current=void 0),c||l?(s(e),T.current({type:"media-play",requestId:i,activationId:t})):T.current({type:"media-play",requestId:i,activationId:t})},l=e=>{a()&&(k.current.frameworkPausePending||(P.current=void 0),s(e),T.current({type:"media-pause",activationId:t}))},u=e=>{a()&&(s(e),T.current({type:"media-ended",activationId:t}))};e.addEventListener("loadstart",o,Vn),e.addEventListener("play",c,Vn),e.addEventListener("pause",l,Vn),e.addEventListener("ended",u,Vn),A.current={video:e,generation:r,activationId:t,loadStart:o,play:c,pause:l,ended:u}},[]),[z,F]=(0,t.useState)(!1),[N,$]=(0,t.useState)(0),[B,W]=(0,t.useState)(0),H=(0,t.useCallback)((e=!0)=>{I.current+=1,k.current=Ln(k.current,{type:"reset",activationId:I.current}).state,P.current=void 0,E.current=[],j(e?b.current:null,I.current)},[j]);(0,t.useEffect)(()=>{const e={release:()=>{const e=b.current;F(!0),e&&(e.pause(),V.current=e.getAttribute("src"),e.removeAttribute("src"),e.load()),H(!1)},warmUp:()=>{const e=b.current;if(e&&!e.getAttribute("src")){const t=V.current;t&&(e.src=t,V.current=null)}F(!1),$(e=>e+1),H(!1)}};return S&&(S.current=e),()=>{S&&(S.current=null)}},[S,H]);const q=(0,t.useCallback)(e=>{e||j(null,I.current),b.current=e,e&&j(e,I.current),function(e,t){"function"==typeof e?e(t):e&&(e.current=t)}(y,e)},[j,y]),U=(0,t.useMemo)(()=>"number"==typeof o?x?.convert(o)??o:o,[x,o]),Y=(0,t.useMemo)(()=>"number"==typeof s?x?.convert(s)??s:s,[x,s]),X=(0,t.useMemo)(()=>cn(c,x??null),[x,c]);(0,t.useEffect)(()=>{if(typeof window>"u"||!e)return void R({src:e,url:null});let t=!0,n=!1;const r=()=>{const t=function(e){const t=mn.get(e);if(t)return Rn(e),Sn.set(e,(Sn.get(e)??0)+1),t.objectUrl}(e);return!!t&&(n=!0,R({src:e,url:t}),!0)};let i=()=>{};return r()||(R({src:e,url:null}),i=function(e){return vn.add(e),()=>{vn.delete(e)}}(i=>{i===e&&t&&!n&&r()})),()=>{t=!1,i(),n&&function(e){const t=Sn.get(e)??0;t<=1?Sn.delete(e):Sn.set(e,t-1),En("")}(e)}},[e]),(0,t.useEffect)(()=>{typeof window>"u"||!e||!u||function(e){return e.length>0&&pn.has(e)}(e)||kn(e,"video").catch(()=>{})},[u,e]),(0,t.useEffect)(()=>{F(!1),$(e=>e+1)},[e]),On(()=>{const e=b.current;e&&(e.playbackRate=f??1)},[B,M,f,z,e]);const K=(0,t.useCallback)((e,t)=>{e.currentTime=t},[e]),Z=(0,t.useCallback)(e=>{const t=b.current;if(!t)return;const n=Ln(k.current,e);k.current=n.state,n.commands.forEach(e=>{switch(e.type){case"pause":return void t.pause();case"seek":return void K(t,e.time);case"play":{const n={requestId:e.requestId,generation:C.current,activationId:k.current.activationId,settled:!1};P.current=n;const r=t=>{if(P.current===n&&!n.settled){if(n.settled=!0,"play-rejected"===t&&(P.current=void 0),C.current!==n.generation||k.current.activationId!==n.activationId)return void(P.current=void 0);Z({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"))}}})},[K]);On(()=>{T.current=Z;const t=D.current;let n=!1;(t.src!==e||t.objectUrl!==M)&&(D.current={src:e,objectUrl:M},C.current+=1,O.current=null,H(),n=!0),!n&&b.current&&b.current.readyState>=1&&(O.current=C.current),j(b.current,I.current)},[j,Z,N,M,H,e]),(0,t.useEffect)(()=>()=>j(null,I.current),[j]),(0,t.useEffect)(()=>{if(!i)return;const e=b.current;if(!e||typeof window>"u")return;let t=i.get();const n=n=>{t=n;const r=k.current;if("entering"===n.phase&&("ended"===r.status||r.outgoingLatched))return I.current+=1,j(null,I.current),Z({type:"activate",activationId:I.current}),void W(e=>e+1);!Number.isFinite(e.duration)||e.duration<=0||Z({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)}},[j,Z,N,B,M,a,i]),(0,t.useEffect)(()=>{if(i)return;const e=b.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||K(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)}},[N,M,n,K,i]);const _=e=>{const t=L.current.get(e);return L.current.delete(e),!(!t||t.generation!==C.current||t.activationId!==I.current)},G=z&&w.src===e,J=JSON.stringify([e,M,B,G?"released":"active"]);return(0,r.jsx)("video",{ref:q,src:(G?void 0:M??e)||void 0,muted:!0,playsInline:!0,preload:G?"none":u?"auto":M?"metadata":"none","aria-label":l,width:U,height:Y,style:X,poster:d||void 0,onPlay:e=>{_(e.nativeEvent)&&m?.(e)},onPause:e=>{_(e.nativeEvent)&&p?.(e)},onEnded:e=>{_(e.nativeEvent)&&g?.(e)},onTimeUpdate:h,onError:v},J)});jn.displayName="VideoFrameRenderer";var zn={initial:{opacity:1},animate:{opacity:1}},Fn=(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 S=gt(),y=function(e,n){const r=(0,t.useRef)(null),i=gt(),a=(0,t.useContext)(St),o=function(e,n=!0){return function(e,n,r){const i=(0,t.useContext)(vt),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)(jn,{ref:v,controlRef:y,src:e,progress:S.progress,timelineFrame:S.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})}),Nn=(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:S,onPause:y,onTimeUpdate:x,onError:b},w){return(0,r.jsx)(Et,{animateId:u,enterAnimation:f??zn,exitAnimation:g,duration:{enter:d?.enter,exit:d?.exit},timeline:m,visibility:p,children:(0,r.jsx)(Fn,{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:S,onPause:y,onTimeUpdate:x,onError:b})})});Nn.displayName="AnimateVideo";var $n=Et,Bn=Pt,Wn=on;function Hn(e){return Array.from(new Set(e.filter(e=>e.length>0)))}function qn(e,t,n,r){const i=Hn(e).filter(e=>!n.has(e)&&!r.has(e)),a=new Set(i);return{priorityBatch:i,backgroundBatch:Hn(t).filter(e=>!n.has(e)&&!r.has(e)&&!a.has(e))}}var Un=(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,S]=(0,t.useState)(new Map),[y,x]=(0,t.useState)(!1),b=(0,t.useRef)([...n]),w=(0,t.useRef)([...r]),R=(0,t.useRef)(!1),M=(0,t.useRef)(new Map),E=(0,t.useRef)(0),k=(0,t.useRef)(null),I=(0,t.useRef)(new Set),P=(0,t.useRef)(new Set),C=(0,t.useRef)(0),D=(0,t.useRef)(0),A=(0,t.useRef)(i),T=(0,t.useRef)(a),L=(0,t.useRef)(o);(0,t.useEffect)(()=>{A.current=i,T.current=a,L.current=o},[i,a,o]);const O=(0,t.useCallback)((e,t)=>{const n=Hn(e).filter(e=>!I.current.has(e));if(0===n.length)return;const r=new Set(b.current),i=new Set(w.current),a=n.filter(e=>!r.has(e)&&!i.has(e));0!==a.length&&(t?b.current=[...b.current,...a]:w.current=[...w.current,...a])},[]);(0,t.useEffect)(()=>{O(n,!0),O(r,!1),R.current||m(b.current.length+w.current.length)},[n,r,O]);const V=(0,t.useCallback)((e,t)=>{const n=bn(e);return n?kn(e,n).then(()=>(fn(e),{url:e,success:!0})).catch(n=>{const r=n instanceof Error?n:new Error(String(n));return E.current===t&&L.current?.(e,r),{url:e,success:!1,error:r}}):new Promise(n=>{const r=new Image,i=new AbortController;M.current.set(e,i);let a=!1,o=null;const s=t=>{a||(a=!0,null!==o&&(clearTimeout(o),o=null),M.current.delete(e),n(t))};r.onload=()=>{fn(e),s({url:e,success:!0})},r.onerror=()=>{const n=new Error(`Failed to load image: ${e}`);E.current===t&&L.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}`);E.current===t&&L.current?.(e,n),s({url:e,success:!1,error:n})},15e3),r.src=e})},[]),j=(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),A.current?.(i)},[]),z=(0,t.useCallback)(()=>{if(R.current)return k.current??Promise.resolve();const e=(async()=>{const e=E.current+1;E.current=e,R.current=!0,c(!0),u(0),f(0),h([]),S(new Map),x(!1),P.current=new Set,C.current=0,D.current=0;const t=qn(b.current,w.current,I.current,P.current),n=t.priorityBatch.length+t.backgroundBatch.length;if(D.current=n,m(n),0===n)return j(0,0),E.current===e&&(c(!1),x(!0)),R.current=!1,void T.current?.([]);const r=new Set(t.priorityBatch);let i=0===r.size;i&&x(!0);const a=[],o=new Map,s=()=>{const e=qn(b.current,w.current,I.current,P.current);return D.current=C.current+e.priorityBatch.length+e.backgroundBatch.length,m(D.current),e},l=(e,t)=>{a.push(t),P.current.add(e),C.current+=1,!t.success&&t.error?o.set(e,t.error):t.success&&I.current.add(e),j(C.current,D.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 V(t,e);E.current===e&&l(t,n)})),E.current!==e)return;const r=await Promise.all(n.map(async t=>({url:t,result:await V(t,e)})));if(E.current!==e)return;r.forEach(({url:e,result:t})=>{l(e,t)})}h(a),S(o),c(!1),R.current=!1,m(b.current.length+w.current.length),T.current?.(a)})();return k.current=e.finally(()=>{k.current===e&&(k.current=null)}),k.current},[V,j]),F=(0,t.useCallback)(()=>{E.current+=1,M.current.forEach(e=>{e.abort()}),M.current.clear(),c(!1),u(0),f(0),m(b.current.length+w.current.length),h([]),S(new Map),x(!1),I.current.clear(),P.current.clear(),C.current=0,D.current=0,R.current=!1,k.current=null},[]),N=(0,t.useCallback)((e,t=!1)=>{O(e,t);const{priorityBatch:n,backgroundBatch:r}=qn(b.current,w.current,I.current,P.current),i=R.current?C.current+n.length+r.length:n.length+r.length;R.current&&(D.current=i),m(i)},[O]);return(0,t.useEffect)(()=>{const e=M.current;return()=>{E.current+=1,R.current=!1,k.current=null,e.forEach(e=>{e.abort()}),e.clear()}},[]),[{isLoading:s,progress:l,loadedCount:d,totalCount:g,results:p,errors:v,priorityComplete:y},{startPreload:z,reset:F,addUrls:N}]};function Yn({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),S=Math.max(0,i),y=(0,t.useRef)(o);y.current=o;const x=(0,t.useRef)(s);return x.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=x.current();y.current("FIRST_SCENE_TIMEOUT",`First scene priority assets did not load within ${S}ms.`,{sceneIndex:0,timeoutMs:S,loadedCount:e.loadedCount,totalCount:e.totalCount})||(h.current=!0,d(!1),l(!1),t("static"))},S)),()=>{v.current&&(clearTimeout(v.current),v.current=null)})},[e,n,r,S]),(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)},[])}}var Xn=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}},Kn=0,Zn=Xn,_n=()=>{1===(Kn+=1)&&Xn.start();let e=!1;return()=>{e||(e=!0,0===(Kn=Math.max(Kn-1,0))&&Xn.stop())}};function Gn({index:e,currentScene:n,totalScenes:i,direction:a,renderProgressMotion:o,style:s,sceneWrapperRefs:c,children:l}){const u=(0,t.useRef)(null);return On(()=>{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})}function Jn({scenes:e,visibleSceneIndices: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:S,direction:y,isAnimating:x,viewportWidth:b,viewportHeight:w,sceneActions:R,sceneWrapperRefs:M,renderLaneRef:E,takeoverSnapshot:k,candidateSuspended:I,onCandidateSuspensionChange:P,onElementContinuationChange:C,onPointerSessionStart:D,dragTransaction:A,onPrepared:T,onPreparedInvalidated:L,onOwnershipRequest:O,onSceneChange:V,onDragProgressChange:j,onRenderProgressChange:z,onDragTimelineProgressChange:F,onDraggingChange:N,onSharedTimelineDurationChange:$,onDragRelease:B,onDragReset:W,onTransactionComplete:H,onFirstSceneEnterComplete:q}){return(0,r.jsx)(r.Fragment,{children:e.map((U,Y)=>{if(!n.has(Y))return null;const X=Y===i,K=U.props,Z=s?.direction??K.slideDirection??"y",_=Vt(s,K.drag),G={position:"absolute",inset:0,width:"100%",height:"100%"};if("drag"===o)G.visibility="visible",G.opacity=1,G.pointerEvents=X||g||x||null!==A?"auto":"none",G.contentVisibility="visible",G.transition="none",G.zIndex=X?10:1;else{const e=X||x&&"backward"===y&&(Y===i||Y===i+1)||x&&"forward"===y&&(Y===i||Y===i-1);G.visibility=e?"visible":"hidden",G.contentVisibility=e?"visible":"hidden",G.zIndex=x?"backward"===y?Y===i+1?2:Y===i?1:0:Y===i?2:Y===i-1?1:0:X?1:0}const J=A?.targetSceneIndex===Y?A:null,Q=t.default.cloneElement(U,{sceneRuntime:{mode:o,direction:Z,isActive:X,sceneIndex:Y,totalScenes:e.length,currentSceneIndex:i,transitionDirection:y,isSceneAnimating:x,sharedTimelineDurationMs:m,activationToken:h.get(Y)?.token??0,activationKind:h.get(Y)?.kind??null,viewportWidth:b,viewportHeight:w,firstSceneEnterActive:v&&0===Y,firstSceneEnterReady:S&&0===Y},dragRuntime:{progress:c,renderProgress:u,timelineProgress:l,renderProgressMotion:d,timelineProgressMotion:f,isDragging:g,release:p,threshold:s?.threshold,dragMappingConfig:_,transaction:J,onPrepared:T,onPreparedInvalidated:L,onOwnershipRequest:O,candidateSuspended:I,onCandidateSuspensionChange:P,takeoverSnapshot:k,onElementContinuationChange:e=>{C(Y,e)},onPointerSessionStart:D,renderLane:E,onCommit:V,onReset:W,onActivationComplete:()=>{0===Y&&v?q():R.completeDragTransition(),"settling"===J?.phase&&H(J.transactionId)},onTransactionComplete:H,onProgressChange:j,onRenderProgressChange:z,onTimelineProgressChange:F,onDraggingChange:N,onRelease:B,onSharedTimelineDurationChange:$},onSceneChange:V});return"drag"===o?(0,r.jsx)(Gn,{index:Y,currentScene:i,totalScenes:a,direction:Z,renderProgressMotion:d,style:G,sceneWrapperRefs:M,children:Q},Y):(0,r.jsx)("div",{ref:e=>{M.current[Y]=e},style:G,"data-scene-index":Y,children:Q},Y)})})}function Qn(e,t,n){return Math.min(n,Math.max(t,e))}function er(e,t,n,r){if(!(e instanceof Element)||0===r)return!1;const i="x"===n?"overflowX":"overflowY";let a=e;for(;a&&a!==t;){if(a instanceof HTMLElement){const e=window.getComputedStyle(a)[i],t="auto"===e||"scroll"===e||"overlay"===e,o="x"===n?a.scrollLeft:a.scrollTop,s=Math.max(("x"===n?a.scrollWidth:a.scrollHeight)-("x"===n?a.clientWidth:a.clientHeight),0);if(t&&s>1&&(r>0&&o<s-1||r<0&&o>1))return!0}a=a.parentElement}return!1}function tr(e,t,n){const r=Math.max(.86*n,1);switch(e){case"PageDown":return r;case"PageUp":return-r;case" ":case"Spacebar":return t?-r:r;case"ArrowDown":return 80;case"ArrowUp":return-80;case"Home":return Number.NEGATIVE_INFINITY;case"End":return Number.POSITIVE_INFINITY;default:return 0}}function nr(e,t){if(!(e instanceof Element))return!1;const n=e.tagName.toLowerCase();return!(" "!==t||!("button"===n||"summary"===n||"a"===n&&e.hasAttribute("href")||"button"===e.getAttribute("role")||"link"===e.getAttribute("role")))||"input"===n||"textarea"===n||"select"===n||!!(e instanceof HTMLElement&&e.isContentEditable)}function rr(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}function ir(e){const t=e;return"number"==typeof t&&Number.isFinite(t)&&t>0?{designSize:t}:{designSize:750}}function ar(e){return e.layout?.overlap??"cover"}function or(e,t,n,r){const i="takeover"===r,a=e=>i?Math.max(e,1):e;if("number"==typeof e&&Number.isFinite(e)&&e>0)return i?null:e;if("string"!=typeof e)return null;const o=e.trim().toLowerCase();if(!o||"auto"===o)return null;const s=Number.parseFloat(o);return!Number.isFinite(s)||s<=0?null:o.endsWith("px")?i?null:s:o.endsWith("vh")?a(n*s/100):o.endsWith("vw")?a(t*s/100):null}function sr(e,t,n){return or(e,t,n,"takeover")}function cr(e,t,n){const r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a="x"===n?t.scrollLeft:t.scrollTop;return"x"===n?r.left-i.left+a:r.top-i.top+a}function lr(e){return e.assets?.preloadImages??[]}function ur(e,t,n={}){if(!t||0===t.length)return[];const r=n.includeZoneIds??!1,i=new Set,a=[],o=e=>{e&&lr(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}function dr(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:{}}}var fr="(prefers-reduced-motion: reduce)";function gr(){return typeof window<"u"&&"function"==typeof window.matchMedia&&window.matchMedia(fr).matches}function mr(e){if(typeof window>"u"||"function"!=typeof window.matchMedia)return()=>{};const t=window.matchMedia(fr);return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}function pr(){return(0,t.useSyncExternalStore)(mr,gr,()=>!1)}function hr(e,t,n){return Math.min(n,Math.max(t,e))}function vr(e){return e??"drag"}var Sr={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},yr=(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:h}=e,{designSize:v}=ir(a),S=(0,t.useMemo)(()=>({direction:s,transitionDuration:c,threshold:l,unit:u,scale:d,firstSceneTimeout:f}),[s,c,l,u,d,f]),y=(0,t.useRef)(null),x=(0,t.useRef)([]),b=(0,t.useRef)(0),w=(0,t.useRef)(null),R=(0,t.useRef)([]),M=(0,t.useRef)(null),E=(0,t.useRef)(new Set),[k,I]=(0,t.useMemo)(()=>{const e=[];return t.Children.forEach(h,t=>{rr(t)&&e.push(t)}),[e,!1]},[h]),P=k.length,C=(0,t.useMemo)(()=>vr(o),[o]),D=(0,t.useMemo)(()=>dr(m),[m]),A=(0,t.useRef)(D),T=(0,t.useRef)(!1),L=(0,t.useRef)(!1),[O,V]=(0,t.useState)(!1),j=(0,t.useRef)(new Set),z=(0,t.useRef)(new Set),F=(0,t.useRef)(null),N=(0,t.useRef)(null),$=(0,t.useRef)(0),B=(0,t.useRef)(!1),W=(0,t.useRef)(new tn),[H,q]=(0,t.useState)(null),U=(0,t.useRef)(null),Y=(0,t.useRef)(0),X=(0,t.useRef)(null),K=(0,t.useRef)(new Set),Z=(0,t.useRef)(!1),_=(0,t.useRef)(null),G=(0,t.useRef)(0),[J,Q]=(0,t.useState)(()=>new Map),ee=(0,t.useCallback)((e,t)=>{const n={token:++G.current,kind:t};Q(t=>{const r=new Map(t);return r.set(e,n),r})},[]);(0,t.useEffect)(()=>{A.current=D},[D]);const te=(0,t.useCallback)((e,t,n)=>{A.current.common?.onError?.({code:e,message:t,context:n})},[]),ne=(0,t.useCallback)((e,t,n)=>{let r=!1;return A.current.common?.onError?.({code:e,message:t,context:n,preventDefault:()=>{r=!0}}),r},[]),re=(0,t.useCallback)(e=>{A.current.common?.onLoadProgress?.(e)},[]);(0,t.useEffect)(()=>{0===P&&te("EMPTY_SCENES","CineView requires at least one Scene child.",{mode:C})},[te,C,P]),(0,t.useEffect)(()=>{"drag"===C&&k.forEach((e,t)=>{const n=e.props;Vt(S,n.drag,({field:e,value:n})=>{const r=`${t}:${e}`;K.current.has(r)||(K.current.add(r),te("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(K.current.has(e))return;K.current.add(e),te("INVALID_DRAG_CONFIG","Invalid drag enabled flag; using true.",{sceneIndex:t,field:"enabled",value:r})}})},[te,S,C,k]);const[ie,ae]=(0,t.useState)(0),[oe,se]=(0,t.useState)(0),ce=(0,t.useCallback)((e,t)=>{w.current=e,D.common?.onSceneEnter?.({fromIndex:e,toIndex:t,direction:t>e?"forward":t<e?"backward":null})},[D]),le=(0,t.useCallback)((e,t)=>{const n=t??w.current??e;w.current=null,D.common?.onSceneLeave?.({fromIndex:n,toIndex:e,direction:n===e?null:e>n?"forward":e<n?"backward":null})},[D]),[ue,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),[S,y]=(0,t.useState)(0),[x,b]=(0,t.useState)(null),[w,R]=(0,t.useState)(0),[M,E]=(0,t.useState)(!1),[k,I]=(0,t.useState)(!1),[P,C]=(0,t.useState)(0),[D,A]=(0,t.useState)(null),T=(0,t.useRef)(0),[L,O]=(0,t.useState)(null),V=(0,t.useRef)(!1),j=(0,t.useRef)(c),z=(0,t.useRef)(null),F=(0,t.useRef)(!1),N=(0,t.useRef)(!1),$=(0,t.useRef)(null);j.current=c,(0,t.useEffect)(()=>{const e=Math.max(n-1,0);j.current<=e||(l(e),V.current&&(d(!1),V.current=!1,g(null),$.current=null))},[n]);const B=(0,t.useCallback)(()=>{z.current=null,F.current=!1,N.current=!1,p(0),v(0),C(0),A(null),g(null)},[]),W=(0,t.useCallback)(e=>{if(null===e)return N.current=!1,void A(null);N.current="settle"===e.mode,T.current+=1,A({...e,token:T.current})},[]),H=(0,t.useCallback)(()=>c<n-1,[c,n]),q=(0,t.useCallback)(()=>c>0,[c]),U=(0,t.useCallback)((e,t=!0)=>{if(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),V.current=!0,$.current={fromScene:c,releaseToken:null},"drag"===i&&(T.current+=1,$.current.releaseToken=T.current,A({token:T.current,mode:"enter",direction:r,targetSceneIndex:e}))):s?.(e,c)},[c,n,i,a,o,s]),Y=(0,t.useCallback)(()=>{H()&&U(c+1)},[c,H,U]),X=(0,t.useCallback)(()=>{q()&&U(c-1)},[c,q,U]),K=(0,t.useCallback)(e=>{if(d(e),V.current=e,!e){const e=$.current;$.current=null,e?s?.(c,e.fromScene):s?.(c),g(null);const t=e?.releaseToken;null!=t&&A(e=>null!==e&&e.token===t?null:e)}},[c,s]),Z=(0,t.useCallback)(()=>{N.current&&null!==z.current||(z.current=null,F.current=!1,N.current=!1,A(null)),p(0),v(0),R(0),E(!1),C(0)},[]),_=(0,t.useCallback)(()=>{z.current=null,F.current=!1,N.current=!1,A(null),g(null),v(0),C(0)},[]),G=(0,t.useCallback)(()=>{y(0),b(null),I(!1),O(null)},[]),J=(0,t.useCallback)((e,t,r,i)=>{const c=j.current,u="forward"===e?c+1:c-1,f=Math.max(0,Math.min(t,1));return f.toFixed(3),u<0||u>=n?(Z(),g(null),d(!1),V.current=!1,!1):(a?.(c,u),g(e),v(f),z.current=c,l(u),o?.(u,c,"drag"),s?.(u,c),p(0),R(0),E(!1),d(!1),V.current=!1,f.toFixed(3),F.current&&B(),!0)},[B,s,a,o,Z,n]),Q=(0,t.useCallback)(()=>{null===z.current?N.current&&(F.current=!0):B()},[B]),ee=(0,t.useCallback)((e,t)=>{const r=j.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 G(),g(null),d(!1),void(V.current=!1);a?.(r,i),g(e),b(e),y(o),O({fromScene:r,toScene:i,direction:e,progressRatio:o,startedAt:Date.now(),lastInputAt:Date.now(),isSettling:!1,settleDirection:null}),l(i),y(0),b(null),O(null),I(!1),d(!1),V.current=!1,s?.(i,r),o.toFixed(3)},[s,a,G,n]),te=(0,t.useCallback)(()=>{S.toFixed(3),y(0),b(null),O(null)},[S]);return[{currentScene:c,isAnimating:u,direction:f,dragProgress:m,dragTimelineProgress:h,scrollProgress:S,scrollDirection:x,renderProgress:w,isDragging:M,isScrolling:k,sharedTimelineDurationMs:P,dragRelease:D,scrollTransitionSnapshot:L},{goToScene:U,nextScene:Y,prevScene:X,setAnimating:K,canGoNext:H,canGoPrev:q,setDragProgress:p,setDragTimelineProgress:v,setScrollProgress:y,setScrollDirection:b,setScrollTransitionSnapshot:O,setRenderProgress:R,setIsDragging:E,setIsScrolling:I,setSharedTimelineDurationMs:C,setDragRelease:W,resetDragInteraction:Z,abortDragContinuation:_,resetScrollInteraction:G,commitDragSceneChange:J,completeDragTransition:Q,commitScrollSceneChange:ee,clearScrollTransitionSnapshot:te}]})({totalScenes:P,initialScene:0,mode:C,onBeforeChange:ce,onCommit:(e,t,n)=>{"drag"===C&&ee(e,"drag"===n?"commit":"programmatic")},onAfterChange:(e,t)=>{le(e,t??b.current)}}),fe=(0,t.useRef)(de);fe.current=de;const{currentScene:ge,isAnimating:me,direction:pe,dragProgress:he,dragTimelineProgress:ve,renderProgress:Se,isDragging:ye,sharedTimelineDurationMs:xe,dragRelease:be}=ue,we=(0,n.useMotionValue)(0),Re=(0,n.useMotionValue)(0),Me=pr(),Ee=e.a11y?.label??"Scenes";b.current=ge,R.current=k,On(()=>{B.current&&(B.current=!1,we.set(0),Re.set(0))},[ge,Re,we]),(0,t.useEffect)(()=>{if(!me)return;const e=k[ge];if(!e)return;const t=function(e,t,n){return Math.max("drag"===t?n??e.sceneTransitionDuration??800:e.sceneTransitionDuration??800,0)}(e.props,C,c),n=setTimeout(()=>{de.setAnimating(!1)},t),r=E.current;return r.add(n),()=>{clearTimeout(n),r.delete(n)}},[me,ge,k,de,C,c]),(0,t.useEffect)(()=>{if("drag"===C)return;T.current=!1,L.current=!1,V(!1),j.current.clear(),z.current.clear(),Y.current=0,X.current=null;const e=U.current;e&&(W.current.releaseTransaction(e.transactionId),U.current=null,q(null))},[C]);const ke=(0,t.useCallback)(e=>{if(!e)return null;const t=U.current,n=!t||t.transactionId!==e.transactionId||t.phase!==e.phase;return t&&t.transactionId!==e.transactionId&&W.current.releaseTransaction(t.transactionId),U.current=e,n&&q(e),e},[]),Ie=(0,t.useCallback)(e=>{const t=U.current;!t||e&&t.transactionId!==e||(W.current.releaseTransaction(t.transactionId),U.current=null,q(null))},[]),Pe=(0,t.useCallback)(e=>{W.current.publishPrepared(e)},[]),Ce=(0,t.useCallback)(e=>{W.current.invalidatePrepared(e)},[]),De=(0,t.useCallback)((e,t)=>{t?j.current.add(e):j.current.delete(e)},[]),Ae=(0,t.useCallback)(()=>{z.current.clear()},[]),Te=(0,t.useCallback)(e=>e?"drag"===C&&(null!==F.current||j.current.size>0)&&(N.current={token:++$.current,sceneIndices:[...j.current],staleRatio:Re.get(),baseRatio:null},L.current=!0,V(!0),!0):(L.current=!1,V(!1),null===N.current?.baseRatio&&(N.current=null),!1),[Re,C]),Le=(0,t.useCallback)(e=>{const t=U.current;!t||t.targetSceneIndex===e||(de.abortDragContinuation(),j.current.delete(t.targetSceneIndex))},[de]),Oe=(0,t.useCallback)(e=>{if("drag"!==C)return!1;const t=L.current,n=T.current;if(n&&!t)return!1;const r=b.current,i=r+("forward"===e?1:-1);if(i<0||i>=P)t&&(Le(null),Ie());else{if(!1===k[i]?.props?.drag?.enabled)return z.current.has(e)||(z.current.add(e),A.current.drag?.onDragBlocked?.({fromIndex:r,targetSceneIndex:i,direction:e})),!1;if(!W.current.getPrepared(i))return!1;const t=W.current.beginTransaction(i,"driving",0);if(!t||(Le(i),!ke(t)))return!1}return L.current=!1,V(!1),n||(T.current=!0,Y.current=0,X.current=null,A.current.drag?.onDragStart?.({sceneIndex:r,progress:0,direction:e})),!0},[Le,ke,Ie,C,k,P]),Ve=(0,t.useCallback)(e=>{if("drag"!==C||!T.current)return;const t=0===e?0:hr(e,-1,1);if(t!==Y.current){if(Y.current=t,0!==t){const e=b.current+(t>0?1:-1);if(e>=0&&e<P){const n=W.current.beginTransaction(e,"driving",Math.abs(t));n&&(Le(e),ke(n))}}A.current.drag?.onDragProgress?.({sceneIndex:b.current,progress:Math.abs(t),direction:t>0?"forward":t<0?"backward":null})}},[Le,ke,C,P]),ze=(0,t.useCallback)(e=>{e||(N.current=null),de.setIsDragging(e)},[de]),Ne=(0,t.useCallback)(e=>{"bounce"===e?.mode&&T.current?X.current={sceneIndex:b.current,signedProgress:Y.current}:"bounce"!==e?.mode&&(X.current=null),de.setDragRelease(e)},[de]);(0,t.useEffect)(()=>{if("drag"===C){if(be)return void ke(W.current.beginTransaction(be.targetSceneIndex,"settle"===be.mode?"settling":"bounce"===be.mode?"bouncing":"programmatic","enter"===be.mode?0:be.progressRatio??0));"driving"!==U.current?.phase&&Ie()}},[ke,be,Ie,C]);const $e=(0,t.useCallback)(()=>{if("drag"===C&&T.current){const e=X.current??{sceneIndex:b.current,signedProgress:Y.current};T.current=!1,Y.current=0,X.current=null,A.current.drag?.onDragCancel?.({sceneIndex:e.sceneIndex,progress:Math.abs(e.signedProgress),direction:e.signedProgress>0?"forward":e.signedProgress<0?"backward":null})}"settling"!==U.current?.phase&&Ie(),we.set(0),Re.set(0),de.resetDragInteraction()},[Re,Ie,we,C,de]);(0,t.useEffect)(()=>{const e=y.current;if(!e)return;const t=e.ownerDocument?.defaultView??window,n=()=>{const t=e.getBoundingClientRect(),n=t.width,r=t.height;n>0&&ae(n),r>0&&se(r)};M.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),()=>{M.current=null,i?.disconnect(),t.removeEventListener("resize",n)}},[]),(0,t.useEffect)(()=>{if(!g||!1===g.enabled)return;const e=y.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 Be=ge,{priorityImages:We,backgroundImages:He}=(0,t.useMemo)(()=>function(e,t,n){if("scroll"===n){const n=e[hr(t,0,Math.max(e.length-1,0))],r=n?lr(n.props):[],i=new Set(r);return{priorityImages:r,backgroundImages:Array.from(new Set(e.flatMap(e=>lr(e.props).filter(e=>!i.has(e)))))}}const r=hr(t,0,Math.max(e.length-1,0)),i=[],a=[];e.forEach((e,t)=>{const n=lr(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))))}}(k,Be,C),[k,Be,C]),[qe,Ue]=Un({priorityUrls:We,backgroundUrls:He,onProgress:re,onError:(e,t)=>{te("IMAGE_LOAD_FAILED",t.message,{url:e})}}),Ye=(0,t.useRef)(Ue);Ye.current=Ue;const Xe=(0,t.useRef)({loadedCount:0,totalCount:0});Xe.current={loadedCount:qe.loadedCount,totalCount:qe.totalCount};const Ke=Math.max(0,f??3e3),Ze=(0,t.useCallback)(()=>({loadedCount:Xe.current.loadedCount,totalCount:Xe.current.totalCount}),[]),{firstSceneEnterActive:_e,firstSceneEnterReady:Ge,firstSceneActivationToken:Je,firstSceneActivationKind:Qe,handleComplete:et}=Yn({enabled:k.length>0,hasFirstScene:!!k[0],priorityComplete:qe.priorityComplete,timeoutMs:Ke,preemptSignal:ye,emitRecoverableError:ne,getPreloadCounts:Ze}),tt=(0,t.useRef)(0);(0,t.useEffect)(()=>{"drag"!==C||Je<=tt.current||null===Qe||(tt.current=Je,ee(0,Qe))},[ee,Qe,Je,C]),(0,t.useEffect)(()=>{const e=E.current;return Ue.startPreload(),()=>{e.forEach(e=>{clearTimeout(e)}),e.clear()}},[i]),(0,t.useEffect)(()=>{if(p)return _n()},[p]),(0,t.useEffect)(()=>{const e=`${We.join("|")}::${He.join("|")}`;if(_.current!==e){if(_.current=e,Ue.addUrls(We,!0),Ue.addUrls(He,!1),!Z.current)return void(Z.current=!0);qe.isLoading||Ue.startPreload()}},[We,He,Ue,qe.isLoading]);const nt=(0,t.useMemo)(()=>{const e=new Set;return e.add(ge),"drag"===C&&(ge>0&&e.add(ge-1),ge<P-1&&e.add(ge+1)),e},[C,ge,P]);!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=ur(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)(()=>Zn.getMetrics(),[]),g=(0,t.useMemo)(()=>({goToScene:c,refreshLayout:l,preload:u,getCurrentIndex:d,getPerformanceMetrics:f}),[d,f,c,u,l]);(0,t.useImperativeHandle)(e,()=>g,[g]);const m=(0,t.useRef)(!1);(0,t.useEffect)(()=>{m.current||(m.current=!0,s.current.common?.onReady?.(g))},[s,g])}({ref:i,currentSceneRef:b,scenesRef:R,sceneActionsRef:fe,preloadActionsRef:Ye,measureViewportRef:M,resolvedCallbacksRef:A});const rt=(0,t.useCallback)((e,t,n,r)=>{const i=ge,a="forward"===e?i+1:i-1;if("drag"!==C)return void("forward"===e?de.nextScene():de.prevScene());const o=U.current,s=o?.targetSceneIndex===a?o:null,c=s?s.releaseSeed.progressRatio:Math.max(0,Math.min(t??Re.get(),1)),l=s?s.releaseSeed.elapsedMs:Math.max(0,n??0),u=s?s.registrySnapshot.timelineDuration:Math.max(0,r??0);T.current=!1,Y.current=0,X.current=null,A.current.drag?.onDragEnd?.({sceneIndex:i,targetSceneIndex:a,progress:c,direction:e,elapsedMs:l,timelineDurationMs:u}),B.current=!0,de.commitDragSceneChange(e,c,l,u)||(B.current=!1)},[de,ge,Re,C]);(0,t.useEffect)(()=>{},[I,P]);const it=(0,t.useCallback)(e=>{if("drag"!==C||e.target!==e.currentTarget)return;const t=Math.max(0,R.current.length-1),n="x"===s?"ArrowRight":"ArrowDown",r="x"===s?"ArrowLeft":"ArrowUp";let i=null;if("PageDown"===e.key||e.key===n?i=b.current+1:"PageUp"===e.key||e.key===r?i=b.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!==b.current&&de.goToScene(a,!0)},[s,C,de]),at=P>0?`${ge+1} / ${P}`:"",ot=(0,t.useMemo)(()=>({mode:C,scrollEnterMargin:void 0,scrollExitMargin:void 0,prefersReducedMotion:Me,reportError:e=>{te(e.code,e.message,e.context)}}),[C,te,Me]);return(0,r.jsx)(je,{designSize:v,children:(0,r.jsx)(Fe.Provider,{value:ot,children:(0,r.jsxs)("div",{ref:y,style:{position:"relative",width:"100%",height:"100vh",minHeight:"100vh",overflowX:"hidden",overflowY:"hidden",background:"#0d1624"},className:"cineview-container","data-cineview-container":"true",role:"drag"===C?"region":void 0,"aria-roledescription":"drag"===C?"carousel":void 0,"aria-label":"drag"===C?Ee:void 0,tabIndex:"drag"===C?0:void 0,onKeyDown:"drag"===C?it:void 0,children:[(0,r.jsx)("div",{style:{opacity:1,pointerEvents:"auto"},children:(0,r.jsx)(Jn,{scenes:k,visibleSceneIndices:nt,currentScene:ge,totalScenes:P,mode:C,dragConfig:S,dragProgress:he,dragTimelineProgress:ve,renderProgress:Se,renderProgressMotion:we,timelineProgressMotion:Re,isDragging:ye,sharedTimelineDurationMs:xe,dragRelease:be,sceneActivations:J,firstSceneEnterActive:_e,firstSceneEnterReady:Ge,direction:pe,isAnimating:me,viewportWidth:ie,viewportHeight:oe,sceneActions:de,sceneWrapperRefs:x,renderLaneRef:F,takeoverSnapshot:N,candidateSuspended:O,onCandidateSuspensionChange:Te,onElementContinuationChange:De,onPointerSessionStart:Ae,dragTransaction:H,onPrepared:Pe,onPreparedInvalidated:Ce,onOwnershipRequest:Oe,onTransactionComplete:Ie,onSceneChange:rt,onDragProgressChange:Ve,onRenderProgressChange:void 0,onDragTimelineProgressChange:e=>Re.set(e),onDraggingChange:ze,onSharedTimelineDurationChange:de.setSharedTimelineDurationMs,onDragRelease:Ne,onDragReset:$e,onFirstSceneEnterComplete:et})}),"drag"===C?(0,r.jsx)("div",{role:"status","aria-live":"polite",style:Sr,children:at}):null]})})})});yr.displayName="CineViewDrag";var xr=yr;function br({direction:e,viewportSpan:n,scrollContentSpan:i,scrollOffset:a,scrollOffsetStore:o,isScrolling:s,config:c,onScrollToOffset:l}){const u=c.autoHide??!0,d=c.ariaLabel??"CineView scroll position",f=Math.max(c.width??6,4),g=Math.max(c.radius??999,0),m=Math.max(c.inset??0,0),p=c.trackColor??"transparent",h=c.thumbColor??"rgba(255, 255, 255, 0.28)",v=c.thumbHoverColor??"rgba(255, 255, 255, 0.42)",[S,y]=(0,t.useState)(!1),x=(0,t.useRef)(null),b=(0,t.useRef)(null),w=Math.max(i-n,0),R=Qn(o?.getSnapshot()??a,0,w),M=(0,t.useRef)(R);M.current=R;const E=w+n,k=w>1,I=Math.max(n-2*m,1),P=w>0?Qn(n/Math.max(E,n)*I,Math.min(40,I),I):I,C=Math.max(I-P,0),D=w>0?Qn(R/w*C,0,C):0;(0,t.useEffect)(()=>{const t=()=>{const t=Qn(o?.getSnapshot()??a,0,w);if(M.current=t,x.current?.setAttribute("aria-valuenow",String(Math.round(t))),!b.current)return;const n=w>0?Qn(t/w*C,0,C):0;"x"===e?b.current.style.left=`${n}px`:b.current.style.top=`${n}px`};return t(),o?.subscribe(t)},[e,a,w,o,C]);const A=(0,t.useRef)(null);(0,t.useEffect)(()=>{A.current?.()},[e,w,l,I,P]);const T=(0,t.useCallback)(e=>{const t=tr(e.key,e.shiftKey,n);0!==t&&(l(t===Number.POSITIVE_INFINITY?w:t===Number.NEGATIVE_INFINITY?0:Qn(M.current+t,0,w)),e.preventDefault())},[w,l,n]),L=(0,t.useCallback)(t=>{if(w<=0||typeof window>"u"||"mouse"===t.pointerType&&0!==t.button||!1===t.isPrimary||(t.preventDefault(),A.current))return;const n=t.currentTarget.getBoundingClientRect(),r="x"===e?n.width:n.height,i="x"===e?n.left:n.top,a="x"===e?t.clientX:t.clientY,o=w>0?Qn(M.current/w*Math.max(r-P,0),0,Math.max(r-P,0)):0,s=a-i,c=s>=o&&s<=o+P,u=c?s-o:P/2,d=e=>{const t=Math.max(r-P,0),n=Qn(e-i-u,0,t);l((t>0?n/t:0)*w)};if(d(a),!c)return;const f=t.pointerId,g=t=>{t.pointerId===f&&(t.preventDefault(),d("x"===e?t.clientX:t.clientY))},m=()=>{window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),A.current===m&&(A.current=null)};function p(e){e.pointerId===f&&m()}A.current=m,window.addEventListener("pointermove",g,{passive:!1}),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p)},[e,w,l,P]);return(0,t.useEffect)(()=>()=>{A.current?.()},[]),k?(0,r.jsx)("div",{"data-cineview-scrollbar-overlay":"true",style:{position:"absolute",inset:0,zIndex:80,pointerEvents:"none",opacity:u?s||S?1:0:1,transition:u?s?"opacity 0.08s ease-out":"opacity 0.5s ease-in 0.15s":"none"},children:(0,r.jsx)("div",{ref:x,role:"scrollbar","aria-label":d,"aria-orientation":"x"===e?"horizontal":"vertical","aria-valuemin":0,"aria-valuemax":Math.round(w),"aria-valuenow":Math.round(R),tabIndex:0,"data-cineview-scrollbar-rail":"true",onPointerDown:L,onKeyDown:T,onFocus:()=>y(!0),onBlur:()=>y(!1),style:"x"===e?{position:"absolute",left:m,bottom:m,width:I,height:f,borderRadius:g,background:p,boxShadow:"0 0 0 1px rgba(255, 255, 255, 0.78), 0 10px 24px rgba(53, 74, 116, 0.14)",pointerEvents:"auto",touchAction:"none",cursor:"pointer",outline:S?"2px solid rgba(24, 119, 242, 0.95)":"none",outlineOffset:2}:{position:"absolute",top:m,right:m,width:f,height:I,borderRadius:g,background:p,boxShadow:"0 0 0 1px rgba(255, 255, 255, 0.78), 0 10px 24px rgba(53, 74, 116, 0.14)",pointerEvents:"auto",touchAction:"none",cursor:"pointer",outline:S?"2px solid rgba(24, 119, 242, 0.95)":"none",outlineOffset:2},children:(0,r.jsx)("div",{ref:b,"data-cineview-scrollbar-thumb":"true",style:"x"===e?{position:"absolute",left:D,top:0,width:P,height:f,borderRadius:g,background:h,boxShadow:`0 0 0 1px ${v}, 0 10px 24px rgba(53, 74, 116, 0.16)`,cursor:"grab"}:{position:"absolute",top:D,left:0,width:f,height:P,borderRadius:g,background:h,boxShadow:`0 0 0 1px ${v}, 0 10px 24px rgba(53, 74, 116, 0.16)`,cursor:"grab"}})})}):null}function wr(e,t){let n=e;const r=new Map;return{getSnapshot:()=>n,getKeySnapshot:e=>t(n,e),subscribeKey:(e,t)=>{const n=r.get(e)??new Set;return n.add(t),r.set(e,n),()=>{n.delete(t),0===n.size&&r.delete(e)}},setSnapshot:e=>{if(Object.is(n,e))return;const i=n;n=e,r.forEach((n,r)=>{Object.is(t(i,r),t(e,r))||n.forEach(e=>e())})}}}br.displayName="ScrollbarOverlay";var Rr={sceneLayout:null,sceneZoneState:null,sceneTimelineState:null,isCurrent:!1,isBackdropActive:!1,visualViewportOffset:0,isScrolling:!1,scrollDirection:null,activeSceneIndex:0,viewportWidth:0,viewportHeight:0,firstSceneEnterGateKnown:!1,firstSceneEnterActive:!1,firstSceneEnterReady:!1,direction:"y",sceneCount:0,sceneSizing:"content",exposeTakeoverDebugData:!1,takeoverSceneSpan:null},Mr=(0,t.memo)(function({child:e,store:n,frameStore:i,sceneIndex:a,setWrapperRef:o,scrollCallbacks:s}){const c=(0,t.useCallback)(e=>n.subscribeKey(a,e),[a,n]),l=(0,t.useCallback)(()=>n.getKeySnapshot(a)??Rr,[a,n]),{sceneLayout:u,sceneZoneState:d,sceneTimelineState:f,isCurrent:g,isBackdropActive:m,visualViewportOffset:p,isScrolling:h,scrollDirection:v,activeSceneIndex:S,viewportWidth:y,viewportHeight:x,firstSceneEnterGateKnown:b,firstSceneEnterActive:w,firstSceneEnterReady:R,direction:M,sceneCount:E,sceneSizing:k,exposeTakeoverDebugData:I,takeoverSceneSpan:P}=(0,t.useSyncExternalStore)(c,l,l),C=!!e.props.scroll,D=(0,t.useRef)(null);On(()=>{const e=D.current;if(!e)return;if(!I||!C||!i)return e.removeAttribute("data-cineview-takeover-progress-px"),void e.removeAttribute("data-cineview-takeover-viewport-offset");const t=()=>{const t=i.getKeySnapshot(a);e.setAttribute("data-cineview-takeover-progress-px",null==t?.zoneProgressPx?"":String(t.zoneProgressPx)),e.setAttribute("data-cineview-takeover-viewport-offset",t?String(t.visualViewportOffset):"")};return t(),i.subscribeKey(a,t)},[I,i,C,a]);const A=Math.max("x"===M?y:x,1),T="screen"===k&&!C,L=u?.flowSpan,O=u?.visualSpan??P??A,V=e.props.layout?.width??e.props.sceneWidth??"100vw",j=C?Math.max((O-A)/2,0):0,z=C?Math.max((A-O)/2,0):0,F=(0,t.useCallback)(e=>o(a,e),[a,o]),N=t.default.cloneElement(e,{layout:C&&null!==P?{...e.props.layout,..."x"===M?{width:P}:{height:P}}:"x"!==M||C?e.props.layout:{...e.props.layout,width:"auto"===V?"auto":"100%"},callbacks:{...e.props.callbacks,onVisibilityChange:t=>{e.props.callbacks?.onVisibilityChange?.(t),s?.onSceneVisibilityChange?.(t)}},sceneRuntime:{mode:"scroll",direction:M,isActive:g,sceneIndex:a,totalScenes:E,currentSceneIndex:S,transitionDirection:v,isSceneAnimating:h,sharedElapsedMs:0,sharedTimelineDurationMs:0,viewportWidth:y,viewportHeight:x,firstSceneEnterGateKnown:b,firstSceneEnterActive:w,firstSceneEnterReady:R},scrollRuntime:{progress:f?.sceneProgress??0,isScrolling:h,direction:v,transitionSnapshot:null,backdropActive:m,timelineState:f,activeSceneIndex:S,viewportOffset:p,onProgressChange:void 0,onDirectionChange:void 0,onScrollingChange:void 0,onCommit:void 0,onReset:void 0,frameStore:i,sceneIndex:a}});return(0,r.jsx)("div",{ref:F,"data-scene-index":a,style:{position:"relative",width:"x"===M?C&&"number"==typeof L?L:C?"100vw":V:"100%",flex:"x"===M?"0 0 auto":void 0,minHeight:"y"===M&&T?"100vh":void 0,minWidth:"x"===M&&T?"100vw":void 0,...C&&"number"==typeof L?"x"===M?{boxSizing:"border-box",paddingLeft:j}:{boxSizing:"border-box",paddingTop:j,height:L}:{}},children:C?(0,r.jsx)("div",{ref:D,"data-cineview-takeover-shell":a,...I?{"data-cineview-takeover-active-zone":d?.active?d.zoneId:"","data-cineview-takeover-total-distance-px":d?.totalBudgetPx??"","data-cineview-takeover-center-lock-offset":u?.centerLockOffset??"","data-cineview-takeover-segment-start":u?.segmentStart??"","data-cineview-takeover-segment-end":u?.segmentEnd??""}:{},style:"x"===M?{position:"sticky",left:z,width:O,maxWidth:"100vw",height:"100%",overflow:"hidden",zIndex:d?.active?30:void 0}:{position:"sticky",top:z,width:"100%",height:O,maxHeight:"100vh",overflow:"hidden",zIndex:d?.active?30:void 0},children:(0,r.jsx)("div",{"data-cineview-takeover-content":a,style:"x"===M?{width:O,height:"100%",transform:`translateX(${-j}px)`}:{width:"100%",height:O,transform:`translateY(${-j}px)`},children:N})}):N},e.key??`scene-${a}`)});function Er({childrenArray:e,store:n,frameStore:i,setWrapperRef:a,scrollCallbacks:o}){let s=0;return(0,r.jsx)(r.Fragment,{children:e.map((e,c)=>{if(!rr(e))return(0,r.jsx)(t.default.Fragment,{children:e},`flow-${c}`);const l=s++;return(0,r.jsx)(Mr,{child:e,store:n,frameStore:i,sceneIndex:l,setWrapperRef:a,scrollCallbacks:o},e.key??`scene-${l}`)})})}function kr(e){return Number.isFinite(e)?Math.max(0,e):0}function Ir(e,t,n){return Math.min(n,Math.max(t,e))}function Pr(e,t,n,r){return void 0===e?t:n+(r-n)*Ir(e,0,1)}function Cr(e,t,n,r,i,a){const o=n.get(e);if(o)return o;const s=t.get(e);if(!s){const t={animateId:e,startMs:0,enterStartMs:0,enterEndMs:0,exitStartMs:null,exitEndMs:null,totalEndMs:0,hasExit:!1};return n.set(e,t),t}if(r.has(e)){const t=[...r],a=t.indexOf(e);t.slice(a).forEach(e=>i.add(e));const o={animateId:e,startMs:kr(s.delay),enterStartMs:kr(s.delay),enterEndMs:kr(s.delay)+kr(s.enterDuration),exitStartMs:null,exitEndMs:null,totalEndMs:kr(s.delay)+kr(s.enterDuration),hasExit:!1};return n.set(e,o),o}r.add(e);let c=0;if(s.after){const o=Cr(s.after,t,n,r,i,a);i.has(e)||(c=a.get(s.after)??o.totalEndMs)}const l=c+kr(s.delay),u=Math.max(kr(s.enterDuration),1),d=kr(s.exitDuration),f=l+u,g=d>0,m=g?f+d:null,p={animateId:e,startMs:l,enterStartMs:l,enterEndMs:f,exitStartMs:g?f:null,exitEndMs:m,totalEndMs:m??f,hasExit:g};return n.set(e,p),r.delete(e),p}function Dr(e,t,n){const r=void 0!==e.phase?.start?Ir(e.phase.start,0,1)*n:t.startMs,i=void 0!==e.phase?.end?Ir(e.phase.end,0,1)*n:Math.max(t.enterEndMs,t.startMs+1);return Math.max(i,r+1)}function Ar(e){const t=new Map,n=new Set,r=new Map,i=()=>{e.forEach((i,a)=>{Cr(a,e,t,new Set,n,r)})};if([...e.values()].some(e=>void 0!==e.phase?.start||void 0!==e.phase?.end))for(let a=0;a<1e5;a+=1){t.clear(),n.clear(),i();let a=0;t.forEach(e=>{a=Math.max(a,e.totalEndMs)});let o=!0;if(e.forEach((e,n)=>{if(void 0===e.phase?.start&&void 0===e.phase?.end)return;const i=t.get(n);if(!i)return;const s=Dr(e,i,a),c=r.get(n);(void 0===c||Math.abs(c-s)>1e-9)&&(o=!1),r.set(n,s)}),o)break}t.clear(),n.clear(),i();let a=0;t.forEach(e=>{a=Math.max(a,e.totalEndMs)});const o=a>0?Math.max(1*a,1):0,s={};return t.forEach((t,n)=>{const r=e.get(n),i=void 0!==r?.phase?.start||void 0!==r?.phase?.end,a={...t,startPx:1*t.startMs,enterStartPx:1*t.enterStartMs,enterEndPx:1*t.enterEndMs,exitStartPx:null===t.exitStartMs?null:1*t.exitStartMs,exitEndPx:null===t.exitEndMs?null:1*t.exitEndMs,totalEndPx:1*t.totalEndMs,phaseStartPx:0,phaseEndPx:0},c=a.enterStartPx,l=Math.max(a.enterEndPx,c+1),u=i?0:c,d=i?o:l,f=Pr(r?.phase?.start,c,u,d),g=Math.max(Pr(r?.phase?.end,l,u,d),f+1);if(a.phaseStartPx=f,a.phaseEndPx=g,i)if(a.hasExit){const e=kr((t.exitEndMs??t.totalEndMs)-(t.exitStartMs??t.enterEndMs)),n=1*Math.max(e,1);a.exitEndPx=o,a.exitStartPx=Math.max(g,o-n),a.totalEndPx=a.exitEndPx}else a.totalEndPx=g;s[n]=a}),{budgets:s,totalDurationMs:a,totalBudgetPx:o}}var Tr=(0,t.forwardRef)(function({children:e,designWidth:n,direction:i,zoneTrigger:a,sceneSizing:o,enterMargin:s,exitMargin:c,scrollbar:l,callbacks:u,monitor:d,debug:f},g){const{designSize:m}=ir(n),p=(0,t.useMemo)(()=>dr(u),[u]),h=(0,t.useMemo)(()=>({direction:i??"y",zoneTrigger:a??"center-lock",sceneSizing:o??"content"}),[i,a,o]),v=h.direction??"y",S=(0,t.useRef)(null),y=(0,t.useRef)(0),x=(0,t.useRef)(function(){let e=0;const t=new Set;return{getSnapshot:()=>e,subscribe:e=>(t.add(e),()=>t.delete(e)),setSnapshot:n=>{Object.is(e,n)||(e=n,t.forEach(e=>e()))}}}()),b=(0,t.useRef)(null),w=(0,t.useRef)(()=>{}),R=(0,t.useRef)(0),M=(0,t.useRef)(null),[E,k,I,P]=(0,t.useMemo)(()=>{const n=new Map,r=[],i=[];let a=!1;return[t.Children.toArray(e).map(e=>{if(a||(a=!1),!rr(e))return e;const o=i.length,s=e;let c=s;if(s.props.scroll){const e=s.props.scroll.zoneId??s.props.sceneId;if(void 0!==e){const i=n.get(e);void 0===i?n.set(e,o):(r[o]=[e,i],c=t.default.cloneElement(s,{scroll:void 0}))}}return i.push(c),c}),i,r,a]},[e]),{viewportSize:C,viewportSizeRef:D,getViewportSpan:A,updateViewportMetrics:T}=function({rootRef:e,direction:n}){const[r,i]=(0,t.useState)({width:0,height:0}),a=(0,t.useRef)({width:0,height:0});return{viewportSize:r,viewportSizeRef:a,getViewportSpan:(0,t.useCallback)(()=>{const t=e.current;return Math.max("x"===n?t?.clientWidth??a.current.width:t?.clientHeight??a.current.height,1)},[n,e]),updateViewportMetrics:(0,t.useCallback)(()=>{const t=e.current;if(!t)return;const n=t.clientWidth,r=t.clientHeight;a.current={width:n,height:r},i(e=>e.width===n&&e.height===r?e:{width:n,height:r})},[e])}}({rootRef:S,direction:v}),{zoneRegistryRef:L,zoneStatesRef:O,timelineStoreRef:V,zoneRuntimeVersion:j,getZoneIdForScene:z,getZoneDistance:F,zoneRuntimeValue:N,zoneTimelineValue:$}=function({scrollOffsetRef:e,measureSceneLayoutsRef:n,updateSceneRenderSnapshotsRef:r}){const i=(0,t.useRef)(new Map),a=(0,t.useRef)(new Map),o=(0,t.useRef)({}),s=(0,t.useRef)(wr({},(e,t)=>e[t])),[c,l]=(0,t.useState)(0),u=(0,t.useCallback)(e=>{for(const[t,n]of i.current.entries())if(n.sceneIndex===e)return t;return null},[]),d=(0,t.useCallback)(e=>{const t=u(e);return t?o.current[t]?.totalBudgetPx??0:0},[u]),f=(0,t.useCallback)((t,n)=>{const i=o.current,a=n(i[t]);if(a){const e=i[t];if(e&&e.sceneIndex===a.sceneIndex&&e.progressPx===a.progressPx&&e.totalBudgetPx===a.totalBudgetPx&&e.active===a.active&&e.direction===a.direction&&e.approach===a.approach&&function(e,t){if(e.totalDurationMs!==t.totalDurationMs||e.totalBudgetPx!==t.totalBudgetPx)return!1;const n=Object.keys(e.budgets);return n.length===Object.keys(t.budgets).length&&n.every(n=>{const r=e.budgets[n],i=t.budgets[n];return!!(r&&i&&function(e,t){return e.animateId===t.animateId&&e.startMs===t.startMs&&e.enterStartMs===t.enterStartMs&&e.enterEndMs===t.enterEndMs&&e.exitStartMs===t.exitStartMs&&e.exitEndMs===t.exitEndMs&&e.totalEndMs===t.totalEndMs&&e.startPx===t.startPx&&e.enterStartPx===t.enterStartPx&&e.enterEndPx===t.enterEndPx&&e.exitStartPx===t.exitStartPx&&e.exitEndPx===t.exitEndPx&&e.totalEndPx===t.totalEndPx&&e.phaseStartPx===t.phaseStartPx&&e.phaseEndPx===t.phaseEndPx&&e.hasExit===t.hasExit}(r,i))})}(e.sequence,a.sequence))return;o.current={...i,[t]:a}}else{if(!(t in i))return;const e={...i};delete e[t],o.current=e}s.current.setSnapshot(o.current),r.current(e.current)},[e,r]),g=(0,t.useCallback)(e=>{const t=i.current.get(e);if(!t)return void f(e,()=>null);const n=Ar(a.current.get(e)??new Map);f(e,r=>({zoneId:e,sceneIndex:t.sceneIndex,progressPx:Math.min(n.totalBudgetPx,Math.max(r?.progressPx??0,0)),totalBudgetPx:n.totalBudgetPx,active:r?.active??!1,direction:r?.direction??null,sequence:n,approach:r?.approach??"near"})),l(e=>e+1)},[f]);(0,t.useRef)(new Set);const m=(0,t.useCallback)((e,t)=>{const n=i.current.get(e);if(!n||n.sceneIndex===t.sceneIndex){if(n)return void g(e);i.current.set(e,{...t,element:null}),g(e)}},[g]),p=(0,t.useCallback)((e,t)=>{i.current.get(e)?.sceneIndex===t&&(i.current.delete(e),a.current.delete(e),f(e,()=>null),l(e=>e+1))},[f]),h=(0,t.useCallback)((e,t,r)=>{const a=i.current.get(e);!a||a.sceneIndex!==t||(a.element=r,n.current?.())},[n]),v=(0,t.useCallback)((e,t)=>{const n=a.current.get(e)??new Map;return n.set(t.animateId,t),a.current.set(e,n),g(e),t},[g]),S=(0,t.useCallback)((e,t,n)=>{const r=a.current.get(e);!r||r.get(t)!==n||(r.delete(t),g(e))},[g]);return{zoneRegistryRef:i,zoneAnimationsRef:a,zoneStatesRef:o,timelineStoreRef:s,zoneRuntimeVersion:c,getZoneIdForScene:u,getZoneDistance:d,syncZoneState:f,recomputeZoneSequence:g,zoneRuntimeValue:(0,t.useMemo)(()=>({registerZone:m,unregisterZone:p,setZoneElement:h,registerZoneAnimation:v,unregisterZoneAnimation:S}),[m,p,h,v,S]),zoneTimelineValue:(0,t.useMemo)(()=>({store:s.current}),[])}}({scrollOffsetRef:y,measureSceneLayoutsRef:b,updateSceneRenderSnapshotsRef:w}),{sceneLayoutsRef:B,sceneWrapperRefs:W,measureSceneLayouts:H,setSceneWrapperRef:q}=function({rootRef:e,direction:n,scenes:r,sceneSizing:i,getViewportSpan:a,getZoneIdForScene:o,getZoneDistance:s,zoneRegistryRef:c,scrollOffsetRef:l,updateSceneRenderSnapshotsRef:u}){const d=(0,t.useRef)([]),f=(0,t.useRef)([]);return{sceneLayoutsRef:d,sceneWrapperRefs:f,measureSceneLayouts:(0,t.useCallback)(()=>{const t=e.current;if(!t)return d.current;const g=a(),m=r.map((e,a)=>{const l=f.current[a],u=e.props,d=function(e){return{enterAnimation:e.transition?.enterAnimation??e.enterAnimation,exitAnimation:e.transition?.exitAnimation??e.exitAnimation,transitionDurationMs:e.sceneTransitionDuration??800,scrollEnterLength:e.scrollEnterLength,scrollExitLength:e.scrollExitLength}}(u),m=!!u.scroll,p=m?sr("x"===n?u.layout?.width??u.sceneWidth:u.layout?.height??u.sceneHeight,t.clientWidth,t.clientHeight):null,h=o(a),v=h?c.current.get(h)?.element:null,S=m?p:function(e,t,n,r){return or("x"===t?e.layout?.width??e.sceneWidth:e.layout?.height??e.sceneHeight,n,r,"declared")}(u,n,t.clientWidth,t.clientHeight),y="x"===n?Math.max(m?v?.offsetWidth??0:l?.offsetWidth??0,m?v?.clientWidth??0:l?.clientWidth??0,0):Math.max(m?v?.offsetHeight??0:l?.offsetHeight??0,m?v?.clientHeight??0:l?.clientHeight??0,0),x=m?Math.max(p??y,1):"screen"===i?Math.max(y,S??0,g,1):Math.max(y,S??0,1),b=m?s(a):0,w=m?Math.max(x,g)+b:x,R=l?cr(l,t,n):0,M=R+w,E=Math.max(R+x/2-g/2,0),k=!!(d.enterAnimation&&a>0),I=!!(d.exitAnimation&&a<r.length-1),P=Math.max(0,d.scrollEnterLength??(k?d.transitionDurationMs:0)),C=Math.max(0,d.scrollExitLength??(I?d.transitionDurationMs:0)),D=Math.max(Math.min(w,g),1);return{sceneStart:R,sceneEnd:M,visualSpan:x,flowSpan:w,timelineDistancePx:b,centerLockOffset:E,segmentStart:E,segmentEnd:E+b,enterLength:Math.min(P,D),exitLength:Math.min(C,D),stackMode:ar(u)}});return d.current=function(e,t){return e.length===t.length&&t.every((t,n)=>{const r=e[n];return r.sceneStart===t.sceneStart&&r.sceneEnd===t.sceneEnd&&r.visualSpan===t.visualSpan&&r.flowSpan===t.flowSpan&&r.timelineDistancePx===t.timelineDistancePx&&r.centerLockOffset===t.centerLockOffset&&r.segmentStart===t.segmentStart&&r.segmentEnd===t.segmentEnd&&r.enterLength===t.enterLength&&r.exitLength===t.exitLength&&r.stackMode===t.stackMode})}(d.current,m)?d.current:m,u.current(l.current),d.current},[n,a,s,o,e,i,r,l,u,c]),setSceneWrapperRef:(0,t.useCallback)((e,t)=>{f.current[e]=t},[])}}({rootRef:S,direction:v,scenes:k,sceneSizing:h.sceneSizing,getViewportSpan:A,getZoneIdForScene:z,getZoneDistance:F,zoneRegistryRef:L,scrollOffsetRef:y,updateSceneRenderSnapshotsRef:w}),U=(0,t.useRef)(!1),Y=function(e){return void 0!==e?e:!(typeof window>"u"||!window.__CINEVIEW_SCROLL_DEBUG__)}(f),X=(0,t.useMemo)(()=>{const e=lr(k[0]?.props??{}),t=new Set(e);return{priorityImages:e,backgroundImages:Array.from(new Set(k.flatMap(e=>lr(e.props).filter(e=>!t.has(e)))))}},[k]),[K,Z]=Un({priorityUrls:X.priorityImages,backgroundUrls:X.backgroundImages,onProgress:p.common?.onLoadProgress}),_=Z.startPreload,G=(0,t.useRef)({loadedCount:0,totalCount:0});G.current={loadedCount:K.loadedCount,totalCount:K.totalCount};const J=(0,t.useCallback)((e,t,n)=>{let r=!1;return p.common?.onError?.({code:e,message:t,context:n,preventDefault:()=>{r=!0}}),r},[p.common]),Q=pr(),ee=k.length;(0,t.useEffect)(()=>{0===ee&&J("EMPTY_SCENES","CineView requires at least one Scene child.",{mode:"scroll"})},[J,ee]);const te=(0,t.useRef)(void 0);(0,t.useEffect)(()=>{te.current!==I&&(te.current=I,I.forEach(([e,t],n)=>{J("INVALID_COMPONENT_HIERARCHY",`Duplicate scroll zone id "${e}".`,{reason:"duplicate-scroll-zone",zoneId:e,ownerSceneIndex:t,rejectedSceneIndex:n})}))},[I,J]);const ne=(0,t.useCallback)(()=>({loadedCount:G.current.loadedCount,totalCount:G.current.totalCount}),[]),{firstSceneEnterActive:re,firstSceneEnterReady:ie}=Yn({enabled:k.length>0,hasFirstScene:!!k[0],priorityComplete:K.priorityComplete,timeoutMs:3e3,emitRecoverableError:J,getPreloadCounts:ne}),ae=(0,t.useCallback)(e=>ur(k,e,{includeZoneIds:!0}),[k]);(0,t.useEffect)(()=>{_()},[X,_]);const{store:oe,frameStore:se}=function({scenes:e,sceneLayoutsRef:n,timelineStoreRef:r,viewportSizeRef:i,activeSceneIndexRef:a,scrollDirectionRef:o,isScrollingStateRef:s,direction:c,sceneSizing:l,firstSceneEnterActive:u,firstSceneEnterReady:d,exposeTakeoverDebugData:f,scrollOffsetRef:g,updateSceneRenderSnapshotsRef:m}){const p=(0,t.useRef)(wr([],(e,t)=>e[t])),h=(0,t.useRef)(function(){let e=[];const t=new Map,n=e=>{t.get(e)?.forEach(e=>e())};return{setSnapshot:t=>{const r=e;e=Array.from(t);const i=Math.max(r.length,e.length);for(let t=0;t<i;t+=1)Object.is(r[t],e[t])||n(t)},setKeySnapshot:(t,r)=>{Object.is(e[t],r)||(e[t]=r,n(t))},clearFrom:t=>{if(e.length<=t)return;const r=e.length;e.length=t;for(let e=t;e<r;e+=1)n(e)},getKeySnapshot:t=>e[t],subscribeKey:(e,n)=>{const r=t.get(e)??new Set;return r.add(n),t.set(e,r),()=>{r.delete(n),0===r.size&&t.delete(e)}}}}()),v=(0,t.useRef)(null),[S,y]=(0,t.useState)(0),x=(0,t.useRef)(null),b=(0,t.useRef)([]),w=(0,t.useCallback)(t=>{const g=r.current.getSnapshot(),m=n.current,S=i.current,w=Math.max("x"===c?S.width:S.height,1),R=a.current,M="cover"===m[R]?.stackMode&&R>0?R-1:null,E=p.current.getSnapshot(),k=x.current,I=s.current,P=o.current,C=null===k||k[0]!==e||k[1]!==m||k[6]!==S.width||k[7]!==S.height||k[10]!==c||k[11]!==l||k[12]!==f,D=new Set,A=t=>{null!==t&&t>=0&&t<e.length&&D.add(t)},T=e=>{A(e-1),A(e),A(e+1)};if(C){b.current.length=0;for(const e in g){const t=g[e];b.current[t.sceneIndex]=t}for(let t=0;t<e.length;t+=1)D.add(t)}else{const[,,e,n,r,i,a,o,s,l]=k;for(const t in g){const n=g[t],r=e[t];n!==r&&(r&&r.sceneIndex!==n.sceneIndex&&b.current[r.sceneIndex]===r&&(b.current[r.sceneIndex]=void 0),b.current[n.sceneIndex]=n,A(r?.sceneIndex??null),A(n.sceneIndex))}for(const t in e){if(t in g)continue;const n=e[t];b.current[n.sceneIndex]===n&&(b.current[n.sceneIndex]=void 0),A(n.sceneIndex)}const f=Math.max("x"===c?a:o,1);for(let e=0;e<m.length;e+=1){const r=m[e],i=t<r.sceneEnd&&t+w>r.sceneStart,a=n<r.sceneEnd&&n+f>r.sceneStart;(i||a)&&A(e)}T(r),T(R),A(i),A(M),(s!==u||l!==d)&&A(0)}const L=C?[]:E.slice();let O=C;const V=C?new Array(e.length):null;D.forEach(n=>{const r=e[n];if(!r)return;const i=m[n]??null,a=b.current[n]??null,o=!!r.props.scroll,s=n===R||!!a?.active,g=M===n,p=o&&a?.active&&i?i.centerLockOffset:t,v=i?function(e,t,n){if(!e)return null;const r=Math.max(n,1),i=t,a=t+r,o=i+r/2,s=e.sceneStart+e.enterLength,c=e.sceneEnd-Math.max(e.exitLength,0);let l,u=0,d=0;a<=e.sceneStart?l="before":i>=e.sceneEnd?(l="after",u=e.enterLength>0?1:0,d=e.exitLength>0?1:0):e.enterLength>0&&i<s?(l="enter",u=Qn((a-e.sceneStart)/Math.max(e.enterLength,1),0,1)):e.exitLength>0&&i>=c?(l="exit",d=Qn((i-c)/Math.max(e.exitLength,1),0,1),u=e.enterLength>0?1:0):(l="hold",u=e.enterLength>0?1:0);const f=Math.max(e.sceneEnd-e.sceneStart,1);return{phase:l,enterProgress:u,exitProgress:d,sceneProgress:Qn((o-e.sceneStart)/f,0,1),rangeStart:e.sceneStart,rangeEnd:e.sceneEnd,rangeLength:f,enterLength:e.enterLength,exitLength:e.exitLength}}(i,p,w):null,y=o?sr("x"===c?r.props.layout?.width??r.props.sceneWidth:r.props.layout?.height??r.props.sceneHeight,S.width,S.height):null,x=s||g||"enter"===v?.phase||"hold"===v?.phase||"exit"===v?.phase,k={timelineState:v,progress:v?.sceneProgress??0,zoneProgressPx:a?.progressPx??null,visualViewportOffset:p,isCurrent:s,isBackdropActive:g,isScrolling:x&&I,scrollDirection:x&&I?P:null},C=h.current.getKeySnapshot(n),D=void 0!==C&&(C?.timelineState===k.timelineState||null!=C?.timelineState&&null!==k.timelineState&&C.timelineState.phase===k.timelineState.phase&&C.timelineState.enterProgress===k.timelineState.enterProgress&&C.timelineState.exitProgress===k.timelineState.exitProgress&&C.timelineState.sceneProgress===k.timelineState.sceneProgress&&C.timelineState.rangeStart===k.timelineState.rangeStart&&C.timelineState.rangeEnd===k.timelineState.rangeEnd&&C.timelineState.enterLength===k.timelineState.enterLength&&C.timelineState.exitLength===k.timelineState.exitLength)&&C.progress===k.progress&&C.zoneProgressPx===k.zoneProgressPx&&C.visualViewportOffset===k.visualViewportOffset&&C.isCurrent===k.isCurrent&&C.isBackdropActive===k.isBackdropActive&&C.isScrolling===k.isScrolling&&C.scrollDirection===k.scrollDirection;V?V[n]=k:D||h.current.setKeySnapshot(n,k);const A={sceneLayout:i,sceneZoneState:a,sceneTimelineState:v,isCurrent:s,isBackdropActive:g,visualViewportOffset:p,isScrolling:x&&I,scrollDirection:x&&I?P:null,activeSceneIndex:R,viewportWidth:S.width,viewportHeight:S.height,firstSceneEnterGateKnown:!0,firstSceneEnterActive:0===n&&u,firstSceneEnterReady:0===n&&d,direction:c,sceneCount:e.length,sceneSizing:l,exposeTakeoverDebugData:f,takeoverSceneSpan:y},T=E[n]??Rr;!function(e,t){const n=e.sceneTimelineState,r=t.sceneTimelineState,i=n===r||null!==n&&null!==r&&n.phase===r.phase&&n.rangeStart===r.rangeStart&&n.rangeEnd===r.rangeEnd&&n.rangeLength===r.rangeLength&&n.enterLength===r.enterLength&&n.exitLength===r.exitLength,a=e.sceneZoneState,o=t.sceneZoneState;return e.sceneLayout===t.sceneLayout&&(a===o||null!==a&&null!==o&&a.zoneId===o.zoneId&&a.sceneIndex===o.sceneIndex&&a.totalBudgetPx===o.totalBudgetPx&&a.active===o.active&&a.direction===o.direction&&a.approach===o.approach&&a.sequence===o.sequence)&&i&&e.isCurrent===t.isCurrent&&e.isBackdropActive===t.isBackdropActive&&e.isScrolling===t.isScrolling&&e.scrollDirection===t.scrollDirection&&e.activeSceneIndex===t.activeSceneIndex&&e.viewportWidth===t.viewportWidth&&e.viewportHeight===t.viewportHeight&&e.firstSceneEnterGateKnown===t.firstSceneEnterGateKnown&&e.firstSceneEnterActive===t.firstSceneEnterActive&&e.firstSceneEnterReady===t.firstSceneEnterReady&&e.direction===t.direction&&e.sceneCount===t.sceneCount&&e.sceneSizing===t.sceneSizing&&e.exposeTakeoverDebugData===t.exposeTakeoverDebugData&&e.takeoverSceneSpan===t.takeoverSceneSpan}(T,A)?(L[n]=A,O=!0):L[n]=T}),L.length=e.length,O&&p.current.setSnapshot(L),V?(v.current=V,y(e=>e+1)):h.current.clearFrom(e.length),x.current=[e,m,g,t,R,M,S.width,S.height,u,d,c,l,f]},[a,c,f,u,d,s,n,l,e,o,r,i]);return m.current=w,On(()=>{const e=v.current;e&&(v.current=null,h.current.setSnapshot(e))},[S]),(0,t.useEffect)(()=>{w(g.current)},[g,w]),{store:p.current,frameStore:h.current,updateSceneRenderSnapshots:w}}({scenes:k,sceneLayoutsRef:B,timelineStoreRef:V,viewportSizeRef:D,activeSceneIndexRef:R,scrollDirectionRef:M,isScrollingStateRef:U,direction:v,sceneSizing:h.sceneSizing,firstSceneEnterActive:re,firstSceneEnterReady:ie,exposeTakeoverDebugData:Y,scrollOffsetRef:y,updateSceneRenderSnapshotsRef:w});b.current=H;const{isScrolling:ce,scrollContentSpan:le,syncNativeScrollState:ue,applyNativeScrollDelta:de,applyNativeScrollbarOffset:fe,goToScrollZone:ge,beginProgrammaticScroll:me}=function({rootRef:e,direction:n,getViewportSpan:r,updateViewportMetrics:i,measureSceneLayouts:a,sceneLayoutsRef:o,zoneRegistryRef:s,zoneStatesRef:c,timelineStoreRef:l,scrollOffsetRef:u,scrollOffsetStore:d,activeSceneIndexRef:f,scrollDirectionRef:g,isScrollingStateRef:m,updateSceneRenderSnapshotsRef:p,callbacks:h,zoneRuntimeVersion:v}){const S=(0,t.useRef)(null),y=(0,t.useRef)(!1),x=(0,t.useRef)(0),b=(0,t.useRef)(null),w=(0,t.useRef)({}),R=(0,t.useRef)({}),M=(0,t.useRef)(0),[E,k]=(0,t.useState)(!1),[I,P]=(0,t.useState)(1),C=(0,t.useRef)(1),D=(0,t.useCallback)(()=>{const t=e.current;return t?Math.max(("x"===n?t.scrollWidth:t.scrollHeight)-r(),0):0},[n,r,e]),A=(0,t.useCallback)(()=>o.current.filter(e=>e.segmentEnd-e.segmentStart>.5).map(e=>({segmentStart:e.segmentStart,segmentEnd:e.segmentEnd})).sort((e,t)=>e.segmentStart-t.segmentStart),[o]),T=(0,t.useCallback)((e,t)=>function({currentOffset:e,deltaPx:t,maxNativeOffset:n,segments:r=[]}){if(0===t)return Qn(e,0,n);const i=Qn(e,0,n),a=t===Number.POSITIVE_INFINITY?n:t===Number.NEGATIVE_INFINITY?0:Qn(i+t,0,n);if(0===r.length||Math.abs(a-i)<=.5)return a;if(a>i){const e=r.find(e=>i<e.segmentStart+.5&&a>e.segmentEnd+.5);if(e)return Math.min(e.segmentStart+1,e.segmentEnd);const t=r.find(e=>i>=e.segmentStart-.5&&i<e.segmentEnd-.5);return t&&a>t.segmentEnd+.5?t.segmentEnd:a}const o=[...r].reverse().find(e=>i>e.segmentEnd-.5&&a<e.segmentStart-.5);if(o)return Math.max(o.segmentEnd-1,o.segmentStart);const s=[...r].reverse().find(e=>i>e.segmentStart+.5&&i<=e.segmentEnd+.5);return s&&a<s.segmentStart-.5?s.segmentStart:a}({currentOffset:e,deltaPx:t,maxNativeOffset:D(),segments:A()}),[A,D]),L=(0,t.useCallback)(t=>{const r=e.current;if(!r)return;const i=Qn(t,0,D());"x"!==n?"function"==typeof r.scrollTo?r.scrollTo({top:i,behavior:"auto"}):r.scrollTop=i:"function"==typeof r.scrollTo?r.scrollTo({left:i,behavior:"auto"}):r.scrollLeft=i},[n,D,e]),O=(0,t.useCallback)(e=>{b.current=Qn(e,0,D())},[D]),V=(0,t.useCallback)(()=>{if(null===b.current)return;b.current=null;const t=e.current;if(!t)return;const r=Qn("x"===n?t.scrollLeft:t.scrollTop,0,D());L(r),x.current=r},[n,D,e,L]),j=(0,t.useCallback)((e,t=r())=>{const n=o.current;if(0===n.length)return;const i=e+t/2;let a=0,s=Number.POSITIVE_INFINITY;for(let e=0;e<n.length;e+=1){const t=n[e];if(i>=t.sceneStart&&i<t.sceneEnd){a=e;break}const r=i<t.sceneStart?t.sceneStart-i:i-t.sceneEnd;r<s&&(s=r,a=e)}if(f.current===a)return;const c=M.current;if(f.current=a,p.current(e),c===a)return;const l=a>=c?"forward":"backward";h.common?.onSceneEnter?.({fromIndex:c,toIndex:a,direction:l}),h.common?.onSceneLeave?.({fromIndex:c,toIndex:a,direction:l}),M.current=a},[f,h.common,r,o,p]),z=(0,t.useCallback)((e,t,n=r())=>{const i=w.current,a=c.current,u=n,d={};Object.entries(a).forEach(([n,r])=>{const i=o.current[r.sceneIndex];if(!i||r.totalBudgetPx<=0)return void(d[n]=0!==r.progressPx||r.active||null!==r.direction?{...r,progressPx:0,active:!1,direction:null}:r);const a=Qn(e-i.segmentStart,0,r.totalBudgetPx),s=a<=.01?0:r.totalBudgetPx-a<=.01?r.totalBudgetPx:a,c=e>i.segmentStart+.5&&e<i.segmentEnd-.5&&s>.5&&s<r.totalBudgetPx-.5,l=function(e,t,n){return e<=0?"inside":"far"===n?e<=1*t?"near":"far":e>1.5*t?"far":"near"}(Math.max(i.segmentStart-e,e-i.segmentEnd,0),u,r.approach),f={...r,progressPx:s,active:c,direction:c?t:null,approach:l};d[n]=r.progressPx===f.progressPx&&r.active===f.active&&r.direction===f.direction&&r.approach===f.approach?r:f});const f=Object.entries(d);Object.keys(a).length===f.length&&f.every(([e,t])=>a[e]===t)||(c.current=d,l.current.setSnapshot(d)),p.current(e),w.current=d,Object.entries(d).forEach(([e,t])=>{const n=i[e],r=s.current.get(e);if(!r)return;const a=R.current[e],o=0===t.progressPx||t.progressPx===t.totalBudgetPx;(void 0===a||Math.abs(a-t.progressPx)>.5||o&&a!==t.progressPx)&&(R.current[e]=t.progressPx,h.scroll?.onZoneProgress?.({zoneId:e,sceneIndex:r.sceneIndex,progress:t.totalBudgetPx>0?Qn(t.progressPx/t.totalBudgetPx,0,1):0})),!n?.active&&t.active?h.scroll?.onZoneEnter?.({zoneId:e,sceneIndex:r.sceneIndex}):n?.active&&!t.active&&h.scroll?.onZoneLeave?.({zoneId:e,sceneIndex:r.sceneIndex})})},[h.scroll,r,o,l,p,s,c]),F=(0,t.useCallback)((t=!1)=>{const o=e.current;if(!o)return;const s="x"===n?o.scrollLeft:o.scrollTop;if(t&&y.current&&null===b.current&&Math.abs(s-x.current)<=.01)return;t&&(y.current||(i(),a()),y.current=!0);const c=x.current,l=b.current;let f;null!==l?(f=Qn(s,0,D()),Math.abs(f-l)<=1&&(b.current=null)):(f=T(c,s-c),Math.abs(f-s)>.5&&L(f));const h=Math.abs(f-c)<=.5?g.current:f>c?"forward":"backward";x.current=f,u.current=f,d.setSnapshot(f),g.current=h,t&&(m.current=!0,k(e=>e||!0),null!==S.current&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{m.current=!1,k(!1),y.current=!1,S.current=null,p.current(u.current)},120));const v=r(),w=Math.max("x"===n?o.scrollWidth:o.scrollHeight,v);z(f,h,v),j(f,v),Math.abs(C.current-w)>.5&&(C.current=w,P(w))},[n,D,r,m,a,T,e,g,u,d,L,z,j,p,i]),N=(0,t.useCallback)(t=>{const r=e.current;if(!r||0===t)return!1;V();const i="x"===n?r.scrollLeft:r.scrollTop,a=T(i,t);return!(Math.abs(a-i)<=.5||(L(a),F(!0),0))},[V,n,T,e,L,F]),$=(0,t.useCallback)(t=>{V();const r=e.current,i=r?"x"===n?r.scrollLeft:r.scrollTop:u.current;L(T(i,t-i)),F(!0)},[V,n,T,e,u,L,F]),B=(0,t.useCallback)((t,r)=>{const i=e.current,a=c.current[t],s=a?o.current[a.sceneIndex]:null;if(i&&s){if(!1!==r?.animated)return O(s.centerLockOffset),void i.scrollTo({top:"x"===n?void 0:s.centerLockOffset,left:"x"===n?s.centerLockOffset:void 0,behavior:"smooth"});i.scrollTo({top:"x"===n?void 0:s.centerLockOffset,left:"x"===n?s.centerLockOffset:void 0,behavior:"auto"}),x.current=s.centerLockOffset,u.current=s.centerLockOffset,d.setSnapshot(s.centerLockOffset),z(s.centerLockOffset,null),j(s.centerLockOffset)}},[O,n,e,o,u,d,z,j,c]);return function({rootRef:e,direction:n,getViewportSpan:r,applyNativeScrollDelta:i}){const a=(0,t.useRef)(null);(0,t.useEffect)(()=>{const t=e.current;if(!t)return;const o=e=>e instanceof Element&&e.closest('[data-cineview-container="true"]')===t,s=e=>{if(e.defaultPrevented||!o(e.target))return;const a=function(e,t,n){return Number.isFinite(e)&&0!==e?1===t?18*e:2===t?e*Math.max(n,1):e:0}("x"===n?e.deltaX:e.deltaY,e.deltaMode,r());0!==a&&(er(e.target,t,n,a)||i(a)&&e.cancelable&&e.preventDefault())},c=e=>{if(!o(e.target))return;const t=e.touches[0];t&&(a.current={x:t.clientX,y:t.clientY})},l=e=>{const r=e.touches[0];if(!r||!a.current)return;if(e.defaultPrevented||!o(e.target))return void(a.current={x:r.clientX,y:r.clientY});const s=function(e){return Number.isFinite(e)?e:0}("x"===n?a.current.x-r.clientX:a.current.y-r.clientY);if(er(e.target,t,n,s))a.current={x:r.clientX,y:r.clientY};else if(0!==s){const t=i(s);a.current={x:r.clientX,y:r.clientY},t&&e.cancelable&&e.preventDefault()}},u=()=>{a.current=null};return t.addEventListener("wheel",s,{capture:!0,passive:!1}),t.addEventListener("touchstart",c,{passive:!0}),t.addEventListener("touchmove",l,{passive:!1}),t.addEventListener("touchend",u),t.addEventListener("touchcancel",u),()=>{t.removeEventListener("wheel",s,{capture:!0}),t.removeEventListener("touchstart",c),t.removeEventListener("touchmove",l),t.removeEventListener("touchend",u),t.removeEventListener("touchcancel",u),a.current=null}},[i,n,r,e]),(0,t.useEffect)(()=>{if(typeof window>"u")return;const e=e=>{if(e.defaultPrevented||function(e){return nr(e.target,e.key)}(e))return;const t=tr(e.key,e.shiftKey,r());if(0===t)return;const n=document.activeElement;(n===document.body||n===document.documentElement)&&i(t)&&e.cancelable&&e.preventDefault()};return window.addEventListener("keydown",e,!0),()=>{window.removeEventListener("keydown",e,!0)}},[i,r])}({rootRef:e,direction:n,getViewportSpan:r,applyNativeScrollDelta:N}),(0,t.useEffect)(()=>()=>{null!==S.current&&(window.clearTimeout(S.current),S.current=null),b.current=null},[]),(0,t.useEffect)(()=>{i(),a(),F()},[a,F,i,v]),(0,t.useEffect)(()=>{if(typeof window>"u")return;const e=()=>{i(),a(),F()};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[a,F,i]),{isScrolling:E,scrollContentSpan:I,syncNativeScrollState:F,applyNativeScrollDelta:N,applyNativeScrollbarOffset:$,goToScrollZone:B,beginProgrammaticScroll:O}}({rootRef:S,direction:v,getViewportSpan:A,updateViewportMetrics:T,measureSceneLayouts:H,sceneLayoutsRef:B,zoneRegistryRef:L,zoneStatesRef:O,timelineStoreRef:V,scrollOffsetRef:y,scrollOffsetStore:x.current,activeSceneIndexRef:R,scrollDirectionRef:M,isScrollingStateRef:U,updateSceneRenderSnapshotsRef:w,callbacks:p,zoneRuntimeVersion:j}),pe=(0,t.useRef)(!1),he=(0,t.useRef)(null),ve=(0,t.useCallback)(()=>{pe.current=!1,T(),H(),ue()},[H,ue,T]);(0,t.useEffect)(()=>{if(typeof ResizeObserver>"u")return;const e=new ResizeObserver(()=>{null===he.current&&(he.current=window.requestAnimationFrame(()=>{he.current=null,U.current?pe.current=!0:ve()}))});return W.current.forEach(t=>{t&&e.observe(t)}),()=>{null!==he.current&&(window.cancelAnimationFrame(he.current),he.current=null),e.disconnect()}},[ve,W,k]),(0,t.useEffect)(()=>{ce||!pe.current||ve()},[ce,ve]),(0,t.useEffect)(()=>{if(d)return _n()},[d]),(0,t.useEffect)(()=>{},[P]);const Se=(0,t.useCallback)(()=>({goToScene:(e,t=!0)=>{if(e<0||e>=k.length)return;const n=S.current,r=W.current[e];if(!n||!r)return;const i=cr(r,n,v);me(i),n.scrollTo({top:"x"===v?void 0:i,left:"x"===v?i:void 0,behavior:t?"smooth":"auto"})},goToZone:(e,t)=>{ge(e,t)},refreshLayout:()=>{T(),H(),ue()},preload:async e=>{const t=ae(e);t.length>0&&Z.addUrls(t,!0),await _()},getCurrentIndex:()=>R.current,getPerformanceMetrics:()=>Zn.getMetrics()}),[me,v,ge,H,Z,ae,k.length,W,_,ue,T]),ye=(0,t.useRef)(Se);ye.current=Se;const xe=(0,t.useRef)(p.common?.onReady);xe.current=p.common?.onReady,(0,t.useEffect)(()=>{xe.current?.(ye.current())},[]),(0,t.useImperativeHandle)(g,Se,[Se]);const be="object"==typeof l?l:{},we=be.autoHide??!0,Re="object"==typeof l&&!1!==l.enabled,Me={position:"relative",width:"100%",height:"100vh",minHeight:"100vh",overflowX:"x"===v?"scroll":"hidden",overflowY:"x"===v?"hidden":"scroll",overscrollBehavior:"contain",WebkitOverflowScrolling:"touch",scrollbarGutter:Re?"auto":"stable",background:"#ffffff"},Ee=(0,t.useMemo)(()=>({mode:"scroll",scrollEnterMargin:s,scrollExitMargin:c,prefersReducedMotion:Q,reportError:e=>{p.common?.onError?.({...e,code:e.code})}}),[s,c,p.common,Q]);return(0,r.jsx)(je,{designSize:m,children:(0,r.jsx)(Fe.Provider,{value:Ee,children:(0,r.jsx)(ht.Provider,{value:N,children:(0,r.jsxs)(vt.Provider,{value:$,children:[Re&&(0,r.jsx)("style",{children:'\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 '}),"x"===v&&(0,r.jsx)("style",{children:'[data-cineview-scroll-stream="x"] > * { flex-shrink: 0; }'}),(0,r.jsxs)("div",{style:{position:"relative",width:"100%",height:"100vh",minHeight:"100vh"},children:[(0,r.jsx)("div",{ref:S,style:Me,className:"cineview-container","data-cineview-container":"true","data-cineview-scrollbar-autohide":String(we),tabIndex:0,onScroll:()=>ue(!0),onKeyDownCapture:e=>{if(e.defaultPrevented||!(e.target instanceof Element)||e.target.closest('[data-cineview-container="true"]')!==e.currentTarget||nr(e.target,e.key))return;const t=tr(e.key,e.shiftKey,A());0!==t&&!er(e.target,e.currentTarget,v,t)&&de(t)&&e.preventDefault()},children:(0,r.jsx)("div",{"data-cineview-scroll-stream":v,style:"x"===v?{display:"flex",flexDirection:"row",alignItems:"stretch",width:"100%"}:void 0,children:(0,r.jsx)(Er,{childrenArray:E,store:oe,frameStore:se,setWrapperRef:q,scrollCallbacks:p.scroll})})}),Re&&(0,r.jsx)(br,{direction:v,scrollContentSpan:le,viewportSpan:Math.max("x"===v?C.width:C.height,1),scrollOffset:y.current,scrollOffsetStore:x.current,isScrolling:ce,config:be,onScrollToOffset:fe})]})]})})})})});Tr.displayName="DirectScrollCineView";var Lr=(0,t.forwardRef)((e,t)=>"scroll"===vr(e.mode)?(0,r.jsx)(Tr,{...e,ref:t}):(0,r.jsx)(xr,{...e,ref:t}));Lr.displayName="CineView";var Or=Lr;e.Animate=$n,e.AnimateVideo=Nn,e.CineView=Or,e.Container=ln,e.Image=gn,e.Position=Bn,e.Scene=Wn,e.useAnimateTimeline=gt});
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,h,v,S,y,x,b,w,R,M,E,k=m({fadeAnimations:()=>p}),P=g(()=>{p={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}}}}),I=m({slideAnimations:()=>h}),C=g(()=>{h={"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}}}}),D=m({zoomAnimations:()=>v}),A=g(()=>{v={"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}}}}),T=m({rotateAnimations:()=>S}),L=g(()=>{S={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}}}}),O=m({flipAnimations:()=>y}),V=g(()=>{y={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}}}}),j=m({bounceAnimations:()=>x}),z=g(()=>{x={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}}}}}),F=m({blinkAnimations:()=>b}),N=g(()=>{b={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}}}}),$=m({shakeAnimations:()=>w}),B=g(()=>{w={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}}}}),W=m({blurAnimations:()=>R}),H=g(()=>{R={"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}}}}),q=m({elasticAnimations:()=>M}),Y=g(()=>{M={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}}}}),U=m({specialAnimations:()=>E}),X=g(()=>{E={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}}}}),K=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 Z(e){return e instanceof K}var _={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"},G=["fade","slide","zoom","rotate","flip","bounce","blink","shake","blur","elastic","special"],J=new Map,Q=new Map,ee=new Map,te=new Map,ne=new Map,re={left:"0%",center:"50%",right:"100%"},ie={top:"0%",center:"50%",bottom:"100%"},ae={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 oe(e,t){return Array.isArray(t)?t.map(t=>oe(e,t)):t&&"object"==typeof t?se(t):"transformOrigin"===e&&"string"==typeof t?function(e){const t=e.trim().toLowerCase().replace(/\s+/g," "),n=ae[t];if(n)return n;const r=t.split(" ");if(1===r.length){const t=re[r[0]],n=ie[r[0]];return t&&n?`${t} ${n}`:t?`${t} 50%`:n?`50% ${n}`:e}if(2===r.length){const[e,t]=r,n=re[e]??re[t],i=ie[e]??ie[t];if(n&&i)return`${n} ${i}`}return e}(t):t}function se(e){const t={};return Object.entries(e).forEach(([e,n])=>{t[e]=oe(e,n)}),t}function ce(e){return{initial:se(e.initial||{}),animate:se(e.animate||{}),exit:se(e.exit||{})}}var le=async e=>"string"==typeof e?await(async e=>ce(await async function(e){const t=ne.get(e);if(t)throw t;const n=_[e];if(!n){const t=new K("INVALID_ANIMATION",`Unknown preset animation: ${e}`,{permanent:!0,presetName:e});throw ne.set(e,t),t}const r=(await function(e){const t=J.get(e);if(t)return Promise.resolve(t);const n=te.get(e);if(n)return Promise.reject(n);if(!function(e){return G.includes(e)}(e)){const t=new K("INVALID_ANIMATION",`Unknown animation category: ${e}`,{permanent:!0,category:e});return te.set(e,t),ee.set(e,"failed-permanent"),Promise.reject(t)}const r=Q.get(e);if(r)return r;ee.set(e,"pending");const i=function(e,t){return new Promise((n,r)=>{const i=setTimeout(()=>{r(new K("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(()=>(P(),k))).fadeAnimations;case"slide":return(await Promise.resolve().then(()=>(C(),I))).slideAnimations;case"zoom":return(await Promise.resolve().then(()=>(A(),D))).zoomAnimations;case"rotate":return(await Promise.resolve().then(()=>(L(),T))).rotateAnimations;case"flip":return(await Promise.resolve().then(()=>(V(),O))).flipAnimations;case"bounce":return(await Promise.resolve().then(()=>(z(),j))).bounceAnimations;case"blink":return(await Promise.resolve().then(()=>(N(),F))).blinkAnimations;case"shake":return(await Promise.resolve().then(()=>(B(),$))).shakeAnimations;case"blur":return(await Promise.resolve().then(()=>(H(),W))).blurAnimations;case"elastic":return(await Promise.resolve().then(()=>(Y(),q))).elasticAnimations;case"special":return(await Promise.resolve().then(()=>(X(),U))).specialAnimations;default:throw new K("INVALID_ANIMATION",`Unknown animation category: ${e}`,{permanent:!0,category:e})}}(e),e).then(t=>(J.set(e,t),ee.set(e,"success"),t)).catch(t=>{const n=function(e,t){return Z(t)?t:new K("ANIMATION_ASSET_LOAD_FAILED",`Failed to load animation category "${e}".`,{permanent:!1,category:e,cause:t})}(e,t);throw ee.set(e,n.permanent?"failed-permanent":"failed-transient"),n.permanent&&te.set(e,n),n}).finally(()=>{Q.get(e)===i&&Q.delete(e)});return Q.set(e,i),i}(n))[e];if(r)return r;const i=new K("INVALID_ANIMATION",`Preset animation "${e}" is missing from category "${n}".`,{permanent:!0,category:n,presetName:e});throw ne.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=>ce({initial:e.initial??{},animate:e.animate??{},exit:e.exit??{}}))(e)}catch(e){return null}})(e):null,ue=e=>{const t={};return e.forEach(e=>{Object.assign(t,e)}),t},de=async e=>{const t=[];for(let n=0;n<e.length;n++){const r=await le(e[n]);r&&t.push({variant:r,sourceIndex:n})}return t},fe=e=>{const{transition:t,...n}=e.animate;return{values:n,transition:t||{}}},ge=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 me(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 de(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}=fe(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:ge(o),exit:i}})(n,r):"parallel"===t?await(async(e,t=[])=>{const n=await de(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}=fe(e);return{values:i,transition:{...a,delay:r/1e3}}}),a=n.map(({variant:e})=>e.exit);return{initial:ue(r),animate:ge(i),exit:ue(a)}})(n,r):null}catch(e){if(Z(e))throw e;return null}})(e):await le(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=Z(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 pe(e){return"string"==typeof e&&!e.includes("(")&&e.trim().includes(" ")}function he(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(pe(s)||pe(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 ve(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 Se(e,t,n){return Math.min(n,Math.max(t,e))}function ye(e,t,n){return e+(t-e)*n}function xe(e,t,n){if("number"==typeof e&&"number"==typeof t)return ye(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=ye(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=ye(e,t,n);return`${c[1]}(${i}${r})`}return n>=1?t:e}function be(e,t,n,r,i){const a=t[n]??r,o=Se(i,0,1);if(!Array.isArray(a))return xe(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 ve(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 xe(ve(a,t-1,e),ve(a,t,e),c)}return ve(a,a.length-1,e)}function we(e,t,n){const r=e[t]??n;return Array.isArray(r)?ve(r,r.length-1,n):r}function Re(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 Me(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 Ee(e,t,n){const r=e[t];return void 0===r?n:r}function ke(e,t,r,i){return(0,n.useTransform)(e,e=>i(e,t.current,r))}function Pe(e,t,r,i,a){return(0,n.useTransform)(e,e=>{const n=Re(Me(r,"animate"),0);return Re((a??i)(e,t.current,r),n)})}function Ie(e,t,n,r){const i=Pe(e,t,"opacity",n,r),a=ke(e,t,"x",n),o=ke(e,t,"y",n),s=Pe(e,t,"scale",n,r),c=ke(e,t,"rotate",n),l=ke(e,t,"rotateX",n),u=ke(e,t,"rotateY",n),d=ke(e,t,"skewX",n),f=ke(e,t,"skewY",n),g=ke(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 Ce=.001;function De(e){return e.renderProgressMotion?.get()??e.renderProgress??0}function Ae(e){return e.dragTransaction?e.dragTransaction:!0===e.firstSceneEnterActive?e.preparedSnapshot??null:null}function Te(e){return Ae(e)?.registrySnapshot.timelineDuration??e.getTimelineDuration?.()??e.sceneTransitionDuration}function Le(e,t,n,r,i,a){const o=function(e,t,n,r){const i=function(e){return De(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 Se("number"==typeof t?t:Math.abs(De(e)),0,1)}(e),s=function(e){const t=Te(e);if(Ae(e))return t;const n=e.sharedTimelineDurationMs??0;return n>0?n:t}(e),c=Te(e),l=Math.abs(De(e)),u=function(e,t,n){return n<=0?e>=t-Ce?1:0:e<=t?0:Se((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>Ce){if(l<=Ce&&t)return{...d,mode:"enter",localProgress:u};const n=Math.max(r,1),i=l*e.sceneTransitionDuration;return{...d,mode:"outgoing",localProgress:Se(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>Ce)?{...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 Oe(e,t,n){return e?function(e,t,n){const r=we(t.enterInitial,n,Me(n,"initial")),i=we(t.enterAnimate,n,Me(n,"animate"));switch(e.mode){case"rest":default:return i;case"hidden":return r;case"enter":return be(r,t.enterAnimate,n,Me(n,"animate"),e.localProgress);case"outgoing":return 0===Object.keys(t.exitTarget).length?i:"forward"===e.direction?be(i,t.exitTarget,n,Me(n,"exit"),e.localProgress):be(r,t.enterAnimate,n,Me(n,"animate"),1-e.localProgress)}}(e,t,n):we(t.enterAnimate,n,Me(n,"animate"))}var Ve=(0,t.createContext)(null),je=({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)(Ve.Provider,{value:l,children:(0,r.jsx)("div",{className:"cineview-responsive-container",style:u,children:n})})},ze=()=>(0,t.useContext)(Ve),Fe=(0,t.createContext)(null);function Ne(){return(0,t.useContext)(Fe)}var $e=new WeakMap,Be=new WeakMap;function We(e,t){return"entered"===e&&t}function He(e,t,n,r){return void 0===e?t:n+(r-n)*Se(e,0,1)}function qe(e,t,n){return xe(Ee(t.initial,n,Me(n,"initial")),Ee(t.animate,n,Me(n,"animate")),e)}function Ye(e,t,n){const r=Re(Me(n,"animate"),0),i=Re(Ee(t.initial,n,Me(n,"initial")),r);return i+(Re(Ee(t.animate,n,Me(n,"animate")),r)-i)*e}function Ue(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 Xe(e){return e<=0?0:e>=1?1:e}function Ke(e,t){return{enterProgress:Xe(t),phase:e}}function Ze(e,t){const n=t<=0?0:t>=1?1:t;return{enterProgress:n,phase:Ue(e,n)}}var _e={enterProgress:0,phase:"idle"};function Ge({signedVisual:e,phaseMotion:i,render:a}){const[o,s]=(0,t.useState)(()=>Ke(i.get(),e.get()));return(0,n.useMotionValueEvent)(e,"change",e=>{s(Ke(i.get(),e))}),(0,n.useMotionValueEvent)(i,"change",t=>{s(Ke(t,e.get()))}),(0,r.jsx)(r.Fragment,{children:a(o)})}function Je({visualState:e,render:i}){const[a,o]=(0,t.useState)(()=>{const t=e.get();return t?Ze(t.mode,t.localProgress):_e});return(0,n.useMotionValueEvent)(e,"change",e=>{o(e?Ze(e.mode,e.localProgress):_e)}),(0,r.jsx)(r.Fragment,{children:i(a)})}function Qe(e){if("string"==typeof e){const t=n.motion[e];if(t)return t}return n.motion.div}function et(e,t,n){return"last"===n?t-1-e:"center"===n?Math.abs(e-(t-1)/2):e}function tt(e){return t.Children.toArray(e.props.children).filter(t.isValidElement)}function nt(e){return tt(e).length}function rt(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,et(e,i,r));const u=l*c;return{itemDurationMs:s,tailDurationMs:u,effectiveDurationMs:Math.max(t,u+s)}}function it(e,t,n,r,i){return rt(e,t??0,n,r,nt(i)).effectiveDurationMs}function at(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 ot(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 st(e,n,i,a,o,s,c,l,u=!1){const d=t.Children.toArray(e.props.children),f=tt(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:et(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:et(e,f,a)*g}}}};let v=0;const S=d.map((e,n)=>{if(!(0,t.isValidElement)(e))return e;const i=v;v+=1;const a=Qe(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)}),y=Qe(e.type),{children:x,...b}=e.props;return(0,r.jsx)(y,{...b,initial:"initial",animate:m,variants:{initial:{},animate:{},exit:{}},children:S})}function ct({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,exitVariant:o,exitItemDurationMs:s,signedVisual:c}){const[l,u]=at(c,e=>e>0?"animate":e<0&&o?"exit":"initial");return st(e,t,n,r,l,i,o,s,ot(l,a??it(t,i,n,r,e),u))}function lt({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,phaseMotion:o,staticReveal:s}){const[c,l]=at(o,e=>"entering"===e||"entered"===e?"animate":"initial"),u=ot(c,a??it(t,i,n,r,e),l);return st(e,t,n,r,c,i,void 0,void 0,s||u)}function ut({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,exitVariant:o,exitItemDurationMs:s,visualState:c}){const[l,u]=at(c,e=>"outgoing"===e?.mode&&o?"exit":e&&("enter"===e.mode&&e.localProgress>0||"rest"===e.mode)?"animate":"initial");return st(e,t,n,r,l,i,o,s,ot(l,a??it(t,i,n,r,e),u))}var dt=(0,t.createContext)(null);function ft({value:e,children:t}){return(0,r.jsx)(dt.Provider,{value:e,children:t})}function gt(){const e=(0,t.useContext)(dt);if(!e)throw new Error("useAnimateTimeline must be used inside an <Animate> child.");return e}var mt=Object.freeze({progress:0,signedProgress:0,phase:"idle",source:"idle"});function pt(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 ht=(0,t.createContext)(null),vt=(0,t.createContext)(null),St=(0,t.createContext)(null);function yt(e){if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function xt(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(!yt(e)||!yt(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)=>xt(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]||!xt(i[t],a[t],n,r))return!1}return!0}finally{n.delete(i),r.delete(a)}}function bt(e){const n=(0,t.useRef)(e);return xt(n.current,e,new WeakMap,new WeakMap)||(n.current=e),n.current}var wt=(0,t.createContext)(null),Rt=Object.freeze({opacity:1}),Mt=0,Et=({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-"+ ++Mt).current,p=(0,t.useContext)(wt),h=Ne(),v=h?.reportError,S=!0===h?.prefersReducedMotion,y=(0,t.useContext)(ht),x=(0,t.useContext)(St),[b,w]=(0,t.useState)(null),[R,M]=(0,t.useState)(null),[E,k]=(0,t.useState)(null),[P,I]=(0,t.useState)(0),C=(0,t.useRef)(0),D=(0,t.useRef)(null),A=(0,t.useRef)(new Set),T=(0,t.useRef)(null),L=(0,t.useRef)(new Set),O=bt(e),V=bt(i),j=bt(a),z=(0,n.useAnimation)(),F=(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]),$=p?.mode??h?.mode??"drag",B="drag"===$&&"clock"===N.timeline.driver,W=(0,t.useRef)(null),H="drag"===$&&p?.isActive?p.activationToken??0:0;(null===W.current||W.current.mode!==$||W.current.token!==H||0===H&&W.current.arrival!==B)&&(W.current={token:H,mode:$,arrival:B});const q="drag"===$&&W.current.arrival,Y=p?.beginPreparation,U=p?.declareAnimateLane,X=(0,t.useMemo)(()=>{const{driver:e,...t}=N.timeline;return{...t,lane:"scroll"===$&&"scene"===e&&x?"scroll":"visibility"}},[x,$,N.timeline]),K=N.duration.enter,Z=N.duration.exit,_=X.delay,G=X.after,J=(0,t.useContext)(vt),Q=q&&p?.isActive?p.activationToken??0:0,ee=P>0&&D.current?.enterAnimation===O&&D.current?.exitAnimation===V&&D.current?.loopAnimation===j,te=(0,t.useRef)(null),ne=te.current;q&&(0===Q||null===ne||ne.token!==Q)&&(te.current={token:Q,ready:ee,enterVariant:ee?b:null,exitVariant:ee?R:null,infiniteVariant:ee?E:null,hasAuthoredEnterAnimation:!!O,enterDuration:K,exitDuration:Z,delay:_,stagger:u,enterAnimation:O,exitAnimation:V,loopAnimation:j});const re=q?te.current:null;re&&!re.ready&&P>0&&D.current?.enterAnimation===re.enterAnimation&&D.current?.exitAnimation===re.exitAnimation&&D.current?.loopAnimation===re.loopAnimation&&(re.ready=!0,re.enterVariant=b,re.exitVariant=R,re.infiniteVariant=E);const ie=re?re.enterAnimation:O,ae=re?re.exitAnimation:V,oe=re?re.loopAnimation:j,se=re?.ready?re.enterVariant:q?null:b,ce=re?.ready?re.exitVariant:q?null:R,le=re?.ready?re.infiniteVariant:q?null:E,ue=re?.enterDuration??K,de=re?.exitDuration??Z,fe=re?.delay??_,ge=re?re.stagger:u;(0,t.useEffect)(()=>{if(!q)return;const e=U?.(m,"visibility");return()=>e?.dispose()},[U,m,q]),(0,t.useEffect)(()=>{if(!q)return;const e=(e,t)=>{const n=`${m}:${e}`;A.current.has(n)||(A.current.add(n),v?.({code:"INVALID_ANIMATION",message:t,context:{componentId:m,field:e,lane:"visibility",mode:"drag"}}))};G&&e("after",`Animate "${m}" ignores after in drag mode when timeline.driver is 'clock'.`),V&&e("exitAnimation",`Animate "${m}" ignores exitAnimation in drag mode when timeline.driver is 'clock'.`)},[m,q,G,v,V]);const pe="function"==typeof g,he=!(!ie&&!oe||(q?re?.ready??ee:ee)||se||ce||le),ve="drag"===$?!q:"scroll"===X.lane,ye="scroll"===$&&!ve,xe=(0,t.useRef)(new Set);(0,t.useEffect)(()=>{if(!d&&!f)return;const e=(e,t)=>{const n=`${m}:${e}`;xe.current.has(n)||(xe.current.add(n),v?.({code:"INVALID_ANIMATION",message:t,context:{componentId:m,field:e,mode:$,scrub:ve}}))};if(ve){const t="drag"===$?"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.`))}q&&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,q,ve,$,v]);const Re=q?ge:u,Ee=Re&&!pe&&se&&(0,t.isValidElement)(g)?g:null,ke=!!Ee,Pe=Re?.each??40,Ce=Re?.from??"first",Te=(0,t.useMemo)(()=>Ee&&se?rt(se,ue,Pe,Ce,nt(Ee)):null,[ue,se,Ee,Pe,Ce]),Ve=(0,t.useMemo)(()=>Ee&&ce?rt(ce,de,Pe,Ce,nt(Ee),"exit"):null,[de,ce,Ee,Pe,Ce]),je=Te?.effectiveDurationMs??ue,Fe=Ve?.effectiveDurationMs??de,Ke=(0,t.useMemo)(()=>y?{...y,zoneStates:J?.zoneStates??{},store:J?.store}:null,[y,J?.store,J?.zoneStates]);(0,t.useEffect)(()=>{const e=L.current,t=++C.current,n=()=>C.current===t;T.current?.lease.cancel(),T.current=null;const r="drag"!==$||q?void 0:Y?.();r&&e.add(r),T.current=r?{generation:t,lease:r}:null;const i=e=>{n()&&v?.(e)};return w(null),M(null),k(null),I(0),ie||oe?((async()=>{const[e,n,r]=await Promise.all([me(ie,m,"enter",i),me(ae,m,"exit",i),me(oe,m,"loop",i)]);C.current===t&&(D.current={enterAnimation:ie,exitAnimation:ae,loopAnimation:oe},w(e??null),M(n??null),k(r??null),I(t))})(),()=>{e.forEach(e=>e.cancel()),e.clear(),n()&&(C.current+=1)}):(v?.({code:"INVALID_ANIMATION",message:`Animate "${m}" requires enterAnimation or loopAnimation.`,context:{componentId:m,hasExitAnimation:!!ae}}),(()=>{const n=T.current;!n||n.generation!==t||(n.lease.complete(),e.delete(n.lease),T.current=null)})(),()=>{e.forEach(e=>e.cancel()),e.clear(),n()&&(C.current+=1)})},[m,$,q,v,Y,ie,ae,oe]),(0,t.useEffect)(()=>{!q||0===Q||!re||(re.enterAnimation!==O||re.exitAnimation!==V||re.loopAnimation!==j)&&Promise.all([me(O,m,"enter"),me(V,m,"exit"),me(j,m,"loop")])},[re,Q,m,q,O,V,j]);const Ze=function({sceneContext:e,enterVariant:r,exitVariant:i,componentId:a,delay:o,enterDuration:s,exitDuration:c,after:l,variantsPending:u=!1}){const d=e?Ae(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,S=(0,t.useRef)(h),y=(0,t.useRef)(d);y.current=d;const x=(0,t.useRef)({enterInitial:v?.initial||{},enterAnimate:v?.animate||{},exitTarget:i?.exit||{}}),b=e?Le(e,S.current,p,c,m,u):null,w=b?"outgoing"===b.mode?("forward"===b.direction?1:-1)*b.localProgress:b.localProgress:0,R=(0,n.useMotionValue)(w),M=(0,n.useMotionValue)(b),[E,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)(()=>{x.current={enterInitial:v?.initial||{},enterAnimate:v?.animate||{},exitTarget:i?.exit||{}},d&&(S.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),y.current||(S.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)S.current=h;else{const t=e.getCalculatedDelay?.(a);"number"==typeof t&&(S.current=t)}const t=Le(e,S.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,De(e).toFixed(3),t.transitionProgress.toFixed(3),t.sharedElapsedMs.toFixed(1),t.projectedSceneElapsedMs.toFixed(1),t.sharedTimelineDurationMs,t.sceneTimelineDurationMs,t.localProgress.toFixed(3),S.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),S.current,t.localProgress.toFixed(3),De(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 C=Ie(M,x,Oe);return(0,t.useEffect)(()=>{if(!e)return void k(!1);const t=()=>{const t=Le(e,S.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:C.style,opacity:C.opacity,x:C.x,y:C.y,scale:C.scale,rotate:C.rotate,useInteractiveStyles:!0,shouldRunInfinite:E,visualState:M}}({sceneContext:"drag"!==$||q?null:p,enterVariant:b,exitVariant:R,componentId:m,delay:_,enterDuration:je,exitDuration:Fe,after:G,variantsPending:he}),Qe=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,S]=(0,t.useState)(!1),y=(0,t.useRef)(null),x=(0,t.useRef)(null),b=(0,t.useRef)(0),w=(0,t.useRef)(0),R=(0,t.useRef)(null),M=(0,t.useRef)(!1),E=(0,t.useRef)(0===(r?.activationToken??0)),k=(0,t.useRef)(r);k.current=r;const P=(0,t.useCallback)(()=>{y.current?.stop(),y.current=null,null!==x.current&&(clearTimeout(x.current),x.current=null)},[]),I=(0,t.useCallback)(()=>{const e=f.current;P(),b.current=0,w.current=0,R.current=null,M.current=!1,h(!1),S(!1),m.set(e.hasAuthoredEnterAnimation?"idle":"entered"),g.set(e.hasAuthoredEnterAnimation?0:1)},[m,P,g]),C=(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(b.current===e)return;w.current=0,b.current=e,P(),R.current=null,h(!1),u.current={initial:i.enterVariant?.initial??{},animate:i.enterVariant?.animate??{}};const a="static"===t&&E.current;S(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():x.current=setTimeout(()=>{x.current=null,s()},e)})();m.set("waiting"),g.set(0);const c=()=>{if(x.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);y.current=(0,n.animate)(g,1,{duration:e/1e3,ease:"easeInOut",onComplete:()=>{y.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?x.current=setTimeout(c,l):c()},[m,P,g]),D=e&&r?.isActive?r.activationToken??0:0,A=r?.activationKind??null;(0,t.useEffect)(()=>{D<=0?I():C(D,A)},[A,D,I,C]),(0,t.useEffect)(()=>{const e=w.current;e<=0||!o||C(e,k.current?.activationKind??null)},[i,o,C]),(0,t.useEffect)(()=>()=>{P(),b.current=0,w.current=0},[P]);const T=(0,t.useCallback)(()=>{const e=R.current;e?(R.current=null,M.current=!1,null!==x.current&&(clearTimeout(x.current),x.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:Ie(g,u,qe,Ye).style,visualMotion:g,phaseMotion:m,shouldRunInfinite:p,staticReveal:v}}({enabled:q,sceneContext:"drag"===$?p:null,enterVariant:se,hasAuthoredEnterAnimation:re?.hasAuthoredEnterAnimation??!!e,parseReady:re?.ready??P>0,delay:fe,enterDuration:je,enterRef:q?d:void 0}),et=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:v,variantsPending:S=!1}){const y=d.enter,x=d.exit,b=!0===Ne()?.prefersReducedMotion,w=b?0:y,R=b?0:x,M=f.delay,E=f.after,k="scroll"===f.lane,P=f.phase?.start,I=f.phase?.end,C=g.replay,D=ze()?.scale??1,A=g.enterMargin??m??50,T=g.exitMargin??p??50,L=Math.max(0,A*D),O=Math.max(0,T*D),V=(0,t.useRef)({enterInitial:{},enterAnimate:{},exitTarget:{}}),j=(0,n.useMotionValue)(0),z=(0,n.useMotionValue)(i&&r?r.store?.getKeySnapshot(i)??r.zoneStates[i]??null:null),[F,N]=(0,t.useState)(!1),$=(0,t.useRef)(null),[B,W]=(0,t.useState)(0),H=r?.registerZoneAnimation,q=r?.unregisterZoneAnimation,Y=!!(a?.animate&&Object.keys(a.animate).length>0)||!!s,U=function(e,t){return!!(t>0&&e?.exit&&Object.keys(e.exit).length>0)}(o,x)||!!c;(0,t.useEffect)(()=>{V.current={enterInitial:a?.initial||{},enterAnimate:a?.animate||{},exitTarget:o?.exit||{}}},[a,o]);const X=(0,t.useRef)("idle"),K=(0,n.useMotionValue)("idle"),Z=(0,t.useCallback)(e=>{X.current=e,K.set(e)},[K]),_=(0,t.useRef)(null),G=(0,t.useRef)(null),J=(0,t.useRef)(0),Q=(0,t.useRef)(!1),ee=(0,t.useRef)(null),te=(0,t.useRef)(null),ne=(0,t.useRef)(null),re=(0,t.useRef)(()=>{}),ie=(0,t.useRef)(0),ae=(0,t.useRef)(null),oe=(0,t.useRef)(!1),se=(0,t.useRef)(!1),ce=(0,t.useRef)(!1),le=(0,t.useCallback)(()=>r&&i?r.store?.getKeySnapshot(i)??r.zoneStates[i]??null:null,[i,r]);(0,t.useEffect)(()=>{if(!k||!r||!i)return void z.set(null);const e=()=>{z.set(le())};return e(),r.store?.subscribeKey(i,e)},[k,le,i,r,z]);const ue=!!h&&!k&&!(E||M>0),de=!!v&&!k,fe=(0,t.useRef)(!1),ge=(0,t.useRef)(!1),me=(0,t.useCallback)(e=>{e?.publishEnterCompleted()},[]),pe=(0,t.useCallback)(()=>{ie.current+=1,ae.current=null,ee.current&&(clearTimeout(ee.current),ee.current=null),te.current&&(te.current(),te.current=null),ne.current&&(ne.current(),ne.current=null)},[]),he=(0,t.useCallback)(()=>{J.current+=1,G.current&&(G.current.stop(),G.current=null),pe()},[pe]),ve=(0,t.useCallback)(()=>{const e=$.current?.ownerDocument?.defaultView;e&&(ne.current?.(),ne.current=function(e,t){let n=Be.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},Be.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&&Be.get(e)===r&&Be.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,Be.get(e)===r&&Be.delete(e))}}(e,()=>{ne.current=null,re.current()}))},[]),ye=(0,t.useCallback)(()=>{pe(),Z("entering"),j.get()<0&&j.set(0);const e=_.current,t=++J.current,r=(0,n.animate)(j,1,{duration:Math.max(w,0)/1e3,ease:"easeInOut",onComplete:()=>{J.current===t&&(G.current=null,Z("entered"),me(e),ve())}});G.current=r},[pe,w,me,ve,Z,j]),xe=(0,t.useCallback)((e=!1)=>{const t=X.current,n="exited"===t?"exited":"exiting"===t?"exiting":"idle";he();const r={token:++ie.current,origin:n,dependencyReady:!E,delayStarted:!1,delayReady:!1,coldStartBypass:e};ae.current=r,Z("waiting"),N(!1);const i=e=>{ae.current?.token!==r.token||"pending"===e.kind||(r.dependencyReady=!0,te.current=null,ve())};if(!E)return;const a=_.current;a?te.current=a.observeAfter(i):i({kind:"invalid",leaderId:E,reason:"missing"})},[ve,Z,he,E]),Re=(0,t.useCallback)(()=>{const e=ae.current;if(e&&e.dependencyReady){if(!e.delayStarted){if(e.delayStarted=!0,M>0){const t=e.token;return void(ee.current=setTimeout(()=>{ee.current=null,ae.current?.token===t&&(e.delayReady=!0,ve())},M))}e.delayReady=!0}e.delayReady&&ye()}},[M,ye,ve]),Ee=(0,t.useCallback)(()=>{he(),Z("exiting"),N(!1),j.get()>=0&&j.set(-1e-6);const e=++J.current,t=(0,n.animate)(j,-1,{duration:Math.max(R,0)/1e3,ease:"easeInOut",onComplete:()=>{J.current===e&&(G.current=null,Z("exited"))}});G.current=t},[R,he,Z,j]),ke=(0,t.useCallback)(t=>{if(k||S)return;const n=$.current;if(!(n instanceof HTMLElement))return;const r=e?.firstSceneEnterGateKnown,i=e?.firstSceneEnterReady,a=e?.firstSceneEnterActive;if(!1===r)return he(),Z("idle"),j.set(0),void N(!1);if(!1===i&&!0===a)return se.current=!1,he(),Z("idle"),j.set(0),void N(!1);const o=!1===i&&!1===a&&!se.current&&!ue;o&&(se.current=!0,oe.current=!0,he(),Z("entered"),j.set(1),me(_.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-L,m=g?d<=u/2:d>=0&&f<=u-L,p=g?f<=.7*u:d<=O||f>=u-O,h=g?m&&!p:m,v=f<=0,y=f>0&&d<u;if(o)return v&&(ce.current=!1),void N(We("entered",y));if(!oe.current){if(oe.current=!0,ue)return void N(!1);if(v)return he(),Z("entered"),j.set(1),me(_.current),N(We("entered",!1)),void(ce.current=!1);if(!0===i&&!g&&d>=0&&f<=u)return xe(!0),void Re()}if("waiting"===X.current){const e=ae.current;if(e&&(!0===e?.coldStartBypass&&!0===i&&!g&&d>=0&&f<=u||h&&!p))Re();else{const t=e?.origin??"idle";pe(),Z(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}}(X.current,h,p,{hasExplicitExit:U,replay:C});y&&!ce.current&&(ce.current=!0),"enter"!==e||ue||fe.current||ge.current?"exit"===e&&!de&&(!ce.current&&v||Ee()):(xe(),Re())}N(We(X.current,y))},[Re,ue,de,xe,pe,L,O,U,k,me,C,Ee,e?.firstSceneEnterGateKnown,e?.firstSceneEnterActive,e?.firstSceneEnterReady,Z,he,S,j]);re.current=ke;const Pe=(0,t.useCallback)(()=>{fe.current=!0,ge.current=!1,oe.current=!0,se.current=!0,ye()},[ye]),Ce=(0,t.useCallback)(()=>{ge.current=!0,Ee()},[Ee]);(0,t.useEffect)(()=>{if(h&&!k)return h.current=Pe,()=>{h.current===Pe&&(h.current=null)}},[h,k,Pe]),(0,t.useEffect)(()=>{if(v&&!k)return v.current=Ce,()=>{v.current===Ce&&(v.current=null)}},[v,k,Ce]),(0,t.useEffect)(()=>{const t=e?.registerAnimate,n=e?.unregisterAnimate;if(!t||!Y&&!U)return;const r=t(u,{delay:M,duration:Y?y:x,after:E,lane:k?"scroll":"visibility"});return _.current=r??null,Q.current=!1,()=>{pe(),_.current===r&&(_.current=null),r?.dispose?r.dispose():n?.(u)}},[e?.registerAnimate,e?.unregisterAnimate,pe,u,M,y,x,E,Y,U,k]),(0,t.useEffect)(()=>{if(typeof document>"u"||S||$.current?.isConnected)return;const e=document.querySelector(`[data-cineview-animate-host="${u}"]`)??document.querySelector(`[data-cineview-animate-id="${u}"]`);e instanceof HTMLElement&&$.current!==e&&($.current=e,W(e=>e+1))},[u,a,o,S]),(0,t.useEffect)(()=>{if(!(k&&H&&q&&i&&(Y||U)))return;const e=H(i,{animateId:u,delay:M,enterDuration:y,exitDuration:U?x:0,after:E,...void 0!==P||void 0!==I?{phase:{start:P,end:I}}:{}});return()=>{q(i,u,e)}},[u,M,y,x,U,Y,k,I,P,i,E,H,q]);const De=(0,t.useCallback)(e=>{if(!Y&&!U)return"entered"!==X.current&&Z("entered"),void(1!==j.get()&&j.set(1));if(!r||!i)return void(0!==j.get()&&j.set(0));const t=e?.sequence.budgets[u];if(!e||!t)return void(0!==j.get()&&j.set(0));const n=Se(e.progressPx,0,e.totalBudgetPx),a=t.enterStartPx,o=Math.max(t.enterEndPx,t.enterStartPx+1),s="number"==typeof t.phaseStartPx?t.phaseStartPx:He(P,a,a,o),c=Math.max("number"==typeof t.phaseEndPx?t.phaseEndPx:He(I,o,a,o),s+1);if(n>=c&&!Q.current&&(Q.current=!0,me(_.current)),n<=s)return void(0!==j.get()&&j.set(0));if(!t.hasExit)return n>=c?void(1!==j.get()&&j.set(1)):void j.set(Se((n-s)/Math.max(c-s,1),0,1));const l=t.exitStartPx??c,d=t.exitEndPx??l+1;n<=c?j.set(Se((n-s)/Math.max(c-s,1),0,1)):n<=l?1!==j.get()&&j.set(1):n>=d?-1!==j.get()&&j.set(-1):j.set(-Se((n-l)/Math.max(d-l,1),0,1))},[u,Y,U,I,P,me,Z,j,i,r]);(0,t.useEffect)(()=>{if(!k)return;const e=()=>De(z.get());return e(),Y||U?z.on("change",e):void 0},[De,Y,U,k,z]),(0,t.useEffect)(()=>{k||ke()},[B,k,ke,e?.scrollProgress,e?.scrollTimelineState]),(0,t.useEffect)(()=>{if(k)return;const e=$.current;return e instanceof HTMLElement&&!(typeof window>"u")?function(e,t){const n=function(e){const t=$e.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}),$e.set(e,o),o}(e);return n.subscribers.add(t),n.schedule(),()=>{n.subscribers.delete(t),0===n.subscribers.size&&(n.cleanup(),$e.delete(e))}}(e.closest('[data-cineview-container="true"]')??window,ke):void 0},[B,k,ke]),(0,t.useEffect)(()=>he,[he]);const Ae=(0,t.useRef)(!1),Te=(0,t.useCallback)(t=>{if(!(l&&k&&r&&i))return void(Ae.current&&(Ae.current=!1,N(!1)));const n=e?.runtimeState,a=void 0===n||"covered"!==n&&"inactive"!==n&&"parked"!==n&&"exiting"!==n;if(!Y&&!U)return void(Ae.current!==a&&(Ae.current=a,N(a)));const o=t?.sequence.budgets[u];if(!t||!o||!a)return void(Ae.current&&(Ae.current=!1,N(!1)));const s=Se(t.progressPx,0,t.totalBudgetPx),c=o.enterStartPx,d=Math.max(o.enterEndPx,o.enterStartPx+1),f="number"==typeof o.phaseStartPx?o.phaseStartPx:He(P,c,c,d),g=Math.max("number"==typeof o.phaseEndPx?o.phaseEndPx:He(I,d,c,d),f+1),m=Y?s>=g-.5:s>.5,p=!o.hasExit||null===o.exitStartPx||s<=o.exitStartPx+.5,h=m&&p;Ae.current!==h&&(Ae.current=h,N(h))},[u,Y,U,l,k,I,P,e?.runtimeState,N,i,r]);return(0,t.useEffect)(()=>{if(k&&l)return Te(z.get()),Y||U?z.on("change",Te):void 0;Te(null)},[Y,U,l,k,Te,z]),{style:Ie(j,V,(e,t,n)=>function(e,t,n){const r=n>=0,i=r?e.enterAnimate:e.exitTarget;return be(we(r?e.enterInitial:e.enterAnimate,t,Me(t,r?"initial":"animate")),i,t,Me(t,r?"animate":"exit"),r?n:Math.abs(n))}(t,n,e)).style,shouldRunInfinite:F,visualMotion:j,phaseMotion:K}}({sceneContext:"scroll"===$?p:null,zoneRuntime:"scroll"===$?Ke:null,zoneId:x,enterVariant:b,exitVariant:R,hasAuthoredEnterAnimation:!!e,hasAuthoredExitAnimation:!!i,hasInfiniteAnimation:!!E,componentId:m,duration:{enter:je,exit:Fe},timeline:X,visibility:N.visibility,globalEnterMargin:h?.scrollEnterMargin,globalExitMargin:h?.scrollExitMargin,enterRef:ye?d:void 0,exitRef:ye?f:void 0,variantsPending:he});(0,t.useEffect)(()=>{if("drag"!==$||0===P)return;const e=T.current;!e||e.generation!==P||(e.lease.complete(),T.current=null)},[$,P]);const tt=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)(mt);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:Xe(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(mt);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:Ue(e.mode,t),source:pt(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:$,isDragArrival:q,timelineLane:"scroll"===$||q?X.lane:"drag",sceneContext:p,arrivalVisualMotion:Qe.visualMotion,arrivalPhaseMotion:Qe.phaseMotion,scrollVisualMotion:et.visualMotion,scrollPhaseMotion:et.phaseMotion,dragVisualState:Ze.visualState});(0,t.useEffect)(()=>{const e=q?le:E;if("drag"===$&&e){if(S||!(q?Qe.shouldRunInfinite:Ze.shouldRunInfinite))return void z.stop();z.start({...e.animate,transition:{...e.animate.transition||{},repeat:1/0}})}},[Qe.shouldRunInfinite,z,Ze.shouldRunInfinite,E,q,$,S,le]),(0,t.useEffect)(()=>{if("scroll"===$&&E){if(S||!et.shouldRunInfinite)return void F.stop();F.start({...E.animate,transition:{...E.animate.transition||{},repeat:1/0}})}},[$,E,S,et.shouldRunInfinite,F]);const it=pe?g:void 0,at=pe?null:g,ot=(0,r.jsx)(ft,{value:tt,children:ke?Ee&&se?"scroll"===$?(0,r.jsx)(ct,{container:Ee,variant:se,each:Pe,from:Ce,itemDurationMs:Te?.itemDurationMs,effectiveDurationMs:Te?.effectiveDurationMs,exitVariant:ce,exitItemDurationMs:Ve?.itemDurationMs,signedVisual:et.visualMotion}):q?(0,r.jsx)(lt,{container:Ee,variant:se,each:Pe,from:Ce,itemDurationMs:Te?.itemDurationMs,effectiveDurationMs:Te?.effectiveDurationMs,phaseMotion:Qe.phaseMotion,staticReveal:Qe.staticReveal}):(0,r.jsx)(ut,{container:Ee,variant:se,each:Pe,from:Ce,itemDurationMs:Te?.itemDurationMs,effectiveDurationMs:Te?.effectiveDurationMs,exitVariant:ce,exitItemDurationMs:Ve?.itemDurationMs,visualState:Ze.visualState}):null:it?"scroll"===$||q?(0,r.jsx)(Ge,{signedVisual:q?Qe.visualMotion:et.visualMotion,phaseMotion:q?Qe.phaseMotion:et.phaseMotion,render:it}):(0,r.jsx)(Je,{visualState:Ze.visualState,render:it}):at}),st=ke?Rt:et.style,dt=ke?Rt:q?Qe.style:Ze.style;return se||ce||le||he?"scroll"===$?le?(0,r.jsx)("div",{"data-cineview-animate-host":m,children:(0,r.jsx)(n.motion.div,{style:st,className:"cineview-animate","data-cineview-animate-id":m,children:(0,r.jsx)(n.motion.div,{animate:F,children:ot})})}):(0,r.jsx)("div",{"data-cineview-animate-host":m,children:(0,r.jsx)(n.motion.div,{style:st,className:"cineview-animate","data-cineview-animate-id":m,children:ot})}):le?(0,r.jsx)(n.motion.div,{style:dt,className:"cineview-animate","data-cineview-animate-id":m,children:(0,r.jsx)(n.motion.div,{animate:z,children:ot})}):(0,r.jsx)(n.motion.div,{style:dt,className:"cineview-animate","data-cineview-animate-id":m,children:ot}):(0,r.jsx)(ft,{value:tt,children:it?it(_e):at})};Et.displayName="Animate";var kt=(0,t.createContext)({lastX:0,lastY:0}),Pt=(0,t.createContext)(null),It=(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=ze(),p=Ne(),h=(0,t.useContext)(kt),v=(0,t.useContext)(Pt),S=e?.x??n,y=e?.y??a,x=e?.offsetX??o,b=e?.offsetY??s,w=c,R=e?.anchor,M="center"===R||"center-x"===R,E="center"===R||"center-y"===R,k=w&&"scroll"===p?.mode&&!v,{finalLeft:P,finalTop:I,finalX:C,finalY:D}=(0,t.useMemo)(()=>{const e=m?.convert??(e=>e);if(void 0!==S||void 0!==y){const t=void 0!==S?S:0,n=void 0!==y?y:0;return{finalLeft:e(t),finalTop:e(n),finalX:t,finalY:n}}if(void 0!==x||void 0!==b){const t=h.lastX+(void 0!==x?x:0),n=h.lastY+(void 0!==b?b:0);return{finalLeft:e(t),finalTop:e(n),finalX:t,finalY:n}}return{finalLeft:0,finalTop:0,finalX:0,finalY:0}},[m,h,x,b,S,y]),{leftStyle:A,topStyle:T,centerTransform:L}=(0,t.useMemo)(()=>{const e=m?.convert??(e=>e),t=[];let n=P;if(M){const r=e(S??0);n=0===r?"50%":`calc(50% + ${r}px)`,t.push("translateX(-50%)")}let r=I;if(E){const n=e(y??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,M,E,S,y,P,I]),O=(0,t.useMemo)(()=>({lastX:C,lastY:D}),[C,D]),V=(0,t.useMemo)(()=>{const e=[L,u?.transform].filter(Boolean).join(" ")||void 0;return{...u,position:k?"sticky":"absolute",left:A,top:T,pointerEvents:w?u?.pointerEvents??"auto":u?.pointerEvents,transform:e}},[k,w,A,T,L,u]),j=(0,r.jsx)(kt.Provider,{value:O,children:(0,r.jsx)("div",{ref:g,style:V,className:d,...f,children:l})});return w&&v&&!k?(0,i.createPortal)(j,v):j});It.displayName="Position";var Ct={opacity:1,x:0,y:0,scale:1,rotate:0};function Dt(e,t){return function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}(e)?{...t,...e}:t}function At(e){return Math.max(0,Math.min(e,1))}var Tt="time",Lt={time:10,percent:1},Ot={unit:Tt,scale:Lt[Tt]};function Vt(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:Tt,scale:Lt.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:Lt[a]}):{unit:a,scale:o??Lt[a]}}function jt(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))}function zt(e,t){return"drag"!==e?"auto":"y"===t?"pan-x pinch-zoom":"pan-y pinch-zoom"}function Ft({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 Nt({onVisibilityChange:e,sceneVisibilityCallback:t,sceneIndex:n,visible:r,progress:i}){e?.(r,i),t?.({sceneIndex:n,visible:r,progress:i})}function $t({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 Bt({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=$t({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 Wt(e,t){return e===t||"visibility"===e&&"scroll"===t}var Ht=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 qt(e){return new Ht(e)}function Yt(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 Ut(e,t){const n=Yt(t);e.some(e=>Yt(e)===n)||e.push(t)}function Xt({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=>{Ut(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)),Ut(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||Wt(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 Ut(a,{type:"incompatible-lane",animateId:e,after:u.after,followerLane:u.lane,leaderLane:i.lane});else void 0===u.lane||void 0===o||Wt(u.lane,o)?Ut(a,{type:"missing-dependency",animateId:e,after:u.after}):Ut(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 Kt(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 Zt(e){let t;return e.forEach(e=>{t=e}),t}function _t(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 Gt(){return typeof performance<"u"?performance.now():Date.now()}function Jt(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}function Qt(e){return Math.max(0,Math.min(Number.isFinite(e)?e:0,1))}function en(e){return Object.freeze({...e,mapping:Object.freeze({...e.mapping}),enterVariantsByAnimateId:qt(e.enterVariantsByAnimateId)})}var tn=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,en(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=Qt(n);return Object.freeze({...e,phase:t,releaseSeed:Object.freeze({progressRatio:r,elapsedMs:jt(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=Qt(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:jt(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()}},nn=t.default.createContext(null),rn=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"]),an=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:v,globalDirection:S,globalSharedTimelineDurationMs:y,globalActivationToken:x,globalActivationKind:b,globalFirstSceneEnterGateKnown:w,globalFirstSceneEnterActive:R,globalFirstSceneEnterReady:M,globalViewportWidth:E,globalViewportHeight:k,globalDragProgress:P,globalRenderProgress:I,globalDragTimelineProgress:C,globalIsDragging:D,globalDragRelease:A,globalScrollProgress:T,globalIsScrolling:L,globalScrollDirection:O,globalScrollTransitionSnapshot:V,globalScrollBackdropActive:j,globalScrollTimelineState:z,globalScrollViewportOffset:F,resolvedSceneWidth:N,resolvedSceneHeight:$,resolvedSceneAnchor:B,resolvedSceneOverflow:W,resolvedSceneZIndex:H,effectiveSceneStackMode:q,resolvedSceneTransitionDuration:Y,resolvedEnterAnimation:U,resolvedExitAnimation:X,sceneVisibilityCallback:K,onVisibilityChange:Z,onSceneChange:_,dragRuntime:G,onActivationComplete:J,onDragProgressChange:Q,onRenderProgressChange:ee,onDragTimelineProgressChange:te,onDraggingChange:ne,onSharedTimelineDurationChange:re,onDragRelease:ie,onDragGestureEnd:ae,onDragReset:oe,slideDuration:se,compatFields:ce}=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),le=e.scrollRuntime?.frameStore,ue=e.scrollRuntime?.sceneIndex??p,de=ze(),fe=Ne(),ge=fe?.reportError,pe=(0,n.useAnimation)(),[ve,Se]=(0,t.useState)(null),[ye,xe]=(0,t.useState)(null),be=(0,t.useRef)(0);(0,t.useRef)(null);const we=bt(U),Re=bt(X),Me=!!(G||e.onDragProgressChange||e.onRenderProgressChange||e.onDragTimelineProgressChange||e.onDraggingChange||e.onSharedTimelineDurationChange||e.onDragGestureEnd||e.onDragReset),[Ee,ke]=(0,t.useState)(P),[Pe,Ie]=(0,t.useState)(I),[Ce,De]=(0,t.useState)(C),[Ae,Te]=(0,t.useState)(D),[Le,Oe]=(0,t.useState)(y),[Ve,je]=(0,t.useState)(A),Fe=(0,t.useRef)(0),$e=(0,t.useCallback)(e=>{null!==e?(Fe.current+=1,je({...e,token:Fe.current})):je(null)},[]),Be=Me?P:Ee,We=Me?I:Pe,He=Me?C:Ce,qe=Me?D:Ae,Ye=Me?y:Le,Ue=Me?A:Ve,Xe=qe,Ke=(0,n.useMotionValue)(Be),Ze=G?.renderProgressMotion??Ke,_e=(0,n.useMotionValue)(He),Ge=G?.timelineProgressMotion??_e,Je=(0,n.useMotionValue)(0),[Qe,et]=(0,t.useState)("initial"),tt=p-v,[nt,rt]=(0,t.useState)(!1),it=(0,t.useRef)(Symbol(`scene:${p}`)),at=(0,t.useRef)(null),ot=(0,t.useRef)(G?.onPreparedInvalidated);ot.current=G?.onPreparedInvalidated;const[st,ct]=(0,t.useState)(null),lt=(0,t.useMemo)(()=>G?.dragMappingConfig??Vt(void 0,e.drag),[G?.dragMappingConfig,e.drag]),ut=(0,t.useCallback)((t,n,r)=>{if("drag"!==f)return;const i=en({sceneIndex:p,instanceId:it.current,revision:n,enabled:!1!==e.drag?.enabled,mapping:lt,registrySnapshot:t,enterVariantsByAnimateId:r});at.current=i,ct(i),G?.onPrepared?.(i)},[G,f,lt,e.drag?.enabled,p]),{timelineDuration:dt,beginPreparation:ft,registerAnimate:gt,declareAnimateLane:mt,unregisterAnimate:pt,getCalculatedDelay:vt,getTimelineDuration:yt}=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)(Xt({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),S=(0,t.useRef)(null),y=(0,t.useRef)(!0),x=(0,t.useRef)(r);x.current=r;const b=(0,t.useRef)(i);b.current=i;const w=(0,t.useRef)(n),[R,M]=(0,t.useState)(n),[E,k]=(0,t.useState)(!1),P=(0,t.useCallback)(()=>{y.current&&k(!1)},[]),I=(0,t.useCallback)(t=>{t.forEach(t=>{const n=Kt(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.`),x.current?.({code:r,message:i,context:{sceneIndex:e}})})},[e]),C=(0,t.useCallback)(()=>{s.current.clear(),c.current.clear(),l.current.clear(),a.current.forEach((e,t)=>{const n=Zt(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)})},[]),D=(0,t.useCallback)(()=>{C();const e=Xt({baseDuration:n,registrations:s.current,declaredLanes:c.current,duplicateIds:l.current});return u.current=e,w.current=e.timelineDuration,y.current&&M(t=>t===e.timelineDuration?t:e.timelineDuration),e},[n,C]),A=(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&&!Wt(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=Zt(i);return t&&A(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&&!Wt(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}},[A]),L=(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))},[]),O=(0,t.useCallback)(e=>{g.current.forEach(t=>{[...t].forEach(n=>{n.follower.disposed||n.terminal?t.delete(n):(L(n,T(n,e)),n.terminal&&t.delete(n))})}),g.current.forEach((e,t)=>{0===e.size&&g.current.delete(t)})},[L,T]),V=(0,t.useCallback)(e=>{if(0!==p.current||!y.current)return;const t=new Map;a.current.forEach((e,n)=>{const r=Zt(e);r?.enterVariant&&t.set(n,r.enterVariant)});const n=v.current,r=S.current,i=null!==n&&null!==r&&function(e,t){return e.timelineDuration===t.timelineDuration&&_t(e.registrations,t.registrations,(e,t)=>e.delay===t.delay&&e.duration===t.duration&&e.after===t.after&&e.lane===t.lane)&&_t(e.calculatedDelays,t.calculatedDelays)&&e.issues.length===t.issues.length&&e.issues.every((e,n)=>Kt(e)===Kt(t.issues[n]))}(n,e)&&_t(r,t);k(!0),!i&&(h.current+=1,v.current=e,S.current=new Map(t),b.current?.(function(e){const t=[];return e.registrations.forEach((e,n)=>{t.push([n,Object.freeze({...e})])}),Object.freeze({registrations:qt(t),calculatedDelays:qt(e.calculatedDelays),issues:Object.freeze([...e.issues]),timelineDuration:e.timelineDuration})}(e),h.current,t))},[]),j=(0,t.useCallback)(()=>{if(0!==p.current||!y.current)return;null!==f.current&&(clearTimeout(f.current),f.current=null);const e=D();I(e.issues),O(!0),V(e)},[V,D,O,I]),z=(0,t.useCallback)(()=>{P(),null!==f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,j()},0)},[j,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()&&j()},cancel:()=>{t()&&z()}}},[j,P,z]),N=(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)})},[]),$=(0,t.useCallback)(e=>{if(e.disposed)return;e.disposed=!0,N(e);const t=a.current.get(e.id);t?.delete(e.token),0===t?.size&&a.current.delete(e.id),D(),z()},[D,N,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),D(),z(),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,z())},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),L(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,O(!1))},dispose:()=>$(n)}},[$,L,T,D,O,e,z]),W=(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),D(),z(),{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),D(),z()}}},[D,z]),H=(0,t.useCallback)(e=>{const t=a.current.get(e),n=t?Zt(t):void 0;n&&$(n)},[$]),q=(0,t.useCallback)(e=>u.current.calculatedDelays.get(e)??s.current.get(e)?.delay??0,[]),Y=(0,t.useCallback)(()=>w.current,[]);return(0,t.useEffect)(()=>{z()},[n,z]),(0,t.useEffect)(()=>{y.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()=>{y.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:E,beginPreparation:F,registerAnimate:B,declareAnimateLane:W,unregisterAnimate:H,getCalculatedDelay:q,getTimelineDuration:Y}}({sceneIndex:p,baseDuration:"drag"===f?0:Y,reportError:fe?.reportError,onStableSnapshot:ut}),xt=(0,t.useRef)(!1);(0,t.useEffect)(()=>{xt.current||t.default.Children.count(a)>0||(xt.current=!0,ge?.({code:"EMPTY_SCENES",message:`Scene ${p} has no children; it renders an empty full-screen layer.`,context:{scope:"scene",sceneIndex:p}}))},[a,ge,p]),(0,t.useEffect)(()=>()=>{const e=at.current;e&&ot.current?.({sceneIndex:e.sceneIndex,instanceId:e.instanceId,revision:e.revision})},[]);const Rt=(0,t.useRef)(null),Mt=(0,t.useCallback)(e=>{Rt.current=e,"function"==typeof i?i(e):i&&(i.current=e)},[i]),[Et,kt]=(0,t.useState)(null),It=(0,t.useCallback)(e=>{kt(t=>t===e?t:e)},[]),Tt=function({sceneId:e,sceneIndex:n,mode:r,scroll:i,elementRef:a}){const o=(0,t.useContext)(ht),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:Rt});(0,t.useEffect)(()=>{G?.renderProgressMotion||Ke.set(Be)},[Be,G?.renderProgressMotion,Ke]),(0,t.useEffect)(()=>{G?.timelineProgressMotion||_e.set(He)},[He,G?.timelineProgressMotion,_e]),(0,t.useEffect)(()=>{Me&&(ke(P),Ie(I),De(C),Te(D),Oe(y),je(A))},[Me,P,I,C,D,y,A]);const Lt=(0,t.useCallback)(e=>"drag"!==f?0:!Me&&h<=1?Math.max(-1,Math.min(1,e)):0===v&&e<0||v===h-1&&e>0?0:Math.max(-1,Math.min(1,e)),[f,Me,v,h]);(0,t.useEffect)(()=>{},[de,p]),(0,t.useEffect)(()=>{"scroll"!==f&&kt(null)},[f]),(0,t.useEffect)(()=>{const e=++be.current,t=()=>be.current===e,n=e=>{t()&&ge?.(e)};return Se(null),xe(null),"scroll"!==f?((we||Re)&&[we?"enterAnimation":null,Re?"exitAnimation":null].filter(Boolean).join(","),()=>{t()&&(be.current+=1)}):we||Re?((async()=>{const[e,r]=await Promise.all([me(we,`Scene ${p}`,"enter",n),me(Re,`Scene ${p}`,"exit",n)]);t()&&(Se(e??null),xe(r??null))})(),()=>{t()&&(be.current+=1)}):()=>{t()&&(be.current+=1)}},[f,ge,p,we,Re]);const Ht=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:Qe,isActive:m,sceneOffset:tt,globalScrollProgress:T,globalScrollDirection:O,globalIsScrolling:L,globalScrollBackdropActive:j,hasExitAnimation:!!X,scrollTimelineState:z}),Yt=(0,t.useMemo)(()=>Ft({effectiveMode:f,isActive:m,globalScrollTimelineState:z,hasExitAnimation:!!X}),[f,m,z,X]),Ut=Yt>.001,Qt=(0,t.useRef)(Z),tn=(0,t.useRef)(K);(0,t.useEffect)(()=>{Qt.current=Z,tn.current=K},[Z,K]),(0,t.useEffect)(()=>{"scroll"===f&&le||Nt({onVisibilityChange:Qt.current,sceneVisibilityCallback:tn.current,sceneIndex:p,visible:Ut,progress:Yt})},[f,p,Ut,Yt,le]),(0,t.useEffect)(()=>{if("scroll"!==f||!le)return;const e=()=>{const e=le.getKeySnapshot(ue)??null,t=Ft({effectiveMode:f,isActive:e?.isCurrent??m,globalScrollTimelineState:e?.timelineState??null,hasExitAnimation:!!X});Nt({onVisibilityChange:Qt.current,sceneVisibilityCallback:tn.current,sceneIndex:p,visible:t>.001,progress:t})};return e(),le.subscribeKey(ue,e)},[f,le,m,X,p,K,ue]),(0,t.useEffect)(()=>{"drag"!==f||!m||((G?.onSharedTimelineDurationChange??re)?.(yt()),Me||Oe(yt()))},[f,m,yt,dt,G,re,Qe,Me]);const an="drag"===f?M&&null!==st:M,on=(0,t.useMemo)(()=>({mode:f,isActive:m,isDragging:!1,dragProgressMotion:Ze,runtimeState:Ht,sceneState:Qe,sceneOffset:tt,activationToken:x,activationKind:b,firstSceneEnterGateKnown:0===p?w:void 0,firstSceneEnterActive:0===p?R:void 0,firstSceneEnterReady:0===p?an:void 0,sceneTransitionDuration:Y,getTimelineDuration:yt,beginPreparation:ft,registerAnimate:gt,declareAnimateLane:mt,unregisterAnimate:pt,getCalculatedDelay:vt,enterDuration:se}),[ft,mt,f,an,vt,b,x,R,w,yt,m,Ze,gt,Y,p,tt,Qe,se,pt,Ht]),sn=(0,t.useMemo)(()=>({...on,isDragging:Xe,dragProgressMotion:Ze,renderProgressMotion:Ze,dragTransaction:G?.transaction??null,preparedSnapshot:st,dragTimelineProgress:He,sharedElapsedMotion:Je,renderProgress:We,dragRelease:Ue,sharedTimelineDurationMs:Ye,firstSceneEnterActive:R}),[Ue,He,We,Ye,Ze,G?.transaction,Je,R,Xe,st,on]),cn="drag"===f?sn:on;!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 S=(0,t.useRef)(null),y=(0,t.useRef)(null),x=(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=Dt(t.enterVariant?.animate,Ct),m=Dt(t.enterVariant?.initial,g),p=Dt(t.exitVariant?.exit,g),h=e=>{S.current!==e&&(S.current=e,t.setSceneState(e))},x=(e,n,r)=>{const i=y.current;i&&i.kind===e&&i.progress===n&&i.enterVariant===t.enterVariant&&i.exitVariant===t.exitVariant&&i.controls===t.controls||(y.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 x("before",0,m);if("enter"===r.phase){const e=At(r.enterProgress);return h("entering"),void x("enter",e,he(m,g,e))}if("hold"===r.phase)return h("active"),void x("hold",1,g);if("exit"===r.phase){const e=At(r.exitProgress);return h(t.exitVariant?.exit?"exiting":"active"),void x("exit",e,t.exitVariant?.exit?he(g,p,e):g)}h(f?t.exitVariant?.exit?"exiting":"active":t.exitVariant?.exit?"exiting":i?"active":"initial"),x("after",1,t.exitVariant?.exit?p:g)}else if(u){h("entering");const e=At(c);x("fallback-enter",e,he(m,g,e))}else if(d||f){h(t.exitVariant?.exit?"exiting":"active");const e=At(c);x("fallback-exit",e,t.exitVariant?.exit?he(g,p,e):g)}else h(i?"active":"initial"),x(i?"fallback-active":"fallback-initial",i?1:0,i?g:m)},[]);(0,t.useEffect)(()=>{if("scroll"===e){if(m&&"number"==typeof p){const e=()=>{x(m.getKeySnapshot(p)??null)};return e(),m.subscribeKey(p,e)}x(null)}},[x,o,s,f,u,l,g,d,c,n,r,i,p,m,e])}({slideMode:f,isActive:m,sceneOffset:tt,sceneStackMode:q,controls:pe,enterVariant:ve,exitVariant:ye,globalIsScrolling:L,globalScrollProgress:T,globalScrollDirection:O,globalScrollTransitionSnapshot:V,globalScrollBackdropActive:j,globalScrollTimelineState:z,scrollFrameStore:le,scrollFrameSceneIndex:ue,setSceneState:et});const ln=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:S,preparedSnapshot:y,requirePreparedSnapshot:x=!1,dragMappingConfig:b,takeoverSnapshot:w,onElementContinuationChange:R,onSettleComplete:M,onColdStartComplete:E}){const k=(0,t.useRef)(null),P=(0,t.useRef)(null),I=(0,t.useRef)(0),C=(0,t.useRef)(null),D=(0,t.useRef)(null),A=(0,t.useRef)(!1),T=(0,t.useRef)(0),L=(0,t.useRef)(!1),O=(0,t.useRef)(h);O.current=h;const V=(0,t.useRef)(S);V.current=S;const j=(0,t.useRef)(y);j.current=y;const z=(0,t.useRef)(x);z.current=x;const F=(0,t.useRef)(null),N=()=>V.current||(z.current?null:j.current??null),$=e=>e?.registrySnapshot.timelineDuration??O.current(),B=e=>e?.mapping??J.current,W=(0,t.useRef)(M);W.current=M;const H=(0,t.useRef)(E);H.current=E;const q=(0,t.useRef)(R);q.current=R;const Y=(0,t.useRef)(!1),U=e=>{Y.current!==e&&(Y.current=e,q.current?.(e))},X=(0,t.useRef)(p);X.current=p;const K=(0,t.useRef)(null),Z=(0,t.useRef)(null),_=(0,t.useRef)(null),G=(0,t.useRef)(null),J=(0,t.useRef)(b??Ot);J.current=b??Ot;const Q=(0,t.useRef)(f?.get()??u);return Q.current=f?.get()??u,(0,t.useEffect)(()=>{if("drag"===e&&c&&k.current){if(Y.current){K.current=Math.max(0,X.current.get());const e=w?.current,t=e?.sceneIndices.includes(i)??!1;_.current=t?e.token:null,Z.current=t?e.baseRatio:null,G.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=_.current,t=w?.current;null!==e&&t?.token===e&&null!==t.baseRatio||(K.current=null,Z.current=null,_.current=null,G.current=null)},[c,s,w]),(0,t.useEffect)(()=>{if("drag"!==e||!s)return;k.current&&(k.current.stop(),k.current=null,P.current=null),U(!1),A.current=!0,L.current=!1;const t=e=>{Q.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=N();if(z.current&&!r)return;const s=$(r),c=Math.max(0,Math.min(e,1)),u=B(r),f=K.current;if(null!==f){const e=w?.current,n=_.current;if(null!==n&&e?.token===n&&e.sceneIndices.includes(i)&&null!==e.baseRatio){const r=e.baseRatio;if(Z.current=r,G.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(G.current=n);const i=jt(u,s,100*r),a=jt(u,s,100*c);return void X.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=jt(u,s,100*r),o=jt(u,s,100*c);return void X.current.set(Math.max(0,Math.min(s,f+o-a)))}X.current.set(jt(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,S?.transactionId]),(0,t.useEffect)(()=>{if("drag"!==e||c)return;const t=g;if(!t||t.targetSceneIndex!==i)return;const r=N();if(z.current&&!r||C.current===t.token)return;C.current=t.token;const a=++I.current;k.current?.stop(),k.current=null,U(!1);const o=X.current,s=$(r),l="number"==typeof t.progressRatio?t.progressRatio:Q.current,u=r&&"releaseSeed"in r?r.releaseSeed.elapsedMs:jt(B(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 U(!1),o.set(s),D.current=t.token,void W.current?.();P.current="settle",U(!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,U(!1),o.set(s),D.current=t.token,W.current?.())}})}else{if(d<=.001)return U(!1),void o.set(0);const e=Math.min(.5*Math.max(d,0),300);P.current="bounce",U(!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,U(!1),o.set(0))}})}},[e,g?.token,i,S?.transactionId]),(0,t.useEffect)(()=>{if("drag"!==e||c||s)return;const t=g;if(!t||"enter"===t.mode||t.targetSceneIndex!==i||C.current!==t.token||"settle"===t.mode&&D.current===t.token||k.current)return;const r=N();if(z.current&&!r)return;const a=X.current,o=Math.max(0,a.get());if("bounce"===t.mode){if(o<=.001)return U(!1),void a.set(0);const e=++I.current;return P.current="bounce",U(!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,U(!1),a.set(0))}}))}const l=$(r),u=l-o;if(u<=.001)return U(!1),a.set(l),D.current=t.token,void W.current?.();const d=++I.current;P.current="settle",U(!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,U(!1),a.set(l),D.current=t.token,W.current?.())}})},[e,c,s,g?.token,i]),(0,t.useEffect)(()=>{if("drag"!==e||0!==i||!m||s)return;const t=X.current;if(!A.current){const e=j.current??null;if(z.current&&!e)return;F.current=e;const r=$(e);A.current=!0,L.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(!L.current||F.current)return;const r=O.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,y?.revision]),(0,t.useEffect)(()=>()=>{k.current?.stop(),k.current=null,U(!1)},[]),{completeImmediately:(0,t.useCallback)(()=>{I.current+=1,k.current?.stop(),k.current=null,P.current=null,U(!1),X.current.set(O.current())},[]),resetImmediately:(0,t.useCallback)(()=>{I.current+=1,k.current?.stop(),k.current=null,P.current=null,U(!1),X.current.set(0)},[])}}({slideMode:f,isActive:m,sceneIndex:p,sceneOffset:tt,globalDirection:S,globalRenderProgress:We,renderProgressMotion:Ze,globalIsDragging:qe,candidateSuspended:G?.candidateSuspended??!1,globalDragTimelineProgress:He,dragTimelineProgressMotion:Ge,dragRelease:Ue,firstSceneEnterReady:M,elementElapsedMotion:Je,getTimelineDuration:yt,timelineDurationState:dt,dragTransaction:G?.transaction??null,preparedSnapshot:st,requirePreparedSnapshot:Me,dragMappingConfig:G?.dragMappingConfig,takeoverSnapshot:G?.takeoverSnapshot,onElementContinuationChange:G?.onElementContinuationChange,onSettleComplete:G?.onActivationComplete??J,onColdStartComplete:G?.onActivationComplete??J}),{handleCandidateSuspend:un,handleCandidateResume:dn,handleDragStart:fn,handlePan:gn,handlePanEnd:mn}=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:S,setSceneState:y,setIsAnimating:x,resolveDragProgress:b,getTimelineDuration:w,onDragProgressChange:R,onRenderProgressChange:M,onDragTimelineProgressChange:E,onOwnershipRequest:k,onCandidateSuspensionChange:P,takeoverSnapshot:I,onDraggingChange:C,onDragRelease:D,renderLaneRef:A,completeReleaseImmediately:T=!1,onDragEnd:L,onDragReset:O,thresholdConfig:V}){(0,t.useRef)(null);const j=(0,t.useRef)(null),z=(0,t.useRef)(0),F=(0,t.useRef)(null),N=A??F,$=(0,t.useRef)(!1),B=(0,t.useRef)(0),W=(0,t.useRef)(!1),H=(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&&y(a)},[e,v,r,d,i,g,m,u,f,y]),(0,t.useEffect)(()=>()=>{z.current+=1;const e=N.current;e&&e.ownerSceneIndex===i&&(e.stop(),N.current=null),$.current=!1,W.current=!1},[N,i]),{handleCandidateSuspend:(0,t.useCallback)(()=>{if("drag"!==e)return!1;const t=N.current,n=!!t?.suspend;W.current=n,t?.suspend?.();const r=P?.(!0)??!1;return n||r},[N,P,e]),handleCandidateResume:(0,t.useCallback)(()=>{N.current?.resume?.(),W.current=!1,P?.(!1)},[N,P]),handleDragStart:(0,t.useCallback)(t=>{if("drag"!==e)return!1;const n=N.current;if(!r&&!n||k&&!k(t))return!1;const i=n&&W.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(),N.current=null,W.current=!1,B.current=i,H.current=!0,S.set(i),R?.(i),E?.(Math.abs(i)),n.kind,i.toFixed(3)):(B.current=0,H.current=!1),$.current=!0,p.toFixed(3),h.toFixed(3),C?.(!0),!0},[e,r,N,k,S,R,E,C,i,a,o,p,h,g,P,I]),handlePan:(0,t.useCallback)((t,n)=>{if("drag"!==e||!r&&!$.current)return;const i="y"===s?n.offset.y:n.offset.x,a=b(B.current-i/("y"===s?window.innerHeight:window.innerWidth)),o=Math.abs(a);S.set(a),R?.(a),E?.(o),M?.(a)},[e,r,s,i,R,E,M,S,b]),handlePanEnd:(0,t.useCallback)((t,o)=>{if("drag"!==e||!r&&!$.current)return;$.current=!1;const l="pointercancel"===t.type;z.current+=1,N.current?.stop(),N.current=null;const u=S.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=S.get(),o=0,s=!1,c=!1;const l=e/Math.max(Math.abs(a),1e-6),u=()=>{c||s||N.current!==g||(N.current=null,r?.stop(),a=0,S.set(0),R?.(0),E?.(0),M?.(0),t())},d=()=>{if(c||s||N.current!==g)return;const e=Math.abs(a)*l;if(e<=1e-6)return void u();const t=++o;r=(0,n.animate)(S,0,{duration:e,ease:"easeOut",onUpdate:e=>{t!==o||c||s||(a=e,S.set(e),R?.(e),E?.(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=S.get(),s=!0,o+=1,r?.stop())},resume:()=>{c||!s||(a=S.get(),s=!1,d())},preempt:f,getCurrent:()=>a};N.current=g,d()};if(m<.001){if(u.toFixed(3),O?.(),H.current){const e=B.current>=0?"forward":"backward";D?.({mode:"bounce",direction:e,targetSceneIndex:"forward"===e?a+1:a-1})}return C?.(!1),void(r&&y("active"))}const h=u>0?"forward":"backward",v="forward"===h?a+1:a-1;if(0===b(u)&&0!==u)return x(!0),u.toFixed(3),g.toFixed(1),C?.(!1),D?.({mode:"bounce",direction:h,targetSceneIndex:v}),void p(.15,()=>{O?.(),y("active"),x(!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,V);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(x(!0),C?.(!1),T)return L?.(h,1,d,d),void x(!1);const e=++z.current,t="forward"===h?1:-1,r=Math.abs(t-u),a=Math.max(r*(c/1e3),0),o=Math.min(m,1);D?.({mode:"settle",direction:h,targetSceneIndex:v,progressRatio:m});let s=null,l=u,f=0,g=!1,p=!1;const y=()=>{p||g||N.current!==R||(N.current=null,s?.stop(),o.toFixed(3),(1e3*a).toFixed(1),L?.(h,o,o*d,d),M?.(0),x(!1))},b=()=>{if(p||g||N.current!==R)return;const r=Math.abs(t-l)*(c/1e3);if(r<=1e-6)return void y();const i=++f;s=(0,n.animate)(l,t,{duration:r,ease:"easeOut",onUpdate:n=>{if(i===f&&!p&&!g&&z.current===e&&(l=n,Math.abs(n-t)>1e-6&&S.set(n),M?.(n),0)){const e=Math.round(10*Math.abs(n))/10;j.current!==e&&(j.current=e)}},onComplete:()=>{i===f&&(l=t,y())}})},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,b())},preempt:w,getCurrent:()=>l};u.toFixed(3),(1e3*a).toFixed(1),o.toFixed(3),N.current=R,b()}else{x(!0);const e=Math.min(m*c,300)/1e3;u.toFixed(3),(1e3*e).toFixed(1),C?.(!1),D?.({mode:"bounce",direction:h,targetSceneIndex:v}),p(e,()=>{O?.(),x(!1)})}},[e,r,N,s,i,a,c,S,R,E,M,D,L,O,C,b,w,l,x,y,T,V])}}({slideMode:f,isActive:m,sceneIndex:p,currentSceneIndex:v,totalScenes:h,slideDirection:g,slideDuration:se,sceneTransitionDuration:Y,sceneOffset:tt,sceneState:Qe,globalDirection:S,globalRenderProgress:We,globalIsDragging:qe,globalDragProgress:Be,globalDragTimelineProgress:He,controls:pe,dragProgressMotion:Ze,setSceneState:et,setIsAnimating:rt,resolveDragProgress:Lt,getTimelineDuration:yt,onOwnershipRequest:G?.onOwnershipRequest,onCandidateSuspensionChange:G?.onCandidateSuspensionChange,takeoverSnapshot:G?.takeoverSnapshot,onDragProgressChange:G?.onProgressChange??Q,onRenderProgressChange:G?.onRenderProgressChange??ee,onDragTimelineProgressChange:G?.onTimelineProgressChange??te??(Me?void 0:e=>_e.set(e)),onDraggingChange:G?.onDraggingChange??ne??(Me?void 0:Te),onDragRelease:G?.onRelease??ie??(Me?void 0:$e),renderLaneRef:G?.renderLane,completeReleaseImmediately:!Me,thresholdConfig:G?.threshold,onDragEnd:G?.onCommit??ae??(Me?void 0:(e,t,n,r)=>{ke(0),Ie(0),De(0),Te(!1),Oe(r??0),je(null),ln.completeImmediately(),_?.(e)}),onDragReset:G?.onReset??oe??(Me?void 0:()=>{ke(0),Ie(0),De(0),Te(!1),je(null),ln.resetImmediately()})}),pn="drag"===f&&(m||!!G?.renderLane?.current||!!Ue),{onPointerDown:hn,onPointerMove:vn,onPointerUp:Sn,onPointerCancel:yn,onFramerPanStart:xn,onFramerPan:bn,onFramerPanEnd:wn}=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 S=(0,t.useRef)(s);S.current=s;const y=(0,t.useRef)(c);y.current=c;const x=(0,t.useCallback)(()=>{g.current?.(),g.current=null},[]),b=(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;x(),l.current=null,t.ownsGesture?(Gt()-t.lastTime>100&&(t.velocityX=0,t.velocityY=0),n.releasePointerCapture?.(t.pointerId),y.current(e,Jt(t,e.clientX,e.clientY))):t.candidateSuspended&&p.current?.(),b();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},[x,b]),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?.()),x(),b(),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:Gt(),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)}},[x,b,e,w]),M=(0,t.useCallback)(e=>{const t=l.current;if(!t||t.pointerId!==e.pointerId)return;const r=Gt();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,S.current(e.nativeEvent,Jt(t,e.clientX,e.clientY)),t.lastX=e.clientX,t.lastY=e.clientY,t.lastTime=r,e.cancelable&&e.preventDefault()},[n]),E=(0,t.useCallback)(e=>w(e.nativeEvent),[w]);return(0,t.useEffect)(()=>()=>{const e=l.current;e&&!e.ownsGesture&&e.candidateSuspended&&p.current?.(),x(),b(),d.current+=1,l.current=null,u.current=!1},[x,b]),{onPointerDown:R,onPointerMove:M,onPointerUp:E,onPointerCancel:E,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,S=(0,t.useCallback)(e=>{l?.(e),e.defaultPrevented||m(e)},[l,m]),y=(0,t.useCallback)(e=>{u?.(e),e.defaultPrevented||p(e)},[u,p]),x=(0,t.useCallback)(e=>{d?.(e),h(e)},[d,h]),b=(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}},[]),E=(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:S,onPointerMove:y,onPointerUp:x,onPointerCancel:b,onFramerPanStart:E,onFramerPan:k,onFramerPanEnd:P}}({axis:g,enabled:pn,onCandidateStart:un,onCandidateEnd:dn,onPointerSessionStart:G?.onPointerSessionStart,onDragStart:fn,onPan:gn,onPanEnd:mn,authoredPointerDown:c,authoredPointerMove:l,authoredPointerUp:u,authoredPointerCancel:d}),Rn=(0,t.useMemo)(()=>"drag"===f?{opacity:1}:ve?ve.initial:{opacity:1},[ve,f]),Mn=(0,t.useMemo)(()=>"drag"===f?"none":"translateZ(0)",[f]),En=(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}}}(B),[B]),kn=(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"}}}(B),[B]),Pn=(0,t.useMemo)(()=>$t({effectiveMode:f,effectiveDirection:g,globalScrollTimelineState:z,globalScrollViewportOffset:F,globalViewportWidth:E,globalViewportHeight:k}),[f,g,z,F,E,k]),In=!pn&&("covered"===Ht||"parked"===Ht||"inactive"===Ht),Cn=In?{"aria-hidden":!0}:void 0,Dn=In||!0===e.inert;(0,t.useEffect)(()=>{const e=Rt.current;e&&(e.inert=Dn)},[Dn]);const An=(0,t.useMemo)(()=>({width:N,height:$,position:"scroll"===f?"relative":"absolute",overflow:W,willChange:nt||Xe||L?"transform, opacity":"auto",contain:"drag"===f?"layout style":"layout style paint",transform:Mn,userSelect:"drag"===f&&Xe?"none":void 0,WebkitUserSelect:"drag"===f&&Xe?"none":void 0,touchAction:zt(f,g),zIndex:H,pointerEvents:pn||"covered"!==Ht&&"parked"!==Ht&&"inactive"!==Ht?"auto":"none",..."scroll"===f?kn:En}),[nt,Xe,L,pn,Mn,f,g,N,$,W,H,Ht,kn,En]);return(0,r.jsx)(nn.Provider,{value:p,children:(0,r.jsx)(wt.Provider,{value:cn,children:(0,r.jsx)(Pt.Provider,{value:"scroll"===f?Et:null,children:(0,r.jsx)(St.Provider,{value:"scroll"===f?Tt:null,children:(0,r.jsxs)(n.motion.div,{ref:Mt,"data-cineview-scroll-zone":"scroll"===f?Tt??e.sceneId??void 0:void 0,initial:Rn,animate:pe,...Object.fromEntries(Object.entries(e).filter(([e])=>!rn.has(e))),className:o,style:{...s,...An},...Cn,inert:Dn,onPanStart:"drag"===f?xn:void 0,onPan:"drag"===f?bn:void 0,onPanEnd:"drag"===f?wn:void 0,onPointerDown:"drag"===f?hn:c,onPointerMove:"drag"===f?vn:l,onPointerUp:"drag"===f?Sn:u,onPointerCancel:"drag"===f?yn:d,children:["scroll"===f?(0,r.jsx)(Bt,{sceneIndex:p,metrics:Pn,setHostRef:It,frameStore:le,direction:g,viewportWidth:E,viewportHeight:k}):null,a]})})})})})}),on=Object.assign(an,{cineViewScene:!0});on.displayName="Scene";var sn=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"]),cn=(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("--")&&sn.has(e)?n.convert(t):t)(e,i,t);r[e]=a,n||(n=a!==i)}),n?r:e},ln=(0,t.forwardRef)(function({width:e,height:n,children:i,style:a,className:o,...s},c){const l=ze(),u=(0,t.useMemo)(()=>{if(!l)return a;const t=cn(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})});ln.displayName="Container";var un=new Set,dn=new Set;function fn(e){if(!e)return;const t=un.has(e);un.add(e),t||dn.forEach(t=>t(e))}var gn=(0,t.forwardRef)(function({src:e,alt:n,width:i,height:a,style:o,loading:s,preload:c,...l},u){const d=ze(),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)(()=>cn(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&&un.has(e)}(e))return;const t=new window.Image,n=()=>{fn(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})});gn.displayName="Image";var mn=new Map,pn=new Set,hn=new Map,vn=new Set,Sn=new Map,yn=0,xn=/\.(mp4|webm|mov|m4v|ogv|ogg)(\?|#|$)/i;function bn(e){return xn.test(e)?"video":null}function wn(e){const t=mn.get(e);if(t)return Rn(e),t.objectUrl}function Rn(e){const t=mn.get(e);t&&(mn.delete(e),mn.set(e,t))}function Mn(e){typeof URL<"u"&&URL.revokeObjectURL&&URL.revokeObjectURL(e)}function En(e){for(const[t,n]of mn){if(yn<=134217728)break;t===e||(Sn.get(t)??0)>0||(mn.delete(t),pn.delete(t),yn-=n.bytes,Mn(n.objectUrl))}}function kn(e,t){if(!e||pn.has(e))return Promise.resolve();const n=hn.get(e);if(n)return n;if(typeof fetch>"u")return Promise.reject(new Error("preloadMedia requires fetch (client-side only)"));if(!(t??bn(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=mn.get(e);n&&(yn-=n.bytes,Mn(n.objectUrl)),mn.set(e,t),yn+=t.bytes,En(e)})(e,{kind:"video",objectUrl:URL.createObjectURL(r),bytes:r.size}),function(e){const t=pn.has(e);pn.add(e),t||vn.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(()=>{hn.delete(e)});return hn.set(e,r),r}var Pn=1e-4;function In(e,t,n){return Math.min(n,Math.max(t,e))}function Cn(e,t){return function(e){return Number.isFinite(e)&&e>0}(e)?t?[Number.isFinite(t[0])?In(t[0],0,e):0,Number.isFinite(t[1])?In(t[1],0,e):e]:[0,e]:null}function Dn(e){return{activationId:e,status:"framework-scrub",activePlayRequestId:null,settledPlayRequestId:null,nextPlayRequestId:1,lastSeekTime:null,endpointLatched:!1,outgoingLatched:!1,frameworkPlayBlocked:!1,frameworkPausePending:!1}}function An(e,t=[]){return{state:e,commands:t}}function Tn(e,t){return{...Dn(t),nextPlayRequestId:e.nextPlayRequestId}}function Ln(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 An(e);const t="native-playback"===e.status||"play-pending"===e.status,n=null!==e.activePlayRequestId||null!==e.settledPlayRequestId;return An({...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 An(e);const r=function(e,t,n){const r=Cn(t,n);if(!r)return null;const i=In(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 An(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 An(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)>Pn)&&t.push({type:"seek",time:r}),An({...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)>Pn)&&i.push({type:"seek",time:r}),function(e,t){if(!e.scrubRange||t||e.frame.progress<.999)return!1;const n=Cn(e.duration,e.scrubRange);return!!n&&n[1]<e.duration-Pn}(t,e.endpointLatched)){const t=e.nextPlayRequestId;return i.push({type:"play",requestId:t}),An({...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 An({...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?An(e):void 0!==t.requestId?e.activePlayRequestId===t.requestId||"native-playback"===e.status&&!e.frameworkPlayBlocked&&e.settledPlayRequestId===t.requestId?An({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:t.requestId,frameworkPausePending:!1,frameworkPlayBlocked:!1}):An({...e,frameworkPausePending:!0,frameworkPlayBlocked:!0},[{type:"pause"}]):e.frameworkPlayBlocked?An({...e,frameworkPausePending:!0},[{type:"pause"}]):An({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:null,frameworkPausePending:!1,frameworkPlayBlocked:!1});case"media-pause":return t.activationId!==e.activationId?An(e):e.frameworkPausePending?An({...e,frameworkPausePending:!1}):An({...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?An(e):An({...e,status:"ended",activePlayRequestId:null,endpointLatched:!0,frameworkPausePending:!1});case"play-resolved":return e.activePlayRequestId!==t.requestId?An(e):An({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:t.requestId,frameworkPlayBlocked:!1,frameworkPausePending:!1});case"play-rejected":return e.activePlayRequestId!==t.requestId?An(e):An({...e,status:"play-rejected",activePlayRequestId:null,settledPlayRequestId:null,frameworkPlayBlocked:!1,frameworkPausePending:!1});case"activate":return e.activationId===t.activationId?An(e):An(Tn(e,t.activationId));case"reset":return An(Tn(e,t.activationId))}}var On=typeof document<"u"?t.useLayoutEffect:t.useEffect,Vn=!0,jn=(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:v,controlRef:S},y){const x=ze(),b=(0,t.useRef)(null),[w,R]=(0,t.useState)(()=>({src:e,url:wn(e)??null})),M=w.src===e?w.url:null,E=(0,t.useRef)([]),k=(0,t.useRef)(Dn(0)),P=(0,t.useRef)(0),I=(0,t.useRef)(void 0),C=(0,t.useRef)(0),D=(0,t.useRef)({src:e,objectUrl:M}),A=(0,t.useRef)(null),T=(0,t.useRef)(()=>{}),L=(0,t.useRef)(new WeakMap),O=(0,t.useRef)(null),V=(0,t.useRef)(null),j=(0,t.useCallback)((e,t)=>{const n=A.current,r=C.current;if(n&&(n.video!==e||n.activationId!==t||n.generation!==r)&&(n.video.removeEventListener("loadstart",n.loadStart,Vn),n.video.removeEventListener("play",n.play,Vn),n.video.removeEventListener("pause",n.pause,Vn),n.video.removeEventListener("ended",n.ended,Vn),A.current=null),!e||A.current)return;const i=()=>P.current===t&&C.current===r,a=()=>i()&&O.current===r,o=()=>{i()&&(O.current=r)},s=e=>{L.current.set(e,{generation:r,activationId:t})},c=e=>{if(!a())return;const n=I.current,i=n?.generation===r&&n.activationId===t?n.requestId:void 0,o=k.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&&(I.current=void 0),c||l?(s(e),T.current({type:"media-play",requestId:i,activationId:t})):T.current({type:"media-play",requestId:i,activationId:t})},l=e=>{a()&&(k.current.frameworkPausePending||(I.current=void 0),s(e),T.current({type:"media-pause",activationId:t}))},u=e=>{a()&&(s(e),T.current({type:"media-ended",activationId:t}))};e.addEventListener("loadstart",o,Vn),e.addEventListener("play",c,Vn),e.addEventListener("pause",l,Vn),e.addEventListener("ended",u,Vn),A.current={video:e,generation:r,activationId:t,loadStart:o,play:c,pause:l,ended:u}},[]),[z,F]=(0,t.useState)(!1),[N,$]=(0,t.useState)(0),[B,W]=(0,t.useState)(0),H=(0,t.useCallback)((e=!0)=>{P.current+=1,k.current=Ln(k.current,{type:"reset",activationId:P.current}).state,I.current=void 0,E.current=[],j(e?b.current:null,P.current)},[j]);(0,t.useEffect)(()=>{const e={release:()=>{const e=b.current;F(!0),e&&(e.pause(),V.current=e.getAttribute("src"),e.removeAttribute("src"),e.load()),H(!1)},warmUp:()=>{const e=b.current;if(e&&!e.getAttribute("src")){const t=V.current;t&&(e.src=t,V.current=null)}F(!1),$(e=>e+1),H(!1)}};return S&&(S.current=e),()=>{S&&(S.current=null)}},[S,H]);const q=(0,t.useCallback)(e=>{e||j(null,P.current),b.current=e,e&&j(e,P.current),function(e,t){"function"==typeof e?e(t):e&&(e.current=t)}(y,e)},[j,y]),Y=(0,t.useMemo)(()=>"number"==typeof o?x?.convert(o)??o:o,[x,o]),U=(0,t.useMemo)(()=>"number"==typeof s?x?.convert(s)??s:s,[x,s]),X=(0,t.useMemo)(()=>cn(c,x??null),[x,c]);(0,t.useEffect)(()=>{if(typeof window>"u"||!e)return void R({src:e,url:null});let t=!0,n=!1;const r=()=>{const t=function(e){const t=mn.get(e);if(t)return Rn(e),Sn.set(e,(Sn.get(e)??0)+1),t.objectUrl}(e);return!!t&&(n=!0,R({src:e,url:t}),!0)};let i=()=>{};return r()||(R({src:e,url:null}),i=function(e){return vn.add(e),()=>{vn.delete(e)}}(i=>{i===e&&t&&!n&&r()})),()=>{t=!1,i(),n&&function(e){const t=Sn.get(e)??0;t<=1?Sn.delete(e):Sn.set(e,t-1),En("")}(e)}},[e]),(0,t.useEffect)(()=>{typeof window>"u"||!e||!u||function(e){return e.length>0&&pn.has(e)}(e)||kn(e,"video").catch(()=>{})},[u,e]),(0,t.useEffect)(()=>{F(!1),$(e=>e+1)},[e]),On(()=>{const e=b.current;e&&(e.playbackRate=f??1)},[B,M,f,z,e]);const K=(0,t.useCallback)((e,t)=>{e.currentTime=t},[e]),Z=(0,t.useCallback)(e=>{const t=b.current;if(!t)return;const n=Ln(k.current,e);k.current=n.state,n.commands.forEach(e=>{switch(e.type){case"pause":return void t.pause();case"seek":return void K(t,e.time);case"play":{const n={requestId:e.requestId,generation:C.current,activationId:k.current.activationId,settled:!1};I.current=n;const r=t=>{if(I.current===n&&!n.settled){if(n.settled=!0,"play-rejected"===t&&(I.current=void 0),C.current!==n.generation||k.current.activationId!==n.activationId)return void(I.current=void 0);Z({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"))}}})},[K]);On(()=>{T.current=Z;const t=D.current;let n=!1;(t.src!==e||t.objectUrl!==M)&&(D.current={src:e,objectUrl:M},C.current+=1,O.current=null,H(),n=!0),!n&&b.current&&b.current.readyState>=1&&(O.current=C.current),j(b.current,P.current)},[j,Z,N,M,H,e]),(0,t.useEffect)(()=>()=>j(null,P.current),[j]),(0,t.useEffect)(()=>{if(!i)return;const e=b.current;if(!e||typeof window>"u")return;let t=i.get();const n=n=>{t=n;const r=k.current;if("entering"===n.phase&&("ended"===r.status||r.outgoingLatched))return P.current+=1,j(null,P.current),Z({type:"activate",activationId:P.current}),void W(e=>e+1);!Number.isFinite(e.duration)||e.duration<=0||Z({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)}},[j,Z,N,B,M,a,i]),(0,t.useEffect)(()=>{if(i)return;const e=b.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||K(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)}},[N,M,n,K,i]);const _=e=>{const t=L.current.get(e);return L.current.delete(e),!(!t||t.generation!==C.current||t.activationId!==P.current)},G=z&&w.src===e,J=JSON.stringify([e,M,B,G?"released":"active"]);return(0,r.jsx)("video",{ref:q,src:(G?void 0:M??e)||void 0,muted:!0,playsInline:!0,preload:G?"none":u?"auto":M?"metadata":"none","aria-label":l,width:Y,height:U,style:X,poster:d||void 0,onPlay:e=>{_(e.nativeEvent)&&m?.(e)},onPause:e=>{_(e.nativeEvent)&&p?.(e)},onEnded:e=>{_(e.nativeEvent)&&g?.(e)},onTimeUpdate:h,onError:v},J)});jn.displayName="VideoFrameRenderer";var zn={initial:{opacity:1},animate:{opacity:1}},Fn=(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 S=gt(),y=function(e,n){const r=(0,t.useRef)(null),i=gt(),a=(0,t.useContext)(St),o=function(e,n=!0){return function(e,n,r){const i=(0,t.useContext)(vt),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)(jn,{ref:v,controlRef:y,src:e,progress:S.progress,timelineFrame:S.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})}),Nn=(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:S,onPause:y,onTimeUpdate:x,onError:b},w){return(0,r.jsx)(Et,{animateId:u,enterAnimation:f??zn,exitAnimation:g,duration:{enter:d?.enter,exit:d?.exit},timeline:m,visibility:p,children:(0,r.jsx)(Fn,{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:S,onPause:y,onTimeUpdate:x,onError:b})})});Nn.displayName="AnimateVideo";var $n=Et,Bn=It,Wn=on;function Hn(e){return Array.from(new Set(e.filter(e=>e.length>0)))}function qn(e,t,n,r){const i=Hn(e).filter(e=>!n.has(e)&&!r.has(e)),a=new Set(i);return{priorityBatch:i,backgroundBatch:Hn(t).filter(e=>!n.has(e)&&!r.has(e)&&!a.has(e))}}var Yn=(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,S]=(0,t.useState)(new Map),[y,x]=(0,t.useState)(!1),b=(0,t.useRef)([...n]),w=(0,t.useRef)([...r]),R=(0,t.useRef)(!1),M=(0,t.useRef)(new Map),E=(0,t.useRef)(0),k=(0,t.useRef)(null),P=(0,t.useRef)(new Set),I=(0,t.useRef)(new Set),C=(0,t.useRef)(0),D=(0,t.useRef)(0),A=(0,t.useRef)(i),T=(0,t.useRef)(a),L=(0,t.useRef)(o);(0,t.useEffect)(()=>{A.current=i,T.current=a,L.current=o},[i,a,o]);const O=(0,t.useCallback)((e,t)=>{const n=Hn(e).filter(e=>!P.current.has(e));if(0===n.length)return;const r=new Set(b.current),i=new Set(w.current),a=n.filter(e=>!r.has(e)&&!i.has(e));0!==a.length&&(t?b.current=[...b.current,...a]:w.current=[...w.current,...a])},[]);(0,t.useEffect)(()=>{O(n,!0),O(r,!1),R.current||m(b.current.length+w.current.length)},[n,r,O]);const V=(0,t.useCallback)((e,t)=>{const n=bn(e);return n?kn(e,n).then(()=>(fn(e),{url:e,success:!0})).catch(n=>{const r=n instanceof Error?n:new Error(String(n));return E.current===t&&L.current?.(e,r),{url:e,success:!1,error:r}}):new Promise(n=>{const r=new Image,i=new AbortController;M.current.set(e,i);let a=!1,o=null;const s=t=>{a||(a=!0,null!==o&&(clearTimeout(o),o=null),M.current.delete(e),n(t))};r.onload=()=>{fn(e),s({url:e,success:!0})},r.onerror=()=>{const n=new Error(`Failed to load image: ${e}`);E.current===t&&L.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}`);E.current===t&&L.current?.(e,n),s({url:e,success:!1,error:n})},15e3),r.src=e})},[]),j=(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),A.current?.(i)},[]),z=(0,t.useCallback)(()=>{if(R.current)return k.current??Promise.resolve();const e=(async()=>{const e=E.current+1;E.current=e,R.current=!0,c(!0),u(0),f(0),h([]),S(new Map),x(!1),I.current=new Set,C.current=0,D.current=0;const t=qn(b.current,w.current,P.current,I.current),n=t.priorityBatch.length+t.backgroundBatch.length;if(D.current=n,m(n),0===n)return j(0,0),E.current===e&&(c(!1),x(!0)),R.current=!1,void T.current?.([]);const r=new Set(t.priorityBatch);let i=0===r.size;i&&x(!0);const a=[],o=new Map,s=()=>{const e=qn(b.current,w.current,P.current,I.current);return D.current=C.current+e.priorityBatch.length+e.backgroundBatch.length,m(D.current),e},l=(e,t)=>{a.push(t),I.current.add(e),C.current+=1,!t.success&&t.error?o.set(e,t.error):t.success&&P.current.add(e),j(C.current,D.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 V(t,e);E.current===e&&l(t,n)})),E.current!==e)return;const r=await Promise.all(n.map(async t=>({url:t,result:await V(t,e)})));if(E.current!==e)return;r.forEach(({url:e,result:t})=>{l(e,t)})}h(a),S(o),c(!1),R.current=!1,m(b.current.length+w.current.length),T.current?.(a)})();return k.current=e.finally(()=>{k.current===e&&(k.current=null)}),k.current},[V,j]),F=(0,t.useCallback)(()=>{E.current+=1,M.current.forEach(e=>{e.abort()}),M.current.clear(),c(!1),u(0),f(0),m(b.current.length+w.current.length),h([]),S(new Map),x(!1),P.current.clear(),I.current.clear(),C.current=0,D.current=0,R.current=!1,k.current=null},[]),N=(0,t.useCallback)((e,t=!1)=>{O(e,t);const{priorityBatch:n,backgroundBatch:r}=qn(b.current,w.current,P.current,I.current),i=R.current?C.current+n.length+r.length:n.length+r.length;R.current&&(D.current=i),m(i)},[O]);return(0,t.useEffect)(()=>{const e=M.current;return()=>{E.current+=1,R.current=!1,k.current=null,e.forEach(e=>{e.abort()}),e.clear()}},[]),[{isLoading:s,progress:l,loadedCount:d,totalCount:g,results:p,errors:v,priorityComplete:y},{startPreload:z,reset:F,addUrls:N}]};function Un({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),S=Math.max(0,i),y=(0,t.useRef)(o);y.current=o;const x=(0,t.useRef)(s);return x.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=x.current();y.current("FIRST_SCENE_TIMEOUT",`First scene priority assets did not load within ${S}ms.`,{sceneIndex:0,timeoutMs:S,loadedCount:e.loadedCount,totalCount:e.totalCount})||(h.current=!0,d(!1),l(!1),t("static"))},S)),()=>{v.current&&(clearTimeout(v.current),v.current=null)})},[e,n,r,S]),(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)},[])}}var Xn=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}},Kn=0,Zn=Xn,_n=()=>{1===(Kn+=1)&&Xn.start();let e=!1;return()=>{e||(e=!0,0===(Kn=Math.max(Kn-1,0))&&Xn.stop())}};function Gn(e,t,n){return Math.min(n,Math.max(t,e))}function Jn(e,t){if(null!=e.key)return`key:${e.key}`;const{sceneId:n}=e.props;return void 0!==n?`scene:${n}`:`index:${t}`}function Qn(e,t,n,r){if(!(e instanceof Element)||0===r)return!1;const i="x"===n?"overflowX":"overflowY";let a=e;for(;a&&a!==t;){if(a instanceof HTMLElement){const e=window.getComputedStyle(a)[i],t="auto"===e||"scroll"===e||"overlay"===e,o="x"===n?a.scrollLeft:a.scrollTop,s=Math.max(("x"===n?a.scrollWidth:a.scrollHeight)-("x"===n?a.clientWidth:a.clientHeight),0);if(t&&s>1&&(r>0&&o<s-1||r<0&&o>1))return!0}a=a.parentElement}return!1}function er(e,t,n){const r=Math.max(.86*n,1);switch(e){case"PageDown":return r;case"PageUp":return-r;case" ":case"Spacebar":return t?-r:r;case"ArrowDown":return 80;case"ArrowUp":return-80;case"Home":return Number.NEGATIVE_INFINITY;case"End":return Number.POSITIVE_INFINITY;default:return 0}}function tr(e,t){if(!(e instanceof Element))return!1;const n=e.tagName.toLowerCase();return!(" "!==t||!("button"===n||"summary"===n||"a"===n&&e.hasAttribute("href")||"button"===e.getAttribute("role")||"link"===e.getAttribute("role")))||"input"===n||"textarea"===n||"select"===n||!!(e instanceof HTMLElement&&e.isContentEditable)}function nr(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}function rr(e){const t=e;return"number"==typeof t&&Number.isFinite(t)&&t>0?{designSize:t}:{designSize:750}}function ir(e){return e.layout?.overlap??"cover"}function ar(e,t,n,r){const i="takeover"===r,a=e=>i?Math.max(e,1):e;if("number"==typeof e&&Number.isFinite(e)&&e>0)return i?null:e;if("string"!=typeof e)return null;const o=e.trim().toLowerCase();if(!o||"auto"===o)return null;const s=Number.parseFloat(o);return!Number.isFinite(s)||s<=0?null:o.endsWith("px")?i?null:s:o.endsWith("vh")?a(n*s/100):o.endsWith("vw")?a(t*s/100):null}function or(e,t,n){return ar(e,t,n,"takeover")}function sr(e,t,n){const r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a="x"===n?t.scrollLeft:t.scrollTop;return"x"===n?r.left-i.left+a:r.top-i.top+a}function cr({index:e,currentScene:n,totalScenes:i,direction:a,renderProgressMotion:o,style:s,sceneWrapperRefs:c,children:l}){const u=(0,t.useRef)(null);return On(()=>{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 lr=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:S,direction:y,isAnimating:x,viewportWidth:b,viewportHeight:w,sceneActions:R,sceneWrapperRefs:M,renderLaneRef:E,takeoverSnapshot:k,candidateSuspended:P,onCandidateSuspensionChange:I,onElementContinuationChange:C,onPointerSessionStart:D,dragTransaction:A,onPrepared:T,onPreparedInvalidated:L,onOwnershipRequest:O,onSceneChange:V,onDragProgressChange:j,onRenderProgressChange:z,onDragTimelineProgressChange:F,onDraggingChange:N,onSharedTimelineDurationChange:$,onDragRelease:B,onDragReset:W,onTransactionComplete:H,onFirstSceneEnterComplete:q}){const Y=n===i,U=e.props,X=s?.direction??U.slideDirection??"y",K=Vt(s,U.drag),Z={position:"absolute",inset:0,width:"100%",height:"100%"};if("drag"===o)Z.visibility="visible",Z.opacity=1,Z.pointerEvents=Y||g||x||null!==A?"auto":"none",Z.contentVisibility="visible",Z.transition="none",Z.zIndex=Y?10:1;else{const e=Y||x&&"backward"===y&&(n===i||n===i+1)||x&&"forward"===y&&(n===i||n===i-1);Z.visibility=e?"visible":"hidden",Z.contentVisibility=e?"visible":"hidden",Z.zIndex=x?"backward"===y?n===i+1?2:n===i?1:0:n===i?2:n===i-1?1:0:Y?1:0}const _=A?.targetSceneIndex===n?A:null,G=t.default.useCallback(()=>{0===n&&v?q():R.completeDragTransition(),"settling"===_?.phase&&H(_.transactionId)},[v,n,q,H,R,_]),J=t.default.useCallback(e=>{C(n,e)},[n,C]),Q=t.default.useMemo(()=>t.default.cloneElement(e,{sceneRuntime:{mode:o,direction:X,isActive:Y,sceneIndex:n,totalScenes:a,currentSceneIndex:i,transitionDirection:y,isSceneAnimating:x,sharedTimelineDurationMs:m,activationToken:h.get(n)?.token??0,activationKind:h.get(n)?.kind??null,viewportWidth:b,viewportHeight:w,firstSceneEnterActive:v&&0===n,firstSceneEnterReady:S&&0===n},dragRuntime:{progress:c,renderProgress:u,timelineProgress:l,renderProgressMotion:d,timelineProgressMotion:f,isDragging:g,release:p,threshold:s?.threshold,dragMappingConfig:K,transaction:_,onPrepared:T,onPreparedInvalidated:L,onOwnershipRequest:O,candidateSuspended:P,onCandidateSuspensionChange:I,takeoverSnapshot:k,onElementContinuationChange:J,onPointerSessionStart:D,renderLane:E,onCommit:V,onReset:W,onActivationComplete:G,onTransactionComplete:H,onProgressChange:j,onRenderProgressChange:z,onTimelineProgressChange:F,onDraggingChange:N,onRelease:B,onSharedTimelineDurationChange:$},onSceneChange:V}),[e,o,X,Y,n,a,i,y,x,m,h,b,w,v,S,c,u,l,d,f,g,p,s,K,_,T,L,O,P,I,k,J,D,E,V,W,G,H,j,z,F,N,B,$]);return"drag"===o?(0,r.jsx)(cr,{index:n,currentScene:i,totalScenes:a,direction:X,renderProgressMotion:d,style:Z,sceneWrapperRefs:M,children:Q}):(0,r.jsx)("div",{ref:e=>{M.current[n]=e},style:Z,"data-scene-index":n,children:Q})});function ur({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:S,isAnimating:y,viewportWidth:x,viewportHeight:b,sceneActions:w,sceneWrapperRefs:R,renderLaneRef:M,takeoverSnapshot:E,candidateSuspended:k,onCandidateSuspensionChange:P,onElementContinuationChange:I,onPointerSessionStart:C,dragTransaction:D,onPrepared:A,onPreparedInvalidated:T,onOwnershipRequest:L,onSceneChange:O,onDragProgressChange:V,onRenderProgressChange:j,onDragTimelineProgressChange:z,onDraggingChange:F,onSharedTimelineDurationChange:N,onDragRelease:$,onDragReset:B,onTransactionComplete:W,onFirstSceneEnterComplete:H}){return(0,r.jsx)(r.Fragment,{children:e.map((e,q)=>t.has(q)?(0,r.jsx)(lr,{scene:e,index:q,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:S,isAnimating:y,viewportWidth:x,viewportHeight:b,sceneActions:w,sceneWrapperRefs:R,renderLaneRef:M,takeoverSnapshot:E,candidateSuspended:k,onCandidateSuspensionChange:P,onElementContinuationChange:I,onPointerSessionStart:C,dragTransaction:D,onPrepared:A,onPreparedInvalidated:T,onOwnershipRequest:L,onSceneChange:O,onDragProgressChange:V,onRenderProgressChange:j,onDragTimelineProgressChange:z,onDraggingChange:F,onSharedTimelineDurationChange:N,onDragRelease:$,onDragReset:B,onTransactionComplete:W,onFirstSceneEnterComplete:H},Jn(e,q)):null)})}function dr(e){return e.assets?.preloadImages??[]}function fr(e,t,n={}){if(!t||0===t.length)return[];const r=n.includeZoneIds??!1,i=new Set,a=[],o=e=>{e&&dr(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}function gr(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:{}}}var mr="(prefers-reduced-motion: reduce)";function pr(){return typeof window<"u"&&"function"==typeof window.matchMedia&&window.matchMedia(mr).matches}function hr(e){if(typeof window>"u"||"function"!=typeof window.matchMedia)return()=>{};const t=window.matchMedia(mr);return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}function vr(){return(0,t.useSyncExternalStore)(hr,pr,()=>!1)}function Sr(e,t,n){return Math.min(n,Math.max(t,e))}function yr(e){return e??"drag"}var xr={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},br=(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:h}=e,{designSize:v}=rr(a),S=(0,t.useMemo)(()=>({direction:s,transitionDuration:c,threshold:l,unit:u,scale:d,firstSceneTimeout:f}),[s,c,l,u,d,f]),y=(0,t.useRef)(null),x=(0,t.useRef)([]),b=(0,t.useRef)(0),w=(0,t.useRef)(null),R=(0,t.useRef)([]),M=(0,t.useRef)(null),E=(0,t.useRef)(new Set),[k,P]=(0,t.useMemo)(()=>{const e=[];return t.Children.forEach(h,t=>{nr(t)&&e.push(t)}),[e,!1]},[h]),I=k.length,C=(0,t.useMemo)(()=>yr(o),[o]),D=(0,t.useMemo)(()=>gr(m),[m]),A=(0,t.useRef)(D),T=(0,t.useRef)(!1),L=(0,t.useRef)(!1),[O,V]=(0,t.useState)(!1),j=(0,t.useRef)(new Set),z=(0,t.useRef)(new Set),F=(0,t.useRef)(null),N=(0,t.useRef)(null),$=(0,t.useRef)(0),B=(0,t.useRef)(!1),W=(0,t.useRef)(new tn),[H,q]=(0,t.useState)(null),Y=(0,t.useRef)(null),U=(0,t.useRef)(0),X=(0,t.useRef)(null),K=(0,t.useRef)(new Set),Z=(0,t.useRef)(!1),_=(0,t.useRef)(null),G=(0,t.useRef)(0),[J,Q]=(0,t.useState)(()=>new Map),ee=(0,t.useCallback)((e,t)=>{const n={token:++G.current,kind:t};Q(t=>{const r=new Map(t);return r.set(e,n),r})},[]);(0,t.useEffect)(()=>{A.current=D},[D]);const te=(0,t.useCallback)((e,t,n)=>{A.current.common?.onError?.({code:e,message:t,context:n})},[]),ne=(0,t.useCallback)((e,t,n)=>{let r=!1;return A.current.common?.onError?.({code:e,message:t,context:n,preventDefault:()=>{r=!0}}),r},[]),re=(0,t.useCallback)(e=>{A.current.common?.onLoadProgress?.(e)},[]);(0,t.useEffect)(()=>{0===I&&te("EMPTY_SCENES","Cineview requires at least one Scene child.",{mode:C})},[te,C,I]),(0,t.useEffect)(()=>{"drag"===C&&k.forEach((e,t)=>{const n=e.props;Vt(S,n.drag,({field:e,value:n})=>{const r=`${t}:${e}`;K.current.has(r)||(K.current.add(r),te("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(K.current.has(e))return;K.current.add(e),te("INVALID_DRAG_CONFIG","Invalid drag enabled flag; using true.",{sceneIndex:t,field:"enabled",value:r})}})},[te,S,C,k]);const[ie,ae]=(0,t.useState)(0),[oe,se]=(0,t.useState)(0),ce=(0,t.useCallback)((e,t)=>{w.current=e,D.common?.onSceneEnter?.({fromIndex:e,toIndex:t,direction:t>e?"forward":t<e?"backward":null})},[D]),le=(0,t.useCallback)((e,t)=>{const n=t??w.current??e;w.current=null,D.common?.onSceneLeave?.({fromIndex:n,toIndex:e,direction:n===e?null:e>n?"forward":e<n?"backward":null})},[D]),[ue,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),[S,y]=(0,t.useState)(0),[x,b]=(0,t.useState)(null),[w,R]=(0,t.useState)(0),[M,E]=(0,t.useState)(!1),[k,P]=(0,t.useState)(!1),[I,C]=(0,t.useState)(0),[D,A]=(0,t.useState)(null),T=(0,t.useRef)(0),[L,O]=(0,t.useState)(null),V=(0,t.useRef)(!1),j=(0,t.useRef)(c),z=(0,t.useRef)(null),F=(0,t.useRef)(!1),N=(0,t.useRef)(!1),$=(0,t.useRef)(null);j.current=c,(0,t.useEffect)(()=>{const e=Math.max(n-1,0);j.current<=e||(l(e),V.current&&(d(!1),V.current=!1,g(null),$.current=null))},[n]);const B=(0,t.useCallback)(()=>{z.current=null,F.current=!1,N.current=!1,p(0),v(0),C(0),A(null),g(null)},[]),W=(0,t.useCallback)(e=>{j.current=e,l(e),$.current=null,V.current=!1,d(!1),E(!1),R(0),B()},[B]),H=(0,t.useCallback)(e=>{if(null===e)return N.current=!1,void A(null);N.current="settle"===e.mode,T.current+=1,A({...e,token:T.current})},[]),q=(0,t.useCallback)(()=>c<n-1,[c,n]),Y=(0,t.useCallback)(()=>c>0,[c]),U=(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),V.current=!0,$.current={fromScene:c,releaseToken:null},"drag"===i&&(T.current+=1,$.current.releaseToken=T.current,A({token:T.current,mode:"enter",direction:r,targetSceneIndex:e}))):(d(!1),V.current=!1,$.current=null,B(),s?.(e,c))},[c,n,i,a,o,s,B]),X=(0,t.useCallback)(()=>{q()&&U(c+1)},[c,q,U]),K=(0,t.useCallback)(()=>{Y()&&U(c-1)},[c,Y,U]),Z=(0,t.useCallback)(e=>{if(d(e),V.current=e,!e){const e=$.current;$.current=null,e?s?.(c,e.fromScene):s?.(c),g(null);const t=e?.releaseToken;null!=t&&A(e=>null!==e&&e.token===t?null:e)}},[c,s]),_=(0,t.useCallback)(()=>{N.current&&null!==z.current||(z.current=null,F.current=!1,N.current=!1,A(null)),p(0),v(0),R(0),E(!1),C(0)},[]),G=(0,t.useCallback)(()=>{z.current=null,F.current=!1,N.current=!1,A(null),g(null),v(0),C(0)},[]),J=(0,t.useCallback)(()=>{y(0),b(null),P(!1),O(null)},[]),Q=(0,t.useCallback)((e,t,r,i)=>{const c=j.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),V.current=!1,!1):(a?.(c,u),g(e),v(f),z.current=c,l(u),o?.(u,c,"drag"),s?.(u,c),p(0),R(0),E(!1),d(!1),V.current=!1,f.toFixed(3),F.current&&B(),!0)},[B,s,a,o,_,n]),ee=(0,t.useCallback)(()=>{null===z.current?N.current&&(F.current=!0):B()},[B]),te=(0,t.useCallback)((e,t)=>{const r=j.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(V.current=!1);a?.(r,i),g(e),b(e),y(o),O({fromScene:r,toScene:i,direction:e,progressRatio:o,startedAt:Date.now(),lastInputAt:Date.now(),isSettling:!1,settleDirection:null}),l(i),y(0),b(null),O(null),P(!1),d(!1),V.current=!1,s?.(i,r),o.toFixed(3)},[s,a,J,n]),ne=(0,t.useCallback)(()=>{S.toFixed(3),y(0),b(null),O(null)},[S]);return[{currentScene:c,isAnimating:u,direction:f,dragProgress:m,dragTimelineProgress:h,scrollProgress:S,scrollDirection:x,renderProgress:w,isDragging:M,isScrolling:k,sharedTimelineDurationMs:I,dragRelease:D,scrollTransitionSnapshot:L},{reconcileSceneList:W,goToScene:U,nextScene:X,prevScene:K,setAnimating:Z,canGoNext:q,canGoPrev:Y,setDragProgress:p,setDragTimelineProgress:v,setScrollProgress:y,setScrollDirection:b,setScrollTransitionSnapshot:O,setRenderProgress:R,setIsDragging:E,setIsScrolling:P,setSharedTimelineDurationMs:C,setDragRelease:H,resetDragInteraction:_,abortDragContinuation:G,resetScrollInteraction:J,commitDragSceneChange:Q,completeDragTransition:ee,commitScrollSceneChange:te,clearScrollTransitionSnapshot:ne}]})({totalScenes:I,initialScene:0,mode:C,onBeforeChange:ce,onCommit:(e,t,n)=>{"drag"===C&&ee(e,"drag"===n?"commit":"programmatic")},onAfterChange:(e,t)=>{le(e,t??b.current)}}),fe=(0,t.useRef)(de);fe.current=de;const{currentScene:ge,isAnimating:me,direction:pe,dragProgress:he,dragTimelineProgress:ve,renderProgress:Se,isDragging:ye,sharedTimelineDurationMs:xe,dragRelease:be}=ue,we=(0,t.useMemo)(()=>k.map(Jn),[k]),[Re,Me]=(0,t.useState)(we);if(Re.length!==we.length||Re.some((e,t)=>e!==we[t])){const e=we.indexOf(Re[ge]),t=e>=0?e:Sr(ge,0,Math.max(0,I-1));Me(we),de.reconcileSceneList(t),Q(e=>{const t=new Map;for(const[n,r]of e){const e=we.indexOf(Re[n]);e>=0&&t.set(e,r)}return t})}const Ee=(0,n.useMotionValue)(0),ke=(0,n.useMotionValue)(0),Pe=vr(),Ie=e.a11y?.label??"Scenes";b.current=ge,R.current=k,On(()=>{B.current&&(B.current=!1,Ee.set(0),ke.set(0))},[ge,ke,Ee]);const Ce=k[ge],De=Ce?function(e,t,n){return Math.max("drag"===t?n??e.sceneTransitionDuration??800:e.sceneTransitionDuration??800,0)}(Ce.props,C,c):0;(0,t.useEffect)(()=>{if(!me||!R.current[ge])return;const e=setTimeout(()=>{fe.current.setAnimating(!1)},De),t=E.current;return t.add(e),()=>{clearTimeout(e),t.delete(e)}},[me,ge,De]),(0,t.useEffect)(()=>{if("drag"===C)return;T.current=!1,L.current=!1,V(!1),j.current.clear(),z.current.clear(),U.current=0,X.current=null;const e=Y.current;e&&(W.current.releaseTransaction(e.transactionId),Y.current=null,q(null))},[C]);const Ae=(0,t.useCallback)(e=>{if(!e)return null;const t=Y.current,n=!t||t.transactionId!==e.transactionId||t.phase!==e.phase;return t&&t.transactionId!==e.transactionId&&W.current.releaseTransaction(t.transactionId),Y.current=e,n&&q(e),e},[]),Te=(0,t.useCallback)(e=>{const t=Y.current;!t||e&&t.transactionId!==e||(W.current.releaseTransaction(t.transactionId),Y.current=null,q(null))},[]),Le=(0,t.useCallback)(e=>{W.current.publishPrepared(e)},[]),Oe=(0,t.useCallback)(e=>{W.current.invalidatePrepared(e)},[]),Ve=(0,t.useCallback)((e,t)=>{t?j.current.add(e):j.current.delete(e)},[]),ze=(0,t.useCallback)(()=>{z.current.clear()},[]),Ne=(0,t.useCallback)(e=>e?"drag"===C&&(null!==F.current||j.current.size>0)&&(N.current={token:++$.current,sceneIndices:[...j.current],staleRatio:ke.get(),baseRatio:null},L.current=!0,V(!0),!0):(L.current=!1,V(!1),null===N.current?.baseRatio&&(N.current=null),!1),[ke,C]),$e=(0,t.useCallback)(e=>{const t=Y.current;!t||t.targetSceneIndex===e||(de.abortDragContinuation(),j.current.delete(t.targetSceneIndex))},[de]),Be=(0,t.useCallback)(e=>{if("drag"!==C)return!1;const t=L.current,n=T.current;if(n&&!t)return!1;const r=b.current,i=r+("forward"===e?1:-1);if(i<0||i>=I)t&&($e(null),Te());else{if(!1===k[i]?.props?.drag?.enabled)return z.current.has(e)||(z.current.add(e),A.current.drag?.onDragBlocked?.({fromIndex:r,targetSceneIndex:i,direction:e})),!1;if(!W.current.getPrepared(i))return!1;const t=W.current.beginTransaction(i,"driving",0);if(!t||($e(i),!Ae(t)))return!1}return L.current=!1,V(!1),n||(T.current=!0,U.current=0,X.current=null,A.current.drag?.onDragStart?.({sceneIndex:r,progress:0,direction:e})),!0},[$e,Ae,Te,C,k,I]),We=(0,t.useCallback)(e=>{if("drag"!==C||!T.current)return;const t=0===e?0:Sr(e,-1,1);if(t!==U.current){if(U.current=t,0!==t){const e=b.current+(t>0?1:-1);if(e>=0&&e<I){const n=W.current.beginTransaction(e,"driving",Math.abs(t));n&&($e(e),Ae(n))}}A.current.drag?.onDragProgress?.({sceneIndex:b.current,progress:Math.abs(t),direction:t>0?"forward":t<0?"backward":null})}},[$e,Ae,C,I]),He=(0,t.useCallback)(e=>{e||(N.current=null),de.setIsDragging(e)},[de]),qe=(0,t.useCallback)(e=>{"bounce"===e?.mode&&T.current?X.current={sceneIndex:b.current,signedProgress:U.current}:"bounce"!==e?.mode&&(X.current=null),de.setDragRelease(e)},[de]);(0,t.useEffect)(()=>{if("drag"===C){if(be)return void Ae(W.current.beginTransaction(be.targetSceneIndex,"settle"===be.mode?"settling":"bounce"===be.mode?"bouncing":"programmatic","enter"===be.mode?0:be.progressRatio??0));"driving"!==Y.current?.phase&&Te()}},[Ae,be,Te,C]);const Ye=(0,t.useCallback)(()=>{if("drag"===C&&T.current){const e=X.current??{sceneIndex:b.current,signedProgress:U.current};T.current=!1,U.current=0,X.current=null,A.current.drag?.onDragCancel?.({sceneIndex:e.sceneIndex,progress:Math.abs(e.signedProgress),direction:e.signedProgress>0?"forward":e.signedProgress<0?"backward":null})}"settling"!==Y.current?.phase&&Te(),Ee.set(0),ke.set(0),de.resetDragInteraction()},[ke,Te,Ee,C,de]);(0,t.useEffect)(()=>{const e=y.current;if(!e)return;const t=e.ownerDocument?.defaultView??window,n=()=>{const t=e.getBoundingClientRect(),n=t.width,r=t.height;n>0&&ae(n),r>0&&se(r)};M.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),()=>{M.current=null,i?.disconnect(),t.removeEventListener("resize",n)}},[]),(0,t.useEffect)(()=>{if(!g||!1===g.enabled)return;const e=y.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 Ue=ge,{priorityImages:Xe,backgroundImages:Ke}=(0,t.useMemo)(()=>function(e,t,n){if("scroll"===n){const n=e[Sr(t,0,Math.max(e.length-1,0))],r=n?dr(n.props):[],i=new Set(r);return{priorityImages:r,backgroundImages:Array.from(new Set(e.flatMap(e=>dr(e.props).filter(e=>!i.has(e)))))}}const r=Sr(t,0,Math.max(e.length-1,0)),i=[],a=[];e.forEach((e,t)=>{const n=dr(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))))}}(k,Ue,C),[k,Ue,C]),[Ze,_e]=Yn({priorityUrls:Xe,backgroundUrls:Ke,onProgress:re,onError:(e,t)=>{te("IMAGE_LOAD_FAILED",t.message,{url:e})}}),Ge=(0,t.useRef)(_e);Ge.current=_e;const Je=(0,t.useRef)({loadedCount:0,totalCount:0});Je.current={loadedCount:Ze.loadedCount,totalCount:Ze.totalCount};const Qe=Math.max(0,f??3e3),et=(0,t.useCallback)(()=>({loadedCount:Je.current.loadedCount,totalCount:Je.current.totalCount}),[]),{firstSceneEnterActive:tt,firstSceneEnterReady:nt,firstSceneActivationToken:rt,firstSceneActivationKind:it,handleComplete:at}=Un({enabled:k.length>0,hasFirstScene:!!k[0],priorityComplete:Ze.priorityComplete,timeoutMs:Qe,preemptSignal:ye,emitRecoverableError:ne,getPreloadCounts:et}),ot=(0,t.useRef)(0);(0,t.useEffect)(()=>{"drag"!==C||rt<=ot.current||null===it||(ot.current=rt,ee(0,it))},[ee,it,rt,C]),(0,t.useEffect)(()=>{const e=E.current;return _e.startPreload(),()=>{e.forEach(e=>{clearTimeout(e)}),e.clear()}},[i]),(0,t.useEffect)(()=>{if(p)return _n()},[p]),(0,t.useEffect)(()=>{const e=`${Xe.join("|")}::${Ke.join("|")}`;if(_.current!==e){if(_.current=e,_e.addUrls(Xe,!0),_e.addUrls(Ke,!1),!Z.current)return void(Z.current=!0);Ze.isLoading||_e.startPreload()}},[Xe,Ke,_e,Ze.isLoading]);const st=(0,t.useMemo)(()=>{const e=new Set;return e.add(ge),"drag"===C&&(ge>0&&e.add(ge-1),ge<I-1&&e.add(ge+1)),e},[C,ge,I]);!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=fr(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)(()=>Zn.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:b,scenesRef:R,sceneActionsRef:fe,preloadActionsRef:Ge,measureViewportRef:M,resolvedCallbacksRef:A});const ct=(0,t.useCallback)((e,t,n,r)=>{const i=ge,a="forward"===e?i+1:i-1;if("drag"!==C)return void("forward"===e?de.nextScene():de.prevScene());const o=Y.current,s=o?.targetSceneIndex===a?o:null,c=s?s.releaseSeed.progressRatio:Math.max(0,Math.min(t??ke.get(),1)),l=s?s.releaseSeed.elapsedMs:Math.max(0,n??0),u=s?s.registrySnapshot.timelineDuration:Math.max(0,r??0);T.current=!1,U.current=0,X.current=null,A.current.drag?.onDragEnd?.({sceneIndex:i,targetSceneIndex:a,progress:c,direction:e,elapsedMs:l,timelineDurationMs:u}),B.current=!0,de.commitDragSceneChange(e,c,l,u)||(B.current=!1)},[de,ge,ke,C]);(0,t.useEffect)(()=>{},[P,I]);const lt=(0,t.useCallback)(e=>{if("drag"!==C||e.target!==e.currentTarget)return;const t=Math.max(0,R.current.length-1),n="x"===s?"ArrowRight":"ArrowDown",r="x"===s?"ArrowLeft":"ArrowUp";let i=null;if("PageDown"===e.key||e.key===n?i=b.current+1:"PageUp"===e.key||e.key===r?i=b.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!==b.current&&de.goToScene(a,!0)},[s,C,de]),ut=I>0?`${ge+1} / ${I}`:"",dt=(0,t.useMemo)(()=>({mode:C,scrollEnterMargin:void 0,scrollExitMargin:void 0,prefersReducedMotion:Pe,reportError:e=>{te(e.code,e.message,e.context)}}),[C,te,Pe]);return(0,r.jsx)(je,{designSize:v,children:(0,r.jsx)(Fe.Provider,{value:dt,children:(0,r.jsxs)("div",{ref:y,style:{position:"relative",width:"100%",height:"100vh",minHeight:"100vh",overflowX:"hidden",overflowY:"hidden",background:"#0d1624"},className:"cineview-container","data-cineview-container":"true",role:"drag"===C?"region":void 0,"aria-roledescription":"drag"===C?"carousel":void 0,"aria-label":"drag"===C?Ie:void 0,tabIndex:"drag"===C?0:void 0,onKeyDown:"drag"===C?lt:void 0,children:[(0,r.jsx)("div",{style:{opacity:1,pointerEvents:"auto"},children:(0,r.jsx)(ur,{scenes:k,visibleSceneIndices:st,currentScene:ge,totalScenes:I,mode:C,dragConfig:S,dragProgress:he,dragTimelineProgress:ve,renderProgress:Se,renderProgressMotion:Ee,timelineProgressMotion:ke,isDragging:ye,sharedTimelineDurationMs:xe,dragRelease:be,sceneActivations:J,firstSceneEnterActive:tt,firstSceneEnterReady:nt,direction:pe,isAnimating:me,viewportWidth:ie,viewportHeight:oe,sceneActions:de,sceneWrapperRefs:x,renderLaneRef:F,takeoverSnapshot:N,candidateSuspended:O,onCandidateSuspensionChange:Ne,onElementContinuationChange:Ve,onPointerSessionStart:ze,dragTransaction:H,onPrepared:Le,onPreparedInvalidated:Oe,onOwnershipRequest:Be,onTransactionComplete:Te,onSceneChange:ct,onDragProgressChange:We,onRenderProgressChange:void 0,onDragTimelineProgressChange:e=>ke.set(e),onDraggingChange:He,onSharedTimelineDurationChange:de.setSharedTimelineDurationMs,onDragRelease:qe,onDragReset:Ye,onFirstSceneEnterComplete:at})}),"drag"===C?(0,r.jsx)("div",{role:"status","aria-live":"polite",style:xr,children:ut}):null]})})})});br.displayName="CineviewDrag";var wr=br;function Rr({direction:e,viewportSpan:n,scrollContentSpan:i,scrollOffset:a,scrollOffsetStore:o,isScrolling:s,config:c,onScrollToOffset:l}){const u=c.autoHide??!0,d=c.ariaLabel??"CineView scroll position",f=Math.max(c.width??6,4),g=Math.max(c.radius??999,0),m=Math.max(c.inset??0,0),p=c.trackColor??"transparent",h=c.thumbColor??"rgba(255, 255, 255, 0.28)",v=c.thumbHoverColor??h,[S,y]=(0,t.useState)(!1),[x,b]=(0,t.useState)(!1),w=(0,t.useRef)(null),R=(0,t.useRef)(null),M=Math.max(i-n,0),E=Gn(o?.getSnapshot()??a,0,M),k=(0,t.useRef)(E);k.current=E;const P=M+n,I=M>1,C=Math.max(n-2*m,1),D=M>0?Gn(n/Math.max(P,n)*C,Math.min(40,C),C):C,A=Math.max(C-D,0),T=M>0?Gn(E/M*A,0,A):0;(0,t.useEffect)(()=>{const t=()=>{const t=Gn(o?.getSnapshot()??a,0,M);if(k.current=t,w.current?.setAttribute("aria-valuenow",String(Math.round(t))),!R.current)return;const n=M>0?Gn(t/M*A,0,A):0;"x"===e?R.current.style.left=`${n}px`:R.current.style.top=`${n}px`};return t(),o?.subscribe(t)},[e,a,M,o,A]);const L=(0,t.useRef)(null);(0,t.useEffect)(()=>{L.current?.()},[e,M,l,C,D]);const O=(0,t.useCallback)(e=>{const t=er(e.key,e.shiftKey,n);0!==t&&(l(t===Number.POSITIVE_INFINITY?M:t===Number.NEGATIVE_INFINITY?0:Gn(k.current+t,0,M)),e.preventDefault())},[M,l,n]),V=(0,t.useCallback)(t=>{if(M<=0||typeof window>"u"||"mouse"===t.pointerType&&0!==t.button||!1===t.isPrimary||(t.preventDefault(),L.current))return;const n=t.currentTarget.getBoundingClientRect(),r="x"===e?n.width:n.height,i="x"===e?n.left:n.top,a="x"===e?t.clientX:t.clientY,o=M>0?Gn(k.current/M*Math.max(r-D,0),0,Math.max(r-D,0)):0,s=a-i,c=s>=o&&s<=o+D,u=c?s-o:D/2,d=e=>{const t=Math.max(r-D,0),n=Gn(e-i-u,0,t);l((t>0?n/t:0)*M)};if(d(a),!c)return;const f=t.pointerId,g=t=>{t.pointerId===f&&(t.preventDefault(),d("x"===e?t.clientX:t.clientY))},m=()=>{window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),L.current===m&&(L.current=null)};function p(e){e.pointerId===f&&m()}L.current=m,window.addEventListener("pointermove",g,{passive:!1}),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p)},[e,M,l,D]);return(0,t.useEffect)(()=>()=>{L.current?.()},[]),I?(0,r.jsx)("div",{"data-cineview-scrollbar-overlay":"true",style:{position:"absolute",inset:0,zIndex:80,pointerEvents:"none",opacity:u?s||S?1:0:1,transition:u?s?"opacity 0.08s ease-out":"opacity 0.5s ease-in 0.15s":"none"},children:(0,r.jsx)("div",{ref:w,role:"scrollbar","aria-label":d,"aria-orientation":"x"===e?"horizontal":"vertical","aria-valuemin":0,"aria-valuemax":Math.round(M),"aria-valuenow":Math.round(E),tabIndex:0,"data-cineview-scrollbar-rail":"true",onPointerDown:V,onKeyDown:O,onFocus:()=>y(!0),onBlur:()=>y(!1),style:"x"===e?{position:"absolute",left:m,bottom:m,width:C,height:f,borderRadius:g,background:p,boxShadow:"0 10px 24px rgba(53, 74, 116, 0.14)",pointerEvents:"auto",touchAction:"none",cursor:"pointer",outline:S?"2px solid rgba(24, 119, 242, 0.95)":"none",outlineOffset:2}:{position:"absolute",top:m,right:m,width:f,height:C,borderRadius:g,background:p,boxShadow:"0 10px 24px rgba(53, 74, 116, 0.14)",pointerEvents:"auto",touchAction:"none",cursor:"pointer",outline:S?"2px solid rgba(24, 119, 242, 0.95)":"none",outlineOffset:2},children:(0,r.jsx)("div",{ref:R,"data-cineview-scrollbar-thumb":"true",onPointerEnter:()=>b(!0),onPointerLeave:()=>b(!1),style:"x"===e?{position:"absolute",left:T,top:0,width:D,height:f,borderRadius:g,background:x?v:h,boxShadow:"0 10px 24px rgba(53, 74, 116, 0.16)",cursor:"grab"}:{position:"absolute",top:T,left:0,width:f,height:D,borderRadius:g,background:x?v:h,boxShadow:"0 10px 24px rgba(53, 74, 116, 0.16)",cursor:"grab"}})})}):null}function Mr(e,t){let n=e;const r=new Map;return{getSnapshot:()=>n,getKeySnapshot:e=>t(n,e),subscribeKey:(e,t)=>{const n=r.get(e)??new Set;return n.add(t),r.set(e,n),()=>{n.delete(t),0===n.size&&r.delete(e)}},setSnapshot:e=>{if(Object.is(n,e))return;const i=n;n=e,r.forEach((n,r)=>{Object.is(t(i,r),t(e,r))||n.forEach(e=>e())})}}}Rr.displayName="ScrollbarOverlay";var Er={sceneLayout:null,sceneZoneState:null,sceneTimelineState:null,isCurrent:!1,isBackdropActive:!1,visualViewportOffset:0,isScrolling:!1,scrollDirection:null,activeSceneIndex:0,viewportWidth:0,viewportHeight:0,firstSceneEnterGateKnown:!1,firstSceneEnterActive:!1,firstSceneEnterReady:!1,direction:"y",sceneCount:0,sceneSizing:"content",exposeTakeoverDebugData:!1,takeoverSceneSpan:null},kr=(0,t.memo)(function({child:e,store:n,frameStore:i,sceneIndex:a,setWrapperRef:o,scrollCallbacks:s}){const c=(0,t.useCallback)(e=>n.subscribeKey(a,e),[a,n]),l=(0,t.useCallback)(()=>n.getKeySnapshot(a)??Er,[a,n]),{sceneLayout:u,sceneZoneState:d,sceneTimelineState:f,isCurrent:g,isBackdropActive:m,visualViewportOffset:p,isScrolling:h,scrollDirection:v,activeSceneIndex:S,viewportWidth:y,viewportHeight:x,firstSceneEnterGateKnown:b,firstSceneEnterActive:w,firstSceneEnterReady:R,direction:M,sceneCount:E,sceneSizing:k,exposeTakeoverDebugData:P,takeoverSceneSpan:I}=(0,t.useSyncExternalStore)(c,l,l),C=!!e.props.scroll,D=(0,t.useRef)(null);On(()=>{const e=D.current;if(!e)return;if(!P||!C||!i)return e.removeAttribute("data-cineview-takeover-progress-px"),void e.removeAttribute("data-cineview-takeover-viewport-offset");const t=()=>{const t=i.getKeySnapshot(a);e.setAttribute("data-cineview-takeover-progress-px",null==t?.zoneProgressPx?"":String(t.zoneProgressPx)),e.setAttribute("data-cineview-takeover-viewport-offset",t?String(t.visualViewportOffset):"")};return t(),i.subscribeKey(a,t)},[P,i,C,a]);const A=Math.max("x"===M?y:x,1),T="screen"===k&&!C,L=u?.flowSpan,O=u?.visualSpan??I??A,V=e.props.layout?.width??e.props.sceneWidth??"100vw",j=C?Math.max((O-A)/2,0):0,z=C?Math.max((A-O)/2,0):0,F=(0,t.useCallback)(e=>o(a,e),[a,o]),N=t.default.useRef(e.props.callbacks);N.current=e.props.callbacks;const $=t.default.useMemo(()=>({get onVisibilityChange(){const e=N.current?.onVisibilityChange,t=s?.onSceneVisibilityChange;return n=>{e?.(n),t?.(n)}}}),[s?.onSceneVisibilityChange]),B=t.default.useRef(e.props.layout);B.current=e.props.layout;const W=t.default.useMemo(()=>{const e=B.current;return C&&null!==I?{...e,..."x"===M?{width:I}:{height:I}}:"x"!==M||C?e:{...e,width:"auto"===V?"auto":"100%"}},[C,I,M,V]),H=t.default.useMemo(()=>({mode:"scroll",direction:M,isActive:g,sceneIndex:a,totalScenes:E,currentSceneIndex:S,transitionDirection:v,isSceneAnimating:h,sharedElapsedMs:0,sharedTimelineDurationMs:0,viewportWidth:y,viewportHeight:x,firstSceneEnterGateKnown:b,firstSceneEnterActive:w,firstSceneEnterReady:R}),[M,g,a,E,S,v,h,y,x,b,w,R]),q=t.default.useMemo(()=>({progress:f?.sceneProgress??0,isScrolling:h,direction:v,transitionSnapshot:null,backdropActive:m,timelineState:f,activeSceneIndex:S,viewportOffset:p,onProgressChange:void 0,onDirectionChange:void 0,onScrollingChange:void 0,onCommit:void 0,onReset:void 0,frameStore:i,sceneIndex:a}),[f,h,v,m,S,p,i,a]),Y=t.default.cloneElement(e,{layout:W,callbacks:$,sceneRuntime:H,scrollRuntime:q});return(0,r.jsx)("div",{ref:F,"data-scene-index":a,style:{position:"relative",width:"x"===M?C&&"number"==typeof L?L:C?"100vw":V:"100%",flex:"x"===M?"0 0 auto":void 0,minHeight:"y"===M&&T?"100vh":void 0,minWidth:"x"===M&&T?"100vw":void 0,...C&&"number"==typeof L?"x"===M?{boxSizing:"border-box",paddingLeft:j}:{boxSizing:"border-box",paddingTop:j,height:L}:{}},children:C?(0,r.jsx)("div",{ref:D,"data-cineview-takeover-shell":a,...P?{"data-cineview-takeover-active-zone":d?.active?d.zoneId:"","data-cineview-takeover-total-distance-px":d?.totalBudgetPx??"","data-cineview-takeover-center-lock-offset":u?.centerLockOffset??"","data-cineview-takeover-segment-start":u?.segmentStart??"","data-cineview-takeover-segment-end":u?.segmentEnd??""}:{},style:"x"===M?{position:"sticky",left:z,width:O,maxWidth:"100vw",height:"100%",overflow:"hidden",zIndex:d?.active?30:void 0}:{position:"sticky",top:z,width:"100%",height:O,maxHeight:"100vh",overflow:"hidden",zIndex:d?.active?30:void 0},children:(0,r.jsx)("div",{"data-cineview-takeover-content":a,style:"x"===M?{width:O,height:"100%",transform:`translateX(${-j}px)`}:{width:"100%",height:O,transform:`translateY(${-j}px)`},children:Y})}):Y},e.key??`scene-${a}`)});function Pr({childrenArray:e,store:n,frameStore:i,setWrapperRef:a,scrollCallbacks:o}){let s=0;return(0,r.jsx)(r.Fragment,{children:e.map((e,c)=>{if(!nr(e))return(0,r.jsx)(t.default.Fragment,{children:e},`flow-${c}`);const l=s++;return(0,r.jsx)(kr,{child:e,store:n,frameStore:i,sceneIndex:l,setWrapperRef:a,scrollCallbacks:o},e.key??`scene-${l}`)})})}function Ir(e){return Number.isFinite(e)?Math.max(0,e):0}function Cr(e,t,n){return Math.min(n,Math.max(t,e))}function Dr(e,t,n,r){return void 0===e?t:n+(r-n)*Cr(e,0,1)}function Ar(e,t,n,r,i,a){const o=n.get(e);if(o)return o;const s=t.get(e);if(!s){const t={animateId:e,startMs:0,enterStartMs:0,enterEndMs:0,exitStartMs:null,exitEndMs:null,totalEndMs:0,hasExit:!1};return n.set(e,t),t}if(r.has(e)){const t=[...r],a=t.indexOf(e);t.slice(a).forEach(e=>i.add(e));const o={animateId:e,startMs:Ir(s.delay),enterStartMs:Ir(s.delay),enterEndMs:Ir(s.delay)+Ir(s.enterDuration),exitStartMs:null,exitEndMs:null,totalEndMs:Ir(s.delay)+Ir(s.enterDuration),hasExit:!1};return n.set(e,o),o}r.add(e);let c=0;if(s.after){const o=Ar(s.after,t,n,r,i,a);i.has(e)||(c=a.get(s.after)??o.enterEndMs)}const l=c+Ir(s.delay),u=Math.max(Ir(s.enterDuration),1),d=Ir(s.exitDuration),f=l+u,g=d>0,m=g?f+d:null,p={animateId:e,startMs:l,enterStartMs:l,enterEndMs:f,exitStartMs:g?f:null,exitEndMs:m,totalEndMs:m??f,hasExit:g};return n.set(e,p),r.delete(e),p}function Tr(e){const t=new Map,n=new Set;let r=new Map,i=e;const a=[...e.values()].some(e=>void 0!==e.phase?.start||void 0!==e.phase?.end),o=()=>{i.forEach((e,a)=>{Ar(a,i,t,new Set,n,r)})};o();let s,c=0;if(a){const a=function(e,t){const n=new Set;e.forEach((e,t)=>{[e.phase?.start,e.phase?.end].some(e=>void 0!==e&&!Number.isFinite(e))&&n.add(t)});const r=(e,t)=>e.map(e=>({...e,offset:e.offset+t})),i=(...e)=>{const t=new Map;return e.flat().forEach(e=>{(!t.has(e.fraction)||t.get(e.fraction).offset<e.offset)&&t.set(e.fraction,e)}),[...t.values()]};for(;;){const a=new Map,o=[],s=c=>{const l=a.get(c);if(l)return l;const u=e.get(c);if(!u)return[{fraction:0,offset:0}];const d=!!u.after&&!t.has(c),f=d?s(u.after):[{fraction:0,offset:0}],g=r(f,Ir(u.delay)),m=r(g,Math.max(Ir(u.enterDuration),1));o.push(...r(m,Ir(u.exitDuration)));const p=n.has(c)?void 0:u.phase;let h=m;if(void 0!==p?.start||void 0!==p?.end){const e=void 0===p.start?g:i([{fraction:Cr(p.start,0,1),offset:0,phaseId:c}],d?g:[]);h=i(void 0===p.end?m:[{fraction:Cr(p.end,0,1),offset:0,phaseId:c}],r(e,1)),o.push(...r(h,u.exitDuration>0?1:0))}return a.set(c,h),h};e.forEach((e,t)=>s(t));let c=0;const l=n.size;if(o.forEach(e=>{const t=e.fraction<1?e.offset/(1-e.fraction):0===e.offset?0:1/0;!Number.isFinite(t)&&e.phaseId?n.add(e.phaseId):c=Math.max(c,t)}),n.size!==l)continue;const u=new Map;return a.forEach((e,t)=>{u.set(t,e.reduce((e,t)=>Math.max(e,t.fraction*c+t.offset),0))}),{enterEnds:u,totalDurationMs:c,invalidPhaseIds:n}}}(e,n);c=a.totalDurationMs,r=a.enterEnds,s=a.invalidPhaseIds,s.size>0&&(i=new Map(e),s.forEach(t=>{i.set(t,{...e.get(t),phase:void 0})})),t.clear(),n.clear(),o()}t.forEach(e=>{c=Math.max(c,e.totalEndMs)});const l=c>0?Math.max(1*c,1):0,u={};return t.forEach((e,t)=>{const r=i.get(t),a=void 0!==r?.phase?.start||void 0!==r?.phase?.end,o={...e,startPx:1*e.startMs,enterStartPx:1*e.enterStartMs,enterEndPx:1*e.enterEndMs,exitStartPx:null===e.exitStartMs?null:1*e.exitStartMs,exitEndPx:null===e.exitEndMs?null:1*e.exitEndMs,totalEndPx:1*e.totalEndMs,phaseStartPx:0,phaseEndPx:0},s=o.enterStartPx,c=Math.max(o.enterEndPx,s+1),d=a?0:s,f=a?l:c,g=Math.max(Dr(r?.phase?.start,s,d,f),r?.after&&!n.has(t)?s:0),m=Math.max(Dr(r?.phase?.end,c,d,f),g+1);if(o.phaseStartPx=g,o.phaseEndPx=m,a)if(o.hasExit){const t=Ir((e.exitEndMs??e.totalEndMs)-(e.exitStartMs??e.enterEndMs)),n=1*Math.max(t,1);o.exitEndPx=l,o.exitStartPx=Math.max(m,l-n),o.totalEndPx=o.exitEndPx}else o.totalEndPx=m;u[t]=o}),{budgets:u,totalDurationMs:c,totalBudgetPx:l,...s?.size?{invalidPhaseIds:[...s]}:{}}}var Lr=(0,t.forwardRef)(function({children:e,designWidth:n,direction:i,sceneSizing:a="content",enterMargin:o,exitMargin:s,scrollbar:c,callbacks:l,monitor:u,debug:d},f){const{designSize:g}=rr(n),m=(0,t.useMemo)(()=>gr({onReady:l?.onReady,onLoadProgress:l?.onLoadProgress,onSceneEnter:l?.onSceneEnter,onSceneLeave:l?.onSceneLeave,onError:l?.onError,onDragStart:l?.onDragStart,onDragProgress:l?.onDragProgress,onDragBlocked:l?.onDragBlocked,onDragEnd:l?.onDragEnd,onDragCancel:l?.onDragCancel,onZoneEnter:l?.onZoneEnter,onZoneLeave:l?.onZoneLeave,onZoneProgress:l?.onZoneProgress,onSceneVisibilityChange:l?.onSceneVisibilityChange}),[l?.onReady,l?.onLoadProgress,l?.onSceneEnter,l?.onSceneLeave,l?.onError,l?.onDragStart,l?.onDragProgress,l?.onDragBlocked,l?.onDragEnd,l?.onDragCancel,l?.onZoneEnter,l?.onZoneLeave,l?.onZoneProgress,l?.onSceneVisibilityChange]),p=i??"y",h=(0,t.useRef)(null),v=(0,t.useRef)(0),S=(0,t.useRef)(function(){let e=0;const t=new Set;return{getSnapshot:()=>e,subscribe:e=>(t.add(e),()=>t.delete(e)),setSnapshot:n=>{Object.is(e,n)||(e=n,t.forEach(e=>e()))}}}()),y=(0,t.useRef)(null),x=(0,t.useRef)(()=>{}),b=(0,t.useRef)(0),w=(0,t.useRef)(null),R=(0,t.useRef)([]),[M,E,k,P]=(0,t.useMemo)(()=>{const n=new Map,r=[],i=[];let a=!1;return[t.Children.toArray(e).map(e=>{if(a||(a=!1),!nr(e))return e;const o=i.length,s=e;let c=s;if(s.props.scroll){const e=s.props.scroll.zoneId??s.props.sceneId;if(void 0!==e){const i=n.get(e);void 0===i?n.set(e,o):(r[o]=[e,i],c=t.default.cloneElement(s,{scroll:void 0}))}}return i.push(c),c}),i,r,a]},[e]);R.current=E;const{viewportSize:I,viewportSizeRef:C,getViewportSpan:D,updateViewportMetrics:A}=function({rootRef:e,direction:n}){const[r,i]=(0,t.useState)({width:0,height:0}),a=(0,t.useRef)({width:0,height:0});return{viewportSize:r,viewportSizeRef:a,getViewportSpan:(0,t.useCallback)(()=>{const t=e.current;return Math.max("x"===n?t?.clientWidth??a.current.width:t?.clientHeight??a.current.height,1)},[n,e]),updateViewportMetrics:(0,t.useCallback)(()=>{const t=e.current;if(!t)return;const n=t.clientWidth,r=t.clientHeight;a.current={width:n,height:r},i(e=>e.width===n&&e.height===r?e:{width:n,height:r})},[e])}}({rootRef:h,direction:p}),{zoneRegistryRef:T,zoneStatesRef:L,timelineStoreRef:O,zoneRuntimeVersion:V,getZoneIdForScene:j,getZoneDistance:z,zoneRuntimeValue:F,zoneTimelineValue:N}=function({scrollOffsetRef:e,measureSceneLayoutsRef:n,updateSceneRenderSnapshotsRef:r,onError:i}){const a=(0,t.useRef)(i);a.current=i;const o=(0,t.useRef)(new WeakSet),s=(0,t.useRef)(new Map),c=(0,t.useRef)(new Map),l=(0,t.useRef)({}),u=(0,t.useRef)(Mr({},(e,t)=>e[t])),[d,f]=(0,t.useState)(0),g=(0,t.useCallback)(e=>{for(const[t,n]of s.current.entries())if(n.sceneIndex===e)return t;return null},[]),m=(0,t.useCallback)(e=>{const t=g(e);return t?l.current[t]?.totalBudgetPx??0:0},[g]),p=(0,t.useCallback)((t,n)=>{const i=l.current,a=n(i[t]);if(a){const e=i[t];if(e&&e.sceneIndex===a.sceneIndex&&e.progressPx===a.progressPx&&e.totalBudgetPx===a.totalBudgetPx&&e.active===a.active&&e.direction===a.direction&&e.approach===a.approach&&function(e,t){if(e.totalDurationMs!==t.totalDurationMs||e.totalBudgetPx!==t.totalBudgetPx||(e.invalidPhaseIds??[]).join("\0")!==(t.invalidPhaseIds??[]).join("\0"))return!1;const n=Object.keys(e.budgets);return n.length===Object.keys(t.budgets).length&&n.every(n=>{const r=e.budgets[n],i=t.budgets[n];return!!(r&&i&&function(e,t){return e.animateId===t.animateId&&e.startMs===t.startMs&&e.enterStartMs===t.enterStartMs&&e.enterEndMs===t.enterEndMs&&e.exitStartMs===t.exitStartMs&&e.exitEndMs===t.exitEndMs&&e.totalEndMs===t.totalEndMs&&e.startPx===t.startPx&&e.enterStartPx===t.enterStartPx&&e.enterEndPx===t.enterEndPx&&e.exitStartPx===t.exitStartPx&&e.exitEndPx===t.exitEndPx&&e.totalEndPx===t.totalEndPx&&e.phaseStartPx===t.phaseStartPx&&e.phaseEndPx===t.phaseEndPx&&e.hasExit===t.hasExit}(r,i))})}(e.sequence,a.sequence))return;l.current={...i,[t]:a}}else{if(!(t in i))return;const e={...i};delete e[t],l.current=e}u.current.setSnapshot(l.current),r.current(e.current)},[e,r]),h=(0,t.useCallback)(e=>{const t=s.current.get(e);if(!t)return void p(e,()=>null);const n=c.current.get(e)??new Map,r=Tr(n);r.invalidPhaseIds?.forEach(t=>{const r=n.get(t);if(!r||o.current.has(r))return;o.current.add(r);const i=`Animate "${t}" has an invalid timeline.phase in zone "${e}". Its phase cannot fit reachable entrance and exit intervals in a finite zone budget; using duration, delay and after instead.`;a.current?.({code:"INVALID_ANIMATION",message:i,context:{zoneId:e,animateId:t,field:"timeline.phase"}})}),p(e,n=>({zoneId:e,sceneIndex:t.sceneIndex,progressPx:Math.min(r.totalBudgetPx,Math.max(n?.progressPx??0,0)),totalBudgetPx:r.totalBudgetPx,active:n?.active??!1,direction:n?.direction??null,sequence:r,approach:n?.approach??"near"})),f(e=>e+1)},[p]);(0,t.useRef)(new Set);const v=(0,t.useCallback)((e,t)=>{const n=s.current.get(e);if(!n||n.sceneIndex===t.sceneIndex){if(n)return void h(e);s.current.set(e,{...t,element:null}),h(e)}},[h]),S=(0,t.useCallback)((e,t)=>{s.current.get(e)?.sceneIndex===t&&(s.current.delete(e),c.current.delete(e),p(e,()=>null),f(e=>e+1))},[p]),y=(0,t.useCallback)((e,t,r)=>{const i=s.current.get(e);!i||i.sceneIndex!==t||(i.element=r,n.current?.())},[n]),x=(0,t.useCallback)((e,t)=>{const n=c.current.get(e)??new Map;return n.set(t.animateId,t),c.current.set(e,n),h(e),t},[h]),b=(0,t.useCallback)((e,t,n)=>{const r=c.current.get(e);!r||r.get(t)!==n||(r.delete(t),h(e))},[h]);return{zoneRegistryRef:s,zoneAnimationsRef:c,zoneStatesRef:l,timelineStoreRef:u,zoneRuntimeVersion:d,getZoneIdForScene:g,getZoneDistance:m,syncZoneState:p,recomputeZoneSequence:h,zoneRuntimeValue:(0,t.useMemo)(()=>({registerZone:v,unregisterZone:S,setZoneElement:y,registerZoneAnimation:x,unregisterZoneAnimation:b}),[v,S,y,x,b]),zoneTimelineValue:(0,t.useMemo)(()=>({store:u.current}),[])}}({scrollOffsetRef:v,measureSceneLayoutsRef:y,updateSceneRenderSnapshotsRef:x,onError:m.common?.onError}),{sceneLayoutsRef:$,sceneWrapperRefs:B,measureSceneLayouts:W,setSceneWrapperRef:H}=function({rootRef:e,direction:n,scenes:r,sceneSizing:i,getViewportSpan:a,getZoneIdForScene:o,getZoneDistance:s,zoneRegistryRef:c,scrollOffsetRef:l,updateSceneRenderSnapshotsRef:u}){const d=(0,t.useRef)([]),f=(0,t.useRef)([]);return{sceneLayoutsRef:d,sceneWrapperRefs:f,measureSceneLayouts:(0,t.useCallback)(()=>{const t=e.current;if(!t)return d.current;const g=a(),m=r.map((e,a)=>{const l=f.current[a],u=e.props,d=function(e){return{enterAnimation:e.transition?.enterAnimation??e.enterAnimation,exitAnimation:e.transition?.exitAnimation??e.exitAnimation,transitionDurationMs:e.sceneTransitionDuration??800,scrollEnterLength:e.scrollEnterLength,scrollExitLength:e.scrollExitLength}}(u),m=!!u.scroll,p=m?or("x"===n?u.layout?.width??u.sceneWidth:u.layout?.height??u.sceneHeight,t.clientWidth,t.clientHeight):null,h=o(a),v=h?c.current.get(h)?.element:null,S=m?p:function(e,t,n,r){return ar("x"===t?e.layout?.width??e.sceneWidth:e.layout?.height??e.sceneHeight,n,r,"declared")}(u,n,t.clientWidth,t.clientHeight),y="x"===n?Math.max(m?v?.offsetWidth??0:l?.offsetWidth??0,m?v?.clientWidth??0:l?.clientWidth??0,0):Math.max(m?v?.offsetHeight??0:l?.offsetHeight??0,m?v?.clientHeight??0:l?.clientHeight??0,0),x=m?Math.max(p??y,1):"screen"===i?Math.max(y,S??0,g,1):Math.max(y,S??0,1),b=m?s(a):0,w=m?Math.max(x,g)+b:x,R=l?sr(l,t,n):0,M=R+w,E=Math.max(R+x/2-g/2,0),k=!!(d.enterAnimation&&a>0),P=!!(d.exitAnimation&&a<r.length-1),I=Math.max(0,d.scrollEnterLength??(k?d.transitionDurationMs:0)),C=Math.max(0,d.scrollExitLength??(P?d.transitionDurationMs:0)),D=Math.max(Math.min(w,g),1);return{sceneStart:R,sceneEnd:M,visualSpan:x,flowSpan:w,timelineDistancePx:b,centerLockOffset:E,segmentStart:E,segmentEnd:E+b,enterLength:Math.min(I,D),exitLength:Math.min(C,D),stackMode:ir(u)}});return d.current=function(e,t){return e.length===t.length&&t.every((t,n)=>{const r=e[n];return r.sceneStart===t.sceneStart&&r.sceneEnd===t.sceneEnd&&r.visualSpan===t.visualSpan&&r.flowSpan===t.flowSpan&&r.timelineDistancePx===t.timelineDistancePx&&r.centerLockOffset===t.centerLockOffset&&r.segmentStart===t.segmentStart&&r.segmentEnd===t.segmentEnd&&r.enterLength===t.enterLength&&r.exitLength===t.exitLength&&r.stackMode===t.stackMode})}(d.current,m)?d.current:m,u.current(l.current),d.current},[n,a,s,o,e,i,r,l,u,c]),setSceneWrapperRef:(0,t.useCallback)((e,t)=>{f.current[e]=t},[])}}({rootRef:h,direction:p,scenes:E,sceneSizing:a,getViewportSpan:D,getZoneIdForScene:j,getZoneDistance:z,zoneRegistryRef:T,scrollOffsetRef:v,updateSceneRenderSnapshotsRef:x}),q=(0,t.useRef)(!1),Y=function(e){return void 0!==e?e:!(typeof window>"u"||!window.__CINEVIEW_SCROLL_DEBUG__)}(d),U=(0,t.useMemo)(()=>{const e=dr(E[0]?.props??{}),t=new Set(e);return{priorityImages:e,backgroundImages:Array.from(new Set(E.flatMap(e=>dr(e.props).filter(e=>!t.has(e)))))}},[E]),[X,K]=Yn({priorityUrls:U.priorityImages,backgroundUrls:U.backgroundImages,onProgress:m.common?.onLoadProgress}),Z=K.startPreload,_=(0,t.useRef)({loadedCount:0,totalCount:0});_.current={loadedCount:X.loadedCount,totalCount:X.totalCount};const G=(0,t.useCallback)((e,t,n)=>{let r=!1;return m.common?.onError?.({code:e,message:t,context:n,preventDefault:()=>{r=!0}}),r},[m.common]),J=vr(),Q=E.length;(0,t.useEffect)(()=>{0===Q&&G("EMPTY_SCENES","Cineview requires at least one Scene child.",{mode:"scroll"})},[G,Q]);const ee=(0,t.useRef)(void 0);(0,t.useEffect)(()=>{ee.current!==k&&(ee.current=k,k.forEach(([e,t],n)=>{G("INVALID_COMPONENT_HIERARCHY",`Duplicate scroll zone id "${e}".`,{reason:"duplicate-scroll-zone",zoneId:e,ownerSceneIndex:t,rejectedSceneIndex:n})}))},[k,G]);const te=(0,t.useCallback)(()=>({loadedCount:_.current.loadedCount,totalCount:_.current.totalCount}),[]),{firstSceneEnterActive:ne,firstSceneEnterReady:re}=Un({enabled:E.length>0,hasFirstScene:!!E[0],priorityComplete:X.priorityComplete,timeoutMs:3e3,emitRecoverableError:G,getPreloadCounts:te}),ie=(0,t.useCallback)(e=>fr(E,e,{includeZoneIds:!0}),[E]);(0,t.useEffect)(()=>{Z()},[U,Z]);const{store:ae,frameStore:oe}=function({scenes:e,sceneLayoutsRef:n,timelineStoreRef:r,viewportSizeRef:i,activeSceneIndexRef:a,scrollDirectionRef:o,isScrollingStateRef:s,direction:c,sceneSizing:l,firstSceneEnterActive:u,firstSceneEnterReady:d,exposeTakeoverDebugData:f,scrollOffsetRef:g,updateSceneRenderSnapshotsRef:m}){const p=(0,t.useRef)(Mr([],(e,t)=>e[t])),h=(0,t.useRef)(function(){let e=[];const t=new Map,n=e=>{t.get(e)?.forEach(e=>e())};return{setSnapshot:t=>{const r=e;e=Array.from(t);const i=Math.max(r.length,e.length);for(let t=0;t<i;t+=1)Object.is(r[t],e[t])||n(t)},setKeySnapshot:(t,r)=>{Object.is(e[t],r)||(e[t]=r,n(t))},clearFrom:t=>{if(e.length<=t)return;const r=e.length;e.length=t;for(let e=t;e<r;e+=1)n(e)},getKeySnapshot:t=>e[t],subscribeKey:(e,n)=>{const r=t.get(e)??new Set;return r.add(n),t.set(e,r),()=>{r.delete(n),0===r.size&&t.delete(e)}}}}()),v=(0,t.useRef)(null),[S,y]=(0,t.useState)(0),x=(0,t.useRef)(null),b=(0,t.useRef)([]),w=(0,t.useCallback)(t=>{const g=r.current.getSnapshot(),m=n.current,S=i.current,w=Math.max("x"===c?S.width:S.height,1),R=a.current,M="cover"===m[R]?.stackMode&&R>0?R-1:null,E=p.current.getSnapshot(),k=x.current,P=s.current,I=o.current,C=null===k||k[0]!==e||k[1]!==m||k[6]!==S.width||k[7]!==S.height||k[10]!==c||k[11]!==l||k[12]!==f,D=new Set,A=t=>{null!==t&&t>=0&&t<e.length&&D.add(t)},T=e=>{A(e-1),A(e),A(e+1)};if(C){b.current.length=0;for(const e in g){const t=g[e];b.current[t.sceneIndex]=t}for(let t=0;t<e.length;t+=1)D.add(t)}else{const[,,e,n,r,i,a,o,s,l]=k;for(const t in g){const n=g[t],r=e[t];n!==r&&(r&&r.sceneIndex!==n.sceneIndex&&b.current[r.sceneIndex]===r&&(b.current[r.sceneIndex]=void 0),b.current[n.sceneIndex]=n,A(r?.sceneIndex??null),A(n.sceneIndex))}for(const t in e){if(t in g)continue;const n=e[t];b.current[n.sceneIndex]===n&&(b.current[n.sceneIndex]=void 0),A(n.sceneIndex)}const f=Math.max("x"===c?a:o,1);for(let e=0;e<m.length;e+=1){const r=m[e],i=t<r.sceneEnd&&t+w>r.sceneStart,a=n<r.sceneEnd&&n+f>r.sceneStart;(i||a)&&A(e)}T(r),T(R),A(i),A(M),(s!==u||l!==d)&&A(0)}const L=C?[]:E.slice();let O=C;const V=C?new Array(e.length):null;D.forEach(n=>{const r=e[n];if(!r)return;const i=m[n]??null,a=b.current[n]??null,o=!!r.props.scroll,s=n===R||!!a?.active,g=M===n,p=o&&a?.active&&i?i.centerLockOffset:t,v=o&&i?i.centerLockOffset:t,y=i?function(e,t,n){if(!e)return null;const r=Math.max(n,1),i=t,a=t+r,o=i+r/2,s=e.sceneStart+e.enterLength,c=e.sceneEnd-Math.max(e.exitLength,0);let l,u=0,d=0;a<=e.sceneStart?l="before":i>=e.sceneEnd?(l="after",u=e.enterLength>0?1:0,d=e.exitLength>0?1:0):e.enterLength>0&&i<s?(l="enter",u=Gn((a-e.sceneStart)/Math.max(e.enterLength,1),0,1)):e.exitLength>0&&i>=c?(l="exit",d=Gn((i-c)/Math.max(e.exitLength,1),0,1),u=e.enterLength>0?1:0):(l="hold",u=e.enterLength>0?1:0);const f=Math.max(e.sceneEnd-e.sceneStart,1);return{phase:l,enterProgress:u,exitProgress:d,sceneProgress:Gn((o-e.sceneStart)/f,0,1),rangeStart:e.sceneStart,rangeEnd:e.sceneEnd,rangeLength:f,enterLength:e.enterLength,exitLength:e.exitLength}}(i,p,w):null,x=o?or("x"===c?r.props.layout?.width??r.props.sceneWidth:r.props.layout?.height??r.props.sceneHeight,S.width,S.height):null,k=s||g||"enter"===y?.phase||"hold"===y?.phase||"exit"===y?.phase,C={timelineState:y,progress:y?.sceneProgress??0,zoneProgressPx:a?.progressPx??null,visualViewportOffset:v,isCurrent:s,isBackdropActive:g,isScrolling:k&&P,scrollDirection:k&&P?I:null},D=h.current.getKeySnapshot(n),A=void 0!==D&&(D?.timelineState===C.timelineState||null!=D?.timelineState&&null!==C.timelineState&&D.timelineState.phase===C.timelineState.phase&&D.timelineState.enterProgress===C.timelineState.enterProgress&&D.timelineState.exitProgress===C.timelineState.exitProgress&&D.timelineState.sceneProgress===C.timelineState.sceneProgress&&D.timelineState.rangeStart===C.timelineState.rangeStart&&D.timelineState.rangeEnd===C.timelineState.rangeEnd&&D.timelineState.enterLength===C.timelineState.enterLength&&D.timelineState.exitLength===C.timelineState.exitLength)&&D.progress===C.progress&&D.zoneProgressPx===C.zoneProgressPx&&D.visualViewportOffset===C.visualViewportOffset&&D.isCurrent===C.isCurrent&&D.isBackdropActive===C.isBackdropActive&&D.isScrolling===C.isScrolling&&D.scrollDirection===C.scrollDirection;V?V[n]=C:A||h.current.setKeySnapshot(n,C);const T={sceneLayout:i,sceneZoneState:a,sceneTimelineState:y,isCurrent:s,isBackdropActive:g,visualViewportOffset:v,isScrolling:k&&P,scrollDirection:k&&P?I:null,activeSceneIndex:R,viewportWidth:S.width,viewportHeight:S.height,firstSceneEnterGateKnown:!0,firstSceneEnterActive:0===n&&u,firstSceneEnterReady:0===n&&d,direction:c,sceneCount:e.length,sceneSizing:l,exposeTakeoverDebugData:f,takeoverSceneSpan:x},j=E[n]??Er;!function(e,t){const n=e.sceneTimelineState,r=t.sceneTimelineState,i=n===r||null!==n&&null!==r&&n.phase===r.phase&&n.rangeStart===r.rangeStart&&n.rangeEnd===r.rangeEnd&&n.rangeLength===r.rangeLength&&n.enterLength===r.enterLength&&n.exitLength===r.exitLength,a=e.sceneZoneState,o=t.sceneZoneState;return e.sceneLayout===t.sceneLayout&&(a===o||null!==a&&null!==o&&a.zoneId===o.zoneId&&a.sceneIndex===o.sceneIndex&&a.totalBudgetPx===o.totalBudgetPx&&a.active===o.active&&a.direction===o.direction&&a.approach===o.approach&&a.sequence===o.sequence)&&i&&e.isCurrent===t.isCurrent&&e.isBackdropActive===t.isBackdropActive&&e.isScrolling===t.isScrolling&&e.scrollDirection===t.scrollDirection&&e.activeSceneIndex===t.activeSceneIndex&&e.viewportWidth===t.viewportWidth&&e.viewportHeight===t.viewportHeight&&e.firstSceneEnterGateKnown===t.firstSceneEnterGateKnown&&e.firstSceneEnterActive===t.firstSceneEnterActive&&e.firstSceneEnterReady===t.firstSceneEnterReady&&e.direction===t.direction&&e.sceneCount===t.sceneCount&&e.sceneSizing===t.sceneSizing&&e.exposeTakeoverDebugData===t.exposeTakeoverDebugData&&e.takeoverSceneSpan===t.takeoverSceneSpan}(j,T)?(L[n]=T,O=!0):L[n]=j}),L.length=e.length,O&&p.current.setSnapshot(L),V?(v.current=V,y(e=>e+1)):h.current.clearFrom(e.length),x.current=[e,m,g,t,R,M,S.width,S.height,u,d,c,l,f]},[a,c,f,u,d,s,n,l,e,o,r,i]);return m.current=w,On(()=>{const e=v.current;e&&(v.current=null,h.current.setSnapshot(e))},[S]),(0,t.useEffect)(()=>{w(g.current)},[g,w]),{store:p.current,frameStore:h.current,updateSceneRenderSnapshots:w}}({scenes:E,sceneLayoutsRef:$,timelineStoreRef:O,viewportSizeRef:C,activeSceneIndexRef:b,scrollDirectionRef:w,isScrollingStateRef:q,direction:p,sceneSizing:a,firstSceneEnterActive:ne,firstSceneEnterReady:re,exposeTakeoverDebugData:Y,scrollOffsetRef:v,updateSceneRenderSnapshotsRef:x});y.current=W;const{isScrolling:se,scrollContentSpan:ce,syncNativeScrollState:le,applyNativeScrollDelta:ue,applyNativeScrollbarOffset:de,goToScrollZone:fe,beginProgrammaticScroll:ge}=function({rootRef:e,direction:n,getViewportSpan:r,updateViewportMetrics:i,measureSceneLayouts:a,sceneLayoutsRef:o,zoneRegistryRef:s,zoneStatesRef:c,timelineStoreRef:l,scrollOffsetRef:u,scrollOffsetStore:d,activeSceneIndexRef:f,scrollDirectionRef:g,isScrollingStateRef:m,updateSceneRenderSnapshotsRef:p,callbacks:h,zoneRuntimeVersion:v}){const S=(0,t.useRef)(null),y=(0,t.useRef)(!1),x=(0,t.useRef)(0),b=(0,t.useRef)(null),w=(0,t.useRef)({}),R=(0,t.useRef)({}),M=(0,t.useRef)(0),[E,k]=(0,t.useState)(!1),[P,I]=(0,t.useState)(1),C=(0,t.useRef)(1),D=(0,t.useCallback)(()=>{const t=e.current;return t?Math.max(("x"===n?t.scrollWidth:t.scrollHeight)-r(),0):0},[n,r,e]),A=(0,t.useCallback)(()=>o.current.filter(e=>e.segmentEnd-e.segmentStart>.5).map(e=>({segmentStart:e.segmentStart,segmentEnd:e.segmentEnd})).sort((e,t)=>e.segmentStart-t.segmentStart),[o]),T=(0,t.useCallback)((e,t)=>function({currentOffset:e,deltaPx:t,maxNativeOffset:n,segments:r=[]}){if(0===t)return Gn(e,0,n);const i=Gn(e,0,n),a=t===Number.POSITIVE_INFINITY?n:t===Number.NEGATIVE_INFINITY?0:Gn(i+t,0,n);if(0===r.length||Math.abs(a-i)<=.5)return a;if(a>i){const e=r.find(e=>i<e.segmentStart+.5&&a>e.segmentEnd+.5);if(e)return Math.min(e.segmentStart+1,e.segmentEnd);const t=r.find(e=>i>=e.segmentStart-.5&&i<e.segmentEnd-.5);return t&&a>t.segmentEnd+.5?t.segmentEnd:a}const o=[...r].reverse().find(e=>i>e.segmentEnd-.5&&a<e.segmentStart-.5);if(o)return Math.max(o.segmentEnd-1,o.segmentStart);const s=[...r].reverse().find(e=>i>e.segmentStart+.5&&i<=e.segmentEnd+.5);return s&&a<s.segmentStart-.5?s.segmentStart:a}({currentOffset:e,deltaPx:t,maxNativeOffset:D(),segments:A()}),[A,D]),L=(0,t.useCallback)(t=>{const r=e.current;if(!r)return;const i=Gn(t,0,D());"x"!==n?"function"==typeof r.scrollTo?r.scrollTo({top:i,behavior:"auto"}):r.scrollTop=i:"function"==typeof r.scrollTo?r.scrollTo({left:i,behavior:"auto"}):r.scrollLeft=i},[n,D,e]),O=(0,t.useCallback)(e=>{b.current=Gn(e,0,D())},[D]),V=(0,t.useCallback)(()=>{if(null===b.current)return;b.current=null;const t=e.current;if(!t)return;const r=Gn("x"===n?t.scrollLeft:t.scrollTop,0,D());L(r),x.current=r},[n,D,e,L]),j=(0,t.useCallback)((e,t=r())=>{const n=o.current;if(0===n.length)return;const i=e+t/2;let a=0,s=Number.POSITIVE_INFINITY;for(let e=0;e<n.length;e+=1){const t=n[e];if(i>=t.sceneStart&&i<t.sceneEnd){a=e;break}const r=i<t.sceneStart?t.sceneStart-i:i-t.sceneEnd;r<s&&(s=r,a=e)}if(f.current===a)return;const c=M.current;if(f.current=a,p.current(e),c===a)return;const l=a>=c?"forward":"backward";h.common?.onSceneEnter?.({fromIndex:c,toIndex:a,direction:l}),h.common?.onSceneLeave?.({fromIndex:c,toIndex:a,direction:l}),M.current=a},[f,h.common,r,o,p]),z=(0,t.useCallback)((e,t,n=r())=>{const i=w.current,a=c.current,u=n,d={};Object.entries(a).forEach(([n,r])=>{const i=o.current[r.sceneIndex];if(!i||r.totalBudgetPx<=0)return void(d[n]=0!==r.progressPx||r.active||null!==r.direction?{...r,progressPx:0,active:!1,direction:null}:r);const a=Gn(e-i.segmentStart,0,r.totalBudgetPx),s=a<=.01?0:r.totalBudgetPx-a<=.01?r.totalBudgetPx:a,c=e>i.segmentStart+.5&&e<i.segmentEnd-.5&&s>.5&&s<r.totalBudgetPx-.5,l=function(e,t,n){return e<=0?"inside":"far"===n?e<=1*t?"near":"far":e>1.5*t?"far":"near"}(Math.max(i.segmentStart-e,e-i.segmentEnd,0),u,r.approach),f={...r,progressPx:s,active:c,direction:c?t:null,approach:l};d[n]=r.progressPx===f.progressPx&&r.active===f.active&&r.direction===f.direction&&r.approach===f.approach?r:f});const f=Object.entries(d);Object.keys(a).length===f.length&&f.every(([e,t])=>a[e]===t)||(c.current=d,l.current.setSnapshot(d)),p.current(e),w.current=d,Object.entries(d).forEach(([e,t])=>{const n=i[e],r=s.current.get(e);if(!r)return;const a=R.current[e],o=0===t.progressPx||t.progressPx===t.totalBudgetPx;(void 0===a||Math.abs(a-t.progressPx)>.5||o&&a!==t.progressPx)&&(R.current[e]=t.progressPx,h.scroll?.onZoneProgress?.({zoneId:e,sceneIndex:r.sceneIndex,progress:t.totalBudgetPx>0?Gn(t.progressPx/t.totalBudgetPx,0,1):0})),!n?.active&&t.active?h.scroll?.onZoneEnter?.({zoneId:e,sceneIndex:r.sceneIndex}):n?.active&&!t.active&&h.scroll?.onZoneLeave?.({zoneId:e,sceneIndex:r.sceneIndex})})},[h.scroll,r,o,l,p,s,c]),F=(0,t.useCallback)((t=!1)=>{const o=e.current;if(!o)return;const s="x"===n?o.scrollLeft:o.scrollTop;if(t&&y.current&&null===b.current&&Math.abs(s-x.current)<=.01)return;t&&(y.current||(i(),a()),y.current=!0);const c=x.current,l=b.current;let f;null!==l?(f=Gn(s,0,D()),Math.abs(f-l)<=1&&(b.current=null)):(f=T(c,s-c),Math.abs(f-s)>.5&&L(f));const h=Math.abs(f-c)<=.5?g.current:f>c?"forward":"backward";x.current=f,u.current=f,d.setSnapshot(f),g.current=h,t&&(m.current=!0,k(e=>e||!0),null!==S.current&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{m.current=!1,k(!1),y.current=!1,S.current=null,p.current(u.current)},120));const v=r(),w=Math.max("x"===n?o.scrollWidth:o.scrollHeight,v);z(f,h,v),j(f,v),Math.abs(C.current-w)>.5&&(C.current=w,I(w))},[n,D,r,m,a,T,e,g,u,d,L,z,j,p,i]),N=(0,t.useCallback)(t=>{const r=e.current;if(!r||0===t)return!1;V();const i="x"===n?r.scrollLeft:r.scrollTop,a=T(i,t);return!(Math.abs(a-i)<=.5||(L(a),F(!0),0))},[V,n,T,e,L,F]),$=(0,t.useCallback)(t=>{V();const r=e.current,i=r?"x"===n?r.scrollLeft:r.scrollTop:u.current;L(T(i,t-i)),F(!0)},[V,n,T,e,u,L,F]),B=(0,t.useCallback)((t,r)=>{const i=e.current,a=c.current[t],s=a?o.current[a.sceneIndex]:null;if(i&&s){if(!1!==r?.animated)return O(s.centerLockOffset),void i.scrollTo({top:"x"===n?void 0:s.centerLockOffset,left:"x"===n?s.centerLockOffset:void 0,behavior:"smooth"});i.scrollTo({top:"x"===n?void 0:s.centerLockOffset,left:"x"===n?s.centerLockOffset:void 0,behavior:"auto"}),x.current=s.centerLockOffset,u.current=s.centerLockOffset,d.setSnapshot(s.centerLockOffset),z(s.centerLockOffset,null),j(s.centerLockOffset)}},[O,n,e,o,u,d,z,j,c]);return function({rootRef:e,direction:n,getViewportSpan:r,applyNativeScrollDelta:i}){const a=(0,t.useRef)(null);(0,t.useEffect)(()=>{const t=e.current;if(!t)return;const o=e=>e instanceof Element&&e.closest('[data-cineview-container="true"]')===t,s=e=>{if(e.defaultPrevented||!o(e.target))return;const a=function(e,t,n){return Number.isFinite(e)&&0!==e?1===t?18*e:2===t?e*Math.max(n,1):e:0}("x"===n?e.deltaX:e.deltaY,e.deltaMode,r());0!==a&&(Qn(e.target,t,n,a)||i(a)&&e.cancelable&&e.preventDefault())},c=e=>{if(!o(e.target))return;const t=e.touches[0];t&&(a.current={x:t.clientX,y:t.clientY})},l=e=>{const r=e.touches[0];if(!r||!a.current)return;if(e.defaultPrevented||!o(e.target))return void(a.current={x:r.clientX,y:r.clientY});const s=function(e){return Number.isFinite(e)?e:0}("x"===n?a.current.x-r.clientX:a.current.y-r.clientY);if(Qn(e.target,t,n,s))a.current={x:r.clientX,y:r.clientY};else if(0!==s){const t=i(s);a.current={x:r.clientX,y:r.clientY},t&&e.cancelable&&e.preventDefault()}},u=()=>{a.current=null};return t.addEventListener("wheel",s,{capture:!0,passive:!1}),t.addEventListener("touchstart",c,{passive:!0}),t.addEventListener("touchmove",l,{passive:!1}),t.addEventListener("touchend",u),t.addEventListener("touchcancel",u),()=>{t.removeEventListener("wheel",s,{capture:!0}),t.removeEventListener("touchstart",c),t.removeEventListener("touchmove",l),t.removeEventListener("touchend",u),t.removeEventListener("touchcancel",u),a.current=null}},[i,n,r,e]),(0,t.useEffect)(()=>{if(typeof window>"u")return;const e=e=>{if(e.defaultPrevented||function(e){return tr(e.target,e.key)}(e))return;const t=er(e.key,e.shiftKey,r());if(0===t)return;const n=document.activeElement;(n===document.body||n===document.documentElement)&&i(t)&&e.cancelable&&e.preventDefault()};return window.addEventListener("keydown",e,!0),()=>{window.removeEventListener("keydown",e,!0)}},[i,r])}({rootRef:e,direction:n,getViewportSpan:r,applyNativeScrollDelta:N}),(0,t.useEffect)(()=>()=>{null!==S.current&&(window.clearTimeout(S.current),S.current=null),b.current=null},[]),(0,t.useEffect)(()=>{i(),a(),F()},[a,F,i,v]),(0,t.useEffect)(()=>{if(typeof window>"u")return;const e=()=>{i(),a(),F()};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[a,F,i]),{isScrolling:E,scrollContentSpan:P,syncNativeScrollState:F,applyNativeScrollDelta:N,applyNativeScrollbarOffset:$,goToScrollZone:B,beginProgrammaticScroll:O}}({rootRef:h,direction:p,getViewportSpan:D,updateViewportMetrics:A,measureSceneLayouts:W,sceneLayoutsRef:$,zoneRegistryRef:T,zoneStatesRef:L,timelineStoreRef:O,scrollOffsetRef:v,scrollOffsetStore:S.current,activeSceneIndexRef:b,scrollDirectionRef:w,isScrollingStateRef:q,updateSceneRenderSnapshotsRef:x,callbacks:m,zoneRuntimeVersion:V}),me=(0,t.useRef)(!1),pe=(0,t.useRef)(null),he=(0,t.useCallback)(()=>{me.current=!1,A(),W(),le()},[W,le,A]);(0,t.useEffect)(()=>{if(typeof ResizeObserver>"u")return;const e=new ResizeObserver(()=>{null===pe.current&&(pe.current=window.requestAnimationFrame(()=>{pe.current=null,q.current?me.current=!0:he()}))});return B.current.forEach(t=>{t&&e.observe(t)}),()=>{null!==pe.current&&(window.cancelAnimationFrame(pe.current),pe.current=null),e.disconnect()}},[he,B,E]),(0,t.useEffect)(()=>{se||!me.current||he()},[se,he]),(0,t.useEffect)(()=>{if(u)return _n()},[u]),(0,t.useEffect)(()=>{},[P]);const ve=(0,t.useRef)(null),Se=(0,t.useCallback)((e,t=!0)=>{if(e<0||e>=R.current.length)return;const n=h.current,r=B.current[e];if(!n||!r)return;const i=sr(r,n,p);ge(i),n.scrollTo({top:"x"===p?void 0:i,left:"x"===p?i:void 0,behavior:t?"smooth":"auto"})},[ge,p,B]),ye=(0,t.useCallback)(()=>{A(),W(),le()},[W,le,A]),xe=(0,t.useCallback)(async e=>{const t=ie(e);t.length>0&&K.addUrls(t,!0),await Z()},[K,ie,Z]);ve.current||(ve.current={goToScene:(e,t=!0)=>Se(e,t),goToZone:(e,t)=>fe(e,t),refreshLayout:()=>ye(),preload:e=>xe(e),getCurrentIndex:()=>b.current,getPerformanceMetrics:()=>Zn.getMetrics()});const be=ve.current,we=(0,t.useRef)(!1);(0,t.useEffect)(()=>{we.current||(we.current=!0,m.common?.onReady?.(be))},[m.common,be]),(0,t.useImperativeHandle)(f,()=>be,[be]);const Re="object"==typeof c?c:{},Me=Re.autoHide??!0,Ee="object"==typeof c&&!1!==c.enabled,ke={position:"relative",width:"100%",height:"100vh",minHeight:"100vh",overflowX:"x"===p?"scroll":"hidden",overflowY:"x"===p?"hidden":"scroll",overscrollBehavior:"contain",WebkitOverflowScrolling:"touch",scrollbarGutter:Ee?"auto":"stable",background:"#ffffff"},Pe=(0,t.useMemo)(()=>({mode:"scroll",scrollEnterMargin:o,scrollExitMargin:s,prefersReducedMotion:J,reportError:e=>{m.common?.onError?.({...e,code:e.code})}}),[o,s,m.common,J]);return(0,r.jsx)(je,{designSize:g,children:(0,r.jsx)(Fe.Provider,{value:Pe,children:(0,r.jsx)(ht.Provider,{value:F,children:(0,r.jsxs)(vt.Provider,{value:N,children:[Ee&&(0,r.jsx)("style",{children:'\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 '}),"x"===p&&(0,r.jsx)("style",{children:'[data-cineview-scroll-stream="x"] > * { flex-shrink: 0; }'}),(0,r.jsxs)("div",{style:{position:"relative",width:"100%",height:"100vh",minHeight:"100vh"},children:[(0,r.jsx)("div",{ref:h,style:ke,className:"cineview-container","data-cineview-container":"true","data-cineview-scrollbar-autohide":String(Me),tabIndex:0,onScroll:()=>le(!0),onKeyDownCapture:e=>{if(e.defaultPrevented||!(e.target instanceof Element)||e.target.closest('[data-cineview-container="true"]')!==e.currentTarget||tr(e.target,e.key))return;const t=er(e.key,e.shiftKey,D());0!==t&&!Qn(e.target,e.currentTarget,p,t)&&ue(t)&&e.preventDefault()},children:(0,r.jsx)("div",{"data-cineview-scroll-stream":p,style:"x"===p?{display:"flex",flexDirection:"row",alignItems:"stretch",width:"100%"}:void 0,children:(0,r.jsx)(Pr,{childrenArray:M,store:ae,frameStore:oe,setWrapperRef:H,scrollCallbacks:m.scroll})})}),Ee&&(0,r.jsx)(Rr,{direction:p,scrollContentSpan:ce,viewportSpan:Math.max("x"===p?I.width:I.height,1),scrollOffset:v.current,scrollOffsetStore:S.current,isScrolling:se,config:Re,onScrollToOffset:de})]})]})})})})});Lr.displayName="DirectScrollCineview";var Or=Lr,Vr=(0,t.forwardRef)((e,t)=>"scroll"===yr(e.mode)?(0,r.jsx)(Or,{...e,ref:t}):(0,r.jsx)(wr,{...e,ref:t}));Vr.displayName="Cineview";var jr=Vr;e.Animate=$n,e.AnimateVideo=Nn,e.Cineview=jr,e.Container=ln,e.Image=gn,e.Position=Bn,e.Scene=Wn,e.useAnimateTimeline=gt});
2
2
  //# sourceMappingURL=cineview.umd.js.map