aptechka 0.88.11 → 0.88.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ const popstateAllowed = { value: !0 };
2
+ export {
3
+ popstateAllowed as p
4
+ };
@@ -0,0 +1 @@
1
+ "use strict";const popstateAllowed={value:!0};exports.popstateAllowed=popstateAllowed;
@@ -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 intersector_index=require("../index-Cz5-98rw.cjs"),dom=require("../dom-B40i6NXw.cjs"),events=require("../events-UlGk63iC.cjs"),promises=require("../promises-nDm8_iG6.cjs"),scroll=require("../scroll-Dv9QcIKd.cjs");require("construct-style-sheets-polyfill");const url=require("../url-CPCO10Sy.cjs"),cssValueParser_index=require("../css-value-parser/index.cjs"),string=require("../string-Bx5N38JG.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;intersector_index.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=string.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,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,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=string.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(),__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(intersector_index.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,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,{centerScroll,offsetScroll,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,{centerScroll,offsetScroll,behavior:scrollBehaviour})):normalizedURL.hash?(nextRoute.clearScrollState(),__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,normalizedURL.hash,{centerScroll,offsetScroll,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,{scrollElement:__privateGet(this,_currentScrollElement),behavior:(options==null?void 0:options.behavior)||"instant",center:options==null?void 0:options.centerScroll,offset:options==null?void 0:options.offsetScroll})},"#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 intersector_index=require("../index-Cz5-98rw.cjs"),dom=require("../dom-B40i6NXw.cjs"),events=require("../events-UlGk63iC.cjs"),promises=require("../promises-nDm8_iG6.cjs"),scroll=require("../scroll-Dv9QcIKd.cjs");require("construct-style-sheets-polyfill");const url=require("../url-CPCO10Sy.cjs"),cssValueParser_index=require("../css-value-parser/index.cjs"),string=require("../string-Bx5N38JG.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;intersector_index.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=string.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,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,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=string.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(intersector_index.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,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,{centerScroll,offsetScroll,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,{centerScroll,offsetScroll,behavior:scrollBehaviour})):normalizedURL.hash?(nextRoute.clearScrollState(),__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,normalizedURL.hash,{centerScroll,offsetScroll,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,{scrollElement:__privateGet(this,_currentScrollElement),behavior:(options==null?void 0:options.behavior)||"instant",center:options==null?void 0:options.centerScroll,offset:options==null?void 0:options.offsetScroll})},"#tryScrollToElement"),_popStateListener=new WeakMap,_scrollListener=new WeakMap,__name(_Morph,"Morph"),_Morph.instance=null;let Morph=_Morph;exports.Morph=Morph;
@@ -41,6 +41,7 @@ import "construct-style-sheets-polyfill";
41
41
  import { a as normalizeBase, c as changeHistory, d as splitPath } from "../url-CWCY_qe_.js";
42
42
  import { cssValueParser } from "../css-value-parser/index.js";
43
43
  import { c as camelToKebab } from "../string-Ct-dy_cs.js";
44
+ import { p as popstateAllowed } from "../history-BodB82F7.js";
44
45
  const _MorphAnnouncer = class _MorphAnnouncer extends HTMLElement {
45
46
  connectedCallback() {
46
47
  const attrs = {
@@ -340,12 +341,12 @@ const _Morph = class _Morph {
340
341
  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";
341
342
  }, "#checkLink"));
342
343
  __privateAdd(this, _popStateListener, /* @__PURE__ */ __name((event) => __async(this, null, function* () {
343
- event.preventDefault(), __privateSet(this, _isPopstateNavigation, !0), yield this.navigate(location.href.replace(location.origin, ""), {
344
+ event.preventDefault(), popstateAllowed.value && (__privateSet(this, _isPopstateNavigation, !0), yield this.navigate(location.href.replace(location.origin, ""), {
344
345
  historyAction: "none",
345
346
  submorph: __privateGet(this, _lastRevalidate) ? void 0 : __privateGet(this, _lastSubmorph),
346
347
  revalidate: __privateGet(this, _lastRevalidate),
347
348
  keepScrollPosition: __privateGet(this, _lastKeepScrollPosition)
348
- }), __privateSet(this, _isPopstateNavigation, !1);
349
+ }), __privateSet(this, _isPopstateNavigation, !1));
349
350
  }), "#popStateListener"));
350
351
  __privateAdd(this, _scrollListener, /* @__PURE__ */ __name(() => {
351
352
  const { left, top } = this.scrollValue, directionY = top - __privateGet(this, _currentScrollY), directionX = left - __privateGet(this, _currentScrollX);
@@ -33,7 +33,7 @@ export declare class PopoverElement extends HTMLElement {
33
33
  skipTransition?: boolean;
34
34
  trigger?: any;
35
35
  }): void;
36
- close(): void;
36
+ close(back?: boolean): void;
37
37
  protected connectedCallback(): void;
38
38
  protected disconnectedCallback(): void;
39
39
  }
@@ -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-DwPeXyM2.cjs"),elementLinkedStore_index=require("../element-linked-store/index.cjs"),intersector_index=require("../index-Cz5-98rw.cjs"),events=require("../events-UlGk63iC.cjs"),_function=require("../function-H4b_gTg6.cjs"),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()}},"#clickOutsideListener"));__privateAdd(this,_keydownListener,__name(e=>{if(e.code==="Escape"){const lastPopover=[...__privateGet(this,_stack)].reverse().find(el=>el.escape.current);lastPopover&&lastPopover.close()}},"#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,()=>{__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()}),__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(){__privateGet(this,_opened)&&(__privateSet(this,_opened,!1),cancelAnimationFrame(__privateGet(this,_openFrameId)),clearTimeout(__privateGet(this,_openTransitionTimeoutId)),_PopoverElement.stack.remove(__privateGet(this,_group).current,this),__privateMethod(this,_PopoverElement_instances,deleteSearchParam_fn).call(this),__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)))}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;intersector_index.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"));intersector_index.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()}}),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;intersector_index.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-DwPeXyM2.cjs"),elementLinkedStore_index=require("../element-linked-store/index.cjs"),history$1=require("../history-CToz4ary.cjs"),intersector_index=require("../index-Cz5-98rw.cjs"),events=require("../events-UlGk63iC.cjs"),_function=require("../function-H4b_gTg6.cjs"),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;intersector_index.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"));intersector_index.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;intersector_index.isBrowser&&!customElements.get("e-popover-button")&&customElements.define("e-popover-button",PopoverButtonElement);exports.PopoverButtonElement=PopoverButtonElement;exports.PopoverElement=PopoverElement;
@@ -8,6 +8,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
8
8
  import { CSSProperty } from "../css-property/index.js";
9
9
  import { v as viewport } from "../Viewport-9ZphaP_o.js";
10
10
  import { ElementLinkedStore } from "../element-linked-store/index.js";
11
+ import { p as popstateAllowed } from "../history-BodB82F7.js";
11
12
  import { i as isBrowser } from "../index-uJboZXlu.js";
12
13
  import { d as dispatchEvent } from "../events-Ds-TuvYW.js";
13
14
  import { d as debounce } from "../function-UmbPrOHm.js";
@@ -30,13 +31,13 @@ const _PopoverGroups = class _PopoverGroups {
30
31
  ))
31
32
  return;
32
33
  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");
33
- (!containsTarget || outsideTarget) && lastPopover.close();
34
+ (!containsTarget || outsideTarget) && lastPopover.close(!0);
34
35
  }
35
36
  }, "#clickOutsideListener"));
36
37
  __privateAdd(this, _keydownListener, /* @__PURE__ */ __name((e) => {
37
38
  if (e.code === "Escape") {
38
39
  const lastPopover = [...__privateGet(this, _stack)].reverse().find((el) => el.escape.current);
39
- lastPopover && lastPopover.close();
40
+ lastPopover && lastPopover.close(!0);
40
41
  }
41
42
  }, "#keydownListener"));
42
43
  document.documentElement.addEventListener(
@@ -126,8 +127,8 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
126
127
  opened: !1,
127
128
  closing: !1,
128
129
  transitionend: !1
129
- })), __privateSet(this, _innerCloseElements, []), __privateSet(this, _resetScrollElements, []), __privateSet(this, _popStateListener, () => {
130
- __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);
130
+ })), __privateSet(this, _innerCloseElements, []), __privateSet(this, _resetScrollElements, []), __privateSet(this, _popStateListener, (e) => {
131
+ 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
132
  }), __privateSet(this, _resizeListener, () => {
132
133
  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);
133
134
  }), __privateSet(this, _debouncedResize, debounce(() => {
@@ -139,7 +140,7 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
139
140
  rect.right > viewport.width ? viewportOffsetX = viewport.width - rect.right : rect.left < 0 && (viewportOffsetX = rect.left * -1), rect.bottom > viewport.height ? viewportOffsetY = 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");
140
141
  }
141
142
  }), __privateSet(this, _closeElementClickListener, () => {
142
- this.close();
143
+ this.close(!0);
143
144
  }), __privateGet(this, _group).subscribe((e) => {
144
145
  e.previous && (_PopoverElement.stack.remove(e.previous, this), e.current || (document.documentElement.classList.remove(
145
146
  `${this.group.previous}-closing`
@@ -233,9 +234,9 @@ const _PopoverElement = class _PopoverElement extends HTMLElement {
233
234
  }, "opened");
234
235
  options != null && options.skipTransition ? opened() : __privateSet(this, _openFrameId, requestAnimationFrame(opened));
235
236
  }
236
- close() {
237
- __privateGet(this, _opened) && (__privateSet(this, _opened, !1), cancelAnimationFrame(__privateGet(this, _openFrameId)), clearTimeout(__privateGet(this, _openTransitionTimeoutId)), _PopoverElement.stack.remove(__privateGet(this, _group).current, this), __privateMethod(this, _PopoverElement_instances, deleteSearchParam_fn).call(this), __privateSet(this, _startClosingTimeoutId, setTimeout(() => {
238
- __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", {
237
+ close(back) {
238
+ __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(() => {
239
+ 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", {
239
240
  custom: !0,
240
241
  bubbles: !0
241
242
  }), __privateSet(this, _closeTimeoutId, setTimeout(
@@ -308,7 +309,7 @@ const _PopoverButtonElement = class _PopoverButtonElement extends HTMLElement {
308
309
  isBrowser && (this.addEventListener("click", () => {
309
310
  if (__privateGet(this, _popoverElement)) {
310
311
  const type = __privateGet(this, _type).current;
311
- 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();
312
+ 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);
312
313
  }
313
314
  }), this.addEventListener("keydown", (e) => {
314
315
  e.code === "Space" && !this.hasAttribute("keydown-disabled") && (e.preventDefault(), this.click());
@@ -0,0 +1,3 @@
1
+ export declare const popstateAllowed: {
2
+ value: boolean;
3
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aptechka",
3
- "version": "0.88.11",
3
+ "version": "0.88.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/denisavitski/aptechka.git"