@nice2dev/ui-forms 1.4.4 → 1.4.6

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/studio.mjs CHANGED
@@ -1,7 +1,138 @@
1
- var ae = Object.defineProperty;
2
- var ce = (e, t, n) => t in e ? ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var q = (e, t, n) => ce(e, typeof t != "symbol" ? t + "" : t, n);
4
- const H = {
1
+ var we = Object.defineProperty;
2
+ var ve = (e, t, n) => t in e ? we(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var Y = (e, t, n) => ve(e, typeof t != "symbol" ? t + "" : t, n);
4
+ const J = () => ({
5
+ version: 1,
6
+ sections: [],
7
+ folders: [],
8
+ placement: {}
9
+ }), dt = (e, t) => `${e}:${t}`, _ = ".studio.json", Se = /^([^/]+?)\.(manifest|entities|views|workflows|permissions|rbac|seeds|datasources|scripts)\.json$/i, $e = (e) => !e.includes("/") && e.toLowerCase().endsWith(_);
10
+ function ft(e) {
11
+ const t = e.find((n) => $e(n.path));
12
+ if (t)
13
+ return t.path;
14
+ for (const n of e) {
15
+ const s = Se.exec(n.path);
16
+ if (s)
17
+ return `${s[1]}${_}`;
18
+ }
19
+ return `module${_}`;
20
+ }
21
+ const N = (e) => typeof e == "object" && e !== null && !Array.isArray(e), b = (e) => typeof e == "string" && e ? e : void 0;
22
+ function pt(e) {
23
+ if (!e)
24
+ return J();
25
+ let t;
26
+ try {
27
+ t = JSON.parse(e.replace(/^\uFEFF/, ""));
28
+ } catch {
29
+ return J();
30
+ }
31
+ if (!N(t))
32
+ return J();
33
+ const n = (Array.isArray(t.sections) ? t.sections : []).filter(N).map((i) => ({ id: b(i.id), label: b(i.label) ?? b(i.id) })).filter((i) => !!i.id && !!i.label), s = (Array.isArray(t.folders) ? t.folders : []).filter(N).map((i) => ({
34
+ id: b(i.id),
35
+ label: b(i.label) ?? b(i.id),
36
+ group: b(i.group),
37
+ ...b(i.parent) ? { parent: b(i.parent) } : {},
38
+ ...b(i.section) ? { section: b(i.section) } : {}
39
+ })).filter((i) => !!i.id && !!i.label && !!i.group), r = {};
40
+ if (N(t.placement))
41
+ for (const [i, a] of Object.entries(t.placement)) {
42
+ if (!N(a))
43
+ continue;
44
+ const l = {};
45
+ b(a.section) && (l.section = b(a.section)), b(a.folder) && (l.folder = b(a.folder)), typeof a.order == "number" && Number.isFinite(a.order) && (l.order = a.order), (l.section || l.folder || l.order !== void 0) && (r[i] = l);
46
+ }
47
+ return { version: 1, sections: n, folders: s, placement: r };
48
+ }
49
+ const ut = (e) => e.sections.length === 0 && e.folders.length === 0 && Object.keys(e.placement).length === 0;
50
+ function mt(e, t) {
51
+ const n = JSON.stringify(e, null, 2) + `
52
+ `;
53
+ return t != null && t.includes(`\r
54
+ `) ? n.replace(/\n/g, `\r
55
+ `) : n;
56
+ }
57
+ const je = (e) => e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "item";
58
+ function re(e, t) {
59
+ const n = je(e);
60
+ let s = n;
61
+ for (let r = 2; t.has(s); r++)
62
+ s = `${n}-${r}`;
63
+ return s;
64
+ }
65
+ function ht(e, t) {
66
+ const n = re(t, new Set(e.sections.map((s) => s.id)));
67
+ return { layout: { ...e, sections: [...e.sections, { id: n, label: t }] }, id: n };
68
+ }
69
+ function yt(e, t) {
70
+ const n = re(t.label, new Set(e.folders.map((r) => r.id))), s = { id: n, label: t.label, group: t.group };
71
+ return t.parent && (s.parent = t.parent), t.section && (s.section = t.section), { layout: { ...e, folders: [...e.folders, s] }, id: n };
72
+ }
73
+ function gt(e, t, n) {
74
+ return t.kind === "section" ? { ...e, sections: e.sections.map((s) => s.id === t.id ? { ...s, label: n } : s) } : { ...e, folders: e.folders.map((s) => s.id === t.id ? { ...s, label: n } : s) };
75
+ }
76
+ function bt(e, t) {
77
+ const n = {};
78
+ if (t.kind === "folder") {
79
+ const s = e.folders.find((r) => r.id === t.id);
80
+ for (const [r, i] of Object.entries(e.placement))
81
+ n[r] = i.folder === t.id ? { ...i, folder: s == null ? void 0 : s.parent } : i, n[r].folder || delete n[r].folder;
82
+ return {
83
+ ...e,
84
+ folders: e.folders.filter((r) => r.id !== t.id).map((r) => r.parent === t.id ? { ...r, parent: s == null ? void 0 : s.parent } : r).map((r) => {
85
+ if (!r.parent) {
86
+ const { parent: i, ...a } = r;
87
+ return a;
88
+ }
89
+ return r;
90
+ }),
91
+ placement: U(n)
92
+ };
93
+ }
94
+ for (const [s, r] of Object.entries(e.placement))
95
+ if (r.section === t.id) {
96
+ const { section: i, ...a } = r;
97
+ n[s] = a;
98
+ } else
99
+ n[s] = r;
100
+ return {
101
+ ...e,
102
+ sections: e.sections.filter((s) => s.id !== t.id),
103
+ folders: e.folders.map((s) => {
104
+ if (s.section === t.id) {
105
+ const { section: r, ...i } = s;
106
+ return i;
107
+ }
108
+ return s;
109
+ }),
110
+ placement: U(n)
111
+ };
112
+ }
113
+ function U(e) {
114
+ const t = {};
115
+ for (const [n, s] of Object.entries(e))
116
+ (s.section || s.folder || s.order !== void 0) && (t[n] = s);
117
+ return t;
118
+ }
119
+ function kt(e, t, n) {
120
+ var i;
121
+ const s = (i = e.placement[t]) == null ? void 0 : i.order, r = {};
122
+ if (n.folder) {
123
+ r.folder = n.folder;
124
+ const a = e.folders.find((l) => l.id === n.folder);
125
+ a != null && a.section && (r.section = a.section);
126
+ } else n.section && (r.section = n.section);
127
+ return s !== void 0 && (r.order = s), { ...e, placement: U({ ...e.placement, [t]: r }) };
128
+ }
129
+ function wt(e, t, n) {
130
+ if (t === n || !e.placement[t])
131
+ return e;
132
+ const s = { ...e.placement, [n]: e.placement[t] };
133
+ return delete s[t], { ...e, placement: s };
134
+ }
135
+ const ie = "\uFEFF", oe = {
5
136
  bom: !1,
6
137
  eol: `
7
138
  `,
@@ -9,98 +140,98 @@ const H = {
9
140
  finalNewline: !0,
10
141
  colonSpace: !0
11
142
  };
12
- function C(e) {
143
+ function X(e) {
13
144
  const t = e.charCodeAt(0) === 65279, n = e.includes(`\r
14
145
  `) ? `\r
15
146
  ` : `
16
147
  `;
17
- let i = H.indent;
148
+ let s = oe.indent;
18
149
  const r = e.split(/\r?\n/);
19
- for (let c = 1; c < r.length; c++) {
20
- const d = /^([ \t]+)\S/.exec(r[c]);
21
- if (d) {
22
- i = d[1];
150
+ for (let a = 1; a < r.length; a++) {
151
+ const l = /^([ \t]+)\S/.exec(r[a]);
152
+ if (l) {
153
+ s = l[1];
23
154
  break;
24
155
  }
25
156
  }
26
- const a = /"\s*:(\s?)/.exec(e);
157
+ const i = /"\s*:(\s?)/.exec(e);
27
158
  return {
28
159
  bom: t,
29
160
  eol: n,
30
- indent: i,
161
+ indent: s,
31
162
  finalNewline: /\n$/.test(e),
32
- colonSpace: a ? a[1] !== "" : !0
163
+ colonSpace: i ? i[1] !== "" : !0
33
164
  };
34
165
  }
35
- function E(e) {
36
- const t = C(e);
166
+ function x(e) {
167
+ const t = X(e);
37
168
  return { value: JSON.parse(t.bom ? e.slice(1) : e), format: t };
38
169
  }
39
- function k(e, t) {
40
- const n = { ...H, ...t }, i = j(e, n, "");
41
- return (n.bom ? "\uFEFF" : "") + i + (n.finalNewline ? n.eol : "");
170
+ function v(e, t) {
171
+ const n = { ...oe, ...t }, s = A(e, n, "");
172
+ return (n.bom ? ie : "") + s + (n.finalNewline ? n.eol : "");
42
173
  }
43
- function le(e, t) {
174
+ function Oe(e, t) {
44
175
  if (t === void 0)
45
176
  return e;
46
177
  let n = t.includes(`\r
47
178
  `) ? e.replace(/\r?\n/g, `\r
48
179
  `) : e;
49
- return t.charCodeAt(0) === 65279 && n.charCodeAt(0) !== 65279 && (n = "\uFEFF" + n), n;
180
+ return t.charCodeAt(0) === 65279 && n.charCodeAt(0) !== 65279 && (n = ie + n), n;
50
181
  }
51
- function I(e, t) {
182
+ function C(e, t) {
52
183
  if (e === t)
53
184
  return !0;
54
185
  if (typeof e != typeof t || e === null || t === null || typeof e != "object" || Array.isArray(e) !== Array.isArray(t))
55
186
  return !1;
56
187
  if (Array.isArray(e)) {
57
- const a = t;
58
- return e.length === a.length && e.every((c, d) => I(c, a[d]));
188
+ const i = t;
189
+ return e.length === i.length && e.every((a, l) => C(a, i[l]));
59
190
  }
60
- const n = e, i = t, r = Object.keys(n);
61
- return r.length !== Object.keys(i).length ? !1 : r.every(
62
- (a) => Object.prototype.hasOwnProperty.call(i, a) && I(n[a], i[a])
191
+ const n = e, s = t, r = Object.keys(n);
192
+ return r.length !== Object.keys(s).length ? !1 : r.every(
193
+ (i) => Object.prototype.hasOwnProperty.call(s, i) && C(n[i], s[i])
63
194
  );
64
195
  }
65
- function X(e, t, n) {
66
- return de(e, t, n).text;
196
+ function ae(e, t, n) {
197
+ return Ae(e, t, n).text;
67
198
  }
68
- function de(e, t, n) {
69
- const i = C(e), r = (s) => ({
70
- text: k(t, i),
199
+ function Ae(e, t, n) {
200
+ const s = X(e), r = (o) => ({
201
+ text: v(t, s),
71
202
  exact: !1,
72
- reason: s
203
+ reason: o
73
204
  });
74
- let a;
205
+ let i;
75
206
  try {
76
- a = new fe(e).parseDocument();
77
- } catch (s) {
78
- return r(s instanceof Error ? s.message : String(s));
207
+ i = new Ee(e).parseDocument();
208
+ } catch (o) {
209
+ return r(o instanceof Error ? o.message : String(o));
79
210
  }
80
- if (T(a))
211
+ if (R(i))
81
212
  return r("duplicate keys");
82
- const c = [], d = {
213
+ const a = [], l = {
83
214
  text: e,
84
- format: i,
85
- edits: c,
215
+ format: s,
216
+ edits: a,
86
217
  options: n,
87
218
  compact: !e.trimEnd().includes(`
88
219
  `)
89
220
  };
90
- U(d, a, t, "", !1);
91
- const u = ue(e, c);
221
+ G(l, i, t, "", !1);
222
+ const f = Ke(e, a);
92
223
  try {
93
- const s = JSON.parse(i.bom ? u.slice(1) : u);
94
- if (!I(s, t))
224
+ const o = JSON.parse(s.bom ? f.slice(1) : f);
225
+ if (!C(o, t))
95
226
  return r("patch did not read back");
96
227
  } catch {
97
228
  return r("patch was not valid JSON");
98
229
  }
99
- return { text: u, exact: !0 };
230
+ return { text: f, exact: !0 };
100
231
  }
101
- class fe {
232
+ class Ee {
102
233
  constructor(t) {
103
- q(this, "pos", 0);
234
+ Y(this, "pos", 0);
104
235
  this.text = t;
105
236
  }
106
237
  parseDocument() {
@@ -124,12 +255,12 @@ class fe {
124
255
  const n = this.pos;
125
256
  if (t === '"')
126
257
  return { kind: "scalar", start: n, end: this.stringEnd(), value: JSON.parse(this.slice(n)) };
127
- const i = /^(?:-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/.exec(
258
+ const s = /^(?:-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)/.exec(
128
259
  this.text.slice(n, n + 64)
129
260
  );
130
- if (!i)
261
+ if (!s)
131
262
  throw new Error(`Unexpected token at ${n}`);
132
- return this.pos = n + i[0].length, { kind: "scalar", start: n, end: this.pos, value: JSON.parse(i[0]) };
263
+ return this.pos = n + s[0].length, { kind: "scalar", start: n, end: this.pos, value: JSON.parse(s[0]) };
133
264
  }
134
265
  slice(t) {
135
266
  return this.text.slice(t, this.pos);
@@ -153,17 +284,17 @@ class fe {
153
284
  return { kind: "object", start: t, end: ++this.pos, members: n };
154
285
  for (; ; ) {
155
286
  this.ws();
156
- const i = this.pos;
287
+ const s = this.pos;
157
288
  if (this.text[this.pos] !== '"')
158
289
  throw new Error(`Expected a key at ${this.pos}`);
159
- const r = JSON.parse(this.text.slice(i, this.stringEnd()));
290
+ const r = JSON.parse(this.text.slice(s, this.stringEnd()));
160
291
  if (this.ws(), this.text[this.pos] !== ":")
161
292
  throw new Error(`Expected ':' at ${this.pos}`);
162
- this.pos++, n.push({ key: r, start: i, value: this.value() }), this.ws();
163
- const a = this.text[this.pos++];
164
- if (a === "}")
293
+ this.pos++, n.push({ key: r, start: s, value: this.value() }), this.ws();
294
+ const i = this.text[this.pos++];
295
+ if (i === "}")
165
296
  return { kind: "object", start: t, end: this.pos, members: n };
166
- if (a !== ",")
297
+ if (i !== ",")
167
298
  throw new Error(`Expected ',' or '}' at ${this.pos - 1}`);
168
299
  }
169
300
  }
@@ -173,277 +304,277 @@ class fe {
173
304
  return { kind: "array", start: t, end: ++this.pos, items: n };
174
305
  for (; ; ) {
175
306
  n.push(this.value()), this.ws();
176
- const i = this.text[this.pos++];
177
- if (i === "]")
307
+ const s = this.text[this.pos++];
308
+ if (s === "]")
178
309
  return { kind: "array", start: t, end: this.pos, items: n };
179
- if (i !== ",")
310
+ if (s !== ",")
180
311
  throw new Error(`Expected ',' or ']' at ${this.pos - 1}`);
181
312
  }
182
313
  }
183
314
  }
184
- function T(e) {
315
+ function R(e) {
185
316
  if (e.kind === "object") {
186
317
  const t = /* @__PURE__ */ new Set();
187
318
  for (const n of e.members) {
188
- if (t.has(n.key) || T(n.value))
319
+ if (t.has(n.key) || R(n.value))
189
320
  return !0;
190
321
  t.add(n.key);
191
322
  }
192
323
  } else if (e.kind === "array")
193
- return e.items.some(T);
324
+ return e.items.some(R);
194
325
  return !1;
195
326
  }
196
- function M(e) {
327
+ function F(e) {
197
328
  if (e.kind === "scalar")
198
329
  return e.value;
199
330
  if (e.kind === "array")
200
- return e.items.map(M);
331
+ return e.items.map(F);
201
332
  const t = {};
202
333
  for (const n of e.members)
203
- t[n.key] = M(n.value);
334
+ t[n.key] = F(n.value);
204
335
  return t;
205
336
  }
206
- function j(e, t, n) {
337
+ function A(e, t, n) {
207
338
  if (e === null || typeof e != "object")
208
339
  return e === void 0 ? "null" : JSON.stringify(e);
209
- const i = n + t.indent, r = t.colonSpace ? ": " : ":";
340
+ const s = n + t.indent, r = t.colonSpace ? ": " : ":";
210
341
  if (Array.isArray(e))
211
- return e.length === 0 ? "[]" : `[${t.eol}${e.map((c) => i + j(c, t, i)).join(`,${t.eol}`)}${t.eol}${n}]`;
212
- const a = Object.entries(e).filter(
213
- ([, c]) => c !== void 0
342
+ return e.length === 0 ? "[]" : `[${t.eol}${e.map((a) => s + A(a, t, s)).join(`,${t.eol}`)}${t.eol}${n}]`;
343
+ const i = Object.entries(e).filter(
344
+ ([, a]) => a !== void 0
214
345
  );
215
- return a.length === 0 ? "{}" : `{${t.eol}${a.map(([c, d]) => `${i}${JSON.stringify(c)}${r}${j(d, t, i)}`).join(`,${t.eol}`)}${t.eol}${n}}`;
346
+ return i.length === 0 ? "{}" : `{${t.eol}${i.map(([a, l]) => `${s}${JSON.stringify(a)}${r}${A(l, t, s)}`).join(`,${t.eol}`)}${t.eol}${n}}`;
216
347
  }
217
- function O(e, t, n = !1) {
348
+ function E(e, t, n = !1) {
218
349
  if (e === null || typeof e != "object")
219
350
  return e === void 0 ? "null" : JSON.stringify(e);
220
- const i = t.colonSpace ? ": " : ":", r = n ? "," : ", ";
351
+ const s = t.colonSpace ? ": " : ":", r = n ? "," : ", ";
221
352
  if (Array.isArray(e))
222
- return `[${e.map((d) => O(d, t, n)).join(r)}]`;
223
- const a = Object.entries(e).filter(
224
- ([, d]) => d !== void 0
225
- ), c = n ? "" : " ";
226
- return a.length === 0 ? "{}" : `{${c}${a.map(([d, u]) => `${JSON.stringify(d)}${i}${O(u, t, n)}`).join(r)}${c}}`;
227
- }
228
- const Y = (e) => e.compact ? "," : ", ";
229
- function ue(e, t) {
353
+ return `[${e.map((l) => E(l, t, n)).join(r)}]`;
354
+ const i = Object.entries(e).filter(
355
+ ([, l]) => l !== void 0
356
+ ), a = n ? "" : " ";
357
+ return i.length === 0 ? "{}" : `{${a}${i.map(([l, f]) => `${JSON.stringify(l)}${s}${E(f, t, n)}`).join(r)}${a}}`;
358
+ }
359
+ const ce = (e) => e.compact ? "," : ", ";
360
+ function Ke(e, t) {
230
361
  let n = e;
231
- for (const i of [...t].sort((r, a) => a.start - r.start))
232
- n = n.slice(0, i.start) + i.text + n.slice(i.end);
362
+ for (const s of [...t].sort((r, i) => i.start - r.start))
363
+ n = n.slice(0, s.start) + s.text + n.slice(s.end);
233
364
  return n;
234
365
  }
235
- function x(e, t) {
236
- var i;
366
+ function L(e, t) {
367
+ var s;
237
368
  const n = e.lastIndexOf(`
238
369
  `, t - 1) + 1;
239
- return ((i = /^[ \t]*/.exec(e.slice(n, t))) == null ? void 0 : i[0]) ?? "";
370
+ return ((s = /^[ \t]*/.exec(e.slice(n, t))) == null ? void 0 : s[0]) ?? "";
240
371
  }
241
- function Z(e, t) {
372
+ function le(e, t) {
242
373
  return !e.slice(t.start, t.end).includes(`
243
374
  `);
244
375
  }
245
- function V(e, t, n) {
246
- return e.compact ? !0 : t.kind === "scalar" || (t.kind === "object" ? t.members.length === 0 : t.items.length === 0) ? n : Z(e.text, t);
376
+ function Z(e, t, n) {
377
+ return e.compact ? !0 : t.kind === "scalar" || (t.kind === "object" ? t.members.length === 0 : t.items.length === 0) ? n : le(e.text, t);
247
378
  }
248
- function N(e, t, n, i) {
249
- const r = V(e, t, i);
379
+ function T(e, t, n, s) {
380
+ const r = Z(e, t, s);
250
381
  e.edits.push({
251
382
  start: t.start,
252
383
  end: t.end,
253
- text: r ? O(n, e.format, e.compact) : j(n, e.format, x(e.text, t.start))
384
+ text: r ? E(n, e.format, e.compact) : A(n, e.format, L(e.text, t.start))
254
385
  });
255
386
  }
256
- const Q = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
257
- function U(e, t, n, i, r) {
387
+ const de = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
388
+ function G(e, t, n, s, r) {
258
389
  if (t.kind === "scalar") {
259
390
  if (t.value === n)
260
391
  return;
261
- N(e, t, n, r);
392
+ T(e, t, n, r);
262
393
  return;
263
394
  }
264
- I(M(t), n) || (t.kind === "object" && Q(n) ? pe(e, t, n, i, r) : t.kind === "array" && Array.isArray(n) ? ye(e, t, n, i, r) : N(e, t, n, r));
395
+ C(F(t), n) || (t.kind === "object" && de(n) ? Ne(e, t, n, s, r) : t.kind === "array" && Array.isArray(n) ? Te(e, t, n, s, r) : T(e, t, n, r));
265
396
  }
266
- function ee(e, t, n) {
267
- return n !== void 0 ? x(e.text, n) : x(e.text, t.start) + e.format.indent;
397
+ function fe(e, t, n) {
398
+ return n !== void 0 ? L(e.text, n) : L(e.text, t.start) + e.format.indent;
268
399
  }
269
- function pe(e, t, n, i, r) {
270
- var l;
271
- const a = V(e, t, r), c = t.members.filter(
272
- (f) => Object.prototype.hasOwnProperty.call(n, f.key) && n[f.key] !== void 0
273
- ), d = Object.keys(n).filter(
274
- (f) => n[f] !== void 0 && !t.members.some((h) => h.key === f)
400
+ function Ne(e, t, n, s, r) {
401
+ var d;
402
+ const i = Z(e, t, r), a = t.members.filter(
403
+ (p) => Object.prototype.hasOwnProperty.call(n, p.key) && n[p.key] !== void 0
404
+ ), l = Object.keys(n).filter(
405
+ (p) => n[p] !== void 0 && !t.members.some((h) => h.key === p)
275
406
  );
276
- if (c.length === 0 && t.members.length > 0) {
277
- N(e, t, n, r);
407
+ if (a.length === 0 && t.members.length > 0) {
408
+ T(e, t, n, r);
278
409
  return;
279
410
  }
280
- for (const f of c)
281
- U(e, f.value, n[f.key], `${i}/${we(f.key)}`, a);
282
- if (te(
411
+ for (const p of a)
412
+ G(e, p.value, n[p.key], `${s}/${Le(p.key)}`, i);
413
+ if (pe(
283
414
  e,
284
- t.members.map((f) => ({ start: f.start, end: f.value.end })),
285
- t.members.map((f) => c.includes(f))
286
- ), d.length === 0)
415
+ t.members.map((p) => ({ start: p.start, end: p.value.end })),
416
+ t.members.map((p) => a.includes(p))
417
+ ), l.length === 0)
287
418
  return;
288
- const u = e.format.colonSpace ? ": " : ":";
289
- if (a) {
290
- const f = d.map(
291
- (h) => `${JSON.stringify(h)}${u}${O(n[h], e.format, e.compact)}`
419
+ const f = e.format.colonSpace ? ": " : ":";
420
+ if (i) {
421
+ const p = l.map(
422
+ (h) => `${JSON.stringify(h)}${f}${E(n[h], e.format, e.compact)}`
292
423
  );
293
- se(e, t, c.length > 0 ? c[c.length - 1].value.end : void 0, f);
424
+ me(e, t, a.length > 0 ? a[a.length - 1].value.end : void 0, p);
294
425
  return;
295
426
  }
296
- const s = ee(e, t, (l = t.members[0]) == null ? void 0 : l.start), o = d.map(
297
- (f) => `${s}${JSON.stringify(f)}${u}${j(n[f], e.format, s)}`
427
+ const o = fe(e, t, (d = t.members[0]) == null ? void 0 : d.start), c = l.map(
428
+ (p) => `${o}${JSON.stringify(p)}${f}${A(n[p], e.format, o)}`
298
429
  );
299
- ne(e, t, c.length > 0 ? c[c.length - 1].value.end : void 0, o);
430
+ ue(e, t, a.length > 0 ? a[a.length - 1].value.end : void 0, c);
300
431
  }
301
- const me = ["name", "id", "code", "key", "slug", "state", "Id"];
302
- function he(e, t, n, i) {
303
- var u, s;
304
- const r = [...n, ...i];
305
- if (r.length === 0 || !r.every(Q))
432
+ const Ie = ["name", "id", "code", "key", "slug", "state", "Id"];
433
+ function xe(e, t, n, s) {
434
+ var f, o;
435
+ const r = [...n, ...s];
436
+ if (r.length === 0 || !r.every(de))
306
437
  return;
307
- const a = (o, l) => {
308
- const f = o.map((h) => h[l]);
309
- return f.every((h) => typeof h == "string" || typeof h == "number") && new Set(f).size === f.length;
310
- }, c = (s = (u = e.options) == null ? void 0 : u.arrayKey) == null ? void 0 : s.call(u, t);
311
- return (c ? [c] : me).find((o) => a(n, o) && a(i, o));
438
+ const i = (c, d) => {
439
+ const p = c.map((h) => h[d]);
440
+ return p.every((h) => typeof h == "string" || typeof h == "number") && new Set(p).size === p.length;
441
+ }, a = (o = (f = e.options) == null ? void 0 : f.arrayKey) == null ? void 0 : o.call(f, t);
442
+ return (a ? [a] : Ie).find((c) => i(n, c) && i(s, c));
312
443
  }
313
- function ye(e, t, n, i, r) {
444
+ function Te(e, t, n, s, r) {
314
445
  var g;
315
- const a = V(e, t, r), c = t.items.map(M), d = he(e, i, c, n), u = (p) => p[d], s = d !== void 0 ? c.map((p) => {
316
- const m = u(p);
317
- return n.findIndex((b) => u(b) === m);
318
- }) : be(c, n);
446
+ const i = Z(e, t, r), a = t.items.map(F), l = xe(e, s, a, n), f = (u) => u[l], o = l !== void 0 ? a.map((u) => {
447
+ const m = f(u);
448
+ return n.findIndex((k) => f(k) === m);
449
+ }) : Fe(a, n);
319
450
  {
320
- const p = new Set(s.filter((m) => m >= 0));
321
- for (let m = 0; m < s.length; m++) {
322
- if (s[m] >= 0)
451
+ const u = new Set(o.filter((m) => m >= 0));
452
+ for (let m = 0; m < o.length; m++) {
453
+ if (o[m] >= 0)
323
454
  continue;
324
- let b = -1;
455
+ let k = -1;
325
456
  for (let y = m - 1; y >= 0; y--)
326
- if (s[y] >= 0) {
327
- b = s[y];
457
+ if (o[y] >= 0) {
458
+ k = o[y];
328
459
  break;
329
460
  }
330
- let v = n.length;
331
- for (let y = m + 1; y < s.length; y++)
332
- if (s[y] >= 0) {
333
- v = s[y];
461
+ let j = n.length;
462
+ for (let y = m + 1; y < o.length; y++)
463
+ if (o[y] >= 0) {
464
+ j = o[y];
334
465
  break;
335
466
  }
336
- for (let y = b + 1; y < v; y++)
337
- if (!p.has(y)) {
338
- s[m] = y, p.add(y);
467
+ for (let y = k + 1; y < j; y++)
468
+ if (!u.has(y)) {
469
+ o[m] = y, u.add(y);
339
470
  break;
340
471
  }
341
472
  }
342
473
  }
343
- const o = s.filter((p) => p >= 0);
344
- if (o.some((p, m) => m > 0 && p < o[m - 1])) {
345
- N(e, t, n, r);
474
+ const c = o.filter((u) => u >= 0);
475
+ if (c.some((u, m) => m > 0 && u < c[m - 1])) {
476
+ T(e, t, n, r);
346
477
  return;
347
478
  }
348
- if (o.length === 0 && t.items.length > 0) {
349
- N(e, t, n, r);
479
+ if (c.length === 0 && t.items.length > 0) {
480
+ T(e, t, n, r);
350
481
  return;
351
482
  }
352
- t.items.forEach((p, m) => {
353
- s[m] >= 0 && U(e, p, n[s[m]], `${i}/${s[m]}`, a);
354
- }), te(
483
+ t.items.forEach((u, m) => {
484
+ o[m] >= 0 && G(e, u, n[o[m]], `${s}/${o[m]}`, i);
485
+ }), pe(
355
486
  e,
356
- t.items.map((p) => ({ start: p.start, end: p.end })),
357
- s.map((p) => p >= 0)
487
+ t.items.map((u) => ({ start: u.start, end: u.end })),
488
+ o.map((u) => u >= 0)
358
489
  );
359
- const l = t.items.length > 0 && t.items.every((p) => p.kind !== "scalar" && Z(e.text, p)), f = ee(e, t, (g = t.items[0]) == null ? void 0 : g.start), h = /* @__PURE__ */ new Map();
360
- n.forEach((p, m) => {
361
- if (s.includes(m))
490
+ const d = t.items.length > 0 && t.items.every((u) => u.kind !== "scalar" && le(e.text, u)), p = fe(e, t, (g = t.items[0]) == null ? void 0 : g.start), h = /* @__PURE__ */ new Map();
491
+ n.forEach((u, m) => {
492
+ if (o.includes(m))
362
493
  return;
363
- let b;
364
- for (let $ = t.items.length - 1; $ >= 0; $--)
365
- if (s[$] >= 0 && s[$] < m) {
366
- b = $;
494
+ let k;
495
+ for (let O = t.items.length - 1; O >= 0; O--)
496
+ if (o[O] >= 0 && o[O] < m) {
497
+ k = O;
367
498
  break;
368
499
  }
369
- const v = a ? O(p, e.format, e.compact) : l ? `${f}${O(p, e.format)}` : `${f}${j(p, e.format, f)}`, y = h.get(b) ?? [];
370
- y.push(v), h.set(b, y);
500
+ const j = i ? E(u, e.format, e.compact) : d ? `${p}${E(u, e.format)}` : `${p}${A(u, e.format, p)}`, y = h.get(k) ?? [];
501
+ y.push(j), h.set(k, y);
371
502
  });
372
- for (const [p, m] of h) {
373
- const b = p === void 0 ? void 0 : t.items[p].end;
374
- if (p === void 0 && o.length > 0) {
375
- const v = t.items[s.findIndex(($) => $ >= 0)], y = a ? Y(e) : `,${e.format.eol}`;
503
+ for (const [u, m] of h) {
504
+ const k = u === void 0 ? void 0 : t.items[u].end;
505
+ if (u === void 0 && c.length > 0) {
506
+ const j = t.items[o.findIndex((O) => O >= 0)], y = i ? ce(e) : `,${e.format.eol}`;
376
507
  e.edits.push({
377
- start: v.start,
378
- end: v.start,
379
- text: a ? m.join(y) + y : m.join(y).trimStart() + y + f
508
+ start: j.start,
509
+ end: j.start,
510
+ text: i ? m.join(y) + y : m.join(y).trimStart() + y + p
380
511
  });
381
512
  continue;
382
513
  }
383
- a ? se(e, t, b, m) : ne(e, t, b, m);
514
+ i ? me(e, t, k, m) : ue(e, t, k, m);
384
515
  }
385
516
  }
386
- const ge = 4e6;
387
- function be(e, t) {
388
- const n = e.length, i = t.length;
389
- if (n * i > ge)
390
- return e.map((o, l) => l < i ? l : -1);
391
- const r = e.map((o) => JSON.stringify(o)), a = t.map((o) => JSON.stringify(o)), c = Array.from({ length: n + 1 }, () => new Uint32Array(i + 1));
392
- for (let o = n - 1; o >= 0; o--)
393
- for (let l = i - 1; l >= 0; l--)
394
- c[o][l] = r[o] === a[l] ? c[o + 1][l + 1] + 1 : Math.max(c[o + 1][l], c[o][l + 1]);
395
- const d = new Array(n).fill(-1);
396
- let u = 0, s = 0;
397
- for (; u < n && s < i; )
398
- r[u] === a[s] ? d[u++] = s++ : c[u + 1][s] >= c[u][s + 1] ? u++ : s++;
399
- return d;
400
- }
401
- function te(e, t, n) {
402
- for (let i = 0; i < t.length; i++) {
403
- if (n[i])
517
+ const Ce = 4e6;
518
+ function Fe(e, t) {
519
+ const n = e.length, s = t.length;
520
+ if (n * s > Ce)
521
+ return e.map((c, d) => d < s ? d : -1);
522
+ const r = e.map((c) => JSON.stringify(c)), i = t.map((c) => JSON.stringify(c)), a = Array.from({ length: n + 1 }, () => new Uint32Array(s + 1));
523
+ for (let c = n - 1; c >= 0; c--)
524
+ for (let d = s - 1; d >= 0; d--)
525
+ a[c][d] = r[c] === i[d] ? a[c + 1][d + 1] + 1 : Math.max(a[c + 1][d], a[c][d + 1]);
526
+ const l = new Array(n).fill(-1);
527
+ let f = 0, o = 0;
528
+ for (; f < n && o < s; )
529
+ r[f] === i[o] ? l[f++] = o++ : a[f + 1][o] >= a[f][o + 1] ? f++ : o++;
530
+ return l;
531
+ }
532
+ function pe(e, t, n) {
533
+ for (let s = 0; s < t.length; s++) {
534
+ if (n[s])
404
535
  continue;
405
- let r = i;
536
+ let r = s;
406
537
  for (; r + 1 < t.length && !n[r + 1]; )
407
538
  r++;
408
- r + 1 < t.length ? e.edits.push({ start: t[i].start, end: t[r + 1].start, text: "" }) : i > 0 ? e.edits.push({ start: t[i - 1].end, end: t[r].end, text: "" }) : e.edits.push({ start: t[i].start, end: t[r].end, text: "" }), i = r;
539
+ r + 1 < t.length ? e.edits.push({ start: t[s].start, end: t[r + 1].start, text: "" }) : s > 0 ? e.edits.push({ start: t[s - 1].end, end: t[r].end, text: "" }) : e.edits.push({ start: t[s].start, end: t[r].end, text: "" }), s = r;
409
540
  }
410
541
  }
411
- function ne(e, t, n, i) {
542
+ function ue(e, t, n, s) {
412
543
  const r = e.format.eol;
413
544
  if (n !== void 0) {
414
- e.edits.push({ start: n, end: n, text: `,${r}${i.join(`,${r}`)}` });
545
+ e.edits.push({ start: n, end: n, text: `,${r}${s.join(`,${r}`)}` });
415
546
  return;
416
547
  }
417
- const a = t.end - 1;
548
+ const i = t.end - 1;
418
549
  if ((t.kind === "object" ? t.members.length : t.items.length) === 0)
419
550
  e.edits.push({
420
551
  start: t.start + 1,
421
- end: a,
422
- text: `${r}${i.join(`,${r}`)}${r}${x(e.text, t.start)}`
552
+ end: i,
553
+ text: `${r}${s.join(`,${r}`)}${r}${L(e.text, t.start)}`
423
554
  });
424
555
  else {
425
- const d = t.kind === "object" ? t.members[0].start : t.items[0].start;
426
- e.edits.push({ start: d, end: d, text: `${i.join(`,${r}`).trimStart()}` });
556
+ const l = t.kind === "object" ? t.members[0].start : t.items[0].start;
557
+ e.edits.push({ start: l, end: l, text: `${s.join(`,${r}`).trimStart()}` });
427
558
  }
428
559
  }
429
- function se(e, t, n, i) {
430
- const r = Y(e);
560
+ function me(e, t, n, s) {
561
+ const r = ce(e);
431
562
  if (n !== void 0) {
432
- e.edits.push({ start: n, end: n, text: `${r}${i.join(r)}` });
563
+ e.edits.push({ start: n, end: n, text: `${r}${s.join(r)}` });
433
564
  return;
434
565
  }
435
- const a = t.kind === "object" && !e.compact ? " " : "";
566
+ const i = t.kind === "object" && !e.compact ? " " : "";
436
567
  e.edits.push({
437
568
  start: t.start + 1,
438
569
  end: t.end - 1,
439
- text: `${a}${i.join(r)}${a}`
570
+ text: `${i}${s.join(r)}${i}`
440
571
  });
441
572
  }
442
- function we(e) {
573
+ function Le(e) {
443
574
  return e.replace(/~/g, "~0").replace(/\//g, "~1");
444
575
  }
445
- const K = (e) => e.slice(e.lastIndexOf("/") + 1), ke = (e) => e.charCodeAt(0) === 65279 ? e.slice(1) : e;
446
- function R(e) {
576
+ const K = (e) => e.slice(e.lastIndexOf("/") + 1), Me = (e) => e.charCodeAt(0) === 65279 ? e.slice(1) : e;
577
+ function M(e) {
447
578
  return {
448
579
  id: e.id,
449
580
  label: e.label,
@@ -452,19 +583,19 @@ function R(e) {
452
583
  match: e.match,
453
584
  editor: e.editor,
454
585
  decode(t, n) {
455
- return e.select(E(t[0].text).value, n);
586
+ return e.select(x(t[0].text).value, n);
456
587
  },
457
- encode(t, n, i) {
458
- const r = n[0].text, a = E(r).value, c = e.assign(a, t, i);
588
+ encode(t, n, s) {
589
+ const r = n[0].text, i = x(r).value, a = e.assign(i, t, s);
459
590
  return {
460
591
  files: [
461
- { path: n[0].path, text: X(r, c, { arrayKey: e.arrayKey }) }
592
+ { path: n[0].path, text: ae(r, a, { arrayKey: e.arrayKey }) }
462
593
  ]
463
594
  };
464
595
  }
465
596
  };
466
597
  }
467
- const F = R({
598
+ const q = M({
468
599
  id: "json",
469
600
  label: "JSON",
470
601
  labelKey: "devStudio.kind.json",
@@ -473,7 +604,7 @@ const F = R({
473
604
  editor: "json",
474
605
  select: (e) => e,
475
606
  assign: (e, t) => t
476
- }), P = {
607
+ }), z = {
477
608
  id: "text",
478
609
  label: "Text",
479
610
  labelKey: "devStudio.kind.text",
@@ -482,20 +613,20 @@ const F = R({
482
613
  editor: "text",
483
614
  decode: (e) => e[0].text,
484
615
  encode: (e, t) => ({
485
- files: [{ path: t[0].path, text: le(e, t[0].text) }]
616
+ files: [{ path: t[0].path, text: Oe(e, t[0].text) }]
486
617
  })
487
618
  };
488
- function ve(e, t) {
489
- return e.find((n) => n.match(t)) ?? (F.match(t) ? F : P);
619
+ function Pe(e, t) {
620
+ return e.find((n) => n.match(t)) ?? (q.match(t) ? q : z);
490
621
  }
491
- function $e(e, t, n) {
492
- for (const i of [F, P])
493
- if (i.match(e.path))
622
+ function Je(e, t, n) {
623
+ for (const s of [q, z])
624
+ if (s.match(e.path))
494
625
  try {
495
- const r = i.decode([e], n);
626
+ const r = s.decode([e], n);
496
627
  return {
497
- key: `${i.id}:${e.path}`,
498
- kind: i,
628
+ key: `${s.id}:${e.path}`,
629
+ kind: s,
499
630
  paths: [e.path],
500
631
  label: K(e.path),
501
632
  model: r,
@@ -505,64 +636,64 @@ function $e(e, t, n) {
505
636
  }
506
637
  return {
507
638
  key: `text:${e.path}`,
508
- kind: P,
639
+ kind: z,
509
640
  paths: [e.path],
510
641
  label: K(e.path),
511
642
  model: e.text,
512
643
  error: t
513
644
  };
514
645
  }
515
- function Se(e, t, n, i) {
516
- var d, u;
517
- const r = e.encode(t, n, i), a = new Map(n.map((s) => [s.path, s.text])), c = ((d = r.files.find((s) => a.get(s.path) !== s.text)) == null ? void 0 : d.path) ?? ((u = r.deleted) == null ? void 0 : u.find((s) => a.has(s)));
518
- if (c !== void 0)
519
- throw new Error(`${K(c)} would not be stored as it is`);
520
- }
521
- function Ce(e, t, n) {
522
- const i = /* @__PURE__ */ new Map();
523
- for (const a of t) {
524
- const c = ve(e, a.path), d = c.group ? c.group(a.path) : a.path, u = `${c.id}:${d}`, s = i.get(u) ?? { kind: c, group: d, files: [] };
525
- s.files.push(a), i.set(u, s);
646
+ function De(e, t, n, s) {
647
+ var l, f;
648
+ const r = e.encode(t, n, s), i = new Map(n.map((o) => [o.path, o.text])), a = ((l = r.files.find((o) => i.get(o.path) !== o.text)) == null ? void 0 : l.path) ?? ((f = r.deleted) == null ? void 0 : f.find((o) => i.has(o)));
649
+ if (a !== void 0)
650
+ throw new Error(`${K(a)} would not be stored as it is`);
651
+ }
652
+ function vt(e, t, n) {
653
+ const s = /* @__PURE__ */ new Map();
654
+ for (const i of t) {
655
+ const a = Pe(e, i.path), l = a.group ? a.group(i.path) : i.path, f = `${a.id}:${l}`, o = s.get(f) ?? { kind: a, group: l, files: [] };
656
+ o.files.push(i), s.set(f, o);
526
657
  }
527
658
  const r = [];
528
- for (const [a, { kind: c, group: d, files: u }] of i) {
529
- const s = u.map((l) => l.path).sort(), o = K(c.group ? d : s[0]);
659
+ for (const [i, { kind: a, group: l, files: f }] of s) {
660
+ const o = f.map((d) => d.path).sort(), c = K(a.group ? l : o[0]);
530
661
  try {
531
- const l = c.decode(u, n);
532
- Se(c, l, u, n), r.push({ key: a, kind: c, paths: s, label: o, model: l });
533
- } catch (l) {
534
- const f = l instanceof Error ? l.message : String(l);
535
- for (const h of u)
536
- r.push($e(h, f, n));
662
+ const d = a.decode(f, n);
663
+ De(a, d, f, n), r.push({ key: i, kind: a, paths: o, label: c, model: d });
664
+ } catch (d) {
665
+ const p = d instanceof Error ? d.message : String(d);
666
+ for (const h of f)
667
+ r.push(Je(h, p, n));
537
668
  }
538
669
  }
539
- return r.sort((a, c) => a.label.localeCompare(c.label));
670
+ return r.sort((i, a) => i.label.localeCompare(a.label));
540
671
  }
541
- function Ve(e, t, n, i) {
542
- const r = n.filter((u) => e.paths.includes(u.path)), a = e.kind.encode(t, r, i), c = new Map(n.map((u) => [u.path, u])), d = [];
543
- for (const u of a.files) {
544
- const s = c.get(u.path);
545
- s && s.text === u.text || d.push({ type: "write", path: u.path, text: u.text, baseVersion: s == null ? void 0 : s.version });
672
+ function St(e, t, n, s) {
673
+ const r = n.filter((f) => e.paths.includes(f.path)), i = e.kind.encode(t, r, s), a = new Map(n.map((f) => [f.path, f])), l = [];
674
+ for (const f of i.files) {
675
+ const o = a.get(f.path);
676
+ o && o.text === f.text || l.push({ type: "write", path: f.path, text: f.text, baseVersion: o == null ? void 0 : o.version });
546
677
  }
547
- for (const u of a.deleted ?? []) {
548
- const s = c.get(u);
549
- s && d.push({ type: "delete", path: u, baseVersion: s.version });
678
+ for (const f of i.deleted ?? []) {
679
+ const o = a.get(f);
680
+ o && l.push({ type: "delete", path: f, baseVersion: o.version });
550
681
  }
551
- return d;
682
+ return l;
552
683
  }
553
- function je(e, t) {
684
+ function _e(e, t) {
554
685
  try {
555
- return JSON.parse(ke(e));
686
+ return JSON.parse(Me(e));
556
687
  } catch {
557
688
  return t;
558
689
  }
559
690
  }
560
- const w = (e) => typeof e == "object" && e !== null && !Array.isArray(e), S = (...e) => (t) => {
691
+ const w = (e) => typeof e == "object" && e !== null && !Array.isArray(e), $ = (...e) => (t) => {
561
692
  const n = t.toLowerCase();
562
- return e.some((i) => n.endsWith(i.toLowerCase()));
693
+ return e.some((s) => n.endsWith(s.toLowerCase()));
563
694
  };
564
- function J(e) {
565
- return R({
695
+ function P(e) {
696
+ return M({
566
697
  id: e.id,
567
698
  label: e.label,
568
699
  labelKey: e.labelKey,
@@ -579,123 +710,318 @@ function J(e) {
579
710
  arrayKey: e.itemKey ? () => e.itemKey : void 0
580
711
  });
581
712
  }
582
- function ie(e) {
583
- const t = J(e);
713
+ function he(e) {
714
+ const t = P(e);
584
715
  return {
585
716
  ...t,
586
- decode: (n, i) => t.decode(n, i).map((r, a) => e.toItem(r, a)),
587
- encode: (n, i, r) => t.encode(
588
- n.map((a) => e.fromItem(a)),
589
- i,
717
+ decode: (n, s) => t.decode(n, s).map((r, i) => e.toItem(r, i)),
718
+ encode: (n, s, r) => t.encode(
719
+ n.map((i) => e.fromItem(i)),
720
+ s,
590
721
  r
591
722
  )
592
723
  };
593
724
  }
594
- function re(e) {
595
- return R({
725
+ function ye(e) {
726
+ return M({
596
727
  ...e,
597
728
  select: (t) => w(t) ? t : {},
598
729
  assign: (t, n) => n
599
730
  });
600
731
  }
601
- const Oe = /^(.*)\.([a-z]{2,3}(?:-[A-Za-z]{2,4})?)\.i18n\.json$/i, Ke = (e) => {
602
- const t = Oe.exec(e);
732
+ const Ue = /^(.*)\.([a-z]{2,3}(?:-[A-Za-z]{2,4})?)\.i18n\.json$/i, Re = (e) => {
733
+ const t = Ue.exec(e);
603
734
  return t ? { group: t[1], locale: t[2] } : null;
604
- }, D = (e) => w(e) && Object.values(e).every((t) => typeof t == "string");
605
- function Ae(e) {
735
+ }, V = (e) => w(e) && Object.values(e).every((t) => typeof t == "string");
736
+ function qe(e) {
606
737
  if (w(e)) {
607
738
  for (const t of ["translations", "keys"])
608
739
  if (t in e) {
609
- if (D(e[t]))
740
+ if (V(e[t]))
610
741
  return e[t];
611
742
  throw new Error(`"${t}" is not a flat map of texts`);
612
743
  }
613
- if (D(e))
744
+ if (V(e))
614
745
  return e;
615
746
  }
616
747
  throw new Error("no translations in this file");
617
748
  }
618
- function z(e, t) {
619
- return w(e) ? w(e.translations) ? { ...e, translations: t } : w(e.keys) ? { ...e, keys: t } : D(e) ? t : { ...e, translations: t } : { translations: t };
749
+ function Q(e, t) {
750
+ return w(e) ? w(e.translations) ? { ...e, translations: t } : w(e.keys) ? { ...e, keys: t } : V(e) ? t : { ...e, translations: t } : { translations: t };
620
751
  }
621
- function Ee(e = {}) {
622
- const t = e.parse ?? Ke, n = e.pathFor ?? ((i, r) => `${i}.${r}.i18n.json`);
752
+ function ze(e = {}) {
753
+ const t = e.parse ?? Re, n = e.pathFor ?? ((s, r) => `${s}.${r}.i18n.json`);
623
754
  return {
624
755
  id: e.id ?? "i18n",
625
756
  label: e.label ?? "Translations",
626
757
  labelKey: e.labelKey ?? "devStudio.kind.i18n",
627
758
  icon: "globe",
628
759
  editor: "i18n",
629
- match: (i) => t(i) !== null,
630
- group: (i) => {
760
+ match: (s) => t(s) !== null,
761
+ group: (s) => {
631
762
  var r;
632
- return ((r = t(i)) == null ? void 0 : r.group) ?? i;
763
+ return ((r = t(s)) == null ? void 0 : r.group) ?? s;
633
764
  },
634
- decode(i) {
765
+ decode(s) {
635
766
  const r = {};
636
- for (const a of i) {
637
- const c = t(a.path);
638
- c && (r[c.locale] = { ...Ae(E(a.text).value) });
767
+ for (const i of s) {
768
+ const a = t(i.path);
769
+ a && (r[a.locale] = { ...qe(x(i.text).value) });
639
770
  }
640
771
  return r;
641
772
  },
642
- encode(i, r) {
643
- const a = /* @__PURE__ */ new Map();
644
- let c = "";
645
- for (const o of r) {
646
- const l = t(o.path);
647
- l && (a.set(l.locale, o), c = l.group);
773
+ encode(s, r) {
774
+ const i = /* @__PURE__ */ new Map();
775
+ let a = "";
776
+ for (const c of r) {
777
+ const d = t(c.path);
778
+ d && (i.set(d.locale, c), a = d.group);
648
779
  }
649
- const d = a.get("en") ?? r[0], u = [];
650
- for (const [o, l] of Object.entries(i)) {
651
- const f = a.get(o);
652
- if (f) {
653
- const g = E(f.text).value;
654
- u.push({
655
- path: f.path,
656
- text: X(f.text, z(g, l))
780
+ const l = i.get("en") ?? r[0], f = [];
781
+ for (const [c, d] of Object.entries(s)) {
782
+ const p = i.get(c);
783
+ if (p) {
784
+ const g = x(p.text).value;
785
+ f.push({
786
+ path: p.path,
787
+ text: ae(p.text, Q(g, d))
657
788
  });
658
789
  continue;
659
790
  }
660
- const h = n(c || K((d == null ? void 0 : d.path) ?? "module"), o);
661
- if (d) {
662
- const g = E(d.text).value, p = w(g) && "locale" in g ? { ...g, locale: o } : g;
663
- u.push({
791
+ const h = n(a || K((l == null ? void 0 : l.path) ?? "module"), c);
792
+ if (l) {
793
+ const g = x(l.text).value, u = w(g) && "locale" in g ? { ...g, locale: c } : g;
794
+ f.push({
664
795
  path: h,
665
- text: k(
666
- z(p, l),
667
- C(d.text)
796
+ text: v(
797
+ Q(u, d),
798
+ X(l.text)
668
799
  )
669
800
  });
670
801
  } else
671
- u.push({ path: h, text: k({ locale: o, translations: l }) });
802
+ f.push({ path: h, text: v({ locale: c, translations: d }) });
672
803
  }
673
- const s = [...a.entries()].filter(([o]) => !(o in i)).map(([, o]) => o.path);
674
- return { files: u, deleted: s };
804
+ const o = [...i.entries()].filter(([c]) => !(c in s)).map(([, c]) => c.path);
805
+ return { files: f, deleted: o };
675
806
  }
676
807
  };
677
808
  }
678
- const A = (e) => JSON.parse(JSON.stringify(e));
679
- function Ue(e) {
809
+ const S = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Ve = [
810
+ "frontend",
811
+ "backend",
812
+ "noCode",
813
+ "sql"
814
+ ], $t = [
815
+ "preInstall",
816
+ "postInstall",
817
+ "preUninstall",
818
+ "postUninstall"
819
+ ];
820
+ function We(e) {
821
+ switch (e) {
822
+ case "frontend":
823
+ return ["typescript", "javascript"];
824
+ case "backend":
825
+ return ["csharp", "javascript"];
826
+ case "sql":
827
+ return ["sql"];
828
+ case "noCode":
829
+ return [];
830
+ }
831
+ }
832
+ const Be = /* @__PURE__ */ new Set([
833
+ "read",
834
+ "filter",
835
+ "map",
836
+ "aggregate",
837
+ "set",
838
+ "if",
839
+ "forEach",
840
+ "write",
841
+ "callScript",
842
+ "return"
843
+ ]), ge = (e) => Array.isArray(e) && e.every((t) => S(t) && typeof t.id == "string" && Be.has(String(t.type)));
844
+ function W(e) {
845
+ if (Ve.includes(e.kind))
846
+ return e.kind;
847
+ if (e.source === void 0 && ge(e.steps))
848
+ return "noCode";
849
+ const t = typeof e.language == "string" ? e.language.toLowerCase() : "";
850
+ return t.endsWith("sql") || e.source === void 0 && typeof e.sql == "string" ? "sql" : /^(csharp|c#|cs\b)/.test(t) ? "backend" : "frontend";
851
+ }
852
+ const be = [
853
+ "id",
854
+ "displayName",
855
+ "description",
856
+ "language",
857
+ "category",
858
+ "trigger",
859
+ "returnType",
860
+ "source",
861
+ "sourcePath"
862
+ ], Xe = (e) => Array.isArray(e) && e.every((t) => S(t) && typeof t.name == "string");
863
+ function Ze(e, t) {
864
+ const n = `#${t + 1}`;
865
+ if (!S(e) || typeof e.name != "string" || !e.name) {
866
+ const l = S(e) && typeof e.displayName == "string" ? e.displayName : n;
867
+ return { key: `#${t}`, label: l, rawReason: "no name", source: e };
868
+ }
869
+ const s = e.name, r = typeof e.displayName == "string" && e.displayName ? e.displayName : s, i = (l) => ({
870
+ key: s,
871
+ label: r,
872
+ rawReason: l,
873
+ source: e
874
+ }), a = { name: s, kind: W(e) };
875
+ for (const l of be) {
876
+ const f = e[l];
877
+ if (f !== void 0) {
878
+ if (typeof f != "string")
879
+ return i(`"${l}" is not text`);
880
+ a[l] = f;
881
+ }
882
+ }
883
+ if (e.parameters !== void 0) {
884
+ if (!Xe(e.parameters))
885
+ return i('"parameters" is not a list of named parameters');
886
+ a.parameters = e.parameters;
887
+ }
888
+ if (a.kind === "noCode") {
889
+ if (e.steps !== void 0 && !ge(e.steps))
890
+ return i('"steps" are not no-code steps');
891
+ a.steps = e.steps ?? [];
892
+ }
893
+ return { key: s, label: r, definition: a, source: e };
894
+ }
895
+ function Ge(e) {
896
+ const t = e.definition;
897
+ if (!t)
898
+ return e.source;
899
+ const n = S(e.source) ? e.source : {}, s = { ...n, name: t.name };
900
+ for (const r of be)
901
+ t[r] === void 0 ? delete s[r] : s[r] = t[r];
902
+ return t.parameters === void 0 ? delete s.parameters : s.parameters = t.parameters, t.kind === "noCode" ? s.steps = t.steps ?? [] : W(n) === "noCode" && delete s.steps, delete s.kind, ("kind" in n || W(s) !== t.kind) && (s.kind = t.kind), s;
903
+ }
904
+ function D(e) {
905
+ const t = /* @__PURE__ */ new Set();
906
+ return e.map((n, s) => {
907
+ const r = Ze(n, s);
908
+ return t.has(r.key) && (r.key = `${r.key}#${s}`), t.add(r.key), r;
909
+ });
910
+ }
911
+ function ee(e, t) {
912
+ if (!S(e) || !Object.values(e).every((n) => Array.isArray(n) && n.every((s) => typeof s == "string")))
913
+ throw new Error(`"${t}" is not lists of SQL statements per phase`);
914
+ return e;
915
+ }
916
+ function He(e) {
917
+ const t = e.property ?? "scripts", n = e.phasesProperty ?? "phases", s = t === n, r = (i) => i.scripts.map(Ge);
918
+ return M({
919
+ id: e.id ?? "scripts",
920
+ label: e.label ?? "Scripts",
921
+ labelKey: e.labelKey ?? "devStudio.kind.scripts",
922
+ icon: e.icon ?? "code",
923
+ editor: "scriptList",
924
+ match: e.match,
925
+ select: (i) => {
926
+ if (Array.isArray(i))
927
+ return { scripts: D(i), ...s ? { holds: "scripts" } : {} };
928
+ if (!S(i) || i[t] === void 0 && i[n] === void 0)
929
+ throw new Error(`no "${t}" in this file`);
930
+ const a = i[t];
931
+ if (s)
932
+ return Array.isArray(a) ? { scripts: D(a), holds: "scripts" } : { scripts: [], phases: ee(a, t), holds: "phases" };
933
+ if (a !== void 0 && !Array.isArray(a))
934
+ throw new Error(`"${t}" is not a list`);
935
+ const l = i[n];
936
+ return {
937
+ scripts: D(a ?? []),
938
+ ...l !== void 0 ? { phases: ee(l, n) } : {}
939
+ };
940
+ },
941
+ assign: (i, a) => {
942
+ if (a.holds === "phases" && a.scripts.length > 0)
943
+ throw new Error("This file holds database scripts only; add scripts to another file.");
944
+ if (Array.isArray(i) && a.phases === void 0)
945
+ return r(a);
946
+ const l = S(i) ? i : {};
947
+ if (s)
948
+ return {
949
+ ...l,
950
+ [t]: a.holds === "phases" ? a.phases ?? {} : r(a)
951
+ };
952
+ const f = { ...l };
953
+ return (t in l || a.scripts.length > 0) && (f[t] = r(a)), a.phases === void 0 ? delete f[n] : f[n] = a.phases, f;
954
+ },
955
+ arrayKey: (i) => i === `/${t}` ? "name" : void 0
956
+ });
957
+ }
958
+ function Ye(e) {
959
+ const n = e.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").split(/[^A-Za-z0-9]+/).filter(Boolean).map((s, r) => r === 0 ? s[0].toLowerCase() + s.slice(1) : s[0].toUpperCase() + s.slice(1)).join("");
960
+ return /^[A-Za-z_]/.test(n) ? n : `script${n}`;
961
+ }
962
+ function jt(e) {
963
+ const t = Ye(e.name), n = e.language ?? We(e.kind)[0], s = {
964
+ name: t,
965
+ kind: e.kind,
966
+ ...e.name !== t ? { displayName: e.name } : {},
967
+ ...n ? { language: n } : {},
968
+ ...e.category ? { category: e.category } : {},
969
+ ...e.trigger ? { trigger: e.trigger } : {},
970
+ parameters: []
971
+ }, r = t[0].toUpperCase() + t.slice(1);
972
+ switch (e.kind) {
973
+ case "noCode":
974
+ return { ...s, steps: [] };
975
+ case "sql":
976
+ return { ...s, source: `-- ${e.name}
977
+ SELECT 1;
978
+ ` };
979
+ case "backend":
980
+ return {
981
+ ...s,
982
+ returnType: "object",
983
+ source: n === "csharp" ? `public static object ${r}(IDictionary<string, object> args)
984
+ {
985
+ return null;
986
+ }
987
+ ` : `function ${t}(args) {
988
+ return null;
989
+ }
990
+ `
991
+ };
992
+ case "frontend":
993
+ return {
994
+ ...s,
995
+ returnType: "void",
996
+ source: n === "typescript" ? `export function ${t}(): void {
997
+ }
998
+ ` : `export function ${t}() {
999
+ }
1000
+ `
1001
+ };
1002
+ }
1003
+ }
1004
+ const I = (e) => JSON.parse(JSON.stringify(e));
1005
+ function Ot(e) {
680
1006
  const t = e.revisions !== !1;
681
1007
  let n = 0;
682
- const i = e.workspaces.map((s) => ({
1008
+ const s = e.workspaces.map((o) => ({
683
1009
  meta: {
684
- id: s.id,
685
- label: s.label,
686
- description: s.description,
687
- icon: s.icon,
688
- readOnly: s.readOnly
1010
+ id: o.id,
1011
+ label: o.label,
1012
+ description: o.description,
1013
+ icon: o.icon,
1014
+ readOnly: o.readOnly
689
1015
  },
690
- packages: new Map((s.packages ?? []).map((o) => [o.id, { ...o, workspaceId: s.id }])),
1016
+ packages: new Map((o.packages ?? []).map((c) => [c.id, { ...c, workspaceId: o.id }])),
691
1017
  modules: new Map(
692
- s.modules.map((o) => [
693
- o.id,
1018
+ o.modules.map((c) => [
1019
+ c.id,
694
1020
  {
695
- ...o,
1021
+ ...c,
696
1022
  files: new Map(
697
- Object.entries(o.files).map(
698
- ([l, f]) => [l, { text: f, version: ++n }]
1023
+ Object.entries(c.files).map(
1024
+ ([d, p]) => [d, { text: p, version: ++n }]
699
1025
  )
700
1026
  ),
701
1027
  revisions: []
@@ -703,166 +1029,166 @@ function Ue(e) {
703
1029
  ])
704
1030
  )
705
1031
  }));
706
- let r = (e.templates ?? []).map((s) => A(s));
707
- const a = (s) => {
708
- const o = i.find((l) => l.meta.id === s);
709
- if (!o)
710
- throw new Error(`Unknown workspace "${s}"`);
711
- return o;
712
- }, c = (s) => {
713
- const o = a(s.workspaceId).modules.get(s.id);
714
- if (!o)
715
- throw new Error(`Unknown module "${s.id}"`);
716
- return o;
717
- }, d = (s, o) => ({
718
- workspaceId: s,
719
- id: o.id,
720
- packageId: o.packageId,
721
- label: o.label ?? o.id,
722
- description: o.description,
723
- icon: o.icon,
724
- version: o.version,
725
- readOnly: o.readOnly || a(s).meta.readOnly,
726
- files: [...o.files.keys()].sort()
727
- }), u = (s, o) => ({
728
- path: s,
729
- text: o.text,
730
- version: String(o.version)
1032
+ let r = (e.templates ?? []).map((o) => I(o));
1033
+ const i = (o) => {
1034
+ const c = s.find((d) => d.meta.id === o);
1035
+ if (!c)
1036
+ throw new Error(`Unknown workspace "${o}"`);
1037
+ return c;
1038
+ }, a = (o) => {
1039
+ const c = i(o.workspaceId).modules.get(o.id);
1040
+ if (!c)
1041
+ throw new Error(`Unknown module "${o.id}"`);
1042
+ return c;
1043
+ }, l = (o, c) => ({
1044
+ workspaceId: o,
1045
+ id: c.id,
1046
+ packageId: c.packageId,
1047
+ label: c.label ?? c.id,
1048
+ description: c.description,
1049
+ icon: c.icon,
1050
+ version: c.version,
1051
+ readOnly: c.readOnly || i(o).meta.readOnly,
1052
+ files: [...c.files.keys()].sort()
1053
+ }), f = (o, c) => ({
1054
+ path: o,
1055
+ text: c.text,
1056
+ version: String(c.version)
731
1057
  });
732
1058
  return {
733
1059
  async listWorkspaces() {
734
- return i.map((s) => ({ ...s.meta }));
1060
+ return s.map((o) => ({ ...o.meta }));
735
1061
  },
736
- async listModules(s) {
737
- return [...a(s).modules.values()].map((l) => d(s, l));
1062
+ async listModules(o) {
1063
+ return [...i(o).modules.values()].map((d) => l(o, d));
738
1064
  },
739
- async listPackages(s) {
740
- const o = a(s), l = [...o.packages.values()], f = [...new Set([...o.modules.values()].map((h) => h.packageId).filter(Boolean))].filter((h) => !o.packages.has(h)).map((h) => ({ id: h, workspaceId: s, label: h, derived: !0 }));
741
- return [...l, ...f];
1065
+ async listPackages(o) {
1066
+ const c = i(o), d = [...c.packages.values()], p = [...new Set([...c.modules.values()].map((h) => h.packageId).filter(Boolean))].filter((h) => !c.packages.has(h)).map((h) => ({ id: h, workspaceId: o, label: h, derived: !0 }));
1067
+ return [...d, ...p];
742
1068
  },
743
- async readModule(s) {
744
- return [...c(s).files.entries()].map(([l, f]) => u(l, f));
1069
+ async readModule(o) {
1070
+ return [...a(o).files.entries()].map(([d, p]) => f(d, p));
745
1071
  },
746
- async writeModule(s, o) {
747
- const l = c(s);
748
- if (l.readOnly || a(s.workspaceId).meta.readOnly)
749
- throw new Error(`Module "${s.id}" is read-only`);
750
- const f = o.filter((p) => p.baseVersion !== void 0).filter((p) => {
751
- const m = l.files.get(p.path);
752
- return m ? String(m.version) !== p.baseVersion : !1;
753
- }).map((p) => {
1072
+ async writeModule(o, c) {
1073
+ const d = a(o);
1074
+ if (d.readOnly || i(o.workspaceId).meta.readOnly)
1075
+ throw new Error(`Module "${o.id}" is read-only`);
1076
+ const p = c.filter((u) => u.baseVersion !== void 0).filter((u) => {
1077
+ const m = d.files.get(u.path);
1078
+ return m ? String(m.version) !== u.baseVersion : !1;
1079
+ }).map((u) => {
754
1080
  var m;
755
- return { path: p.path, currentVersion: String((m = l.files.get(p.path)) == null ? void 0 : m.version) };
1081
+ return { path: u.path, currentVersion: String((m = d.files.get(u.path)) == null ? void 0 : m.version) };
756
1082
  });
757
- if (f.length > 0)
758
- return { ok: !1, conflicts: f };
1083
+ if (p.length > 0)
1084
+ return { ok: !1, conflicts: p };
759
1085
  let h;
760
1086
  if (t) {
761
- const p = {};
762
- for (const [m, b] of l.files)
763
- p[m] = b.text;
764
- h = `r${++n}`, l.revisions.unshift({
1087
+ const u = {};
1088
+ for (const [m, k] of d.files)
1089
+ u[m] = k.text;
1090
+ h = `r${++n}`, d.revisions.unshift({
765
1091
  id: h,
766
1092
  timestamp: Date.now(),
767
1093
  label: h,
768
- summary: o.map((m) => `${m.type} ${m.path}`).join(", "),
769
- files: p
1094
+ summary: c.map((m) => `${m.type} ${m.path}`).join(", "),
1095
+ files: u
770
1096
  });
771
1097
  }
772
1098
  const g = {};
773
- for (const p of o)
774
- if (p.type === "delete")
775
- l.files.delete(p.path);
1099
+ for (const u of c)
1100
+ if (u.type === "delete")
1101
+ d.files.delete(u.path);
776
1102
  else {
777
1103
  const m = ++n;
778
- l.files.set(p.path, { text: p.text, version: m }), g[p.path] = String(m);
1104
+ d.files.set(u.path, { text: u.text, version: m }), g[u.path] = String(m);
779
1105
  }
780
1106
  return { ok: !0, versions: g, revision: h };
781
1107
  },
782
- async createModule(s) {
783
- const o = a(s.workspaceId);
784
- if (o.meta.readOnly)
785
- throw new Error(`Workspace "${s.workspaceId}" is read-only`);
786
- if (o.modules.has(s.id))
787
- throw new Error(`Module "${s.id}" already exists`);
788
- const l = {
789
- id: s.id,
790
- packageId: s.packageId,
1108
+ async createModule(o) {
1109
+ const c = i(o.workspaceId);
1110
+ if (c.meta.readOnly)
1111
+ throw new Error(`Workspace "${o.workspaceId}" is read-only`);
1112
+ if (c.modules.has(o.id))
1113
+ throw new Error(`Module "${o.id}" already exists`);
1114
+ const d = {
1115
+ id: o.id,
1116
+ packageId: o.packageId,
791
1117
  files: new Map(
792
- s.files.map((f) => [f.path, { text: f.text, version: ++n }])
1118
+ o.files.map((p) => [p.path, { text: p.text, version: ++n }])
793
1119
  ),
794
1120
  revisions: []
795
1121
  };
796
- return o.modules.set(s.id, l), d(s.workspaceId, l);
1122
+ return c.modules.set(o.id, d), l(o.workspaceId, d);
797
1123
  },
798
- async deleteModule(s) {
799
- const o = a(s.workspaceId);
800
- if (o.meta.readOnly)
801
- throw new Error(`Workspace "${s.workspaceId}" is read-only`);
802
- o.modules.delete(s.id);
1124
+ async deleteModule(o) {
1125
+ const c = i(o.workspaceId);
1126
+ if (c.meta.readOnly)
1127
+ throw new Error(`Workspace "${o.workspaceId}" is read-only`);
1128
+ c.modules.delete(o.id);
803
1129
  },
804
- async savePackage(s) {
805
- return a(s.workspaceId).packages.set(s.id, { ...s, derived: !1 }), { ...s, derived: !1 };
1130
+ async savePackage(o) {
1131
+ return i(o.workspaceId).packages.set(o.id, { ...o, derived: !1 }), { ...o, derived: !1 };
806
1132
  },
807
- async deletePackage(s) {
808
- a(s.workspaceId).packages.delete(s.id);
1133
+ async deletePackage(o) {
1134
+ i(o.workspaceId).packages.delete(o.id);
809
1135
  },
810
1136
  async listTemplates() {
811
- return r.map((s) => A(s));
1137
+ return r.map((o) => I(o));
812
1138
  },
813
- async saveTemplate(s, o) {
814
- const l = (o == null ? void 0 : o.previousId) ?? s.id, f = A(s), h = r.findIndex((g) => g.id === l);
815
- return r = h >= 0 ? r.map((g, p) => p === h ? f : g) : [...r, f], A(f);
1139
+ async saveTemplate(o, c) {
1140
+ const d = (c == null ? void 0 : c.previousId) ?? o.id, p = I(o), h = r.findIndex((g) => g.id === d);
1141
+ return r = h >= 0 ? r.map((g, u) => u === h ? p : g) : [...r, p], I(p);
816
1142
  },
817
- async deleteTemplate(s) {
818
- r = r.filter((o) => o.id !== s);
1143
+ async deleteTemplate(o) {
1144
+ r = r.filter((c) => c.id !== o);
819
1145
  },
820
- async listRevisions(s, o) {
821
- return c(s).revisions.filter((l) => !o || o in l.files).map(({ files: l, ...f }) => ({ ...f, ...o ? { path: o } : {} }));
1146
+ async listRevisions(o, c) {
1147
+ return a(o).revisions.filter((d) => !c || c in d.files).map(({ files: d, ...p }) => ({ ...p, ...c ? { path: c } : {} }));
822
1148
  },
823
- async readRevision(s, o, l) {
824
- const f = c(s).revisions.find((h) => h.id === o);
825
- if (!f)
826
- throw new Error(`Unknown revision "${o}"`);
827
- return l ? f.files[l] ?? "" : JSON.stringify(f.files, null, 2);
1149
+ async readRevision(o, c, d) {
1150
+ const p = a(o).revisions.find((h) => h.id === c);
1151
+ if (!p)
1152
+ throw new Error(`Unknown revision "${c}"`);
1153
+ return d ? p.files[d] ?? "" : JSON.stringify(p.files, null, 2);
828
1154
  },
829
- async rollback(s, o, l) {
830
- const f = c(s), h = f.revisions.find((p) => p.id === o);
1155
+ async rollback(o, c, d) {
1156
+ const p = a(o), h = p.revisions.find((u) => u.id === c);
831
1157
  if (!h)
832
- throw new Error(`Unknown revision "${o}"`);
833
- const g = l ? { [l]: h.files[l] } : h.files;
834
- if (!l)
835
- for (const p of [...f.files.keys()])
836
- p in g || f.files.delete(p);
837
- for (const [p, m] of Object.entries(g))
838
- m !== void 0 && f.files.set(p, { text: m, version: ++n });
1158
+ throw new Error(`Unknown revision "${c}"`);
1159
+ const g = d ? { [d]: h.files[d] } : h.files;
1160
+ if (!d)
1161
+ for (const u of [...p.files.keys()])
1162
+ u in g || p.files.delete(u);
1163
+ for (const [u, m] of Object.entries(g))
1164
+ m !== void 0 && p.files.set(u, { text: m, version: ++n });
839
1165
  },
840
1166
  snapshot() {
841
1167
  return {
842
- workspaces: i.map((s) => ({
843
- ...s.meta,
844
- packages: [...s.packages.values()].map(({ workspaceId: o, ...l }) => l),
845
- modules: [...s.modules.values()].map((o) => ({
846
- id: o.id,
847
- packageId: o.packageId,
848
- label: o.label,
849
- description: o.description,
850
- icon: o.icon,
851
- version: o.version,
852
- readOnly: o.readOnly,
853
- files: Object.fromEntries([...o.files.entries()].map(([l, f]) => [l, f.text]))
1168
+ workspaces: s.map((o) => ({
1169
+ ...o.meta,
1170
+ packages: [...o.packages.values()].map(({ workspaceId: c, ...d }) => d),
1171
+ modules: [...o.modules.values()].map((c) => ({
1172
+ id: c.id,
1173
+ packageId: c.packageId,
1174
+ label: c.label,
1175
+ description: c.description,
1176
+ icon: c.icon,
1177
+ version: c.version,
1178
+ readOnly: c.readOnly,
1179
+ files: Object.fromEntries([...c.files.entries()].map(([d, p]) => [d, p.text]))
854
1180
  }))
855
1181
  })),
856
- templates: r.map((s) => A(s)),
1182
+ templates: r.map((o) => I(o)),
857
1183
  revisions: t
858
1184
  };
859
1185
  }
860
1186
  };
861
1187
  }
862
- function Re(e) {
1188
+ function At(e) {
863
1189
  return e;
864
1190
  }
865
- function L(e, t) {
1191
+ function B(e, t) {
866
1192
  if (!t || e === void 0 || e === null)
867
1193
  return !0;
868
1194
  if (t.enum && !t.enum.includes(e))
@@ -877,71 +1203,71 @@ function L(e, t) {
877
1203
  case "boolean":
878
1204
  return typeof e == "boolean";
879
1205
  case "array":
880
- return Array.isArray(e) && (!t.items || e.every((n) => L(n, t.items)));
1206
+ return Array.isArray(e) && (!t.items || e.every((n) => B(n, t.items)));
881
1207
  case "object": {
882
1208
  if (typeof e != "object" || Array.isArray(e))
883
1209
  return !1;
884
1210
  const n = t.properties;
885
- return !n || Object.entries(e).every(([i, r]) => i in n && L(r, n[i]));
1211
+ return !n || Object.entries(e).every(([s, r]) => s in n && B(r, n[s]));
886
1212
  }
887
1213
  default:
888
1214
  return !0;
889
1215
  }
890
1216
  }
891
- function _e(e, t) {
892
- var c;
893
- const n = (e.fields ?? []).map((d) => d.name), i = (c = e.schema) == null ? void 0 : c.properties;
894
- if (!e.schema || !i)
1217
+ function Et(e, t) {
1218
+ var a;
1219
+ const n = (e.fields ?? []).map((l) => l.name), s = (a = e.schema) == null ? void 0 : a.properties;
1220
+ if (!e.schema || !s)
895
1221
  return { section: e, keys: n };
896
- const r = Object.entries(i).filter(
897
- ([d, u]) => !(d in t) || L(t[d], u)
898
- ), a = r.map(([d]) => d);
1222
+ const r = Object.entries(s).filter(
1223
+ ([l, f]) => !(l in t) || B(t[l], f)
1224
+ ), i = r.map(([l]) => l);
899
1225
  return {
900
1226
  section: {
901
1227
  ...e,
902
1228
  schema: {
903
1229
  ...e.schema,
904
1230
  properties: Object.fromEntries(r),
905
- ...e.schema.required ? { required: e.schema.required.filter((d) => a.includes(d)) } : {}
1231
+ ...e.schema.required ? { required: e.schema.required.filter((l) => i.includes(l)) } : {}
906
1232
  }
907
1233
  },
908
- keys: [...a, ...n]
1234
+ keys: [...i, ...n]
909
1235
  };
910
1236
  }
911
- function qe(e) {
1237
+ function Kt(e) {
912
1238
  var n;
913
1239
  const t = /* @__PURE__ */ new Set();
914
- for (const i of e) {
915
- for (const r of Object.keys(((n = i.schema) == null ? void 0 : n.properties) ?? {}))
1240
+ for (const s of e) {
1241
+ for (const r of Object.keys(((n = s.schema) == null ? void 0 : n.properties) ?? {}))
916
1242
  t.add(r);
917
- for (const r of i.fields ?? [])
1243
+ for (const r of s.fields ?? [])
918
1244
  t.add(r.name);
919
1245
  }
920
1246
  return t;
921
1247
  }
922
- function ze(e) {
1248
+ function Nt(e) {
923
1249
  return e.map((t) => {
924
1250
  const n = t;
925
1251
  return {
926
1252
  name: String(n.tableName || n.name || "Entity"),
927
- columns: (Array.isArray(n.fields) ? n.fields : []).map((i) => ({
928
- name: String(i.name ?? ""),
1253
+ columns: (Array.isArray(n.fields) ? n.fields : []).map((s) => ({
1254
+ name: String(s.name ?? ""),
929
1255
  // seeds spell the type both ways (OmniVerk: `dataType`, older files: `type`)
930
- dataType: String(i.dataType ?? i.type ?? "string"),
931
- isPrimaryKey: !!i.isPrimaryKey,
932
- isForeignKey: !!(i.isForeignKey ?? i.foreignKey)
1256
+ dataType: String(s.dataType ?? s.type ?? "string"),
1257
+ isPrimaryKey: !!s.isPrimaryKey,
1258
+ isForeignKey: !!(s.isForeignKey ?? s.foreignKey)
933
1259
  }))
934
1260
  };
935
1261
  });
936
1262
  }
937
- function Be(e) {
938
- const t = e.manifest ?? {}, n = String(t.displayName || t.packageName || "Module"), i = (e.views ?? []).map((a) => ({
939
- id: `view:${a.id}`,
940
- label: a.name,
1263
+ function It(e) {
1264
+ const t = e.manifest ?? {}, n = String(t.displayName || t.packageName || "Module"), s = (e.views ?? []).map((i) => ({
1265
+ id: `view:${i.id}`,
1266
+ label: i.name,
941
1267
  type: "view"
942
- })), r = (e.entities ?? []).map((a) => {
943
- const c = String(a.name ?? "Entity");
944
- return { id: `entity:${c}`, label: c, type: "entity" };
1268
+ })), r = (e.entities ?? []).map((i) => {
1269
+ const a = String(i.name ?? "Entity");
1270
+ return { id: `entity:${a}`, label: a, type: "entity" };
945
1271
  });
946
1272
  return {
947
1273
  roles: [
@@ -960,7 +1286,7 @@ function Be(e) {
960
1286
  label: n,
961
1287
  type: "module",
962
1288
  children: [
963
- ...i.length ? [{ id: "views", label: "Views", type: "group", children: i }] : [],
1289
+ ...s.length ? [{ id: "views", label: "Views", type: "group", children: s }] : [],
964
1290
  ...r.length ? [{ id: "entities", label: "Entities", type: "group", children: r }] : []
965
1291
  ]
966
1292
  }
@@ -968,111 +1294,114 @@ function Be(e) {
968
1294
  grants: {}
969
1295
  };
970
1296
  }
971
- const _ = re({
1297
+ const H = ye({
972
1298
  id: "manifest",
973
1299
  label: "Manifest",
974
1300
  labelKey: "devStudio.kind.manifest",
975
1301
  icon: "file",
976
1302
  editor: "manifest",
977
- match: S(".manifest.json")
978
- }), Ne = J({
1303
+ match: $(".manifest.json")
1304
+ }), Qe = P({
979
1305
  id: "entities",
980
1306
  label: "Entities",
981
1307
  labelKey: "devStudio.kind.entities",
982
1308
  icon: "database",
983
1309
  editor: "entities",
984
- match: S(".entities.json"),
1310
+ match: $(".entities.json"),
985
1311
  property: "entities",
986
1312
  itemKey: "name"
987
- }), Ie = Ee();
988
- function oe(e, t) {
989
- const n = e, i = typeof e == "object" && e !== null && typeof n.id == "string";
1313
+ }), et = ze();
1314
+ function ke(e, t) {
1315
+ const n = e, s = typeof e == "object" && e !== null && typeof n.id == "string";
990
1316
  return {
991
- key: i ? n.id : `#${t}`,
992
- label: i && n.name || (i ? n.id : `#${t + 1}`),
993
- ...i ? { definition: n } : { rawReason: "no id" },
1317
+ key: s ? n.id : `#${t}`,
1318
+ label: s && n.name || (s ? n.id : `#${t + 1}`),
1319
+ ...s ? { definition: n } : { rawReason: "no id" },
994
1320
  source: e
995
1321
  };
996
1322
  }
997
- const Me = ie({
1323
+ const tt = he({
998
1324
  id: "views",
999
1325
  label: "Views",
1000
1326
  labelKey: "devStudio.kind.views",
1001
1327
  icon: "grid",
1002
1328
  editor: "views",
1003
- match: S(".views.json"),
1329
+ match: $(".views.json"),
1004
1330
  property: "views",
1005
1331
  itemKey: "id",
1006
- toItem: (e, t) => oe(e, t),
1332
+ toItem: (e, t) => ke(e, t),
1007
1333
  fromItem: (e) => e.definition ?? e.source
1008
- }), xe = ie({
1334
+ }), nt = he({
1009
1335
  id: "workflows",
1010
1336
  label: "Workflows",
1011
1337
  labelKey: "devStudio.kind.workflows",
1012
1338
  icon: "git-branch",
1013
1339
  editor: "workflows",
1014
- match: S(".workflows.json"),
1340
+ match: $(".workflows.json"),
1015
1341
  property: "workflows",
1016
1342
  itemKey: "id",
1017
- toItem: (e, t) => oe(e, t),
1343
+ toItem: (e, t) => ke(e, t),
1018
1344
  fromItem: (e) => e.definition ?? e.source
1019
- }), Je = J({
1345
+ }), st = P({
1020
1346
  id: "dataSources",
1021
1347
  label: "Data sources",
1022
1348
  labelKey: "devStudio.kind.dataSources",
1023
1349
  icon: "database",
1024
1350
  editor: "dataSources",
1025
- match: S(".datasources.json"),
1351
+ match: $(".datasources.json"),
1026
1352
  property: "dataSources",
1027
1353
  itemKey: "key"
1028
- }), Te = re({
1354
+ }), rt = ye({
1029
1355
  id: "rbac",
1030
1356
  label: "Access",
1031
1357
  labelKey: "devStudio.kind.rbac",
1032
1358
  icon: "shield",
1033
1359
  editor: "rbac",
1034
- match: S(".rbac.json")
1035
- }), Fe = J({
1360
+ match: $(".rbac.json")
1361
+ }), it = P({
1036
1362
  id: "hooks",
1037
1363
  label: "Lifecycle hooks",
1038
1364
  labelKey: "devStudio.kind.hooks",
1039
1365
  icon: "zap",
1040
1366
  editor: "hooks",
1041
- match: S(".hooks.json"),
1367
+ match: $(".hooks.json"),
1042
1368
  property: "bindings",
1043
1369
  itemKey: "id"
1044
- }), Pe = [
1045
- _,
1046
- Ne,
1047
- Ie,
1048
- Me,
1049
- xe,
1050
- Je,
1051
- Te,
1052
- Fe
1370
+ }), ot = He({
1371
+ match: $(".scripts.json")
1372
+ }), at = [
1373
+ H,
1374
+ Qe,
1375
+ et,
1376
+ tt,
1377
+ nt,
1378
+ st,
1379
+ rt,
1380
+ it,
1381
+ ot
1053
1382
  ];
1054
- function B(e) {
1383
+ function te(e) {
1055
1384
  return e.normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/ł/g, "l").replace(/Ł/g, "L").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "module";
1056
1385
  }
1057
- const W = (e) => {
1058
- const t = e.find((n) => _.match(n.path));
1059
- return t ? je(t.text, void 0) : void 0;
1386
+ const ne = (e) => {
1387
+ const t = e.find((n) => H.match(n.path));
1388
+ return t ? _e(t.text, void 0) : void 0;
1060
1389
  };
1061
- function De(e) {
1062
- const t = e.find((n) => _.match(n.path));
1390
+ function ct(e) {
1391
+ const t = e.find((n) => H.match(n.path));
1063
1392
  return t ? K(t.path).replace(/\.manifest\.json$/i, "") : "module";
1064
1393
  }
1065
- const G = (e) => Array.isArray(e.fields) ? e.fields : [], We = {
1394
+ const se = (e) => Array.isArray(e.fields) ? e.fields : [], xt = {
1066
1395
  id: "native",
1067
- kinds: Pe,
1396
+ kinds: at,
1068
1397
  locales: ["en", "pl", "de", "fr", "es", "uk"],
1069
1398
  requiredLocales: ["en"],
1070
1399
  moduleId: (e) => {
1071
- const t = W(e), n = (t == null ? void 0 : t.id) ?? (t == null ? void 0 : t.packageName);
1400
+ const t = ne(e), n = (t == null ? void 0 : t.id) ?? (t == null ? void 0 : t.packageName);
1072
1401
  return typeof n == "string" ? n : void 0;
1073
1402
  },
1074
1403
  validateModule: ({ files: e }) => {
1075
- const t = W(e);
1404
+ const t = ne(e);
1076
1405
  return t ? ["id", "name", "version"].filter((n) => typeof t[n] != "string" || !t[n]).map((n) => ({
1077
1406
  severity: "error",
1078
1407
  code: "manifest.required",
@@ -1090,24 +1419,25 @@ const G = (e) => Array.isArray(e.fields) ? e.fields : [], We = {
1090
1419
  ];
1091
1420
  },
1092
1421
  newFile: (e, { files: t }) => {
1093
- const n = De(t), r = {
1422
+ const n = ct(t), r = {
1094
1423
  entities: ["entities.json", { entities: [] }],
1095
1424
  views: ["views.json", { views: [] }],
1096
1425
  workflows: ["workflows.json", { workflows: [] }],
1097
1426
  dataSources: ["datasources.json", { dataSources: [] }],
1098
1427
  rbac: ["rbac.json", { roles: [], actions: [], resources: [], grants: {} }],
1099
- hooks: ["hooks.json", { bindings: [] }]
1428
+ hooks: ["hooks.json", { bindings: [] }],
1429
+ scripts: ["scripts.json", { scripts: [] }]
1100
1430
  }[e];
1101
- return r ? { path: `${n}.${r[0]}`, text: k(r[1]) } : void 0;
1431
+ return r ? { path: `${n}.${r[0]}`, text: v(r[1]) } : void 0;
1102
1432
  },
1103
1433
  generateModule: async (e, { existingIds: t }) => {
1104
- let n = B(e.name);
1434
+ let n = te(e.name);
1105
1435
  for (let r = 2; t.has(n); r++)
1106
- n = `${B(e.name)}-${r}`;
1107
- const i = [
1436
+ n = `${te(e.name)}-${r}`;
1437
+ const s = [
1108
1438
  {
1109
1439
  path: `${n}.manifest.json`,
1110
- text: k({
1440
+ text: v({
1111
1441
  id: n,
1112
1442
  name: e.name,
1113
1443
  version: "1.0.0",
@@ -1116,31 +1446,31 @@ const G = (e) => Array.isArray(e.fields) ? e.fields : [], We = {
1116
1446
  ...e.packageId ? { category: e.packageId } : {}
1117
1447
  })
1118
1448
  },
1119
- { path: `${n}.entities.json`, text: k({ entities: e.entities }) }
1449
+ { path: `${n}.entities.json`, text: v({ entities: e.entities }) }
1120
1450
  ];
1121
1451
  for (const r of e.locales) {
1122
- const a = { "module.displayName": e.name };
1123
- for (const c of e.entities) {
1124
- const d = String(c.name ?? "");
1125
- a[`entity.${d}.displayName`] = d;
1126
- for (const u of G(c))
1127
- a[`field.${d}.${String(u.name)}.label`] = String(u.name);
1452
+ const i = { "module.displayName": e.name };
1453
+ for (const a of e.entities) {
1454
+ const l = String(a.name ?? "");
1455
+ i[`entity.${l}.displayName`] = l;
1456
+ for (const f of se(a))
1457
+ i[`field.${l}.${String(f.name)}.label`] = String(f.name);
1128
1458
  }
1129
- i.push({
1459
+ s.push({
1130
1460
  path: `${n}.${r}.i18n.json`,
1131
- text: k({ locale: r, translations: a })
1461
+ text: v({ locale: r, translations: i })
1132
1462
  });
1133
1463
  }
1134
1464
  if (e.views) {
1135
- const r = e.entities.map((a) => {
1136
- const c = String(a.name ?? "Item");
1465
+ const r = e.entities.map((i) => {
1466
+ const a = String(i.name ?? "Item");
1137
1467
  return {
1138
- id: `${c}List`,
1139
- name: `${c} list`,
1468
+ id: `${a}List`,
1469
+ name: `${a} list`,
1140
1470
  kind: "grid",
1141
1471
  version: 2,
1142
1472
  columns: 12,
1143
- dataSources: [{ key: "rows", type: "entity", entity: c, autoLoad: !0 }],
1473
+ dataSources: [{ key: "rows", type: "entity", entity: a, autoLoad: !0 }],
1144
1474
  rows: [
1145
1475
  {
1146
1476
  id: "r1",
@@ -1150,9 +1480,9 @@ const G = (e) => Array.isArray(e.fields) ? e.fields : [], We = {
1150
1480
  controlType: "dataGrid",
1151
1481
  colSpan: 12,
1152
1482
  props: {
1153
- columns: G(a).map((d) => ({
1154
- field: String(d.name),
1155
- header: String(d.name)
1483
+ columns: se(i).map((l) => ({
1484
+ field: String(l.name),
1485
+ header: String(l.name)
1156
1486
  }))
1157
1487
  },
1158
1488
  bindings: { data: { source: "rows", field: "" } }
@@ -1162,7 +1492,7 @@ const G = (e) => Array.isArray(e.fields) ? e.fields : [], We = {
1162
1492
  ]
1163
1493
  };
1164
1494
  });
1165
- i.push({ path: `${n}.views.json`, text: k({ views: r }) });
1495
+ s.push({ path: `${n}.views.json`, text: v({ views: r }) });
1166
1496
  }
1167
1497
  if (e.permissions) {
1168
1498
  const r = {
@@ -1176,58 +1506,81 @@ const G = (e) => Array.isArray(e.fields) ? e.fields : [], We = {
1176
1506
  { id: "edit", label: "Edit" },
1177
1507
  { id: "delete", label: "Delete" }
1178
1508
  ],
1179
- resources: e.entities.map((a) => ({
1180
- id: `entity:${String(a.name)}`,
1181
- label: String(a.name),
1509
+ resources: e.entities.map((i) => ({
1510
+ id: `entity:${String(i.name)}`,
1511
+ label: String(i.name),
1182
1512
  type: "entity"
1183
1513
  })),
1184
1514
  grants: {}
1185
1515
  };
1186
- i.push({ path: `${n}.rbac.json`, text: k(r) });
1516
+ s.push({ path: `${n}.rbac.json`, text: v(r) });
1187
1517
  }
1188
- return { id: n, packageId: e.packageId, files: i };
1518
+ return { id: n, packageId: e.packageId, files: s };
1189
1519
  }
1190
1520
  };
1191
1521
  export {
1192
- J as arrayFileKind,
1193
- Ce as buildDocuments,
1194
- Ue as createMemoryStudioProvider,
1195
- Re as defineManifestSection,
1196
- Be as deriveDefaultRbac,
1197
- C as detectJsonTextFormat,
1198
- Ve as encodeDocument,
1199
- S as endsWithAny,
1200
- ze as entitiesToSchemas,
1522
+ Ve as NICE_STUDIO_SCRIPT_KINDS,
1523
+ $t as NICE_STUDIO_SCRIPT_PHASES,
1524
+ yt as addStudioFolder,
1525
+ ht as addStudioSection,
1526
+ P as arrayFileKind,
1527
+ vt as buildDocuments,
1528
+ Ot as createMemoryStudioProvider,
1529
+ At as defineManifestSection,
1530
+ It as deriveDefaultRbac,
1531
+ X as detectJsonTextFormat,
1532
+ J as emptyStudioLayout,
1533
+ St as encodeDocument,
1534
+ $ as endsWithAny,
1535
+ Nt as entitiesToSchemas,
1201
1536
  K as fileName,
1202
- _e as fitManifestSection,
1203
- Ee as i18nFileKind,
1204
- ie as itemsFileKind,
1205
- F as jsonFallbackKind,
1206
- R as jsonFileKind,
1207
- L as jsonValueFitsSchema,
1208
- I as jsonValuesEqual,
1209
- le as keepTextFormat,
1210
- qe as manifestSectionKeys,
1211
- De as modulePrefix,
1212
- Je as nativeDataSourcesKind,
1213
- Ne as nativeEntitiesKind,
1214
- Pe as nativeFileKinds,
1215
- Fe as nativeHooksKind,
1216
- Ie as nativeI18nKind,
1217
- _ as nativeManifestKind,
1218
- Te as nativeRbacKind,
1219
- We as nativeStudioPreset,
1220
- Me as nativeViewsKind,
1221
- xe as nativeWorkflowsKind,
1222
- re as objectFileKind,
1223
- E as parseJsonText,
1224
- X as patchJsonText,
1225
- de as patchJsonTextDetailed,
1226
- Ae as readTranslations,
1227
- ve as resolveFileKind,
1228
- je as safeJson,
1229
- B as slugifyModuleId,
1230
- k as stringifyJsonText,
1231
- P as textFallbackKind,
1232
- z as writeTranslations
1537
+ Et as fitManifestSection,
1538
+ Ge as fromStudioScriptItem,
1539
+ ze as i18nFileKind,
1540
+ W as inferStudioScriptKind,
1541
+ ut as isEmptyStudioLayout,
1542
+ $e as isStudioLayoutPath,
1543
+ he as itemsFileKind,
1544
+ q as jsonFallbackKind,
1545
+ M as jsonFileKind,
1546
+ B as jsonValueFitsSchema,
1547
+ C as jsonValuesEqual,
1548
+ Oe as keepTextFormat,
1549
+ Kt as manifestSectionKeys,
1550
+ ct as modulePrefix,
1551
+ st as nativeDataSourcesKind,
1552
+ Qe as nativeEntitiesKind,
1553
+ at as nativeFileKinds,
1554
+ it as nativeHooksKind,
1555
+ et as nativeI18nKind,
1556
+ H as nativeManifestKind,
1557
+ rt as nativeRbacKind,
1558
+ ot as nativeScriptsKind,
1559
+ xt as nativeStudioPreset,
1560
+ tt as nativeViewsKind,
1561
+ nt as nativeWorkflowsKind,
1562
+ jt as newStudioScript,
1563
+ ye as objectFileKind,
1564
+ x as parseJsonText,
1565
+ pt as parseStudioLayout,
1566
+ ae as patchJsonText,
1567
+ Ae as patchJsonTextDetailed,
1568
+ kt as placeStudioEntry,
1569
+ qe as readTranslations,
1570
+ bt as removeStudioLayoutNode,
1571
+ wt as renameStudioEntryRef,
1572
+ gt as renameStudioLayoutNode,
1573
+ Pe as resolveFileKind,
1574
+ _e as safeJson,
1575
+ He as scriptsFileKind,
1576
+ mt as serializeStudioLayout,
1577
+ te as slugifyModuleId,
1578
+ v as stringifyJsonText,
1579
+ dt as studioEntryRef,
1580
+ ft as studioLayoutPath,
1581
+ Ye as studioScriptIdentifier,
1582
+ We as studioScriptLanguages,
1583
+ z as textFallbackKind,
1584
+ Ze as toStudioScriptItem,
1585
+ Q as writeTranslations
1233
1586
  };