@ssgoi/core 7.1.3-beta.4 → 7.1.3-beta.5
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/internal.cjs +1 -1
- package/dist/internal.js +468 -490
- package/dist/types/index.d.ts +5 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/get-scrolling-element.d.ts.map +1 -1
- package/dist/utils/scroll-lock.d.ts +5 -1
- package/dist/utils/scroll-lock.d.ts.map +1 -1
- package/package.json +1 -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 Pe=require("./resolve-transition-rule-BL12rDDu.cjs"),fe=require("./multi-animation-hDUcfD7W.cjs"),tt=require("./provider-D9Q2URox.cjs");class Ke extends fe.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 d=o.getPose();o.complete(),e.matchInto(d)}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=d=>{var i;s==null||s(d),(i=this.onUpdate)==null||i.call(this,d),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"},ae=new WeakMap,ot=t=>ae.has(t);function rt(t){var o,c;let n=ae.get(t);if(!n){const s=t.ownerDocument,d=s.defaultView,i=t===s.documentElement||t===s.scrollingElement,h=i?s:t,p=t.style,y=d.getComputedStyle(t),f=[],m=(l,v)=>{const S=p.getPropertyValue(l),x=p.getPropertyPriority(l);p.setProperty(l,v,"important"),f.push(()=>{p.getPropertyValue(l)!==v||p.getPropertyPriority(l)!=="important"||(S?p.setProperty(l,S,x):p.removeProperty(l))})},R=i?d.innerWidth-t.clientWidth:t.offsetWidth-t.clientWidth-(parseFloat(y.borderLeftWidth)||0)-(parseFloat(y.borderRightWidth)||0);if(R>0&&!((o=y.scrollbarGutter)!=null&&o.includes("stable")))if((c=d.CSS)!=null&&c.supports("scrollbar-gutter","stable"))m("scrollbar-gutter","stable");else{if(!i){const l=t.offsetWidth;m("box-sizing","border-box"),m("width",`${l}px`)}m("padding-right",`${(parseFloat(y.paddingRight)||0)+R}px`)}m("overflow-x","hidden"),m("overflow-y","hidden"),m("overscroll-behavior-x","none"),m("overscroll-behavior-y","none"),m("overflow-anchor","none"),m("touch-action","pinch-zoom");const _=l=>{l.type==="wheel"&&l.ctrlKey||l.type==="touchmove"&&l.touches.length>1||l.cancelable&&l.preventDefault()},O={passive:!1,capture:!0};h.addEventListener("wheel",_,O),h.addEventListener("touchmove",_,O);const W=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"," "]),b=l=>{var S,x;const v=l;if(!(v.defaultPrevented||v.altKey||!W.has(v.key))){for(const F of v.composedPath()){const D=F;if(D.isContentEditable||(S=D.matches)!=null&&S.call(D,"input, textarea, select, [role=slider], [role=spinbutton], [role=listbox], [role=menu], [role=tablist]")||v.key===" "&&((x=D.matches)!=null&&x.call(D,"button, [role=button]")))return}v.cancelable&&v.preventDefault()}};h.addEventListener("keydown",b,{capture:!0}),n={owners:0,restore(){h.removeEventListener("wheel",_,{capture:!0}),h.removeEventListener("touchmove",_,{capture:!0}),h.removeEventListener("keydown",b,{capture:!0});for(const l of f.reverse())l()}},ae.set(t,n)}n.owners++;let e=!1;return()=>{e||(e=!0,--n.owners===0&&(ae.delete(t),n.restore()))}}const Le=new Set(["auto","scroll","overlay"]),st=t=>{let n=t.parentElement;for(;n&&n!==document.body;){const e=window.getComputedStyle(n);if(ot(n)||Le.has(e.overflowY)||Le.has(e.overflowX))return n;n=n.parentElement}return document.documentElement},it=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 lt(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 ct=768,at=10,ut=10;function dt(t={}){const{resolvePath:n=g=>g}=t;let e=null,o=null;const c=new Set,s=g=>{const P=g&&e?rt(e):()=>{},M=()=>{c.delete(M)&&P()};return c.add(M),M};let d=!1,i=!1;const h=()=>{const g=(e==null?void 0:e.clientWidth)??0,P=g>0?g:typeof window<"u"?window.innerWidth:0;return P>0&&P<ct},p=()=>(i||(d=h(),i=!0),d),y=g=>`path:${n(g)}`;let f=null;const m=new Map;let R=null,_=!1,O=0,W=0,b=0;const l=()=>{e&&R&&!_&&!c.size&&m.set(y(R),{x:e.scrollLeft,y:e.scrollTop})},v=(g,P,M)=>{if(!e)return;const N=++W,I=y(g),C=P&&m.has(I)?m.get(I):{x:0,y:0};let z=0;const K=()=>{if(!e||M!==O||N!==W)return;P||m.set(I,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)&&z<at&&(z++,requestAnimationFrame(K))};requestAnimationFrame(K)};return{beginTransition:s,disconnect(){++O,++W;for(const g of c)g();e&&(e===document.documentElement?window:e).removeEventListener("scroll",l),o==null||o.disconnect(),o=null,e=null,f=null,R=null,i=!1},initializeContext:(g,P,M)=>{_=!0;const N=R===P?O:++O;f=g,e||(e=st(g),d=h(),i=!0,typeof ResizeObserver<"u"&&(o=new ResizeObserver(()=>{d=h()}),o.observe(e)),(e===document.documentElement?window:e).addEventListener("scroll",l,{passive:!0})),R=P;const I=y(P),C=m.get(I),z=U=>{N===O&&(b=N,U&&C&&m.set(I,C),v(P,U,N))};M!==void 0?z(M):requestAnimationFrame(()=>{b!==N&&N===O&&z(!1)});let K=0;const A=()=>{N===O&&(K++,K>=ut?_=!1:requestAnimationFrame(A))};return requestAnimationFrame(A),z},calculateScrollOffset:(g,P,M=!1)=>{const N=g?y(g):null,I=N&&m.has(N)?m.get(N):{x:0,y:0},C=P&&M?y(P):null,z=C&&m.has(C)?m.get(C):{x:0,y:0};return{x:-z.x+I.x,y:-z.y+I.y}},evictScrollPosition:g=>{m.delete(y(g))},getScrollContainer:()=>e,getPositionedParentElement:()=>f?it(f):document.body,getScrollPosition:(g,P=!0)=>{if(!P)return{x:0,y:0};const M=g?y(g):null;return M&&m.has(M)?m.get(M):{x:0,y:0}},getIsMobile:p}}const _e=30,De=8,He=1.2,Ne=30,ft=600;function pt(){let t=null,n=!1,e=!1,o=null,c=null,s=!1;const d=(l,v)=>{for(let S=0;S<l.length;S++){const x=l.item(S);if(x&&x.identifier===v)return x}return null},i=()=>{o!==null&&(clearTimeout(o),o=null)},h=()=>{c!==null&&(clearTimeout(c),c=null)},p=()=>{n=!0,e=!0,i(),h(),o=setTimeout(()=>{n=!1,e=!1,o=null},ft)},y=l=>{if(l.touches.length!==1){t=null;return}const v=l.touches.item(0);if(!v){t=null;return}const S=window.innerWidth,x=v.clientX<=_e,F=v.clientX>=S-_e;if(!x&&!F){t=null;return}t={identifier:v.identifier,startX:v.clientX,startY:v.clientY,fromLeftEdge:x,moved:!1}},f=l=>{if(!t)return;if(l.touches.length!==1){t=null;return}const v=d(l.touches,t.identifier);if(!v){t=null;return}const S=v.clientX-t.startX,x=v.clientY-t.startY,F=Math.abs(S),D=Math.abs(x);if(D>De&&D>F*He){t=null;return}const ee=t.fromLeftEdge?S>0:S<0;F>De&&F>D*He&&ee&&(t.moved=!0)},m=l=>{if(!t)return;const v=d(l.changedTouches,t.identifier);if(!v){t=null;return}const S=v.clientX-t.startX,x=t.fromLeftEdge?S>0:S<0;if(t.moved&&x&&Math.abs(S)>=Ne){p(),t=null;return}t.moved&&Math.abs(S)>=Ne&&p(),t=null},R=()=>{t&&(t.moved&&p(),t=null)};return{initialize:()=>{if(typeof window>"u"||s)return;s=!0;const l={passive:!0,capture:!0};window.addEventListener("touchstart",y,l),window.addEventListener("touchmove",f,l),window.addEventListener("touchend",m,l),window.addEventListener("touchcancel",R,l)},destroy:()=>{if(typeof window>"u"||!s)return;s=!1;const l={capture:!0};window.removeEventListener("touchstart",y,l),window.removeEventListener("touchmove",f,l),window.removeEventListener("touchend",m,l),window.removeEventListener("touchcancel",R,l),i(),h(),t=null,n=!1,e=!1},isSwipeBack:()=>{const l=n||e;return l&&i(),l},onPageEnter:()=>{n=!1,i(),h(),c=setTimeout(()=>{e=!1,c=null},0)}}}const Ie="__ssgoi_entry_v1",Se=new WeakMap,Ue={read:()=>null,previous:()=>null,dispose(){}};function ht(){if(typeof window>"u")return Ue;const t=window.navigation,n=window;let e=Se.get(n);e||(e=yt(n,t),Se.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(),Se.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 Ee(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===Object.prototype}function yt(t,n){var W;const e=t.history,o=e.pushState,c=e.replaceState,s=`${Date.now()}-${Math.random().toString(36).slice(2)}-`;let d=0,i=!0,h=null,p=null;const y=()=>{const b=We(n==null?void 0:n.currentEntry);return(b==null?void 0:b.url)===t.location.href?b:null},f=()=>{const b=e.state,l=Ee(b)?b[Ie]:null;return!Ee(l)||typeof l.key!="string"||!l.key.startsWith(s)||!Number.isSafeInteger(l.index)?y():{key:l.key,index:l.index,url:t.location.href}},m=(b,l)=>b!==null&&!Ee(b)?b:{...b,[Ie]:l},R=b=>({key:`${s}${++d}`,index:b});try{c.call(e,m(e.state,R(((W=y())==null?void 0:W.index)??0)),"")}catch{return{...Ue,read:y,users:0}}const _=function(b,l,v){var F;if(!i)return o.call(this,b,l,v);const S=f(),x=R(((S==null?void 0:S.index)??0)+1);o.call(this,m(b,x),l,v),h=S,p=((F=f())==null?void 0:F.key)??null},O=function(b,l,v){if(!i)return c.call(this,b,l,v);const S=f();c.call(this,m(b,S??R(0)),l,v)};return e.pushState=_,e.replaceState=O,{users:0,read:f,previous:()=>{var l;if(((l=f())==null?void 0:l.key)===p)return h;const b=y();return b?We(n==null?void 0:n.entries().find(v=>v.index===b.index-1)):null},dispose(){i=!1,e.pushState===_&&(e.pushState=o),e.replaceState===O&&(e.replaceState=c)}}}function mt(){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=ht(),n=t.read(),o(n))};return{connect:c,resolve(s,d){c();const i=t.read();let h=n,p="unknown";if(h&&i&&(i.key===h.key||i.index===h.index?p="replace":i.index<h.index?p="back":p=e.has(i.key)?"forward":"push"),p==="push"){const y=t.previous();y&&y.index===i.index-1&&Pe.normalizePath(new URL(y.url).pathname)===Pe.normalizePath(s)&&(h=y)}return n=i,o(h),o(i),{kind:p,direction:p==="back"?"backward":"forward",from:h,to:i}},dispose(){t==null||t.dispose(),t=null,n=null,e.clear()}}}function vt(){const t=mt(),n=new Map;return{connect:t.connect,resolve(e,o,c){var p,y;const s=t.resolve(e,o),d=(p=s.from)==null?void 0:p.key,i=(y=s.to)==null?void 0:y.key;if(s.kind==="back"&&d&&i){const f=n.get(d);if((f==null?void 0:f.source)===i&&f.from===o&&f.to===e)return f.rule?{...f.rule,direction:f.rule.direction==="forward"?"backward":"forward",preserveScroll:{from:f.rule.preserveScroll.to,to:f.rule.preserveScroll.from}}:null}if(s.kind==="forward"&&d&&i){const f=n.get(i);if((f==null?void 0:f.source)===d&&f.from===e&&f.to===o)return f.rule}const h=c(s.direction);if(i&&s.kind==="replace"&&n.delete(i),i&&d&&s.kind==="push"){for(const[f,m]of n)m.index>=s.to.index&&n.delete(f);n.set(i,{source:d,index:s.to.index,from:e,to:o,rule:h?{...h,preserveScroll:{...h.preserveScroll}}:null}),n.size>100&&n.delete(n.keys().next().value)}return h},dispose(){t.dispose(),n.clear()}}}function gt(t={}){let n=null,e=null;function o(){var s,d;n&&((s=n.out)==null||s.resolve(null),(d=n.in)==null||d.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,d,i){return new Promise(h=>{var m,R;const p=e===null?null:d==="out"?{path:e.from,payload:e.out}:{path:e.to,payload:e.in};if((p==null?void 0:p.path)===s){h(null);return}d==="out"&&((m=n==null?void 0:n.in)==null?void 0:m.path)===s&&!n.out&&(n.in.resolve(null),n.in=void 0);const y=n==null?void 0:n[d];y&&y.path!==s&&o(),n||(n={});const f=n[d];if(f){if(((R=t.keepCurrent)==null?void 0:R.call(t,{type:d,path:s,current:f.payload,next:i}))??!1){h(null);return}f.resolve(null)}n[d]={path:s,payload:i,resolve:h},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 bt={},j=new Map;let le=null,Fe=!1;function Xe(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))Xe(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,d=!1;for(;s;){if(s.group===o.group&&n.has(s)){d=!0;break}s=s.parent}queueMicrotask(()=>o.callback(c,{emit:!d}))}}function St(){if(Fe||typeof document>"u")return;Fe=!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))Xe(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=bt){St();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 Te=new WeakMap;let ce=null;const ue="none !important";function Q(t){const n=t.style.getPropertyValue("display");return t.style.getPropertyPriority("display")?`${n} !important`:n}function Pt(){return ce||(ce=new MutationObserver(t=>{for(const n of t){const e=n.target,o=Te.get(e);if(!o)continue;const c=Q(e);c!==o.accounted&&(o.accounted=c,c===ue?(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===ue,onHide:n.onHide,onShow:n.onShow};return Te.set(t,o),Pt().observe(t,{attributes:!0,attributeFilter:["style"]}),{get isHidden(){return Q(t)===ue},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===ue},stop(){Te.delete(t)}}}const kt=5e3;function xt(t,n={}){const{transitions:e=[],middleware:o=(r,a)=>({from:r,to:a})}=t,c=n.host??new Ke,s={},d=gt({keepCurrent:({current:r,next:a})=>r.element.contains(a.element)}),i=vt(),h=typeof e=="function"?e:()=>e,p=pt();p.initialize();const y=new Map,f=r=>{let a=y.get(r);return a===void 0&&(a=o(r,r).from,y.set(r,a)),a},{initializeContext:m,beginTransition:R,disconnect:_,calculateScrollOffset:O,evictScrollPosition:W,getScrollContainer:b,getPositionedParentElement:l,getScrollPosition:v,getIsMobile:S}=dt({resolvePath:f}),x=new Map,F=()=>{const r=S();let a=x.get(r);return a||(a=h({isMobile:r}),x.set(r,a)),a},D=new WeakMap,ee=r=>{D.set(r,{parent:r.parentNode,nextSibling:r.nextSibling})},te=r=>{const a=D.get(r);return a||{parent:r.parentNode,nextSibling:r.nextSibling}},g=new WeakMap,P=new WeakMap;let M=0;const N=r=>{const a=typeof getComputedStyle<"u"?getComputedStyle(r).display:"";return a&&a!=="none"?a:"block"},I=(r,a)=>{a.visibleDisplay=r.style.getPropertyValue("display"),a.computedDisplay=N(r)},C=(r,a)=>{if(P.get(r)!==a)return;P.delete(r);const u=g.get(r);u&&(u.savedCss!==null&&(r.style.cssText=u.savedCss,u.savedCss=null),u.intent==="hidden"?u.vis.setDisplay("none",!0):u.visibleDisplay?(u.vis.setDisplay(u.visibleDisplay,!1),I(r,u)):(u.vis.setDisplay(null),I(r,u)))},z=(r,a)=>{if(r.mode!=="hidden")return;const u=Array.from(new Set([r.element,a==null?void 0:a.element].filter(Boolean))),L=++M;for(const w of u)P.set(w,L);c.complete();for(const w of u)C(w,L)},K=new Set;let A,U=0,ne=!1;const $e=(r,a,u,L,w,E,B)=>{const T=w.element,k=E.element,X=(w.mode??"unmount")==="hidden",{parent:q,nextSibling:V}=w.parent?{parent:w.parent,nextSibling:w.nextSibling}:te(T),Y=O(u,L,B.to),ye={direction:a,scrollOffset:Y,from:{scroll:v(u)},to:{scroll:v(L,B.to)},get scrollingElement(){return b()||document.documentElement},get positionedParent(){return l()}};let G;if(X){G=T,G.style.top=`${-1*((Y==null?void 0:Y.y)??0)}px`;const H=g.get(k);H&&H.savedCss===null&&(H.savedCss=k.style.cssText)}else G=T,nt(G,ye);B.from||W(u);const ie=X?++M:0;X&&(P.set(k,ie),P.set(T,ie));const Re=Promise.resolve(G),Ae=Promise.resolve(k),Me=[],Ze={from:Re,to:Ae,context:ye,createElement:((H,ge="div")=>{const Z=document.createElement(ge);return Z.setAttribute("data-ssgoi-id",H),Me.push(Z),Z})},Je=R(t.scrollLock!==!1);let me=!1;const $=()=>{if(!me){me=!0,clearTimeout(Oe),K.delete($),A===$&&(A=void 0);try{X?(C(T,ie),C(k,ie)):G.parentNode&&G.parentNode.removeChild(G);for(const H of Me)H.parentNode&&H.parentNode.removeChild(H)}finally{Je()}}};K.add($),A==null||A(),A=$;const ve=H=>{$(),console.error("[SSGOI] Page transition failed",H)},Oe=setTimeout(()=>{ve(new Error("Page transition preparation timed out"))},kt);let Ce;try{Ce=Promise.resolve(r.prepare?r.prepare(Ze):{})}catch(H){ve(H);return}lt({from:Re,to:Ae,extras:Ce}).then(({from:H,to:ge,extras:Z})=>{if(me)return;clearTimeout(Oe),A===$&&(A=void 0),!X&&q&&(V&&q.contains(V)?q.insertBefore(G,V):q.appendChild(G));const be=r.animation({from:H,to:ge,context:ye,...Z}),we=be.onComplete;be.onComplete=()=>{try{we==null||we()}finally{$()}},c.attach(be)}).catch(ve)},oe=(r,a,u)=>{if(ne)return;const L=U,w=p.isSwipeBack();d.arrive(r,a,u).then(E=>{var he,X,q,V;if(ne||L!==U)return;if(a==="in"&&p.onPageEnter(),!E){a==="out"&&z(u);return}if(a!=="in")return;const{from:B,to:T}=o(E.from,E.to),k=i.resolve(E.from,E.to,Y=>Pe.resolveTransitionRule(B,T,F(),Y));if(!k){(X=(he=E.in).applyScrollPolicy)==null||X.call(he,!1),W(E.from),z(E.out,E.in),A==null||A(),c.complete();return}if((V=(q=E.in).applyScrollPolicy)==null||V.call(q,k.preserveScroll.to),w){k.preserveScroll.from||W(E.from),z(E.out,E.in),A==null||A(),c.complete();return}$e(k.transition,k.direction,E.from,E.to,E.out,E.in,k.preserveScroll)})},Ve=(r,a)=>{const u=g.get(r);if(!u)return;const L=u.intent==="hidden";if(u.intent="hidden",u.savedCss===null&&(u.savedCss=r.style.cssText),u.vis.setDisplay(u.computedDisplay||"block",!0),r.style.position="absolute",r.style.width="100%",r.style.left="0",L)return;const w=te(r),E={element:r,parent:w.parent,nextSibling:w.nextSibling,mode:"hidden"},B=u.pendingOutPath??u.currentPath??a;u.pendingOutPath=null,oe(B,"out",E)},Ye=(r,a)=>{const u=g.get(r);if(!u||u.intent==="visible")return;u.intent="visible",u.currentPath=r.getAttribute("data-ssgoi-transition")??u.currentPath??a,u.pendingOutPath=null,u.pathRevision++,I(r,u),u.savedCss!==null&&(r.style.cssText=u.savedCss,u.visibleDisplay?u.vis.setDisplay(u.visibleDisplay,!1):u.vis.setDisplay(null));const L=u.currentPath,w=m(r,L),E={element:r,parent:r.parentElement,nextSibling:r.nextElementSibling,applyScrollPolicy:w};oe(L,"in",E)},je=(r,a,u,L=!0)=>{const w=g.get(r);se.delete(r);const E=(w==null?void 0:w.pendingOutPath)??(w==null?void 0:w.currentPath)??a;if(w&&(w.vis.stop(),re.delete(w.vis),g.delete(r),P.delete(r),w.intent==="hidden")){d.cancel(k=>k.element===r);return}if(!L)return;const B=u??te(r),T={element:r,parent:B.parent,nextSibling:B.nextSibling,mode:"unmount"};oe(E,"out",T)};let pe=new WeakSet;const re=new Set,se=new Map,ke=(r,a,{enter:u=!0}={})=>{if(ne=!1,i.connect(),p.initialize(),pe.has(a)){const T=g.get(a);if(T&&T.currentPath!==r){T.intent==="visible"&&T.pendingOutPath===null&&(T.pendingOutPath=T.currentPath),T.currentPath=r;const k=++T.pathRevision;queueMicrotask(()=>{T.pathRevision===k&&(T.pendingOutPath=null)})}return}pe.add(a);const L=U;ee(a);const w=Tt(a,{onHide:()=>Ve(a,r),onShow:()=>Ye(a,r)});re.add(w);const E={vis:w,savedCss:null,intent:w.isHidden?"hidden":"visible",visibleDisplay:"",computedDisplay:"block",currentPath:r,pendingOutPath:null,pathRevision:0};if(g.set(a,E),!w.isHidden&&(I(a,E),u)){const T=m(a,r),k={element:a,parent:a.parentElement,nextSibling:a.nextElementSibling,applyScrollPolicy:T};oe(r,"in",k)}const B=Et(a,(T,k)=>{L===U&&je(a,r,T,(k==null?void 0:k.emit)??!0)},s);se.set(a,B)},xe=new Map;return{register:ke,refFor:r=>{let a=xe.get(r);return a||(a=u=>{u&&ke(r,u)},xe.set(r,a)),a},disconnect(){ne=!0,U++,d.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(),pe=new WeakSet,_(),p.destroy(),i.dispose()}}}}const qe="data-ssgoi-root",Rt=`[${qe}]`,de="data-ssgoi-transition",ze=`[${de}]`,At="[data-ssgoi-clone]";function Mt(){return typeof MutationObserver<"u"&&typeof HTMLElement<"u"&&typeof Node<"u"}function Ot(t){return t.nodeType===Node.ELEMENT_NODE}function Ct(t){return t instanceof HTMLElement}function Be(t){let n=0,e=t.parentElement;for(;e;)n++,e=e.parentElement;return n}function Ge(t,n,e=t){const o=Array.from(t).sort((c,s)=>Be(c)-Be(s));for(const c of o){const s=c.getAttribute(de);if(s===null)continue;let d=c.parentElement,i=!1;for(;d;){if(e.has(d)){i=!0;break}d=d.parentElement}n.register(s,c,{enter:!i})}}function Lt(t,n){if(!Mt())return()=>{};t.setAttribute(qe,"");const e=i=>i.closest(Rt)===t,o=i=>!Ct(i)||!e(i)||i.closest(At)||i.getAttribute(de)===null?null:i,c=(i,h)=>{if(Ot(i)){if(i.matches(ze)){const p=o(i);p&&h.add(p)}for(const p of i.querySelectorAll(ze)){const y=o(p);y&&h.add(y)}}},s=new MutationObserver(i=>{const h=new Set,p=new Set;for(const y of i){if(y.type==="attributes"){const f=o(y.target);f&&h.add(f);continue}for(const f of y.addedNodes)c(f,p)}for(const y of p)h.add(y);Ge(h,n,p)});s.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[de]});const d=new Set;return c(t,d),Ge(d,n),()=>{var i;s.disconnect(),(i=n.disconnect)==null||i.call(n)}}exports.Animation=fe.Animation;exports.MultiAnimation=fe.MultiAnimation;exports.WebAnimation=fe.WebAnimation;exports.simulate=tt.simulate;exports.HostAnimation=Ke;exports.createSggoiTransitionContext=xt;exports.observeSsgoiTransitions=Lt;
|
|
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;
|