@ssgoi/core 6.6.2 → 6.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -55,11 +55,15 @@ const config = {
55
55
 
56
56
  export default function App() {
57
57
  return (
58
- <Ssgoi config={config}>
59
- <SsgoiTransitionBoundary className="relative z-0 min-h-dvh bg-white">
60
- {/* Your app */}
61
- </SsgoiTransitionBoundary>
62
- </Ssgoi>
58
+ <div className="relative z-0 min-h-dvh bg-white">
59
+ {/* Layout shell above: positioned ancestor + stacking context for the OUT clone. */}
60
+ <Ssgoi config={config}>
61
+ {/* Routed content marker. Layout positioning belongs to the outer wrapper. */}
62
+ <SsgoiTransitionBoundary className="min-h-full bg-white">
63
+ {/* Your app */}
64
+ </SsgoiTransitionBoundary>
65
+ </Ssgoi>
66
+ </div>
63
67
  );
64
68
  }
65
69
  ```
@@ -77,10 +81,11 @@ export default function HomePage() {
77
81
  }
78
82
  ```
79
83
 
80
- For React adapters, create one router-specific `SsgoiTransitionBoundary` utility in your layout.
81
- It reads the current pathname internally, sets the transition boundary key, and
82
- uses that pathname as a logical page id matched by config such as
83
- `/products/*`. Use `/products/**` when the parent path itself should match too.
84
+ For React adapters, create one router-specific `SsgoiTransitionBoundary` utility
85
+ in your layout. It reads the current pathname internally, sets the transition
86
+ boundary key, and uses that pathname as a logical page id matched by config such
87
+ as `/products/*`. Use `/products/**` when the parent path itself should match
88
+ too.
84
89
 
85
90
  Next.js implementation:
86
91
 
@@ -207,9 +212,15 @@ For mount/unmount of individual elements (not whole pages):
207
212
 
208
213
  ## Layout Requirements
209
214
 
210
- The element wrapping `<Ssgoi>` needs `position: relative` and `z-index: 0`.
215
+ The outer element wrapping the SSGOI provider / `<Ssgoi>` needs
216
+ `position: relative` and `z-index: 0`.
211
217
 
212
- When a page leaves, SSGOI clones it back into the DOM with `position: absolute` so it can animate out while the new page animates in. Without a positioned, stacking-context ancestor the clone jumps to the wrong place or falls behind the background. Add `overflow-x-clip` too if you use horizontal transitions (`slide`, `drill`).
218
+ When a page leaves, SSGOI clones it back into the DOM with `position: absolute`
219
+ so it can animate out while the new page animates in. Without a positioned,
220
+ stacking-context ancestor the clone jumps to the wrong place or falls behind the
221
+ background. Add `overflow-x-clip` too if you use horizontal transitions
222
+ (`slide`, `drill`). Keep these layout classes on the outer wrapper, not on the
223
+ route boundary marker.
213
224
 
214
225
  ```tsx
215
226
  <div className="relative z-0 overflow-x-clip">
package/dist/internal.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var Nt=Object.defineProperty;var kt=(t,s,e)=>s in t?Nt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e;var z=(t,s,e)=>kt(t,typeof s!="symbol"?s+"":s,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("./multi-animation-uzEnQnrG.cjs");class Pt extends j.Animation{constructor(){super(...arguments);z(this,"child",null);z(this,"_state","idle");z(this,"_settled",!1);z(this,"listeners",new Set)}attach(e){const n=this.child;if(this.child=e,this._settled=!1,n){const l=n.getPose();n.complete(),e.matchInto(l)}e.playbackRate=this.playbackRate;const r=e.onComplete;e.onComplete=()=>{r==null||r(),this.child===e&&(this.child=null,this._state="idle",this._settled=!0),this.notify()};const u=e.onUpdate;e.onUpdate=l=>{var d;u==null||u(l),(d=this.onUpdate)==null||d.call(this,l),this.notify()},this._state==="paused"?e.pause():this._state==="reversing"?e.reverse():(this._state="playing",e.play()),this.notify()}play(){var e;this._state="playing",this._settled=!1,(e=this.child)==null||e.play(),this.notify()}reverse(){var e;this._state="reversing",this._settled=!1,(e=this.child)==null||e.reverse(),this.notify()}pause(){var e;this._state="paused",(e=this.child)==null||e.pause(),this.notify()}complete(){var e;(e=this.child)==null||e.complete(),this.notify()}get isAnimating(){var e;return((e=this.child)==null?void 0:e.isAnimating)??!1}get isPaused(){return this._state==="paused"}get isComplete(){return this._settled&&!this.child}get isReversing(){var e;return((e=this.child)==null?void 0:e.isReversing)??this._state==="reversing"}get progress(){var e;return((e=this.child)==null?void 0:e.progress)??0}findTimeForProgress(e){var n;return((n=this.child)==null?void 0:n.findTimeForProgress(e))??null}get playbackRate(){return super.playbackRate}set playbackRate(e){super.playbackRate=e,this.child&&(this.child.playbackRate=e),this.notify()}getPose(){var e;return((e=this.child)==null?void 0:e.getPose())??[]}getTimeline(){var e;return((e=this.child)==null?void 0:e.getTimeline())??[]}matchInto(e){var n;(n=this.child)==null||n.matchInto(e)}get activeChild(){return this.child}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(){for(const e of this.listeners)e()}}const It=(t,s)=>{var e;t.style.position="absolute",t.style.width="100%",t.style.top=`${-1*(((e=s==null?void 0:s.scrollOffset)==null?void 0:e.y)??0)}px`,t.style.left="0"},mt=new Set(["auto","scroll","overlay"]),Ht=t=>{let s=t.parentElement;for(;s&&s!==document.body;){const e=window.getComputedStyle(s);if(mt.has(e.overflowY)||mt.has(e.overflowX))return s;s=s.parentElement}return document.documentElement},Wt=t=>{let s=t.parentElement;for(;s&&s!==document.body;){const e=window.getComputedStyle(s).position;if(e==="relative"||e==="absolute"||e==="fixed"||e==="sticky")return s;s=s.parentElement}return document.body};function zt(t){const s=Object.keys(t);return Promise.all(s.map(e=>t[e])).then(e=>{const n={};return s.forEach((r,u)=>{n[r]=e[u]}),n})}function Bt(t){const s=t.filter(e=>e.symmetric).map(e=>({from:e.to,to:e.from,transition:e.transition}));return[...t,...s]}const Ft=1e6,gt=100,Kt=10;function Xt(t){const s=t.trim(),e=s.indexOf("#"),n=s.indexOf("?"),r=[e,n].filter(u=>u>=0).reduce((u,l)=>Math.min(u,l),s.length);return s.slice(0,r)}function at(t){const s=Xt(t);try{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(s))return at(new URL(s).pathname)}catch{}const n=(s.startsWith("/")?s:`/${s}`).replace(/\/+/g,"/");return(n.length>1?n.replace(/\/+$/g,""):n)||"/"}function $t(t){const s=t.trim();return s==="*"?"*":at(s)}function ot(t){return t==="/"?[]:t.slice(1).split("/")}function qt(t){return t.startsWith(":")||t.startsWith("[")&&t.endsWith("]")||t.startsWith("{")&&t.endsWith("}")}function rt(t,s){const e=at(t),n=$t(s);if(n==="*")return{matched:!0,specificity:0};if(e===n)return{matched:!0,specificity:Ft+ot(n).length*gt};const r=ot(e),u=ot(n);let l=0;for(let d=0;d<u.length;d++){const y=u[d],M=r[d],R=d===u.length-1;if(y===void 0)return{matched:!1,specificity:0};if((y==="*"||y==="**")&&R)return{matched:y==="**"?r.length>=d:r.length>d,specificity:l};if(M===void 0)return{matched:!1,specificity:0};if(y==="*"||qt(y)){l+=Kt;continue}if(y!==M)return{matched:!1,specificity:0};l+=gt}return{matched:r.length===u.length,specificity:l}}function Ut(t,s){return rt(t,s).matched}function Vt(t,s,e){let n;for(const r of e){const u=rt(t,r.from);if(!u.matched)continue;const l=rt(s,r.to);if(!l.matched)continue;const d=u.specificity+l.specificity;(!n||d>n.specificity)&&(n={transition:r.transition,specificity:d})}return(n==null?void 0:n.transition)??null}const Gt=768,Yt=10,Zt=10;function jt(t={}){const{preserveScroll:s=f=>f}=t,e=typeof s=="function"?s:()=>s;let n=null,r=!1,u=!1;const l=()=>{const f=(n==null?void 0:n.clientWidth)??0,a=f>0?f:typeof window<"u"?window.innerWidth:0;return a>0&&a<Gt},d=()=>(u||(r=l(),u=!0),r),y=f=>{var S;const a=e(d());if(a===!1)return{preserves:!1,shared:!1,storageKey:`path:${f}`};if(a===!0)return{preserves:!0,shared:!1,storageKey:`path:${f}`};const v=((S=a.exclude)==null?void 0:S.some(w=>Ut(f,w)))??!1,T=!v&&!!a.key;return{preserves:!v,shared:T,storageKey:T?`shared:${a.key}`:`path:${f}`}},M=f=>y(f).preserves;let R=null;const b=new Map;let x=null,O=!1,I=0;const H=()=>{n&&x&&!O&&b.set(y(x).storageKey,{x:n.scrollLeft,y:n.scrollTop})},K=f=>{if(!n)return;const a=y(f);if(a.preserves&&a.shared&&!b.has(a.storageKey))return;const v=a.preserves&&b.has(a.storageKey)?b.get(a.storageKey):{x:0,y:0};let T=0;const S=()=>{if(!n)return;n.scrollTo({top:v.y,left:v.x}),!(Math.abs(n.scrollTop-v.y)<1&&Math.abs(n.scrollLeft-v.x)<1)&&T<Yt&&(T++,requestAnimationFrame(S))};requestAnimationFrame(S)};return{initializeContext:(f,a)=>{O=!0;const v=++I;R=f,n||(n=Ht(f),r=l(),u=!0,typeof ResizeObserver<"u"&&new ResizeObserver(()=>{r=l()}).observe(n),(n===document.documentElement?window:n).addEventListener("scroll",H,{passive:!0})),x=a,K(a);let T=0;const S=()=>{v===I&&(T++,T>=Zt?O=!1:requestAnimationFrame(S))};requestAnimationFrame(S)},calculateScrollOffset:(f,a)=>{const v=f?y(f).storageKey:null,T=v&&b.has(v)?b.get(v):{x:0,y:0},S=a?y(a):null,w=S!=null&&S.preserves?S.storageKey:null,k=w&&b.has(w)?b.get(w):{x:0,y:0};return{x:-k.x+T.x,y:-k.y+T.y}},evictScrollPosition:f=>{b.delete(y(f).storageKey)},shouldPreserve:M,getScrollContainer:()=>n,getPositionedParentElement:()=>R?Wt(R):document.body,getScrollPosition:f=>{const a=f?y(f).storageKey:null;return a&&b.has(a)?b.get(a):{x:0,y:0}},getIsMobile:d}}const vt=30,bt=8,St=1.2,Et=30,Qt=600;function Jt(){let t=null,s=!1,e=!1,n=null,r=null,u=!1;const l=(h,p)=>{for(let m=0;m<h.length;m++){const E=h.item(m);if(E&&E.identifier===p)return E}return null},d=()=>{n!==null&&(clearTimeout(n),n=null)},y=()=>{r!==null&&(clearTimeout(r),r=null)},M=()=>{s=!0,e=!0,d(),y(),n=setTimeout(()=>{s=!1,e=!1,n=null},Qt)},R=h=>{if(h.touches.length!==1){t=null;return}const p=h.touches.item(0);if(!p){t=null;return}const m=window.innerWidth,E=p.clientX<=vt,L=p.clientX>=m-vt;if(!E&&!L){t=null;return}t={identifier:p.identifier,startX:p.clientX,startY:p.clientY,fromLeftEdge:E,moved:!1}},b=h=>{if(!t)return;if(h.touches.length!==1){t=null;return}const p=l(h.touches,t.identifier);if(!p){t=null;return}const m=p.clientX-t.startX,E=p.clientY-t.startY,L=Math.abs(m),f=Math.abs(E);if(f>bt&&f>L*St){t=null;return}const a=t.fromLeftEdge?m>0:m<0;L>bt&&L>f*St&&a&&(t.moved=!0)},x=h=>{if(!t)return;const p=l(h.changedTouches,t.identifier);if(!p){t=null;return}const m=p.clientX-t.startX,E=t.fromLeftEdge?m>0:m<0;if(t.moved&&E&&Math.abs(m)>=Et){M(),t=null;return}t.moved&&Math.abs(m)>=Et&&M(),t=null},O=()=>{t&&(t.moved&&M(),t=null)};return{initialize:()=>{if(typeof window>"u"||u)return;u=!0;const h={passive:!0,capture:!0};window.addEventListener("touchstart",R,h),window.addEventListener("touchmove",b,h),window.addEventListener("touchend",x,h),window.addEventListener("touchcancel",O,h)},destroy:()=>{if(typeof window>"u"||!u)return;u=!1;const h={capture:!0};window.removeEventListener("touchstart",R,h),window.removeEventListener("touchmove",b,h),window.removeEventListener("touchend",x,h),window.removeEventListener("touchcancel",O,h),d(),y(),t=null,s=!1,e=!1},isSwipeBack:()=>{const h=s||e;return h&&d(),h},onPageEnter:()=>{s=!1,d(),y(),r=setTimeout(()=>{e=!1,r=null},0)}}}function te(){let t=null;function s(){var n,r;t&&((n=t.outResolve)==null||n.call(t,null),(r=t.inResolve)==null||r.call(t,null),t=null)}function e(){if(t!=null&&t.from&&(t!=null&&t.to)&&(t!=null&&t.outResolve)&&(t!=null&&t.inResolve)){if(t.from===t.to){s();return}const n={from:t.from,to:t.to};t.outResolve(n),t.inResolve(n),t=null}}return{trigger(n,r){var l;r==="out"&&(t==null?void 0:t.to)===n&&!t.from&&((l=t.inResolve)==null||l.call(t,null),t={}),t&&(r==="out"&&t.from&&t.from!==n||r==="in"&&t.to&&t.to!==n)&&s(),t||(t={}),r==="out"?t.from=n:t.to=n},get(n){return new Promise(r=>{t||(t={}),n==="out"?t.outResolve=r:t.inResolve=r,e()})}}}const F=new Map;let G=null,Tt=!1;function At(t,s){if(t instanceof HTMLElement&&F.has(t)&&!t.isConnected){const e=F.get(t);F.delete(t),queueMicrotask(()=>e(s))}for(const e of Array.from(t.childNodes))At(e,s)}function ee(){if(Tt||typeof document>"u")return;Tt=!0,G=new MutationObserver(s=>{for(const e of s){const n={parent:e.target,nextSibling:e.nextSibling};for(const r of Array.from(e.removedNodes))At(r,n)}});const t=()=>{G==null||G.observe(document.body,{childList:!0,subtree:!0})};document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}function ne(t,s){return ee(),F.set(t,s),()=>{F.delete(t)}}const ct=new WeakMap;let Y=null;const Z="none !important";function B(t){const s=t.style.getPropertyValue("display");return t.style.getPropertyPriority("display")?`${s} !important`:s}function se(){return Y||(Y=new MutationObserver(t=>{for(const s of t){const e=s.target,n=ct.get(e);if(!n)continue;const r=B(e);r!==n.accounted&&(n.accounted=r,r===Z?(n.reactHidden=!0,n.onHide()):r!=="none"&&n.reactHidden&&(n.reactHidden=!1,n.onShow()))}}),Y)}function ie(t,s){const e=B(t),n={accounted:e,reactHidden:e===Z,onHide:s.onHide,onShow:s.onShow};return ct.set(t,n),se().observe(t,{attributes:!0,attributeFilter:["style"]}),{get isHidden(){return B(t)===Z},setDisplay(r,u=!1){r===null?t.style.removeProperty("display"):t.style.setProperty("display",r,u?"important":""),n.accounted=B(t)},sync(){n.accounted=B(t),n.reactHidden=n.accounted===Z},stop(){ct.delete(t)}}}function oe(t){return Array.isArray(t)}function Mt(t){const s=[];for(const e of t)oe(e)?s.push(...Mt(e)):s.push(e);return s}function re(t,s={}){const{transitions:e=[],middleware:n=(i,o)=>({from:i,to:o}),preserveScroll:r=i=>i}=t,u=s.host??new Pt,l=te(),d=typeof e=="function"?e:()=>e,y=Jt();y.initialize();const{initializeContext:M,calculateScrollOffset:R,evictScrollPosition:b,shouldPreserve:x,getScrollContainer:O,getPositionedParentElement:I,getScrollPosition:H,getIsMobile:K}=jt({preserveScroll:r}),X=new Map,h=()=>{const i=K();let o=X.get(i);return o||(o=Bt(Mt(d({isMobile:i}))),X.set(i,o)),o};let p=null,m=null;const E=new WeakMap,L=i=>{E.set(i,{parent:i.parentNode,nextSibling:i.nextSibling})},f=i=>{const o=E.get(i);return o||{parent:i.parentNode,nextSibling:i.nextSibling}},a=new WeakMap,v=new WeakMap;let T=0;const S=i=>{const o=typeof getComputedStyle<"u"?getComputedStyle(i).display:"";return o&&o!=="none"?o:"block"},w=(i,o)=>{o.visibleDisplay=i.style.getPropertyValue("display"),o.computedDisplay=S(i)},k=(i,o)=>{if(v.get(i)!==o)return;v.delete(i);const c=a.get(i);c&&(c.savedCss!==null&&(i.style.cssText=c.savedCss,c.savedCss=null),c.intent==="hidden"?c.vis.setDisplay("none",!0):c.visibleDisplay?(c.vis.setDisplay(c.visibleDisplay,!1),w(i,c)):(c.vis.setDisplay(null),w(i,c)))},Ct=(i,o,c,g,P)=>{const A=g.element,_=P.element,D=(g.mode??"unmount")==="hidden",{parent:q,nextSibling:J}=g.parent?{parent:g.parent,nextSibling:g.nextSibling}:f(A),U=R(o,c),tt={scrollOffset:U,from:{scroll:H(o)},to:{scroll:H(c)},get scrollingElement(){return O()||document.documentElement},get positionedParent(){return I()}};let C;if(D){C=A,C.style.top=`${-1*((U==null?void 0:U.y)??0)}px`;const N=a.get(_);N&&N.savedCss===null&&(N.savedCss=_.style.cssText)}else C=A,It(C,tt);x(o)||b(o);const V=D?++T:0;D&&(v.set(_,V),v.set(A,V));const ht=Promise.resolve(C),pt=Promise.resolve(_),yt=[],_t={from:ht,to:pt,context:tt,createElement:((N,et="div")=>{const W=document.createElement(et);return W.setAttribute("data-ssgoi-id",N),yt.push(W),W})},Dt=Promise.resolve(i.prepare?i.prepare(_t):{});zt({from:ht,to:pt,extras:Dt}).then(({from:N,to:et,extras:W})=>{!D&&q&&(J&&q.contains(J)?q.insertBefore(C,J):q.appendChild(C));const nt=i.animation({from:N,to:et,context:tt,...W}),st=nt.onComplete;nt.onComplete=()=>{st==null||st(),D?(k(A,V),k(_,V)):C.parentNode&&C.parentNode.removeChild(C);for(const it of yt)it.parentNode&&it.parentNode.removeChild(it)},u.attach(nt)})},$=(i,o)=>{const c=y.isSwipeBack();l.trigger(i,o),l.get(o).then(g=>{if(o==="in"&&y.onPageEnter(),!g)return;if(c){o==="out"&&g.from&&!x(g.from)&&b(g.from),p=null,m=null;return}if(o!=="in")return;const{from:P,to:A}=n(g.from,g.to),_=Vt(P,A,h()),Q=p,D=m;p=null,m=null,!(!_||!Q||!D)&&Ct(_,P,A,Q,D)})},xt=(i,o)=>{const c=a.get(i);if(!c)return;const g=c.intent==="hidden";if(c.intent="hidden",c.savedCss===null&&(c.savedCss=i.style.cssText),c.vis.setDisplay(c.computedDisplay||"block",!0),i.style.position="absolute",i.style.width="100%",i.style.left="0",g)return;const P=f(i);p={element:i,parent:P.parent,nextSibling:P.nextSibling,mode:"hidden"};const A=i.getAttribute("data-ssgoi-transition")??o;$(A,"out")},Ot=(i,o)=>{const c=a.get(i);if(!c||c.intent==="visible")return;c.intent="visible",w(i,c),c.savedCss!==null&&(i.style.cssText=c.savedCss,c.visibleDisplay?c.vis.setDisplay(c.visibleDisplay,!1):c.vis.setDisplay(null)),M(i,o),m={element:i,parent:i.parentElement,nextSibling:i.nextElementSibling};const g=i.getAttribute("data-ssgoi-transition")??o;$(g,"in")},Lt=(i,o,c)=>{const g=a.get(i);if(g&&(g.vis.stop(),a.delete(i),v.delete(i),g.intent==="hidden")){(p==null?void 0:p.element)===i&&(p=null),(m==null?void 0:m.element)===i&&(m=null);return}const P=c??f(i);p={element:i,parent:P.parent,nextSibling:P.nextSibling,mode:"unmount"};const A=i.getAttribute("data-ssgoi-transition")??o;$(A,"out")},ut=new WeakSet,dt=(i,o)=>{if(ut.has(o))return;ut.add(o),L(o);const c=ie(o,{onHide:()=>xt(o,i),onShow:()=>Ot(o,i)}),g={vis:c,savedCss:null,intent:c.isHidden?"hidden":"visible",visibleDisplay:"",computedDisplay:"block"};a.set(o,g),c.isHidden||(w(o,g),M(o,i),m={element:o,parent:o.parentElement,nextSibling:o.nextElementSibling},$(i,"in")),ne(o,P=>Lt(o,i,P))},ft=new Map;return{register:dt,refFor:i=>{let o=ft.get(i);return o||(o=c=>{c&&dt(i,c)},ft.set(i,o)),o}}}const Rt="data-ssgoi-root",ce=`[${Rt}]`,lt="data-ssgoi-transition",wt=`[${lt}]`,le="[data-ssgoi-clone]";function ae(){return typeof MutationObserver<"u"&&typeof HTMLElement<"u"&&typeof Node<"u"}function ue(t){return t.nodeType===Node.ELEMENT_NODE}function de(t){return t instanceof HTMLElement}function fe(t,s){if(!ae())return()=>{};t.setAttribute(Rt,"");const e=l=>l.closest(ce)===t,n=l=>{if(!de(l)||!e(l)||l.closest(le))return;const d=l.getAttribute(lt);d!==null&&s.register(d,l)},r=l=>{if(ue(l)){l.matches(wt)&&n(l);for(const d of l.querySelectorAll(wt))n(d)}},u=new MutationObserver(l=>{for(const d of l){if(d.type==="attributes"){n(d.target);continue}for(const y of d.addedNodes)r(y)}});return u.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[lt]}),r(t),()=>u.disconnect()}exports.Animation=j.Animation;exports.MultiAnimation=j.MultiAnimation;exports.WebAnimation=j.WebAnimation;exports.HostAnimation=Pt;exports.createSggoiTransitionContext=re;exports.observeSsgoiTransitions=fe;
1
+ "use strict";var It=Object.defineProperty;var Ht=(t,n,e)=>n in t?It(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var F=(t,n,e)=>Ht(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=require("./multi-animation-uzEnQnrG.cjs");class Mt extends Q.Animation{constructor(){super(...arguments);F(this,"child",null);F(this,"_state","idle");F(this,"_settled",!1);F(this,"listeners",new Set)}attach(e){const s=this.child;if(this.child=e,this._settled=!1,s){const l=s.getPose();s.complete(),e.matchInto(l)}e.playbackRate=this.playbackRate;const o=e.onComplete;e.onComplete=()=>{o==null||o(),this.child===e&&(this.child=null,this._state="idle",this._settled=!0),this.notify()};const a=e.onUpdate;e.onUpdate=l=>{var u;a==null||a(l),(u=this.onUpdate)==null||u.call(this,l),this.notify()},this._state==="paused"?e.pause():this._state==="reversing"?e.reverse():(this._state="playing",e.play()),this.notify()}play(){var e;this._state="playing",this._settled=!1,(e=this.child)==null||e.play(),this.notify()}reverse(){var e;this._state="reversing",this._settled=!1,(e=this.child)==null||e.reverse(),this.notify()}pause(){var e;this._state="paused",(e=this.child)==null||e.pause(),this.notify()}complete(){var e;(e=this.child)==null||e.complete(),this.notify()}get isAnimating(){var e;return((e=this.child)==null?void 0:e.isAnimating)??!1}get isPaused(){return this._state==="paused"}get isComplete(){return this._settled&&!this.child}get isReversing(){var e;return((e=this.child)==null?void 0:e.isReversing)??this._state==="reversing"}get progress(){var e;return((e=this.child)==null?void 0:e.progress)??0}findTimeForProgress(e){var s;return((s=this.child)==null?void 0:s.findTimeForProgress(e))??null}get playbackRate(){return super.playbackRate}set playbackRate(e){super.playbackRate=e,this.child&&(this.child.playbackRate=e),this.notify()}getPose(){var e;return((e=this.child)==null?void 0:e.getPose())??[]}getTimeline(){var e;return((e=this.child)==null?void 0:e.getTimeline())??[]}matchInto(e){var s;(s=this.child)==null||s.matchInto(e)}get activeChild(){return this.child}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(){for(const e of this.listeners)e()}}const Wt=(t,n)=>{var e;t.style.position="absolute",t.style.width="100%",t.style.top=`${-1*(((e=n==null?void 0:n.scrollOffset)==null?void 0:e.y)??0)}px`,t.style.left="0"},vt=new Set(["auto","scroll","overlay"]),zt=t=>{let n=t.parentElement;for(;n&&n!==document.body;){const e=window.getComputedStyle(n);if(vt.has(e.overflowY)||vt.has(e.overflowX))return n;n=n.parentElement}return document.documentElement},Bt=t=>{let n=t.parentElement;for(;n&&n!==document.body;){const e=window.getComputedStyle(n).position;if(e==="relative"||e==="absolute"||e==="fixed"||e==="sticky")return n;n=n.parentElement}return document.body};function Ft(t){const n=Object.keys(t);return Promise.all(n.map(e=>t[e])).then(e=>{const s={};return n.forEach((o,a)=>{s[o]=e[a]}),s})}function Kt(t){const n=t.filter(e=>e.symmetric).map(e=>({from:e.to,to:e.from,transition:e.transition}));return[...t,...n]}const Xt=1e6,bt=100,$t=10;function qt(t){const n=t.trim(),e=n.indexOf("#"),s=n.indexOf("?"),o=[e,s].filter(a=>a>=0).reduce((a,l)=>Math.min(a,l),n.length);return n.slice(0,o)}function ut(t){const n=qt(t);try{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n))return ut(new URL(n).pathname)}catch{}const s=(n.startsWith("/")?n:`/${n}`).replace(/\/+/g,"/");return(s.length>1?s.replace(/\/+$/g,""):s)||"/"}function Ut(t){const n=t.trim();return n==="*"?"*":ut(n)}function rt(t){return t==="/"?[]:t.slice(1).split("/")}function Vt(t){return t.startsWith(":")||t.startsWith("[")&&t.endsWith("]")||t.startsWith("{")&&t.endsWith("}")}function ct(t,n){const e=ut(t),s=Ut(n);if(s==="*")return{matched:!0,specificity:0};if(e===s)return{matched:!0,specificity:Xt+rt(s).length*bt};const o=rt(e),a=rt(s);let l=0;for(let u=0;u<a.length;u++){const g=a[u],b=o[u],_=u===a.length-1;if(g===void 0)return{matched:!1,specificity:0};if((g==="*"||g==="**")&&_)return{matched:g==="**"?o.length>=u:o.length>u,specificity:l};if(b===void 0)return{matched:!1,specificity:0};if(g==="*"||Vt(g)){l+=$t;continue}if(g!==b)return{matched:!1,specificity:0};l+=bt}return{matched:o.length===a.length,specificity:l}}function Gt(t,n){return ct(t,n).matched}function Yt(t,n,e){let s;for(const o of e){const a=ct(t,o.from);if(!a.matched)continue;const l=ct(n,o.to);if(!l.matched)continue;const u=a.specificity+l.specificity;(!s||u>s.specificity)&&(s={transition:o.transition,specificity:u})}return(s==null?void 0:s.transition)??null}const Zt=768,jt=10,Qt=10;function Jt(t={}){const{preserveScroll:n=f=>f,resolvePath:e=f=>f}=t,s=typeof n=="function"?n:()=>n;let o=null,a=!1,l=!1;const u=()=>{const f=(o==null?void 0:o.clientWidth)??0,d=f>0?f:typeof window<"u"?window.innerWidth:0;return d>0&&d<Zt},g=()=>(l||(a=u(),l=!0),a),b=f=>{var R;const d=e(f),y=s(g());if(y===!1)return{preserves:!1,shared:!1,storageKey:`path:${d}`};if(y===!0)return{preserves:!0,shared:!1,storageKey:`path:${d}`};const E=((R=y.exclude)==null?void 0:R.some(C=>Gt(d,C)))??!1,P=!E&&!!y.key;return{preserves:!E,shared:P,storageKey:P?`shared:${y.key}`:`path:${d}`}},_=f=>b(f).preserves;let O=null;const T=new Map;let L=null,k=!1,W=0;const $=()=>{o&&L&&!k&&T.set(b(L).storageKey,{x:o.scrollLeft,y:o.scrollTop})},z=f=>{if(!o)return;const d=b(f);if(d.preserves&&d.shared&&!T.has(d.storageKey))return;const y=d.preserves&&T.has(d.storageKey)?T.get(d.storageKey):{x:0,y:0};let E=0;const P=()=>{if(!o)return;o.scrollTo({top:y.y,left:y.x}),!(Math.abs(o.scrollTop-y.y)<1&&Math.abs(o.scrollLeft-y.x)<1)&&E<jt&&(E++,requestAnimationFrame(P))};requestAnimationFrame(P)};return{initializeContext:(f,d)=>{k=!0;const y=++W;O=f,o||(o=zt(f),a=u(),l=!0,typeof ResizeObserver<"u"&&new ResizeObserver(()=>{a=u()}).observe(o),(o===document.documentElement?window:o).addEventListener("scroll",$,{passive:!0})),L=d,z(d);let E=0;const P=()=>{y===W&&(E++,E>=Qt?k=!1:requestAnimationFrame(P))};requestAnimationFrame(P)},calculateScrollOffset:(f,d)=>{const y=f?b(f).storageKey:null,E=y&&T.has(y)?T.get(y):{x:0,y:0},P=d?b(d):null,R=P!=null&&P.preserves?P.storageKey:null,C=R&&T.has(R)?T.get(R):{x:0,y:0};return{x:-C.x+E.x,y:-C.y+E.y}},evictScrollPosition:f=>{T.delete(b(f).storageKey)},shouldPreserve:_,getScrollContainer:()=>o,getPositionedParentElement:()=>O?Bt(O):document.body,getScrollPosition:f=>{const d=f?b(f).storageKey:null;return d&&T.has(d)?T.get(d):{x:0,y:0}},getIsMobile:g}}const St=30,Et=8,Tt=1.2,wt=30,te=600;function ee(){let t=null,n=!1,e=!1,s=null,o=null,a=!1;const l=(h,v)=>{for(let S=0;S<h.length;S++){const m=h.item(S);if(m&&m.identifier===v)return m}return null},u=()=>{s!==null&&(clearTimeout(s),s=null)},g=()=>{o!==null&&(clearTimeout(o),o=null)},b=()=>{n=!0,e=!0,u(),g(),s=setTimeout(()=>{n=!1,e=!1,s=null},te)},_=h=>{if(h.touches.length!==1){t=null;return}const v=h.touches.item(0);if(!v){t=null;return}const S=window.innerWidth,m=v.clientX<=St,w=v.clientX>=S-St;if(!m&&!w){t=null;return}t={identifier:v.identifier,startX:v.clientX,startY:v.clientY,fromLeftEdge:m,moved:!1}},O=h=>{if(!t)return;if(h.touches.length!==1){t=null;return}const v=l(h.touches,t.identifier);if(!v){t=null;return}const S=v.clientX-t.startX,m=v.clientY-t.startY,w=Math.abs(S),I=Math.abs(m);if(I>Et&&I>w*Tt){t=null;return}const f=t.fromLeftEdge?S>0:S<0;w>Et&&w>I*Tt&&f&&(t.moved=!0)},T=h=>{if(!t)return;const v=l(h.changedTouches,t.identifier);if(!v){t=null;return}const S=v.clientX-t.startX,m=t.fromLeftEdge?S>0:S<0;if(t.moved&&m&&Math.abs(S)>=wt){b(),t=null;return}t.moved&&Math.abs(S)>=wt&&b(),t=null},L=()=>{t&&(t.moved&&b(),t=null)};return{initialize:()=>{if(typeof window>"u"||a)return;a=!0;const h={passive:!0,capture:!0};window.addEventListener("touchstart",_,h),window.addEventListener("touchmove",O,h),window.addEventListener("touchend",T,h),window.addEventListener("touchcancel",L,h)},destroy:()=>{if(typeof window>"u"||!a)return;a=!1;const h={capture:!0};window.removeEventListener("touchstart",_,h),window.removeEventListener("touchmove",O,h),window.removeEventListener("touchend",T,h),window.removeEventListener("touchcancel",L,h),u(),g(),t=null,n=!1,e=!1},isSwipeBack:()=>{const h=n||e;return h&&u(),h},onPageEnter:()=>{n=!1,u(),g(),o=setTimeout(()=>{e=!1,o=null},0)}}}function ne(){let t=null;function n(){var s,o;t&&((s=t.outResolve)==null||s.call(t,null),(o=t.inResolve)==null||o.call(t,null),t=null)}function e(){if(t!=null&&t.from&&(t!=null&&t.to)&&(t!=null&&t.outResolve)&&(t!=null&&t.inResolve)){if(t.from===t.to){n();return}const s={from:t.from,to:t.to};t.outResolve(s),t.inResolve(s),t=null}}return{trigger(s,o){var l;o==="out"&&(t==null?void 0:t.to)===s&&!t.from&&((l=t.inResolve)==null||l.call(t,null),t={}),t&&(o==="out"&&t.from&&t.from!==s||o==="in"&&t.to&&t.to!==s)&&n(),t||(t={}),o==="out"?t.from=s:t.to=s},get(s){return new Promise(o=>{t||(t={}),s==="out"?t.outResolve=o:t.inResolve=o,e()})}}}const X=new Map;let Y=null,Pt=!1;function Rt(t,n){if(t instanceof HTMLElement&&X.has(t)&&!t.isConnected){const e=X.get(t);X.delete(t),queueMicrotask(()=>e(n))}for(const e of Array.from(t.childNodes))Rt(e,n)}function se(){if(Pt||typeof document>"u")return;Pt=!0,Y=new MutationObserver(n=>{for(const e of n){const s={parent:e.target,nextSibling:e.nextSibling};for(const o of Array.from(e.removedNodes))Rt(o,s)}});const t=()=>{Y==null||Y.observe(document.body,{childList:!0,subtree:!0})};document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}function ie(t,n){return se(),X.set(t,n),()=>{X.delete(t)}}const lt=new WeakMap;let Z=null;const j="none !important";function K(t){const n=t.style.getPropertyValue("display");return t.style.getPropertyPriority("display")?`${n} !important`:n}function oe(){return Z||(Z=new MutationObserver(t=>{for(const n of t){const e=n.target,s=lt.get(e);if(!s)continue;const o=K(e);o!==s.accounted&&(s.accounted=o,o===j?(s.reactHidden=!0,s.onHide()):o!=="none"&&s.reactHidden&&(s.reactHidden=!1,s.onShow()))}}),Z)}function re(t,n){const e=K(t),s={accounted:e,reactHidden:e===j,onHide:n.onHide,onShow:n.onShow};return lt.set(t,s),oe().observe(t,{attributes:!0,attributeFilter:["style"]}),{get isHidden(){return K(t)===j},setDisplay(o,a=!1){o===null?t.style.removeProperty("display"):t.style.setProperty("display",o,a?"important":""),s.accounted=K(t)},sync(){s.accounted=K(t),s.reactHidden=s.accounted===j},stop(){lt.delete(t)}}}function ce(t){return Array.isArray(t)}function Ct(t){const n=[];for(const e of t)ce(e)?n.push(...Ct(e)):n.push(e);return n}function le(t,n={}){const{transitions:e=[],middleware:s=(i,r)=>({from:i,to:r}),preserveScroll:o=i=>i}=t,a=n.host??new Mt,l=ne(),u=typeof e=="function"?e:()=>e,g=ee();g.initialize();const b=new Map,_=i=>{let r=b.get(i);return r===void 0&&(r=s(i,i).from,b.set(i,r)),r},{initializeContext:O,calculateScrollOffset:T,evictScrollPosition:L,shouldPreserve:k,getScrollContainer:W,getPositionedParentElement:$,getScrollPosition:z,getIsMobile:h}=Jt({preserveScroll:o,resolvePath:_}),v=new Map,S=()=>{const i=h();let r=v.get(i);return r||(r=Kt(Ct(u({isMobile:i}))),v.set(i,r)),r};let m=null,w=null;const I=new WeakMap,f=i=>{I.set(i,{parent:i.parentNode,nextSibling:i.nextSibling})},d=i=>{const r=I.get(i);return r||{parent:i.parentNode,nextSibling:i.nextSibling}},y=new WeakMap,E=new WeakMap;let P=0;const R=i=>{const r=typeof getComputedStyle<"u"?getComputedStyle(i).display:"";return r&&r!=="none"?r:"block"},C=(i,r)=>{r.visibleDisplay=i.style.getPropertyValue("display"),r.computedDisplay=R(i)},dt=(i,r)=>{if(E.get(i)!==r)return;E.delete(i);const c=y.get(i);c&&(c.savedCss!==null&&(i.style.cssText=c.savedCss,c.savedCss=null),c.intent==="hidden"?c.vis.setDisplay("none",!0):c.visibleDisplay?(c.vis.setDisplay(c.visibleDisplay,!1),C(i,c)):(c.vis.setDisplay(null),C(i,c)))},Ot=(i,r,c,p,A)=>{const M=p.element,D=A.element,N=(p.mode??"unmount")==="hidden",{parent:U,nextSibling:tt}=p.parent?{parent:p.parent,nextSibling:p.nextSibling}:d(M),V=T(r,c),et={scrollOffset:V,from:{scroll:z(r)},to:{scroll:z(c)},get scrollingElement(){return W()||document.documentElement},get positionedParent(){return $()}};let x;if(N){x=M,x.style.top=`${-1*((V==null?void 0:V.y)??0)}px`;const H=y.get(D);H&&H.savedCss===null&&(H.savedCss=D.style.cssText)}else x=M,Wt(x,et);k(r)||L(r);const G=N?++P:0;N&&(E.set(D,G),E.set(M,G));const yt=Promise.resolve(x),mt=Promise.resolve(D),gt=[],Nt={from:yt,to:mt,context:et,createElement:((H,nt="div")=>{const B=document.createElement(nt);return B.setAttribute("data-ssgoi-id",H),gt.push(B),B})},kt=Promise.resolve(i.prepare?i.prepare(Nt):{});Ft({from:yt,to:mt,extras:kt}).then(({from:H,to:nt,extras:B})=>{!N&&U&&(tt&&U.contains(tt)?U.insertBefore(x,tt):U.appendChild(x));const st=i.animation({from:H,to:nt,context:et,...B}),it=st.onComplete;st.onComplete=()=>{it==null||it(),N?(dt(M,G),dt(D,G)):x.parentNode&&x.parentNode.removeChild(x);for(const ot of gt)ot.parentNode&&ot.parentNode.removeChild(ot)},a.attach(st)})},q=(i,r)=>{const c=g.isSwipeBack();l.trigger(i,r),l.get(r).then(p=>{if(r==="in"&&g.onPageEnter(),!p)return;if(c){r==="out"&&p.from&&!k(p.from)&&L(p.from),m=null,w=null;return}if(r!=="in")return;const{from:A,to:M}=s(p.from,p.to),D=Yt(A,M,S()),J=m,N=w;m=null,w=null,!(!D||!J||!N)&&Ot(D,p.from,p.to,J,N)})},Lt=(i,r)=>{const c=y.get(i);if(!c)return;const p=c.intent==="hidden";if(c.intent="hidden",c.savedCss===null&&(c.savedCss=i.style.cssText),c.vis.setDisplay(c.computedDisplay||"block",!0),i.style.position="absolute",i.style.width="100%",i.style.left="0",p)return;const A=d(i);m={element:i,parent:A.parent,nextSibling:A.nextSibling,mode:"hidden"};const M=i.getAttribute("data-ssgoi-transition")??r;q(M,"out")},_t=(i,r)=>{const c=y.get(i);if(!c||c.intent==="visible")return;c.intent="visible",C(i,c),c.savedCss!==null&&(i.style.cssText=c.savedCss,c.visibleDisplay?c.vis.setDisplay(c.visibleDisplay,!1):c.vis.setDisplay(null)),O(i,r),w={element:i,parent:i.parentElement,nextSibling:i.nextElementSibling};const p=i.getAttribute("data-ssgoi-transition")??r;q(p,"in")},Dt=(i,r,c)=>{const p=y.get(i);if(p&&(p.vis.stop(),y.delete(i),E.delete(i),p.intent==="hidden")){(m==null?void 0:m.element)===i&&(m=null),(w==null?void 0:w.element)===i&&(w=null);return}const A=c??d(i);m={element:i,parent:A.parent,nextSibling:A.nextSibling,mode:"unmount"};const M=i.getAttribute("data-ssgoi-transition")??r;q(M,"out")},ft=new WeakSet,ht=(i,r)=>{if(ft.has(r))return;ft.add(r),f(r);const c=re(r,{onHide:()=>Lt(r,i),onShow:()=>_t(r,i)}),p={vis:c,savedCss:null,intent:c.isHidden?"hidden":"visible",visibleDisplay:"",computedDisplay:"block"};y.set(r,p),c.isHidden||(C(r,p),O(r,i),w={element:r,parent:r.parentElement,nextSibling:r.nextElementSibling},q(i,"in")),ie(r,A=>Dt(r,i,A))},pt=new Map;return{register:ht,refFor:i=>{let r=pt.get(i);return r||(r=c=>{c&&ht(i,c)},pt.set(i,r)),r}}}const xt="data-ssgoi-root",ae=`[${xt}]`,at="data-ssgoi-transition",At=`[${at}]`,ue="[data-ssgoi-clone]";function de(){return typeof MutationObserver<"u"&&typeof HTMLElement<"u"&&typeof Node<"u"}function fe(t){return t.nodeType===Node.ELEMENT_NODE}function he(t){return t instanceof HTMLElement}function pe(t,n){if(!de())return()=>{};t.setAttribute(xt,"");const e=l=>l.closest(ae)===t,s=l=>{if(!he(l)||!e(l)||l.closest(ue))return;const u=l.getAttribute(at);u!==null&&n.register(u,l)},o=l=>{if(fe(l)){l.matches(At)&&s(l);for(const u of l.querySelectorAll(At))s(u)}},a=new MutationObserver(l=>{for(const u of l){if(u.type==="attributes"){s(u.target);continue}for(const g of u.addedNodes)o(g)}});return a.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[at]}),o(t),()=>a.disconnect()}exports.Animation=Q.Animation;exports.MultiAnimation=Q.MultiAnimation;exports.WebAnimation=Q.WebAnimation;exports.HostAnimation=Mt;exports.createSggoiTransitionContext=le;exports.observeSsgoiTransitions=pe;