@websublime/vite-plugin-open-api-devtools 0.7.0 → 0.8.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 (72) hide show
  1. package/dist/ModelsPage-C1LQvwFk.js +750 -0
  2. package/dist/ModelsPage-C1LQvwFk.js.map +1 -0
  3. package/dist/{RoutesPage-D3FSr2Y6.js → RoutesPage-BHmWMFsq.js} +4 -4
  4. package/dist/{RoutesPage-D3FSr2Y6.js.map → RoutesPage-BHmWMFsq.js.map} +1 -1
  5. package/dist/{SimulatorPage-CzJrwWzc.js → SimulatorPage-Bx1k15hK.js} +154 -149
  6. package/dist/SimulatorPage-Bx1k15hK.js.map +1 -0
  7. package/dist/{TimelinePage-HGh13pF3.js → TimelinePage-BNUW_r67.js} +7 -7
  8. package/dist/{TimelinePage-HGh13pF3.js.map → TimelinePage-BNUW_r67.js.map} +1 -1
  9. package/dist/{check-BLIoatWd.js → check-Crwhzuxr.js} +2 -2
  10. package/dist/{check-BLIoatWd.js.map → check-Crwhzuxr.js.map} +1 -1
  11. package/dist/devtools.css +1 -1
  12. package/dist/devtools.js +1 -1
  13. package/dist/devtools.umd.cjs +3 -3
  14. package/dist/devtools.umd.cjs.map +1 -1
  15. package/dist/{format-lBEBG5Y6.js → format-BjZBWUrM.js} +2 -2
  16. package/dist/{format-lBEBG5Y6.js.map → format-BjZBWUrM.js.map} +1 -1
  17. package/dist/{main-DKt7pJsx.js → main-ECCULvdl.js} +250 -250
  18. package/dist/main-ECCULvdl.js.map +1 -0
  19. package/dist/spa/assets/ModelsPage-BslYlawu.css +1 -0
  20. package/dist/spa/assets/ModelsPage-DQt9z3J2.js +4 -0
  21. package/dist/spa/assets/ModelsPage-DQt9z3J2.js.map +1 -0
  22. package/dist/spa/assets/RoutesPage-BP6-uw-k.js +2 -0
  23. package/dist/spa/assets/{RoutesPage-Bhnu6w5-.js.map → RoutesPage-BP6-uw-k.js.map} +1 -1
  24. package/dist/spa/assets/SimulatorPage-BH2KmZ_S.js +2 -0
  25. package/dist/spa/assets/SimulatorPage-BH2KmZ_S.js.map +1 -0
  26. package/dist/spa/assets/SimulatorPage-DGEq_rzM.css +1 -0
  27. package/dist/spa/assets/TimelinePage-BAbAB_--.js +2 -0
  28. package/dist/spa/assets/{TimelinePage-CwR-Coxj.js.map → TimelinePage-BAbAB_--.js.map} +1 -1
  29. package/dist/spa/assets/check-C0owz4na.js +2 -0
  30. package/dist/spa/assets/{check-DxJBRQqh.js.map → check-C0owz4na.js.map} +1 -1
  31. package/dist/spa/assets/{format-B1udViy3.js → format-C4BPxS33.js} +2 -2
  32. package/dist/spa/assets/{format-B1udViy3.js.map → format-C4BPxS33.js.map} +1 -1
  33. package/dist/spa/assets/index-CFIFFTBf.css +1 -0
  34. package/dist/spa/assets/index-rRRRtsjM.js +3 -0
  35. package/dist/spa/assets/index-rRRRtsjM.js.map +1 -0
  36. package/dist/spa/assets/{registry-Z11QUkpV.js → registry-DjJcdO1T.js} +2 -2
  37. package/dist/spa/assets/{registry-Z11QUkpV.js.map → registry-DjJcdO1T.js.map} +1 -1
  38. package/dist/spa/assets/{trash-2-CDyKV6GB.js → trash-2-CR2SZgyU.js} +2 -2
  39. package/dist/spa/assets/{trash-2-CDyKV6GB.js.map → trash-2-CR2SZgyU.js.map} +1 -1
  40. package/dist/spa/assets/{triangle-alert-CAGaIjAo.js → triangle-alert-BMgTQ4dT.js} +2 -2
  41. package/dist/spa/assets/{triangle-alert-CAGaIjAo.js.map → triangle-alert-BMgTQ4dT.js.map} +1 -1
  42. package/dist/spa/assets/{vue-vendor-CtA47il-.js → vue-vendor-Bkktf9yg.js} +2 -2
  43. package/dist/spa/assets/{vue-vendor-CtA47il-.js.map → vue-vendor-Bkktf9yg.js.map} +1 -1
  44. package/dist/spa/assets/x-qSQxHLmz.js +2 -0
  45. package/dist/spa/assets/{x-zxrccEon.js.map → x-qSQxHLmz.js.map} +1 -1
  46. package/dist/spa/index.html +3 -3
  47. package/dist/{trash-2-RxS9jzWT.js → trash-2-DkjAUIEq.js} +2 -2
  48. package/dist/{trash-2-RxS9jzWT.js.map → trash-2-DkjAUIEq.js.map} +1 -1
  49. package/dist/{triangle-alert-gLhIcFT5.js → triangle-alert-BUAaw7Jx.js} +2 -2
  50. package/dist/{triangle-alert-gLhIcFT5.js.map → triangle-alert-BUAaw7Jx.js.map} +1 -1
  51. package/dist/{x-UqfnjULc.js → x-CMARYnCH.js} +2 -2
  52. package/dist/{x-UqfnjULc.js.map → x-CMARYnCH.js.map} +1 -1
  53. package/package.json +11 -11
  54. package/dist/ModelsPage-CSuUHUuV.js +0 -629
  55. package/dist/ModelsPage-CSuUHUuV.js.map +0 -1
  56. package/dist/SimulatorPage-CzJrwWzc.js.map +0 -1
  57. package/dist/main-DKt7pJsx.js.map +0 -1
  58. package/dist/spa/assets/ModelsPage-DQN_XP0u.css +0 -1
  59. package/dist/spa/assets/ModelsPage-DqYHHuAQ.js +0 -4
  60. package/dist/spa/assets/ModelsPage-DqYHHuAQ.js.map +0 -1
  61. package/dist/spa/assets/RoutesPage-Bhnu6w5-.js +0 -2
  62. package/dist/spa/assets/SimulatorPage-B1voZDRi.css +0 -1
  63. package/dist/spa/assets/SimulatorPage-ROKoAmUT.js +0 -2
  64. package/dist/spa/assets/SimulatorPage-ROKoAmUT.js.map +0 -1
  65. package/dist/spa/assets/TimelinePage-CwR-Coxj.js +0 -2
  66. package/dist/spa/assets/check-DxJBRQqh.js +0 -2
  67. package/dist/spa/assets/index-9_6u4UTF.css +0 -1
  68. package/dist/spa/assets/index-GQ9qRqEi.js +0 -3
  69. package/dist/spa/assets/index-GQ9qRqEi.js.map +0 -1
  70. package/dist/spa/assets/useWebSocket-C2ttWF5T.js +0 -2
  71. package/dist/spa/assets/useWebSocket-C2ttWF5T.js.map +0 -1
  72. package/dist/spa/assets/x-zxrccEon.js +0 -2
@@ -0,0 +1,750 @@
1
+ import { ref as w, computed as M, toRaw as te, defineComponent as q, createElementBlock as m, openBlock as f, createCommentVNode as N, createVNode as E, createElementVNode as s, unref as r, Fragment as J, renderList as A, normalizeClass as B, toDisplayString as C, watch as H, normalizeStyle as se, reactive as ne, onMounted as ae, nextTick as oe, createBlock as le, Teleport as re, withModifiers as ie, createTextVNode as G } from "vue";
2
+ import { c as W, D as K, _ as X, u as ce } from "./main-ECCULvdl.js";
3
+ import { C as de } from "./check-Crwhzuxr.js";
4
+ import { defineStore as ue } from "pinia";
5
+ import { X as fe } from "./x-CMARYnCH.js";
6
+ import { T as me } from "./trash-2-DkjAUIEq.js";
7
+ const ve = W("circle-alert", [
8
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
9
+ ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
10
+ ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
11
+ ]);
12
+ const he = W("refresh-cw", [
13
+ ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
14
+ ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
15
+ ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
16
+ ["path", { d: "M8 16H3v5", key: "1cv678" }]
17
+ ]);
18
+ const _e = W("save", [
19
+ [
20
+ "path",
21
+ {
22
+ d: "M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",
23
+ key: "1c8476"
24
+ }
25
+ ],
26
+ ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
27
+ ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
28
+ ]);
29
+ function U(t) {
30
+ try {
31
+ return structuredClone(te(t));
32
+ } catch {
33
+ return JSON.parse(JSON.stringify(t));
34
+ }
35
+ }
36
+ const ye = ue("models", () => {
37
+ const t = w([]), e = w(null), i = w([]), c = w([]), u = w(!1), o = w(null), y = M(() => e.value ? t.value.find((a) => a.name === e.value) ?? null : null), g = w(!1), d = M(() => g.value), v = M(() => t.value.length), p = M(() => t.value.reduce((a, _) => a + _.count, 0));
38
+ async function x() {
39
+ u.value = !0, o.value = null;
40
+ try {
41
+ const a = await fetch("/_api/store");
42
+ if (!a.ok)
43
+ throw new Error(`Failed to fetch schemas: ${a.statusText}`);
44
+ const _ = await a.json();
45
+ t.value = _.schemas ?? [];
46
+ } catch (a) {
47
+ o.value = a instanceof Error ? a.message : "Failed to fetch schemas", console.error("[ModelsStore] Error fetching schemas:", a);
48
+ } finally {
49
+ u.value = !1;
50
+ }
51
+ }
52
+ async function F(a) {
53
+ e.value !== a && (e.value = a, await j(a));
54
+ }
55
+ async function j(a) {
56
+ u.value = !0, o.value = null;
57
+ try {
58
+ const _ = await fetch(`/_api/store/${encodeURIComponent(a)}`);
59
+ if (!_.ok)
60
+ throw new Error(`Failed to fetch schema data: ${_.statusText}`);
61
+ const I = await _.json(), D = I.items ?? [];
62
+ i.value = U(D), c.value = U(D), g.value = !1;
63
+ const Y = t.value.findIndex((ee) => ee.name === a);
64
+ Y !== -1 && (t.value[Y].count = I.count);
65
+ } catch (_) {
66
+ o.value = _ instanceof Error ? _.message : "Failed to fetch schema data", console.error("[ModelsStore] Error fetching schema data:", _);
67
+ } finally {
68
+ u.value = !1;
69
+ }
70
+ }
71
+ function O(a) {
72
+ if (!Array.isArray(a)) {
73
+ o.value = "Invalid data: Expected an array of items", console.error("[ModelsStore] updateItems received non-array value:", typeof a);
74
+ return;
75
+ }
76
+ i.value = a, o.value = null, g.value = !0;
77
+ }
78
+ async function h() {
79
+ if (!e.value)
80
+ return o.value = "No schema selected", !1;
81
+ u.value = !0, o.value = null;
82
+ try {
83
+ const a = await fetch(`/_api/store/${encodeURIComponent(e.value)}`, {
84
+ method: "POST",
85
+ headers: {
86
+ "Content-Type": "application/json"
87
+ },
88
+ body: JSON.stringify(i.value)
89
+ });
90
+ if (!a.ok) {
91
+ const D = await a.json().catch(() => ({}));
92
+ throw new Error(D.error || `Failed to save items: ${a.statusText}`);
93
+ }
94
+ const _ = await a.json();
95
+ c.value = U(i.value), g.value = !1;
96
+ const I = t.value.findIndex((D) => D.name === e.value);
97
+ return I !== -1 && (t.value[I].count = _.created ?? i.value.length), !0;
98
+ } catch (a) {
99
+ return o.value = a instanceof Error ? a.message : "Failed to save items", console.error("[ModelsStore] Error saving items:", a), !1;
100
+ } finally {
101
+ u.value = !1;
102
+ }
103
+ }
104
+ async function b() {
105
+ if (!e.value)
106
+ return o.value = "No schema selected", !1;
107
+ u.value = !0, o.value = null;
108
+ try {
109
+ const a = await fetch(`/_api/store/${encodeURIComponent(e.value)}`, {
110
+ method: "DELETE"
111
+ });
112
+ if (!a.ok)
113
+ throw new Error(`Failed to clear schema: ${a.statusText}`);
114
+ i.value = [], c.value = [], g.value = !1;
115
+ const _ = t.value.findIndex((I) => I.name === e.value);
116
+ return _ !== -1 && (t.value[_].count = 0), !0;
117
+ } catch (a) {
118
+ return o.value = a instanceof Error ? a.message : "Failed to clear schema", console.error("[ModelsStore] Error clearing schema:", a), !1;
119
+ } finally {
120
+ u.value = !1;
121
+ }
122
+ }
123
+ function $() {
124
+ i.value = U(c.value), g.value = !1;
125
+ }
126
+ async function l() {
127
+ e.value ? await j(e.value) : await x();
128
+ }
129
+ function n() {
130
+ t.value = [], e.value = null, i.value = [], c.value = [], u.value = !1, o.value = null, g.value = !1;
131
+ }
132
+ function S(a) {
133
+ const _ = t.value.findIndex((I) => I.name === a.schema);
134
+ _ !== -1 && (t.value[_].count = a.count), e.value === a.schema && (d.value ? console.warn(
135
+ `[ModelsStore] Skipping auto-refresh for schema "${a.schema}" - unsaved changes exist`
136
+ ) : j(a.schema));
137
+ }
138
+ function R(a) {
139
+ a.success && (x(), e.value && (d.value ? console.warn(
140
+ `[ModelsStore] Skipping auto-refresh after reseed for schema "${e.value}" - unsaved changes exist`
141
+ ) : j(e.value)));
142
+ }
143
+ return {
144
+ // State
145
+ schemas: t,
146
+ selectedSchema: e,
147
+ currentItems: i,
148
+ loading: u,
149
+ error: o,
150
+ // Computed
151
+ currentSchema: y,
152
+ isDirty: d,
153
+ schemaCount: v,
154
+ totalItems: p,
155
+ // Actions
156
+ fetchSchemas: x,
157
+ selectSchemaByName: F,
158
+ fetchSchemaData: j,
159
+ updateItems: O,
160
+ saveItems: h,
161
+ clearSchema: b,
162
+ discardChanges: $,
163
+ refresh: l,
164
+ reset: n,
165
+ handleStoreUpdate: S,
166
+ handleReseedComplete: R
167
+ };
168
+ });
169
+ function L(t, e) {
170
+ return t.length <= e ? t : `${t.slice(0, e)}…`;
171
+ }
172
+ function pe(t) {
173
+ return t == null ? "--" : typeof t == "string" ? L(t, 50) : typeof t == "number" || typeof t == "boolean" ? String(t) : Array.isArray(t) || typeof t == "object" ? L(JSON.stringify(t), 50) : String(t);
174
+ }
175
+ function Q(t, e) {
176
+ if (!(typeof t != "object" || t === null))
177
+ return t[e];
178
+ }
179
+ function ge(t, e, i) {
180
+ const c = Q(t, e);
181
+ return typeof c == "string" || typeof c == "number" ? c : i;
182
+ }
183
+ function be(t, e) {
184
+ if (t.length === 0) return [];
185
+ const i = /* @__PURE__ */ new Set();
186
+ for (const u of t)
187
+ if (typeof u == "object" && u !== null)
188
+ for (const o of Object.keys(u))
189
+ i.add(o);
190
+ if (i.size === 0) return [];
191
+ const c = Array.from(i);
192
+ return c.includes(e) ? [e, ...c.filter((u) => u !== e)] : c;
193
+ }
194
+ const Se = { class: "data-table" }, Ce = {
195
+ key: 0,
196
+ class: "data-table__empty"
197
+ }, ke = {
198
+ key: 1,
199
+ class: "data-table__container"
200
+ }, we = { class: "data-table__table" }, xe = ["onClick"], Ie = { class: "data-table__row-num" }, $e = {
201
+ key: 2,
202
+ class: "data-table__footer"
203
+ }, Te = { class: "data-table__info" }, Ee = { class: "data-table__info" }, je = /* @__PURE__ */ q({
204
+ __name: "DataTable",
205
+ props: {
206
+ items: {},
207
+ idField: {},
208
+ selectedIndex: { default: -1 }
209
+ },
210
+ emits: ["select"],
211
+ setup(t, { emit: e }) {
212
+ const i = t, c = e, u = M(() => be(i.items, i.idField));
213
+ function o(g) {
214
+ c("select", g);
215
+ }
216
+ function y(g, d) {
217
+ return ge(g, i.idField, d);
218
+ }
219
+ return (g, d) => (f(), m("div", Se, [
220
+ t.items.length === 0 ? (f(), m("div", Ce, [
221
+ E(r(K), {
222
+ size: 32,
223
+ class: "data-table__empty-icon"
224
+ }),
225
+ d[0] || (d[0] = s("span", null, "No items", -1))
226
+ ])) : (f(), m("div", ke, [
227
+ s("table", we, [
228
+ s("thead", null, [
229
+ s("tr", null, [
230
+ d[1] || (d[1] = s("th", { class: "data-table__row-num" }, "#", -1)),
231
+ (f(!0), m(J, null, A(u.value, (v) => (f(), m("th", {
232
+ key: v,
233
+ class: B(["data-table__header", { "data-table__header--id": v === t.idField }])
234
+ }, C(v), 3))), 128))
235
+ ])
236
+ ]),
237
+ s("tbody", null, [
238
+ (f(!0), m(J, null, A(t.items, (v, p) => (f(), m("tr", {
239
+ key: y(v, p),
240
+ class: B(["data-table__row", { "data-table__row--selected": p === t.selectedIndex }]),
241
+ onClick: (x) => o(p)
242
+ }, [
243
+ s("td", Ie, C(p + 1), 1),
244
+ (f(!0), m(J, null, A(u.value, (x) => (f(), m("td", {
245
+ key: x,
246
+ class: B(["data-table__cell", { "data-table__cell--id": x === t.idField }])
247
+ }, C(r(pe)(r(Q)(v, x))), 3))), 128))
248
+ ], 10, xe))), 128))
249
+ ])
250
+ ])
251
+ ])),
252
+ t.items.length > 0 ? (f(), m("div", $e, [
253
+ s("span", Te, C(t.items.length) + " items", 1),
254
+ s("span", Ee, C(u.value.length) + " columns", 1)
255
+ ])) : N("", !0)
256
+ ]));
257
+ }
258
+ }), De = /* @__PURE__ */ X(je, [["__scopeId", "data-v-dcdce8f7"]]), Me = { class: "json-editor" }, Ne = { class: "json-editor__container" }, Je = {
259
+ class: "json-editor__lines",
260
+ "aria-hidden": "true"
261
+ }, Fe = ["value", "readonly", "placeholder"], Ve = { class: "json-editor__status" }, Oe = { class: "json-editor__status-left" }, Re = {
262
+ key: 0,
263
+ class: "json-editor__valid"
264
+ }, Ae = {
265
+ key: 1,
266
+ class: "json-editor__error"
267
+ }, ze = { class: "json-editor__status-right" }, Ue = { class: "json-editor__info" }, Pe = /* @__PURE__ */ q({
268
+ __name: "JsonEditor",
269
+ props: {
270
+ modelValue: {},
271
+ readonly: { type: Boolean, default: !1 },
272
+ placeholder: { default: "Enter JSON data..." },
273
+ minHeight: { default: 200 }
274
+ },
275
+ emits: ["update:modelValue"],
276
+ setup(t, { expose: e, emit: i }) {
277
+ const c = t, u = i, o = w(""), y = w(null), g = M(() => y.value === null), d = M(() => o.value.split(`
278
+ `).length), v = M(() => Array.from({ length: d.value }, (h, b) => b + 1));
279
+ function p() {
280
+ try {
281
+ o.value = JSON.stringify(c.modelValue, null, 2), y.value = null;
282
+ } catch {
283
+ o.value = "", y.value = "Invalid initial value";
284
+ }
285
+ }
286
+ p(), H(
287
+ () => c.modelValue,
288
+ () => {
289
+ try {
290
+ const h = JSON.parse(o.value);
291
+ JSON.stringify(h) !== JSON.stringify(c.modelValue) && p();
292
+ } catch {
293
+ p();
294
+ }
295
+ }
296
+ );
297
+ function x(h) {
298
+ const b = h.target;
299
+ o.value = b.value, F();
300
+ }
301
+ function F() {
302
+ if (o.value.trim() === "") {
303
+ y.value = null, u("update:modelValue", []);
304
+ return;
305
+ }
306
+ try {
307
+ const h = JSON.parse(o.value);
308
+ y.value = null, u("update:modelValue", h);
309
+ } catch (h) {
310
+ if (h instanceof Error) {
311
+ const b = h.message.match(/position (\d+)/);
312
+ if (b) {
313
+ const $ = Number.parseInt(b[1], 10), l = o.value.substring(0, $).split(`
314
+ `), n = l.length, S = l[l.length - 1].length + 1;
315
+ y.value = `Line ${n}, Column ${S}: ${h.message}`;
316
+ } else
317
+ y.value = h.message;
318
+ } else
319
+ y.value = "Invalid JSON";
320
+ }
321
+ }
322
+ function j() {
323
+ try {
324
+ const h = JSON.parse(o.value);
325
+ o.value = JSON.stringify(h, null, 2), y.value = null, u("update:modelValue", h);
326
+ } catch {
327
+ }
328
+ }
329
+ function O(h) {
330
+ if (h.key === "Tab") {
331
+ h.preventDefault();
332
+ const b = h.target, $ = b.selectionStart, l = b.selectionEnd, n = `${o.value.substring(0, $)} ${o.value.substring(l)}`;
333
+ o.value = n, setTimeout(() => {
334
+ b.selectionStart = b.selectionEnd = $ + 2;
335
+ }, 0), F();
336
+ }
337
+ }
338
+ return e({
339
+ formatJson: j,
340
+ isValid: g
341
+ }), (h, b) => (f(), m("div", Me, [
342
+ s("div", Ne, [
343
+ s("div", Je, [
344
+ (f(!0), m(J, null, A(v.value, ($) => (f(), m("div", {
345
+ key: $,
346
+ class: "json-editor__line-number"
347
+ }, C($), 1))), 128))
348
+ ]),
349
+ s("textarea", {
350
+ value: o.value,
351
+ readonly: t.readonly,
352
+ placeholder: t.placeholder,
353
+ style: se({ minHeight: `${t.minHeight}px` }),
354
+ class: "json-editor__textarea",
355
+ spellcheck: "false",
356
+ onInput: x,
357
+ onKeydown: O
358
+ }, null, 44, Fe)
359
+ ]),
360
+ s("div", Ve, [
361
+ s("div", Oe, [
362
+ g.value ? (f(), m("div", Re, [
363
+ E(r(de), { size: 14 }),
364
+ b[0] || (b[0] = s("span", null, "Valid JSON", -1))
365
+ ])) : y.value ? (f(), m("div", Ae, [
366
+ E(r(ve), { size: 14 }),
367
+ s("span", null, C(y.value), 1)
368
+ ])) : N("", !0)
369
+ ]),
370
+ s("div", ze, [
371
+ s("span", Ue, C(d.value) + " lines", 1)
372
+ ])
373
+ ])
374
+ ]));
375
+ }
376
+ }), Be = /* @__PURE__ */ X(Pe, [["__scopeId", "data-v-dbd5ce20"]]), z = w([]), T = ne({
377
+ visible: !1,
378
+ title: "",
379
+ message: "",
380
+ confirmText: "Confirm",
381
+ cancelText: "Cancel",
382
+ onConfirm: null,
383
+ onCancel: null
384
+ }), V = /* @__PURE__ */ new Map();
385
+ let k = null, Le = 0;
386
+ function He() {
387
+ return `toast-${Date.now()}-${Le++}`;
388
+ }
389
+ function P(t, e, i = 3e3) {
390
+ const c = He(), u = {
391
+ id: c,
392
+ type: t,
393
+ message: e,
394
+ duration: i,
395
+ timestamp: Date.now()
396
+ };
397
+ if (z.value.push(u), i > 0) {
398
+ const o = setTimeout(() => {
399
+ Z(c), V.delete(c);
400
+ }, i);
401
+ V.set(c, o);
402
+ }
403
+ return c;
404
+ }
405
+ function Z(t) {
406
+ const e = V.get(t);
407
+ e !== void 0 && (clearTimeout(e), V.delete(t));
408
+ const i = z.value.findIndex((c) => c.id === t);
409
+ i !== -1 && z.value.splice(i, 1);
410
+ }
411
+ function Ke() {
412
+ function t(d, v) {
413
+ return P("success", d, v);
414
+ }
415
+ function e(d, v) {
416
+ return P("error", d, v);
417
+ }
418
+ function i(d, v) {
419
+ return P("info", d, v);
420
+ }
421
+ function c(d, v) {
422
+ return P("warning", d, v);
423
+ }
424
+ function u(d, v) {
425
+ return new Promise((p) => {
426
+ k && (k(!1), k = null), k = p, T.visible = !0, T.title = v?.title || "Confirm", T.message = d, T.confirmText = v?.confirmText || "Confirm", T.cancelText = v?.cancelText || "Cancel", T.onConfirm = () => {
427
+ T.visible = !1, k && (k(!0), k = null);
428
+ }, T.onCancel = () => {
429
+ T.visible = !1, k && (k(!1), k = null);
430
+ };
431
+ });
432
+ }
433
+ function o() {
434
+ T.visible = !1, k && (k(!1), k = null);
435
+ }
436
+ function y(d) {
437
+ Z(d);
438
+ }
439
+ function g() {
440
+ for (const d of V.values())
441
+ clearTimeout(d);
442
+ V.clear(), z.value = [];
443
+ }
444
+ return {
445
+ // State
446
+ toasts: z,
447
+ confirmDialog: T,
448
+ // Toast methods
449
+ success: t,
450
+ error: e,
451
+ info: i,
452
+ warning: c,
453
+ dismiss: y,
454
+ clearAll: g,
455
+ // Confirm methods
456
+ confirm: u,
457
+ closeConfirm: o
458
+ };
459
+ }
460
+ const qe = { class: "models-page" }, We = { class: "models-sidebar" }, Xe = { class: "models-sidebar__header" }, Ye = { class: "models-sidebar__badge" }, Ge = {
461
+ key: 0,
462
+ class: "models-sidebar__loading"
463
+ }, Qe = {
464
+ key: 1,
465
+ class: "models-sidebar__list"
466
+ }, Ze = ["onClick"], et = { class: "models-sidebar__name" }, tt = { class: "models-sidebar__count" }, st = { class: "models-sidebar__footer" }, nt = { class: "models-sidebar__stat" }, at = { class: "font-mono" }, ot = { class: "models-content" }, lt = { class: "models-toolbar" }, rt = { class: "models-toolbar__title" }, it = { class: "font-mono" }, ct = { class: "text-muted" }, dt = {
467
+ key: 0,
468
+ class: "models-toolbar__badge models-toolbar__badge--warning"
469
+ }, ut = { class: "models-toolbar__actions" }, ft = ["disabled"], mt = ["disabled"], vt = {
470
+ key: 0,
471
+ class: "models-error"
472
+ }, ht = { class: "models-panels" }, _t = { class: "models-panel" }, yt = { class: "models-panel" }, pt = {
473
+ key: 1,
474
+ class: "models-loading-overlay"
475
+ }, gt = {
476
+ key: 1,
477
+ class: "empty-state"
478
+ }, bt = {
479
+ key: 0,
480
+ class: "models-error"
481
+ }, St = { class: "modal__body" }, Ct = { class: "modal__footer" }, kt = /* @__PURE__ */ q({
482
+ __name: "ModelsPage",
483
+ setup(t) {
484
+ const e = ye(), { send: i, on: c, connected: u } = ce(), { success: o, error: y, confirm: g } = Ke(), d = w(null), v = w(!1), p = w(-1);
485
+ ae(async () => {
486
+ try {
487
+ await e.fetchSchemas(), e.schemas.length > 0 && !e.selectedSchema && await e.selectSchemaByName(e.schemas[0].name);
488
+ } catch (l) {
489
+ e.error || (e.error = l instanceof Error ? l.message : "Failed to load schemas");
490
+ }
491
+ }), c("store:updated", (l) => {
492
+ const n = l;
493
+ if (typeof l != "object" || l === null || typeof n.schema != "string" || typeof n.action != "string" || typeof n.count != "number") {
494
+ console.warn("[ModelsPage] Invalid store:updated payload:", l);
495
+ return;
496
+ }
497
+ e.handleStoreUpdate(l), p.value = -1;
498
+ }), c("reseeded", (l) => {
499
+ const n = l;
500
+ if (typeof l != "object" || l === null || typeof n.success != "boolean" || !Array.isArray(n.schemas)) {
501
+ console.warn("[ModelsPage] Invalid reseeded payload:", l);
502
+ return;
503
+ }
504
+ e.handleReseedComplete(l), p.value = -1;
505
+ }), H(
506
+ () => e.selectedSchema,
507
+ async () => {
508
+ p.value = -1, d.value && e.currentItems.length > 0 && (await oe(), d.value?.formatJson());
509
+ }
510
+ ), H(
511
+ () => e.currentItems,
512
+ (l, n) => {
513
+ const S = p.value;
514
+ if (S < 0) return;
515
+ if (S >= l.length) {
516
+ p.value = -1;
517
+ return;
518
+ }
519
+ const R = e.currentSchema?.idField ?? "id", a = n?.[S], _ = l[S];
520
+ if (a !== _) {
521
+ if (typeof a == "object" && a !== null && typeof _ == "object" && _ !== null) {
522
+ const I = a[R], D = _[R];
523
+ if (I !== void 0 && I === D) return;
524
+ }
525
+ p.value = -1;
526
+ }
527
+ }
528
+ );
529
+ async function x(l) {
530
+ e.isDirty && !await g(
531
+ "You have unsaved changes. Are you sure you want to switch schemas?",
532
+ {
533
+ title: "Unsaved Changes",
534
+ confirmText: "Switch Schema",
535
+ cancelText: "Cancel"
536
+ }
537
+ ) || await e.selectSchemaByName(l);
538
+ }
539
+ async function F() {
540
+ if (!d.value?.isValid) {
541
+ y("Cannot save invalid JSON. Please fix the errors first.");
542
+ return;
543
+ }
544
+ if (await e.saveItems())
545
+ o("Items saved successfully");
546
+ else {
547
+ const n = e.error || "Failed to save items";
548
+ y(n);
549
+ }
550
+ }
551
+ async function j() {
552
+ if (!e.isDirty) return;
553
+ await g("Discard all changes and revert to saved data?", {
554
+ title: "Discard Changes",
555
+ confirmText: "Discard",
556
+ cancelText: "Cancel"
557
+ }) && (e.discardChanges(), o("Changes discarded"));
558
+ }
559
+ async function O() {
560
+ v.value = !1;
561
+ try {
562
+ if (await e.clearSchema())
563
+ o("Schema cleared successfully");
564
+ else {
565
+ const n = e.error || "Failed to clear schema";
566
+ y(n);
567
+ }
568
+ } catch (l) {
569
+ const n = l instanceof Error ? l.message : "Failed to clear schema";
570
+ y(n);
571
+ }
572
+ }
573
+ async function h() {
574
+ if (!u.value) {
575
+ y("WebSocket not connected. Cannot trigger reseed.");
576
+ return;
577
+ }
578
+ await g(
579
+ "This will regenerate all seed data and replace existing items. Continue?",
580
+ {
581
+ title: "Reseed All Schemas",
582
+ confirmText: "Reseed",
583
+ cancelText: "Cancel"
584
+ }
585
+ ) && (i({ type: "reseed" }), o("Reseed command sent"));
586
+ }
587
+ function b(l) {
588
+ e.updateItems(l);
589
+ }
590
+ function $(l) {
591
+ p.value = p.value === l ? -1 : l;
592
+ }
593
+ return (l, n) => (f(), m("div", qe, [
594
+ s("aside", We, [
595
+ s("div", Xe, [
596
+ E(r(K), { size: 18 }),
597
+ n[4] || (n[4] = s("span", null, "Schemas", -1)),
598
+ s("span", Ye, C(r(e).schemaCount), 1)
599
+ ]),
600
+ r(e).loading && r(e).schemas.length === 0 ? (f(), m("div", Ge, [...n[5] || (n[5] = [
601
+ s("div", { class: "spinner" }, null, -1),
602
+ s("span", null, "Loading...", -1)
603
+ ])])) : (f(), m("div", Qe, [
604
+ (f(!0), m(J, null, A(r(e).schemas, (S) => (f(), m("button", {
605
+ key: S.name,
606
+ class: B([
607
+ "models-sidebar__item",
608
+ { "models-sidebar__item--active": r(e).selectedSchema === S.name }
609
+ ]),
610
+ onClick: (R) => x(S.name)
611
+ }, [
612
+ s("span", et, C(S.name), 1),
613
+ s("span", tt, C(S.count), 1)
614
+ ], 10, Ze))), 128))
615
+ ])),
616
+ s("div", st, [
617
+ s("div", nt, [
618
+ n[6] || (n[6] = s("span", { class: "text-muted" }, "Total Items:", -1)),
619
+ s("span", at, C(r(e).totalItems), 1)
620
+ ])
621
+ ])
622
+ ]),
623
+ s("main", ot, [
624
+ r(e).selectedSchema ? (f(), m(J, { key: 0 }, [
625
+ s("div", lt, [
626
+ s("div", rt, [
627
+ s("span", it, C(r(e).selectedSchema), 1),
628
+ s("span", ct, "(" + C(r(e).currentItems.length) + " items)", 1),
629
+ r(e).isDirty ? (f(), m("span", dt, " Unsaved ")) : N("", !0)
630
+ ]),
631
+ s("div", ut, [
632
+ r(e).isDirty ? (f(), m("button", {
633
+ key: 0,
634
+ class: "btn btn--ghost",
635
+ title: "Discard changes",
636
+ onClick: j
637
+ }, [
638
+ E(r(fe), { size: 16 }),
639
+ n[7] || (n[7] = s("span", null, "Discard", -1))
640
+ ])) : N("", !0),
641
+ s("button", {
642
+ disabled: !r(e).isDirty || r(e).loading,
643
+ class: "btn btn--primary",
644
+ title: "Save changes",
645
+ onClick: F
646
+ }, [
647
+ E(r(_e), { size: 16 }),
648
+ n[8] || (n[8] = s("span", null, "Save", -1))
649
+ ], 8, ft),
650
+ s("button", {
651
+ class: "btn btn--danger",
652
+ title: "Clear all items",
653
+ onClick: n[0] || (n[0] = (S) => v.value = !0)
654
+ }, [
655
+ E(r(me), { size: 16 }),
656
+ n[9] || (n[9] = s("span", null, "Clear", -1))
657
+ ]),
658
+ s("button", {
659
+ disabled: !r(u),
660
+ class: "btn btn--secondary",
661
+ title: "Reseed all schemas with generated data",
662
+ onClick: h
663
+ }, [
664
+ E(r(he), { size: 16 }),
665
+ n[10] || (n[10] = s("span", null, "Reseed All", -1))
666
+ ], 8, mt)
667
+ ])
668
+ ]),
669
+ r(e).error ? (f(), m("div", vt, [
670
+ s("span", null, "⚠️ " + C(r(e).error), 1)
671
+ ])) : N("", !0),
672
+ s("div", ht, [
673
+ s("div", _t, [
674
+ E(Be, {
675
+ ref_key: "jsonEditorRef",
676
+ ref: d,
677
+ "model-value": r(e).currentItems,
678
+ readonly: r(e).loading,
679
+ "min-height": 400,
680
+ "onUpdate:modelValue": b
681
+ }, null, 8, ["model-value", "readonly"])
682
+ ]),
683
+ s("div", yt, [
684
+ E(De, {
685
+ items: r(e).currentItems,
686
+ "id-field": r(e).currentSchema?.idField ?? "id",
687
+ "selected-index": p.value,
688
+ onSelect: $
689
+ }, null, 8, ["items", "id-field", "selected-index"])
690
+ ])
691
+ ]),
692
+ r(e).loading ? (f(), m("div", pt, [...n[11] || (n[11] = [
693
+ s("div", { class: "spinner" }, null, -1),
694
+ s("span", null, "Loading...", -1)
695
+ ])])) : N("", !0)
696
+ ], 64)) : (f(), m("div", gt, [
697
+ r(e).error ? (f(), m("div", bt, [
698
+ s("span", null, "⚠️ " + C(r(e).error), 1)
699
+ ])) : (f(), m(J, { key: 1 }, [
700
+ E(r(K), {
701
+ size: 48,
702
+ class: "empty-state__icon"
703
+ }),
704
+ n[12] || (n[12] = s("h3", { class: "empty-state__title" }, "Select a schema", -1)),
705
+ n[13] || (n[13] = s("p", { class: "empty-state__description" }, " Choose a schema from the sidebar to view and edit its data. ", -1))
706
+ ], 64))
707
+ ]))
708
+ ]),
709
+ (f(), le(re, { to: "body" }, [
710
+ v.value ? (f(), m("div", {
711
+ key: 0,
712
+ class: "modal-overlay",
713
+ onClick: n[3] || (n[3] = (S) => v.value = !1)
714
+ }, [
715
+ s("div", {
716
+ class: "modal",
717
+ onClick: n[2] || (n[2] = ie(() => {
718
+ }, ["stop"]))
719
+ }, [
720
+ n[17] || (n[17] = s("div", { class: "modal__header" }, [
721
+ s("h3", null, "Clear Schema Data")
722
+ ], -1)),
723
+ s("div", St, [
724
+ s("p", null, [
725
+ n[14] || (n[14] = G(" Are you sure you want to clear all items for ", -1)),
726
+ s("strong", null, C(r(e).selectedSchema), 1),
727
+ n[15] || (n[15] = G("? ", -1))
728
+ ]),
729
+ n[16] || (n[16] = s("p", { class: "text-muted" }, "This action cannot be undone.", -1))
730
+ ]),
731
+ s("div", Ct, [
732
+ s("button", {
733
+ class: "btn btn--ghost",
734
+ onClick: n[1] || (n[1] = (S) => v.value = !1)
735
+ }, " Cancel "),
736
+ s("button", {
737
+ class: "btn btn--danger",
738
+ onClick: O
739
+ }, " Clear Schema ")
740
+ ])
741
+ ])
742
+ ])) : N("", !0)
743
+ ]))
744
+ ]));
745
+ }
746
+ }), jt = /* @__PURE__ */ X(kt, [["__scopeId", "data-v-353edfbc"]]);
747
+ export {
748
+ jt as default
749
+ };
750
+ //# sourceMappingURL=ModelsPage-C1LQvwFk.js.map