@inpageedit/core 0.11.1 → 0.12.1

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 (95) hide show
  1. package/dist/ActionButton-CRjo_l3y.js +24 -0
  2. package/dist/ActionButton-CRjo_l3y.js.map +1 -0
  3. package/dist/{IconQuickEdit-CAL1HXIb.js → IconQuickEdit-CMCQncyj.js} +2 -2
  4. package/dist/{IconQuickEdit-CAL1HXIb.js.map → IconQuickEdit-CMCQncyj.js.map} +1 -1
  5. package/dist/InPageEdit.d.ts +5 -1
  6. package/dist/InputBox-nQKtiWtZ.js +30 -0
  7. package/dist/InputBox-nQKtiWtZ.js.map +1 -0
  8. package/dist/PluginPrefSync-Ziogy_o-.js +339 -0
  9. package/dist/PluginPrefSync-Ziogy_o-.js.map +1 -0
  10. package/dist/PluginStoreApp-Bnvyl-Oc.js +452 -0
  11. package/dist/PluginStoreApp-Bnvyl-Oc.js.map +1 -0
  12. package/dist/{RadioBox-nJqWsxW2.js → RadioBox-0UuxlcWZ.js} +2 -2
  13. package/dist/{RadioBox-nJqWsxW2.js.map → RadioBox-0UuxlcWZ.js.map} +1 -1
  14. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +10 -0
  15. package/dist/_plugin-vue_export-helper-CHgC5LLL.js.map +1 -0
  16. package/dist/components/index.js +50 -69
  17. package/dist/components/index.js.map +1 -1
  18. package/dist/constants/endpoints.d.ts +2 -1
  19. package/dist/{index-CfgnJ51A.js → index-B3FUDhxl.js} +53 -43
  20. package/dist/index-B3FUDhxl.js.map +1 -0
  21. package/dist/index-B3YJdjxo.js +361 -0
  22. package/dist/index-B3YJdjxo.js.map +1 -0
  23. package/dist/{index-BNDyaWnI.js → index-BRjEc8b8.js} +10 -9
  24. package/dist/index-BRjEc8b8.js.map +1 -0
  25. package/dist/index-Bd70aDMT.js +172 -0
  26. package/dist/index-Bd70aDMT.js.map +1 -0
  27. package/dist/index-BvuaLEFc.js +179 -0
  28. package/dist/index-BvuaLEFc.js.map +1 -0
  29. package/dist/{index-lZkYoUca.js → index-CG38LlAh.js} +2 -2
  30. package/dist/{index-lZkYoUca.js.map → index-CG38LlAh.js.map} +1 -1
  31. package/dist/{index-CvhkVj_L.js → index-CM_6yF2v.js} +3 -3
  32. package/dist/{index-CvhkVj_L.js.map → index-CM_6yF2v.js.map} +1 -1
  33. package/dist/{index-etJXONAj.js → index-Ccr3YhkP.js} +6 -6
  34. package/dist/index-Ccr3YhkP.js.map +1 -0
  35. package/dist/{index-U2RPZk8N.js → index-D5zX93bn.js} +43 -44
  36. package/dist/index-D5zX93bn.js.map +1 -0
  37. package/dist/{index-Bh70Udzi.js → index-DD5CVCfD.js} +2 -2
  38. package/dist/{index-Bh70Udzi.js.map → index-DD5CVCfD.js.map} +1 -1
  39. package/dist/{index-BUI2IX49.js → index-DgQNTfPR.js} +2314 -2316
  40. package/dist/index-DgQNTfPR.js.map +1 -0
  41. package/dist/{index-BQzuJxBO.js → index-Dnmv-xDn.js} +4 -4
  42. package/dist/index-Dnmv-xDn.js.map +1 -0
  43. package/dist/index-eARjMi7f.js +1168 -0
  44. package/dist/index-eARjMi7f.js.map +1 -0
  45. package/dist/{index-D5J7RU5I.js → index-zHTGCjfF.js} +5 -7
  46. package/dist/index-zHTGCjfF.js.map +1 -0
  47. package/dist/index.js +1 -1
  48. package/dist/models/MemoryStorage.d.ts +10 -0
  49. package/dist/models/WikiPage/index.d.ts +19 -1
  50. package/dist/plugins/in-article-links/index.d.ts +5 -0
  51. package/dist/plugins/plugin-store/index.d.ts +56 -0
  52. package/dist/plugins/plugin-store/schema.d.ts +41 -0
  53. package/dist/plugins/preferences-ui/PluginPrefSync.d.ts +1 -0
  54. package/dist/plugins/preferences-ui/index.d.ts +34 -5
  55. package/dist/plugins/quick-diff/index.d.ts +3 -0
  56. package/dist/plugins/quick-edit/index.d.ts +8 -0
  57. package/dist/plugins/quick-move/index.d.ts +5 -3
  58. package/dist/plugins/quick-preview/index.d.ts +4 -0
  59. package/dist/plugins/quick-redirect/index.d.ts +11 -4
  60. package/dist/plugins/toolbox/index.d.ts +3 -0
  61. package/dist/services/PreferencesService.d.ts +53 -11
  62. package/dist/services/ResourceLoaderService.d.ts +3 -0
  63. package/dist/services/WikiMetadataService.d.ts +1 -1
  64. package/dist/services/storage/index.d.ts +18 -8
  65. package/dist/services/storage/{IPEStorageManager.d.ts → managers/IDBStorageManager.d.ts} +9 -6
  66. package/dist/services/storage/managers/LocalStorageManager.d.ts +27 -0
  67. package/dist/style.css +1 -1
  68. package/dist/vueHooks-l04s8cIl.js +4064 -0
  69. package/dist/vueHooks-l04s8cIl.js.map +1 -0
  70. package/lib/index.umd.js +12 -112
  71. package/lib/index.umd.js.map +1 -1
  72. package/lib/style.css +1 -1
  73. package/package.json +14 -14
  74. package/dist/CheckBox-D3rHnX7I.js +0 -13
  75. package/dist/CheckBox-D3rHnX7I.js.map +0 -1
  76. package/dist/InputBox-BV4m05Xs.js +0 -22
  77. package/dist/InputBox-BV4m05Xs.js.map +0 -1
  78. package/dist/PluginPrefSync-COidewzp.js +0 -258
  79. package/dist/PluginPrefSync-COidewzp.js.map +0 -1
  80. package/dist/index-BNDyaWnI.js.map +0 -1
  81. package/dist/index-BQzuJxBO.js.map +0 -1
  82. package/dist/index-BUI2IX49.js.map +0 -1
  83. package/dist/index-CBszdxJJ.js +0 -159
  84. package/dist/index-CBszdxJJ.js.map +0 -1
  85. package/dist/index-CfgnJ51A.js.map +0 -1
  86. package/dist/index-Cx4qgCJK.js +0 -4914
  87. package/dist/index-Cx4qgCJK.js.map +0 -1
  88. package/dist/index-D5J7RU5I.js.map +0 -1
  89. package/dist/index-MhNAv9Vf.js +0 -302
  90. package/dist/index-MhNAv9Vf.js.map +0 -1
  91. package/dist/index-U2RPZk8N.js.map +0 -1
  92. package/dist/index-VnRKIVau.js +0 -167
  93. package/dist/index-VnRKIVau.js.map +0 -1
  94. package/dist/index-etJXONAj.js.map +0 -1
  95. package/dist/plugins/quick-delete/index.d.ts +0 -52
@@ -0,0 +1,1168 @@
1
+ import { j as _, P as Ae, F as Le } from "./index-CM_6yF2v.js";
2
+ import { S as Ie, B as Me, I as Pe } from "./index-DgQNTfPR.js";
3
+ import { a as re, m as te, u as ae, b as oe, e as D, o as Fe, f as le, g as je, w as J, n as U, h as M, i as De, j as Te, t as Re, k as He, s as Oe, r as H, l as z, p as qe, q as O, v as G, F as Ue, x as Be, y as Ve, z as ne, A as ze, B as se, c as Ge } from "./vueHooks-l04s8cIl.js";
4
+ import { n as Je } from "./noop-ClDc6zv4.js";
5
+ import { _ as We } from "./_plugin-vue_export-helper-CHgC5LLL.js";
6
+ const k = '@charset "UTF-8";:host{display:block;font-family:var(--schema-font-family, ui-sans-serif, system-ui, -apple-system);color:var(--schema-color-fg, #111827)}*,*:before,*:after{box-sizing:border-box}.wrapper{display:block;background:var(--schema-color-bg, #ffffff)}.form{display:grid;gap:12px}.field{display:grid;gap:6px;padding:8px 10px;border:1px solid var(--schema-color-muted, #e5e7eb);border-radius:var(--schema-radius, 10px);background:var(--schema-surface, #fff)}.label{font-size:12px;color:var(--schema-color-muted-text, #6b7280)}.input,select,textarea{width:100%;padding:8px 10px;border-radius:8px;border:1px solid var(--schema-color-muted, #e5e7eb);background:var(--schema-input-bg, #fff);color:inherit}.checkbox{display:inline-flex;align-items:center;gap:8px}.helper{font-size:12px;color:var(--schema-color-muted-text, #6b7280)}.row{display:grid;gap:8px}.actions{display:flex;gap:8px}.btn{padding:6px 10px;border:1px solid var(--schema-color-muted, #e5e7eb);background:var(--schema-btn-bg, #f8fafc);border-radius:8px;cursor:pointer}.btn.primary{background:var(--schema-color-primary, #2563eb);color:#fff;border-color:transparent}.btn:disabled{opacity:.5;cursor:not-allowed}.btn.danger{background:var(--schema-color-danger, #dc2626);color:#fff;border-color:transparent}.group{display:grid;gap:10px}.kv{display:grid;grid-template-columns:1fr 1fr auto;gap:8px;align-items:center}.badge{display:inline-flex;padding:2px 6px;border-radius:999px;font-size:11px;background:var(--schema-badge-bg, #eef2ff);color:var(--schema-badge-fg, #4f46e5)}.hidden{display:none!important}.toolbar{display:flex;gap:6px}.schema-collection-row{position:relative;transition:transform var(--schema-collection-transition-duration, .25s) var(--schema-collection-transition-ease, ease),opacity var(--schema-collection-transition-duration, .25s) var(--schema-collection-transition-ease, ease)}.schema-collection-row.enter{opacity:0}.schema-collection-row.enter.enter-active{opacity:1}.schema-collection-row.leaving{opacity:0}.field.schema-type-array .group,.field.schema-type-array .group .row{position:relative}', ce = {
7
+ arrayAdd: "+",
8
+ arrayMoveUp: "↑",
9
+ arrayMoveDown: "↓",
10
+ arrayRemove: "×",
11
+ dictAdd: "+",
12
+ dictRemove: "×",
13
+ rootLabel: "root"
14
+ }, b = (n, e) => {
15
+ customElements.get(n) || customElements.define(n, e);
16
+ }, Qe = (n, e, s) => {
17
+ if (!e.length) return;
18
+ let a = n, t = null, r = null;
19
+ for (let o = 0; o < e.length - 1; o++) {
20
+ const c = e[o];
21
+ let h = a?.[c];
22
+ h == null ? (h = typeof e[o + 1] == "number" ? [] : {}, a[c] = h) : typeof h != "object" && (h = typeof e[o + 1] == "number" ? [] : {}, a[c] = h), t = a, r = c, a = h;
23
+ }
24
+ const i = e[e.length - 1];
25
+ if (a == null || typeof a != "object") {
26
+ const o = typeof i == "number" ? [] : {};
27
+ if (t)
28
+ t[r] = o, a = o;
29
+ else
30
+ return;
31
+ }
32
+ try {
33
+ a[i] = s;
34
+ } catch {
35
+ try {
36
+ const o = Array.isArray(a) ? a.slice() : { ...a };
37
+ o[i] = s, t && (t[r] = o);
38
+ } catch {
39
+ }
40
+ }
41
+ }, R = (n) => n.map(String).join("."), Xe = (n) => n.replace(/[^a-zA-Z0-9_-]/g, "_"), L = (n) => `schema_${Xe(R(n) || "root")}`, F = (n) => R(n), p = (n, ...e) => {
42
+ const s = new Set(e);
43
+ s.size && n.setAttribute("part", Array.from(s).join(" "));
44
+ }, Ye = [
45
+ "wrapper",
46
+ "form",
47
+ "field",
48
+ "field-intersect",
49
+ "field-string",
50
+ "field-number",
51
+ "field-boolean",
52
+ "field-date",
53
+ "field-const",
54
+ "field-array",
55
+ "field-object",
56
+ "field-tuple",
57
+ "field-union",
58
+ "field-dict",
59
+ "field-label",
60
+ "field-helper",
61
+ "field-group",
62
+ "field-row",
63
+ "field-actions",
64
+ "field-button",
65
+ "field-button-primary",
66
+ "field-button-danger",
67
+ "field-button-secondary",
68
+ "field-toolbar",
69
+ "field-badge",
70
+ "field-input",
71
+ "field-input-text",
72
+ "field-input-number",
73
+ "field-input-date",
74
+ "field-input-select",
75
+ "field-input-textarea",
76
+ "field-input-checkbox",
77
+ "field-const-value",
78
+ "collection-row",
79
+ "field-checkbox",
80
+ "field-checkbox-text",
81
+ "field-toolbar-select"
82
+ ].join(" ");
83
+ function X(n, e) {
84
+ if (e == null) return e;
85
+ switch (n) {
86
+ case "number":
87
+ case "natural":
88
+ case "percent": {
89
+ if (e === "") return;
90
+ const s = Number(e);
91
+ return Number.isNaN(s) ? void 0 : s;
92
+ }
93
+ case "boolean":
94
+ return !!e;
95
+ case "date": {
96
+ if (!e) return;
97
+ const s = new Date(e);
98
+ return Number.isNaN(+s) ? void 0 : s;
99
+ }
100
+ case "const":
101
+ case "string":
102
+ default:
103
+ return e;
104
+ }
105
+ }
106
+ function ie(n) {
107
+ return typeof n == "function" && !!n?.type;
108
+ }
109
+ function de(n) {
110
+ if (!n) throw new Error("schema is required");
111
+ if (ie(n)) return n;
112
+ try {
113
+ const e = Schema.from(n);
114
+ if (ie(e)) return e;
115
+ } catch {
116
+ }
117
+ if (n?.type) {
118
+ const e = n.type;
119
+ if (Schema[e]) return Schema[e](n.inner ?? n.list ?? n.dict);
120
+ }
121
+ throw new Error("无法从传入对象生成 Schemastery 实例,请传入 schema 或 schema.toJSON() 的结果。");
122
+ }
123
+ function N(n) {
124
+ return n?.meta ?? {};
125
+ }
126
+ function Ze(n) {
127
+ return n.length > 0 && n.every((e) => e?.type === "const");
128
+ }
129
+ function j(n) {
130
+ if (!n) return;
131
+ const e = n, s = e.meta || {};
132
+ if (Object.prototype.hasOwnProperty.call(s, "default")) return s.default;
133
+ const a = e.type;
134
+ try {
135
+ const t = n();
136
+ if (t !== void 0) return t;
137
+ } catch {
138
+ }
139
+ switch (a) {
140
+ case "string":
141
+ return "";
142
+ case "number":
143
+ case "natural":
144
+ case "percent":
145
+ return 0;
146
+ case "boolean":
147
+ return !1;
148
+ case "array":
149
+ return [];
150
+ case "tuple":
151
+ return [];
152
+ case "object":
153
+ return {};
154
+ case "dict":
155
+ return {};
156
+ case "union": {
157
+ const t = e.list || [];
158
+ return t.length ? j(t[0]) : void 0;
159
+ }
160
+ case "const":
161
+ return e.value;
162
+ case "date":
163
+ return;
164
+ case "intersect": {
165
+ const t = e.list || [], r = (o, c) => {
166
+ if (Array.isArray(o) && Array.isArray(c)) return c.slice();
167
+ if (o && c && typeof o == "object" && typeof c == "object") {
168
+ const h = { ...o };
169
+ for (const l of Object.keys(c))
170
+ h[l] = l in h ? r(h[l], c[l]) : c[l];
171
+ return h;
172
+ }
173
+ return c ?? o;
174
+ };
175
+ let i = {};
176
+ for (const o of t) i = r(i, j(o));
177
+ return i;
178
+ }
179
+ default:
180
+ return;
181
+ }
182
+ }
183
+ class S extends HTMLElement {
184
+ constructor() {
185
+ super(), this._path = [], this._i18n = ce, this.$root = this.attachShadow({ mode: "open" });
186
+ const e = document.createElement("style");
187
+ e.textContent = k, this.$root.appendChild(e);
188
+ }
189
+ /** 初始化公共容器(带类名与 data-path) */
190
+ makeFieldContainer(e, s) {
191
+ const a = document.createElement("div");
192
+ if (a.className = `field schema-form-item schema-type-${e}`, a.setAttribute("data-path", R(this._path)), p(a, "field", `field-${e}`), this._label) {
193
+ const t = document.createElement("label");
194
+ t.className = "label", t.textContent = this._label, p(t, "field-label"), a.appendChild(t);
195
+ }
196
+ if (s && s !== this._label) {
197
+ const t = document.createElement("div");
198
+ t.className = "helper", t.textContent = s, p(t, "field-helper"), a.appendChild(t);
199
+ }
200
+ return a;
201
+ }
202
+ /** 外部设置 schema/path/label/value */
203
+ set schema(e) {
204
+ this._schema = de(e), this.render();
205
+ }
206
+ get schema() {
207
+ return this._schema;
208
+ }
209
+ set path(e) {
210
+ this._path = e ?? [], this.render();
211
+ }
212
+ get path() {
213
+ return this._path;
214
+ }
215
+ set label(e) {
216
+ this._label = e, this.render();
217
+ }
218
+ get label() {
219
+ return this._label;
220
+ }
221
+ set i18n(e) {
222
+ e && (this._i18n = { ...this._i18n, ...e }), this.render();
223
+ }
224
+ get i18n() {
225
+ return this._i18n;
226
+ }
227
+ setValue(e) {
228
+ this._value = e, this.render();
229
+ }
230
+ getValue() {
231
+ return this._value;
232
+ }
233
+ /** 触发变更事件(冒泡) */
234
+ emitChange(e) {
235
+ this._value = e, this.dispatchEvent(
236
+ new CustomEvent("change", {
237
+ bubbles: !0,
238
+ composed: !0,
239
+ detail: { path: this._path, value: e }
240
+ })
241
+ );
242
+ }
243
+ }
244
+ class ue extends S {
245
+ render() {
246
+ if (this.$input && this.$root.contains(this.$input)) {
247
+ const r = !!this.$root.querySelector("label.label");
248
+ if (!(this._label && !r)) {
249
+ const i = this._value ?? "";
250
+ this.$input.value !== i && document.activeElement !== this.$input && (this.$input.value = i);
251
+ return;
252
+ }
253
+ }
254
+ this.$root.innerHTML = `<style>${k}</style>`;
255
+ const e = N(this._schema), s = this.makeFieldContainer("string", e.description), a = document.createElement("input");
256
+ this.$input = a, a.className = "input", p(a, "field-input", "field-input-text"), a.type = "text", a.name = F(this._path), a.id = L(this._path), e?.pattern?.source && (a.pattern = e.pattern.source), e?.max != null && (a.maxLength = e.max), a.value = this._value ?? "", a.oninput = () => this.emitChange(X("string", a.value));
257
+ const t = s.querySelector("label.label");
258
+ t && (t.htmlFor = a.id), s.appendChild(a), this.$root.appendChild(s);
259
+ }
260
+ }
261
+ b("schema-form-string", ue);
262
+ class he extends S {
263
+ render() {
264
+ if (this.$input && this.$root.contains(this.$input)) {
265
+ const i = !!this.$root.querySelector("label.label");
266
+ if (!(this._label && !i)) {
267
+ const o = this._value ?? "";
268
+ this.$input.value !== String(o) && document.activeElement !== this.$input && (this.$input.value = o);
269
+ return;
270
+ }
271
+ }
272
+ this.$root.innerHTML = `<style>${k}</style>`;
273
+ const e = this._schema?.type ?? "number", s = N(this._schema), a = this.makeFieldContainer("number", s.description), t = document.createElement("input");
274
+ this.$input = t, t.className = "input", p(t, "field-input", "field-input-number"), t.name = F(this._path), t.id = L(this._path), s?.min != null && (t.min = String(s.min)), s?.max != null && (t.max = String(s.max)), s?.step != null && (t.step = String(s.step)), e === "percent" && !t.step && (t.step = "0.01"), t.value = this._value ?? "", t.oninput = () => this.emitChange(X(e, t.value));
275
+ const r = a.querySelector("label.label");
276
+ r && (r.htmlFor = t.id), s.role === "slider" ? t.type = "range" : t.type = "number", a.appendChild(t), this.$root.appendChild(a);
277
+ }
278
+ }
279
+ b("schema-form-number", he);
280
+ class me extends S {
281
+ render() {
282
+ this.$root.innerHTML = `<style>${k}</style>`;
283
+ const e = N(this._schema), s = this.makeFieldContainer("boolean", e.description), a = document.createElement("label");
284
+ a.className = "checkbox", p(a, "field-checkbox");
285
+ const t = document.createElement("input");
286
+ t.type = "checkbox", t.checked = !!this._value, t.name = F(this._path), t.id = L(this._path), p(t, "field-input", "field-input-checkbox");
287
+ const r = document.createElement("span");
288
+ r.textContent = e.description ?? this._label ?? "", p(r, "field-checkbox-text"), t.onchange = () => this.emitChange(t.checked);
289
+ const i = s.querySelector("label.label");
290
+ i && (i.htmlFor = t.id), a.append(t, r), s.appendChild(a), this.$root.appendChild(s);
291
+ }
292
+ }
293
+ b("schema-form-boolean", me);
294
+ function B(n) {
295
+ return String(n).padStart(2, "0");
296
+ }
297
+ function T(n) {
298
+ return `${n.getFullYear()}-${B(n.getMonth() + 1)}-${B(n.getDate())}`;
299
+ }
300
+ function W(n) {
301
+ return `${B(n.getHours())}:${B(n.getMinutes())}`;
302
+ }
303
+ function q(n) {
304
+ return `${T(n)}T${W(n)}`;
305
+ }
306
+ class pe extends S {
307
+ render() {
308
+ if (this.$input && this.$root.contains(this.$input)) {
309
+ const i = !!this.$root.querySelector("label.label");
310
+ if (!(this._label && !i)) {
311
+ const o = N(this._schema).role || "date";
312
+ if (document.activeElement !== this.$input)
313
+ if (this._value instanceof Date)
314
+ o === "date" ? this.$input.value = T(this._value) : o === "time" ? this.$input.value = W(this._value) : o === "datetime" && (this.$input.value = q(this._value));
315
+ else if (typeof this._value == "string" && o !== "time") {
316
+ const c = new Date(this._value);
317
+ isNaN(+c) || (o === "date" ? this.$input.value = T(c) : o === "datetime" && (this.$input.value = q(c)));
318
+ } else this._value || (this.$input.value = "");
319
+ return;
320
+ }
321
+ }
322
+ this.$root.innerHTML = `<style>${k}</style>`;
323
+ const e = N(this._schema), s = this.makeFieldContainer("date", e.description), a = document.createElement("input");
324
+ this.$input = a, a.className = "input", p(a, "field-input", "field-input-date");
325
+ const t = e.role || "date";
326
+ if (t === "datetime" ? a.type = "datetime-local" : t === "time" ? a.type = "time" : a.type = "date", a.name = F(this._path), a.id = L(this._path), this._value instanceof Date)
327
+ t === "date" ? a.value = T(this._value) : t === "time" ? a.value = W(this._value) : t === "datetime" && (a.value = q(this._value));
328
+ else if (typeof this._value == "string" && t !== "time") {
329
+ const i = new Date(this._value);
330
+ isNaN(+i) || (t === "date" ? a.value = T(i) : t === "datetime" && (a.value = q(i)));
331
+ }
332
+ a.oninput = () => {
333
+ e.role;
334
+ let i;
335
+ if (!a.value)
336
+ i = void 0;
337
+ else {
338
+ const o = new Date(a.value);
339
+ i = Number.isNaN(+o) ? void 0 : o;
340
+ }
341
+ this.emitChange(i);
342
+ };
343
+ const r = s.querySelector("label.label");
344
+ r && (r.htmlFor = a.id), s.appendChild(a), this.$root.appendChild(s);
345
+ }
346
+ }
347
+ b("schema-form-date", pe);
348
+ class Y extends S {
349
+ render() {
350
+ this.$root.innerHTML = `<style>${k}</style>`;
351
+ const e = N(this._schema), s = this._schema.value;
352
+ if (e.role === "raw-html") {
353
+ if (s instanceof Node) {
354
+ this.$root.append(s);
355
+ return;
356
+ } else if (typeof s == "function") {
357
+ this.$root.append(s());
358
+ return;
359
+ } else if (typeof s == "string") {
360
+ const i = document.createElement("div");
361
+ i.innerHTML = String(s), p(i, "field-const-value"), this.$root.appendChild(i);
362
+ return;
363
+ }
364
+ }
365
+ const a = this.makeFieldContainer("const", e.description), t = document.createElement("section");
366
+ t.className = "const content", t.textContent = String(s), t.id = L(this._path), p(t, "field-const-value");
367
+ const r = a.querySelector("label.label");
368
+ r && (r.htmlFor = t.id), a.appendChild(t), this.$root.appendChild(a);
369
+ }
370
+ }
371
+ b("schema-form-const", Y);
372
+ class fe extends S {
373
+ render() {
374
+ this.$root.innerHTML = `<style>${k}</style>`;
375
+ const e = N(this._schema), s = this.makeFieldContainer("intersect", e.description);
376
+ s.classList.remove("field");
377
+ const a = document.createElement("div");
378
+ a.classList.add("group"), p(a, "field-group");
379
+ const t = this._schema.list || [], r = t.length > 0 && t.every((o) => o?.type === "object"), i = (o, c) => {
380
+ if (Array.isArray(o) && Array.isArray(c)) return c.slice();
381
+ if (o && c && typeof o == "object" && typeof c == "object") {
382
+ const h = { ...o };
383
+ for (const l of Object.keys(c))
384
+ h[l] = l in h ? i(h[l], c[l]) : c[l];
385
+ return h;
386
+ }
387
+ return c ?? o;
388
+ };
389
+ if (r) {
390
+ const o = this._value && typeof this._value == "object" ? this._value : {};
391
+ t.forEach((c, h) => {
392
+ const l = c?.meta?.description ?? "", m = I(c, this._path, o, l, this._i18n);
393
+ m.addEventListener("change", (u) => {
394
+ u.stopPropagation();
395
+ const f = i(this._value ?? {}, u.detail.value);
396
+ this.emitChange(f);
397
+ }), a.appendChild(m);
398
+ });
399
+ } else {
400
+ const o = t[t.length - 1], c = I(o, this._path, this._value, this._label, this._i18n);
401
+ c.addEventListener("change", (h) => {
402
+ h.stopPropagation(), this.emitChange(h.detail.value);
403
+ }), a.appendChild(c);
404
+ }
405
+ s.appendChild(a), this.$root.appendChild(s);
406
+ }
407
+ }
408
+ b("schema-form-intersect", fe);
409
+ function Ke(n) {
410
+ switch (n.type) {
411
+ case "intersect":
412
+ return "schema-form-intersect";
413
+ case "string":
414
+ return "schema-form-string";
415
+ case "number":
416
+ case "natural":
417
+ case "percent":
418
+ return "schema-form-number";
419
+ case "boolean":
420
+ return "schema-form-boolean";
421
+ case "date":
422
+ return "schema-form-date";
423
+ case "const":
424
+ return "schema-form-const";
425
+ case "array":
426
+ return "schema-form-array";
427
+ case "object":
428
+ return "schema-form-object";
429
+ case "tuple":
430
+ return "schema-form-tuple";
431
+ case "dict":
432
+ return "schema-form-dict";
433
+ case "union": {
434
+ const e = n.list || [];
435
+ return e.length === 2 && e[0]?.type === "is" && e[0]?.constructor === Date && e[1]?.type === "transform" && (e[1]?.inner?.meta?.role === "datetime" || e[1]?.inner?.meta?.role === "date" || e[1]?.inner?.meta?.role === "time") ? "schema-form-date" : "schema-form-union";
436
+ }
437
+ default:
438
+ return "schema-form-string";
439
+ }
440
+ }
441
+ function I(n, e, s, a, t) {
442
+ const r = Ke(n), i = document.createElement(r);
443
+ return i.schema = n, i.path = e, i.label = a, t && (i.i18n = t), i.setValue?.(s), i.setAttribute("exportparts", Ye), i;
444
+ }
445
+ class ve extends S {
446
+ render() {
447
+ this.$root.innerHTML = `<style>${k}</style>`;
448
+ const e = N(this._schema), s = this.makeFieldContainer("union", e.description), a = this._schema.list || [];
449
+ if (Ze(a)) {
450
+ const t = document.createElement("select");
451
+ t.className = "input", p(t, "field-input", "field-input-select"), t.name = F(this._path), t.id = L(this._path), a.forEach((i) => {
452
+ const o = document.createElement("option");
453
+ o.value = String(i.value), o.textContent = String(i.meta?.description || i.value || i.type), this._value === i.value && (o.selected = !0), t.appendChild(o);
454
+ }), t.onchange = () => this.emitChange(X("string", t.value));
455
+ const r = s.querySelector("label.label");
456
+ r && (r.htmlFor = t.id), s.appendChild(t);
457
+ } else {
458
+ const t = document.createElement("div");
459
+ t.className = "toolbar", p(t, "field-toolbar");
460
+ const r = document.createElement("select");
461
+ r.className = "input", p(r, "field-input", "field-input-select", "field-toolbar-select"), r.name = F(this._path) + ".__type", r.id = L(this._path) + "__type";
462
+ let i = 0;
463
+ a.forEach((l, m) => {
464
+ const u = document.createElement("option");
465
+ u.value = String(m), u.textContent = String(l.meta?.description || l.value || l.type), r.appendChild(u);
466
+ }), r.onchange = () => {
467
+ i = Number(r.value);
468
+ const l = a[i], m = j(l);
469
+ this.emitChange(m), h();
470
+ };
471
+ const o = s.querySelector("label.label");
472
+ o && (o.htmlFor = r.id), t.appendChild(r), s.appendChild(t);
473
+ const c = document.createElement("div");
474
+ c.className = "group", p(c, "field-group");
475
+ const h = () => {
476
+ c.innerHTML = "";
477
+ const l = a[i], m = I(l, this._path, this._value, this._label);
478
+ m instanceof Y || (m.addEventListener("change", (u) => {
479
+ u.stopPropagation(), this.emitChange(u.detail.value);
480
+ }), c.appendChild(m));
481
+ };
482
+ h(), s.appendChild(c);
483
+ }
484
+ this.$root.appendChild(s);
485
+ }
486
+ }
487
+ b("schema-form-union", ve);
488
+ class ge extends S {
489
+ render() {
490
+ this.$root.innerHTML = `<style>${k}</style>`;
491
+ const e = N(this._schema), s = this.makeFieldContainer("tuple", e.description), a = document.createElement("div");
492
+ a.className = "group", p(a, "field-group");
493
+ const t = Array.isArray(this._value) ? this._value : [];
494
+ (this._schema.list || []).forEach((r, i) => {
495
+ const o = I(
496
+ r,
497
+ [...this._path, i],
498
+ t[i],
499
+ `${this._label ?? ""}[${i}]`
500
+ );
501
+ o.addEventListener("change", (c) => {
502
+ c.stopPropagation();
503
+ const h = Array.isArray(this._value) ? this._value.slice() : [];
504
+ h[i] = c.detail.value, this.emitChange(h);
505
+ }), a.appendChild(o);
506
+ }), s.appendChild(a), this.$root.appendChild(s);
507
+ }
508
+ }
509
+ b("schema-form-tuple", ge);
510
+ class _e extends S {
511
+ render() {
512
+ this.$root.innerHTML = `<style>${k}</style>`;
513
+ const e = N(this._schema), s = this.makeFieldContainer("object", e.description), a = document.createElement("div");
514
+ a.className = "group", p(a, "field-group");
515
+ const t = this._schema.dict || {};
516
+ Object.keys(t).forEach((r) => {
517
+ if (t[r]?.meta?.hidden) return;
518
+ const i = (this._value ?? {})[r], o = I(t[r], [...this._path, r], i, r);
519
+ o.addEventListener("change", (c) => {
520
+ c.stopPropagation();
521
+ const h = { ...this._value ?? {} };
522
+ h[r] = c.detail.value, this.emitChange(h);
523
+ }), a.appendChild(o);
524
+ }), s.appendChild(a), this.$root.appendChild(s);
525
+ }
526
+ }
527
+ b("schema-form-object", _e);
528
+ class V extends S {
529
+ constructor() {
530
+ super(...arguments), this._itemIds = [];
531
+ }
532
+ static {
533
+ this._idCounter = 0;
534
+ }
535
+ generateItemId() {
536
+ try {
537
+ if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
538
+ return crypto.randomUUID();
539
+ } catch {
540
+ }
541
+ return "i" + V._idCounter++;
542
+ }
543
+ ensureItemIds(e) {
544
+ for (; this._itemIds.length < e; ) this._itemIds.push(this.generateItemId());
545
+ this._itemIds.length > e && (this._itemIds.length = e);
546
+ }
547
+ // 采集当前行位置信息(用于 FLIP)
548
+ capturePositions(e) {
549
+ const s = {};
550
+ return e.querySelectorAll(".row").forEach((a) => {
551
+ const t = a.dataset.uid;
552
+ t && (s[t] = a.getBoundingClientRect());
553
+ }), s;
554
+ }
555
+ playFLIP(e, s) {
556
+ Array.from(e.querySelectorAll(".row")).forEach((a) => {
557
+ const t = a.dataset.uid;
558
+ if (!t) return;
559
+ const r = s[t];
560
+ if (!r) return;
561
+ const i = a.getBoundingClientRect(), o = r.left - i.left, c = r.top - i.top;
562
+ (o || c) && (a.style.transition = "none", a.style.transform = `translate(${o}px, ${c}px)`, requestAnimationFrame(() => {
563
+ a.style.transition = "transform .25s ease", a.style.transform = "";
564
+ }));
565
+ });
566
+ }
567
+ render() {
568
+ this.$root.innerHTML = `<style>${k}</style>`;
569
+ const e = N(this._schema), s = this.makeFieldContainer("array", e.description), a = document.createElement("div");
570
+ a.className = "group", p(a, "field-group");
571
+ const t = this._schema.inner, r = () => Array.isArray(this._value) ? this._value : [];
572
+ this.ensureItemIds(r().length);
573
+ const i = (h, l) => {
574
+ a.innerHTML = "", r().forEach((m, u) => {
575
+ const f = [...this._path, u], d = document.createElement("div");
576
+ d.className = "row schema-collection-row", p(d, "field-row", "collection-row");
577
+ const g = this._itemIds[u];
578
+ d.dataset.uid = g, d.setAttribute("data-path", R(f));
579
+ const v = I(
580
+ t,
581
+ f,
582
+ m,
583
+ `${this._label ?? ""}[${u}]`
584
+ );
585
+ v.addEventListener("change", (E) => {
586
+ E.stopPropagation();
587
+ const x = r().slice();
588
+ x[u] = E.detail.value, this._value = x, this.emitChange(x);
589
+ });
590
+ const C = document.createElement("div");
591
+ C.className = "actions", p(C, "field-actions");
592
+ const w = document.createElement("button");
593
+ w.type = "button", w.className = "btn", p(w, "field-button", "field-button-secondary"), w.textContent = this._i18n.arrayMoveUp ?? "↑", w.onclick = () => {
594
+ if (u <= 0) return;
595
+ const E = this.capturePositions(a), x = r().slice();
596
+ [x[u - 1], x[u]] = [x[u], x[u - 1]], [this._itemIds[u - 1], this._itemIds[u]] = [
597
+ this._itemIds[u],
598
+ this._itemIds[u - 1]
599
+ ], this._value = x, i(E), this.emitChange(x);
600
+ };
601
+ const $ = document.createElement("button");
602
+ $.type = "button", $.className = "btn", p($, "field-button", "field-button-secondary"), $.textContent = this._i18n.arrayMoveDown ?? "↓", $.onclick = () => {
603
+ const E = r();
604
+ if (u >= E.length - 1) return;
605
+ const x = this.capturePositions(a), A = E.slice();
606
+ [A[u + 1], A[u]] = [A[u], A[u + 1]], [this._itemIds[u + 1], this._itemIds[u]] = [
607
+ this._itemIds[u],
608
+ this._itemIds[u + 1]
609
+ ], this._value = A, i(x), this.emitChange(A);
610
+ };
611
+ const y = document.createElement("button");
612
+ y.type = "button", y.className = "btn danger", p(y, "field-button", "field-button-danger"), y.textContent = this._i18n.arrayRemove ?? "×", y.onclick = () => {
613
+ d.classList.add("leaving");
614
+ const E = 250;
615
+ let x = !1;
616
+ const A = () => {
617
+ if (x) return;
618
+ x = !0, clearTimeout(ke);
619
+ const ee = r().filter((xt, Se) => Se !== u);
620
+ this._itemIds.splice(u, 1);
621
+ const Ne = this.capturePositions(a);
622
+ this._value = ee, i(Ne), this.emitChange(ee);
623
+ };
624
+ d.addEventListener("transitionend", A, { once: !0 });
625
+ const ke = setTimeout(A, E + 80);
626
+ }, C.append(w, $, y), d.appendChild(v), d.appendChild(C), a.appendChild(d), l && l === g && (d.classList.add("enter"), requestAnimationFrame(() => {
627
+ d.classList.add("enter-active");
628
+ }), requestAnimationFrame(() => {
629
+ d.classList.remove("enter");
630
+ }));
631
+ }), h && this.playFLIP(a, h);
632
+ };
633
+ i();
634
+ const o = document.createElement("button");
635
+ o.type = "button", o.className = "btn primary", p(o, "field-button", "field-button-primary"), o.textContent = this._i18n.arrayAdd ?? "+", o.onclick = () => {
636
+ const h = this.capturePositions(a), l = r().slice(), m = j(t);
637
+ l.push(m);
638
+ const u = this.generateItemId();
639
+ this._itemIds.push(u), this._value = l, i(h, u), this.emitChange(l);
640
+ };
641
+ const c = document.createElement("div");
642
+ c.className = "actions", p(c, "field-actions"), c.appendChild(o), s.appendChild(a), s.appendChild(c), this.$root.appendChild(s);
643
+ }
644
+ }
645
+ b("schema-form-array", V);
646
+ class be extends S {
647
+ render() {
648
+ this.$root.innerHTML = `<style>${k}</style>`;
649
+ const e = N(this._schema), s = this.makeFieldContainer("dict", e.description), a = document.createElement("div");
650
+ a.className = "group", p(a, "field-group");
651
+ const t = this._schema.inner, r = this._value ?? {}, i = (u) => `d_${u}`, o = () => {
652
+ const u = {};
653
+ return a.querySelectorAll(".kv").forEach((f) => {
654
+ const d = f.dataset.uid;
655
+ d && (u[d] = f.getBoundingClientRect());
656
+ }), u;
657
+ }, c = (u) => {
658
+ a.querySelectorAll(".kv").forEach((f) => {
659
+ const d = f.dataset.uid;
660
+ if (!d) return;
661
+ const g = u[d];
662
+ if (!g) return;
663
+ const v = f.getBoundingClientRect(), C = g.left - v.left, w = g.top - v.top;
664
+ (C || w) && (f.style.transition = "none", f.style.transform = `translate(${C}px, ${w}px)`, requestAnimationFrame(() => {
665
+ f.style.transition = "transform .25s ease", f.style.transform = "";
666
+ }));
667
+ });
668
+ }, h = (u, f) => {
669
+ a.innerHTML = "", Object.keys(r).forEach((d) => {
670
+ const g = [...this._path, d], v = document.createElement("div");
671
+ v.className = "kv schema-collection-row", p(v, "field-row", "collection-row"), v.dataset.uid = i(d), v.setAttribute("data-path", R(g));
672
+ const C = document.createElement("input");
673
+ C.className = "input", p(C, "field-input", "field-input-text"), C.value = d, C.name = F(g) + ".__key", C.id = L(g) + "__key";
674
+ const w = I(t, g, r[d], `${this._label ?? ""}[${d}]`), $ = document.createElement("button");
675
+ $.type = "button", $.className = "btn danger", p($, "field-button", "field-button-danger"), $.textContent = this._i18n.dictRemove ?? "×", $.onclick = () => {
676
+ const y = o();
677
+ delete r[d];
678
+ const E = { ...this._value ?? {} };
679
+ delete E[d], this._value = E, h(y), this.emitChange(E);
680
+ }, C.onchange = () => {
681
+ const y = C.value.trim();
682
+ if (!y || y === d || r[y] !== void 0) return;
683
+ const E = o();
684
+ r[y] = r[d], delete r[d];
685
+ const x = { ...this._value ?? {} };
686
+ x[y] = x[d], delete x[d], this._value = x, h(E), this.emitChange(x);
687
+ }, w.addEventListener("change", (y) => {
688
+ y.stopPropagation();
689
+ const E = { ...this._value ?? {} };
690
+ E[d] = y.detail.value, this._value = E, this.emitChange(E);
691
+ }), v.append(C, w, $), a.appendChild(v), f === d && (v.classList.add("enter"), requestAnimationFrame(() => v.classList.add("enter-active")), requestAnimationFrame(() => v.classList.remove("enter")));
692
+ }), u && c(u);
693
+ };
694
+ h();
695
+ const l = document.createElement("button");
696
+ l.type = "button", l.className = "btn primary", p(l, "field-button", "field-button-primary"), l.textContent = this._i18n.dictAdd ?? "+", l.onclick = () => {
697
+ let u = Object.keys(r).length + 1, f = `k${u}`;
698
+ for (; r[f] !== void 0; ) f = `k${++u}`;
699
+ const d = o();
700
+ r[f] = j(t);
701
+ const g = { ...this._value ?? {}, [f]: r[f] };
702
+ this._value = g, h(d, f), this.emitChange(g);
703
+ };
704
+ const m = document.createElement("div");
705
+ m.className = "actions", p(m, "field-actions"), m.appendChild(l), s.appendChild(a), s.appendChild(m), this.$root.appendChild(s);
706
+ }
707
+ }
708
+ b("schema-form-dict", be);
709
+ class ye extends HTMLElement {
710
+ constructor() {
711
+ super(), this._i18n = { ...ce }, this._i18nCommitted = !1, this.$root = this.attachShadow({ mode: "open" });
712
+ const e = document.createElement("style");
713
+ e.textContent = k, this.$root.appendChild(e);
714
+ const s = document.createElement("div");
715
+ s.className = "wrapper", p(s, "wrapper");
716
+ const a = document.createElement("form");
717
+ a.className = "form", p(a, "form"), s.appendChild(a), this.$root.appendChild(s), this.addEventListener("change", (t) => {
718
+ if (!t?.detail) return;
719
+ const { path: r, value: i } = t.detail;
720
+ Array.isArray(r) && r.length === 0 ? this._state = i : Qe(this._state ?? (this._state = {}), r, i), this.dispatchEvent(
721
+ new CustomEvent("form-change", { detail: { path: r, value: i, state: this._state } })
722
+ );
723
+ });
724
+ }
725
+ // --- 对外 API ---
726
+ set schema(e) {
727
+ this._schema = de(e);
728
+ try {
729
+ this._state = this._schema(null, { autofix: !0 });
730
+ } catch {
731
+ this._state = j(this._schema);
732
+ }
733
+ this.render();
734
+ }
735
+ get schema() {
736
+ return this._schema;
737
+ }
738
+ set schemaJSON(e) {
739
+ this.schema = e;
740
+ }
741
+ get schemaJSON() {
742
+ return this._schema?.toJSON?.();
743
+ }
744
+ setData(e, s = { validate: !0, autofix: !0 }) {
745
+ if (!this._schema) throw new Error("请先设置 schema");
746
+ const a = s.validate ? this._schema(e ?? null, { autofix: s.autofix }) : e;
747
+ this._state = a, this.render();
748
+ }
749
+ getData(e = { validate: !0, autofix: !0 }) {
750
+ if (!this._schema) throw new Error("请先设置 schema");
751
+ const s = this._state;
752
+ return e.validate ? this._schema(s ?? null, { autofix: e.autofix }) : s;
753
+ }
754
+ reset() {
755
+ try {
756
+ this._state = this._schema(null, { autofix: !0 });
757
+ } catch {
758
+ this._state = j(this._schema);
759
+ }
760
+ this.render();
761
+ }
762
+ refresh() {
763
+ this.render();
764
+ }
765
+ // i18n 相关
766
+ set i18n(e) {
767
+ this._i18nCommitted || (this._i18n = { ...this._i18n, ...e }, this._i18nCommitted = !0, this.render());
768
+ }
769
+ get i18n() {
770
+ return this._i18n;
771
+ }
772
+ render() {
773
+ if (!this._schema) return;
774
+ const e = this.$root.querySelector("form");
775
+ e.innerHTML = "";
776
+ const s = I(
777
+ this._schema,
778
+ [],
779
+ this._state,
780
+ this._i18n.rootLabel,
781
+ this._i18n
782
+ );
783
+ e.appendChild(s);
784
+ }
785
+ }
786
+ b("schema-form", ye);
787
+ function et() {
788
+ b("schema-form", ye), b("schema-form-string", ue), b("schema-form-number", he), b("schema-form-boolean", me), b("schema-form-date", pe), b("schema-form-const", Y), b("schema-form-union", ve), b("schema-form-tuple", ge), b("schema-form-object", _e), b("schema-form-array", V), b("schema-form-dict", be), b("schema-form-intersect", fe);
789
+ }
790
+ const tt = /* @__PURE__ */ re({
791
+ __name: "SchemasteryFormVue",
792
+ props: /* @__PURE__ */ te({
793
+ schema: {},
794
+ value: {},
795
+ validateOnChange: { type: Boolean, default: !1 }
796
+ }, {
797
+ schema: { required: !0 },
798
+ schemaModifiers: {},
799
+ value: { required: !1, default: {} },
800
+ valueModifiers: {}
801
+ }),
802
+ emits: /* @__PURE__ */ te(["change"], ["update:schema", "update:value"]),
803
+ setup(n, { expose: e, emit: s }) {
804
+ const a = ae(n, "schema"), t = ae(n, "value"), r = s, i = oe("elRef");
805
+ let o = !1, c = !1;
806
+ const h = (l) => {
807
+ if (c)
808
+ return;
809
+ const m = i.value, u = n.validateOnChange ? m.getData({ validate: !0 }) : l.detail.state;
810
+ o = !0, t.value = u, U(() => {
811
+ o = !1;
812
+ }), r("change", l.detail);
813
+ };
814
+ return Fe(() => {
815
+ et();
816
+ }), le(() => {
817
+ const l = i.value;
818
+ a.value && (l.schema = a.value), t.value !== void 0 && l.setData(t.value, { validate: !1, autofix: !0 }), l.addEventListener("form-change", h);
819
+ }), je(() => {
820
+ i.value?.removeEventListener("form-change", h);
821
+ }), J(
822
+ a,
823
+ (l) => {
824
+ o || i.value && l && i.value.schema !== l && (c = !0, i.value.schema = l, U(() => {
825
+ c = !1;
826
+ }));
827
+ },
828
+ { deep: !0, immediate: !0 }
829
+ ), J(
830
+ t,
831
+ (l) => {
832
+ if (o || !i.value || l === void 0) return;
833
+ const m = i.value.getData({ validate: !1 });
834
+ JSON.stringify(m) !== JSON.stringify(l) && (c = !0, i.value.setData(l, { validate: !1 }), U(() => {
835
+ c = !1;
836
+ }));
837
+ },
838
+ { deep: !0, immediate: !0 }
839
+ ), e({
840
+ /** 手动设置数据并可选择是否触发 v-model:data */
841
+ setData(l, m) {
842
+ const u = i.value;
843
+ u.setData(l, { validate: !!m?.validate }), m?.emit && (t.value = u.getData({ validate: !!m?.validate }));
844
+ },
845
+ /** 获取数据 */
846
+ getData(l) {
847
+ return i.value.getData(l);
848
+ },
849
+ /** 设置 schema,并同步到 v-model:schema */
850
+ setSchema(l, m = !0) {
851
+ i.value.schema = l, m && (a.value = l);
852
+ },
853
+ refresh() {
854
+ i.value.refresh();
855
+ },
856
+ reset() {
857
+ i.value.reset();
858
+ },
859
+ /** 原生元素 */
860
+ el: i
861
+ }), (l, m) => (M(), D("schema-form", De({
862
+ ref_key: "elRef",
863
+ ref: i
864
+ }, l.$attrs), null, 16));
865
+ }
866
+ });
867
+ function P(n, e = /* @__PURE__ */ new WeakMap()) {
868
+ if (Te(n))
869
+ return P(n.value, e);
870
+ if (n === null || typeof n != "object")
871
+ return n;
872
+ if (e.has(n))
873
+ return e.get(n);
874
+ if (n instanceof Date)
875
+ return new Date(n);
876
+ if (n instanceof RegExp)
877
+ return new RegExp(n);
878
+ if (n instanceof Map) {
879
+ const t = /* @__PURE__ */ new Map();
880
+ return e.set(n, t), Array.from(n.entries()).forEach(([r, i]) => {
881
+ t.set(r, P(i, e));
882
+ }), t;
883
+ }
884
+ if (n instanceof Set) {
885
+ const t = /* @__PURE__ */ new Set();
886
+ return e.set(n, t), Array.from(n).forEach((r) => {
887
+ t.add(P(r, e));
888
+ }), t;
889
+ }
890
+ if (Array.isArray(n)) {
891
+ const t = [];
892
+ e.set(n, t);
893
+ for (const r of n)
894
+ t.push(P(r, e));
895
+ return t;
896
+ }
897
+ const s = Re(n), a = {};
898
+ e.set(n, a);
899
+ for (const t of Object.keys(s))
900
+ a[t] = P(s[t], e);
901
+ for (const t of Object.getOwnPropertySymbols(s))
902
+ a[t] = P(s[t], e);
903
+ return a;
904
+ }
905
+ const at = { id: "preferences-ui-app" }, nt = { class: "tabbar" }, st = { class: "tabbar-tabs" }, it = ["onClick", "data-value"], rt = { class: "tabbar-content" }, ot = { key: 0 }, lt = { style: { "max-height": "20em", overflow: "auto" } }, ct = /* @__PURE__ */ re({
906
+ __name: "PreferencesApp",
907
+ setup(n, { expose: e }) {
908
+ const s = He(), a = !1, t = Oe([]), r = H([]), i = H(""), o = z(() => r.value.find((d) => d.name === i.value) || null), c = z(() => {
909
+ const d = t.value.filter((g) => g.category === i.value).map((g) => g.schema);
910
+ return d.length === 0 ? null : Ie.intersect(d);
911
+ }), h = z(() => o.value && typeof o.value.autoGenerateForm == "boolean" ? o.value.autoGenerateForm : !0), l = H({});
912
+ e({
913
+ getValue() {
914
+ return P(l);
915
+ },
916
+ mergeValue(d) {
917
+ l.value = {
918
+ ...l.value,
919
+ ...d
920
+ };
921
+ },
922
+ selectTab(d) {
923
+ i.value = d;
924
+ }
925
+ }), le(async () => {
926
+ s.inject(["preferences"], async (d) => {
927
+ const g = await d.preferences.getAll();
928
+ l.value = g, r.value = d.preferences.getConfigCategories(), t.value = d.preferences.getConfigRegistries(), i.value = r.value[0].name;
929
+ });
930
+ });
931
+ const m = (d, g) => {
932
+ d.preventDefault(), i.value = g;
933
+ const v = d.currentTarget;
934
+ v && v.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "center" });
935
+ }, u = oe("customRenderContainerRef"), f = H([]);
936
+ return qe(() => {
937
+ f.value.forEach((d) => d()), f.value = [];
938
+ }), J(
939
+ o,
940
+ async (d) => {
941
+ f.value.forEach((v) => v()), f.value = [], await U();
942
+ const g = u.value;
943
+ if (g && (g.innerText = "", d && typeof d.customRenderer == "function")) {
944
+ let v = Je;
945
+ const C = (y) => {
946
+ v = y;
947
+ }, w = (y) => {
948
+ f.value.push(y);
949
+ }, $ = await d.customRenderer({ ctx: s, onMounted: C, onUnmount: w });
950
+ $ && (g.appendChild($), v?.(g));
951
+ }
952
+ },
953
+ { immediate: !0, deep: !1 }
954
+ ), (d, g) => (M(), D("div", at, [
955
+ O("div", nt, [
956
+ O("div", st, [
957
+ (M(!0), D(Ue, null, Be(r.value, (v) => (M(), D("a", {
958
+ class: Ve(["tab", { active: i.value === v.name }]),
959
+ key: v.name,
960
+ onClick: (C) => m(C, v.name),
961
+ "data-value": v.name
962
+ }, ne(v.label), 11, it))), 128))
963
+ ]),
964
+ O("div", rt, [
965
+ o.value && o.value.customRenderer ? (M(), D("div", {
966
+ class: "custom-render-container",
967
+ ref_key: "customRenderContainerRef",
968
+ ref: u,
969
+ key: i.value
970
+ })) : G("", !0),
971
+ h.value && c.value ? (M(), ze(se(tt), {
972
+ class: "auto-schema-form",
973
+ key: i.value,
974
+ "data-category": i.value,
975
+ schema: c.value,
976
+ value: l.value,
977
+ "onUpdate:value": g[0] || (g[0] = (v) => l.value = { ...l.value, ...v }),
978
+ "validate-on-change": !1,
979
+ i18n: { rootLabel: "" }
980
+ }, null, 8, ["data-category", "schema", "value"])) : G("", !0)
981
+ ])
982
+ ]),
983
+ se(a) ? (M(), D("details", ot, [
984
+ O("pre", lt, ne(l.value), 1)
985
+ ])) : G("", !0)
986
+ ]));
987
+ }
988
+ }), dt = /* @__PURE__ */ We(ct, [["__scopeId", "data-v-7f07706b"]]);
989
+ var ut = Object.create, Z = Object.defineProperty, ht = Object.getOwnPropertyDescriptor, xe = (n, e) => (e = Symbol[n]) ? e : Symbol.for("Symbol." + n), Ce = (n) => {
990
+ throw TypeError(n);
991
+ }, mt = (n, e, s) => e in n ? Z(n, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[e] = s, pt = (n, e) => Z(n, "name", { value: e, configurable: !0 }), ft = (n) => [, , , ut(n?.[xe("metadata")] ?? null)], vt = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], Ee = (n) => n !== void 0 && typeof n != "function" ? Ce("Function expected") : n, gt = (n, e, s, a, t) => ({ kind: vt[n], name: e, metadata: a, addInitializer: (r) => s._ ? Ce("Already initialized") : t.push(Ee(r || null)) }), _t = (n, e) => mt(e, xe("metadata"), n[3]), bt = (n, e, s, a) => {
992
+ for (var t = 0, r = n[e >> 1], i = r && r.length; t < i; t++) r[t].call(s);
993
+ return a;
994
+ }, yt = (n, e, s, a, t, r) => {
995
+ var i, o, c, h = e & 7, l = !1, m = 0, u = n[m] || (n[m] = []), f = h && (t = t.prototype, h < 5 && (h > 3 || !l) && ht(t, s));
996
+ pt(t, s);
997
+ for (var d = a.length - 1; d >= 0; d--)
998
+ c = gt(h, s, o = {}, n[3], u), i = (0, a[d])(t, c), o._ = 1, Ee(i) && (t = i);
999
+ return _t(n, t), f && Z(t, s, f), l ? h ^ 4 ? r : f : t;
1000
+ }, $e, K, we;
1001
+ $e = [Pe(["preferences", "modal"])];
1002
+ class Q extends (we = Me) {
1003
+ constructor(e) {
1004
+ super(e, {}, "preferences-ui"), this.ctx = e, this._modal = null, this._form = null, e.set("preferencesUI", this), e.preferences.defineCategory({
1005
+ name: "about",
1006
+ label: "About",
1007
+ description: "About InPageEdit",
1008
+ index: 99,
1009
+ customRenderer: () => /* @__PURE__ */ _("section", { className: "theme-ipe-prose", children: [
1010
+ /* @__PURE__ */ _("h2", { children: "✏️ InPageEdit NEXT" }),
1011
+ /* @__PURE__ */ _("p", { children: "🚀 Modular, Extensible Supercharged Plugin for MediaWiki." }),
1012
+ /* @__PURE__ */ _("h3", { children: "Portals" }),
1013
+ /* @__PURE__ */ _("ul", { children: [
1014
+ /* @__PURE__ */ _("li", { children: /* @__PURE__ */ _("a", { href: this.ctx.Endpoints.HOME_URL, target: "_blank", children: "Official Website & Help Center" }) }),
1015
+ /* @__PURE__ */ _("li", { children: /* @__PURE__ */ _(
1016
+ "a",
1017
+ {
1018
+ href: `${this.ctx.Endpoints.UPDATE_LOGS_URL}#${this.ctx.version.split("-")[0]}`,
1019
+ target: "_blank",
1020
+ children: "Update Logs"
1021
+ }
1022
+ ) })
1023
+ ] }),
1024
+ /* @__PURE__ */ _("h3", { children: "Join us" }),
1025
+ /* @__PURE__ */ _("ul", { children: [
1026
+ /* @__PURE__ */ _("li", { children: [
1027
+ /* @__PURE__ */ _("strong", { children: "GitHub" }),
1028
+ ":",
1029
+ " ",
1030
+ /* @__PURE__ */ _("a", { href: this.ctx.Endpoints.GITHUB_URL, target: "_blank", children: "inpageedit/inpageedit-next" })
1031
+ ] }),
1032
+ /* @__PURE__ */ _("li", { children: [
1033
+ /* @__PURE__ */ _("strong", { children: "QQ Group" }),
1034
+ ": 1026023666"
1035
+ ] })
1036
+ ] }),
1037
+ /* @__PURE__ */ _("hr", {}),
1038
+ /* @__PURE__ */ _("p", { style: { textAlign: "center" }, children: [
1039
+ "InPageEdit-NEXT Copyright © 2025-",
1040
+ (/* @__PURE__ */ new Date()).getFullYear(),
1041
+ " dragon-fish"
1042
+ ] }),
1043
+ /* @__PURE__ */ _("hr", {})
1044
+ ] })
1045
+ }), e.inject(["toolbox"], (s) => {
1046
+ s.toolbox.addButton({
1047
+ id: "preferences",
1048
+ icon: /* @__PURE__ */ _(
1049
+ "svg",
1050
+ {
1051
+ xmlns: "http://www.w3.org/2000/svg",
1052
+ width: "24",
1053
+ height: "24",
1054
+ viewBox: "0 0 24 24",
1055
+ fill: "currentColor",
1056
+ class: "icon icon-tabler icons-tabler-filled icon-tabler-settings",
1057
+ children: [
1058
+ /* @__PURE__ */ _("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
1059
+ /* @__PURE__ */ _("path", { d: "M14.647 4.081a.724 .724 0 0 0 1.08 .448c2.439 -1.485 5.23 1.305 3.745 3.744a.724 .724 0 0 0 .447 1.08c2.775 .673 2.775 4.62 0 5.294a.724 .724 0 0 0 -.448 1.08c1.485 2.439 -1.305 5.23 -3.744 3.745a.724 .724 0 0 0 -1.08 .447c-.673 2.775 -4.62 2.775 -5.294 0a.724 .724 0 0 0 -1.08 -.448c-2.439 1.485 -5.23 -1.305 -3.745 -3.744a.724 .724 0 0 0 -.447 -1.08c-2.775 -.673 -2.775 -4.62 0 -5.294a.724 .724 0 0 0 .448 -1.08c-1.485 -2.439 1.305 -5.23 3.744 -3.745a.722 .722 0 0 0 1.08 -.447c.673 -2.775 4.62 -2.775 5.294 0zm-2.647 4.919a3 3 0 1 0 0 6a3 3 0 0 0 0 -6z" })
1060
+ ]
1061
+ }
1062
+ ),
1063
+ tooltip: "Configure Preferences",
1064
+ group: "group2",
1065
+ index: 99,
1066
+ onClick: () => this.showModal()
1067
+ }), this.addDisposeHandler((a) => {
1068
+ a.toolbox.removeButton("preferences");
1069
+ });
1070
+ });
1071
+ }
1072
+ async start() {
1073
+ import("./PluginPrefSync-Ziogy_o-.js").then(({ PluginPrefSync: e }) => {
1074
+ this.ctx.plugin(e);
1075
+ }).catch(this.ctx.logger.warn), this.ctx.on("preferences/changed", (e) => {
1076
+ this._form?.mergeValue?.(e.input);
1077
+ });
1078
+ }
1079
+ stop() {
1080
+ }
1081
+ showModal() {
1082
+ if (this._modal && !this._modal.isDestroyed)
1083
+ return this._modal;
1084
+ const e = this.ctx.modal.show({
1085
+ className: "ipe-preference compact-buttons",
1086
+ sizeClass: "small",
1087
+ outSideClose: !1,
1088
+ center: !0,
1089
+ title: `InPageEdit Preferences (${this.ctx.version})`,
1090
+ content: /* @__PURE__ */ _(Le, { children: /* @__PURE__ */ _(Ae, {}) })
1091
+ });
1092
+ e.get$window().classList.add("dialog");
1093
+ const s = /* @__PURE__ */ _(
1094
+ "div",
1095
+ {
1096
+ id: "ipe-preferences-app",
1097
+ style: { minHeight: "calc(85dvh - var(--ipe-modal-spacing) * 2)" }
1098
+ }
1099
+ );
1100
+ e.setContent(s), this.ctx.emit("preferences-ui/modal-shown", {
1101
+ ctx: this.ctx,
1102
+ modal: e
1103
+ });
1104
+ const a = this.createPreferencesUIApp(), t = a.mount(s);
1105
+ return this._form = t, this.ctx.emit("preferences-ui/vue-app-mounted", {
1106
+ ctx: this.ctx,
1107
+ app: a,
1108
+ form: t
1109
+ }), e.setButtons([
1110
+ {
1111
+ label: "Close",
1112
+ className: "is-ghost",
1113
+ method: () => {
1114
+ e.close();
1115
+ }
1116
+ },
1117
+ {
1118
+ label: "Save",
1119
+ className: "is-primary is-ghost",
1120
+ method: async () => {
1121
+ const r = t.getValue();
1122
+ try {
1123
+ const i = await this.ctx.preferences.setMany(r);
1124
+ this.logger.info("preferences saved", r, i);
1125
+ } catch (i) {
1126
+ this.logger.error("failed to save preferences", i);
1127
+ }
1128
+ e.close(), this.ctx.modal.notify("success", {
1129
+ title: "Preferences Saved",
1130
+ content: /* @__PURE__ */ _("p", { children: "Some settings may take effect after reloading the page." })
1131
+ });
1132
+ }
1133
+ }
1134
+ ]), this._modal = e, e.on(e.Event.Close, () => {
1135
+ this.logger.debug("preferences modal closed, vue app unmounting"), a.unmount(), this._modal = null, this._form = null, this.ctx.emit("preferences-ui/modal-closed", {
1136
+ ctx: this.ctx,
1137
+ modal: e
1138
+ });
1139
+ }), e;
1140
+ }
1141
+ getCurrentModal() {
1142
+ return this._modal;
1143
+ }
1144
+ closeCurrentModal() {
1145
+ return this._modal?.close();
1146
+ }
1147
+ async dispatchFormSave(e) {
1148
+ e = e || this._form || void 0;
1149
+ const s = e?.getValue();
1150
+ return s ? (this.ctx.preferences.setMany(s), !0) : !1;
1151
+ }
1152
+ getCurrentFormValue() {
1153
+ return this._form?.getValue();
1154
+ }
1155
+ mergeFormValue(e) {
1156
+ return this._form?.mergeValue?.(e), !!this._form?.mergeValue;
1157
+ }
1158
+ createPreferencesUIApp() {
1159
+ return Ge(this.ctx, dt);
1160
+ }
1161
+ }
1162
+ K = ft(we);
1163
+ Q = yt(K, 0, "PluginPreferencesUI", $e, Q);
1164
+ bt(K, 1, Q);
1165
+ export {
1166
+ Q as PluginPreferencesUI
1167
+ };
1168
+ //# sourceMappingURL=index-eARjMi7f.js.map