aptechka 0.71.8 → 0.71.10
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/SourceElement-8nqiFLJ2.cjs +5 -0
- package/lib/SourceElement-DrZ3QNm-.js +257 -0
- package/lib/iframe/index.cjs +1 -1
- package/lib/iframe/index.js +1 -1
- package/lib/image/index.cjs +1 -1
- package/lib/image/index.js +1 -1
- package/lib/morph/Morph.d.ts +1 -0
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +110 -108
- package/lib/sequence/index.cjs +1 -1
- package/lib/sequence/index.js +1 -1
- package/lib/source/index.cjs +1 -1
- package/lib/source/index.js +1 -1
- package/lib/video/index.cjs +1 -1
- package/lib/video/index.js +1 -1
- package/lib/youtube/index.cjs +1 -1
- package/lib/youtube/index.js +1 -1
- package/package.json +1 -1
- package/lib/SourceElement-D3xzMW9v.cjs +0 -5
- package/lib/SourceElement-DdvZ3tM_.js +0 -255
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var X=c=>{throw TypeError(c)};var W=(c,n,e)=>n.has(c)||X("Cannot "+e);var t=(c,n,e)=>(W(c,n,"read from private field"),e?e.call(c):n.get(c)),i=(c,n,e)=>n.has(c)?X("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(c):n.set(c,e),s=(c,n,e,a)=>(W(c,n,"write to private field"),a?a.call(c,e):n.set(c,e),e),F=(c,n,e)=>(W(c,n,"access private method"),e);const st=require("./element-linked-store/index.cjs"),it=require("./index-DekP7OZe.cjs"),M=require("./events-KVanG9sR.cjs"),rt=require("./string-DUXXtU8v.cjs");require("construct-style-sheets-polyfill");const Z=require("./loading/index.cjs"),nt=require("./order/index.cjs"),Y=require("./window-resizer/index.cjs"),at=require("./Store-Cd1GlEmZ.cjs");var V,b,C,L,d,p,$;class tt{constructor(n){i(this,V);i(this,b);i(this,C);i(this,L);i(this,d);i(this,p);i(this,$);s(this,V,n);let e=n.split(".");const a=/\b\d{1,2}x\b/g,l=e.find(y=>y.match(a)&&parseInt(y));s(this,C,l?parseInt(l):1),l&&(e=e.slice(0,-1)),s(this,b,e.length>1?e.slice(0,-1).join("."):e.join("."));const h=/\d+max/g,m=/\d+min/g,w=/\d+mar/g,U=/\d+mir/g,K=e.find(y=>y.match(h)),u=e.find(y=>y.match(m)),x=e.find(y=>y.match(w)),Q=e.find(y=>y.match(U));x?(s(this,d,parseInt(x)),s(this,p,"max"),s(this,L,`(max-aspect-ratio: ${t(this,d)})`)):Q?(s(this,d,parseInt(Q)),s(this,p,"max"),s(this,L,`(min-aspect-ratio: ${t(this,d)})`)):K?(s(this,d,parseInt(K)),s(this,p,"max"),s(this,L,`(max-width: ${t(this,d)}px)`)):u?(s(this,d,parseInt(u)),s(this,L,`(min-width: ${t(this,d)}px)`),s(this,p,"min")):(s(this,d,0),s(this,L,`(min-width: ${t(this,d)}px)`),s(this,p,"min")),s(this,b,t(this,b).replace(`.${t(this,d)}${t(this,p)}`,"")),s(this,$,e[e.length-1]===t(this,b)?"":"."+e[e.length-1]),s(this,$,t(this,$).replace(`.${t(this,d)}${t(this,p)}`,""))}get url(){return t(this,V)}get name(){return t(this,b)}get density(){return t(this,C)}get query(){return t(this,L)}get extension(){return t(this,$)}get queryType(){return t(this,p)}get queryValue(){return t(this,d)}}V=new WeakMap,b=new WeakMap,C=new WeakMap,L=new WeakMap,d=new WeakMap,p=new WeakMap,$=new WeakMap;var q;class J{constructor(n,e){i(this,q);s(this,q,new Map);const a=(e==null?void 0:e.mediaBuckets)!==!1,l=typeof n=="string"?a?n.trim().split(",").map(u=>u.trim()).filter(u=>!!u):[n]:n,h=[];l.forEach(u=>{const x=new tt(u);h.push([x.query,x])});const m=h.filter(u=>u[1].queryType.includes("max")).sort((u,x)=>x[1].queryValue-u[1].queryValue),w=h.filter(u=>u[1].queryType.includes("min")&&u[1].queryValue!==0).sort((u,x)=>u[1].queryValue-x[1].queryValue),U=h.filter(u=>u[0]==="(min-width: 0px)");(U?[...U,...m,...w]:[...m,...w]).forEach(u=>{t(this,q).has(u[0])||t(this,q).set(u[0],[]),t(this,q).get(u[0]).push(u[1])})}get mediaBuckets(){return t(this,q)}}q=new WeakMap;var R,A;class et extends at.Store{constructor(e){super(void 0);i(this,R);i(this,A,()=>{let e;t(this,R).mediaBuckets.forEach((h,m)=>{matchMedia(m).matches&&(e=h)});let a,l=0;e==null||e.forEach(h=>{h.density>l&&h.density<=Math.max(devicePixelRatio,1)&&(l=h.density,a=h)}),e!=null&&e.length&&!a&&(a=e[0]),this.current=a});s(this,R,new J(e.srcset,e.sourceSetOptions))}updateSource(e){s(this,R,new J(e.srcset,e.sourceSetOptions)),t(this,A).call(this)}close(){super.close(),this.disconnect()}connect(){Y.windowResizer.subscribe(t(this,A),nt.RESIZE_ORDER.SOURCE_MANAGER),t(this,A).call(this)}disconnect(){Y.windowResizer.unsubscribe(t(this,A))}}R=new WeakMap,A=new WeakMap;function ht(c){if(isNaN(c))return"0:00";const n=Math.floor(Math.max(0,c)),e=Math.floor(n/3600),a=Math.floor(n%3600/60),h=(n%60).toString().padStart(2,"0");if(e>0){const m=a.toString().padStart(2,"0");return`${e}:${m}:${h}`}else return`${a}:${h}`}let ot=0;var f,r,E,S,g,B,I,o,k,O,v,P,T,H,j,_,G,D,N,z;class ct extends HTMLElement{constructor(e){super();i(this,T);i(this,f,null);i(this,r,null);i(this,E,!1);i(this,S,!1);i(this,g,!1);i(this,B,"");i(this,I,"");i(this,o,new st.ElementLinkedStore(this,{loading:!1,loaded:!1,error:!1,clear:!1,playing:!1,metadata:!1}));i(this,k,null);i(this,O);i(this,v,null);i(this,P);i(this,j,e=>{const a=e[0];t(this,g)&&(!t(this,S)||this.hasAttribute("reload-source"))&&a.isIntersecting&&this.triggerLazyLoad(),a.isIntersecting?M.dispatchEvent(this,"sourceCapture",{custom:!0}):(this.hasAttribute("reload-source")&&(F(this,T,H).call(this,void 0),s(this,S,!1)),M.dispatchEvent(this,"sourceRelease",{custom:!0}))});i(this,_,()=>{t(this,o).set("loaded",!0),t(this,o).set("error",!1),t(this,o).set("loading",!1),!t(this,g)&&!t(this,E)&&Z.loading.complete(t(this,I)),M.dispatchEvent(this,"sourceLoaded",{custom:!0});const e=getComputedStyle(this).getPropertyValue("--clear-duration");e?s(this,O,setTimeout(()=>{t(this,o).set("clear",!0)},parseFloat(e)*1e3)):t(this,o).set("clear",!0),s(this,E,!0)});i(this,G,e=>{t(this,o).set("loaded",!1),t(this,o).set("error",!0),t(this,o).set("loading",!1),!t(this,g)&&!t(this,E)&&Z.loading.error(t(this,I)),M.dispatchEvent(this,"sourceError",{custom:!0}),s(this,E,!0)});i(this,D,()=>{t(this,o).set("playing",!0),M.dispatchEvent(this,"sourcePlay",{custom:!0})});i(this,N,()=>{t(this,o).set("playing",!1),M.dispatchEvent(this,"sourcePause",{custom:!0})});i(this,z,()=>{const e=t(this,r);(e.tagName==="VIDEO"||e.tagName==="AUDIO")&&e.readyState>=1&&(t(this,o).set("metadata",!0),M.dispatchEvent(this,"sourceMetadataLoaded",{custom:!0}),this.querySelectorAll("[data-source-duration]").forEach(a=>{a.textContent=ht(e.duration)}))});s(this,P,e==null?void 0:e.sourceSetOptions),it.isBrowser&&window.IntersectionObserver&&s(this,k,new IntersectionObserver(t(this,j))),t(this,o).subscribe(a=>{var h;const l=(h=this.getAttribute("data-global-play-class"))==null?void 0:h.split(",");l!=null&&l.length&&(a.current.playing?l.forEach(m=>{document.documentElement.classList.add(m.trim())}):l.forEach(m=>{document.documentElement.classList.remove(m.trim())}))})}get consumerElement(){return t(this,r)}get sourceManager(){return t(this,f)}get status(){return t(this,o)}get isLazy(){return t(this,g)}get currentURL(){return t(this,v)}get isFirstLoadHappened(){return t(this,E)}triggerLazyLoad(){!t(this,S)&&t(this,f).current&&t(this,f).current!==t(this,f).previous&&(s(this,S,!0),F(this,T,H).call(this,t(this,f).current))}connectedCallback(){var l;s(this,B,`source-consumer-${++ot}`);const e=this.getAttribute("srcset")||"",a=this.hasAttribute("notify")?this.closest(this.getAttribute("notify")):null;a&&t(this,o).addElement(a),(l=this.querySelector(".source-consumer"))==null||l.remove(),s(this,r,this.createConsumer()),t(this,r).style.cssText=`
|
|
2
|
+
display: block;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
`,t(this,r).classList.add("source-consumer"),t(this,r).addEventListener("play",t(this,D)),t(this,r).addEventListener("pause",t(this,N)),t(this,r).addEventListener("loadedmetadata",t(this,z)),t(this,z).call(this),Array.from(this.attributes).forEach(h=>{if(h.name!=="srcset"){const m=h.nodeValue||"",w=rt.kebabToCamel(h.name);w in t(this,r)&&(t(this,r)[w]=m||!0)}}),this.appendChild(t(this,r)),s(this,f,new et({srcset:e,sourceSetOptions:t(this,P)})),s(this,g,this.hasAttribute("lazy")),t(this,f).subscribe(h=>{(!t(this,g)||t(this,g)&&t(this,S))&&F(this,T,H).call(this,h.current)}),t(this,f).connect(),t(this,k).observe(this)}disconnectedCallback(){var e;clearTimeout(t(this,O)),t(this,k).disconnect(),(e=t(this,f))==null||e.close(),t(this,r)&&(this.consumeSource(null),t(this,r).removeEventListener("play",t(this,D)),t(this,r).removeEventListener("pause",t(this,N)),t(this,r).removeEventListener("loadedmetadata",t(this,z)),t(this,r).onloadeddata=null,t(this,r).onload=null,t(this,r).onerror=null,t(this,r).onerror=null,t(this,r).remove()),s(this,E,!1),s(this,S,!1),t(this,o).reset()}}f=new WeakMap,r=new WeakMap,E=new WeakMap,S=new WeakMap,g=new WeakMap,B=new WeakMap,I=new WeakMap,o=new WeakMap,k=new WeakMap,O=new WeakMap,v=new WeakMap,P=new WeakMap,T=new WeakSet,H=function(e){if(clearTimeout(t(this,O)),t(this,r).onloadeddata=null,t(this,r).onload=null,t(this,r).onerror=null,t(this,o).set("loaded",!1),t(this,o).set("error",!1),t(this,o).set("loading",!1),t(this,o).set("clear",!1),t(this,o).set("playing",!1),t(this,o).set("metadata",!1),e){s(this,I,`${t(this,B)}-${e.url}`);const a=this.hasAttribute("keep-source-parameters");t(this,o).set("loading",!0),s(this,v,a?e.url:e.name+e.extension),this.consumeSource(t(this,v)),!t(this,g)&&!t(this,E)&&Z.loading.add(t(this,I)),t(this,r).onloadeddata=()=>{t(this,_).call(this)},t(this,r).onload=()=>{t(this,_).call(this)},t(this,r).onerror=()=>{t(this,G).call(this,t(this,v))}}else s(this,v,null),this.consumeSource(null)},j=new WeakMap,_=new WeakMap,G=new WeakMap,D=new WeakMap,N=new WeakMap,z=new WeakMap;exports.Source=tt;exports.SourceElement=ct;exports.SourceManager=et;exports.SourceSet=J;
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
var Q = (c) => {
|
|
2
|
+
throw TypeError(c);
|
|
3
|
+
};
|
|
4
|
+
var W = (c, a, e) => a.has(c) || Q("Cannot " + e);
|
|
5
|
+
var t = (c, a, e) => (W(c, a, "read from private field"), e ? e.call(c) : a.get(c)), i = (c, a, e) => a.has(c) ? Q("Cannot add the same private member more than once") : a instanceof WeakSet ? a.add(c) : a.set(c, e), s = (c, a, e, n) => (W(c, a, "write to private field"), n ? n.call(c, e) : a.set(c, e), e), H = (c, a, e) => (W(c, a, "access private method"), e);
|
|
6
|
+
import { ElementLinkedStore as tt } from "./element-linked-store/index.js";
|
|
7
|
+
import { i as et } from "./index-Bv9zgfdb.js";
|
|
8
|
+
import { d as $ } from "./events-CsVF98U6.js";
|
|
9
|
+
import { k as st } from "./string-BlMQbe8b.js";
|
|
10
|
+
import "construct-style-sheets-polyfill";
|
|
11
|
+
import { loading as Z } from "./loading/index.js";
|
|
12
|
+
import { RESIZE_ORDER as it } from "./order/index.js";
|
|
13
|
+
import { windowResizer as X } from "./window-resizer/index.js";
|
|
14
|
+
import { S as rt } from "./Store-0BVty6AZ.js";
|
|
15
|
+
var C, S, z, L, d, p, q;
|
|
16
|
+
class at {
|
|
17
|
+
constructor(a) {
|
|
18
|
+
i(this, C);
|
|
19
|
+
i(this, S);
|
|
20
|
+
i(this, z);
|
|
21
|
+
i(this, L);
|
|
22
|
+
i(this, d);
|
|
23
|
+
i(this, p);
|
|
24
|
+
i(this, q);
|
|
25
|
+
s(this, C, a);
|
|
26
|
+
let e = a.split(".");
|
|
27
|
+
const n = /\b\d{1,2}x\b/g, u = e.find((y) => y.match(n) && parseInt(y));
|
|
28
|
+
s(this, z, u ? parseInt(u) : 1), u && (e = e.slice(0, -1)), s(this, S, e.length > 1 ? e.slice(0, -1).join(".") : e.join("."));
|
|
29
|
+
const h = /\d+max/g, m = /\d+min/g, w = /\d+mar/g, F = /\d+mir/g, K = e.find((y) => y.match(h)), l = e.find((y) => y.match(m)), x = e.find((y) => y.match(w)), J = e.find((y) => y.match(F));
|
|
30
|
+
x ? (s(this, d, parseInt(x)), s(this, p, "max"), s(this, L, `(max-aspect-ratio: ${t(this, d)})`)) : J ? (s(this, d, parseInt(J)), s(this, p, "max"), s(this, L, `(min-aspect-ratio: ${t(this, d)})`)) : K ? (s(this, d, parseInt(K)), s(this, p, "max"), s(this, L, `(max-width: ${t(this, d)}px)`)) : l ? (s(this, d, parseInt(l)), s(this, L, `(min-width: ${t(this, d)}px)`), s(this, p, "min")) : (s(this, d, 0), s(this, L, `(min-width: ${t(this, d)}px)`), s(this, p, "min")), s(this, S, t(this, S).replace(
|
|
31
|
+
`.${t(this, d)}${t(this, p)}`,
|
|
32
|
+
""
|
|
33
|
+
)), s(this, q, e[e.length - 1] === t(this, S) ? "" : "." + e[e.length - 1]), s(this, q, t(this, q).replace(
|
|
34
|
+
`.${t(this, d)}${t(this, p)}`,
|
|
35
|
+
""
|
|
36
|
+
));
|
|
37
|
+
}
|
|
38
|
+
get url() {
|
|
39
|
+
return t(this, C);
|
|
40
|
+
}
|
|
41
|
+
get name() {
|
|
42
|
+
return t(this, S);
|
|
43
|
+
}
|
|
44
|
+
get density() {
|
|
45
|
+
return t(this, z);
|
|
46
|
+
}
|
|
47
|
+
get query() {
|
|
48
|
+
return t(this, L);
|
|
49
|
+
}
|
|
50
|
+
get extension() {
|
|
51
|
+
return t(this, q);
|
|
52
|
+
}
|
|
53
|
+
get queryType() {
|
|
54
|
+
return t(this, p);
|
|
55
|
+
}
|
|
56
|
+
get queryValue() {
|
|
57
|
+
return t(this, d);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
C = new WeakMap(), S = new WeakMap(), z = new WeakMap(), L = new WeakMap(), d = new WeakMap(), p = new WeakMap(), q = new WeakMap();
|
|
61
|
+
var M;
|
|
62
|
+
class Y {
|
|
63
|
+
constructor(a, e) {
|
|
64
|
+
i(this, M);
|
|
65
|
+
s(this, M, /* @__PURE__ */ new Map());
|
|
66
|
+
const n = (e == null ? void 0 : e.mediaBuckets) !== !1, u = typeof a == "string" ? n ? a.trim().split(",").map((l) => l.trim()).filter((l) => !!l) : [a] : a, h = [];
|
|
67
|
+
u.forEach((l) => {
|
|
68
|
+
const x = new at(l);
|
|
69
|
+
h.push([x.query, x]);
|
|
70
|
+
});
|
|
71
|
+
const m = h.filter((l) => l[1].queryType.includes("max")).sort((l, x) => x[1].queryValue - l[1].queryValue), w = h.filter((l) => l[1].queryType.includes("min") && l[1].queryValue !== 0).sort((l, x) => l[1].queryValue - x[1].queryValue), F = h.filter((l) => l[0] === "(min-width: 0px)");
|
|
72
|
+
(F ? [...F, ...m, ...w] : [...m, ...w]).forEach((l) => {
|
|
73
|
+
t(this, M).has(l[0]) || t(this, M).set(l[0], []), t(this, M).get(l[0]).push(l[1]);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
get mediaBuckets() {
|
|
77
|
+
return t(this, M);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
M = new WeakMap();
|
|
81
|
+
var k, A;
|
|
82
|
+
class nt extends rt {
|
|
83
|
+
constructor(e) {
|
|
84
|
+
super(void 0);
|
|
85
|
+
i(this, k);
|
|
86
|
+
i(this, A, () => {
|
|
87
|
+
let e;
|
|
88
|
+
t(this, k).mediaBuckets.forEach((h, m) => {
|
|
89
|
+
matchMedia(m).matches && (e = h);
|
|
90
|
+
});
|
|
91
|
+
let n, u = 0;
|
|
92
|
+
e == null || e.forEach((h) => {
|
|
93
|
+
h.density > u && h.density <= Math.max(devicePixelRatio, 1) && (u = h.density, n = h);
|
|
94
|
+
}), e != null && e.length && !n && (n = e[0]), this.current = n;
|
|
95
|
+
});
|
|
96
|
+
s(this, k, new Y(e.srcset, e.sourceSetOptions));
|
|
97
|
+
}
|
|
98
|
+
updateSource(e) {
|
|
99
|
+
s(this, k, new Y(e.srcset, e.sourceSetOptions)), t(this, A).call(this);
|
|
100
|
+
}
|
|
101
|
+
close() {
|
|
102
|
+
super.close(), this.disconnect();
|
|
103
|
+
}
|
|
104
|
+
connect() {
|
|
105
|
+
X.subscribe(t(this, A), it.SOURCE_MANAGER), t(this, A).call(this);
|
|
106
|
+
}
|
|
107
|
+
disconnect() {
|
|
108
|
+
X.unsubscribe(t(this, A));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
k = new WeakMap(), A = new WeakMap();
|
|
112
|
+
function ht(c) {
|
|
113
|
+
if (isNaN(c)) return "0:00";
|
|
114
|
+
const a = Math.floor(Math.max(0, c)), e = Math.floor(a / 3600), n = Math.floor(a % 3600 / 60), h = (a % 60).toString().padStart(2, "0");
|
|
115
|
+
if (e > 0) {
|
|
116
|
+
const m = n.toString().padStart(2, "0");
|
|
117
|
+
return `${e}:${m}:${h}`;
|
|
118
|
+
} else
|
|
119
|
+
return `${n}:${h}`;
|
|
120
|
+
}
|
|
121
|
+
let ot = 0;
|
|
122
|
+
var f, r, E, b, g, B, I, o, O, R, v, P, T, j, _, D, G, N, U, V;
|
|
123
|
+
class xt extends HTMLElement {
|
|
124
|
+
constructor(e) {
|
|
125
|
+
super();
|
|
126
|
+
i(this, T);
|
|
127
|
+
i(this, f, null);
|
|
128
|
+
i(this, r, null);
|
|
129
|
+
i(this, E, !1);
|
|
130
|
+
i(this, b, !1);
|
|
131
|
+
i(this, g, !1);
|
|
132
|
+
i(this, B, "");
|
|
133
|
+
i(this, I, "");
|
|
134
|
+
i(this, o, new tt(this, {
|
|
135
|
+
loading: !1,
|
|
136
|
+
loaded: !1,
|
|
137
|
+
error: !1,
|
|
138
|
+
clear: !1,
|
|
139
|
+
playing: !1,
|
|
140
|
+
metadata: !1
|
|
141
|
+
}));
|
|
142
|
+
i(this, O, null);
|
|
143
|
+
i(this, R);
|
|
144
|
+
i(this, v, null);
|
|
145
|
+
i(this, P);
|
|
146
|
+
i(this, _, (e) => {
|
|
147
|
+
const n = e[0];
|
|
148
|
+
t(this, g) && (!t(this, b) || this.hasAttribute("reload-source")) && n.isIntersecting && this.triggerLazyLoad(), n.isIntersecting ? $(this, "sourceCapture", { custom: !0 }) : (this.hasAttribute("reload-source") && (H(this, T, j).call(this, void 0), s(this, b, !1)), $(this, "sourceRelease", { custom: !0 }));
|
|
149
|
+
});
|
|
150
|
+
i(this, D, () => {
|
|
151
|
+
t(this, o).set("loaded", !0), t(this, o).set("error", !1), t(this, o).set("loading", !1), !t(this, g) && !t(this, E) && Z.complete(t(this, I)), $(this, "sourceLoaded", { custom: !0 });
|
|
152
|
+
const e = getComputedStyle(this).getPropertyValue("--clear-duration");
|
|
153
|
+
e ? s(this, R, setTimeout(() => {
|
|
154
|
+
t(this, o).set("clear", !0);
|
|
155
|
+
}, parseFloat(e) * 1e3)) : t(this, o).set("clear", !0), s(this, E, !0);
|
|
156
|
+
});
|
|
157
|
+
i(this, G, (e) => {
|
|
158
|
+
t(this, o).set("loaded", !1), t(this, o).set("error", !0), t(this, o).set("loading", !1), !t(this, g) && !t(this, E) && Z.error(t(this, I)), $(this, "sourceError", { custom: !0 }), s(this, E, !0);
|
|
159
|
+
});
|
|
160
|
+
i(this, N, () => {
|
|
161
|
+
t(this, o).set("playing", !0), $(this, "sourcePlay", { custom: !0 });
|
|
162
|
+
});
|
|
163
|
+
i(this, U, () => {
|
|
164
|
+
t(this, o).set("playing", !1), $(this, "sourcePause", { custom: !0 });
|
|
165
|
+
});
|
|
166
|
+
i(this, V, () => {
|
|
167
|
+
const e = t(this, r);
|
|
168
|
+
(e.tagName === "VIDEO" || e.tagName === "AUDIO") && e.readyState >= 1 && (t(this, o).set("metadata", !0), $(this, "sourceMetadataLoaded", { custom: !0 }), this.querySelectorAll("[data-source-duration]").forEach((n) => {
|
|
169
|
+
n.textContent = ht(e.duration);
|
|
170
|
+
}));
|
|
171
|
+
});
|
|
172
|
+
s(this, P, e == null ? void 0 : e.sourceSetOptions), et && window.IntersectionObserver && s(this, O, new IntersectionObserver(
|
|
173
|
+
t(this, _)
|
|
174
|
+
)), t(this, o).subscribe((n) => {
|
|
175
|
+
var h;
|
|
176
|
+
const u = (h = this.getAttribute("data-global-play-class")) == null ? void 0 : h.split(
|
|
177
|
+
","
|
|
178
|
+
);
|
|
179
|
+
u != null && u.length && (n.current.playing ? u.forEach((m) => {
|
|
180
|
+
document.documentElement.classList.add(m.trim());
|
|
181
|
+
}) : u.forEach((m) => {
|
|
182
|
+
document.documentElement.classList.remove(m.trim());
|
|
183
|
+
}));
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
get consumerElement() {
|
|
187
|
+
return t(this, r);
|
|
188
|
+
}
|
|
189
|
+
get sourceManager() {
|
|
190
|
+
return t(this, f);
|
|
191
|
+
}
|
|
192
|
+
get status() {
|
|
193
|
+
return t(this, o);
|
|
194
|
+
}
|
|
195
|
+
get isLazy() {
|
|
196
|
+
return t(this, g);
|
|
197
|
+
}
|
|
198
|
+
get currentURL() {
|
|
199
|
+
return t(this, v);
|
|
200
|
+
}
|
|
201
|
+
get isFirstLoadHappened() {
|
|
202
|
+
return t(this, E);
|
|
203
|
+
}
|
|
204
|
+
triggerLazyLoad() {
|
|
205
|
+
!t(this, b) && t(this, f).current && t(this, f).current !== t(this, f).previous && (s(this, b, !0), H(this, T, j).call(this, t(this, f).current));
|
|
206
|
+
}
|
|
207
|
+
connectedCallback() {
|
|
208
|
+
var u;
|
|
209
|
+
s(this, B, `source-consumer-${++ot}`);
|
|
210
|
+
const e = this.getAttribute("srcset") || "", n = this.hasAttribute("notify") ? this.closest(this.getAttribute("notify")) : null;
|
|
211
|
+
n && t(this, o).addElement(n), (u = this.querySelector(".source-consumer")) == null || u.remove(), s(this, r, this.createConsumer()), t(this, r).style.cssText = `
|
|
212
|
+
display: block;
|
|
213
|
+
width: 100%;
|
|
214
|
+
height: 100%;
|
|
215
|
+
`, t(this, r).classList.add("source-consumer"), t(this, r).addEventListener("play", t(this, N)), t(this, r).addEventListener("pause", t(this, U)), t(this, r).addEventListener(
|
|
216
|
+
"loadedmetadata",
|
|
217
|
+
t(this, V)
|
|
218
|
+
), t(this, V).call(this), Array.from(this.attributes).forEach((h) => {
|
|
219
|
+
if (h.name !== "srcset") {
|
|
220
|
+
const m = h.nodeValue || "", w = st(h.name);
|
|
221
|
+
w in t(this, r) && (t(this, r)[w] = m || !0);
|
|
222
|
+
}
|
|
223
|
+
}), this.appendChild(t(this, r)), s(this, f, new nt({
|
|
224
|
+
srcset: e,
|
|
225
|
+
sourceSetOptions: t(this, P)
|
|
226
|
+
})), s(this, g, this.hasAttribute("lazy")), t(this, f).subscribe((h) => {
|
|
227
|
+
(!t(this, g) || t(this, g) && t(this, b)) && H(this, T, j).call(this, h.current);
|
|
228
|
+
}), t(this, f).connect(), t(this, O).observe(this);
|
|
229
|
+
}
|
|
230
|
+
disconnectedCallback() {
|
|
231
|
+
var e;
|
|
232
|
+
clearTimeout(t(this, R)), t(this, O).disconnect(), (e = t(this, f)) == null || e.close(), t(this, r) && (this.consumeSource(null), t(this, r).removeEventListener("play", t(this, N)), t(this, r).removeEventListener("pause", t(this, U)), t(this, r).removeEventListener(
|
|
233
|
+
"loadedmetadata",
|
|
234
|
+
t(this, V)
|
|
235
|
+
), t(this, r).onloadeddata = null, t(this, r).onload = null, t(this, r).onerror = null, t(this, r).onerror = null, t(this, r).remove()), s(this, E, !1), s(this, b, !1), t(this, o).reset();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
f = new WeakMap(), r = new WeakMap(), E = new WeakMap(), b = new WeakMap(), g = new WeakMap(), B = new WeakMap(), I = new WeakMap(), o = new WeakMap(), O = new WeakMap(), R = new WeakMap(), v = new WeakMap(), P = new WeakMap(), T = new WeakSet(), j = function(e) {
|
|
239
|
+
if (clearTimeout(t(this, R)), t(this, r).onloadeddata = null, t(this, r).onload = null, t(this, r).onerror = null, t(this, o).set("loaded", !1), t(this, o).set("error", !1), t(this, o).set("loading", !1), t(this, o).set("clear", !1), t(this, o).set("playing", !1), t(this, o).set("metadata", !1), e) {
|
|
240
|
+
s(this, I, `${t(this, B)}-${e.url}`);
|
|
241
|
+
const n = this.hasAttribute("keep-source-parameters");
|
|
242
|
+
t(this, o).set("loading", !0), s(this, v, n ? e.url : e.name + e.extension), this.consumeSource(t(this, v)), !t(this, g) && !t(this, E) && Z.add(t(this, I)), t(this, r).onloadeddata = () => {
|
|
243
|
+
t(this, D).call(this);
|
|
244
|
+
}, t(this, r).onload = () => {
|
|
245
|
+
t(this, D).call(this);
|
|
246
|
+
}, t(this, r).onerror = () => {
|
|
247
|
+
t(this, G).call(this, t(this, v));
|
|
248
|
+
};
|
|
249
|
+
} else
|
|
250
|
+
s(this, v, null), this.consumeSource(null);
|
|
251
|
+
}, _ = new WeakMap(), D = new WeakMap(), G = new WeakMap(), N = new WeakMap(), U = new WeakMap(), V = new WeakMap();
|
|
252
|
+
export {
|
|
253
|
+
at as S,
|
|
254
|
+
xt as a,
|
|
255
|
+
Y as b,
|
|
256
|
+
nt as c
|
|
257
|
+
};
|
package/lib/iframe/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var u=r=>{throw TypeError(r)};var a=(r,t,e)=>t.has(r)||u("Cannot "+e);var s=(r,t,e)=>(a(r,t,"read from private field"),e?e.call(r):t.get(r)),o=(r,t,e)=>t.has(r)?u("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),c=(r,t,e,i)=>(a(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../SourceElement-
|
|
1
|
+
"use strict";var u=r=>{throw TypeError(r)};var a=(r,t,e)=>t.has(r)||u("Cannot "+e);var s=(r,t,e)=>(a(r,t,"read from private field"),e?e.call(r):t.get(r)),o=(r,t,e)=>t.has(r)?u("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),c=(r,t,e,i)=>(a(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../SourceElement-8nqiFLJ2.cjs");require("../window-resizer/index.cjs");require("../Store-Cd1GlEmZ.cjs");const f=require("../index-DekP7OZe.cjs");require("construct-style-sheets-polyfill");var n,l,m;class E extends h.SourceElement{constructor(){super({sourceSetOptions:{mediaBuckets:!1}});o(this,n,null);o(this,l,()=>{var e,i;(i=(e=this.consumerElement).onload)==null||i.call(e,new Event("load"))});o(this,m,()=>{var e,i;(i=(e=this.consumerElement).onload)==null||i.call(e,new Event("error"))})}createConsumer(){return document.createElement("div")}consumeSource(e){s(this,n)&&(s(this,n).onload=null,s(this,n).onerror=null),this.consumerElement.innerHTML=(e==null?void 0:e.replace(/\\u003C/g,"<").replace(/\\u003E/g,">").replace(/\\"/g,'"'))||"",c(this,n,this.consumerElement.querySelector("iframe")),s(this,n)&&(s(this,n).onload=s(this,l),s(this,n).onerror=s(this,m))}}n=new WeakMap,l=new WeakMap,m=new WeakMap;f.isBrowser&&!customElements.get("e-iframe")&&customElements.define("e-iframe",E);exports.IFrameElement=E;
|
package/lib/iframe/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var a = (r) => {
|
|
|
3
3
|
};
|
|
4
4
|
var u = (r, t, e) => t.has(r) || a("Cannot " + e);
|
|
5
5
|
var s = (r, t, e) => (u(r, t, "read from private field"), e ? e.call(r) : t.get(r)), i = (r, t, e) => t.has(r) ? a("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), c = (r, t, e, o) => (u(r, t, "write to private field"), o ? o.call(r, e) : t.set(r, e), e);
|
|
6
|
-
import { a as E } from "../SourceElement-
|
|
6
|
+
import { a as E } from "../SourceElement-DrZ3QNm-.js";
|
|
7
7
|
import "../window-resizer/index.js";
|
|
8
8
|
import "../Store-0BVty6AZ.js";
|
|
9
9
|
import { i as f } from "../index-Bv9zgfdb.js";
|
package/lib/image/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../Viewport-DB0qAZPJ.cjs"),i=require("../SourceElement-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../Viewport-DB0qAZPJ.cjs"),i=require("../SourceElement-8nqiFLJ2.cjs");require("../window-resizer/index.cjs");require("../Store-Cd1GlEmZ.cjs");const n=require("../index-DekP7OZe.cjs");require("construct-style-sheets-polyfill");class t extends i.SourceElement{createConsumer(){return document.createElement("img")}consumeSource(e){if(e&&this.hasAttribute("webp")&&s.device.isWebp){const r=e.split(".").slice(0,-1).join(".")+".webp";this.consumerElement.src=r}else this.consumerElement.src=e||""}}n.isBrowser&&!customElements.get("e-image")&&customElements.define("e-image",t);exports.ImageElement=t;
|
package/lib/image/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { d as m } from "../Viewport-DA10iWAO.js";
|
|
2
|
-
import { a as s } from "../SourceElement-
|
|
2
|
+
import { a as s } from "../SourceElement-DrZ3QNm-.js";
|
|
3
3
|
import "../window-resizer/index.js";
|
|
4
4
|
import "../Store-0BVty6AZ.js";
|
|
5
5
|
import { i } from "../index-Bv9zgfdb.js";
|
package/lib/morph/Morph.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ export interface MorphEvents {
|
|
|
50
50
|
morphScroll: CustomEvent<MorphScrollDetail>;
|
|
51
51
|
morphBeforeNavigationScroll: CustomEvent<MorphRouteScrollState>;
|
|
52
52
|
morphURLParametersChange: CustomEvent<MorphURLParametersChangeEntry>;
|
|
53
|
+
morphSamePath: CustomEvent;
|
|
53
54
|
}
|
|
54
55
|
export interface MorphGetRouteOptions {
|
|
55
56
|
searchParameters?: string;
|
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var $t=Object.defineProperty,Gt=Object.defineProperties;var Jt=Object.getOwnPropertyDescriptors;var qt=Object.getOwnPropertySymbols;var Qt=Object.prototype.hasOwnProperty,Zt=Object.prototype.propertyIsEnumerable;var Dt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),zt=n=>{throw TypeError(n)};var Ut=(n,t,s)=>t in n?$t(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s,Et=(n,t)=>{for(var s in t||(t={}))Qt.call(t,s)&&Ut(n,s,t[s]);if(qt)for(var s of qt(t))Zt.call(t,s)&&Ut(n,s,t[s]);return n},gt=(n,t)=>Gt(n,Jt(t));var vt=(n,t,s)=>t.has(n)||zt("Cannot "+s);var e=(n,t,s)=>(vt(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?zt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),r=(n,t,s,i)=>(vt(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),p=(n,t,s)=>(vt(n,t,"access private method"),s);var O=(n,t,s)=>new Promise((i,u)=>{var w=g=>{try{S(s.next(g))}catch(V){u(V)}},b=g=>{try{S(s.throw(g))}catch(V){u(V)}},S=g=>g.done?i(g.value):Promise.resolve(g.value).then(w,b);S((s=s.apply(n,t)).next())});var It=(n,t,s)=>(t=n[Dt("asyncIterator")])?t.call(n):(n=n[Dt("iterator")](),t={},s=(i,u)=>(u=n[i])&&(t[i]=w=>new Promise((b,S,g)=>(w=u.call(n,w),g=w.done,Promise.resolve(w.value).then(V=>b({value:V,done:g}),S)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Bt=require("../index-DekP7OZe.cjs"),R=require("../events-KVanG9sR.cjs"),_t=require("../polyfills-Df4r-ETT.cjs"),Vt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const st=require("../url-YEESIcRn.cjs"),te=require("../css-value-parser/index.cjs");class Ot extends HTMLElement{connectedCallback(){const t={"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[s,i]of Object.entries(t))this.setAttribute(s,i)}}Bt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Ot);var C,h,N,nt,G;class St{constructor(t,s){o(this,C);o(this,h);o(this,N);o(this,nt,t=>{var i;if(t.preventDefault(),e(this,h).hasAttribute("data-back")&&e(this,C).previousURL)history.back();else{r(this,N,e(this,h).getAttribute("href")||"/");const u=e(this,h).getAttribute("data-history-action")||"push",w=e(this,h).hasAttribute("data-center-scroll"),b=getComputedStyle(e(this,h)).getPropertyValue("--offset-scroll").trim(),S=b?te.cssValueParser.parse(b):void 0,g=e(this,h).hasAttribute("data-revalidate"),V=e(this,h).hasAttribute("data-keep-search-parameters"),l=(i=e(this,h).getAttribute("data-submorph"))==null?void 0:i.split(",").map(lt=>lt.trim()),ot=e(this,h).hasAttribute("data-clear-state");e(this,C).navigate(e(this,N),{historyAction:u,centerScroll:w,offsetScroll:S,revalidate:g,keepSearchParameters:V,submorph:l,clearState:ot})}});o(this,G,()=>{const t=e(this,h).hasAttribute("data-revalidate");e(this,C).prefetch(e(this,N),t),e(this,h).removeEventListener("pointerenter",e(this,G))});r(this,C,s),r(this,h,t),r(this,N,e(this,h).getAttribute("href")||"/"),e(this,h).addEventListener("click",e(this,nt)),this.checkCurrent(location.pathname),e(this,h).hasAttribute("data-prefetch")&&e(this,h).addEventListener("pointerenter",e(this,G))}get element(){return e(this,h)}checkCurrent(t){const s=e(this,C).normalizePath(t),i=e(this,C).normalizePath(e(this,N));e(this,h).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,h).classList.add("current"):i.pathname===s.pathname?e(this,h).classList.add("current"):e(this,h).classList.remove("current")}destroy(){e(this,h).removeEventListener("click",e(this,nt)),e(this,h).removeEventListener("pointerenter",e(this,G)),e(this,h).classList.remove("current")}}C=new WeakMap,h=new WeakMap,N=new WeakMap,nt=new WeakMap,G=new WeakMap;const ee=new DOMParser;var H,W,y,P,Y,q,J,X,D,Q;class Ft{constructor(t,s){o(this,H);o(this,W);o(this,y,{x:0,y:0});o(this,P,null);o(this,Y,null);o(this,q,null);o(this,J,null);o(this,X,null);o(this,D,null);o(this,Q);r(this,H,t),r(this,W,s),r(this,Q,s)}get pathname(){return e(this,W)}get scrollState(){return e(this,y)}get document(){return e(this,q)}setInitialDocument(t){r(this,P,t.cloneNode(!0))}abort(){var t;return(t=e(this,X))==null?void 0:t.abort(`[${e(this,W)}] page loading cancelled`)}fetch(t,s){return O(this,null,function*(){return e(this,D)||e(this,P)&&e(this,P).documentElement.hasAttribute("data-cache")&&(!s||e(this,Q)!==t)||e(this,P)&&e(this,H).isPopstateNavigation?e(this,D):(r(this,Q,t),r(this,D,new Promise(i=>O(this,null,function*(){try{r(this,X,new AbortController);const w=yield(yield fetch(t,{signal:e(this,X).signal})).text(),b=ee.parseFromString(w,"text/html");this.setInitialDocument(b)}catch(u){console.warn(u)}finally{r(this,X,null),r(this,D,null),i()}}))),e(this,D))})}cloneDocument(){r(this,q,(e(this,Y)||e(this,P)).cloneNode(!0))}get title(){let t="";if(e(this,q).title)t=e(this,q).title;else{const s=e(this,q).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,W)}return t}clearScrollState(){e(this,y).x=0,e(this,y).y=0}clearDocumentState(){r(this,Y,null)}saveScrollState(){e(this,P).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,y).x=0,e(this,y).y=0):(e(this,y).x=e(this,H).scrollValue.left,e(this,y).y=e(this,H).scrollValue.top)}restoreScrollPosition(){e(this,H).scrollElement.scroll({top:e(this,y).y,left:e(this,y).x,behavior:"instant"})}saveDocumentState(){e(this,P).documentElement.hasAttribute("data-no-page-restoration")?r(this,Y,null):r(this,Y,document.cloneNode(!0))}renewScrollPosition(){e(this,H).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){r(this,J,t)}clearState(){const t=e(this,J);return r(this,J,null),t}}H=new WeakMap,W=new WeakMap,y=new WeakMap,P=new WeakMap,Y=new WeakMap,q=new WeakMap,J=new WeakMap,X=new WeakMap,D=new WeakMap,Q=new WeakMap;var A,Z,E,U,m,j,z,I,L,rt,M,K,_,tt,c,yt,at,ut,Lt,Wt,bt,Pt,At,kt,dt,et;const it=class it{constructor(t){o(this,c);o(this,A,null);o(this,Z,null);o(this,E,[]);o(this,U);o(this,m,null);o(this,j);o(this,z,[]);o(this,I,!1);o(this,L,null);o(this,rt,!1);o(this,M,new Map);o(this,K,null);o(this,_,0);o(this,tt,0);o(this,at,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});o(this,dt,t=>O(this,null,function*(){t.preventDefault(),r(this,I,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none"}),r(this,I,!1)}));o(this,et,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,tt),u=t-e(this,_);r(this,tt,s),r(this,_,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",u>0),document.documentElement.classList.toggle("scroll-x-backward",u<0),R.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Bt.isBrowser&&!it.instance){it.instance=this,r(this,A,{base:st.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),r(this,Z,p(this,c,Lt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);r(this,m,s);const i=new Ft(this,e(this,m).pathname);i.setInitialDocument(document),e(this,M).set(e(this,m).pathname,i),document.documentElement.setAttribute("data-current-pathname",e(this,m).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,dt)),st.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),r(this,K,new Ot),p(this,c,At).call(this,document)}}get currentURL(){return e(this,m)}get previousURL(){return e(this,j)}get links(){return e(this,E)}get scrollElement(){return e(this,L)}get isPopstateNavigation(){return e(this,I)}get scrollValue(){let t=0,s=0;return e(this,rt)?(t=window.scrollY,s=window.scrollX):(t=e(this,L).scrollTop,s=e(this,L).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,M).get(e(this,m).path);s&&s.saveState(t)}getState(){const t=e(this,M).get(e(this,m).path);return t==null?void 0:t.clearState()}normalizePath(t){return st.splitPath(t,{base:e(this,A).base,trailingSlash:e(this,A).trailingSlash})}prefetch(t,s){return O(this,null,function*(){if(e(this,z).length)return;const i=p(this,c,ut).call(this,t);i==null||i.fetch(t,s)})}excludeHeadChild(t){return!1}navigate(V){return O(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:w,keepSearchParameters:b,submorph:S,clearState:g}={}){var ot,lt,Ct,Ht;if(e(this,z).length)return;const l=this.normalizePath(((ot=this.pathnameModifier)==null?void 0:ot.call(this,t))||t);if(((lt=e(this,U))==null?void 0:lt.pathname)===l.pathname||e(this,m).pathname===l.pathname){p(this,c,kt).call(this,l.hash||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"}),((Ct=e(this,m))==null?void 0:Ct.parameters)!==l.parameters&&(r(this,j,e(this,m)),r(this,m,l),st.changeHistory({action:((Ht=e(this,m))==null?void 0:Ht.hash)!==l.hash?"replace":s,pathname:l.pathname,searchParameters:l.parameters,hash:l.hash}),R.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,m),previousURL:e(this,j)}}));return}r(this,U,l),e(this,E).forEach($=>{$.checkCurrent(l.pathname)});try{let $=!0;if(this.preprocessor)try{yield new Promise((a,k)=>{var T;(T=this.preprocessor)==null||T.call(this,{url:l,resolve:a,reject:k,submorph:S})})}catch(a){a?console.error(a):console.log("Route change canceled"),$=!1}if(!$||e(this,U).pathname!==l.pathname){e(this,E).forEach(a=>{a.checkCurrent(e(this,m).pathname)});return}const Mt={url:l,submorph:S};R.dispatchEvent(document,"morphNavigation",{detail:Mt});const mt=p(this,c,ut).call(this,e(this,m).pathname),f=p(this,c,ut).call(this,l.pathname);if(e(this,M).forEach(a=>{a.pathname!==l.pathname&&a.abort()}),yield f==null?void 0:f.fetch(t,w),e(this,U).pathname!==l.pathname){e(this,E).forEach(a=>{a.checkCurrent(e(this,m).path)});return}mt.clearState(),mt.saveScrollState(),mt.saveDocumentState(),e(this,I)||(f.clearScrollState(),f.clearDocumentState()),g&&f.clearState(),f.cloneDocument(),e(this,K).textContent=f.title,document.body.appendChild(e(this,K));const ft=gt(Et({},Mt),{document:f.document});R.dispatchEvent(document,"morphStart",{detail:ft});const Tt=Array.from(document.head.children),xt=Array.from(f.document.head.children),Rt=p(this,c,Wt).call(this,Tt,xt),Yt=p(this,c,bt).call(this,Tt,Rt),ht=p(this,c,bt).call(this,xt,Rt).filter(a=>!this.excludeHeadChild(a));ht.forEach((a,k)=>{a.tagName==="SCRIPT"&&(ht[k]=p(this,c,yt).call(this,a))}),ht.forEach(a=>{document.head.appendChild(a)});const pt=ht.filter(a=>{if(a.hasAttribute("data-no-waiting"))return!1;if(p(this,c,Pt).call(this,a))return!0});e(this,A).waitForHeadToLoad&&pt.length&&(yield new Promise(a=>O(this,null,function*(){let k=0;try{for(var T=It(pt),jt,F,B;jt=!(F=yield T.next()).done;jt=!1){const ct=F.value;ct.onload=()=>{k++,k===pt.length&&a()}}}catch(F){B=[F]}finally{try{jt&&(F=T.return)&&(yield F.call(T))}finally{if(B)throw B[0]}}}))),yield Vt.wait(10);const Nt=[];Yt.forEach(a=>{a.hasAttribute("data-permanent")||(p(this,c,Pt).call(this,a)?Nt.push(a):a.remove())});const Xt=p(this,c,Lt).call(this,f.document.body);e(this,A).morphInsideScrollContainer||p(this,c,At).call(this,f.document),document.documentElement.setAttribute("data-current-pathname",l.pathname),document.documentElement.setAttribute("data-current-leaf",l.leaf),st.changeHistory({action:s,pathname:l.pathname,searchParameters:l.parameters||(b?location.search:""),hash:l.hash}),e(this,K).remove(),r(this,j,e(this,m)),r(this,m,l),e(this,Z).forEach((a,k)=>{const T=Xt[k],jt=getComputedStyle(a).getPropertyValue("--morph-duration");let F=[],B=[];S?S.forEach(d=>{const v=a.querySelector(d),x=T.querySelector(d);v&&x&&(B.push(v),F.push(x))}):(F.push(...T.childNodes),B.push(...a.childNodes)),B.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"))}),F.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"))}),S?F.forEach((d,v)=>{var x;(x=B[v].parentElement)==null||x.insertBefore(d,B[v])}):a.prepend(...F),_t.requestIdleCallback(()=>{B.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old-idle")}),F.forEach(d=>{var v;d instanceof HTMLElement&&((v=d.parentElement)==null||v.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("new-idle"))})});const ct=gt(Et({},ft),{morphElement:a});R.dispatchEvent(document,"morphNewChildrenAdded",{detail:ct});const Kt=new Promise(d=>{setTimeout(()=>{B.forEach(v=>v.remove()),F.forEach(v=>{var x;v instanceof HTMLElement&&((x=v.parentElement)==null||x.style.removeProperty("--new-content-height"),v.classList.remove("new-idle","new"))}),R.dispatchEvent(document,"morphOldChildrenRemoved",{detail:ct}),d()},(parseFloat(jt)||0)*1e3+10)});e(this,z).push(Kt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-f.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),R.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:f.scrollState}),l.hash?(f.clearScrollState(),p(this,c,kt).call(this,l.hash,{centerScroll:i,offsetScroll:u})):e(this,I)?f.restoreScrollPosition():f.renewScrollPosition(),yield Promise.all(e(this,z)),Nt.forEach(a=>a.remove()),r(this,z,[]),e(this,Z).forEach(a=>{a.querySelectorAll("script").forEach(T=>{T.replaceWith(p(this,c,yt).call(this,T))})}),R.dispatchEvent(document,"morphComplete",{detail:ft}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch($){console.error($)}r(this,U,void 0)})}addLink(t){e(this,E).push(new St(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){r(this,E,e(this,E).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){r(this,E,e(this,E).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,at));e(this,E).push(...s.map(i=>new St(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,at));e(this,E).forEach(s=>s.destroy()),r(this,E,t.map(s=>new St(s,this)))}};A=new WeakMap,Z=new WeakMap,E=new WeakMap,U=new WeakMap,m=new WeakMap,j=new WeakMap,z=new WeakMap,I=new WeakMap,L=new WeakMap,rt=new WeakMap,M=new WeakMap,K=new WeakMap,_=new WeakMap,tt=new WeakMap,c=new WeakSet,yt=function(t){const s=document.createElement("script");for(let i=0;i<t.attributes.length;i++){const u=t.attributes[i];s.setAttribute(u.name,u.value)}return t.hasAttribute("src")||(s.innerHTML=t.innerHTML),s},at=new WeakMap,ut=function(t){const s=this.normalizePath(t);let i=e(this,M).get(s.pathname);return i||(i=new Ft(this,s.pathname),e(this,M).set(s.pathname,i)),i},Lt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Wt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},bt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},Pt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},At=function(t){var s,i;(s=e(this,L))==null||s.removeEventListener("scroll",e(this,et)),r(this,tt,0),r(this,_,0),r(this,L,e(this,A).scrollSelector&&t.querySelector(e(this,A).scrollSelector)||window),r(this,rt,e(this,L)===window),(i=e(this,L))==null||i.addEventListener("scroll",e(this,et)),e(this,et).call(this)},kt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Vt.scrollToElement(i,{scrollElement:e(this,L),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},dt=new WeakMap,et=new WeakMap,it.instance=null;let wt=it;exports.Morph=wt;
|
|
1
|
+
"use strict";var $t=Object.defineProperty,Gt=Object.defineProperties;var Jt=Object.getOwnPropertyDescriptors;var qt=Object.getOwnPropertySymbols;var Qt=Object.prototype.hasOwnProperty,Zt=Object.prototype.propertyIsEnumerable;var Dt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),zt=n=>{throw TypeError(n)};var Ut=(n,t,s)=>t in n?$t(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s,Et=(n,t)=>{for(var s in t||(t={}))Qt.call(t,s)&&Ut(n,s,t[s]);if(qt)for(var s of qt(t))Zt.call(t,s)&&Ut(n,s,t[s]);return n},gt=(n,t)=>Gt(n,Jt(t));var vt=(n,t,s)=>t.has(n)||zt("Cannot "+s);var e=(n,t,s)=>(vt(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?zt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),r=(n,t,s,i)=>(vt(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),p=(n,t,s)=>(vt(n,t,"access private method"),s);var O=(n,t,s)=>new Promise((i,u)=>{var w=g=>{try{S(s.next(g))}catch(V){u(V)}},b=g=>{try{S(s.throw(g))}catch(V){u(V)}},S=g=>g.done?i(g.value):Promise.resolve(g.value).then(w,b);S((s=s.apply(n,t)).next())});var It=(n,t,s)=>(t=n[Dt("asyncIterator")])?t.call(n):(n=n[Dt("iterator")](),t={},s=(i,u)=>(u=n[i])&&(t[i]=w=>new Promise((b,S,g)=>(w=u.call(n,w),g=w.done,Promise.resolve(w.value).then(V=>b({value:V,done:g}),S)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Bt=require("../index-DekP7OZe.cjs"),C=require("../events-KVanG9sR.cjs"),_t=require("../polyfills-Df4r-ETT.cjs"),Vt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const st=require("../url-YEESIcRn.cjs"),te=require("../css-value-parser/index.cjs");class Ot extends HTMLElement{connectedCallback(){const t={"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[s,i]of Object.entries(t))this.setAttribute(s,i)}}Bt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Ot);var H,h,N,nt,G;class St{constructor(t,s){o(this,H);o(this,h);o(this,N);o(this,nt,t=>{var i;if(t.preventDefault(),e(this,h).hasAttribute("data-back")&&e(this,H).previousURL)history.back();else{r(this,N,e(this,h).getAttribute("href")||"/");const u=e(this,h).getAttribute("data-history-action")||"push",w=e(this,h).hasAttribute("data-center-scroll"),b=getComputedStyle(e(this,h)).getPropertyValue("--offset-scroll").trim(),S=b?te.cssValueParser.parse(b):void 0,g=e(this,h).hasAttribute("data-revalidate"),V=e(this,h).hasAttribute("data-keep-search-parameters"),l=(i=e(this,h).getAttribute("data-submorph"))==null?void 0:i.split(",").map(lt=>lt.trim()),ot=e(this,h).hasAttribute("data-clear-state");e(this,H).navigate(e(this,N),{historyAction:u,centerScroll:w,offsetScroll:S,revalidate:g,keepSearchParameters:V,submorph:l,clearState:ot})}});o(this,G,()=>{const t=e(this,h).hasAttribute("data-revalidate");e(this,H).prefetch(e(this,N),t),e(this,h).removeEventListener("pointerenter",e(this,G))});r(this,H,s),r(this,h,t),r(this,N,e(this,h).getAttribute("href")||"/"),e(this,h).addEventListener("click",e(this,nt)),this.checkCurrent(location.pathname),e(this,h).hasAttribute("data-prefetch")&&e(this,h).addEventListener("pointerenter",e(this,G))}get element(){return e(this,h)}checkCurrent(t){const s=e(this,H).normalizePath(t),i=e(this,H).normalizePath(e(this,N));e(this,h).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,h).classList.add("current"):i.pathname===s.pathname?e(this,h).classList.add("current"):e(this,h).classList.remove("current")}destroy(){e(this,h).removeEventListener("click",e(this,nt)),e(this,h).removeEventListener("pointerenter",e(this,G)),e(this,h).classList.remove("current")}}H=new WeakMap,h=new WeakMap,N=new WeakMap,nt=new WeakMap,G=new WeakMap;const ee=new DOMParser;var M,W,y,P,Y,q,J,X,D,Q;class Ft{constructor(t,s){o(this,M);o(this,W);o(this,y,{x:0,y:0});o(this,P,null);o(this,Y,null);o(this,q,null);o(this,J,null);o(this,X,null);o(this,D,null);o(this,Q);r(this,M,t),r(this,W,s),r(this,Q,s)}get pathname(){return e(this,W)}get scrollState(){return e(this,y)}get document(){return e(this,q)}setInitialDocument(t){r(this,P,t.cloneNode(!0))}abort(){var t;return(t=e(this,X))==null?void 0:t.abort(`[${e(this,W)}] page loading cancelled`)}fetch(t,s){return O(this,null,function*(){return e(this,D)||e(this,P)&&e(this,P).documentElement.hasAttribute("data-cache")&&(!s||e(this,Q)!==t)||e(this,P)&&e(this,M).isPopstateNavigation?e(this,D):(r(this,Q,t),r(this,D,new Promise(i=>O(this,null,function*(){try{r(this,X,new AbortController);const w=yield(yield fetch(t,{signal:e(this,X).signal})).text(),b=ee.parseFromString(w,"text/html");this.setInitialDocument(b)}catch(u){console.warn(u)}finally{r(this,X,null),r(this,D,null),i()}}))),e(this,D))})}cloneDocument(){r(this,q,(e(this,Y)||e(this,P)).cloneNode(!0))}get title(){let t="";if(e(this,q).title)t=e(this,q).title;else{const s=e(this,q).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,W)}return t}clearScrollState(){e(this,y).x=0,e(this,y).y=0}clearDocumentState(){r(this,Y,null)}saveScrollState(){e(this,P).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,y).x=0,e(this,y).y=0):(e(this,y).x=e(this,M).scrollValue.left,e(this,y).y=e(this,M).scrollValue.top)}restoreScrollPosition(){e(this,M).scrollElement.scroll({top:e(this,y).y,left:e(this,y).x,behavior:"instant"})}saveDocumentState(){e(this,P).documentElement.hasAttribute("data-no-page-restoration")?r(this,Y,null):r(this,Y,document.cloneNode(!0))}renewScrollPosition(){e(this,M).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){r(this,J,t)}clearState(){const t=e(this,J);return r(this,J,null),t}}M=new WeakMap,W=new WeakMap,y=new WeakMap,P=new WeakMap,Y=new WeakMap,q=new WeakMap,J=new WeakMap,X=new WeakMap,D=new WeakMap,Q=new WeakMap;var A,Z,E,U,m,j,z,I,L,rt,T,K,_,tt,c,yt,at,ut,Lt,Wt,bt,Pt,At,kt,dt,et;const it=class it{constructor(t){o(this,c);o(this,A,null);o(this,Z,null);o(this,E,[]);o(this,U);o(this,m,null);o(this,j);o(this,z,[]);o(this,I,!1);o(this,L,null);o(this,rt,!1);o(this,T,new Map);o(this,K,null);o(this,_,0);o(this,tt,0);o(this,at,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});o(this,dt,t=>O(this,null,function*(){t.preventDefault(),r(this,I,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none"}),r(this,I,!1)}));o(this,et,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,tt),u=t-e(this,_);r(this,tt,s),r(this,_,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",u>0),document.documentElement.classList.toggle("scroll-x-backward",u<0),C.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Bt.isBrowser&&!it.instance){it.instance=this,r(this,A,{base:st.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),r(this,Z,p(this,c,Lt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);r(this,m,s);const i=new Ft(this,e(this,m).pathname);i.setInitialDocument(document),e(this,T).set(e(this,m).pathname,i),document.documentElement.setAttribute("data-current-pathname",e(this,m).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,dt)),st.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),r(this,K,new Ot),p(this,c,At).call(this,document)}}get currentURL(){return e(this,m)}get previousURL(){return e(this,j)}get links(){return e(this,E)}get scrollElement(){return e(this,L)}get isPopstateNavigation(){return e(this,I)}get scrollValue(){let t=0,s=0;return e(this,rt)?(t=window.scrollY,s=window.scrollX):(t=e(this,L).scrollTop,s=e(this,L).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,T).get(e(this,m).path);s&&s.saveState(t)}getState(){const t=e(this,T).get(e(this,m).path);return t==null?void 0:t.clearState()}normalizePath(t){return st.splitPath(t,{base:e(this,A).base,trailingSlash:e(this,A).trailingSlash})}prefetch(t,s){return O(this,null,function*(){if(e(this,z).length)return;const i=p(this,c,ut).call(this,t);i==null||i.fetch(t,s)})}excludeHeadChild(t){return!1}navigate(V){return O(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:w,keepSearchParameters:b,submorph:S,clearState:g}={}){var ot,lt,Ct,Ht;if(e(this,z).length)return;const l=this.normalizePath(((ot=this.pathnameModifier)==null?void 0:ot.call(this,t))||t);if(((lt=e(this,U))==null?void 0:lt.pathname)===l.pathname||e(this,m).pathname===l.pathname){p(this,c,kt).call(this,l.hash||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"}),C.dispatchEvent(document,"morphSamePath",{custom:!0}),((Ct=e(this,m))==null?void 0:Ct.parameters)!==l.parameters&&(r(this,j,e(this,m)),r(this,m,l),st.changeHistory({action:((Ht=e(this,m))==null?void 0:Ht.hash)!==l.hash?"replace":s,pathname:l.pathname,searchParameters:l.parameters,hash:l.hash}),C.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,m),previousURL:e(this,j)}}));return}r(this,U,l),e(this,E).forEach($=>{$.checkCurrent(l.pathname)});try{let $=!0;if(this.preprocessor)try{yield new Promise((a,k)=>{var x;(x=this.preprocessor)==null||x.call(this,{url:l,resolve:a,reject:k,submorph:S})})}catch(a){a?console.error(a):console.log("Route change canceled"),$=!1}if(!$||e(this,U).pathname!==l.pathname){e(this,E).forEach(a=>{a.checkCurrent(e(this,m).pathname)});return}const Mt={url:l,submorph:S};C.dispatchEvent(document,"morphNavigation",{detail:Mt});const mt=p(this,c,ut).call(this,e(this,m).pathname),f=p(this,c,ut).call(this,l.pathname);if(e(this,T).forEach(a=>{a.pathname!==l.pathname&&a.abort()}),yield f==null?void 0:f.fetch(t,w),e(this,U).pathname!==l.pathname){e(this,E).forEach(a=>{a.checkCurrent(e(this,m).path)});return}mt.clearState(),mt.saveScrollState(),mt.saveDocumentState(),e(this,I)||(f.clearScrollState(),f.clearDocumentState()),g&&f.clearState(),f.cloneDocument(),e(this,K).textContent=f.title,document.body.appendChild(e(this,K));const ft=gt(Et({},Mt),{document:f.document});C.dispatchEvent(document,"morphStart",{detail:ft});const Tt=Array.from(document.head.children),xt=Array.from(f.document.head.children),Rt=p(this,c,Wt).call(this,Tt,xt),Yt=p(this,c,bt).call(this,Tt,Rt),ht=p(this,c,bt).call(this,xt,Rt).filter(a=>!this.excludeHeadChild(a));ht.forEach((a,k)=>{a.tagName==="SCRIPT"&&(ht[k]=p(this,c,yt).call(this,a))}),ht.forEach(a=>{document.head.appendChild(a)});const pt=ht.filter(a=>{if(a.hasAttribute("data-no-waiting"))return!1;if(p(this,c,Pt).call(this,a))return!0});e(this,A).waitForHeadToLoad&&pt.length&&(yield new Promise(a=>O(this,null,function*(){let k=0;try{for(var x=It(pt),jt,F,B;jt=!(F=yield x.next()).done;jt=!1){const ct=F.value;ct.onload=()=>{k++,k===pt.length&&a()}}}catch(F){B=[F]}finally{try{jt&&(F=x.return)&&(yield F.call(x))}finally{if(B)throw B[0]}}}))),yield Vt.wait(10);const Nt=[];Yt.forEach(a=>{a.hasAttribute("data-permanent")||(p(this,c,Pt).call(this,a)?Nt.push(a):a.remove())});const Xt=p(this,c,Lt).call(this,f.document.body);e(this,A).morphInsideScrollContainer||p(this,c,At).call(this,f.document),document.documentElement.setAttribute("data-current-pathname",l.pathname),document.documentElement.setAttribute("data-current-leaf",l.leaf),st.changeHistory({action:s,pathname:l.pathname,searchParameters:l.parameters||(b?location.search:""),hash:l.hash}),e(this,K).remove(),r(this,j,e(this,m)),r(this,m,l),e(this,Z).forEach((a,k)=>{const x=Xt[k],jt=getComputedStyle(a).getPropertyValue("--morph-duration");let F=[],B=[];S?S.forEach(d=>{const v=a.querySelector(d),R=x.querySelector(d);v&&R&&(B.push(v),F.push(R))}):(F.push(...x.childNodes),B.push(...a.childNodes)),B.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"))}),F.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"))}),S?F.forEach((d,v)=>{var R;(R=B[v].parentElement)==null||R.insertBefore(d,B[v])}):a.prepend(...F),_t.requestIdleCallback(()=>{B.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old-idle")}),F.forEach(d=>{var v;d instanceof HTMLElement&&((v=d.parentElement)==null||v.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("new-idle"))})});const ct=gt(Et({},ft),{morphElement:a});C.dispatchEvent(document,"morphNewChildrenAdded",{detail:ct});const Kt=new Promise(d=>{setTimeout(()=>{B.forEach(v=>v.remove()),F.forEach(v=>{var R;v instanceof HTMLElement&&((R=v.parentElement)==null||R.style.removeProperty("--new-content-height"),v.classList.remove("new-idle","new"))}),C.dispatchEvent(document,"morphOldChildrenRemoved",{detail:ct}),d()},(parseFloat(jt)||0)*1e3+10)});e(this,z).push(Kt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-f.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),C.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:f.scrollState}),l.hash?(f.clearScrollState(),p(this,c,kt).call(this,l.hash,{centerScroll:i,offsetScroll:u})):e(this,I)?f.restoreScrollPosition():f.renewScrollPosition(),yield Promise.all(e(this,z)),Nt.forEach(a=>a.remove()),r(this,z,[]),e(this,Z).forEach(a=>{a.querySelectorAll("script").forEach(x=>{x.replaceWith(p(this,c,yt).call(this,x))})}),C.dispatchEvent(document,"morphComplete",{detail:ft}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch($){console.error($)}r(this,U,void 0)})}addLink(t){e(this,E).push(new St(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){r(this,E,e(this,E).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){r(this,E,e(this,E).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,at));e(this,E).push(...s.map(i=>new St(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,at));e(this,E).forEach(s=>s.destroy()),r(this,E,t.map(s=>new St(s,this)))}};A=new WeakMap,Z=new WeakMap,E=new WeakMap,U=new WeakMap,m=new WeakMap,j=new WeakMap,z=new WeakMap,I=new WeakMap,L=new WeakMap,rt=new WeakMap,T=new WeakMap,K=new WeakMap,_=new WeakMap,tt=new WeakMap,c=new WeakSet,yt=function(t){const s=document.createElement("script");for(let i=0;i<t.attributes.length;i++){const u=t.attributes[i];s.setAttribute(u.name,u.value)}return t.hasAttribute("src")||(s.innerHTML=t.innerHTML),s},at=new WeakMap,ut=function(t){const s=this.normalizePath(t);let i=e(this,T).get(s.pathname);return i||(i=new Ft(this,s.pathname),e(this,T).set(s.pathname,i)),i},Lt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Wt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},bt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},Pt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},At=function(t){var s,i;(s=e(this,L))==null||s.removeEventListener("scroll",e(this,et)),r(this,tt,0),r(this,_,0),r(this,L,e(this,A).scrollSelector&&t.querySelector(e(this,A).scrollSelector)||window),r(this,rt,e(this,L)===window),(i=e(this,L))==null||i.addEventListener("scroll",e(this,et)),e(this,et).call(this)},kt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Vt.scrollToElement(i,{scrollElement:e(this,L),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},dt=new WeakMap,et=new WeakMap,it.instance=null;let wt=it;exports.Morph=wt;
|