@ssgoi/core 5.2.1 → 5.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var ct=Object.defineProperty;var lt=(e,n,t)=>n in e?ct(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var d=(e,n,t)=>lt(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("./types.cjs"),X=require("./spring-integrator-95Mh7mdw.cjs"),ut=require("./provider-BKaONTeg.cjs");class ft{constructor(){d(this,"listeners",new Set);d(this,"rafId",null);d(this,"isRunning",!1);d(this,"startTime",Date.now());d(this,"lastUpdate",this.startTime);d(this,"elapsed",0);d(this,"lagThreshold",500);d(this,"adjustedLag",33);d(this,"maxDeltaTime",33);d(this,"gap",1e3/240);d(this,"nextTime",this.gap);d(this,"tick",()=>{const n=Date.now();let i=n-this.lastUpdate;i>this.lagThreshold||i<0?(this.startTime+=i-this.adjustedLag,i=this.adjustedLag):i>this.maxDeltaTime&&(i=this.maxDeltaTime),this.lastUpdate=n;const r=n-this.startTime,o=r-this.nextTime;if(o>0){const s=i/1e3;this.elapsed=r/1e3,this.nextTime+=o+(o>=this.gap?4:this.gap-o),this.listeners.forEach(m=>{m(s,this.elapsed)})}this.listeners.size>0?this.rafId=requestAnimationFrame(this.tick):(this.isRunning=!1,this.rafId=null)})}subscribe(n){return this.listeners.add(n),this.isRunning||(this.isRunning=!0,this.rafId=requestAnimationFrame(this.tick)),()=>{this.unsubscribe(n)}}unsubscribe(n){this.listeners.delete(n),this.listeners.size===0&&this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.isRunning=!1,this.rafId=null)}lagSmoothing(n,t){this.lagThreshold=n,this.adjustedLag=Math.min(t,n)}fps(n){this.gap=1e3/n,this.nextTime=this.elapsed*1e3+this.gap}getListenerCount(){return this.listeners.size}getElapsed(){return this.elapsed}}const _=new ft;function mt(e){const{integrator:n,from:t,to:i,velocity:r=0,onUpdate:o,onComplete:s,onStart:m}=e;let l={position:t,velocity:r},u=!0,h=0,v=!1;const A=S=>{if(u){if(v||(v=!0,m==null||m()),l=n.step(l,i,S),n.isSettled(l,i)){if(h+=Math.min(S,.033),h>=X.SETTLE_THRESHOLD){l={position:i,velocity:0},u=!1,o(l.position),_.unsubscribe(A),s();return}}else h=0;o(l.position)}};return _.subscribe(A),{stop:()=>{u&&(u=!1,_.unsubscribe(A))},getPosition:()=>l.position,getVelocity:()=>l.velocity,isRunning:()=>u}}const L=1e3/60;function dt(e,n,t,i=0){let o={position:n,velocity:i},s=0;const m=[];for(let l=0;l<600;l++){const u=l*L;if(m.push({time:u,position:o.position,velocity:o.velocity}),o=e.step(o,t,L/1e3),e.isSettled(o,t)){if(s+=L/1e3,s>=X.SETTLE_THRESHOLD){m.push({time:(l+1)*L,position:t,velocity:0});break}}else s=0}return m}function Y(e,n){if(e.length===0)return{position:0,velocity:0};const t=e[0],i=e[e.length-1];if(n<=0)return{position:t.position,velocity:t.velocity};if(n>=i.time)return{position:i.position,velocity:i.velocity};let r=0,o=e.length-1;for(;r<o-1;){const u=Math.floor((r+o)/2);e[u].time<=n?r=u:o=u}const s=e[r],m=e[o],l=(n-s.time)/(m.time-s.time);return{position:s.position+(m.position-s.position)*l,velocity:s.velocity+(m.velocity-s.velocity)*l}}function ht(e,n){return e.map(t=>n(t.position))}function gt(e){const{integrator:n,element:t,from:i,to:r,velocity:o=0,style:s,onComplete:m,onStart:l}=e,u=dt(n,i,r,o);if(u.length===0)return l==null||l(),m(),{stop:()=>{},getPosition:()=>r,getVelocity:()=>0,isRunning:()=>!1};const h=ht(u,s),v=u[u.length-1],A=v.time,S=h[0];if(S)for(const C of Object.keys(S))t.style[C]="";const y=t.animate(h,{duration:A,fill:"forwards",easing:"linear",composite:"replace"});let p=!0;const R=performance.now();return l==null||l(),y.onfinish=()=>{p&&(p=!1,m())},{stop:()=>{p&&(p=!1,y.cancel())},getPosition:()=>{if(!p)return v.position;const C=performance.now()-R;return Y(u,C).position},getVelocity:()=>{if(!p)return 0;const C=performance.now()-R;return Y(u,C).velocity},isRunning:()=>p}}function yt(e){const{element:n,frames:t,duration:i,easing:r="linear",from:o,to:s,onComplete:m,onStart:l}=e,u=t[0];if(u)for(const S of Object.keys(u))S==="offset"||S==="easing"||S==="composite"||(n.style[S]="");const h=n.animate(t,{duration:i,fill:"forwards",easing:r,composite:"replace"});let v=!0;const A=performance.now();return l==null||l(),h.onfinish=()=>{v&&(v=!1,m())},{stop:()=>{v&&(v=!1,h.cancel())},getPosition:()=>{if(!v)return s;const S=performance.now()-A,y=Math.min(Math.max(S/i,0),1);return o+(s-o)*y},getVelocity:()=>0,isRunning:()=>v}}function wt(e){const{to:n,onStart:t,onComplete:i}=e;return t==null||t(),i(),{stop:()=>{},getPosition:()=>n,getVelocity:()=>0,isRunning:()=>!1}}class pt{static from(n){const{tick:t,css:i,keyframes:r}=n;if((t?1:0)+(i?1:0)+(r?1:0)>1)throw new Error("Cannot use more than one of 'tick', 'css', 'keyframes' together");return r?s=>yt({element:r.element,frames:r.frames,duration:r.duration,easing:r.easing,from:s.from,to:s.to,onComplete:s.onComplete,onStart:s.onStart}):i?s=>{if(!s.integrator)throw new Error("css mode requires an integrator");return gt({integrator:s.integrator,from:s.from,to:s.to,velocity:s.velocity,onComplete:s.onComplete,onStart:s.onStart,element:i.element,style:i.style})}:t?s=>{if(!s.integrator)throw new Error("tick mode requires an integrator");return mt({integrator:s.integrator,from:s.from,to:s.to,velocity:s.velocity,onComplete:s.onComplete,onStart:s.onStart,onUpdate:t})}:wt}}class Q{}const vt={stiffness:300,damping:30};class j extends Q{constructor(t){super();d(this,"options");d(this,"runner");d(this,"controls",null);d(this,"isAnimating",!1);d(this,"currentValue");d(this,"currentVelocity",0);d(this,"updateFn");d(this,"isKeyframesMode");if(this.options={from:t.from??0,to:t.to??1,physics:t.physics,onComplete:t.onComplete??(()=>{}),onStart:t.onStart},this.currentValue=this.options.from,this.isKeyframesMode=!!t.keyframes,t.tick)this.updateFn=i=>{var r;return(r=t.tick)==null?void 0:r.call(t,i)};else if(t.css){const{element:i,style:r}=t.css;this.updateFn=o=>{const s=r(o);for(const[m,l]of Object.entries(s))i.style[m]=typeof l=="number"?String(l):l}}else this.updateFn=()=>{};this.runner=pt.from({tick:t.tick,css:t.css,keyframes:t.keyframes})}syncState(){var t;(t=this.updateFn)==null||t.call(this,this.currentValue)}createIntegrator(){const t=this.options.physics;return t!=null&&t.integrator?t.integrator():t!=null&&t.spring||t!=null&&t.inertia?ut.IntegratorProvider.from({spring:t.spring,inertia:t.inertia}):new X.SpringIntegrator(vt)}runAnimation(t){this.isAnimating=!0,this.controls=this.runner({integrator:this.isKeyframesMode?void 0:this.createIntegrator(),from:this.currentValue,to:t,velocity:this.currentVelocity,onStart:this.options.onStart,onComplete:()=>{this.currentValue=t,this.currentVelocity=0,this.isAnimating=!1,this.controls=null,this.options.onComplete()}})}forward(){this.stop(),this.runAnimation(this.options.to)}backward(){this.stop(),this.runAnimation(this.options.from)}reverse(){const t=this.options.from;this.options.from=this.options.to,this.options.to=t,this.isAnimating&&(this.stop(),this.runAnimation(this.options.to))}stop(){this.controls&&(this.currentValue=this.controls.getPosition(),this.currentVelocity=this.controls.getVelocity(),this.controls.stop(),this.controls=null),this.isAnimating=!1}getVelocity(){var t;return((t=this.controls)==null?void 0:t.getVelocity())??this.currentVelocity}getCurrentValue(){var t;return((t=this.controls)==null?void 0:t.getPosition())??this.currentValue}getIsAnimating(){return this.isAnimating}getCurrentState(){return{position:this.getCurrentValue(),velocity:this.getVelocity(),from:this.options.from,to:this.options.to}}setValue(t){this.currentValue=t}setVelocity(t){this.currentVelocity=t}updateOptions(t){this.options={...this.options,...t}}}class z extends Q{constructor(t){super();d(this,"config");d(this,"animators",new Map);d(this,"itemOrder",[]);d(this,"completedCount",0);d(this,"completedAnimators",new Set);d(this,"direction","forward");d(this,"idCounter",0);d(this,"rafId",null);d(this,"from");d(this,"to");d(this,"initialState");this.config=t.config,this.from=t.from,this.to=t.to,this.initialState=t.state??{position:t.from,velocity:0},this.initializeAnimators()}generateId(){return`spring_${this.idCounter++}`}initializeAnimators(){this.config.items.forEach((t,i)=>{const r=this.generateId(),o=new j({from:this.from,to:this.to,physics:t.physics,tick:t.tick,css:t.css,keyframes:t.keyframes,onComplete:()=>this.onAnimatorComplete(r),onStart:t.onStart});(i===0||t.normalizedOffset===0)&&(o.setValue(this.initialState.position),o.setVelocity(this.initialState.velocity),o.syncState()),this.animators.set(r,{id:r,item:t,animator:o,started:!1}),this.itemOrder.push(r)})}getAnimatorProgress(t){const i=t.animator.getCurrentState(),r=Math.abs(i.to-i.from);return r===0?1:Math.abs(i.position-i.from)/r}getOrderedIds(){return this.direction==="forward"?this.itemOrder:[...this.itemOrder].reverse()}onAnimatorComplete(t){var r,o,s,m,l,u;const i=this.animators.get(t);!i||this.completedAnimators.has(t)||(this.completedAnimators.add(t),this.completedCount++,(o=(r=i.item).onComplete)==null||o.call(r),(m=(s=this.config).onProgress)==null||m.call(s,this.completedCount,this.config.items.length),this.completedCount===this.config.items.length&&(this.stopScheduler(),(u=(l=this.config).onEnd)==null||u.call(l)))}checkAndStartSprings(){const t=this.getOrderedIds();for(let i=0;i<t.length;i++){const r=t[i],o=this.animators.get(r);if(!o||o.started)continue;if(i===0){this.startAnimator(r);continue}const s=t[i-1],m=this.animators.get(s);if(!m||!m.started)continue;const l=this.getAnimatorProgress(m),u=o.item.normalizedOffset;l>=u&&this.startAnimator(r)}}startAnimator(t){const i=this.animators.get(t);!i||i.started||(i.started=!0,this.direction==="forward"?i.animator.forward():i.animator.backward())}startScheduler(){const t=()=>{this.checkAndStartSprings(),this.getIsAnimating()&&(this.rafId=requestAnimationFrame(t))};t()}stopScheduler(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}getFirstAnimator(){var i;const t=this.itemOrder[0];return t?((i=this.animators.get(t))==null?void 0:i.animator)??null:null}forward(){var t,i;this.stop(),this.direction="forward",this.completedCount=0,this.completedAnimators.clear(),this.resetStartedFlags(),(i=(t=this.config).onStart)==null||i.call(t),this.startScheduler()}backward(){var t,i;this.stop(),this.direction="backward",this.completedCount=0,this.completedAnimators.clear(),this.resetStartedFlags(),(i=(t=this.config).onStart)==null||i.call(t),this.startScheduler()}resetStartedFlags(){this.animators.forEach(t=>{t.started=!1})}stop(){this.stopScheduler(),this.animators.forEach(t=>{t.animator.stop(),t.started=!1})}reverse(){this.direction=this.direction==="forward"?"backward":"forward",this.animators.forEach(t=>{if(!t.started)return;const i=t.animator.getCurrentState();if(i.position===i.to){const o=new j({from:this.to,to:this.from,physics:t.item.physics,tick:t.item.tick,css:t.item.css,keyframes:t.item.keyframes,onComplete:()=>this.onAnimatorComplete(t.id),onStart:t.item.onStart});o.setValue(this.to),o.setVelocity(0),o.syncState(),o.forward(),t.animator=o}else t.animator.reverse()})}getCurrentState(){const t=this.getFirstAnimator();return t?t.getCurrentState():{position:0,velocity:0,from:0,to:1}}getCurrentValue(){const t=this.getFirstAnimator();return(t==null?void 0:t.getCurrentValue())??0}getVelocity(){const t=this.getFirstAnimator();return(t==null?void 0:t.getVelocity())??0}setValue(t){const i=this.getFirstAnimator();i==null||i.setValue(t)}setVelocity(t){const i=this.getFirstAnimator();i==null||i.setVelocity(t)}getIsAnimating(){for(const t of this.animators.values())if(t.animator.getIsAnimating())return!0;return!1}static fromState(t,i){return new z({...i,state:t})}}const H=Symbol.for("TRANSITION_STRATEGY"),tt=e=>({runIn:async n=>{const{currentAnimation:t}=e;if(t&&t.direction==="out"){const r=t.controller.getCurrentValue(),o=t.controller.getVelocity();if(t.controller.stop(),n.out)return{config:await n.out,state:{position:r,velocity:o},from:1,to:0,direction:"backward"}}return n.in?{config:await n.in,state:{position:0,velocity:0},from:0,to:1,direction:"forward"}:{state:{position:0,velocity:0},from:0,to:1,direction:"forward"}},runOut:async n=>{const{currentAnimation:t}=e;if(t&&t.direction==="in"){const r=t.controller.getCurrentValue(),o=t.controller.getVelocity();if(t.controller.stop(),n.in)return{config:await n.in,state:{position:r,velocity:o},from:0,to:1,direction:"backward"}}return n.out?{config:await n.out,state:{position:1,velocity:0},from:1,to:0,direction:"forward"}:{state:{position:1,velocity:0},from:1,to:0,direction:"forward"}}}),et=()=>({runIn:async e=>e.in?{config:await e.in,state:{position:0,velocity:0},from:0,to:1,direction:"forward"}:{state:{position:0,velocity:0},from:0,to:1,direction:"forward"},runOut:async e=>e.out?{config:await e.out,state:{position:1,velocity:0},from:1,to:0,direction:"forward"}:{state:{position:1,velocity:0},from:1,to:0,direction:"forward"}}),U="data-ssgoi-scope",K="data-ssgoi-scope-ready";function St(){return e=>{if(e)return e.setAttribute(U,""),queueMicrotask(()=>{queueMicrotask(()=>{e.setAttribute(K,"true")})}),()=>{}}}function it(e){return e.hasAttribute(K)}function nt(e){return e.closest(`[${U}]`)}const At=e=>{let n=e.parentElement;for(;n&&n!==document.body;){const t=window.getComputedStyle(n),i=t.overflow+t.overflowY+t.overflowX;if(i.includes("auto")||i.includes("scroll")||n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)return n;n=n.parentElement}return document.documentElement},Tt=e=>{let n=e.parentElement;for(;n&&n!==document.body;){const t=window.getComputedStyle(n).position;if(t==="relative"||t==="absolute"||t==="fixed"||t==="sticky")return n;n=n.parentElement}return document.body};function B(e){return new Promise(n=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{n()})})})}function Et(e,n){var S;let t=null,i=null,r=null,o=null;const s={get currentAnimation(){return t}},m=((S=n==null?void 0:n.strategy)==null?void 0:S.call(n,s))||tt(s),l=async y=>{var g,E;i&&(i.remove(),i=null);const p=e(),R=p.in&&p.in(y),C=!(n!=null&&n.strategy)&&p.out?p.out(y):void 0;if(!R)return;const w={in:k.normalizeToMultiAnimation(R),out:C?k.normalizeToMultiAnimation(C):void 0},f=await m.runIn(w);if(!f.config){t&&(t.direction="in");return}const a=f.config;(g=a.prepare)==null||g.call(a);const T=k.normalizeSchedule({...a,onEnd:()=>{var b;t=null,(b=a.onEnd)==null||b.call(a)}},y);a.wait&&await a.wait();const c=z.fromState(f.state,{config:T,from:f.from,to:f.to});t={controller:c,direction:"in"},(E=a.onReady)==null||E.call(a),await B(),f.direction==="forward"?c.forward():c.backward()},u=async y=>{var E,b;i=y;const p=e(),R=!(n!=null&&n.strategy)&&p.in?p.in(y):void 0,C=p.out&&p.out(y);if(!C)return;const w={in:R?k.normalizeToMultiAnimation(R):void 0,out:k.normalizeToMultiAnimation(C)},f=await m.runOut(w);if(!f.config){t&&(t.direction="out"),i&&(i.remove(),i=null);return}const a=f.config;g(),(E=a.prepare)==null||E.call(a);const T=k.normalizeSchedule({...a,onEnd:()=>{var M,V;(M=a.onEnd)==null||M.call(a),i&&(i.remove(),i=null),t=null,(V=n==null?void 0:n.onCleanupEnd)==null||V.call(n)}},y);a.wait&&await a.wait();const c=z.fromState(f.state,{config:T,from:f.from,to:f.to});t={controller:c,direction:"out"},(b=a.onReady)==null||b.call(a),await B(),f.direction==="forward"?c.forward():c.backward();function g(){!r||!i||(o&&r.contains(o)?r.insertBefore(i,o):r.appendChild(i))}};let h=null,v=!1;const A=y=>()=>{if(v)return;v=!0;const p=y.cloneNode(!0);h?queueMicrotask(()=>{document.contains(h)&&u(p)}):u(p)};return y=>{if(y)return requestAnimationFrame(()=>{r=y.parentElement,o=y.nextElementSibling}),v=!1,(n==null?void 0:n.scope)==="local"?queueMicrotask(()=>{h=nt(y),!(h&&!it(h))&&l(y)}):l(y),A(y)}}const I=new Map;let P=null,q=!1;function rt(e){if(e instanceof HTMLElement&&I.has(e)){const t=I.get(e);I.delete(e),queueMicrotask(()=>{t()})}const n=e.childNodes;for(let t=0;t<n.length;t++){const i=n[t];i&&rt(i)}}function Ct(){q||typeof document>"u"||(q=!0,P=new MutationObserver(e=>{for(const n of e){const t=n.removedNodes;for(let i=0;i<t.length;i++){const r=t[i];r&&rt(r)}}}),document.body?P.observe(document.body,{childList:!0,subtree:!0}):document.addEventListener("DOMContentLoaded",()=>{P==null||P.observe(document.body,{childList:!0,subtree:!0})},{once:!0}))}function ot(e,n){Ct(),I.set(e,n)}function bt(e){return I.has(e)}function Rt(){return I.size}function kt(e){const n=I.get(e);return n?(I.delete(e),n(),!0):!1}function Mt(){I.clear(),P==null||P.disconnect(),P=null,q=!1}const O=new Map,N=new Map,W=new Map;function Pt(e,n,t){O.set(e,n);let i=N.get(e);if(i)return i;const r=n;return i=Et(()=>{const o=O.get(e);return o||(console.warn(`Transition "${String(e)}" not found`),{})},{strategy:t==null?void 0:t.strategy,scope:t==null?void 0:t.scope,onCleanupEnd:()=>{O.get(e)===r&&It(e)}}),N.set(e,i),i}function It(e){O.delete(e),N.delete(e),W.delete(e)}function Vt(e,n="manual"){const t=Pt(e.key,{in:e.in,out:e.out},{strategy:e[H],scope:e.scope});if(n==="manual")return t;let i=W.get(e.key);return i||(i=r=>{if(r){const o=t(r);o&&ot(r,o)}},W.set(e.key,i),i)}function Ft(e){const n=e.filter(t=>t.symmetric).map(t=>({from:t.to,to:t.from,transition:t.transition}));return[...e,...n]}function F(e,n){if(n==="*")return!0;if(n.endsWith("/*")){const t=n.slice(0,-1);return e.startsWith(t)&&e.length>t.length}return e===n}function xt(e,n,t){for(const i of t)if(F(e,i.from)&&F(n,i.to))return i.transition;for(const i of t)if((i.from==="*"||F(e,i.from))&&(i.to==="*"||F(n,i.to)))return i.transition;return null}const Lt=768,Ot=10,zt=10;function Dt(e={}){const{preserveScroll:n=c=>c}=e,t=typeof n=="function"?n:()=>n;let i=null,r=!1,o=!1;const s=()=>{const c=(i==null?void 0:i.clientWidth)??0,g=c>0?c:typeof window<"u"?window.innerWidth:0;return g>0&&g<Lt},m=()=>(o||(r=s(),o=!0),r),l=c=>{const g=t(m());return g===!1?!1:g===!0?!0:!g.exclude.some(E=>F(c,E))};let u=null;const h=new Map;let v=null,A=!1,S=0;const y=()=>{i&&v&&!A&&h.set(v,{x:i.scrollLeft,y:i.scrollTop})},p=c=>{if(!i)return;const g=l(c)&&h.has(c)?h.get(c):{x:0,y:0};let E=0;const b=()=>{if(!i)return;i.scrollTo({top:g.y,left:g.x}),!(Math.abs(i.scrollTop-g.y)<1&&Math.abs(i.scrollLeft-g.x)<1)&&E<Ot&&(E++,requestAnimationFrame(b))};requestAnimationFrame(b)};return{initializeContext:(c,g)=>{A=!0;const E=++S;u=c,i||(i=At(c),r=s(),o=!0,typeof ResizeObserver<"u"&&new ResizeObserver(()=>{r=s()}).observe(i),(i===document.documentElement?window:i).addEventListener("scroll",y,{passive:!0})),v=g,p(g);let b=0;const M=()=>{E===S&&(b++,b>=zt?A=!1:requestAnimationFrame(M))};requestAnimationFrame(M)},calculateScrollOffset:(c,g)=>{const E=c&&h.has(c)?h.get(c):{x:0,y:0},b=g&&l(g)&&h.has(g)?h.get(g):{x:0,y:0};return{x:-b.x+E.x,y:-b.y+E.y}},evictScrollPosition:c=>{h.delete(c)},shouldPreserve:l,getScrollContainer:()=>i,getPositionedParentElement:()=>u?Tt(u):document.body,getScrollPosition:c=>c&&h.has(c)?h.get(c):{x:0,y:0}}}const G=30,$=8,Z=1.2,J=30,_t=600;function qt(){let e=null,n=!1,t=!1,i=null,r=null,o=!1;const s=(w,f)=>{for(let a=0;a<w.length;a++){const T=w.item(a);if(T&&T.identifier===f)return T}return null},m=()=>{i!==null&&(clearTimeout(i),i=null)},l=()=>{r!==null&&(clearTimeout(r),r=null)},u=()=>{n=!0,t=!0,m(),l(),i=setTimeout(()=>{n=!1,t=!1,i=null},_t)},h=w=>{if(w.touches.length!==1){e=null;return}const f=w.touches.item(0);if(!f){e=null;return}const a=window.innerWidth,T=f.clientX<=G,c=f.clientX>=a-G;if(!T&&!c){e=null;return}e={identifier:f.identifier,startX:f.clientX,startY:f.clientY,fromLeftEdge:T,moved:!1}},v=w=>{if(!e)return;if(w.touches.length!==1){e=null;return}const f=s(w.touches,e.identifier);if(!f){e=null;return}const a=f.clientX-e.startX,T=f.clientY-e.startY,c=Math.abs(a),g=Math.abs(T);if(g>$&&g>c*Z){e=null;return}const E=e.fromLeftEdge?a>0:a<0;c>$&&c>g*Z&&E&&(e.moved=!0)},A=w=>{if(!e)return;const f=s(w.changedTouches,e.identifier);if(!f){e=null;return}const a=f.clientX-e.startX,T=e.fromLeftEdge?a>0:a<0;if(e.moved&&T&&Math.abs(a)>=J){u(),e=null;return}e.moved&&Math.abs(a)>=J&&u(),e=null},S=()=>{e&&(e.moved&&u(),e=null)};return{initialize:()=>{if(typeof window>"u"||o)return;o=!0;const w={passive:!0,capture:!0};window.addEventListener("touchstart",h,w),window.addEventListener("touchmove",v,w),window.addEventListener("touchend",A,w),window.addEventListener("touchcancel",S,w)},destroy:()=>{if(typeof window>"u"||!o)return;o=!1;const w={capture:!0};window.removeEventListener("touchstart",h,w),window.removeEventListener("touchmove",v,w),window.removeEventListener("touchend",A,w),window.removeEventListener("touchcancel",S,w),m(),l(),e=null,n=!1,t=!1},isSwipeBack:()=>{const w=n||t;return w&&m(),w},onPageEnter:()=>{n=!1,m(),l(),r=setTimeout(()=>{t=!1,r=null},0)}}}function st(){let e=null;function n(){if(e!=null&&e.from&&(e!=null&&e.to)&&(e!=null&&e.outResolve)&&(e!=null&&e.inResolve)){const t={from:e.from,to:e.to};e.outResolve(t),e.inResolve(t),e=null}}return{trigger(t,i){e||(e={}),i==="out"?e.from=t:e.to=t},get(t){return t==="in"&&(!e||!e.from)?Promise.resolve(null):new Promise(i=>{e||(e={}),t==="out"?e.outResolve=i:e.inResolve=i,n()})}}}function at(){let e=null;function n(){var i,r;e&&((i=e.outResolve)==null||i.call(e,null),(r=e.inResolve)==null||r.call(e,null),e=null)}function t(){if(e!=null&&e.from&&(e!=null&&e.to)&&(e!=null&&e.outResolve)&&(e!=null&&e.inResolve)){if(e.from===e.to){n();return}const i={from:e.from,to:e.to};e.outResolve(i),e.inResolve(i),e=null}}return{trigger(i,r){e&&(r==="out"&&e.from&&e.from!==i||r==="in"&&e.to&&e.to!==i)&&n(),e||(e={}),r==="out"?e.from=i:e.to=i},get(i){return new Promise(r=>{e||(e={}),i==="out"?e.outResolve=r:e.inResolve=r,t()})}}}function Nt(e,n){const{transitions:t=[],defaultTransition:i,middleware:r=(f,a)=>({from:f,to:a}),preserveScroll:o=f=>f}=e,{outFirst:s=!0}=n||{},m=s?st():at(),l=Ft(t),u=qt();u.initialize();const{initializeContext:h,calculateScrollOffset:v,evictScrollPosition:A,shouldPreserve:S,getScrollContainer:y,getPositionedParentElement:p,getScrollPosition:R}=Dt({preserveScroll:o}),C=async(f,a)=>{const T=u.isSwipeBack();m.trigger(f,a);const c=await m.get(a);if(a==="in"&&u.onPageEnter(),!c)return()=>({});if(T)return a==="out"&&c.from&&!S(c.from)&&A(c.from),()=>({});const{from:g,to:E}=r(c.from,c.to),M=xt(g,E,l)||i;if(!M)return()=>({});const V=v(c.from,c.to);if(a==="out"){const x={scrollOffset:V,scroll:R(c.from),get scrollingElement(){return y()||document.documentElement},get positionedParent(){return p()}};return c.from&&!S(c.from)&&A(c.from),D=>M.out(D,x)}else{const x={scrollOffset:V,get scroll(){return R(c.to)},get scrollingElement(){return y()||document.documentElement},get positionedParent(){return p()}};return D=>M.in(D,x)}};return f=>({key:f,in:async a=>(h(a,f),(await C(f,"in"))(a)),out:async a=>(await C(f,"out"))(a),[H]:et})}exports.isCssAnimation=k.isCssAnimation;exports.isKeyframesAnimation=k.isKeyframesAnimation;exports.isMultiAnimation=k.isMultiAnimation;exports.isSingleAnimation=k.isSingleAnimation;exports.isTickAnimation=k.isTickAnimation;exports.normalizeSchedule=k.normalizeSchedule;exports.normalizeToMultiAnimation=k.normalizeToMultiAnimation;exports.SCOPE_ATTR=U;exports.SCOPE_READY_ATTR=K;exports.TRANSITION_STRATEGY=H;exports.createAnyOrderDetector=at;exports.createDefaultStrategy=tt;exports.createOutFirstDetector=st;exports.createPageTransitionStrategy=et;exports.createSggoiTransitionContext=Nt;exports.createTransitionScope=St;exports.findScope=nt;exports.getWatchedCount=Rt;exports.isScopeReady=it;exports.isWatched=bt;exports.resetObserver=Mt;exports.transition=Vt;exports.triggerUnmount=kt;exports.watchUnmount=ot;
1
+ "use strict";var lt=Object.defineProperty;var ut=(e,i,t)=>i in e?lt(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t;var d=(e,i,t)=>ut(e,typeof i!="symbol"?i+"":i,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("./types.cjs"),W=require("./spring-integrator-95Mh7mdw.cjs"),ft=require("./provider-BKaONTeg.cjs");class mt{constructor(){d(this,"listeners",new Set);d(this,"rafId",null);d(this,"isRunning",!1);d(this,"startTime",Date.now());d(this,"lastUpdate",this.startTime);d(this,"elapsed",0);d(this,"lagThreshold",500);d(this,"adjustedLag",33);d(this,"maxDeltaTime",33);d(this,"gap",1e3/240);d(this,"nextTime",this.gap);d(this,"tick",()=>{const i=Date.now();let n=i-this.lastUpdate;n>this.lagThreshold||n<0?(this.startTime+=n-this.adjustedLag,n=this.adjustedLag):n>this.maxDeltaTime&&(n=this.maxDeltaTime),this.lastUpdate=i;const r=i-this.startTime,o=r-this.nextTime;if(o>0){const s=n/1e3;this.elapsed=r/1e3,this.nextTime+=o+(o>=this.gap?4:this.gap-o),this.listeners.forEach(m=>{m(s,this.elapsed)})}this.listeners.size>0?this.rafId=requestAnimationFrame(this.tick):(this.isRunning=!1,this.rafId=null)})}subscribe(i){return this.listeners.add(i),this.isRunning||(this.isRunning=!0,this.rafId=requestAnimationFrame(this.tick)),()=>{this.unsubscribe(i)}}unsubscribe(i){this.listeners.delete(i),this.listeners.size===0&&this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.isRunning=!1,this.rafId=null)}lagSmoothing(i,t){this.lagThreshold=i,this.adjustedLag=Math.min(t,i)}fps(i){this.gap=1e3/i,this.nextTime=this.elapsed*1e3+this.gap}getListenerCount(){return this.listeners.size}getElapsed(){return this.elapsed}}const D=new mt;function dt(e){const{integrator:i,from:t,to:n,velocity:r=0,onUpdate:o,onComplete:s,onStart:m}=e;let l={position:t,velocity:r},u=!0,h=0,v=!1;const A=S=>{if(u){if(v||(v=!0,m==null||m()),l=i.step(l,n,S),i.isSettled(l,n)){if(h+=Math.min(S,.033),h>=W.SETTLE_THRESHOLD){l={position:n,velocity:0},u=!1,o(l.position),D.unsubscribe(A),s();return}}else h=0;o(l.position)}};return D.subscribe(A),{stop:()=>{u&&(u=!1,D.unsubscribe(A))},getPosition:()=>l.position,getVelocity:()=>l.velocity,isRunning:()=>u}}const L=1e3/60;function ht(e,i,t,n=0){let o={position:i,velocity:n},s=0;const m=[];for(let l=0;l<600;l++){const u=l*L;if(m.push({time:u,position:o.position,velocity:o.velocity}),o=e.step(o,t,L/1e3),e.isSettled(o,t)){if(s+=L/1e3,s>=W.SETTLE_THRESHOLD){m.push({time:(l+1)*L,position:t,velocity:0});break}}else s=0}return m}function Y(e,i){if(e.length===0)return{position:0,velocity:0};const t=e[0],n=e[e.length-1];if(i<=0)return{position:t.position,velocity:t.velocity};if(i>=n.time)return{position:n.position,velocity:n.velocity};let r=0,o=e.length-1;for(;r<o-1;){const u=Math.floor((r+o)/2);e[u].time<=i?r=u:o=u}const s=e[r],m=e[o],l=(i-s.time)/(m.time-s.time);return{position:s.position+(m.position-s.position)*l,velocity:s.velocity+(m.velocity-s.velocity)*l}}function gt(e,i){return e.map(t=>i(t.position))}function yt(e){const{integrator:i,element:t,from:n,to:r,velocity:o=0,style:s,onComplete:m,onStart:l}=e,u=ht(i,n,r,o);if(u.length===0)return l==null||l(),m(),{stop:()=>{},getPosition:()=>r,getVelocity:()=>0,isRunning:()=>!1};const h=gt(u,s),v=u[u.length-1],A=v.time,S=h[0];if(S)for(const C of Object.keys(S))t.style[C]="";const y=t.animate(h,{duration:A,fill:"forwards",easing:"linear",composite:"replace"});let p=!0;const R=performance.now();return l==null||l(),y.onfinish=()=>{p&&(p=!1,m())},{stop:()=>{p&&(p=!1,y.cancel())},getPosition:()=>{if(!p)return v.position;const C=performance.now()-R;return Y(u,C).position},getVelocity:()=>{if(!p)return 0;const C=performance.now()-R;return Y(u,C).velocity},isRunning:()=>p}}function wt(e){const{element:i,frames:t,duration:n,easing:r="linear",from:o,to:s,onComplete:m,onStart:l}=e,u=t[0];if(u)for(const S of Object.keys(u))S==="offset"||S==="easing"||S==="composite"||(i.style[S]="");const h=i.animate(t,{duration:n,fill:"forwards",easing:r,composite:"replace"});let v=!0;const A=performance.now();return l==null||l(),h.onfinish=()=>{v&&(v=!1,m())},{stop:()=>{v&&(v=!1,h.cancel())},getPosition:()=>{if(!v)return s;const S=performance.now()-A,y=Math.min(Math.max(S/n,0),1);return o+(s-o)*y},getVelocity:()=>0,isRunning:()=>v}}function pt(e){const{to:i,onStart:t,onComplete:n}=e;return t==null||t(),n(),{stop:()=>{},getPosition:()=>i,getVelocity:()=>0,isRunning:()=>!1}}class vt{static from(i){const{tick:t,css:n,keyframes:r}=i;if((t?1:0)+(n?1:0)+(r?1:0)>1)throw new Error("Cannot use more than one of 'tick', 'css', 'keyframes' together");return r?s=>wt({element:r.element,frames:r.frames,duration:r.duration,easing:r.easing,from:s.from,to:s.to,onComplete:s.onComplete,onStart:s.onStart}):n?s=>{if(!s.integrator)throw new Error("css mode requires an integrator");return yt({integrator:s.integrator,from:s.from,to:s.to,velocity:s.velocity,onComplete:s.onComplete,onStart:s.onStart,element:n.element,style:n.style})}:t?s=>{if(!s.integrator)throw new Error("tick mode requires an integrator");return dt({integrator:s.integrator,from:s.from,to:s.to,velocity:s.velocity,onComplete:s.onComplete,onStart:s.onStart,onUpdate:t})}:pt}}class tt{}const St={stiffness:300,damping:30};class j extends tt{constructor(t){super();d(this,"options");d(this,"runner");d(this,"controls",null);d(this,"isAnimating",!1);d(this,"currentValue");d(this,"currentVelocity",0);d(this,"updateFn");d(this,"isKeyframesMode");if(this.options={from:t.from??0,to:t.to??1,physics:t.physics,onComplete:t.onComplete??(()=>{}),onStart:t.onStart},this.currentValue=this.options.from,this.isKeyframesMode=!!t.keyframes,t.tick)this.updateFn=n=>{var r;return(r=t.tick)==null?void 0:r.call(t,n)};else if(t.css){const{element:n,style:r}=t.css;this.updateFn=o=>{const s=r(o);for(const[m,l]of Object.entries(s))n.style[m]=typeof l=="number"?String(l):l}}else this.updateFn=()=>{};this.runner=vt.from({tick:t.tick,css:t.css,keyframes:t.keyframes})}syncState(){var t;(t=this.updateFn)==null||t.call(this,this.currentValue)}createIntegrator(){const t=this.options.physics;return t!=null&&t.integrator?t.integrator():t!=null&&t.spring||t!=null&&t.inertia?ft.IntegratorProvider.from({spring:t.spring,inertia:t.inertia}):new W.SpringIntegrator(St)}runAnimation(t){this.isAnimating=!0,this.controls=this.runner({integrator:this.isKeyframesMode?void 0:this.createIntegrator(),from:this.currentValue,to:t,velocity:this.currentVelocity,onStart:this.options.onStart,onComplete:()=>{this.currentValue=t,this.currentVelocity=0,this.isAnimating=!1,this.controls=null,this.options.onComplete()}})}forward(){this.stop(),this.runAnimation(this.options.to)}backward(){this.stop(),this.runAnimation(this.options.from)}reverse(){const t=this.options.from;this.options.from=this.options.to,this.options.to=t,this.isAnimating&&(this.stop(),this.runAnimation(this.options.to))}stop(){this.controls&&(this.currentValue=this.controls.getPosition(),this.currentVelocity=this.controls.getVelocity(),this.controls.stop(),this.controls=null),this.isAnimating=!1}getVelocity(){var t;return((t=this.controls)==null?void 0:t.getVelocity())??this.currentVelocity}getCurrentValue(){var t;return((t=this.controls)==null?void 0:t.getPosition())??this.currentValue}getIsAnimating(){return this.isAnimating}getCurrentState(){return{position:this.getCurrentValue(),velocity:this.getVelocity(),from:this.options.from,to:this.options.to}}setValue(t){this.currentValue=t}setVelocity(t){this.currentVelocity=t}updateOptions(t){this.options={...this.options,...t}}}class z extends tt{constructor(t){super();d(this,"config");d(this,"animators",new Map);d(this,"itemOrder",[]);d(this,"completedCount",0);d(this,"completedAnimators",new Set);d(this,"direction","forward");d(this,"idCounter",0);d(this,"rafId",null);d(this,"from");d(this,"to");d(this,"initialState");this.config=t.config,this.from=t.from,this.to=t.to,this.initialState=t.state??{position:t.from,velocity:0},this.initializeAnimators()}generateId(){return`spring_${this.idCounter++}`}initializeAnimators(){this.config.items.forEach((t,n)=>{const r=this.generateId(),o=new j({from:this.from,to:this.to,physics:t.physics,tick:t.tick,css:t.css,keyframes:t.keyframes,onComplete:()=>this.onAnimatorComplete(r),onStart:t.onStart});(n===0||t.normalizedOffset===0)&&(o.setValue(this.initialState.position),o.setVelocity(this.initialState.velocity),o.syncState()),this.animators.set(r,{id:r,item:t,animator:o,started:!1}),this.itemOrder.push(r)})}getAnimatorProgress(t){const n=t.animator.getCurrentState(),r=Math.abs(n.to-n.from);return r===0?1:Math.abs(n.position-n.from)/r}getOrderedIds(){return this.direction==="forward"?this.itemOrder:[...this.itemOrder].reverse()}onAnimatorComplete(t){var r,o,s,m,l,u;const n=this.animators.get(t);!n||this.completedAnimators.has(t)||(this.completedAnimators.add(t),this.completedCount++,(o=(r=n.item).onComplete)==null||o.call(r),(m=(s=this.config).onProgress)==null||m.call(s,this.completedCount,this.config.items.length),this.completedCount===this.config.items.length&&(this.stopScheduler(),(u=(l=this.config).onEnd)==null||u.call(l)))}checkAndStartSprings(){const t=this.getOrderedIds();for(let n=0;n<t.length;n++){const r=t[n],o=this.animators.get(r);if(!o||o.started)continue;if(n===0){this.startAnimator(r);continue}const s=t[n-1],m=this.animators.get(s);if(!m||!m.started)continue;const l=this.getAnimatorProgress(m),u=o.item.normalizedOffset;l>=u&&this.startAnimator(r)}}startAnimator(t){const n=this.animators.get(t);!n||n.started||(n.started=!0,this.direction==="forward"?n.animator.forward():n.animator.backward())}startScheduler(){const t=()=>{this.checkAndStartSprings(),this.getIsAnimating()&&(this.rafId=requestAnimationFrame(t))};t()}stopScheduler(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}getFirstAnimator(){var n;const t=this.itemOrder[0];return t?((n=this.animators.get(t))==null?void 0:n.animator)??null:null}forward(){var t,n;this.stop(),this.direction="forward",this.completedCount=0,this.completedAnimators.clear(),this.resetStartedFlags(),(n=(t=this.config).onStart)==null||n.call(t),this.startScheduler()}backward(){var t,n;this.stop(),this.direction="backward",this.completedCount=0,this.completedAnimators.clear(),this.resetStartedFlags(),(n=(t=this.config).onStart)==null||n.call(t),this.startScheduler()}resetStartedFlags(){this.animators.forEach(t=>{t.started=!1})}stop(){this.stopScheduler(),this.animators.forEach(t=>{t.animator.stop(),t.started=!1})}reverse(){this.direction=this.direction==="forward"?"backward":"forward",this.animators.forEach(t=>{if(!t.started)return;const n=t.animator.getCurrentState();if(n.position===n.to){const o=new j({from:this.to,to:this.from,physics:t.item.physics,tick:t.item.tick,css:t.item.css,keyframes:t.item.keyframes,onComplete:()=>this.onAnimatorComplete(t.id),onStart:t.item.onStart});o.setValue(this.to),o.setVelocity(0),o.syncState(),o.forward(),t.animator=o}else t.animator.reverse()})}getCurrentState(){const t=this.getFirstAnimator();return t?t.getCurrentState():{position:0,velocity:0,from:0,to:1}}getCurrentValue(){const t=this.getFirstAnimator();return(t==null?void 0:t.getCurrentValue())??0}getVelocity(){const t=this.getFirstAnimator();return(t==null?void 0:t.getVelocity())??0}setValue(t){const n=this.getFirstAnimator();n==null||n.setValue(t)}setVelocity(t){const n=this.getFirstAnimator();n==null||n.setVelocity(t)}getIsAnimating(){for(const t of this.animators.values())if(t.animator.getIsAnimating())return!0;return!1}static fromState(t,n){return new z({...n,state:t})}}const U=Symbol.for("TRANSITION_STRATEGY"),et=e=>({runIn:async i=>{const{currentAnimation:t}=e;if(t&&t.direction==="out"){const r=t.controller.getCurrentValue(),o=t.controller.getVelocity();if(t.controller.stop(),i.out)return{config:await i.out,state:{position:r,velocity:o},from:1,to:0,direction:"backward"}}return i.in?{config:await i.in,state:{position:0,velocity:0},from:0,to:1,direction:"forward"}:{state:{position:0,velocity:0},from:0,to:1,direction:"forward"}},runOut:async i=>{const{currentAnimation:t}=e;if(t&&t.direction==="in"){const r=t.controller.getCurrentValue(),o=t.controller.getVelocity();if(t.controller.stop(),i.in)return{config:await i.in,state:{position:r,velocity:o},from:0,to:1,direction:"backward"}}return i.out?{config:await i.out,state:{position:1,velocity:0},from:1,to:0,direction:"forward"}:{state:{position:1,velocity:0},from:1,to:0,direction:"forward"}}}),nt=()=>({runIn:async e=>e.in?{config:await e.in,state:{position:0,velocity:0},from:0,to:1,direction:"forward"}:{state:{position:0,velocity:0},from:0,to:1,direction:"forward"},runOut:async e=>e.out?{config:await e.out,state:{position:1,velocity:0},from:1,to:0,direction:"forward"}:{state:{position:1,velocity:0},from:1,to:0,direction:"forward"}}),H="data-ssgoi-scope",K="data-ssgoi-scope-ready";function At(){return e=>{if(e)return e.setAttribute(H,""),queueMicrotask(()=>{queueMicrotask(()=>{e.setAttribute(K,"true")})}),()=>{}}}function it(e){return e.hasAttribute(K)}function rt(e){return e.closest(`[${H}]`)}const B=new Set(["auto","scroll","overlay"]),Tt=e=>{let i=e.parentElement;for(;i&&i!==document.body;){const t=window.getComputedStyle(i);if(B.has(t.overflowY)||B.has(t.overflowX))return i;i=i.parentElement}return document.documentElement},Et=e=>{let i=e.parentElement;for(;i&&i!==document.body;){const t=window.getComputedStyle(i).position;if(t==="relative"||t==="absolute"||t==="fixed"||t==="sticky")return i;i=i.parentElement}return document.body};function G(e){return new Promise(i=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{i()})})})}function Ct(e,i){var S;let t=null,n=null,r=null,o=null;const s={get currentAnimation(){return t}},m=((S=i==null?void 0:i.strategy)==null?void 0:S.call(i,s))||et(s),l=async y=>{var g,E;n&&(n.remove(),n=null);const p=e(),R=p.in&&p.in(y),C=!(i!=null&&i.strategy)&&p.out?p.out(y):void 0;if(!R)return;const w={in:k.normalizeToMultiAnimation(R),out:C?k.normalizeToMultiAnimation(C):void 0},f=await m.runIn(w);if(!f.config){t&&(t.direction="in");return}const a=f.config;(g=a.prepare)==null||g.call(a);const T=k.normalizeSchedule({...a,onEnd:()=>{var b;t=null,(b=a.onEnd)==null||b.call(a)}},y);a.wait&&await a.wait();const c=z.fromState(f.state,{config:T,from:f.from,to:f.to});t={controller:c,direction:"in"},(E=a.onReady)==null||E.call(a),await G(),f.direction==="forward"?c.forward():c.backward()},u=async y=>{var E,b;n=y;const p=e(),R=!(i!=null&&i.strategy)&&p.in?p.in(y):void 0,C=p.out&&p.out(y);if(!C)return;const w={in:R?k.normalizeToMultiAnimation(R):void 0,out:k.normalizeToMultiAnimation(C)},f=await m.runOut(w);if(!f.config){t&&(t.direction="out"),n&&(n.remove(),n=null);return}const a=f.config;g(),(E=a.prepare)==null||E.call(a);const T=k.normalizeSchedule({...a,onEnd:()=>{var M,V;(M=a.onEnd)==null||M.call(a),n&&(n.remove(),n=null),t=null,(V=i==null?void 0:i.onCleanupEnd)==null||V.call(i)}},y);a.wait&&await a.wait();const c=z.fromState(f.state,{config:T,from:f.from,to:f.to});t={controller:c,direction:"out"},(b=a.onReady)==null||b.call(a),await G(),f.direction==="forward"?c.forward():c.backward();function g(){!r||!n||(o&&r.contains(o)?r.insertBefore(n,o):r.appendChild(n))}};let h=null,v=!1;const A=y=>()=>{if(v)return;v=!0;const p=y.cloneNode(!0);h?queueMicrotask(()=>{document.contains(h)&&u(p)}):u(p)};return y=>{if(y)return requestAnimationFrame(()=>{r=y.parentElement,o=y.nextElementSibling}),v=!1,(i==null?void 0:i.scope)==="local"?queueMicrotask(()=>{h=rt(y),!(h&&!it(h))&&l(y)}):l(y),A(y)}}const I=new Map;let P=null,q=!1;function ot(e){if(e instanceof HTMLElement&&I.has(e)){const t=I.get(e);I.delete(e),queueMicrotask(()=>{t()})}const i=e.childNodes;for(let t=0;t<i.length;t++){const n=i[t];n&&ot(n)}}function bt(){q||typeof document>"u"||(q=!0,P=new MutationObserver(e=>{for(const i of e){const t=i.removedNodes;for(let n=0;n<t.length;n++){const r=t[n];r&&ot(r)}}}),document.body?P.observe(document.body,{childList:!0,subtree:!0}):document.addEventListener("DOMContentLoaded",()=>{P==null||P.observe(document.body,{childList:!0,subtree:!0})},{once:!0}))}function st(e,i){bt(),I.set(e,i)}function Rt(e){return I.has(e)}function kt(){return I.size}function Mt(e){const i=I.get(e);return i?(I.delete(e),i(),!0):!1}function Pt(){I.clear(),P==null||P.disconnect(),P=null,q=!1}const O=new Map,N=new Map,X=new Map;function It(e,i,t){O.set(e,i);let n=N.get(e);if(n)return n;const r=i;return n=Ct(()=>{const o=O.get(e);return o||(console.warn(`Transition "${String(e)}" not found`),{})},{strategy:t==null?void 0:t.strategy,scope:t==null?void 0:t.scope,onCleanupEnd:()=>{O.get(e)===r&&Vt(e)}}),N.set(e,n),n}function Vt(e){O.delete(e),N.delete(e),X.delete(e)}function Ft(e,i="manual"){const t=It(e.key,{in:e.in,out:e.out},{strategy:e[U],scope:e.scope});if(i==="manual")return t;let n=X.get(e.key);return n||(n=r=>{if(r){const o=t(r);o&&st(r,o)}},X.set(e.key,n),n)}function xt(e){const i=e.filter(t=>t.symmetric).map(t=>({from:t.to,to:t.from,transition:t.transition}));return[...e,...i]}function F(e,i){if(i==="*")return!0;if(i.endsWith("/*")){const t=i.slice(0,-1);return e.startsWith(t)&&e.length>t.length}return e===i}function Lt(e,i,t){for(const n of t)if(F(e,n.from)&&F(i,n.to))return n.transition;for(const n of t)if((n.from==="*"||F(e,n.from))&&(n.to==="*"||F(i,n.to)))return n.transition;return null}const Ot=768,zt=10,_t=10;function Dt(e={}){const{preserveScroll:i=c=>c}=e,t=typeof i=="function"?i:()=>i;let n=null,r=!1,o=!1;const s=()=>{const c=(n==null?void 0:n.clientWidth)??0,g=c>0?c:typeof window<"u"?window.innerWidth:0;return g>0&&g<Ot},m=()=>(o||(r=s(),o=!0),r),l=c=>{const g=t(m());return g===!1?!1:g===!0?!0:!g.exclude.some(E=>F(c,E))};let u=null;const h=new Map;let v=null,A=!1,S=0;const y=()=>{n&&v&&!A&&h.set(v,{x:n.scrollLeft,y:n.scrollTop})},p=c=>{if(!n)return;const g=l(c)&&h.has(c)?h.get(c):{x:0,y:0};let E=0;const b=()=>{if(!n)return;n.scrollTo({top:g.y,left:g.x}),!(Math.abs(n.scrollTop-g.y)<1&&Math.abs(n.scrollLeft-g.x)<1)&&E<zt&&(E++,requestAnimationFrame(b))};requestAnimationFrame(b)};return{initializeContext:(c,g)=>{A=!0;const E=++S;u=c,n||(n=Tt(c),r=s(),o=!0,typeof ResizeObserver<"u"&&new ResizeObserver(()=>{r=s()}).observe(n),(n===document.documentElement?window:n).addEventListener("scroll",y,{passive:!0})),v=g,p(g);let b=0;const M=()=>{E===S&&(b++,b>=_t?A=!1:requestAnimationFrame(M))};requestAnimationFrame(M)},calculateScrollOffset:(c,g)=>{const E=c&&h.has(c)?h.get(c):{x:0,y:0},b=g&&l(g)&&h.has(g)?h.get(g):{x:0,y:0};return{x:-b.x+E.x,y:-b.y+E.y}},evictScrollPosition:c=>{h.delete(c)},shouldPreserve:l,getScrollContainer:()=>n,getPositionedParentElement:()=>u?Et(u):document.body,getScrollPosition:c=>c&&h.has(c)?h.get(c):{x:0,y:0}}}const $=30,Z=8,J=1.2,Q=30,qt=600;function Nt(){let e=null,i=!1,t=!1,n=null,r=null,o=!1;const s=(w,f)=>{for(let a=0;a<w.length;a++){const T=w.item(a);if(T&&T.identifier===f)return T}return null},m=()=>{n!==null&&(clearTimeout(n),n=null)},l=()=>{r!==null&&(clearTimeout(r),r=null)},u=()=>{i=!0,t=!0,m(),l(),n=setTimeout(()=>{i=!1,t=!1,n=null},qt)},h=w=>{if(w.touches.length!==1){e=null;return}const f=w.touches.item(0);if(!f){e=null;return}const a=window.innerWidth,T=f.clientX<=$,c=f.clientX>=a-$;if(!T&&!c){e=null;return}e={identifier:f.identifier,startX:f.clientX,startY:f.clientY,fromLeftEdge:T,moved:!1}},v=w=>{if(!e)return;if(w.touches.length!==1){e=null;return}const f=s(w.touches,e.identifier);if(!f){e=null;return}const a=f.clientX-e.startX,T=f.clientY-e.startY,c=Math.abs(a),g=Math.abs(T);if(g>Z&&g>c*J){e=null;return}const E=e.fromLeftEdge?a>0:a<0;c>Z&&c>g*J&&E&&(e.moved=!0)},A=w=>{if(!e)return;const f=s(w.changedTouches,e.identifier);if(!f){e=null;return}const a=f.clientX-e.startX,T=e.fromLeftEdge?a>0:a<0;if(e.moved&&T&&Math.abs(a)>=Q){u(),e=null;return}e.moved&&Math.abs(a)>=Q&&u(),e=null},S=()=>{e&&(e.moved&&u(),e=null)};return{initialize:()=>{if(typeof window>"u"||o)return;o=!0;const w={passive:!0,capture:!0};window.addEventListener("touchstart",h,w),window.addEventListener("touchmove",v,w),window.addEventListener("touchend",A,w),window.addEventListener("touchcancel",S,w)},destroy:()=>{if(typeof window>"u"||!o)return;o=!1;const w={capture:!0};window.removeEventListener("touchstart",h,w),window.removeEventListener("touchmove",v,w),window.removeEventListener("touchend",A,w),window.removeEventListener("touchcancel",S,w),m(),l(),e=null,i=!1,t=!1},isSwipeBack:()=>{const w=i||t;return w&&m(),w},onPageEnter:()=>{i=!1,m(),l(),r=setTimeout(()=>{t=!1,r=null},0)}}}function at(){let e=null;function i(){if(e!=null&&e.from&&(e!=null&&e.to)&&(e!=null&&e.outResolve)&&(e!=null&&e.inResolve)){const t={from:e.from,to:e.to};e.outResolve(t),e.inResolve(t),e=null}}return{trigger(t,n){e||(e={}),n==="out"?e.from=t:e.to=t},get(t){return t==="in"&&(!e||!e.from)?Promise.resolve(null):new Promise(n=>{e||(e={}),t==="out"?e.outResolve=n:e.inResolve=n,i()})}}}function ct(){let e=null;function i(){var n,r;e&&((n=e.outResolve)==null||n.call(e,null),(r=e.inResolve)==null||r.call(e,null),e=null)}function t(){if(e!=null&&e.from&&(e!=null&&e.to)&&(e!=null&&e.outResolve)&&(e!=null&&e.inResolve)){if(e.from===e.to){i();return}const n={from:e.from,to:e.to};e.outResolve(n),e.inResolve(n),e=null}}return{trigger(n,r){e&&(r==="out"&&e.from&&e.from!==n||r==="in"&&e.to&&e.to!==n)&&i(),e||(e={}),r==="out"?e.from=n:e.to=n},get(n){return new Promise(r=>{e||(e={}),n==="out"?e.outResolve=r:e.inResolve=r,t()})}}}function Xt(e,i){const{transitions:t=[],defaultTransition:n,middleware:r=(f,a)=>({from:f,to:a}),preserveScroll:o=f=>f}=e,{outFirst:s=!0}=i||{},m=s?at():ct(),l=xt(t),u=Nt();u.initialize();const{initializeContext:h,calculateScrollOffset:v,evictScrollPosition:A,shouldPreserve:S,getScrollContainer:y,getPositionedParentElement:p,getScrollPosition:R}=Dt({preserveScroll:o}),C=async(f,a)=>{const T=u.isSwipeBack();m.trigger(f,a);const c=await m.get(a);if(a==="in"&&u.onPageEnter(),!c)return()=>({});if(T)return a==="out"&&c.from&&!S(c.from)&&A(c.from),()=>({});const{from:g,to:E}=r(c.from,c.to),M=Lt(g,E,l)||n;if(!M)return()=>({});const V=v(c.from,c.to);if(a==="out"){const x={scrollOffset:V,scroll:R(c.from),get scrollingElement(){return y()||document.documentElement},get positionedParent(){return p()}};return c.from&&!S(c.from)&&A(c.from),_=>M.out(_,x)}else{const x={scrollOffset:V,get scroll(){return R(c.to)},get scrollingElement(){return y()||document.documentElement},get positionedParent(){return p()}};return _=>M.in(_,x)}};return f=>({key:f,in:async a=>(h(a,f),(await C(f,"in"))(a)),out:async a=>(await C(f,"out"))(a),[U]:nt})}exports.isCssAnimation=k.isCssAnimation;exports.isKeyframesAnimation=k.isKeyframesAnimation;exports.isMultiAnimation=k.isMultiAnimation;exports.isSingleAnimation=k.isSingleAnimation;exports.isTickAnimation=k.isTickAnimation;exports.normalizeSchedule=k.normalizeSchedule;exports.normalizeToMultiAnimation=k.normalizeToMultiAnimation;exports.SCOPE_ATTR=H;exports.SCOPE_READY_ATTR=K;exports.TRANSITION_STRATEGY=U;exports.createAnyOrderDetector=ct;exports.createDefaultStrategy=et;exports.createOutFirstDetector=at;exports.createPageTransitionStrategy=nt;exports.createSggoiTransitionContext=Xt;exports.createTransitionScope=At;exports.findScope=rt;exports.getWatchedCount=kt;exports.isScopeReady=it;exports.isWatched=Rt;exports.resetObserver=Pt;exports.transition=Ft;exports.triggerUnmount=Mt;exports.watchUnmount=st;
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- var nt = Object.defineProperty;
2
- var it = (e, i, t) => i in e ? nt(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t;
3
- var d = (e, i, t) => it(e, typeof i != "symbol" ? i + "" : i, t);
1
+ var it = Object.defineProperty;
2
+ var rt = (e, i, t) => i in e ? it(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t;
3
+ var d = (e, i, t) => rt(e, typeof i != "symbol" ? i + "" : i, t);
4
4
  import { normalizeToMultiAnimation as F, normalizeSchedule as W } from "./types.js";
5
- import { isCssAnimation as Gt, isKeyframesAnimation as $t, isMultiAnimation as Zt, isSingleAnimation as Jt, isTickAnimation as Qt } from "./types.js";
6
- import { S as $, a as rt } from "./spring-integrator-BM4a-82c.js";
7
- import { I as ot } from "./provider-B2B8CK6H.js";
8
- class st {
5
+ import { isCssAnimation as $t, isKeyframesAnimation as Zt, isMultiAnimation as Jt, isSingleAnimation as Qt, isTickAnimation as te } from "./types.js";
6
+ import { S as Z, a as ot } from "./spring-integrator-BM4a-82c.js";
7
+ import { I as st } from "./provider-B2B8CK6H.js";
8
+ class at {
9
9
  constructor() {
10
10
  d(this, "listeners", /* @__PURE__ */ new Set());
11
11
  d(this, "rafId", null);
@@ -69,8 +69,8 @@ class st {
69
69
  return this.elapsed;
70
70
  }
71
71
  }
72
- const z = new st();
73
- function at(e) {
72
+ const z = new at();
73
+ function ct(e) {
74
74
  const {
75
75
  integrator: i,
76
76
  from: t,
@@ -81,11 +81,11 @@ function at(e) {
81
81
  onStart: m
82
82
  } = e;
83
83
  let l = { position: t, velocity: r }, u = !0, h = 0, v = !1;
84
- const A = (S) => {
84
+ const E = (S) => {
85
85
  if (u) {
86
86
  if (v || (v = !0, m == null || m()), l = i.step(l, n, S), i.isSettled(l, n)) {
87
- if (h += Math.min(S, 0.033), h >= $) {
88
- l = { position: n, velocity: 0 }, u = !1, o(l.position), z.unsubscribe(A), s();
87
+ if (h += Math.min(S, 0.033), h >= Z) {
88
+ l = { position: n, velocity: 0 }, u = !1, o(l.position), z.unsubscribe(E), s();
89
89
  return;
90
90
  }
91
91
  } else
@@ -93,9 +93,9 @@ function at(e) {
93
93
  o(l.position);
94
94
  }
95
95
  };
96
- return z.subscribe(A), {
96
+ return z.subscribe(E), {
97
97
  stop: () => {
98
- u && (u = !1, z.unsubscribe(A));
98
+ u && (u = !1, z.unsubscribe(E));
99
99
  },
100
100
  getPosition: () => l.position,
101
101
  getVelocity: () => l.velocity,
@@ -103,7 +103,7 @@ function at(e) {
103
103
  };
104
104
  }
105
105
  const L = 1e3 / 60;
106
- function ct(e, i, t, n = 0) {
106
+ function lt(e, i, t, n = 0) {
107
107
  let o = { position: i, velocity: n }, s = 0;
108
108
  const m = [];
109
109
  for (let l = 0; l < 600; l++) {
@@ -113,7 +113,7 @@ function ct(e, i, t, n = 0) {
113
113
  position: o.position,
114
114
  velocity: o.velocity
115
115
  }), o = e.step(o, t, L / 1e3), e.isSettled(o, t)) {
116
- if (s += L / 1e3, s >= $) {
116
+ if (s += L / 1e3, s >= Z) {
117
117
  m.push({
118
118
  time: (l + 1) * L,
119
119
  position: t,
@@ -126,7 +126,7 @@ function ct(e, i, t, n = 0) {
126
126
  }
127
127
  return m;
128
128
  }
129
- function H(e, i) {
129
+ function U(e, i) {
130
130
  if (e.length === 0)
131
131
  return { position: 0, velocity: 0 };
132
132
  const t = e[0], n = e[e.length - 1];
@@ -145,10 +145,10 @@ function H(e, i) {
145
145
  velocity: s.velocity + (m.velocity - s.velocity) * l
146
146
  };
147
147
  }
148
- function lt(e, i) {
148
+ function ut(e, i) {
149
149
  return e.map((t) => i(t.position));
150
150
  }
151
- function ut(e) {
151
+ function ft(e) {
152
152
  const {
153
153
  integrator: i,
154
154
  element: t,
@@ -158,7 +158,7 @@ function ut(e) {
158
158
  style: s,
159
159
  onComplete: m,
160
160
  onStart: l
161
- } = e, u = ct(i, n, r, o);
161
+ } = e, u = lt(i, n, r, o);
162
162
  if (u.length === 0)
163
163
  return l == null || l(), m(), {
164
164
  stop: () => {
@@ -167,12 +167,12 @@ function ut(e) {
167
167
  getVelocity: () => 0,
168
168
  isRunning: () => !1
169
169
  };
170
- const h = lt(u, s), v = u[u.length - 1], A = v.time, S = h[0];
170
+ const h = ut(u, s), v = u[u.length - 1], E = v.time, S = h[0];
171
171
  if (S)
172
172
  for (const T of Object.keys(S))
173
173
  t.style[T] = "";
174
174
  const y = t.animate(h, {
175
- duration: A,
175
+ duration: E,
176
176
  fill: "forwards",
177
177
  easing: "linear",
178
178
  composite: "replace"
@@ -189,18 +189,18 @@ function ut(e) {
189
189
  if (!p)
190
190
  return v.position;
191
191
  const T = performance.now() - k;
192
- return H(u, T).position;
192
+ return U(u, T).position;
193
193
  },
194
194
  getVelocity: () => {
195
195
  if (!p)
196
196
  return 0;
197
197
  const T = performance.now() - k;
198
- return H(u, T).velocity;
198
+ return U(u, T).velocity;
199
199
  },
200
200
  isRunning: () => p
201
201
  };
202
202
  }
203
- function ft(e) {
203
+ function mt(e) {
204
204
  const {
205
205
  element: i,
206
206
  frames: t,
@@ -221,7 +221,7 @@ function ft(e) {
221
221
  composite: "replace"
222
222
  });
223
223
  let v = !0;
224
- const A = performance.now();
224
+ const E = performance.now();
225
225
  return l == null || l(), h.onfinish = () => {
226
226
  v && (v = !1, m());
227
227
  }, {
@@ -234,7 +234,7 @@ function ft(e) {
234
234
  // progress signal.
235
235
  getPosition: () => {
236
236
  if (!v) return s;
237
- const S = performance.now() - A, y = Math.min(Math.max(S / n, 0), 1);
237
+ const S = performance.now() - E, y = Math.min(Math.max(S / n, 0), 1);
238
238
  return o + (s - o) * y;
239
239
  },
240
240
  // Baked animations don't expose velocity — interruption/resumption isn't
@@ -243,7 +243,7 @@ function ft(e) {
243
243
  isRunning: () => v
244
244
  };
245
245
  }
246
- function mt(e) {
246
+ function dt(e) {
247
247
  const { to: i, onStart: t, onComplete: n } = e;
248
248
  return t == null || t(), n(), {
249
249
  stop: () => {
@@ -253,7 +253,7 @@ function mt(e) {
253
253
  isRunning: () => !1
254
254
  };
255
255
  }
256
- class dt {
256
+ class ht {
257
257
  /**
258
258
  * Get bound runner based on animation mode
259
259
  *
@@ -267,7 +267,7 @@ class dt {
267
267
  throw new Error(
268
268
  "Cannot use more than one of 'tick', 'css', 'keyframes' together"
269
269
  );
270
- return r ? (s) => ft({
270
+ return r ? (s) => mt({
271
271
  element: r.element,
272
272
  frames: r.frames,
273
273
  duration: r.duration,
@@ -279,7 +279,7 @@ class dt {
279
279
  }) : n ? (s) => {
280
280
  if (!s.integrator)
281
281
  throw new Error("css mode requires an integrator");
282
- return ut({
282
+ return ft({
283
283
  integrator: s.integrator,
284
284
  from: s.from,
285
285
  to: s.to,
@@ -292,7 +292,7 @@ class dt {
292
292
  } : t ? (s) => {
293
293
  if (!s.integrator)
294
294
  throw new Error("tick mode requires an integrator");
295
- return at({
295
+ return ct({
296
296
  integrator: s.integrator,
297
297
  from: s.from,
298
298
  to: s.to,
@@ -301,13 +301,13 @@ class dt {
301
301
  onStart: s.onStart,
302
302
  onUpdate: t
303
303
  });
304
- } : mt;
304
+ } : dt;
305
305
  }
306
306
  }
307
- class Z {
307
+ class J {
308
308
  }
309
- const ht = { stiffness: 300, damping: 30 };
310
- class K extends Z {
309
+ const gt = { stiffness: 300, damping: 30 };
310
+ class B extends J {
311
311
  constructor(t) {
312
312
  super();
313
313
  d(this, "options");
@@ -340,7 +340,7 @@ class K extends Z {
340
340
  } else
341
341
  this.updateFn = () => {
342
342
  };
343
- this.runner = dt.from({
343
+ this.runner = ht.from({
344
344
  tick: t.tick,
345
345
  css: t.css,
346
346
  keyframes: t.keyframes
@@ -360,10 +360,10 @@ class K extends Z {
360
360
  */
361
361
  createIntegrator() {
362
362
  const t = this.options.physics;
363
- return t != null && t.integrator ? t.integrator() : t != null && t.spring || t != null && t.inertia ? ot.from({
363
+ return t != null && t.integrator ? t.integrator() : t != null && t.spring || t != null && t.inertia ? st.from({
364
364
  spring: t.spring,
365
365
  inertia: t.inertia
366
- }) : new rt(ht);
366
+ }) : new ot(gt);
367
367
  }
368
368
  runAnimation(t) {
369
369
  this.isAnimating = !0, this.controls = this.runner({
@@ -421,7 +421,7 @@ class K extends Z {
421
421
  this.options = { ...this.options, ...t };
422
422
  }
423
423
  }
424
- class D extends Z {
424
+ class _ extends J {
425
425
  constructor(t) {
426
426
  super();
427
427
  d(this, "config");
@@ -445,7 +445,7 @@ class D extends Z {
445
445
  }
446
446
  initializeAnimators() {
447
447
  this.config.items.forEach((t, n) => {
448
- const r = this.generateId(), o = new K({
448
+ const r = this.generateId(), o = new B({
449
449
  from: this.from,
450
450
  to: this.to,
451
451
  physics: t.physics,
@@ -548,7 +548,7 @@ class D extends Z {
548
548
  return;
549
549
  const n = t.animator.getCurrentState();
550
550
  if (n.position === n.to) {
551
- const o = new K({
551
+ const o = new B({
552
552
  from: this.to,
553
553
  to: this.from,
554
554
  physics: t.item.physics,
@@ -616,10 +616,10 @@ class D extends Z {
616
616
  * Uses first animator's state for initialization
617
617
  */
618
618
  static fromState(t, n) {
619
- return new D({ ...n, state: t });
619
+ return new _({ ...n, state: t });
620
620
  }
621
621
  }
622
- const J = Symbol.for("TRANSITION_STRATEGY"), gt = (e) => ({
622
+ const Q = Symbol.for("TRANSITION_STRATEGY"), yt = (e) => ({
623
623
  runIn: async (i) => {
624
624
  const { currentAnimation: t } = e;
625
625
  if (t && t.direction === "out") {
@@ -686,7 +686,7 @@ const J = Symbol.for("TRANSITION_STRATEGY"), gt = (e) => ({
686
686
  direction: "forward"
687
687
  };
688
688
  }
689
- }), yt = () => ({
689
+ }), wt = () => ({
690
690
  runIn: async (e) => e.in ? {
691
691
  config: await e.in,
692
692
  state: {
@@ -723,34 +723,34 @@ const J = Symbol.for("TRANSITION_STRATEGY"), gt = (e) => ({
723
723
  to: 0,
724
724
  direction: "forward"
725
725
  }
726
- }), Q = "data-ssgoi-scope", tt = "data-ssgoi-scope-ready";
727
- function Nt() {
726
+ }), tt = "data-ssgoi-scope", et = "data-ssgoi-scope-ready";
727
+ function Xt() {
728
728
  return (e) => {
729
729
  if (e)
730
- return e.setAttribute(Q, ""), queueMicrotask(() => {
730
+ return e.setAttribute(tt, ""), queueMicrotask(() => {
731
731
  queueMicrotask(() => {
732
- e.setAttribute(tt, "true");
732
+ e.setAttribute(et, "true");
733
733
  });
734
734
  }), () => {
735
735
  };
736
736
  };
737
737
  }
738
- function wt(e) {
739
- return e.hasAttribute(tt);
740
- }
741
738
  function pt(e) {
742
- return e.closest(`[${Q}]`);
739
+ return e.hasAttribute(et);
740
+ }
741
+ function vt(e) {
742
+ return e.closest(`[${tt}]`);
743
743
  }
744
- const vt = (e) => {
744
+ const H = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]), St = (e) => {
745
745
  let i = e.parentElement;
746
746
  for (; i && i !== document.body; ) {
747
- const t = window.getComputedStyle(i), n = t.overflow + t.overflowY + t.overflowX;
748
- if (n.includes("auto") || n.includes("scroll") || i.scrollHeight > i.clientHeight || i.scrollWidth > i.clientWidth)
747
+ const t = window.getComputedStyle(i);
748
+ if (H.has(t.overflowY) || H.has(t.overflowX))
749
749
  return i;
750
750
  i = i.parentElement;
751
751
  }
752
752
  return document.documentElement;
753
- }, St = (e) => {
753
+ }, Et = (e) => {
754
754
  let i = e.parentElement;
755
755
  for (; i && i !== document.body; ) {
756
756
  const t = window.getComputedStyle(i).position;
@@ -760,7 +760,7 @@ const vt = (e) => {
760
760
  }
761
761
  return document.body;
762
762
  };
763
- function U(e) {
763
+ function K(e) {
764
764
  return new Promise((i) => {
765
765
  requestAnimationFrame(() => {
766
766
  requestAnimationFrame(() => {
@@ -776,8 +776,8 @@ function At(e, i) {
776
776
  get currentAnimation() {
777
777
  return t;
778
778
  }
779
- }, m = ((S = i == null ? void 0 : i.strategy) == null ? void 0 : S.call(i, s)) || gt(s), l = async (y) => {
780
- var g, E;
779
+ }, m = ((S = i == null ? void 0 : i.strategy) == null ? void 0 : S.call(i, s)) || yt(s), l = async (y) => {
780
+ var g, C;
781
781
  n && (n.remove(), n = null);
782
782
  const p = e(), k = p.in && p.in(y), T = !(i != null && i.strategy) && p.out ? p.out(y) : void 0;
783
783
  if (!k)
@@ -792,7 +792,7 @@ function At(e, i) {
792
792
  }
793
793
  const a = f.config;
794
794
  (g = a.prepare) == null || g.call(a);
795
- const C = W(
795
+ const A = W(
796
796
  {
797
797
  ...a,
798
798
  onEnd: () => {
@@ -803,14 +803,14 @@ function At(e, i) {
803
803
  y
804
804
  );
805
805
  a.wait && await a.wait();
806
- const c = D.fromState(f.state, {
807
- config: C,
806
+ const c = _.fromState(f.state, {
807
+ config: A,
808
808
  from: f.from,
809
809
  to: f.to
810
810
  });
811
- t = { controller: c, direction: "in" }, (E = a.onReady) == null || E.call(a), await U(), f.direction === "forward" ? c.forward() : c.backward();
811
+ t = { controller: c, direction: "in" }, (C = a.onReady) == null || C.call(a), await K(), f.direction === "forward" ? c.forward() : c.backward();
812
812
  }, u = async (y) => {
813
- var E, b;
813
+ var C, b;
814
814
  n = y;
815
815
  const p = e(), k = !(i != null && i.strategy) && p.in ? p.in(y) : void 0, T = p.out && p.out(y);
816
816
  if (!T)
@@ -824,8 +824,8 @@ function At(e, i) {
824
824
  return;
825
825
  }
826
826
  const a = f.config;
827
- g(), (E = a.prepare) == null || E.call(a);
828
- const C = W(
827
+ g(), (C = a.prepare) == null || C.call(a);
828
+ const A = W(
829
829
  {
830
830
  ...a,
831
831
  onEnd: () => {
@@ -836,18 +836,18 @@ function At(e, i) {
836
836
  y
837
837
  );
838
838
  a.wait && await a.wait();
839
- const c = D.fromState(f.state, {
840
- config: C,
839
+ const c = _.fromState(f.state, {
840
+ config: A,
841
841
  from: f.from,
842
842
  to: f.to
843
843
  });
844
- t = { controller: c, direction: "out" }, (b = a.onReady) == null || b.call(a), await U(), f.direction === "forward" ? c.forward() : c.backward();
844
+ t = { controller: c, direction: "out" }, (b = a.onReady) == null || b.call(a), await K(), f.direction === "forward" ? c.forward() : c.backward();
845
845
  function g() {
846
846
  !r || !n || (o && r.contains(o) ? r.insertBefore(n, o) : r.appendChild(n));
847
847
  }
848
848
  };
849
849
  let h = null, v = !1;
850
- const A = (y) => () => {
850
+ const E = (y) => () => {
851
851
  if (v) return;
852
852
  v = !0;
853
853
  const p = y.cloneNode(!0);
@@ -860,13 +860,13 @@ function At(e, i) {
860
860
  return requestAnimationFrame(() => {
861
861
  r = y.parentElement, o = y.nextElementSibling;
862
862
  }), v = !1, (i == null ? void 0 : i.scope) === "local" ? queueMicrotask(() => {
863
- h = pt(y), !(h && !wt(h)) && l(y);
864
- }) : l(y), A(y);
863
+ h = vt(y), !(h && !pt(h)) && l(y);
864
+ }) : l(y), E(y);
865
865
  };
866
866
  }
867
867
  const P = /* @__PURE__ */ new Map();
868
868
  let I = null, q = !1;
869
- function et(e) {
869
+ function nt(e) {
870
870
  if (e instanceof HTMLElement && P.has(e)) {
871
871
  const t = P.get(e);
872
872
  P.delete(e), queueMicrotask(() => {
@@ -876,7 +876,7 @@ function et(e) {
876
876
  const i = e.childNodes;
877
877
  for (let t = 0; t < i.length; t++) {
878
878
  const n = i[t];
879
- n && et(n);
879
+ n && nt(n);
880
880
  }
881
881
  }
882
882
  function Ct() {
@@ -885,7 +885,7 @@ function Ct() {
885
885
  const t = i.removedNodes;
886
886
  for (let n = 0; n < t.length; n++) {
887
887
  const r = t[n];
888
- r && et(r);
888
+ r && nt(r);
889
889
  }
890
890
  }
891
891
  }), document.body ? I.observe(document.body, {
@@ -902,24 +902,24 @@ function Ct() {
902
902
  { once: !0 }
903
903
  ));
904
904
  }
905
- function Et(e, i) {
905
+ function Tt(e, i) {
906
906
  Ct(), P.set(e, i);
907
907
  }
908
- function Xt(e) {
908
+ function Wt(e) {
909
909
  return P.has(e);
910
910
  }
911
- function Wt() {
911
+ function Ut() {
912
912
  return P.size;
913
913
  }
914
- function Ht(e) {
914
+ function Bt(e) {
915
915
  const i = P.get(e);
916
916
  return i ? (P.delete(e), i(), !0) : !1;
917
917
  }
918
- function Kt() {
918
+ function Ht() {
919
919
  P.clear(), I == null || I.disconnect(), I = null, q = !1;
920
920
  }
921
921
  const O = /* @__PURE__ */ new Map(), N = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map();
922
- function Tt(e, i, t) {
922
+ function bt(e, i, t) {
923
923
  O.set(e, i);
924
924
  let n = N.get(e);
925
925
  if (n)
@@ -934,23 +934,23 @@ function Tt(e, i, t) {
934
934
  strategy: t == null ? void 0 : t.strategy,
935
935
  scope: t == null ? void 0 : t.scope,
936
936
  onCleanupEnd: () => {
937
- O.get(e) === r && bt(e);
937
+ O.get(e) === r && kt(e);
938
938
  }
939
939
  }
940
940
  ), N.set(e, n), n;
941
941
  }
942
- function bt(e) {
942
+ function kt(e) {
943
943
  O.delete(e), N.delete(e), X.delete(e);
944
944
  }
945
- function Ut(e, i = "manual") {
946
- const t = Tt(
945
+ function Kt(e, i = "manual") {
946
+ const t = bt(
947
947
  e.key,
948
948
  {
949
949
  in: e.in,
950
950
  out: e.out
951
951
  },
952
952
  {
953
- strategy: e[J],
953
+ strategy: e[Q],
954
954
  scope: e.scope
955
955
  }
956
956
  );
@@ -960,11 +960,11 @@ function Ut(e, i = "manual") {
960
960
  return n || (n = (r) => {
961
961
  if (r) {
962
962
  const o = t(r);
963
- o && Et(r, o);
963
+ o && Tt(r, o);
964
964
  }
965
965
  }, X.set(e.key, n), n);
966
966
  }
967
- function kt(e) {
967
+ function Rt(e) {
968
968
  const i = e.filter((t) => t.symmetric).map((t) => ({
969
969
  from: t.to,
970
970
  to: t.from,
@@ -981,7 +981,7 @@ function V(e, i) {
981
981
  }
982
982
  return e === i;
983
983
  }
984
- function Rt(e, i, t) {
984
+ function It(e, i, t) {
985
985
  for (const n of t)
986
986
  if (V(e, n.from) && V(i, n.to))
987
987
  return n.transition;
@@ -990,58 +990,58 @@ function Rt(e, i, t) {
990
990
  return n.transition;
991
991
  return null;
992
992
  }
993
- const It = 768, Pt = 10, Mt = 10;
994
- function Vt(e = {}) {
993
+ const Pt = 768, Mt = 10, Vt = 10;
994
+ function xt(e = {}) {
995
995
  const { preserveScroll: i = (c) => c } = e, t = typeof i == "function" ? i : () => i;
996
996
  let n = null, r = !1, o = !1;
997
997
  const s = () => {
998
998
  const c = (n == null ? void 0 : n.clientWidth) ?? 0, g = c > 0 ? c : typeof window < "u" ? window.innerWidth : 0;
999
- return g > 0 && g < It;
999
+ return g > 0 && g < Pt;
1000
1000
  }, m = () => (o || (r = s(), o = !0), r), l = (c) => {
1001
1001
  const g = t(m());
1002
- return g === !1 ? !1 : g === !0 ? !0 : !g.exclude.some((E) => V(c, E));
1002
+ return g === !1 ? !1 : g === !0 ? !0 : !g.exclude.some((C) => V(c, C));
1003
1003
  };
1004
1004
  let u = null;
1005
1005
  const h = /* @__PURE__ */ new Map();
1006
- let v = null, A = !1, S = 0;
1006
+ let v = null, E = !1, S = 0;
1007
1007
  const y = () => {
1008
- n && v && !A && h.set(v, {
1008
+ n && v && !E && h.set(v, {
1009
1009
  x: n.scrollLeft,
1010
1010
  y: n.scrollTop
1011
1011
  });
1012
1012
  }, p = (c) => {
1013
1013
  if (!n) return;
1014
1014
  const g = l(c) && h.has(c) ? h.get(c) : { x: 0, y: 0 };
1015
- let E = 0;
1015
+ let C = 0;
1016
1016
  const b = () => {
1017
1017
  if (!n) return;
1018
1018
  n.scrollTo({
1019
1019
  top: g.y,
1020
1020
  left: g.x
1021
- }), !(Math.abs(n.scrollTop - g.y) < 1 && Math.abs(n.scrollLeft - g.x) < 1) && E < Pt && (E++, requestAnimationFrame(b));
1021
+ }), !(Math.abs(n.scrollTop - g.y) < 1 && Math.abs(n.scrollLeft - g.x) < 1) && C < Mt && (C++, requestAnimationFrame(b));
1022
1022
  };
1023
1023
  requestAnimationFrame(b);
1024
1024
  };
1025
1025
  return {
1026
1026
  initializeContext: (c, g) => {
1027
- A = !0;
1028
- const E = ++S;
1029
- u = c, n || (n = vt(c), r = s(), o = !0, typeof ResizeObserver < "u" && new ResizeObserver(() => {
1027
+ E = !0;
1028
+ const C = ++S;
1029
+ u = c, n || (n = St(c), r = s(), o = !0, typeof ResizeObserver < "u" && new ResizeObserver(() => {
1030
1030
  r = s();
1031
1031
  }).observe(n), (n === document.documentElement ? window : n).addEventListener("scroll", y, {
1032
1032
  passive: !0
1033
1033
  })), v = g, p(g);
1034
1034
  let b = 0;
1035
1035
  const R = () => {
1036
- E === S && (b++, b >= Mt ? A = !1 : requestAnimationFrame(R));
1036
+ C === S && (b++, b >= Vt ? E = !1 : requestAnimationFrame(R));
1037
1037
  };
1038
1038
  requestAnimationFrame(R);
1039
1039
  },
1040
1040
  calculateScrollOffset: (c, g) => {
1041
- const E = c && h.has(c) ? h.get(c) : { x: 0, y: 0 }, b = g && l(g) && h.has(g) ? h.get(g) : { x: 0, y: 0 };
1041
+ const C = c && h.has(c) ? h.get(c) : { x: 0, y: 0 }, b = g && l(g) && h.has(g) ? h.get(g) : { x: 0, y: 0 };
1042
1042
  return {
1043
- x: -b.x + E.x,
1044
- y: -b.y + E.y
1043
+ x: -b.x + C.x,
1044
+ y: -b.y + C.y
1045
1045
  };
1046
1046
  },
1047
1047
  evictScrollPosition: (c) => {
@@ -1049,17 +1049,17 @@ function Vt(e = {}) {
1049
1049
  },
1050
1050
  shouldPreserve: l,
1051
1051
  getScrollContainer: () => n,
1052
- getPositionedParentElement: () => u ? St(u) : document.body,
1052
+ getPositionedParentElement: () => u ? Et(u) : document.body,
1053
1053
  getScrollPosition: (c) => c && h.has(c) ? h.get(c) : { x: 0, y: 0 }
1054
1054
  };
1055
1055
  }
1056
- const j = 30, B = 8, Y = 1.2, G = 30, xt = 600;
1057
- function Ft() {
1056
+ const j = 30, Y = 8, G = 1.2, $ = 30, Ft = 600;
1057
+ function Lt() {
1058
1058
  let e = null, i = !1, t = !1, n = null, r = null, o = !1;
1059
1059
  const s = (w, f) => {
1060
1060
  for (let a = 0; a < w.length; a++) {
1061
- const C = w.item(a);
1062
- if (C && C.identifier === f) return C;
1061
+ const A = w.item(a);
1062
+ if (A && A.identifier === f) return A;
1063
1063
  }
1064
1064
  return null;
1065
1065
  }, m = () => {
@@ -1069,7 +1069,7 @@ function Ft() {
1069
1069
  }, u = () => {
1070
1070
  i = !0, t = !0, m(), l(), n = setTimeout(() => {
1071
1071
  i = !1, t = !1, n = null;
1072
- }, xt);
1072
+ }, Ft);
1073
1073
  }, h = (w) => {
1074
1074
  if (w.touches.length !== 1) {
1075
1075
  e = null;
@@ -1080,8 +1080,8 @@ function Ft() {
1080
1080
  e = null;
1081
1081
  return;
1082
1082
  }
1083
- const a = window.innerWidth, C = f.clientX <= j, c = f.clientX >= a - j;
1084
- if (!C && !c) {
1083
+ const a = window.innerWidth, A = f.clientX <= j, c = f.clientX >= a - j;
1084
+ if (!A && !c) {
1085
1085
  e = null;
1086
1086
  return;
1087
1087
  }
@@ -1089,7 +1089,7 @@ function Ft() {
1089
1089
  identifier: f.identifier,
1090
1090
  startX: f.clientX,
1091
1091
  startY: f.clientY,
1092
- fromLeftEdge: C,
1092
+ fromLeftEdge: A,
1093
1093
  moved: !1
1094
1094
  };
1095
1095
  }, v = (w) => {
@@ -1103,26 +1103,26 @@ function Ft() {
1103
1103
  e = null;
1104
1104
  return;
1105
1105
  }
1106
- const a = f.clientX - e.startX, C = f.clientY - e.startY, c = Math.abs(a), g = Math.abs(C);
1107
- if (g > B && g > c * Y) {
1106
+ const a = f.clientX - e.startX, A = f.clientY - e.startY, c = Math.abs(a), g = Math.abs(A);
1107
+ if (g > Y && g > c * G) {
1108
1108
  e = null;
1109
1109
  return;
1110
1110
  }
1111
- const E = e.fromLeftEdge ? a > 0 : a < 0;
1112
- c > B && c > g * Y && E && (e.moved = !0);
1113
- }, A = (w) => {
1111
+ const C = e.fromLeftEdge ? a > 0 : a < 0;
1112
+ c > Y && c > g * G && C && (e.moved = !0);
1113
+ }, E = (w) => {
1114
1114
  if (!e) return;
1115
1115
  const f = s(w.changedTouches, e.identifier);
1116
1116
  if (!f) {
1117
1117
  e = null;
1118
1118
  return;
1119
1119
  }
1120
- const a = f.clientX - e.startX, C = e.fromLeftEdge ? a > 0 : a < 0;
1121
- if (e.moved && C && Math.abs(a) >= G) {
1120
+ const a = f.clientX - e.startX, A = e.fromLeftEdge ? a > 0 : a < 0;
1121
+ if (e.moved && A && Math.abs(a) >= $) {
1122
1122
  u(), e = null;
1123
1123
  return;
1124
1124
  }
1125
- e.moved && Math.abs(a) >= G && u(), e = null;
1125
+ e.moved && Math.abs(a) >= $ && u(), e = null;
1126
1126
  }, S = () => {
1127
1127
  e && (e.moved && u(), e = null);
1128
1128
  };
@@ -1130,12 +1130,12 @@ function Ft() {
1130
1130
  if (typeof window > "u" || o) return;
1131
1131
  o = !0;
1132
1132
  const w = { passive: !0, capture: !0 };
1133
- window.addEventListener("touchstart", h, w), window.addEventListener("touchmove", v, w), window.addEventListener("touchend", A, w), window.addEventListener("touchcancel", S, w);
1133
+ window.addEventListener("touchstart", h, w), window.addEventListener("touchmove", v, w), window.addEventListener("touchend", E, w), window.addEventListener("touchcancel", S, w);
1134
1134
  }, destroy: () => {
1135
1135
  if (typeof window > "u" || !o) return;
1136
1136
  o = !1;
1137
1137
  const w = { capture: !0 };
1138
- window.removeEventListener("touchstart", h, w), window.removeEventListener("touchmove", v, w), window.removeEventListener("touchend", A, w), window.removeEventListener("touchcancel", S, w), m(), l(), e = null, i = !1, t = !1;
1138
+ window.removeEventListener("touchstart", h, w), window.removeEventListener("touchmove", v, w), window.removeEventListener("touchend", E, w), window.removeEventListener("touchcancel", S, w), m(), l(), e = null, i = !1, t = !1;
1139
1139
  }, isSwipeBack: () => {
1140
1140
  const w = i || t;
1141
1141
  return w && m(), w;
@@ -1145,7 +1145,7 @@ function Ft() {
1145
1145
  }, 0);
1146
1146
  } };
1147
1147
  }
1148
- function Lt() {
1148
+ function Ot() {
1149
1149
  let e = null;
1150
1150
  function i() {
1151
1151
  if (e != null && e.from && (e != null && e.to) && (e != null && e.outResolve) && (e != null && e.inResolve)) {
@@ -1164,7 +1164,7 @@ function Lt() {
1164
1164
  }
1165
1165
  };
1166
1166
  }
1167
- function Ot() {
1167
+ function _t() {
1168
1168
  let e = null;
1169
1169
  function i() {
1170
1170
  var n, r;
@@ -1198,31 +1198,31 @@ function jt(e, i) {
1198
1198
  middleware: r = (f, a) => ({ from: f, to: a }),
1199
1199
  // Identity function as default
1200
1200
  preserveScroll: o = (f) => f
1201
- } = e, { outFirst: s = !0 } = i || {}, m = s ? Lt() : Ot(), l = kt(t), u = Ft();
1201
+ } = e, { outFirst: s = !0 } = i || {}, m = s ? Ot() : _t(), l = Rt(t), u = Lt();
1202
1202
  u.initialize();
1203
1203
  const {
1204
1204
  initializeContext: h,
1205
1205
  calculateScrollOffset: v,
1206
- evictScrollPosition: A,
1206
+ evictScrollPosition: E,
1207
1207
  shouldPreserve: S,
1208
1208
  getScrollContainer: y,
1209
1209
  getPositionedParentElement: p,
1210
1210
  getScrollPosition: k
1211
- } = Vt({
1211
+ } = xt({
1212
1212
  preserveScroll: o
1213
1213
  }), T = async (f, a) => {
1214
- const C = u.isSwipeBack();
1214
+ const A = u.isSwipeBack();
1215
1215
  m.trigger(f, a);
1216
1216
  const c = await m.get(a);
1217
1217
  if (a === "in" && u.onPageEnter(), !c) return () => ({});
1218
- if (C)
1219
- return a === "out" && c.from && !S(c.from) && A(c.from), () => ({});
1220
- const { from: g, to: E } = r(
1218
+ if (A)
1219
+ return a === "out" && c.from && !S(c.from) && E(c.from), () => ({});
1220
+ const { from: g, to: C } = r(
1221
1221
  c.from,
1222
1222
  c.to
1223
- ), R = Rt(
1223
+ ), R = It(
1224
1224
  g,
1225
- E,
1225
+ C,
1226
1226
  l
1227
1227
  ) || n;
1228
1228
  if (!R) return () => ({});
@@ -1238,7 +1238,7 @@ function jt(e, i) {
1238
1238
  return p();
1239
1239
  }
1240
1240
  };
1241
- return c.from && !S(c.from) && A(c.from), (_) => R.out(_, x);
1241
+ return c.from && !S(c.from) && E(c.from), (D) => R.out(D, x);
1242
1242
  } else {
1243
1243
  const x = {
1244
1244
  scrollOffset: M,
@@ -1252,7 +1252,7 @@ function jt(e, i) {
1252
1252
  return p();
1253
1253
  }
1254
1254
  };
1255
- return (_) => R.in(_, x);
1255
+ return (D) => R.in(D, x);
1256
1256
  }
1257
1257
  };
1258
1258
  return (f) => ({
@@ -1260,32 +1260,32 @@ function jt(e, i) {
1260
1260
  in: async (a) => (h(a, f), (await T(f, "in"))(a)),
1261
1261
  out: async (a) => (await T(f, "out"))(a),
1262
1262
  // Add page transition strategy for page-level transitions
1263
- [J]: yt
1263
+ [Q]: wt
1264
1264
  });
1265
1265
  }
1266
1266
  export {
1267
- Q as SCOPE_ATTR,
1268
- tt as SCOPE_READY_ATTR,
1269
- J as TRANSITION_STRATEGY,
1270
- Ot as createAnyOrderDetector,
1271
- gt as createDefaultStrategy,
1272
- Lt as createOutFirstDetector,
1273
- yt as createPageTransitionStrategy,
1267
+ tt as SCOPE_ATTR,
1268
+ et as SCOPE_READY_ATTR,
1269
+ Q as TRANSITION_STRATEGY,
1270
+ _t as createAnyOrderDetector,
1271
+ yt as createDefaultStrategy,
1272
+ Ot as createOutFirstDetector,
1273
+ wt as createPageTransitionStrategy,
1274
1274
  jt as createSggoiTransitionContext,
1275
- Nt as createTransitionScope,
1276
- pt as findScope,
1277
- Wt as getWatchedCount,
1278
- Gt as isCssAnimation,
1279
- $t as isKeyframesAnimation,
1280
- Zt as isMultiAnimation,
1281
- wt as isScopeReady,
1282
- Jt as isSingleAnimation,
1283
- Qt as isTickAnimation,
1284
- Xt as isWatched,
1275
+ Xt as createTransitionScope,
1276
+ vt as findScope,
1277
+ Ut as getWatchedCount,
1278
+ $t as isCssAnimation,
1279
+ Zt as isKeyframesAnimation,
1280
+ Jt as isMultiAnimation,
1281
+ pt as isScopeReady,
1282
+ Qt as isSingleAnimation,
1283
+ te as isTickAnimation,
1284
+ Wt as isWatched,
1285
1285
  W as normalizeSchedule,
1286
1286
  F as normalizeToMultiAnimation,
1287
- Kt as resetObserver,
1288
- Ut as transition,
1289
- Ht as triggerUnmount,
1290
- Et as watchUnmount
1287
+ Ht as resetObserver,
1288
+ Kt as transition,
1289
+ Bt as triggerUnmount,
1290
+ Tt as watchUnmount
1291
1291
  };
@@ -1 +1 @@
1
- {"version":3,"file":"get-scrolling-element.d.ts","sourceRoot":"","sources":["../../src/lib/utils/get-scrolling-element.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,WAAW,KAAG,WAyB1D,CAAC"}
1
+ {"version":3,"file":"get-scrolling-element.d.ts","sourceRoot":"","sources":["../../src/lib/utils/get-scrolling-element.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,WAAW,KAAG,WAkB1D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssgoi/core",
3
- "version": "5.2.1",
3
+ "version": "5.2.2",
4
4
  "description": "Core animation engine for SSGOI - Native app-like page transitions with spring physics",
5
5
  "private": false,
6
6
  "type": "module",