@ssgoi/core 4.3.2 → 4.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +416 -385
- package/dist/ssgoi-transition/create-context-manager.d.ts +5 -0
- package/dist/ssgoi-transition/create-context-manager.d.ts.map +1 -1
- package/dist/ssgoi-transition/create-navigation-direction-detector.d.ts +20 -0
- package/dist/ssgoi-transition/create-navigation-direction-detector.d.ts.map +1 -0
- package/dist/ssgoi-transition/create-ssgoi-transition-context.d.ts.map +1 -1
- package/dist/ssgoi-transition/find-matching-transition.d.ts.map +1 -1
- package/dist/ssgoi-transition/navigation-detector-strategy.d.ts.map +1 -1
- package/dist/types.d.ts +42 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/is-android.d.ts +5 -0
- package/dist/utils/is-android.d.ts.map +1 -0
- package/dist/utils/is-desktop.d.ts +5 -0
- package/dist/utils/is-desktop.d.ts.map +1 -0
- package/dist/utils/is-ios.d.ts +6 -0
- package/dist/utils/is-ios.d.ts.map +1 -0
- package/dist/utils/match-platform.d.ts +8 -0
- package/dist/utils/match-platform.d.ts.map +1 -0
- package/dist/view-transitions/drill.d.ts.map +1 -1
- package/dist/view-transitions/index.cjs +9 -9
- package/dist/view-transitions/index.js +217 -217
- package/package.json +14 -13
- package/dist/ssgoi-transition/create-swipe-detector.d.ts +0 -11
- package/dist/ssgoi-transition/create-swipe-detector.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var at=Object.defineProperty;var ct=(e,n,t)=>n in e?at(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var d=(e,n,t)=>ct(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./types.cjs"),D=require("./provider-Cs5iBqRD.cjs");class lt{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 l=i/1e3;this.elapsed=r/1e3,this.nextTime+=o+(o>=this.gap?4:this.gap-o),this.listeners.forEach(f=>{f(l,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 U=new lt;function ut(e){const{integrator:n,from:t,to:i,velocity:r=0,onUpdate:o,onComplete:l,onStart:f}=e;let a={position:t,velocity:r},m=!0,w=0,v=!1;const A=T=>{if(m){if(v||(v=!0,f==null||f()),a=n.step(a,i,T),n.isSettled(a,i)){if(w+=Math.min(T,.033),w>=D.SETTLE_THRESHOLD){a={position:i,velocity:0},m=!1,o(a.position),U.unsubscribe(A),l();return}}else w=0;o(a.position)}};return U.subscribe(A),{stop:()=>{m&&(m=!1,U.unsubscribe(A))},getPosition:()=>a.position,getVelocity:()=>a.velocity,isRunning:()=>m}}const x=1e3/60;function ft(e,n,t,i=0){let o={position:n,velocity:i},l=0;const f=[];for(let a=0;a<600;a++){const m=a*x;if(f.push({time:m,position:o.position,velocity:o.velocity}),o=e.step(o,t,x/1e3),e.isSettled(o,t)){if(l+=x/1e3,l>=D.SETTLE_THRESHOLD){f.push({time:(a+1)*x,position:t,velocity:0});break}}else l=0}return f}function $(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 m=Math.floor((r+o)/2);e[m].time<=n?r=m:o=m}const l=e[r],f=e[o],a=(n-l.time)/(f.time-l.time);return{position:l.position+(f.position-l.position)*a,velocity:l.velocity+(f.velocity-l.velocity)*a}}function mt(e,n){return e.map(t=>n(t.position))}function dt(e){const{integrator:n,element:t,from:i,to:r,velocity:o=0,style:l,onComplete:f,onStart:a}=e,m=ft(n,i,r,o);if(m.length===0)return a==null||a(),f(),{stop:()=>{},getPosition:()=>r,getVelocity:()=>0,isRunning:()=>!1};const w=mt(m,l),v=m[m.length-1],A=v.time,T=w[0];if(T)for(const h of Object.keys(T))t.style[h]="";const c=t.animate(w,{duration:A,fill:"forwards",easing:"linear",composite:"replace"});let s=!0;const g=performance.now();return a==null||a(),c.onfinish=()=>{s&&(s=!1,f())},{stop:()=>{s&&(s=!1,c.cancel())},getPosition:()=>{if(!s)return v.position;const h=performance.now()-g;return $(m,h).position},getVelocity:()=>{if(!s)return 0;const h=performance.now()-g;return $(m,h).velocity},isRunning:()=>s}}function ht(e){const{to:n,onStart:t,onComplete:i}=e;return t==null||t(),i(),{stop:()=>{},getPosition:()=>n,getVelocity:()=>0,isRunning:()=>!1}}class gt{static from(n){const{tick:t,css:i}=n;if(t&&i)throw new Error("Cannot use both 'tick' and 'css' options together");return i?r=>dt({...r,element:i.element,style:i.style}):t?r=>ut({...r,onUpdate:t}):ht}}class Q{}const pt={stiffness:300,damping:30};class K 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");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,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 l=r(o);for(const[f,a]of Object.entries(l))i.style[f]=typeof a=="number"?String(a):a}}else this.updateFn=()=>{};this.runner=gt.from({tick:t.tick,css:t.css})}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?D.IntegratorProvider.from({spring:t.spring,inertia:t.inertia}):new D.SpringIntegrator(pt)}runAnimation(t){this.isAnimating=!0,this.controls=this.runner({integrator: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 q 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 K({from:this.from,to:this.to,physics:t.physics,tick:t.tick,css:t.css,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,l,f,a,m;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),(f=(l=this.config).onProgress)==null||f.call(l,this.completedCount,this.config.items.length),this.completedCount===this.config.items.length&&(this.stopScheduler(),(m=(a=this.config).onEnd)==null||m.call(a)))}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 l=t[i-1],f=this.animators.get(l);if(!f||!f.started)continue;const a=this.getAnimatorProgress(f),m=o.item.normalizedOffset;a>=m&&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 K({from:this.to,to:this.from,physics:t.item.physics,tick:t.item.tick,css:t.item.css,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 q({...i,state:t})}}const X=Symbol.for("TRANSITION_STRATEGY"),Z=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"}}}),tt=()=>({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"}}),j="data-ssgoi-scope",G="data-ssgoi-scope-ready";function yt(){return e=>{if(e)return e.setAttribute(j,""),queueMicrotask(()=>{queueMicrotask(()=>{e.setAttribute(G,"true")})}),()=>{}}}function et(e){return e.hasAttribute(G)}function it(e){return e.closest(`[${j}]`)}const wt=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},St=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 vt(e,n){var T;let t=null,i=null,r=null,o=null;const l={get currentAnimation(){return t}},f=((T=n==null?void 0:n.strategy)==null?void 0:T.call(n,l))||Z(l),a=async c=>{var P,k;i&&(i.remove(),i=null);const s=e(),g=s.in&&s.in(c),h=!(n!=null&&n.strategy)&&s.out?s.out(c):void 0;if(!g)return;const C={in:E.normalizeToMultiAnimation(g),out:h?E.normalizeToMultiAnimation(h):void 0},p=await f.runIn(C);if(!p.config){t&&(t.direction="in");return}const u=p.config;(P=u.prepare)==null||P.call(u);const S=E.normalizeSchedule({...u,onEnd:()=>{var F;t=null,(F=u.onEnd)==null||F.call(u)}},c);u.wait&&await u.wait();const y=q.fromState(p.state,{config:S,from:p.from,to:p.to});t={controller:y,direction:"in"},(k=u.onReady)==null||k.call(u),await B(),p.direction==="forward"?y.forward():y.backward()},m=async c=>{var k,F;i=c;const s=e(),g=!(n!=null&&n.strategy)&&s.in?s.in(c):void 0,h=s.out&&s.out(c);if(!h)return;const C={in:g?E.normalizeToMultiAnimation(g):void 0,out:E.normalizeToMultiAnimation(h)},p=await f.runOut(C);if(!p.config){t&&(t.direction="out"),i&&(i.remove(),i=null);return}const u=p.config;P(),(k=u.prepare)==null||k.call(u);const S=E.normalizeSchedule({...u,onEnd:()=>{var V,I;(V=u.onEnd)==null||V.call(u),i&&(i.remove(),i=null),t=null,(I=n==null?void 0:n.onCleanupEnd)==null||I.call(n)}},c);u.wait&&await u.wait();const y=q.fromState(p.state,{config:S,from:p.from,to:p.to});t={controller:y,direction:"out"},(F=u.onReady)==null||F.call(u),await B(),p.direction==="forward"?y.forward():y.backward();function P(){!r||!i||(o&&r.contains(o)?r.insertBefore(i,o):r.appendChild(i))}};let w=null,v=!1;const A=c=>()=>{if(v)return;v=!0;const s=c.cloneNode(!0);w?queueMicrotask(()=>{document.contains(w)&&m(s)}):m(s)};return c=>{if(c)return requestAnimationFrame(()=>{r=c.parentElement,o=c.nextElementSibling}),v=!1,(n==null?void 0:n.scope)==="local"?queueMicrotask(()=>{w=it(c),!(w&&!et(w))&&a(c)}):a(c),A(c)}}const R=new Map;let b=null,Y=!1;function nt(e){if(e instanceof HTMLElement&&R.has(e)){const t=R.get(e);R.delete(e),queueMicrotask(()=>{t()})}const n=e.childNodes;for(let t=0;t<n.length;t++){const i=n[t];i&&nt(i)}}function At(){Y||typeof document>"u"||(Y=!0,b=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&&nt(r)}}}),document.body?b.observe(document.body,{childList:!0,subtree:!0}):document.addEventListener("DOMContentLoaded",()=>{b==null||b.observe(document.body,{childList:!0,subtree:!0})},{once:!0}))}function rt(e,n){At(),R.set(e,n)}function Tt(e){return R.has(e)}function Ct(){return R.size}function Et(e){const n=R.get(e);return n?(R.delete(e),n(),!0):!1}function bt(){R.clear(),b==null||b.disconnect(),b=null,Y=!1}const z=new Map,H=new Map,W=new Map;function Rt(e,n,t){z.set(e,n);let i=H.get(e);if(i)return i;const r=n;return i=vt(()=>{const o=z.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:()=>{z.get(e)===r&&Pt(e)}}),H.set(e,i),i}function Pt(e){z.delete(e),H.delete(e),W.delete(e)}function kt(e,n="manual"){const t=Rt(e.key,{in:e.in,out:e.out},{strategy:e[X],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&&rt(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 Vt(e){let n=!1,t=0,i=0,r=!1;const o=50,l=c=>{if(!e)return;const s=c.touches[0];s&&(r=s.clientX<o,r&&(t=s.clientX,i=s.clientY))},f=c=>{if(!e||!r)return;const s=c.touches[0];if(!s)return;const g=s.clientX-t,h=s.clientY-i;g>window.outerWidth/2-5&&Math.abs(g)>Math.abs(h)?n=!0:n=!1},a=()=>{e&&(r=!1,t=0,i=0)},m=()=>n,w=()=>{typeof window>"u"||e&&(window.addEventListener("touchstart",l,{passive:!0}),window.addEventListener("touchmove",f,{passive:!0}),window.addEventListener("touchend",a,{passive:!0}))},v=()=>{typeof window>"u"||(window.removeEventListener("touchstart",l),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",a))};let A=0;return{initialize:w,cleanup:v,isSwipePending:m,resetSwipeDetection:()=>{requestAnimationFrame(()=>{A++,A>1&&(A=0,n=!1)})}}}function It(e={}){const{preserveScroll:n=!1}=e;let t=null,i=null;const r=new Map;let o=null,l=!1;const f=()=>{t&&o&&!l&&r.set(o,{x:t.scrollLeft,y:t.scrollTop})},a=c=>{if(!t||!n)return;const s=r.get(c);if(!s)return;const g=10;let h=0;const C=()=>{if(!t)return;t.scrollTo({top:s.y,left:s.x});const p=t.scrollTop,u=t.scrollLeft;!(Math.abs(p-s.y)<1&&Math.abs(u-s.x)<1)&&h<g&&(h++,requestAnimationFrame(C))};requestAnimationFrame(C)};return{initializeContext:(c,s)=>{l=!0,i=c,t||(t=wt(c),(t===document.documentElement?window:t).addEventListener("scroll",f,{passive:!0})),o=s,n&&t&&(r.get(s)?a(s):t.scrollTo({top:0,left:0}));const g=10;let h=0;const C=()=>{h++,h>=g?l=!1:requestAnimationFrame(C)};requestAnimationFrame(C)},calculateScrollOffset:(c,s)=>{const g=c&&r.has(c)?r.get(c):{x:0,y:0},h=s&&r.has(s)?r.get(s):{x:0,y:0};return{x:-h.x+g.x,y:-h.y+g.y}},getScrollContainer:()=>t,getPositionedParentElement:()=>i?St(i):document.body,getScrollPosition:c=>c&&r.has(c)?r.get(c):{x:0,y:0}}}function L(e,n){if(n==="*")return!0;if(n.endsWith("/*")){const t=n.slice(0,-2);return e===t||e.startsWith(t+"/")}return e===n}function J(e,n,t){for(const i of t)if(L(e,i.from)&&L(n,i.to))return i.transition;for(const i of t)if((i.from==="*"||L(e,i.from))&&(i.to==="*"||L(n,i.to)))return i.transition;return null}function ot(){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 st(){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)){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 Mt(e,n){const{transitions:t=[],defaultTransition:i,middleware:r=(u,S)=>({from:u,to:S}),skipOnIosSwipe:o=!0,experimentalPreserveScroll:l=!1}=e,{outFirst:f=!0,createNavigationDetector:a}=n||{},m=(a==null?void 0:a())??(f?ot():st()),w=Ft(t),{initializeContext:v,calculateScrollOffset:A,getScrollContainer:T,getPositionedParentElement:c,getScrollPosition:s}=It({preserveScroll:l}),g=Vt(o);g.initialize();const h=async(u,S)=>{if(g.isSwipePending())return g.resetSwipeDetection(),S==="in"?async M=>({onReady:()=>{M.style.visibility="visible"}}):()=>({});m.trigger(u,S);const y=await m.get(S);if(!y)return()=>({});const{from:P,to:k}=r(y.from,y.to),V=J(P,k,w)||i;if(!V)return()=>({});const I=A(y.from,y.to);if(S==="out"){const M={scrollOffset:I,scroll:s(y.from),get scrollingElement(){return T()||document.documentElement},get positionedParent(){return c()}};return O=>V.out(O,M)}else{const M={scrollOffset:I,get scroll(){return s(y.to)},get scrollingElement(){return T()||document.documentElement},get positionedParent(){return c()}};return async O=>{const _=await Promise.resolve(V.in(O,M)),N=_.onReady;return _.onReady=()=>{O.style.visibility="visible",N==null||N()},_}}},C=u=>({key:u,in:async S=>(v(S,u),(await h(u,"in"))(S)),out:async S=>(await h(u,"out"))(S),[X]:tt}),p=(u,S)=>{if(g.isSwipePending())return!1;const{from:y,to:P}=r(u,S);return!!(J(y,P,w)||i)};return a?{getTransition:C,hasMatchingTransition:p}:C}exports.isCssAnimation=E.isCssAnimation;exports.isMultiAnimation=E.isMultiAnimation;exports.isSingleAnimation=E.isSingleAnimation;exports.isTickAnimation=E.isTickAnimation;exports.normalizeSchedule=E.normalizeSchedule;exports.normalizeToMultiAnimation=E.normalizeToMultiAnimation;exports.SCOPE_ATTR=j;exports.SCOPE_READY_ATTR=G;exports.TRANSITION_STRATEGY=X;exports.createAnyOrderDetector=st;exports.createDefaultStrategy=Z;exports.createOutFirstDetector=ot;exports.createPageTransitionStrategy=tt;exports.createSggoiTransitionContext=Mt;exports.createTransitionScope=yt;exports.findScope=it;exports.getWatchedCount=Ct;exports.isScopeReady=et;exports.isWatched=Tt;exports.resetObserver=bt;exports.transition=kt;exports.triggerUnmount=Et;exports.watchUnmount=rt;
|
|
1
|
+
"use strict";var mt=Object.defineProperty;var ht=(e,n,t)=>n in e?mt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var d=(e,n,t)=>ht(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("./types.cjs"),L=require("./provider-Cs5iBqRD.cjs");class gt{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 a=i/1e3;this.elapsed=r/1e3,this.nextTime+=o+(o>=this.gap?4:this.gap-o),this.listeners.forEach(l=>{l(a,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 B=new gt;function yt(e){const{integrator:n,from:t,to:i,velocity:r=0,onUpdate:o,onComplete:a,onStart:l}=e;let s={position:t,velocity:r},u=!0,p=0,C=!1;const v=T=>{if(u){if(C||(C=!0,l==null||l()),s=n.step(s,i,T),n.isSettled(s,i)){if(p+=Math.min(T,.033),p>=L.SETTLE_THRESHOLD){s={position:i,velocity:0},u=!1,o(s.position),B.unsubscribe(v),a();return}}else p=0;o(s.position)}};return B.subscribe(v),{stop:()=>{u&&(u=!1,B.unsubscribe(v))},getPosition:()=>s.position,getVelocity:()=>s.velocity,isRunning:()=>u}}const z=1e3/60;function pt(e,n,t,i=0){let o={position:n,velocity:i},a=0;const l=[];for(let s=0;s<600;s++){const u=s*z;if(l.push({time:u,position:o.position,velocity:o.velocity}),o=e.step(o,t,z/1e3),e.isSettled(o,t)){if(a+=z/1e3,a>=L.SETTLE_THRESHOLD){l.push({time:(s+1)*z,position:t,velocity:0});break}}else a=0}return l}function J(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 a=e[r],l=e[o],s=(n-a.time)/(l.time-a.time);return{position:a.position+(l.position-a.position)*s,velocity:a.velocity+(l.velocity-a.velocity)*s}}function wt(e,n){return e.map(t=>n(t.position))}function St(e){const{integrator:n,element:t,from:i,to:r,velocity:o=0,style:a,onComplete:l,onStart:s}=e,u=pt(n,i,r,o);if(u.length===0)return s==null||s(),l(),{stop:()=>{},getPosition:()=>r,getVelocity:()=>0,isRunning:()=>!1};const p=wt(u,a),C=u[u.length-1],v=C.time,T=p[0];if(T)for(const f of Object.keys(T))t.style[f]="";const h=t.animate(p,{duration:v,fill:"forwards",easing:"linear",composite:"replace"});let y=!0;const m=performance.now();return s==null||s(),h.onfinish=()=>{y&&(y=!1,l())},{stop:()=>{y&&(y=!1,h.cancel())},getPosition:()=>{if(!y)return C.position;const f=performance.now()-m;return J(u,f).position},getVelocity:()=>{if(!y)return 0;const f=performance.now()-m;return J(u,f).velocity},isRunning:()=>y}}function vt(e){const{to:n,onStart:t,onComplete:i}=e;return t==null||t(),i(),{stop:()=>{},getPosition:()=>n,getVelocity:()=>0,isRunning:()=>!1}}class At{static from(n){const{tick:t,css:i}=n;if(t&&i)throw new Error("Cannot use both 'tick' and 'css' options together");return i?r=>St({...r,element:i.element,style:i.style}):t?r=>yt({...r,onUpdate:t}):vt}}class et{}const Ct={stiffness:300,damping:30};class Q extends et{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");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,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 a=r(o);for(const[l,s]of Object.entries(a))i.style[l]=typeof s=="number"?String(s):s}}else this.updateFn=()=>{};this.runner=At.from({tick:t.tick,css:t.css})}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?L.IntegratorProvider.from({spring:t.spring,inertia:t.inertia}):new L.SpringIntegrator(Ct)}runAnimation(t){this.isAnimating=!0,this.controls=this.runner({integrator: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 q extends et{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 Q({from:this.from,to:this.to,physics:t.physics,tick:t.tick,css:t.css,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,a,l,s,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),(l=(a=this.config).onProgress)==null||l.call(a,this.completedCount,this.config.items.length),this.completedCount===this.config.items.length&&(this.stopScheduler(),(u=(s=this.config).onEnd)==null||u.call(s)))}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 a=t[i-1],l=this.animators.get(a);if(!l||!l.started)continue;const s=this.getAnimatorProgress(l),u=o.item.normalizedOffset;s>=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 Q({from:this.to,to:this.from,physics:t.item.physics,tick:t.item.tick,css:t.item.css,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 q({...i,state:t})}}const Y=Symbol.for("TRANSITION_STRATEGY"),it=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"}}}),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"}}),G="data-ssgoi-scope",X="data-ssgoi-scope-ready";function Tt(){return e=>{if(e)return e.setAttribute(G,""),queueMicrotask(()=>{queueMicrotask(()=>{e.setAttribute(X,"true")})}),()=>{}}}function rt(e){return e.hasAttribute(X)}function ot(e){return e.closest(`[${G}]`)}const bt=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},Et=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 Z(e){return new Promise(n=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{n()})})})}function st(){return typeof window>"u"||typeof navigator>"u"?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}function at(){return typeof window>"u"||typeof navigator>"u"?!1:/Android/i.test(navigator.userAgent)}function kt(){return typeof window>"u"||typeof navigator>"u"?!1:!st()&&!at()}function Pt(e){return e.length===0?!1:!!(e.includes("all")||e.includes("ios")&&st()||e.includes("android")&&at()||e.includes("desktop")&&kt())}function Rt(e,n){var T;let t=null,i=null,r=null,o=null;const a={get currentAnimation(){return t}},l=((T=n==null?void 0:n.strategy)==null?void 0:T.call(n,a))||it(a),s=async h=>{var O,S;i&&(i.remove(),i=null);const y=e(),m=y.in&&y.in(h),f=!(n!=null&&n.strategy)&&y.out?y.out(h):void 0;if(!m)return;const A={in:k.normalizeToMultiAnimation(m),out:f?k.normalizeToMultiAnimation(f):void 0},g=await l.runIn(A);if(!g.config){t&&(t.direction="in");return}const c=g.config;(O=c.prepare)==null||O.call(c);const P=k.normalizeSchedule({...c,onEnd:()=>{var w;t=null,(w=c.onEnd)==null||w.call(c)}},h);c.wait&&await c.wait();const b=q.fromState(g.state,{config:P,from:g.from,to:g.to});t={controller:b,direction:"in"},(S=c.onReady)==null||S.call(c),await Z(),g.direction==="forward"?b.forward():b.backward()},u=async h=>{var S,w;i=h;const y=e(),m=!(n!=null&&n.strategy)&&y.in?y.in(h):void 0,f=y.out&&y.out(h);if(!f)return;const A={in:m?k.normalizeToMultiAnimation(m):void 0,out:k.normalizeToMultiAnimation(f)},g=await l.runOut(A);if(!g.config){t&&(t.direction="out"),i&&(i.remove(),i=null);return}const c=g.config;O(),(S=c.prepare)==null||S.call(c);const P=k.normalizeSchedule({...c,onEnd:()=>{var x,E;(x=c.onEnd)==null||x.call(c),i&&(i.remove(),i=null),t=null,(E=n==null?void 0:n.onCleanupEnd)==null||E.call(n)}},h);c.wait&&await c.wait();const b=q.fromState(g.state,{config:P,from:g.from,to:g.to});t={controller:b,direction:"out"},(w=c.onReady)==null||w.call(c),await Z(),g.direction==="forward"?b.forward():b.backward();function O(){!r||!i||(o&&r.contains(o)?r.insertBefore(i,o):r.appendChild(i))}};let p=null,C=!1;const v=h=>()=>{if(C)return;C=!0;const y=h.cloneNode(!0);p?queueMicrotask(()=>{document.contains(p)&&u(y)}):u(y)};return h=>{if(h)return requestAnimationFrame(()=>{r=h.parentElement,o=h.nextElementSibling}),C=!1,(n==null?void 0:n.scope)==="local"?queueMicrotask(()=>{p=ot(h),!(p&&!rt(p))&&s(h)}):s(h),v(h)}}const I=new Map;let R=null,j=!1;function ct(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&&ct(i)}}function It(){j||typeof document>"u"||(j=!0,R=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&&ct(r)}}}),document.body?R.observe(document.body,{childList:!0,subtree:!0}):document.addEventListener("DOMContentLoaded",()=>{R==null||R.observe(document.body,{childList:!0,subtree:!0})},{once:!0}))}function lt(e,n){It(),I.set(e,n)}function xt(e){return I.has(e)}function Ot(){return I.size}function Vt(e){const n=I.get(e);return n?(I.delete(e),n(),!0):!1}function Ft(){I.clear(),R==null||R.disconnect(),R=null,j=!1}const D=new Map,H=new Map,W=new Map;function Mt(e,n,t){D.set(e,n);let i=H.get(e);if(i)return i;const r=n;return i=Rt(()=>{const o=D.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:()=>{D.get(e)===r&&zt(e)}}),H.set(e,i),i}function zt(e){D.delete(e),H.delete(e),W.delete(e)}function Dt(e,n="manual"){const t=Mt(e.key,{in:e.in,out:e.out},{strategy:e[Y],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&<(r,o)}},W.set(e.key,i),i)}function Lt(e){const n=e.filter(t=>t.symmetric).map(t=>({from:t.to,to:t.from,transition:t.transition}));return[...e,...n]}function qt(){var l;let e=typeof history<"u"?((l=history.state)==null?void 0:l.ssgoiIndex)??0:0,n="push",t=!1;const i=s=>{var p;t=!0;const u=((p=s.state)==null?void 0:p.ssgoiIndex)??0;u<e?n="back":u>e&&(n="forward"),e=u};return{initialize:()=>{var s;typeof window>"u"||(window.addEventListener("popstate",i),((s=history.state)==null?void 0:s.ssgoiIndex)==null?history.replaceState({...history.state,ssgoiIndex:e},""):e=history.state.ssgoiIndex)},onPageEnter:()=>{t||(e++,history.replaceState({...history.state,ssgoiIndex:e},""));const s=n;return n="push",t=!1,s},isBack:()=>n==="back"}}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 tt(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}function _t(e={}){const{preserveScroll:n=!1,resetPatterns:t=[]}=e,i=m=>t.some(f=>F(m,f));let r=null,o=null;const a=new Map;let l=null,s=!1;const u=()=>{r&&l&&!s&&a.set(l,{x:r.scrollLeft,y:r.scrollTop})},p=m=>{if(!r||!n)return;if(i(m)){r.scrollTo({top:0,left:0});return}const f=a.get(m);if(!f){r.scrollTo({top:0,left:0});return}const A=10;let g=0;const c=()=>{if(!r)return;r.scrollTo({top:f.y,left:f.x});const P=r.scrollTop,b=r.scrollLeft;!(Math.abs(P-f.y)<1&&Math.abs(b-f.x)<1)&&g<A&&(g++,requestAnimationFrame(c))};requestAnimationFrame(c)};return{initializeContext:(m,f)=>{s=!0,o=m,r||(r=bt(m),(r===document.documentElement?window:r).addEventListener("scroll",u,{passive:!0})),l=f,p(f);const A=10;let g=0;const c=()=>{g++,g>=A?s=!1:requestAnimationFrame(c)};requestAnimationFrame(c)},calculateScrollOffset:(m,f)=>{const A=m&&a.has(m)?a.get(m):{x:0,y:0},g=f&&i(f);g&&a.set(f,{x:0,y:0});const c=g?{x:0,y:0}:f&&a.has(f)?a.get(f):{x:0,y:0};return{x:-c.x+A.x,y:-c.y+A.y}},getScrollContainer:()=>r,getPositionedParentElement:()=>o?Et(o):document.body,getScrollPosition:m=>m&&a.has(m)?a.get(m):{x:0,y:0}}}function ut(){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 ft(){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=(S,w)=>({from:S,to:w}),skipOnIosSwipe:o,skipAnimationOnBack:a,experimentalPreserveScroll:l=!1,scrollResetPatterns:s=[]}=e;o!==void 0&&console.warn("[SSGOI] skipOnIosSwipe is deprecated. Use skipAnimationOnBack: ['ios'] instead.");const p=Pt(a??(o===!1?[]:["ios"])),{outFirst:C=!0,createNavigationDetector:v}=n||{},T=(v==null?void 0:v())??(C?ut():ft()),h=Lt(t),{initializeContext:y,calculateScrollOffset:m,getScrollContainer:f,getPositionedParentElement:A,getScrollPosition:g}=_t({preserveScroll:l,resetPatterns:s}),c=qt();p&&c.initialize();const P=async(S,w)=>{const x=p&&c.isBack();T.trigger(S,w);const E=await T.get(w);if(!E)return()=>({});if(w==="in"&&p&&c.onPageEnter(),x){if(w==="out")return()=>({});if(w==="in")return async V=>({onReady:()=>{V.style.visibility="visible"}})}const{from:$,to:dt}=r(E.from,E.to),_=tt($,dt,h)||i;if(!_)return()=>({});const K=m(E.from,E.to);if(w==="out"){const V={scrollOffset:K,scroll:g(E.from),get scrollingElement(){return f()||document.documentElement},get positionedParent(){return A()}};return M=>_.out(M,V)}else{const V={scrollOffset:K,get scroll(){return g(E.to)},get scrollingElement(){return f()||document.documentElement},get positionedParent(){return A()}};return async M=>{const N=await Promise.resolve(_.in(M,V)),U=N.onReady;return N.onReady=()=>{M.style.visibility="visible",U==null||U()},N}}},b=S=>({key:S,in:async w=>(y(w,S),(await P(S,"in"))(w)),out:async w=>(await P(S,"out"))(w),[Y]:nt}),O=(S,w)=>{if(p&&c.isBack())return!1;const{from:x,to:E}=r(S,w);return!!(tt(x,E,h)||i)};return v?{getTransition:b,hasMatchingTransition:O}:b}exports.isCssAnimation=k.isCssAnimation;exports.isMultiAnimation=k.isMultiAnimation;exports.isSingleAnimation=k.isSingleAnimation;exports.isTickAnimation=k.isTickAnimation;exports.normalizeSchedule=k.normalizeSchedule;exports.normalizeToMultiAnimation=k.normalizeToMultiAnimation;exports.SCOPE_ATTR=G;exports.SCOPE_READY_ATTR=X;exports.TRANSITION_STRATEGY=Y;exports.createAnyOrderDetector=ft;exports.createDefaultStrategy=it;exports.createOutFirstDetector=ut;exports.createPageTransitionStrategy=nt;exports.createSggoiTransitionContext=Nt;exports.createTransitionScope=Tt;exports.findScope=ot;exports.getWatchedCount=Ot;exports.isScopeReady=rt;exports.isWatched=xt;exports.resetObserver=Ft;exports.transition=Dt;exports.triggerUnmount=Vt;exports.watchUnmount=lt;
|