okno 1.0.0-beta.44 → 1.0.0-beta.45

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.
Files changed (53) hide show
  1. package/dist/astro/index.d.ts +0 -8
  2. package/dist/astro/index.d.ts.map +1 -1
  3. package/dist/astro/index.js +6 -18
  4. package/dist/build-revision.d.ts +5 -0
  5. package/dist/build-revision.d.ts.map +1 -0
  6. package/dist/codegen/generate.d.ts.map +1 -1
  7. package/dist/codegen/modules.d.ts +12 -7
  8. package/dist/codegen/modules.d.ts.map +1 -1
  9. package/dist/codegen/validate-content.d.ts +39 -0
  10. package/dist/codegen/validate-content.d.ts.map +1 -0
  11. package/dist/{encode-BfJY0Xy5.js → content-path-Bc0rnTVl.js} +10 -6
  12. package/dist/dispatch-C1NpqUhY.js +1187 -0
  13. package/dist/editor/index.d.ts +5 -0
  14. package/dist/editor/index.d.ts.map +1 -0
  15. package/dist/editor/index.js +15324 -14664
  16. package/dist/engine/content-path.d.ts +5 -0
  17. package/dist/engine/content-path.d.ts.map +1 -0
  18. package/dist/engine/index.d.ts +1 -0
  19. package/dist/engine/index.d.ts.map +1 -1
  20. package/dist/engine/index.js +13 -12
  21. package/dist/index.js +1 -1
  22. package/dist/local/dispatch.d.ts.map +1 -1
  23. package/dist/mcp.d.ts.map +1 -1
  24. package/dist/mcp.js +39 -38
  25. package/dist/next/codegen.d.ts.map +1 -1
  26. package/dist/next/config.d.ts +3 -0
  27. package/dist/next/config.d.ts.map +1 -1
  28. package/dist/next/index.js +85 -77
  29. package/dist/plugin-4k3fA3lQ.js +504 -0
  30. package/dist/runtime/wrap.d.ts +13 -1
  31. package/dist/runtime/wrap.d.ts.map +1 -1
  32. package/dist/runtime/wrap.js +533 -432
  33. package/dist/types/fields.d.ts +6 -1
  34. package/dist/types/fields.d.ts.map +1 -1
  35. package/dist/types/schema.d.ts +6 -6
  36. package/dist/types/schema.d.ts.map +1 -1
  37. package/dist/vite/index.js +1 -1
  38. package/dist/vite/plugin.d.ts +12 -1
  39. package/dist/vite/plugin.d.ts.map +1 -1
  40. package/package.json +1 -1
  41. package/src/runtime/wrap.test.ts +160 -1
  42. package/src/runtime/wrap.ts +223 -45
  43. package/dist/codegen/modules-instant.d.ts +0 -24
  44. package/dist/codegen/modules-instant.d.ts.map +0 -1
  45. package/dist/dispatch-CumCB1dI.js +0 -986
  46. package/dist/engine/materialize.d.ts +0 -66
  47. package/dist/engine/materialize.d.ts.map +0 -1
  48. package/dist/plugin-DCxkXmmG.js +0 -587
  49. package/dist/runtime/instant.d.ts +0 -60
  50. package/dist/runtime/instant.d.ts.map +0 -1
  51. package/dist/runtime/instant.js +0 -271
  52. package/src/runtime/instant.test.ts +0 -391
  53. package/src/runtime/instant.ts +0 -398
@@ -0,0 +1,1187 @@
1
+ import { join as y, relative as ee, sep as G, dirname as F, resolve as ke } from "node:path";
2
+ import { readdir as I, readFile as Re, writeFile as Me } from "node:fs/promises";
3
+ import { existsSync as b, readdirSync as se, readFileSync as T, mkdirSync as U, writeFileSync as E, statSync as Ie, realpathSync as We, unlinkSync as X, renameSync as Le } from "node:fs";
4
+ import { p as Z } from "./parse-tlTHgSSs.js";
5
+ import { execSync as de } from "node:child_process";
6
+ import { fileURLToPath as Ce } from "node:url";
7
+ import { o as Fe } from "./order-bAkdncZC.js";
8
+ import { simpleGit as be } from "simple-git";
9
+ import { b as ue, a as Ue, i as ze, e as Je } from "./content-path-Bc0rnTVl.js";
10
+ import { applyKeyChanges as we, setStringsSchema as Ve, saveFields as Be, setLocales as Ge, setName as Ke, setUrl as Ze, renameSlug as He, reorderKind as qe, setLayout as Xe, setCollectionOrder as Qe, setDrafts as Ye, deleteSchemaEntry as De, scaffoldEntry as et, fieldsToContent as tt, EngineError as nt } from "./engine/index.js";
11
+ const st = /* @__PURE__ */ new Set([".astro", ".svelte", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".vue"]), ot = /* @__PURE__ */ new Set([
12
+ "node_modules",
13
+ ".astro",
14
+ ".svelte-kit",
15
+ ".next",
16
+ ".nuxt",
17
+ ".vite",
18
+ "dist",
19
+ "build",
20
+ ".git",
21
+ ".turbo"
22
+ ]);
23
+ async function ie(e, n) {
24
+ const s = new RegExp(`import\\s*\\{([^}]+)\\}\\s*from\\s*["']okno/${n}["']`, "g"), c = /* @__PURE__ */ new Set();
25
+ async function i(u) {
26
+ let l;
27
+ try {
28
+ l = await I(u, { withFileTypes: !0 });
29
+ } catch {
30
+ return;
31
+ }
32
+ for (const p of l) {
33
+ if (p.name.startsWith(".") && p.name !== "." || ot.has(p.name)) continue;
34
+ const a = y(u, p.name);
35
+ if (p.isDirectory()) {
36
+ await i(a);
37
+ continue;
38
+ }
39
+ const t = p.name.lastIndexOf(".");
40
+ if (t === -1) continue;
41
+ const o = p.name.slice(t);
42
+ if (!st.has(o)) continue;
43
+ let r;
44
+ try {
45
+ r = await Re(a, "utf-8");
46
+ } catch {
47
+ continue;
48
+ }
49
+ if (r.includes(`okno/${n}`))
50
+ for (const m of r.matchAll(s)) {
51
+ const d = m[1] ?? "";
52
+ for (const h of d.split(",")) {
53
+ const g = h.trim().split(/\s+as\s+/)[0]?.trim();
54
+ g && /^[A-Za-z_$][\w$]*$/.test(g) && c.add(g);
55
+ }
56
+ }
57
+ }
58
+ }
59
+ return await i(e), c;
60
+ }
61
+ const Se = /* @__PURE__ */ new Set(), rt = (e) => e == null || e === "";
62
+ function Q(e) {
63
+ return b(e) ? se(e, { withFileTypes: !0 }).filter((n) => n.isFile() && n.name.endsWith(".ts") && n.name !== "index.ts").map((n) => y(e, n.name)) : [];
64
+ }
65
+ function ce(e) {
66
+ try {
67
+ const n = Z(T(e, "utf8"));
68
+ return n && typeof n == "object" && !Array.isArray(n) ? n : null;
69
+ } catch (n) {
70
+ throw new Error(`[okno] Invalid content module ${e}: ${n instanceof Error ? n.message : String(n)}`);
71
+ }
72
+ }
73
+ function at(e, n) {
74
+ if (!n) return;
75
+ const s = [], c = /* @__PURE__ */ new Map(), i = (n.locales?.supported ?? []).map((t) => typeof t == "string" ? t : t?.id).filter((t) => typeof t == "string" && t.length > 0);
76
+ for (const t of Object.keys(n.collections ?? {})) {
77
+ const o = /* @__PURE__ */ new Set();
78
+ for (const r of Q(y(e, "collections", t))) {
79
+ const d = ce(r)?.slug;
80
+ typeof d == "string" && d && o.add(d);
81
+ }
82
+ c.set(t, o);
83
+ }
84
+ const u = (t, o) => {
85
+ switch (o.type) {
86
+ case "number":
87
+ return typeof t == "number" && Number.isFinite(t);
88
+ case "boolean":
89
+ return typeof t == "boolean";
90
+ case "media":
91
+ return !!t && typeof t == "object" && !Array.isArray(t) && typeof t.src == "string";
92
+ case "link":
93
+ return !!t && typeof t == "object" && !Array.isArray(t) && typeof t.url == "string";
94
+ case "group":
95
+ case "block":
96
+ return !!t && typeof t == "object" && !Array.isArray(t);
97
+ case "reference":
98
+ return typeof t == "string";
99
+ default:
100
+ return typeof t == "string";
101
+ }
102
+ }, l = (t, o, r, m = !1) => {
103
+ for (const [d, h] of Object.entries(o)) {
104
+ if (h.type === "divider") continue;
105
+ const g = t[d], _ = `${r}.${d}`;
106
+ if (rt(g)) {
107
+ !m && h.required && s.push({ path: _, message: "required value is missing", fatal: !0 });
108
+ continue;
109
+ }
110
+ const $ = h.multiple ? g : [g];
111
+ if (h.multiple && !Array.isArray(g)) {
112
+ s.push({ path: _, message: "must be an array" });
113
+ continue;
114
+ }
115
+ for (const [w, f] of $.entries()) {
116
+ const k = h.multiple ? `${_}.${w}` : _;
117
+ if (!u(f, { ...h })) {
118
+ s.push({ path: k, message: `does not match ${h.type ?? "field"}` });
119
+ continue;
120
+ }
121
+ if (h.type === "enum") {
122
+ const O = (h.options ?? []).map((S) => typeof S == "string" ? S : S.value).filter(Boolean);
123
+ O.length && !O.includes(f) && s.push({ path: k, message: `unknown option ${JSON.stringify(f)}` });
124
+ }
125
+ if (h.type === "reference" && h.collection && (c.get(h.collection)?.has(f) || s.push({ path: k, message: `references missing ${h.collection}.${f}`, fatal: !0 })), h.type === "group" && h.fields && l(f, h.fields, k, m), h.type === "block") {
126
+ const O = Array.isArray(h.blocks) ? h.blocks : h.block ? [h.block] : [], S = f.__block, j = typeof S == "string" ? S : h.block;
127
+ if (Array.isArray(h.blocks) && typeof S != "string") s.push({ path: k, message: "polymorphic block is missing __block", fatal: !0 });
128
+ else if (!j || !O.includes(j)) s.push({ path: k, message: `unknown block ${JSON.stringify(j)}`, fatal: !0 });
129
+ else {
130
+ const v = n.blocks?.[j]?.fields;
131
+ v && l(f, v, k, m);
132
+ }
133
+ }
134
+ }
135
+ }
136
+ };
137
+ for (const t of ["pages", "globals", "collections"])
138
+ for (const [o, r] of Object.entries(n[t] ?? {})) {
139
+ const m = t === "collections" ? Q(y(e, t, o)) : Q(y(e, t)).filter((d) => d.endsWith(`/${o}.ts`));
140
+ for (const d of m) {
141
+ const h = ce(d);
142
+ h && l(h, r.fields ?? {}, `${t}.${o}.${typeof h.slug == "string" ? h.slug : o}`);
143
+ }
144
+ for (const d of i) {
145
+ const h = t === "collections" ? Q(y(e, t, d, o)) : Q(y(e, t, d)).filter((g) => g.endsWith(`/${o}.ts`));
146
+ for (const g of h) {
147
+ const _ = ce(g);
148
+ _ && l(_, r.fields ?? {}, `${t}.${o}.${d}.${typeof _.slug == "string" ? _.slug : o}`, !0);
149
+ }
150
+ }
151
+ }
152
+ const p = s.filter((t) => t.fatal), a = s.filter((t) => !t.fatal);
153
+ if (a.length) {
154
+ const t = a.slice(0, 5).map((d) => ` - ${d.path}: ${d.message}`).join(`
155
+ `), o = a.length > 5 ? `
156
+ - …and ${a.length - 5} more` : "", r = `[okno] ${a.length} legacy content value(s) do not match the current schema. They remain readable, but should be resaved:
157
+ ${t}${o}`, m = `${e}
158
+ ${r}`;
159
+ Se.has(m) || (Se.add(m), console.warn(r));
160
+ }
161
+ if (p.length) {
162
+ const t = p.slice(0, 25).map((r) => ` - ${r.path}: ${r.message}`).join(`
163
+ `), o = p.length > 25 ? `
164
+ - …and ${p.length - 25} more` : "";
165
+ throw new Error(`[okno] Content integrity errors:
166
+ ${t}${o}`);
167
+ }
168
+ }
169
+ const J = (e, n) => {
170
+ const s = (c) => [...c].map((i) => /^[A-Za-z0-9_]$/.test(i) ? i : `_x${i.codePointAt(0).toString(16)}_`).join("");
171
+ return `OknoSchema_${s(e)}_${s(n)}`;
172
+ };
173
+ function it(e) {
174
+ if (!e) return [];
175
+ const n = [
176
+ "/** Canonical raw media shape. Framework-specific optimized data is exposed by the wrapped value's `.image` handle. */",
177
+ "type OknoSchemaMedia = { src: string; alt: string; width?: number; height?: number; focal?: { x: number; y: number } }",
178
+ "type OknoSchemaLink = { text: string; url: string; external?: boolean }",
179
+ ""
180
+ ], s = (i) => {
181
+ if (!i) return "unknown";
182
+ if (i.type === "string" && !i.multiple && Object.keys(i.slots ?? {}).length)
183
+ return `(params: { ${Object.entries(i.slots).map(
184
+ ([p, a]) => `${JSON.stringify(p)}: ${a === "number" || a === "count" ? "number" : "string"}`
185
+ ).join("; ")} }) => OknoValue<string>`;
186
+ let u;
187
+ switch (i.type) {
188
+ case "number":
189
+ u = "number";
190
+ break;
191
+ case "boolean":
192
+ u = "boolean";
193
+ break;
194
+ case "media":
195
+ u = "OknoSchemaMedia";
196
+ break;
197
+ case "link":
198
+ u = "OknoSchemaLink";
199
+ break;
200
+ case "enum": {
201
+ const l = (i.options ?? []).map((a) => typeof a == "string" ? a : a?.value).filter((a) => typeof a == "string");
202
+ u = `{ name: string; value: ${l.length ? l.map((a) => JSON.stringify(a)).join(" | ") : "string"} }`;
203
+ break;
204
+ }
205
+ case "reference":
206
+ u = typeof i.collection == "string" && e.collections?.[i.collection] ? J("collections", i.collection) : "Record<string, unknown>";
207
+ break;
208
+ case "group":
209
+ u = c(i.fields ?? {});
210
+ break;
211
+ case "block": {
212
+ const l = Array.isArray(i.blocks) ? i.blocks.filter((p) => typeof p == "string") : typeof i.block == "string" ? [i.block] : [];
213
+ if (l.length > 1 || Array.isArray(i.blocks))
214
+ u = l.length ? l.map(
215
+ (p) => e.blocks?.[p] ? `({ readonly __block: ${JSON.stringify(p)} } & ${J("blocks", p)})` : `({ readonly __block: ${JSON.stringify(p)} } & Record<string, unknown>)`
216
+ ).join(" | ") : "Record<string, unknown>";
217
+ else {
218
+ const p = l[0];
219
+ u = p && e.blocks?.[p] ? J("blocks", p) : "Record<string, unknown>";
220
+ }
221
+ break;
222
+ }
223
+ case "divider":
224
+ u = "never";
225
+ break;
226
+ default:
227
+ u = "string";
228
+ }
229
+ return i.multiple ? `(${u})[]` : u;
230
+ };
231
+ function c(i) {
232
+ return `{ ${Object.entries(i).filter(([, l]) => l?.type !== "divider").map(([l, p]) => `${JSON.stringify(l)}: ${s(p)}`).join("; ")} }`;
233
+ }
234
+ for (const i of ["blocks", "collections", "pages", "globals"])
235
+ for (const [u, l] of Object.entries(e[i] ?? {})) {
236
+ const p = l.url, a = i !== "blocks" ? ` & { created: OknoStamp; updated: OknoStamp${i === "collections" && typeof p == "string" && p.trim() ? "; href: string" : ""} }` : "", t = Object.fromEntries(Object.entries(l.fields ?? {}).filter(([o]) => i === "blocks" || !["created", "updated"].includes(o)));
237
+ n.push(`type ${J(i, u)} = ${c(t)}${a}`);
238
+ }
239
+ return n.push(""), n;
240
+ }
241
+ async function Vt(e, n) {
242
+ const s = await yt(e), c = new Map(s.map((f) => [f.name, f.first])), i = ht(e);
243
+ at(e, i);
244
+ const u = [
245
+ "// Auto-generated by okno. Do not edit.",
246
+ "",
247
+ "/** A wrapped content value that can be spread onto elements and rendered as text. */",
248
+ "type OknoValue<T = unknown> = {",
249
+ ' readonly "data-okno": string',
250
+ ' readonly "data-okno-locale"?: string',
251
+ " toString(): string",
252
+ // NB: NO `[Symbol.toPrimitive]` in the TYPE. Svelte 5's element-attribute type
253
+ // carries a symbol index signature for attachments (`[key: symbol]: Attachment`),
254
+ // and a `(hint: string) => string` toPrimitive isn't assignable to it — so a
255
+ // `{...field}` spread would fail type-check on every element. The runtime keeps
256
+ // Symbol.toPrimitive (see runtime/wrap.ts) so `{field}` / String(field) still
257
+ // coerce; `toString()` covers the static string-coercion the type needs.
258
+ " onedit(callback: (value: T) => void): () => void",
259
+ " /** Re-root reads at a locale; no-op when unset or on the default locale. Returns the SAME wrapped shape (not `this`, which would drop array element types). */",
260
+ " locale(code?: string | null): OknoWrapped<T>",
261
+ " /** `true` when this field/reference actually holds a value — every read is a truthy wrapper, so `entry.ref ? …` can't tell set from unset. */",
262
+ " readonly exists: boolean",
263
+ "}",
264
+ "",
265
+ "/** The explicit reorder handle — spread `.drag` on a semantic wrapper (`<li {...item.drag}>`, `<tr {...item.drag}>`) when the item's own element can't be the direct child of the reorder container. Emits the same `data-okno-item` boundary as the bare `{...item}` spread; the editor resolves the OUTERMOST element carrying it as the drag unit, so both a wrapper's `.drag` and an inner `{...item}` can coexist. Present on every array item (leaf AND block). */",
266
+ 'type OknoDrag = { readonly drag: { readonly "data-okno-item": string; readonly "data-okno-locale"?: string } }',
267
+ "/** The reorder hook carried directly on a LEAF array item's bare spread (`{...item}`), so a leaf multiple needs no separate `{...item.drag}` in the common case. */",
268
+ 'type OknoDragItem = { readonly "data-okno-item": string; readonly "data-okno-locale"?: string }',
269
+ "/** One array member. A LEAF (media/link/text) is spread bare — `{...item}` — so it carries `data-okno-item` for reorder AND still exposes `.drag` as an escape hatch (for a semantic wrapper). A BLOCK/reference member has inner fields, so its bare `{...item}` would dump field keys; it spreads content fields on its wrapper plus `.drag` for reorder. */",
270
+ "type OknoArrayItem<U> =",
271
+ " U extends string | number | boolean",
272
+ " ? OknoWrapped<U> & OknoDragItem & OknoDrag",
273
+ " : U extends { src: string }",
274
+ " ? OknoWrapped<U> & OknoDragItem & OknoDrag",
275
+ " : U extends { url: string; text: string }",
276
+ " ? OknoWrapped<U> & OknoDragItem & OknoDrag",
277
+ " : OknoWrapped<U> & OknoDrag",
278
+ "",
279
+ "/** A media value's `.image` handle — props for the active framework image component: an Astro asset source or a Next/Nuxt/raw URL, plus alt/dimensions and the edit hook. Use `<img {...cover}>` for the universal raw path. `src` stays loose because its framework-specific type is intentionally different. */",
280
+ 'type OknoImage = { src: any; alt: string; width?: number; height?: number; readonly "data-okno": string; readonly "data-okno-locale"?: string }',
281
+ "",
282
+ "/** Recursively wraps content types so values are spreadable/renderable. Media (`{src}`) and link (`{url,text}`) objects keep RAW attribute values so `<img {...media}>` / `<a {...link}>` type-check; media also exposes `.image`; other objects expose wrapped fields + the data-okno hook. Array items carry `data-okno-item` on the bare spread (leaf multiples) AND expose `.drag` (the explicit reorder handle, for block wrappers or a leaf's semantic wrapper). */",
283
+ "type OknoWrapped<T> =",
284
+ " T extends (...args: any[]) => any ? T :",
285
+ " T extends string | number | boolean",
286
+ " ? OknoValue<T> & { readonly value: T }",
287
+ " : T extends ReadonlyArray<infer U>",
288
+ " ? OknoArrayItem<U>[]",
289
+ " : T extends { src: string }",
290
+ ' ? Omit<T, "focal"> & OknoValue<T> & { readonly image: OknoImage } & (T extends { focal: infer F } ? { readonly focal: OknoWrapped<F> } : {})',
291
+ " : T extends { url: string; text: string }",
292
+ " ? { href: string; target?: string; rel?: string } & OknoValue<T>",
293
+ " : T extends Record<string, unknown>",
294
+ ' ? { [K in keyof T]: K extends "href" | "slug" | "__block" ? T[K] : OknoWrapped<T[K]> } & OknoValue<T> & (T extends { created: OknoStamp; updated: OknoStamp } ? OknoDrag : {})',
295
+ " : OknoValue<T>",
296
+ "",
297
+ "/** Content referenced in code but not yet scaffolded — shape unknown, so every field is a flat leaf. Nested access (`home.hero.title`) is a type error on purpose: okno fields are flat (dividers organize the editor, they don't nest data). Use a Block for nested shapes. */",
298
+ "type OknoUnscaffolded = OknoWrapped<Record<string, unknown>>",
299
+ "",
300
+ "/** Authorship + timestamp metadata Okno writes on every entry (page, collection item, global). Read-only — never edit or spread; it's the data your own `.sort()` uses. Each is wrapped, so render `{a.updated.date}` and compare `String(a.updated.date)`. */",
301
+ "type OknoStamp = { readonly date: string; readonly author: string }",
302
+ "type OknoMeta = {",
303
+ " readonly created: OknoWrapped<OknoStamp>",
304
+ " readonly updated: OknoWrapped<OknoStamp>",
305
+ "}",
306
+ "",
307
+ "/** A collection's real records plus its permanent, non-enumerated creation record. Use `.new` only when mapping the collection's dynamic route; normal iteration contains stored records only. */",
308
+ "type OknoCollection<T> = T[] & { readonly new: T }",
309
+ ""
310
+ ];
311
+ u.push(...it(i)), u.push(...ct(i));
312
+ const l = ([, f]) => f?.type === "reference" && typeof f.collection == "string" && c.has(f.collection), p = ([, f]) => f?.type === "enum", a = ([, f]) => f?.type === "string" && !f.multiple && f.slots && typeof f.slots == "object" && !Array.isArray(f.slots) && Object.keys(f.slots).length > 0, t = (f) => f === "number" || f === "count" ? "number" : "string", o = ([f, k]) => {
313
+ const O = Object.entries(k.slots).map(([S, j]) => `${JSON.stringify(S)}: ${t(j)}`).join("; ");
314
+ return `${f}: (p: { ${O} }) => OknoValue<string>`;
315
+ }, r = ([f, k]) => {
316
+ const O = (Array.isArray(k?.options) ? k.options : []).map((v) => typeof v == "string" ? v : v?.value).filter((v) => typeof v == "string"), j = `{ name: string; value: ${O.length ? O.map((v) => JSON.stringify(v)).join(" | ") : "string"} }`;
317
+ return `${f}: ${k.multiple ? `${j}[]` : j}`;
318
+ }, m = (f) => i?.collections?.[f] ? J("collections", f) : `typeof import("./collections/${f}/${c.get(f)}").default`, d = (f) => {
319
+ const k = i?.collections?.[f]?.url;
320
+ return typeof k == "string" && k.trim() ? " & { href: string }" : "";
321
+ }, h = (f, k) => {
322
+ const O = m(f);
323
+ if (i?.collections?.[f]) return `${O}${d(f)}`;
324
+ const S = i?.collections?.[f]?.fields, j = S ? Object.entries(S) : [], v = j.filter(l), A = j.filter(p);
325
+ if (v.length === 0 && A.length === 0) return `${O}${d(f)}`;
326
+ const x = [...v, ...A].map(([R]) => `"${R}"`).join(" | "), N = new Set(k).add(f), W = [
327
+ ...v.map(([R, L]) => {
328
+ const C = L.collection, M = k.has(C) ? m(C) : h(C, N);
329
+ return `${R}: ${L.multiple ? `(${M})[]` : M}`;
330
+ }),
331
+ ...A.map(r)
332
+ ].join("; ");
333
+ return `Omit<${O}, ${x}> & { ${W} }${d(f)}`;
334
+ }, g = (f, k, O) => {
335
+ const S = !!i?.[f]?.[k], j = S ? J(f, k) : `typeof import("${O}").default`, v = i?.[f]?.[k]?.fields, A = v ? Object.entries(v) : [], x = A.filter(l), N = A.filter(p), W = A.filter(a), R = '"created" | "updated"', L = f === "collections" ? d(k) : "", C = W.length ? ` & { ${W.map(o).join("; ")} }` : "";
336
+ if (S)
337
+ return `OknoWrapped<${j}>`;
338
+ if (x.length === 0 && N.length === 0 && W.length === 0)
339
+ return `OknoWrapped<Omit<${j}, ${R}>${L}> & OknoMeta`;
340
+ const M = f === "collections" ? /* @__PURE__ */ new Set([k]) : /* @__PURE__ */ new Set(), H = `${[...x, ...N, ...W].map(([re]) => `"${re}"`).join(" | ")} | ${R}`, q = [
341
+ ...x.map(([re, _e]) => {
342
+ const ae = _e.collection, $e = M.has(ae) ? m(ae) : h(ae, M);
343
+ return `${re}: ${_e.multiple ? `(${$e})[]` : $e}`;
344
+ }),
345
+ ...N.map(r)
346
+ ].join("; ");
347
+ return `OknoWrapped<${q ? `Omit<${j}, ${H}> & { ${q} }` : `Omit<${j}, ${H}>`}${L}> & OknoMeta${C}`;
348
+ }, [_, $, w] = await Promise.all([
349
+ ie(n, "pages"),
350
+ ie(n, "globals"),
351
+ ie(n, "collections")
352
+ ]);
353
+ u.push(
354
+ ...Oe("okno/pages", "pages", await fe(y(e, "pages")), _, g)
355
+ ), u.push(...mt(s, w, g)), u.push(
356
+ ...Oe("okno/globals", "globals", await fe(y(e, "globals")), $, g)
357
+ ), u.push(...ft(gt(e), dt(i))), u.push(...lt()), u.push(...ut()), await Me(y(e, "modules.d.ts"), u.join(`
358
+ `));
359
+ }
360
+ function ct(e) {
361
+ const n = [];
362
+ for (const [s, c] of Object.entries(e?.blocks ?? {})) {
363
+ const i = J("blocks", s), u = Object.entries(c.fields ?? {}).filter(([, l]) => l.type !== "divider").map(([l]) => ` ${JSON.stringify(l)}: OknoWrapped<${i}>[${JSON.stringify(l)}]`);
364
+ n.push(` interface ${i}_Wrapped extends OknoValue<${i}> {`, ...u, " }"), /^[A-Za-z_$][\w$]*$/.test(s) && !["default", "BlockTypes"].includes(s) && n.push(` export type { ${i}_Wrapped as ${s} }`);
365
+ }
366
+ n.push(" export interface BlockTypes {");
367
+ for (const s of Object.keys(e?.blocks ?? {}))
368
+ n.push(` ${JSON.stringify(s)}: ${J("blocks", s)}_Wrapped`);
369
+ return n.push(" }"), ['declare module "okno/blocks" {', ...n, "}", ""];
370
+ }
371
+ function Oe(e, n, s, c, i) {
372
+ const u = /* @__PURE__ */ new Set(), l = [];
373
+ for (const p of s)
374
+ l.push(` export const ${p}: ${i(n, p, `./${n}/${p}`)}`), u.add(p);
375
+ for (const p of c)
376
+ u.has(p) || l.push(` export const ${p}: OknoUnscaffolded`);
377
+ return [`declare module "${e}" {`, ...l, "}", ""];
378
+ }
379
+ function lt() {
380
+ return [
381
+ 'declare module "okno/locales" {',
382
+ ' /** A configured language. `id` is the BCP-47 tag (e.g. "zh-Hant"), `name` the display label, `slug` the URL segment you map into routing. `link(url)` returns this page\'s hreflang <link> descriptor — spread onto a <link> (pass Astro.url for an absolute href). Okno owns no routing; you map these. */',
383
+ " export interface OknoLocale {",
384
+ " id: string",
385
+ " name: string",
386
+ " slug: string",
387
+ ' link(url: URL | string): { rel: "alternate"; hreflang: string; href: string }',
388
+ " }",
389
+ " /** The configured languages; `locales.default` is the base-locale entry. Empty (`.default` undefined) when no languages are configured. */",
390
+ " export const locales: OknoLocale[] & { default: OknoLocale }",
391
+ "}",
392
+ ""
393
+ ];
394
+ }
395
+ function ut() {
396
+ return [
397
+ 'declare module "okno/content" {',
398
+ ' /** Unified content namespace — `import * as okno from "okno/content"` then `okno.pages.home`, `okno.globals.nav`, `okno.collections.articles`, `okno.strings.nav.home`. */',
399
+ ' export * as pages from "okno/pages"',
400
+ ' export * as globals from "okno/globals"',
401
+ ' export * as collections from "okno/collections"',
402
+ ' export { strings } from "okno/strings"',
403
+ "}",
404
+ ""
405
+ ];
406
+ }
407
+ function ft(e, n) {
408
+ const s = e.length ? `${pt(e, n)}` : "any", c = e.length ? `
409
+ locale(code?: string | null): ${s}` : "";
410
+ return [
411
+ 'declare module "okno/strings" {',
412
+ " /** The UI-strings store. A plain leaf is string-like (spread `{...s.nav.home}` for the edit hook, render `{s.nav.home}` for the text); a SLOTTED leaf is a `(params) => …` function — call it, then spread/render the result (`{...s.cart.items({count})}`). `.locale(code)` re-roots the whole tree at a language. */",
413
+ ` export const strings: ${e.length ? `${s} & {${c}
414
+ }` : "any"}`,
415
+ "}",
416
+ ""
417
+ ];
418
+ }
419
+ function pt(e, n) {
420
+ const s = { children: /* @__PURE__ */ new Map() };
421
+ for (const l of e) {
422
+ let p = s;
423
+ for (const a of l.split(".")) {
424
+ let t = p.children.get(a);
425
+ t || (t = { children: /* @__PURE__ */ new Map() }, p.children.set(a, t)), p = t;
426
+ }
427
+ }
428
+ const c = (l) => l === "text" ? "string" : "number", i = (l) => {
429
+ const p = n[l];
430
+ return !p || Object.keys(p).length === 0 ? "OknoValue<string>" : `(p: { ${Object.entries(p).map(([t, o]) => `${JSON.stringify(t)}: ${c(o)}`).join("; ")} }) => OknoValue<string>`;
431
+ }, u = (l, p) => l.children.size === 0 ? i(p) : `{ ${[...l.children.entries()].map(
432
+ ([t, o]) => `${JSON.stringify(t)}: ${u(o, p ? `${p}.${t}` : t)}`
433
+ ).join("; ")} }`;
434
+ return u(s, "");
435
+ }
436
+ function dt(e) {
437
+ const n = {}, s = e?.strings;
438
+ if (!s || typeof s != "object" || Array.isArray(s)) return n;
439
+ for (const [c, i] of Object.entries(s)) {
440
+ const u = i?.slots;
441
+ if (!u || typeof u != "object" || Array.isArray(u)) continue;
442
+ const l = {};
443
+ for (const [p, a] of Object.entries(u))
444
+ (a === "text" || a === "number" || a === "count") && (l[p] = a);
445
+ Object.keys(l).length && (n[c] = l);
446
+ }
447
+ return n;
448
+ }
449
+ function mt(e, n, s) {
450
+ const c = /* @__PURE__ */ new Set(), i = [];
451
+ for (const u of e) {
452
+ const l = s("collections", u.name, `./collections/${u.name}/${u.first}`);
453
+ i.push(` export const ${u.name}: OknoCollection<${l} & OknoDrag>`), c.add(u.name);
454
+ }
455
+ for (const u of n)
456
+ c.has(u) || i.push(` export const ${u}: OknoCollection<OknoUnscaffolded>`);
457
+ return ['declare module "okno/collections" {', ...i, "}", ""];
458
+ }
459
+ function ht(e) {
460
+ const n = y(e, "schema.ts");
461
+ if (!b(n)) return null;
462
+ try {
463
+ let s = T(n, "utf8");
464
+ const c = s.indexOf("export default");
465
+ return c === -1 ? null : (s = s.slice(c + 14).replace(/\bas const\b/g, "").replace(/\bsatisfies\s+[A-Za-z0-9_.]+/g, "").trim(), s.endsWith(";") && (s = s.slice(0, -1).trim()), JSON.parse(s));
466
+ } catch {
467
+ return null;
468
+ }
469
+ }
470
+ function gt(e) {
471
+ const n = y(e, "strings.ts");
472
+ if (!b(n)) return [];
473
+ try {
474
+ let s = T(n, "utf8");
475
+ const c = s.indexOf("export default");
476
+ if (c === -1) return [];
477
+ s = s.slice(c + 14).replace(/\bas const\b/g, "").replace(/\bsatisfies\s+[A-Za-z0-9_.]+/g, "").trim(), s.endsWith(";") && (s = s.slice(0, -1).trim());
478
+ const i = JSON.parse(s);
479
+ return i && typeof i == "object" && !Array.isArray(i) ? Object.keys(i) : [];
480
+ } catch {
481
+ return [];
482
+ }
483
+ }
484
+ async function yt(e) {
485
+ const n = y(e, "collections");
486
+ if (!b(n)) return [];
487
+ const s = (await I(n, { withFileTypes: !0 })).filter((i) => i.isDirectory()), c = [];
488
+ for (const i of s) {
489
+ const u = await fe(y(n, i.name));
490
+ u.length > 0 && c.push({ name: i.name, first: u[0] });
491
+ }
492
+ return c;
493
+ }
494
+ async function fe(e) {
495
+ return b(e) ? (await I(e)).filter((s) => s.endsWith(".ts") && s !== "index.ts" && s !== "modules.d.ts").map((s) => s.replace(".ts", "")) : [];
496
+ }
497
+ function me(e) {
498
+ try {
499
+ return de(e, { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim();
500
+ } catch {
501
+ return null;
502
+ }
503
+ }
504
+ function _t() {
505
+ const e = me("git rev-parse --abbrev-ref HEAD");
506
+ if (e && e !== "HEAD") return e;
507
+ const n = process.env;
508
+ return n.CF_PAGES_BRANCH || // Cloudflare Pages
509
+ n.VERCEL_GIT_COMMIT_REF || // Vercel
510
+ n.BRANCH || // Netlify
511
+ n.GITHUB_REF_NAME || // GitHub Actions
512
+ "main";
513
+ }
514
+ function $t(e) {
515
+ try {
516
+ const n = JSON.parse(T(y(process.cwd(), e, "project.json"), "utf-8"));
517
+ return typeof n?.repoId == "number" ? n.repoId : null;
518
+ } catch {
519
+ return null;
520
+ }
521
+ }
522
+ function Bt(e = "okno") {
523
+ const n = me("git remote get-url origin");
524
+ if (!n) return null;
525
+ const s = n.match(/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/);
526
+ if (!s) return null;
527
+ const c = $t(e);
528
+ return `${s[1]}/${s[2]}${c ? `#${c}` : ""}@${_t()}`;
529
+ }
530
+ function Gt() {
531
+ const e = me("git rev-parse --show-toplevel");
532
+ return e ? ee(e, process.cwd()).split(G).join("/") : "";
533
+ }
534
+ function xe(e) {
535
+ try {
536
+ const n = T(y(e, ".revision"), "utf-8").trim();
537
+ if (!/^\d+$/.test(n)) return 0;
538
+ const s = Number(n);
539
+ return Number.isSafeInteger(s) ? s : 0;
540
+ } catch {
541
+ return 0;
542
+ }
543
+ }
544
+ function Kt(e, n) {
545
+ if (!b(e)) return;
546
+ const s = y(n, "okno");
547
+ U(s, { recursive: !0 }), E(y(s, "build.json"), `${JSON.stringify({ revision: xe(e) })}
548
+ `);
549
+ }
550
+ const kt = "__oknoSetImages({})", bt = '__oknoSetImages(import.meta.glob("/okno/files/**/*.{png,jpg,jpeg,webp,avif,gif,svg,tiff}", { eager: false }))';
551
+ function he(e = "raw") {
552
+ return e === "astro" ? bt : kt;
553
+ }
554
+ const je = F(Ce(import.meta.url)), wt = [
555
+ ke(je, "./runtime/wrap.js"),
556
+ // bundled at dist/ (Vite plugin chunk)
557
+ ke(je, "../runtime/wrap.js")
558
+ // bundled at dist/next/ (Next entry)
559
+ ];
560
+ function Zt() {
561
+ for (const e of wt)
562
+ if (b(e)) return T(e, "utf-8");
563
+ return null;
564
+ }
565
+ function Ht() {
566
+ return [
567
+ 'export * as pages from "okno/pages"',
568
+ 'export * as globals from "okno/globals"',
569
+ 'export * as collections from "okno/collections"',
570
+ 'export { strings } from "okno/strings"'
571
+ ].join(`
572
+ `);
573
+ }
574
+ function B(e) {
575
+ const n = y(e, "schema.ts");
576
+ if (!b(n)) return null;
577
+ try {
578
+ const c = Z(T(n, "utf-8"))?.locales?.supported;
579
+ if (!Array.isArray(c) || c.length === 0) return null;
580
+ const i = c.map((u) => typeof u == "string" ? u : u?.id).filter((u) => typeof u == "string");
581
+ return i.length ? new Set(i) : null;
582
+ } catch {
583
+ return null;
584
+ }
585
+ }
586
+ function D(e, n) {
587
+ return n ? n.has(e) : jt.test(e);
588
+ }
589
+ function St(e) {
590
+ for (const n of [e, "en"])
591
+ try {
592
+ const s = new Intl.DisplayNames([n], { type: "language" }).of(e);
593
+ if (s && s !== e) return s;
594
+ } catch {
595
+ }
596
+ return e;
597
+ }
598
+ async function ge(e) {
599
+ return b(e) ? (await I(e)).filter((s) => s.endsWith(".ts") && s !== "index.ts") : [];
600
+ }
601
+ function Ot(e) {
602
+ const n = y(e, "schema.ts"), s = {}, c = [], i = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
603
+ if (!b(n)) return { names: c, orders: s, draftsOff: i, schedulingOff: u };
604
+ try {
605
+ const p = Z(T(n, "utf-8"))?.collections ?? {};
606
+ for (const [a, t] of Object.entries(p))
607
+ c.push(a), Array.isArray(t?.order) && (s[a] = t.order.filter((o) => typeof o == "string")), t?.drafts === !1 && i.add(a), t?.scheduling === !1 && u.add(a);
608
+ } catch {
609
+ }
610
+ return { names: c, orders: s, draftsOff: i, schedulingOff: u };
611
+ }
612
+ const jt = /^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|[0-9]{3}))?$/i, oe = (e) => e.replace(/[^a-zA-Z0-9]/g, "_");
613
+ function ye(e) {
614
+ return e.replace(".ts", "").replace(/-/g, "_");
615
+ }
616
+ function Ne(e) {
617
+ return e.replace(".ts", "").replace(/-/g, "_");
618
+ }
619
+ function ne(e) {
620
+ return e.replace(".ts", "");
621
+ }
622
+ function qt(e) {
623
+ const n = y(e, "schema.ts");
624
+ let s = [], c = "";
625
+ if (b(n))
626
+ try {
627
+ const i = Z(T(n, "utf-8")), u = i?.locales?.supported;
628
+ Array.isArray(u) && (s = u.map((l) => typeof l == "string" ? { id: l } : l).filter((l) => !!l && typeof l.id == "string").map((l) => ({
629
+ id: l.id,
630
+ name: l.name || St(l.id),
631
+ // Preserve an intentionally empty slug (= no URL prefix for the default).
632
+ slug: typeof l.slug == "string" ? l.slug : l.id.toLowerCase()
633
+ })), c = typeof i.locales.default == "string" ? i.locales.default : s[0]?.id ?? "");
634
+ } catch {
635
+ }
636
+ return [
637
+ `const __raw = ${JSON.stringify(s)}`,
638
+ `const __def = ${JSON.stringify(c)}`,
639
+ // Swap the locale prefix on a path (empty slug = no prefix). Best-effort,
640
+ // matches the editor's own resolver; fully translated paths = dev's own tags.
641
+ "function __swap(pathname, slug) {",
642
+ ' const norm = (pathname || "/").replace(/\\/+$/, "") || "/"',
643
+ ' const segs = norm.split("/").filter(Boolean)',
644
+ " const known = __raw.find((l) => l.slug && l.slug === segs[0])",
645
+ ' const rest = known ? "/" + segs.slice(1).join("/") : norm',
646
+ ' const r = rest === "" ? "/" : rest',
647
+ " if (!slug) return r",
648
+ ' return r === "/" ? "/" + slug : "/" + slug + r',
649
+ "}",
650
+ 'const __origin = (url) => (typeof url === "object" && url !== null ? url.origin : "")',
651
+ 'const __path = (url) => (typeof url === "object" && url !== null ? url.pathname : String(url || "/"))',
652
+ "/** The configured languages — an array of { id, name, slug, link(url) }.",
653
+ " * link(url) → this entry's hreflang <link> descriptor (spread onto a <link>;",
654
+ " * pass Astro.url for an absolute href). `locales.default` is the base entry. */",
655
+ "export const locales = __raw.map((l) => ({",
656
+ " ...l,",
657
+ ' link: (url) => ({ rel: "alternate", hreflang: l.id, href: __origin(url) + __swap(__path(url), l.slug) }),',
658
+ "}))",
659
+ // `.default` = the base-locale entry (same object reference as in the array).
660
+ "locales.default = locales.find((l) => l.id === __def) || locales[0]"
661
+ ].join(`
662
+ `);
663
+ }
664
+ async function Xt(e) {
665
+ const n = y(e, "strings.ts");
666
+ if (!b(n))
667
+ return [
668
+ 'import { __oknoMakeStrings } from "okno/runtime"',
669
+ 'export const strings = __oknoMakeStrings({}, {}, "")'
670
+ ].join(`
671
+ `);
672
+ const s = y(e, "schema.ts"), c = b(s), i = [...B(e) ?? []], u = B(e), l = y(e, "strings"), p = [];
673
+ if (b(l)) {
674
+ const d = await I(l, { withFileTypes: !0 });
675
+ for (const h of d) {
676
+ if (!h.isFile() || !h.name.endsWith(".ts") || h.name === "index.ts") continue;
677
+ const g = h.name.replace(/\.ts$/, "");
678
+ D(g, u) && p.push(g);
679
+ }
680
+ }
681
+ const a = [
682
+ 'import { __oknoMakeStrings, __oknoLocalize, __oknoExpandStrings } from "okno/runtime"',
683
+ `import _strings_default from "${n}"`
684
+ ];
685
+ c && a.push(`import __schema from "${s}"`);
686
+ const t = c ? "__schema?.strings" : "{}", o = c ? "__schema?.locales?.default" : '""', r = JSON.stringify(i);
687
+ if (p.length === 0)
688
+ return a.push(`export const strings = __oknoMakeStrings(__oknoExpandStrings(_strings_default), ${t}, ${o}, ${r})`), a.join(`
689
+ `);
690
+ const m = [];
691
+ for (const d of p) {
692
+ const h = oe(d);
693
+ a.push(`import _strings_${h} from "${y(l, d + ".ts")}"`), m.push(`"${d}": __oknoExpandStrings(_strings_${h})`);
694
+ }
695
+ return a.push("const _strings_base = __oknoExpandStrings(_strings_default)"), a.push(`const _strings_localized = __oknoLocalize(_strings_base, { ${m.join(", ")} })`), a.push(`export const strings = __oknoMakeStrings(_strings_localized, ${t}, ${o}, ${r})`), a.join(`
696
+ `);
697
+ }
698
+ async function Qt(e, n = /* @__PURE__ */ new Set(), s = "raw") {
699
+ const c = y(e, "pages"), i = y(e, "schema.ts"), u = b(i), l = [
700
+ 'import { __oknoWrap, __oknoLocalize, __oknoResolveEnums, __oknoLiftSlots, __oknoSetImages, __oknoSetRoutes } from "okno/runtime"',
701
+ he(s)
702
+ ];
703
+ u && (l.push('import * as __collections from "okno/collections"'), l.push(`import __schema from "${i}"`), l.push("__oknoSetRoutes(__schema)"));
704
+ const p = JSON.stringify([...B(e) ?? []]), a = (r, m) => {
705
+ if (!u) return `_${r}`;
706
+ const d = `__schema?.pages?.["${m}"]?.fields`;
707
+ return `__oknoResolveEnums(_${r}, ${d}, ${p})`;
708
+ }, t = (r) => u ? `, undefined, { slots: __oknoLiftSlots(__schema?.pages?.["${r}"]?.fields), defaultLocale: __schema?.locales?.default, fields: __schema?.pages?.["${r}"]?.fields, schema: __schema, collections: __collections, locales: ${p} }` : "", o = /* @__PURE__ */ new Set();
709
+ if (b(c)) {
710
+ const r = B(e), d = (await I(c, { withFileTypes: !0 })).filter((g) => g.isDirectory() && D(g.name, r)).map((g) => g.name), h = await ge(c);
711
+ for (const g of h) {
712
+ const _ = ye(g), $ = Ne(g), w = ne(g), f = y(c, g);
713
+ if (d.length === 0) {
714
+ l.push(`import _${_} from "${f}"`), l.push(`export const ${$} = __oknoWrap(${a(_, w)}, "${w}"${t(w)})`), o.add($);
715
+ continue;
716
+ }
717
+ const k = [`import _${_}_default from "${f}"`], O = [];
718
+ for (const S of d) {
719
+ const j = y(c, S, g);
720
+ if (b(j)) {
721
+ const v = oe(S);
722
+ k.push(`import _${_}_${v} from "${j}"`), O.push(`"${S}": _${_}_${v}`);
723
+ }
724
+ }
725
+ l.push(...k), l.push(`const _${_} = __oknoLocalize(_${_}_default, { ${O.join(", ")} })`), l.push(`export const ${$} = __oknoWrap(${a(_, w)}, "${w}"${t(w)})`), o.add($);
726
+ }
727
+ }
728
+ for (const r of n)
729
+ o.has(r) || l.push(`export const ${r} = __oknoWrap(null, "${r}"${t(r)})`);
730
+ return l.join(`
731
+ `);
732
+ }
733
+ async function Yt(e, n = /* @__PURE__ */ new Set(), s = !1, c = "raw") {
734
+ const i = y(e, "collections"), u = B(e), l = b(i) ? await I(i, { withFileTypes: !0 }) : [], { names: p, orders: a, draftsOff: t, schedulingOff: o } = Ot(e), r = l.filter((f) => f.isDirectory() && D(f.name, u)).map((f) => f.name), m = l.filter((f) => f.isDirectory() && !r.includes(f.name)).map((f) => f.name), d = [...new Set([...p, ...m, ...n].map((f) => f.replace(/_/g, "-")))], h = JSON.stringify([...u ?? []]);
735
+ for (const f of d) {
736
+ const k = await I(y(i, f), { withFileTypes: !0 }).catch(() => []);
737
+ for (const O of k)
738
+ O.isDirectory() && D(O.name, u) && console.warn(
739
+ `[okno] "collections/${f}/${O.name}/" looks like a misplaced locale folder. Collection locale overrides go at "collections/${O.name}/${f}/<slug>.ts" (locale right after "collections/"). This folder will NOT be localized.`
740
+ );
741
+ }
742
+ const g = y(e, "schema.ts"), _ = b(g), $ = [
743
+ 'import { __oknoWrap, __oknoLocalize, __oknoResolveEnums, __oknoLiftSlots, __oknoSetImages, __oknoSetRoutes, __oknoVisible } from "okno/runtime"',
744
+ he(c)
745
+ ];
746
+ _ && ($.push(`import __schema from "${g}"`), $.push("__oknoSetRoutes(__schema)"));
747
+ const w = [];
748
+ for (const f of d) {
749
+ const k = y(i, f), O = Fe(await ge(k), ne, a[f]), S = f.replace(/-/g, "_"), j = s && !t.has(f), v = s && !o.has(f), A = [];
750
+ for (const x of O) {
751
+ const N = `_${S}_${ye(x)}`, W = ne(x), R = y(k, x);
752
+ if (r.length === 0)
753
+ $.push(`import ${N} from "${R}"`);
754
+ else {
755
+ const L = [`import ${N}_default from "${R}"`], C = [];
756
+ for (const M of r) {
757
+ const H = y(i, M, f, x);
758
+ if (b(H)) {
759
+ const q = oe(M);
760
+ L.push(`import ${N}_${q} from "${H}"`), C.push(`"${M}": ${N}_${q}`);
761
+ }
762
+ }
763
+ $.push(...L), $.push(`const ${N} = __oknoLocalize(${N}_default, { ${C.join(", ")} })`);
764
+ }
765
+ A.push({ varName: N, itemName: W });
766
+ }
767
+ $.push(`const __oknoRaw_${S} = [${A.map((x) => x.varName).join(", ")}]`), w.push({ name: f, safe: S, draftsOn: j, schedulingOn: v, items: A });
768
+ }
769
+ _ && $.push(`const __oknoNs = { ${w.map((f) => `${f.safe}: __oknoRaw_${f.safe}`).join(", ")} }`);
770
+ for (const f of w) {
771
+ const k = `__schema?.collections?.["${f.name}"]?.fields`, O = (A) => _ ? `__oknoResolveEnums(${A.varName}, ${k}, ${h})` : A.varName;
772
+ let S = "";
773
+ _ && ($.push(`const __oknoSlots_${f.safe} = __oknoLiftSlots(${k})`), S = `, { slots: __oknoSlots_${f.safe}, defaultLocale: __schema?.locales?.default, fields: ${k}, schema: __schema, collections: __oknoNs, locales: ${h} }`);
774
+ const j = [];
775
+ f.draftsOn && j.push('e[0]?.status !== "draft"'), f.schedulingOn && j.push("__oknoVisible(e[0])");
776
+ const v = j.length ? `[${f.items.map((A) => `[${A.varName}, ${O(A)}, ${JSON.stringify(A.itemName)}]`).join(", ")}].filter((e) => ${j.join(" && ")}).map((e, __i) => __oknoWrap(e[1], "${f.name}." + e[2], "${f.name}." + __i${S}))` : `[${f.items.map((A, x) => `__oknoWrap(${O(A)}, "${f.name}.${A.itemName}", "${f.name}.${x}"${S})`).join(", ")}]`;
777
+ $.push(`const __oknoCollection_${f.safe} = ${v}`), $.push(
778
+ `Object.defineProperty(__oknoCollection_${f.safe}, "new", { value: __oknoWrap({ slug: "new" }, "${f.name}.new", undefined${S}), enumerable: false })`
779
+ ), $.push(`export const ${f.safe} = __oknoCollection_${f.safe}`);
780
+ }
781
+ return $.join(`
782
+ `);
783
+ }
784
+ async function Dt(e, n = /* @__PURE__ */ new Set(), s = "raw") {
785
+ const c = y(e, "globals"), i = y(e, "schema.ts"), u = b(i), l = [
786
+ 'import { __oknoWrap, __oknoLocalize, __oknoResolveEnums, __oknoLiftSlots, __oknoSetImages, __oknoSetRoutes } from "okno/runtime"',
787
+ he(s)
788
+ ];
789
+ u && (l.push('import * as __collections from "okno/collections"'), l.push(`import __schema from "${i}"`), l.push("__oknoSetRoutes(__schema)"));
790
+ const p = JSON.stringify([...B(e) ?? []]), a = (r, m) => {
791
+ if (!u) return `_${r}`;
792
+ const d = `__schema?.globals?.["${m}"]?.fields`;
793
+ return `__oknoResolveEnums(_${r}, ${d}, ${p})`;
794
+ }, t = (r) => u ? `, undefined, { slots: __oknoLiftSlots(__schema?.globals?.["${r}"]?.fields), defaultLocale: __schema?.locales?.default, fields: __schema?.globals?.["${r}"]?.fields, schema: __schema, collections: __collections, locales: ${p} }` : "", o = /* @__PURE__ */ new Set();
795
+ if (b(c)) {
796
+ const r = B(e), d = (await I(c, { withFileTypes: !0 })).filter((g) => g.isDirectory() && D(g.name, r)).map((g) => g.name), h = await ge(c);
797
+ for (const g of h) {
798
+ const _ = ye(g), $ = Ne(g), w = ne(g), f = y(c, g);
799
+ if (d.length === 0) {
800
+ l.push(`import _${_} from "${f}"`), l.push(`export const ${$} = __oknoWrap(${a(_, w)}, "${w}"${t(w)})`), o.add($);
801
+ continue;
802
+ }
803
+ const k = [`import _${_}_default from "${f}"`], O = [];
804
+ for (const S of d) {
805
+ const j = y(c, S, g);
806
+ if (b(j)) {
807
+ const v = oe(S);
808
+ k.push(`import _${_}_${v} from "${j}"`), O.push(`"${S}": _${_}_${v}`);
809
+ }
810
+ }
811
+ l.push(...k), l.push(`const _${_} = __oknoLocalize(_${_}_default, { ${O.join(", ")} })`), l.push(`export const ${$} = __oknoWrap(${a(_, w)}, "${w}"${t(w)})`), o.add($);
812
+ }
813
+ }
814
+ for (const r of n)
815
+ o.has(r) || l.push(`export const ${r} = __oknoWrap(null, "${r}"${t(r)})`);
816
+ return l.join(`
817
+ `);
818
+ }
819
+ const Pe = /* @__PURE__ */ new Map();
820
+ function z(e) {
821
+ Pe.set(e, Date.now());
822
+ }
823
+ function en(e) {
824
+ const n = Pe.get(e);
825
+ return n !== void 0 && Date.now() - n < 3e3;
826
+ }
827
+ const vt = ["pages", "collections", "globals"];
828
+ function V(e, n) {
829
+ if (!n || n.includes("..") || n.includes("\0") || n.startsWith("/") || !n.endsWith(".ts")) return null;
830
+ const s = y(e, n);
831
+ return s !== e && !s.startsWith(e + G) ? null : s;
832
+ }
833
+ function K(e, n) {
834
+ if (!n || n.includes("..") || n.includes("\0") || n.startsWith("/")) return null;
835
+ const s = y(e, n);
836
+ return s !== e && !s.startsWith(e + G) ? null : s;
837
+ }
838
+ function At(e) {
839
+ const n = {}, s = (i) => {
840
+ if (b(i))
841
+ for (const u of se(i, { withFileTypes: !0 })) {
842
+ const l = y(i, u.name);
843
+ if (u.isDirectory()) s(l);
844
+ else if (u.name.endsWith(".ts") && u.name !== "index.ts") {
845
+ const p = ee(e, l).split(G).join("/");
846
+ n[p] = T(l, "utf-8");
847
+ }
848
+ }
849
+ };
850
+ for (const i of vt) s(y(e, i));
851
+ const c = y(e, "strings.ts");
852
+ return b(c) && (n["strings.ts"] = T(c, "utf-8")), s(y(e, "strings")), n;
853
+ }
854
+ function Ee(e) {
855
+ const n = y(e, "files"), s = [], c = (i) => {
856
+ if (b(i))
857
+ for (const u of se(i, { withFileTypes: !0 })) {
858
+ const l = y(i, u.name);
859
+ if (u.isDirectory()) c(l);
860
+ else if (u.name !== ".okno-tree.json") {
861
+ const p = ee(n, l).split(G).join("/");
862
+ s.push({ path: `files/${p}`, filename: u.name, size: Ie(l).size });
863
+ }
864
+ }
865
+ };
866
+ return c(n), s;
867
+ }
868
+ function Tt(e) {
869
+ const n = y(e, "schema.ts"), s = y(e, "users.json"), c = y(e, "origins.json");
870
+ return {
871
+ schema: b(n) ? T(n, "utf-8") : null,
872
+ users: b(s) ? T(s, "utf-8") : null,
873
+ origins: b(c) ? T(c, "utf-8") : null,
874
+ content: At(e),
875
+ files: Ee(e)
876
+ };
877
+ }
878
+ const ve = (e) => e.replace(/[^a-zA-Z0-9._-]/g, "-"), Ae = (e) => e.split("/").map((n) => n.replace(/[^a-zA-Z0-9._-]/g, "-")).filter((n) => n && n !== "-" && n !== "..").join("/");
879
+ function P(e) {
880
+ const n = y(e, "schema.ts");
881
+ let s = `import type { Schema } from "okno"
882
+
883
+ `, c = {};
884
+ if (b(n)) {
885
+ const i = T(n, "utf-8"), u = i.indexOf("export default");
886
+ u > 0 && (s = i.slice(0, u));
887
+ try {
888
+ c = Z(i) ?? {};
889
+ } catch {
890
+ c = {};
891
+ }
892
+ }
893
+ return { schema: c, header: s };
894
+ }
895
+ function xt(e, n, s) {
896
+ E(y(e, "schema.ts"), Ue(n, s));
897
+ }
898
+ function Nt(e, n, s, c, i) {
899
+ const u = y(e, n), l = new Set(i), p = [];
900
+ if (!b(u) || Object.keys(c).length === 0 && l.size === 0) return p;
901
+ const a = [], t = (o) => {
902
+ for (const r of se(o, { withFileTypes: !0 })) {
903
+ const m = y(o, r.name);
904
+ r.isDirectory() ? t(m) : r.name === `${s}.ts` && a.push(m);
905
+ }
906
+ };
907
+ t(u);
908
+ for (const o of a) {
909
+ let r;
910
+ try {
911
+ r = Z(T(o, "utf-8"));
912
+ } catch {
913
+ continue;
914
+ }
915
+ let m, d = !1;
916
+ if (Array.isArray(r))
917
+ m = r.map((g) => {
918
+ if (g && typeof g == "object" && !Array.isArray(g)) {
919
+ const _ = we(g, c, l);
920
+ return _.changed && (d = !0), _.out;
921
+ }
922
+ return g;
923
+ });
924
+ else if (r && typeof r == "object") {
925
+ const g = we(r, c, l);
926
+ m = g.out, d = g.changed;
927
+ } else
928
+ continue;
929
+ if (!d) continue;
930
+ z(o), E(o, ue(m));
931
+ const h = ee(e, o).split(G).join("/");
932
+ p.push({ rel: h, abs: o }), console.log(`[okno] field-change migrated content: ${h}`, { renames: c, deletes: i });
933
+ }
934
+ return p;
935
+ }
936
+ let le;
937
+ function pe(e) {
938
+ return le || (le = de("git rev-parse --show-toplevel", { cwd: e, encoding: "utf-8" }).trim()), le;
939
+ }
940
+ function Te(e) {
941
+ return ee(pe(e), We(e)).split(G).join("/");
942
+ }
943
+ let Y;
944
+ function Pt(e) {
945
+ if (Y !== void 0) return Y;
946
+ try {
947
+ Y = de("git config user.name", { cwd: e, encoding: "utf-8" }).trim() || "local";
948
+ } catch {
949
+ Y = "local";
950
+ }
951
+ return Y;
952
+ }
953
+ function te(e) {
954
+ return e.startsWith("files/") && e.length > 6;
955
+ }
956
+ async function tn(e, n) {
957
+ const { method: s, route: c } = n, i = { files: [], modules: [] }, u = (t, o) => {
958
+ const r = t.split("/")[0];
959
+ r !== "pages" && r !== "collections" && r !== "globals" || (i.modules.push(r), i.files.push(o));
960
+ }, l = () => i.modules.push("pages", "collections", "globals"), p = (t, o) => {
961
+ xt(e, t, o), l();
962
+ }, a = (t, o) => ({ status: t, body: o, invalidation: i });
963
+ try {
964
+ if (s === "GET" && c === "content") return a(200, Tt(e));
965
+ if (s === "POST" && c === "content/save") {
966
+ const { path: t, content: o, created: r, author: m } = await n.json();
967
+ if (!t || !o) return a(400, { error: "Missing path or content" });
968
+ if (ze(t)) return a(400, { error: 'Slug "new" is reserved for creating items' });
969
+ const d = V(e, t);
970
+ if (!d) return a(400, { error: "Invalid path" });
971
+ const h = Je(o, { now: (/* @__PURE__ */ new Date()).toISOString(), author: m || Pt(e), created: r });
972
+ return U(F(d), { recursive: !0 }), z(d), E(d, h), u(t, d), a(200, { ok: !0, commit: { fileSha: "" } });
973
+ }
974
+ if (s === "POST" && c === "content/delete") {
975
+ const t = (await n.json())?.path;
976
+ if (!t) return a(400, { error: "Missing path" });
977
+ const o = V(e, t);
978
+ return o ? (b(o) && (z(o), X(o), u(t, o)), a(200, { ok: !0 })) : a(400, { error: "Invalid path" });
979
+ }
980
+ if (s === "POST" && c === "strings/save") {
981
+ const { path: t, content: o } = await n.json();
982
+ if (!t || !o || typeof o != "object") return a(400, { error: "Missing path or content" });
983
+ if (t !== "strings.ts" && !/^strings\/[^/]+\.ts$/.test(t)) return a(400, { error: "Invalid strings path" });
984
+ const r = V(e, t);
985
+ return r ? (U(F(r), { recursive: !0 }), z(r), E(r, ue(o)), i.modules.push("strings", "content"), i.files.push(r), a(200, { ok: !0, commit: { fileSha: "" } })) : a(400, { error: "Invalid path" });
986
+ }
987
+ if (s === "POST" && c === "strings/set-schema") {
988
+ const { strings: t } = await n.json();
989
+ if (t != null && (typeof t != "object" || Array.isArray(t))) return a(400, { error: "Invalid strings" });
990
+ const { schema: o, header: r } = P(e);
991
+ return Ve(o, t), p(o, r), i.modules.push("strings", "content"), a(200, { ok: !0, commit: { fileSha: "" }, schema: o });
992
+ }
993
+ if (s === "GET" && c === "publish-state")
994
+ try {
995
+ const t = be(pe(e)), o = await t.status(), r = Te(e), m = (_) => _.startsWith(r + "/"), d = o.files.map((_) => _.path).filter(m);
996
+ let h = [];
997
+ if (o.ahead > 0)
998
+ try {
999
+ h = (await t.raw(["diff", "--name-only", "@{u}...HEAD", "--", r])).split(`
1000
+ `).map(($) => $.trim()).filter(Boolean);
1001
+ } catch {
1002
+ }
1003
+ const g = Array.from(/* @__PURE__ */ new Set([...d, ...h]));
1004
+ return a(200, { pendingPublish: d.length > 0 || o.ahead > 0, changed: g });
1005
+ } catch {
1006
+ return a(200, { pendingPublish: !1 });
1007
+ }
1008
+ if (s === "POST" && c === "publish") {
1009
+ const t = be(pe(e)), o = Te(e), r = await t.status();
1010
+ let m = xe(e);
1011
+ r.files.some((w) => w.path.startsWith(o + "/")) && (m += 1, E(y(e, ".revision"), `${m}
1012
+ `)), await t.raw(["add", "-A", "--", o]);
1013
+ const d = await t.status(), h = d.staged.length > 0;
1014
+ let g = !1;
1015
+ h && (await t.commit("okno: publish content"), g = !0);
1016
+ let _ = !1, $ = null;
1017
+ try {
1018
+ (g || d.ahead > 0) && (await t.push(), _ = !0);
1019
+ } catch (w) {
1020
+ $ = w instanceof Error ? w.message.split(`
1021
+ `)[0] : String(w);
1022
+ }
1023
+ return $ ? a(502, { error: `Git push failed: ${$}`, committed: g, revision: m }) : a(200, { ok: !0, alreadyUpToDate: !g && d.ahead === 0, committed: g, pushed: _, pushError: $, revision: m });
1024
+ }
1025
+ if (s === "POST" && c === "schema/save-fields") {
1026
+ const { kind: t, name: o, fields: r, renames: m, deletes: d } = await n.json();
1027
+ if (!t || !o || !r) return a(400, { error: "Missing kind, name or fields" });
1028
+ const { schema: h, header: g } = P(e);
1029
+ Be(h, t, o, r), p(h, g);
1030
+ const _ = m && typeof m == "object" ? m : {}, $ = Array.isArray(d) ? d : [];
1031
+ if (Object.keys(_).length > 0 || $.length > 0)
1032
+ for (const { rel: w, abs: f } of Nt(e, t, o, _, $)) u(w, f);
1033
+ return a(200, { ok: !0, commit: { fileSha: "" }, schema: h });
1034
+ }
1035
+ if (s === "POST" && c === "schema/set-locales") {
1036
+ const t = (await n.json())?.locales, { schema: o, header: r } = P(e);
1037
+ return Ge(o, t), p(o, r), a(200, { ok: !0, commit: { fileSha: "" } });
1038
+ }
1039
+ if (s === "POST" && c === "schema/set-name") {
1040
+ const { kind: t, slug: o, name: r } = await n.json();
1041
+ if (!t || !o || !r) return a(400, { error: "Missing kind, slug or name" });
1042
+ const { schema: m, header: d } = P(e);
1043
+ return Ke(m, t, o, r), p(m, d), a(200, { ok: !0, commit: { fileSha: "" } });
1044
+ }
1045
+ if (s === "POST" && c === "schema/set-url") {
1046
+ const { kind: t, slug: o, url: r } = await n.json();
1047
+ if (!t || !o) return a(400, { error: "Missing kind or slug" });
1048
+ const { schema: m, header: d } = P(e);
1049
+ return Ze(m, t, o, r), p(m, d), a(200, { ok: !0, commit: { fileSha: "" } });
1050
+ }
1051
+ if (s === "POST" && c === "schema/rename-slug") {
1052
+ const { kind: t, from: o, to: r } = await n.json();
1053
+ if (!t || !o || !r) return a(400, { error: "Missing kind, from or to" });
1054
+ const { schema: m, header: d } = P(e), { unchanged: h } = He(m, t, o, r);
1055
+ if (h) return a(200, { ok: !0, unchanged: !0 });
1056
+ p(m, d);
1057
+ const g = `${t}/${o}.ts`, _ = `${t}/${r}.ts`, $ = V(e, g), w = V(e, _);
1058
+ return $ && w && b($) && (U(F(w), { recursive: !0 }), z($), z(w), E(w, T($)), X($), u(g, $), u(_, w)), a(200, { ok: !0, commit: { fileSha: "" }, schema: m, from: o, to: r, kind: t });
1059
+ }
1060
+ if (s === "POST" && c === "schema/reorder") {
1061
+ const { kind: t, order: o } = await n.json();
1062
+ if (!t || !Array.isArray(o)) return a(400, { error: "Missing kind or order" });
1063
+ const { schema: r, header: m } = P(e);
1064
+ return qe(r, t, o), p(r, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: r });
1065
+ }
1066
+ if (s === "POST" && c === "schema/set-layout") {
1067
+ const { kind: t, layout: o } = await n.json();
1068
+ if (!t || !Array.isArray(o)) return a(400, { error: "Missing kind or layout" });
1069
+ const { schema: r, header: m } = P(e);
1070
+ return Xe(r, t, o), p(r, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: r });
1071
+ }
1072
+ if (s === "POST" && c === "collections/set-order") {
1073
+ const { name: t, order: o } = await n.json();
1074
+ if (!t || !Array.isArray(o)) return a(400, { error: "Missing name or order" });
1075
+ const { schema: r, header: m } = P(e);
1076
+ return Qe(r, t, o), p(r, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: r });
1077
+ }
1078
+ if (s === "POST" && c === "collections/set-drafts") {
1079
+ const { name: t, drafts: o } = await n.json();
1080
+ if (!t || typeof o != "boolean") return a(400, { error: "Missing name or drafts" });
1081
+ const { schema: r, header: m } = P(e);
1082
+ return Ye(r, t, o), p(r, m), a(200, { ok: !0, commit: { fileSha: "" }, schema: r });
1083
+ }
1084
+ if (s === "POST" && c === "schema/delete-entry") {
1085
+ const { kind: t, name: o } = await n.json();
1086
+ if (!t || !o) return a(400, { error: "Missing kind or name" });
1087
+ const { schema: r, header: m } = P(e);
1088
+ De(r, t, o), p(r, m);
1089
+ const d = `${t}/${o}.ts`, h = V(e, d);
1090
+ return h && b(h) && (z(h), X(h), u(d, h)), a(200, { ok: !0, commit: { fileSha: "" }, schema: r });
1091
+ }
1092
+ if (s === "POST" && c === "setup/scaffold-page") {
1093
+ const { name: t, kind: o, fields: r, label: m } = await n.json();
1094
+ if (!t || !o) return a(400, { error: "Missing name or kind" });
1095
+ const d = r ?? [], { schema: h, header: g } = P(e);
1096
+ if (et(h, t, o, d, m), p(h, g), o !== "blocks") {
1097
+ const _ = `${o}/${t}.ts`, $ = V(e, _);
1098
+ if ($) {
1099
+ const w = o === "collections" ? `export default []
1100
+ ` : ue(tt(d));
1101
+ U(F($), { recursive: !0 }), z($), E($, w), u(_, $);
1102
+ }
1103
+ }
1104
+ return a(200, { ok: !0 });
1105
+ }
1106
+ if (s === "GET" && c === "files") {
1107
+ const t = y(e, "files", ".okno-tree.json");
1108
+ return a(200, {
1109
+ files: Ee(e),
1110
+ manifest: b(t) ? T(t, "utf-8") : null
1111
+ });
1112
+ }
1113
+ if (s === "POST" && c === "files/blob") {
1114
+ const t = ve(decodeURIComponent(n.header("x-okno-filename") || "")), o = n.header("x-okno-dir") ? decodeURIComponent(n.header("x-okno-dir")) : "";
1115
+ if (!t || t === "-") return a(400, { error: "Invalid filename" });
1116
+ const r = Ae(o), m = r ? `${r}/${t}` : t, d = K(e, `files/${m}`);
1117
+ if (!d) return a(400, { error: "Invalid path" });
1118
+ const h = await n.binary();
1119
+ return h.length === 0 ? a(400, { error: "Empty body" }) : (U(F(d), { recursive: !0 }), E(d, h), a(200, { ok: !0, blobSha: "", path: `files/${m}`, filename: t }));
1120
+ }
1121
+ if (s === "POST" && c === "files/commit") return a(200, { ok: !0 });
1122
+ if (s === "POST" && c === "files/upload") {
1123
+ const { filename: t, content: o, dir: r } = await n.json();
1124
+ if (!t || o == null) return a(400, { error: "Missing filename or content" });
1125
+ const m = ve(t);
1126
+ if (!m || m === "-") return a(400, { error: "Invalid filename" });
1127
+ const d = Ae(r ?? ""), h = d ? `${d}/${m}` : m, g = K(e, `files/${h}`);
1128
+ return g ? (U(F(g), { recursive: !0 }), E(g, Buffer.from(o, "base64")), a(200, { ok: !0, path: `files/${h}`, filename: m, commit: { fileSha: "" } })) : a(400, { error: "Invalid path" });
1129
+ }
1130
+ if (s === "POST" && c === "files/delete") {
1131
+ const t = (await n.json())?.path;
1132
+ if (!t) return a(400, { error: "Missing path" });
1133
+ if (!te(t)) return a(400, { error: "Invalid path" });
1134
+ const o = K(e, t);
1135
+ return o ? (b(o) && X(o), a(200, { ok: !0 })) : a(400, { error: "Invalid path" });
1136
+ }
1137
+ if (s === "POST" && c === "files/delete-many") {
1138
+ const t = (await n.json())?.paths;
1139
+ if (!Array.isArray(t)) return a(400, { error: "Missing paths" });
1140
+ if (t.some((o) => !te(String(o)))) return a(400, { error: "Invalid path" });
1141
+ for (const o of t) {
1142
+ const r = K(e, String(o));
1143
+ r && b(r) && X(r);
1144
+ }
1145
+ return a(200, { ok: !0 });
1146
+ }
1147
+ if (s === "POST" && c === "files/rename") {
1148
+ const { from: t, to: o } = await n.json();
1149
+ if (!t || !o) return a(400, { error: "Missing from or to" });
1150
+ if (!te(t) || !te(o)) return a(400, { error: "Invalid path" });
1151
+ const r = K(e, t), m = K(e, o);
1152
+ return !r || !m ? a(400, { error: "Invalid path" }) : b(r) ? (U(F(m), { recursive: !0 }), Le(r, m), a(200, { ok: !0, commit: { fileSha: "" } })) : a(404, { error: "Source not found" });
1153
+ }
1154
+ if (s === "POST" && c === "users/save") {
1155
+ const t = (await n.json())?.users;
1156
+ return Array.isArray(t) ? (E(y(e, "users.json"), JSON.stringify(t, null, " ") + `
1157
+ `), a(200, { ok: !0, commit: { fileSha: "" } })) : a(400, { error: "Missing users" });
1158
+ }
1159
+ if (s === "POST" && c === "origins/save") {
1160
+ const t = (await n.json())?.origins;
1161
+ if (!Array.isArray(t) || t.some((r) => typeof r != "string")) return a(400, { error: "Missing origins" });
1162
+ const o = [...new Set(t.map((r) => r.trim()).filter(Boolean))];
1163
+ return E(y(e, "origins.json"), JSON.stringify(o, null, " ") + `
1164
+ `), a(200, { ok: !0, origins: o, commit: { fileSha: "" } });
1165
+ }
1166
+ return null;
1167
+ } catch (t) {
1168
+ return t instanceof nt ? { status: t.status, body: { error: t.message } } : { status: 500, body: { error: t instanceof Error ? t.message : String(t) } };
1169
+ }
1170
+ }
1171
+ export {
1172
+ Yt as a,
1173
+ Qt as b,
1174
+ Dt as c,
1175
+ Xt as d,
1176
+ qt as e,
1177
+ Ht as f,
1178
+ Zt as g,
1179
+ Gt as h,
1180
+ Bt as i,
1181
+ Vt as j,
1182
+ tn as k,
1183
+ Tt as l,
1184
+ en as m,
1185
+ ie as s,
1186
+ Kt as w
1187
+ };