aptechka 0.93.3 → 0.93.4

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.
@@ -0,0 +1 @@
1
+ "use strict";var __defProp=Object.defineProperty;var __typeError=msg=>{throw TypeError(msg)};var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);const historyManager=require("./historyManager-Car6P2ak.cjs"),morph=require("./morph-BW6QJlwg.cjs");require("./Store-B96mD8mD.cjs");require("./index-BoGx2BWX.cjs");require("construct-style-sheets-polyfill");const url=require("./url-CbDPURsX.cjs");var _options,_LocalLinks_instances,isElement_fn,processClickEvent_fn,_clickListener;const _LocalLinks=class _LocalLinks{constructor(options){__privateAdd(this,_LocalLinks_instances);__privateAdd(this,_options);__privateAdd(this,_clickListener,__name(event=>{var _a,_b;const result=__privateMethod(this,_LocalLinks_instances,processClickEvent_fn).call(this,event);if(!result)return;const{url:url2,options={}}=result;url2&&((_b=(_a=__privateGet(this,_options)).onClick)==null||_b.call(_a,url2,options))},"#clickListener"));__privateSet(this,_options,options),window.addEventListener("click",__privateGet(this,_clickListener))}destroy(){window.removeEventListener("click",__privateGet(this,_clickListener))}update(){document.querySelectorAll("a").forEach(link=>{const href=link.getAttribute("href");href&&url.normalizeURL(href,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash}).pathname===location.pathname?link.classList.add("current"):link.classList.remove("current")})}};_options=new WeakMap,_LocalLinks_instances=new WeakSet,isElement_fn=__name(function(target){return(target==null?void 0:target.nodeType)===morph.NODE_TYPE_ELEMENT},"#isElement"),processClickEvent_fn=__name(function(e){const target=e.composedPath()[0];if(!__privateMethod(this,_LocalLinks_instances,isElement_fn).call(this,target))return;const anchorElement=target.closest("a");if(!anchorElement||typeof __privateGet(this,_options).includeAnchor=="function"&&!__privateGet(this,_options).includeAnchor(anchorElement,e)||anchorElement.closest("[data-router-ignore]"))return;const{href}=anchorElement;if(!url.isLocalUrl(href))return;const options={keepScrollPosition:"keepScrollPosition"in anchorElement.dataset,cache:"cache"in anchorElement.dataset,revalidate:"revalidate"in anchorElement.dataset,scrollLeft:parseFloat(anchorElement.dataset.scrollLeft||"0"),scrollTop:parseFloat(anchorElement.dataset.scrollTop||"0")};if(e.preventDefault(),anchorElement.hasAttribute("data-back")&&historyManager.historyManager.size>1){history.back();return}return{url:url.normalizeURL(new URL(href),{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash}),options}},"#processClickEvent"),_clickListener=new WeakMap,__name(_LocalLinks,"LocalLinks");let LocalLinks=_LocalLinks;exports.LocalLinks=LocalLinks;
@@ -5,6 +5,7 @@ var __typeError = (msg) => {
5
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
6
6
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
7
7
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value), __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
8
+ import { h as historyManager } from "./historyManager-DyjFBozJ.js";
8
9
  import { N as NODE_TYPE_ELEMENT } from "./morph-ChSinItH.js";
9
10
  import "./Store-CAGUSjFX.js";
10
11
  import "./index-DAG0CtYo.js";
@@ -21,7 +22,7 @@ const _LocalLinks = class _LocalLinks {
21
22
  if (!result)
22
23
  return;
23
24
  const { url, options = {} } = result;
24
- url && (event.preventDefault(), (_b = (_a = __privateGet(this, _options)).onClick) == null || _b.call(_a, url, options));
25
+ url && ((_b = (_a = __privateGet(this, _options)).onClick) == null || _b.call(_a, url, options));
25
26
  }, "#clickListener"));
26
27
  __privateSet(this, _options, options), window.addEventListener("click", __privateGet(this, _clickListener));
27
28
  }
@@ -57,6 +58,10 @@ _options = new WeakMap(), _LocalLinks_instances = new WeakSet(), isElement_fn =
57
58
  scrollLeft: parseFloat(anchorElement.dataset.scrollLeft || "0"),
58
59
  scrollTop: parseFloat(anchorElement.dataset.scrollTop || "0")
59
60
  };
61
+ if (e.preventDefault(), anchorElement.hasAttribute("data-back") && historyManager.size > 1) {
62
+ history.back();
63
+ return;
64
+ }
60
65
  return {
61
66
  url: normalizeURL(new URL(href), {
62
67
  base: __privateGet(this, _options).base,
@@ -0,0 +1 @@
1
+ "use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);var _previousStates,_popStateHandlers,_HistoryManager_instances,setupTracking_fn,overrideHistoryMethods_fn,updateHistory_fn,handlePopState_fn,getPathname_fn;const _HistoryManager=class _HistoryManager{constructor(){__privateAdd(this,_HistoryManager_instances);__privateAdd(this,_previousStates);__privateAdd(this,_popStateHandlers);history.scrollRestoration="manual",__privateSet(this,_previousStates,[history.state]),__privateSet(this,_popStateHandlers,[]),__privateMethod(this,_HistoryManager_instances,setupTracking_fn).call(this)}get size(){return __privateGet(this,_previousStates).length}getPreviousState(){return __privateGet(this,_previousStates).length>1?__privateGet(this,_previousStates)[__privateGet(this,_previousStates).length-2]:null}getCurrentState(){return __privateGet(this,_previousStates).length>0?__privateGet(this,_previousStates)[__privateGet(this,_previousStates).length-1]:null}addPopStateHandler(handler,unshift){unshift?__privateGet(this,_popStateHandlers).unshift(handler):__privateGet(this,_popStateHandlers).push(handler)}removePopStateHandler(handler){const index=__privateGet(this,_popStateHandlers).indexOf(handler);index>-1&&__privateGet(this,_popStateHandlers).splice(index,1)}updateCurrentStateData(data){let state=this.getCurrentState();state&&(state.data=__spreadValues(__spreadValues({},state.data),data))}updatePreviousStateData(data){let state=this.getPreviousState();state&&(state.data=__spreadValues(__spreadValues({},state.data),data))}pushState(page,data){const state={page:__privateMethod(this,_HistoryManager_instances,getPathname_fn).call(this,page),data,timestamp:Date.now()};history.pushState(state,"",page)}replaceState(page,data){const state={page:__privateMethod(this,_HistoryManager_instances,getPathname_fn).call(this,page),data,timestamp:Date.now()};history.replaceState(state,"",page)}back(){history.back()}forward(){history.forward()}go(delta){history.go(delta)}__change(parameters){if(parameters.action==="none")return;const por=parameters==null?void 0:parameters.searchParameters,hash=parameters.hash?parameters.hash.startsWith("#")?parameters.hash:"#"+parameters.hash:"",searhParameters=por?por.startsWith("?")?por:"?"+por:"",pathPlus=`${parameters.pathname}${searhParameters}${hash}`;parameters.action==="push"?this.pushState(pathPlus,parameters.data):parameters.action==="replace"&&this.replaceState(pathPlus,parameters.data)}debugHistory(){console.log("Current history state:"),__privateGet(this,_previousStates).forEach((state,index)=>{console.log(`[${index}]:`,state==null?void 0:state.page)})}};_previousStates=new WeakMap,_popStateHandlers=new WeakMap,_HistoryManager_instances=new WeakSet,setupTracking_fn=__name(function(){window.addEventListener("popstate",__privateMethod(this,_HistoryManager_instances,handlePopState_fn).bind(this)),__privateMethod(this,_HistoryManager_instances,overrideHistoryMethods_fn).call(this)},"#setupTracking"),overrideHistoryMethods_fn=__name(function(){const originalPushState=history.pushState,originalReplaceState=history.replaceState;history.pushState=(state,title,url)=>(__privateMethod(this,_HistoryManager_instances,updateHistory_fn).call(this,state),originalPushState.call(history,state,title,url)),history.replaceState=(state,title,url)=>(__privateMethod(this,_HistoryManager_instances,updateHistory_fn).call(this,state,!0),originalReplaceState.call(history,state,title,url))},"#overrideHistoryMethods"),updateHistory_fn=__name(function(state,isReplace=!1){isReplace&&__privateGet(this,_previousStates).length>0?__privateGet(this,_previousStates)[__privateGet(this,_previousStates).length-1]=state:(__privateGet(this,_previousStates).push(state),__privateGet(this,_previousStates).length>50&&__privateGet(this,_previousStates).shift())},"#updateHistory"),handlePopState_fn=__name(function(event){const targetState=this.getPreviousState(),previousState=this.getCurrentState();targetState&&(__privateGet(this,_previousStates)[__privateGet(this,_previousStates).length-2]=previousState,__privateGet(this,_previousStates)[__privateGet(this,_previousStates).length-1]=targetState),__privateGet(this,_popStateHandlers).forEach(handler=>{handler(__spreadProps(__spreadValues({},event),{state:targetState,previousState}))})},"#handlePopState"),getPathname_fn=__name(function(url){return typeof url=="string"?url:url.pathname},"#getPathname"),__name(_HistoryManager,"HistoryManager");let HistoryManager=_HistoryManager;const historyManager=new HistoryManager;exports.historyManager=historyManager;
@@ -23,6 +23,9 @@ const _HistoryManager = class _HistoryManager {
23
23
  __privateAdd(this, _popStateHandlers);
24
24
  history.scrollRestoration = "manual", __privateSet(this, _previousStates, [history.state]), __privateSet(this, _popStateHandlers, []), __privateMethod(this, _HistoryManager_instances, setupTracking_fn).call(this);
25
25
  }
26
+ get size() {
27
+ return __privateGet(this, _previousStates).length;
28
+ }
26
29
  getPreviousState() {
27
30
  return __privateGet(this, _previousStates).length > 1 ? __privateGet(this, _previousStates)[__privateGet(this, _previousStates).length - 2] : null;
28
31
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const LocalLinks=require("../LocalLinks-Dg9sbmY6.cjs");exports.LocalLinks=LocalLinks.LocalLinks;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const LocalLinks=require("../LocalLinks-DXGiMKnk.cjs");exports.LocalLinks=LocalLinks.LocalLinks;
@@ -1,4 +1,4 @@
1
- import { L } from "../LocalLinks-DYT4kzSV.js";
1
+ import { L } from "../LocalLinks-JdNN4mez.js";
2
2
  export {
3
3
  L as LocalLinks
4
4
  };
@@ -1 +1 @@
1
- "use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __knownSymbol=(name,symbol)=>(symbol=Symbol[name])?symbol:Symbol.for("Symbol."+name),__typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);var __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});var __forAwait=(obj,it,method)=>(it=obj[__knownSymbol("asyncIterator")])?it.call(obj):(obj=obj[__knownSymbol("iterator")](),it={},method=(key,fn)=>(fn=obj[key])&&(it[key]=arg=>new Promise((yes,no,done)=>(arg=fn.call(obj,arg),done=arg.done,Promise.resolve(arg.value).then(value=>yes({value,done}),no)))),method("next"),method("return"),it);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Store=require("../Store-B96mD8mD.cjs"),dom=require("../dom-B40i6NXw.cjs"),events=require("../events-UlGk63iC.cjs"),promises=require("../promises-nDm8_iG6.cjs"),scroll=require("../scroll-CTDesBpj.cjs");require("construct-style-sheets-polyfill");require("../index-BoGx2BWX.cjs");const url=require("../url-CbDPURsX.cjs"),cssValueParser_index=require("../css-value-parser/index.cjs"),historyManager=require("../historyManager-DB2fSEtH.cjs"),_MorphAnnouncer=class _MorphAnnouncer extends HTMLElement{connectedCallback(){const attrs={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[key,value]of Object.entries(attrs))this.setAttribute(key,value)}};__name(_MorphAnnouncer,"MorphAnnouncer");let MorphAnnouncer=_MorphAnnouncer;Store.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",MorphAnnouncer);var _morph,_element,_MorphLink_instances,path_get,click_fn,_clickListener,_pointerListener;const _MorphLink=class _MorphLink{constructor(element,morph){__privateAdd(this,_MorphLink_instances);__privateAdd(this,_morph);__privateAdd(this,_element);__privateAdd(this,_clickListener,__name(e=>{e.preventDefault(),__privateMethod(this,_MorphLink_instances,click_fn).call(this)},"#clickListener"));__privateAdd(this,_pointerListener,__name(()=>{const revalidate=__privateGet(this,_element).hasAttribute("data-revalidate");__privateGet(this,_morph).prefetch(__privateGet(this,_MorphLink_instances,path_get),revalidate),__privateGet(this,_element).removeEventListener("pointerenter",__privateGet(this,_pointerListener))},"#pointerListener"));__privateSet(this,_morph,morph),__privateSet(this,_element,element),__privateGet(this,_element).addEventListener("click",__privateGet(this,_clickListener)),this.checkCurrent(location.href.replace(location.origin,"")),__privateGet(this,_element).hasAttribute("data-prefetch")&&__privateGet(this,_element).addEventListener("pointerenter",__privateGet(this,_pointerListener))}get element(){return __privateGet(this,_element)}checkCurrent(path){var _a,_b;const locationUrl=__privateGet(this,_morph).normalizePath(path),linkUrl=__privateGet(this,_morph).normalizePath(__privateGet(this,_MorphLink_instances,path_get));__privateGet(this,_element).hasAttribute("data-include")&&locationUrl.pathname.includes(linkUrl.pathname)?__privateGet(this,_element).classList.add("current"):linkUrl.pathname===locationUrl.pathname?__privateGet(this,_element).classList.add("current"):(_a=__privateGet(this,_element).getAttribute("data-associated-paths"))!=null&&_a.split(",").find(path2=>locationUrl.pathname.includes(path2))?__privateGet(this,_element).classList.add("current"):__privateGet(this,_element).classList.remove("current"),locationUrl.path===linkUrl.path?__privateGet(this,_element).classList.add("exact"):__privateGet(this,_element).classList.remove("exact");const[pathWithoutParams,pathParamsStr]=(_b=__privateGet(this,_MorphLink_instances,path_get).split("#")[0])==null?void 0:_b.split("?"),pathParams=new URLSearchParams(pathParamsStr),locationParams=new URLSearchParams(location.search);let matchCounter=0;for(const[key]of locationParams)pathParams.has(key)&&locationParams.get(key)===pathParams.get(key)&&matchCounter++;matchCounter?(__privateGet(this,_element).classList.toggle("all-params-matched",locationParams.size===matchCounter),__privateGet(this,_element).classList.toggle("some-params-matched",locationParams.size!==matchCounter)):!locationParams.size&&__privateGet(this,_element).hasAttribute("data-match-no-params")?__privateGet(this,_element).classList.add("all-params-matched"):(__privateGet(this,_element).classList.remove("all-params-matched"),__privateGet(this,_element).classList.remove("some-params-matched"));for(const key in __privateGet(this,_element).dataset){const kebabKey=Store.camelToKebab(key);if(kebabKey.startsWith("match-param-")){const name=kebabKey.split("match-param-")[1],value=__privateGet(this,_element).dataset[key],className=`param-${name}-matched`;locationParams.has(name)&&locationParams.get(name)===value||!locationParams.has(name)&&(value===""||value==="*"||value==="all"||value==="any"||value==="vse")?__privateGet(this,_element).classList.add(className):__privateGet(this,_element).classList.remove(className)}}}destroy(){__privateGet(this,_element).removeEventListener("click",__privateGet(this,_clickListener)),__privateGet(this,_element).removeEventListener("pointerenter",__privateGet(this,_pointerListener)),__privateGet(this,_element).classList.remove("current","exact")}};_morph=new WeakMap,_element=new WeakMap,_MorphLink_instances=new WeakSet,path_get=__name(function(){const url2=new URL(__privateGet(this,_element).href);return __privateGet(this,_morph).normalizePath(url2.pathname+url2.search+url2.hash).path},"#path"),click_fn=__name(function(){var _a;if(document.documentElement.classList.contains("click-disabled"))return;if(__privateGet(this,_element).hasAttribute("data-back")&&__privateGet(this,_morph).previousURL)history.back();else{const historyAction=__privateGet(this,_element).getAttribute("data-history-action")||"push",centerScroll=__privateGet(this,_element).hasAttribute("data-center-scroll"),offsetScrollRawValue=getComputedStyle(__privateGet(this,_element)).getPropertyValue("--offset-scroll").trim(),offsetScroll=offsetScrollRawValue?cssValueParser_index.cssValueParser.parse(offsetScrollRawValue):void 0,scrollDuration=parseFloat(__privateGet(this,_element).getAttribute("data-scroll-duration")||"0")||void 0,scrollEasing=__privateGet(this,_element).getAttribute("data-scroll-easing")||void 0,revalidate=__privateGet(this,_element).hasAttribute("data-revalidate")||__privateGet(this,_element).hasAttribute("data-pagination-more-link")||__privateGet(this,_element).hasAttribute("data-pagination-set-link")||__privateGet(this,_element).hasAttribute("data-pagination-next-link")||__privateGet(this,_element).hasAttribute("data-pagination-prev-link"),keepSearchParameters=__privateGet(this,_element).hasAttribute("data-keep-search-parameters"),keepScrollPosition=__privateGet(this,_element).hasAttribute("data-keep-scroll-position")||__privateGet(this,_element).hasAttribute("data-pagination-more-link"),scrollBehaviour=__privateGet(this,_element).getAttribute("data-scroll-behaviour"),submorph=(_a=__privateGet(this,_element).getAttribute("data-submorph")||__privateGet(this,_element).getAttribute("data-submorph-append"))==null?void 0:_a.split(",").map(v=>v.trim()),clearState=__privateGet(this,_element).hasAttribute("data-clear-state");let path=__privateGet(this,_MorphLink_instances,path_get);if(__privateGet(this,_element).hasAttribute("data-toggle-params")){const[pathWithoutParams,pathParamsStr]=__privateGet(this,_MorphLink_instances,path_get).split("?"),pathParams=new URLSearchParams(pathParamsStr),locationParams=new URLSearchParams(location.search),resultParams=new URLSearchParams;for(const[key]of pathParams)(!locationParams.has(key)||locationParams.has(key)&&locationParams.get(key)!==pathParams.get(key))&&resultParams.append(key,pathParams.get(key));if(__privateGet(this,_element).hasAttribute("data-merge-params"))for(const[key]of locationParams)pathParams.has(key)||resultParams.append(key,locationParams.get(key));path=`${pathWithoutParams}?${resultParams.toString()}`}__privateGet(this,_morph).navigate(path,{historyAction,centerScroll,offsetScroll,revalidate,keepSearchParameters,submorph,clearState,keepScrollPosition,scrollBehaviour,scrollDuration,scrollEasing,submorphAppend:__privateGet(this,_element).hasAttribute("data-submorph-append"),mergeParams:__privateGet(this,_element).hasAttribute("data-merge-params")&&!__privateGet(this,_element).hasAttribute("data-toggle-params"),detail:__privateGet(this,_element).getAttribute("data-detail"),removeParams:__privateGet(this,_element).getAttribute("data-remove-params")||void 0,scrollTo:__privateGet(this,_element).getAttribute("data-scroll-to")||void 0})}},"#click"),_clickListener=new WeakMap,_pointerListener=new WeakMap,__name(_MorphLink,"MorphLink");let MorphLink=_MorphLink;var _element2,_params,_MorphParamsDependent_instances,update_fn,_urlChangeListener;const _MorphParamsDependent=class _MorphParamsDependent{constructor(element){__privateAdd(this,_MorphParamsDependent_instances);__privateAdd(this,_element2);__privateAdd(this,_params,[]);__privateAdd(this,_urlChangeListener,__name(()=>{__privateMethod(this,_MorphParamsDependent_instances,update_fn).call(this)},"#urlChangeListener"));__privateSet(this,_element2,element);for(const key in __privateGet(this,_element2).dataset){const kebabKey=Store.camelToKebab(key);if(kebabKey.startsWith("param-")){const name=kebabKey.split("param-")[1],value=__privateGet(this,_element2).dataset[key];__privateGet(this,_params).push({name,value})}}document.addEventListener("morphURLParametersChange",__privateGet(this,_urlChangeListener)),__privateMethod(this,_MorphParamsDependent_instances,update_fn).call(this)}destroy(){document.removeEventListener("morphURLParametersChange",__privateGet(this,_urlChangeListener))}};_element2=new WeakMap,_params=new WeakMap,_MorphParamsDependent_instances=new WeakSet,update_fn=__name(function(){const locationParams=new URLSearchParams(location.search);let matched=!!__privateGet(this,_params).find(param=>locationParams.has(param.name)&&(locationParams.get(param.name)===param.value||param.value==="*"||param.value==="all"||param.value==="any"||param.value==="vse"||locationParams.get(param.name)==="*"||locationParams.get(param.name)==="all"||locationParams.get(param.name)==="any"||locationParams.get(param.name)==="vse"));!matched&&__privateGet(this,_element2).hasAttribute("data-match-no-params")&&(matched=!__privateGet(this,_params).filter(param=>locationParams.has(param.name)).length);const hideClass=__privateGet(this,_element2).getAttribute("data-hide-class");matched?hideClass?__privateGet(this,_element2).classList.remove(hideClass):__privateGet(this,_element2).style.display="":hideClass?__privateGet(this,_element2).classList.add(hideClass):__privateGet(this,_element2).style.display="none",requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("resize"))})},"#update"),_urlChangeListener=new WeakMap,__name(_MorphParamsDependent,"MorphParamsDependent");let MorphParamsDependent=_MorphParamsDependent;const domParser=new DOMParser;var _morph2,_pathname,_scrollState,_initialDocument,_modifiedDocument,_currentDocument,_savedState,_abortController,_fetching,_headers,_needRavalidation;const _MorphRoute=class _MorphRoute{constructor(morph,pathname){__privateAdd(this,_morph2);__privateAdd(this,_pathname);__privateAdd(this,_scrollState,{x:0,y:0});__privateAdd(this,_initialDocument,null);__privateAdd(this,_modifiedDocument,null);__privateAdd(this,_currentDocument,null);__privateAdd(this,_savedState,null);__privateAdd(this,_abortController,null);__privateAdd(this,_fetching,null);__privateAdd(this,_headers);__privateAdd(this,_needRavalidation,!1);__privateSet(this,_morph2,morph),__privateSet(this,_pathname,pathname)}get pathname(){return __privateGet(this,_pathname)}get scrollState(){return __privateGet(this,_scrollState)}get document(){return __privateGet(this,_currentDocument)}needRavalidation(){__privateSet(this,_needRavalidation,!0)}setHeaders(headers){__privateSet(this,_headers,headers)}setInitialDocument(document2){__privateSet(this,_initialDocument,document2.cloneNode(!0))}abort(){var _a;return(_a=__privateGet(this,_abortController))==null?void 0:_a.abort(`[${__privateGet(this,_pathname)}] page loading cancelled`)}fetch(path,currentPath,revalidate){return __async(this,null,function*(){var _a;if(!revalidate&&!__privateGet(this,_needRavalidation)){const shouldUseCache=((_a=__privateGet(this,_initialDocument))==null?void 0:_a.documentElement.getAttribute("data-cache"))&&currentPath!==path,isPopstateNavigation=__privateGet(this,_initialDocument)&&__privateGet(this,_morph2).isPopstateNavigation;if(__privateGet(this,_fetching)||shouldUseCache||isPopstateNavigation)return __privateGet(this,_fetching)}return __privateSet(this,_fetching,new Promise(res=>__async(this,null,function*(){try{__privateSet(this,_abortController,new AbortController);const text=yield(yield fetch(path,{signal:__privateGet(this,_abortController).signal,headers:__spreadValues({"X-MORPH":"true","X-MORPH-REVALIDATE":revalidate?"true":"false","X-MORPH-CURRENT-PATH":encodeURIComponent(currentPath),"X-MORPH-NEW-PATH":encodeURIComponent(path)},__privateGet(this,_headers))})).text(),document2=domParser.parseFromString(text,"text/html");this.setInitialDocument(document2),__privateSet(this,_needRavalidation,!1)}catch(e){console.warn(e)}finally{__privateSet(this,_abortController,null),__privateSet(this,_fetching,null),res()}}))),__privateGet(this,_fetching)})}cloneDocument(){__privateSet(this,_currentDocument,(__privateGet(this,_modifiedDocument)||__privateGet(this,_initialDocument)).cloneNode(!0))}get title(){let title="";if(__privateGet(this,_currentDocument).title)title=__privateGet(this,_currentDocument).title;else{const h1=__privateGet(this,_currentDocument).querySelector("h1");title=(h1==null?void 0:h1.innerText)||(h1==null?void 0:h1.textContent)||__privateGet(this,_pathname)}return title}clearScrollState(){__privateGet(this,_scrollState).x=0,__privateGet(this,_scrollState).y=0}clearDocumentState(){__privateSet(this,_modifiedDocument,null)}saveScrollState(){__privateGet(this,_initialDocument).documentElement.hasAttribute("data-no-scroll-restoration")?(__privateGet(this,_scrollState).x=0,__privateGet(this,_scrollState).y=0):(__privateGet(this,_scrollState).x=__privateGet(this,_morph2).scrollValue.left,__privateGet(this,_scrollState).y=__privateGet(this,_morph2).scrollValue.top)}restoreScrollPosition(){__privateGet(this,_morph2).scrollElement.scroll({top:__privateGet(this,_scrollState).y,left:__privateGet(this,_scrollState).x,behavior:"instant"})}saveDocumentState(){__privateGet(this,_initialDocument).documentElement.hasAttribute("data-no-page-restoration")?__privateSet(this,_modifiedDocument,null):__privateSet(this,_modifiedDocument,document.cloneNode(!0))}renewScrollPosition(){__privateGet(this,_morph2).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(state){__privateSet(this,_savedState,state)}clearState(){const state=__privateGet(this,_savedState);return __privateSet(this,_savedState,null),state}};_morph2=new WeakMap,_pathname=new WeakMap,_scrollState=new WeakMap,_initialDocument=new WeakMap,_modifiedDocument=new WeakMap,_currentDocument=new WeakMap,_savedState=new WeakMap,_abortController=new WeakMap,_fetching=new WeakMap,_headers=new WeakMap,_needRavalidation=new WeakMap,__name(_MorphRoute,"MorphRoute");let MorphRoute=_MorphRoute;var _options,_morphElements,_links,_candidateURL,_currentURL,_previousURL,_promises,_isPopstateNavigation,_currentScrollElement,_isWindowScroll,_routes,_paramDependent,_announcer,_currentScrollX,_currentScrollY,_lastSubmorph,_lastRevalidate,_lastKeepScrollPosition,_checkLink,_Morph_instances,getRoute_fn,getMorphElements_fn,isElementEmitsLoadEvent_fn,updateCurrentScrollElement_fn,tryScrollToElement_fn,_popStateListener,_scrollListener;const _Morph=class _Morph{constructor(parameters){__privateAdd(this,_Morph_instances);__privateAdd(this,_options,null);__privateAdd(this,_morphElements,null);__privateAdd(this,_links,[]);__privateAdd(this,_candidateURL);__privateAdd(this,_currentURL,null);__privateAdd(this,_previousURL);__privateAdd(this,_promises,[]);__privateAdd(this,_isPopstateNavigation,!1);__privateAdd(this,_currentScrollElement,null);__privateAdd(this,_isWindowScroll,!1);__privateAdd(this,_routes,new Map);__privateAdd(this,_paramDependent,[]);__privateAdd(this,_announcer,null);__privateAdd(this,_currentScrollX,0);__privateAdd(this,_currentScrollY,0);__privateAdd(this,_lastSubmorph);__privateAdd(this,_lastRevalidate);__privateAdd(this,_lastKeepScrollPosition);__privateAdd(this,_checkLink,__name(element=>{var _a,_b;return(((_a=element.getAttribute("href"))==null?void 0:_a.startsWith("/"))||((_b=element.getAttribute("href"))==null?void 0:_b.startsWith("?")))&&!element.hasAttribute("download")&&!element.hasAttribute("data-morph-skip")&&!element.closest("[data-morph-skip]")&&element.getAttribute("target")!=="_blank"},"#checkLink"));__privateAdd(this,_popStateListener,__name(event=>__async(this,null,function*(){var _a,_b,_c,_d;(_b=(_a=event.state)==null?void 0:_a.data)!=null&&_b.popover||(_d=(_c=event.previousState)==null?void 0:_c.data)!=null&&_d.popover||(__privateSet(this,_isPopstateNavigation,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:__privateGet(this,_lastRevalidate)?void 0:__privateGet(this,_lastSubmorph),revalidate:__privateGet(this,_lastRevalidate),keepScrollPosition:__privateGet(this,_lastKeepScrollPosition)}),__privateSet(this,_isPopstateNavigation,!1))}),"#popStateListener"));__privateAdd(this,_scrollListener,__name(()=>{const{left,top}=this.scrollValue,directionY=top-__privateGet(this,_currentScrollY),directionX=left-__privateGet(this,_currentScrollX);__privateSet(this,_currentScrollY,top),__privateSet(this,_currentScrollX,left),document.documentElement.classList.toggle("scroll-y",top>0),document.documentElement.classList.toggle("scroll-x",left>0),document.documentElement.classList.toggle("scroll-y-forward",directionY>0),document.documentElement.classList.toggle("scroll-y-backward",directionY<0),document.documentElement.classList.toggle("scroll-x-forward",directionX>0),document.documentElement.classList.toggle("scroll-x-backward",directionX<0),events.dispatchEvent(document,"morphScroll",{detail:{left,top}})},"#scrollListener"));if(Store.isBrowser&&!_Morph.instance){_Morph.instance=this,__privateSet(this,_options,{base:url.normalizeBase(parameters==null?void 0:parameters.base),waitForHeadToLoad:(parameters==null?void 0:parameters.waitForHeadToLoad)!==!1,trailingSlash:(parameters==null?void 0:parameters.trailingSlash)||!1,scrollSelector:parameters==null?void 0:parameters.scrollSelector,morphInsideScrollContainer:(parameters==null?void 0:parameters.morphInsideScrollContainer)||!1}),__privateSet(this,_morphElements,__privateMethod(this,_Morph_instances,getMorphElements_fn).call(this,document.body));const normalizedURL=this.normalizePath(location.pathname+location.search+location.hash);__privateSet(this,_currentURL,normalizedURL);const initialRoute=new MorphRoute(this,__privateGet(this,_currentURL).pathname);initialRoute.setInitialDocument(document),__privateGet(this,_routes).set(__privateGet(this,_currentURL).pathname,initialRoute),document.documentElement.setAttribute("data-current-pathname",__privateGet(this,_currentURL).pathname),document.documentElement.setAttribute("data-current-leaf",normalizedURL.leaf),this.findLinks(),this.findParamsDependent(),historyManager.historyManager.addPopStateHandler(__privateGet(this,_popStateListener)),historyManager.historyManager.__change({action:"replace",pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters,hash:normalizedURL.hash}),__privateSet(this,_announcer,new MorphAnnouncer),__privateMethod(this,_Morph_instances,updateCurrentScrollElement_fn).call(this,document)}}get currentURL(){return __privateGet(this,_currentURL)}get previousURL(){return __privateGet(this,_previousURL)}get links(){return __privateGet(this,_links)}get scrollElement(){return __privateGet(this,_currentScrollElement)}get isPopstateNavigation(){return __privateGet(this,_isPopstateNavigation)}get scrollValue(){let top=0,left=0;return __privateGet(this,_isWindowScroll)?(top=window.scrollY,left=window.scrollX):(top=__privateGet(this,_currentScrollElement).scrollTop,left=__privateGet(this,_currentScrollElement).scrollLeft),{top,left}}get isNavigating(){return!!__privateGet(this,_promises).length}saveState(state){const route=__privateGet(this,_routes).get(__privateGet(this,_currentURL).path);route&&route.saveState(state)}getState(){const route=__privateGet(this,_routes).get(__privateGet(this,_currentURL).path);return route==null?void 0:route.clearState()}normalizePath(path,options){return url.splitPath(path,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash,mergeParams:options!=null&&options.mergeParams?location.search:"",removeParams:options==null?void 0:options.removeParams})}prefetch(path,revalidate){return __async(this,null,function*(){var _a;if(__privateGet(this,_promises).length)return;path=((_a=this.pathnameModifier)==null?void 0:_a.call(this,path))||path;const route=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,path);route==null||route.fetch(path,__privateGet(this,_currentURL).path,revalidate)})}excludeHeadChild(child){return!1}needRavalidation(path){const normalizedURL=this.normalizePath(path),route=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,normalizedURL.path);route==null||route.needRavalidation()}navigate(_0){return __async(this,arguments,function*(path,{historyAction="push",centerScroll,offsetScroll,scrollDuration,scrollEasing,scrollBehaviour,revalidate,keepSearchParameters,submorph,submorphAppend,clearState,keepScrollPosition,mergeParams,removeParams,detail,scrollTo}={}){var _a,_b,_c,_d;if(__privateGet(this,_promises).length)return;__privateSet(this,_lastSubmorph,submorph),__privateSet(this,_lastRevalidate,revalidate),__privateSet(this,_lastKeepScrollPosition,keepScrollPosition);const modifiedPath=((_a=this.pathnameModifier)==null?void 0:_a.call(this,path))||path,normalizedURL=this.normalizePath(modifiedPath,{mergeParams,removeParams});if(!revalidate&&(((_b=__privateGet(this,_candidateURL))==null?void 0:_b.pathname)===normalizedURL.pathname||__privateGet(this,_currentURL).pathname===normalizedURL.pathname)){keepScrollPosition||__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,scrollTo||normalizedURL.hash||0,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:"smooth"}),events.dispatchEvent(document,"morphSamePath",{detail:{detail}}),((_c=__privateGet(this,_currentURL))==null?void 0:_c.parameters)!==normalizedURL.parameters&&(__privateSet(this,_previousURL,__privateGet(this,_currentURL)),__privateSet(this,_currentURL,normalizedURL),historyManager.historyManager.__change({action:((_d=__privateGet(this,_currentURL))==null?void 0:_d.hash)!==normalizedURL.hash?"replace":historyAction,pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters,hash:normalizedURL.hash}),events.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:__privateGet(this,_currentURL),previousURL:__privateGet(this,_previousURL),detail}})),__privateGet(this,_links).forEach(link=>{link.checkCurrent(normalizedURL.path)});return}else __privateGet(this,_links).forEach(link=>{link.checkCurrent(normalizedURL.path)});__privateSet(this,_candidateURL,normalizedURL);try{let preprocessedSuccesfully=!0;if(this.preprocessor)try{yield new Promise((resolve,reject)=>{var _a2;(_a2=this.preprocessor)==null||_a2.call(this,{url:normalizedURL,resolve,reject,submorph,detail})})}catch(e){e?console.error(e):console.log("Route change canceled"),preprocessedSuccesfully=!1}if(!preprocessedSuccesfully||__privateGet(this,_candidateURL).pathname!==normalizedURL.pathname){__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)});return}const navigationEntry={url:normalizedURL,submorph,detail};submorph?submorphAppend||submorph.forEach(sel=>{document.querySelectorAll(sel).forEach(el=>{el.classList.add("out"),el.setAttribute("data-morph-out","")})}):__privateGet(this,_morphElements).forEach(el=>{var _a2,_b2;(_a2=el.firstElementChild)==null||_a2.classList.add("out"),(_b2=el.firstElementChild)==null||_b2.setAttribute("data-morph-out","")}),events.dispatchEvent(document,"morphNavigation",{detail:navigationEntry});const currentRoute=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,__privateGet(this,_currentURL).pathname),nextRoute=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,normalizedURL.pathname);if(__privateGet(this,_routes).forEach(el=>{el.pathname!==normalizedURL.pathname&&el.abort()}),yield nextRoute==null?void 0:nextRoute.fetch(modifiedPath,__privateGet(this,_currentURL).path,revalidate),__privateGet(this,_candidateURL).pathname!==normalizedURL.pathname){__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)});return}currentRoute.clearState(),currentRoute.saveScrollState(),currentRoute.saveDocumentState(),(!__privateGet(this,_isPopstateNavigation)||revalidate)&&(nextRoute.clearScrollState(),nextRoute.clearDocumentState()),clearState&&nextRoute.clearState(),nextRoute.cloneDocument(),__privateGet(this,_announcer).textContent=nextRoute.title,document.body.appendChild(__privateGet(this,_announcer));const documentFetchedEntry=__spreadProps(__spreadValues({},navigationEntry),{document:nextRoute.document});submorphAppend||documentFetchedEntry.document.querySelectorAll("[data-morph-out]").forEach(el=>{el.classList.remove("out")}),events.dispatchEvent(document,"morphStart",{detail:documentFetchedEntry});const currentHeadChildren=Array.from(document.head.children),newHeadChildren=Array.from(nextRoute.document.head.children),identicalHeadChildren=dom.intersectElements(currentHeadChildren,newHeadChildren),removeHeadChildren=dom.excludeElements(currentHeadChildren,identicalHeadChildren),addHeadChildren=dom.excludeElements(newHeadChildren,identicalHeadChildren).filter(child=>!this.excludeHeadChild(child));addHeadChildren.forEach((child,index)=>{child.tagName==="SCRIPT"&&(addHeadChildren[index]=dom.createScriptElement(child))}),addHeadChildren.forEach(child=>{document.head.appendChild(child)});const elementsWithLoad=addHeadChildren.filter(child=>{if(child.hasAttribute("data-no-waiting"))return!1;if(__privateMethod(this,_Morph_instances,isElementEmitsLoadEvent_fn).call(this,child))return!0});__privateGet(this,_options).waitForHeadToLoad&&elementsWithLoad.length&&(yield new Promise(res=>__async(this,null,function*(){let counter=0;try{for(var iter=__forAwait(elementsWithLoad),more,temp,error;more=!(temp=yield iter.next()).done;more=!1){const element=temp.value;element.onload=()=>{counter++,counter===elementsWithLoad.length&&res()}}}catch(temp){error=[temp]}finally{try{more&&(temp=iter.return)&&(yield temp.call(iter))}finally{if(error)throw error[0]}}}))),yield promises.wait(10);const oldElementsWithLoadEvent=[];submorphAppend||removeHeadChildren.forEach(child=>{child.hasAttribute("data-permanent")||(__privateMethod(this,_Morph_instances,isElementEmitsLoadEvent_fn).call(this,child)?oldElementsWithLoadEvent.push(child):child.remove())});const newMorphElements=__privateMethod(this,_Morph_instances,getMorphElements_fn).call(this,nextRoute.document.body);!__privateGet(this,_options).morphInsideScrollContainer&&!submorph&&__privateMethod(this,_Morph_instances,updateCurrentScrollElement_fn).call(this,nextRoute.document),document.documentElement.setAttribute("data-current-pathname",normalizedURL.pathname),document.documentElement.setAttribute("data-current-leaf",normalizedURL.leaf),historyManager.historyManager.__change({action:historyAction,pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters||(keepSearchParameters?location.search:""),hash:normalizedURL.hash}),__privateGet(this,_announcer).remove(),__privateSet(this,_previousURL,__privateGet(this,_currentURL)),__privateSet(this,_currentURL,normalizedURL);const morphedElements=[];__privateGet(this,_morphElements).forEach((morphElement,i)=>{const newMorphElement=newMorphElements[i],duration=getComputedStyle(morphElement).getPropertyValue("--morph-duration");let newMorphElementChildNodes=[],currentMorphElementChildNodes=[];submorph?(submorph.forEach(selector=>{const curSubMorphElement=morphElement.querySelector(selector),newSubMorphElement=newMorphElement.querySelector(selector);curSubMorphElement&&newSubMorphElement&&(currentMorphElementChildNodes.push(curSubMorphElement),newMorphElementChildNodes.push(newSubMorphElement))}),currentMorphElementChildNodes.forEach(el=>{el.parentElement&&morphedElements.push(el.parentElement)})):(newMorphElementChildNodes.push(...newMorphElement.childNodes),currentMorphElementChildNodes.push(...morphElement.childNodes),morphedElements.push(morphElement));const transfer=[];submorphAppend||currentMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&(this.destroyOldLinks(element),element.classList.add("old"),element.querySelectorAll("[data-morph-transfer]").forEach(el=>{const selector=el.getAttribute("data-morph-transfer");transfer.push({element:el,selector})}))}),newMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&(transfer.forEach(item=>{const nestlement=element.querySelector(item.selector);nestlement&&nestlement.replaceWith(nextRoute.document.importNode(item.element,!0))}),this.findNewLinks(element),element.classList.add("new"))}),submorph?submorphAppend?newMorphElementChildNodes.forEach((el,i2)=>{currentMorphElementChildNodes[i2]instanceof HTMLElement&&currentMorphElementChildNodes[i2].append(...el.childNodes)}):newMorphElementChildNodes.forEach((el,i2)=>{var _a2;(_a2=currentMorphElementChildNodes[i2].parentElement)==null||_a2.insertBefore(el,currentMorphElementChildNodes[i2])}):morphElement.prepend(...newMorphElementChildNodes),setTimeout(()=>{submorphAppend||currentMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&element.classList.add("old-idle")}),newMorphElementChildNodes.forEach(element=>{var _a2;element instanceof HTMLElement&&((_a2=element.parentElement)==null||_a2.style.setProperty("--new-content-height",element.offsetHeight+"px"),element.classList.add("new-idle"))})},0);const detail2=__spreadProps(__spreadValues({},documentFetchedEntry),{morphElement});events.dispatchEvent(document,"morphNewChildrenAdded",{detail:detail2});const promise=new Promise(res=>{setTimeout(()=>{submorphAppend||currentMorphElementChildNodes.forEach(el=>{el.remove()}),newMorphElementChildNodes.forEach(element=>{var _a2;element instanceof HTMLElement&&((_a2=element.parentElement)==null||_a2.style.removeProperty("--new-content-height"),element.classList.remove("new-idle","new"))}),submorphAppend||events.dispatchEvent(document,"morphOldChildrenRemoved",{detail:detail2}),res()},(parseFloat(duration)||0)*1e3+10)});__privateGet(this,_promises).push(promise)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-nextRoute.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),events.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:nextRoute.scrollState}),scrollTo?(nextRoute.clearScrollState(),__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,scrollTo,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:scrollBehaviour})):normalizedURL.hash?(nextRoute.clearScrollState(),__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,normalizedURL.hash,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:scrollBehaviour})):__privateGet(this,_isPopstateNavigation)?nextRoute.restoreScrollPosition():keepScrollPosition||nextRoute.renewScrollPosition(),yield Promise.all(__privateGet(this,_promises)),submorphAppend||oldElementsWithLoadEvent.forEach(child=>child.remove()),__privateSet(this,_promises,[]),morphedElements.forEach(el=>{el.querySelectorAll("script").forEach(element=>{element.replaceWith(dom.createScriptElement(element))})}),__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)}),this.findParamsDependent(),events.dispatchEvent(document,"morphComplete",{detail:documentFetchedEntry}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(e){console.error(e)}__privateSet(this,_candidateURL,void 0)})}addLink(element){__privateGet(this,_links).push(new MorphLink(element,this))}addLinks(elements){elements.forEach(element=>{this.addLink(element)})}removeLink(element){__privateSet(this,_links,__privateGet(this,_links).filter(link=>link.element===element?(link.destroy(),!1):!0))}destroyOldLinks(morphElement){__privateSet(this,_links,__privateGet(this,_links).filter(link=>morphElement.contains(link.element)?(link.destroy(),!1):!0))}findNewLinks(morphElement){const linkElements=[...morphElement.querySelectorAll("a")].filter(__privateGet(this,_checkLink));__privateGet(this,_links).push(...linkElements.map(element=>new MorphLink(element,this)))}findLinks(){const linkElements=[...document.documentElement.querySelectorAll("a")].filter(__privateGet(this,_checkLink));__privateGet(this,_links).forEach(link=>link.destroy()),__privateSet(this,_links,linkElements.map(element=>new MorphLink(element,this)))}findParamsDependent(){const elements=[...document.documentElement.querySelectorAll("[data-morph-params-dependent]")];__privateGet(this,_paramDependent).forEach(link=>link.destroy()),__privateSet(this,_paramDependent,elements.map(element=>new MorphParamsDependent(element)))}};_options=new WeakMap,_morphElements=new WeakMap,_links=new WeakMap,_candidateURL=new WeakMap,_currentURL=new WeakMap,_previousURL=new WeakMap,_promises=new WeakMap,_isPopstateNavigation=new WeakMap,_currentScrollElement=new WeakMap,_isWindowScroll=new WeakMap,_routes=new WeakMap,_paramDependent=new WeakMap,_announcer=new WeakMap,_currentScrollX=new WeakMap,_currentScrollY=new WeakMap,_lastSubmorph=new WeakMap,_lastRevalidate=new WeakMap,_lastKeepScrollPosition=new WeakMap,_checkLink=new WeakMap,_Morph_instances=new WeakSet,getRoute_fn=__name(function(path){const normalizedURL=this.normalizePath(path);let route=__privateGet(this,_routes).get(normalizedURL.pathname);return route||(route=new MorphRoute(this,normalizedURL.pathname),__privateGet(this,_routes).set(normalizedURL.pathname,route)),route},"#getRoute"),getMorphElements_fn=__name(function(el){const morphElements=[...el.querySelectorAll("[data-morph]")];return morphElements.length?morphElements:[el]},"#getMorphElements"),isElementEmitsLoadEvent_fn=__name(function(element){return element.tagName==="SCRIPT"||element.tagName==="STYLE"||element.tagName==="LINK"&&element.getAttribute("rel")==="stylesheet"},"#isElementEmitsLoadEvent"),updateCurrentScrollElement_fn=__name(function(document2){var _a,_b;(_a=__privateGet(this,_currentScrollElement))==null||_a.removeEventListener("scroll",__privateGet(this,_scrollListener)),__privateSet(this,_currentScrollY,0),__privateSet(this,_currentScrollX,0),__privateSet(this,_currentScrollElement,__privateGet(this,_options).scrollSelector&&document2.querySelector(__privateGet(this,_options).scrollSelector)||window),__privateSet(this,_isWindowScroll,__privateGet(this,_currentScrollElement)===window),(_b=__privateGet(this,_currentScrollElement))==null||_b.addEventListener("scroll",__privateGet(this,_scrollListener)),__privateGet(this,_scrollListener).call(this)},"#updateCurrentScrollElement"),tryScrollToElement_fn=__name(function(id,options){const value=typeof id=="string"?document.querySelector(id):id;(typeof value=="number"||value)&&scroll.scrollToElement(value,__spreadValues({scrollElement:__privateGet(this,_currentScrollElement)},options))},"#tryScrollToElement"),_popStateListener=new WeakMap,_scrollListener=new WeakMap,__name(_Morph,"Morph"),_Morph.instance=null;let Morph=_Morph;exports.Morph=Morph;
1
+ "use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __knownSymbol=(name,symbol)=>(symbol=Symbol[name])?symbol:Symbol.for("Symbol."+name),__typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);var __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});var __forAwait=(obj,it,method)=>(it=obj[__knownSymbol("asyncIterator")])?it.call(obj):(obj=obj[__knownSymbol("iterator")](),it={},method=(key,fn)=>(fn=obj[key])&&(it[key]=arg=>new Promise((yes,no,done)=>(arg=fn.call(obj,arg),done=arg.done,Promise.resolve(arg.value).then(value=>yes({value,done}),no)))),method("next"),method("return"),it);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Store=require("../Store-B96mD8mD.cjs"),dom=require("../dom-B40i6NXw.cjs"),events=require("../events-UlGk63iC.cjs"),promises=require("../promises-nDm8_iG6.cjs"),scroll=require("../scroll-CTDesBpj.cjs");require("construct-style-sheets-polyfill");require("../index-BoGx2BWX.cjs");const url=require("../url-CbDPURsX.cjs"),cssValueParser_index=require("../css-value-parser/index.cjs"),historyManager=require("../historyManager-Car6P2ak.cjs"),_MorphAnnouncer=class _MorphAnnouncer extends HTMLElement{connectedCallback(){const attrs={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[key,value]of Object.entries(attrs))this.setAttribute(key,value)}};__name(_MorphAnnouncer,"MorphAnnouncer");let MorphAnnouncer=_MorphAnnouncer;Store.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",MorphAnnouncer);var _morph,_element,_MorphLink_instances,path_get,click_fn,_clickListener,_pointerListener;const _MorphLink=class _MorphLink{constructor(element,morph){__privateAdd(this,_MorphLink_instances);__privateAdd(this,_morph);__privateAdd(this,_element);__privateAdd(this,_clickListener,__name(e=>{e.preventDefault(),__privateMethod(this,_MorphLink_instances,click_fn).call(this)},"#clickListener"));__privateAdd(this,_pointerListener,__name(()=>{const revalidate=__privateGet(this,_element).hasAttribute("data-revalidate");__privateGet(this,_morph).prefetch(__privateGet(this,_MorphLink_instances,path_get),revalidate),__privateGet(this,_element).removeEventListener("pointerenter",__privateGet(this,_pointerListener))},"#pointerListener"));__privateSet(this,_morph,morph),__privateSet(this,_element,element),__privateGet(this,_element).addEventListener("click",__privateGet(this,_clickListener)),this.checkCurrent(location.href.replace(location.origin,"")),__privateGet(this,_element).hasAttribute("data-prefetch")&&__privateGet(this,_element).addEventListener("pointerenter",__privateGet(this,_pointerListener))}get element(){return __privateGet(this,_element)}checkCurrent(path){var _a,_b;const locationUrl=__privateGet(this,_morph).normalizePath(path),linkUrl=__privateGet(this,_morph).normalizePath(__privateGet(this,_MorphLink_instances,path_get));__privateGet(this,_element).hasAttribute("data-include")&&locationUrl.pathname.includes(linkUrl.pathname)?__privateGet(this,_element).classList.add("current"):linkUrl.pathname===locationUrl.pathname?__privateGet(this,_element).classList.add("current"):(_a=__privateGet(this,_element).getAttribute("data-associated-paths"))!=null&&_a.split(",").find(path2=>locationUrl.pathname.includes(path2))?__privateGet(this,_element).classList.add("current"):__privateGet(this,_element).classList.remove("current"),locationUrl.path===linkUrl.path?__privateGet(this,_element).classList.add("exact"):__privateGet(this,_element).classList.remove("exact");const[pathWithoutParams,pathParamsStr]=(_b=__privateGet(this,_MorphLink_instances,path_get).split("#")[0])==null?void 0:_b.split("?"),pathParams=new URLSearchParams(pathParamsStr),locationParams=new URLSearchParams(location.search);let matchCounter=0;for(const[key]of locationParams)pathParams.has(key)&&locationParams.get(key)===pathParams.get(key)&&matchCounter++;matchCounter?(__privateGet(this,_element).classList.toggle("all-params-matched",locationParams.size===matchCounter),__privateGet(this,_element).classList.toggle("some-params-matched",locationParams.size!==matchCounter)):!locationParams.size&&__privateGet(this,_element).hasAttribute("data-match-no-params")?__privateGet(this,_element).classList.add("all-params-matched"):(__privateGet(this,_element).classList.remove("all-params-matched"),__privateGet(this,_element).classList.remove("some-params-matched"));for(const key in __privateGet(this,_element).dataset){const kebabKey=Store.camelToKebab(key);if(kebabKey.startsWith("match-param-")){const name=kebabKey.split("match-param-")[1],value=__privateGet(this,_element).dataset[key],className=`param-${name}-matched`;locationParams.has(name)&&locationParams.get(name)===value||!locationParams.has(name)&&(value===""||value==="*"||value==="all"||value==="any"||value==="vse")?__privateGet(this,_element).classList.add(className):__privateGet(this,_element).classList.remove(className)}}}destroy(){__privateGet(this,_element).removeEventListener("click",__privateGet(this,_clickListener)),__privateGet(this,_element).removeEventListener("pointerenter",__privateGet(this,_pointerListener)),__privateGet(this,_element).classList.remove("current","exact")}};_morph=new WeakMap,_element=new WeakMap,_MorphLink_instances=new WeakSet,path_get=__name(function(){const url2=new URL(__privateGet(this,_element).href);return __privateGet(this,_morph).normalizePath(url2.pathname+url2.search+url2.hash).path},"#path"),click_fn=__name(function(){var _a;if(document.documentElement.classList.contains("click-disabled"))return;if(__privateGet(this,_element).hasAttribute("data-back")&&__privateGet(this,_morph).previousURL)history.back();else{const historyAction=__privateGet(this,_element).getAttribute("data-history-action")||"push",centerScroll=__privateGet(this,_element).hasAttribute("data-center-scroll"),offsetScrollRawValue=getComputedStyle(__privateGet(this,_element)).getPropertyValue("--offset-scroll").trim(),offsetScroll=offsetScrollRawValue?cssValueParser_index.cssValueParser.parse(offsetScrollRawValue):void 0,scrollDuration=parseFloat(__privateGet(this,_element).getAttribute("data-scroll-duration")||"0")||void 0,scrollEasing=__privateGet(this,_element).getAttribute("data-scroll-easing")||void 0,revalidate=__privateGet(this,_element).hasAttribute("data-revalidate")||__privateGet(this,_element).hasAttribute("data-pagination-more-link")||__privateGet(this,_element).hasAttribute("data-pagination-set-link")||__privateGet(this,_element).hasAttribute("data-pagination-next-link")||__privateGet(this,_element).hasAttribute("data-pagination-prev-link"),keepSearchParameters=__privateGet(this,_element).hasAttribute("data-keep-search-parameters"),keepScrollPosition=__privateGet(this,_element).hasAttribute("data-keep-scroll-position")||__privateGet(this,_element).hasAttribute("data-pagination-more-link"),scrollBehaviour=__privateGet(this,_element).getAttribute("data-scroll-behaviour"),submorph=(_a=__privateGet(this,_element).getAttribute("data-submorph")||__privateGet(this,_element).getAttribute("data-submorph-append"))==null?void 0:_a.split(",").map(v=>v.trim()),clearState=__privateGet(this,_element).hasAttribute("data-clear-state");let path=__privateGet(this,_MorphLink_instances,path_get);if(__privateGet(this,_element).hasAttribute("data-toggle-params")){const[pathWithoutParams,pathParamsStr]=__privateGet(this,_MorphLink_instances,path_get).split("?"),pathParams=new URLSearchParams(pathParamsStr),locationParams=new URLSearchParams(location.search),resultParams=new URLSearchParams;for(const[key]of pathParams)(!locationParams.has(key)||locationParams.has(key)&&locationParams.get(key)!==pathParams.get(key))&&resultParams.append(key,pathParams.get(key));if(__privateGet(this,_element).hasAttribute("data-merge-params"))for(const[key]of locationParams)pathParams.has(key)||resultParams.append(key,locationParams.get(key));path=`${pathWithoutParams}?${resultParams.toString()}`}__privateGet(this,_morph).navigate(path,{historyAction,centerScroll,offsetScroll,revalidate,keepSearchParameters,submorph,clearState,keepScrollPosition,scrollBehaviour,scrollDuration,scrollEasing,submorphAppend:__privateGet(this,_element).hasAttribute("data-submorph-append"),mergeParams:__privateGet(this,_element).hasAttribute("data-merge-params")&&!__privateGet(this,_element).hasAttribute("data-toggle-params"),detail:__privateGet(this,_element).getAttribute("data-detail"),removeParams:__privateGet(this,_element).getAttribute("data-remove-params")||void 0,scrollTo:__privateGet(this,_element).getAttribute("data-scroll-to")||void 0})}},"#click"),_clickListener=new WeakMap,_pointerListener=new WeakMap,__name(_MorphLink,"MorphLink");let MorphLink=_MorphLink;var _element2,_params,_MorphParamsDependent_instances,update_fn,_urlChangeListener;const _MorphParamsDependent=class _MorphParamsDependent{constructor(element){__privateAdd(this,_MorphParamsDependent_instances);__privateAdd(this,_element2);__privateAdd(this,_params,[]);__privateAdd(this,_urlChangeListener,__name(()=>{__privateMethod(this,_MorphParamsDependent_instances,update_fn).call(this)},"#urlChangeListener"));__privateSet(this,_element2,element);for(const key in __privateGet(this,_element2).dataset){const kebabKey=Store.camelToKebab(key);if(kebabKey.startsWith("param-")){const name=kebabKey.split("param-")[1],value=__privateGet(this,_element2).dataset[key];__privateGet(this,_params).push({name,value})}}document.addEventListener("morphURLParametersChange",__privateGet(this,_urlChangeListener)),__privateMethod(this,_MorphParamsDependent_instances,update_fn).call(this)}destroy(){document.removeEventListener("morphURLParametersChange",__privateGet(this,_urlChangeListener))}};_element2=new WeakMap,_params=new WeakMap,_MorphParamsDependent_instances=new WeakSet,update_fn=__name(function(){const locationParams=new URLSearchParams(location.search);let matched=!!__privateGet(this,_params).find(param=>locationParams.has(param.name)&&(locationParams.get(param.name)===param.value||param.value==="*"||param.value==="all"||param.value==="any"||param.value==="vse"||locationParams.get(param.name)==="*"||locationParams.get(param.name)==="all"||locationParams.get(param.name)==="any"||locationParams.get(param.name)==="vse"));!matched&&__privateGet(this,_element2).hasAttribute("data-match-no-params")&&(matched=!__privateGet(this,_params).filter(param=>locationParams.has(param.name)).length);const hideClass=__privateGet(this,_element2).getAttribute("data-hide-class");matched?hideClass?__privateGet(this,_element2).classList.remove(hideClass):__privateGet(this,_element2).style.display="":hideClass?__privateGet(this,_element2).classList.add(hideClass):__privateGet(this,_element2).style.display="none",requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("resize"))})},"#update"),_urlChangeListener=new WeakMap,__name(_MorphParamsDependent,"MorphParamsDependent");let MorphParamsDependent=_MorphParamsDependent;const domParser=new DOMParser;var _morph2,_pathname,_scrollState,_initialDocument,_modifiedDocument,_currentDocument,_savedState,_abortController,_fetching,_headers,_needRavalidation;const _MorphRoute=class _MorphRoute{constructor(morph,pathname){__privateAdd(this,_morph2);__privateAdd(this,_pathname);__privateAdd(this,_scrollState,{x:0,y:0});__privateAdd(this,_initialDocument,null);__privateAdd(this,_modifiedDocument,null);__privateAdd(this,_currentDocument,null);__privateAdd(this,_savedState,null);__privateAdd(this,_abortController,null);__privateAdd(this,_fetching,null);__privateAdd(this,_headers);__privateAdd(this,_needRavalidation,!1);__privateSet(this,_morph2,morph),__privateSet(this,_pathname,pathname)}get pathname(){return __privateGet(this,_pathname)}get scrollState(){return __privateGet(this,_scrollState)}get document(){return __privateGet(this,_currentDocument)}needRavalidation(){__privateSet(this,_needRavalidation,!0)}setHeaders(headers){__privateSet(this,_headers,headers)}setInitialDocument(document2){__privateSet(this,_initialDocument,document2.cloneNode(!0))}abort(){var _a;return(_a=__privateGet(this,_abortController))==null?void 0:_a.abort(`[${__privateGet(this,_pathname)}] page loading cancelled`)}fetch(path,currentPath,revalidate){return __async(this,null,function*(){var _a;if(!revalidate&&!__privateGet(this,_needRavalidation)){const shouldUseCache=((_a=__privateGet(this,_initialDocument))==null?void 0:_a.documentElement.getAttribute("data-cache"))&&currentPath!==path,isPopstateNavigation=__privateGet(this,_initialDocument)&&__privateGet(this,_morph2).isPopstateNavigation;if(__privateGet(this,_fetching)||shouldUseCache||isPopstateNavigation)return __privateGet(this,_fetching)}return __privateSet(this,_fetching,new Promise(res=>__async(this,null,function*(){try{__privateSet(this,_abortController,new AbortController);const text=yield(yield fetch(path,{signal:__privateGet(this,_abortController).signal,headers:__spreadValues({"X-MORPH":"true","X-MORPH-REVALIDATE":revalidate?"true":"false","X-MORPH-CURRENT-PATH":encodeURIComponent(currentPath),"X-MORPH-NEW-PATH":encodeURIComponent(path)},__privateGet(this,_headers))})).text(),document2=domParser.parseFromString(text,"text/html");this.setInitialDocument(document2),__privateSet(this,_needRavalidation,!1)}catch(e){console.warn(e)}finally{__privateSet(this,_abortController,null),__privateSet(this,_fetching,null),res()}}))),__privateGet(this,_fetching)})}cloneDocument(){__privateSet(this,_currentDocument,(__privateGet(this,_modifiedDocument)||__privateGet(this,_initialDocument)).cloneNode(!0))}get title(){let title="";if(__privateGet(this,_currentDocument).title)title=__privateGet(this,_currentDocument).title;else{const h1=__privateGet(this,_currentDocument).querySelector("h1");title=(h1==null?void 0:h1.innerText)||(h1==null?void 0:h1.textContent)||__privateGet(this,_pathname)}return title}clearScrollState(){__privateGet(this,_scrollState).x=0,__privateGet(this,_scrollState).y=0}clearDocumentState(){__privateSet(this,_modifiedDocument,null)}saveScrollState(){__privateGet(this,_initialDocument).documentElement.hasAttribute("data-no-scroll-restoration")?(__privateGet(this,_scrollState).x=0,__privateGet(this,_scrollState).y=0):(__privateGet(this,_scrollState).x=__privateGet(this,_morph2).scrollValue.left,__privateGet(this,_scrollState).y=__privateGet(this,_morph2).scrollValue.top)}restoreScrollPosition(){__privateGet(this,_morph2).scrollElement.scroll({top:__privateGet(this,_scrollState).y,left:__privateGet(this,_scrollState).x,behavior:"instant"})}saveDocumentState(){__privateGet(this,_initialDocument).documentElement.hasAttribute("data-no-page-restoration")?__privateSet(this,_modifiedDocument,null):__privateSet(this,_modifiedDocument,document.cloneNode(!0))}renewScrollPosition(){__privateGet(this,_morph2).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(state){__privateSet(this,_savedState,state)}clearState(){const state=__privateGet(this,_savedState);return __privateSet(this,_savedState,null),state}};_morph2=new WeakMap,_pathname=new WeakMap,_scrollState=new WeakMap,_initialDocument=new WeakMap,_modifiedDocument=new WeakMap,_currentDocument=new WeakMap,_savedState=new WeakMap,_abortController=new WeakMap,_fetching=new WeakMap,_headers=new WeakMap,_needRavalidation=new WeakMap,__name(_MorphRoute,"MorphRoute");let MorphRoute=_MorphRoute;var _options,_morphElements,_links,_candidateURL,_currentURL,_previousURL,_promises,_isPopstateNavigation,_currentScrollElement,_isWindowScroll,_routes,_paramDependent,_announcer,_currentScrollX,_currentScrollY,_lastSubmorph,_lastRevalidate,_lastKeepScrollPosition,_checkLink,_Morph_instances,getRoute_fn,getMorphElements_fn,isElementEmitsLoadEvent_fn,updateCurrentScrollElement_fn,tryScrollToElement_fn,_popStateListener,_scrollListener;const _Morph=class _Morph{constructor(parameters){__privateAdd(this,_Morph_instances);__privateAdd(this,_options,null);__privateAdd(this,_morphElements,null);__privateAdd(this,_links,[]);__privateAdd(this,_candidateURL);__privateAdd(this,_currentURL,null);__privateAdd(this,_previousURL);__privateAdd(this,_promises,[]);__privateAdd(this,_isPopstateNavigation,!1);__privateAdd(this,_currentScrollElement,null);__privateAdd(this,_isWindowScroll,!1);__privateAdd(this,_routes,new Map);__privateAdd(this,_paramDependent,[]);__privateAdd(this,_announcer,null);__privateAdd(this,_currentScrollX,0);__privateAdd(this,_currentScrollY,0);__privateAdd(this,_lastSubmorph);__privateAdd(this,_lastRevalidate);__privateAdd(this,_lastKeepScrollPosition);__privateAdd(this,_checkLink,__name(element=>{var _a,_b;return(((_a=element.getAttribute("href"))==null?void 0:_a.startsWith("/"))||((_b=element.getAttribute("href"))==null?void 0:_b.startsWith("?")))&&!element.hasAttribute("download")&&!element.hasAttribute("data-morph-skip")&&!element.closest("[data-morph-skip]")&&element.getAttribute("target")!=="_blank"},"#checkLink"));__privateAdd(this,_popStateListener,__name(event=>__async(this,null,function*(){var _a,_b,_c,_d;(_b=(_a=event.state)==null?void 0:_a.data)!=null&&_b.popover||(_d=(_c=event.previousState)==null?void 0:_c.data)!=null&&_d.popover||(__privateSet(this,_isPopstateNavigation,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:__privateGet(this,_lastRevalidate)?void 0:__privateGet(this,_lastSubmorph),revalidate:__privateGet(this,_lastRevalidate),keepScrollPosition:__privateGet(this,_lastKeepScrollPosition)}),__privateSet(this,_isPopstateNavigation,!1))}),"#popStateListener"));__privateAdd(this,_scrollListener,__name(()=>{const{left,top}=this.scrollValue,directionY=top-__privateGet(this,_currentScrollY),directionX=left-__privateGet(this,_currentScrollX);__privateSet(this,_currentScrollY,top),__privateSet(this,_currentScrollX,left),document.documentElement.classList.toggle("scroll-y",top>0),document.documentElement.classList.toggle("scroll-x",left>0),document.documentElement.classList.toggle("scroll-y-forward",directionY>0),document.documentElement.classList.toggle("scroll-y-backward",directionY<0),document.documentElement.classList.toggle("scroll-x-forward",directionX>0),document.documentElement.classList.toggle("scroll-x-backward",directionX<0),events.dispatchEvent(document,"morphScroll",{detail:{left,top}})},"#scrollListener"));if(Store.isBrowser&&!_Morph.instance){_Morph.instance=this,__privateSet(this,_options,{base:url.normalizeBase(parameters==null?void 0:parameters.base),waitForHeadToLoad:(parameters==null?void 0:parameters.waitForHeadToLoad)!==!1,trailingSlash:(parameters==null?void 0:parameters.trailingSlash)||!1,scrollSelector:parameters==null?void 0:parameters.scrollSelector,morphInsideScrollContainer:(parameters==null?void 0:parameters.morphInsideScrollContainer)||!1}),__privateSet(this,_morphElements,__privateMethod(this,_Morph_instances,getMorphElements_fn).call(this,document.body));const normalizedURL=this.normalizePath(location.pathname+location.search+location.hash);__privateSet(this,_currentURL,normalizedURL);const initialRoute=new MorphRoute(this,__privateGet(this,_currentURL).pathname);initialRoute.setInitialDocument(document),__privateGet(this,_routes).set(__privateGet(this,_currentURL).pathname,initialRoute),document.documentElement.setAttribute("data-current-pathname",__privateGet(this,_currentURL).pathname),document.documentElement.setAttribute("data-current-leaf",normalizedURL.leaf),this.findLinks(),this.findParamsDependent(),historyManager.historyManager.addPopStateHandler(__privateGet(this,_popStateListener)),historyManager.historyManager.__change({action:"replace",pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters,hash:normalizedURL.hash}),__privateSet(this,_announcer,new MorphAnnouncer),__privateMethod(this,_Morph_instances,updateCurrentScrollElement_fn).call(this,document)}}get currentURL(){return __privateGet(this,_currentURL)}get previousURL(){return __privateGet(this,_previousURL)}get links(){return __privateGet(this,_links)}get scrollElement(){return __privateGet(this,_currentScrollElement)}get isPopstateNavigation(){return __privateGet(this,_isPopstateNavigation)}get scrollValue(){let top=0,left=0;return __privateGet(this,_isWindowScroll)?(top=window.scrollY,left=window.scrollX):(top=__privateGet(this,_currentScrollElement).scrollTop,left=__privateGet(this,_currentScrollElement).scrollLeft),{top,left}}get isNavigating(){return!!__privateGet(this,_promises).length}saveState(state){const route=__privateGet(this,_routes).get(__privateGet(this,_currentURL).path);route&&route.saveState(state)}getState(){const route=__privateGet(this,_routes).get(__privateGet(this,_currentURL).path);return route==null?void 0:route.clearState()}normalizePath(path,options){return url.splitPath(path,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash,mergeParams:options!=null&&options.mergeParams?location.search:"",removeParams:options==null?void 0:options.removeParams})}prefetch(path,revalidate){return __async(this,null,function*(){var _a;if(__privateGet(this,_promises).length)return;path=((_a=this.pathnameModifier)==null?void 0:_a.call(this,path))||path;const route=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,path);route==null||route.fetch(path,__privateGet(this,_currentURL).path,revalidate)})}excludeHeadChild(child){return!1}needRavalidation(path){const normalizedURL=this.normalizePath(path),route=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,normalizedURL.path);route==null||route.needRavalidation()}navigate(_0){return __async(this,arguments,function*(path,{historyAction="push",centerScroll,offsetScroll,scrollDuration,scrollEasing,scrollBehaviour,revalidate,keepSearchParameters,submorph,submorphAppend,clearState,keepScrollPosition,mergeParams,removeParams,detail,scrollTo}={}){var _a,_b,_c,_d;if(__privateGet(this,_promises).length)return;__privateSet(this,_lastSubmorph,submorph),__privateSet(this,_lastRevalidate,revalidate),__privateSet(this,_lastKeepScrollPosition,keepScrollPosition);const modifiedPath=((_a=this.pathnameModifier)==null?void 0:_a.call(this,path))||path,normalizedURL=this.normalizePath(modifiedPath,{mergeParams,removeParams});if(!revalidate&&(((_b=__privateGet(this,_candidateURL))==null?void 0:_b.pathname)===normalizedURL.pathname||__privateGet(this,_currentURL).pathname===normalizedURL.pathname)){keepScrollPosition||__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,scrollTo||normalizedURL.hash||0,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:"smooth"}),events.dispatchEvent(document,"morphSamePath",{detail:{detail}}),((_c=__privateGet(this,_currentURL))==null?void 0:_c.parameters)!==normalizedURL.parameters&&(__privateSet(this,_previousURL,__privateGet(this,_currentURL)),__privateSet(this,_currentURL,normalizedURL),historyManager.historyManager.__change({action:((_d=__privateGet(this,_currentURL))==null?void 0:_d.hash)!==normalizedURL.hash?"replace":historyAction,pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters,hash:normalizedURL.hash}),events.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:__privateGet(this,_currentURL),previousURL:__privateGet(this,_previousURL),detail}})),__privateGet(this,_links).forEach(link=>{link.checkCurrent(normalizedURL.path)});return}else __privateGet(this,_links).forEach(link=>{link.checkCurrent(normalizedURL.path)});__privateSet(this,_candidateURL,normalizedURL);try{let preprocessedSuccesfully=!0;if(this.preprocessor)try{yield new Promise((resolve,reject)=>{var _a2;(_a2=this.preprocessor)==null||_a2.call(this,{url:normalizedURL,resolve,reject,submorph,detail})})}catch(e){e?console.error(e):console.log("Route change canceled"),preprocessedSuccesfully=!1}if(!preprocessedSuccesfully||__privateGet(this,_candidateURL).pathname!==normalizedURL.pathname){__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)});return}const navigationEntry={url:normalizedURL,submorph,detail};submorph?submorphAppend||submorph.forEach(sel=>{document.querySelectorAll(sel).forEach(el=>{el.classList.add("out"),el.setAttribute("data-morph-out","")})}):__privateGet(this,_morphElements).forEach(el=>{var _a2,_b2;(_a2=el.firstElementChild)==null||_a2.classList.add("out"),(_b2=el.firstElementChild)==null||_b2.setAttribute("data-morph-out","")}),events.dispatchEvent(document,"morphNavigation",{detail:navigationEntry});const currentRoute=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,__privateGet(this,_currentURL).pathname),nextRoute=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,normalizedURL.pathname);if(__privateGet(this,_routes).forEach(el=>{el.pathname!==normalizedURL.pathname&&el.abort()}),yield nextRoute==null?void 0:nextRoute.fetch(modifiedPath,__privateGet(this,_currentURL).path,revalidate),__privateGet(this,_candidateURL).pathname!==normalizedURL.pathname){__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)});return}currentRoute.clearState(),currentRoute.saveScrollState(),currentRoute.saveDocumentState(),(!__privateGet(this,_isPopstateNavigation)||revalidate)&&(nextRoute.clearScrollState(),nextRoute.clearDocumentState()),clearState&&nextRoute.clearState(),nextRoute.cloneDocument(),__privateGet(this,_announcer).textContent=nextRoute.title,document.body.appendChild(__privateGet(this,_announcer));const documentFetchedEntry=__spreadProps(__spreadValues({},navigationEntry),{document:nextRoute.document});submorphAppend||documentFetchedEntry.document.querySelectorAll("[data-morph-out]").forEach(el=>{el.classList.remove("out")}),events.dispatchEvent(document,"morphStart",{detail:documentFetchedEntry});const currentHeadChildren=Array.from(document.head.children),newHeadChildren=Array.from(nextRoute.document.head.children),identicalHeadChildren=dom.intersectElements(currentHeadChildren,newHeadChildren),removeHeadChildren=dom.excludeElements(currentHeadChildren,identicalHeadChildren),addHeadChildren=dom.excludeElements(newHeadChildren,identicalHeadChildren).filter(child=>!this.excludeHeadChild(child));addHeadChildren.forEach((child,index)=>{child.tagName==="SCRIPT"&&(addHeadChildren[index]=dom.createScriptElement(child))}),addHeadChildren.forEach(child=>{document.head.appendChild(child)});const elementsWithLoad=addHeadChildren.filter(child=>{if(child.hasAttribute("data-no-waiting"))return!1;if(__privateMethod(this,_Morph_instances,isElementEmitsLoadEvent_fn).call(this,child))return!0});__privateGet(this,_options).waitForHeadToLoad&&elementsWithLoad.length&&(yield new Promise(res=>__async(this,null,function*(){let counter=0;try{for(var iter=__forAwait(elementsWithLoad),more,temp,error;more=!(temp=yield iter.next()).done;more=!1){const element=temp.value;element.onload=()=>{counter++,counter===elementsWithLoad.length&&res()}}}catch(temp){error=[temp]}finally{try{more&&(temp=iter.return)&&(yield temp.call(iter))}finally{if(error)throw error[0]}}}))),yield promises.wait(10);const oldElementsWithLoadEvent=[];submorphAppend||removeHeadChildren.forEach(child=>{child.hasAttribute("data-permanent")||(__privateMethod(this,_Morph_instances,isElementEmitsLoadEvent_fn).call(this,child)?oldElementsWithLoadEvent.push(child):child.remove())});const newMorphElements=__privateMethod(this,_Morph_instances,getMorphElements_fn).call(this,nextRoute.document.body);!__privateGet(this,_options).morphInsideScrollContainer&&!submorph&&__privateMethod(this,_Morph_instances,updateCurrentScrollElement_fn).call(this,nextRoute.document),document.documentElement.setAttribute("data-current-pathname",normalizedURL.pathname),document.documentElement.setAttribute("data-current-leaf",normalizedURL.leaf),historyManager.historyManager.__change({action:historyAction,pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters||(keepSearchParameters?location.search:""),hash:normalizedURL.hash}),__privateGet(this,_announcer).remove(),__privateSet(this,_previousURL,__privateGet(this,_currentURL)),__privateSet(this,_currentURL,normalizedURL);const morphedElements=[];__privateGet(this,_morphElements).forEach((morphElement,i)=>{const newMorphElement=newMorphElements[i],duration=getComputedStyle(morphElement).getPropertyValue("--morph-duration");let newMorphElementChildNodes=[],currentMorphElementChildNodes=[];submorph?(submorph.forEach(selector=>{const curSubMorphElement=morphElement.querySelector(selector),newSubMorphElement=newMorphElement.querySelector(selector);curSubMorphElement&&newSubMorphElement&&(currentMorphElementChildNodes.push(curSubMorphElement),newMorphElementChildNodes.push(newSubMorphElement))}),currentMorphElementChildNodes.forEach(el=>{el.parentElement&&morphedElements.push(el.parentElement)})):(newMorphElementChildNodes.push(...newMorphElement.childNodes),currentMorphElementChildNodes.push(...morphElement.childNodes),morphedElements.push(morphElement));const transfer=[];submorphAppend||currentMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&(this.destroyOldLinks(element),element.classList.add("old"),element.querySelectorAll("[data-morph-transfer]").forEach(el=>{const selector=el.getAttribute("data-morph-transfer");transfer.push({element:el,selector})}))}),newMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&(transfer.forEach(item=>{const nestlement=element.querySelector(item.selector);nestlement&&nestlement.replaceWith(nextRoute.document.importNode(item.element,!0))}),this.findNewLinks(element),element.classList.add("new"))}),submorph?submorphAppend?newMorphElementChildNodes.forEach((el,i2)=>{currentMorphElementChildNodes[i2]instanceof HTMLElement&&currentMorphElementChildNodes[i2].append(...el.childNodes)}):newMorphElementChildNodes.forEach((el,i2)=>{var _a2;(_a2=currentMorphElementChildNodes[i2].parentElement)==null||_a2.insertBefore(el,currentMorphElementChildNodes[i2])}):morphElement.prepend(...newMorphElementChildNodes),setTimeout(()=>{submorphAppend||currentMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&element.classList.add("old-idle")}),newMorphElementChildNodes.forEach(element=>{var _a2;element instanceof HTMLElement&&((_a2=element.parentElement)==null||_a2.style.setProperty("--new-content-height",element.offsetHeight+"px"),element.classList.add("new-idle"))})},0);const detail2=__spreadProps(__spreadValues({},documentFetchedEntry),{morphElement});events.dispatchEvent(document,"morphNewChildrenAdded",{detail:detail2});const promise=new Promise(res=>{setTimeout(()=>{submorphAppend||currentMorphElementChildNodes.forEach(el=>{el.remove()}),newMorphElementChildNodes.forEach(element=>{var _a2;element instanceof HTMLElement&&((_a2=element.parentElement)==null||_a2.style.removeProperty("--new-content-height"),element.classList.remove("new-idle","new"))}),submorphAppend||events.dispatchEvent(document,"morphOldChildrenRemoved",{detail:detail2}),res()},(parseFloat(duration)||0)*1e3+10)});__privateGet(this,_promises).push(promise)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-nextRoute.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),events.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:nextRoute.scrollState}),scrollTo?(nextRoute.clearScrollState(),__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,scrollTo,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:scrollBehaviour})):normalizedURL.hash?(nextRoute.clearScrollState(),__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,normalizedURL.hash,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:scrollBehaviour})):__privateGet(this,_isPopstateNavigation)?nextRoute.restoreScrollPosition():keepScrollPosition||nextRoute.renewScrollPosition(),yield Promise.all(__privateGet(this,_promises)),submorphAppend||oldElementsWithLoadEvent.forEach(child=>child.remove()),__privateSet(this,_promises,[]),morphedElements.forEach(el=>{el.querySelectorAll("script").forEach(element=>{element.replaceWith(dom.createScriptElement(element))})}),__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)}),this.findParamsDependent(),events.dispatchEvent(document,"morphComplete",{detail:documentFetchedEntry}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(e){console.error(e)}__privateSet(this,_candidateURL,void 0)})}addLink(element){__privateGet(this,_links).push(new MorphLink(element,this))}addLinks(elements){elements.forEach(element=>{this.addLink(element)})}removeLink(element){__privateSet(this,_links,__privateGet(this,_links).filter(link=>link.element===element?(link.destroy(),!1):!0))}destroyOldLinks(morphElement){__privateSet(this,_links,__privateGet(this,_links).filter(link=>morphElement.contains(link.element)?(link.destroy(),!1):!0))}findNewLinks(morphElement){const linkElements=[...morphElement.querySelectorAll("a")].filter(__privateGet(this,_checkLink));__privateGet(this,_links).push(...linkElements.map(element=>new MorphLink(element,this)))}findLinks(){const linkElements=[...document.documentElement.querySelectorAll("a")].filter(__privateGet(this,_checkLink));__privateGet(this,_links).forEach(link=>link.destroy()),__privateSet(this,_links,linkElements.map(element=>new MorphLink(element,this)))}findParamsDependent(){const elements=[...document.documentElement.querySelectorAll("[data-morph-params-dependent]")];__privateGet(this,_paramDependent).forEach(link=>link.destroy()),__privateSet(this,_paramDependent,elements.map(element=>new MorphParamsDependent(element)))}};_options=new WeakMap,_morphElements=new WeakMap,_links=new WeakMap,_candidateURL=new WeakMap,_currentURL=new WeakMap,_previousURL=new WeakMap,_promises=new WeakMap,_isPopstateNavigation=new WeakMap,_currentScrollElement=new WeakMap,_isWindowScroll=new WeakMap,_routes=new WeakMap,_paramDependent=new WeakMap,_announcer=new WeakMap,_currentScrollX=new WeakMap,_currentScrollY=new WeakMap,_lastSubmorph=new WeakMap,_lastRevalidate=new WeakMap,_lastKeepScrollPosition=new WeakMap,_checkLink=new WeakMap,_Morph_instances=new WeakSet,getRoute_fn=__name(function(path){const normalizedURL=this.normalizePath(path);let route=__privateGet(this,_routes).get(normalizedURL.pathname);return route||(route=new MorphRoute(this,normalizedURL.pathname),__privateGet(this,_routes).set(normalizedURL.pathname,route)),route},"#getRoute"),getMorphElements_fn=__name(function(el){const morphElements=[...el.querySelectorAll("[data-morph]")];return morphElements.length?morphElements:[el]},"#getMorphElements"),isElementEmitsLoadEvent_fn=__name(function(element){return element.tagName==="SCRIPT"||element.tagName==="STYLE"||element.tagName==="LINK"&&element.getAttribute("rel")==="stylesheet"},"#isElementEmitsLoadEvent"),updateCurrentScrollElement_fn=__name(function(document2){var _a,_b;(_a=__privateGet(this,_currentScrollElement))==null||_a.removeEventListener("scroll",__privateGet(this,_scrollListener)),__privateSet(this,_currentScrollY,0),__privateSet(this,_currentScrollX,0),__privateSet(this,_currentScrollElement,__privateGet(this,_options).scrollSelector&&document2.querySelector(__privateGet(this,_options).scrollSelector)||window),__privateSet(this,_isWindowScroll,__privateGet(this,_currentScrollElement)===window),(_b=__privateGet(this,_currentScrollElement))==null||_b.addEventListener("scroll",__privateGet(this,_scrollListener)),__privateGet(this,_scrollListener).call(this)},"#updateCurrentScrollElement"),tryScrollToElement_fn=__name(function(id,options){const value=typeof id=="string"?document.querySelector(id):id;(typeof value=="number"||value)&&scroll.scrollToElement(value,__spreadValues({scrollElement:__privateGet(this,_currentScrollElement)},options))},"#tryScrollToElement"),_popStateListener=new WeakMap,_scrollListener=new WeakMap,__name(_Morph,"Morph"),_Morph.instance=null;let Morph=_Morph;exports.Morph=Morph;
@@ -41,7 +41,7 @@ import "construct-style-sheets-polyfill";
41
41
  import "../index-DAG0CtYo.js";
42
42
  import { a as normalizeBase, c as splitPath } from "../url-B9T9gMkY.js";
43
43
  import { cssValueParser } from "../css-value-parser/index.js";
44
- import { h as historyManager } from "../historyManager--LUUUbW7.js";
44
+ import { h as historyManager } from "../historyManager-DyjFBozJ.js";
45
45
  const _MorphAnnouncer = class _MorphAnnouncer extends HTMLElement {
46
46
  connectedCallback() {
47
47
  const attrs = {
@@ -1 +1 @@
1
- "use strict";var __defProp=Object.defineProperty;var __typeError=msg=>{throw TypeError(msg)};var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const cssProperty_index=require("../css-property/index.cjs"),Viewport=require("../Viewport-Blxv_yl_.cjs"),elementLinkedStore_index=require("../element-linked-store/index.cjs"),historyManager=require("../historyManager-DB2fSEtH.cjs"),Store=require("../Store-B96mD8mD.cjs"),events=require("../events-UlGk63iC.cjs"),_function=require("../function-H4b_gTg6.cjs");require("../index-BoGx2BWX.cjs");const style=require("../style-IDJ6db6n.cjs");require("construct-style-sheets-polyfill");const url=require("../url-CbDPURsX.cjs"),windowResizer_index=require("../window-resizer/index.cjs");var _groups,_stack,_clickOutsideListener,_keydownListener;const _PopoverGroups=class _PopoverGroups{constructor(){__privateAdd(this,_groups,new Map);__privateAdd(this,_stack,[]);__privateAdd(this,_clickOutsideListener,__name(e=>{var _a;const lastPopover=[...__privateGet(this,_stack)].reverse().find(el=>el.clickOutside.current);if(lastPopover){const path=e.composedPath();if(path.find(el=>el instanceof HTMLElement&&el.hasAttribute("data-popover-content")))return;const target=path[0],containsTarget=target instanceof Node&&(lastPopover.contains(target)||((_a=lastPopover.shadowRoot)==null?void 0:_a.contains(target))),outsideTarget=target instanceof HTMLElement&&target.hasAttribute("data-outside");(!containsTarget||outsideTarget)&&lastPopover.close(!0)}},"#clickOutsideListener"));__privateAdd(this,_keydownListener,__name(e=>{if(e.code==="Escape"){const lastPopover=[...__privateGet(this,_stack)].reverse().find(el=>el.escape.current);lastPopover&&lastPopover.close(!0)}},"#keydownListener"));document.documentElement.addEventListener("click",__privateGet(this,_clickOutsideListener)),addEventListener("keydown",__privateGet(this,_keydownListener))}get groups(){return __privateGet(this,_groups)}get stack(){return __privateGet(this,_stack)}add(groupName,element){if(element.closeRest.current)__privateGet(this,_groups).forEach(g=>{g.forEach(e=>{e.close()})});else if(element.closeRestInGroup.current){let group2=__privateGet(this,_groups).get(groupName);group2==null||group2.forEach(e=>{e.close()})}let group=__privateGet(this,_groups).get(groupName);group!=null&&group.length||(group=[],__privateGet(this,_groups).set(groupName,group)),__privateGet(this,_stack).push(element),group.push(element)}remove(groupName,element){if(setTimeout(()=>{__privateSet(this,_stack,__privateGet(this,_stack).filter(e=>e!==element))}),element.closeRest.current){let elements=[];__privateGet(this,_groups).forEach(group=>{group.forEach(element2=>elements.push(element2))}),__privateGet(this,_groups).clear(),elements.forEach(element2=>element2.close())}else if(element.closeRestInGroup.current){const group=__privateGet(this,_groups).get(groupName);__privateGet(this,_groups).delete(groupName),group==null||group.forEach(element2=>{element2.close()})}else{let group=__privateGet(this,_groups).get(groupName);group&&(group=group.filter(el=>el!==element),__privateGet(this,_groups).set(groupName,group))}}};_groups=new WeakMap,_stack=new WeakMap,_clickOutsideListener=new WeakMap,_keydownListener=new WeakMap,__name(_PopoverGroups,"PopoverGroups");let PopoverGroups=_PopoverGroups;var _opened,_startClosingTimeoutId,_closeTimeoutId,_openFrameId,_openTransitionTimeoutId,_history,_restore,_dispatchResize,_closeRest,_closeRestInGroup,_group,_clickOutside,_escape,_checkViewportBounds,_lastTrigger,_status,_innerCloseElements,_resetScrollElements,_isFromPopState,_PopoverElement_instances,path_get,toggleGlobalClass_fn,deleteSearchParam_fn,_popStateListener,_resizeListener,_debouncedResize,_resize,_closeElementClickListener;const _PopoverElement=class _PopoverElement extends HTMLElement{constructor(){super();__privateAdd(this,_PopoverElement_instances);__privateAdd(this,_opened);__privateAdd(this,_startClosingTimeoutId);__privateAdd(this,_closeTimeoutId);__privateAdd(this,_openFrameId);__privateAdd(this,_openTransitionTimeoutId);__privateAdd(this,_history);__privateAdd(this,_restore);__privateAdd(this,_dispatchResize);__privateAdd(this,_closeRest);__privateAdd(this,_closeRestInGroup);__privateAdd(this,_group);__privateAdd(this,_clickOutside);__privateAdd(this,_escape);__privateAdd(this,_checkViewportBounds);__privateAdd(this,_lastTrigger);__privateAdd(this,_status);__privateAdd(this,_innerCloseElements);__privateAdd(this,_resetScrollElements);__privateAdd(this,_isFromPopState);__privateAdd(this,_popStateListener);__privateAdd(this,_resizeListener);__privateAdd(this,_debouncedResize);__privateAdd(this,_resize);__privateAdd(this,_closeElementClickListener);this.urlValue="",__privateSet(this,_opened,!1),__privateSet(this,_history,new cssProperty_index.CSSProperty(this,"--history",!1)),__privateSet(this,_restore,new cssProperty_index.CSSProperty(this,"--restore",!1)),__privateSet(this,_dispatchResize,new cssProperty_index.CSSProperty(this,"--dispatch-resize",!1)),__privateSet(this,_closeRest,new cssProperty_index.CSSProperty(this,"--close-rest",!1)),__privateSet(this,_closeRestInGroup,new cssProperty_index.CSSProperty(this,"--close-rest-in-group",!1)),__privateSet(this,_group,new cssProperty_index.CSSProperty(this,"--group","")),__privateSet(this,_clickOutside,new cssProperty_index.CSSProperty(this,"--click-outside",!1)),__privateSet(this,_escape,new cssProperty_index.CSSProperty(this,"--escape",!1)),__privateSet(this,_checkViewportBounds,new cssProperty_index.CSSProperty(this,"--check-viewport-bounds",!1)),__privateSet(this,_status,new elementLinkedStore_index.ElementLinkedStore(this,{triggered:!1,beforeopen:!1,opened:!1,closing:!1,transitionend:!1})),__privateSet(this,_innerCloseElements,[]),__privateSet(this,_resetScrollElements,[]),__privateSet(this,_isFromPopState,!1),__privateSet(this,_popStateListener,()=>{_PopoverElement.popoverHistoryTransactionsDepth>0||(__privateSet(this,_isFromPopState,!0),__privateGet(this,_opened)&&__privateGet(this,_history).current&&!location.search.includes(this.id)?this.close():!__privateGet(this,_opened)&&__privateGet(this,_history).current&&location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),setTimeout(()=>{__privateSet(this,_isFromPopState,!1)},0))}),__privateSet(this,_resizeListener,()=>{this.style.setProperty("--content-width","initial"),this.style.setProperty("--content-height","initial"),this.style.setProperty("--viewport-offset-x","0px"),this.style.setProperty("--viewport-offset-y","0px"),__privateGet(this,_debouncedResize).call(this)}),__privateSet(this,_debouncedResize,_function.debounce(()=>{__privateGet(this,_resize).call(this)},10)),__privateSet(this,_resize,()=>{if(this.style.setProperty("--content-width",this.scrollWidth+"px"),this.style.setProperty("--content-height",this.scrollHeight+"px"),__privateGet(this,_checkViewportBounds).current){const rect=this.getBoundingClientRect();let viewportOffsetX=0,viewportOffsetY=0;rect.right>Viewport.viewport.width?viewportOffsetX=Viewport.viewport.width-rect.right:rect.left<0&&(viewportOffsetX=rect.left*-1),rect.bottom>Viewport.viewport.height?viewportOffsetY=Viewport.viewport.height-rect.bottom:rect.top<0&&(viewportOffsetY=rect.top*-1),this.style.setProperty("--viewport-offset-x",viewportOffsetX+"px"),this.style.setProperty("--viewport-offset-y",viewportOffsetY+"px")}}),__privateSet(this,_closeElementClickListener,()=>{this.close(!0)}),__privateGet(this,_group).subscribe(e=>{e.previous&&(_PopoverElement.stack.remove(e.previous,this),e.current||(document.documentElement.classList.remove(`${this.group.previous}-closing`),document.documentElement.classList.remove(`${this.group.previous}-opened`)))}),__privateGet(this,_status).subscribe(e=>{if(this.group.current){document.documentElement.classList.toggle(`${this.group.current}-closing`,e.current.closing);const group=_PopoverElement.stack.groups.get(this.group.current),element=group==null?void 0:group.find(e2=>e2.opened);document.documentElement.classList.toggle(`${this.group.current}-opened`,!!element)}})}get openClass(){return this.getAttribute("data-open-global-class")}get closingClass(){return this.getAttribute("data-closing-global-class")}get history(){return __privateGet(this,_history)}get restore(){return __privateGet(this,_restore)}get dispatchResize(){return __privateGet(this,_dispatchResize)}get closeRest(){return __privateGet(this,_closeRest)}get closeRestInGroup(){return __privateGet(this,_closeRestInGroup)}get group(){return __privateGet(this,_group)}get clickOutside(){return __privateGet(this,_clickOutside)}get escape(){return __privateGet(this,_escape)}get opened(){return __privateGet(this,_opened)}get lastTrigger(){return __privateGet(this,_lastTrigger)}get idWithValue(){return`${this.id}${this.urlValue?"="+this.urlValue:""}`}updateUrlValue(value){this.urlValue=(value==null?void 0:value.toString())||"",__privateGet(this,_opened)&&url.updateSearchParameter(this.id,value)}open(options){if(__privateGet(this,_opened))return;__privateSet(this,_lastTrigger,options==null?void 0:options.trigger),clearTimeout(__privateGet(this,_startClosingTimeoutId)),clearTimeout(__privateGet(this,_closeTimeoutId)),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.closingClass),__privateGet(this,_status).set("closing",!1),__privateGet(this,_status).set("triggered",!0),events.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:__privateGet(this,_lastTrigger)}}),__privateGet(this,_history).current&&(this.beginHistoryTransaction(),__privateGet(this,_isFromPopState)||historyManager.historyManager.pushState(__privateGet(this,_PopoverElement_instances,path_get),{popover:!0}),this.endHistoryTransaction()),__privateGet(this,_status).set("beforeopen",!0),__privateSet(this,_opened,!0);const opened=__name(()=>{_PopoverElement.stack.add(__privateGet(this,_group).current,this),__privateGet(this,_resetScrollElements).forEach(el=>{el.scroll({top:0,left:0,behavior:"instant"})}),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!0,this.openClass),__privateGet(this,_status).set("opened",!0),__privateGet(this,_dispatchResize).current?events.dispatchEvent(window,"resize",{custom:!0}):__privateGet(this,_resizeListener).call(this),events.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:__privateGet(this,_lastTrigger)},bubbles:!0}),__privateSet(this,_openFrameId,void 0),__privateSet(this,_openTransitionTimeoutId,setTimeout(()=>{__privateGet(this,_status).set("transitionend",!0),events.dispatchEvent(this,"popoverTransitionend")},style.getElementTransitionDurationMS(this)+10))},"opened");options!=null&&options.skipTransition?opened():__privateSet(this,_openFrameId,requestAnimationFrame(opened))}close(back){__privateGet(this,_opened)&&(__privateSet(this,_opened,!1),cancelAnimationFrame(__privateGet(this,_openFrameId)),clearTimeout(__privateGet(this,_openTransitionTimeoutId)),_PopoverElement.stack.remove(__privateGet(this,_group).current,this),__privateGet(this,_history).current&&(this.beginHistoryTransaction(),back?historyManager.historyManager.back():__privateMethod(this,_PopoverElement_instances,deleteSearchParam_fn).call(this),this.endHistoryTransaction()),__privateSet(this,_startClosingTimeoutId,setTimeout(()=>{__privateGet(this,_status).set("transitionend",!1),__privateGet(this,_status).set("opened",!1),__privateGet(this,_status).set("closing",!0),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.openClass),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!0,this.closingClass),events.dispatchEvent(this,"popoverClosing",{custom:!0,bubbles:!0}),__privateSet(this,_closeTimeoutId,setTimeout(()=>{__privateGet(this,_status).set("triggered",!1),__privateGet(this,_status).set("beforeopen",!1),__privateGet(this,_status).set("closing",!1),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.closingClass),events.dispatchEvent(this,"popoverClosed",{custom:!0,bubbles:!0})},style.getElementTransitionDurationMS(this)+10))},10)))}beginHistoryTransaction(){_PopoverElement.popoverHistoryTransactionsDepth++}endHistoryTransaction(){setTimeout(()=>{_PopoverElement.popoverHistoryTransactionsDepth--},0)}connectedCallback(){__privateSet(this,_innerCloseElements,[...this.querySelectorAll(`[data-popover-close${this.id?`="${this.id}"`:""}]`)]),__privateGet(this,_innerCloseElements).forEach(el=>{el.addEventListener("click",__privateGet(this,_closeElementClickListener))}),__privateSet(this,_resetScrollElements,[...this.querySelectorAll(`[data-popover-reset-scroll${this.id?`="${this.id}"`:""}]`)]),__privateGet(this,_history).observe(),__privateGet(this,_restore).observe(),__privateGet(this,_dispatchResize).observe(),__privateGet(this,_closeRest).observe(),__privateGet(this,_closeRestInGroup).observe(),__privateGet(this,_group).observe(),__privateGet(this,_clickOutside).observe(),__privateGet(this,_escape).observe(),__privateGet(this,_checkViewportBounds).observe(),this.setAttribute("role","dialog"),historyManager.historyManager.addPopStateHandler(__privateGet(this,_popStateListener),!0),setTimeout(()=>{__privateSet(this,_isFromPopState,!0),__privateGet(this,_restore).current?(this.urlValue=url.parseSearchParameters(location.search)[this.id],location.search.includes(this.id)&&this.open({trigger:this.idWithValue})):__privateMethod(this,_PopoverElement_instances,deleteSearchParam_fn).call(this),setTimeout(()=>{__privateSet(this,_isFromPopState,!1)},0)},0),__privateGet(this,_checkViewportBounds).subscribe(()=>{__privateGet(this,_resizeListener).call(this)}),windowResizer_index.windowResizer.subscribe(__privateGet(this,_resizeListener))}disconnectedCallback(){__privateGet(this,_innerCloseElements).forEach(el=>{el.removeEventListener("click",__privateGet(this,_closeElementClickListener))}),_PopoverElement.stack.remove(__privateGet(this,_group).current,this),windowResizer_index.windowResizer.unsubscribe(__privateGet(this,_resizeListener)),__privateGet(this,_history).close(),__privateGet(this,_restore).close(),__privateGet(this,_dispatchResize).close(),__privateGet(this,_closeRest).close(),__privateGet(this,_closeRestInGroup).close(),__privateGet(this,_group).close(),__privateGet(this,_clickOutside).close(),__privateGet(this,_escape).close(),__privateGet(this,_checkViewportBounds).close(),this.removeAttribute("role"),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.openClass),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.closingClass),clearTimeout(__privateGet(this,_startClosingTimeoutId)),clearTimeout(__privateGet(this,_closeTimeoutId)),clearTimeout(__privateGet(this,_openFrameId)),clearTimeout(__privateGet(this,_openTransitionTimeoutId)),historyManager.historyManager.removePopStateHandler(__privateGet(this,_popStateListener)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),this.style.removeProperty("--viewport-offset-x"),this.style.removeProperty("--viewport-offset-y"),__privateMethod(this,_PopoverElement_instances,deleteSearchParam_fn).call(this)}};_opened=new WeakMap,_startClosingTimeoutId=new WeakMap,_closeTimeoutId=new WeakMap,_openFrameId=new WeakMap,_openTransitionTimeoutId=new WeakMap,_history=new WeakMap,_restore=new WeakMap,_dispatchResize=new WeakMap,_closeRest=new WeakMap,_closeRestInGroup=new WeakMap,_group=new WeakMap,_clickOutside=new WeakMap,_escape=new WeakMap,_checkViewportBounds=new WeakMap,_lastTrigger=new WeakMap,_status=new WeakMap,_innerCloseElements=new WeakMap,_resetScrollElements=new WeakMap,_isFromPopState=new WeakMap,_PopoverElement_instances=new WeakSet,path_get=__name(function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},"#path"),toggleGlobalClass_fn=__name(function(on,className){className&&className.split(" ").map(v=>{document.documentElement.classList.toggle(v.trim(),on)})},"#toggleGlobalClass"),deleteSearchParam_fn=__name(function(){if(__privateGet(this,_history).current){const url2=new URL(location.href);url2.searchParams.delete(this.id),historyManager.historyManager.replaceState(url2.href)}},"#deleteSearchParam"),_popStateListener=new WeakMap,_resizeListener=new WeakMap,_debouncedResize=new WeakMap,_resize=new WeakMap,_closeElementClickListener=new WeakMap,__name(_PopoverElement,"PopoverElement"),_PopoverElement.stack=new PopoverGroups,_PopoverElement.popoverHistoryTransactionsDepth=0;let PopoverElement=_PopoverElement;Store.isBrowser&&!customElements.get("e-popover")&&customElements.define("e-popover",PopoverElement);var _popoverElement,_type,_PopoverButtonElement_instances,unlistenPopover_fn,_popoverTriggeredListener,_popoverOpenedListener,_popoverClosingListener,_popoverClosedListener,updateType_fn;const _PopoverButtonElement=class _PopoverButtonElement extends HTMLElement{constructor(){super();__privateAdd(this,_PopoverButtonElement_instances);__privateAdd(this,_popoverElement);__privateAdd(this,_type,new cssProperty_index.CSSProperty(this,"--type","open"));__privateAdd(this,_popoverTriggeredListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&this.classList.add("triggered")},"#popoverTriggeredListener"));__privateAdd(this,_popoverOpenedListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))},"#popoverOpenedListener"));__privateAdd(this,_popoverClosingListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&this.classList.remove("opened")},"#popoverClosingListener"));__privateAdd(this,_popoverClosedListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&(this.classList.remove("triggered"),this.setAttribute("aria-expanded","false"))},"#popoverClosedListener"));Store.isBrowser&&(this.addEventListener("click",()=>{if(__privateGet(this,_popoverElement)){const type=__privateGet(this,_type).current;type==="open"||type==="toggle"&&!__privateGet(this,_popoverElement).opened?__privateGet(this,_popoverElement).open({trigger:this}):(type==="close"||type==="toggle"&&__privateGet(this,_popoverElement).opened)&&__privateGet(this,_popoverElement).close(!0)}}),this.addEventListener("keydown",e=>{e.code==="Space"&&!this.hasAttribute("keydown-disabled")&&(e.preventDefault(),this.click())}))}get type(){return __privateGet(this,_type)}get popoverElement(){return __privateGet(this,_popoverElement)}changePopover(targetId){var _a;if(__privateMethod(this,_PopoverButtonElement_instances,unlistenPopover_fn).call(this),targetId){let popoverElement=null;if(targetId==="parent"){const closestTarget=this.closest("[data-popover]");if(closestTarget)popoverElement=closestTarget;else{const rootNode=this.getRootNode();rootNode instanceof ShadowRoot?popoverElement=rootNode.host.closest("[data-popover]"):rootNode instanceof HTMLElement&&(popoverElement=rootNode.closest("[data-popover]"))}}else if(targetId==="sibling")popoverElement=(_a=this.parentElement)==null?void 0:_a.querySelector("[data-popover]");else if(targetId==="ancestor-child"){const find=__name(el=>{if(!el)return null;let founded=el.querySelector("[data-popover]");return!founded&&(el!=null&&el.parentElement)&&(founded=find(el.parentElement)),founded},"find");popoverElement=find(this.parentElement)||null}else{let selector=targetId;if(isNaN(parseInt(selector))&&(!targetId.startsWith(".")&&!targetId.startsWith("[")&&!targetId.startsWith("#")&&(selector=`#${targetId}`),popoverElement=document.querySelector(selector)||this.getRootNode().querySelector(selector)),!popoverElement){const founded=[...document.querySelectorAll("[data-popover-ids]")].find(el=>{var _a2;return(_a2=el.getAttribute("data-popover-ids"))==null?void 0:_a2.split(",").find(v=>v.trim()===targetId)});founded&&(popoverElement=founded)}}popoverElement instanceof HTMLElement?(__privateSet(this,_popoverElement,popoverElement),__privateGet(this,_popoverElement).addEventListener("popoverTriggered",__privateGet(this,_popoverTriggeredListener)),__privateGet(this,_popoverElement).addEventListener("popoverOpened",__privateGet(this,_popoverOpenedListener)),__privateGet(this,_popoverElement).addEventListener("popoverClosing",__privateGet(this,_popoverClosingListener)),__privateGet(this,_popoverElement).addEventListener("popoverClosed",__privateGet(this,_popoverClosedListener))):console.warn(this,`target ${targetId} not found`)}__privateMethod(this,_PopoverButtonElement_instances,updateType_fn).call(this,__privateGet(this,_type).current)}connectedCallback(){__privateGet(this,_type).subscribe(e=>{__privateMethod(this,_PopoverButtonElement_instances,updateType_fn).call(this,e.current)}),this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("role")||this.setAttribute("role","button");const targetId=this.getAttribute("target");targetId&&this.changePopover(targetId),this.isConnected&&__privateGet(this,_type).observe()}disconnectedCallback(){__privateGet(this,_type).unobserve(),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls"),this.removeAttribute("role"),this.removeAttribute("tabindex"),__privateMethod(this,_PopoverButtonElement_instances,unlistenPopover_fn).call(this)}};_popoverElement=new WeakMap,_type=new WeakMap,_PopoverButtonElement_instances=new WeakSet,unlistenPopover_fn=__name(function(){__privateGet(this,_popoverElement)&&(__privateGet(this,_popoverElement).removeEventListener("popoverTriggered",__privateGet(this,_popoverTriggeredListener)),__privateGet(this,_popoverElement).removeEventListener("popoverOpened",__privateGet(this,_popoverOpenedListener)),__privateGet(this,_popoverElement).removeEventListener("popoverClosing",__privateGet(this,_popoverClosingListener)),__privateGet(this,_popoverElement).removeEventListener("popoverClosed",__privateGet(this,_popoverClosedListener)))},"#unlistenPopover"),_popoverTriggeredListener=new WeakMap,_popoverOpenedListener=new WeakMap,_popoverClosingListener=new WeakMap,_popoverClosedListener=new WeakMap,updateType_fn=__name(function(value){__privateGet(this,_popoverElement)instanceof PopoverElement&&(value!=="close"?(this.setAttribute("aria-haspopup","true"),this.setAttribute("aria-expanded",__privateGet(this,_popoverElement).opened?"true":"false"),this.setAttribute("aria-controls",__privateGet(this,_popoverElement).id||"")):(this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls")))},"#updateType"),__name(_PopoverButtonElement,"PopoverButtonElement");let PopoverButtonElement=_PopoverButtonElement;Store.isBrowser&&!customElements.get("e-popover-button")&&customElements.define("e-popover-button",PopoverButtonElement);exports.PopoverButtonElement=PopoverButtonElement;exports.PopoverElement=PopoverElement;
1
+ "use strict";var __defProp=Object.defineProperty;var __typeError=msg=>{throw TypeError(msg)};var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const cssProperty_index=require("../css-property/index.cjs"),Viewport=require("../Viewport-Blxv_yl_.cjs"),elementLinkedStore_index=require("../element-linked-store/index.cjs"),historyManager=require("../historyManager-Car6P2ak.cjs"),Store=require("../Store-B96mD8mD.cjs"),events=require("../events-UlGk63iC.cjs"),_function=require("../function-H4b_gTg6.cjs");require("../index-BoGx2BWX.cjs");const style=require("../style-IDJ6db6n.cjs");require("construct-style-sheets-polyfill");const url=require("../url-CbDPURsX.cjs"),windowResizer_index=require("../window-resizer/index.cjs");var _groups,_stack,_clickOutsideListener,_keydownListener;const _PopoverGroups=class _PopoverGroups{constructor(){__privateAdd(this,_groups,new Map);__privateAdd(this,_stack,[]);__privateAdd(this,_clickOutsideListener,__name(e=>{var _a;const lastPopover=[...__privateGet(this,_stack)].reverse().find(el=>el.clickOutside.current);if(lastPopover){const path=e.composedPath();if(path.find(el=>el instanceof HTMLElement&&el.hasAttribute("data-popover-content")))return;const target=path[0],containsTarget=target instanceof Node&&(lastPopover.contains(target)||((_a=lastPopover.shadowRoot)==null?void 0:_a.contains(target))),outsideTarget=target instanceof HTMLElement&&target.hasAttribute("data-outside");(!containsTarget||outsideTarget)&&lastPopover.close(!0)}},"#clickOutsideListener"));__privateAdd(this,_keydownListener,__name(e=>{if(e.code==="Escape"){const lastPopover=[...__privateGet(this,_stack)].reverse().find(el=>el.escape.current);lastPopover&&lastPopover.close(!0)}},"#keydownListener"));document.documentElement.addEventListener("click",__privateGet(this,_clickOutsideListener)),addEventListener("keydown",__privateGet(this,_keydownListener))}get groups(){return __privateGet(this,_groups)}get stack(){return __privateGet(this,_stack)}add(groupName,element){if(element.closeRest.current)__privateGet(this,_groups).forEach(g=>{g.forEach(e=>{e.close()})});else if(element.closeRestInGroup.current){let group2=__privateGet(this,_groups).get(groupName);group2==null||group2.forEach(e=>{e.close()})}let group=__privateGet(this,_groups).get(groupName);group!=null&&group.length||(group=[],__privateGet(this,_groups).set(groupName,group)),__privateGet(this,_stack).push(element),group.push(element)}remove(groupName,element){if(setTimeout(()=>{__privateSet(this,_stack,__privateGet(this,_stack).filter(e=>e!==element))}),element.closeRest.current){let elements=[];__privateGet(this,_groups).forEach(group=>{group.forEach(element2=>elements.push(element2))}),__privateGet(this,_groups).clear(),elements.forEach(element2=>element2.close())}else if(element.closeRestInGroup.current){const group=__privateGet(this,_groups).get(groupName);__privateGet(this,_groups).delete(groupName),group==null||group.forEach(element2=>{element2.close()})}else{let group=__privateGet(this,_groups).get(groupName);group&&(group=group.filter(el=>el!==element),__privateGet(this,_groups).set(groupName,group))}}};_groups=new WeakMap,_stack=new WeakMap,_clickOutsideListener=new WeakMap,_keydownListener=new WeakMap,__name(_PopoverGroups,"PopoverGroups");let PopoverGroups=_PopoverGroups;var _opened,_startClosingTimeoutId,_closeTimeoutId,_openFrameId,_openTransitionTimeoutId,_history,_restore,_dispatchResize,_closeRest,_closeRestInGroup,_group,_clickOutside,_escape,_checkViewportBounds,_lastTrigger,_status,_innerCloseElements,_resetScrollElements,_isFromPopState,_PopoverElement_instances,path_get,toggleGlobalClass_fn,deleteSearchParam_fn,_popStateListener,_resizeListener,_debouncedResize,_resize,_closeElementClickListener;const _PopoverElement=class _PopoverElement extends HTMLElement{constructor(){super();__privateAdd(this,_PopoverElement_instances);__privateAdd(this,_opened);__privateAdd(this,_startClosingTimeoutId);__privateAdd(this,_closeTimeoutId);__privateAdd(this,_openFrameId);__privateAdd(this,_openTransitionTimeoutId);__privateAdd(this,_history);__privateAdd(this,_restore);__privateAdd(this,_dispatchResize);__privateAdd(this,_closeRest);__privateAdd(this,_closeRestInGroup);__privateAdd(this,_group);__privateAdd(this,_clickOutside);__privateAdd(this,_escape);__privateAdd(this,_checkViewportBounds);__privateAdd(this,_lastTrigger);__privateAdd(this,_status);__privateAdd(this,_innerCloseElements);__privateAdd(this,_resetScrollElements);__privateAdd(this,_isFromPopState);__privateAdd(this,_popStateListener);__privateAdd(this,_resizeListener);__privateAdd(this,_debouncedResize);__privateAdd(this,_resize);__privateAdd(this,_closeElementClickListener);this.urlValue="",__privateSet(this,_opened,!1),__privateSet(this,_history,new cssProperty_index.CSSProperty(this,"--history",!1)),__privateSet(this,_restore,new cssProperty_index.CSSProperty(this,"--restore",!1)),__privateSet(this,_dispatchResize,new cssProperty_index.CSSProperty(this,"--dispatch-resize",!1)),__privateSet(this,_closeRest,new cssProperty_index.CSSProperty(this,"--close-rest",!1)),__privateSet(this,_closeRestInGroup,new cssProperty_index.CSSProperty(this,"--close-rest-in-group",!1)),__privateSet(this,_group,new cssProperty_index.CSSProperty(this,"--group","")),__privateSet(this,_clickOutside,new cssProperty_index.CSSProperty(this,"--click-outside",!1)),__privateSet(this,_escape,new cssProperty_index.CSSProperty(this,"--escape",!1)),__privateSet(this,_checkViewportBounds,new cssProperty_index.CSSProperty(this,"--check-viewport-bounds",!1)),__privateSet(this,_status,new elementLinkedStore_index.ElementLinkedStore(this,{triggered:!1,beforeopen:!1,opened:!1,closing:!1,transitionend:!1})),__privateSet(this,_innerCloseElements,[]),__privateSet(this,_resetScrollElements,[]),__privateSet(this,_isFromPopState,!1),__privateSet(this,_popStateListener,()=>{_PopoverElement.popoverHistoryTransactionsDepth>0||(__privateSet(this,_isFromPopState,!0),__privateGet(this,_opened)&&__privateGet(this,_history).current&&!location.search.includes(this.id)?this.close():!__privateGet(this,_opened)&&__privateGet(this,_history).current&&location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),setTimeout(()=>{__privateSet(this,_isFromPopState,!1)},0))}),__privateSet(this,_resizeListener,()=>{this.style.setProperty("--content-width","initial"),this.style.setProperty("--content-height","initial"),this.style.setProperty("--viewport-offset-x","0px"),this.style.setProperty("--viewport-offset-y","0px"),__privateGet(this,_debouncedResize).call(this)}),__privateSet(this,_debouncedResize,_function.debounce(()=>{__privateGet(this,_resize).call(this)},10)),__privateSet(this,_resize,()=>{if(this.style.setProperty("--content-width",this.scrollWidth+"px"),this.style.setProperty("--content-height",this.scrollHeight+"px"),__privateGet(this,_checkViewportBounds).current){const rect=this.getBoundingClientRect();let viewportOffsetX=0,viewportOffsetY=0;rect.right>Viewport.viewport.width?viewportOffsetX=Viewport.viewport.width-rect.right:rect.left<0&&(viewportOffsetX=rect.left*-1),rect.bottom>Viewport.viewport.height?viewportOffsetY=Viewport.viewport.height-rect.bottom:rect.top<0&&(viewportOffsetY=rect.top*-1),this.style.setProperty("--viewport-offset-x",viewportOffsetX+"px"),this.style.setProperty("--viewport-offset-y",viewportOffsetY+"px")}}),__privateSet(this,_closeElementClickListener,()=>{this.close(!0)}),__privateGet(this,_group).subscribe(e=>{e.previous&&(_PopoverElement.stack.remove(e.previous,this),e.current||(document.documentElement.classList.remove(`${this.group.previous}-closing`),document.documentElement.classList.remove(`${this.group.previous}-opened`)))}),__privateGet(this,_status).subscribe(e=>{if(this.group.current){document.documentElement.classList.toggle(`${this.group.current}-closing`,e.current.closing);const group=_PopoverElement.stack.groups.get(this.group.current),element=group==null?void 0:group.find(e2=>e2.opened);document.documentElement.classList.toggle(`${this.group.current}-opened`,!!element)}})}get openClass(){return this.getAttribute("data-open-global-class")}get closingClass(){return this.getAttribute("data-closing-global-class")}get history(){return __privateGet(this,_history)}get restore(){return __privateGet(this,_restore)}get dispatchResize(){return __privateGet(this,_dispatchResize)}get closeRest(){return __privateGet(this,_closeRest)}get closeRestInGroup(){return __privateGet(this,_closeRestInGroup)}get group(){return __privateGet(this,_group)}get clickOutside(){return __privateGet(this,_clickOutside)}get escape(){return __privateGet(this,_escape)}get opened(){return __privateGet(this,_opened)}get lastTrigger(){return __privateGet(this,_lastTrigger)}get idWithValue(){return`${this.id}${this.urlValue?"="+this.urlValue:""}`}updateUrlValue(value){this.urlValue=(value==null?void 0:value.toString())||"",__privateGet(this,_opened)&&url.updateSearchParameter(this.id,value)}open(options){if(__privateGet(this,_opened))return;__privateSet(this,_lastTrigger,options==null?void 0:options.trigger),clearTimeout(__privateGet(this,_startClosingTimeoutId)),clearTimeout(__privateGet(this,_closeTimeoutId)),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.closingClass),__privateGet(this,_status).set("closing",!1),__privateGet(this,_status).set("triggered",!0),events.dispatchEvent(this,"popoverTriggered",{custom:!0,detail:{trigger:__privateGet(this,_lastTrigger)}}),__privateGet(this,_history).current&&(this.beginHistoryTransaction(),__privateGet(this,_isFromPopState)||historyManager.historyManager.pushState(__privateGet(this,_PopoverElement_instances,path_get),{popover:!0}),this.endHistoryTransaction()),__privateGet(this,_status).set("beforeopen",!0),__privateSet(this,_opened,!0);const opened=__name(()=>{_PopoverElement.stack.add(__privateGet(this,_group).current,this),__privateGet(this,_resetScrollElements).forEach(el=>{el.scroll({top:0,left:0,behavior:"instant"})}),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!0,this.openClass),__privateGet(this,_status).set("opened",!0),__privateGet(this,_dispatchResize).current?events.dispatchEvent(window,"resize",{custom:!0}):__privateGet(this,_resizeListener).call(this),events.dispatchEvent(this,"popoverOpened",{custom:!0,detail:{trigger:__privateGet(this,_lastTrigger)},bubbles:!0}),__privateSet(this,_openFrameId,void 0),__privateSet(this,_openTransitionTimeoutId,setTimeout(()=>{__privateGet(this,_status).set("transitionend",!0),events.dispatchEvent(this,"popoverTransitionend")},style.getElementTransitionDurationMS(this)+10))},"opened");options!=null&&options.skipTransition?opened():__privateSet(this,_openFrameId,requestAnimationFrame(opened))}close(back){__privateGet(this,_opened)&&(__privateSet(this,_opened,!1),cancelAnimationFrame(__privateGet(this,_openFrameId)),clearTimeout(__privateGet(this,_openTransitionTimeoutId)),_PopoverElement.stack.remove(__privateGet(this,_group).current,this),__privateGet(this,_history).current&&(this.beginHistoryTransaction(),back?historyManager.historyManager.back():__privateMethod(this,_PopoverElement_instances,deleteSearchParam_fn).call(this),this.endHistoryTransaction()),__privateSet(this,_startClosingTimeoutId,setTimeout(()=>{__privateGet(this,_status).set("transitionend",!1),__privateGet(this,_status).set("opened",!1),__privateGet(this,_status).set("closing",!0),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.openClass),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!0,this.closingClass),events.dispatchEvent(this,"popoverClosing",{custom:!0,bubbles:!0}),__privateSet(this,_closeTimeoutId,setTimeout(()=>{__privateGet(this,_status).set("triggered",!1),__privateGet(this,_status).set("beforeopen",!1),__privateGet(this,_status).set("closing",!1),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.closingClass),events.dispatchEvent(this,"popoverClosed",{custom:!0,bubbles:!0})},style.getElementTransitionDurationMS(this)+10))},10)))}beginHistoryTransaction(){_PopoverElement.popoverHistoryTransactionsDepth++}endHistoryTransaction(){setTimeout(()=>{_PopoverElement.popoverHistoryTransactionsDepth--},0)}connectedCallback(){__privateSet(this,_innerCloseElements,[...this.querySelectorAll(`[data-popover-close${this.id?`="${this.id}"`:""}]`)]),__privateGet(this,_innerCloseElements).forEach(el=>{el.addEventListener("click",__privateGet(this,_closeElementClickListener))}),__privateSet(this,_resetScrollElements,[...this.querySelectorAll(`[data-popover-reset-scroll${this.id?`="${this.id}"`:""}]`)]),__privateGet(this,_history).observe(),__privateGet(this,_restore).observe(),__privateGet(this,_dispatchResize).observe(),__privateGet(this,_closeRest).observe(),__privateGet(this,_closeRestInGroup).observe(),__privateGet(this,_group).observe(),__privateGet(this,_clickOutside).observe(),__privateGet(this,_escape).observe(),__privateGet(this,_checkViewportBounds).observe(),this.setAttribute("role","dialog"),historyManager.historyManager.addPopStateHandler(__privateGet(this,_popStateListener),!0),setTimeout(()=>{__privateSet(this,_isFromPopState,!0),__privateGet(this,_restore).current?(this.urlValue=url.parseSearchParameters(location.search)[this.id],location.search.includes(this.id)&&this.open({trigger:this.idWithValue})):__privateMethod(this,_PopoverElement_instances,deleteSearchParam_fn).call(this),setTimeout(()=>{__privateSet(this,_isFromPopState,!1)},0)},0),__privateGet(this,_checkViewportBounds).subscribe(()=>{__privateGet(this,_resizeListener).call(this)}),windowResizer_index.windowResizer.subscribe(__privateGet(this,_resizeListener))}disconnectedCallback(){__privateGet(this,_innerCloseElements).forEach(el=>{el.removeEventListener("click",__privateGet(this,_closeElementClickListener))}),_PopoverElement.stack.remove(__privateGet(this,_group).current,this),windowResizer_index.windowResizer.unsubscribe(__privateGet(this,_resizeListener)),__privateGet(this,_history).close(),__privateGet(this,_restore).close(),__privateGet(this,_dispatchResize).close(),__privateGet(this,_closeRest).close(),__privateGet(this,_closeRestInGroup).close(),__privateGet(this,_group).close(),__privateGet(this,_clickOutside).close(),__privateGet(this,_escape).close(),__privateGet(this,_checkViewportBounds).close(),this.removeAttribute("role"),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.openClass),__privateMethod(this,_PopoverElement_instances,toggleGlobalClass_fn).call(this,!1,this.closingClass),clearTimeout(__privateGet(this,_startClosingTimeoutId)),clearTimeout(__privateGet(this,_closeTimeoutId)),clearTimeout(__privateGet(this,_openFrameId)),clearTimeout(__privateGet(this,_openTransitionTimeoutId)),historyManager.historyManager.removePopStateHandler(__privateGet(this,_popStateListener)),this.style.removeProperty("--content-width"),this.style.removeProperty("--content-height"),this.style.removeProperty("--viewport-offset-x"),this.style.removeProperty("--viewport-offset-y"),__privateMethod(this,_PopoverElement_instances,deleteSearchParam_fn).call(this)}};_opened=new WeakMap,_startClosingTimeoutId=new WeakMap,_closeTimeoutId=new WeakMap,_openFrameId=new WeakMap,_openTransitionTimeoutId=new WeakMap,_history=new WeakMap,_restore=new WeakMap,_dispatchResize=new WeakMap,_closeRest=new WeakMap,_closeRestInGroup=new WeakMap,_group=new WeakMap,_clickOutside=new WeakMap,_escape=new WeakMap,_checkViewportBounds=new WeakMap,_lastTrigger=new WeakMap,_status=new WeakMap,_innerCloseElements=new WeakMap,_resetScrollElements=new WeakMap,_isFromPopState=new WeakMap,_PopoverElement_instances=new WeakSet,path_get=__name(function(){return`${location.pathname}${location.search?location.search+"&":"?"}${this.idWithValue}`},"#path"),toggleGlobalClass_fn=__name(function(on,className){className&&className.split(" ").map(v=>{document.documentElement.classList.toggle(v.trim(),on)})},"#toggleGlobalClass"),deleteSearchParam_fn=__name(function(){if(__privateGet(this,_history).current){const url2=new URL(location.href);url2.searchParams.delete(this.id),historyManager.historyManager.replaceState(url2.href)}},"#deleteSearchParam"),_popStateListener=new WeakMap,_resizeListener=new WeakMap,_debouncedResize=new WeakMap,_resize=new WeakMap,_closeElementClickListener=new WeakMap,__name(_PopoverElement,"PopoverElement"),_PopoverElement.stack=new PopoverGroups,_PopoverElement.popoverHistoryTransactionsDepth=0;let PopoverElement=_PopoverElement;Store.isBrowser&&!customElements.get("e-popover")&&customElements.define("e-popover",PopoverElement);var _popoverElement,_type,_PopoverButtonElement_instances,unlistenPopover_fn,_popoverTriggeredListener,_popoverOpenedListener,_popoverClosingListener,_popoverClosedListener,updateType_fn;const _PopoverButtonElement=class _PopoverButtonElement extends HTMLElement{constructor(){super();__privateAdd(this,_PopoverButtonElement_instances);__privateAdd(this,_popoverElement);__privateAdd(this,_type,new cssProperty_index.CSSProperty(this,"--type","open"));__privateAdd(this,_popoverTriggeredListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&this.classList.add("triggered")},"#popoverTriggeredListener"));__privateAdd(this,_popoverOpenedListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&(this.classList.add("opened"),this.setAttribute("aria-expanded","true"))},"#popoverOpenedListener"));__privateAdd(this,_popoverClosingListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&this.classList.remove("opened")},"#popoverClosingListener"));__privateAdd(this,_popoverClosedListener,__name(e=>{e.target===__privateGet(this,_popoverElement)&&__privateGet(this,_type).current!=="close"&&(this.classList.remove("triggered"),this.setAttribute("aria-expanded","false"))},"#popoverClosedListener"));Store.isBrowser&&(this.addEventListener("click",()=>{if(__privateGet(this,_popoverElement)){const type=__privateGet(this,_type).current;type==="open"||type==="toggle"&&!__privateGet(this,_popoverElement).opened?__privateGet(this,_popoverElement).open({trigger:this}):(type==="close"||type==="toggle"&&__privateGet(this,_popoverElement).opened)&&__privateGet(this,_popoverElement).close(!0)}}),this.addEventListener("keydown",e=>{e.code==="Space"&&!this.hasAttribute("keydown-disabled")&&(e.preventDefault(),this.click())}))}get type(){return __privateGet(this,_type)}get popoverElement(){return __privateGet(this,_popoverElement)}changePopover(targetId){var _a;if(__privateMethod(this,_PopoverButtonElement_instances,unlistenPopover_fn).call(this),targetId){let popoverElement=null;if(targetId==="parent"){const closestTarget=this.closest("[data-popover]");if(closestTarget)popoverElement=closestTarget;else{const rootNode=this.getRootNode();rootNode instanceof ShadowRoot?popoverElement=rootNode.host.closest("[data-popover]"):rootNode instanceof HTMLElement&&(popoverElement=rootNode.closest("[data-popover]"))}}else if(targetId==="sibling")popoverElement=(_a=this.parentElement)==null?void 0:_a.querySelector("[data-popover]");else if(targetId==="ancestor-child"){const find=__name(el=>{if(!el)return null;let founded=el.querySelector("[data-popover]");return!founded&&(el!=null&&el.parentElement)&&(founded=find(el.parentElement)),founded},"find");popoverElement=find(this.parentElement)||null}else{let selector=targetId;if(isNaN(parseInt(selector))&&(!targetId.startsWith(".")&&!targetId.startsWith("[")&&!targetId.startsWith("#")&&(selector=`#${targetId}`),popoverElement=document.querySelector(selector)||this.getRootNode().querySelector(selector)),!popoverElement){const founded=[...document.querySelectorAll("[data-popover-ids]")].find(el=>{var _a2;return(_a2=el.getAttribute("data-popover-ids"))==null?void 0:_a2.split(",").find(v=>v.trim()===targetId)});founded&&(popoverElement=founded)}}popoverElement instanceof HTMLElement?(__privateSet(this,_popoverElement,popoverElement),__privateGet(this,_popoverElement).addEventListener("popoverTriggered",__privateGet(this,_popoverTriggeredListener)),__privateGet(this,_popoverElement).addEventListener("popoverOpened",__privateGet(this,_popoverOpenedListener)),__privateGet(this,_popoverElement).addEventListener("popoverClosing",__privateGet(this,_popoverClosingListener)),__privateGet(this,_popoverElement).addEventListener("popoverClosed",__privateGet(this,_popoverClosedListener))):console.warn(this,`target ${targetId} not found`)}__privateMethod(this,_PopoverButtonElement_instances,updateType_fn).call(this,__privateGet(this,_type).current)}connectedCallback(){__privateGet(this,_type).subscribe(e=>{__privateMethod(this,_PopoverButtonElement_instances,updateType_fn).call(this,e.current)}),this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("role")||this.setAttribute("role","button");const targetId=this.getAttribute("target");targetId&&this.changePopover(targetId),this.isConnected&&__privateGet(this,_type).observe()}disconnectedCallback(){__privateGet(this,_type).unobserve(),this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls"),this.removeAttribute("role"),this.removeAttribute("tabindex"),__privateMethod(this,_PopoverButtonElement_instances,unlistenPopover_fn).call(this)}};_popoverElement=new WeakMap,_type=new WeakMap,_PopoverButtonElement_instances=new WeakSet,unlistenPopover_fn=__name(function(){__privateGet(this,_popoverElement)&&(__privateGet(this,_popoverElement).removeEventListener("popoverTriggered",__privateGet(this,_popoverTriggeredListener)),__privateGet(this,_popoverElement).removeEventListener("popoverOpened",__privateGet(this,_popoverOpenedListener)),__privateGet(this,_popoverElement).removeEventListener("popoverClosing",__privateGet(this,_popoverClosingListener)),__privateGet(this,_popoverElement).removeEventListener("popoverClosed",__privateGet(this,_popoverClosedListener)))},"#unlistenPopover"),_popoverTriggeredListener=new WeakMap,_popoverOpenedListener=new WeakMap,_popoverClosingListener=new WeakMap,_popoverClosedListener=new WeakMap,updateType_fn=__name(function(value){__privateGet(this,_popoverElement)instanceof PopoverElement&&(value!=="close"?(this.setAttribute("aria-haspopup","true"),this.setAttribute("aria-expanded",__privateGet(this,_popoverElement).opened?"true":"false"),this.setAttribute("aria-controls",__privateGet(this,_popoverElement).id||"")):(this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.removeAttribute("aria-controls")))},"#updateType"),__name(_PopoverButtonElement,"PopoverButtonElement");let PopoverButtonElement=_PopoverButtonElement;Store.isBrowser&&!customElements.get("e-popover-button")&&customElements.define("e-popover-button",PopoverButtonElement);exports.PopoverButtonElement=PopoverButtonElement;exports.PopoverElement=PopoverElement;
@@ -8,7 +8,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
8
8
  import { CSSProperty } from "../css-property/index.js";
9
9
  import { v as viewport } from "../Viewport-B3kVX27H.js";
10
10
  import { ElementLinkedStore } from "../element-linked-store/index.js";
11
- import { h as historyManager } from "../historyManager--LUUUbW7.js";
11
+ import { h as historyManager } from "../historyManager-DyjFBozJ.js";
12
12
  import { i as isBrowser } from "../Store-CAGUSjFX.js";
13
13
  import { d as dispatchEvent } from "../events-Ds-TuvYW.js";
14
14
  import { d as debounce } from "../function-UmbPrOHm.js";
@@ -1 +1 @@
1
- "use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);var __privateWrapper=(obj,member,setter,getter)=>({set _(value){__privateSet(obj,member,value,setter)},get _(){return __privateGet(obj,member,getter)}});var __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const history_index=require("../history/index.cjs"),LocalLinks=require("../LocalLinks-Dg9sbmY6.cjs"),PageAnnouncerElement=require("../PageAnnouncerElement-auvTbYB3.cjs"),PageScroll=require("../PageScroll-DYsZDt3U.cjs");require("../Store-B96mD8mD.cjs");require("../index-BoGx2BWX.cjs");require("construct-style-sheets-polyfill");const url=require("../url-CbDPURsX.cjs"),urlpatternPolyfill=require("urlpattern-polyfill"),render=require("../render-D3D-lyxw.cjs"),object=require("../object-DTY_W6xG.cjs");var _pattern,_module,_urlPattern,_elementConstructor,_elementInstance,_isActive,_nestTarget,_mutationObserver,_permanentHeadNodes,_temporalHeadNodes,_Route_instances,initializeRouteModule_fn,appendPermanentHeadNodes_fn,renderRouteComponent_fn,findNestTarget_fn,cleanup_fn,removeTemporalHeadNodes_fn,handleHeadMutations_fn,waitForHeadNodesLoad_fn,isLoadableNode_fn,_instanceReplaceListener;const _Route=class _Route{constructor(pattern,module2){__privateAdd(this,_Route_instances);__privateAdd(this,_pattern);__privateAdd(this,_module);__privateAdd(this,_urlPattern);__privateAdd(this,_elementConstructor,null);__privateAdd(this,_elementInstance,null);__privateAdd(this,_isActive,!1);__privateAdd(this,_nestTarget,null);__privateAdd(this,_mutationObserver);__privateAdd(this,_permanentHeadNodes,[]);__privateAdd(this,_temporalHeadNodes,[]);__privateAdd(this,_instanceReplaceListener,__name(e=>{__privateGet(this,_elementInstance).removeEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener)),__privateSet(this,_elementInstance,e.detail.element),__privateGet(this,_elementInstance).addEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener))},"#instanceReplaceListener"));__privateSet(this,_pattern,pattern),__privateSet(this,_module,module2),__privateSet(this,_urlPattern,new URLPattern({pathname:__privateGet(this,_pattern)})),__privateSet(this,_mutationObserver,new MutationObserver(__privateMethod(this,_Route_instances,handleHeadMutations_fn).bind(this)))}get pattern(){return __privateGet(this,_pattern)}get isActive(){return __privateGet(this,_isActive)}get element(){return __privateGet(this,_elementInstance)}get nest(){return __privateGet(this,_nestTarget)}testPathname(pathname){return __privateGet(this,_urlPattern).test({pathname})}render(container,url2){return __async(this,null,function*(){__privateGet(this,_mutationObserver).observe(document.head,{childList:!0,subtree:!0}),__privateGet(this,_elementConstructor)?__privateMethod(this,_Route_instances,appendPermanentHeadNodes_fn).call(this):yield __privateMethod(this,_Route_instances,initializeRouteModule_fn).call(this),yield __privateMethod(this,_Route_instances,waitForHeadNodesLoad_fn).call(this),__privateGet(this,_elementConstructor)&&(yield __privateMethod(this,_Route_instances,renderRouteComponent_fn).call(this,container,url2)),__privateGet(this,_mutationObserver).disconnect()})}close(){__privateMethod(this,_Route_instances,cleanup_fn).call(this)}};_pattern=new WeakMap,_module=new WeakMap,_urlPattern=new WeakMap,_elementConstructor=new WeakMap,_elementInstance=new WeakMap,_isActive=new WeakMap,_nestTarget=new WeakMap,_mutationObserver=new WeakMap,_permanentHeadNodes=new WeakMap,_temporalHeadNodes=new WeakMap,_Route_instances=new WeakSet,initializeRouteModule_fn=__name(function(){return __async(this,null,function*(){const content=yield __privateGet(this,_module).call(this);__privateSet(this,_temporalHeadNodes,[...__privateGet(this,_permanentHeadNodes)]),typeof content.default=="function"&&__privateSet(this,_elementConstructor,content.default)})},"#initializeRouteModule"),appendPermanentHeadNodes_fn=__name(function(){__privateGet(this,_permanentHeadNodes).forEach(node=>{document.head.appendChild(node.cloneNode(!0))})},"#appendPermanentHeadNodes"),renderRouteComponent_fn=__name(function(container,url2){return __async(this,null,function*(){var _a;const routeParams={urlPatternResult:__privateGet(this,_urlPattern).exec({pathname:url2.pathname})};object.isESClass(__privateGet(this,_elementConstructor))?(__privateSet(this,_elementInstance,new(__privateGet(this,_elementConstructor))(routeParams)),container.appendChild(__privateGet(this,_elementInstance))):__privateSet(this,_elementInstance,render.render(container,__privateGet(this,_elementConstructor),routeParams)),(_a=__privateGet(this,_elementInstance))==null||_a.addEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener)),__privateMethod(this,_Route_instances,findNestTarget_fn).call(this),__privateSet(this,_isActive,!0)})},"#renderRouteComponent"),findNestTarget_fn=__name(function(){var _a;__privateGet(this,_elementInstance)&&__privateSet(this,_nestTarget,__privateGet(this,_elementInstance).querySelector("[data-nest]")||((_a=__privateGet(this,_elementInstance).shadowRoot)==null?void 0:_a.querySelector("[data-nest]"))||__privateGet(this,_elementInstance).shadowRoot||__privateGet(this,_elementInstance))},"#findNestTarget"),cleanup_fn=__name(function(){__privateGet(this,_mutationObserver).disconnect(),__privateGet(this,_elementInstance)&&(__privateGet(this,_elementInstance).removeEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener)),__privateGet(this,_elementInstance).remove()),__privateSet(this,_isActive,!1),__privateMethod(this,_Route_instances,removeTemporalHeadNodes_fn).call(this)},"#cleanup"),removeTemporalHeadNodes_fn=__name(function(){__privateGet(this,_temporalHeadNodes).forEach(node=>{node.parentNode===document.head&&document.head.removeChild(node)}),__privateSet(this,_temporalHeadNodes,[])},"#removeTemporalHeadNodes"),handleHeadMutations_fn=__name(function(mutations){mutations.forEach(mutation=>{mutation.addedNodes.forEach(node=>{__privateGet(this,_elementConstructor)?__privateGet(this,_temporalHeadNodes).push(node):__privateGet(this,_permanentHeadNodes).push(node)})})},"#handleHeadMutations"),waitForHeadNodesLoad_fn=__name(function(){return __async(this,null,function*(){const loadableNodes=__privateGet(this,_permanentHeadNodes).filter(__privateMethod(this,_Route_instances,isLoadableNode_fn));yield Promise.all(loadableNodes.map(node=>new Promise(resolve=>{__privateMethod(this,_Route_instances,isLoadableNode_fn).call(this,node)?node.onload=()=>resolve():resolve()})))})},"#waitForHeadNodesLoad"),isLoadableNode_fn=__name(function(node){return node instanceof HTMLElement&&(node.tagName==="STYLE"||node.tagName==="SCRIPT"||node.tagName==="LINK")},"#isLoadableNode"),_instanceReplaceListener=new WeakMap,__name(_Route,"Route");let Route=_Route;globalThis.URLPattern=urlpatternPolyfill.URLPattern;var _options,_scroll,_links,_history,_announcerElement,_updateId,_routes,_lastRoute,_Router_instances,runPreprocessor_fn,categorizeRoutes_fn,closeOldRoutes_fn,renderNewRoutes_fn,sortRoutesByPathDepth_fn;const _Router=class _Router{constructor(options){__privateAdd(this,_Router_instances);__privateAdd(this,_options,null);__privateAdd(this,_scroll,null);__privateAdd(this,_links,null);__privateAdd(this,_history,null);__privateAdd(this,_announcerElement,null);__privateAdd(this,_updateId,0);__privateAdd(this,_routes,[]);__privateAdd(this,_lastRoute,null);__privateSet(this,_options,__spreadProps(__spreadValues({},options),{rootElement:(options==null?void 0:options.rootElement)||document.body,base:url.normalizeBase(options==null?void 0:options.base)})),__privateSet(this,_announcerElement,new PageAnnouncerElement.PageAnnouncerElement),__privateSet(this,_scroll,new PageScroll.PageScroll(__privateGet(this,_options).scrollSelector)),__privateGet(this,_scroll).update(),__privateSet(this,_links,new LocalLinks.LocalLinks({base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash,includeAnchor:options==null?void 0:options.includeAnchor,onClick:__name((url2,options2)=>{try{this.navigate(url2,options2)}catch(e){window.location.assign(url2)}},"onClick")})),__privateGet(this,_links).update(),__privateSet(this,_history,new history_index.History({onPop:__name(url2=>{this.navigate(url2)},"onPop")}))}history(){return __privateGet(this,_history)}get scroll(){return scroll}get routes(){return __privateGet(this,_routes)}run(){__privateMethod(this,_Router_instances,sortRoutesByPathDepth_fn).call(this),this.navigate(new URL(location.href),{revalidate:!0})}defineRoute(pattern,module2){const route=new Route(pattern,module2);__privateGet(this,_routes).push(route)}navigate(url$1,options){return __async(this,null,function*(){var _a,_b,_c,_d,_e,_f;const isBack=__privateGet(this,_history).isBack,updateId=++__privateWrapper(this,_updateId)._;let fullUrl=url.normalizeURL(url$1,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash});if(__privateGet(this,_options).urlModifier&&(fullUrl=__privateGet(this,_options).urlModifier(fullUrl)),!(yield __privateMethod(this,_Router_instances,runPreprocessor_fn).call(this,fullUrl))||__privateGet(this,_updateId)!==updateId||(yield(_b=(_a=__privateGet(this,_options)).beforeNavigation)==null?void 0:_b.call(_a),__privateGet(this,_updateId)!==updateId))return;const{activeRoutes,newRoutes,oldRoutes,keepRoutes}=__privateMethod(this,_Router_instances,categorizeRoutes_fn).call(this,fullUrl);__privateSet(this,_lastRoute,(_c=keepRoutes[keepRoutes.length-1])!=null?_c:null),isBack||(__privateGet(this,_history).push(fullUrl),((_d=options==null?void 0:options.keepScrollPosition)==null||_d)&&__privateGet(this,_scroll).element.scrollTo({top:0,behavior:"instant"})),__privateGet(this,_announcerElement).create(document,fullUrl.pathname),__privateGet(this,_options).viewTransition&&document.startViewTransition?yield document.startViewTransition(()=>__privateMethod(this,_Router_instances,renderNewRoutes_fn).call(this,oldRoutes,newRoutes,fullUrl)).finished:yield __privateMethod(this,_Router_instances,renderNewRoutes_fn).call(this,oldRoutes,newRoutes,fullUrl),__privateGet(this,_scroll).update(),__privateGet(this,_links).update(),__privateGet(this,_announcerElement).done(),yield(_f=(_e=__privateGet(this,_options)).afterNavigation)==null?void 0:_f.call(_e)})}};_options=new WeakMap,_scroll=new WeakMap,_links=new WeakMap,_history=new WeakMap,_announcerElement=new WeakMap,_updateId=new WeakMap,_routes=new WeakMap,_lastRoute=new WeakMap,_Router_instances=new WeakSet,runPreprocessor_fn=__name(function(url2){return __async(this,null,function*(){if(!__privateGet(this,_options).preprocessor)return!0;try{return yield new Promise((resolve,reject)=>{var _a,_b;(_b=(_a=__privateGet(this,_options)).preprocessor)==null||_b.call(_a,{url:url2,resolve,reject})}),!0}catch(error){return console.error(error!=null?error:"Route change canceled"),!1}})},"#runPreprocessor"),categorizeRoutes_fn=__name(function(url2){let leaf=url2.pathname.replace(__privateGet(this,_options).base,"");leaf.startsWith("/")||(leaf=`/${leaf}`);const activeRoutes=__privateGet(this,_routes).filter(route=>route.isActive);return{activeRoutes,newRoutes:__privateGet(this,_routes).filter(route=>!activeRoutes.includes(route)&&route.testPathname(leaf)),oldRoutes:activeRoutes.filter(route=>!route.testPathname(leaf)),keepRoutes:activeRoutes.filter(route=>route.testPathname(leaf))}},"#categorizeRoutes"),closeOldRoutes_fn=__name(function(routes){routes.forEach(route=>route.close())},"#closeOldRoutes"),renderNewRoutes_fn=__name(function(oldRoutes,routes,url2){return __async(this,null,function*(){var _a,_b;__privateMethod(this,_Router_instances,closeOldRoutes_fn).call(this,oldRoutes);for(const route of routes){const target=(_b=(_a=__privateGet(this,_lastRoute))==null?void 0:_a.nest)!=null?_b:__privateGet(this,_options).rootElement;yield route.render(target,url2),__privateSet(this,_lastRoute,route)}})},"#renderNewRoutes"),sortRoutesByPathDepth_fn=__name(function(){__privateGet(this,_routes).sort((a,b)=>{const depthA=a.pattern.split("/").length,depthB=b.pattern.split("/").length;return depthA-depthB})},"#sortRoutesByPathDepth"),__name(_Router,"Router");let Router=_Router;exports.Router=Router;
1
+ "use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);var __privateWrapper=(obj,member,setter,getter)=>({set _(value){__privateSet(obj,member,value,setter)},get _(){return __privateGet(obj,member,getter)}});var __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const history_index=require("../history/index.cjs"),LocalLinks=require("../LocalLinks-DXGiMKnk.cjs"),PageAnnouncerElement=require("../PageAnnouncerElement-auvTbYB3.cjs"),PageScroll=require("../PageScroll-DYsZDt3U.cjs");require("../Store-B96mD8mD.cjs");require("../index-BoGx2BWX.cjs");require("construct-style-sheets-polyfill");const url=require("../url-CbDPURsX.cjs"),urlpatternPolyfill=require("urlpattern-polyfill"),render=require("../render-D3D-lyxw.cjs"),object=require("../object-DTY_W6xG.cjs");var _pattern,_module,_urlPattern,_elementConstructor,_elementInstance,_isActive,_nestTarget,_mutationObserver,_permanentHeadNodes,_temporalHeadNodes,_Route_instances,initializeRouteModule_fn,appendPermanentHeadNodes_fn,renderRouteComponent_fn,findNestTarget_fn,cleanup_fn,removeTemporalHeadNodes_fn,handleHeadMutations_fn,waitForHeadNodesLoad_fn,isLoadableNode_fn,_instanceReplaceListener;const _Route=class _Route{constructor(pattern,module2){__privateAdd(this,_Route_instances);__privateAdd(this,_pattern);__privateAdd(this,_module);__privateAdd(this,_urlPattern);__privateAdd(this,_elementConstructor,null);__privateAdd(this,_elementInstance,null);__privateAdd(this,_isActive,!1);__privateAdd(this,_nestTarget,null);__privateAdd(this,_mutationObserver);__privateAdd(this,_permanentHeadNodes,[]);__privateAdd(this,_temporalHeadNodes,[]);__privateAdd(this,_instanceReplaceListener,__name(e=>{__privateGet(this,_elementInstance).removeEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener)),__privateSet(this,_elementInstance,e.detail.element),__privateGet(this,_elementInstance).addEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener))},"#instanceReplaceListener"));__privateSet(this,_pattern,pattern),__privateSet(this,_module,module2),__privateSet(this,_urlPattern,new URLPattern({pathname:__privateGet(this,_pattern)})),__privateSet(this,_mutationObserver,new MutationObserver(__privateMethod(this,_Route_instances,handleHeadMutations_fn).bind(this)))}get pattern(){return __privateGet(this,_pattern)}get isActive(){return __privateGet(this,_isActive)}get element(){return __privateGet(this,_elementInstance)}get nest(){return __privateGet(this,_nestTarget)}testPathname(pathname){return __privateGet(this,_urlPattern).test({pathname})}render(container,url2){return __async(this,null,function*(){__privateGet(this,_mutationObserver).observe(document.head,{childList:!0,subtree:!0}),__privateGet(this,_elementConstructor)?__privateMethod(this,_Route_instances,appendPermanentHeadNodes_fn).call(this):yield __privateMethod(this,_Route_instances,initializeRouteModule_fn).call(this),yield __privateMethod(this,_Route_instances,waitForHeadNodesLoad_fn).call(this),__privateGet(this,_elementConstructor)&&(yield __privateMethod(this,_Route_instances,renderRouteComponent_fn).call(this,container,url2)),__privateGet(this,_mutationObserver).disconnect()})}close(){__privateMethod(this,_Route_instances,cleanup_fn).call(this)}};_pattern=new WeakMap,_module=new WeakMap,_urlPattern=new WeakMap,_elementConstructor=new WeakMap,_elementInstance=new WeakMap,_isActive=new WeakMap,_nestTarget=new WeakMap,_mutationObserver=new WeakMap,_permanentHeadNodes=new WeakMap,_temporalHeadNodes=new WeakMap,_Route_instances=new WeakSet,initializeRouteModule_fn=__name(function(){return __async(this,null,function*(){const content=yield __privateGet(this,_module).call(this);__privateSet(this,_temporalHeadNodes,[...__privateGet(this,_permanentHeadNodes)]),typeof content.default=="function"&&__privateSet(this,_elementConstructor,content.default)})},"#initializeRouteModule"),appendPermanentHeadNodes_fn=__name(function(){__privateGet(this,_permanentHeadNodes).forEach(node=>{document.head.appendChild(node.cloneNode(!0))})},"#appendPermanentHeadNodes"),renderRouteComponent_fn=__name(function(container,url2){return __async(this,null,function*(){var _a;const routeParams={urlPatternResult:__privateGet(this,_urlPattern).exec({pathname:url2.pathname})};object.isESClass(__privateGet(this,_elementConstructor))?(__privateSet(this,_elementInstance,new(__privateGet(this,_elementConstructor))(routeParams)),container.appendChild(__privateGet(this,_elementInstance))):__privateSet(this,_elementInstance,render.render(container,__privateGet(this,_elementConstructor),routeParams)),(_a=__privateGet(this,_elementInstance))==null||_a.addEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener)),__privateMethod(this,_Route_instances,findNestTarget_fn).call(this),__privateSet(this,_isActive,!0)})},"#renderRouteComponent"),findNestTarget_fn=__name(function(){var _a;__privateGet(this,_elementInstance)&&__privateSet(this,_nestTarget,__privateGet(this,_elementInstance).querySelector("[data-nest]")||((_a=__privateGet(this,_elementInstance).shadowRoot)==null?void 0:_a.querySelector("[data-nest]"))||__privateGet(this,_elementInstance).shadowRoot||__privateGet(this,_elementInstance))},"#findNestTarget"),cleanup_fn=__name(function(){__privateGet(this,_mutationObserver).disconnect(),__privateGet(this,_elementInstance)&&(__privateGet(this,_elementInstance).removeEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener)),__privateGet(this,_elementInstance).remove()),__privateSet(this,_isActive,!1),__privateMethod(this,_Route_instances,removeTemporalHeadNodes_fn).call(this)},"#cleanup"),removeTemporalHeadNodes_fn=__name(function(){__privateGet(this,_temporalHeadNodes).forEach(node=>{node.parentNode===document.head&&document.head.removeChild(node)}),__privateSet(this,_temporalHeadNodes,[])},"#removeTemporalHeadNodes"),handleHeadMutations_fn=__name(function(mutations){mutations.forEach(mutation=>{mutation.addedNodes.forEach(node=>{__privateGet(this,_elementConstructor)?__privateGet(this,_temporalHeadNodes).push(node):__privateGet(this,_permanentHeadNodes).push(node)})})},"#handleHeadMutations"),waitForHeadNodesLoad_fn=__name(function(){return __async(this,null,function*(){const loadableNodes=__privateGet(this,_permanentHeadNodes).filter(__privateMethod(this,_Route_instances,isLoadableNode_fn));yield Promise.all(loadableNodes.map(node=>new Promise(resolve=>{__privateMethod(this,_Route_instances,isLoadableNode_fn).call(this,node)?node.onload=()=>resolve():resolve()})))})},"#waitForHeadNodesLoad"),isLoadableNode_fn=__name(function(node){return node instanceof HTMLElement&&(node.tagName==="STYLE"||node.tagName==="SCRIPT"||node.tagName==="LINK")},"#isLoadableNode"),_instanceReplaceListener=new WeakMap,__name(_Route,"Route");let Route=_Route;globalThis.URLPattern=urlpatternPolyfill.URLPattern;var _options,_scroll,_links,_history,_announcerElement,_updateId,_routes,_lastRoute,_Router_instances,runPreprocessor_fn,categorizeRoutes_fn,closeOldRoutes_fn,renderNewRoutes_fn,sortRoutesByPathDepth_fn;const _Router=class _Router{constructor(options){__privateAdd(this,_Router_instances);__privateAdd(this,_options,null);__privateAdd(this,_scroll,null);__privateAdd(this,_links,null);__privateAdd(this,_history,null);__privateAdd(this,_announcerElement,null);__privateAdd(this,_updateId,0);__privateAdd(this,_routes,[]);__privateAdd(this,_lastRoute,null);__privateSet(this,_options,__spreadProps(__spreadValues({},options),{rootElement:(options==null?void 0:options.rootElement)||document.body,base:url.normalizeBase(options==null?void 0:options.base)})),__privateSet(this,_announcerElement,new PageAnnouncerElement.PageAnnouncerElement),__privateSet(this,_scroll,new PageScroll.PageScroll(__privateGet(this,_options).scrollSelector)),__privateGet(this,_scroll).update(),__privateSet(this,_links,new LocalLinks.LocalLinks({base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash,includeAnchor:options==null?void 0:options.includeAnchor,onClick:__name((url2,options2)=>{try{this.navigate(url2,options2)}catch(e){window.location.assign(url2)}},"onClick")})),__privateGet(this,_links).update(),__privateSet(this,_history,new history_index.History({onPop:__name(url2=>{this.navigate(url2)},"onPop")}))}history(){return __privateGet(this,_history)}get scroll(){return scroll}get routes(){return __privateGet(this,_routes)}run(){__privateMethod(this,_Router_instances,sortRoutesByPathDepth_fn).call(this),this.navigate(new URL(location.href),{revalidate:!0})}defineRoute(pattern,module2){const route=new Route(pattern,module2);__privateGet(this,_routes).push(route)}navigate(url$1,options){return __async(this,null,function*(){var _a,_b,_c,_d,_e,_f;const isBack=__privateGet(this,_history).isBack,updateId=++__privateWrapper(this,_updateId)._;let fullUrl=url.normalizeURL(url$1,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash});if(__privateGet(this,_options).urlModifier&&(fullUrl=__privateGet(this,_options).urlModifier(fullUrl)),!(yield __privateMethod(this,_Router_instances,runPreprocessor_fn).call(this,fullUrl))||__privateGet(this,_updateId)!==updateId||(yield(_b=(_a=__privateGet(this,_options)).beforeNavigation)==null?void 0:_b.call(_a),__privateGet(this,_updateId)!==updateId))return;const{activeRoutes,newRoutes,oldRoutes,keepRoutes}=__privateMethod(this,_Router_instances,categorizeRoutes_fn).call(this,fullUrl);__privateSet(this,_lastRoute,(_c=keepRoutes[keepRoutes.length-1])!=null?_c:null),isBack||(__privateGet(this,_history).push(fullUrl),((_d=options==null?void 0:options.keepScrollPosition)==null||_d)&&__privateGet(this,_scroll).element.scrollTo({top:0,behavior:"instant"})),__privateGet(this,_announcerElement).create(document,fullUrl.pathname),__privateGet(this,_options).viewTransition&&document.startViewTransition?yield document.startViewTransition(()=>__privateMethod(this,_Router_instances,renderNewRoutes_fn).call(this,oldRoutes,newRoutes,fullUrl)).finished:yield __privateMethod(this,_Router_instances,renderNewRoutes_fn).call(this,oldRoutes,newRoutes,fullUrl),__privateGet(this,_scroll).update(),__privateGet(this,_links).update(),__privateGet(this,_announcerElement).done(),yield(_f=(_e=__privateGet(this,_options)).afterNavigation)==null?void 0:_f.call(_e)})}};_options=new WeakMap,_scroll=new WeakMap,_links=new WeakMap,_history=new WeakMap,_announcerElement=new WeakMap,_updateId=new WeakMap,_routes=new WeakMap,_lastRoute=new WeakMap,_Router_instances=new WeakSet,runPreprocessor_fn=__name(function(url2){return __async(this,null,function*(){if(!__privateGet(this,_options).preprocessor)return!0;try{return yield new Promise((resolve,reject)=>{var _a,_b;(_b=(_a=__privateGet(this,_options)).preprocessor)==null||_b.call(_a,{url:url2,resolve,reject})}),!0}catch(error){return console.error(error!=null?error:"Route change canceled"),!1}})},"#runPreprocessor"),categorizeRoutes_fn=__name(function(url2){let leaf=url2.pathname.replace(__privateGet(this,_options).base,"");leaf.startsWith("/")||(leaf=`/${leaf}`);const activeRoutes=__privateGet(this,_routes).filter(route=>route.isActive);return{activeRoutes,newRoutes:__privateGet(this,_routes).filter(route=>!activeRoutes.includes(route)&&route.testPathname(leaf)),oldRoutes:activeRoutes.filter(route=>!route.testPathname(leaf)),keepRoutes:activeRoutes.filter(route=>route.testPathname(leaf))}},"#categorizeRoutes"),closeOldRoutes_fn=__name(function(routes){routes.forEach(route=>route.close())},"#closeOldRoutes"),renderNewRoutes_fn=__name(function(oldRoutes,routes,url2){return __async(this,null,function*(){var _a,_b;__privateMethod(this,_Router_instances,closeOldRoutes_fn).call(this,oldRoutes);for(const route of routes){const target=(_b=(_a=__privateGet(this,_lastRoute))==null?void 0:_a.nest)!=null?_b:__privateGet(this,_options).rootElement;yield route.render(target,url2),__privateSet(this,_lastRoute,route)}})},"#renderNewRoutes"),sortRoutesByPathDepth_fn=__name(function(){__privateGet(this,_routes).sort((a,b)=>{const depthA=a.pattern.split("/").length,depthB=b.pattern.split("/").length;return depthA-depthB})},"#sortRoutesByPathDepth"),__name(_Router,"Router");let Router=_Router;exports.Router=Router;
@@ -40,7 +40,7 @@ var __async = (__this, __arguments, generator) => new Promise((resolve, reject)
40
40
  step((generator = generator.apply(__this, __arguments)).next());
41
41
  });
42
42
  import { History } from "../history/index.js";
43
- import { L as LocalLinks } from "../LocalLinks-DYT4kzSV.js";
43
+ import { L as LocalLinks } from "../LocalLinks-JdNN4mez.js";
44
44
  import { P as PageAnnouncerElement } from "../PageAnnouncerElement-Bqbv_gWM.js";
45
45
  import { P as PageScroll } from "../PageScroll-DgTMhV1L.js";
46
46
  import "../Store-CAGUSjFX.js";
@@ -19,6 +19,7 @@ type PopStateHandler = (event: HistoryManagerPopStateEvent) => void;
19
19
  declare class HistoryManager {
20
20
  #private;
21
21
  constructor();
22
+ get size(): number;
22
23
  getPreviousState(): HistoryManagerState | null;
23
24
  getCurrentState(): HistoryManagerState | null;
24
25
  addPopStateHandler(handler: PopStateHandler, unshift?: boolean): void;
package/lib/spa/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value);var __privateWrapper=(obj,member,setter,getter)=>({set _(value){__privateSet(obj,member,value,setter)},get _(){return __privateGet(obj,member,getter)}});var __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const cache_index=require("../cache/index.cjs"),LocalLinks=require("../LocalLinks-Dg9sbmY6.cjs"),PageAnnouncerElement=require("../PageAnnouncerElement-auvTbYB3.cjs"),PageScroll=require("../PageScroll-DYsZDt3U.cjs"),historyManager=require("../historyManager-DB2fSEtH.cjs"),events=require("../events-UlGk63iC.cjs"),morph=require("../morph-BW6QJlwg.cjs");require("../Store-B96mD8mD.cjs");require("../index-BoGx2BWX.cjs");require("construct-style-sheets-polyfill");const url=require("../url-CbDPURsX.cjs");var _cache,_domParser,_options,_scroll,_links,_announcerElement,_updateId,_isBack;const _SPA=class _SPA{constructor(options){__privateAdd(this,_cache,new cache_index.Cache);__privateAdd(this,_domParser,new DOMParser);__privateAdd(this,_options,null);__privateAdd(this,_scroll,null);__privateAdd(this,_links,null);__privateAdd(this,_announcerElement,null);__privateAdd(this,_updateId,0);__privateAdd(this,_isBack,!1);_SPA.instance||(_SPA.instance=this,__privateSet(this,_options,__spreadProps(__spreadValues({},options),{base:url.normalizeBase(options==null?void 0:options.base)})),__privateSet(this,_announcerElement,new PageAnnouncerElement.PageAnnouncerElement),__privateSet(this,_scroll,new PageScroll.PageScroll(__privateGet(this,_options).scrollSelector)),__privateGet(this,_scroll).update(),__privateSet(this,_links,new LocalLinks.LocalLinks({base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash,includeAnchor:options==null?void 0:options.includeAnchor,onClick:__name((url2,options2)=>{try{this.navigate(url2,options2)}catch(e){window.location.assign(url2)}},"onClick")})),__privateGet(this,_links).update(),historyManager.historyManager.addPopStateHandler(event=>{var _a,_b,_c,_d,_e,_f,_g,_h;(_b=(_a=event.state)==null?void 0:_a.data)!=null&&_b.popover||(_d=(_c=event.previousState)==null?void 0:_c.data)!=null&&_d.popover||(__privateSet(this,_isBack,!0),this.navigate(location.href.replace(location.origin,""),{scrollTop:((_f=(_e=event.state)==null?void 0:_e.data)==null?void 0:_f.scrollTop)||0,scrollLeft:((_h=(_g=event.state)==null?void 0:_g.data)==null?void 0:_h.scrollLeft)||0}))}))}get scroll(){return __privateGet(this,_scroll)}navigate(url$1,options){return __async(this,null,function*(){var _a,_b,_c,_d,_e,_f,_g;let isBack=__privateGet(this,_isBack);__privateSet(this,_isBack,!1);const updateId=++__privateWrapper(this,_updateId)._;let fullUrl=url.normalizeURL(url$1,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash});__privateGet(this,_options).urlModifier&&(fullUrl=__privateGet(this,_options).urlModifier(fullUrl));let contents=__privateGet(this,_cache).get(fullUrl.toString());if((!contents||options!=null&&options.revalidate)&&(contents=yield fetch(`${fullUrl}`,{headers:{"X-SPA":"true"}}).then(res=>res.text()).catch(()=>{window.location.assign(fullUrl)})),!contents||(options!=null&&options.cache&&__privateGet(this,_cache).set(fullUrl.toString(),contents),__privateGet(this,_updateId)!==updateId))return;isBack?historyManager.historyManager.updatePreviousStateData({scrollTop:__privateGet(this,_scroll).y,scrollLeft:__privateGet(this,_scroll).x}):(historyManager.historyManager.updateCurrentStateData({scrollTop:__privateGet(this,_scroll).y,scrollLeft:__privateGet(this,_scroll).x}),historyManager.historyManager.pushState(fullUrl));const html=__privateGet(this,_domParser).parseFromString(contents,"text/html");if(url.normalizeRelativeURLs(html,fullUrl),yield(_b=(_a=__privateGet(this,_options)).beforeDiff)==null?void 0:_b.call(_a,html),__privateGet(this,_updateId)!==updateId)return;events.dispatchEvent(document,"spaBeforeUpdate",{custom:!0});let title=(_c=html.querySelector("title"))==null?void 0:_c.textContent;if(title)document.title=title;else{const h1=document.querySelector("h1");title=(_e=(_d=h1==null?void 0:h1.innerText)!=null?_d:h1==null?void 0:h1.textContent)!=null?_e:fullUrl.pathname}__privateGet(this,_announcerElement).create(html,title);const updateDone=__name(()=>{__privateGet(this,_scroll).update(),__privateGet(this,_links).update(),__privateGet(this,_announcerElement).done(),options!=null&&options.keepScrollPosition||__privateGet(this,_scroll).element.scrollTo({top:(options==null?void 0:options.scrollTop)||0,left:(options==null?void 0:options.scrollLeft)||0,behavior:"instant"})},"updateDone");if(__privateGet(this,_options).viewTransition&&document.startViewTransition){const v=document.startViewTransition(()=>morph.morph(document,html));yield v.updateCallbackDone,updateDone(),yield v.finished}else yield morph.morph(document,html),updateDone();yield(_g=(_f=__privateGet(this,_options)).afterDiff)==null?void 0:_g.call(_f),events.dispatchEvent(document,"spaAfterUpdate",{custom:!0})})}};_cache=new WeakMap,_domParser=new WeakMap,_options=new WeakMap,_scroll=new WeakMap,_links=new WeakMap,_announcerElement=new WeakMap,_updateId=new WeakMap,_isBack=new WeakMap,__name(_SPA,"SPA"),_SPA.instance=null;let SPA=_SPA;exports.SPA=SPA;
1
+ "use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value);var __privateWrapper=(obj,member,setter,getter)=>({set _(value){__privateSet(obj,member,value,setter)},get _(){return __privateGet(obj,member,getter)}});var __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const cache_index=require("../cache/index.cjs"),LocalLinks=require("../LocalLinks-DXGiMKnk.cjs"),PageAnnouncerElement=require("../PageAnnouncerElement-auvTbYB3.cjs"),PageScroll=require("../PageScroll-DYsZDt3U.cjs"),historyManager=require("../historyManager-Car6P2ak.cjs"),events=require("../events-UlGk63iC.cjs"),morph=require("../morph-BW6QJlwg.cjs");require("../Store-B96mD8mD.cjs");require("../index-BoGx2BWX.cjs");require("construct-style-sheets-polyfill");const url=require("../url-CbDPURsX.cjs");var _cache,_domParser,_options,_scroll,_links,_announcerElement,_updateId,_isBack;const _SPA=class _SPA{constructor(options){__privateAdd(this,_cache,new cache_index.Cache);__privateAdd(this,_domParser,new DOMParser);__privateAdd(this,_options,null);__privateAdd(this,_scroll,null);__privateAdd(this,_links,null);__privateAdd(this,_announcerElement,null);__privateAdd(this,_updateId,0);__privateAdd(this,_isBack,!1);_SPA.instance||(_SPA.instance=this,__privateSet(this,_options,__spreadProps(__spreadValues({},options),{base:url.normalizeBase(options==null?void 0:options.base)})),__privateSet(this,_announcerElement,new PageAnnouncerElement.PageAnnouncerElement),__privateSet(this,_scroll,new PageScroll.PageScroll(__privateGet(this,_options).scrollSelector)),__privateGet(this,_scroll).update(),__privateSet(this,_links,new LocalLinks.LocalLinks({base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash,includeAnchor:options==null?void 0:options.includeAnchor,onClick:__name((url2,options2)=>{try{this.navigate(url2,options2)}catch(e){window.location.assign(url2)}},"onClick")})),__privateGet(this,_links).update(),historyManager.historyManager.addPopStateHandler(event=>{var _a,_b,_c,_d,_e,_f,_g,_h;(_b=(_a=event.state)==null?void 0:_a.data)!=null&&_b.popover||(_d=(_c=event.previousState)==null?void 0:_c.data)!=null&&_d.popover||(__privateSet(this,_isBack,!0),this.navigate(location.href.replace(location.origin,""),{scrollTop:((_f=(_e=event.state)==null?void 0:_e.data)==null?void 0:_f.scrollTop)||0,scrollLeft:((_h=(_g=event.state)==null?void 0:_g.data)==null?void 0:_h.scrollLeft)||0}))}))}get scroll(){return __privateGet(this,_scroll)}navigate(url$1,options){return __async(this,null,function*(){var _a,_b,_c,_d,_e,_f,_g;let isBack=__privateGet(this,_isBack);__privateSet(this,_isBack,!1);const updateId=++__privateWrapper(this,_updateId)._;let fullUrl=url.normalizeURL(url$1,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash});__privateGet(this,_options).urlModifier&&(fullUrl=__privateGet(this,_options).urlModifier(fullUrl));let contents=__privateGet(this,_cache).get(fullUrl.toString());if((!contents||options!=null&&options.revalidate)&&(contents=yield fetch(`${fullUrl}`,{headers:{"X-SPA":"true"}}).then(res=>res.text()).catch(()=>{window.location.assign(fullUrl)})),!contents||(options!=null&&options.cache&&__privateGet(this,_cache).set(fullUrl.toString(),contents),__privateGet(this,_updateId)!==updateId))return;isBack?historyManager.historyManager.updatePreviousStateData({scrollTop:__privateGet(this,_scroll).y,scrollLeft:__privateGet(this,_scroll).x}):(historyManager.historyManager.updateCurrentStateData({scrollTop:__privateGet(this,_scroll).y,scrollLeft:__privateGet(this,_scroll).x}),historyManager.historyManager.pushState(fullUrl));const html=__privateGet(this,_domParser).parseFromString(contents,"text/html");if(url.normalizeRelativeURLs(html,fullUrl),yield(_b=(_a=__privateGet(this,_options)).beforeDiff)==null?void 0:_b.call(_a,html),__privateGet(this,_updateId)!==updateId)return;events.dispatchEvent(document,"spaBeforeUpdate",{custom:!0});let title=(_c=html.querySelector("title"))==null?void 0:_c.textContent;if(title)document.title=title;else{const h1=document.querySelector("h1");title=(_e=(_d=h1==null?void 0:h1.innerText)!=null?_d:h1==null?void 0:h1.textContent)!=null?_e:fullUrl.pathname}__privateGet(this,_announcerElement).create(html,title);const updateDone=__name(()=>{__privateGet(this,_scroll).update(),__privateGet(this,_links).update(),__privateGet(this,_announcerElement).done(),options!=null&&options.keepScrollPosition||__privateGet(this,_scroll).element.scrollTo({top:(options==null?void 0:options.scrollTop)||0,left:(options==null?void 0:options.scrollLeft)||0,behavior:"instant"})},"updateDone");if(__privateGet(this,_options).viewTransition&&document.startViewTransition){const v=document.startViewTransition(()=>morph.morph(document,html));yield v.updateCallbackDone,updateDone(),yield v.finished}else yield morph.morph(document,html),updateDone();yield(_g=(_f=__privateGet(this,_options)).afterDiff)==null?void 0:_g.call(_f),events.dispatchEvent(document,"spaAfterUpdate",{custom:!0})})}};_cache=new WeakMap,_domParser=new WeakMap,_options=new WeakMap,_scroll=new WeakMap,_links=new WeakMap,_announcerElement=new WeakMap,_updateId=new WeakMap,_isBack=new WeakMap,__name(_SPA,"SPA"),_SPA.instance=null;let SPA=_SPA;exports.SPA=SPA;
package/lib/spa/index.js CHANGED
@@ -40,10 +40,10 @@ var __async = (__this, __arguments, generator) => new Promise((resolve, reject)
40
40
  step((generator = generator.apply(__this, __arguments)).next());
41
41
  });
42
42
  import { Cache } from "../cache/index.js";
43
- import { L as LocalLinks } from "../LocalLinks-DYT4kzSV.js";
43
+ import { L as LocalLinks } from "../LocalLinks-JdNN4mez.js";
44
44
  import { P as PageAnnouncerElement } from "../PageAnnouncerElement-Bqbv_gWM.js";
45
45
  import { P as PageScroll } from "../PageScroll-DgTMhV1L.js";
46
- import { h as historyManager } from "../historyManager--LUUUbW7.js";
46
+ import { h as historyManager } from "../historyManager-DyjFBozJ.js";
47
47
  import { d as dispatchEvent } from "../events-Ds-TuvYW.js";
48
48
  import { m as morph } from "../morph-ChSinItH.js";
49
49
  import "../Store-CAGUSjFX.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aptechka",
3
- "version": "0.93.3",
3
+ "version": "0.93.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/denisavitski/aptechka.git"
@@ -1 +0,0 @@
1
- "use strict";var __defProp=Object.defineProperty;var __typeError=msg=>{throw TypeError(msg)};var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);const morph=require("./morph-BW6QJlwg.cjs");require("./Store-B96mD8mD.cjs");require("./index-BoGx2BWX.cjs");require("construct-style-sheets-polyfill");const url=require("./url-CbDPURsX.cjs");var _options,_LocalLinks_instances,isElement_fn,processClickEvent_fn,_clickListener;const _LocalLinks=class _LocalLinks{constructor(options){__privateAdd(this,_LocalLinks_instances);__privateAdd(this,_options);__privateAdd(this,_clickListener,__name(event=>{var _a,_b;const result=__privateMethod(this,_LocalLinks_instances,processClickEvent_fn).call(this,event);if(!result)return;const{url:url2,options={}}=result;url2&&(event.preventDefault(),(_b=(_a=__privateGet(this,_options)).onClick)==null||_b.call(_a,url2,options))},"#clickListener"));__privateSet(this,_options,options),window.addEventListener("click",__privateGet(this,_clickListener))}destroy(){window.removeEventListener("click",__privateGet(this,_clickListener))}update(){document.querySelectorAll("a").forEach(link=>{const href=link.getAttribute("href");href&&url.normalizeURL(href,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash}).pathname===location.pathname?link.classList.add("current"):link.classList.remove("current")})}};_options=new WeakMap,_LocalLinks_instances=new WeakSet,isElement_fn=__name(function(target){return(target==null?void 0:target.nodeType)===morph.NODE_TYPE_ELEMENT},"#isElement"),processClickEvent_fn=__name(function(e){const target=e.composedPath()[0];if(!__privateMethod(this,_LocalLinks_instances,isElement_fn).call(this,target))return;const anchorElement=target.closest("a");if(!anchorElement||typeof __privateGet(this,_options).includeAnchor=="function"&&!__privateGet(this,_options).includeAnchor(anchorElement,e)||anchorElement.closest("[data-router-ignore]"))return;const{href}=anchorElement;if(!url.isLocalUrl(href))return;const options={keepScrollPosition:"keepScrollPosition"in anchorElement.dataset,cache:"cache"in anchorElement.dataset,revalidate:"revalidate"in anchorElement.dataset,scrollLeft:parseFloat(anchorElement.dataset.scrollLeft||"0"),scrollTop:parseFloat(anchorElement.dataset.scrollTop||"0")};return{url:url.normalizeURL(new URL(href),{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash}),options}},"#processClickEvent"),_clickListener=new WeakMap,__name(_LocalLinks,"LocalLinks");let LocalLinks=_LocalLinks;exports.LocalLinks=LocalLinks;
@@ -1 +0,0 @@
1
- "use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);var _previousStates,_popStateHandlers,_HistoryManager_instances,setupTracking_fn,overrideHistoryMethods_fn,updateHistory_fn,handlePopState_fn,getPathname_fn;const _HistoryManager=class _HistoryManager{constructor(){__privateAdd(this,_HistoryManager_instances);__privateAdd(this,_previousStates);__privateAdd(this,_popStateHandlers);history.scrollRestoration="manual",__privateSet(this,_previousStates,[history.state]),__privateSet(this,_popStateHandlers,[]),__privateMethod(this,_HistoryManager_instances,setupTracking_fn).call(this)}getPreviousState(){return __privateGet(this,_previousStates).length>1?__privateGet(this,_previousStates)[__privateGet(this,_previousStates).length-2]:null}getCurrentState(){return __privateGet(this,_previousStates).length>0?__privateGet(this,_previousStates)[__privateGet(this,_previousStates).length-1]:null}addPopStateHandler(handler,unshift){unshift?__privateGet(this,_popStateHandlers).unshift(handler):__privateGet(this,_popStateHandlers).push(handler)}removePopStateHandler(handler){const index=__privateGet(this,_popStateHandlers).indexOf(handler);index>-1&&__privateGet(this,_popStateHandlers).splice(index,1)}updateCurrentStateData(data){let state=this.getCurrentState();state&&(state.data=__spreadValues(__spreadValues({},state.data),data))}updatePreviousStateData(data){let state=this.getPreviousState();state&&(state.data=__spreadValues(__spreadValues({},state.data),data))}pushState(page,data){const state={page:__privateMethod(this,_HistoryManager_instances,getPathname_fn).call(this,page),data,timestamp:Date.now()};history.pushState(state,"",page)}replaceState(page,data){const state={page:__privateMethod(this,_HistoryManager_instances,getPathname_fn).call(this,page),data,timestamp:Date.now()};history.replaceState(state,"",page)}back(){history.back()}forward(){history.forward()}go(delta){history.go(delta)}__change(parameters){if(parameters.action==="none")return;const por=parameters==null?void 0:parameters.searchParameters,hash=parameters.hash?parameters.hash.startsWith("#")?parameters.hash:"#"+parameters.hash:"",searhParameters=por?por.startsWith("?")?por:"?"+por:"",pathPlus=`${parameters.pathname}${searhParameters}${hash}`;parameters.action==="push"?this.pushState(pathPlus,parameters.data):parameters.action==="replace"&&this.replaceState(pathPlus,parameters.data)}debugHistory(){console.log("Current history state:"),__privateGet(this,_previousStates).forEach((state,index)=>{console.log(`[${index}]:`,state==null?void 0:state.page)})}};_previousStates=new WeakMap,_popStateHandlers=new WeakMap,_HistoryManager_instances=new WeakSet,setupTracking_fn=__name(function(){window.addEventListener("popstate",__privateMethod(this,_HistoryManager_instances,handlePopState_fn).bind(this)),__privateMethod(this,_HistoryManager_instances,overrideHistoryMethods_fn).call(this)},"#setupTracking"),overrideHistoryMethods_fn=__name(function(){const originalPushState=history.pushState,originalReplaceState=history.replaceState;history.pushState=(state,title,url)=>(__privateMethod(this,_HistoryManager_instances,updateHistory_fn).call(this,state),originalPushState.call(history,state,title,url)),history.replaceState=(state,title,url)=>(__privateMethod(this,_HistoryManager_instances,updateHistory_fn).call(this,state,!0),originalReplaceState.call(history,state,title,url))},"#overrideHistoryMethods"),updateHistory_fn=__name(function(state,isReplace=!1){isReplace&&__privateGet(this,_previousStates).length>0?__privateGet(this,_previousStates)[__privateGet(this,_previousStates).length-1]=state:(__privateGet(this,_previousStates).push(state),__privateGet(this,_previousStates).length>50&&__privateGet(this,_previousStates).shift())},"#updateHistory"),handlePopState_fn=__name(function(event){const targetState=this.getPreviousState(),previousState=this.getCurrentState();targetState&&(__privateGet(this,_previousStates)[__privateGet(this,_previousStates).length-2]=previousState,__privateGet(this,_previousStates)[__privateGet(this,_previousStates).length-1]=targetState),__privateGet(this,_popStateHandlers).forEach(handler=>{handler(__spreadProps(__spreadValues({},event),{state:targetState,previousState}))})},"#handlePopState"),getPathname_fn=__name(function(url){return typeof url=="string"?url:url.pathname},"#getPathname"),__name(_HistoryManager,"HistoryManager");let HistoryManager=_HistoryManager;const historyManager=new HistoryManager;exports.historyManager=historyManager;