aptechka 0.66.4 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,33 +1,33 @@
1
- var Ct = (a, t) => (t = Symbol[a]) ? t : Symbol.for("Symbol." + a), Tt = (a) => {
1
+ var xt = (a, t) => (t = Symbol[a]) ? t : Symbol.for("Symbol." + a), Mt = (a) => {
2
2
  throw TypeError(a);
3
3
  };
4
- var ft = (a, t, s) => t.has(a) || Tt("Cannot " + s);
5
- var e = (a, t, s) => (ft(a, t, "read from private field"), s ? s.call(a) : t.get(a)), o = (a, t, s) => t.has(a) ? Tt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(a) : t.set(a, s), n = (a, t, s, i) => (ft(a, t, "write to private field"), i ? i.call(a, s) : t.set(a, s), s), m = (a, t, s) => (ft(a, t, "access private method"), s);
6
- var I = (a, t, s) => new Promise((i, h) => {
7
- var w = (E) => {
4
+ var gt = (a, t, s) => t.has(a) || Mt("Cannot " + s);
5
+ var e = (a, t, s) => (gt(a, t, "read from private field"), s ? s.call(a) : t.get(a)), o = (a, t, s) => t.has(a) ? Mt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(a) : t.set(a, s), r = (a, t, s, i) => (gt(a, t, "write to private field"), i ? i.call(a, s) : t.set(a, s), s), p = (a, t, s) => (gt(a, t, "access private method"), s);
6
+ var z = (a, t, s) => new Promise((i, c) => {
7
+ var y = (E) => {
8
8
  try {
9
- S(s.next(E));
10
- } catch (q) {
11
- h(q);
9
+ w(s.next(E));
10
+ } catch (V) {
11
+ c(V);
12
12
  }
13
- }, b = (E) => {
13
+ }, x = (E) => {
14
14
  try {
15
- S(s.throw(E));
16
- } catch (q) {
17
- h(q);
15
+ w(s.throw(E));
16
+ } catch (V) {
17
+ c(V);
18
18
  }
19
- }, S = (E) => E.done ? i(E.value) : Promise.resolve(E.value).then(w, b);
20
- S((s = s.apply(a, t)).next());
19
+ }, w = (E) => E.done ? i(E.value) : Promise.resolve(E.value).then(y, x);
20
+ w((s = s.apply(a, t)).next());
21
21
  });
22
- var xt = (a, t, s) => (t = a[Ct("asyncIterator")]) ? t.call(a) : (a = a[Ct("iterator")](), t = {}, s = (i, h) => (h = a[i]) && (t[i] = (w) => new Promise((b, S, E) => (w = h.call(a, w), E = w.done, Promise.resolve(w.value).then((q) => b({ value: q, done: E }), S)))), s("next"), s("return"), t);
23
- import { i as Dt } from "../index-Bv9zgfdb.js";
24
- import { d as V } from "../events-CsVF98U6.js";
22
+ var Nt = (a, t, s) => (t = a[xt("asyncIterator")]) ? t.call(a) : (a = a[xt("iterator")](), t = {}, s = (i, c) => (c = a[i]) && (t[i] = (y) => new Promise((x, w, E) => (y = c.call(a, y), E = y.done, Promise.resolve(y.value).then((V) => x({ value: V, done: E }), w)))), s("next"), s("return"), t);
23
+ import { i as Rt } from "../index-Bv9zgfdb.js";
24
+ import { d as B } from "../events-CsVF98U6.js";
25
25
  import { r as Wt } from "../polyfills-DJrTJQky.js";
26
- import { w as Bt, s as Yt } from "../scroll-DPkCFTxg.js";
26
+ import { w as Yt, s as Xt } from "../scroll-DPkCFTxg.js";
27
27
  import "construct-style-sheets-polyfill";
28
- import { n as Xt, c as Mt, s as Ut } from "../url-Cc-RVfii.js";
29
- import { cssValueParser as $t } from "../css-value-parser/index.js";
30
- class Rt extends HTMLElement {
28
+ import { n as $t, c as Ht, s as Ut } from "../url-Cc-RVfii.js";
29
+ import { cssValueParser as jt } from "../css-value-parser/index.js";
30
+ class Vt extends HTMLElement {
31
31
  connectedCallback() {
32
32
  const t = {
33
33
  "aria-live": "assertive",
@@ -38,109 +38,149 @@ class Rt extends HTMLElement {
38
38
  this.setAttribute(s, i);
39
39
  }
40
40
  }
41
- Dt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Rt);
42
- var C, l, M, et, $;
43
- class pt {
41
+ Rt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Vt);
42
+ var k, l, N, it, K;
43
+ class Et {
44
44
  constructor(t, s) {
45
- o(this, C);
45
+ o(this, k);
46
46
  o(this, l);
47
- o(this, M);
48
- o(this, et, (t) => {
47
+ o(this, N);
48
+ o(this, it, (t) => {
49
49
  var i;
50
- if (t.preventDefault(), e(this, l).hasAttribute("data-back") && e(this, C).previousPathname)
50
+ if (t.preventDefault(), e(this, l).hasAttribute("data-back") && e(this, k).previousPathname)
51
51
  history.back();
52
52
  else {
53
- n(this, M, e(this, l).getAttribute("href") || "/");
54
- const h = e(this, l).getAttribute(
53
+ r(this, N, e(this, l).getAttribute("href") || "/");
54
+ const c = e(this, l).getAttribute(
55
55
  "data-history-action"
56
- ) || "push", w = e(this, l).hasAttribute("data-center-scroll"), b = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), S = b ? $t.parse(b) : void 0, E = e(this, l).hasAttribute("data-revalidate"), q = e(this, l).hasAttribute(
56
+ ) || "push", y = e(this, l).hasAttribute("data-center-scroll"), x = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), w = x ? jt.parse(x) : void 0, E = e(this, l).hasAttribute("data-revalidate"), V = e(this, l).hasAttribute(
57
57
  "data-keep-search-parameters"
58
- ), ht = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((Y) => Y.trim()), f = e(this, l).hasAttribute("data-clear-state");
59
- e(this, C).navigate(e(this, M), {
60
- historyAction: h,
61
- centerScroll: w,
62
- offsetScroll: S,
58
+ ), dt = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map(($) => $.trim()), m = e(this, l).hasAttribute("data-clear-state");
59
+ e(this, k).navigate(e(this, N), {
60
+ historyAction: c,
61
+ centerScroll: y,
62
+ offsetScroll: w,
63
63
  revalidate: E,
64
- keepSearchParameters: q,
65
- submorph: ht,
66
- clearState: f
64
+ keepSearchParameters: V,
65
+ submorph: dt,
66
+ clearState: m
67
67
  });
68
68
  }
69
69
  });
70
- o(this, $, () => {
70
+ o(this, K, () => {
71
71
  const t = e(this, l).hasAttribute("data-revalidate");
72
- e(this, C).prefetch(e(this, M), t), e(this, l).removeEventListener("pointerenter", e(this, $));
72
+ e(this, k).prefetch(e(this, N), t), e(this, l).removeEventListener("pointerenter", e(this, K));
73
73
  });
74
- n(this, C, s), n(this, l, t), n(this, M, e(this, l).getAttribute("href") || "/"), e(this, l).addEventListener("click", e(this, et)), this.checkCurrent(location.pathname), e(this, l).hasAttribute("data-prefetch") && e(this, l).addEventListener("pointerenter", e(this, $));
74
+ r(this, k, s), r(this, l, t), r(this, N, e(this, l).getAttribute("href") || "/"), e(this, l).addEventListener("click", e(this, it)), this.checkCurrent(location.pathname), e(this, l).hasAttribute("data-prefetch") && e(this, l).addEventListener("pointerenter", e(this, K));
75
75
  }
76
76
  get element() {
77
77
  return e(this, l);
78
78
  }
79
79
  checkCurrent(t) {
80
- const s = e(this, C).normalizePath(t), i = e(this, C).normalizePath(e(this, M));
80
+ const s = e(this, k).normalizePath(t), i = e(this, k).normalizePath(e(this, N));
81
81
  e(this, l).hasAttribute("data-include") && s.pathname.includes(i.pathname) ? e(this, l).classList.add("current") : i.pathname === s.pathname ? e(this, l).classList.add("current") : e(this, l).classList.remove("current");
82
82
  }
83
83
  destroy() {
84
- e(this, l).removeEventListener("click", e(this, et)), e(this, l).removeEventListener("pointerenter", e(this, $)), e(this, l).classList.remove("current");
84
+ e(this, l).removeEventListener("click", e(this, it)), e(this, l).removeEventListener("pointerenter", e(this, K)), e(this, l).classList.remove("current");
85
85
  }
86
86
  }
87
- C = new WeakMap(), l = new WeakMap(), M = new WeakMap(), et = new WeakMap(), $ = new WeakMap();
88
- var H, j, L, F, O, N, K;
89
- class Ht {
87
+ k = new WeakMap(), l = new WeakMap(), N = new WeakMap(), it = new WeakMap(), K = new WeakMap();
88
+ const Kt = new DOMParser();
89
+ var H, G, rt, b, D, F, I, J, O, W;
90
+ class Dt {
90
91
  constructor(t, s, i) {
91
92
  o(this, H);
92
- o(this, j);
93
- o(this, L, { x: 0, y: 0 });
94
- o(this, F);
93
+ o(this, G);
94
+ o(this, rt);
95
+ o(this, b, { x: 0, y: 0 });
96
+ o(this, D, null);
97
+ o(this, F, null);
98
+ o(this, I, null);
99
+ o(this, J, null);
95
100
  o(this, O, null);
96
- o(this, N, null);
97
- o(this, K, null);
98
- n(this, H, t), n(this, j, s), n(this, F, i.cloneNode(!0));
101
+ o(this, W, null);
102
+ r(this, H, t), r(this, G, s), r(this, rt, i);
99
103
  }
100
104
  get pathname() {
101
- return e(this, j);
105
+ return e(this, G);
106
+ }
107
+ get searchParameters() {
108
+ return e(this, rt);
102
109
  }
103
110
  get scrollState() {
104
- return e(this, L);
111
+ return e(this, b);
105
112
  }
106
113
  get document() {
107
- return e(this, N);
114
+ return e(this, I);
115
+ }
116
+ setInitialDocument(t) {
117
+ r(this, D, t.cloneNode(!0));
118
+ }
119
+ abort() {
120
+ var t;
121
+ return (t = e(this, O)) == null ? void 0 : t.abort(
122
+ `[${this.pathname}] page loading cancelled`
123
+ );
124
+ }
125
+ fetch(t) {
126
+ return z(this, null, function* () {
127
+ if (!(e(this, D) && !t)) {
128
+ if (e(this, W))
129
+ return e(this, W);
130
+ r(this, W, new Promise((s) => z(this, null, function* () {
131
+ try {
132
+ r(this, O, new AbortController());
133
+ const c = yield (yield fetch(
134
+ `${this.pathname}${this.searchParameters ? "?" + this.searchParameters : ""}`,
135
+ {
136
+ signal: e(this, O).signal
137
+ }
138
+ )).text(), y = Kt.parseFromString(c, "text/html");
139
+ this.setInitialDocument(y);
140
+ } catch (i) {
141
+ console.warn(i);
142
+ } finally {
143
+ r(this, O, null), r(this, W, null), s();
144
+ }
145
+ })));
146
+ }
147
+ });
108
148
  }
109
149
  cloneDocument() {
110
- n(this, N, (e(this, O) || e(this, F)).cloneNode(!0));
150
+ r(this, I, (e(this, F) || e(this, D)).cloneNode(!0));
111
151
  }
112
152
  get title() {
113
153
  let t = "";
114
- if (e(this, N).title)
115
- t = e(this, N).title;
154
+ if (e(this, I).title)
155
+ t = e(this, I).title;
116
156
  else {
117
- const s = e(this, N).querySelector("h1");
118
- t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this, j);
157
+ const s = e(this, I).querySelector("h1");
158
+ t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this, G);
119
159
  }
120
160
  return t;
121
161
  }
122
162
  clearScrollState() {
123
- e(this, L).x = 0, e(this, L).y = 0;
163
+ e(this, b).x = 0, e(this, b).y = 0;
124
164
  }
125
165
  clearDocumentState() {
126
- n(this, O, null);
166
+ r(this, F, null);
127
167
  }
128
168
  saveScrollState() {
129
- e(this, F).documentElement.hasAttribute(
169
+ e(this, D).documentElement.hasAttribute(
130
170
  "data-no-scroll-restoration"
131
- ) ? (e(this, L).x = 0, e(this, L).y = 0) : (e(this, L).x = e(this, H).scrollValue.left, e(this, L).y = e(this, H).scrollValue.top);
171
+ ) ? (e(this, b).x = 0, e(this, b).y = 0) : (e(this, b).x = e(this, H).scrollValue.left, e(this, b).y = e(this, H).scrollValue.top);
132
172
  }
133
173
  restoreScrollPosition() {
134
174
  e(this, H).scrollElement.scroll({
135
- top: e(this, L).y,
136
- left: e(this, L).x,
175
+ top: e(this, b).y,
176
+ left: e(this, b).x,
137
177
  behavior: "instant"
138
178
  });
139
179
  }
140
180
  saveDocumentState() {
141
- e(this, F).documentElement.hasAttribute(
181
+ e(this, D).documentElement.hasAttribute(
142
182
  "data-no-page-restoration"
143
- ) ? n(this, O, null) : n(this, O, document.cloneNode(!0));
183
+ ) ? r(this, F, null) : r(this, F, document.cloneNode(!0));
144
184
  }
145
185
  renewScrollPosition() {
146
186
  e(this, H).scrollElement.scroll({
@@ -150,44 +190,43 @@ class Ht {
150
190
  });
151
191
  }
152
192
  saveState(t) {
153
- n(this, K, t);
193
+ r(this, J, t);
154
194
  }
155
195
  clearState() {
156
- const t = e(this, K);
157
- return n(this, K, null), t;
196
+ const t = e(this, J);
197
+ return r(this, J, null), t;
158
198
  }
159
199
  }
160
- H = new WeakMap(), j = new WeakMap(), L = new WeakMap(), F = new WeakMap(), O = new WeakMap(), N = new WeakMap(), K = new WeakMap();
161
- var A, G, p, lt, D, d, st, W, T, P, it, R, B, J, Q, rt, c, ot, qt, Et, zt, gt, St, wt, vt, ct, Z;
162
- const tt = class tt {
200
+ H = new WeakMap(), G = new WeakMap(), rt = new WeakMap(), b = new WeakMap(), D = new WeakMap(), F = new WeakMap(), I = new WeakMap(), J = new WeakMap(), O = new WeakMap(), W = new WeakMap();
201
+ var P, Q, g, R, d, nt, Y, C, L, ot, T, X, Z, _, at, h, ht, St, qt, wt, yt, vt, bt, ut, tt;
202
+ const st = class st {
163
203
  constructor(t) {
164
- o(this, c);
165
- o(this, A, null);
166
- o(this, G, null);
167
- o(this, p, []);
168
- o(this, lt, new DOMParser());
169
- o(this, D);
170
- o(this, d, null);
171
- o(this, st);
172
- o(this, W, []);
173
- o(this, T, !1);
204
+ o(this, h);
174
205
  o(this, P, null);
175
- o(this, it, !1);
176
- o(this, R, /* @__PURE__ */ new Map());
177
- o(this, B, null);
178
- o(this, J, 0);
179
- o(this, Q, 0);
180
- o(this, rt, (t) => {
206
+ o(this, Q, null);
207
+ o(this, g, []);
208
+ o(this, R);
209
+ o(this, d, null);
210
+ o(this, nt);
211
+ o(this, Y, []);
212
+ o(this, C, !1);
213
+ o(this, L, null);
214
+ o(this, ot, !1);
215
+ o(this, T, /* @__PURE__ */ new Map());
216
+ o(this, X, null);
217
+ o(this, Z, 0);
218
+ o(this, _, 0);
219
+ o(this, at, (t) => {
181
220
  var s;
182
221
  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";
183
222
  });
184
- o(this, ct, (t) => I(this, null, function* () {
223
+ o(this, ut, (t) => z(this, null, function* () {
185
224
  var s;
186
- (s = t.state) != null && s.path && (t.preventDefault(), n(this, T, !0), yield this.navigate(t.state.path, { historyAction: "none" }), n(this, T, !1));
225
+ (s = t.state) != null && s.path && (t.preventDefault(), r(this, C, !0), yield this.navigate(t.state.path, { historyAction: "none" }), r(this, C, !1));
187
226
  }));
188
- o(this, Z, () => {
189
- const { left: t, top: s } = this.scrollValue, i = s - e(this, Q), h = t - e(this, J);
190
- n(this, Q, s), n(this, J, t), document.documentElement.classList.toggle("scroll-y", s > 0), document.documentElement.classList.toggle("scroll-x", t > 0), document.documentElement.classList.toggle(
227
+ o(this, tt, () => {
228
+ const { left: t, top: s } = this.scrollValue, i = s - e(this, _), c = t - e(this, Z);
229
+ r(this, _, s), r(this, Z, t), document.documentElement.classList.toggle("scroll-y", s > 0), document.documentElement.classList.toggle("scroll-x", t > 0), document.documentElement.classList.toggle(
191
230
  "scroll-y-forward",
192
231
  i > 0
193
232
  ), document.documentElement.classList.toggle(
@@ -195,264 +234,267 @@ const tt = class tt {
195
234
  i < 0
196
235
  ), document.documentElement.classList.toggle(
197
236
  "scroll-x-forward",
198
- h > 0
237
+ c > 0
199
238
  ), document.documentElement.classList.toggle(
200
239
  "scroll-x-backward",
201
- h < 0
202
- ), V(document, "morphScroll", {
240
+ c < 0
241
+ ), B(document, "morphScroll", {
203
242
  detail: {
204
243
  left: t,
205
244
  top: s
206
245
  }
207
246
  });
208
247
  });
209
- if (Dt && !tt.instance) {
210
- tt.instance = this, n(this, A, {
211
- base: Xt(t == null ? void 0 : t.base),
248
+ if (Rt && !st.instance) {
249
+ st.instance = this, r(this, P, {
250
+ base: $t(t == null ? void 0 : t.base),
212
251
  waitForHeadToLoad: (t == null ? void 0 : t.waitForHeadToLoad) !== !1,
213
252
  cachePages: (t == null ? void 0 : t.cachePages) !== !1,
214
253
  trailingSlash: (t == null ? void 0 : t.trailingSlash) || !1,
215
254
  scrollSelector: t == null ? void 0 : t.scrollSelector,
216
255
  morphInsideScrollContainer: (t == null ? void 0 : t.morphInsideScrollContainer) || !1
217
- }), n(this, G, m(this, c, Et).call(this, document.body));
256
+ }), r(this, Q, p(this, h, St).call(this, document.body));
218
257
  const s = this.normalizePath(
219
258
  location.pathname + location.hash
220
259
  );
221
- n(this, d, s.pathname), e(this, R).set(
222
- e(this, d),
223
- new Ht(this, e(this, d), document)
224
- ), document.documentElement.setAttribute(
260
+ r(this, d, s.pathname);
261
+ const i = new Dt(this, e(this, d));
262
+ i.setInitialDocument(document), e(this, T).set(e(this, d), i), document.documentElement.setAttribute(
225
263
  "data-current-pathname",
226
264
  e(this, d)
227
265
  ), document.documentElement.setAttribute(
228
266
  "data-current-leaf",
229
267
  s.leaf
230
- ), this.findLinks(), history.scrollRestoration = "manual", addEventListener("popstate", e(this, ct)), Mt({
268
+ ), this.findLinks(), history.scrollRestoration = "manual", addEventListener("popstate", e(this, ut)), Ht({
231
269
  action: "replace",
232
270
  pathname: e(this, d),
233
271
  searchParameters: s.parameters || location.search,
234
272
  hash: s.hash
235
- }), n(this, B, new Rt()), m(this, c, wt).call(this, document);
273
+ }), r(this, X, new Vt()), p(this, h, vt).call(this, document);
236
274
  }
237
275
  }
238
276
  get currentPathname() {
239
277
  return e(this, d);
240
278
  }
241
279
  get previousPathname() {
242
- return e(this, st);
280
+ return e(this, nt);
243
281
  }
244
282
  get links() {
245
- return e(this, p);
283
+ return e(this, g);
246
284
  }
247
285
  get scrollElement() {
248
- return e(this, P);
286
+ return e(this, L);
249
287
  }
250
288
  get isPopstateNavigation() {
251
- return e(this, T);
289
+ return e(this, C);
252
290
  }
253
291
  get scrollValue() {
254
292
  let t = 0, s = 0;
255
- return e(this, it) ? (t = window.scrollY, s = window.scrollX) : (t = e(this, P).scrollTop, s = e(this, P).scrollLeft), { top: t, left: s };
293
+ return e(this, ot) ? (t = window.scrollY, s = window.scrollX) : (t = e(this, L).scrollTop, s = e(this, L).scrollLeft), { top: t, left: s };
256
294
  }
257
295
  saveState(t) {
258
- const s = e(this, R).get(e(this, d));
296
+ const s = e(this, T).get(e(this, d));
259
297
  s && s.saveState(t);
260
298
  }
261
299
  getState() {
262
- const t = e(this, R).get(e(this, d));
300
+ const t = e(this, T).get(e(this, d));
263
301
  return t == null ? void 0 : t.clearState();
264
302
  }
265
303
  normalizePath(t) {
266
304
  return Ut(t, {
267
- base: e(this, A).base,
268
- trailingSlash: e(this, A).trailingSlash
305
+ base: e(this, P).base,
306
+ trailingSlash: e(this, P).trailingSlash
269
307
  });
270
308
  }
271
309
  prefetch(t, s) {
272
- return I(this, null, function* () {
273
- const i = this.normalizePath(t);
274
- m(this, c, ot).call(this, i.pathname, {
275
- searchParameters: i.parameters,
276
- revalidate: s
277
- });
310
+ return z(this, null, function* () {
311
+ const i = this.normalizePath(t), c = p(this, h, ht).call(this, i.pathname, i.parameters);
312
+ c == null || c.fetch(s);
278
313
  });
279
314
  }
280
- navigate(q) {
281
- return I(this, arguments, function* (t, {
315
+ navigate(V) {
316
+ return z(this, arguments, function* (t, {
282
317
  historyAction: s = "push",
283
318
  centerScroll: i,
284
- offsetScroll: h,
285
- revalidate: w,
286
- keepSearchParameters: b,
287
- submorph: S,
319
+ offsetScroll: c,
320
+ revalidate: y,
321
+ keepSearchParameters: x,
322
+ submorph: w,
288
323
  clearState: E
289
324
  } = {}) {
290
- var Lt;
291
- if (e(this, W).length)
325
+ var Pt;
326
+ if (e(this, Y).length)
292
327
  return;
293
- const ht = this.normalizePath(((Lt = this.pathnameModifier) == null ? void 0 : Lt.call(this, t)) || t);
294
- let { pathname: f, hash: Y, parameters: yt, leaf: It } = ht;
295
- if (e(this, D) === f || e(this, d) === f) {
296
- e(this, T) || m(this, c, vt).call(this, Y || 0, {
328
+ const dt = this.normalizePath(((Pt = this.pathnameModifier) == null ? void 0 : Pt.call(this, t)) || t);
329
+ let { pathname: m, hash: $, parameters: Lt, leaf: zt } = dt;
330
+ if (e(this, R) === m || e(this, d) === m) {
331
+ e(this, C) || p(this, h, bt).call(this, $ || 0, {
297
332
  centerScroll: i,
298
- offsetScroll: h,
333
+ offsetScroll: c,
299
334
  behavior: "smooth"
300
335
  });
301
336
  return;
302
337
  }
303
- n(this, D, f), e(this, p).forEach((X) => {
304
- X.checkCurrent(f);
338
+ r(this, R, m), e(this, g).forEach((U) => {
339
+ U.checkCurrent(m);
305
340
  });
306
341
  try {
307
- let X = !0;
342
+ let U = !0;
308
343
  if (this.preprocessor)
309
344
  try {
310
- yield new Promise((r, k) => {
311
- var y;
312
- (y = this.preprocessor) == null || y.call(this, {
313
- pathname: f,
314
- resolve: r,
315
- reject: k,
316
- submorph: S
345
+ yield new Promise((n, A) => {
346
+ var v;
347
+ (v = this.preprocessor) == null || v.call(this, {
348
+ pathname: m,
349
+ resolve: n,
350
+ reject: A,
351
+ submorph: w
317
352
  });
318
353
  });
319
- } catch (r) {
320
- r ? console.error(r) : console.log("Route change canceled"), X = !1;
354
+ } catch (n) {
355
+ n ? console.error(n) : console.log("Route change canceled"), U = !1;
321
356
  }
322
- if (!X || e(this, D) !== f) {
323
- e(this, p).forEach((r) => {
324
- r.checkCurrent(e(this, d));
357
+ if (!U || e(this, R) !== m) {
358
+ e(this, g).forEach((n) => {
359
+ n.checkCurrent(e(this, d));
325
360
  });
326
361
  return;
327
362
  }
328
- const ut = {
329
- pathname: f,
330
- submorph: S
363
+ const mt = {
364
+ pathname: m,
365
+ submorph: w
331
366
  };
332
- V(document, "morphNavigation", {
333
- detail: ut
334
- });
335
- const dt = yield m(this, c, ot).call(this, e(this, d)), v = yield m(this, c, ot).call(this, f, {
336
- searchParameters: yt,
337
- revalidate: w
367
+ B(document, "morphNavigation", {
368
+ detail: mt
338
369
  });
339
- if (e(this, D) !== f) {
340
- e(this, p).forEach((r) => {
341
- r.checkCurrent(e(this, d));
370
+ const ft = p(this, h, ht).call(this, e(this, d)), f = p(this, h, ht).call(this, m, Lt);
371
+ if (e(this, T).forEach((n) => {
372
+ n.pathname !== m && n.abort();
373
+ }), yield f == null ? void 0 : f.fetch(y), e(this, R) !== m) {
374
+ e(this, g).forEach((n) => {
375
+ n.checkCurrent(e(this, d));
342
376
  });
343
377
  return;
344
378
  }
345
- dt.clearState(), dt.saveScrollState(), dt.saveDocumentState(), e(this, T) || (v.clearScrollState(), v.clearDocumentState()), E && v.clearState(), v.cloneDocument(), e(this, B).textContent = v.title, document.body.appendChild(e(this, B)), V(document, "morphStart", {
346
- detail: ut
379
+ ft.clearState(), ft.saveScrollState(), ft.saveDocumentState(), e(this, C) || (f.clearScrollState(), f.clearDocumentState()), E && f.clearState(), f.cloneDocument(), e(this, X).textContent = f.title, document.body.appendChild(e(this, X)), B(document, "morphStart", {
380
+ detail: mt
347
381
  });
348
- const bt = Array.from(document.head.children), Pt = Array.from(v.document.head.children), At = m(this, c, zt).call(this, bt, Pt), Vt = m(this, c, gt).call(this, bt, At), nt = m(this, c, gt).call(this, Pt, At);
349
- nt.forEach((r, k) => {
350
- if (r.tagName === "SCRIPT" && r.getAttribute("src")) {
351
- const y = document.createElement("script");
352
- y.type = "module", y.src = r.getAttribute("src"), nt[k] = y;
382
+ const At = Array.from(document.head.children), kt = Array.from(f.document.head.children), Ct = p(this, h, qt).call(this, At, kt), Bt = p(this, h, wt).call(this, At, Ct), lt = p(this, h, wt).call(this, kt, Ct);
383
+ lt.forEach((n, A) => {
384
+ if (n.tagName === "SCRIPT" && n.getAttribute("src")) {
385
+ const v = document.createElement("script");
386
+ v.type = "module", v.src = n.getAttribute("src"), lt[A] = v;
353
387
  }
354
- }), nt.forEach((r) => {
355
- document.head.appendChild(r);
388
+ }), lt.forEach((n) => {
389
+ document.head.appendChild(n);
356
390
  });
357
- const mt = nt.filter((r) => {
358
- if (r.hasAttribute("data-no-waiting"))
391
+ const pt = lt.filter((n) => {
392
+ if (n.hasAttribute("data-no-waiting"))
359
393
  return !1;
360
- if (m(this, c, St).call(this, r))
394
+ if (p(this, h, yt).call(this, n))
361
395
  return !0;
362
396
  });
363
- e(this, A).waitForHeadToLoad && mt.length && (yield new Promise((r) => I(this, null, function* () {
364
- let k = 0;
397
+ e(this, P).waitForHeadToLoad && pt.length && (yield new Promise((n) => z(this, null, function* () {
398
+ let A = 0;
365
399
  try {
366
- for (var y = xt(mt), _, z, U; _ = !(z = yield y.next()).done; _ = !1) {
367
- const at = z.value;
368
- at.onload = () => {
369
- k++, k === mt.length && r();
400
+ for (var v = Nt(pt), et, q, j; et = !(q = yield v.next()).done; et = !1) {
401
+ const ct = q.value;
402
+ ct.onload = () => {
403
+ A++, A === pt.length && n();
370
404
  };
371
405
  }
372
- } catch (z) {
373
- U = [z];
406
+ } catch (q) {
407
+ j = [q];
374
408
  } finally {
375
409
  try {
376
- _ && (z = y.return) && (yield z.call(y));
410
+ et && (q = v.return) && (yield q.call(v));
377
411
  } finally {
378
- if (U)
379
- throw U[0];
412
+ if (j)
413
+ throw j[0];
380
414
  }
381
415
  }
382
- }))), yield Bt(10);
383
- const kt = [];
384
- Vt.forEach((r) => {
385
- r.hasAttribute("data-permanent") || (m(this, c, St).call(this, r) ? kt.push(r) : r.remove());
416
+ }))), yield Yt(10);
417
+ const Tt = [];
418
+ Bt.forEach((n) => {
419
+ n.hasAttribute("data-permanent") || (p(this, h, yt).call(this, n) ? Tt.push(n) : n.remove());
386
420
  });
387
- const Ft = m(this, c, Et).call(this, v.document.body);
388
- e(this, A).morphInsideScrollContainer || m(this, c, wt).call(this, v.document), document.documentElement.setAttribute("data-current-pathname", f), document.documentElement.setAttribute("data-current-leaf", It), Mt({
421
+ const Ft = p(this, h, St).call(this, f.document.body);
422
+ e(this, P).morphInsideScrollContainer || p(this, h, vt).call(this, f.document), document.documentElement.setAttribute("data-current-pathname", m), document.documentElement.setAttribute("data-current-leaf", zt), Ht({
389
423
  action: s,
390
- pathname: f,
391
- searchParameters: yt || (b ? location.search : ""),
392
- hash: Y
393
- }), e(this, B).remove(), n(this, st, e(this, d)), n(this, d, f), e(this, G).forEach((r, k) => {
394
- const y = Ft[k], _ = getComputedStyle(r).getPropertyValue("--morph-duration");
395
- let z = [], U = [];
396
- S ? S.forEach((u) => {
397
- const g = r.querySelector(u), x = y.querySelector(u);
398
- g && x && (U.push(g), z.push(x));
399
- }) : (z.push(...y.childNodes), U.push(...r.childNodes)), U.forEach((u) => {
424
+ pathname: m,
425
+ searchParameters: Lt || (x ? location.search : ""),
426
+ hash: $
427
+ }), e(this, X).remove(), r(this, nt, e(this, d)), r(this, d, m), e(this, Q).forEach((n, A) => {
428
+ const v = Ft[A], et = getComputedStyle(n).getPropertyValue("--morph-duration");
429
+ let q = [], j = [];
430
+ w ? w.forEach((u) => {
431
+ const S = n.querySelector(u), M = v.querySelector(u);
432
+ S && M && (j.push(S), q.push(M));
433
+ }) : (q.push(...v.childNodes), j.push(...n.childNodes)), j.forEach((u) => {
400
434
  u instanceof HTMLElement && (this.destroyOldLinks(u), u.classList.add("old"));
401
- }), z.forEach((u) => {
435
+ }), q.forEach((u) => {
402
436
  u instanceof HTMLElement && (this.findNewLinks(u), u.classList.add("new"));
403
- }), S ? z.forEach((u, g) => {
404
- var x;
405
- (x = U[g].parentElement) == null || x.insertBefore(
437
+ }), w ? q.forEach((u, S) => {
438
+ var M;
439
+ (M = j[S].parentElement) == null || M.insertBefore(
406
440
  u,
407
- U[g]
441
+ j[S]
408
442
  );
409
- }) : r.prepend(...z), Wt(() => {
410
- z.forEach((u) => {
411
- var g;
412
- u instanceof HTMLElement && ((g = u.parentElement) == null || g.style.setProperty(
443
+ }) : n.prepend(...q), Wt(() => {
444
+ q.forEach((u) => {
445
+ var S;
446
+ u instanceof HTMLElement && ((S = u.parentElement) == null || S.style.setProperty(
413
447
  "--new-content-height",
414
448
  u.offsetHeight + "px"
415
449
  ), u.classList.add("in"));
416
450
  });
417
451
  });
418
- const at = {
419
- morphElement: r,
420
- pathname: f
452
+ const ct = {
453
+ morphElement: n,
454
+ pathname: m
421
455
  };
422
- V(document, "morphNewChildrenAdded", {
423
- detail: at
456
+ B(document, "morphNewChildrenAdded", {
457
+ detail: ct
424
458
  });
425
459
  const Ot = new Promise((u) => {
426
460
  setTimeout(() => {
427
- U.forEach((g) => g.remove()), z.forEach((g) => {
428
- var x;
429
- g instanceof HTMLElement && ((x = g.parentElement) == null || x.style.removeProperty(
461
+ j.forEach((S) => S.remove()), q.forEach((S) => {
462
+ var M;
463
+ S instanceof HTMLElement && ((M = S.parentElement) == null || M.style.removeProperty(
430
464
  "--new-content-height"
431
- ), g.classList.remove("in", "new"));
432
- }), V(document, "morphOldChildrenRemoved", {
433
- detail: at
465
+ ), S.classList.remove("in", "new"));
466
+ }), B(document, "morphOldChildrenRemoved", {
467
+ detail: ct
434
468
  }), u();
435
- }, (parseFloat(_) || 0) * 1e3 + 10);
469
+ }, (parseFloat(et) || 0) * 1e3 + 10);
436
470
  });
437
- e(this, W).push(Ot);
438
- }), Y ? (v.clearScrollState(), m(this, c, vt).call(this, Y, { centerScroll: i, offsetScroll: h })) : e(this, T) ? v.restoreScrollPosition() : v.renewScrollPosition(), V(document, "morphNavigationScroll", {
439
- detail: v.scrollState
440
- }), yield Promise.all(e(this, W)), kt.forEach((r) => r.remove()), n(this, W, []), e(this, G).forEach((r) => {
441
- r.querySelectorAll("script").forEach((y) => {
442
- const _ = document.createElement("script");
443
- _.type = "module", _.src = y.getAttribute("src"), y.replaceWith(_);
471
+ e(this, Y).push(Ot);
472
+ }), this.isPopstateNavigation ? document.documentElement.style.setProperty(
473
+ "--new-document-scroll-position",
474
+ (this.scrollValue.top - f.scrollState.y) * 1 + "px"
475
+ ) : document.documentElement.style.setProperty(
476
+ "--new-document-scroll-position",
477
+ this.scrollValue.top + "px"
478
+ ), B(document, "morphBeforeNavigationScroll", {
479
+ detail: f.scrollState
480
+ }), $ ? (f.clearScrollState(), p(this, h, bt).call(this, $, { centerScroll: i, offsetScroll: c })) : e(this, C) ? f.restoreScrollPosition() : f.renewScrollPosition(), yield Promise.all(e(this, Y)), Tt.forEach((n) => n.remove()), r(this, Y, []), e(this, Q).forEach((n) => {
481
+ n.querySelectorAll("script").forEach((v) => {
482
+ const et = document.createElement("script");
483
+ et.type = "module", et.src = v.getAttribute("src"), v.replaceWith(et);
444
484
  });
445
- }), V(document, "morphComplete", {
446
- detail: ut
447
- }), window.dispatchEvent(new Event("resize"));
448
- } catch (X) {
449
- console.error(X);
485
+ }), B(document, "morphComplete", {
486
+ detail: mt
487
+ }), document.documentElement.style.removeProperty(
488
+ "--new-document-scroll-position"
489
+ ), window.dispatchEvent(new Event("resize"));
490
+ } catch (U) {
491
+ console.error(U);
450
492
  }
451
- n(this, D, void 0);
493
+ r(this, R, void 0);
452
494
  });
453
495
  }
454
496
  addLink(t) {
455
- e(this, p).push(new pt(t, this));
497
+ e(this, g).push(new Et(t, this));
456
498
  }
457
499
  addLinks(t) {
458
500
  t.forEach((s) => {
@@ -460,71 +502,62 @@ const tt = class tt {
460
502
  });
461
503
  }
462
504
  removeLink(t) {
463
- n(this, p, e(this, p).filter((s) => s.element === t ? (s.destroy(), !1) : !0));
505
+ r(this, g, e(this, g).filter((s) => s.element === t ? (s.destroy(), !1) : !0));
464
506
  }
465
507
  destroyOldLinks(t) {
466
- n(this, p, e(this, p).filter((s) => t.contains(s.element) ? (s.destroy(), !1) : !0));
508
+ r(this, g, e(this, g).filter((s) => t.contains(s.element) ? (s.destroy(), !1) : !0));
467
509
  }
468
510
  findNewLinks(t) {
469
511
  const s = [...t.querySelectorAll("a")].filter(
470
- e(this, rt)
512
+ e(this, at)
471
513
  );
472
- e(this, p).push(
473
- ...s.map((i) => new pt(i, this))
514
+ e(this, g).push(
515
+ ...s.map((i) => new Et(i, this))
474
516
  );
475
517
  }
476
518
  findLinks() {
477
519
  const t = [
478
520
  ...document.documentElement.querySelectorAll("a")
479
- ].filter(e(this, rt));
480
- e(this, p).forEach((s) => s.destroy()), n(this, p, t.map((s) => new pt(s, this)));
521
+ ].filter(e(this, at));
522
+ e(this, g).forEach((s) => s.destroy()), r(this, g, t.map((s) => new Et(s, this)));
481
523
  }
482
524
  };
483
- A = new WeakMap(), G = new WeakMap(), p = new WeakMap(), lt = new WeakMap(), D = new WeakMap(), d = new WeakMap(), st = new WeakMap(), W = new WeakMap(), T = new WeakMap(), P = new WeakMap(), it = new WeakMap(), R = new WeakMap(), B = new WeakMap(), J = new WeakMap(), Q = new WeakMap(), rt = new WeakMap(), c = new WeakSet(), ot = function(t, s) {
484
- return I(this, null, function* () {
485
- let i = e(this, R).get(t);
486
- return (!i || s != null && s.revalidate) && (i = yield m(this, c, qt).call(this, t, s == null ? void 0 : s.searchParameters)), i;
487
- });
488
- }, qt = function(t, s) {
489
- return I(this, null, function* () {
490
- const h = yield (yield fetch(
491
- `${t}${s ? "?" + s : ""}`
492
- )).text(), w = e(this, lt).parseFromString(h, "text/html"), b = new Ht(this, t, w);
493
- return e(this, R).set(t, b), b;
494
- });
495
- }, Et = function(t) {
525
+ P = new WeakMap(), Q = new WeakMap(), g = new WeakMap(), R = new WeakMap(), d = new WeakMap(), nt = new WeakMap(), Y = new WeakMap(), C = new WeakMap(), L = new WeakMap(), ot = new WeakMap(), T = new WeakMap(), X = new WeakMap(), Z = new WeakMap(), _ = new WeakMap(), at = new WeakMap(), h = new WeakSet(), ht = function(t, s) {
526
+ let i = e(this, T).get(t);
527
+ return i || (i = new Dt(this, t, s), e(this, T).set(t, i)), i;
528
+ }, St = function(t) {
496
529
  const s = [...t.querySelectorAll("[data-morph]")];
497
530
  return s.length ? s : [t];
498
- }, zt = function(t, s) {
531
+ }, qt = function(t, s) {
499
532
  return t.filter(
500
533
  (i) => s.find(
501
- (h) => h.outerHTML === i.outerHTML
534
+ (c) => c.outerHTML === i.outerHTML
502
535
  )
503
536
  );
504
- }, gt = function(t, s) {
537
+ }, wt = function(t, s) {
505
538
  return t.filter(
506
539
  (i) => !s.find(
507
- (h) => h.outerHTML === i.outerHTML
540
+ (c) => c.outerHTML === i.outerHTML
508
541
  )
509
542
  );
510
- }, St = function(t) {
543
+ }, yt = function(t) {
511
544
  return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
512
- }, wt = function(t) {
545
+ }, vt = function(t) {
513
546
  var s, i;
514
- (s = e(this, P)) == null || s.removeEventListener(
547
+ (s = e(this, L)) == null || s.removeEventListener(
515
548
  "scroll",
516
- e(this, Z)
517
- ), n(this, Q, 0), n(this, J, 0), n(this, P, e(this, A).scrollSelector && t.querySelector(e(this, A).scrollSelector) || window), n(this, it, e(this, P) === window), (i = e(this, P)) == null || i.addEventListener("scroll", e(this, Z)), e(this, Z).call(this);
518
- }, vt = function(t, s) {
549
+ e(this, tt)
550
+ ), r(this, _, 0), r(this, Z, 0), r(this, L, e(this, P).scrollSelector && t.querySelector(e(this, P).scrollSelector) || window), r(this, ot, e(this, L) === window), (i = e(this, L)) == null || i.addEventListener("scroll", e(this, tt)), e(this, tt).call(this);
551
+ }, bt = function(t, s) {
519
552
  const i = typeof t == "string" ? document.getElementById(t) : t;
520
- (typeof i == "number" || i) && Yt(i, {
521
- scrollElement: e(this, P),
553
+ (typeof i == "number" || i) && Xt(i, {
554
+ scrollElement: e(this, L),
522
555
  behavior: (s == null ? void 0 : s.behavior) || "instant",
523
556
  center: s == null ? void 0 : s.centerScroll,
524
557
  offset: s == null ? void 0 : s.offsetScroll
525
558
  });
526
- }, ct = new WeakMap(), Z = new WeakMap(), tt.instance = null;
527
- let Nt = tt;
559
+ }, ut = new WeakMap(), tt = new WeakMap(), st.instance = null;
560
+ let It = st;
528
561
  export {
529
- Nt as Morph
562
+ It as Morph
530
563
  };