@ssgoi/core 7.2.0 → 7.3.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/animation/animation.d.ts +21 -0
  2. package/dist/animation/animation.d.ts.map +1 -1
  3. package/dist/animation/host-animation.d.ts +28 -19
  4. package/dist/animation/host-animation.d.ts.map +1 -1
  5. package/dist/animation/multi-animation.d.ts +13 -2
  6. package/dist/animation/multi-animation.d.ts.map +1 -1
  7. package/dist/animation/web-animation.d.ts +69 -3
  8. package/dist/animation/web-animation.d.ts.map +1 -1
  9. package/dist/animation/web-presentation.d.ts +25 -0
  10. package/dist/animation/web-presentation.d.ts.map +1 -0
  11. package/dist/index.cjs +3 -3
  12. package/dist/index.d.ts +4 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +1206 -1184
  15. package/dist/internal.cjs +1 -1
  16. package/dist/internal.js +924 -631
  17. package/dist/{page-motion-MEazegOU.js → page-motion-CoPTk-Gd.js} +1 -1
  18. package/dist/{page-motion-DF3fFkOw.cjs → page-motion-Dhj3UfzO.cjs} +1 -1
  19. package/dist/provider-BLf6XeXT.js +291 -0
  20. package/dist/provider-JDtJ5Jzf.cjs +1 -0
  21. package/dist/retain-opacity-BFlsDhI7.cjs +1 -0
  22. package/dist/retain-opacity-Dvv9gi8-.js +1141 -0
  23. package/dist/runtime/index.d.ts +1 -0
  24. package/dist/runtime/index.d.ts.map +1 -1
  25. package/dist/runtime/motion-matching.d.ts +31 -0
  26. package/dist/runtime/motion-matching.d.ts.map +1 -0
  27. package/dist/runtime/timeline.d.ts +6 -2
  28. package/dist/runtime/timeline.d.ts.map +1 -1
  29. package/dist/runtime.cjs +1 -1
  30. package/dist/runtime.js +29 -25
  31. package/dist/ssgoi-transition/create-ssgoi-transition-context.d.ts.map +1 -1
  32. package/dist/transitions/blind/transition.d.ts.map +1 -1
  33. package/dist/transitions/crossfade.d.ts +1 -6
  34. package/dist/transitions/crossfade.d.ts.map +1 -1
  35. package/dist/transitions/film/transition.d.ts.map +1 -1
  36. package/dist/transitions/hero/in-place.d.ts +5 -2
  37. package/dist/transitions/hero/in-place.d.ts.map +1 -1
  38. package/dist/transitions/hero/provider/chrome/fade.d.ts.map +1 -1
  39. package/dist/transitions/hero/provider/chrome/static.d.ts.map +1 -1
  40. package/dist/transitions/hero/transition.d.ts.map +1 -1
  41. package/dist/transitions/hero/types.d.ts +2 -1
  42. package/dist/transitions/hero/types.d.ts.map +1 -1
  43. package/dist/transitions/shared-visibility.d.ts +2 -0
  44. package/dist/transitions/shared-visibility.d.ts.map +1 -0
  45. package/dist/transitions/sheet/transition.d.ts.map +1 -1
  46. package/dist/transitions/zoom/crossfade.d.ts.map +1 -1
  47. package/dist/transitions/zoom/provider/blur.d.ts.map +1 -1
  48. package/dist/transitions/zoom/transition.d.ts.map +1 -1
  49. package/dist/transitions/zoom/types.d.ts +2 -1
  50. package/dist/transitions/zoom/types.d.ts.map +1 -1
  51. package/dist/types/index.d.ts +4 -0
  52. package/dist/types/index.d.ts.map +1 -1
  53. package/dist/utils/index.d.ts +1 -0
  54. package/dist/utils/index.d.ts.map +1 -1
  55. package/dist/utils/retain-opacity.d.ts +7 -0
  56. package/dist/utils/retain-opacity.d.ts.map +1 -0
  57. package/package.json +1 -1
  58. package/dist/multi-animation-Du9W3ZS_.js +0 -503
  59. package/dist/multi-animation-hDUcfD7W.cjs +0 -1
  60. package/dist/provider-Cea0Pfm1.js +0 -232
  61. package/dist/provider-D9Q2URox.cjs +0 -1
package/dist/internal.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var Qe=Object.defineProperty;var et=(t,n,e)=>n in t?Qe(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var J=(t,n,e)=>et(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Te=require("./resolve-transition-rule-BL12rDDu.cjs"),de=require("./multi-animation-hDUcfD7W.cjs"),tt=require("./provider-D9Q2URox.cjs");class Ue extends de.Animation{constructor(){super(...arguments);J(this,"child",null);J(this,"_state","idle");J(this,"_settled",!1);J(this,"listeners",new Set)}attach(e){const o=this.child;if(this.child=e,this._settled=!1,o){const u=o.getPose();o.complete(),e.matchInto(u)}e.playbackRate=this.playbackRate;const c=e.onComplete;e.onComplete=()=>{c==null||c(),this.child===e&&(this.child=null,this._state="idle",this._settled=!0),this.notify()};const s=e.onUpdate;e.onUpdate=u=>{var i;s==null||s(u),(i=this.onUpdate)==null||i.call(this,u),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 o;return((o=this.child)==null?void 0:o.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 o;(o=this.child)==null||o.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 nt=(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"},Le=new Set(["auto","scroll","overlay"]),ot=t=>{let n=t.parentElement;for(;n&&n!==document.body;){const e=window.getComputedStyle(n);if(Le.has(e.overflowY)||Le.has(e.overflowX))return n;n=n.parentElement}return document.documentElement},rt=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 st(t){const n=Object.keys(t);return Promise.all(n.map(e=>t[e])).then(e=>{const o={};return n.forEach((c,s)=>{o[c]=e[s]}),o})}const be=new WeakMap;function it(t){let n=be.get(t);if(!n){const o=t.ownerDocument,s=t===o.documentElement||t===o.scrollingElement?o:t,u=f=>{f.type==="wheel"&&f.ctrlKey||f.type==="touchmove"&&f.touches.length>1||f.cancelable&&f.preventDefault()},i={passive:!1,capture:!0};s.addEventListener("wheel",u,i),s.addEventListener("touchmove",u,i);const y=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"," "]),h=f=>{var g,R;const d=f;if(!(d.defaultPrevented||d.altKey||!y.has(d.key))){for(const I of d.composedPath()){const x=I;if(x.isContentEditable||(g=x.matches)!=null&&g.call(x,"input, textarea, select, [role=slider], [role=spinbutton], [role=listbox], [role=menu], [role=tablist]")||d.key===" "&&((R=x.matches)!=null&&R.call(x,"button, [role=button]")))return}d.cancelable&&d.preventDefault()}};s.addEventListener("keydown",h,{capture:!0}),n={owners:0,restore(){s.removeEventListener("wheel",u,{capture:!0}),s.removeEventListener("touchmove",u,{capture:!0}),s.removeEventListener("keydown",h,{capture:!0})}},be.set(t,n)}n.owners++;let e=!1;return()=>{e||(e=!0,--n.owners===0&&(be.delete(t),n.restore()))}}const lt=768,ct=10,at=10;function ut(t={}){const{resolvePath:n=m=>m}=t;let e=null,o=null;const c=new Set,s=m=>{const S=m&&e?it(e):()=>{},M=()=>{c.delete(M)&&S()};return c.add(M),M};let u=!1,i=!1;const y=()=>{const m=(e==null?void 0:e.clientWidth)??0,S=m>0?m:typeof window<"u"?window.innerWidth:0;return S>0&&S<lt},h=()=>(i||(u=y(),i=!0),u),f=m=>`path:${n(m)}`;let d=null;const g=new Map;let R=null,I=!1,x=0,B=0,w=0;const p=()=>{e&&R&&!I&&!c.size&&g.set(f(R),{x:e.scrollLeft,y:e.scrollTop})},b=(m,S,M)=>{if(!e)return;const D=++B,H=f(m),C=S&&g.has(H)?g.get(H):{x:0,y:0};let N=0;const K=()=>{if(!e||M!==x||D!==B)return;S||g.set(H,C),e.scrollTo({top:C.y,left:C.x,behavior:"instant"}),!(Math.abs(e.scrollTop-C.y)<1&&Math.abs(e.scrollLeft-C.x)<1)&&N<ct&&(N++,requestAnimationFrame(K))};requestAnimationFrame(K)};return{beginTransition:s,disconnect(){++x,++B;for(const m of c)m();e&&(e===document.documentElement?window:e).removeEventListener("scroll",p),o==null||o.disconnect(),o=null,e=null,d=null,R=null,i=!1},initializeContext:(m,S,M)=>{I=!0;const D=R===S?x:++x;d=m,e||(e=ot(m),u=y(),i=!0,typeof ResizeObserver<"u"&&(o=new ResizeObserver(()=>{u=y()}),o.observe(e)),(e===document.documentElement?window:e).addEventListener("scroll",p,{passive:!0})),R=S;const H=f(S),C=g.get(H),N=U=>{D===x&&(w=D,U&&C&&g.set(H,C),b(S,U,D))};M!==void 0?N(M):requestAnimationFrame(()=>{w!==D&&D===x&&N(!1)});let K=0;const A=()=>{D===x&&(K++,K>=at?I=!1:requestAnimationFrame(A))};return requestAnimationFrame(A),N},calculateScrollOffset:(m,S,M=!1)=>{const D=m?f(m):null,H=D&&g.has(D)?g.get(D):{x:0,y:0},C=S&&M?f(S):null,N=C&&g.has(C)?g.get(C):{x:0,y:0};return{x:-N.x+H.x,y:-N.y+H.y}},evictScrollPosition:m=>{g.delete(f(m))},getScrollContainer:()=>e,getPositionedParentElement:()=>d?rt(d):document.body,getScrollPosition:(m,S=!0)=>{if(!S)return{x:0,y:0};const M=m?f(m):null;return M&&g.has(M)?g.get(M):{x:0,y:0}},getIsMobile:h}}const _e=30,De=8,He=1.2,Ne=30,dt=600;function ft(){let t=null,n=!1,e=!1,o=null,c=null,s=!1;const u=(p,b)=>{for(let T=0;T<p.length;T++){const O=p.item(T);if(O&&O.identifier===b)return O}return null},i=()=>{o!==null&&(clearTimeout(o),o=null)},y=()=>{c!==null&&(clearTimeout(c),c=null)},h=()=>{n=!0,e=!0,i(),y(),o=setTimeout(()=>{n=!1,e=!1,o=null},dt)},f=p=>{if(p.touches.length!==1){t=null;return}const b=p.touches.item(0);if(!b){t=null;return}const T=window.innerWidth,O=b.clientX<=_e,F=b.clientX>=T-_e;if(!O&&!F){t=null;return}t={identifier:b.identifier,startX:b.clientX,startY:b.clientY,fromLeftEdge:O,moved:!1}},d=p=>{if(!t)return;if(p.touches.length!==1){t=null;return}const b=u(p.touches,t.identifier);if(!b){t=null;return}const T=b.clientX-t.startX,O=b.clientY-t.startY,F=Math.abs(T),q=Math.abs(O);if(q>De&&q>F*He){t=null;return}const ee=t.fromLeftEdge?T>0:T<0;F>De&&F>q*He&&ee&&(t.moved=!0)},g=p=>{if(!t)return;const b=u(p.changedTouches,t.identifier);if(!b){t=null;return}const T=b.clientX-t.startX,O=t.fromLeftEdge?T>0:T<0;if(t.moved&&O&&Math.abs(T)>=Ne){h(),t=null;return}t.moved&&Math.abs(T)>=Ne&&h(),t=null},R=()=>{t&&(t.moved&&h(),t=null)};return{initialize:()=>{if(typeof window>"u"||s)return;s=!0;const p={passive:!0,capture:!0};window.addEventListener("touchstart",f,p),window.addEventListener("touchmove",d,p),window.addEventListener("touchend",g,p),window.addEventListener("touchcancel",R,p)},destroy:()=>{if(typeof window>"u"||!s)return;s=!1;const p={capture:!0};window.removeEventListener("touchstart",f,p),window.removeEventListener("touchmove",d,p),window.removeEventListener("touchend",g,p),window.removeEventListener("touchcancel",R,p),i(),y(),t=null,n=!1,e=!1},isSwipeBack:()=>{const p=n||e;return p&&i(),p},onPageEnter:()=>{n=!1,i(),y(),c=setTimeout(()=>{e=!1,c=null},0)}}}const Ie="__ssgoi_entry_v1",Ee=new WeakMap,Xe={read:()=>null,previous:()=>null,dispose(){}};function pt(){if(typeof window>"u")return Xe;const t=window.navigation,n=window;let e=Ee.get(n);e||(e=ht(n,t),Ee.set(n,e)),e.users++;const o=e;let c=!1;return{read:o.read,previous:o.previous,dispose(){c||(c=!0,--o.users===0&&(o.dispose(),Ee.delete(n)))}}}function We(t){return t&&typeof t.key=="string"&&typeof t.url=="string"&&Number.isSafeInteger(t.index)&&t.index>=0?{key:t.key,index:t.index,url:t.url}:null}function Se(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===Object.prototype}function ht(t,n){var B;const e=t.history,o=e.pushState,c=e.replaceState,s=`${Date.now()}-${Math.random().toString(36).slice(2)}-`;let u=0,i=!0,y=null,h=null;const f=()=>{const w=We(n==null?void 0:n.currentEntry);return(w==null?void 0:w.url)===t.location.href?w:null},d=()=>{const w=e.state,p=Se(w)?w[Ie]:null;return!Se(p)||typeof p.key!="string"||!p.key.startsWith(s)||!Number.isSafeInteger(p.index)?f():{key:p.key,index:p.index,url:t.location.href}},g=(w,p)=>w!==null&&!Se(w)?w:{...w,[Ie]:p},R=w=>({key:`${s}${++u}`,index:w});try{c.call(e,g(e.state,R(((B=f())==null?void 0:B.index)??0)),"")}catch{return{...Xe,read:f,users:0}}const I=function(w,p,b){var F;if(!i)return o.call(this,w,p,b);const T=d(),O=R(((T==null?void 0:T.index)??0)+1);o.call(this,g(w,O),p,b),y=T,h=((F=d())==null?void 0:F.key)??null},x=function(w,p,b){if(!i)return c.call(this,w,p,b);const T=d();c.call(this,g(w,T??R(0)),p,b)};return e.pushState=I,e.replaceState=x,{users:0,read:d,previous:()=>{var p;if(((p=d())==null?void 0:p.key)===h)return y;const w=f();return w?We(n==null?void 0:n.entries().find(b=>b.index===w.index-1)):null},dispose(){i=!1,e.pushState===I&&(e.pushState=o),e.replaceState===x&&(e.replaceState=c)}}}function yt(){let t=null,n=null;const e=new Set,o=s=>{s&&e.add(s.key),e.size>200&&e.delete(e.values().next().value)},c=()=>{t||(t=pt(),n=t.read(),o(n))};return{connect:c,resolve(s,u){c();const i=t.read();let y=n,h="unknown";if(y&&i&&(i.key===y.key||i.index===y.index?h="replace":i.index<y.index?h="back":h=e.has(i.key)?"forward":"push"),h==="push"){const f=t.previous();f&&f.index===i.index-1&&Te.normalizePath(new URL(f.url).pathname)===Te.normalizePath(s)&&(y=f)}return n=i,o(y),o(i),{kind:h,direction:h==="back"?"backward":"forward",from:y,to:i}},dispose(){t==null||t.dispose(),t=null,n=null,e.clear()}}}function mt(){const t=yt(),n=new Map;return{connect:t.connect,resolve(e,o,c){var h,f;const s=t.resolve(e,o),u=(h=s.from)==null?void 0:h.key,i=(f=s.to)==null?void 0:f.key;if(s.kind==="back"&&u&&i){const d=n.get(u);if((d==null?void 0:d.source)===i&&d.from===o&&d.to===e)return d.rule?{...d.rule,direction:d.rule.direction==="forward"?"backward":"forward",preserveScroll:{from:d.rule.preserveScroll.to,to:d.rule.preserveScroll.from}}:null}if(s.kind==="forward"&&u&&i){const d=n.get(i);if((d==null?void 0:d.source)===u&&d.from===e&&d.to===o)return d.rule}const y=c(s.direction);if(i&&s.kind==="replace"&&n.delete(i),i&&u&&s.kind==="push"){for(const[d,g]of n)g.index>=s.to.index&&n.delete(d);n.set(i,{source:u,index:s.to.index,from:e,to:o,rule:y?{...y,preserveScroll:{...y.preserveScroll}}:null}),n.size>100&&n.delete(n.keys().next().value)}return y},dispose(){t.dispose(),n.clear()}}}function vt(t={}){let n=null,e=null;function o(){var s,u;n&&((s=n.out)==null||s.resolve(null),(u=n.in)==null||u.resolve(null),n=null)}function c(){if(n!=null&&n.out&&n.in){if(n.out.path===n.in.path){o();return}const s={from:n.out.path,to:n.in.path,out:n.out.payload,in:n.in.payload};e=s,n.out.resolve(s),n.in.resolve(s),n=null}}return{arrive(s,u,i){return new Promise(y=>{var g,R;const h=e===null?null:u==="out"?{path:e.from,payload:e.out}:{path:e.to,payload:e.in};if((h==null?void 0:h.path)===s){y(null);return}u==="out"&&((g=n==null?void 0:n.in)==null?void 0:g.path)===s&&!n.out&&(n.in.resolve(null),n.in=void 0);const f=n==null?void 0:n[u];f&&f.path!==s&&o(),n||(n={});const d=n[u];if(d){if(((R=t.keepCurrent)==null?void 0:R.call(t,{type:u,path:s,current:d.payload,next:i}))??!1){y(null);return}d.resolve(null)}n[u]={path:s,payload:i,resolve:y},c()})},cancel(s){(n!=null&&n.out&&s(n.out.payload)||n!=null&&n.in&&s(n.in.payload))&&o(),(e&&s(e.out)||e&&s(e.in))&&(e=null)}}}const gt={},j=new Map;let le=null,Be=!1;function qe(t,n,e){t instanceof HTMLElement&&j.has(t)&&!t.isConnected&&e.set(t,{entry:j.get(t),anchor:n});for(const o of Array.from(t.childNodes))qe(o,n,e)}function wt(t){const n=new Set(Array.from(t.values(),({entry:e})=>e));for(const[e,{entry:o,anchor:c}]of t){j.delete(e);let s=o.parent,u=!1;for(;s;){if(s.group===o.group&&n.has(s)){u=!0;break}s=s.parent}queueMicrotask(()=>o.callback(c,{emit:!u}))}}function bt(){if(Be||typeof document>"u")return;Be=!0,le=new MutationObserver(n=>{const e=new Map;for(const o of n){const c={parent:o.target,nextSibling:o.nextSibling};for(const s of Array.from(o.removedNodes))qe(s,c,e)}wt(e)});const t=()=>{le==null||le.observe(document.body,{childList:!0,subtree:!0})};document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}function Et(t,n,e=gt){bt();let o=t.parentElement,c=null;for(;o;){const s=j.get(o);if((s==null?void 0:s.group)===e){c=s;break}o=o.parentElement}return j.set(t,{element:t,callback:n,group:e,parent:c}),()=>{j.delete(t)}}const ke=new WeakMap;let ce=null;const ae="none !important";function Q(t){const n=t.style.getPropertyValue("display");return t.style.getPropertyPriority("display")?`${n} !important`:n}function St(){return ce||(ce=new MutationObserver(t=>{for(const n of t){const e=n.target,o=ke.get(e);if(!o)continue;const c=Q(e);c!==o.accounted&&(o.accounted=c,c===ae?(o.reactHidden=!0,o.onHide()):c!=="none"&&o.reactHidden&&(o.reactHidden=!1,o.onShow()))}}),ce)}function Tt(t,n){const e=Q(t),o={accounted:e,reactHidden:e===ae,onHide:n.onHide,onShow:n.onShow};return ke.set(t,o),St().observe(t,{attributes:!0,attributeFilter:["style"]}),{get isHidden(){return Q(t)===ae},setDisplay(c,s=!1){c===null?t.style.removeProperty("display"):t.style.setProperty("display",c,s?"important":""),o.accounted=Q(t)},sync(){o.accounted=Q(t),o.reactHidden=o.accounted===ae},stop(){ke.delete(t)}}}const kt=5e3;function Pt(t,n={}){const{transitions:e=[],middleware:o=(r,l)=>({from:r,to:l})}=t,c=n.host??new Ue,s={},u=vt({keepCurrent:({current:r,next:l})=>r.element.contains(l.element)}),i=mt(),y=typeof e=="function"?e:()=>e,h=ft();h.initialize();const f=new Map,d=r=>{let l=f.get(r);return l===void 0&&(l=o(r,r).from,f.set(r,l)),l},{initializeContext:g,beginTransition:R,disconnect:I,calculateScrollOffset:x,evictScrollPosition:B,getScrollContainer:w,getPositionedParentElement:p,getScrollPosition:b,getIsMobile:T}=ut({resolvePath:d}),O=new Map,F=()=>{const r=T();let l=O.get(r);return l||(l=y({isMobile:r}),O.set(r,l)),l},q=new WeakMap,ee=r=>{q.set(r,{parent:r.parentNode,nextSibling:r.nextSibling})},te=r=>{const l=q.get(r);return l||{parent:r.parentNode,nextSibling:r.nextSibling}},m=new WeakMap,S=new WeakMap;let M=0;const D=r=>{const l=typeof getComputedStyle<"u"?getComputedStyle(r).display:"";return l&&l!=="none"?l:"block"},H=(r,l)=>{l.visibleDisplay=r.style.getPropertyValue("display"),l.computedDisplay=D(r)},C=(r,l)=>{if(S.get(r)!==l)return;S.delete(r);const a=m.get(r);a&&(a.savedCss!==null&&(r.style.cssText=a.savedCss,a.savedCss=null),a.intent==="hidden"?a.vis.setDisplay("none",!0):a.visibleDisplay?(a.vis.setDisplay(a.visibleDisplay,!1),H(r,a)):(a.vis.setDisplay(null),H(r,a)))},N=(r,l)=>{if(r.mode!=="hidden")return;const a=Array.from(new Set([r.element,l==null?void 0:l.element].filter(Boolean))),L=++M;for(const v of a)S.set(v,L);c.complete();for(const v of a)C(v,L)},K=new Set;let A,U=0,ne=!1;const $e=(r,l,a,L,v,E,W)=>{const k=v.element,P=E.element,X=(v.mode??"unmount")==="hidden",{parent:G,nextSibling:V}=v.parent?{parent:v.parent,nextSibling:v.nextSibling}:te(k),Y=x(a,L,W.to),he={direction:l,scrollOffset:Y,from:{scroll:b(a)},to:{scroll:b(L,W.to)},get scrollingElement(){return w()||document.documentElement},get positionedParent(){return p()}};let z;if(X){z=k,z.style.top=`${-1*((Y==null?void 0:Y.y)??0)}px`;const _=m.get(P);_&&_.savedCss===null&&(_.savedCss=P.style.cssText)}else z=k,nt(z,he);W.from||B(a);const ie=X?++M:0;X&&(S.set(P,ie),S.set(k,ie));const Re=Promise.resolve(z),Ae=Promise.resolve(P),Me=[],Ze={from:Re,to:Ae,context:he,createElement:((_,ve="div")=>{const Z=document.createElement(ve);return Z.setAttribute("data-ssgoi-id",_),Me.push(Z),Z})},Je=R(t.scrollLock!==!1);let ye=!1;const $=()=>{if(!ye){ye=!0,clearTimeout(Oe),K.delete($),A===$&&(A=void 0);try{X?(C(k,ie),C(P,ie)):z.parentNode&&z.parentNode.removeChild(z);for(const _ of Me)_.parentNode&&_.parentNode.removeChild(_)}finally{Je()}}};K.add($),A==null||A(),A=$;const me=_=>{$(),console.error("[SSGOI] Page transition failed",_)},Oe=setTimeout(()=>{me(new Error("Page transition preparation timed out"))},kt);let Ce;try{Ce=Promise.resolve(r.prepare?r.prepare(Ze):{})}catch(_){me(_);return}st({from:Re,to:Ae,extras:Ce}).then(({from:_,to:ve,extras:Z})=>{if(ye)return;clearTimeout(Oe),A===$&&(A=void 0),!X&&G&&(V&&G.contains(V)?G.insertBefore(z,V):G.appendChild(z));const ge=r.animation({from:_,to:ve,context:he,...Z}),we=ge.onComplete;ge.onComplete=()=>{try{we==null||we()}finally{$()}},c.attach(ge)}).catch(me)},oe=(r,l,a)=>{if(ne)return;const L=U,v=h.isSwipeBack();u.arrive(r,l,a).then(E=>{var pe,X,G,V;if(ne||L!==U)return;if(l==="in"&&h.onPageEnter(),!E){l==="out"&&N(a);return}if(l!=="in")return;const{from:W,to:k}=o(E.from,E.to),P=i.resolve(E.from,E.to,Y=>Te.resolveTransitionRule(W,k,F(),Y));if(!P){(X=(pe=E.in).applyScrollPolicy)==null||X.call(pe,!1),B(E.from),N(E.out,E.in),A==null||A(),c.complete();return}if((V=(G=E.in).applyScrollPolicy)==null||V.call(G,P.preserveScroll.to),v){P.preserveScroll.from||B(E.from),N(E.out,E.in),A==null||A(),c.complete();return}$e(P.transition,P.direction,E.from,E.to,E.out,E.in,P.preserveScroll)})},Ve=(r,l)=>{const a=m.get(r);if(!a)return;const L=a.intent==="hidden";if(a.intent="hidden",a.savedCss===null&&(a.savedCss=r.style.cssText),a.vis.setDisplay(a.computedDisplay||"block",!0),r.style.position="absolute",r.style.width="100%",r.style.left="0",L)return;const v=te(r),E={element:r,parent:v.parent,nextSibling:v.nextSibling,mode:"hidden"},W=a.pendingOutPath??a.currentPath??l;a.pendingOutPath=null,oe(W,"out",E)},Ye=(r,l)=>{const a=m.get(r);if(!a||a.intent==="visible")return;a.intent="visible",a.currentPath=r.getAttribute("data-ssgoi-transition")??a.currentPath??l,a.pendingOutPath=null,a.pathRevision++,H(r,a),a.savedCss!==null&&(r.style.cssText=a.savedCss,a.visibleDisplay?a.vis.setDisplay(a.visibleDisplay,!1):a.vis.setDisplay(null));const L=a.currentPath,v=g(r,L),E={element:r,parent:r.parentElement,nextSibling:r.nextElementSibling,applyScrollPolicy:v};oe(L,"in",E)},je=(r,l,a,L=!0)=>{const v=m.get(r);se.delete(r);const E=(v==null?void 0:v.pendingOutPath)??(v==null?void 0:v.currentPath)??l;if(v&&(v.vis.stop(),re.delete(v.vis),m.delete(r),S.delete(r),v.intent==="hidden")){u.cancel(P=>P.element===r);return}if(!L)return;const W=a??te(r),k={element:r,parent:W.parent,nextSibling:W.nextSibling,mode:"unmount"};oe(E,"out",k)};let fe=new WeakSet;const re=new Set,se=new Map,Pe=(r,l,{enter:a=!0}={})=>{if(ne=!1,i.connect(),h.initialize(),fe.has(l)){const k=m.get(l);if(k&&k.currentPath!==r){k.intent==="visible"&&k.pendingOutPath===null&&(k.pendingOutPath=k.currentPath),k.currentPath=r;const P=++k.pathRevision;queueMicrotask(()=>{k.pathRevision===P&&(k.pendingOutPath=null)})}return}fe.add(l);const L=U;ee(l);const v=Tt(l,{onHide:()=>Ve(l,r),onShow:()=>Ye(l,r)});re.add(v);const E={vis:v,savedCss:null,intent:v.isHidden?"hidden":"visible",visibleDisplay:"",computedDisplay:"block",currentPath:r,pendingOutPath:null,pathRevision:0};if(m.set(l,E),!v.isHidden&&(H(l,E),a)){const k=g(l,r),P={element:l,parent:l.parentElement,nextSibling:l.nextElementSibling,applyScrollPolicy:k};oe(r,"in",P)}const W=Et(l,(k,P)=>{L===U&&je(l,r,k,(P==null?void 0:P.emit)??!0)},s);se.set(l,W)},xe=new Map;return{register:Pe,refFor:r=>{let l=xe.get(r);return l||(l=a=>{a&&Pe(r,a)},xe.set(r,l)),l},disconnect(){ne=!0,U++,u.cancel(()=>!0);try{c.complete()}finally{for(const r of K)r();for(const r of re)r.stop();re.clear();for(const r of se.values())r();se.clear(),fe=new WeakSet,I(),h.destroy(),i.dispose()}}}}const Ge="data-ssgoi-root",xt=`[${Ge}]`,ue="data-ssgoi-transition",Fe=`[${ue}]`,Rt="[data-ssgoi-clone]";function At(){return typeof MutationObserver<"u"&&typeof HTMLElement<"u"&&typeof Node<"u"}function Mt(t){return t.nodeType===Node.ELEMENT_NODE}function Ot(t){return t instanceof HTMLElement}function ze(t){let n=0,e=t.parentElement;for(;e;)n++,e=e.parentElement;return n}function Ke(t,n,e=t){const o=Array.from(t).sort((c,s)=>ze(c)-ze(s));for(const c of o){const s=c.getAttribute(ue);if(s===null)continue;let u=c.parentElement,i=!1;for(;u;){if(e.has(u)){i=!0;break}u=u.parentElement}n.register(s,c,{enter:!i})}}function Ct(t,n){if(!At())return()=>{};t.setAttribute(Ge,"");const e=i=>i.closest(xt)===t,o=i=>!Ot(i)||!e(i)||i.closest(Rt)||i.getAttribute(ue)===null?null:i,c=(i,y)=>{if(Mt(i)){if(i.matches(Fe)){const h=o(i);h&&y.add(h)}for(const h of i.querySelectorAll(Fe)){const f=o(h);f&&y.add(f)}}},s=new MutationObserver(i=>{const y=new Set,h=new Set;for(const f of i){if(f.type==="attributes"){const d=o(f.target);d&&y.add(d);continue}for(const d of f.addedNodes)c(d,h)}for(const f of h)y.add(f);Ke(y,n,h)});s.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[ue]});const u=new Set;return c(t,u),Ke(u,n),()=>{var i;s.disconnect(),(i=n.disconnect)==null||i.call(n)}}exports.Animation=de.Animation;exports.MultiAnimation=de.MultiAnimation;exports.WebAnimation=de.WebAnimation;exports.simulate=tt.simulate;exports.HostAnimation=Ue;exports.createSggoiTransitionContext=Pt;exports.observeSsgoiTransitions=Ct;
1
+ "use strict";var kt=Object.defineProperty;var Tt=(t,n,e)=>n in t?kt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var K=(t,n,e)=>Tt(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _e=require("./resolve-transition-rule-BL12rDDu.cjs"),G=require("./retain-opacity-BFlsDhI7.cjs"),He=require("./provider-JDtJ5Jzf.cjs");function oe(t){return[...t.getMotionTracks()]}class dt extends G.Animation{constructor(){super(...arguments);K(this,"child",null);K(this,"run",null);K(this,"retiring",[]);K(this,"owners",new WeakMap);K(this,"epoch",0);K(this,"prepared",null);K(this,"_state","idle");K(this,"_settled",!1);K(this,"listeners",new Set);K(this,"onHandoff")}prepareHandoff(){var e;if(!this.prepared){this.prepared=this.sceneSnapshots(),(e=this.child)==null||e.pause();for(const s of this.retiring)for(const l of s.releases)l.pause()}}attach(e,s={}){var L;if(this.child===e)return;e.validate();const l=this.run,r=this.prepared??this.sceneSnapshots();this.prepared=null;const h=++this.epoch,c=oe(e),v=r.filter(u=>u.lifetime!=="temporary"&&!c.some(o=>o.element===u.target)&&(s.targets??[]).some(o=>{var a;return o===u.target||((a=o.contains)==null?void 0:a.call(o,u.target))})&&("transform"in u.channels||"opacity"in u.channels)).map(u=>{const o=u.target,a={transform:o.style.transform,opacity:o.style.opacity},w=o.style.opacity||1;return new G.WebAnimation({element:o,integrator:new He.SpringIntegrator({stiffness:200,damping:24}),style:()=>({transform:"none",opacity:w}),motion:{key:u.key,role:u.role,space:u.space},onDispose:()=>{!a.transform&&o.style.transform==="none"&&(o.style.transform=""),!a.opacity&&String(o.style.opacity)===String(w)&&(o.style.opacity="")}})});if(v.length){const u=e.onDispose;e.onDispose=void 0,e=new G.MultiAnimation({effect:e,restore:new G.MultiAnimation(v)}),e.onDispose=u}const g=oe(e),m=new Set([...s.targets??[],...g.map(u=>u.element)]);for(const u of s.targets??[])this.owners.set(u,h);for(const u of c)this.owners.set(u.element,h);this.child=e;const d={animation:e,epoch:h,targets:m,hidden:[]};this.run=d,this._settled=!1;const y=[];if(e.supportsInterruption&&(!l||l.animation.supportsInterruption)){const u=He.matchMotion(r,g.map(o=>o.motionIdentity));u.forEach((o,a)=>{y.push({kind:o.reason,target:o.next.target,key:o.next.key}),o.previous&&g[a].adopt(o.previous),g[a].handoffFallbacks.length&&y.push({kind:"fallback",target:o.next.target,channels:g[a].handoffFallbacks,fallback:g[a].handoffFallbackMode})});for(const o of u){if(!o.previous||o.previous.target===o.next.target)continue;if(o.previous.lifetime==="temporary"){o.previous.target.remove();continue}const a=G.retainOpacity(o.previous.target);a.set(0),d.hidden.push(a.restore)}for(const o of[...this.retiring]){for(const a of o.releases)(m.has(a.element)||u.some(C=>{var W;return((W=C.previous)==null?void 0:W.target)===a.element}))&&a.cancel({reason:"interrupted",owns:()=>!1});o.releases=o.releases.filter(a=>a.isAnimating||a.isPaused),o.releases.length||this.disposeRetiring(o)}l&&this.retire(l,r,new Set([...m,...u.flatMap(o=>o.previous?[o.previous.target]:[])]),y)}else if(l){y.push({kind:"fallback"});const u=[...m].map(o=>[o,o.style.cssText]);l.animation.complete();for(const[o,a]of u)o.style.cssText=a}e.playbackRate=this.playbackRate;const E=e.onDispose;e.onDispose=u=>{try{E==null||E(u)}finally{for(const o of d.hidden.splice(0))o()}};const O=e.onComplete;e.onComplete=()=>{O==null||O(),this.child===e&&(this.child=null,this.run=null,this._state="idle",this._settled=this.retiring.length===0),this.notify()};const M=e.onUpdate;e.onUpdate=u=>{var o;M==null||M(u),this.child===e&&((o=this.onUpdate)==null||o.call(this,u),this.notify())},this._state==="paused"?e.pause():(this._state="playing",e.play());for(const u of this.retiring)for(const o of u.releases)this._state!=="paused"&&o.isPaused&&o.play();(L=this.onHandoff)==null||L.call(this,y),this.notify()}sceneSnapshots(){return[...this.child?oe(this.child).map(e=>e.getMotionSnapshot()):[],...this.run?[...this.run.targets].filter(e=>!oe(this.run.animation).some(s=>s.element===e)).map(e=>({target:e,channels:G.createWebPresentationCodec(e).read({transform:typeof getComputedStyle=="function"&&getComputedStyle(e).transform||"none",opacity:typeof getComputedStyle=="function"&&getComputedStyle(e).opacity||"1"})})):[],...this.retiring.flatMap(e=>e.releases.map(s=>s.getMotionSnapshot()))]}disposal(e){return{reason:"interrupted",owns:s=>!this.owners.has(s)||this.owners.get(s)===e.epoch}}retire(e,s,l,r){var g,m,d;e.animation.stop();const h=oe(e.animation),c={...e,releases:[]},v=new Set([...e.targets,...l]);for(const y of e.targets){if(l.has(y)||[...v].some(a=>{var w;return a!==y&&((w=a.contains)==null?void 0:w.call(a,y))}))continue;const E=s.find(a=>a.target===y);if(!E||((g=h.find(a=>a.element===y))==null?void 0:g.motion.release)==="remove")continue;const O=(m=h.find(a=>a.element===y))==null?void 0:m.motion.release;if(typeof O=="function")try{const a=O(E);if(a.element!==y)throw new Error("Release must own the retiring target");a.validate();const w=a.onComplete;a.onComplete=()=>{w==null||w(),c.releases.every(C=>C.isComplete)&&this.disposeRetiring(c)},a.adopt(E),a.playbackRate=this.playbackRate,c.releases.push(a),r.push({kind:"release",target:y});continue}catch(a){console.error("[ssgoi] invalid release; using fade",a),r.push({kind:"fallback",target:y})}const L=G.createWebPresentationCodec(y).write(E.channels),u=Number(L.opacity??1),o=new G.WebAnimation({element:y,integrator:{step:(a,w,C)=>({position:Math.min(w,a.position+C/.18),velocity:a.position>=w?0:1/.18}),isSettled:(a,w)=>a.position>=w},style:(a,w)=>({...L,opacity:u*w}),motion:{...(d=h.find(a=>a.element===y))==null?void 0:d.motion,handoffDuration:180},onComplete:()=>{c.releases.every(a=>a.isComplete)&&this.disposeRetiring(c)}});o.adopt(E),o.playbackRate=this.playbackRate,c.releases.push(o),r.push({kind:"release",target:y})}if(!c.releases.length){e.animation.cancel(this.disposal(e));return}this.retiring.push(c);for(const y of c.releases)y.play(),this._state==="paused"&&y.pause();for(;this.retiring.length>8;)this.disposeRetiring(this.retiring[0])}disposeRetiring(e){if(this.retiring.includes(e)){this.retiring=this.retiring.filter(s=>s!==e);for(const s of e.releases)s.cancel({reason:"disposed",owns:()=>!1});e.animation.cancel(this.disposal(e)),!this.child&&!this.retiring.length&&(this._settled=!0),this.notify()}}play(){var e;this._state="playing",this._settled=!1,(e=this.child)==null||e.play();for(const s of this.retiring)for(const l of s.releases)l.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();for(const s of this.retiring)for(const l of s.releases)l.pause();this.notify()}complete(){var e;this.prepared=null,(e=this.child)==null||e.complete();for(const s of[...this.retiring])this.disposeRetiring(s);this.notify()}cancel(e){this.prepared=null;const s=this.child;this.child=null,this.run=null,this._state="idle",s==null||s.cancel(e);for(const l of[...this.retiring])this.disposeRetiring(l);this._settled=!0,this.notify()}get isAnimating(){var e;return!!((e=this.child)!=null&&e.isAnimating)||this.retiring.some(s=>s.releases.some(l=>l.isAnimating))}get isPaused(){return this._state==="paused"}get isComplete(){return this._settled&&!this.child&&!this.retiring.length}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);for(const s of this.retiring)for(const l of s.releases)l.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}get retiringCount(){return this.retiring.length}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(){for(const e of this.listeners)e()}}const Pt=(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"},tt=new Set(["auto","scroll","overlay"]),Rt=t=>{let n=t.parentElement;for(;n&&n!==document.body;){const e=window.getComputedStyle(n);if(tt.has(e.overflowY)||tt.has(e.overflowX))return n;n=n.parentElement}return document.documentElement},Mt=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 xt(t){const n=Object.keys(t);return Promise.all(n.map(e=>t[e])).then(e=>{const s={};return n.forEach((l,r)=>{s[l]=e[r]}),s})}const Oe=new WeakMap;function Ct(t){let n=Oe.get(t);if(!n){const s=t.ownerDocument,r=t===s.documentElement||t===s.scrollingElement?s:t,h=m=>{m.type==="wheel"&&m.ctrlKey||m.type==="touchmove"&&m.touches.length>1||m.cancelable&&m.preventDefault()},c={passive:!1,capture:!0};r.addEventListener("wheel",h,c),r.addEventListener("touchmove",h,c);const v=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"," "]),g=m=>{var y,E;const d=m;if(!(d.defaultPrevented||d.altKey||!v.has(d.key))){for(const O of d.composedPath()){const M=O;if(M.isContentEditable||(y=M.matches)!=null&&y.call(M,"input, textarea, select, [role=slider], [role=spinbutton], [role=listbox], [role=menu], [role=tablist]")||d.key===" "&&((E=M.matches)!=null&&E.call(M,"button, [role=button]")))return}d.cancelable&&d.preventDefault()}};r.addEventListener("keydown",g,{capture:!0}),n={owners:0,restore(){r.removeEventListener("wheel",h,{capture:!0}),r.removeEventListener("touchmove",h,{capture:!0}),r.removeEventListener("keydown",g,{capture:!0})}},Oe.set(t,n)}n.owners++;let e=!1;return()=>{e||(e=!0,--n.owners===0&&(Oe.delete(t),n.restore()))}}const At=768,Ot=10,Dt=10;function Lt(t={}){const{resolvePath:n=b=>b}=t;let e=null,s=null;const l=new Set,r=b=>{const k=b&&e?Ct(e):()=>{},_=()=>{l.delete(_)&&k()};return l.add(_),_};let h=!1,c=!1;const v=()=>{const b=(e==null?void 0:e.clientWidth)??0,k=b>0?b:typeof window<"u"?window.innerWidth:0;return k>0&&k<At},g=()=>(c||(h=v(),c=!0),h),m=b=>`path:${n(b)}`;let d=null;const y=new Map;let E=null,O=!1,M=0,L=0,u=0;const o=()=>{e&&E&&!O&&!l.size&&y.set(m(E),{x:e.scrollLeft,y:e.scrollTop})},a=(b,k,_)=>{if(!e)return;const D=++L,N=m(b),A=k&&y.has(N)?y.get(N):{x:0,y:0};let H=0;const B=()=>{if(!e||_!==M||D!==L)return;k||y.set(N,A),e.scrollTo({top:A.y,left:A.x,behavior:"instant"}),!(Math.abs(e.scrollTop-A.y)<1&&Math.abs(e.scrollLeft-A.x)<1)&&H<Ot&&(H++,requestAnimationFrame(B))};requestAnimationFrame(B)};return{beginTransition:r,disconnect(){++M,++L;for(const b of l)b();e&&(e===document.documentElement?window:e).removeEventListener("scroll",o),s==null||s.disconnect(),s=null,e=null,d=null,E=null,c=!1},initializeContext:(b,k,_)=>{O=!0;const D=E===k?M:++M;d=b,e||(e=Rt(b),h=v(),c=!0,typeof ResizeObserver<"u"&&(s=new ResizeObserver(()=>{h=v()}),s.observe(e)),(e===document.documentElement?window:e).addEventListener("scroll",o,{passive:!0})),E=k;const N=m(k),A=y.get(N),H=ee=>{D===M&&(u=D,ee&&A&&y.set(N,A),a(k,ee,D))};_!==void 0?H(_):requestAnimationFrame(()=>{u!==D&&D===M&&H(!1)});let B=0;const V=()=>{D===M&&(B++,B>=Dt?O=!1:requestAnimationFrame(V))};return requestAnimationFrame(V),H},calculateScrollOffset:(b,k,_=!1)=>{const D=b?m(b):null,N=D&&y.has(D)?y.get(D):{x:0,y:0},A=k&&_?m(k):null,H=A&&y.has(A)?y.get(A):{x:0,y:0};return{x:-H.x+N.x,y:-H.y+N.y}},evictScrollPosition:b=>{y.delete(m(b))},getScrollContainer:()=>e,getPositionedParentElement:()=>d?Mt(d):document.body,getScrollPosition:(b,k=!0)=>{if(!k)return{x:0,y:0};const _=b?m(b):null;return _&&y.has(_)?y.get(_):{x:0,y:0}},getIsMobile:g}}const nt=30,st=8,ot=1.2,rt=30,_t=600;function Ht(){let t=null,n=!1,e=!1,s=null,l=null,r=!1;const h=(o,a)=>{for(let w=0;w<o.length;w++){const C=o.item(w);if(C&&C.identifier===a)return C}return null},c=()=>{s!==null&&(clearTimeout(s),s=null)},v=()=>{l!==null&&(clearTimeout(l),l=null)},g=()=>{n=!0,e=!0,c(),v(),s=setTimeout(()=>{n=!1,e=!1,s=null},_t)},m=o=>{if(o.touches.length!==1){t=null;return}const a=o.touches.item(0);if(!a){t=null;return}const w=window.innerWidth,C=a.clientX<=nt,W=a.clientX>=w-nt;if(!C&&!W){t=null;return}t={identifier:a.identifier,startX:a.clientX,startY:a.clientY,fromLeftEdge:C,moved:!1}},d=o=>{if(!t)return;if(o.touches.length!==1){t=null;return}const a=h(o.touches,t.identifier);if(!a){t=null;return}const w=a.clientX-t.startX,C=a.clientY-t.startY,W=Math.abs(w),Y=Math.abs(C);if(Y>st&&Y>W*ot){t=null;return}const ie=t.fromLeftEdge?w>0:w<0;W>st&&W>Y*ot&&ie&&(t.moved=!0)},y=o=>{if(!t)return;const a=h(o.changedTouches,t.identifier);if(!a){t=null;return}const w=a.clientX-t.startX,C=t.fromLeftEdge?w>0:w<0;if(t.moved&&C&&Math.abs(w)>=rt){g(),t=null;return}t.moved&&Math.abs(w)>=rt&&g(),t=null},E=()=>{t&&(t.moved&&g(),t=null)};return{initialize:()=>{if(typeof window>"u"||r)return;r=!0;const o={passive:!0,capture:!0};window.addEventListener("touchstart",m,o),window.addEventListener("touchmove",d,o),window.addEventListener("touchend",y,o),window.addEventListener("touchcancel",E,o)},destroy:()=>{if(typeof window>"u"||!r)return;r=!1;const o={capture:!0};window.removeEventListener("touchstart",m,o),window.removeEventListener("touchmove",d,o),window.removeEventListener("touchend",y,o),window.removeEventListener("touchcancel",E,o),c(),v(),t=null,n=!1,e=!1},isSwipeBack:()=>{const o=n||e;return o&&c(),o},onPageEnter:()=>{n=!1,c(),v(),l=setTimeout(()=>{e=!1,l=null},0)}}}const it="__ssgoi_entry_v1",De=new WeakMap,pt={read:()=>null,previous:()=>null,dispose(){}};function It(){if(typeof window>"u")return pt;const t=window.navigation,n=window;let e=De.get(n);e||(e=Nt(n,t),De.set(n,e)),e.users++;const s=e;let l=!1;return{read:s.read,previous:s.previous,dispose(){l||(l=!0,--s.users===0&&(s.dispose(),De.delete(n)))}}}function lt(t){return t&&typeof t.key=="string"&&typeof t.url=="string"&&Number.isSafeInteger(t.index)&&t.index>=0?{key:t.key,index:t.index,url:t.url}:null}function Le(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===Object.prototype}function Nt(t,n){var L;const e=t.history,s=e.pushState,l=e.replaceState,r=`${Date.now()}-${Math.random().toString(36).slice(2)}-`;let h=0,c=!0,v=null,g=null;const m=()=>{const u=lt(n==null?void 0:n.currentEntry);return(u==null?void 0:u.url)===t.location.href?u:null},d=()=>{const u=e.state,o=Le(u)?u[it]:null;return!Le(o)||typeof o.key!="string"||!o.key.startsWith(r)||!Number.isSafeInteger(o.index)?m():{key:o.key,index:o.index,url:t.location.href}},y=(u,o)=>u!==null&&!Le(u)?u:{...u,[it]:o},E=u=>({key:`${r}${++h}`,index:u});try{l.call(e,y(e.state,E(((L=m())==null?void 0:L.index)??0)),"")}catch{return{...pt,read:m,users:0}}const O=function(u,o,a){var W;if(!c)return s.call(this,u,o,a);const w=d(),C=E(((w==null?void 0:w.index)??0)+1);s.call(this,y(u,C),o,a),v=w,g=((W=d())==null?void 0:W.key)??null},M=function(u,o,a){if(!c)return l.call(this,u,o,a);const w=d();l.call(this,y(u,w??E(0)),o,a)};return e.pushState=O,e.replaceState=M,{users:0,read:d,previous:()=>{var o;if(((o=d())==null?void 0:o.key)===g)return v;const u=m();return u?lt(n==null?void 0:n.entries().find(a=>a.index===u.index-1)):null},dispose(){c=!1,e.pushState===O&&(e.pushState=s),e.replaceState===M&&(e.replaceState=l)}}}function Wt(){let t=null,n=null;const e=new Set,s=r=>{r&&e.add(r.key),e.size>200&&e.delete(e.values().next().value)},l=()=>{t||(t=It(),n=t.read(),s(n))};return{connect:l,resolve(r,h){l();const c=t.read();let v=n,g="unknown";if(v&&c&&(c.key===v.key||c.index===v.index?g="replace":c.index<v.index?g="back":g=e.has(c.key)?"forward":"push"),g==="push"){const m=t.previous();m&&m.index===c.index-1&&_e.normalizePath(new URL(m.url).pathname)===_e.normalizePath(r)&&(v=m)}return n=c,s(v),s(c),{kind:g,direction:g==="back"?"backward":"forward",from:v,to:c}},dispose(){t==null||t.dispose(),t=null,n=null,e.clear()}}}function Ft(){const t=Wt(),n=new Map;return{connect:t.connect,resolve(e,s,l){var g,m;const r=t.resolve(e,s),h=(g=r.from)==null?void 0:g.key,c=(m=r.to)==null?void 0:m.key;if(r.kind==="back"&&h&&c){const d=n.get(h);if((d==null?void 0:d.source)===c&&d.from===s&&d.to===e)return d.rule?{...d.rule,direction:d.rule.direction==="forward"?"backward":"forward",preserveScroll:{from:d.rule.preserveScroll.to,to:d.rule.preserveScroll.from}}:null}if(r.kind==="forward"&&h&&c){const d=n.get(c);if((d==null?void 0:d.source)===h&&d.from===e&&d.to===s)return d.rule}const v=l(r.direction);if(c&&r.kind==="replace"&&n.delete(c),c&&h&&r.kind==="push"){for(const[d,y]of n)y.index>=r.to.index&&n.delete(d);n.set(c,{source:h,index:r.to.index,from:e,to:s,rule:v?{...v,preserveScroll:{...v.preserveScroll}}:null}),n.size>100&&n.delete(n.keys().next().value)}return v},dispose(){t.dispose(),n.clear()}}}function Bt(t={}){let n=null,e=null;function s(){var r,h;n&&((r=n.out)==null||r.resolve(null),(h=n.in)==null||h.resolve(null),n=null)}function l(){if(n!=null&&n.out&&n.in){if(n.out.path===n.in.path){s();return}const r={from:n.out.path,to:n.in.path,out:n.out.payload,in:n.in.payload};e=r,n.out.resolve(r),n.in.resolve(r),n=null}}return{arrive(r,h,c){return new Promise(v=>{var y,E;const g=e===null?null:h==="out"?{path:e.from,payload:e.out}:{path:e.to,payload:e.in};if((g==null?void 0:g.path)===r){v(null);return}h==="out"&&((y=n==null?void 0:n.in)==null?void 0:y.path)===r&&!n.out&&(n.in.resolve(null),n.in=void 0);const m=n==null?void 0:n[h];m&&m.path!==r&&s(),n||(n={});const d=n[h];if(d){if(((E=t.keepCurrent)==null?void 0:E.call(t,{type:h,path:r,current:d.payload,next:c}))??!1){v(null);return}d.resolve(null)}n[h]={path:r,payload:c,resolve:v},l()})},cancel(r){(n!=null&&n.out&&r(n.out.payload)||n!=null&&n.in&&r(n.in.payload))&&s(),(e&&r(e.out)||e&&r(e.in))&&(e=null)}}}const zt={},Q=new Map;let we=null,at=!1;function ht(t,n,e){t instanceof HTMLElement&&Q.has(t)&&!t.isConnected&&e.set(t,{entry:Q.get(t),anchor:n});for(const s of Array.from(t.childNodes))ht(s,n,e)}function Gt(t){const n=new Set(Array.from(t.values(),({entry:e})=>e));for(const[e,{entry:s,anchor:l}]of t){Q.delete(e);let r=s.parent,h=!1;for(;r;){if(r.group===s.group&&n.has(r)){h=!0;break}r=r.parent}queueMicrotask(()=>s.callback(l,{emit:!h}))}}function Kt(){if(at||typeof document>"u")return;at=!0,we=new MutationObserver(n=>{const e=new Map;for(const s of n){const l={parent:s.target,nextSibling:s.nextSibling};for(const r of Array.from(s.removedNodes))ht(r,l,e)}Gt(e)});const t=()=>{we==null||we.observe(document.body,{childList:!0,subtree:!0})};document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}function Ut(t,n,e=zt){Kt();let s=t.parentElement,l=null;for(;s;){const r=Q.get(s);if((r==null?void 0:r.group)===e){l=r;break}s=s.parentElement}return Q.set(t,{element:t,callback:n,group:e,parent:l}),()=>{Q.delete(t)}}const Ie=new WeakMap;let be=null;const Se="none !important";function re(t){const n=t.style.getPropertyValue("display");return t.style.getPropertyPriority("display")?`${n} !important`:n}function Xt(){return be||(be=new MutationObserver(t=>{for(const n of t){const e=n.target,s=Ie.get(e);if(!s)continue;const l=re(e);l!==s.accounted&&(s.accounted=l,l===Se?(s.reactHidden=!0,s.onHide()):l!=="none"&&s.reactHidden&&(s.reactHidden=!1,s.onShow()))}}),be)}function qt(t,n){const e=re(t),s={accounted:e,reactHidden:e===Se,onHide:n.onHide,onShow:n.onShow};return Ie.set(t,s),Xt().observe(t,{attributes:!0,attributeFilter:["style"]}),{get isHidden(){return re(t)===Se},setDisplay(l,r=!1){l===null?t.style.removeProperty("display"):t.style.setProperty("display",l,r?"important":""),s.accounted=re(t)},sync(){s.accounted=re(t),s.reactHidden=s.accounted===Se},stop(){Ie.delete(t)}}}const $t=5e3;function Vt(t,n={}){const{transitions:e=[],middleware:s=(i,f)=>({from:i,to:f})}=t,l=n.host??new dt,r={},h=Bt({keepCurrent:({current:i,next:f})=>i.element.contains(f.element)}),c=Ft(),v=typeof e=="function"?e:()=>e,g=Ht();g.initialize();const m=new Map,d=i=>{let f=m.get(i);return f===void 0&&(f=s(i,i).from,m.set(i,f)),f},{initializeContext:y,beginTransition:E,disconnect:O,calculateScrollOffset:M,evictScrollPosition:L,getScrollContainer:u,getPositionedParentElement:o,getScrollPosition:a,getIsMobile:w}=Lt({resolvePath:d}),C=new Map,W=()=>{const i=w();let f=C.get(i);return f||(f=v({isMobile:i}),C.set(i,f)),f},Y=new WeakMap,ie=i=>{Y.set(i,{parent:i.parentNode,nextSibling:i.nextSibling})},le=i=>{const f=Y.get(i);return f||{parent:i.parentNode,nextSibling:i.nextSibling}},b=new WeakMap,k=new WeakMap;let _=0,D=0,N=null,A=null,H=!1;const B=new WeakMap,V=()=>{D++,N==null||N.abort(),A==null||A(),A=null},ee=i=>{const f=typeof getComputedStyle<"u"?getComputedStyle(i).display:"";return f&&f!=="none"?f:"block"},ae=(i,f)=>{f.visibleDisplay=i.style.getPropertyValue("display"),f.computedDisplay=ee(i)},ke=(i,f)=>{if(k.get(i)!==f)return;k.delete(i);const p=b.get(i);p&&(p.savedCss!==null&&(i.style.cssText=p.savedCss,p.savedCss=null),p.intent==="hidden"?p.vis.setDisplay("none",!0):p.visibleDisplay?(p.vis.setDisplay(p.visibleDisplay,!1),ae(i,p)):(p.vis.setDisplay(null),ae(i,p)))},Te=(i,f)=>{if(i.mode!=="hidden")return;const p=Array.from(new Set([i.element,f==null?void 0:f.element].filter(Boolean))),I=++_;for(const S of p)k.set(S,I);l.complete();for(const S of p)ke(S,I)};let te=0;const yt=(i,f,p,I,S,T,z)=>{var $e;const P=S.element,x=T.element,$=++_;k.set(x,$),k.set(P,$);const de=E(t.scrollLock!==!1);V();const J=D;N=new AbortController;const j=N.signal;l.prepareHandoff();for(const R of[P,x])B.has(R)||B.set(R,(($e=b.get(R))==null?void 0:$e.savedCss)??R.style.cssText);const pe=(S.mode??"unmount")==="hidden",{parent:he,nextSibling:Re}=S.parent?{parent:S.parent,nextSibling:S.nextSibling}:le(P),me=M(p,I,z.to),ye={direction:f,scrollOffset:me,from:{scroll:a(p)},to:{scroll:a(I,z.to)},get scrollingElement(){return u()||document.documentElement},get positionedParent(){return o()}};let F;if(pe){F=P,F.style.top=`${-1*((me==null?void 0:me.y)??0)}px`;const R=b.get(x);R&&R.savedCss===null&&(R.savedCss=x.style.cssText)}else F=P,Pt(F,ye);z.from||L(p);const Be=Promise.resolve(F),ze=Promise.resolve(x),Me=[],Ge=[];let xe=!1;const ge=()=>{if(!xe){xe=!0;for(const R of Ge)try{R()}catch(U){console.error("[ssgoi] prepare cleanup",U)}for(const R of Me)R.remove()}},bt={from:Be,to:ze,context:ye,createElement:((R,U="div")=>{const se=document.createElement(U);return se.setAttribute("data-ssgoi-id",R),Me.push(se),se}),signal:j,onCleanup:R=>{xe?R():Ge.push(R)}};let Ke=!1,ne=!1;const ve=()=>{ne||(ne=!0,clearTimeout(qe),ge(),de())},Ue=()=>{for(const R of[P,x]){if(k.get(R)!==$)continue;const U=B.get(R);U!==void 0&&(R.style.cssText=U),B.delete(R),ke(R,$)}};A=()=>{ge(),Ue(),ve()};const Xe=R=>{ge();const U=ne||j.aborted||H||J!==D;if(A&&J===D&&(A=null),U){ve();return}l.cancel({reason:"disposed",owns:()=>!0}),Ue(),pe||F.remove(),ve(),console.error("[SSGOI] Page transition failed",R)},qe=setTimeout(()=>{Ke||ne||Xe(new Error("Page transition preparation timed out"))},$t),St=Promise.resolve().then(()=>j.aborted?{}:i.prepare?i.prepare(bt):{});xt({from:Be,to:ze,extras:St}).then(({from:R,to:U,extras:se})=>{var je,Ze,Je,Qe;if(ne||j.aborted||H||J!==D){ge();return}Ke=!0,clearTimeout(qe),A=null,!pe&&he&&(Re&&he.contains(Re)?he.insertBefore(F,Re):he.appendChild(F));const Z=i.animation({from:R,to:U,context:ye,...se}),Et=Z.getMotionTracks();for(const X of Et)Me.includes(X.element)&&((je=X.motion).lifetime??(je.lifetime="temporary"),(Ze=X.motion).role??(Ze.role="overlay"),(Je=X.motion).key??(Je.key=X.element.getAttribute("data-ssgoi-id")??void 0),(Qe=X.motion).space??(Qe.space=ye.positionedParent));const Ce=Z.onDispose;let Ve=!1;const Ye=X=>{if(!Ve){Ve=!0;try{Ce==null||Ce(X)}catch(q){console.error("[ssgoi] effect cleanup failed",q)}try{for(const q of[P,x]){if(k.get(q)!==$||!X.owns(q))continue;const et=B.get(q);et!==void 0&&(q.style.cssText=et),B.delete(q),b.has(q)?ke(q,$):k.delete(q)}!pe&&X.owns(F)&&F.parentNode&&!k.has(F)&&F.parentNode.removeChild(F)}finally{ve()}}};Z.onDispose=Ye;const Ae=Z.onComplete;Z.onComplete=()=>{try{Ae==null||Ae()}finally{Z.supportsInterruption||Ye(G.finishedDisposal)}},l.attach(Z,{targets:[P,x]})}).catch(Xe)},ce=(i,f,p)=>{if(H)return;const I=te,S=g.isSwipeBack();h.arrive(i,f,p).then(T=>{var $,de,J,j;if(H||I!==te)return;if(f==="in"&&g.onPageEnter(),!T){f==="out"&&Te(p);return}if(f!=="in")return;const{from:z,to:P}=s(T.from,T.to),x=c.resolve(T.from,T.to,Fe=>_e.resolveTransitionRule(z,P,W(),Fe));if(!x){(de=($=T.in).applyScrollPolicy)==null||de.call($,!1),L(T.from),V(),Te(T.out,T.in),l.complete();return}if((j=(J=T.in).applyScrollPolicy)==null||j.call(J,x.preserveScroll.to),S){x.preserveScroll.from||L(T.from),V(),Te(T.out,T.in),l.complete();return}yt(x.transition,x.direction,T.from,T.to,T.out,T.in,x.preserveScroll)})},gt=(i,f)=>{const p=b.get(i);if(!p)return;const I=p.intent==="hidden";if(p.intent="hidden",p.savedCss===null&&(p.savedCss=i.style.cssText),p.vis.setDisplay(p.computedDisplay||"block",!0),i.style.position="absolute",i.style.width="100%",i.style.left="0",I)return;const S=le(i),T={element:i,parent:S.parent,nextSibling:S.nextSibling,mode:"hidden"},z=p.pendingOutPath??p.currentPath??f;p.pendingOutPath=null,ce(z,"out",T)},vt=(i,f)=>{const p=b.get(i);if(!p||p.intent==="visible")return;p.intent="visible",p.currentPath=i.getAttribute("data-ssgoi-transition")??p.currentPath??f,p.pendingOutPath=null,p.pathRevision++,ae(i,p),p.savedCss!==null&&(i.style.cssText=p.savedCss,p.visibleDisplay?p.vis.setDisplay(p.visibleDisplay,!1):p.vis.setDisplay(null));const I=p.currentPath,S=y(i,I),T={element:i,parent:i.parentElement,nextSibling:i.nextElementSibling,applyScrollPolicy:S};ce(I,"in",T)},wt=(i,f,p,I=!0)=>{const S=b.get(i);fe.delete(i);const T=(S==null?void 0:S.pendingOutPath)??(S==null?void 0:S.currentPath)??f;if(S&&(S.vis.stop(),ue.delete(S.vis),b.delete(i),k.delete(i),S.intent==="hidden")){h.cancel(x=>x.element===i);return}if(!I)return;const z=p??le(i),P={element:i,parent:z.parent,nextSibling:z.nextSibling,mode:"unmount"};ce(T,"out",P)};let Pe=new WeakSet;const ue=new Set,fe=new Map,Ne=(i,f,{enter:p=!0}={})=>{if(H=!1,c.connect(),g.initialize(),Pe.has(f)){const P=b.get(f);if(P&&P.currentPath!==i){P.intent==="visible"&&P.pendingOutPath===null&&(P.pendingOutPath=P.currentPath),P.currentPath=i;const x=++P.pathRevision;queueMicrotask(()=>{P.pathRevision===x&&(P.pendingOutPath=null)})}return}Pe.add(f);const I=te;ie(f);const S=qt(f,{onHide:()=>gt(f,i),onShow:()=>vt(f,i)});ue.add(S);const T={vis:S,savedCss:null,intent:S.isHidden?"hidden":"visible",visibleDisplay:"",computedDisplay:"block",currentPath:i,pendingOutPath:null,pathRevision:0};if(b.set(f,T),!S.isHidden&&(ae(f,T),p)){const P=y(f,i),x={element:f,parent:f.parentElement,nextSibling:f.nextElementSibling,applyScrollPolicy:P};ce(i,"in",x)}const z=Ut(f,(P,x)=>{I===te&&wt(f,i,P,(x==null?void 0:x.emit)??!0)},r);fe.set(f,z)},We=new Map;return{register:Ne,refFor:i=>{let f=We.get(i);return f||(f=p=>{p&&Ne(i,p)},We.set(i,f)),f},disconnect(){H=!0,te++,h.cancel(()=>!0),V();try{l.cancel({reason:"disposed",owns:()=>!0})}finally{for(const i of ue)i.stop();ue.clear();for(const i of fe.values())i();fe.clear(),Pe=new WeakSet,O(),g.destroy(),c.dispose()}}}}const mt="data-ssgoi-root",Yt=`[${mt}]`,Ee="data-ssgoi-transition",ct=`[${Ee}]`,jt="[data-ssgoi-clone]";function Zt(){return typeof MutationObserver<"u"&&typeof HTMLElement<"u"&&typeof Node<"u"}function Jt(t){return t.nodeType===Node.ELEMENT_NODE}function Qt(t){return t instanceof HTMLElement}function ut(t){let n=0,e=t.parentElement;for(;e;)n++,e=e.parentElement;return n}function ft(t,n,e=t){const s=Array.from(t).sort((l,r)=>ut(l)-ut(r));for(const l of s){const r=l.getAttribute(Ee);if(r===null)continue;let h=l.parentElement,c=!1;for(;h;){if(e.has(h)){c=!0;break}h=h.parentElement}n.register(r,l,{enter:!c})}}function en(t,n){if(!Zt())return()=>{};t.setAttribute(mt,"");const e=c=>c.closest(Yt)===t,s=c=>!Qt(c)||!e(c)||c.closest(jt)||c.getAttribute(Ee)===null?null:c,l=(c,v)=>{if(Jt(c)){if(c.matches(ct)){const g=s(c);g&&v.add(g)}for(const g of c.querySelectorAll(ct)){const m=s(g);m&&v.add(m)}}},r=new MutationObserver(c=>{const v=new Set,g=new Set;for(const m of c){if(m.type==="attributes"){const d=s(m.target);d&&v.add(d);continue}for(const d of m.addedNodes)l(d,g)}for(const m of g)v.add(m);ft(v,n,g)});r.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[Ee]});const h=new Set;return l(t,h),ft(h,n),()=>{var c;r.disconnect(),(c=n.disconnect)==null||c.call(n)}}exports.Animation=G.Animation;exports.MultiAnimation=G.MultiAnimation;exports.WebAnimation=G.WebAnimation;exports.simulate=He.simulate;exports.HostAnimation=dt;exports.createSggoiTransitionContext=Vt;exports.observeSsgoiTransitions=en;