aptechka 0.92.3 → 0.92.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api-fetcher/index.cjs +1 -1
- package/lib/api-fetcher/index.d.ts +4 -0
- package/lib/api-fetcher/index.js +49 -28
- package/lib/{layout-BL6AX9-r.js → layout-DxOCR4qe.js} +5 -5
- package/lib/layout-box/index.cjs +1 -1
- package/lib/layout-box/index.js +1 -1
- package/lib/{layout-CnGLl7oe.cjs → layout-rR4-aYTY.cjs} +1 -1
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +1 -1
- package/lib/scroll/index.cjs +1 -1
- package/lib/scroll/index.js +1 -1
- package/lib/{scroll-IQwW3E-B.js → scroll-CqF_88wv.js} +1 -1
- package/lib/{scroll-DfvKl-On.cjs → scroll-DbYCgAnW.cjs} +1 -1
- package/lib/scroll-kit/index.cjs +1 -1
- package/lib/scroll-kit/index.js +2 -2
- package/lib/utils/index.cjs +1 -1
- package/lib/utils/index.js +2 -2
- package/package.json +1 -1
|
@@ -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 __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 __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const cache_index=require("../cache/index.cjs");require("../Store-B96mD8mD.cjs");require("../index-BoGx2BWX.cjs");require("construct-style-sheets-polyfill");const url=require("../url-D0rESDQq.cjs"),
|
|
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 __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 __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const cache_index=require("../cache/index.cjs");require("../Store-B96mD8mD.cjs");require("../index-BoGx2BWX.cjs");require("construct-style-sheets-polyfill");const url=require("../url-D0rESDQq.cjs"),apiFetcherCache=new cache_index.Cache,pendingRequests=new Map;function apiFetcherClearPendingRequests(){pendingRequests.clear()}__name(apiFetcherClearPendingRequests,"apiFetcherClearPendingRequests");function apiFetcherGetPendingRequestsCount(){return pendingRequests.size}__name(apiFetcherGetPendingRequestsCount,"apiFetcherGetPendingRequestsCount");function apiFetcher(input,options){return __async(this,null,function*(){var _a,_b;const startTime=Date.now(),baseResult={data:null,error:null,status:"unknown",headers:new Headers};try{let url$1=input;if(options!=null&&options.params){const params=url.searchParamsObjectToString(options.params);if(params){const separator=url$1.includes("?")?"&":"?";url$1+=`${separator}${params}`}}const cacheKey=(_a=options==null?void 0:options.cacheKey)!=null?_a:url$1,cacheTTL=(_b=options==null?void 0:options.cacheTTLMinutes)!=null?_b:0,cacheAllowed=cacheTTL>0;if((options!=null&&options.forceClearCache||globalThis.forceClearCache)&&(apiFetcherCache.delete(cacheKey),pendingRequests.delete(cacheKey)),cacheAllowed){const cached=apiFetcherCache.get(cacheKey);if(cached)return __spreadProps(__spreadValues({},baseResult),{data:cached,cached:!0,status:"success",time:Date.now()-startTime})}const pendingRequest=pendingRequests.get(cacheKey);if(pendingRequest)return pendingRequest;const requestPromise=__async(this,null,function*(){try{const response=yield fetch(url$1,options==null?void 0:options.init);if(!response.ok){const errorText=yield response.text();return __spreadProps(__spreadValues({},baseResult),{error:errorText,status:"error",time:Date.now()-startTime,headers:response.headers})}const contentType=response.headers.get("content-type");if(!(contentType!=null&&contentType.includes("application/json")))return __spreadProps(__spreadValues({},baseResult),{error:"Endpoint did not return JSON",status:"error",time:Date.now()-startTime,headers:response.headers});const jsonData=yield response.json();return cacheAllowed&&apiFetcherCache.set(cacheKey,jsonData,cacheTTL),__spreadProps(__spreadValues({},baseResult),{data:jsonData,status:"success",time:Date.now()-startTime,headers:response.headers})}finally{pendingRequests.delete(cacheKey)}});return pendingRequests.set(cacheKey,requestPromise),yield requestPromise}catch(error){const errorMessage=error instanceof Error?error.message:String(error);return __spreadProps(__spreadValues({},baseResult),{error:errorMessage,status:"error",time:Date.now()-startTime})}})}__name(apiFetcher,"apiFetcher");exports.apiFetcher=apiFetcher;exports.apiFetcherCache=apiFetcherCache;exports.apiFetcherClearPendingRequests=apiFetcherClearPendingRequests;exports.apiFetcherGetPendingRequestsCount=apiFetcherGetPendingRequestsCount;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Cache } from '../cache';
|
|
1
2
|
export interface IAPIFetcherOptions<Params extends object = {}> {
|
|
2
3
|
init?: RequestInit;
|
|
3
4
|
cacheKey?: string;
|
|
@@ -13,4 +14,7 @@ export interface IAPIResponseJSON<T = null> {
|
|
|
13
14
|
cached?: boolean;
|
|
14
15
|
headers: Headers;
|
|
15
16
|
}
|
|
17
|
+
export declare const apiFetcherCache: Cache;
|
|
18
|
+
export declare function apiFetcherClearPendingRequests(): void;
|
|
19
|
+
export declare function apiFetcherGetPendingRequestsCount(): number;
|
|
16
20
|
export declare function apiFetcher<Params extends object = {}, Result = any>(input: string, options?: IAPIFetcherOptions<Params>): Promise<IAPIResponseJSON<Result>>;
|
package/lib/api-fetcher/index.js
CHANGED
|
@@ -31,7 +31,15 @@ import "../Store-CAGUSjFX.js";
|
|
|
31
31
|
import "../index-DAG0CtYo.js";
|
|
32
32
|
import "construct-style-sheets-polyfill";
|
|
33
33
|
import { s as searchParamsObjectToString } from "../url-DTxLpq5m.js";
|
|
34
|
-
const
|
|
34
|
+
const apiFetcherCache = new Cache(), pendingRequests = /* @__PURE__ */ new Map();
|
|
35
|
+
function apiFetcherClearPendingRequests() {
|
|
36
|
+
pendingRequests.clear();
|
|
37
|
+
}
|
|
38
|
+
__name(apiFetcherClearPendingRequests, "apiFetcherClearPendingRequests");
|
|
39
|
+
function apiFetcherGetPendingRequestsCount() {
|
|
40
|
+
return pendingRequests.size;
|
|
41
|
+
}
|
|
42
|
+
__name(apiFetcherGetPendingRequestsCount, "apiFetcherGetPendingRequestsCount");
|
|
35
43
|
function apiFetcher(input, options) {
|
|
36
44
|
return __async(this, null, function* () {
|
|
37
45
|
var _a, _b;
|
|
@@ -51,8 +59,8 @@ function apiFetcher(input, options) {
|
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
61
|
const cacheKey = (_a = options == null ? void 0 : options.cacheKey) != null ? _a : url, cacheTTL = (_b = options == null ? void 0 : options.cacheTTLMinutes) != null ? _b : 0, cacheAllowed = cacheTTL > 0;
|
|
54
|
-
if ((options != null && options.forceClearCache || globalThis.forceClearCache) &&
|
|
55
|
-
const cached =
|
|
62
|
+
if ((options != null && options.forceClearCache || globalThis.forceClearCache) && (apiFetcherCache.delete(cacheKey), pendingRequests.delete(cacheKey)), cacheAllowed) {
|
|
63
|
+
const cached = apiFetcherCache.get(cacheKey);
|
|
56
64
|
if (cached)
|
|
57
65
|
return __spreadProps(__spreadValues({}, baseResult), {
|
|
58
66
|
data: cached,
|
|
@@ -61,31 +69,41 @@ function apiFetcher(input, options) {
|
|
|
61
69
|
time: Date.now() - startTime
|
|
62
70
|
});
|
|
63
71
|
}
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
72
|
+
const pendingRequest = pendingRequests.get(cacheKey);
|
|
73
|
+
if (pendingRequest)
|
|
74
|
+
return pendingRequest;
|
|
75
|
+
const requestPromise = __async(this, null, function* () {
|
|
76
|
+
try {
|
|
77
|
+
const response = yield fetch(url, options == null ? void 0 : options.init);
|
|
78
|
+
if (!response.ok) {
|
|
79
|
+
const errorText = yield response.text();
|
|
80
|
+
return __spreadProps(__spreadValues({}, baseResult), {
|
|
81
|
+
error: errorText,
|
|
82
|
+
status: "error",
|
|
83
|
+
time: Date.now() - startTime,
|
|
84
|
+
headers: response.headers
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const contentType = response.headers.get("content-type");
|
|
88
|
+
if (!(contentType != null && contentType.includes("application/json")))
|
|
89
|
+
return __spreadProps(__spreadValues({}, baseResult), {
|
|
90
|
+
error: "Endpoint did not return JSON",
|
|
91
|
+
status: "error",
|
|
92
|
+
time: Date.now() - startTime,
|
|
93
|
+
headers: response.headers
|
|
94
|
+
});
|
|
95
|
+
const jsonData = yield response.json();
|
|
96
|
+
return cacheAllowed && apiFetcherCache.set(cacheKey, jsonData, cacheTTL), __spreadProps(__spreadValues({}, baseResult), {
|
|
97
|
+
data: jsonData,
|
|
98
|
+
status: "success",
|
|
99
|
+
time: Date.now() - startTime,
|
|
100
|
+
headers: response.headers
|
|
101
|
+
});
|
|
102
|
+
} finally {
|
|
103
|
+
pendingRequests.delete(cacheKey);
|
|
104
|
+
}
|
|
88
105
|
});
|
|
106
|
+
return pendingRequests.set(cacheKey, requestPromise), yield requestPromise;
|
|
89
107
|
} catch (error) {
|
|
90
108
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
91
109
|
return __spreadProps(__spreadValues({}, baseResult), {
|
|
@@ -98,5 +116,8 @@ function apiFetcher(input, options) {
|
|
|
98
116
|
}
|
|
99
117
|
__name(apiFetcher, "apiFetcher");
|
|
100
118
|
export {
|
|
101
|
-
apiFetcher
|
|
119
|
+
apiFetcher,
|
|
120
|
+
apiFetcherCache,
|
|
121
|
+
apiFetcherClearPendingRequests,
|
|
122
|
+
apiFetcherGetPendingRequestsCount
|
|
102
123
|
};
|
|
@@ -17,11 +17,11 @@ function getCumulativeOffsetTop(target, stopElement) {
|
|
|
17
17
|
}
|
|
18
18
|
__name(getCumulativeOffsetTop, "getCumulativeOffsetTop");
|
|
19
19
|
function getStickyOffset(el, type) {
|
|
20
|
-
const
|
|
21
|
-
let
|
|
22
|
-
for (;
|
|
23
|
-
window.getComputedStyle(
|
|
24
|
-
return
|
|
20
|
+
const stickyElements = [];
|
|
21
|
+
let currentElement = el;
|
|
22
|
+
for (; currentElement; )
|
|
23
|
+
window.getComputedStyle(currentElement).position === "sticky" && stickyElements.push(currentElement), currentElement = currentElement.parentElement;
|
|
24
|
+
return stickyElements.reduce(
|
|
25
25
|
(p, c) => p + (type === "top" ? c.offsetTop : c.offsetLeft),
|
|
26
26
|
0
|
|
27
27
|
);
|
package/lib/layout-box/index.cjs
CHANGED
|
@@ -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 cssUnitParser_index=require("../css-unit-parser/index.cjs"),elementResizer_index=require("../element-resizer/index.cjs"),ladder_index=require("../ladder/index.cjs"),notifier_index=require("../notifier/index.cjs"),order_index=require("../order/index.cjs"),scrollEntries_index=require("../scroll-entries/index.cjs"),ticker_index=require("../index-BoGx2BWX.cjs"),Store=require("../Store-B96mD8mD.cjs"),dom=require("../dom-B40i6NXw.cjs"),layout=require("../layout-CnGLl7oe.cjs");require("construct-style-sheets-polyfill");const windowResizer_index=require("../window-resizer/index.cjs");function decomposeCSSMatrix(matrix){const scaleX=Math.sqrt(matrix.m11*matrix.m11+matrix.m12*matrix.m12+matrix.m13*matrix.m13),scaleY=Math.sqrt(matrix.m21*matrix.m21+matrix.m22*matrix.m22+matrix.m23*matrix.m23),scaleZ=Math.sqrt(matrix.m31*matrix.m31+matrix.m32*matrix.m32+matrix.m33*matrix.m33),rotationX=Math.atan2(matrix.m32,matrix.m33),rotationY=Math.atan2(-matrix.m31,Math.sqrt(matrix.m32*matrix.m32+matrix.m33*matrix.m33)),rotationZ=Math.atan2(matrix.m21,matrix.m11),translationX=matrix.m41,translationY=matrix.m42*-1,translationZ=matrix.m43;return{scaleX,scaleY,scaleZ,rotationX,rotationY,rotationZ,translationX,translationY,translationZ}}__name(decomposeCSSMatrix,"decomposeCSSMatrix");var _element,_containerElement,_scrollStepSetterCallbacks,_scrollAxis,_frontSide,_isCartesian,_isSizeStep,_isPositionStep,_isTransformStep,_isScrollStep,_width,_height,_depth,_top,_left,_front,_x,_y,_z,_CSSTranslation,_CSSRotation,_CSSScale,_rotation,_position,_scale,_scrollValue,_scrollEntries,_resizeNotifier,_LayoutBox_instances,recalculate_fn,composeSteps_fn,updateDimensions_fn,updateScrollPosition_fn,_resizeListener,_tickListener,_scrollEntriesListener;const _LayoutBox=class _LayoutBox{constructor(element,options){__privateAdd(this,_LayoutBox_instances);__privateAdd(this,_element,null);__privateAdd(this,_containerElement,null);__privateAdd(this,_scrollStepSetterCallbacks,[]);__privateAdd(this,_scrollAxis,"auto");__privateAdd(this,_frontSide,"top");__privateAdd(this,_isCartesian,!1);__privateAdd(this,_isSizeStep,!0);__privateAdd(this,_isPositionStep,!0);__privateAdd(this,_isTransformStep,!0);__privateAdd(this,_isScrollStep,!0);__privateAdd(this,_width,0);__privateAdd(this,_height,0);__privateAdd(this,_depth,0);__privateAdd(this,_top,0);__privateAdd(this,_left,0);__privateAdd(this,_front,0);__privateAdd(this,_x,0);__privateAdd(this,_y,0);__privateAdd(this,_z,0);__privateAdd(this,_CSSTranslation,{x:0,y:0,z:0});__privateAdd(this,_CSSRotation,{x:0,y:0,z:0});__privateAdd(this,_CSSScale,{x:1,y:1,z:1});__privateAdd(this,_rotation,new ladder_index.Ladder({x:0,y:0,z:0}));__privateAdd(this,_position,new ladder_index.Ladder({x:0,y:0,z:0}));__privateAdd(this,_scale,new ladder_index.Ladder({x:0,y:0,z:0}));__privateAdd(this,_scrollValue,{x:0,y:0,z:0});__privateAdd(this,_scrollEntries,new Map);__privateAdd(this,_resizeNotifier,new notifier_index.Notifier);__privateAdd(this,_resizeListener,__name(()=>{Store.isBrowser&&__privateMethod(this,_LayoutBox_instances,updateDimensions_fn).call(this)},"#resizeListener"));__privateAdd(this,_tickListener,__name(()=>{__privateMethod(this,_LayoutBox_instances,updateScrollPosition_fn).call(this),__privateMethod(this,_LayoutBox_instances,recalculate_fn).call(this)},"#tickListener"));__privateAdd(this,_scrollEntriesListener,__name(()=>{const allEntries=scrollEntries_index.scrollEntries.getAll(this.element);__privateGet(this,_scrollEntries).forEach((value,key)=>{allEntries.includes(key)||(this.deleteScrollStep(value),__privateGet(this,_scrollEntries).delete(key))}),allEntries.forEach(entry=>{if(!__privateGet(this,_scrollEntries).has(entry)){const callback=__name(()=>entry,"callback");__privateGet(this,_scrollEntries).set(entry,callback),this.setScrollStep(callback)}})},"#scrollEntriesListener"));Store.isBrowser&&(__privateSet(this,_element,dom.getElement(element)||document.body),__privateSet(this,_containerElement,dom.getElement(options==null?void 0:options.containerElement)||document.body),__privateSet(this,_scrollAxis,(options==null?void 0:options.scrollAxis)||"auto"),__privateSet(this,_frontSide,(options==null?void 0:options.frontSide)||"top"),__privateSet(this,_isCartesian,(options==null?void 0:options.cartesian)||!1),__privateSet(this,_isSizeStep,(options==null?void 0:options.sizeStep)!==void 0?options.sizeStep:!0),__privateSet(this,_isPositionStep,(options==null?void 0:options.positionStep)!==void 0?options.positionStep:!0),__privateSet(this,_isTransformStep,(options==null?void 0:options.transformStep)!==void 0?options.transformStep:!0),__privateSet(this,_isScrollStep,(options==null?void 0:options.scrollStep)!==void 0?options.scrollStep:!0),__privateGet(this,_scale).setStep("_size","+",{x:1,y:1,z:1}),__privateGet(this,_position).setStep("_position","+",{x:0,y:0,z:0}),__privateGet(this,_scale).setStep("_scale","*",{x:1,y:1,z:1}),__privateGet(this,_position).setStep("_translation","+",{x:0,y:0,z:0}),__privateGet(this,_rotation).setStep("_rotation","+",{x:0,y:0,z:0}),__privateGet(this,_isScrollStep)&&(scrollEntries_index.scrollEntries.notifier.subscribe(__privateGet(this,_scrollEntriesListener)),__privateGet(this,_scrollEntriesListener).call(this),this.setScrollStep(()=>({axis:"y",value:layout.getStickyOffset(this.element,"top")*-1})),this.setScrollStep(()=>({axis:"x",value:layout.getStickyOffset(this.element,"left")*-1}))),elementResizer_index.elementResizer.subscribe(this.element,__privateGet(this,_resizeListener)),windowResizer_index.windowResizer.subscribe(__privateGet(this,_resizeListener),order_index.RESIZE_ORDER.LAYOUT_BOX),ticker_index.ticker.subscribe(__privateGet(this,_tickListener),{order:order_index.TICK_ORDER.LAYOUT_BOX,culling:options!=null&&options.culling?this.element:void 0}))}get element(){return __privateGet(this,_element)}get containerElement(){return __privateGet(this,_containerElement)}get position(){return __privateGet(this,_position).current}get rotation(){return __privateGet(this,_rotation).current}get scale(){return __privateGet(this,_scale).current}get scrollValue(){return __privateGet(this,_scrollValue)}get left(){return __privateGet(this,_left)}get top(){return __privateGet(this,_top)}get CSSTranslation(){return __privateGet(this,_CSSTranslation)}get CSSRotation(){return __privateGet(this,_CSSRotation)}get CSSScale(){return __privateGet(this,_CSSScale)}get front(){return __privateGet(this,_front)}get width(){return __privateGet(this,_width)}get height(){return __privateGet(this,_height)}get depth(){return __privateGet(this,_depth)}destroy(){ticker_index.ticker.unsubscribe(__privateGet(this,_tickListener)),elementResizer_index.elementResizer.unsubscribe(__privateGet(this,_resizeListener)),windowResizer_index.windowResizer.unsubscribe(__privateGet(this,_resizeListener)),scrollEntries_index.scrollEntries.notifier.unsubscribe(__privateGet(this,_scrollEntriesListener)),__privateGet(this,_scrollEntries).clear(),__privateGet(this,_position).close(),__privateGet(this,_rotation).close(),__privateGet(this,_scale).close()}bindObject(object){object.position&&__privateGet(this,_position).bind(object.position),object.rotation&&__privateGet(this,_rotation).bind(object.rotation),object.scale&&__privateGet(this,_scale).bind(object.scale)}unbindObject(object){object.position&&__privateGet(this,_position).unbind(object.position),object.rotation&&__privateGet(this,_rotation).unbind(object.rotation),object.scale&&__privateGet(this,_scale).unbind(object.scale)}setScrollStep(callback){return __privateGet(this,_scrollStepSetterCallbacks).includes(callback)||__privateGet(this,_scrollStepSetterCallbacks).push(callback),()=>this.deleteScrollStep(callback)}deleteScrollStep(callback){__privateSet(this,_scrollStepSetterCallbacks,__privateGet(this,_scrollStepSetterCallbacks).filter(s=>s!==callback))}setPositionStep(...args){__privateGet(this,_position).setStep(...args)}getPositionStep(...args){return __privateGet(this,_position).getStepValue(...args)}setRotationStep(...args){__privateGet(this,_rotation).setStep(...args)}getRotationStep(...args){return __privateGet(this,_rotation).getStepValue(...args)}getExcludedRotationSteps(...args){return __privateGet(this,_rotation).getExcludedStepsValue(...args)}getIncludedRotationSteps(...args){return __privateGet(this,_rotation).getIncludedStepsValue(...args)}setScaleStep(...args){__privateGet(this,_scale).setStep(...args)}getScaleStep(...args){return __privateGet(this,_scale).getStepValue(...args)}getExcludedScaleSteps(...args){return __privateGet(this,_scale).getExcludedStepsValue(...args)}getIncludedScaleSteps(...args){return __privateGet(this,_scale).getIncludedStepsValue(...args)}deletePositionStep(...args){__privateGet(this,_position).deleteStep(...args)}getExcludedPositionSteps(...args){return __privateGet(this,_position).getExcludedStepsValue(...args)}getIncludedPositionSteps(...args){return __privateGet(this,_position).getIncludedStepsValue(...args)}deleteRotationStep(...args){__privateGet(this,_rotation).deleteStep(...args)}deleteScaleStep(...args){__privateGet(this,_scale).deleteStep(...args)}onPosition(...args){return __privateGet(this,_position).subscribe(...args)}offPosition(...args){__privateGet(this,_position).unsubscribe(...args)}onScale(...args){return __privateGet(this,_scale).subscribe(...args)}offScale(...args){__privateGet(this,_scale).unsubscribe(...args)}onRotation(...args){return __privateGet(this,_rotation).subscribe(...args)}offRotation(...args){__privateGet(this,_rotation).unsubscribe(...args)}onResize(...args){return __privateGet(this,_resizeNotifier).subscribe(...args)}offResize(...args){return __privateGet(this,_resizeNotifier).unsubscribe(...args)}};_element=new WeakMap,_containerElement=new WeakMap,_scrollStepSetterCallbacks=new WeakMap,_scrollAxis=new WeakMap,_frontSide=new WeakMap,_isCartesian=new WeakMap,_isSizeStep=new WeakMap,_isPositionStep=new WeakMap,_isTransformStep=new WeakMap,_isScrollStep=new WeakMap,_width=new WeakMap,_height=new WeakMap,_depth=new WeakMap,_top=new WeakMap,_left=new WeakMap,_front=new WeakMap,_x=new WeakMap,_y=new WeakMap,_z=new WeakMap,_CSSTranslation=new WeakMap,_CSSRotation=new WeakMap,_CSSScale=new WeakMap,_rotation=new WeakMap,_position=new WeakMap,_scale=new WeakMap,_scrollValue=new WeakMap,_scrollEntries=new WeakMap,_resizeNotifier=new WeakMap,_LayoutBox_instances=new WeakSet,recalculate_fn=__name(function(){__privateGet(this,_scale).calculate(),__privateGet(this,_position).calculate(),__privateGet(this,_rotation).calculate()},"#recalculate"),composeSteps_fn=__name(function(){__privateGet(this,_scale).setStep("_size","+",{x:__privateGet(this,_isSizeStep)?__privateGet(this,_width):1,y:__privateGet(this,_isSizeStep)?__privateGet(this,_height):1,z:__privateGet(this,_isSizeStep)?__privateGet(this,_depth):1});const xPosition=__privateGet(this,_isPositionStep)?__privateGet(this,_x):0,yPosition=__privateGet(this,_isPositionStep)?__privateGet(this,_y):0,zPosition=__privateGet(this,_isPositionStep)?__privateGet(this,_z):0;__privateGet(this,_position).setStep("_position","+",{x:xPosition,y:yPosition,z:zPosition}),__privateGet(this,_isTransformStep)?(__privateGet(this,_scale).setStep("_scale","*",{x:__privateGet(this,_CSSScale).x,y:__privateGet(this,_CSSScale).y,z:__privateGet(this,_CSSScale).z}),__privateGet(this,_position).setStep("_translation","+",{x:__privateGet(this,_CSSTranslation).x,y:__privateGet(this,_CSSTranslation).y,z:__privateGet(this,_CSSTranslation).z}),__privateGet(this,_rotation).setStep("_rotation","+",{x:__privateGet(this,_CSSRotation).x,y:__privateGet(this,_CSSRotation).y,z:__privateGet(this,_CSSRotation).z})):(__privateGet(this,_scale).setStep("_scale","*",{x:1,y:1,z:1}),__privateGet(this,_position).setStep("_translation","+",{x:0,y:0,z:0}),__privateGet(this,_rotation).setStep("_rotation","+",{x:0,y:0,z:0}))},"#composeSteps"),updateDimensions_fn=__name(function(){const computed=getComputedStyle(__privateGet(this,_element));__privateSet(this,_width,Math.max(__privateGet(this,_element).clientWidth,1)),__privateSet(this,_height,Math.max(__privateGet(this,_element).clientHeight,1)),__privateSet(this,_depth,Math.max(cssUnitParser_index.cssUnitParser.parse(computed.getPropertyValue("--depth")||"0px")||0,1));const vl=layout.getCumulativeOffsetLeft(__privateGet(this,_containerElement)),vt=layout.getCumulativeOffsetTop(__privateGet(this,_containerElement)),vw=__privateGet(this,_containerElement).clientWidth,vh=__privateGet(this,_containerElement).clientHeight;if(__privateSet(this,_left,layout.getCumulativeOffsetLeft(__privateGet(this,_element))-vl),__privateSet(this,_top,layout.getCumulativeOffsetTop(__privateGet(this,_element))-vt),__privateGet(this,_scrollAxis)==="z"){const nl=__privateGet(this,_left)/vw,nt=__privateGet(this,_top)/vh;__privateSet(this,_left,(nl-Math.floor(nl))*vw),__privateSet(this,_top,(nt-Math.floor(nt))*vh),__privateGet(this,_frontSide)==="left"?__privateSet(this,_front,layout.getCumulativeOffsetLeft(__privateGet(this,_element))-vl-__privateGet(this,_left)):__privateSet(this,_front,layout.getCumulativeOffsetTop(__privateGet(this,_element))-vt-__privateGet(this,_top))}if(__privateSet(this,_left,__privateGet(this,_left)+__privateGet(this,_element).clientLeft),__privateSet(this,_top,__privateGet(this,_top)+__privateGet(this,_element).clientTop),__privateSet(this,_left,__privateGet(this,_left)+layout.getStickyOffset(this.element,"left")*-1),__privateSet(this,_top,__privateGet(this,_top)+layout.getStickyOffset(this.element,"top")*-1),__privateGet(this,_isCartesian)){const viewHalfWidth=Math.round(vw/2),viewHalfHeight=Math.round(vh/2),thisHalfWidth=__privateGet(this,_width)?Math.round(__privateGet(this,_width)/2):0,thisHalfHeight=__privateGet(this,_height)?Math.round(__privateGet(this,_height)/2):0,positionX=__privateGet(this,_left)-viewHalfWidth+thisHalfWidth,positionY=(__privateGet(this,_top)-viewHalfHeight+thisHalfHeight)*-1;__privateSet(this,_x,positionX),__privateSet(this,_y,positionY)}else __privateSet(this,_x,__privateGet(this,_left)),__privateSet(this,_y,__privateGet(this,_top));__privateSet(this,_z,__privateGet(this,_front)*-1);const cssMatrix=new WebKitCSSMatrix(computed.transform),decomposedMatrix=decomposeCSSMatrix(cssMatrix);__privateGet(this,_CSSTranslation).x=decomposedMatrix.translationX,__privateGet(this,_CSSTranslation).y=decomposedMatrix.translationY,__privateGet(this,_CSSTranslation).z=decomposedMatrix.translationZ,__privateGet(this,_CSSScale).x=decomposedMatrix.scaleX,__privateGet(this,_CSSScale).y=decomposedMatrix.scaleY,__privateGet(this,_CSSScale).z=decomposedMatrix.scaleZ,__privateGet(this,_CSSRotation).x=decomposedMatrix.rotationX,__privateGet(this,_CSSRotation).y=decomposedMatrix.rotationY,__privateGet(this,_CSSRotation).z=decomposedMatrix.rotationZ,__privateMethod(this,_LayoutBox_instances,composeSteps_fn).call(this),__privateMethod(this,_LayoutBox_instances,recalculate_fn).call(this),__privateGet(this,_resizeNotifier).notify()},"#updateDimensions"),updateScrollPosition_fn=__name(function(){__privateGet(this,_scrollValue).x=0,__privateGet(this,_scrollValue).y=0,__privateGet(this,_scrollValue).z=0;for(let index=0;index<__privateGet(this,_scrollStepSetterCallbacks).length;index++){const callbackReturn=__privateGet(this,_scrollStepSetterCallbacks)[index]();let axis=callbackReturn.axis;__privateGet(this,_scrollAxis)!=="auto"&&(axis=__privateGet(this,_scrollAxis));const value=callbackReturn.value*(axis==="x"?-1:__privateGet(this,_isCartesian)?1:-1);__privateGet(this,_scrollValue)[axis]+=value,__privateGet(this,_position).setStep(`_scroll_${index}`,"+",{[axis]:value})}},"#updateScrollPosition"),_resizeListener=new WeakMap,_tickListener=new WeakMap,_scrollEntriesListener=new WeakMap,__name(_LayoutBox,"LayoutBox");let LayoutBox=_LayoutBox;exports.LayoutBox=LayoutBox;exports.decomposeCSSMatrix=decomposeCSSMatrix;
|
|
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 cssUnitParser_index=require("../css-unit-parser/index.cjs"),elementResizer_index=require("../element-resizer/index.cjs"),ladder_index=require("../ladder/index.cjs"),notifier_index=require("../notifier/index.cjs"),order_index=require("../order/index.cjs"),scrollEntries_index=require("../scroll-entries/index.cjs"),ticker_index=require("../index-BoGx2BWX.cjs"),Store=require("../Store-B96mD8mD.cjs"),dom=require("../dom-B40i6NXw.cjs"),layout=require("../layout-rR4-aYTY.cjs");require("construct-style-sheets-polyfill");const windowResizer_index=require("../window-resizer/index.cjs");function decomposeCSSMatrix(matrix){const scaleX=Math.sqrt(matrix.m11*matrix.m11+matrix.m12*matrix.m12+matrix.m13*matrix.m13),scaleY=Math.sqrt(matrix.m21*matrix.m21+matrix.m22*matrix.m22+matrix.m23*matrix.m23),scaleZ=Math.sqrt(matrix.m31*matrix.m31+matrix.m32*matrix.m32+matrix.m33*matrix.m33),rotationX=Math.atan2(matrix.m32,matrix.m33),rotationY=Math.atan2(-matrix.m31,Math.sqrt(matrix.m32*matrix.m32+matrix.m33*matrix.m33)),rotationZ=Math.atan2(matrix.m21,matrix.m11),translationX=matrix.m41,translationY=matrix.m42*-1,translationZ=matrix.m43;return{scaleX,scaleY,scaleZ,rotationX,rotationY,rotationZ,translationX,translationY,translationZ}}__name(decomposeCSSMatrix,"decomposeCSSMatrix");var _element,_containerElement,_scrollStepSetterCallbacks,_scrollAxis,_frontSide,_isCartesian,_isSizeStep,_isPositionStep,_isTransformStep,_isScrollStep,_width,_height,_depth,_top,_left,_front,_x,_y,_z,_CSSTranslation,_CSSRotation,_CSSScale,_rotation,_position,_scale,_scrollValue,_scrollEntries,_resizeNotifier,_LayoutBox_instances,recalculate_fn,composeSteps_fn,updateDimensions_fn,updateScrollPosition_fn,_resizeListener,_tickListener,_scrollEntriesListener;const _LayoutBox=class _LayoutBox{constructor(element,options){__privateAdd(this,_LayoutBox_instances);__privateAdd(this,_element,null);__privateAdd(this,_containerElement,null);__privateAdd(this,_scrollStepSetterCallbacks,[]);__privateAdd(this,_scrollAxis,"auto");__privateAdd(this,_frontSide,"top");__privateAdd(this,_isCartesian,!1);__privateAdd(this,_isSizeStep,!0);__privateAdd(this,_isPositionStep,!0);__privateAdd(this,_isTransformStep,!0);__privateAdd(this,_isScrollStep,!0);__privateAdd(this,_width,0);__privateAdd(this,_height,0);__privateAdd(this,_depth,0);__privateAdd(this,_top,0);__privateAdd(this,_left,0);__privateAdd(this,_front,0);__privateAdd(this,_x,0);__privateAdd(this,_y,0);__privateAdd(this,_z,0);__privateAdd(this,_CSSTranslation,{x:0,y:0,z:0});__privateAdd(this,_CSSRotation,{x:0,y:0,z:0});__privateAdd(this,_CSSScale,{x:1,y:1,z:1});__privateAdd(this,_rotation,new ladder_index.Ladder({x:0,y:0,z:0}));__privateAdd(this,_position,new ladder_index.Ladder({x:0,y:0,z:0}));__privateAdd(this,_scale,new ladder_index.Ladder({x:0,y:0,z:0}));__privateAdd(this,_scrollValue,{x:0,y:0,z:0});__privateAdd(this,_scrollEntries,new Map);__privateAdd(this,_resizeNotifier,new notifier_index.Notifier);__privateAdd(this,_resizeListener,__name(()=>{Store.isBrowser&&__privateMethod(this,_LayoutBox_instances,updateDimensions_fn).call(this)},"#resizeListener"));__privateAdd(this,_tickListener,__name(()=>{__privateMethod(this,_LayoutBox_instances,updateScrollPosition_fn).call(this),__privateMethod(this,_LayoutBox_instances,recalculate_fn).call(this)},"#tickListener"));__privateAdd(this,_scrollEntriesListener,__name(()=>{const allEntries=scrollEntries_index.scrollEntries.getAll(this.element);__privateGet(this,_scrollEntries).forEach((value,key)=>{allEntries.includes(key)||(this.deleteScrollStep(value),__privateGet(this,_scrollEntries).delete(key))}),allEntries.forEach(entry=>{if(!__privateGet(this,_scrollEntries).has(entry)){const callback=__name(()=>entry,"callback");__privateGet(this,_scrollEntries).set(entry,callback),this.setScrollStep(callback)}})},"#scrollEntriesListener"));Store.isBrowser&&(__privateSet(this,_element,dom.getElement(element)||document.body),__privateSet(this,_containerElement,dom.getElement(options==null?void 0:options.containerElement)||document.body),__privateSet(this,_scrollAxis,(options==null?void 0:options.scrollAxis)||"auto"),__privateSet(this,_frontSide,(options==null?void 0:options.frontSide)||"top"),__privateSet(this,_isCartesian,(options==null?void 0:options.cartesian)||!1),__privateSet(this,_isSizeStep,(options==null?void 0:options.sizeStep)!==void 0?options.sizeStep:!0),__privateSet(this,_isPositionStep,(options==null?void 0:options.positionStep)!==void 0?options.positionStep:!0),__privateSet(this,_isTransformStep,(options==null?void 0:options.transformStep)!==void 0?options.transformStep:!0),__privateSet(this,_isScrollStep,(options==null?void 0:options.scrollStep)!==void 0?options.scrollStep:!0),__privateGet(this,_scale).setStep("_size","+",{x:1,y:1,z:1}),__privateGet(this,_position).setStep("_position","+",{x:0,y:0,z:0}),__privateGet(this,_scale).setStep("_scale","*",{x:1,y:1,z:1}),__privateGet(this,_position).setStep("_translation","+",{x:0,y:0,z:0}),__privateGet(this,_rotation).setStep("_rotation","+",{x:0,y:0,z:0}),__privateGet(this,_isScrollStep)&&(scrollEntries_index.scrollEntries.notifier.subscribe(__privateGet(this,_scrollEntriesListener)),__privateGet(this,_scrollEntriesListener).call(this),this.setScrollStep(()=>({axis:"y",value:layout.getStickyOffset(this.element,"top")*-1})),this.setScrollStep(()=>({axis:"x",value:layout.getStickyOffset(this.element,"left")*-1}))),elementResizer_index.elementResizer.subscribe(this.element,__privateGet(this,_resizeListener)),windowResizer_index.windowResizer.subscribe(__privateGet(this,_resizeListener),order_index.RESIZE_ORDER.LAYOUT_BOX),ticker_index.ticker.subscribe(__privateGet(this,_tickListener),{order:order_index.TICK_ORDER.LAYOUT_BOX,culling:options!=null&&options.culling?this.element:void 0}))}get element(){return __privateGet(this,_element)}get containerElement(){return __privateGet(this,_containerElement)}get position(){return __privateGet(this,_position).current}get rotation(){return __privateGet(this,_rotation).current}get scale(){return __privateGet(this,_scale).current}get scrollValue(){return __privateGet(this,_scrollValue)}get left(){return __privateGet(this,_left)}get top(){return __privateGet(this,_top)}get CSSTranslation(){return __privateGet(this,_CSSTranslation)}get CSSRotation(){return __privateGet(this,_CSSRotation)}get CSSScale(){return __privateGet(this,_CSSScale)}get front(){return __privateGet(this,_front)}get width(){return __privateGet(this,_width)}get height(){return __privateGet(this,_height)}get depth(){return __privateGet(this,_depth)}destroy(){ticker_index.ticker.unsubscribe(__privateGet(this,_tickListener)),elementResizer_index.elementResizer.unsubscribe(__privateGet(this,_resizeListener)),windowResizer_index.windowResizer.unsubscribe(__privateGet(this,_resizeListener)),scrollEntries_index.scrollEntries.notifier.unsubscribe(__privateGet(this,_scrollEntriesListener)),__privateGet(this,_scrollEntries).clear(),__privateGet(this,_position).close(),__privateGet(this,_rotation).close(),__privateGet(this,_scale).close()}bindObject(object){object.position&&__privateGet(this,_position).bind(object.position),object.rotation&&__privateGet(this,_rotation).bind(object.rotation),object.scale&&__privateGet(this,_scale).bind(object.scale)}unbindObject(object){object.position&&__privateGet(this,_position).unbind(object.position),object.rotation&&__privateGet(this,_rotation).unbind(object.rotation),object.scale&&__privateGet(this,_scale).unbind(object.scale)}setScrollStep(callback){return __privateGet(this,_scrollStepSetterCallbacks).includes(callback)||__privateGet(this,_scrollStepSetterCallbacks).push(callback),()=>this.deleteScrollStep(callback)}deleteScrollStep(callback){__privateSet(this,_scrollStepSetterCallbacks,__privateGet(this,_scrollStepSetterCallbacks).filter(s=>s!==callback))}setPositionStep(...args){__privateGet(this,_position).setStep(...args)}getPositionStep(...args){return __privateGet(this,_position).getStepValue(...args)}setRotationStep(...args){__privateGet(this,_rotation).setStep(...args)}getRotationStep(...args){return __privateGet(this,_rotation).getStepValue(...args)}getExcludedRotationSteps(...args){return __privateGet(this,_rotation).getExcludedStepsValue(...args)}getIncludedRotationSteps(...args){return __privateGet(this,_rotation).getIncludedStepsValue(...args)}setScaleStep(...args){__privateGet(this,_scale).setStep(...args)}getScaleStep(...args){return __privateGet(this,_scale).getStepValue(...args)}getExcludedScaleSteps(...args){return __privateGet(this,_scale).getExcludedStepsValue(...args)}getIncludedScaleSteps(...args){return __privateGet(this,_scale).getIncludedStepsValue(...args)}deletePositionStep(...args){__privateGet(this,_position).deleteStep(...args)}getExcludedPositionSteps(...args){return __privateGet(this,_position).getExcludedStepsValue(...args)}getIncludedPositionSteps(...args){return __privateGet(this,_position).getIncludedStepsValue(...args)}deleteRotationStep(...args){__privateGet(this,_rotation).deleteStep(...args)}deleteScaleStep(...args){__privateGet(this,_scale).deleteStep(...args)}onPosition(...args){return __privateGet(this,_position).subscribe(...args)}offPosition(...args){__privateGet(this,_position).unsubscribe(...args)}onScale(...args){return __privateGet(this,_scale).subscribe(...args)}offScale(...args){__privateGet(this,_scale).unsubscribe(...args)}onRotation(...args){return __privateGet(this,_rotation).subscribe(...args)}offRotation(...args){__privateGet(this,_rotation).unsubscribe(...args)}onResize(...args){return __privateGet(this,_resizeNotifier).subscribe(...args)}offResize(...args){return __privateGet(this,_resizeNotifier).unsubscribe(...args)}};_element=new WeakMap,_containerElement=new WeakMap,_scrollStepSetterCallbacks=new WeakMap,_scrollAxis=new WeakMap,_frontSide=new WeakMap,_isCartesian=new WeakMap,_isSizeStep=new WeakMap,_isPositionStep=new WeakMap,_isTransformStep=new WeakMap,_isScrollStep=new WeakMap,_width=new WeakMap,_height=new WeakMap,_depth=new WeakMap,_top=new WeakMap,_left=new WeakMap,_front=new WeakMap,_x=new WeakMap,_y=new WeakMap,_z=new WeakMap,_CSSTranslation=new WeakMap,_CSSRotation=new WeakMap,_CSSScale=new WeakMap,_rotation=new WeakMap,_position=new WeakMap,_scale=new WeakMap,_scrollValue=new WeakMap,_scrollEntries=new WeakMap,_resizeNotifier=new WeakMap,_LayoutBox_instances=new WeakSet,recalculate_fn=__name(function(){__privateGet(this,_scale).calculate(),__privateGet(this,_position).calculate(),__privateGet(this,_rotation).calculate()},"#recalculate"),composeSteps_fn=__name(function(){__privateGet(this,_scale).setStep("_size","+",{x:__privateGet(this,_isSizeStep)?__privateGet(this,_width):1,y:__privateGet(this,_isSizeStep)?__privateGet(this,_height):1,z:__privateGet(this,_isSizeStep)?__privateGet(this,_depth):1});const xPosition=__privateGet(this,_isPositionStep)?__privateGet(this,_x):0,yPosition=__privateGet(this,_isPositionStep)?__privateGet(this,_y):0,zPosition=__privateGet(this,_isPositionStep)?__privateGet(this,_z):0;__privateGet(this,_position).setStep("_position","+",{x:xPosition,y:yPosition,z:zPosition}),__privateGet(this,_isTransformStep)?(__privateGet(this,_scale).setStep("_scale","*",{x:__privateGet(this,_CSSScale).x,y:__privateGet(this,_CSSScale).y,z:__privateGet(this,_CSSScale).z}),__privateGet(this,_position).setStep("_translation","+",{x:__privateGet(this,_CSSTranslation).x,y:__privateGet(this,_CSSTranslation).y,z:__privateGet(this,_CSSTranslation).z}),__privateGet(this,_rotation).setStep("_rotation","+",{x:__privateGet(this,_CSSRotation).x,y:__privateGet(this,_CSSRotation).y,z:__privateGet(this,_CSSRotation).z})):(__privateGet(this,_scale).setStep("_scale","*",{x:1,y:1,z:1}),__privateGet(this,_position).setStep("_translation","+",{x:0,y:0,z:0}),__privateGet(this,_rotation).setStep("_rotation","+",{x:0,y:0,z:0}))},"#composeSteps"),updateDimensions_fn=__name(function(){const computed=getComputedStyle(__privateGet(this,_element));__privateSet(this,_width,Math.max(__privateGet(this,_element).clientWidth,1)),__privateSet(this,_height,Math.max(__privateGet(this,_element).clientHeight,1)),__privateSet(this,_depth,Math.max(cssUnitParser_index.cssUnitParser.parse(computed.getPropertyValue("--depth")||"0px")||0,1));const vl=layout.getCumulativeOffsetLeft(__privateGet(this,_containerElement)),vt=layout.getCumulativeOffsetTop(__privateGet(this,_containerElement)),vw=__privateGet(this,_containerElement).clientWidth,vh=__privateGet(this,_containerElement).clientHeight;if(__privateSet(this,_left,layout.getCumulativeOffsetLeft(__privateGet(this,_element))-vl),__privateSet(this,_top,layout.getCumulativeOffsetTop(__privateGet(this,_element))-vt),__privateGet(this,_scrollAxis)==="z"){const nl=__privateGet(this,_left)/vw,nt=__privateGet(this,_top)/vh;__privateSet(this,_left,(nl-Math.floor(nl))*vw),__privateSet(this,_top,(nt-Math.floor(nt))*vh),__privateGet(this,_frontSide)==="left"?__privateSet(this,_front,layout.getCumulativeOffsetLeft(__privateGet(this,_element))-vl-__privateGet(this,_left)):__privateSet(this,_front,layout.getCumulativeOffsetTop(__privateGet(this,_element))-vt-__privateGet(this,_top))}if(__privateSet(this,_left,__privateGet(this,_left)+__privateGet(this,_element).clientLeft),__privateSet(this,_top,__privateGet(this,_top)+__privateGet(this,_element).clientTop),__privateSet(this,_left,__privateGet(this,_left)+layout.getStickyOffset(this.element,"left")*-1),__privateSet(this,_top,__privateGet(this,_top)+layout.getStickyOffset(this.element,"top")*-1),__privateGet(this,_isCartesian)){const viewHalfWidth=Math.round(vw/2),viewHalfHeight=Math.round(vh/2),thisHalfWidth=__privateGet(this,_width)?Math.round(__privateGet(this,_width)/2):0,thisHalfHeight=__privateGet(this,_height)?Math.round(__privateGet(this,_height)/2):0,positionX=__privateGet(this,_left)-viewHalfWidth+thisHalfWidth,positionY=(__privateGet(this,_top)-viewHalfHeight+thisHalfHeight)*-1;__privateSet(this,_x,positionX),__privateSet(this,_y,positionY)}else __privateSet(this,_x,__privateGet(this,_left)),__privateSet(this,_y,__privateGet(this,_top));__privateSet(this,_z,__privateGet(this,_front)*-1);const cssMatrix=new WebKitCSSMatrix(computed.transform),decomposedMatrix=decomposeCSSMatrix(cssMatrix);__privateGet(this,_CSSTranslation).x=decomposedMatrix.translationX,__privateGet(this,_CSSTranslation).y=decomposedMatrix.translationY,__privateGet(this,_CSSTranslation).z=decomposedMatrix.translationZ,__privateGet(this,_CSSScale).x=decomposedMatrix.scaleX,__privateGet(this,_CSSScale).y=decomposedMatrix.scaleY,__privateGet(this,_CSSScale).z=decomposedMatrix.scaleZ,__privateGet(this,_CSSRotation).x=decomposedMatrix.rotationX,__privateGet(this,_CSSRotation).y=decomposedMatrix.rotationY,__privateGet(this,_CSSRotation).z=decomposedMatrix.rotationZ,__privateMethod(this,_LayoutBox_instances,composeSteps_fn).call(this),__privateMethod(this,_LayoutBox_instances,recalculate_fn).call(this),__privateGet(this,_resizeNotifier).notify()},"#updateDimensions"),updateScrollPosition_fn=__name(function(){__privateGet(this,_scrollValue).x=0,__privateGet(this,_scrollValue).y=0,__privateGet(this,_scrollValue).z=0;for(let index=0;index<__privateGet(this,_scrollStepSetterCallbacks).length;index++){const callbackReturn=__privateGet(this,_scrollStepSetterCallbacks)[index]();let axis=callbackReturn.axis;__privateGet(this,_scrollAxis)!=="auto"&&(axis=__privateGet(this,_scrollAxis));const value=callbackReturn.value*(axis==="x"?-1:__privateGet(this,_isCartesian)?1:-1);__privateGet(this,_scrollValue)[axis]+=value,__privateGet(this,_position).setStep(`_scroll_${index}`,"+",{[axis]:value})}},"#updateScrollPosition"),_resizeListener=new WeakMap,_tickListener=new WeakMap,_scrollEntriesListener=new WeakMap,__name(_LayoutBox,"LayoutBox");let LayoutBox=_LayoutBox;exports.LayoutBox=LayoutBox;exports.decomposeCSSMatrix=decomposeCSSMatrix;
|
package/lib/layout-box/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import { scrollEntries } from "../scroll-entries/index.js";
|
|
|
14
14
|
import { t as ticker } from "../index-DAG0CtYo.js";
|
|
15
15
|
import { i as isBrowser } from "../Store-CAGUSjFX.js";
|
|
16
16
|
import { g as getElement } from "../dom-D8D-_9ty.js";
|
|
17
|
-
import { g as getStickyOffset, a as getCumulativeOffsetLeft, b as getCumulativeOffsetTop } from "../layout-
|
|
17
|
+
import { g as getStickyOffset, a as getCumulativeOffsetLeft, b as getCumulativeOffsetTop } from "../layout-DxOCR4qe.js";
|
|
18
18
|
import "construct-style-sheets-polyfill";
|
|
19
19
|
import { windowResizer } from "../window-resizer/index.js";
|
|
20
20
|
function decomposeCSSMatrix(matrix) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});function getCumulativePosition(target,from="offsetLeft",stopElement){let acc=0;do acc+=target[from]||0,target=target.offsetParent;while(target&&target!==stopElement);return acc}__name(getCumulativePosition,"getCumulativePosition");function getCumulativeOffsetLeft(target,stopElement){return getCumulativePosition(target,"offsetLeft",stopElement)}__name(getCumulativeOffsetLeft,"getCumulativeOffsetLeft");function getCumulativeOffsetTop(target,stopElement){return getCumulativePosition(target,"offsetTop",stopElement)}__name(getCumulativeOffsetTop,"getCumulativeOffsetTop");function getStickyOffset(el,type){const
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});function getCumulativePosition(target,from="offsetLeft",stopElement){let acc=0;do acc+=target[from]||0,target=target.offsetParent;while(target&&target!==stopElement);return acc}__name(getCumulativePosition,"getCumulativePosition");function getCumulativeOffsetLeft(target,stopElement){return getCumulativePosition(target,"offsetLeft",stopElement)}__name(getCumulativeOffsetLeft,"getCumulativeOffsetLeft");function getCumulativeOffsetTop(target,stopElement){return getCumulativePosition(target,"offsetTop",stopElement)}__name(getCumulativeOffsetTop,"getCumulativeOffsetTop");function getStickyOffset(el,type){const stickyElements=[];let currentElement=el;for(;currentElement;)window.getComputedStyle(currentElement).position==="sticky"&&stickyElements.push(currentElement),currentElement=currentElement.parentElement;return stickyElements.reduce((p,c)=>p+(type==="top"?c.offsetTop:c.offsetLeft),0)}__name(getStickyOffset,"getStickyOffset");exports.getCumulativeOffsetLeft=getCumulativeOffsetLeft;exports.getCumulativeOffsetTop=getCumulativeOffsetTop;exports.getCumulativePosition=getCumulativePosition;exports.getStickyOffset=getStickyOffset;
|
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __knownSymbol=(name,symbol)=>(symbol=Symbol[name])?symbol:Symbol.for("Symbol."+name),__typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);var __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});var __forAwait=(obj,it,method)=>(it=obj[__knownSymbol("asyncIterator")])?it.call(obj):(obj=obj[__knownSymbol("iterator")](),it={},method=(key,fn)=>(fn=obj[key])&&(it[key]=arg=>new Promise((yes,no,done)=>(arg=fn.call(obj,arg),done=arg.done,Promise.resolve(arg.value).then(value=>yes({value,done}),no)))),method("next"),method("return"),it);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Store=require("../Store-B96mD8mD.cjs"),dom=require("../dom-B40i6NXw.cjs"),events=require("../events-UlGk63iC.cjs"),promises=require("../promises-nDm8_iG6.cjs"),scroll=require("../scroll-DfvKl-On.cjs");require("construct-style-sheets-polyfill");require("../index-BoGx2BWX.cjs");const url=require("../url-D0rESDQq.cjs"),cssValueParser_index=require("../css-value-parser/index.cjs"),historyManager=require("../historyManager-DB2fSEtH.cjs"),_MorphAnnouncer=class _MorphAnnouncer extends HTMLElement{connectedCallback(){const attrs={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[key,value]of Object.entries(attrs))this.setAttribute(key,value)}};__name(_MorphAnnouncer,"MorphAnnouncer");let MorphAnnouncer=_MorphAnnouncer;Store.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",MorphAnnouncer);var _morph,_element,_MorphLink_instances,path_get,click_fn,_clickListener,_pointerListener;const _MorphLink=class _MorphLink{constructor(element,morph){__privateAdd(this,_MorphLink_instances);__privateAdd(this,_morph);__privateAdd(this,_element);__privateAdd(this,_clickListener,__name(e=>{e.preventDefault(),__privateMethod(this,_MorphLink_instances,click_fn).call(this)},"#clickListener"));__privateAdd(this,_pointerListener,__name(()=>{const revalidate=__privateGet(this,_element).hasAttribute("data-revalidate");__privateGet(this,_morph).prefetch(__privateGet(this,_MorphLink_instances,path_get),revalidate),__privateGet(this,_element).removeEventListener("pointerenter",__privateGet(this,_pointerListener))},"#pointerListener"));__privateSet(this,_morph,morph),__privateSet(this,_element,element),__privateGet(this,_element).addEventListener("click",__privateGet(this,_clickListener)),this.checkCurrent(location.href.replace(location.origin,"")),__privateGet(this,_element).hasAttribute("data-prefetch")&&__privateGet(this,_element).addEventListener("pointerenter",__privateGet(this,_pointerListener))}get element(){return __privateGet(this,_element)}checkCurrent(path){var _a,_b;const locationUrl=__privateGet(this,_morph).normalizePath(path),linkUrl=__privateGet(this,_morph).normalizePath(__privateGet(this,_MorphLink_instances,path_get));__privateGet(this,_element).hasAttribute("data-include")&&locationUrl.pathname.includes(linkUrl.pathname)?__privateGet(this,_element).classList.add("current"):linkUrl.pathname===locationUrl.pathname?__privateGet(this,_element).classList.add("current"):(_a=__privateGet(this,_element).getAttribute("data-associated-paths"))!=null&&_a.split(",").find(path2=>locationUrl.pathname.includes(path2))?__privateGet(this,_element).classList.add("current"):__privateGet(this,_element).classList.remove("current"),locationUrl.path===linkUrl.path?__privateGet(this,_element).classList.add("exact"):__privateGet(this,_element).classList.remove("exact");const[pathWithoutParams,pathParamsStr]=(_b=__privateGet(this,_MorphLink_instances,path_get).split("#")[0])==null?void 0:_b.split("?"),pathParams=new URLSearchParams(pathParamsStr),locationParams=new URLSearchParams(location.search);let matchCounter=0;for(const[key]of locationParams)pathParams.has(key)&&locationParams.get(key)===pathParams.get(key)&&matchCounter++;matchCounter?(__privateGet(this,_element).classList.toggle("all-params-matched",locationParams.size===matchCounter),__privateGet(this,_element).classList.toggle("some-params-matched",locationParams.size!==matchCounter)):!locationParams.size&&__privateGet(this,_element).hasAttribute("data-match-no-params")?__privateGet(this,_element).classList.add("all-params-matched"):(__privateGet(this,_element).classList.remove("all-params-matched"),__privateGet(this,_element).classList.remove("some-params-matched"));for(const key in __privateGet(this,_element).dataset){const kebabKey=Store.camelToKebab(key);if(kebabKey.startsWith("match-param-")){const name=kebabKey.split("match-param-")[1],value=__privateGet(this,_element).dataset[key],className=`param-${name}-matched`;locationParams.has(name)&&locationParams.get(name)===value||!locationParams.has(name)&&(value===""||value==="*"||value==="all"||value==="any"||value==="vse")?__privateGet(this,_element).classList.add(className):__privateGet(this,_element).classList.remove(className)}}}destroy(){__privateGet(this,_element).removeEventListener("click",__privateGet(this,_clickListener)),__privateGet(this,_element).removeEventListener("pointerenter",__privateGet(this,_pointerListener)),__privateGet(this,_element).classList.remove("current","exact")}};_morph=new WeakMap,_element=new WeakMap,_MorphLink_instances=new WeakSet,path_get=__name(function(){const url2=new URL(__privateGet(this,_element).href);return __privateGet(this,_morph).normalizePath(url2.pathname+url2.search+url2.hash).path},"#path"),click_fn=__name(function(){var _a;if(document.documentElement.classList.contains("click-disabled"))return;if(__privateGet(this,_element).hasAttribute("data-back")&&__privateGet(this,_morph).previousURL)history.back();else{const historyAction=__privateGet(this,_element).getAttribute("data-history-action")||"push",centerScroll=__privateGet(this,_element).hasAttribute("data-center-scroll"),offsetScrollRawValue=getComputedStyle(__privateGet(this,_element)).getPropertyValue("--offset-scroll").trim(),offsetScroll=offsetScrollRawValue?cssValueParser_index.cssValueParser.parse(offsetScrollRawValue):void 0,scrollDuration=parseFloat(__privateGet(this,_element).getAttribute("data-scroll-duration")||"0")||void 0,scrollEasing=__privateGet(this,_element).getAttribute("data-scroll-easing")||void 0,revalidate=__privateGet(this,_element).hasAttribute("data-revalidate")||__privateGet(this,_element).hasAttribute("data-pagination-more-link")||__privateGet(this,_element).hasAttribute("data-pagination-set-link")||__privateGet(this,_element).hasAttribute("data-pagination-next-link")||__privateGet(this,_element).hasAttribute("data-pagination-prev-link"),keepSearchParameters=__privateGet(this,_element).hasAttribute("data-keep-search-parameters"),keepScrollPosition=__privateGet(this,_element).hasAttribute("data-keep-scroll-position")||__privateGet(this,_element).hasAttribute("data-pagination-more-link"),scrollBehaviour=__privateGet(this,_element).getAttribute("data-scroll-behaviour"),submorph=(_a=__privateGet(this,_element).getAttribute("data-submorph")||__privateGet(this,_element).getAttribute("data-submorph-append"))==null?void 0:_a.split(",").map(v=>v.trim()),clearState=__privateGet(this,_element).hasAttribute("data-clear-state");let path=__privateGet(this,_MorphLink_instances,path_get);if(__privateGet(this,_element).hasAttribute("data-toggle-params")){const[pathWithoutParams,pathParamsStr]=__privateGet(this,_MorphLink_instances,path_get).split("?"),pathParams=new URLSearchParams(pathParamsStr),locationParams=new URLSearchParams(location.search),resultParams=new URLSearchParams;for(const[key]of pathParams)(!locationParams.has(key)||locationParams.has(key)&&locationParams.get(key)!==pathParams.get(key))&&resultParams.append(key,pathParams.get(key));if(__privateGet(this,_element).hasAttribute("data-merge-params"))for(const[key]of locationParams)pathParams.has(key)||resultParams.append(key,locationParams.get(key));path=`${pathWithoutParams}?${resultParams.toString()}`}__privateGet(this,_morph).navigate(path,{historyAction,centerScroll,offsetScroll,revalidate,keepSearchParameters,submorph,clearState,keepScrollPosition,scrollBehaviour,scrollDuration,scrollEasing,submorphAppend:__privateGet(this,_element).hasAttribute("data-submorph-append"),mergeParams:__privateGet(this,_element).hasAttribute("data-merge-params")&&!__privateGet(this,_element).hasAttribute("data-toggle-params"),detail:__privateGet(this,_element).getAttribute("data-detail"),removeParams:__privateGet(this,_element).getAttribute("data-remove-params")||void 0,scrollTo:__privateGet(this,_element).getAttribute("data-scroll-to")||void 0})}},"#click"),_clickListener=new WeakMap,_pointerListener=new WeakMap,__name(_MorphLink,"MorphLink");let MorphLink=_MorphLink;var _element2,_params,_MorphParamsDependent_instances,update_fn,_urlChangeListener;const _MorphParamsDependent=class _MorphParamsDependent{constructor(element){__privateAdd(this,_MorphParamsDependent_instances);__privateAdd(this,_element2);__privateAdd(this,_params,[]);__privateAdd(this,_urlChangeListener,__name(()=>{__privateMethod(this,_MorphParamsDependent_instances,update_fn).call(this)},"#urlChangeListener"));__privateSet(this,_element2,element);for(const key in __privateGet(this,_element2).dataset){const kebabKey=Store.camelToKebab(key);if(kebabKey.startsWith("param-")){const name=kebabKey.split("param-")[1],value=__privateGet(this,_element2).dataset[key];__privateGet(this,_params).push({name,value})}}document.addEventListener("morphURLParametersChange",__privateGet(this,_urlChangeListener)),__privateMethod(this,_MorphParamsDependent_instances,update_fn).call(this)}destroy(){document.removeEventListener("morphURLParametersChange",__privateGet(this,_urlChangeListener))}};_element2=new WeakMap,_params=new WeakMap,_MorphParamsDependent_instances=new WeakSet,update_fn=__name(function(){const locationParams=new URLSearchParams(location.search);let matched=!!__privateGet(this,_params).find(param=>locationParams.has(param.name)&&(locationParams.get(param.name)===param.value||param.value==="*"||param.value==="all"||param.value==="any"||param.value==="vse"||locationParams.get(param.name)==="*"||locationParams.get(param.name)==="all"||locationParams.get(param.name)==="any"||locationParams.get(param.name)==="vse"));!matched&&__privateGet(this,_element2).hasAttribute("data-match-no-params")&&(matched=!__privateGet(this,_params).filter(param=>locationParams.has(param.name)).length);const hideClass=__privateGet(this,_element2).getAttribute("data-hide-class");matched?hideClass?__privateGet(this,_element2).classList.remove(hideClass):__privateGet(this,_element2).style.display="":hideClass?__privateGet(this,_element2).classList.add(hideClass):__privateGet(this,_element2).style.display="none",requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("resize"))})},"#update"),_urlChangeListener=new WeakMap,__name(_MorphParamsDependent,"MorphParamsDependent");let MorphParamsDependent=_MorphParamsDependent;const domParser=new DOMParser;var _morph2,_pathname,_scrollState,_initialDocument,_modifiedDocument,_currentDocument,_savedState,_abortController,_fetching,_headers,_needRavalidation;const _MorphRoute=class _MorphRoute{constructor(morph,pathname){__privateAdd(this,_morph2);__privateAdd(this,_pathname);__privateAdd(this,_scrollState,{x:0,y:0});__privateAdd(this,_initialDocument,null);__privateAdd(this,_modifiedDocument,null);__privateAdd(this,_currentDocument,null);__privateAdd(this,_savedState,null);__privateAdd(this,_abortController,null);__privateAdd(this,_fetching,null);__privateAdd(this,_headers);__privateAdd(this,_needRavalidation,!1);__privateSet(this,_morph2,morph),__privateSet(this,_pathname,pathname)}get pathname(){return __privateGet(this,_pathname)}get scrollState(){return __privateGet(this,_scrollState)}get document(){return __privateGet(this,_currentDocument)}needRavalidation(){__privateSet(this,_needRavalidation,!0)}setHeaders(headers){__privateSet(this,_headers,headers)}setInitialDocument(document2){__privateSet(this,_initialDocument,document2.cloneNode(!0))}abort(){var _a;return(_a=__privateGet(this,_abortController))==null?void 0:_a.abort(`[${__privateGet(this,_pathname)}] page loading cancelled`)}fetch(path,currentPath,revalidate){return __async(this,null,function*(){var _a;if(!revalidate&&!__privateGet(this,_needRavalidation)){const shouldUseCache=((_a=__privateGet(this,_initialDocument))==null?void 0:_a.documentElement.getAttribute("data-cache"))&¤tPath!==path,isPopstateNavigation=__privateGet(this,_initialDocument)&&__privateGet(this,_morph2).isPopstateNavigation;if(__privateGet(this,_fetching)||shouldUseCache||isPopstateNavigation)return __privateGet(this,_fetching)}return __privateSet(this,_fetching,new Promise(res=>__async(this,null,function*(){try{__privateSet(this,_abortController,new AbortController);const text=yield(yield fetch(path,{signal:__privateGet(this,_abortController).signal,headers:__spreadValues({"X-MORPH":"true","X-MORPH-REVALIDATE":revalidate?"true":"false","X-MORPH-CURRENT-PATH":encodeURIComponent(currentPath),"X-MORPH-NEW-PATH":encodeURIComponent(path)},__privateGet(this,_headers))})).text(),document2=domParser.parseFromString(text,"text/html");this.setInitialDocument(document2),__privateSet(this,_needRavalidation,!1)}catch(e){console.warn(e)}finally{__privateSet(this,_abortController,null),__privateSet(this,_fetching,null),res()}}))),__privateGet(this,_fetching)})}cloneDocument(){__privateSet(this,_currentDocument,(__privateGet(this,_modifiedDocument)||__privateGet(this,_initialDocument)).cloneNode(!0))}get title(){let title="";if(__privateGet(this,_currentDocument).title)title=__privateGet(this,_currentDocument).title;else{const h1=__privateGet(this,_currentDocument).querySelector("h1");title=(h1==null?void 0:h1.innerText)||(h1==null?void 0:h1.textContent)||__privateGet(this,_pathname)}return title}clearScrollState(){__privateGet(this,_scrollState).x=0,__privateGet(this,_scrollState).y=0}clearDocumentState(){__privateSet(this,_modifiedDocument,null)}saveScrollState(){__privateGet(this,_initialDocument).documentElement.hasAttribute("data-no-scroll-restoration")?(__privateGet(this,_scrollState).x=0,__privateGet(this,_scrollState).y=0):(__privateGet(this,_scrollState).x=__privateGet(this,_morph2).scrollValue.left,__privateGet(this,_scrollState).y=__privateGet(this,_morph2).scrollValue.top)}restoreScrollPosition(){__privateGet(this,_morph2).scrollElement.scroll({top:__privateGet(this,_scrollState).y,left:__privateGet(this,_scrollState).x,behavior:"instant"})}saveDocumentState(){__privateGet(this,_initialDocument).documentElement.hasAttribute("data-no-page-restoration")?__privateSet(this,_modifiedDocument,null):__privateSet(this,_modifiedDocument,document.cloneNode(!0))}renewScrollPosition(){__privateGet(this,_morph2).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(state){__privateSet(this,_savedState,state)}clearState(){const state=__privateGet(this,_savedState);return __privateSet(this,_savedState,null),state}};_morph2=new WeakMap,_pathname=new WeakMap,_scrollState=new WeakMap,_initialDocument=new WeakMap,_modifiedDocument=new WeakMap,_currentDocument=new WeakMap,_savedState=new WeakMap,_abortController=new WeakMap,_fetching=new WeakMap,_headers=new WeakMap,_needRavalidation=new WeakMap,__name(_MorphRoute,"MorphRoute");let MorphRoute=_MorphRoute;var _options,_morphElements,_links,_candidateURL,_currentURL,_previousURL,_promises,_isPopstateNavigation,_currentScrollElement,_isWindowScroll,_routes,_paramDependent,_announcer,_currentScrollX,_currentScrollY,_lastSubmorph,_lastRevalidate,_lastKeepScrollPosition,_checkLink,_Morph_instances,getRoute_fn,getMorphElements_fn,isElementEmitsLoadEvent_fn,updateCurrentScrollElement_fn,tryScrollToElement_fn,_popStateListener,_scrollListener;const _Morph=class _Morph{constructor(parameters){__privateAdd(this,_Morph_instances);__privateAdd(this,_options,null);__privateAdd(this,_morphElements,null);__privateAdd(this,_links,[]);__privateAdd(this,_candidateURL);__privateAdd(this,_currentURL,null);__privateAdd(this,_previousURL);__privateAdd(this,_promises,[]);__privateAdd(this,_isPopstateNavigation,!1);__privateAdd(this,_currentScrollElement,null);__privateAdd(this,_isWindowScroll,!1);__privateAdd(this,_routes,new Map);__privateAdd(this,_paramDependent,[]);__privateAdd(this,_announcer,null);__privateAdd(this,_currentScrollX,0);__privateAdd(this,_currentScrollY,0);__privateAdd(this,_lastSubmorph);__privateAdd(this,_lastRevalidate);__privateAdd(this,_lastKeepScrollPosition);__privateAdd(this,_checkLink,__name(element=>{var _a,_b;return(((_a=element.getAttribute("href"))==null?void 0:_a.startsWith("/"))||((_b=element.getAttribute("href"))==null?void 0:_b.startsWith("?")))&&!element.hasAttribute("download")&&!element.hasAttribute("data-morph-skip")&&!element.closest("[data-morph-skip]")&&element.getAttribute("target")!=="_blank"},"#checkLink"));__privateAdd(this,_popStateListener,__name(event=>__async(this,null,function*(){var _a,_b,_c,_d;(_b=(_a=event.state)==null?void 0:_a.data)!=null&&_b.popover||(_d=(_c=event.previousState)==null?void 0:_c.data)!=null&&_d.popover||(__privateSet(this,_isPopstateNavigation,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:__privateGet(this,_lastRevalidate)?void 0:__privateGet(this,_lastSubmorph),revalidate:__privateGet(this,_lastRevalidate),keepScrollPosition:__privateGet(this,_lastKeepScrollPosition)}),__privateSet(this,_isPopstateNavigation,!1))}),"#popStateListener"));__privateAdd(this,_scrollListener,__name(()=>{const{left,top}=this.scrollValue,directionY=top-__privateGet(this,_currentScrollY),directionX=left-__privateGet(this,_currentScrollX);__privateSet(this,_currentScrollY,top),__privateSet(this,_currentScrollX,left),document.documentElement.classList.toggle("scroll-y",top>0),document.documentElement.classList.toggle("scroll-x",left>0),document.documentElement.classList.toggle("scroll-y-forward",directionY>0),document.documentElement.classList.toggle("scroll-y-backward",directionY<0),document.documentElement.classList.toggle("scroll-x-forward",directionX>0),document.documentElement.classList.toggle("scroll-x-backward",directionX<0),events.dispatchEvent(document,"morphScroll",{detail:{left,top}})},"#scrollListener"));if(Store.isBrowser&&!_Morph.instance){_Morph.instance=this,__privateSet(this,_options,{base:url.normalizeBase(parameters==null?void 0:parameters.base),waitForHeadToLoad:(parameters==null?void 0:parameters.waitForHeadToLoad)!==!1,trailingSlash:(parameters==null?void 0:parameters.trailingSlash)||!1,scrollSelector:parameters==null?void 0:parameters.scrollSelector,morphInsideScrollContainer:(parameters==null?void 0:parameters.morphInsideScrollContainer)||!1}),__privateSet(this,_morphElements,__privateMethod(this,_Morph_instances,getMorphElements_fn).call(this,document.body));const normalizedURL=this.normalizePath(location.pathname+location.search+location.hash);__privateSet(this,_currentURL,normalizedURL);const initialRoute=new MorphRoute(this,__privateGet(this,_currentURL).pathname);initialRoute.setInitialDocument(document),__privateGet(this,_routes).set(__privateGet(this,_currentURL).pathname,initialRoute),document.documentElement.setAttribute("data-current-pathname",__privateGet(this,_currentURL).pathname),document.documentElement.setAttribute("data-current-leaf",normalizedURL.leaf),this.findLinks(),this.findParamsDependent(),historyManager.historyManager.addPopStateHandler(__privateGet(this,_popStateListener)),historyManager.historyManager.__change({action:"replace",pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters,hash:normalizedURL.hash}),__privateSet(this,_announcer,new MorphAnnouncer),__privateMethod(this,_Morph_instances,updateCurrentScrollElement_fn).call(this,document)}}get currentURL(){return __privateGet(this,_currentURL)}get previousURL(){return __privateGet(this,_previousURL)}get links(){return __privateGet(this,_links)}get scrollElement(){return __privateGet(this,_currentScrollElement)}get isPopstateNavigation(){return __privateGet(this,_isPopstateNavigation)}get scrollValue(){let top=0,left=0;return __privateGet(this,_isWindowScroll)?(top=window.scrollY,left=window.scrollX):(top=__privateGet(this,_currentScrollElement).scrollTop,left=__privateGet(this,_currentScrollElement).scrollLeft),{top,left}}get isNavigating(){return!!__privateGet(this,_promises).length}saveState(state){const route=__privateGet(this,_routes).get(__privateGet(this,_currentURL).path);route&&route.saveState(state)}getState(){const route=__privateGet(this,_routes).get(__privateGet(this,_currentURL).path);return route==null?void 0:route.clearState()}normalizePath(path,options){return url.splitPath(path,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash,mergeParams:options!=null&&options.mergeParams?location.search:"",removeParams:options==null?void 0:options.removeParams})}prefetch(path,revalidate){return __async(this,null,function*(){var _a;if(__privateGet(this,_promises).length)return;path=((_a=this.pathnameModifier)==null?void 0:_a.call(this,path))||path;const route=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,path);route==null||route.fetch(path,__privateGet(this,_currentURL).path,revalidate)})}excludeHeadChild(child){return!1}needRavalidation(path){const normalizedURL=this.normalizePath(path),route=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,normalizedURL.path);route==null||route.needRavalidation()}navigate(_0){return __async(this,arguments,function*(path,{historyAction="push",centerScroll,offsetScroll,scrollDuration,scrollEasing,scrollBehaviour,revalidate,keepSearchParameters,submorph,submorphAppend,clearState,keepScrollPosition,mergeParams,removeParams,detail,scrollTo}={}){var _a,_b,_c,_d;if(__privateGet(this,_promises).length)return;__privateSet(this,_lastSubmorph,submorph),__privateSet(this,_lastRevalidate,revalidate),__privateSet(this,_lastKeepScrollPosition,keepScrollPosition);const modifiedPath=((_a=this.pathnameModifier)==null?void 0:_a.call(this,path))||path,normalizedURL=this.normalizePath(modifiedPath,{mergeParams,removeParams});if(!revalidate&&(((_b=__privateGet(this,_candidateURL))==null?void 0:_b.pathname)===normalizedURL.pathname||__privateGet(this,_currentURL).pathname===normalizedURL.pathname)){keepScrollPosition||__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,scrollTo||normalizedURL.hash||0,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:"smooth"}),events.dispatchEvent(document,"morphSamePath",{detail:{detail}}),((_c=__privateGet(this,_currentURL))==null?void 0:_c.parameters)!==normalizedURL.parameters&&(__privateSet(this,_previousURL,__privateGet(this,_currentURL)),__privateSet(this,_currentURL,normalizedURL),historyManager.historyManager.__change({action:((_d=__privateGet(this,_currentURL))==null?void 0:_d.hash)!==normalizedURL.hash?"replace":historyAction,pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters,hash:normalizedURL.hash}),events.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:__privateGet(this,_currentURL),previousURL:__privateGet(this,_previousURL),detail}})),__privateGet(this,_links).forEach(link=>{link.checkCurrent(normalizedURL.path)});return}else __privateGet(this,_links).forEach(link=>{link.checkCurrent(normalizedURL.path)});__privateSet(this,_candidateURL,normalizedURL);try{let preprocessedSuccesfully=!0;if(this.preprocessor)try{yield new Promise((resolve,reject)=>{var _a2;(_a2=this.preprocessor)==null||_a2.call(this,{url:normalizedURL,resolve,reject,submorph,detail})})}catch(e){e?console.error(e):console.log("Route change canceled"),preprocessedSuccesfully=!1}if(!preprocessedSuccesfully||__privateGet(this,_candidateURL).pathname!==normalizedURL.pathname){__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)});return}const navigationEntry={url:normalizedURL,submorph,detail};submorph?submorphAppend||submorph.forEach(sel=>{document.querySelectorAll(sel).forEach(el=>{el.classList.add("out"),el.setAttribute("data-morph-out","")})}):__privateGet(this,_morphElements).forEach(el=>{var _a2,_b2;(_a2=el.firstElementChild)==null||_a2.classList.add("out"),(_b2=el.firstElementChild)==null||_b2.setAttribute("data-morph-out","")}),events.dispatchEvent(document,"morphNavigation",{detail:navigationEntry});const currentRoute=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,__privateGet(this,_currentURL).pathname),nextRoute=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,normalizedURL.pathname);if(__privateGet(this,_routes).forEach(el=>{el.pathname!==normalizedURL.pathname&&el.abort()}),yield nextRoute==null?void 0:nextRoute.fetch(modifiedPath,__privateGet(this,_currentURL).path,revalidate),__privateGet(this,_candidateURL).pathname!==normalizedURL.pathname){__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)});return}currentRoute.clearState(),currentRoute.saveScrollState(),currentRoute.saveDocumentState(),(!__privateGet(this,_isPopstateNavigation)||revalidate)&&(nextRoute.clearScrollState(),nextRoute.clearDocumentState()),clearState&&nextRoute.clearState(),nextRoute.cloneDocument(),__privateGet(this,_announcer).textContent=nextRoute.title,document.body.appendChild(__privateGet(this,_announcer));const documentFetchedEntry=__spreadProps(__spreadValues({},navigationEntry),{document:nextRoute.document});submorphAppend||documentFetchedEntry.document.querySelectorAll("[data-morph-out]").forEach(el=>{el.classList.remove("out")}),events.dispatchEvent(document,"morphStart",{detail:documentFetchedEntry});const currentHeadChildren=Array.from(document.head.children),newHeadChildren=Array.from(nextRoute.document.head.children),identicalHeadChildren=dom.intersectElements(currentHeadChildren,newHeadChildren),removeHeadChildren=dom.excludeElements(currentHeadChildren,identicalHeadChildren),addHeadChildren=dom.excludeElements(newHeadChildren,identicalHeadChildren).filter(child=>!this.excludeHeadChild(child));addHeadChildren.forEach((child,index)=>{child.tagName==="SCRIPT"&&(addHeadChildren[index]=dom.createScriptElement(child))}),addHeadChildren.forEach(child=>{document.head.appendChild(child)});const elementsWithLoad=addHeadChildren.filter(child=>{if(child.hasAttribute("data-no-waiting"))return!1;if(__privateMethod(this,_Morph_instances,isElementEmitsLoadEvent_fn).call(this,child))return!0});__privateGet(this,_options).waitForHeadToLoad&&elementsWithLoad.length&&(yield new Promise(res=>__async(this,null,function*(){let counter=0;try{for(var iter=__forAwait(elementsWithLoad),more,temp,error;more=!(temp=yield iter.next()).done;more=!1){const element=temp.value;element.onload=()=>{counter++,counter===elementsWithLoad.length&&res()}}}catch(temp){error=[temp]}finally{try{more&&(temp=iter.return)&&(yield temp.call(iter))}finally{if(error)throw error[0]}}}))),yield promises.wait(10);const oldElementsWithLoadEvent=[];submorphAppend||removeHeadChildren.forEach(child=>{child.hasAttribute("data-permanent")||(__privateMethod(this,_Morph_instances,isElementEmitsLoadEvent_fn).call(this,child)?oldElementsWithLoadEvent.push(child):child.remove())});const newMorphElements=__privateMethod(this,_Morph_instances,getMorphElements_fn).call(this,nextRoute.document.body);!__privateGet(this,_options).morphInsideScrollContainer&&!submorph&&__privateMethod(this,_Morph_instances,updateCurrentScrollElement_fn).call(this,nextRoute.document),document.documentElement.setAttribute("data-current-pathname",normalizedURL.pathname),document.documentElement.setAttribute("data-current-leaf",normalizedURL.leaf),historyManager.historyManager.__change({action:historyAction,pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters||(keepSearchParameters?location.search:""),hash:normalizedURL.hash}),__privateGet(this,_announcer).remove(),__privateSet(this,_previousURL,__privateGet(this,_currentURL)),__privateSet(this,_currentURL,normalizedURL);const morphedElements=[];__privateGet(this,_morphElements).forEach((morphElement,i)=>{const newMorphElement=newMorphElements[i],duration=getComputedStyle(morphElement).getPropertyValue("--morph-duration");let newMorphElementChildNodes=[],currentMorphElementChildNodes=[];submorph?(submorph.forEach(selector=>{const curSubMorphElement=morphElement.querySelector(selector),newSubMorphElement=newMorphElement.querySelector(selector);curSubMorphElement&&newSubMorphElement&&(currentMorphElementChildNodes.push(curSubMorphElement),newMorphElementChildNodes.push(newSubMorphElement))}),currentMorphElementChildNodes.forEach(el=>{el.parentElement&&morphedElements.push(el.parentElement)})):(newMorphElementChildNodes.push(...newMorphElement.childNodes),currentMorphElementChildNodes.push(...morphElement.childNodes),morphedElements.push(morphElement));const transfer=[];submorphAppend||currentMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&(this.destroyOldLinks(element),element.classList.add("old"),element.querySelectorAll("[data-morph-transfer]").forEach(el=>{const selector=el.getAttribute("data-morph-transfer");transfer.push({element:el,selector})}))}),newMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&(transfer.forEach(item=>{const nestlement=element.querySelector(item.selector);nestlement&&nestlement.replaceWith(nextRoute.document.importNode(item.element,!0))}),this.findNewLinks(element),element.classList.add("new"))}),submorph?submorphAppend?newMorphElementChildNodes.forEach((el,i2)=>{currentMorphElementChildNodes[i2]instanceof HTMLElement&¤tMorphElementChildNodes[i2].append(...el.childNodes)}):newMorphElementChildNodes.forEach((el,i2)=>{var _a2;(_a2=currentMorphElementChildNodes[i2].parentElement)==null||_a2.insertBefore(el,currentMorphElementChildNodes[i2])}):morphElement.prepend(...newMorphElementChildNodes),setTimeout(()=>{submorphAppend||currentMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&element.classList.add("old-idle")}),newMorphElementChildNodes.forEach(element=>{var _a2;element instanceof HTMLElement&&((_a2=element.parentElement)==null||_a2.style.setProperty("--new-content-height",element.offsetHeight+"px"),element.classList.add("new-idle"))})},0);const detail2=__spreadProps(__spreadValues({},documentFetchedEntry),{morphElement});events.dispatchEvent(document,"morphNewChildrenAdded",{detail:detail2});const promise=new Promise(res=>{setTimeout(()=>{submorphAppend||currentMorphElementChildNodes.forEach(el=>{el.remove()}),newMorphElementChildNodes.forEach(element=>{var _a2;element instanceof HTMLElement&&((_a2=element.parentElement)==null||_a2.style.removeProperty("--new-content-height"),element.classList.remove("new-idle","new"))}),submorphAppend||events.dispatchEvent(document,"morphOldChildrenRemoved",{detail:detail2}),res()},(parseFloat(duration)||0)*1e3+10)});__privateGet(this,_promises).push(promise)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-nextRoute.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),events.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:nextRoute.scrollState}),scrollTo?(nextRoute.clearScrollState(),__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,scrollTo,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:scrollBehaviour})):normalizedURL.hash?(nextRoute.clearScrollState(),__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,normalizedURL.hash,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:scrollBehaviour})):__privateGet(this,_isPopstateNavigation)?nextRoute.restoreScrollPosition():keepScrollPosition||nextRoute.renewScrollPosition(),yield Promise.all(__privateGet(this,_promises)),submorphAppend||oldElementsWithLoadEvent.forEach(child=>child.remove()),__privateSet(this,_promises,[]),morphedElements.forEach(el=>{el.querySelectorAll("script").forEach(element=>{element.replaceWith(dom.createScriptElement(element))})}),__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)}),this.findParamsDependent(),events.dispatchEvent(document,"morphComplete",{detail:documentFetchedEntry}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(e){console.error(e)}__privateSet(this,_candidateURL,void 0)})}addLink(element){__privateGet(this,_links).push(new MorphLink(element,this))}addLinks(elements){elements.forEach(element=>{this.addLink(element)})}removeLink(element){__privateSet(this,_links,__privateGet(this,_links).filter(link=>link.element===element?(link.destroy(),!1):!0))}destroyOldLinks(morphElement){__privateSet(this,_links,__privateGet(this,_links).filter(link=>morphElement.contains(link.element)?(link.destroy(),!1):!0))}findNewLinks(morphElement){const linkElements=[...morphElement.querySelectorAll("a")].filter(__privateGet(this,_checkLink));__privateGet(this,_links).push(...linkElements.map(element=>new MorphLink(element,this)))}findLinks(){const linkElements=[...document.documentElement.querySelectorAll("a")].filter(__privateGet(this,_checkLink));__privateGet(this,_links).forEach(link=>link.destroy()),__privateSet(this,_links,linkElements.map(element=>new MorphLink(element,this)))}findParamsDependent(){const elements=[...document.documentElement.querySelectorAll("[data-morph-params-dependent]")];__privateGet(this,_paramDependent).forEach(link=>link.destroy()),__privateSet(this,_paramDependent,elements.map(element=>new MorphParamsDependent(element)))}};_options=new WeakMap,_morphElements=new WeakMap,_links=new WeakMap,_candidateURL=new WeakMap,_currentURL=new WeakMap,_previousURL=new WeakMap,_promises=new WeakMap,_isPopstateNavigation=new WeakMap,_currentScrollElement=new WeakMap,_isWindowScroll=new WeakMap,_routes=new WeakMap,_paramDependent=new WeakMap,_announcer=new WeakMap,_currentScrollX=new WeakMap,_currentScrollY=new WeakMap,_lastSubmorph=new WeakMap,_lastRevalidate=new WeakMap,_lastKeepScrollPosition=new WeakMap,_checkLink=new WeakMap,_Morph_instances=new WeakSet,getRoute_fn=__name(function(path){const normalizedURL=this.normalizePath(path);let route=__privateGet(this,_routes).get(normalizedURL.pathname);return route||(route=new MorphRoute(this,normalizedURL.pathname),__privateGet(this,_routes).set(normalizedURL.pathname,route)),route},"#getRoute"),getMorphElements_fn=__name(function(el){const morphElements=[...el.querySelectorAll("[data-morph]")];return morphElements.length?morphElements:[el]},"#getMorphElements"),isElementEmitsLoadEvent_fn=__name(function(element){return element.tagName==="SCRIPT"||element.tagName==="STYLE"||element.tagName==="LINK"&&element.getAttribute("rel")==="stylesheet"},"#isElementEmitsLoadEvent"),updateCurrentScrollElement_fn=__name(function(document2){var _a,_b;(_a=__privateGet(this,_currentScrollElement))==null||_a.removeEventListener("scroll",__privateGet(this,_scrollListener)),__privateSet(this,_currentScrollY,0),__privateSet(this,_currentScrollX,0),__privateSet(this,_currentScrollElement,__privateGet(this,_options).scrollSelector&&document2.querySelector(__privateGet(this,_options).scrollSelector)||window),__privateSet(this,_isWindowScroll,__privateGet(this,_currentScrollElement)===window),(_b=__privateGet(this,_currentScrollElement))==null||_b.addEventListener("scroll",__privateGet(this,_scrollListener)),__privateGet(this,_scrollListener).call(this)},"#updateCurrentScrollElement"),tryScrollToElement_fn=__name(function(id,options){const value=typeof id=="string"?document.querySelector(id):id;(typeof value=="number"||value)&&scroll.scrollToElement(value,__spreadValues({scrollElement:__privateGet(this,_currentScrollElement)},options))},"#tryScrollToElement"),_popStateListener=new WeakMap,_scrollListener=new WeakMap,__name(_Morph,"Morph"),_Morph.instance=null;let Morph=_Morph;exports.Morph=Morph;
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __knownSymbol=(name,symbol)=>(symbol=Symbol[name])?symbol:Symbol.for("Symbol."+name),__typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);var __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});var __forAwait=(obj,it,method)=>(it=obj[__knownSymbol("asyncIterator")])?it.call(obj):(obj=obj[__knownSymbol("iterator")](),it={},method=(key,fn)=>(fn=obj[key])&&(it[key]=arg=>new Promise((yes,no,done)=>(arg=fn.call(obj,arg),done=arg.done,Promise.resolve(arg.value).then(value=>yes({value,done}),no)))),method("next"),method("return"),it);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Store=require("../Store-B96mD8mD.cjs"),dom=require("../dom-B40i6NXw.cjs"),events=require("../events-UlGk63iC.cjs"),promises=require("../promises-nDm8_iG6.cjs"),scroll=require("../scroll-DbYCgAnW.cjs");require("construct-style-sheets-polyfill");require("../index-BoGx2BWX.cjs");const url=require("../url-D0rESDQq.cjs"),cssValueParser_index=require("../css-value-parser/index.cjs"),historyManager=require("../historyManager-DB2fSEtH.cjs"),_MorphAnnouncer=class _MorphAnnouncer extends HTMLElement{connectedCallback(){const attrs={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[key,value]of Object.entries(attrs))this.setAttribute(key,value)}};__name(_MorphAnnouncer,"MorphAnnouncer");let MorphAnnouncer=_MorphAnnouncer;Store.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",MorphAnnouncer);var _morph,_element,_MorphLink_instances,path_get,click_fn,_clickListener,_pointerListener;const _MorphLink=class _MorphLink{constructor(element,morph){__privateAdd(this,_MorphLink_instances);__privateAdd(this,_morph);__privateAdd(this,_element);__privateAdd(this,_clickListener,__name(e=>{e.preventDefault(),__privateMethod(this,_MorphLink_instances,click_fn).call(this)},"#clickListener"));__privateAdd(this,_pointerListener,__name(()=>{const revalidate=__privateGet(this,_element).hasAttribute("data-revalidate");__privateGet(this,_morph).prefetch(__privateGet(this,_MorphLink_instances,path_get),revalidate),__privateGet(this,_element).removeEventListener("pointerenter",__privateGet(this,_pointerListener))},"#pointerListener"));__privateSet(this,_morph,morph),__privateSet(this,_element,element),__privateGet(this,_element).addEventListener("click",__privateGet(this,_clickListener)),this.checkCurrent(location.href.replace(location.origin,"")),__privateGet(this,_element).hasAttribute("data-prefetch")&&__privateGet(this,_element).addEventListener("pointerenter",__privateGet(this,_pointerListener))}get element(){return __privateGet(this,_element)}checkCurrent(path){var _a,_b;const locationUrl=__privateGet(this,_morph).normalizePath(path),linkUrl=__privateGet(this,_morph).normalizePath(__privateGet(this,_MorphLink_instances,path_get));__privateGet(this,_element).hasAttribute("data-include")&&locationUrl.pathname.includes(linkUrl.pathname)?__privateGet(this,_element).classList.add("current"):linkUrl.pathname===locationUrl.pathname?__privateGet(this,_element).classList.add("current"):(_a=__privateGet(this,_element).getAttribute("data-associated-paths"))!=null&&_a.split(",").find(path2=>locationUrl.pathname.includes(path2))?__privateGet(this,_element).classList.add("current"):__privateGet(this,_element).classList.remove("current"),locationUrl.path===linkUrl.path?__privateGet(this,_element).classList.add("exact"):__privateGet(this,_element).classList.remove("exact");const[pathWithoutParams,pathParamsStr]=(_b=__privateGet(this,_MorphLink_instances,path_get).split("#")[0])==null?void 0:_b.split("?"),pathParams=new URLSearchParams(pathParamsStr),locationParams=new URLSearchParams(location.search);let matchCounter=0;for(const[key]of locationParams)pathParams.has(key)&&locationParams.get(key)===pathParams.get(key)&&matchCounter++;matchCounter?(__privateGet(this,_element).classList.toggle("all-params-matched",locationParams.size===matchCounter),__privateGet(this,_element).classList.toggle("some-params-matched",locationParams.size!==matchCounter)):!locationParams.size&&__privateGet(this,_element).hasAttribute("data-match-no-params")?__privateGet(this,_element).classList.add("all-params-matched"):(__privateGet(this,_element).classList.remove("all-params-matched"),__privateGet(this,_element).classList.remove("some-params-matched"));for(const key in __privateGet(this,_element).dataset){const kebabKey=Store.camelToKebab(key);if(kebabKey.startsWith("match-param-")){const name=kebabKey.split("match-param-")[1],value=__privateGet(this,_element).dataset[key],className=`param-${name}-matched`;locationParams.has(name)&&locationParams.get(name)===value||!locationParams.has(name)&&(value===""||value==="*"||value==="all"||value==="any"||value==="vse")?__privateGet(this,_element).classList.add(className):__privateGet(this,_element).classList.remove(className)}}}destroy(){__privateGet(this,_element).removeEventListener("click",__privateGet(this,_clickListener)),__privateGet(this,_element).removeEventListener("pointerenter",__privateGet(this,_pointerListener)),__privateGet(this,_element).classList.remove("current","exact")}};_morph=new WeakMap,_element=new WeakMap,_MorphLink_instances=new WeakSet,path_get=__name(function(){const url2=new URL(__privateGet(this,_element).href);return __privateGet(this,_morph).normalizePath(url2.pathname+url2.search+url2.hash).path},"#path"),click_fn=__name(function(){var _a;if(document.documentElement.classList.contains("click-disabled"))return;if(__privateGet(this,_element).hasAttribute("data-back")&&__privateGet(this,_morph).previousURL)history.back();else{const historyAction=__privateGet(this,_element).getAttribute("data-history-action")||"push",centerScroll=__privateGet(this,_element).hasAttribute("data-center-scroll"),offsetScrollRawValue=getComputedStyle(__privateGet(this,_element)).getPropertyValue("--offset-scroll").trim(),offsetScroll=offsetScrollRawValue?cssValueParser_index.cssValueParser.parse(offsetScrollRawValue):void 0,scrollDuration=parseFloat(__privateGet(this,_element).getAttribute("data-scroll-duration")||"0")||void 0,scrollEasing=__privateGet(this,_element).getAttribute("data-scroll-easing")||void 0,revalidate=__privateGet(this,_element).hasAttribute("data-revalidate")||__privateGet(this,_element).hasAttribute("data-pagination-more-link")||__privateGet(this,_element).hasAttribute("data-pagination-set-link")||__privateGet(this,_element).hasAttribute("data-pagination-next-link")||__privateGet(this,_element).hasAttribute("data-pagination-prev-link"),keepSearchParameters=__privateGet(this,_element).hasAttribute("data-keep-search-parameters"),keepScrollPosition=__privateGet(this,_element).hasAttribute("data-keep-scroll-position")||__privateGet(this,_element).hasAttribute("data-pagination-more-link"),scrollBehaviour=__privateGet(this,_element).getAttribute("data-scroll-behaviour"),submorph=(_a=__privateGet(this,_element).getAttribute("data-submorph")||__privateGet(this,_element).getAttribute("data-submorph-append"))==null?void 0:_a.split(",").map(v=>v.trim()),clearState=__privateGet(this,_element).hasAttribute("data-clear-state");let path=__privateGet(this,_MorphLink_instances,path_get);if(__privateGet(this,_element).hasAttribute("data-toggle-params")){const[pathWithoutParams,pathParamsStr]=__privateGet(this,_MorphLink_instances,path_get).split("?"),pathParams=new URLSearchParams(pathParamsStr),locationParams=new URLSearchParams(location.search),resultParams=new URLSearchParams;for(const[key]of pathParams)(!locationParams.has(key)||locationParams.has(key)&&locationParams.get(key)!==pathParams.get(key))&&resultParams.append(key,pathParams.get(key));if(__privateGet(this,_element).hasAttribute("data-merge-params"))for(const[key]of locationParams)pathParams.has(key)||resultParams.append(key,locationParams.get(key));path=`${pathWithoutParams}?${resultParams.toString()}`}__privateGet(this,_morph).navigate(path,{historyAction,centerScroll,offsetScroll,revalidate,keepSearchParameters,submorph,clearState,keepScrollPosition,scrollBehaviour,scrollDuration,scrollEasing,submorphAppend:__privateGet(this,_element).hasAttribute("data-submorph-append"),mergeParams:__privateGet(this,_element).hasAttribute("data-merge-params")&&!__privateGet(this,_element).hasAttribute("data-toggle-params"),detail:__privateGet(this,_element).getAttribute("data-detail"),removeParams:__privateGet(this,_element).getAttribute("data-remove-params")||void 0,scrollTo:__privateGet(this,_element).getAttribute("data-scroll-to")||void 0})}},"#click"),_clickListener=new WeakMap,_pointerListener=new WeakMap,__name(_MorphLink,"MorphLink");let MorphLink=_MorphLink;var _element2,_params,_MorphParamsDependent_instances,update_fn,_urlChangeListener;const _MorphParamsDependent=class _MorphParamsDependent{constructor(element){__privateAdd(this,_MorphParamsDependent_instances);__privateAdd(this,_element2);__privateAdd(this,_params,[]);__privateAdd(this,_urlChangeListener,__name(()=>{__privateMethod(this,_MorphParamsDependent_instances,update_fn).call(this)},"#urlChangeListener"));__privateSet(this,_element2,element);for(const key in __privateGet(this,_element2).dataset){const kebabKey=Store.camelToKebab(key);if(kebabKey.startsWith("param-")){const name=kebabKey.split("param-")[1],value=__privateGet(this,_element2).dataset[key];__privateGet(this,_params).push({name,value})}}document.addEventListener("morphURLParametersChange",__privateGet(this,_urlChangeListener)),__privateMethod(this,_MorphParamsDependent_instances,update_fn).call(this)}destroy(){document.removeEventListener("morphURLParametersChange",__privateGet(this,_urlChangeListener))}};_element2=new WeakMap,_params=new WeakMap,_MorphParamsDependent_instances=new WeakSet,update_fn=__name(function(){const locationParams=new URLSearchParams(location.search);let matched=!!__privateGet(this,_params).find(param=>locationParams.has(param.name)&&(locationParams.get(param.name)===param.value||param.value==="*"||param.value==="all"||param.value==="any"||param.value==="vse"||locationParams.get(param.name)==="*"||locationParams.get(param.name)==="all"||locationParams.get(param.name)==="any"||locationParams.get(param.name)==="vse"));!matched&&__privateGet(this,_element2).hasAttribute("data-match-no-params")&&(matched=!__privateGet(this,_params).filter(param=>locationParams.has(param.name)).length);const hideClass=__privateGet(this,_element2).getAttribute("data-hide-class");matched?hideClass?__privateGet(this,_element2).classList.remove(hideClass):__privateGet(this,_element2).style.display="":hideClass?__privateGet(this,_element2).classList.add(hideClass):__privateGet(this,_element2).style.display="none",requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("resize"))})},"#update"),_urlChangeListener=new WeakMap,__name(_MorphParamsDependent,"MorphParamsDependent");let MorphParamsDependent=_MorphParamsDependent;const domParser=new DOMParser;var _morph2,_pathname,_scrollState,_initialDocument,_modifiedDocument,_currentDocument,_savedState,_abortController,_fetching,_headers,_needRavalidation;const _MorphRoute=class _MorphRoute{constructor(morph,pathname){__privateAdd(this,_morph2);__privateAdd(this,_pathname);__privateAdd(this,_scrollState,{x:0,y:0});__privateAdd(this,_initialDocument,null);__privateAdd(this,_modifiedDocument,null);__privateAdd(this,_currentDocument,null);__privateAdd(this,_savedState,null);__privateAdd(this,_abortController,null);__privateAdd(this,_fetching,null);__privateAdd(this,_headers);__privateAdd(this,_needRavalidation,!1);__privateSet(this,_morph2,morph),__privateSet(this,_pathname,pathname)}get pathname(){return __privateGet(this,_pathname)}get scrollState(){return __privateGet(this,_scrollState)}get document(){return __privateGet(this,_currentDocument)}needRavalidation(){__privateSet(this,_needRavalidation,!0)}setHeaders(headers){__privateSet(this,_headers,headers)}setInitialDocument(document2){__privateSet(this,_initialDocument,document2.cloneNode(!0))}abort(){var _a;return(_a=__privateGet(this,_abortController))==null?void 0:_a.abort(`[${__privateGet(this,_pathname)}] page loading cancelled`)}fetch(path,currentPath,revalidate){return __async(this,null,function*(){var _a;if(!revalidate&&!__privateGet(this,_needRavalidation)){const shouldUseCache=((_a=__privateGet(this,_initialDocument))==null?void 0:_a.documentElement.getAttribute("data-cache"))&¤tPath!==path,isPopstateNavigation=__privateGet(this,_initialDocument)&&__privateGet(this,_morph2).isPopstateNavigation;if(__privateGet(this,_fetching)||shouldUseCache||isPopstateNavigation)return __privateGet(this,_fetching)}return __privateSet(this,_fetching,new Promise(res=>__async(this,null,function*(){try{__privateSet(this,_abortController,new AbortController);const text=yield(yield fetch(path,{signal:__privateGet(this,_abortController).signal,headers:__spreadValues({"X-MORPH":"true","X-MORPH-REVALIDATE":revalidate?"true":"false","X-MORPH-CURRENT-PATH":encodeURIComponent(currentPath),"X-MORPH-NEW-PATH":encodeURIComponent(path)},__privateGet(this,_headers))})).text(),document2=domParser.parseFromString(text,"text/html");this.setInitialDocument(document2),__privateSet(this,_needRavalidation,!1)}catch(e){console.warn(e)}finally{__privateSet(this,_abortController,null),__privateSet(this,_fetching,null),res()}}))),__privateGet(this,_fetching)})}cloneDocument(){__privateSet(this,_currentDocument,(__privateGet(this,_modifiedDocument)||__privateGet(this,_initialDocument)).cloneNode(!0))}get title(){let title="";if(__privateGet(this,_currentDocument).title)title=__privateGet(this,_currentDocument).title;else{const h1=__privateGet(this,_currentDocument).querySelector("h1");title=(h1==null?void 0:h1.innerText)||(h1==null?void 0:h1.textContent)||__privateGet(this,_pathname)}return title}clearScrollState(){__privateGet(this,_scrollState).x=0,__privateGet(this,_scrollState).y=0}clearDocumentState(){__privateSet(this,_modifiedDocument,null)}saveScrollState(){__privateGet(this,_initialDocument).documentElement.hasAttribute("data-no-scroll-restoration")?(__privateGet(this,_scrollState).x=0,__privateGet(this,_scrollState).y=0):(__privateGet(this,_scrollState).x=__privateGet(this,_morph2).scrollValue.left,__privateGet(this,_scrollState).y=__privateGet(this,_morph2).scrollValue.top)}restoreScrollPosition(){__privateGet(this,_morph2).scrollElement.scroll({top:__privateGet(this,_scrollState).y,left:__privateGet(this,_scrollState).x,behavior:"instant"})}saveDocumentState(){__privateGet(this,_initialDocument).documentElement.hasAttribute("data-no-page-restoration")?__privateSet(this,_modifiedDocument,null):__privateSet(this,_modifiedDocument,document.cloneNode(!0))}renewScrollPosition(){__privateGet(this,_morph2).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(state){__privateSet(this,_savedState,state)}clearState(){const state=__privateGet(this,_savedState);return __privateSet(this,_savedState,null),state}};_morph2=new WeakMap,_pathname=new WeakMap,_scrollState=new WeakMap,_initialDocument=new WeakMap,_modifiedDocument=new WeakMap,_currentDocument=new WeakMap,_savedState=new WeakMap,_abortController=new WeakMap,_fetching=new WeakMap,_headers=new WeakMap,_needRavalidation=new WeakMap,__name(_MorphRoute,"MorphRoute");let MorphRoute=_MorphRoute;var _options,_morphElements,_links,_candidateURL,_currentURL,_previousURL,_promises,_isPopstateNavigation,_currentScrollElement,_isWindowScroll,_routes,_paramDependent,_announcer,_currentScrollX,_currentScrollY,_lastSubmorph,_lastRevalidate,_lastKeepScrollPosition,_checkLink,_Morph_instances,getRoute_fn,getMorphElements_fn,isElementEmitsLoadEvent_fn,updateCurrentScrollElement_fn,tryScrollToElement_fn,_popStateListener,_scrollListener;const _Morph=class _Morph{constructor(parameters){__privateAdd(this,_Morph_instances);__privateAdd(this,_options,null);__privateAdd(this,_morphElements,null);__privateAdd(this,_links,[]);__privateAdd(this,_candidateURL);__privateAdd(this,_currentURL,null);__privateAdd(this,_previousURL);__privateAdd(this,_promises,[]);__privateAdd(this,_isPopstateNavigation,!1);__privateAdd(this,_currentScrollElement,null);__privateAdd(this,_isWindowScroll,!1);__privateAdd(this,_routes,new Map);__privateAdd(this,_paramDependent,[]);__privateAdd(this,_announcer,null);__privateAdd(this,_currentScrollX,0);__privateAdd(this,_currentScrollY,0);__privateAdd(this,_lastSubmorph);__privateAdd(this,_lastRevalidate);__privateAdd(this,_lastKeepScrollPosition);__privateAdd(this,_checkLink,__name(element=>{var _a,_b;return(((_a=element.getAttribute("href"))==null?void 0:_a.startsWith("/"))||((_b=element.getAttribute("href"))==null?void 0:_b.startsWith("?")))&&!element.hasAttribute("download")&&!element.hasAttribute("data-morph-skip")&&!element.closest("[data-morph-skip]")&&element.getAttribute("target")!=="_blank"},"#checkLink"));__privateAdd(this,_popStateListener,__name(event=>__async(this,null,function*(){var _a,_b,_c,_d;(_b=(_a=event.state)==null?void 0:_a.data)!=null&&_b.popover||(_d=(_c=event.previousState)==null?void 0:_c.data)!=null&&_d.popover||(__privateSet(this,_isPopstateNavigation,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:__privateGet(this,_lastRevalidate)?void 0:__privateGet(this,_lastSubmorph),revalidate:__privateGet(this,_lastRevalidate),keepScrollPosition:__privateGet(this,_lastKeepScrollPosition)}),__privateSet(this,_isPopstateNavigation,!1))}),"#popStateListener"));__privateAdd(this,_scrollListener,__name(()=>{const{left,top}=this.scrollValue,directionY=top-__privateGet(this,_currentScrollY),directionX=left-__privateGet(this,_currentScrollX);__privateSet(this,_currentScrollY,top),__privateSet(this,_currentScrollX,left),document.documentElement.classList.toggle("scroll-y",top>0),document.documentElement.classList.toggle("scroll-x",left>0),document.documentElement.classList.toggle("scroll-y-forward",directionY>0),document.documentElement.classList.toggle("scroll-y-backward",directionY<0),document.documentElement.classList.toggle("scroll-x-forward",directionX>0),document.documentElement.classList.toggle("scroll-x-backward",directionX<0),events.dispatchEvent(document,"morphScroll",{detail:{left,top}})},"#scrollListener"));if(Store.isBrowser&&!_Morph.instance){_Morph.instance=this,__privateSet(this,_options,{base:url.normalizeBase(parameters==null?void 0:parameters.base),waitForHeadToLoad:(parameters==null?void 0:parameters.waitForHeadToLoad)!==!1,trailingSlash:(parameters==null?void 0:parameters.trailingSlash)||!1,scrollSelector:parameters==null?void 0:parameters.scrollSelector,morphInsideScrollContainer:(parameters==null?void 0:parameters.morphInsideScrollContainer)||!1}),__privateSet(this,_morphElements,__privateMethod(this,_Morph_instances,getMorphElements_fn).call(this,document.body));const normalizedURL=this.normalizePath(location.pathname+location.search+location.hash);__privateSet(this,_currentURL,normalizedURL);const initialRoute=new MorphRoute(this,__privateGet(this,_currentURL).pathname);initialRoute.setInitialDocument(document),__privateGet(this,_routes).set(__privateGet(this,_currentURL).pathname,initialRoute),document.documentElement.setAttribute("data-current-pathname",__privateGet(this,_currentURL).pathname),document.documentElement.setAttribute("data-current-leaf",normalizedURL.leaf),this.findLinks(),this.findParamsDependent(),historyManager.historyManager.addPopStateHandler(__privateGet(this,_popStateListener)),historyManager.historyManager.__change({action:"replace",pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters,hash:normalizedURL.hash}),__privateSet(this,_announcer,new MorphAnnouncer),__privateMethod(this,_Morph_instances,updateCurrentScrollElement_fn).call(this,document)}}get currentURL(){return __privateGet(this,_currentURL)}get previousURL(){return __privateGet(this,_previousURL)}get links(){return __privateGet(this,_links)}get scrollElement(){return __privateGet(this,_currentScrollElement)}get isPopstateNavigation(){return __privateGet(this,_isPopstateNavigation)}get scrollValue(){let top=0,left=0;return __privateGet(this,_isWindowScroll)?(top=window.scrollY,left=window.scrollX):(top=__privateGet(this,_currentScrollElement).scrollTop,left=__privateGet(this,_currentScrollElement).scrollLeft),{top,left}}get isNavigating(){return!!__privateGet(this,_promises).length}saveState(state){const route=__privateGet(this,_routes).get(__privateGet(this,_currentURL).path);route&&route.saveState(state)}getState(){const route=__privateGet(this,_routes).get(__privateGet(this,_currentURL).path);return route==null?void 0:route.clearState()}normalizePath(path,options){return url.splitPath(path,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash,mergeParams:options!=null&&options.mergeParams?location.search:"",removeParams:options==null?void 0:options.removeParams})}prefetch(path,revalidate){return __async(this,null,function*(){var _a;if(__privateGet(this,_promises).length)return;path=((_a=this.pathnameModifier)==null?void 0:_a.call(this,path))||path;const route=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,path);route==null||route.fetch(path,__privateGet(this,_currentURL).path,revalidate)})}excludeHeadChild(child){return!1}needRavalidation(path){const normalizedURL=this.normalizePath(path),route=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,normalizedURL.path);route==null||route.needRavalidation()}navigate(_0){return __async(this,arguments,function*(path,{historyAction="push",centerScroll,offsetScroll,scrollDuration,scrollEasing,scrollBehaviour,revalidate,keepSearchParameters,submorph,submorphAppend,clearState,keepScrollPosition,mergeParams,removeParams,detail,scrollTo}={}){var _a,_b,_c,_d;if(__privateGet(this,_promises).length)return;__privateSet(this,_lastSubmorph,submorph),__privateSet(this,_lastRevalidate,revalidate),__privateSet(this,_lastKeepScrollPosition,keepScrollPosition);const modifiedPath=((_a=this.pathnameModifier)==null?void 0:_a.call(this,path))||path,normalizedURL=this.normalizePath(modifiedPath,{mergeParams,removeParams});if(!revalidate&&(((_b=__privateGet(this,_candidateURL))==null?void 0:_b.pathname)===normalizedURL.pathname||__privateGet(this,_currentURL).pathname===normalizedURL.pathname)){keepScrollPosition||__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,scrollTo||normalizedURL.hash||0,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:"smooth"}),events.dispatchEvent(document,"morphSamePath",{detail:{detail}}),((_c=__privateGet(this,_currentURL))==null?void 0:_c.parameters)!==normalizedURL.parameters&&(__privateSet(this,_previousURL,__privateGet(this,_currentURL)),__privateSet(this,_currentURL,normalizedURL),historyManager.historyManager.__change({action:((_d=__privateGet(this,_currentURL))==null?void 0:_d.hash)!==normalizedURL.hash?"replace":historyAction,pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters,hash:normalizedURL.hash}),events.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:__privateGet(this,_currentURL),previousURL:__privateGet(this,_previousURL),detail}})),__privateGet(this,_links).forEach(link=>{link.checkCurrent(normalizedURL.path)});return}else __privateGet(this,_links).forEach(link=>{link.checkCurrent(normalizedURL.path)});__privateSet(this,_candidateURL,normalizedURL);try{let preprocessedSuccesfully=!0;if(this.preprocessor)try{yield new Promise((resolve,reject)=>{var _a2;(_a2=this.preprocessor)==null||_a2.call(this,{url:normalizedURL,resolve,reject,submorph,detail})})}catch(e){e?console.error(e):console.log("Route change canceled"),preprocessedSuccesfully=!1}if(!preprocessedSuccesfully||__privateGet(this,_candidateURL).pathname!==normalizedURL.pathname){__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)});return}const navigationEntry={url:normalizedURL,submorph,detail};submorph?submorphAppend||submorph.forEach(sel=>{document.querySelectorAll(sel).forEach(el=>{el.classList.add("out"),el.setAttribute("data-morph-out","")})}):__privateGet(this,_morphElements).forEach(el=>{var _a2,_b2;(_a2=el.firstElementChild)==null||_a2.classList.add("out"),(_b2=el.firstElementChild)==null||_b2.setAttribute("data-morph-out","")}),events.dispatchEvent(document,"morphNavigation",{detail:navigationEntry});const currentRoute=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,__privateGet(this,_currentURL).pathname),nextRoute=__privateMethod(this,_Morph_instances,getRoute_fn).call(this,normalizedURL.pathname);if(__privateGet(this,_routes).forEach(el=>{el.pathname!==normalizedURL.pathname&&el.abort()}),yield nextRoute==null?void 0:nextRoute.fetch(modifiedPath,__privateGet(this,_currentURL).path,revalidate),__privateGet(this,_candidateURL).pathname!==normalizedURL.pathname){__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)});return}currentRoute.clearState(),currentRoute.saveScrollState(),currentRoute.saveDocumentState(),(!__privateGet(this,_isPopstateNavigation)||revalidate)&&(nextRoute.clearScrollState(),nextRoute.clearDocumentState()),clearState&&nextRoute.clearState(),nextRoute.cloneDocument(),__privateGet(this,_announcer).textContent=nextRoute.title,document.body.appendChild(__privateGet(this,_announcer));const documentFetchedEntry=__spreadProps(__spreadValues({},navigationEntry),{document:nextRoute.document});submorphAppend||documentFetchedEntry.document.querySelectorAll("[data-morph-out]").forEach(el=>{el.classList.remove("out")}),events.dispatchEvent(document,"morphStart",{detail:documentFetchedEntry});const currentHeadChildren=Array.from(document.head.children),newHeadChildren=Array.from(nextRoute.document.head.children),identicalHeadChildren=dom.intersectElements(currentHeadChildren,newHeadChildren),removeHeadChildren=dom.excludeElements(currentHeadChildren,identicalHeadChildren),addHeadChildren=dom.excludeElements(newHeadChildren,identicalHeadChildren).filter(child=>!this.excludeHeadChild(child));addHeadChildren.forEach((child,index)=>{child.tagName==="SCRIPT"&&(addHeadChildren[index]=dom.createScriptElement(child))}),addHeadChildren.forEach(child=>{document.head.appendChild(child)});const elementsWithLoad=addHeadChildren.filter(child=>{if(child.hasAttribute("data-no-waiting"))return!1;if(__privateMethod(this,_Morph_instances,isElementEmitsLoadEvent_fn).call(this,child))return!0});__privateGet(this,_options).waitForHeadToLoad&&elementsWithLoad.length&&(yield new Promise(res=>__async(this,null,function*(){let counter=0;try{for(var iter=__forAwait(elementsWithLoad),more,temp,error;more=!(temp=yield iter.next()).done;more=!1){const element=temp.value;element.onload=()=>{counter++,counter===elementsWithLoad.length&&res()}}}catch(temp){error=[temp]}finally{try{more&&(temp=iter.return)&&(yield temp.call(iter))}finally{if(error)throw error[0]}}}))),yield promises.wait(10);const oldElementsWithLoadEvent=[];submorphAppend||removeHeadChildren.forEach(child=>{child.hasAttribute("data-permanent")||(__privateMethod(this,_Morph_instances,isElementEmitsLoadEvent_fn).call(this,child)?oldElementsWithLoadEvent.push(child):child.remove())});const newMorphElements=__privateMethod(this,_Morph_instances,getMorphElements_fn).call(this,nextRoute.document.body);!__privateGet(this,_options).morphInsideScrollContainer&&!submorph&&__privateMethod(this,_Morph_instances,updateCurrentScrollElement_fn).call(this,nextRoute.document),document.documentElement.setAttribute("data-current-pathname",normalizedURL.pathname),document.documentElement.setAttribute("data-current-leaf",normalizedURL.leaf),historyManager.historyManager.__change({action:historyAction,pathname:normalizedURL.pathname,searchParameters:normalizedURL.parameters||(keepSearchParameters?location.search:""),hash:normalizedURL.hash}),__privateGet(this,_announcer).remove(),__privateSet(this,_previousURL,__privateGet(this,_currentURL)),__privateSet(this,_currentURL,normalizedURL);const morphedElements=[];__privateGet(this,_morphElements).forEach((morphElement,i)=>{const newMorphElement=newMorphElements[i],duration=getComputedStyle(morphElement).getPropertyValue("--morph-duration");let newMorphElementChildNodes=[],currentMorphElementChildNodes=[];submorph?(submorph.forEach(selector=>{const curSubMorphElement=morphElement.querySelector(selector),newSubMorphElement=newMorphElement.querySelector(selector);curSubMorphElement&&newSubMorphElement&&(currentMorphElementChildNodes.push(curSubMorphElement),newMorphElementChildNodes.push(newSubMorphElement))}),currentMorphElementChildNodes.forEach(el=>{el.parentElement&&morphedElements.push(el.parentElement)})):(newMorphElementChildNodes.push(...newMorphElement.childNodes),currentMorphElementChildNodes.push(...morphElement.childNodes),morphedElements.push(morphElement));const transfer=[];submorphAppend||currentMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&(this.destroyOldLinks(element),element.classList.add("old"),element.querySelectorAll("[data-morph-transfer]").forEach(el=>{const selector=el.getAttribute("data-morph-transfer");transfer.push({element:el,selector})}))}),newMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&(transfer.forEach(item=>{const nestlement=element.querySelector(item.selector);nestlement&&nestlement.replaceWith(nextRoute.document.importNode(item.element,!0))}),this.findNewLinks(element),element.classList.add("new"))}),submorph?submorphAppend?newMorphElementChildNodes.forEach((el,i2)=>{currentMorphElementChildNodes[i2]instanceof HTMLElement&¤tMorphElementChildNodes[i2].append(...el.childNodes)}):newMorphElementChildNodes.forEach((el,i2)=>{var _a2;(_a2=currentMorphElementChildNodes[i2].parentElement)==null||_a2.insertBefore(el,currentMorphElementChildNodes[i2])}):morphElement.prepend(...newMorphElementChildNodes),setTimeout(()=>{submorphAppend||currentMorphElementChildNodes.forEach(element=>{element instanceof HTMLElement&&element.classList.add("old-idle")}),newMorphElementChildNodes.forEach(element=>{var _a2;element instanceof HTMLElement&&((_a2=element.parentElement)==null||_a2.style.setProperty("--new-content-height",element.offsetHeight+"px"),element.classList.add("new-idle"))})},0);const detail2=__spreadProps(__spreadValues({},documentFetchedEntry),{morphElement});events.dispatchEvent(document,"morphNewChildrenAdded",{detail:detail2});const promise=new Promise(res=>{setTimeout(()=>{submorphAppend||currentMorphElementChildNodes.forEach(el=>{el.remove()}),newMorphElementChildNodes.forEach(element=>{var _a2;element instanceof HTMLElement&&((_a2=element.parentElement)==null||_a2.style.removeProperty("--new-content-height"),element.classList.remove("new-idle","new"))}),submorphAppend||events.dispatchEvent(document,"morphOldChildrenRemoved",{detail:detail2}),res()},(parseFloat(duration)||0)*1e3+10)});__privateGet(this,_promises).push(promise)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-nextRoute.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),events.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:nextRoute.scrollState}),scrollTo?(nextRoute.clearScrollState(),__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,scrollTo,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:scrollBehaviour})):normalizedURL.hash?(nextRoute.clearScrollState(),__privateMethod(this,_Morph_instances,tryScrollToElement_fn).call(this,normalizedURL.hash,{center:centerScroll,offset:offsetScroll,duration:scrollDuration,easing:scrollEasing,behavior:scrollBehaviour})):__privateGet(this,_isPopstateNavigation)?nextRoute.restoreScrollPosition():keepScrollPosition||nextRoute.renewScrollPosition(),yield Promise.all(__privateGet(this,_promises)),submorphAppend||oldElementsWithLoadEvent.forEach(child=>child.remove()),__privateSet(this,_promises,[]),morphedElements.forEach(el=>{el.querySelectorAll("script").forEach(element=>{element.replaceWith(dom.createScriptElement(element))})}),__privateGet(this,_links).forEach(link=>{link.checkCurrent(__privateGet(this,_currentURL).path)}),this.findParamsDependent(),events.dispatchEvent(document,"morphComplete",{detail:documentFetchedEntry}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(e){console.error(e)}__privateSet(this,_candidateURL,void 0)})}addLink(element){__privateGet(this,_links).push(new MorphLink(element,this))}addLinks(elements){elements.forEach(element=>{this.addLink(element)})}removeLink(element){__privateSet(this,_links,__privateGet(this,_links).filter(link=>link.element===element?(link.destroy(),!1):!0))}destroyOldLinks(morphElement){__privateSet(this,_links,__privateGet(this,_links).filter(link=>morphElement.contains(link.element)?(link.destroy(),!1):!0))}findNewLinks(morphElement){const linkElements=[...morphElement.querySelectorAll("a")].filter(__privateGet(this,_checkLink));__privateGet(this,_links).push(...linkElements.map(element=>new MorphLink(element,this)))}findLinks(){const linkElements=[...document.documentElement.querySelectorAll("a")].filter(__privateGet(this,_checkLink));__privateGet(this,_links).forEach(link=>link.destroy()),__privateSet(this,_links,linkElements.map(element=>new MorphLink(element,this)))}findParamsDependent(){const elements=[...document.documentElement.querySelectorAll("[data-morph-params-dependent]")];__privateGet(this,_paramDependent).forEach(link=>link.destroy()),__privateSet(this,_paramDependent,elements.map(element=>new MorphParamsDependent(element)))}};_options=new WeakMap,_morphElements=new WeakMap,_links=new WeakMap,_candidateURL=new WeakMap,_currentURL=new WeakMap,_previousURL=new WeakMap,_promises=new WeakMap,_isPopstateNavigation=new WeakMap,_currentScrollElement=new WeakMap,_isWindowScroll=new WeakMap,_routes=new WeakMap,_paramDependent=new WeakMap,_announcer=new WeakMap,_currentScrollX=new WeakMap,_currentScrollY=new WeakMap,_lastSubmorph=new WeakMap,_lastRevalidate=new WeakMap,_lastKeepScrollPosition=new WeakMap,_checkLink=new WeakMap,_Morph_instances=new WeakSet,getRoute_fn=__name(function(path){const normalizedURL=this.normalizePath(path);let route=__privateGet(this,_routes).get(normalizedURL.pathname);return route||(route=new MorphRoute(this,normalizedURL.pathname),__privateGet(this,_routes).set(normalizedURL.pathname,route)),route},"#getRoute"),getMorphElements_fn=__name(function(el){const morphElements=[...el.querySelectorAll("[data-morph]")];return morphElements.length?morphElements:[el]},"#getMorphElements"),isElementEmitsLoadEvent_fn=__name(function(element){return element.tagName==="SCRIPT"||element.tagName==="STYLE"||element.tagName==="LINK"&&element.getAttribute("rel")==="stylesheet"},"#isElementEmitsLoadEvent"),updateCurrentScrollElement_fn=__name(function(document2){var _a,_b;(_a=__privateGet(this,_currentScrollElement))==null||_a.removeEventListener("scroll",__privateGet(this,_scrollListener)),__privateSet(this,_currentScrollY,0),__privateSet(this,_currentScrollX,0),__privateSet(this,_currentScrollElement,__privateGet(this,_options).scrollSelector&&document2.querySelector(__privateGet(this,_options).scrollSelector)||window),__privateSet(this,_isWindowScroll,__privateGet(this,_currentScrollElement)===window),(_b=__privateGet(this,_currentScrollElement))==null||_b.addEventListener("scroll",__privateGet(this,_scrollListener)),__privateGet(this,_scrollListener).call(this)},"#updateCurrentScrollElement"),tryScrollToElement_fn=__name(function(id,options){const value=typeof id=="string"?document.querySelector(id):id;(typeof value=="number"||value)&&scroll.scrollToElement(value,__spreadValues({scrollElement:__privateGet(this,_currentScrollElement)},options))},"#tryScrollToElement"),_popStateListener=new WeakMap,_scrollListener=new WeakMap,__name(_Morph,"Morph"),_Morph.instance=null;let Morph=_Morph;exports.Morph=Morph;
|
package/lib/morph/index.js
CHANGED
|
@@ -36,7 +36,7 @@ import { i as isBrowser, c as camelToKebab } from "../Store-CAGUSjFX.js";
|
|
|
36
36
|
import { i as intersectElements, e as excludeElements, c as createScriptElement } from "../dom-D8D-_9ty.js";
|
|
37
37
|
import { d as dispatchEvent } from "../events-Ds-TuvYW.js";
|
|
38
38
|
import { w as wait } from "../promises-BsIKOEDq.js";
|
|
39
|
-
import { s as scrollToElement } from "../scroll-
|
|
39
|
+
import { s as scrollToElement } from "../scroll-CqF_88wv.js";
|
|
40
40
|
import "construct-style-sheets-polyfill";
|
|
41
41
|
import "../index-DAG0CtYo.js";
|
|
42
42
|
import { a as normalizeBase, c as splitPath } from "../url-DTxLpq5m.js";
|