aptechka 0.89.4 → 0.90.0

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.
@@ -9,7 +9,7 @@ import { N as NODE_TYPE_ELEMENT } from "./morph-BByLJAAh.js";
9
9
  import "./Store-CAGUSjFX.js";
10
10
  import "./index-DAG0CtYo.js";
11
11
  import "construct-style-sheets-polyfill";
12
- import { n as normalizeURL, i as isLocalUrl } from "./url-CWCY_qe_.js";
12
+ import { n as normalizeURL, i as isLocalUrl } from "./url-IfKLzD5f.js";
13
13
  var _options, _LocalLinks_instances, isElement_fn, processClickEvent_fn, _clickListener;
14
14
  const _LocalLinks = class _LocalLinks {
15
15
  constructor(options) {
@@ -30,7 +30,7 @@ import { Cache } from "../cache/index.js";
30
30
  import "../Store-CAGUSjFX.js";
31
31
  import "../index-DAG0CtYo.js";
32
32
  import "construct-style-sheets-polyfill";
33
- import { s as searchParamsObjectToString } from "../url-CWCY_qe_.js";
33
+ import { s as searchParamsObjectToString } from "../url-IfKLzD5f.js";
34
34
  const cache = new Cache();
35
35
  function apiFetcher(input, options) {
36
36
  return __async(this, null, function* () {
@@ -0,0 +1,97 @@
1
+ var __defProp = Object.defineProperty, __defProps = Object.defineProperties;
2
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
3
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __typeError = (msg) => {
6
+ throw TypeError(msg);
7
+ };
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ __hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);
11
+ if (__getOwnPropSymbols)
12
+ for (var prop of __getOwnPropSymbols(b))
13
+ __propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);
14
+ return a;
15
+ }, __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)), __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
16
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
17
+ 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);
18
+ var _previousStates, _popStateHandlers, _HistoryManager_instances, setupTracking_fn, overrideHistoryMethods_fn, updateHistory_fn, handlePopState_fn;
19
+ const _HistoryManager = class _HistoryManager {
20
+ constructor() {
21
+ __privateAdd(this, _HistoryManager_instances);
22
+ __privateAdd(this, _previousStates);
23
+ __privateAdd(this, _popStateHandlers);
24
+ history.scrollRestoration = "manual", __privateSet(this, _previousStates, [history.state]), __privateSet(this, _popStateHandlers, []), __privateMethod(this, _HistoryManager_instances, setupTracking_fn).call(this);
25
+ }
26
+ getPreviousState() {
27
+ return __privateGet(this, _previousStates).length > 1 ? __privateGet(this, _previousStates)[__privateGet(this, _previousStates).length - 2] : null;
28
+ }
29
+ getCurrentState() {
30
+ return __privateGet(this, _previousStates).length > 0 ? __privateGet(this, _previousStates)[__privateGet(this, _previousStates).length - 1] : null;
31
+ }
32
+ addPopStateHandler(handler, unshift) {
33
+ unshift ? __privateGet(this, _popStateHandlers).unshift(handler) : __privateGet(this, _popStateHandlers).push(handler);
34
+ }
35
+ removePopStateHandler(handler) {
36
+ const index = __privateGet(this, _popStateHandlers).indexOf(handler);
37
+ index > -1 && __privateGet(this, _popStateHandlers).splice(index, 1);
38
+ }
39
+ pushState(page, data) {
40
+ const state = {
41
+ page,
42
+ data,
43
+ timestamp: Date.now()
44
+ };
45
+ history.pushState(state, "", page);
46
+ }
47
+ replaceState(page, data) {
48
+ const state = {
49
+ page,
50
+ data,
51
+ timestamp: Date.now()
52
+ };
53
+ history.replaceState(state, "", page);
54
+ }
55
+ back() {
56
+ history.back();
57
+ }
58
+ forward() {
59
+ history.forward();
60
+ }
61
+ go(delta) {
62
+ history.go(delta);
63
+ }
64
+ // Для Morph. Убрать когда там будут URL
65
+ __change(parameters) {
66
+ if (parameters.action === "none")
67
+ return;
68
+ 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}`;
69
+ parameters.action === "push" ? this.pushState(pathPlus, parameters.data) : parameters.action === "replace" && this.replaceState(pathPlus, parameters.data);
70
+ }
71
+ debugHistory() {
72
+ console.log("Current history state:"), __privateGet(this, _previousStates).forEach((state, index) => {
73
+ console.log(`[${index}]:`, state == null ? void 0 : state.page);
74
+ });
75
+ }
76
+ };
77
+ _previousStates = new WeakMap(), _popStateHandlers = new WeakMap(), _HistoryManager_instances = new WeakSet(), setupTracking_fn = /* @__PURE__ */ __name(function() {
78
+ window.addEventListener("popstate", __privateMethod(this, _HistoryManager_instances, handlePopState_fn).bind(this)), __privateMethod(this, _HistoryManager_instances, overrideHistoryMethods_fn).call(this);
79
+ }, "#setupTracking"), overrideHistoryMethods_fn = /* @__PURE__ */ __name(function() {
80
+ const originalPushState = history.pushState, originalReplaceState = history.replaceState;
81
+ 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));
82
+ }, "#overrideHistoryMethods"), updateHistory_fn = /* @__PURE__ */ __name(function(state, isReplace = !1) {
83
+ 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());
84
+ }, "#updateHistory"), handlePopState_fn = /* @__PURE__ */ __name(function(event) {
85
+ const targetState = event.state, previousState = __privateGet(this, _previousStates).length > 0 ? __privateGet(this, _previousStates)[__privateGet(this, _previousStates).length - 1] : null;
86
+ __privateGet(this, _previousStates).length > 0 && __privateGet(this, _previousStates).pop(), __privateGet(this, _previousStates).push(targetState), __privateGet(this, _popStateHandlers).forEach((handler) => {
87
+ handler(__spreadProps(__spreadValues({}, event), {
88
+ state: targetState,
89
+ previousState
90
+ }));
91
+ });
92
+ }, "#handlePopState"), __name(_HistoryManager, "HistoryManager");
93
+ let HistoryManager = _HistoryManager;
94
+ const historyManager = new HistoryManager();
95
+ export {
96
+ historyManager as h
97
+ };
@@ -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;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)}pushState(page,data){const state={page,data,timestamp:Date.now()};history.pushState(state,"",page)}replaceState(page,data){const state={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=event.state,previousState=__privateGet(this,_previousStates).length>0?__privateGet(this,_previousStates)[__privateGet(this,_previousStates).length-1]:null;__privateGet(this,_previousStates).length>0&&__privateGet(this,_previousStates).pop(),__privateGet(this,_previousStates).push(targetState),__privateGet(this,_popStateHandlers).forEach(handler=>{handler(__spreadProps(__spreadValues({},event),{state:targetState,previousState}))})},"#handlePopState"),__name(_HistoryManager,"HistoryManager");let HistoryManager=_HistoryManager;const historyManager=new HistoryManager;exports.historyManager=historyManager;
@@ -1,4 +1,4 @@
1
- import { L } from "../LocalLinks-DglvO4x9.js";
1
+ import { L } from "../LocalLinks-0fmzhdVd.js";
2
2
  export {
3
3
  L as LocalLinks
4
4
  };
@@ -1,5 +1,6 @@
1
- import { ChangeHistoryAction, ElementOrSelector, ScrollToElementOptions, splitPath } from '../utils';
1
+ import { ElementOrSelector, ScrollToElementOptions, splitPath } from '../utils';
2
2
  import { MorphLink } from './MorphLink';
3
+ import { HistoryManagerChangeAction } from '../shared/historyManager';
3
4
  import { MorphRouteScrollState } from './MorphRoute';
4
5
  export interface MorphOptions {
5
6
  base: string;
@@ -34,7 +35,7 @@ export interface MorphPreprocessorEntry extends MorphNavigationEntry {
34
35
  export type MorphPreprocessor = (entry: MorphPreprocessorEntry) => void;
35
36
  export type MorphPathnameModifier = (pathname: string) => string;
36
37
  export interface MorphNavigateOptions {
37
- historyAction?: ChangeHistoryAction;
38
+ historyAction?: HistoryManagerChangeAction;
38
39
  centerScroll?: boolean;
39
40
  offsetScroll?: number | ElementOrSelector<HTMLElement>;
40
41
  scrollBehaviour?: ScrollBehavior;
@@ -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-BLNEM48A.cjs");require("construct-style-sheets-polyfill");require("../index-BoGx2BWX.cjs");const url=require("../url-CPCO10Sy.cjs"),cssValueParser_index=require("../css-value-parser/index.cjs"),history$1=require("../history-CToz4ary.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*(){event.preventDefault(),history$1.popstateAllowed.value&&(__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(),history.scrollRestoration="manual",addEventListener("popstate",__privateGet(this,_popStateListener)),url.changeHistory({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}setHeaders(path){}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),url.changeHistory({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),url.changeHistory({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-BLNEM48A.cjs");require("construct-style-sheets-polyfill");require("../index-BoGx2BWX.cjs");const url=require("../url-CPCO10Sy.cjs"),cssValueParser_index=require("../css-value-parser/index.cjs"),historyManager=require("../historyManager-C8A99Bvq.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}setHeaders(path){}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;
@@ -39,9 +39,9 @@ import { w as wait } from "../promises-BsIKOEDq.js";
39
39
  import { s as scrollToElement } from "../scroll-BJz9bLZw.js";
40
40
  import "construct-style-sheets-polyfill";
41
41
  import "../index-DAG0CtYo.js";
42
- import { a as normalizeBase, c as changeHistory, d as splitPath } from "../url-CWCY_qe_.js";
42
+ import { a as normalizeBase, c as splitPath } from "../url-IfKLzD5f.js";
43
43
  import { cssValueParser } from "../css-value-parser/index.js";
44
- import { p as popstateAllowed } from "../history-BodB82F7.js";
44
+ import { h as historyManager } from "../historyManager-B21u1HRz.js";
45
45
  const _MorphAnnouncer = class _MorphAnnouncer extends HTMLElement {
46
46
  connectedCallback() {
47
47
  const attrs = {
@@ -343,7 +343,8 @@ const _Morph = class _Morph {
343
343
  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";
344
344
  }, "#checkLink"));
345
345
  __privateAdd(this, _popStateListener, /* @__PURE__ */ __name((event) => __async(this, null, function* () {
346
- event.preventDefault(), popstateAllowed.value && (__privateSet(this, _isPopstateNavigation, !0), yield this.navigate(location.href.replace(location.origin, ""), {
346
+ var _a, _b, _c, _d;
347
+ (_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, ""), {
347
348
  historyAction: "none",
348
349
  submorph: __privateGet(this, _lastRevalidate) ? void 0 : __privateGet(this, _lastSubmorph),
349
350
  revalidate: __privateGet(this, _lastRevalidate),
@@ -390,7 +391,7 @@ const _Morph = class _Morph {
390
391
  ), document.documentElement.setAttribute(
391
392
  "data-current-leaf",
392
393
  normalizedURL.leaf
393
- ), this.findLinks(), this.findParamsDependent(), history.scrollRestoration = "manual", addEventListener("popstate", __privateGet(this, _popStateListener)), changeHistory({
394
+ ), this.findLinks(), this.findParamsDependent(), historyManager.addPopStateHandler(__privateGet(this, _popStateListener)), historyManager.__change({
394
395
  action: "replace",
395
396
  pathname: normalizedURL.pathname,
396
397
  searchParameters: normalizedURL.parameters,
@@ -493,7 +494,7 @@ const _Morph = class _Morph {
493
494
  detail: {
494
495
  detail
495
496
  }
496
- }), ((_c = __privateGet(this, _currentURL)) == null ? void 0 : _c.parameters) !== normalizedURL.parameters && (__privateSet(this, _previousURL, __privateGet(this, _currentURL)), __privateSet(this, _currentURL, normalizedURL), changeHistory({
497
+ }), ((_c = __privateGet(this, _currentURL)) == null ? void 0 : _c.parameters) !== normalizedURL.parameters && (__privateSet(this, _previousURL, __privateGet(this, _currentURL)), __privateSet(this, _currentURL, normalizedURL), historyManager.__change({
497
498
  action: ((_d = __privateGet(this, _currentURL)) == null ? void 0 : _d.hash) !== normalizedURL.hash ? "replace" : historyAction,
498
499
  pathname: normalizedURL.pathname,
499
500
  searchParameters: normalizedURL.parameters,
@@ -623,7 +624,7 @@ const _Morph = class _Morph {
623
624
  ), document.documentElement.setAttribute(
624
625
  "data-current-leaf",
625
626
  normalizedURL.leaf
626
- ), changeHistory({
627
+ ), historyManager.__change({
627
628
  action: historyAction,
628
629
  pathname: normalizedURL.pathname,
629
630
  searchParameters: normalizedURL.parameters || (keepSearchParameters ? location.search : ""),
@@ -13,6 +13,7 @@ export interface PopoverEvents {
13
13
  export declare class PopoverElement extends HTMLElement {
14
14
  #private;
15
15
  private static stack;
16
+ private static popoverHistoryTransactionsDepth;
16
17
  urlValue: string;
17
18
  constructor();
18
19
  get openClass(): string | null;
@@ -34,6 +35,8 @@ export declare class PopoverElement extends HTMLElement {
34
35
  trigger?: any;
35
36
  }): void;
36
37
  close(back?: boolean): void;
38
+ private beginHistoryTransaction;
39
+ private endHistoryTransaction;
37
40
  protected connectedCallback(): void;
38
41
  protected disconnectedCallback(): void;
39
42
  }
@@ -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"),history$1=require("../history-CToz4ary.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-CPCO10Sy.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,_historyAllowed,_lastTrigger,_status,_innerCloseElements,_resetScrollElements,_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,_historyAllowed);__privateAdd(this,_lastTrigger);__privateAdd(this,_status);__privateAdd(this,_innerCloseElements);__privateAdd(this,_resetScrollElements);__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,_historyAllowed,!0),__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,_popStateListener,e=>{e.preventDefault(),history$1.popstateAllowed.value&&(__privateSet(this,_historyAllowed,!1),__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}),__privateSet(this,_historyAllowed,!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&&__privateGet(this,_historyAllowed)&&history.pushState(history.state,"",__privateGet(this,_PopoverElement_instances,path_get)),__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),history$1.popstateAllowed.value=!1,back?history.back():__privateMethod(this,_PopoverElement_instances,deleteSearchParam_fn).call(this),__privateSet(this,_startClosingTimeoutId,setTimeout(()=>{history$1.popstateAllowed.value=!0,__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)))}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"),addEventListener("popstate",__privateGet(this,_popStateListener)),setTimeout(()=>{__privateGet(this,_restore).current?(__privateSet(this,_historyAllowed,!1),this.urlValue=url.parseSearchParameters(location.search)[this.id],location.search.includes(this.id)&&this.open({trigger:this.idWithValue}),__privateSet(this,_historyAllowed,!0)):(__privateMethod(this,_PopoverElement_instances,deleteSearchParam_fn).call(this),__privateSet(this,_historyAllowed,!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)),removeEventListener("popstate",__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,_historyAllowed=new WeakMap,_lastTrigger=new WeakMap,_status=new WeakMap,_innerCloseElements=new WeakMap,_resetScrollElements=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),history.replaceState(history.state,"",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;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-C8A99Bvq.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-CPCO10Sy.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,14 +8,14 @@ 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 { p as popstateAllowed } from "../history-BodB82F7.js";
11
+ import { h as historyManager } from "../historyManager-B21u1HRz.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";
15
15
  import "../index-DAG0CtYo.js";
16
16
  import { g as getElementTransitionDurationMS } from "../style-DBoQWK0d.js";
17
17
  import "construct-style-sheets-polyfill";
18
- import { u as updateSearchParameter, p as parseSearchParameters } from "../url-CWCY_qe_.js";
18
+ import { u as updateSearchParameter, p as parseSearchParameters } from "../url-IfKLzD5f.js";
19
19
  import { windowResizer } from "../window-resizer/index.js";
20
20
  var _groups, _stack, _clickOutsideListener, _keydownListener;
21
21
  const _PopoverGroups = class _PopoverGroups {
@@ -89,7 +89,7 @@ const _PopoverGroups = class _PopoverGroups {
89
89
  };
90
90
  _groups = new WeakMap(), _stack = new WeakMap(), _clickOutsideListener = new WeakMap(), _keydownListener = new WeakMap(), __name(_PopoverGroups, "PopoverGroups");
91
91
  let PopoverGroups = _PopoverGroups;
92
- var _opened, _startClosingTimeoutId, _closeTimeoutId, _openFrameId, _openTransitionTimeoutId, _history, _restore, _dispatchResize, _closeRest, _closeRestInGroup, _group, _clickOutside, _escape, _checkViewportBounds, _historyAllowed, _lastTrigger, _status, _innerCloseElements, _resetScrollElements, _PopoverElement_instances, path_get, toggleGlobalClass_fn, deleteSearchParam_fn, _popStateListener, _resizeListener, _debouncedResize, _resize, _closeElementClickListener;
92
+ 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;
93
93
  const _PopoverElement = class _PopoverElement extends HTMLElement {
94
94
  constructor() {
95
95
  super();
@@ -108,11 +108,11 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
108
108
  __privateAdd(this, _clickOutside);
109
109
  __privateAdd(this, _escape);
110
110
  __privateAdd(this, _checkViewportBounds);
111
- __privateAdd(this, _historyAllowed);
112
111
  __privateAdd(this, _lastTrigger);
113
112
  __privateAdd(this, _status);
114
113
  __privateAdd(this, _innerCloseElements);
115
114
  __privateAdd(this, _resetScrollElements);
115
+ __privateAdd(this, _isFromPopState);
116
116
  __privateAdd(this, _popStateListener);
117
117
  __privateAdd(this, _resizeListener);
118
118
  __privateAdd(this, _debouncedResize);
@@ -122,14 +122,16 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
122
122
  this,
123
123
  "--close-rest-in-group",
124
124
  !1
125
- )), __privateSet(this, _group, new CSSProperty(this, "--group", "")), __privateSet(this, _clickOutside, new CSSProperty(this, "--click-outside", !1)), __privateSet(this, _escape, new CSSProperty(this, "--escape", !1)), __privateSet(this, _checkViewportBounds, new CSSProperty(this, "--check-viewport-bounds", !1)), __privateSet(this, _historyAllowed, !0), __privateSet(this, _status, new ElementLinkedStore(this, {
125
+ )), __privateSet(this, _group, new CSSProperty(this, "--group", "")), __privateSet(this, _clickOutside, new CSSProperty(this, "--click-outside", !1)), __privateSet(this, _escape, new CSSProperty(this, "--escape", !1)), __privateSet(this, _checkViewportBounds, new CSSProperty(this, "--check-viewport-bounds", !1)), __privateSet(this, _status, new ElementLinkedStore(this, {
126
126
  triggered: !1,
127
127
  beforeopen: !1,
128
128
  opened: !1,
129
129
  closing: !1,
130
130
  transitionend: !1
131
- })), __privateSet(this, _innerCloseElements, []), __privateSet(this, _resetScrollElements, []), __privateSet(this, _popStateListener, (e) => {
132
- e.preventDefault(), popstateAllowed.value && (__privateSet(this, _historyAllowed, !1), __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 }), __privateSet(this, _historyAllowed, !0));
131
+ })), __privateSet(this, _innerCloseElements, []), __privateSet(this, _resetScrollElements, []), __privateSet(this, _isFromPopState, !1), __privateSet(this, _popStateListener, () => {
132
+ _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(() => {
133
+ __privateSet(this, _isFromPopState, !1);
134
+ }, 0));
133
135
  }), __privateSet(this, _resizeListener, () => {
134
136
  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);
135
137
  }), __privateSet(this, _debouncedResize, debounce(() => {
@@ -212,7 +214,7 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
212
214
  detail: {
213
215
  trigger: __privateGet(this, _lastTrigger)
214
216
  }
215
- }), __privateGet(this, _history).current && __privateGet(this, _historyAllowed) && history.pushState(history.state, "", __privateGet(this, _PopoverElement_instances, path_get)), __privateGet(this, _status).set("beforeopen", !0), __privateSet(this, _opened, !0);
217
+ }), __privateGet(this, _history).current && (this.beginHistoryTransaction(), __privateGet(this, _isFromPopState) || historyManager.pushState(__privateGet(this, _PopoverElement_instances, path_get), { popover: !0 }), this.endHistoryTransaction()), __privateGet(this, _status).set("beforeopen", !0), __privateSet(this, _opened, !0);
216
218
  const opened = /* @__PURE__ */ __name(() => {
217
219
  _PopoverElement.stack.add(__privateGet(this, _group).current, this), __privateGet(this, _resetScrollElements).forEach((el) => {
218
220
  el.scroll({
@@ -236,8 +238,8 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
236
238
  options != null && options.skipTransition ? opened() : __privateSet(this, _openFrameId, requestAnimationFrame(opened));
237
239
  }
238
240
  close(back) {
239
- __privateGet(this, _opened) && (__privateSet(this, _opened, !1), cancelAnimationFrame(__privateGet(this, _openFrameId)), clearTimeout(__privateGet(this, _openTransitionTimeoutId)), _PopoverElement.stack.remove(__privateGet(this, _group).current, this), popstateAllowed.value = !1, back ? history.back() : __privateMethod(this, _PopoverElement_instances, deleteSearchParam_fn).call(this), __privateSet(this, _startClosingTimeoutId, setTimeout(() => {
240
- popstateAllowed.value = !0, __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), dispatchEvent(this, "popoverClosing", {
241
+ __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.back() : __privateMethod(this, _PopoverElement_instances, deleteSearchParam_fn).call(this), this.endHistoryTransaction()), __privateSet(this, _startClosingTimeoutId, setTimeout(() => {
242
+ __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), dispatchEvent(this, "popoverClosing", {
241
243
  custom: !0,
242
244
  bubbles: !0
243
245
  }), __privateSet(this, _closeTimeoutId, setTimeout(
@@ -251,6 +253,14 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
251
253
  ));
252
254
  }, 10)));
253
255
  }
256
+ beginHistoryTransaction() {
257
+ _PopoverElement.popoverHistoryTransactionsDepth++;
258
+ }
259
+ endHistoryTransaction() {
260
+ setTimeout(() => {
261
+ _PopoverElement.popoverHistoryTransactionsDepth--;
262
+ }, 0);
263
+ }
254
264
  connectedCallback() {
255
265
  __privateSet(this, _innerCloseElements, [
256
266
  ...this.querySelectorAll(
@@ -262,8 +272,10 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
262
272
  ...this.querySelectorAll(
263
273
  `[data-popover-reset-scroll${this.id ? `="${this.id}"` : ""}]`
264
274
  )
265
- ]), __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"), addEventListener("popstate", __privateGet(this, _popStateListener)), setTimeout(() => {
266
- __privateGet(this, _restore).current ? (__privateSet(this, _historyAllowed, !1), this.urlValue = parseSearchParameters(location.search)[this.id], location.search.includes(this.id) && this.open({ trigger: this.idWithValue }), __privateSet(this, _historyAllowed, !0)) : (__privateMethod(this, _PopoverElement_instances, deleteSearchParam_fn).call(this), __privateSet(this, _historyAllowed, !0));
275
+ ]), __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.addPopStateHandler(__privateGet(this, _popStateListener), !0), setTimeout(() => {
276
+ __privateSet(this, _isFromPopState, !0), __privateGet(this, _restore).current ? (this.urlValue = parseSearchParameters(location.search)[this.id], location.search.includes(this.id) && this.open({ trigger: this.idWithValue })) : __privateMethod(this, _PopoverElement_instances, deleteSearchParam_fn).call(this), setTimeout(() => {
277
+ __privateSet(this, _isFromPopState, !1);
278
+ }, 0);
267
279
  }, 0), __privateGet(this, _checkViewportBounds).subscribe(() => {
268
280
  __privateGet(this, _resizeListener).call(this);
269
281
  }), windowResizer.subscribe(__privateGet(this, _resizeListener));
@@ -271,10 +283,10 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
271
283
  disconnectedCallback() {
272
284
  __privateGet(this, _innerCloseElements).forEach((el) => {
273
285
  el.removeEventListener("click", __privateGet(this, _closeElementClickListener));
274
- }), _PopoverElement.stack.remove(__privateGet(this, _group).current, this), 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)), removeEventListener("popstate", __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);
286
+ }), _PopoverElement.stack.remove(__privateGet(this, _group).current, this), 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.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);
275
287
  }
276
288
  };
277
- _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(), _historyAllowed = new WeakMap(), _lastTrigger = new WeakMap(), _status = new WeakMap(), _innerCloseElements = new WeakMap(), _resetScrollElements = new WeakMap(), _PopoverElement_instances = new WeakSet(), path_get = /* @__PURE__ */ __name(function() {
289
+ _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 = /* @__PURE__ */ __name(function() {
278
290
  return `${location.pathname}${location.search ? location.search + "&" : "?"}${this.idWithValue}`;
279
291
  }, "#path"), toggleGlobalClass_fn = /* @__PURE__ */ __name(function(on, className) {
280
292
  className && className.split(" ").map((v) => {
@@ -283,9 +295,9 @@ _opened = new WeakMap(), _startClosingTimeoutId = new WeakMap(), _closeTimeoutId
283
295
  }, "#toggleGlobalClass"), deleteSearchParam_fn = /* @__PURE__ */ __name(function() {
284
296
  if (__privateGet(this, _history).current) {
285
297
  const url = new URL(location.href);
286
- url.searchParams.delete(this.id), history.replaceState(history.state, "", url.href);
298
+ url.searchParams.delete(this.id), historyManager.replaceState(url.href);
287
299
  }
288
- }, "#deleteSearchParam"), _popStateListener = new WeakMap(), _resizeListener = new WeakMap(), _debouncedResize = new WeakMap(), _resize = new WeakMap(), _closeElementClickListener = new WeakMap(), __name(_PopoverElement, "PopoverElement"), _PopoverElement.stack = new PopoverGroups();
300
+ }, "#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;
289
301
  let PopoverElement = _PopoverElement;
290
302
  isBrowser && !customElements.get("e-popover") && customElements.define("e-popover", PopoverElement);
291
303
  var _popoverElement, _type, _PopoverButtonElement_instances, unlistenPopover_fn, _popoverTriggeredListener, _popoverOpenedListener, _popoverClosingListener, _popoverClosedListener, updateType_fn;
@@ -40,13 +40,13 @@ 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-DglvO4x9.js";
43
+ import { L as LocalLinks } from "../LocalLinks-0fmzhdVd.js";
44
44
  import { P as PageAnnouncerElement } from "../PageAnnouncerElement-Bqbv_gWM.js";
45
45
  import { P as PageScroll } from "../PageScroll-C68YZXHb.js";
46
46
  import "../Store-CAGUSjFX.js";
47
47
  import "../index-DAG0CtYo.js";
48
48
  import "construct-style-sheets-polyfill";
49
- import { a as normalizeBase, n as normalizeURL } from "../url-CWCY_qe_.js";
49
+ import { a as normalizeBase, n as normalizeURL } from "../url-IfKLzD5f.js";
50
50
  import { URLPattern as URLPattern$1 } from "urlpattern-polyfill";
51
51
  import { r as render } from "../render-CpcwTFhp.js";
52
52
  import { i as isESClass } from "../object-CiIdEmJx.js";
@@ -0,0 +1,35 @@
1
+ export interface HistoryManagerState {
2
+ page: string;
3
+ data?: Record<string, unknown>;
4
+ timestamp?: number;
5
+ }
6
+ export interface HistoryManagerChangeParameters {
7
+ action: HistoryManagerChangeAction;
8
+ pathname: string;
9
+ searchParameters?: string | undefined;
10
+ hash?: string | undefined;
11
+ data?: Record<string, unknown>;
12
+ }
13
+ export type HistoryManagerChangeAction = 'replace' | 'push' | 'none';
14
+ export interface HistoryManagerPopStateEvent extends PopStateEvent {
15
+ state: HistoryManagerState | null;
16
+ previousState: HistoryManagerState | null;
17
+ }
18
+ type PopStateHandler = (event: HistoryManagerPopStateEvent) => void;
19
+ declare class HistoryManager {
20
+ #private;
21
+ constructor();
22
+ getPreviousState(): HistoryManagerState | null;
23
+ getCurrentState(): HistoryManagerState | null;
24
+ addPopStateHandler(handler: PopStateHandler, unshift?: boolean): void;
25
+ removePopStateHandler(handler: PopStateHandler): void;
26
+ pushState(page: string, data?: Record<string, unknown>): void;
27
+ replaceState(page: string, data?: Record<string, unknown>): void;
28
+ back(): void;
29
+ forward(): void;
30
+ go(delta: number): void;
31
+ __change(parameters: HistoryManagerChangeParameters): void;
32
+ debugHistory(): void;
33
+ }
34
+ export declare const historyManager: HistoryManager;
35
+ export {};
package/lib/spa/index.js CHANGED
@@ -41,7 +41,7 @@ var __async = (__this, __arguments, generator) => new Promise((resolve, reject)
41
41
  });
42
42
  import { Cache } from "../cache/index.js";
43
43
  import { History } from "../history/index.js";
44
- import { L as LocalLinks } from "../LocalLinks-DglvO4x9.js";
44
+ import { L as LocalLinks } from "../LocalLinks-0fmzhdVd.js";
45
45
  import { P as PageAnnouncerElement } from "../PageAnnouncerElement-Bqbv_gWM.js";
46
46
  import { P as PageScroll } from "../PageScroll-C68YZXHb.js";
47
47
  import { d as dispatchEvent } from "../events-Ds-TuvYW.js";
@@ -49,7 +49,7 @@ import { m as morph } from "../morph-BByLJAAh.js";
49
49
  import "../Store-CAGUSjFX.js";
50
50
  import "../index-DAG0CtYo.js";
51
51
  import "construct-style-sheets-polyfill";
52
- import { a as normalizeBase, n as normalizeURL, b as normalizeRelativeURLs } from "../url-CWCY_qe_.js";
52
+ import { a as normalizeBase, n as normalizeURL, b as normalizeRelativeURLs } from "../url-IfKLzD5f.js";
53
53
  var _cache, _domParser, _options, _scroll, _links, _history, _announcerElement, _updateId;
54
54
  const _SPA = class _SPA {
55
55
  constructor(options) {
@@ -113,8 +113,8 @@ __name(searchParamsToObject, "searchParamsToObject");
113
113
  export {
114
114
  normalizeBase as a,
115
115
  normalizeRelativeURLs as b,
116
- changeHistory as c,
117
- splitPath as d,
116
+ splitPath as c,
117
+ changeHistory as d,
118
118
  searchParamsToObject as e,
119
119
  isLocalUrl as i,
120
120
  normalizeURL as n,
@@ -25,7 +25,7 @@ import { w as w2 } from "../promises-BsIKOEDq.js";
25
25
  import { s as s6 } from "../scroll-BJz9bLZw.js";
26
26
  import { g as g8, a as a9 } from "../style-DBoQWK0d.js";
27
27
  import { i as intersector, t as ticker } from "../index-DAG0CtYo.js";
28
- import { c as c11, i as i7, a as a10, b as b10, n as n4, p as p6, s as s7, e as e7, d as d10, u as u2 } from "../url-CWCY_qe_.js";
28
+ import { d as d10, i as i7, a as a10, b as b10, n as n4, p as p6, s as s7, e as e7, c as c11, u as u2 } from "../url-IfKLzD5f.js";
29
29
  function insert(arr, index, ...newItems) {
30
30
  return [...arr.slice(0, index), ...newItems, ...arr.slice(index)];
31
31
  }
@@ -295,7 +295,7 @@ export {
295
295
  f5 as calculateDistanceWithRadius,
296
296
  c as camelToKebab,
297
297
  b2 as capitalize,
298
- c11 as changeHistory,
298
+ d10 as changeHistory,
299
299
  c8 as clamp,
300
300
  c10 as cloneDeep,
301
301
  cloneTemplateContent,
@@ -403,7 +403,7 @@ export {
403
403
  b6 as smootherstep,
404
404
  a6 as smoothstep,
405
405
  s as snakeToDotted,
406
- d10 as splitPath,
406
+ c11 as splitPath,
407
407
  splitPropgress,
408
408
  s5 as step,
409
409
  s4 as styleToString,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aptechka",
3
- "version": "0.89.4",
3
+ "version": "0.90.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/denisavitski/aptechka.git"
@@ -1,4 +0,0 @@
1
- const popstateAllowed = { value: !0 };
2
- export {
3
- popstateAllowed as p
4
- };
@@ -1 +0,0 @@
1
- "use strict";const popstateAllowed={value:!0};exports.popstateAllowed=popstateAllowed;
@@ -1,3 +0,0 @@
1
- export declare const popstateAllowed: {
2
- value: boolean;
3
- };