okno 1.0.0-beta.37 → 1.0.0-beta.39
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/dist/astro/index.d.ts +13 -0
- package/dist/astro/index.d.ts.map +1 -0
- package/dist/astro/index.js +15 -0
- package/dist/codegen/generate.d.ts.map +1 -1
- package/dist/codegen/modules.d.ts.map +1 -1
- package/dist/dispatch-BifB_3GO.js +955 -0
- package/dist/editor/index.js +16807 -15811
- package/dist/index.js +1 -1
- package/dist/init.d.ts +24 -4
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +167 -147
- package/dist/local/dispatch.d.ts.map +1 -1
- package/dist/next/index.js +1 -1
- package/dist/{plugin-CPb37kty.js → plugin-BdiBIiAv.js} +167 -139
- package/dist/runtime/wrap.d.ts +23 -0
- package/dist/runtime/wrap.d.ts.map +1 -1
- package/dist/runtime/wrap.js +344 -226
- package/dist/types/schema.d.ts +23 -12
- package/dist/types/schema.d.ts.map +1 -1
- package/dist/vite/index.js +1 -1
- package/dist/vite/plugin.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/runtime/wrap.ts +288 -33
- package/dist/dispatch-dIjAypRM.js +0 -934
package/dist/runtime/wrap.js
CHANGED
|
@@ -3,27 +3,53 @@ let O = !1;
|
|
|
3
3
|
function M() {
|
|
4
4
|
const t = globalThis;
|
|
5
5
|
O || typeof t.document > "u" || (O = !0, t.document.addEventListener("okno:change", (r) => {
|
|
6
|
-
const { path:
|
|
7
|
-
_.get(
|
|
6
|
+
const { path: o, value: s } = r.detail;
|
|
7
|
+
_.get(o)?.forEach((n) => n(s));
|
|
8
8
|
}));
|
|
9
9
|
}
|
|
10
|
+
let x = {};
|
|
11
|
+
function yt(t) {
|
|
12
|
+
t && typeof t == "object" && (x = t);
|
|
13
|
+
}
|
|
10
14
|
let L = {};
|
|
11
|
-
function
|
|
12
|
-
|
|
15
|
+
function _t(t) {
|
|
16
|
+
const r = t?.collections;
|
|
17
|
+
if (!r || typeof r != "object") return;
|
|
18
|
+
const o = {};
|
|
19
|
+
for (const [s, n] of Object.entries(r)) {
|
|
20
|
+
const e = n?.url;
|
|
21
|
+
typeof e == "string" && e.trim() && (o[s] = e.trim());
|
|
22
|
+
}
|
|
23
|
+
L = o;
|
|
24
|
+
}
|
|
25
|
+
function H(t, r) {
|
|
26
|
+
const o = [];
|
|
27
|
+
for (const s of t.split("/")) {
|
|
28
|
+
if (!s) continue;
|
|
29
|
+
const n = s.match(/^\[(.+)\]$/)?.[1];
|
|
30
|
+
if (!n) {
|
|
31
|
+
o.push(s);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
let e = r[n];
|
|
35
|
+
if (Array.isArray(e) && (e = e[0]), e && typeof e == "object" && (e = e.slug), e == null || e === "") return "";
|
|
36
|
+
o.push(String(e));
|
|
37
|
+
}
|
|
38
|
+
return "/" + o.join("/");
|
|
13
39
|
}
|
|
14
|
-
function
|
|
40
|
+
function ht(t, r = Date.now()) {
|
|
15
41
|
if (!t || typeof t != "object") return !0;
|
|
16
|
-
const
|
|
17
|
-
if (!Number.isNaN(
|
|
18
|
-
const n = typeof
|
|
42
|
+
const o = t, s = typeof o.publishAt == "string" ? Date.parse(o.publishAt) : NaN;
|
|
43
|
+
if (!Number.isNaN(s) && s > r) return !1;
|
|
44
|
+
const n = typeof o.unpublishAt == "string" ? Date.parse(o.unpublishAt) : NaN;
|
|
19
45
|
return !(!Number.isNaN(n) && n <= r);
|
|
20
46
|
}
|
|
21
|
-
function
|
|
47
|
+
function z(t) {
|
|
22
48
|
if (typeof t != "string") return t;
|
|
23
|
-
const r =
|
|
49
|
+
const r = x[t];
|
|
24
50
|
return typeof r == "function" ? r() : r ?? t;
|
|
25
51
|
}
|
|
26
|
-
const
|
|
52
|
+
const K = /* @__PURE__ */ new Set([
|
|
27
53
|
"src",
|
|
28
54
|
"href",
|
|
29
55
|
"alt",
|
|
@@ -36,97 +62,97 @@ const C = /* @__PURE__ */ new Set([
|
|
|
36
62
|
"name",
|
|
37
63
|
"value"
|
|
38
64
|
]);
|
|
39
|
-
function
|
|
65
|
+
function J(t) {
|
|
40
66
|
return t.replace(/[-_]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").trim().replace(/^./, (r) => r.toUpperCase());
|
|
41
67
|
}
|
|
42
68
|
function j(t, r = "") {
|
|
43
69
|
if (t == null) {
|
|
44
70
|
if (!r) return "";
|
|
45
|
-
const
|
|
46
|
-
return !
|
|
71
|
+
const o = r.split(".").pop() ?? "";
|
|
72
|
+
return !o || K.has(o) ? "" : J(o);
|
|
47
73
|
}
|
|
48
|
-
return typeof t != "object" ? String(t) :
|
|
74
|
+
return typeof t != "object" ? String(t) : g(t) ? t.text ?? "" : W(t) ? t.name ?? "" : "";
|
|
49
75
|
}
|
|
50
|
-
function
|
|
76
|
+
function p(t) {
|
|
51
77
|
return typeof t == "object" && t !== null && !Array.isArray(t) && "src" in t;
|
|
52
78
|
}
|
|
53
|
-
function
|
|
79
|
+
function g(t) {
|
|
54
80
|
return typeof t == "object" && t !== null && !Array.isArray(t) && "url" in t && "text" in t && "external" in t;
|
|
55
81
|
}
|
|
56
|
-
function
|
|
82
|
+
function W(t) {
|
|
57
83
|
return typeof t != "object" || t === null || Array.isArray(t) ? !1 : Object.keys(t).length === 2 && "name" in t && "value" in t;
|
|
58
84
|
}
|
|
59
|
-
function
|
|
85
|
+
function I(t, r) {
|
|
60
86
|
if (r === void 0) return t;
|
|
61
87
|
if (t === null || typeof t != "object" || Array.isArray(t) || r === null || typeof r != "object" || Array.isArray(r))
|
|
62
88
|
return r;
|
|
63
|
-
const
|
|
64
|
-
for (const
|
|
65
|
-
|
|
66
|
-
return
|
|
89
|
+
const o = { ...t };
|
|
90
|
+
for (const s of Object.keys(r))
|
|
91
|
+
o[s] = I(t[s], r[s]);
|
|
92
|
+
return o;
|
|
67
93
|
}
|
|
68
|
-
function
|
|
69
|
-
const
|
|
70
|
-
for (const
|
|
71
|
-
|
|
72
|
-
return
|
|
94
|
+
function dt(t, r) {
|
|
95
|
+
const o = { ...t };
|
|
96
|
+
for (const s of Object.keys(r))
|
|
97
|
+
o[s] = I(t, r[s]);
|
|
98
|
+
return o;
|
|
73
99
|
}
|
|
74
|
-
function
|
|
100
|
+
function bt(t) {
|
|
75
101
|
if (!t || typeof t != "object" || Array.isArray(t)) return {};
|
|
76
102
|
const r = {};
|
|
77
|
-
for (const [
|
|
78
|
-
const n =
|
|
103
|
+
for (const [o, s] of Object.entries(t)) {
|
|
104
|
+
const n = o.split(".");
|
|
79
105
|
let e = r;
|
|
80
|
-
for (let
|
|
81
|
-
const
|
|
82
|
-
(!e[
|
|
106
|
+
for (let i = 0; i < n.length - 1; i++) {
|
|
107
|
+
const f = n[i];
|
|
108
|
+
(!e[f] || typeof e[f] != "object" || Array.isArray(e[f])) && (e[f] = {}), e = e[f];
|
|
83
109
|
}
|
|
84
|
-
e[n[n.length - 1]] =
|
|
110
|
+
e[n[n.length - 1]] = s;
|
|
85
111
|
}
|
|
86
112
|
return r;
|
|
87
113
|
}
|
|
88
|
-
const w = "string:",
|
|
89
|
-
function
|
|
114
|
+
const w = "string:", F = { slots: {} };
|
|
115
|
+
function G(t, r) {
|
|
90
116
|
try {
|
|
91
117
|
return new Intl.PluralRules(t || void 0).select(r);
|
|
92
118
|
} catch {
|
|
93
119
|
return "other";
|
|
94
120
|
}
|
|
95
121
|
}
|
|
96
|
-
function
|
|
122
|
+
function N(t, r) {
|
|
97
123
|
try {
|
|
98
124
|
return new Intl.NumberFormat(t || void 0).format(r);
|
|
99
125
|
} catch {
|
|
100
126
|
return String(r);
|
|
101
127
|
}
|
|
102
128
|
}
|
|
103
|
-
function
|
|
104
|
-
const n = Object.keys(r).find((
|
|
129
|
+
function X(t, r, o, s) {
|
|
130
|
+
const n = Object.keys(r).find((f) => r[f] === "count");
|
|
105
131
|
let e;
|
|
106
132
|
if (n && t && typeof t == "object" && !Array.isArray(t)) {
|
|
107
|
-
const
|
|
133
|
+
const f = t, c = G(s, Number(o?.[n])), u = f[c] ?? f.other ?? Object.values(f)[0] ?? "";
|
|
108
134
|
e = String(u);
|
|
109
135
|
} else
|
|
110
136
|
e = typeof t == "string" ? t : String(t ?? "");
|
|
111
|
-
let
|
|
112
|
-
if (!(
|
|
113
|
-
const u =
|
|
114
|
-
return r[
|
|
137
|
+
let i = e.replace(/\{([a-zA-Z0-9_]+)\}/g, (f, c) => {
|
|
138
|
+
if (!(c in r)) return f;
|
|
139
|
+
const u = o?.[c];
|
|
140
|
+
return r[c] === "number" || r[c] === "count" ? N(s, Number(u)) : u == null ? "" : String(u);
|
|
115
141
|
});
|
|
116
|
-
return n && (
|
|
142
|
+
return n && (i = i.replace(/#/g, N(s, Number(o?.[n])))), i;
|
|
117
143
|
}
|
|
118
|
-
function
|
|
119
|
-
const
|
|
144
|
+
function mt(t, r, o) {
|
|
145
|
+
const s = {};
|
|
120
146
|
if (r && typeof r == "object" && !Array.isArray(r))
|
|
121
147
|
for (const [n, e] of Object.entries(r)) {
|
|
122
|
-
const
|
|
123
|
-
|
|
148
|
+
const i = e?.slots;
|
|
149
|
+
i && typeof i == "object" && !Array.isArray(i) && Object.keys(i).length > 0 && (s[n] = i);
|
|
124
150
|
}
|
|
125
|
-
return
|
|
151
|
+
return b(t, "", { slots: s, locale: o, defaultLocale: o });
|
|
126
152
|
}
|
|
127
|
-
function
|
|
128
|
-
const
|
|
129
|
-
return new Proxy(
|
|
153
|
+
function b(t, r = "", o = F) {
|
|
154
|
+
const s = { __raw: t, __path: r };
|
|
155
|
+
return new Proxy(s, {
|
|
130
156
|
get(n, e) {
|
|
131
157
|
if (e === "data-okno") return w + n.__path;
|
|
132
158
|
if (e === Symbol.toPrimitive || e === "toString" || e === "valueOf")
|
|
@@ -150,18 +176,18 @@ function d(t, r = "", i = K) {
|
|
|
150
176
|
if (e === "locale")
|
|
151
177
|
return (u) => {
|
|
152
178
|
const l = n.__raw;
|
|
153
|
-
return u && l !== null && typeof l == "object" && !Array.isArray(l) && typeof l[u] == "object" && l[u] !== null ?
|
|
179
|
+
return u && l !== null && typeof l == "object" && !Array.isArray(l) && typeof l[u] == "object" && l[u] !== null ? b(l[u], n.__path, { ...o, locale: u }) : b(l, n.__path, { ...o, locale: o.defaultLocale });
|
|
154
180
|
};
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
157
|
-
const u =
|
|
158
|
-
return (l = {}) =>
|
|
181
|
+
const i = n.__raw, f = n.__path ? `${n.__path}.${String(e)}` : String(e), c = o.slots[f];
|
|
182
|
+
if (c && Object.keys(c).length > 0) {
|
|
183
|
+
const u = i && typeof i == "object" ? i[String(e)] : void 0;
|
|
184
|
+
return (l = {}) => b(X(u, c, l, o.locale), f, o);
|
|
159
185
|
}
|
|
160
|
-
if (
|
|
161
|
-
const u =
|
|
162
|
-
return u !== void 0 ? typeof u == "function" ? (...l) => u.apply(
|
|
186
|
+
if (i != null && typeof i != "object") {
|
|
187
|
+
const u = i[e];
|
|
188
|
+
return u !== void 0 ? typeof u == "function" ? (...l) => u.apply(i, l) : u : b(null, f, o);
|
|
163
189
|
}
|
|
164
|
-
return
|
|
190
|
+
return i != null && typeof i == "object" && !Array.isArray(i) ? b(i[String(e)], f, o) : b(null, f, o);
|
|
165
191
|
},
|
|
166
192
|
// Spread carries ONLY the hook — strings have no HTML attributes (unlike
|
|
167
193
|
// media `{src}` / link `{url,text}`).
|
|
@@ -174,78 +200,87 @@ function d(t, r = "", i = K) {
|
|
|
174
200
|
},
|
|
175
201
|
has(n, e) {
|
|
176
202
|
if (e === "data-okno" || e === Symbol.toPrimitive || e === "toString") return !0;
|
|
177
|
-
const
|
|
178
|
-
return typeof
|
|
203
|
+
const i = n.__raw;
|
|
204
|
+
return typeof i == "object" && i !== null ? e in i : i != null ? e in Object(i) : !1;
|
|
179
205
|
}
|
|
180
206
|
});
|
|
181
207
|
}
|
|
182
|
-
function m(t, r,
|
|
183
|
-
const
|
|
184
|
-
return new Proxy(
|
|
208
|
+
function m(t, r, o) {
|
|
209
|
+
const s = { __raw: t, __path: r, __drag: o };
|
|
210
|
+
return new Proxy(s, {
|
|
185
211
|
get(n, e) {
|
|
186
212
|
if (e === "data-okno") return n.__path;
|
|
187
213
|
if (e === "children") return;
|
|
188
214
|
if (e === "drag") return { "data-okno-item": n.__drag ?? n.__path };
|
|
189
215
|
if (e === "data-okno-item") return n.__drag ?? void 0;
|
|
190
216
|
if (e === "exists") return n.__raw !== null && n.__raw !== void 0;
|
|
191
|
-
if (e === "
|
|
192
|
-
|
|
217
|
+
if (e === "value" && (n.__raw === null || typeof n.__raw != "object"))
|
|
218
|
+
return n.__raw;
|
|
219
|
+
if (e === "image" && p(n.__raw)) {
|
|
220
|
+
const c = n.__raw;
|
|
193
221
|
return {
|
|
194
|
-
src:
|
|
195
|
-
alt:
|
|
196
|
-
width:
|
|
197
|
-
height:
|
|
222
|
+
src: z(c.src),
|
|
223
|
+
alt: c.alt,
|
|
224
|
+
width: c.width,
|
|
225
|
+
height: c.height,
|
|
198
226
|
"data-okno": n.__path
|
|
199
227
|
};
|
|
200
228
|
}
|
|
229
|
+
if (e === "href" && !g(n.__raw) && !p(n.__raw)) {
|
|
230
|
+
const c = n.__raw, u = n.__path.split(".");
|
|
231
|
+
if (c && typeof c == "object" && !Array.isArray(c) && !("href" in c) && u.length === 2) {
|
|
232
|
+
const l = L[u[0]];
|
|
233
|
+
if (l) return H(l, c);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
201
236
|
if (e === Symbol.toPrimitive || e === "toString" || e === "valueOf")
|
|
202
237
|
return () => j(n.__raw, n.__path);
|
|
203
238
|
if (e === Symbol.iterator) {
|
|
204
|
-
const
|
|
239
|
+
const c = j(n.__raw, n.__path);
|
|
205
240
|
return function* () {
|
|
206
|
-
yield
|
|
241
|
+
yield c;
|
|
207
242
|
};
|
|
208
243
|
}
|
|
209
244
|
if (typeof e == "symbol") return;
|
|
210
245
|
if (e === "toJSON") return () => n.__raw;
|
|
211
246
|
if (e === "onedit")
|
|
212
|
-
return (
|
|
247
|
+
return (c) => {
|
|
213
248
|
M();
|
|
214
249
|
const u = n.__path;
|
|
215
|
-
return _.has(u) || _.set(u, /* @__PURE__ */ new Set()), _.get(u).add(
|
|
216
|
-
_.get(u)?.delete(
|
|
250
|
+
return _.has(u) || _.set(u, /* @__PURE__ */ new Set()), _.get(u).add(c), () => {
|
|
251
|
+
_.get(u)?.delete(c), _.get(u)?.size === 0 && _.delete(u);
|
|
217
252
|
};
|
|
218
253
|
};
|
|
219
254
|
if (e === "locale")
|
|
220
|
-
return (
|
|
255
|
+
return (c) => {
|
|
221
256
|
const u = n.__raw;
|
|
222
|
-
return
|
|
223
|
-
u[
|
|
257
|
+
return c && u !== null && typeof u == "object" && !Array.isArray(u) && typeof u[c] == "object" && u[c] !== null ? m(
|
|
258
|
+
u[c],
|
|
224
259
|
n.__path
|
|
225
260
|
) : m(u, n.__path);
|
|
226
261
|
};
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
229
|
-
if (e === "href") return
|
|
230
|
-
if (e === "target" &&
|
|
231
|
-
if (e === "rel" &&
|
|
262
|
+
const i = n.__raw, f = n.__path ? `${n.__path}.${String(e)}` : String(e);
|
|
263
|
+
if (g(i) && typeof e == "string") {
|
|
264
|
+
if (e === "href") return i.url ?? "";
|
|
265
|
+
if (e === "target" && i.external) return "_blank";
|
|
266
|
+
if (e === "rel" && i.external) return "noopener noreferrer";
|
|
232
267
|
}
|
|
233
|
-
if (
|
|
234
|
-
return
|
|
235
|
-
if (
|
|
236
|
-
const
|
|
237
|
-
return
|
|
268
|
+
if (p(i) && typeof e == "string" && e !== "focal" && e in i)
|
|
269
|
+
return i[e];
|
|
270
|
+
if (i != null && typeof i != "object") {
|
|
271
|
+
const c = i[e];
|
|
272
|
+
return c !== void 0 ? typeof c == "function" ? (...u) => c.apply(i, u) : c : m(null, f);
|
|
238
273
|
}
|
|
239
|
-
if (
|
|
240
|
-
const
|
|
241
|
-
return
|
|
274
|
+
if (i != null && typeof i == "object" && !Array.isArray(i)) {
|
|
275
|
+
const c = i[String(e)];
|
|
276
|
+
return c == null ? m(null, f) : P(c, f);
|
|
242
277
|
}
|
|
243
|
-
return m(null,
|
|
278
|
+
return m(null, f);
|
|
244
279
|
},
|
|
245
280
|
// For spread: expose data-okno, plus all keys for file objects (src, alt, width, height, etc.)
|
|
246
281
|
ownKeys(n) {
|
|
247
|
-
const e = n.__raw,
|
|
248
|
-
return
|
|
282
|
+
const e = n.__raw, i = n.__drag != null ? ["data-okno-item"] : [];
|
|
283
|
+
return p(e) ? [...Object.keys(e).filter((f) => f !== "focal"), "data-okno", ...i] : g(e) ? e.external ? ["href", "target", "rel", "data-okno", ...i] : ["href", "data-okno", ...i] : ["data-okno", ...i];
|
|
249
284
|
},
|
|
250
285
|
getOwnPropertyDescriptor(n, e) {
|
|
251
286
|
if (e === "data-okno")
|
|
@@ -256,221 +291,304 @@ function m(t, r, i) {
|
|
|
256
291
|
};
|
|
257
292
|
if (e === "data-okno-item")
|
|
258
293
|
return n.__drag == null ? void 0 : { value: n.__drag, enumerable: !0, configurable: !0 };
|
|
259
|
-
const
|
|
260
|
-
if (
|
|
294
|
+
const i = n.__raw;
|
|
295
|
+
if (p(i) && typeof e == "string" && e in i && e !== "focal")
|
|
261
296
|
return {
|
|
262
|
-
value:
|
|
297
|
+
value: i[e],
|
|
263
298
|
enumerable: !0,
|
|
264
299
|
configurable: !0
|
|
265
300
|
};
|
|
266
|
-
if (
|
|
301
|
+
if (g(i) && (e === "href" || i.external && (e === "target" || e === "rel")))
|
|
267
302
|
return { value: void 0, enumerable: !0, configurable: !0 };
|
|
268
303
|
},
|
|
269
304
|
has(n, e) {
|
|
270
305
|
if (e === "data-okno" || e === Symbol.toPrimitive || e === "toString") return !0;
|
|
271
|
-
const
|
|
272
|
-
return typeof
|
|
306
|
+
const i = n.__raw;
|
|
307
|
+
return typeof i == "object" && i !== null ? e in i : i != null ? e in Object(i) : !1;
|
|
273
308
|
}
|
|
274
309
|
});
|
|
275
310
|
}
|
|
276
311
|
function T(t) {
|
|
277
312
|
return t !== null && typeof t == "object" && !Array.isArray(t) && "__oknoRef" in t;
|
|
278
313
|
}
|
|
279
|
-
function
|
|
314
|
+
function P(t, r, o) {
|
|
280
315
|
if (T(t)) {
|
|
281
|
-
const { path:
|
|
282
|
-
return m(n,
|
|
316
|
+
const { path: s, data: n } = t.__oknoRef;
|
|
317
|
+
return m(n, s, o ?? s);
|
|
283
318
|
}
|
|
284
319
|
if (Array.isArray(t)) {
|
|
285
|
-
const
|
|
286
|
-
return Object.defineProperty(
|
|
320
|
+
const s = t.map((n, e) => P(n, `${r}.${e}`, `${r}.${e}`));
|
|
321
|
+
return Object.defineProperty(s, "toJSON", {
|
|
287
322
|
value: () => t.map((n) => T(n) ? n.__oknoRef.data : n),
|
|
288
323
|
enumerable: !1
|
|
289
|
-
}),
|
|
324
|
+
}), s;
|
|
290
325
|
}
|
|
291
|
-
return m(t, r,
|
|
326
|
+
return m(t, r, o);
|
|
292
327
|
}
|
|
293
|
-
function
|
|
328
|
+
function Z(t, r) {
|
|
294
329
|
if (r && t && typeof t == "object" && !Array.isArray(t)) {
|
|
295
|
-
const
|
|
296
|
-
if (
|
|
330
|
+
const o = t[r];
|
|
331
|
+
if (o && typeof o == "object" && !Array.isArray(o)) return o;
|
|
297
332
|
}
|
|
298
333
|
return t;
|
|
299
334
|
}
|
|
300
|
-
function
|
|
335
|
+
function pt(t, r, o, s = []) {
|
|
301
336
|
if (!t || typeof t != "object" || Array.isArray(t) || !r) return t;
|
|
302
337
|
const n = Object.keys(r).filter(
|
|
303
|
-
(
|
|
338
|
+
(c) => r[c]?.type === "reference" && typeof r[c]?.collection == "string"
|
|
304
339
|
);
|
|
305
340
|
if (n.length === 0) return t;
|
|
306
341
|
const e = {};
|
|
307
|
-
for (const
|
|
308
|
-
const u = r[
|
|
342
|
+
for (const c of n) {
|
|
343
|
+
const u = r[c].collection;
|
|
309
344
|
if (e[u]) continue;
|
|
310
|
-
const l =
|
|
311
|
-
for (const
|
|
312
|
-
const y =
|
|
345
|
+
const l = o?.[u] ?? o?.[u.replace(/-/g, "_")] ?? [], a = /* @__PURE__ */ new Map();
|
|
346
|
+
for (const h of l) {
|
|
347
|
+
const y = h && typeof h.toJSON == "function" ? h.toJSON() : h;
|
|
313
348
|
y && typeof y == "object" && typeof y.slug == "string" && a.set(y.slug, y);
|
|
314
349
|
}
|
|
315
350
|
e[u] = a;
|
|
316
351
|
}
|
|
317
|
-
const
|
|
318
|
-
const l = { ...
|
|
352
|
+
const i = (c, u) => {
|
|
353
|
+
const l = { ...c };
|
|
319
354
|
for (const a of n) {
|
|
320
|
-
const
|
|
321
|
-
if (typeof
|
|
322
|
-
const
|
|
323
|
-
return
|
|
324
|
-
}, S =
|
|
355
|
+
const h = r[a], y = e[h.collection], $ = (k) => {
|
|
356
|
+
if (typeof k != "string" || !k) return null;
|
|
357
|
+
const E = y.get(k);
|
|
358
|
+
return E === void 0 ? null : { __oknoRef: { path: `${h.collection}.${k}`, data: Z(E, u) } };
|
|
359
|
+
}, S = c[a];
|
|
325
360
|
l[a] = Array.isArray(S) ? S.map($).filter(Boolean) : $(S);
|
|
326
361
|
}
|
|
327
362
|
return l;
|
|
328
|
-
},
|
|
329
|
-
for (const
|
|
330
|
-
const u = c
|
|
331
|
-
u && typeof u == "object" && !Array.isArray(u) && (c
|
|
363
|
+
}, f = i(t, void 0);
|
|
364
|
+
for (const c of s) {
|
|
365
|
+
const u = f[c];
|
|
366
|
+
u && typeof u == "object" && !Array.isArray(u) && (f[c] = i(u, c));
|
|
332
367
|
}
|
|
333
|
-
return
|
|
368
|
+
return f;
|
|
334
369
|
}
|
|
335
|
-
function
|
|
370
|
+
function gt(t, r, o = []) {
|
|
336
371
|
if (!t || typeof t != "object" || Array.isArray(t) || !r) return t;
|
|
337
|
-
const
|
|
338
|
-
(
|
|
372
|
+
const s = Object.keys(r).filter(
|
|
373
|
+
(f) => r[f]?.type === "enum" && Array.isArray(r[f]?.options)
|
|
339
374
|
);
|
|
340
|
-
if (
|
|
375
|
+
if (s.length === 0) return t;
|
|
341
376
|
const n = {};
|
|
342
|
-
for (const
|
|
343
|
-
const
|
|
344
|
-
for (const u of r[
|
|
345
|
-
if (typeof u == "string")
|
|
377
|
+
for (const f of s) {
|
|
378
|
+
const c = /* @__PURE__ */ new Map();
|
|
379
|
+
for (const u of r[f].options)
|
|
380
|
+
if (typeof u == "string") c.set(u, { name: u, value: u });
|
|
346
381
|
else if (u && typeof u == "object" && u.value != null) {
|
|
347
382
|
const l = String(u.value);
|
|
348
|
-
|
|
383
|
+
c.set(l, { name: String(u.name ?? l), value: l });
|
|
349
384
|
}
|
|
350
|
-
n[
|
|
385
|
+
n[f] = c;
|
|
351
386
|
}
|
|
352
|
-
const e = (
|
|
353
|
-
const
|
|
354
|
-
for (const u of
|
|
355
|
-
const l = n[u], a = (y) => typeof y != "string" || !y ? null : l.get(y) ?? { name: y, value: y },
|
|
356
|
-
|
|
387
|
+
const e = (f) => {
|
|
388
|
+
const c = { ...f };
|
|
389
|
+
for (const u of s) {
|
|
390
|
+
const l = n[u], a = (y) => typeof y != "string" || !y ? null : l.get(y) ?? { name: y, value: y }, h = f[u];
|
|
391
|
+
c[u] = Array.isArray(h) ? h.map(a).filter(Boolean) : a(h);
|
|
357
392
|
}
|
|
358
|
-
return
|
|
359
|
-
},
|
|
360
|
-
for (const
|
|
361
|
-
const
|
|
362
|
-
|
|
393
|
+
return c;
|
|
394
|
+
}, i = e(t);
|
|
395
|
+
for (const f of o) {
|
|
396
|
+
const c = i[f];
|
|
397
|
+
c && typeof c == "object" && !Array.isArray(c) && (i[f] = e(c));
|
|
363
398
|
}
|
|
364
|
-
return
|
|
399
|
+
return i;
|
|
400
|
+
}
|
|
401
|
+
const d = "data-okno-item", v = "data-okno", Y = [v, d];
|
|
402
|
+
function V(t) {
|
|
403
|
+
return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
365
404
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
if (r === i) return;
|
|
405
|
+
function A(t, r, o, s = Y) {
|
|
406
|
+
if (r === o) return;
|
|
369
407
|
const n = (e) => {
|
|
370
|
-
for (const
|
|
371
|
-
const
|
|
372
|
-
|
|
408
|
+
for (const i of s) {
|
|
409
|
+
const f = e.getAttribute(i);
|
|
410
|
+
f != null && (f === r ? e.setAttribute(i, o) : f.startsWith(r + ".") && e.setAttribute(i, o + f.slice(r.length)));
|
|
373
411
|
}
|
|
374
412
|
};
|
|
375
413
|
n(t);
|
|
376
|
-
for (const e of
|
|
414
|
+
for (const e of s) t.querySelectorAll(`[${e}]`).forEach(n);
|
|
377
415
|
}
|
|
378
|
-
function
|
|
416
|
+
function C(t) {
|
|
379
417
|
if (typeof document > "u") return [];
|
|
380
|
-
const r = new RegExp(`^${t
|
|
381
|
-
document.querySelectorAll(`[${
|
|
382
|
-
const e = n.getAttribute(
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
418
|
+
const r = new RegExp(`^${V(t)}\\.(\\d+)$`), o = [], s = t.replace(/["\\]/g, "\\$&");
|
|
419
|
+
return document.querySelectorAll(`[${d}^="${s}."]`).forEach((n) => {
|
|
420
|
+
const e = n.getAttribute(d);
|
|
421
|
+
!e || !r.test(e) || !n.parentElement || !(n instanceof HTMLElement) || n.parentElement.closest(`[${d}]`)?.getAttribute(d) !== e && o.push(n);
|
|
422
|
+
}), o;
|
|
423
|
+
}
|
|
424
|
+
function B(t, r) {
|
|
425
|
+
if (t.length < 2) return r;
|
|
426
|
+
const o = (n) => t.reduce((e, i) => e + (n === i || n.contains(i) ? 1 : 0), 0);
|
|
427
|
+
let s = r;
|
|
428
|
+
for (; s.parentElement && o(s.parentElement) === o(s); ) s = s.parentElement;
|
|
429
|
+
return s;
|
|
430
|
+
}
|
|
431
|
+
function At(t, r) {
|
|
432
|
+
if (!(r instanceof HTMLElement)) return null;
|
|
433
|
+
const o = C(t), s = o.find((n) => n === r) ?? o.find((n) => n.contains(r) || r.contains(n));
|
|
434
|
+
return s ? B(o, s) : null;
|
|
435
|
+
}
|
|
436
|
+
function D(t, r) {
|
|
437
|
+
const o = new RegExp(`^${V(t)}\\.(\\d+)$`), s = r.getAttribute(d)?.match(o);
|
|
438
|
+
if (s) return Number(s[1]);
|
|
439
|
+
for (const n of Array.from(r.querySelectorAll(`[${d}]`))) {
|
|
440
|
+
const e = n.getAttribute(d)?.match(o);
|
|
441
|
+
if (e) return Number(e[1]);
|
|
442
|
+
}
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
function Q(t) {
|
|
446
|
+
const r = C(t);
|
|
447
|
+
if (r.length === 0) return [];
|
|
448
|
+
const o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map();
|
|
449
|
+
for (const n of r) {
|
|
450
|
+
const e = B(r, n);
|
|
451
|
+
if (o.has(e) || !e.parentElement) continue;
|
|
452
|
+
o.add(e);
|
|
453
|
+
const i = D(t, n);
|
|
454
|
+
if (i == null) continue;
|
|
455
|
+
const f = s.get(e.parentElement) ?? [];
|
|
456
|
+
f.push({ unit: e, index: i }), s.set(e.parentElement, f);
|
|
457
|
+
}
|
|
458
|
+
return [...s.entries()].map(([n, e]) => ({
|
|
389
459
|
parent: n,
|
|
390
|
-
wrappers: e.sort((
|
|
460
|
+
wrappers: e.sort((i, f) => i.index - f.index).map((i) => i.unit)
|
|
391
461
|
}));
|
|
392
462
|
}
|
|
393
|
-
function
|
|
394
|
-
const
|
|
395
|
-
return
|
|
463
|
+
function U(t, r) {
|
|
464
|
+
const o = D(r, t);
|
|
465
|
+
return `${r}.${o ?? 0}`;
|
|
466
|
+
}
|
|
467
|
+
function q(t) {
|
|
468
|
+
const r = Array.from(t.querySelectorAll(`[${v}]`));
|
|
469
|
+
return t.hasAttribute(v) && r.unshift(t), r;
|
|
396
470
|
}
|
|
397
|
-
function
|
|
398
|
-
for (const r of
|
|
471
|
+
function tt(t) {
|
|
472
|
+
for (const r of q(t))
|
|
399
473
|
r.children.length > 0 || (r.textContent = "", r.tagName === "A" && (r.setAttribute("href", ""), r.removeAttribute("target"), r.removeAttribute("rel")));
|
|
400
474
|
}
|
|
401
|
-
function
|
|
402
|
-
for (const
|
|
403
|
-
|
|
404
|
-
|
|
475
|
+
function et(t, r) {
|
|
476
|
+
for (const o of q(t)) {
|
|
477
|
+
if (o.children.length > 0) continue;
|
|
478
|
+
const s = o.getAttribute(v), n = s != null && s in r, e = o.tagName;
|
|
479
|
+
if (e === "IMG" || e === "VIDEO" || e === "SOURCE") {
|
|
480
|
+
o.setAttribute("src", n ? r[s] ?? "" : "");
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
if (e === "A" && !n) {
|
|
484
|
+
o.textContent = "", o.setAttribute("href", ""), o.removeAttribute("target"), o.removeAttribute("rel");
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
o.textContent = n ? r[s] ?? "" : "";
|
|
405
488
|
}
|
|
406
489
|
}
|
|
407
|
-
function
|
|
490
|
+
function nt(t, r, o) {
|
|
491
|
+
if (!r || !o || r === o || typeof document > "u") return;
|
|
492
|
+
const s = (i) => i.length > 1 && i.endsWith("/") ? i.slice(0, -1) : i, n = s(r), e = Array.from(t.querySelectorAll("a[href]"));
|
|
493
|
+
t.matches("a[href]") && e.unshift(t);
|
|
494
|
+
for (const i of e) {
|
|
495
|
+
const f = i.getAttribute("href");
|
|
496
|
+
if (!f) continue;
|
|
497
|
+
let c;
|
|
498
|
+
try {
|
|
499
|
+
c = new URL(f, document.baseURI);
|
|
500
|
+
} catch {
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
c.origin === new URL(document.baseURI).origin && s(c.pathname) === n && i.setAttribute("href", o + c.search + c.hash);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function rt() {
|
|
408
507
|
return typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
409
508
|
}
|
|
410
|
-
function
|
|
509
|
+
function ot(t) {
|
|
411
510
|
const r = document;
|
|
412
|
-
return typeof r.startViewTransition != "function" ||
|
|
511
|
+
return typeof r.startViewTransition != "function" || rt() ? (t(), Promise.resolve()) : r.startViewTransition(t).finished.catch(() => {
|
|
413
512
|
});
|
|
414
513
|
}
|
|
415
|
-
let
|
|
416
|
-
function
|
|
514
|
+
let it = 0;
|
|
515
|
+
function ut(t) {
|
|
417
516
|
if (typeof document > "u" || !t?.list || !t.op) return;
|
|
418
|
-
const { list: r, op:
|
|
419
|
-
if (
|
|
420
|
-
const n = [], e = (
|
|
421
|
-
|
|
517
|
+
const { list: r, op: o } = t, s = Q(r);
|
|
518
|
+
if (o === "insert" && s.every((u) => u.wrappers.length === 0) || s.length === 0) return;
|
|
519
|
+
const n = [], e = (u) => {
|
|
520
|
+
u.style.viewTransitionName = `okno-vt-${++it}`, n.push(u);
|
|
422
521
|
};
|
|
423
|
-
for (const
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
522
|
+
for (const u of s) for (const l of u.wrappers) e(l);
|
|
523
|
+
const i = document.documentElement;
|
|
524
|
+
i.classList.add("okno-vt-active");
|
|
525
|
+
const f = ct();
|
|
526
|
+
ot(() => {
|
|
527
|
+
for (const u of s)
|
|
528
|
+
o === "reorder" ? ft(u, r, t.from, t.to) : o === "remove" ? lt(u, r, t.index) : o === "insert" && at(u, r, t, e);
|
|
428
529
|
}).finally(() => {
|
|
429
|
-
for (const
|
|
430
|
-
|
|
530
|
+
for (const u of n) u.style.viewTransitionName = "";
|
|
531
|
+
f(), i.classList.remove("okno-vt-active");
|
|
431
532
|
});
|
|
432
533
|
}
|
|
433
|
-
|
|
534
|
+
const st = "okno-shadow-root";
|
|
535
|
+
function ct() {
|
|
536
|
+
const t = document.getElementById(st);
|
|
537
|
+
if (!(t instanceof HTMLElement)) return () => {
|
|
538
|
+
};
|
|
539
|
+
const r = t.style.cssText;
|
|
540
|
+
t.style.cssText = `${r};position:fixed;inset:0;height:auto;pointer-events:none;view-transition-name:okno-editor`;
|
|
541
|
+
const o = t.getBoundingClientRect();
|
|
542
|
+
return globalThis.__oknoVtPin = o.width < 1 || o.height < 1 ? `fallback (${Math.round(o.width)}×${Math.round(o.height)})` : "ok", o.width < 1 || o.height < 1 ? (t.style.cssText = r, () => {
|
|
543
|
+
}) : () => {
|
|
544
|
+
t.style.cssText = r;
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
function ft(t, r, o, s) {
|
|
434
548
|
const n = t.wrappers, e = n.length;
|
|
435
|
-
if (
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
const
|
|
439
|
-
|
|
549
|
+
if (o < 0 || o >= e || s < 0 || s >= e || o === s) return;
|
|
550
|
+
const i = n.slice(), [f] = i.splice(o, 1);
|
|
551
|
+
i.splice(s, 0, f);
|
|
552
|
+
const c = i.map((l) => U(l, r));
|
|
553
|
+
i.forEach((l, a) => A(l, c[a], `${r}.${a}`));
|
|
440
554
|
const u = n[e - 1].nextSibling;
|
|
441
|
-
for (const l of
|
|
555
|
+
for (const l of i) t.parent.insertBefore(l, u);
|
|
442
556
|
}
|
|
443
|
-
function
|
|
444
|
-
const
|
|
445
|
-
if (!(
|
|
446
|
-
|
|
447
|
-
for (let n =
|
|
557
|
+
function lt(t, r, o) {
|
|
558
|
+
const s = t.wrappers;
|
|
559
|
+
if (!(o < 0 || o >= s.length)) {
|
|
560
|
+
s[o].remove();
|
|
561
|
+
for (let n = o + 1; n < s.length; n++) A(s[n], `${r}.${n}`, `${r}.${n - 1}`);
|
|
448
562
|
}
|
|
449
563
|
}
|
|
450
|
-
function
|
|
564
|
+
function at(t, r, o, s) {
|
|
451
565
|
const n = t.wrappers, e = n.length;
|
|
452
566
|
if (e === 0) return;
|
|
453
|
-
const
|
|
454
|
-
for (let a = e - 1; a >=
|
|
455
|
-
|
|
456
|
-
const l =
|
|
567
|
+
const i = Math.max(0, Math.min(o.index ?? e, e)), f = i < e ? i : e - 1, c = U(n[f], r), u = n[f].cloneNode(!0);
|
|
568
|
+
for (let a = e - 1; a >= i; a--) A(n[a], `${r}.${a}`, `${r}.${a + 1}`);
|
|
569
|
+
A(u, c, `${r}.${i}`), o.remap && A(u, o.remap.from, o.remap.to, [v]), o.href && nt(u, o.href.from, o.href.to), o.values ? et(u, o.values) : tt(u), u.style.viewTransitionName = "", s(u);
|
|
570
|
+
const l = i < e ? n[i] : n[e - 1].nextSibling;
|
|
457
571
|
t.parent.insertBefore(u, l);
|
|
458
572
|
}
|
|
459
573
|
let R = !1;
|
|
460
|
-
function
|
|
574
|
+
function vt() {
|
|
461
575
|
const t = globalThis;
|
|
462
|
-
R || typeof t.document > "u" || (R = !0, t.document.addEventListener("okno:structure", (r) =>
|
|
576
|
+
R || typeof t.document > "u" || (R = !0, t.document.addEventListener("okno:structure", (r) => ut(r.detail)));
|
|
463
577
|
}
|
|
464
578
|
export {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
579
|
+
ut as __oknoApplyStructure,
|
|
580
|
+
bt as __oknoExpandStrings,
|
|
581
|
+
vt as __oknoInitStructure,
|
|
582
|
+
dt as __oknoLocalize,
|
|
583
|
+
mt as __oknoMakeStrings,
|
|
584
|
+
gt as __oknoResolveEnums,
|
|
585
|
+
pt as __oknoResolveRefs,
|
|
586
|
+
yt as __oknoSetImages,
|
|
587
|
+
_t as __oknoSetRoutes,
|
|
588
|
+
D as __oknoUnitIndex,
|
|
589
|
+
At as __oknoUnitOf,
|
|
590
|
+
ht as __oknoVisible,
|
|
474
591
|
m as __oknoWrap,
|
|
475
|
-
|
|
592
|
+
b as __oknoWrapStrings,
|
|
593
|
+
V as escapeReg
|
|
476
594
|
};
|