vue3-django 0.1.0

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 (43) hide show
  1. package/README.md +92 -0
  2. package/dist/vue3-django.css +1 -0
  3. package/dist/vue3-django.js +4439 -0
  4. package/docs/iteration-01-preview.jpg +0 -0
  5. package/docs/iterations.md +37 -0
  6. package/docs/migration.md +133 -0
  7. package/docs/verification.md +25 -0
  8. package/package.json +53 -0
  9. package/src/components/form/Field.vue +113 -0
  10. package/src/components/form/Form.js +49 -0
  11. package/src/components/form/Form.vue +285 -0
  12. package/src/components/layout/Actions.vue +132 -0
  13. package/src/components/layout/Drawer.vue +87 -0
  14. package/src/components/layout/Layout.vue +193 -0
  15. package/src/components/layout/SideBar.vue +57 -0
  16. package/src/components/layout/ViewTabs.vue +136 -0
  17. package/src/components/mobile/Form.vue +16 -0
  18. package/src/components/model/Create.vue +20 -0
  19. package/src/components/model/Form.vue +136 -0
  20. package/src/components/model/Relations.vue +236 -0
  21. package/src/components/model/Search.vue +103 -0
  22. package/src/components/model/Select.vue +91 -0
  23. package/src/components/model/Table.vue +335 -0
  24. package/src/components/table/Widget.vue +195 -0
  25. package/src/components/widgets/ForeignKey.vue +58 -0
  26. package/src/components/widgets/Icon.vue +37 -0
  27. package/src/composables/context.js +16 -0
  28. package/src/composables/drawer.js +19 -0
  29. package/src/composables/tab.js +7 -0
  30. package/src/configs/axios.js +2 -0
  31. package/src/core/auth.js +68 -0
  32. package/src/core/http.js +52 -0
  33. package/src/core/menus.js +39 -0
  34. package/src/core/metadata.js +50 -0
  35. package/src/core/registry.js +127 -0
  36. package/src/core/relations.js +74 -0
  37. package/src/core/table.js +48 -0
  38. package/src/core/views.js +23 -0
  39. package/src/index.js +31 -0
  40. package/src/router/index.js +78 -0
  41. package/src/style.css +23 -0
  42. package/src/utils/app_model.js +2 -0
  43. package/src/utils/array_normalize.js +1 -0
@@ -0,0 +1,4439 @@
1
+ import Da from "axios";
2
+ import kr from "qs";
3
+ import { inject as Ct, reactive as Rr, ref as q, computed as X, watch as Ee, openBlock as p, createElementBlock as R, Fragment as G, createVNode as U, unref as A, withCtx as C, renderList as ne, createBlock as _, createCommentVNode as Q, toDisplayString as Y, resolveDynamicComponent as Qe, withDirectives as Ma, vModelSelect as Ca, useAttrs as Na, renderSlot as ye, createTextVNode as Z, mergeProps as Me, withModifiers as Dr, nextTick as yn, createSlots as Mr, normalizeProps as Cr, guardReactiveProps as Nr, toRaw as Fa, resolveComponent as $a, normalizeClass as Nt, normalizeStyle as Qn, createElementVNode as we, shallowRef as ot, defineComponent as La, shallowReactive as Zn, provide as ln, h as Jn, markRaw as er } from "vue";
4
+ import { createRouter as Pa, createWebHashHistory as Ia, routerKey as ja, RouterLink as Fr, useRoute as gn, useRouter as $r, routeLocationKey as Va, RouterView as on } from "vue-router";
5
+ import { ElSelect as vn, ElOption as Dt, ElAlert as Pe, ElSwitch as Ua, ElInputNumber as za, ElDatePicker as qa, ElInput as Lr, ElForm as Ba, ElRow as Ha, ElCol as tr, ElFormItem as nr, ElButton as ve, ElMessage as Wa, ElAvatar as Ga, ElImage as Ya, ElTag as Xa, ElDrawer as Pr, ElTable as Ka, ElTableColumn as rr, ElPagination as Qa, ElTabs as Ir, ElTabPane as jr, ElMenu as Za, ElSubMenu as Ja, ElMenuItem as ar, ElButtonGroup as ei, ElDropdown as ti, ElDropdownMenu as ni, ElDropdownItem as ri, ElMessageBox as ai, ElDialog as ii } from "element-plus";
6
+ import { Switch as li, Field as Vr, Form as oi, NoticeBar as hn, Button as st, Search as si, CellGroup as ui, Cell as ir, Pagination as ci } from "vant";
7
+ function Ur(t = {}) {
8
+ return typeof t == "string" ? { non_field_errors: t } : Array.isArray(t) ? { non_field_errors: t.join(";") } : Object.fromEntries(
9
+ Object.entries(t).map(([e, n]) => [
10
+ e,
11
+ Array.isArray(n) ? n.map((r) => typeof r == "object" ? JSON.stringify(r) : String(r)).join(";") : typeof n == "object" && n !== null ? JSON.stringify(n) : String(n)
12
+ ])
13
+ );
14
+ }
15
+ class lr extends Error {
16
+ constructor(e) {
17
+ const n = e.response?.data ?? e.msg ?? e.message;
18
+ super(typeof n == "string" ? n : n?.detail ?? "请求失败"), this.name = "DrfError", this.code = e.response?.status ?? e.code ?? -1, this.msg = n, this.fields = this.code === 400 ? Ur(n) : {}, this.cause = e;
19
+ }
20
+ }
21
+ function zr(t = {}) {
22
+ const e = Da.create({
23
+ baseURL: "/api/",
24
+ xsrfCookieName: "csrftoken",
25
+ xsrfHeaderName: "X-CSRFToken",
26
+ headers: { "X-Requested-With": "XMLHttpRequest" },
27
+ paramsSerializer: (n) => kr.stringify(n, { arrayFormat: "comma", skipNulls: !0 }),
28
+ ...t
29
+ });
30
+ return e.interceptors.response.use(
31
+ (n) => n,
32
+ (n) => Promise.reject(n instanceof lr ? n : new lr(n))
33
+ ), e.setBaseURL = (n) => {
34
+ e.defaults.baseURL = n;
35
+ }, e.setAuthToken = (n) => {
36
+ n ? e.defaults.headers.common.Authorization = `Token ${n}` : delete e.defaults.headers.common.Authorization;
37
+ }, e;
38
+ }
39
+ function bn(t = "all", e = {}, n = (r) => r) {
40
+ return (t === "all" ? Object.keys(e) : t).map((a) => {
41
+ const l = typeof a == "string" ? a : a.name;
42
+ return n({ ...e[l], ...typeof a == "string" ? {} : a, name: l });
43
+ });
44
+ }
45
+ function fi(t = {}, e = "POST") {
46
+ const n = t.actions ?? {};
47
+ return Object.fromEntries(
48
+ Object.entries({ ...n.LIST, ...n[e] ?? n.POST }).map(
49
+ ([r, a]) => [r, { ...a, name: r }]
50
+ )
51
+ );
52
+ }
53
+ function qr(t, e = {}) {
54
+ return Object.fromEntries(
55
+ Object.entries(t).filter(([, n]) => !n.read_only).map(([n, r]) => {
56
+ const a = Object.hasOwn(e, n) ? e[n] : r.default !== void 0 ? r.default : r.multiple ? [] : r.type === "boolean" ? !0 : r.type === "string" ? "" : r.type === "nested object" ? {} : null;
57
+ return [n, structuredClone(a)];
58
+ })
59
+ );
60
+ }
61
+ function di(t, e) {
62
+ return Object.fromEntries(
63
+ Object.entries(t).filter(([n]) => e[n] && !e[n].read_only)
64
+ );
65
+ }
66
+ function at(t, e) {
67
+ const n = (r) => t.choices?.find((a) => a.value === r)?.display_name ?? r;
68
+ return Array.isArray(e) ? e.map(n).join("、") : e == null ? "—" : t.choices ? n(e) : typeof e == "boolean" ? e ? "是" : "否" : typeof e == "object" ? JSON.stringify(e) : e;
69
+ }
70
+ function mi({
71
+ http: t = zr(),
72
+ apps: e = {},
73
+ views: n = {},
74
+ loadViewsConfig: r
75
+ } = {}) {
76
+ const a = /* @__PURE__ */ Object.create(null), l = /* @__PURE__ */ new Map(), o = {
77
+ http: t,
78
+ configs: a,
79
+ register(s) {
80
+ for (const [u, m] of Object.entries(s))
81
+ for (const [h, g] of Object.entries(m.models ?? {})) {
82
+ const v = `${u}.${h}`;
83
+ a[v] = { ...g, app: u, name: h, fullName: v }, l.delete(v);
84
+ }
85
+ return o;
86
+ },
87
+ getConfig(s) {
88
+ if (!a[s]) throw new Error(`model ${s} not found!`);
89
+ return a[s];
90
+ },
91
+ get(s) {
92
+ return l.has(s) || l.set(s, pi(o.getConfig(s), { http: t, views: n, loadViewsConfig: r })), l.get(s);
93
+ }
94
+ };
95
+ return o.register(e);
96
+ }
97
+ function pi(t, { http: e = zr(), views: n = {}, loadViewsConfig: r } = {}) {
98
+ const a = t.fullName ?? `${t.app}.${t.name}`, l = t.url ?? `${t.app}/${t.name}/`;
99
+ let o, s;
100
+ const u = {
101
+ config: t,
102
+ name: t.name,
103
+ fullName: a,
104
+ appModel: a,
105
+ listUrl: l,
106
+ verboseName: t.verbose_name ?? t.name,
107
+ title_field: t.title_field ?? "name",
108
+ getListUrl: () => l,
109
+ getDetailUrl(m) {
110
+ if (m == null || m === "") throw new Error("详情请求需要主键");
111
+ return `${l}${encodeURIComponent(m)}/`;
112
+ },
113
+ loadOptions() {
114
+ return t.rest_options ? Promise.resolve(t.rest_options) : (o || (o = e.options(l).then(({ data: m }) => {
115
+ if (!m || typeof m != "object" || Array.isArray(m) || !Object.keys(m).length)
116
+ throw new Error(
117
+ `模型 ${a} 的 OPTIONS 返回空或无效元数据,请检查 API 代理是否拦截了 OPTIONS 请求`
118
+ );
119
+ return t.rest_options = m, m;
120
+ }).finally(() => {
121
+ o = void 0;
122
+ })), o);
123
+ },
124
+ loadViewsConfig() {
125
+ return s || (s = Promise.resolve().then(() => n[a] ?? (r ? r(a) : {})).catch((m) => {
126
+ throw s = void 0, m;
127
+ })), s;
128
+ },
129
+ async fields(m = "POST") {
130
+ return fi(await u.loadOptions(), m);
131
+ },
132
+ loadObject(m) {
133
+ return e.get(u.getDetailUrl(m)).then((h) => h.data);
134
+ },
135
+ query(m = {}, h = l) {
136
+ return e.get(h, { params: m }).then((g) => g.data);
137
+ },
138
+ async save(m, h, g = {}) {
139
+ const v = await u.fields(h == null ? "POST" : "PATCH"), d = di({ ...g, ...m }, v);
140
+ return (h == null ? await e.post(l, d) : await e.patch(u.getDetailUrl(h), d)).data;
141
+ },
142
+ destroy(m) {
143
+ return e.delete(u.getDetailUrl(m)).then((h) => h.data);
144
+ },
145
+ doAction(m, h = {}, g = "post", v) {
146
+ if (!/^[\w-]+$/.test(m)) throw new Error("动作名只能包含字母、数字、下划线和连字符");
147
+ const d = `${v == null ? l : u.getDetailUrl(v)}${m}/`;
148
+ return e.request({
149
+ url: d,
150
+ method: g,
151
+ ...["get", "head"].includes(g.toLowerCase()) ? { params: h } : { data: h }
152
+ }).then((b) => b.data);
153
+ },
154
+ genEmptyDataFromRestOptions: qr
155
+ };
156
+ return u;
157
+ }
158
+ const yi = mi(), Br = /* @__PURE__ */ Symbol("vue3-django");
159
+ function Ie() {
160
+ return Ct(Br, { registry: yi });
161
+ }
162
+ function Po({ registry: t, ...e }) {
163
+ return {
164
+ install(n) {
165
+ const r = { registry: t, ...e };
166
+ n.provide(Br, r), n.config.globalProperties.$http = t.http, n.config.globalProperties.$django = r;
167
+ }
168
+ };
169
+ }
170
+ function Io({ http: t, endpoints: e = {}, cookieName: n = "access_token" }) {
171
+ const r = {
172
+ login: "auth/user/login/",
173
+ current: "auth/user/current/",
174
+ logout: "auth/user/logout/",
175
+ ...e
176
+ }, a = Rr({ user: null, ready: !1 });
177
+ let l;
178
+ function o() {
179
+ if (typeof document > "u") return;
180
+ const v = document.cookie.split("; ").find((d) => d.startsWith(`${n}=`));
181
+ return v ? decodeURIComponent(v.slice(n.length + 1)) : void 0;
182
+ }
183
+ function s(v) {
184
+ v ? t.defaults.headers.common.Authorization = `Bearer ${v}` : delete t.defaults.headers.common.Authorization, typeof document < "u" && (document.cookie = `${n}=${encodeURIComponent(v || "")}; Path=/; SameSite=Lax${v ? "" : "; Max-Age=0"}${location.protocol === "https:" ? "; Secure" : ""}`);
185
+ }
186
+ const u = o();
187
+ u && (t.defaults.headers.common.Authorization = `Bearer ${u}`);
188
+ async function m() {
189
+ return l || (l = t.get(r.current).then(({ data: v }) => (a.user = v, a.ready = !0, v)).finally(() => {
190
+ l = void 0;
191
+ })), l;
192
+ }
193
+ async function h(v, d) {
194
+ const { data: b } = await t.post(r.login, { username: v, password: d });
195
+ b.token?.access && s(b.token.access);
196
+ try {
197
+ await m();
198
+ } catch (c) {
199
+ throw s(null), a.user = null, c;
200
+ }
201
+ return b;
202
+ }
203
+ async function g() {
204
+ const { data: v } = await t.get(r.logout);
205
+ return s(null), a.user = null, a.ready = !1, v;
206
+ }
207
+ return {
208
+ state: a,
209
+ getToken: o,
210
+ setToken: s,
211
+ removeToken: () => s(null),
212
+ getUserInfo: m,
213
+ login: h,
214
+ logout: g
215
+ };
216
+ }
217
+ function jo(t, e = "/") {
218
+ return typeof t == "string" && t.startsWith("/") && !t.startsWith("//") && !t.includes("\\") && !t.startsWith("/auth/login") ? t : e;
219
+ }
220
+ function Vo({
221
+ routes: t = [],
222
+ auth: e,
223
+ history: n = Ia(),
224
+ loginPath: r = "/auth/login/"
225
+ }) {
226
+ const a = Pa({ history: n, routes: t });
227
+ return e && a.beforeEach(async (l) => {
228
+ if (l.path.replace(/\/$/, "") === r.replace(/\/$/, "") || l.meta.loginRequired === !1)
229
+ return !0;
230
+ if (!e.state.user)
231
+ try {
232
+ await e.getUserInfo();
233
+ } catch (o) {
234
+ if (![401, 403].includes(o.code ?? o.response?.status)) throw o;
235
+ return e.removeToken(), { path: r, query: { redirect: l.fullPath } };
236
+ }
237
+ return !0;
238
+ }), a;
239
+ }
240
+ function Uo(t, e) {
241
+ const n = typeof e == "object" && e.list ? e : { list: e, create: e, edit: e };
242
+ return Object.entries(t).flatMap(
243
+ ([r, a]) => a.hidden === !0 || a.hidden === "true" ? [] : Object.entries(a.models ?? {}).flatMap(([l, o]) => {
244
+ const s = `/${r}/${l}/`, u = `${r}.${l}`, m = o.verbose_name ?? l;
245
+ return [
246
+ {
247
+ path: s,
248
+ name: `${r}-${l}-list`,
249
+ component: n.list,
250
+ props: { appModel: u, mode: "list" },
251
+ meta: { title: `${m}列表`, model: o }
252
+ },
253
+ {
254
+ path: `${s}add/`,
255
+ name: `${r}-${l}-add`,
256
+ component: n.create ?? n.edit,
257
+ props: { appModel: u, mode: "create" },
258
+ meta: { title: `新增${m}`, model: o }
259
+ },
260
+ {
261
+ path: `${s}:id/`,
262
+ name: `${r}-${l}-edit`,
263
+ component: n.edit,
264
+ props: (h) => ({ appModel: u, mode: "edit", id: h.params.id }),
265
+ meta: { title: `编辑${m}`, model: o }
266
+ }
267
+ ];
268
+ })
269
+ );
270
+ }
271
+ const Hr = {
272
+ __name: "Select",
273
+ props: {
274
+ appModel: String,
275
+ modelValue: [String, Number, Array],
276
+ field: { type: Object, default: () => ({}) },
277
+ pageSize: { type: Number, default: 30 }
278
+ },
279
+ emits: ["update:modelValue", "error"],
280
+ setup(t, { emit: e }) {
281
+ const n = t, r = e, { registry: a } = Ie(), l = q([]), o = q([]), s = q(!1), u = q("");
282
+ let m = 0;
283
+ const h = X(() => n.field.idField || "id"), g = X(() => [
284
+ ...new Map([...o.value, ...l.value].map((d) => [d[h.value], d])).values()
285
+ ]);
286
+ async function v(d = "") {
287
+ const b = ++m;
288
+ s.value = !0, u.value = "";
289
+ try {
290
+ const c = a.get(n.appModel), S = Array.isArray(n.modelValue) ? n.modelValue : n.modelValue == null ? [] : [n.modelValue], [y, $] = await Promise.all([
291
+ c.query({
292
+ ...n.field.baseQueries,
293
+ search: d || void 0,
294
+ page_size: n.pageSize
295
+ }),
296
+ S.length ? c.query({
297
+ ...n.field.baseQueries,
298
+ [`${h.value}__in`]: S,
299
+ page_size: S.length
300
+ }) : []
301
+ ]);
302
+ if (b !== m) return;
303
+ l.value = y.results ?? y, o.value = $.results ?? $;
304
+ } catch (c) {
305
+ b === m && (u.value = c.message, r("error", c));
306
+ } finally {
307
+ b === m && (s.value = !1);
308
+ }
309
+ }
310
+ return Ee(
311
+ () => [n.appModel, n.modelValue, n.field.baseQueries],
312
+ () => v(),
313
+ { immediate: !0, deep: !0 }
314
+ ), (d, b) => (p(), R(G, null, [
315
+ U(A(vn), {
316
+ "model-value": t.modelValue,
317
+ multiple: t.field.multiple,
318
+ loading: s.value,
319
+ filterable: "",
320
+ remote: "",
321
+ clearable: "",
322
+ "remote-method": v,
323
+ placeholder: t.field.placeholder || `请选择${t.field.label || ""}`,
324
+ style: { width: "100%" },
325
+ "onUpdate:modelValue": b[0] || (b[0] = (c) => r("update:modelValue", c === "" ? null : c))
326
+ }, {
327
+ default: C(() => [
328
+ (p(!0), R(G, null, ne(g.value, (c) => (p(), _(A(Dt), {
329
+ key: c[h.value],
330
+ value: c[h.value],
331
+ label: String(c.__str__ ?? c.name ?? c.title ?? c[h.value])
332
+ }, null, 8, ["value", "label"]))), 128))
333
+ ]),
334
+ _: 1
335
+ }, 8, ["model-value", "multiple", "loading", "placeholder"]),
336
+ u.value ? (p(), _(A(Pe), {
337
+ key: 0,
338
+ title: u.value,
339
+ type: "error",
340
+ closable: !1
341
+ }, null, 8, ["title"])) : Q("", !0)
342
+ ], 64));
343
+ }
344
+ }, gi = { key: 0 }, vi = ["multiple", "aria-label"], hi = {
345
+ key: 0,
346
+ value: null
347
+ }, bi = ["value"], Mt = {
348
+ __name: "Field",
349
+ props: {
350
+ field: { type: Object, required: !0 },
351
+ modelValue: null,
352
+ mobile: Boolean
353
+ },
354
+ emits: ["update:modelValue"],
355
+ setup(t, { emit: e }) {
356
+ const n = t, r = e, a = X({ get: () => n.modelValue, set: (s) => r("update:modelValue", s) }), l = X(() => ["integer", "decimal", "float"].includes(n.field.type));
357
+ function o(s) {
358
+ a.value = l.value ? s === "" ? null : Number(s) : s;
359
+ }
360
+ return (s, u) => t.field.read_only ? (p(), R("span", gi, Y(A(at)(t.field, a.value)), 1)) : t.field.widget && typeof t.field.widget != "string" ? (p(), _(Qe(t.field.widget), {
361
+ key: 1,
362
+ modelValue: a.value,
363
+ "onUpdate:modelValue": u[0] || (u[0] = (m) => a.value = m),
364
+ field: t.field
365
+ }, null, 8, ["modelValue", "field"])) : t.field.model || t.field.relateModel ? (p(), _(Hr, {
366
+ key: 2,
367
+ modelValue: a.value,
368
+ "onUpdate:modelValue": u[1] || (u[1] = (m) => a.value = m),
369
+ "app-model": t.field.relateModel || t.field.model,
370
+ field: t.field
371
+ }, null, 8, ["modelValue", "app-model", "field"])) : t.mobile ? (p(), R(G, { key: 3 }, [
372
+ t.field.type === "boolean" ? (p(), _(A(li), {
373
+ key: 0,
374
+ modelValue: a.value,
375
+ "onUpdate:modelValue": u[2] || (u[2] = (m) => a.value = m),
376
+ size: "22px"
377
+ }, null, 8, ["modelValue"])) : t.field.choices ? Ma((p(), R("select", {
378
+ key: 1,
379
+ "onUpdate:modelValue": u[3] || (u[3] = (m) => a.value = m),
380
+ multiple: t.field.multiple,
381
+ "aria-label": t.field.label || t.field.name
382
+ }, [
383
+ t.field.allow_null && !t.field.multiple ? (p(), R("option", hi, " 请选择 ")) : Q("", !0),
384
+ (p(!0), R(G, null, ne(t.field.choices, (m) => (p(), R("option", {
385
+ key: String(m.value),
386
+ value: m.value
387
+ }, Y(m.display_name), 9, bi))), 128))
388
+ ], 8, vi)), [
389
+ [Ca, a.value]
390
+ ]) : (p(), _(A(Vr), {
391
+ key: 2,
392
+ "model-value": a.value == null ? "" : String(a.value),
393
+ type: l.value ? "number" : t.field.widget === "textarea" ? "textarea" : "text",
394
+ placeholder: t.field.placeholder ?? t.field.help_text ?? "请输入",
395
+ "aria-label": t.field.label || t.field.name,
396
+ "onUpdate:modelValue": o
397
+ }, null, 8, ["model-value", "type", "placeholder", "aria-label"]))
398
+ ], 64)) : t.field.choices ? (p(), _(A(vn), {
399
+ key: 4,
400
+ modelValue: a.value,
401
+ "onUpdate:modelValue": u[4] || (u[4] = (m) => a.value = m),
402
+ multiple: t.field.multiple,
403
+ clearable: t.field.allow_null,
404
+ placeholder: t.field.placeholder,
405
+ "aria-label": t.field.label || t.field.name,
406
+ style: { width: "100%" }
407
+ }, {
408
+ default: C(() => [
409
+ (p(!0), R(G, null, ne(t.field.choices, (m) => (p(), _(A(Dt), {
410
+ key: String(m.value),
411
+ label: m.display_name,
412
+ value: m.value
413
+ }, null, 8, ["label", "value"]))), 128))
414
+ ]),
415
+ _: 1
416
+ }, 8, ["modelValue", "multiple", "clearable", "placeholder", "aria-label"])) : t.field.type === "boolean" ? (p(), _(A(Ua), {
417
+ key: 5,
418
+ modelValue: a.value,
419
+ "onUpdate:modelValue": u[5] || (u[5] = (m) => a.value = m)
420
+ }, null, 8, ["modelValue"])) : l.value ? (p(), _(A(za), {
421
+ key: 6,
422
+ modelValue: a.value,
423
+ "onUpdate:modelValue": u[6] || (u[6] = (m) => a.value = m),
424
+ precision: t.field.type === "integer" ? 0 : void 0,
425
+ min: t.field.min_value,
426
+ max: t.field.max_value,
427
+ placeholder: t.field.placeholder,
428
+ "aria-label": t.field.label || t.field.name
429
+ }, null, 8, ["modelValue", "precision", "min", "max", "placeholder", "aria-label"])) : ["date", "datetime"].includes(t.field.type) ? (p(), _(A(qa), {
430
+ key: 7,
431
+ modelValue: a.value,
432
+ "onUpdate:modelValue": u[7] || (u[7] = (m) => a.value = m),
433
+ type: t.field.type,
434
+ "value-format": t.field.type === "date" ? "YYYY-MM-DD" : "YYYY-MM-DDTHH:mm:ssZ",
435
+ placeholder: t.field.placeholder
436
+ }, null, 8, ["modelValue", "type", "value-format", "placeholder"])) : (p(), _(A(Lr), {
437
+ key: 8,
438
+ modelValue: a.value,
439
+ "onUpdate:modelValue": u[8] || (u[8] = (m) => a.value = m),
440
+ type: ["textarea", "password"].includes(t.field.widget) ? t.field.widget : "text",
441
+ maxlength: t.field.max_length,
442
+ autocomplete: t.field.autocomplete,
443
+ placeholder: t.field.placeholder ?? t.field.help_text,
444
+ "aria-label": t.field.label || t.field.name
445
+ }, null, 8, ["modelValue", "type", "maxlength", "autocomplete", "placeholder", "aria-label"]));
446
+ }
447
+ };
448
+ function wi(t) {
449
+ return t.multiple ? "array" : t.choices?.length ? typeof t.choices[0].value : t.model || ["integer", "decimal", "float", "number"].includes(t.type) ? "number" : t.type === "boolean" ? "boolean" : "string";
450
+ }
451
+ function Ei(t) {
452
+ const e = [];
453
+ return t.required && !t.allow_null && e.push({ required: !0, type: wi(t), message: "不能为空" }), t.min_length != null && e.push({ min: t.min_length, message: `长度最小为${t.min_length}` }), t.max_length != null && e.push({ max: t.max_length, message: `长度最大为${t.max_length}` }), e;
454
+ }
455
+ function Ti(t = []) {
456
+ return t.map((e) => {
457
+ const n = typeof e == "string" ? { name: e } : { ...e }, r = typeof n.span == "number" ? { xs: n.span, sm: n.span, md: n.span, lg: n.span, xl: n.span } : n.span || {};
458
+ return {
459
+ type: "string",
460
+ ...n,
461
+ label: n.label ?? n.name,
462
+ rules: n.rules ?? Ei(n),
463
+ span: {
464
+ xs: 24,
465
+ sm: 24,
466
+ md: n.widget === "textarea" ? 24 : 12,
467
+ lg: n.widget === "textarea" ? 24 : 12,
468
+ xl: n.widget === "textarea" ? 24 : 8,
469
+ ...r
470
+ }
471
+ };
472
+ });
473
+ }
474
+ function Ai(t) {
475
+ return Object.fromEntries(
476
+ t.filter((e) => !e.hidden && !e.read_only && e.widget !== "hidden").map((e) => [e.name, e.rules])
477
+ );
478
+ }
479
+ function Le() {
480
+ return Le = Object.assign ? Object.assign.bind() : function(t) {
481
+ for (var e = 1; e < arguments.length; e++) {
482
+ var n = arguments[e];
483
+ for (var r in n)
484
+ Object.prototype.hasOwnProperty.call(n, r) && (t[r] = n[r]);
485
+ }
486
+ return t;
487
+ }, Le.apply(this, arguments);
488
+ }
489
+ function Si(t, e) {
490
+ t.prototype = Object.create(e.prototype), t.prototype.constructor = t, ft(t, e);
491
+ }
492
+ function sn(t) {
493
+ return sn = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(n) {
494
+ return n.__proto__ || Object.getPrototypeOf(n);
495
+ }, sn(t);
496
+ }
497
+ function ft(t, e) {
498
+ return ft = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(r, a) {
499
+ return r.__proto__ = a, r;
500
+ }, ft(t, e);
501
+ }
502
+ function Oi() {
503
+ if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
504
+ if (typeof Proxy == "function") return !0;
505
+ try {
506
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
507
+ })), !0;
508
+ } catch {
509
+ return !1;
510
+ }
511
+ }
512
+ function kt(t, e, n) {
513
+ return Oi() ? kt = Reflect.construct.bind() : kt = function(a, l, o) {
514
+ var s = [null];
515
+ s.push.apply(s, l);
516
+ var u = Function.bind.apply(a, s), m = new u();
517
+ return o && ft(m, o.prototype), m;
518
+ }, kt.apply(null, arguments);
519
+ }
520
+ function _i(t) {
521
+ return Function.toString.call(t).indexOf("[native code]") !== -1;
522
+ }
523
+ function un(t) {
524
+ var e = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
525
+ return un = function(r) {
526
+ if (r === null || !_i(r)) return r;
527
+ if (typeof r != "function")
528
+ throw new TypeError("Super expression must either be null or a function");
529
+ if (typeof e < "u") {
530
+ if (e.has(r)) return e.get(r);
531
+ e.set(r, a);
532
+ }
533
+ function a() {
534
+ return kt(r, arguments, sn(this).constructor);
535
+ }
536
+ return a.prototype = Object.create(r.prototype, {
537
+ constructor: {
538
+ value: a,
539
+ enumerable: !1,
540
+ writable: !0,
541
+ configurable: !0
542
+ }
543
+ }), ft(a, r);
544
+ }, un(t);
545
+ }
546
+ var xi = /%[sdj%]/g, Wr = function() {
547
+ };
548
+ typeof process < "u" && process.env && process.env.NODE_ENV !== "production" && typeof window < "u" && typeof document < "u" && (Wr = function(e, n) {
549
+ typeof console < "u" && console.warn && typeof ASYNC_VALIDATOR_NO_WARNING > "u" && n.every(function(r) {
550
+ return typeof r == "string";
551
+ }) && console.warn(e, n);
552
+ });
553
+ function cn(t) {
554
+ if (!t || !t.length) return null;
555
+ var e = {};
556
+ return t.forEach(function(n) {
557
+ var r = n.field;
558
+ e[r] = e[r] || [], e[r].push(n);
559
+ }), e;
560
+ }
561
+ function ge(t) {
562
+ for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), r = 1; r < e; r++)
563
+ n[r - 1] = arguments[r];
564
+ var a = 0, l = n.length;
565
+ if (typeof t == "function")
566
+ return t.apply(null, n);
567
+ if (typeof t == "string") {
568
+ var o = t.replace(xi, function(s) {
569
+ if (s === "%%")
570
+ return "%";
571
+ if (a >= l)
572
+ return s;
573
+ switch (s) {
574
+ case "%s":
575
+ return String(n[a++]);
576
+ case "%d":
577
+ return Number(n[a++]);
578
+ case "%j":
579
+ try {
580
+ return JSON.stringify(n[a++]);
581
+ } catch {
582
+ return "[Circular]";
583
+ }
584
+ break;
585
+ default:
586
+ return s;
587
+ }
588
+ });
589
+ return o;
590
+ }
591
+ return t;
592
+ }
593
+ function ki(t) {
594
+ return t === "string" || t === "url" || t === "hex" || t === "email" || t === "date" || t === "pattern";
595
+ }
596
+ function oe(t, e) {
597
+ return !!(t == null || e === "array" && Array.isArray(t) && !t.length || ki(e) && typeof t == "string" && !t);
598
+ }
599
+ function Ri(t, e, n) {
600
+ var r = [], a = 0, l = t.length;
601
+ function o(s) {
602
+ r.push.apply(r, s || []), a++, a === l && n(r);
603
+ }
604
+ t.forEach(function(s) {
605
+ e(s, o);
606
+ });
607
+ }
608
+ function or(t, e, n) {
609
+ var r = 0, a = t.length;
610
+ function l(o) {
611
+ if (o && o.length) {
612
+ n(o);
613
+ return;
614
+ }
615
+ var s = r;
616
+ r = r + 1, s < a ? e(t[s], l) : n([]);
617
+ }
618
+ l([]);
619
+ }
620
+ function Di(t) {
621
+ var e = [];
622
+ return Object.keys(t).forEach(function(n) {
623
+ e.push.apply(e, t[n] || []);
624
+ }), e;
625
+ }
626
+ var sr = /* @__PURE__ */ (function(t) {
627
+ Si(e, t);
628
+ function e(n, r) {
629
+ var a;
630
+ return a = t.call(this, "Async Validation Error") || this, a.errors = n, a.fields = r, a;
631
+ }
632
+ return e;
633
+ })(/* @__PURE__ */ un(Error));
634
+ function Mi(t, e, n, r, a) {
635
+ if (e.first) {
636
+ var l = new Promise(function(v, d) {
637
+ var b = function(y) {
638
+ return r(y), y.length ? d(new sr(y, cn(y))) : v(a);
639
+ }, c = Di(t);
640
+ or(c, n, b);
641
+ });
642
+ return l.catch(function(v) {
643
+ return v;
644
+ }), l;
645
+ }
646
+ var o = e.firstFields === !0 ? Object.keys(t) : e.firstFields || [], s = Object.keys(t), u = s.length, m = 0, h = [], g = new Promise(function(v, d) {
647
+ var b = function(S) {
648
+ if (h.push.apply(h, S), m++, m === u)
649
+ return r(h), h.length ? d(new sr(h, cn(h))) : v(a);
650
+ };
651
+ s.length || (r(h), v(a)), s.forEach(function(c) {
652
+ var S = t[c];
653
+ o.indexOf(c) !== -1 ? or(S, n, b) : Ri(S, n, b);
654
+ });
655
+ });
656
+ return g.catch(function(v) {
657
+ return v;
658
+ }), g;
659
+ }
660
+ function Ci(t) {
661
+ return !!(t && t.message !== void 0);
662
+ }
663
+ function Ni(t, e) {
664
+ for (var n = t, r = 0; r < e.length; r++) {
665
+ if (n == null)
666
+ return n;
667
+ n = n[e[r]];
668
+ }
669
+ return n;
670
+ }
671
+ function ur(t, e) {
672
+ return function(n) {
673
+ var r;
674
+ return t.fullFields ? r = Ni(e, t.fullFields) : r = e[n.field || t.fullField], Ci(n) ? (n.field = n.field || t.fullField, n.fieldValue = r, n) : {
675
+ message: typeof n == "function" ? n() : n,
676
+ fieldValue: r,
677
+ field: n.field || t.fullField
678
+ };
679
+ };
680
+ }
681
+ function cr(t, e) {
682
+ if (e) {
683
+ for (var n in e)
684
+ if (e.hasOwnProperty(n)) {
685
+ var r = e[n];
686
+ typeof r == "object" && typeof t[n] == "object" ? t[n] = Le({}, t[n], r) : t[n] = r;
687
+ }
688
+ }
689
+ return t;
690
+ }
691
+ var Gr = function(e, n, r, a, l, o) {
692
+ e.required && (!r.hasOwnProperty(e.field) || oe(n, o || e.type)) && a.push(ge(l.messages.required, e.fullField));
693
+ }, Fi = function(e, n, r, a, l) {
694
+ (/^\s+$/.test(n) || n === "") && a.push(ge(l.messages.whitespace, e.fullField));
695
+ }, _t, $i = (function() {
696
+ if (_t)
697
+ return _t;
698
+ var t = "[a-fA-F\\d:]", e = function(N) {
699
+ return N && N.includeBoundaries ? "(?:(?<=\\s|^)(?=" + t + ")|(?<=" + t + ")(?=\\s|$))" : "";
700
+ }, n = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}", r = "[a-fA-F\\d]{1,4}", a = (`
701
+ (?:
702
+ (?:` + r + ":){7}(?:" + r + `|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
703
+ (?:` + r + ":){6}(?:" + n + "|:" + r + `|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
704
+ (?:` + r + ":){5}(?::" + n + "|(?::" + r + `){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
705
+ (?:` + r + ":){4}(?:(?::" + r + "){0,1}:" + n + "|(?::" + r + `){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
706
+ (?:` + r + ":){3}(?:(?::" + r + "){0,2}:" + n + "|(?::" + r + `){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
707
+ (?:` + r + ":){2}(?:(?::" + r + "){0,3}:" + n + "|(?::" + r + `){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
708
+ (?:` + r + ":){1}(?:(?::" + r + "){0,4}:" + n + "|(?::" + r + `){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
709
+ (?::(?:(?::` + r + "){0,5}:" + n + "|(?::" + r + `){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
710
+ )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
711
+ `).replace(/\s*\/\/.*$/gm, "").replace(/\n/g, "").trim(), l = new RegExp("(?:^" + n + "$)|(?:^" + a + "$)"), o = new RegExp("^" + n + "$"), s = new RegExp("^" + a + "$"), u = function(N) {
712
+ return N && N.exact ? l : new RegExp("(?:" + e(N) + n + e(N) + ")|(?:" + e(N) + a + e(N) + ")", "g");
713
+ };
714
+ u.v4 = function(w) {
715
+ return w && w.exact ? o : new RegExp("" + e(w) + n + e(w), "g");
716
+ }, u.v6 = function(w) {
717
+ return w && w.exact ? s : new RegExp("" + e(w) + a + e(w), "g");
718
+ };
719
+ var m = "(?:(?:[a-z]+:)?//)", h = "(?:\\S+(?::\\S*)?@)?", g = u.v4().source, v = u.v6().source, d = "(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)", b = "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*", c = "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))", S = "(?::\\d{2,5})?", y = '(?:[/?#][^\\s"]*)?', $ = "(?:" + m + "|www\\.)" + h + "(?:localhost|" + g + "|" + v + "|" + d + b + c + ")" + S + y;
720
+ return _t = new RegExp("(?:^" + $ + "$)", "i"), _t;
721
+ }), fr = {
722
+ // http://emailregex.com/
723
+ email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
724
+ // url: new RegExp(
725
+ // '^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$',
726
+ // 'i',
727
+ // ),
728
+ hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
729
+ }, it = {
730
+ integer: function(e) {
731
+ return it.number(e) && parseInt(e, 10) === e;
732
+ },
733
+ float: function(e) {
734
+ return it.number(e) && !it.integer(e);
735
+ },
736
+ array: function(e) {
737
+ return Array.isArray(e);
738
+ },
739
+ regexp: function(e) {
740
+ if (e instanceof RegExp)
741
+ return !0;
742
+ try {
743
+ return !!new RegExp(e);
744
+ } catch {
745
+ return !1;
746
+ }
747
+ },
748
+ date: function(e) {
749
+ return typeof e.getTime == "function" && typeof e.getMonth == "function" && typeof e.getYear == "function" && !isNaN(e.getTime());
750
+ },
751
+ number: function(e) {
752
+ return isNaN(e) ? !1 : typeof e == "number";
753
+ },
754
+ object: function(e) {
755
+ return typeof e == "object" && !it.array(e);
756
+ },
757
+ method: function(e) {
758
+ return typeof e == "function";
759
+ },
760
+ email: function(e) {
761
+ return typeof e == "string" && e.length <= 320 && !!e.match(fr.email);
762
+ },
763
+ url: function(e) {
764
+ return typeof e == "string" && e.length <= 2048 && !!e.match($i());
765
+ },
766
+ hex: function(e) {
767
+ return typeof e == "string" && !!e.match(fr.hex);
768
+ }
769
+ }, Li = function(e, n, r, a, l) {
770
+ if (e.required && n === void 0) {
771
+ Gr(e, n, r, a, l);
772
+ return;
773
+ }
774
+ var o = ["integer", "float", "array", "regexp", "object", "method", "email", "number", "date", "url", "hex"], s = e.type;
775
+ o.indexOf(s) > -1 ? it[s](n) || a.push(ge(l.messages.types[s], e.fullField, e.type)) : s && typeof n !== e.type && a.push(ge(l.messages.types[s], e.fullField, e.type));
776
+ }, Pi = function(e, n, r, a, l) {
777
+ var o = typeof e.len == "number", s = typeof e.min == "number", u = typeof e.max == "number", m = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, h = n, g = null, v = typeof n == "number", d = typeof n == "string", b = Array.isArray(n);
778
+ if (v ? g = "number" : d ? g = "string" : b && (g = "array"), !g)
779
+ return !1;
780
+ b && (h = n.length), d && (h = n.replace(m, "_").length), o ? h !== e.len && a.push(ge(l.messages[g].len, e.fullField, e.len)) : s && !u && h < e.min ? a.push(ge(l.messages[g].min, e.fullField, e.min)) : u && !s && h > e.max ? a.push(ge(l.messages[g].max, e.fullField, e.max)) : s && u && (h < e.min || h > e.max) && a.push(ge(l.messages[g].range, e.fullField, e.min, e.max));
781
+ }, Ge = "enum", Ii = function(e, n, r, a, l) {
782
+ e[Ge] = Array.isArray(e[Ge]) ? e[Ge] : [], e[Ge].indexOf(n) === -1 && a.push(ge(l.messages[Ge], e.fullField, e[Ge].join(", ")));
783
+ }, ji = function(e, n, r, a, l) {
784
+ if (e.pattern) {
785
+ if (e.pattern instanceof RegExp)
786
+ e.pattern.lastIndex = 0, e.pattern.test(n) || a.push(ge(l.messages.pattern.mismatch, e.fullField, n, e.pattern));
787
+ else if (typeof e.pattern == "string") {
788
+ var o = new RegExp(e.pattern);
789
+ o.test(n) || a.push(ge(l.messages.pattern.mismatch, e.fullField, n, e.pattern));
790
+ }
791
+ }
792
+ }, B = {
793
+ required: Gr,
794
+ whitespace: Fi,
795
+ type: Li,
796
+ range: Pi,
797
+ enum: Ii,
798
+ pattern: ji
799
+ }, Vi = function(e, n, r, a, l) {
800
+ var o = [], s = e.required || !e.required && a.hasOwnProperty(e.field);
801
+ if (s) {
802
+ if (oe(n, "string") && !e.required)
803
+ return r();
804
+ B.required(e, n, a, o, l, "string"), oe(n, "string") || (B.type(e, n, a, o, l), B.range(e, n, a, o, l), B.pattern(e, n, a, o, l), e.whitespace === !0 && B.whitespace(e, n, a, o, l));
805
+ }
806
+ r(o);
807
+ }, Ui = function(e, n, r, a, l) {
808
+ var o = [], s = e.required || !e.required && a.hasOwnProperty(e.field);
809
+ if (s) {
810
+ if (oe(n) && !e.required)
811
+ return r();
812
+ B.required(e, n, a, o, l), n !== void 0 && B.type(e, n, a, o, l);
813
+ }
814
+ r(o);
815
+ }, zi = function(e, n, r, a, l) {
816
+ var o = [], s = e.required || !e.required && a.hasOwnProperty(e.field);
817
+ if (s) {
818
+ if (n === "" && (n = void 0), oe(n) && !e.required)
819
+ return r();
820
+ B.required(e, n, a, o, l), n !== void 0 && (B.type(e, n, a, o, l), B.range(e, n, a, o, l));
821
+ }
822
+ r(o);
823
+ }, qi = function(e, n, r, a, l) {
824
+ var o = [], s = e.required || !e.required && a.hasOwnProperty(e.field);
825
+ if (s) {
826
+ if (oe(n) && !e.required)
827
+ return r();
828
+ B.required(e, n, a, o, l), n !== void 0 && B.type(e, n, a, o, l);
829
+ }
830
+ r(o);
831
+ }, Bi = function(e, n, r, a, l) {
832
+ var o = [], s = e.required || !e.required && a.hasOwnProperty(e.field);
833
+ if (s) {
834
+ if (oe(n) && !e.required)
835
+ return r();
836
+ B.required(e, n, a, o, l), oe(n) || B.type(e, n, a, o, l);
837
+ }
838
+ r(o);
839
+ }, Hi = function(e, n, r, a, l) {
840
+ var o = [], s = e.required || !e.required && a.hasOwnProperty(e.field);
841
+ if (s) {
842
+ if (oe(n) && !e.required)
843
+ return r();
844
+ B.required(e, n, a, o, l), n !== void 0 && (B.type(e, n, a, o, l), B.range(e, n, a, o, l));
845
+ }
846
+ r(o);
847
+ }, Wi = function(e, n, r, a, l) {
848
+ var o = [], s = e.required || !e.required && a.hasOwnProperty(e.field);
849
+ if (s) {
850
+ if (oe(n) && !e.required)
851
+ return r();
852
+ B.required(e, n, a, o, l), n !== void 0 && (B.type(e, n, a, o, l), B.range(e, n, a, o, l));
853
+ }
854
+ r(o);
855
+ }, Gi = function(e, n, r, a, l) {
856
+ var o = [], s = e.required || !e.required && a.hasOwnProperty(e.field);
857
+ if (s) {
858
+ if (n == null && !e.required)
859
+ return r();
860
+ B.required(e, n, a, o, l, "array"), n != null && (B.type(e, n, a, o, l), B.range(e, n, a, o, l));
861
+ }
862
+ r(o);
863
+ }, Yi = function(e, n, r, a, l) {
864
+ var o = [], s = e.required || !e.required && a.hasOwnProperty(e.field);
865
+ if (s) {
866
+ if (oe(n) && !e.required)
867
+ return r();
868
+ B.required(e, n, a, o, l), n !== void 0 && B.type(e, n, a, o, l);
869
+ }
870
+ r(o);
871
+ }, Xi = "enum", Ki = function(e, n, r, a, l) {
872
+ var o = [], s = e.required || !e.required && a.hasOwnProperty(e.field);
873
+ if (s) {
874
+ if (oe(n) && !e.required)
875
+ return r();
876
+ B.required(e, n, a, o, l), n !== void 0 && B[Xi](e, n, a, o, l);
877
+ }
878
+ r(o);
879
+ }, Qi = function(e, n, r, a, l) {
880
+ var o = [], s = e.required || !e.required && a.hasOwnProperty(e.field);
881
+ if (s) {
882
+ if (oe(n, "string") && !e.required)
883
+ return r();
884
+ B.required(e, n, a, o, l), oe(n, "string") || B.pattern(e, n, a, o, l);
885
+ }
886
+ r(o);
887
+ }, Zi = function(e, n, r, a, l) {
888
+ var o = [], s = e.required || !e.required && a.hasOwnProperty(e.field);
889
+ if (s) {
890
+ if (oe(n, "date") && !e.required)
891
+ return r();
892
+ if (B.required(e, n, a, o, l), !oe(n, "date")) {
893
+ var u;
894
+ n instanceof Date ? u = n : u = new Date(n), B.type(e, u, a, o, l), u && B.range(e, u.getTime(), a, o, l);
895
+ }
896
+ }
897
+ r(o);
898
+ }, Ji = function(e, n, r, a, l) {
899
+ var o = [], s = Array.isArray(n) ? "array" : typeof n;
900
+ B.required(e, n, a, o, l, s), r(o);
901
+ }, Kt = function(e, n, r, a, l) {
902
+ var o = e.type, s = [], u = e.required || !e.required && a.hasOwnProperty(e.field);
903
+ if (u) {
904
+ if (oe(n, o) && !e.required)
905
+ return r();
906
+ B.required(e, n, a, s, l, o), oe(n, o) || B.type(e, n, a, s, l);
907
+ }
908
+ r(s);
909
+ }, el = function(e, n, r, a, l) {
910
+ var o = [], s = e.required || !e.required && a.hasOwnProperty(e.field);
911
+ if (s) {
912
+ if (oe(n) && !e.required)
913
+ return r();
914
+ B.required(e, n, a, o, l);
915
+ }
916
+ r(o);
917
+ }, ut = {
918
+ string: Vi,
919
+ method: Ui,
920
+ number: zi,
921
+ boolean: qi,
922
+ regexp: Bi,
923
+ integer: Hi,
924
+ float: Wi,
925
+ array: Gi,
926
+ object: Yi,
927
+ enum: Ki,
928
+ pattern: Qi,
929
+ date: Zi,
930
+ url: Kt,
931
+ hex: Kt,
932
+ email: Kt,
933
+ required: Ji,
934
+ any: el
935
+ };
936
+ function fn() {
937
+ return {
938
+ default: "Validation error on field %s",
939
+ required: "%s is required",
940
+ enum: "%s must be one of %s",
941
+ whitespace: "%s cannot be empty",
942
+ date: {
943
+ format: "%s date %s is invalid for format %s",
944
+ parse: "%s date could not be parsed, %s is invalid ",
945
+ invalid: "%s date %s is invalid"
946
+ },
947
+ types: {
948
+ string: "%s is not a %s",
949
+ method: "%s is not a %s (function)",
950
+ array: "%s is not an %s",
951
+ object: "%s is not an %s",
952
+ number: "%s is not a %s",
953
+ date: "%s is not a %s",
954
+ boolean: "%s is not a %s",
955
+ integer: "%s is not an %s",
956
+ float: "%s is not a %s",
957
+ regexp: "%s is not a valid %s",
958
+ email: "%s is not a valid %s",
959
+ url: "%s is not a valid %s",
960
+ hex: "%s is not a valid %s"
961
+ },
962
+ string: {
963
+ len: "%s must be exactly %s characters",
964
+ min: "%s must be at least %s characters",
965
+ max: "%s cannot be longer than %s characters",
966
+ range: "%s must be between %s and %s characters"
967
+ },
968
+ number: {
969
+ len: "%s must equal %s",
970
+ min: "%s cannot be less than %s",
971
+ max: "%s cannot be greater than %s",
972
+ range: "%s must be between %s and %s"
973
+ },
974
+ array: {
975
+ len: "%s must be exactly %s in length",
976
+ min: "%s cannot be less than %s in length",
977
+ max: "%s cannot be greater than %s in length",
978
+ range: "%s must be between %s and %s in length"
979
+ },
980
+ pattern: {
981
+ mismatch: "%s value %s does not match pattern %s"
982
+ },
983
+ clone: function() {
984
+ var e = JSON.parse(JSON.stringify(this));
985
+ return e.clone = this.clone, e;
986
+ }
987
+ };
988
+ }
989
+ var dn = fn(), Ke = /* @__PURE__ */ (function() {
990
+ function t(n) {
991
+ this.rules = null, this._messages = dn, this.define(n);
992
+ }
993
+ var e = t.prototype;
994
+ return e.define = function(r) {
995
+ var a = this;
996
+ if (!r)
997
+ throw new Error("Cannot configure a schema with no rules");
998
+ if (typeof r != "object" || Array.isArray(r))
999
+ throw new Error("Rules must be an object");
1000
+ this.rules = {}, Object.keys(r).forEach(function(l) {
1001
+ var o = r[l];
1002
+ a.rules[l] = Array.isArray(o) ? o : [o];
1003
+ });
1004
+ }, e.messages = function(r) {
1005
+ return r && (this._messages = cr(fn(), r)), this._messages;
1006
+ }, e.validate = function(r, a, l) {
1007
+ var o = this;
1008
+ a === void 0 && (a = {}), l === void 0 && (l = function() {
1009
+ });
1010
+ var s = r, u = a, m = l;
1011
+ if (typeof u == "function" && (m = u, u = {}), !this.rules || Object.keys(this.rules).length === 0)
1012
+ return m && m(null, s), Promise.resolve(s);
1013
+ function h(c) {
1014
+ var S = [], y = {};
1015
+ function $(N) {
1016
+ if (Array.isArray(N)) {
1017
+ var L;
1018
+ S = (L = S).concat.apply(L, N);
1019
+ } else
1020
+ S.push(N);
1021
+ }
1022
+ for (var w = 0; w < c.length; w++)
1023
+ $(c[w]);
1024
+ S.length ? (y = cn(S), m(S, y)) : m(null, s);
1025
+ }
1026
+ if (u.messages) {
1027
+ var g = this.messages();
1028
+ g === dn && (g = fn()), cr(g, u.messages), u.messages = g;
1029
+ } else
1030
+ u.messages = this.messages();
1031
+ var v = {}, d = u.keys || Object.keys(this.rules);
1032
+ d.forEach(function(c) {
1033
+ var S = o.rules[c], y = s[c];
1034
+ S.forEach(function($) {
1035
+ var w = $;
1036
+ typeof w.transform == "function" && (s === r && (s = Le({}, s)), y = s[c] = w.transform(y)), typeof w == "function" ? w = {
1037
+ validator: w
1038
+ } : w = Le({}, w), w.validator = o.getValidationMethod(w), w.validator && (w.field = c, w.fullField = w.fullField || c, w.type = o.getType(w), v[c] = v[c] || [], v[c].push({
1039
+ rule: w,
1040
+ value: y,
1041
+ source: s,
1042
+ field: c
1043
+ }));
1044
+ });
1045
+ });
1046
+ var b = {};
1047
+ return Mi(v, u, function(c, S) {
1048
+ var y = c.rule, $ = (y.type === "object" || y.type === "array") && (typeof y.fields == "object" || typeof y.defaultField == "object");
1049
+ $ = $ && (y.required || !y.required && c.value), y.field = c.field;
1050
+ function w(V, P) {
1051
+ return Le({}, P, {
1052
+ fullField: y.fullField + "." + V,
1053
+ fullFields: y.fullFields ? [].concat(y.fullFields, [V]) : [V]
1054
+ });
1055
+ }
1056
+ function N(V) {
1057
+ V === void 0 && (V = []);
1058
+ var P = Array.isArray(V) ? V : [V];
1059
+ !u.suppressWarning && P.length && t.warning("async-validator:", P), P.length && y.message !== void 0 && (P = [].concat(y.message));
1060
+ var I = P.map(ur(y, s));
1061
+ if (u.first && I.length)
1062
+ return b[y.field] = 1, S(I);
1063
+ if (!$)
1064
+ S(I);
1065
+ else {
1066
+ if (y.required && !c.value)
1067
+ return y.message !== void 0 ? I = [].concat(y.message).map(ur(y, s)) : u.error && (I = [u.error(y, ge(u.messages.required, y.field))]), S(I);
1068
+ var k = {};
1069
+ y.defaultField && Object.keys(c.value).map(function(D) {
1070
+ k[D] = y.defaultField;
1071
+ }), k = Le({}, k, c.rule.fields);
1072
+ var x = {};
1073
+ Object.keys(k).forEach(function(D) {
1074
+ var M = k[D], K = Array.isArray(M) ? M : [M];
1075
+ x[D] = K.map(w.bind(null, D));
1076
+ });
1077
+ var j = new t(x);
1078
+ j.messages(u.messages), c.rule.options && (c.rule.options.messages = u.messages, c.rule.options.error = u.error), j.validate(c.value, c.rule.options || u, function(D) {
1079
+ var M = [];
1080
+ I && I.length && M.push.apply(M, I), D && D.length && M.push.apply(M, D), S(M.length ? M : null);
1081
+ });
1082
+ }
1083
+ }
1084
+ var L;
1085
+ if (y.asyncValidator)
1086
+ L = y.asyncValidator(y, c.value, N, c.source, u);
1087
+ else if (y.validator) {
1088
+ try {
1089
+ L = y.validator(y, c.value, N, c.source, u);
1090
+ } catch (V) {
1091
+ console.error?.(V), u.suppressValidatorError || setTimeout(function() {
1092
+ throw V;
1093
+ }, 0), N(V.message);
1094
+ }
1095
+ L === !0 ? N() : L === !1 ? N(typeof y.message == "function" ? y.message(y.fullField || y.field) : y.message || (y.fullField || y.field) + " fails") : L instanceof Array ? N(L) : L instanceof Error && N(L.message);
1096
+ }
1097
+ L && L.then && L.then(function() {
1098
+ return N();
1099
+ }, function(V) {
1100
+ return N(V);
1101
+ });
1102
+ }, function(c) {
1103
+ h(c);
1104
+ }, s);
1105
+ }, e.getType = function(r) {
1106
+ if (r.type === void 0 && r.pattern instanceof RegExp && (r.type = "pattern"), typeof r.validator != "function" && r.type && !ut.hasOwnProperty(r.type))
1107
+ throw new Error(ge("Unknown rule type %s", r.type));
1108
+ return r.type || "string";
1109
+ }, e.getValidationMethod = function(r) {
1110
+ if (typeof r.validator == "function")
1111
+ return r.validator;
1112
+ var a = Object.keys(r), l = a.indexOf("message");
1113
+ return l !== -1 && a.splice(l, 1), a.length === 1 && a[0] === "required" ? ut.required : ut[this.getType(r)] || void 0;
1114
+ }, t;
1115
+ })();
1116
+ Ke.register = function(e, n) {
1117
+ if (typeof n != "function")
1118
+ throw new Error("Cannot register a validator by type, validator is not a function");
1119
+ ut[e] = n;
1120
+ };
1121
+ Ke.warning = Wr;
1122
+ Ke.messages = dn;
1123
+ Ke.validators = ut;
1124
+ const tl = { key: 0 }, nl = ["value"], rl = { key: 0 }, al = /* @__PURE__ */ Object.assign({ inheritAttrs: !1 }, {
1125
+ __name: "Form",
1126
+ props: {
1127
+ modelValue: Object,
1128
+ value: Object,
1129
+ items: { type: Array, default: () => [] },
1130
+ groups: { type: Array, default: () => [] },
1131
+ actions: Array,
1132
+ url: String,
1133
+ method: { type: String, default: "post" },
1134
+ options: { type: Object, default: () => ({}) },
1135
+ submit: Function,
1136
+ submitName: { type: String, default: "提交" },
1137
+ successInfo: String,
1138
+ showSuccess: { type: Boolean, default: !0 },
1139
+ disabled: Boolean,
1140
+ noLabel: Boolean,
1141
+ oneColumn: Boolean,
1142
+ inline: Boolean,
1143
+ itemOptions: { type: Object, default: () => ({}) },
1144
+ mobile: Boolean
1145
+ },
1146
+ emits: ["update:modelValue", "input", "beforesubmit", "form-posted", "error"],
1147
+ setup(t, { expose: e, emit: n }) {
1148
+ const r = t, a = n, { registry: l } = Ie(), o = Na(), s = q(), u = q({}), m = q({}), h = q(!1), g = X(
1149
+ () => Ti(
1150
+ r.items.length ? r.items : r.groups.flatMap((y) => y.items || [])
1151
+ )
1152
+ ), v = X(() => Ai(g.value));
1153
+ Ee(
1154
+ () => r.modelValue ?? r.value,
1155
+ (y) => {
1156
+ u.value = { ...y };
1157
+ },
1158
+ { immediate: !0, deep: !0 }
1159
+ );
1160
+ function d() {
1161
+ a("update:modelValue", { ...u.value }), a("input", { ...u.value });
1162
+ }
1163
+ function b(y, $) {
1164
+ u.value[y] = $, delete m.value[y], d();
1165
+ }
1166
+ async function c() {
1167
+ if (!(h.value || r.disabled)) {
1168
+ m.value = {};
1169
+ try {
1170
+ for (const $ of g.value)
1171
+ typeof $.widget == "function" && (u.value[$.name] = $.widget(u.value));
1172
+ const y = Ke.default || Ke;
1173
+ if (await new y(v.value).validate(u.value), await yn(), !r.mobile && !await s.value.validate())
1174
+ return !1;
1175
+ } catch (y) {
1176
+ return y.fields && (m.value = Object.fromEntries(
1177
+ Object.entries(y.fields).map(([$, w]) => [
1178
+ $,
1179
+ w.map((N) => N.message).join(";")
1180
+ ])
1181
+ )), !1;
1182
+ }
1183
+ h.value = !0;
1184
+ try {
1185
+ a("beforesubmit", u.value), d();
1186
+ let y;
1187
+ if (r.submit)
1188
+ y = await r.submit({
1189
+ formValue: u.value,
1190
+ formItems: g.value,
1191
+ errors: m.value,
1192
+ loading: h,
1193
+ url: r.url,
1194
+ method: r.method
1195
+ });
1196
+ else {
1197
+ if (!r.url) throw new Error("表单提交需要 url 或 submit 函数");
1198
+ y = (await l.http.request({
1199
+ url: r.url,
1200
+ method: r.method,
1201
+ data: u.value
1202
+ })).data;
1203
+ }
1204
+ return y === !1 ? !1 : (r.showSuccess && Wa.success(r.successInfo || `${r.submitName}成功`), a("form-posted", y), y);
1205
+ } catch (y) {
1206
+ const $ = y.code ?? y.response?.status;
1207
+ m.value = $ === 400 ? Ur(y.msg ?? y.response?.data ?? {}) : { non_field_errors: y.message || "请求失败" }, a("error", y);
1208
+ } finally {
1209
+ h.value = !1;
1210
+ }
1211
+ }
1212
+ }
1213
+ const S = { onSubmit: c, formValue: u, formItems: g, loading: h, errors: m };
1214
+ return e({ ...S, submit: c }), (y, $) => t.mobile ? (p(), _(A(oi), {
1215
+ key: 0,
1216
+ "aria-busy": h.value,
1217
+ onSubmit: c
1218
+ }, {
1219
+ default: C(() => [
1220
+ ye(y.$slots, "header"),
1221
+ m.value.non_field_errors || m.value.detail ? (p(), _(A(hn), {
1222
+ key: 0,
1223
+ text: m.value.non_field_errors || m.value.detail
1224
+ }, null, 8, ["text"])) : Q("", !0),
1225
+ (p(!0), R(G, null, ne(g.value, (w) => (p(), R(G, {
1226
+ key: w.name
1227
+ }, [
1228
+ !w.hidden && w.widget !== "hidden" ? (p(), _(A(Vr), {
1229
+ key: 0,
1230
+ label: t.noLabel || w.noLabel ? "" : w.label,
1231
+ required: w.required,
1232
+ "error-message": m.value[w.name]
1233
+ }, {
1234
+ input: C(() => [
1235
+ ye(y.$slots, `field-${w.name}`, {
1236
+ field: w,
1237
+ value: u.value[w.name],
1238
+ update: (N) => b(w.name, N)
1239
+ }, () => [
1240
+ typeof w.widget == "function" ? (p(), R("span", tl, Y(w.widget(u.value)), 1)) : (p(), _(Mt, {
1241
+ key: 1,
1242
+ field: w,
1243
+ "model-value": u.value[w.name],
1244
+ mobile: "",
1245
+ "onUpdate:modelValue": (N) => b(w.name, N)
1246
+ }, null, 8, ["field", "model-value", "onUpdate:modelValue"]))
1247
+ ])
1248
+ ]),
1249
+ _: 2
1250
+ }, 1032, ["label", "required", "error-message"])) : Q("", !0)
1251
+ ], 64))), 128)),
1252
+ t.submitName ? ye(y.$slots, "submit", {
1253
+ submit: c,
1254
+ loading: h.value,
1255
+ saving: h.value
1256
+ }, () => [
1257
+ t.actions ? (p(!0), R(G, { key: 0 }, ne(t.actions, (w) => (p(), _(A(st), {
1258
+ key: w.name,
1259
+ disabled: h.value || t.disabled,
1260
+ onClick: (N) => w.name === "submit" ? c() : w.do?.(S)
1261
+ }, {
1262
+ default: C(() => [
1263
+ Z(Y(w.label || w.name), 1)
1264
+ ]),
1265
+ _: 2
1266
+ }, 1032, ["disabled", "onClick"]))), 128)) : (p(), _(A(st), {
1267
+ key: 1,
1268
+ block: "",
1269
+ type: "primary",
1270
+ "native-type": "submit",
1271
+ loading: h.value,
1272
+ disabled: t.disabled
1273
+ }, {
1274
+ default: C(() => [
1275
+ Z(Y(t.submitName), 1)
1276
+ ]),
1277
+ _: 1
1278
+ }, 8, ["loading", "disabled"]))
1279
+ ], void 0, 1) : Q("", !0),
1280
+ ye(y.$slots, "footer")
1281
+ ]),
1282
+ _: 3
1283
+ }, 8, ["aria-busy"])) : (p(), _(A(Ba), Me({
1284
+ key: 1,
1285
+ ref_key: "form",
1286
+ ref: s
1287
+ }, { ...t.options.elForm, ...A(o) }, {
1288
+ model: u.value,
1289
+ rules: v.value,
1290
+ inline: t.inline,
1291
+ "label-width": t.noLabel ? "0px" : A(o).labelWidth || "160px",
1292
+ "aria-busy": h.value,
1293
+ onSubmit: Dr(c, ["prevent"])
1294
+ }), {
1295
+ default: C(() => [
1296
+ ye(y.$slots, "header"),
1297
+ m.value.non_field_errors || m.value.detail ? (p(), _(A(Pe), {
1298
+ key: 0,
1299
+ title: m.value.non_field_errors || m.value.detail,
1300
+ type: "error",
1301
+ closable: !1
1302
+ }, null, 8, ["title"])) : Q("", !0),
1303
+ U(A(Ha), { gutter: 20 }, {
1304
+ default: C(() => [
1305
+ (p(!0), R(G, null, ne(g.value, (w) => (p(), R(G, {
1306
+ key: w.name
1307
+ }, [
1308
+ w.widget === "hidden" && !w.hidden ? (p(), R("input", {
1309
+ key: 0,
1310
+ type: "hidden",
1311
+ value: u.value[w.name]
1312
+ }, null, 8, nl)) : w.hidden ? Q("", !0) : (p(), _(A(tr), Me({
1313
+ key: 1,
1314
+ ref_for: !0
1315
+ }, t.oneColumn || t.inline ? { span: 24 } : w.span), {
1316
+ default: C(() => [
1317
+ U(A(nr), Me({ ref_for: !0 }, t.itemOptions, {
1318
+ prop: w.name,
1319
+ label: t.noLabel || t.itemOptions.noLabel || w.noLabel ? "" : w.label,
1320
+ error: m.value[w.name]
1321
+ }), {
1322
+ default: C(() => [
1323
+ ye(y.$slots, `field-${w.name}`, {
1324
+ field: w,
1325
+ value: u.value[w.name],
1326
+ update: (N) => b(w.name, N)
1327
+ }, () => [
1328
+ typeof w.widget == "function" ? (p(), R("span", rl, Y(w.widget(u.value)), 1)) : (p(), _(Mt, {
1329
+ key: 1,
1330
+ field: w,
1331
+ "model-value": u.value[w.name],
1332
+ mobile: t.mobile,
1333
+ "onUpdate:modelValue": (N) => b(w.name, N)
1334
+ }, null, 8, ["field", "model-value", "mobile", "onUpdate:modelValue"]))
1335
+ ])
1336
+ ]),
1337
+ _: 2
1338
+ }, 1040, ["prop", "label", "error"])
1339
+ ]),
1340
+ _: 2
1341
+ }, 1040))
1342
+ ], 64))), 128)),
1343
+ t.submitName ? (p(), _(A(tr), {
1344
+ key: 0,
1345
+ span: 24
1346
+ }, {
1347
+ default: C(() => [
1348
+ U(A(nr), null, {
1349
+ default: C(() => [
1350
+ ye(y.$slots, "submit", {
1351
+ submit: c,
1352
+ loading: h.value,
1353
+ saving: h.value
1354
+ }, () => [
1355
+ t.actions ? (p(!0), R(G, { key: 0 }, ne(t.actions, (w) => (p(), _(A(ve), {
1356
+ key: w.name,
1357
+ type: w.type,
1358
+ disabled: h.value || t.disabled,
1359
+ onClick: (N) => w.name === "submit" ? c() : w.do?.(S)
1360
+ }, {
1361
+ default: C(() => [
1362
+ Z(Y(w.label || w.name), 1)
1363
+ ]),
1364
+ _: 2
1365
+ }, 1032, ["type", "disabled", "onClick"]))), 128)) : (p(), _(A(ve), {
1366
+ key: 1,
1367
+ type: "primary",
1368
+ "native-type": "submit",
1369
+ loading: h.value,
1370
+ disabled: t.disabled
1371
+ }, {
1372
+ default: C(() => [
1373
+ Z(Y(t.submitName), 1)
1374
+ ]),
1375
+ _: 1
1376
+ }, 8, ["loading", "disabled"]))
1377
+ ])
1378
+ ]),
1379
+ _: 3
1380
+ })
1381
+ ]),
1382
+ _: 3
1383
+ })) : Q("", !0),
1384
+ ye(y.$slots, "footer")
1385
+ ]),
1386
+ _: 3
1387
+ })
1388
+ ]),
1389
+ _: 3
1390
+ }, 16, ["model", "rules", "inline", "label-width", "aria-busy"]));
1391
+ }
1392
+ }), Yr = /* @__PURE__ */ Symbol("vue3-django-tab");
1393
+ function il() {
1394
+ return Ct(Yr, null);
1395
+ }
1396
+ const ll = ["aria-busy"], ol = { key: 0 }, wn = /* @__PURE__ */ Object.assign({ inheritAttrs: !1 }, {
1397
+ __name: "Form",
1398
+ props: {
1399
+ appModel: { type: String, required: !0 },
1400
+ id: [String, Number],
1401
+ modelValue: Object,
1402
+ items: [Array, String],
1403
+ defaults: { type: Object, default: () => ({}) },
1404
+ mobile: Boolean
1405
+ },
1406
+ emits: ["update:modelValue", "loaded", "form-posted", "error", "beforesubmit"],
1407
+ setup(t, { expose: e, emit: n }) {
1408
+ const r = t, a = n, { registry: l } = Ie(), o = il(), s = q(), u = q({}), m = q([]), h = q(""), g = q(!1), v = X(() => s.value?.errors ?? {}), d = X(() => r.id != null);
1409
+ let b = 0;
1410
+ function c(L) {
1411
+ if (!d.value) return;
1412
+ const V = l.getConfig(r.appModel);
1413
+ o?.update({ title: L.__str__ ?? L[V.title_field || "name"], icon: V.icon });
1414
+ }
1415
+ function S(L) {
1416
+ u.value = L, a("update:modelValue", { ...L });
1417
+ }
1418
+ Ee(
1419
+ () => r.modelValue,
1420
+ (L) => {
1421
+ L && (u.value = { ...L });
1422
+ },
1423
+ { deep: !0 }
1424
+ );
1425
+ async function y() {
1426
+ const L = ++b;
1427
+ g.value = !0, h.value = "", m.value = [], u.value = {};
1428
+ try {
1429
+ const V = l.get(r.appModel), [P, I, k] = await Promise.all([
1430
+ V.fields(d.value ? "PATCH" : "POST"),
1431
+ V.loadViewsConfig(),
1432
+ d.value ? V.loadObject(r.id) : {}
1433
+ ]);
1434
+ if (L !== b) return;
1435
+ const x = (d.value ? I.update : I.create) ?? I.form ?? {};
1436
+ m.value = bn(r.items ?? x.items ?? "all", P).filter(
1437
+ (j) => !j.read_only
1438
+ ), S({ ...qr(P, r.defaults), ...k, ...r.modelValue }), c(k), a("loaded", V);
1439
+ } catch (V) {
1440
+ L === b && (h.value = V.message, a("error", V));
1441
+ } finally {
1442
+ L === b && (g.value = !1);
1443
+ }
1444
+ }
1445
+ function $({ formValue: L }) {
1446
+ return l.get(r.appModel).save(L, r.id, r.defaults);
1447
+ }
1448
+ function w(L) {
1449
+ S({ ...u.value, ...L }), c(L), a("form-posted", { model: l.getConfig(r.appModel), data: L, intent: "save" });
1450
+ }
1451
+ async function N() {
1452
+ if (!g.value)
1453
+ return await yn(), s.value?.onSubmit();
1454
+ }
1455
+ return Ee(() => [r.appModel, r.id, r.items, r.defaults], y, { immediate: !0 }), e({ load: y, submit: N, data: u, errors: v }), (L, V) => (p(), R("div", {
1456
+ "aria-busy": g.value || s.value?.loading
1457
+ }, [
1458
+ g.value ? (p(), R("p", ol, "正在加载字段…")) : (p(), R(G, { key: 1 }, [
1459
+ h.value && t.mobile ? (p(), _(A(hn), {
1460
+ key: 0,
1461
+ text: h.value
1462
+ }, null, 8, ["text"])) : h.value ? (p(), _(A(Pe), {
1463
+ key: 1,
1464
+ title: h.value,
1465
+ type: "error",
1466
+ closable: !1
1467
+ }, null, 8, ["title"])) : Q("", !0),
1468
+ U(al, Me({
1469
+ ref_key: "form",
1470
+ ref: s
1471
+ }, L.$attrs, {
1472
+ "model-value": u.value,
1473
+ items: m.value,
1474
+ submit: $,
1475
+ mobile: t.mobile,
1476
+ disabled: !!h.value || !m.value.length,
1477
+ "show-success": !1,
1478
+ "submit-name": "保存",
1479
+ "label-position": "top",
1480
+ "onUpdate:modelValue": S,
1481
+ onFormPosted: w,
1482
+ onError: V[0] || (V[0] = (P) => a("error", P)),
1483
+ onBeforesubmit: V[1] || (V[1] = (P) => a("beforesubmit", P))
1484
+ }), Mr({ _: 2 }, [
1485
+ ne(L.$slots, (P, I) => ({
1486
+ name: I,
1487
+ fn: C((k) => [
1488
+ ye(L.$slots, I, Cr(Nr(k || {})))
1489
+ ])
1490
+ }))
1491
+ ]), 1040, ["model-value", "items", "mobile", "disabled"])
1492
+ ], 64))
1493
+ ], 8, ll));
1494
+ }
1495
+ }), sl = {
1496
+ __name: "Search",
1497
+ props: { appModel: String, items: Array },
1498
+ emits: ["change", "error"],
1499
+ setup(t, { emit: e }) {
1500
+ const n = t, r = e, { registry: a } = Ie(), l = q({}), o = q([]), s = q([]);
1501
+ let u = 0;
1502
+ Ee(
1503
+ () => [n.appModel, n.items],
1504
+ async () => {
1505
+ const g = ++u;
1506
+ try {
1507
+ const v = a.get(n.appModel), [d, b, c] = await Promise.all([
1508
+ v.loadOptions(),
1509
+ v.fields(),
1510
+ v.loadViewsConfig()
1511
+ ]);
1512
+ if (g !== u) return;
1513
+ s.value = d.actions?.SEARCH?.search_fields ?? [], o.value = bn(
1514
+ n.items ?? d.actions?.SEARCH?.filter_fields ?? [],
1515
+ b
1516
+ ).map((S) => {
1517
+ const y = { ...S, ...c.search?.[S.name] }, $ = y.model || y.relateModel || y.choices || y.type === "boolean";
1518
+ return {
1519
+ ...y,
1520
+ placeholder: y.placeholder ?? `${$ ? "请选择" : "请输入"}${y.label || y.name}`,
1521
+ read_only: !1,
1522
+ required: !1,
1523
+ multiple: !1
1524
+ };
1525
+ }), l.value = {};
1526
+ } catch (v) {
1527
+ r("error", v);
1528
+ }
1529
+ },
1530
+ { immediate: !0, deep: !0 }
1531
+ );
1532
+ function m() {
1533
+ r(
1534
+ "change",
1535
+ Object.fromEntries(
1536
+ Object.entries(l.value).filter(([, g]) => g !== "" && g != null)
1537
+ )
1538
+ );
1539
+ }
1540
+ function h() {
1541
+ l.value = {}, m();
1542
+ }
1543
+ return (g, v) => (p(), R("form", {
1544
+ class: "vd-toolbar",
1545
+ onSubmit: Dr(m, ["prevent"])
1546
+ }, [
1547
+ s.value.length ? (p(), _(A(Lr), {
1548
+ key: 0,
1549
+ modelValue: l.value.search,
1550
+ "onUpdate:modelValue": v[0] || (v[0] = (d) => l.value.search = d),
1551
+ clearable: "",
1552
+ placeholder: `搜索${s.value.join("、")}`,
1553
+ "aria-label": "搜索记录"
1554
+ }, null, 8, ["modelValue", "placeholder"])) : Q("", !0),
1555
+ (p(!0), R(G, null, ne(o.value, (d) => (p(), R("div", {
1556
+ key: d.name
1557
+ }, [
1558
+ d.type === "boolean" ? (p(), _(A(vn), {
1559
+ key: 0,
1560
+ modelValue: l.value[d.name],
1561
+ "onUpdate:modelValue": (b) => l.value[d.name] = b,
1562
+ clearable: "",
1563
+ placeholder: d.placeholder,
1564
+ "aria-label": d.label || d.name
1565
+ }, {
1566
+ default: C(() => [
1567
+ U(A(Dt), {
1568
+ label: "是",
1569
+ value: !0
1570
+ }),
1571
+ U(A(Dt), {
1572
+ label: "否",
1573
+ value: !1
1574
+ })
1575
+ ]),
1576
+ _: 1
1577
+ }, 8, ["modelValue", "onUpdate:modelValue", "placeholder", "aria-label"])) : (p(), _(Mt, {
1578
+ key: 1,
1579
+ field: d,
1580
+ modelValue: l.value[d.name],
1581
+ "onUpdate:modelValue": (b) => l.value[d.name] = b
1582
+ }, null, 8, ["field", "modelValue", "onUpdate:modelValue"]))
1583
+ ]))), 128)),
1584
+ U(A(ve), { "native-type": "submit" }, {
1585
+ default: C(() => [...v[1] || (v[1] = [
1586
+ Z("搜索", -1)
1587
+ ])]),
1588
+ _: 1
1589
+ }),
1590
+ U(A(ve), { onClick: h }, {
1591
+ default: C(() => [...v[2] || (v[2] = [
1592
+ Z("重置", -1)
1593
+ ])]),
1594
+ _: 1
1595
+ })
1596
+ ], 32));
1597
+ }
1598
+ };
1599
+ function dr(t, e) {
1600
+ (e == null || e > t.length) && (e = t.length);
1601
+ for (var n = 0, r = Array(e); n < e; n++) r[n] = t[n];
1602
+ return r;
1603
+ }
1604
+ function ul(t) {
1605
+ if (Array.isArray(t)) return t;
1606
+ }
1607
+ function cl(t, e) {
1608
+ var n = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
1609
+ if (n != null) {
1610
+ var r, a, l, o, s = [], u = !0, m = !1;
1611
+ try {
1612
+ if (l = (n = n.call(t)).next, e !== 0) for (; !(u = (r = l.call(n)).done) && (s.push(r.value), s.length !== e); u = !0) ;
1613
+ } catch (h) {
1614
+ m = !0, a = h;
1615
+ } finally {
1616
+ try {
1617
+ if (!u && n.return != null && (o = n.return(), Object(o) !== o)) return;
1618
+ } finally {
1619
+ if (m) throw a;
1620
+ }
1621
+ }
1622
+ return s;
1623
+ }
1624
+ }
1625
+ function fl() {
1626
+ throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1627
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
1628
+ }
1629
+ function dl(t, e) {
1630
+ return ul(t) || cl(t, e) || ml(t, e) || fl();
1631
+ }
1632
+ function ml(t, e) {
1633
+ if (t) {
1634
+ if (typeof t == "string") return dr(t, e);
1635
+ var n = {}.toString.call(t).slice(8, -1);
1636
+ return n === "Object" && t.constructor && (n = t.constructor.name), n === "Map" || n === "Set" ? Array.from(t) : n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? dr(t, e) : void 0;
1637
+ }
1638
+ }
1639
+ const Xr = Object.entries, mr = Object.setPrototypeOf, pl = Object.isFrozen, yl = Object.getPrototypeOf, gl = Object.getOwnPropertyDescriptor;
1640
+ let le = Object.freeze, se = Object.seal, Ye = Object.create, Kr = typeof Reflect < "u" && Reflect, mn = Kr.apply, pn = Kr.construct;
1641
+ le || (le = function(e) {
1642
+ return e;
1643
+ });
1644
+ se || (se = function(e) {
1645
+ return e;
1646
+ });
1647
+ mn || (mn = function(e, n) {
1648
+ for (var r = arguments.length, a = new Array(r > 2 ? r - 2 : 0), l = 2; l < r; l++) a[l - 2] = arguments[l];
1649
+ return e.apply(n, a);
1650
+ });
1651
+ pn || (pn = function(e) {
1652
+ for (var n = arguments.length, r = new Array(n > 1 ? n - 1 : 0), a = 1; a < n; a++) r[a - 1] = arguments[a];
1653
+ return new e(...r);
1654
+ });
1655
+ const $e = ie(Array.prototype.forEach), vl = ie(Array.prototype.lastIndexOf), pr = ie(Array.prototype.pop), tt = ie(Array.prototype.push), hl = ie(Array.prototype.splice), Xe = Array.isArray, lt = ie(String.prototype.toLowerCase), Qt = ie(String.prototype.toString), yr = ie(String.prototype.match), nt = ie(String.prototype.replace), gr = ie(String.prototype.indexOf), bl = ie(String.prototype.trim), wl = ie(Number.prototype.toString), El = ie(Boolean.prototype.toString), vr = typeof BigInt > "u" ? null : ie(BigInt.prototype.toString), hr = typeof Symbol > "u" ? null : ie(Symbol.prototype.toString), fe = ie(Object.prototype.hasOwnProperty), rt = ie(Object.prototype.toString), ue = ie(RegExp.prototype.test), Re = Tl(TypeError);
1656
+ function ie(t) {
1657
+ return function(e) {
1658
+ e instanceof RegExp && (e.lastIndex = 0);
1659
+ for (var n = arguments.length, r = new Array(n > 1 ? n - 1 : 0), a = 1; a < n; a++) r[a - 1] = arguments[a];
1660
+ return mn(t, e, r);
1661
+ };
1662
+ }
1663
+ function Tl(t) {
1664
+ return function() {
1665
+ for (var e = arguments.length, n = new Array(e), r = 0; r < e; r++) n[r] = arguments[r];
1666
+ return pn(t, n);
1667
+ };
1668
+ }
1669
+ function W(t, e) {
1670
+ let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : lt;
1671
+ if (mr && mr(t, null), !Xe(e)) return t;
1672
+ let r = e.length;
1673
+ for (; r--; ) {
1674
+ let a = e[r];
1675
+ if (typeof a == "string") {
1676
+ const l = n(a);
1677
+ l !== a && (pl(e) || (e[r] = l), a = l);
1678
+ }
1679
+ t[a] = !0;
1680
+ }
1681
+ return t;
1682
+ }
1683
+ function Al(t) {
1684
+ for (let e = 0; e < t.length; e++) fe(t, e) || (t[e] = null);
1685
+ return t;
1686
+ }
1687
+ function pe(t) {
1688
+ const e = Ye(null);
1689
+ for (const r of Xr(t)) {
1690
+ var n = dl(r, 2);
1691
+ const a = n[0], l = n[1];
1692
+ fe(t, a) && (Xe(l) ? e[a] = Al(l) : l && typeof l == "object" && l.constructor === Object ? e[a] = pe(l) : e[a] = l);
1693
+ }
1694
+ return e;
1695
+ }
1696
+ function Sl(t) {
1697
+ switch (typeof t) {
1698
+ case "string":
1699
+ return t;
1700
+ case "number":
1701
+ return wl(t);
1702
+ case "boolean":
1703
+ return El(t);
1704
+ case "bigint":
1705
+ return vr ? vr(t) : "0";
1706
+ case "symbol":
1707
+ return hr ? hr(t) : "Symbol()";
1708
+ case "undefined":
1709
+ return rt(t);
1710
+ case "function":
1711
+ case "object": {
1712
+ if (t === null) return rt(t);
1713
+ const e = t, n = be(e, "toString");
1714
+ if (typeof n == "function") {
1715
+ const r = n(e);
1716
+ return typeof r == "string" ? r : rt(r);
1717
+ }
1718
+ return rt(t);
1719
+ }
1720
+ default:
1721
+ return rt(t);
1722
+ }
1723
+ }
1724
+ function be(t, e) {
1725
+ for (; t !== null; ) {
1726
+ const r = gl(t, e);
1727
+ if (r) {
1728
+ if (r.get) return ie(r.get);
1729
+ if (typeof r.value == "function") return ie(r.value);
1730
+ }
1731
+ t = yl(t);
1732
+ }
1733
+ function n() {
1734
+ return null;
1735
+ }
1736
+ return n;
1737
+ }
1738
+ function Ol(t) {
1739
+ try {
1740
+ return ue(t, ""), !0;
1741
+ } catch {
1742
+ return !1;
1743
+ }
1744
+ }
1745
+ const br = le([
1746
+ "a",
1747
+ "abbr",
1748
+ "acronym",
1749
+ "address",
1750
+ "area",
1751
+ "article",
1752
+ "aside",
1753
+ "audio",
1754
+ "b",
1755
+ "bdi",
1756
+ "bdo",
1757
+ "big",
1758
+ "blink",
1759
+ "blockquote",
1760
+ "body",
1761
+ "br",
1762
+ "button",
1763
+ "canvas",
1764
+ "caption",
1765
+ "center",
1766
+ "cite",
1767
+ "code",
1768
+ "col",
1769
+ "colgroup",
1770
+ "content",
1771
+ "data",
1772
+ "datalist",
1773
+ "dd",
1774
+ "decorator",
1775
+ "del",
1776
+ "details",
1777
+ "dfn",
1778
+ "dialog",
1779
+ "dir",
1780
+ "div",
1781
+ "dl",
1782
+ "dt",
1783
+ "element",
1784
+ "em",
1785
+ "fieldset",
1786
+ "figcaption",
1787
+ "figure",
1788
+ "font",
1789
+ "footer",
1790
+ "form",
1791
+ "h1",
1792
+ "h2",
1793
+ "h3",
1794
+ "h4",
1795
+ "h5",
1796
+ "h6",
1797
+ "head",
1798
+ "header",
1799
+ "hgroup",
1800
+ "hr",
1801
+ "html",
1802
+ "i",
1803
+ "img",
1804
+ "input",
1805
+ "ins",
1806
+ "kbd",
1807
+ "label",
1808
+ "legend",
1809
+ "li",
1810
+ "main",
1811
+ "map",
1812
+ "mark",
1813
+ "marquee",
1814
+ "menu",
1815
+ "menuitem",
1816
+ "meter",
1817
+ "nav",
1818
+ "nobr",
1819
+ "ol",
1820
+ "optgroup",
1821
+ "option",
1822
+ "output",
1823
+ "p",
1824
+ "picture",
1825
+ "pre",
1826
+ "progress",
1827
+ "q",
1828
+ "rp",
1829
+ "rt",
1830
+ "ruby",
1831
+ "s",
1832
+ "samp",
1833
+ "search",
1834
+ "section",
1835
+ "select",
1836
+ "shadow",
1837
+ "slot",
1838
+ "small",
1839
+ "source",
1840
+ "spacer",
1841
+ "span",
1842
+ "strike",
1843
+ "strong",
1844
+ "style",
1845
+ "sub",
1846
+ "summary",
1847
+ "sup",
1848
+ "table",
1849
+ "tbody",
1850
+ "td",
1851
+ "template",
1852
+ "textarea",
1853
+ "tfoot",
1854
+ "th",
1855
+ "thead",
1856
+ "time",
1857
+ "tr",
1858
+ "track",
1859
+ "tt",
1860
+ "u",
1861
+ "ul",
1862
+ "var",
1863
+ "video",
1864
+ "wbr"
1865
+ ]), Zt = le([
1866
+ "svg",
1867
+ "a",
1868
+ "altglyph",
1869
+ "altglyphdef",
1870
+ "altglyphitem",
1871
+ "animatecolor",
1872
+ "animatemotion",
1873
+ "animatetransform",
1874
+ "circle",
1875
+ "clippath",
1876
+ "defs",
1877
+ "desc",
1878
+ "ellipse",
1879
+ "enterkeyhint",
1880
+ "exportparts",
1881
+ "filter",
1882
+ "font",
1883
+ "g",
1884
+ "glyph",
1885
+ "glyphref",
1886
+ "hkern",
1887
+ "image",
1888
+ "inputmode",
1889
+ "line",
1890
+ "lineargradient",
1891
+ "marker",
1892
+ "mask",
1893
+ "metadata",
1894
+ "mpath",
1895
+ "part",
1896
+ "path",
1897
+ "pattern",
1898
+ "polygon",
1899
+ "polyline",
1900
+ "radialgradient",
1901
+ "rect",
1902
+ "stop",
1903
+ "style",
1904
+ "switch",
1905
+ "symbol",
1906
+ "text",
1907
+ "textpath",
1908
+ "title",
1909
+ "tref",
1910
+ "tspan",
1911
+ "view",
1912
+ "vkern"
1913
+ ]), Jt = le([
1914
+ "feBlend",
1915
+ "feColorMatrix",
1916
+ "feComponentTransfer",
1917
+ "feComposite",
1918
+ "feConvolveMatrix",
1919
+ "feDiffuseLighting",
1920
+ "feDisplacementMap",
1921
+ "feDistantLight",
1922
+ "feDropShadow",
1923
+ "feFlood",
1924
+ "feFuncA",
1925
+ "feFuncB",
1926
+ "feFuncG",
1927
+ "feFuncR",
1928
+ "feGaussianBlur",
1929
+ "feImage",
1930
+ "feMerge",
1931
+ "feMergeNode",
1932
+ "feMorphology",
1933
+ "feOffset",
1934
+ "fePointLight",
1935
+ "feSpecularLighting",
1936
+ "feSpotLight",
1937
+ "feTile",
1938
+ "feTurbulence"
1939
+ ]), _l = le([
1940
+ "animate",
1941
+ "color-profile",
1942
+ "cursor",
1943
+ "discard",
1944
+ "font-face",
1945
+ "font-face-format",
1946
+ "font-face-name",
1947
+ "font-face-src",
1948
+ "font-face-uri",
1949
+ "foreignobject",
1950
+ "hatch",
1951
+ "hatchpath",
1952
+ "mesh",
1953
+ "meshgradient",
1954
+ "meshpatch",
1955
+ "meshrow",
1956
+ "missing-glyph",
1957
+ "script",
1958
+ "set",
1959
+ "solidcolor",
1960
+ "unknown",
1961
+ "use"
1962
+ ]), en = le([
1963
+ "math",
1964
+ "menclose",
1965
+ "merror",
1966
+ "mfenced",
1967
+ "mfrac",
1968
+ "mglyph",
1969
+ "mi",
1970
+ "mlabeledtr",
1971
+ "mmultiscripts",
1972
+ "mn",
1973
+ "mo",
1974
+ "mover",
1975
+ "mpadded",
1976
+ "mphantom",
1977
+ "mroot",
1978
+ "mrow",
1979
+ "ms",
1980
+ "mspace",
1981
+ "msqrt",
1982
+ "mstyle",
1983
+ "msub",
1984
+ "msup",
1985
+ "msubsup",
1986
+ "mtable",
1987
+ "mtd",
1988
+ "mtext",
1989
+ "mtr",
1990
+ "munder",
1991
+ "munderover",
1992
+ "mprescripts"
1993
+ ]), xl = le([
1994
+ "maction",
1995
+ "maligngroup",
1996
+ "malignmark",
1997
+ "mlongdiv",
1998
+ "mscarries",
1999
+ "mscarry",
2000
+ "msgroup",
2001
+ "mstack",
2002
+ "msline",
2003
+ "msrow",
2004
+ "semantics",
2005
+ "annotation",
2006
+ "annotation-xml",
2007
+ "mprescripts",
2008
+ "none"
2009
+ ]), wr = le(["#text"]), Er = le([
2010
+ "accept",
2011
+ "action",
2012
+ "align",
2013
+ "alt",
2014
+ "autocapitalize",
2015
+ "autocomplete",
2016
+ "autopictureinpicture",
2017
+ "autoplay",
2018
+ "background",
2019
+ "bgcolor",
2020
+ "border",
2021
+ "capture",
2022
+ "cellpadding",
2023
+ "cellspacing",
2024
+ "checked",
2025
+ "cite",
2026
+ "class",
2027
+ "clear",
2028
+ "color",
2029
+ "cols",
2030
+ "colspan",
2031
+ "command",
2032
+ "commandfor",
2033
+ "controls",
2034
+ "controlslist",
2035
+ "coords",
2036
+ "crossorigin",
2037
+ "datetime",
2038
+ "decoding",
2039
+ "default",
2040
+ "dir",
2041
+ "disabled",
2042
+ "disablepictureinpicture",
2043
+ "disableremoteplayback",
2044
+ "download",
2045
+ "draggable",
2046
+ "enctype",
2047
+ "enterkeyhint",
2048
+ "exportparts",
2049
+ "face",
2050
+ "for",
2051
+ "headers",
2052
+ "height",
2053
+ "hidden",
2054
+ "high",
2055
+ "href",
2056
+ "hreflang",
2057
+ "id",
2058
+ "inert",
2059
+ "inputmode",
2060
+ "integrity",
2061
+ "ismap",
2062
+ "kind",
2063
+ "label",
2064
+ "lang",
2065
+ "list",
2066
+ "loading",
2067
+ "loop",
2068
+ "low",
2069
+ "max",
2070
+ "maxlength",
2071
+ "media",
2072
+ "method",
2073
+ "min",
2074
+ "minlength",
2075
+ "multiple",
2076
+ "muted",
2077
+ "name",
2078
+ "nonce",
2079
+ "noshade",
2080
+ "novalidate",
2081
+ "nowrap",
2082
+ "open",
2083
+ "optimum",
2084
+ "part",
2085
+ "pattern",
2086
+ "placeholder",
2087
+ "playsinline",
2088
+ "popover",
2089
+ "popovertarget",
2090
+ "popovertargetaction",
2091
+ "poster",
2092
+ "preload",
2093
+ "pubdate",
2094
+ "radiogroup",
2095
+ "readonly",
2096
+ "rel",
2097
+ "required",
2098
+ "rev",
2099
+ "reversed",
2100
+ "role",
2101
+ "rows",
2102
+ "rowspan",
2103
+ "spellcheck",
2104
+ "scope",
2105
+ "selected",
2106
+ "shape",
2107
+ "size",
2108
+ "sizes",
2109
+ "slot",
2110
+ "span",
2111
+ "srclang",
2112
+ "start",
2113
+ "src",
2114
+ "srcset",
2115
+ "step",
2116
+ "style",
2117
+ "summary",
2118
+ "tabindex",
2119
+ "title",
2120
+ "translate",
2121
+ "type",
2122
+ "usemap",
2123
+ "valign",
2124
+ "value",
2125
+ "width",
2126
+ "wrap",
2127
+ "xmlns"
2128
+ ]), tn = le([
2129
+ "accent-height",
2130
+ "accumulate",
2131
+ "additive",
2132
+ "alignment-baseline",
2133
+ "amplitude",
2134
+ "ascent",
2135
+ "attributename",
2136
+ "attributetype",
2137
+ "azimuth",
2138
+ "basefrequency",
2139
+ "baseline-shift",
2140
+ "begin",
2141
+ "bias",
2142
+ "by",
2143
+ "class",
2144
+ "clip",
2145
+ "clippathunits",
2146
+ "clip-path",
2147
+ "clip-rule",
2148
+ "color",
2149
+ "color-interpolation",
2150
+ "color-interpolation-filters",
2151
+ "color-profile",
2152
+ "color-rendering",
2153
+ "cx",
2154
+ "cy",
2155
+ "d",
2156
+ "dx",
2157
+ "dy",
2158
+ "diffuseconstant",
2159
+ "direction",
2160
+ "display",
2161
+ "divisor",
2162
+ "dominant-baseline",
2163
+ "dur",
2164
+ "edgemode",
2165
+ "elevation",
2166
+ "end",
2167
+ "exponent",
2168
+ "fill",
2169
+ "fill-opacity",
2170
+ "fill-rule",
2171
+ "filter",
2172
+ "filterunits",
2173
+ "flood-color",
2174
+ "flood-opacity",
2175
+ "font-family",
2176
+ "font-size",
2177
+ "font-size-adjust",
2178
+ "font-stretch",
2179
+ "font-style",
2180
+ "font-variant",
2181
+ "font-weight",
2182
+ "fx",
2183
+ "fy",
2184
+ "g1",
2185
+ "g2",
2186
+ "glyph-name",
2187
+ "glyphref",
2188
+ "gradientunits",
2189
+ "gradienttransform",
2190
+ "height",
2191
+ "href",
2192
+ "id",
2193
+ "image-rendering",
2194
+ "in",
2195
+ "in2",
2196
+ "intercept",
2197
+ "k",
2198
+ "k1",
2199
+ "k2",
2200
+ "k3",
2201
+ "k4",
2202
+ "kerning",
2203
+ "keypoints",
2204
+ "keysplines",
2205
+ "keytimes",
2206
+ "lang",
2207
+ "lengthadjust",
2208
+ "letter-spacing",
2209
+ "kernelmatrix",
2210
+ "kernelunitlength",
2211
+ "lighting-color",
2212
+ "local",
2213
+ "marker-end",
2214
+ "marker-mid",
2215
+ "marker-start",
2216
+ "markerheight",
2217
+ "markerunits",
2218
+ "markerwidth",
2219
+ "maskcontentunits",
2220
+ "maskunits",
2221
+ "max",
2222
+ "mask",
2223
+ "mask-type",
2224
+ "media",
2225
+ "method",
2226
+ "mode",
2227
+ "min",
2228
+ "name",
2229
+ "numoctaves",
2230
+ "offset",
2231
+ "operator",
2232
+ "opacity",
2233
+ "order",
2234
+ "orient",
2235
+ "orientation",
2236
+ "origin",
2237
+ "overflow",
2238
+ "paint-order",
2239
+ "path",
2240
+ "pathlength",
2241
+ "patterncontentunits",
2242
+ "patterntransform",
2243
+ "patternunits",
2244
+ "pointer-events",
2245
+ "points",
2246
+ "preservealpha",
2247
+ "preserveaspectratio",
2248
+ "primitiveunits",
2249
+ "r",
2250
+ "rx",
2251
+ "ry",
2252
+ "radius",
2253
+ "refx",
2254
+ "refy",
2255
+ "repeatcount",
2256
+ "repeatdur",
2257
+ "restart",
2258
+ "result",
2259
+ "rotate",
2260
+ "scale",
2261
+ "seed",
2262
+ "shape-rendering",
2263
+ "slope",
2264
+ "specularconstant",
2265
+ "specularexponent",
2266
+ "spreadmethod",
2267
+ "startoffset",
2268
+ "stddeviation",
2269
+ "stitchtiles",
2270
+ "stop-color",
2271
+ "stop-opacity",
2272
+ "stroke-dasharray",
2273
+ "stroke-dashoffset",
2274
+ "stroke-linecap",
2275
+ "stroke-linejoin",
2276
+ "stroke-miterlimit",
2277
+ "stroke-opacity",
2278
+ "stroke",
2279
+ "stroke-width",
2280
+ "style",
2281
+ "surfacescale",
2282
+ "systemlanguage",
2283
+ "tabindex",
2284
+ "tablevalues",
2285
+ "targetx",
2286
+ "targety",
2287
+ "transform",
2288
+ "transform-origin",
2289
+ "text-anchor",
2290
+ "text-decoration",
2291
+ "text-orientation",
2292
+ "text-rendering",
2293
+ "textlength",
2294
+ "type",
2295
+ "u1",
2296
+ "u2",
2297
+ "unicode",
2298
+ "values",
2299
+ "vector-effect",
2300
+ "viewbox",
2301
+ "visibility",
2302
+ "version",
2303
+ "vert-adv-y",
2304
+ "vert-origin-x",
2305
+ "vert-origin-y",
2306
+ "width",
2307
+ "word-spacing",
2308
+ "wrap",
2309
+ "writing-mode",
2310
+ "xchannelselector",
2311
+ "ychannelselector",
2312
+ "x",
2313
+ "x1",
2314
+ "x2",
2315
+ "xmlns",
2316
+ "y",
2317
+ "y1",
2318
+ "y2",
2319
+ "z",
2320
+ "zoomandpan"
2321
+ ]), Tr = le([
2322
+ "accent",
2323
+ "accentunder",
2324
+ "align",
2325
+ "bevelled",
2326
+ "close",
2327
+ "columnalign",
2328
+ "columnlines",
2329
+ "columnspacing",
2330
+ "columnspan",
2331
+ "denomalign",
2332
+ "depth",
2333
+ "dir",
2334
+ "display",
2335
+ "displaystyle",
2336
+ "encoding",
2337
+ "fence",
2338
+ "frame",
2339
+ "height",
2340
+ "href",
2341
+ "id",
2342
+ "largeop",
2343
+ "length",
2344
+ "linethickness",
2345
+ "lquote",
2346
+ "lspace",
2347
+ "mathbackground",
2348
+ "mathcolor",
2349
+ "mathsize",
2350
+ "mathvariant",
2351
+ "maxsize",
2352
+ "minsize",
2353
+ "movablelimits",
2354
+ "notation",
2355
+ "numalign",
2356
+ "open",
2357
+ "rowalign",
2358
+ "rowlines",
2359
+ "rowspacing",
2360
+ "rowspan",
2361
+ "rspace",
2362
+ "rquote",
2363
+ "scriptlevel",
2364
+ "scriptminsize",
2365
+ "scriptsizemultiplier",
2366
+ "selection",
2367
+ "separator",
2368
+ "separators",
2369
+ "stretchy",
2370
+ "subscriptshift",
2371
+ "supscriptshift",
2372
+ "symmetric",
2373
+ "voffset",
2374
+ "width",
2375
+ "xmlns"
2376
+ ]), xt = le([
2377
+ "xlink:href",
2378
+ "xml:id",
2379
+ "xlink:title",
2380
+ "xml:space",
2381
+ "xmlns:xlink"
2382
+ ]), kl = se(/{{[\w\W]*|^[\w\W]*}}/g), Rl = se(/<%[\w\W]*|^[\w\W]*%>/g), Dl = se(/\${[\w\W]*/g), Ml = se(/^data-[\-\w.\u00B7-\uFFFF]+$/), Cl = se(/^aria-[\-\w]+$/), Ar = se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i), Nl = se(/^(?:\w+script|data):/i), Fl = se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g), $l = se(/^html$/i), Ll = se(/^[a-z][.\w]*(-[.\w]+)+$/i), Sr = se(/<[/\w!]/g), Or = se(/<[/\w]/g), Pl = se(/<\/no(script|embed|frames)/i), Il = se(/\/>/i), me = {
2383
+ element: 1,
2384
+ attribute: 2,
2385
+ text: 3,
2386
+ cdataSection: 4,
2387
+ entityReference: 5,
2388
+ entityNode: 6,
2389
+ processingInstruction: 7,
2390
+ comment: 8,
2391
+ document: 9,
2392
+ documentType: 10,
2393
+ documentFragment: 11,
2394
+ notation: 12
2395
+ }, Qr = [
2396
+ "style",
2397
+ "script",
2398
+ "xmp",
2399
+ "iframe",
2400
+ "noembed",
2401
+ "noframes",
2402
+ "plaintext",
2403
+ "noscript"
2404
+ ], jl = le(W({}, Qr)), Vl = (function() {
2405
+ const t = {};
2406
+ return $e(Qr, (e) => {
2407
+ t[e] = se(new RegExp("</" + e + "(?=[\\t\\n\\f\\r />])", "i"));
2408
+ }), le(t);
2409
+ })(), Ul = function() {
2410
+ return typeof window > "u" ? null : window;
2411
+ }, zl = function(e, n) {
2412
+ if (typeof e != "object" || typeof e.createPolicy != "function") return null;
2413
+ let r = null;
2414
+ const a = "data-tt-policy-suffix";
2415
+ n && n.hasAttribute(a) && (r = n.getAttribute(a));
2416
+ const l = "dompurify" + (r ? "#" + r : "");
2417
+ try {
2418
+ return e.createPolicy(l, {
2419
+ createHTML(o) {
2420
+ return o;
2421
+ },
2422
+ createScriptURL(o) {
2423
+ return o;
2424
+ }
2425
+ });
2426
+ } catch {
2427
+ return console.warn("TrustedTypes policy " + l + " could not be created."), null;
2428
+ }
2429
+ }, _r = function() {
2430
+ return {
2431
+ afterSanitizeAttributes: [],
2432
+ afterSanitizeElements: [],
2433
+ afterSanitizeShadowDOM: [],
2434
+ beforeSanitizeAttributes: [],
2435
+ beforeSanitizeElements: [],
2436
+ beforeSanitizeShadowDOM: [],
2437
+ uponSanitizeAttribute: [],
2438
+ uponSanitizeElement: [],
2439
+ uponSanitizeShadowNode: []
2440
+ };
2441
+ }, De = function(e, n, r, a) {
2442
+ return fe(e, n) && Xe(e[n]) ? W(a.base ? pe(a.base) : {}, e[n], a.transform) : r;
2443
+ }, nn = function(e, n, r) {
2444
+ const a = fe(e, n) ? e[n] : void 0;
2445
+ return a && typeof a == "object" ? pe(a) : r();
2446
+ };
2447
+ function Zr() {
2448
+ let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Ul();
2449
+ const e = (T) => Zr(T);
2450
+ if (e.version = "3.4.16", e.removed = [], !t || !t.document || t.document.nodeType !== me.document || !t.Element)
2451
+ return e.isSupported = !1, e;
2452
+ let n = t.document;
2453
+ const r = n, a = r.currentScript;
2454
+ t.DocumentFragment;
2455
+ const l = t.HTMLTemplateElement, o = t.Node, s = t.Element, u = t.NodeFilter;
2456
+ t.NamedNodeMap === void 0 && (t.NamedNodeMap || t.MozNamedAttrMap), t.HTMLFormElement;
2457
+ const m = t.DOMParser, h = t.trustedTypes, g = s.prototype, v = be(g, "cloneNode"), d = be(g, "remove"), b = be(g, "removeAttributeNode"), c = be(g, "nextSibling"), S = be(g, "childNodes"), y = be(g, "parentNode"), $ = be(g, "shadowRoot"), w = be(g, "attributes"), N = o && o.prototype ? be(o.prototype, "nodeType") : null, L = o && o.prototype ? be(o.prototype, "nodeName") : null, V = o && o.prototype ? be(o.prototype, "ownerDocument") : null, P = function(i) {
2458
+ return N ? N(i) : i.nodeType;
2459
+ }, I = function(i) {
2460
+ return L ? L(i) : i.nodeName;
2461
+ };
2462
+ if (typeof l == "function") {
2463
+ const T = n.createElement("template");
2464
+ T.content && T.content.ownerDocument && (n = T.content.ownerDocument);
2465
+ }
2466
+ let k, x = "", j, D = !1, M = 0;
2467
+ const K = function() {
2468
+ if (M > 0) throw Re('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.');
2469
+ }, Te = function(i) {
2470
+ K(), M++;
2471
+ try {
2472
+ return k.createHTML(i);
2473
+ } finally {
2474
+ M--;
2475
+ }
2476
+ }, na = function(i) {
2477
+ K(), M++;
2478
+ try {
2479
+ return k.createScriptURL(i);
2480
+ } finally {
2481
+ M--;
2482
+ }
2483
+ }, ra = function() {
2484
+ return D || (j = zl(h, a), D = !0), j;
2485
+ }, mt = n, Ft = mt.implementation, En = mt.createNodeIterator, aa = mt.createDocumentFragment, ia = mt.getElementsByTagName, la = r.importNode;
2486
+ let J = _r();
2487
+ e.isSupported = typeof Xr == "function" && typeof y == "function" && Ft && Ft.createHTMLDocument !== void 0;
2488
+ const oa = kl, sa = Rl, ua = Dl, ca = Ml, fa = Cl, da = Nl, Tn = Fl, ma = Ll;
2489
+ let An = Ar, ee = null;
2490
+ const $t = W({}, [
2491
+ ...br,
2492
+ ...Zt,
2493
+ ...Jt,
2494
+ ...en,
2495
+ ...wr
2496
+ ]);
2497
+ let te = null;
2498
+ const Lt = W({}, [
2499
+ ...Er,
2500
+ ...tn,
2501
+ ...Tr,
2502
+ ...xt
2503
+ ]);
2504
+ let Ae = Object.seal(Ye(null, {
2505
+ tagNameCheck: {
2506
+ writable: !0,
2507
+ configurable: !1,
2508
+ enumerable: !0,
2509
+ value: null
2510
+ },
2511
+ attributeNameCheck: {
2512
+ writable: !0,
2513
+ configurable: !1,
2514
+ enumerable: !0,
2515
+ value: null
2516
+ },
2517
+ allowCustomizedBuiltInElements: {
2518
+ writable: !0,
2519
+ configurable: !1,
2520
+ enumerable: !0,
2521
+ value: !1
2522
+ }
2523
+ })), Ze = null, Sn = null;
2524
+ const _e = Object.seal(Ye(null, {
2525
+ tagCheck: {
2526
+ writable: !0,
2527
+ configurable: !1,
2528
+ enumerable: !0,
2529
+ value: null
2530
+ },
2531
+ attributeCheck: {
2532
+ writable: !0,
2533
+ configurable: !1,
2534
+ enumerable: !0,
2535
+ value: null
2536
+ }
2537
+ }));
2538
+ let On = !0, Pt = !0, _n = !1, xn = !0, xe = !1, Ce = !0, Ne = !1, It = !1, pt = null, yt = null, jt = !1, je = !1, gt = !1, vt = !1, kn = !0, Rn = !1;
2539
+ const Dn = "user-content-";
2540
+ let Vt = !0, Ut = !1, Ve = {}, Ue = null;
2541
+ const Mn = W({}, [
2542
+ "annotation-xml",
2543
+ "audio",
2544
+ "colgroup",
2545
+ "desc",
2546
+ "foreignobject",
2547
+ "head",
2548
+ "iframe",
2549
+ "math",
2550
+ "mi",
2551
+ "mn",
2552
+ "mo",
2553
+ "ms",
2554
+ "mtext",
2555
+ "noembed",
2556
+ "noframes",
2557
+ "noscript",
2558
+ "plaintext",
2559
+ "script",
2560
+ "selectedcontent",
2561
+ "style",
2562
+ "svg",
2563
+ "template",
2564
+ "thead",
2565
+ "title",
2566
+ "video",
2567
+ "xmp"
2568
+ ]);
2569
+ let Cn = null;
2570
+ const Nn = W({}, [
2571
+ "audio",
2572
+ "video",
2573
+ "img",
2574
+ "source",
2575
+ "image",
2576
+ "track"
2577
+ ]);
2578
+ let Fn = null;
2579
+ const $n = W({}, [
2580
+ "alt",
2581
+ "class",
2582
+ "for",
2583
+ "id",
2584
+ "label",
2585
+ "name",
2586
+ "pattern",
2587
+ "placeholder",
2588
+ "role",
2589
+ "summary",
2590
+ "title",
2591
+ "value",
2592
+ "style",
2593
+ "xmlns"
2594
+ ]), ht = "http://www.w3.org/1998/Math/MathML", bt = "http://www.w3.org/2000/svg", Se = "http://www.w3.org/1999/xhtml";
2595
+ let ze = Se, zt = !1, qt = null;
2596
+ const pa = W({}, [
2597
+ ht,
2598
+ bt,
2599
+ Se
2600
+ ], Qt), Ln = le([
2601
+ "mi",
2602
+ "mo",
2603
+ "mn",
2604
+ "ms",
2605
+ "mtext"
2606
+ ]);
2607
+ let Bt = W({}, Ln);
2608
+ const Pn = le(["annotation-xml"]);
2609
+ let Ht = W({}, Pn);
2610
+ const ya = W({}, [
2611
+ "title",
2612
+ "style",
2613
+ "font",
2614
+ "a",
2615
+ "script"
2616
+ ]);
2617
+ let Je = null;
2618
+ const ga = ["application/xhtml+xml", "text/html"], va = "text/html";
2619
+ let ae = null, qe = null;
2620
+ const ha = n.createElement("form"), In = function(i) {
2621
+ return i instanceof RegExp || i instanceof Function;
2622
+ }, Wt = function() {
2623
+ let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2624
+ if (qe && qe === i) return;
2625
+ (!i || typeof i != "object") && (i = {}), i = pe(i), Je = ga.indexOf(i.PARSER_MEDIA_TYPE) === -1 ? va : i.PARSER_MEDIA_TYPE, ae = Je === "application/xhtml+xml" ? Qt : lt, ee = De(i, "ALLOWED_TAGS", $t, { transform: ae }), te = De(i, "ALLOWED_ATTR", Lt, { transform: ae }), qt = De(i, "ALLOWED_NAMESPACES", pa, { transform: Qt }), Fn = De(i, "ADD_URI_SAFE_ATTR", $n, {
2626
+ transform: ae,
2627
+ base: $n
2628
+ }), Cn = De(i, "ADD_DATA_URI_TAGS", Nn, {
2629
+ transform: ae,
2630
+ base: Nn
2631
+ }), Ue = De(i, "FORBID_CONTENTS", Mn, { transform: ae }), Ze = De(i, "FORBID_TAGS", pe({}), { transform: ae }), Sn = De(i, "FORBID_ATTR", pe({}), { transform: ae }), Ve = fe(i, "USE_PROFILES") ? i.USE_PROFILES && typeof i.USE_PROFILES == "object" ? pe(i.USE_PROFILES) : i.USE_PROFILES : !1, On = i.ALLOW_ARIA_ATTR !== !1, Pt = i.ALLOW_DATA_ATTR !== !1, _n = i.ALLOW_UNKNOWN_PROTOCOLS || !1, xn = i.ALLOW_SELF_CLOSE_IN_ATTR !== !1, xe = i.SAFE_FOR_TEMPLATES || !1, Ce = i.SAFE_FOR_XML !== !1, Ne = i.WHOLE_DOCUMENT || !1, je = i.RETURN_DOM || !1, gt = i.RETURN_DOM_FRAGMENT || !1, vt = i.RETURN_TRUSTED_TYPE || !1, jt = i.FORCE_BODY || !1, kn = i.SANITIZE_DOM !== !1, Rn = i.SANITIZE_NAMED_PROPS || !1, Vt = i.KEEP_CONTENT !== !1, Ut = i.IN_PLACE || !1, An = Ol(i.ALLOWED_URI_REGEXP) ? i.ALLOWED_URI_REGEXP : Ar, ze = typeof i.NAMESPACE == "string" ? i.NAMESPACE : Se, Bt = nn(i, "MATHML_TEXT_INTEGRATION_POINTS", () => W({}, Ln)), Ht = nn(i, "HTML_INTEGRATION_POINTS", () => W({}, Pn));
2632
+ const f = nn(i, "CUSTOM_ELEMENT_HANDLING", () => Ye(null));
2633
+ if (Ae = Ye(null), fe(f, "tagNameCheck") && In(f.tagNameCheck) && (Ae.tagNameCheck = f.tagNameCheck), fe(f, "attributeNameCheck") && In(f.attributeNameCheck) && (Ae.attributeNameCheck = f.attributeNameCheck), fe(f, "allowCustomizedBuiltInElements") && typeof f.allowCustomizedBuiltInElements == "boolean" && (Ae.allowCustomizedBuiltInElements = f.allowCustomizedBuiltInElements), se(Ae), xe && (Pt = !1), gt && (je = !0), Ve && (ee = W({}, wr), te = Ye(null), Ve.html === !0 && (W(ee, br), W(te, Er)), Ve.svg === !0 && (W(ee, Zt), W(te, tn), W(te, xt)), Ve.svgFilters === !0 && (W(ee, Jt), W(te, tn), W(te, xt)), Ve.mathMl === !0 && (W(ee, en), W(te, Tr), W(te, xt))), _e.tagCheck = null, _e.attributeCheck = null, fe(i, "ADD_TAGS") && (typeof i.ADD_TAGS == "function" ? _e.tagCheck = i.ADD_TAGS : Xe(i.ADD_TAGS) && (ee === $t && (ee = pe(ee)), W(ee, i.ADD_TAGS, ae))), fe(i, "ADD_ATTR") && (typeof i.ADD_ATTR == "function" ? _e.attributeCheck = i.ADD_ATTR : Xe(i.ADD_ATTR) && (te === Lt && (te = pe(te)), W(te, i.ADD_ATTR, ae))), fe(i, "ADD_FORBID_CONTENTS") && Xe(i.ADD_FORBID_CONTENTS) && (Ue === Mn && (Ue = pe(Ue)), W(Ue, i.ADD_FORBID_CONTENTS, ae)), Vt && (ee["#text"] = !0), Ne && W(ee, [
2634
+ "html",
2635
+ "head",
2636
+ "body"
2637
+ ]), ee.table && (W(ee, ["tbody"]), delete Ze.tbody), i.TRUSTED_TYPES_POLICY) {
2638
+ if (typeof i.TRUSTED_TYPES_POLICY.createHTML != "function") throw Re('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
2639
+ if (typeof i.TRUSTED_TYPES_POLICY.createScriptURL != "function") throw Re('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
2640
+ const E = k;
2641
+ k = i.TRUSTED_TYPES_POLICY;
2642
+ try {
2643
+ x = Te("");
2644
+ } catch (O) {
2645
+ throw k = E, O;
2646
+ }
2647
+ } else i.TRUSTED_TYPES_POLICY === null ? (k = void 0, x = "") : (k === void 0 && (k = ra()), k && typeof x == "string" && (x = Te("")));
2648
+ le && le(i), qe = i;
2649
+ }, jn = W({}, [
2650
+ ...Zt,
2651
+ ...Jt,
2652
+ ..._l
2653
+ ]), Vn = W({}, [...en, ...xl]), ba = function(i, f, E) {
2654
+ return f.namespaceURI === Se ? i === "svg" : f.namespaceURI === ht ? i === "svg" && (E === "annotation-xml" || Bt[E]) : !!jn[i];
2655
+ }, wa = function(i, f, E) {
2656
+ return f.namespaceURI === Se ? i === "math" : f.namespaceURI === bt ? i === "math" && Ht[E] : !!Vn[i];
2657
+ }, Ea = function(i, f, E) {
2658
+ return f.namespaceURI === bt && !Ht[E] || f.namespaceURI === ht && !Bt[E] ? !1 : !Vn[i] && (ya[i] || !jn[i]);
2659
+ }, Ta = function(i) {
2660
+ let f = y(i);
2661
+ (!f || !f.tagName) && (f = {
2662
+ namespaceURI: ze,
2663
+ tagName: "template"
2664
+ });
2665
+ const E = lt(i.tagName), O = lt(f.tagName);
2666
+ return qt[i.namespaceURI] ? i.namespaceURI === bt ? ba(E, f, O) : i.namespaceURI === ht ? wa(E, f, O) : i.namespaceURI === Se ? Ea(E, f, O) : !!(Je === "application/xhtml+xml" && qt[i.namespaceURI]) : !1;
2667
+ }, ke = function(i) {
2668
+ tt(e.removed, { element: i });
2669
+ try {
2670
+ y(i).removeChild(i);
2671
+ } catch {
2672
+ if (d(i), !y(i)) throw Re("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
2673
+ }
2674
+ }, Un = function(i, f, E) {
2675
+ try {
2676
+ b(i, f);
2677
+ } catch {
2678
+ try {
2679
+ i.removeAttribute(E);
2680
+ } catch {
2681
+ }
2682
+ }
2683
+ }, wt = function(i) {
2684
+ Et(i);
2685
+ const f = S(i);
2686
+ if (f) {
2687
+ const O = [];
2688
+ $e(f, (F) => {
2689
+ tt(O, F);
2690
+ }), $e(O, (F) => {
2691
+ try {
2692
+ d(F);
2693
+ } catch {
2694
+ }
2695
+ });
2696
+ }
2697
+ const E = w(i);
2698
+ if (E) for (let O = E.length - 1; O >= 0; --O) {
2699
+ const F = E[O], z = F && F.name;
2700
+ typeof z == "string" && Un(i, F, z);
2701
+ }
2702
+ }, Fe = function(i, f, E) {
2703
+ if (!E) try {
2704
+ E = f.getAttributeNode(i);
2705
+ } catch {
2706
+ E = null;
2707
+ }
2708
+ tt(e.removed, {
2709
+ attribute: E || null,
2710
+ from: f
2711
+ });
2712
+ try {
2713
+ E ? b(f, E) : f.removeAttribute(i);
2714
+ } catch {
2715
+ try {
2716
+ f.removeAttribute(i);
2717
+ } catch {
2718
+ }
2719
+ }
2720
+ if (i === "is")
2721
+ if (je || gt) try {
2722
+ ke(f);
2723
+ } catch {
2724
+ }
2725
+ else try {
2726
+ f.setAttribute(i, "");
2727
+ } catch {
2728
+ }
2729
+ }, Aa = function(i) {
2730
+ const f = w(i);
2731
+ if (f)
2732
+ for (let E = f.length - 1; E >= 0; --E) {
2733
+ const O = f[E], F = O && O.name;
2734
+ typeof F != "string" || te[ae(F)] || Un(i, O, F);
2735
+ }
2736
+ }, Et = function(i) {
2737
+ const f = [i];
2738
+ for (; f.length > 0; ) {
2739
+ const E = f.pop();
2740
+ P(E) === me.element && Aa(E);
2741
+ const O = S(E);
2742
+ if (O) for (let F = O.length - 1; F >= 0; --F) f.push(O[F]);
2743
+ }
2744
+ }, zn = function(i, f) {
2745
+ return Ce ? i === "patchsrc" ? !0 : i === "for" && f !== "label" && f !== "output" : !1;
2746
+ }, Sa = function(i) {
2747
+ if (!Ce) return;
2748
+ const f = [i];
2749
+ for (; f.length > 0; ) {
2750
+ const E = f.pop(), O = P(E);
2751
+ if (O === me.processingInstruction || O === me.comment && ue(Or, E.data)) {
2752
+ try {
2753
+ d(E);
2754
+ } catch {
2755
+ }
2756
+ continue;
2757
+ }
2758
+ if (O === me.element) {
2759
+ const z = E, H = ae(I(E));
2760
+ try {
2761
+ z.hasAttribute && z.hasAttribute("patchsrc") && z.removeAttribute("patchsrc"), z.hasAttribute && z.hasAttribute("for") && zn("for", H) && z.removeAttribute("for");
2762
+ } catch {
2763
+ }
2764
+ }
2765
+ const F = S(E);
2766
+ if (F) for (let z = F.length - 1; z >= 0; --z) f.push(F[z]);
2767
+ }
2768
+ }, qn = function(i) {
2769
+ let f = null, E = null;
2770
+ if (jt) i = "<remove></remove>" + i;
2771
+ else {
2772
+ const z = yr(i, /^[\r\n\t ]+/);
2773
+ E = z && z[0];
2774
+ }
2775
+ Je === "application/xhtml+xml" && ze === Se && (i = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + i + "</body></html>");
2776
+ const O = k ? Te(i) : i;
2777
+ if (ze === Se) try {
2778
+ f = new m().parseFromString(O, Je);
2779
+ } catch {
2780
+ }
2781
+ if (!f || !f.documentElement) {
2782
+ f = Ft.createDocument(ze, "template", null);
2783
+ try {
2784
+ f.documentElement.innerHTML = zt ? x : O;
2785
+ } catch {
2786
+ }
2787
+ }
2788
+ const F = f.body || f.documentElement;
2789
+ return i && E && F.insertBefore(n.createTextNode(E), F.childNodes[0] || null), ze === Se ? ia.call(f, Ne ? "html" : "body")[0] : Ne ? f.documentElement : F;
2790
+ }, Bn = function(i) {
2791
+ const f = V ? V(i) : i.ownerDocument;
2792
+ return En.call(f || i, i, u.SHOW_ELEMENT | u.SHOW_COMMENT | u.SHOW_TEXT | u.SHOW_PROCESSING_INSTRUCTION | u.SHOW_CDATA_SECTION, null);
2793
+ }, Tt = function(i) {
2794
+ return i = nt(i, oa, " "), i = nt(i, sa, " "), i = nt(i, ua, " "), i;
2795
+ }, Gt = function(i) {
2796
+ var f;
2797
+ i.normalize();
2798
+ const E = V ? V(i) : i.ownerDocument, O = En.call(E || i, i, u.SHOW_TEXT | u.SHOW_COMMENT | u.SHOW_CDATA_SECTION | u.SHOW_PROCESSING_INSTRUCTION, null);
2799
+ let F = O.nextNode();
2800
+ for (; F; )
2801
+ F.data = Tt(F.data), F = O.nextNode();
2802
+ const z = (f = i.querySelectorAll) === null || f === void 0 ? void 0 : f.call(i, "template");
2803
+ z && $e(z, (H) => {
2804
+ Be(H.content) && Gt(H.content);
2805
+ });
2806
+ }, At = function(i) {
2807
+ const f = L ? L(i) : null;
2808
+ return typeof f != "string" || ae(f) !== "form" ? !1 : typeof i.nodeName != "string" || typeof i.textContent != "string" || typeof i.removeChild != "function" || i.attributes !== w(i) || typeof i.removeAttribute != "function" || typeof i.removeAttributeNode != "function" || typeof i.getAttributeNode != "function" || typeof i.setAttribute != "function" || typeof i.namespaceURI != "string" || typeof i.insertBefore != "function" || typeof i.hasChildNodes != "function" || i.nodeType !== N(i) || i.childNodes !== S(i);
2809
+ }, Be = function(i) {
2810
+ if (!N || typeof i != "object" || i === null) return !1;
2811
+ try {
2812
+ return N(i) === me.documentFragment;
2813
+ } catch {
2814
+ return !1;
2815
+ }
2816
+ }, et = function(i) {
2817
+ if (!N || typeof i != "object" || i === null) return !1;
2818
+ try {
2819
+ return typeof N(i) == "number";
2820
+ } catch {
2821
+ return !1;
2822
+ }
2823
+ };
2824
+ function Oe(T, i, f) {
2825
+ T.length !== 0 && $e(T, (E) => {
2826
+ E.call(e, i, f, qe);
2827
+ });
2828
+ }
2829
+ const Oa = function(i, f) {
2830
+ return !!(Ce && i.hasChildNodes() && !et(i.firstElementChild) && ue(Sr, i.textContent) && ue(Sr, i.innerHTML) || Ce && i.namespaceURI === Se && jl[f] && (et(i.firstElementChild) || typeof i.textContent == "string" && ue(Vl[f], i.textContent)) || i.nodeType === me.processingInstruction || Ce && i.nodeType === me.comment && ue(Or, i.data));
2831
+ }, St = function(i, f) {
2832
+ if (i instanceof RegExp) return ue(i, f);
2833
+ if (i instanceof Function) {
2834
+ for (var E = arguments.length, O = new Array(E > 2 ? E - 2 : 0), F = 2; F < E; F++) O[F - 2] = arguments[F];
2835
+ return !!i(f, ...O);
2836
+ }
2837
+ return !1;
2838
+ }, _a = function(i, f, E) {
2839
+ if (!Ze[f] && Yn(f) && St(Ae.tagNameCheck, f)) return !1;
2840
+ if (Vt && !Ue[f]) {
2841
+ const O = y(i), F = S(i);
2842
+ if (F && O) {
2843
+ const z = F.length;
2844
+ for (let H = z - 1; H >= 0; --H) {
2845
+ const re = i === E ? v(F[H], !0) : F[H];
2846
+ O.insertBefore(re, c(i));
2847
+ }
2848
+ }
2849
+ }
2850
+ return ke(i), !0;
2851
+ }, Hn = function(i, f, E, O) {
2852
+ return i.length === 0 ? f : f === E || f === O ? pe(f) : f;
2853
+ }, He = function(i, f) {
2854
+ return i === f || y(i) !== null ? !1 : (Ut && Et(i), !0);
2855
+ }, Wn = function(i, f) {
2856
+ if (Oe(J.beforeSanitizeElements, i, null), He(i, f)) return !0;
2857
+ if (At(i))
2858
+ return ke(i), !0;
2859
+ const E = ae(I(i));
2860
+ if (ee = Hn(J.uponSanitizeElement, ee, $t, pt), Oe(J.uponSanitizeElement, i, {
2861
+ tagName: E,
2862
+ allowedTags: ee
2863
+ }), He(i, f)) return !0;
2864
+ if (Oa(i, E))
2865
+ return ke(i), !0;
2866
+ if (Ze[E] || !(_e.tagCheck instanceof Function && _e.tagCheck(E)) && !ee[E]) {
2867
+ const O = _a(i, E, f);
2868
+ return O === !1 && (Oe(J.afterSanitizeElements, i, null), He(i, f)) ? !0 : O;
2869
+ }
2870
+ if (P(i) === me.element && !Ta(i) || (E === "noscript" || E === "noembed" || E === "noframes") && ue(Pl, i.innerHTML))
2871
+ return ke(i), !0;
2872
+ if (xe && i.nodeType === me.text) {
2873
+ const O = Tt(i.textContent);
2874
+ i.textContent !== O && (tt(e.removed, { element: i.cloneNode() }), i.textContent = O);
2875
+ }
2876
+ return Oe(J.afterSanitizeElements, i, null), He(i, f);
2877
+ }, Gn = function(i, f, E) {
2878
+ if (Sn[f] || zn(f, i) || kn && (f === "id" || f === "name") && (E in n || E in ha)) return !1;
2879
+ const O = te[f] || _e.attributeCheck instanceof Function && _e.attributeCheck(f, i);
2880
+ return Pt && ue(ca, f) || On && ue(fa, f) ? !0 : O ? Fn[f] || ue(An, nt(E, Tn, "")) || (f === "src" || f === "xlink:href" || f === "href") && i !== "script" && gr(E, "data:") === 0 && Cn[i] || _n && !ue(da, nt(E, Tn, "")) ? !0 : !E : Yn(i) && St(Ae.tagNameCheck, i) && St(Ae.attributeNameCheck, f, i) || f === "is" && Ae.allowCustomizedBuiltInElements && St(Ae.tagNameCheck, E);
2881
+ }, xa = W({}, [
2882
+ "annotation-xml",
2883
+ "color-profile",
2884
+ "font-face",
2885
+ "font-face-format",
2886
+ "font-face-name",
2887
+ "font-face-src",
2888
+ "font-face-uri",
2889
+ "missing-glyph"
2890
+ ]), Yn = function(i) {
2891
+ return !xa[lt(i)] && ue(ma, i);
2892
+ }, ka = function(i, f, E, O) {
2893
+ if (k && typeof h == "object" && typeof h.getAttributeType == "function" && !E) switch (h.getAttributeType(i, f)) {
2894
+ case "TrustedHTML":
2895
+ return Te(O);
2896
+ case "TrustedScriptURL":
2897
+ return na(O);
2898
+ }
2899
+ return O;
2900
+ }, Ra = function(i, f, E, O) {
2901
+ try {
2902
+ return E ? i.setAttributeNS(E, f, O) : i.setAttribute(f, O), At(i) ? (ke(i), !1) : !0;
2903
+ } catch {
2904
+ return Fe(f, i), !1;
2905
+ }
2906
+ }, Xn = function(i, f) {
2907
+ if (Oe(J.beforeSanitizeAttributes, i, null), He(i, f)) return;
2908
+ const E = i.attributes;
2909
+ if (!E || At(i)) return;
2910
+ te = Hn(J.uponSanitizeAttribute, te, Lt, yt);
2911
+ const O = {
2912
+ attrName: "",
2913
+ attrValue: "",
2914
+ keepAttr: !0,
2915
+ allowedAttributes: te,
2916
+ forceKeepAttr: void 0
2917
+ };
2918
+ let F = E.length;
2919
+ const z = ae(i.nodeName);
2920
+ for (; F--; ) {
2921
+ const H = E[F], re = H.name, he = H.namespaceURI, de = H.value, We = ae(re), Xt = de;
2922
+ let ce = re === "value" ? Xt : bl(Xt), Kn = !1;
2923
+ if (O.attrName = We, O.attrValue = ce, O.keepAttr = !0, O.forceKeepAttr = void 0, Oe(J.uponSanitizeAttribute, i, O), ce = O.attrValue, Rn && (We === "id" || We === "name") && gr(ce, Dn) !== 0 && (Fe(re, i, H), ce = Dn + ce, Kn = !0), Ce && ue(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, ce)) {
2924
+ Fe(re, i, H);
2925
+ continue;
2926
+ }
2927
+ if (We === "attributename" && yr(ce, "href")) {
2928
+ Fe(re, i, H);
2929
+ continue;
2930
+ }
2931
+ if (!O.forceKeepAttr) {
2932
+ if (!O.keepAttr) {
2933
+ Fe(re, i, H);
2934
+ continue;
2935
+ }
2936
+ if (!xn && ue(Il, ce)) {
2937
+ Fe(re, i, H);
2938
+ continue;
2939
+ }
2940
+ if (xe && (ce = Tt(ce)), !Gn(z, We, ce)) {
2941
+ Fe(re, i, H);
2942
+ continue;
2943
+ }
2944
+ ce = ka(z, We, he, ce), ce !== Xt && Ra(i, re, he, ce) && Kn && pr(e.removed);
2945
+ }
2946
+ }
2947
+ Oe(J.afterSanitizeAttributes, i, null), He(i, f);
2948
+ }, Ot = function(i) {
2949
+ let f = null;
2950
+ const E = Bn(i);
2951
+ for (Oe(J.beforeSanitizeShadowDOM, i, null); f = E.nextNode(); )
2952
+ if (Oe(J.uponSanitizeShadowNode, f, null), Wn(f, i), Xn(f, i), Be(f.content) && Ot(f.content), P(f) === me.element) {
2953
+ const O = $(f);
2954
+ Be(O) && (Yt(O), Ot(O));
2955
+ }
2956
+ Oe(J.afterSanitizeShadowDOM, i, null);
2957
+ }, Yt = function(i) {
2958
+ const f = [{
2959
+ node: i,
2960
+ shadow: null
2961
+ }];
2962
+ for (; f.length > 0; ) {
2963
+ const E = f.pop();
2964
+ if (E.shadow) {
2965
+ Ot(E.shadow);
2966
+ continue;
2967
+ }
2968
+ const O = E.node, F = P(O) === me.element, z = S(O);
2969
+ if (z) for (let H = z.length - 1; H >= 0; --H) f.push({
2970
+ node: z[H],
2971
+ shadow: null
2972
+ });
2973
+ if (F) {
2974
+ const H = L ? L(O) : null;
2975
+ if (typeof H == "string" && ae(H) === "template") {
2976
+ const re = O.content;
2977
+ Be(re) && f.push({
2978
+ node: re,
2979
+ shadow: null
2980
+ });
2981
+ }
2982
+ }
2983
+ if (F) {
2984
+ const H = $(O);
2985
+ Be(H) && f.push({
2986
+ node: null,
2987
+ shadow: H
2988
+ }, {
2989
+ node: H,
2990
+ shadow: null
2991
+ });
2992
+ }
2993
+ }
2994
+ };
2995
+ return e.sanitize = function(T) {
2996
+ let i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, f = null, E = null, O = null, F = null;
2997
+ if (zt = !T, zt && (T = "<!-->"), typeof T != "string" && !et(T) && (T = Sl(T), typeof T != "string"))
2998
+ throw Re("dirty is not a string, aborting");
2999
+ if (!e.isSupported) return T;
3000
+ It ? (ee = pt, te = yt) : Wt(i), (J.uponSanitizeElement.length > 0 || J.uponSanitizeAttribute.length > 0) && (ee = pe(ee)), J.uponSanitizeAttribute.length > 0 && (te = pe(te)), e.removed = [];
3001
+ const z = Ut && typeof T != "string" && et(T);
3002
+ if (z) {
3003
+ Sa(T);
3004
+ const he = I(T);
3005
+ if (typeof he == "string") {
3006
+ const de = ae(he);
3007
+ if (!ee[de] || Ze[de])
3008
+ throw wt(T), Re("root node is forbidden and cannot be sanitized in-place");
3009
+ }
3010
+ if (At(T))
3011
+ throw wt(T), Re("root node is clobbered and cannot be sanitized in-place");
3012
+ try {
3013
+ Yt(T);
3014
+ } catch (de) {
3015
+ throw wt(T), de;
3016
+ }
3017
+ } else if (et(T))
3018
+ f = qn("<!---->"), E = f.ownerDocument.importNode(T, !0), E.nodeType === me.element && E.nodeName === "BODY" || E.nodeName === "HTML" ? f = E : f.appendChild(E), Yt(f);
3019
+ else {
3020
+ if (!je && !xe && !Ne && T.indexOf("<") === -1) return k && vt ? Te(T) : T;
3021
+ if (f = qn(T), !f) return je ? null : vt ? x : "";
3022
+ }
3023
+ f && jt && ke(f.firstChild);
3024
+ const H = z ? T : f;
3025
+ try {
3026
+ const he = Bn(H);
3027
+ for (; O = he.nextNode(); )
3028
+ Wn(O, H), Xn(O, H), Be(O.content) && Ot(O.content);
3029
+ } catch (he) {
3030
+ throw z && (wt(T), $e(e.removed, (de) => {
3031
+ de.element && Et(de.element);
3032
+ })), he;
3033
+ }
3034
+ if (z) {
3035
+ let he = !1;
3036
+ if ($e(e.removed, (de) => {
3037
+ de.element && (de.element === T && (he = !0), Et(de.element));
3038
+ }), he) throw Re("a node selected for removal could not be safely returned; refusing to sanitize in place");
3039
+ return xe && Gt(T), T;
3040
+ }
3041
+ if (je) {
3042
+ if (xe && Gt(f), gt)
3043
+ for (F = aa.call(f.ownerDocument); f.firstChild; ) F.appendChild(f.firstChild);
3044
+ else F = f;
3045
+ return (te.shadowroot || te.shadowrootmode) && (F = la.call(r, F, !0)), F;
3046
+ }
3047
+ let re = Ne ? f.outerHTML : f.innerHTML;
3048
+ return Ne && ee["!doctype"] && f.ownerDocument && f.ownerDocument.doctype && f.ownerDocument.doctype.name && ue($l, f.ownerDocument.doctype.name) && (re = "<!DOCTYPE " + f.ownerDocument.doctype.name + `>
3049
+ ` + re), xe && (re = Tt(re)), k && vt ? Te(re) : re;
3050
+ }, e.setConfig = function() {
3051
+ let T = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3052
+ Wt(T), It = !0, pt = ee, yt = te;
3053
+ }, e.clearConfig = function() {
3054
+ qe = null, It = !1, pt = null, yt = null, k = j, x = "";
3055
+ }, e.isValidAttribute = function(T, i, f) {
3056
+ qe || Wt({});
3057
+ const E = ae(T), O = ae(i);
3058
+ return Gn(E, O, f);
3059
+ }, e.addHook = function(T, i) {
3060
+ typeof i == "function" && fe(J, T) && tt(J[T], i);
3061
+ }, e.removeHook = function(T, i) {
3062
+ if (fe(J, T)) {
3063
+ if (i !== void 0) {
3064
+ const f = vl(J[T], i);
3065
+ return f === -1 ? void 0 : hl(J[T], f, 1)[0];
3066
+ }
3067
+ return pr(J[T]);
3068
+ }
3069
+ }, e.removeHooks = function(T) {
3070
+ fe(J, T) && (J[T] = []);
3071
+ }, e.removeAllHooks = function() {
3072
+ J = _r();
3073
+ }, e;
3074
+ }
3075
+ var ql = Zr();
3076
+ const dt = (t, e) => {
3077
+ const n = t.__vccOpts || t;
3078
+ for (const [r, a] of e)
3079
+ n[r] = a;
3080
+ return n;
3081
+ }, Bl = { key: 1 }, Hl = {
3082
+ __name: "ForeignKey",
3083
+ props: {
3084
+ value: { type: Object, required: !0 },
3085
+ field: { type: Object, required: !0 },
3086
+ context: Object
3087
+ },
3088
+ setup(t) {
3089
+ const e = t, { registry: n } = Ie(), r = Ct(ja, null), a = X(() => e.field.model || e.field.relateModel), l = X(() => e.value[e.field.keyField || e.field.name]), o = X(() => {
3090
+ const u = e.value[`${e.field.name}_name`] ?? e.value[e.field.name], m = typeof e.field.labelFormat == "function" ? e.field.labelFormat(u) : u;
3091
+ return m == null || m === "" ? "—" : Array.isArray(m) ? m.join("、") : String(m);
3092
+ }), s = X(() => {
3093
+ if (!r || !n.configs[a.value] || e.field.showLink === !1) return null;
3094
+ const u = l.value;
3095
+ if (u == null || u === "" || Array.isArray(u) || typeof u == "object") return null;
3096
+ const m = `${a.value.replace(".", "-")}-edit`;
3097
+ if (r.hasRoute(m)) return { name: m, params: { id: u } };
3098
+ const h = `/${a.value.replace(".", "/")}/${encodeURIComponent(u)}/`, g = r.resolve(h);
3099
+ return !g.matched.length || g.matched.some((v) => v.path.includes(":pathMatch")) ? null : { path: h };
3100
+ });
3101
+ return (u, m) => s.value ? (p(), _(A(Fr), {
3102
+ key: 0,
3103
+ to: s.value,
3104
+ title: "点击跳转",
3105
+ class: "foreignkey-link"
3106
+ }, {
3107
+ default: C(() => [
3108
+ Z(Y(o.value), 1)
3109
+ ]),
3110
+ _: 1
3111
+ }, 8, ["to"])) : (p(), R("span", Bl, Y(o.value), 1));
3112
+ }
3113
+ }, Wl = /* @__PURE__ */ dt(Hl, [["__scopeId", "data-v-72c5023a"]]);
3114
+ function Jr(t, e) {
3115
+ return String(e).split(".").reduce((n, r) => n?.[r], t);
3116
+ }
3117
+ function rn(t) {
3118
+ if (typeof t != "string" || !t.trim()) return;
3119
+ const e = t.trim();
3120
+ if (/^(https?:|mailto:|tel:)/i.test(e) || /^(\/[^/]|\.\.?\/)/.test(e)) return e;
3121
+ }
3122
+ function Gl(t, e) {
3123
+ const n = Jr(e, t.name);
3124
+ if (t.formatter) return t.formatter(e, t.name, n);
3125
+ if (n == null || n === "") return "—";
3126
+ if (t.choices) return at(t, n);
3127
+ if (["integer", "decimal", "float", "number", "percent"].includes(t.type)) {
3128
+ const r = Number(n);
3129
+ return Number.isFinite(r) ? t.type === "percent" ? `${Number((r * 100).toFixed(2))}%` : r.toLocaleString("zh-CN", { maximumFractionDigits: 20 }) : String(n);
3130
+ }
3131
+ return t.child && Array.isArray(n) ? n.map((r) => r == null || typeof r != "object" ? at(t.child, r) : Object.entries(t.child.children ?? {}).map(([a, l]) => at(l, r[a])).join(",") || JSON.stringify(r)).join(`
3132
+ `) : at(t, n);
3133
+ }
3134
+ function Yl(t, e = !1) {
3135
+ if (t == null || t === "") return "";
3136
+ const r = e || typeof t == "number" || /^\d+$/.test(String(t)) ? Number(t) * (Number(t) < 1e10 ? 1e3 : 1) : t, a = new Date(r);
3137
+ return Number.isNaN(a.getTime()) ? String(t) : a.toLocaleString("zh-CN");
3138
+ }
3139
+ const Xl = ["innerHTML"], Kl = { key: 4 }, Ql = ["aria-label", "title"], Zl = ["title"], Jl = {
3140
+ key: 8,
3141
+ class: "vd-table-images"
3142
+ }, eo = ["src"], to = ["href"], no = {
3143
+ key: 11,
3144
+ class: "vd-table-json"
3145
+ }, ro = ["title"], ao = {
3146
+ __name: "Widget",
3147
+ props: {
3148
+ value: { type: Object, required: !0 },
3149
+ field: { type: Object, required: !0 },
3150
+ context: { type: Object, default: () => ({}) },
3151
+ mobile: Boolean
3152
+ },
3153
+ emits: ["change"],
3154
+ setup(t, { emit: e }) {
3155
+ const n = t, r = e, a = X(() => Jr(n.value, n.field.name)), l = X(() => Gl(n.field, n.value)), o = X(() => Fa(n.field.cellWidget ?? n.field.widget)), s = X(() => typeof o.value == "string" ? o.value.toLowerCase() : ""), u = X(() => ({ row: n.value, ...n.context })), m = X(
3156
+ () => ql.sanitize(
3157
+ String(
3158
+ typeof o.value == "function" ? o.value(n.value, n.field) : l.value ?? ""
3159
+ )
3160
+ )
3161
+ ), h = X(() => Yl(a.value, s.value === "timestamp")), g = X(
3162
+ () => (Array.isArray(a.value) ? a.value : [a.value]).map(
3163
+ (d) => rn(`${n.field.proxy ?? ""}${n.field.imageRoot ?? ""}${d ?? ""}`)
3164
+ ).filter(Boolean)
3165
+ ), v = X(
3166
+ () => (n.field.items ?? Object.keys(a.value ?? {})).map(
3167
+ (d) => typeof d == "string" ? { name: d } : d
3168
+ )
3169
+ );
3170
+ return (d, b) => {
3171
+ const c = $a("Widget", !0);
3172
+ return t.field.useFormWidget ? (p(), _(Mt, {
3173
+ key: 0,
3174
+ field: { ...t.field, read_only: !1 },
3175
+ "model-value": a.value,
3176
+ mobile: t.mobile,
3177
+ "onUpdate:modelValue": b[0] || (b[0] = (S) => r("change", S))
3178
+ }, null, 8, ["field", "model-value", "mobile"])) : o.value && typeof o.value == "object" ? (p(), _(Qe(o.value), {
3179
+ key: 1,
3180
+ value: t.value,
3181
+ "model-value": t.value,
3182
+ field: t.field,
3183
+ context: u.value,
3184
+ "onUpdate:modelValue": b[1] || (b[1] = (S) => r("change", S))
3185
+ }, null, 8, ["value", "model-value", "field", "context"])) : typeof o.value == "function" || s.value === "html" ? (p(), R("span", {
3186
+ key: 2,
3187
+ innerHTML: m.value
3188
+ }, null, 8, Xl)) : s.value === "foreignkey" || !o.value && !t.field.formatter && (t.field.model || t.field.relateModel) ? (p(), _(Wl, {
3189
+ key: 3,
3190
+ value: t.value,
3191
+ field: t.field,
3192
+ context: u.value
3193
+ }, null, 8, ["value", "field", "context"])) : a.value == null || a.value === "" ? (p(), R("span", Kl, Y(l.value), 1)) : s.value === "trueflag" || !o.value && !t.field.formatter && t.field.type === "boolean" ? (p(), R("span", {
3194
+ key: 5,
3195
+ class: Nt(["vd-table-boolean", { "is-true": a.value }]),
3196
+ "aria-label": a.value ? "是" : "否",
3197
+ title: a.value ? "是" : "否"
3198
+ }, Y(a.value ? "✓" : "—"), 11, Ql)) : ["date2now", "timestamp", "date", "datetime"].includes(s.value) || !o.value && !t.field.formatter && ["date", "datetime"].includes(t.field.type) ? (p(), R("span", {
3199
+ key: 6,
3200
+ title: h.value
3201
+ }, Y(h.value), 9, Zl)) : s.value === "avatar" ? (p(), _(A(Ga), {
3202
+ key: 7,
3203
+ src: g.value[0],
3204
+ size: t.field.size ?? 40
3205
+ }, null, 8, ["src", "size"])) : ["picture", "image", "picturegallery"].includes(s.value) ? (p(), R("div", Jl, [
3206
+ (p(!0), R(G, null, ne(g.value, (S) => (p(), _(A(Ya), {
3207
+ key: S,
3208
+ src: S,
3209
+ "preview-src-list": g.value,
3210
+ "preview-teleported": "",
3211
+ fit: "contain",
3212
+ style: Qn({ width: `${t.field.width ?? 64}px`, height: `${t.field.height ?? 48}px` })
3213
+ }, {
3214
+ error: C(() => [...b[2] || (b[2] = [
3215
+ Z("图片无法加载", -1)
3216
+ ])]),
3217
+ _: 1
3218
+ }, 8, ["src", "preview-src-list", "style"]))), 128))
3219
+ ])) : s.value === "video" ? (p(), R("video", {
3220
+ key: 9,
3221
+ src: A(rn)(a.value),
3222
+ controls: "",
3223
+ preload: "none",
3224
+ class: "vd-table-video"
3225
+ }, null, 8, eo)) : ["url", "link", "mobile", "email"].includes(s.value) || !o.value && ["url", "email"].includes(t.field.type) ? (p(), R("a", {
3226
+ key: 10,
3227
+ href: A(rn)(
3228
+ s.value === "mobile" ? `tel:${a.value}` : s.value === "email" || t.field.type === "email" ? `mailto:${a.value}` : a.value
3229
+ ),
3230
+ target: "_blank",
3231
+ rel: "noopener noreferrer"
3232
+ }, Y(l.value), 9, to)) : s.value === "jsondisplay" && typeof a.value == "object" ? (p(), R("dl", no, [
3233
+ (p(!0), R(G, null, ne(v.value, (S) => (p(), R(G, {
3234
+ key: S.name
3235
+ }, [
3236
+ we("dt", null, Y(S.label ?? S.name), 1),
3237
+ we("dd", null, [
3238
+ U(c, {
3239
+ value: a.value,
3240
+ field: S,
3241
+ context: u.value,
3242
+ mobile: t.mobile
3243
+ }, null, 8, ["value", "field", "context", "mobile"])
3244
+ ])
3245
+ ], 64))), 128))
3246
+ ])) : s.value === "colortext" ? (p(), _(A(Xa), {
3247
+ key: 12,
3248
+ style: Qn({ backgroundColor: t.field.getColor?.(u.value) ?? t.field.color })
3249
+ }, {
3250
+ default: C(() => [
3251
+ Z(Y(l.value), 1)
3252
+ ]),
3253
+ _: 1
3254
+ }, 8, ["style"])) : (p(), R("span", {
3255
+ key: 13,
3256
+ class: "vd-table-text",
3257
+ title: s.value === "tooltipcell" ? String(l.value) : void 0
3258
+ }, Y(l.value), 9, ro));
3259
+ };
3260
+ }
3261
+ }, xr = /* @__PURE__ */ dt(ao, [["__scopeId", "data-v-6281d15c"]]), ea = {
3262
+ __name: "Drawer",
3263
+ props: { loadView: Function },
3264
+ emits: ["done", "error", "closed"],
3265
+ setup(t, { expose: e, emit: n }) {
3266
+ const r = t, a = n, l = q(!1), o = ot(), s = q("");
3267
+ let u = 0;
3268
+ async function m(d = {}) {
3269
+ const b = ++u;
3270
+ l.value = !1, o.value = void 0, s.value = "";
3271
+ try {
3272
+ let c = d.component;
3273
+ if (typeof c == "string") {
3274
+ if (!r.loadView) throw new Error("字符串抽屉组件需要配置 loadDrawerView");
3275
+ const y = await r.loadView(c);
3276
+ c = y.default ?? y;
3277
+ }
3278
+ if (b !== u) return;
3279
+ if (!c) throw new Error("抽屉缺少 component");
3280
+ const S = Object.fromEntries(
3281
+ Object.entries(d.context ?? {}).filter(([y]) => !y.startsWith("$"))
3282
+ );
3283
+ o.value = {
3284
+ ...d,
3285
+ component: c,
3286
+ context: S,
3287
+ title: d.title ?? S.title ?? d.label ?? "",
3288
+ size: d.size ?? S.size ?? "30%"
3289
+ }, l.value = !0;
3290
+ } catch (c) {
3291
+ if (b !== u) return;
3292
+ throw a("error", c), c;
3293
+ }
3294
+ }
3295
+ function h() {
3296
+ u++, l.value = !1;
3297
+ }
3298
+ async function g(d) {
3299
+ const b = o.value?.onDone;
3300
+ h(), a("done", d);
3301
+ try {
3302
+ await b?.(d);
3303
+ } catch (c) {
3304
+ s.value = c.message, a("error", c);
3305
+ }
3306
+ }
3307
+ function v() {
3308
+ l.value || (o.value = void 0), a("closed");
3309
+ }
3310
+ return e({ open: m, onOpen: m, close: h }), (d, b) => (p(), R(G, null, [
3311
+ s.value ? (p(), _(A(Pe), {
3312
+ key: 0,
3313
+ title: s.value,
3314
+ type: "error"
3315
+ }, null, 8, ["title"])) : Q("", !0),
3316
+ U(A(Pr), Me({
3317
+ modelValue: l.value,
3318
+ "onUpdate:modelValue": b[0] || (b[0] = (c) => l.value = c)
3319
+ }, d.$attrs, {
3320
+ title: o.value?.title,
3321
+ size: o.value?.size ?? "30%",
3322
+ direction: o.value?.direction ?? "rtl",
3323
+ "before-close": o.value?.beforeClose,
3324
+ onClosed: v
3325
+ }), {
3326
+ default: C(() => [
3327
+ o.value ? (p(), _(Qe(o.value.component), Me({ key: 0 }, o.value.context, { onDone: g }), null, 16)) : Q("", !0)
3328
+ ]),
3329
+ _: 1
3330
+ }, 16, ["modelValue", "title", "size", "direction", "before-close"])
3331
+ ], 64));
3332
+ }
3333
+ }, io = {
3334
+ __name: "Create",
3335
+ props: {
3336
+ appModel: { type: String, required: !0 },
3337
+ defaults: Object,
3338
+ mobile: Boolean
3339
+ },
3340
+ emits: ["done", "error"],
3341
+ setup(t, { emit: e }) {
3342
+ const n = e;
3343
+ return (r, a) => (p(), _(wn, {
3344
+ "app-model": t.appModel,
3345
+ defaults: t.defaults,
3346
+ mobile: t.mobile,
3347
+ onFormPosted: a[0] || (a[0] = (l) => n("done", l)),
3348
+ onError: a[1] || (a[1] = (l) => n("error", l))
3349
+ }, null, 8, ["app-model", "defaults", "mobile"]));
3350
+ }
3351
+ }, lo = ["aria-busy"], oo = { class: "vd-toolbar" }, so = { key: 4 }, uo = { key: 0 }, co = {
3352
+ __name: "Table",
3353
+ props: {
3354
+ appModel: { type: String, required: !0 },
3355
+ items: [Array, String],
3356
+ baseQueries: { type: Object, default: () => ({}) },
3357
+ pageSize: { type: Number, default: 10 },
3358
+ mobile: Boolean,
3359
+ rowActions: Array,
3360
+ dblClickAction: String,
3361
+ createMode: { type: String, default: "drawer" },
3362
+ createDefaults: Object,
3363
+ createDrawerSize: { type: String, default: "66%" }
3364
+ },
3365
+ emits: [
3366
+ "loaded",
3367
+ "edit",
3368
+ "create",
3369
+ "created",
3370
+ "error",
3371
+ "row-dblclick",
3372
+ "field-change"
3373
+ ],
3374
+ setup(t, { expose: e, emit: n }) {
3375
+ const r = t, a = n, l = q(), { registry: o, auth: s } = Ie(), u = q([]), m = q([]), h = q(0), g = q(""), v = q(1), d = q(!1), b = q(""), c = q({}), S = q({}), y = X(() => o.getConfig(r.appModel).verbose_name ?? r.appModel);
3376
+ let $ = 0;
3377
+ async function w() {
3378
+ if (a("create"), r.createMode !== "event")
3379
+ try {
3380
+ await l.value.open({
3381
+ component: io,
3382
+ title: `创建${y.value}`,
3383
+ size: r.mobile ? "100%" : r.createDrawerSize,
3384
+ context: {
3385
+ appModel: r.appModel,
3386
+ defaults: { ...r.baseQueries, ...r.createDefaults },
3387
+ mobile: r.mobile,
3388
+ onError: (x) => a("error", x)
3389
+ },
3390
+ onDone: async (x) => {
3391
+ a("created", x), await N();
3392
+ }
3393
+ });
3394
+ } catch (x) {
3395
+ b.value = x.message, a("error", x);
3396
+ }
3397
+ }
3398
+ async function N() {
3399
+ const x = ++$;
3400
+ d.value = !0, b.value = "";
3401
+ try {
3402
+ const j = o.get(r.appModel), [D, M] = await Promise.all([j.fields(), j.loadViewsConfig()]), K = await j.query({
3403
+ ...S.value,
3404
+ search: g.value || void 0,
3405
+ page: v.value,
3406
+ page_size: r.pageSize,
3407
+ ...M.list?.baseQueries,
3408
+ ...r.baseQueries
3409
+ });
3410
+ if (x !== $) return;
3411
+ if (c.value = M, m.value = bn(
3412
+ r.items ?? M.list?.items ?? M.list?.table ?? "all",
3413
+ D
3414
+ ), u.value = Array.isArray(K) ? K : K.results, h.value = Array.isArray(K) ? K.length : K.count, !Array.isArray(u.value) || !Number.isFinite(h.value))
3415
+ throw new Error("首轮列表需要 DRF PageNumberPagination 的 count/results 或数组响应");
3416
+ a("loaded", K);
3417
+ } catch (j) {
3418
+ x === $ && (u.value = [], h.value = 0, b.value = j.message, a("error", j));
3419
+ } finally {
3420
+ x === $ && (d.value = !1);
3421
+ }
3422
+ }
3423
+ function L() {
3424
+ v.value !== 1 ? v.value = 1 : N();
3425
+ }
3426
+ function V(x) {
3427
+ S.value = x, g.value = x.search || "", L();
3428
+ }
3429
+ function P(x, j, D) {
3430
+ a("row-dblclick", x, j, D);
3431
+ const M = r.dblClickAction ?? c.value.list?.dblClickAction ?? "edit";
3432
+ if (M && !D?.target?.closest?.('a, button, input, select, textarea, [role="button"]'))
3433
+ if (M === "edit") a("edit", x);
3434
+ else {
3435
+ const K = k.value.find((Te) => Te.name === M);
3436
+ K && (!K.show || K.show({ row: x })) && I(K, x);
3437
+ }
3438
+ }
3439
+ async function I(x, j) {
3440
+ try {
3441
+ const D = o.get(r.appModel);
3442
+ if (typeof x.do == "function") await x.do({ row: j, model: D, registry: o });
3443
+ else if (x.api || x.name)
3444
+ await D.doAction(
3445
+ x.api || x.name,
3446
+ x.context,
3447
+ x.method ?? "post",
3448
+ j[D.config.idField ?? "id"]
3449
+ );
3450
+ else throw new Error("首轮行操作需要 do 函数或 api 配置");
3451
+ await N();
3452
+ } catch (D) {
3453
+ b.value = D.message, a("error", D);
3454
+ }
3455
+ }
3456
+ const k = X(
3457
+ () => (r.rowActions ?? c.value.list?.rowActions ?? c.value.list?.options?.remoteTable?.rowActions ?? []).filter((x) => {
3458
+ if (!x.permission) return !0;
3459
+ const j = s?.state.user?.model_permissions?.[r.appModel];
3460
+ return s?.state.user?.is_superuser || Array.isArray(j) && j.includes(x.permission);
3461
+ }).map((x) => ({
3462
+ ...x,
3463
+ label: x.label || x.title || x.verbose_name || x.name
3464
+ }))
3465
+ );
3466
+ return Ee(
3467
+ () => [r.appModel, r.baseQueries, r.pageSize],
3468
+ () => {
3469
+ v.value = 1, N();
3470
+ },
3471
+ { immediate: !0, deep: !0 }
3472
+ ), Ee(v, N), e({ refresh: N, load: N }), (x, j) => (p(), R("section", { "aria-busy": d.value }, [
3473
+ U(ea, {
3474
+ ref_key: "createDrawer",
3475
+ ref: l,
3476
+ onError: j[0] || (j[0] = (D) => a("error", D))
3477
+ }, null, 512),
3478
+ we("div", oo, [
3479
+ we("h2", null, Y(y.value), 1),
3480
+ t.mobile ? (p(), _(A(st), {
3481
+ key: 0,
3482
+ type: "primary",
3483
+ size: "small",
3484
+ onClick: w
3485
+ }, {
3486
+ default: C(() => [...j[5] || (j[5] = [
3487
+ Z("新增", -1)
3488
+ ])]),
3489
+ _: 1
3490
+ })) : (p(), _(A(ve), {
3491
+ key: 1,
3492
+ type: "primary",
3493
+ onClick: w
3494
+ }, {
3495
+ default: C(() => [...j[6] || (j[6] = [
3496
+ Z("新增", -1)
3497
+ ])]),
3498
+ _: 1
3499
+ }))
3500
+ ]),
3501
+ t.mobile ? (p(), _(A(si), {
3502
+ key: 0,
3503
+ modelValue: g.value,
3504
+ "onUpdate:modelValue": j[1] || (j[1] = (D) => g.value = D),
3505
+ placeholder: "搜索记录",
3506
+ onSearch: L,
3507
+ onClear: L
3508
+ }, null, 8, ["modelValue"])) : (p(), _(sl, {
3509
+ key: 1,
3510
+ "app-model": t.appModel,
3511
+ onChange: V,
3512
+ onError: j[2] || (j[2] = (D) => b.value = D.message)
3513
+ }, null, 8, ["app-model"])),
3514
+ b.value && t.mobile ? (p(), _(A(hn), {
3515
+ key: 2,
3516
+ text: b.value
3517
+ }, null, 8, ["text"])) : b.value ? (p(), _(A(Pe), {
3518
+ key: 3,
3519
+ title: b.value,
3520
+ type: "error",
3521
+ closable: !1
3522
+ }, null, 8, ["title"])) : Q("", !0),
3523
+ d.value ? (p(), R("p", so, "加载中…")) : t.mobile ? (p(), R(G, { key: 5 }, [
3524
+ !u.value.length && !b.value ? (p(), R("p", uo, "暂无数据")) : Q("", !0),
3525
+ (p(!0), R(G, null, ne(u.value, (D) => (p(), _(A(ui), {
3526
+ key: D[A(o).getConfig(t.appModel).idField ?? "id"],
3527
+ inset: "",
3528
+ class: "vd-card"
3529
+ }, {
3530
+ default: C(() => [
3531
+ (p(!0), R(G, null, ne(m.value, (M) => (p(), _(A(ir), {
3532
+ key: M.name,
3533
+ title: M.label || M.name
3534
+ }, {
3535
+ value: C(() => [
3536
+ ye(x.$slots, `column-${M.name}`, {
3537
+ row: D,
3538
+ field: M
3539
+ }, () => [
3540
+ U(xr, {
3541
+ value: D,
3542
+ field: M,
3543
+ mobile: "",
3544
+ onChange: (K) => a("field-change", { row: D, field: M, value: K })
3545
+ }, null, 8, ["value", "field", "onChange"])
3546
+ ])
3547
+ ]),
3548
+ _: 2
3549
+ }, 1032, ["title"]))), 128)),
3550
+ U(A(ir), null, {
3551
+ value: C(() => [
3552
+ U(A(st), {
3553
+ size: "small",
3554
+ onClick: (M) => a("edit", D)
3555
+ }, {
3556
+ default: C(() => [...j[7] || (j[7] = [
3557
+ Z("编辑", -1)
3558
+ ])]),
3559
+ _: 1
3560
+ }, 8, ["onClick"]),
3561
+ (p(!0), R(G, null, ne(k.value, (M) => (p(), _(A(st), {
3562
+ key: M.name,
3563
+ size: "small",
3564
+ onClick: (K) => I(M, D)
3565
+ }, {
3566
+ default: C(() => [
3567
+ Z(Y(M.label || M.name), 1)
3568
+ ]),
3569
+ _: 2
3570
+ }, 1032, ["onClick"]))), 128))
3571
+ ]),
3572
+ _: 2
3573
+ }, 1024)
3574
+ ]),
3575
+ _: 2
3576
+ }, 1024))), 128)),
3577
+ U(A(ci), {
3578
+ modelValue: v.value,
3579
+ "onUpdate:modelValue": j[3] || (j[3] = (D) => v.value = D),
3580
+ "total-items": h.value,
3581
+ "items-per-page": t.pageSize
3582
+ }, null, 8, ["modelValue", "total-items", "items-per-page"])
3583
+ ], 64)) : (p(), R(G, { key: 6 }, [
3584
+ U(A(Ka), {
3585
+ data: u.value,
3586
+ stripe: "",
3587
+ onRowDblclick: P
3588
+ }, {
3589
+ default: C(() => [
3590
+ (p(!0), R(G, null, ne(m.value, (D) => (p(), _(A(rr), {
3591
+ key: D.name,
3592
+ prop: D.name,
3593
+ label: D.label || D.name,
3594
+ width: D.width,
3595
+ "min-width": D.minWidth ?? D["min-width"] ?? 120,
3596
+ align: D.align ?? (["integer", "decimal", "float", "number", "percent"].includes(D.type) ? "right" : "left"),
3597
+ fixed: D.fixed,
3598
+ "show-overflow-tooltip": D.showOverflowTooltip
3599
+ }, {
3600
+ default: C(({ row: M, $index: K }) => [
3601
+ ye(x.$slots, `column-${D.name}`, {
3602
+ row: M,
3603
+ field: D,
3604
+ context: { row: M, $index: K }
3605
+ }, () => [
3606
+ U(xr, {
3607
+ value: M,
3608
+ field: D,
3609
+ context: { row: M, $index: K },
3610
+ onChange: (Te) => a("field-change", { row: M, field: D, value: Te })
3611
+ }, null, 8, ["value", "field", "context", "onChange"])
3612
+ ])
3613
+ ]),
3614
+ _: 2
3615
+ }, 1032, ["prop", "label", "width", "min-width", "align", "fixed", "show-overflow-tooltip"]))), 128)),
3616
+ U(A(rr), {
3617
+ label: "操作",
3618
+ "min-width": "140"
3619
+ }, {
3620
+ default: C(({ row: D }) => [
3621
+ U(A(ve), {
3622
+ link: "",
3623
+ type: "primary",
3624
+ onClick: (M) => a("edit", D)
3625
+ }, {
3626
+ default: C(() => [...j[8] || (j[8] = [
3627
+ Z("编辑", -1)
3628
+ ])]),
3629
+ _: 1
3630
+ }, 8, ["onClick"]),
3631
+ (p(!0), R(G, null, ne(k.value, (M) => (p(), _(A(ve), {
3632
+ key: M.name,
3633
+ link: "",
3634
+ onClick: (K) => I(M, D)
3635
+ }, {
3636
+ default: C(() => [
3637
+ Z(Y(M.label || M.name), 1)
3638
+ ]),
3639
+ _: 2
3640
+ }, 1032, ["onClick"]))), 128))
3641
+ ]),
3642
+ _: 1
3643
+ })
3644
+ ]),
3645
+ _: 3
3646
+ }, 8, ["data"]),
3647
+ U(A(Qa), {
3648
+ "current-page": v.value,
3649
+ "onUpdate:currentPage": j[4] || (j[4] = (D) => v.value = D),
3650
+ total: h.value,
3651
+ "page-size": t.pageSize,
3652
+ layout: "total, prev, pager, next"
3653
+ }, null, 8, ["current-page", "total", "page-size"])
3654
+ ], 64))
3655
+ ], 8, lo));
3656
+ }
3657
+ }, zo = /* @__PURE__ */ Object.assign({ inheritAttrs: !1 }, {
3658
+ __name: "Form",
3659
+ setup(t) {
3660
+ return (e, n) => (p(), _(wn, Me(e.$attrs, { mobile: "" }), Mr({ _: 2 }, [
3661
+ ne(e.$slots, (r, a) => ({
3662
+ name: a,
3663
+ fn: C((l) => [
3664
+ ye(e.$slots, a, Cr(Nr(l)))
3665
+ ])
3666
+ }))
3667
+ ]), 1040));
3668
+ }
3669
+ }), fo = {
3670
+ key: 2,
3671
+ class: "tab-icon",
3672
+ "aria-hidden": "true"
3673
+ }, mo = ["title"], po = {
3674
+ __name: "ViewTabs",
3675
+ props: { fallback: { type: String, default: "/" } },
3676
+ setup(t, { expose: e }) {
3677
+ const n = t, r = gn(), a = $r(), l = ot([]), o = X(() => r.meta.layout === "main" || r.meta.tabs === !1), s = La({
3678
+ props: { tab: { type: Object, required: !0 } },
3679
+ setup(d) {
3680
+ const b = Zn({ ...d.tab.to });
3681
+ return Ee(
3682
+ () => d.tab.to,
3683
+ (c) => Object.assign(b, c)
3684
+ ), ln(Va, b), ln(Yr, {
3685
+ update({ title: c, icon: S }) {
3686
+ c != null && c !== "" && (d.tab.title = String(c)), S !== void 0 && (d.tab.icon = S), d.tab.customTitle = !0;
3687
+ }
3688
+ }), () => Jn(
3689
+ on,
3690
+ { route: d.tab.to },
3691
+ {
3692
+ default: ({ Component: c }) => c ? Jn(c, { tab: d.tab }) : null
3693
+ }
3694
+ );
3695
+ }
3696
+ });
3697
+ function u(d) {
3698
+ if (d.meta.layout === "main" || d.meta.tabs === !1 || !d.matched.length) return;
3699
+ const b = d.meta.title || d.path, c = {
3700
+ name: d.path,
3701
+ title: d.params.id != null ? `${b} #${d.params.id}` : b,
3702
+ icon: d.meta.icon || d.meta.model?.icon,
3703
+ to: d
3704
+ }, S = l.value.find((y) => y.name === c.name);
3705
+ S ? (S.customTitle && (c.title = S.title), Object.assign(S, c)) : l.value = [...l.value, Zn(c)];
3706
+ }
3707
+ Ee(
3708
+ () => r.fullPath,
3709
+ () => u({ ...r }),
3710
+ { immediate: !0 }
3711
+ );
3712
+ async function m(d) {
3713
+ const b = l.value.findIndex((c) => c.name === d);
3714
+ if (!(b < 0)) {
3715
+ if (r.path === d) {
3716
+ const c = l.value[b + 1] || l.value[b - 1];
3717
+ if (!c && a.resolve(n.fallback).path === d || await a.push(c?.to.fullPath || n.fallback) || r.path === d) return;
3718
+ }
3719
+ l.value = l.value.filter((c) => c.name !== d);
3720
+ }
3721
+ }
3722
+ function h() {
3723
+ l.value = l.value.filter((d) => d.name === r.path);
3724
+ }
3725
+ function g() {
3726
+ l.value = [];
3727
+ }
3728
+ function v(d) {
3729
+ const b = l.value.find((c) => c.name === d);
3730
+ b && a.push(b.to.fullPath);
3731
+ }
3732
+ return e({ tabs: l, tabRemove: m, clearTabs: h, resetTabs: g }), (d, b) => o.value ? (p(), _(A(on), { key: 0 })) : (p(), _(A(Ir), {
3733
+ key: 1,
3734
+ "model-value": A(r).path,
3735
+ type: "card",
3736
+ class: "viewtabs",
3737
+ onTabChange: v,
3738
+ onTabRemove: m
3739
+ }, {
3740
+ default: C(() => [
3741
+ (p(!0), R(G, null, ne(l.value, (c) => (p(), _(A(jr), {
3742
+ key: c.name,
3743
+ name: c.name,
3744
+ closable: l.value.length > 1
3745
+ }, {
3746
+ label: C(() => [
3747
+ c.icon && typeof c.icon != "string" ? (p(), _(Qe(c.icon), {
3748
+ key: 0,
3749
+ class: "tab-icon",
3750
+ "aria-hidden": "true"
3751
+ })) : c.icon && /^[a-zA-Z][\w -]*$/.test(c.icon) ? (p(), R("i", {
3752
+ key: 1,
3753
+ class: Nt([c.icon.includes(" ") ? c.icon : `fa fa-${c.icon}`, "tab-icon"]),
3754
+ "aria-hidden": "true"
3755
+ }, null, 2)) : c.icon ? (p(), R("span", fo, Y(c.icon), 1)) : Q("", !0),
3756
+ we("span", {
3757
+ title: c.title
3758
+ }, Y(c.title.length > 19 ? `${c.title.slice(0, 16)}…` : c.title), 9, mo)
3759
+ ]),
3760
+ default: C(() => [
3761
+ U(A(s), { tab: c }, null, 8, ["tab"])
3762
+ ]),
3763
+ _: 2
3764
+ }, 1032, ["name", "closable"]))), 128))
3765
+ ]),
3766
+ _: 1
3767
+ }, 8, ["model-value"]));
3768
+ }
3769
+ }, yo = /* @__PURE__ */ dt(po, [["__scopeId", "data-v-5d737ee7"]]), go = {
3770
+ key: 2,
3771
+ class: "model-icon",
3772
+ "aria-hidden": "true"
3773
+ }, vo = {
3774
+ __name: "Icon",
3775
+ props: { icon: [String, Object, Function] },
3776
+ setup(t) {
3777
+ return (e, n) => t.icon && typeof t.icon != "string" ? (p(), _(Qe(t.icon), {
3778
+ key: 0,
3779
+ class: "model-icon",
3780
+ "aria-hidden": "true"
3781
+ })) : t.icon && /^[a-zA-Z][\w -]*$/.test(t.icon) ? (p(), R("i", {
3782
+ key: 1,
3783
+ class: Nt([t.icon.includes(" ") ? t.icon : `fa fa-${t.icon}`, "model-icon"]),
3784
+ "aria-hidden": "true"
3785
+ }, null, 2)) : t.icon ? (p(), R("span", go, Y(t.icon), 1)) : Q("", !0);
3786
+ }
3787
+ }, ct = /* @__PURE__ */ dt(vo, [["__scopeId", "data-v-5a104f44"]]), ho = { "aria-label": "主导航" }, bo = {
3788
+ __name: "SideBar",
3789
+ props: { menus: { type: Object, default: () => ({}) }, collapse: Boolean },
3790
+ emits: ["navigate"],
3791
+ setup(t, { emit: e }) {
3792
+ const n = t, r = e, a = gn(), l = $r(), o = X(() => Object.values(n.menus).filter((m) => m.items?.length)), s = X(
3793
+ () => o.value.flatMap((m) => m.items).filter((m) => a.path.startsWith(m.url)).sort((m, h) => h.url.length - m.url.length)[0]?.url || a.path
3794
+ );
3795
+ async function u(m) {
3796
+ await l.push(m), r("navigate");
3797
+ }
3798
+ return (m, h) => (p(), R("nav", ho, [
3799
+ U(A(Za), {
3800
+ "default-active": s.value,
3801
+ collapse: t.collapse,
3802
+ "default-openeds": o.value.map((g) => g.name),
3803
+ onSelect: u
3804
+ }, {
3805
+ default: C(() => [
3806
+ (p(!0), R(G, null, ne(o.value, (g) => (p(), R(G, {
3807
+ key: g.name
3808
+ }, [
3809
+ g.items.length > 1 ? (p(), _(A(Ja), {
3810
+ key: 0,
3811
+ index: g.name
3812
+ }, {
3813
+ title: C(() => [
3814
+ U(ct, {
3815
+ icon: g.icon
3816
+ }, null, 8, ["icon"]),
3817
+ we("span", null, Y(g.name), 1)
3818
+ ]),
3819
+ default: C(() => [
3820
+ (p(!0), R(G, null, ne(g.items, (v) => (p(), _(A(ar), {
3821
+ key: v.url,
3822
+ index: v.url
3823
+ }, {
3824
+ title: C(() => [
3825
+ Z(Y(v.name), 1)
3826
+ ]),
3827
+ default: C(() => [
3828
+ U(ct, {
3829
+ icon: v.icon
3830
+ }, null, 8, ["icon"])
3831
+ ]),
3832
+ _: 2
3833
+ }, 1032, ["index"]))), 128))
3834
+ ]),
3835
+ _: 2
3836
+ }, 1032, ["index"])) : (p(), _(A(ar), {
3837
+ key: 1,
3838
+ index: g.items[0].url
3839
+ }, {
3840
+ title: C(() => [
3841
+ Z(Y(g.items[0].name), 1)
3842
+ ]),
3843
+ default: C(() => [
3844
+ U(ct, {
3845
+ icon: g.items[0].icon || g.icon
3846
+ }, null, 8, ["icon"])
3847
+ ]),
3848
+ _: 2
3849
+ }, 1032, ["index"]))
3850
+ ], 64))), 128))
3851
+ ]),
3852
+ _: 1
3853
+ }, 8, ["default-active", "collapse", "default-openeds"])
3854
+ ]));
3855
+ }
3856
+ }, ta = /* @__PURE__ */ Symbol("vue3-django-drawer");
3857
+ function wo() {
3858
+ return Ct(ta, void 0);
3859
+ }
3860
+ function qo(t) {
3861
+ return async (e) => {
3862
+ if (!/^[\w-]+(?:\/[\w-]+)*$/.test(e)) throw new Error("抽屉视图路径无效");
3863
+ const n = Object.entries(t).filter(([l]) => l.endsWith(`/views/${e}.vue`));
3864
+ if (n.length !== 1) throw new Error(`抽屉视图 ${e} 未找到或重复`);
3865
+ const r = n[0][1], a = typeof r == "function" ? await r() : r;
3866
+ return a.default ?? a;
3867
+ };
3868
+ }
3869
+ const Eo = {
3870
+ __name: "Actions",
3871
+ props: {
3872
+ items: { type: Array, default: () => [] },
3873
+ context: { type: [Object, Function], default: () => ({}) },
3874
+ map: { type: Object, default: () => ({}) },
3875
+ permissionFunction: Function,
3876
+ size: { type: String, default: "small" },
3877
+ trigger: { type: String, default: "hover" }
3878
+ },
3879
+ emits: ["done", "error", "command"],
3880
+ setup(t, { expose: e, emit: n }) {
3881
+ const r = t, a = n, l = wo(), o = Rr({}), s = X(
3882
+ () => typeof r.context == "function" ? r.context() : r.context
3883
+ );
3884
+ function u(d) {
3885
+ if (Array.isArray(d)) return d.flatMap((S) => u(S));
3886
+ const b = typeof d == "string" ? d : d.name, c = { ...r.map[b], ...typeof d == "string" ? {} : d, name: b };
3887
+ return c.label = c.label ?? c.title ?? b, c;
3888
+ }
3889
+ function m(d) {
3890
+ return (!d.permission || !r.permissionFunction || r.permissionFunction(d.permission)) && (!d.show || d.show(s.value));
3891
+ }
3892
+ const h = X(
3893
+ () => r.items.filter((d) => !Array.isArray(d)).map(u).filter(m)
3894
+ ), g = X(
3895
+ () => r.items.filter(Array.isArray).flatMap(u).filter(m)
3896
+ );
3897
+ async function v(d) {
3898
+ if (!(o[d.name] || d.disabled || !m(d))) {
3899
+ o[d.name] = !0;
3900
+ try {
3901
+ const b = s.value;
3902
+ if (typeof d.confirm == "function") {
3903
+ if (await d.confirm(d, b) === !1) return;
3904
+ } else d.confirm && await ai.confirm(d.notice ?? `确定执行“${d.label}”吗?`, "操作确认", {
3905
+ type: "warning"
3906
+ });
3907
+ if (a("command", d, b), typeof d.do == "function") {
3908
+ const c = await d.do(b);
3909
+ a("done", c, d);
3910
+ } else {
3911
+ if (!l) throw new Error("Actions 的抽屉操作需要放在 Layout 内");
3912
+ await l.open({
3913
+ component: d.do ?? d.component,
3914
+ label: d.label,
3915
+ context: { ...d.drawer, ...b },
3916
+ onDone: async (c) => {
3917
+ await d.onDone?.(c), a("done", c, d);
3918
+ }
3919
+ });
3920
+ }
3921
+ } catch (b) {
3922
+ b !== "cancel" && b !== "close" && a("error", b, d);
3923
+ } finally {
3924
+ o[d.name] = !1;
3925
+ }
3926
+ }
3927
+ }
3928
+ return e({ handleCommand: v, loadingMap: o }), (d, b) => h.value.length || g.value.length ? (p(), _(A(ei), {
3929
+ key: 0,
3930
+ class: "vd-actions"
3931
+ }, {
3932
+ default: C(() => [
3933
+ (p(!0), R(G, null, ne(h.value, (c) => (p(), _(A(ve), {
3934
+ key: c.name,
3935
+ size: c.size ?? t.size,
3936
+ type: c.type,
3937
+ plain: c.plain,
3938
+ disabled: c.disabled,
3939
+ loading: o[c.name],
3940
+ onClick: (S) => v(c)
3941
+ }, {
3942
+ default: C(() => [
3943
+ U(ct, {
3944
+ icon: c.icon
3945
+ }, null, 8, ["icon"]),
3946
+ Z(Y(c.label), 1)
3947
+ ]),
3948
+ _: 2
3949
+ }, 1032, ["size", "type", "plain", "disabled", "loading", "onClick"]))), 128)),
3950
+ g.value.length ? (p(), _(A(ti), {
3951
+ key: 0,
3952
+ size: t.size,
3953
+ trigger: t.trigger,
3954
+ onCommand: v
3955
+ }, {
3956
+ dropdown: C(() => [
3957
+ U(A(ni), null, {
3958
+ default: C(() => [
3959
+ (p(!0), R(G, null, ne(g.value, (c) => (p(), _(A(ri), {
3960
+ key: c.name,
3961
+ command: c,
3962
+ disabled: c.disabled || o[c.name],
3963
+ divided: c.divided
3964
+ }, {
3965
+ default: C(() => [
3966
+ U(ct, {
3967
+ icon: c.icon
3968
+ }, null, 8, ["icon"]),
3969
+ Z(Y(c.label), 1)
3970
+ ]),
3971
+ _: 2
3972
+ }, 1032, ["command", "disabled", "divided"]))), 128))
3973
+ ]),
3974
+ _: 1
3975
+ })
3976
+ ]),
3977
+ default: C(() => [
3978
+ U(A(ve), {
3979
+ size: t.size,
3980
+ "aria-label": "更多操作"
3981
+ }, {
3982
+ default: C(() => [...b[0] || (b[0] = [
3983
+ Z("更多 ▾", -1)
3984
+ ])]),
3985
+ _: 1
3986
+ }, 8, ["size"])
3987
+ ]),
3988
+ _: 1
3989
+ }, 8, ["size", "trigger"])) : Q("", !0)
3990
+ ]),
3991
+ _: 1
3992
+ })) : Q("", !0);
3993
+ }
3994
+ }, To = {
3995
+ key: 1,
3996
+ class: "django-layout"
3997
+ }, Ao = { class: "layout-header" }, So = { class: "layout-account" }, Oo = { class: "layout-body" }, _o = {
3998
+ class: "layout-content",
3999
+ "aria-label": "工作区"
4000
+ }, xo = {
4001
+ __name: "Layout",
4002
+ props: {
4003
+ menus: Object,
4004
+ title: { type: String, default: "vue3-django" },
4005
+ user: Object,
4006
+ actions: Array,
4007
+ actionContext: [Object, Function],
4008
+ actionMap: Object,
4009
+ permissionFunction: Function,
4010
+ loadDrawerView: Function
4011
+ },
4012
+ emits: ["logout", "action-done", "error"],
4013
+ setup(t, { expose: e, emit: n }) {
4014
+ const r = n, a = gn(), l = q(!1), o = q(), s = q(), u = {
4015
+ open: (h) => s.value.open(h),
4016
+ close: () => s.value.close()
4017
+ };
4018
+ ln(ta, u);
4019
+ const m = X(() => a.meta.layout === "main");
4020
+ return e({
4021
+ resetTabs: () => o.value?.resetTabs(),
4022
+ openDrawer: u.open,
4023
+ closeDrawer: u.close
4024
+ }), (h, g) => (p(), R(G, null, [
4025
+ m.value ? (p(), _(A(on), { key: 0 })) : (p(), R("div", To, [
4026
+ we("header", Ao, [
4027
+ U(A(ve), {
4028
+ class: "menu-toggle",
4029
+ "aria-label": "切换导航菜单",
4030
+ "aria-expanded": l.value,
4031
+ onClick: g[0] || (g[0] = (v) => l.value = !l.value)
4032
+ }, {
4033
+ default: C(() => [...g[7] || (g[7] = [
4034
+ Z("菜单", -1)
4035
+ ])]),
4036
+ _: 1
4037
+ }, 8, ["aria-expanded"]),
4038
+ U(A(Fr), {
4039
+ to: "/",
4040
+ class: "layout-brand"
4041
+ }, {
4042
+ default: C(() => [
4043
+ Z(Y(t.title), 1)
4044
+ ]),
4045
+ _: 1
4046
+ }),
4047
+ we("div", So, [
4048
+ ye(h.$slots, "actions", {}, () => [
4049
+ U(Eo, {
4050
+ items: t.actions,
4051
+ context: t.actionContext,
4052
+ map: t.actionMap,
4053
+ "permission-function": t.permissionFunction,
4054
+ onDone: g[1] || (g[1] = (v, d) => r("action-done", v, d)),
4055
+ onError: g[2] || (g[2] = (v) => r("error", v))
4056
+ }, null, 8, ["items", "context", "map", "permission-function"])
4057
+ ], !0),
4058
+ we("span", null, Y(t.user?.name || t.user?.username), 1),
4059
+ t.user ? (p(), _(A(ve), {
4060
+ key: 0,
4061
+ onClick: g[3] || (g[3] = (v) => h.$emit("logout"))
4062
+ }, {
4063
+ default: C(() => [...g[8] || (g[8] = [
4064
+ Z("退出登录", -1)
4065
+ ])]),
4066
+ _: 1
4067
+ })) : Q("", !0)
4068
+ ])
4069
+ ]),
4070
+ we("div", Oo, [
4071
+ l.value ? (p(), R("button", {
4072
+ key: 0,
4073
+ class: "menu-backdrop",
4074
+ "aria-label": "关闭导航菜单",
4075
+ onClick: g[4] || (g[4] = (v) => l.value = !1)
4076
+ })) : Q("", !0),
4077
+ we("aside", {
4078
+ class: Nt(["layout-sidebar", { opened: l.value }])
4079
+ }, [
4080
+ U(bo, {
4081
+ menus: t.menus,
4082
+ onNavigate: g[5] || (g[5] = (v) => l.value = !1)
4083
+ }, null, 8, ["menus"])
4084
+ ], 2),
4085
+ we("section", _o, [
4086
+ U(yo, {
4087
+ ref_key: "tabs",
4088
+ ref: o
4089
+ }, null, 512)
4090
+ ])
4091
+ ])
4092
+ ])),
4093
+ U(ea, {
4094
+ ref_key: "drawer",
4095
+ ref: s,
4096
+ "load-view": t.loadDrawerView,
4097
+ onError: g[6] || (g[6] = (v) => r("error", v))
4098
+ }, null, 8, ["load-view"])
4099
+ ], 64));
4100
+ }
4101
+ }, Bo = /* @__PURE__ */ dt(xo, [["__scopeId", "data-v-d75e30ad"]]), an = (t) => t === !0 || t === "true";
4102
+ function Ho(t, e, n) {
4103
+ const r = Array.isArray(e) ? e : Object.keys(e || t), a = {};
4104
+ for (const l of r) {
4105
+ const o = t[l];
4106
+ if (!o || an(o.hidden)) continue;
4107
+ const s = !Array.isArray(e) && e?.[l], u = typeof s == "string" ? s.split(",").map((g) => g.trim()) : s || Object.keys(o.models ?? {}), m = o.verbose_name || l, h = [];
4108
+ o.home_page && !an(o.home_page.hidden) && h.push({ url: `/${l}/index/`, ...o.home_page });
4109
+ for (const g of u) {
4110
+ const v = o.models?.[g];
4111
+ if (!v || (v.hidden !== void 0 ? an(v.hidden) : n != null && !Object.hasOwn(n, `${l}.${g}`))) continue;
4112
+ const b = { name: v.verbose_name || g, icon: v.icon, url: `/${l}/${g}/` };
4113
+ v.menu ? (a[v.menu] ??= { name: v.menu, items: [] }, a[v.menu].items.push(b)) : h.push(b);
4114
+ }
4115
+ h.length && (a[m] ??= { name: m, icon: o.icon, items: [] }, a[m].items.push(...h));
4116
+ }
4117
+ return a;
4118
+ }
4119
+ function Wo(t) {
4120
+ return async (e) => {
4121
+ const n = `/views/${e.replace(".", "/")}/config.js`, r = Object.entries(t).filter(([o]) => o.endsWith(n));
4122
+ if (!r.length) return {};
4123
+ if (r.length > 1) throw new Error(`模型 ${e} 有多个视图配置文件`);
4124
+ const a = r[0][1], l = typeof a == "function" ? await a() : a;
4125
+ return l.default ?? l;
4126
+ };
4127
+ }
4128
+ function Go(t) {
4129
+ return async (e, n) => {
4130
+ if (!/^[\w-]+(?:\/[\w-]+)*$/.test(n)) throw new Error("关联视图路径无效");
4131
+ const r = `/views/${e.replace(".", "/")}/${n}.vue`, a = Object.entries(t).filter(([o]) => o.endsWith(r));
4132
+ if (a.length !== 1) throw new Error(`关联视图 ${e}/${n} 未找到或重复`);
4133
+ const l = a[0][1];
4134
+ return typeof l == "function" ? l() : l;
4135
+ };
4136
+ }
4137
+ function Rt(t) {
4138
+ const e = typeof t == "string" ? JSON.parse(t) : t ?? [];
4139
+ if (!Array.isArray(e)) throw new Error("多对多关联字段必须是主键数组");
4140
+ return e;
4141
+ }
4142
+ async function ko(t, e, n) {
4143
+ const r = typeof t == "string" ? { name: t } : t;
4144
+ if (!r?.name) throw new Error("关联配置缺少模型 name");
4145
+ const a = r.name.indexOf(":"), l = a < 0 ? r.name : r.name.slice(0, a), o = a < 0 ? void 0 : r.name.slice(a + 1), s = n.get(l), u = n.get(e.appModel), [m, h, g, v] = await Promise.all([
4146
+ s.fields(),
4147
+ u.fields(),
4148
+ s.loadOptions(),
4149
+ u.loadOptions()
4150
+ ]), d = e.id ?? e.data?.[u.config.idField || "id"];
4151
+ if (d == null) throw new Error("关联列表需要已保存的父记录");
4152
+ let b = r.parentRelationQuery, c = {}, S;
4153
+ if (o !== void 0 && (b = Object.fromEntries(
4154
+ Object.entries(kr.parse(o)).map(([y, $]) => {
4155
+ const w = $ === "" || $ === "id" ? d : e.data?.[$];
4156
+ if (w == null) throw new Error(`关联查询 ${y} 缺少父字段 ${$ || "id"}`);
4157
+ return [y, w];
4158
+ })
4159
+ )), !b)
4160
+ if (S = r.parentMultipleRelationFieldName ? h[r.parentMultipleRelationFieldName] : Object.values(h).find((y) => y.model === l && y.multiple), S) {
4161
+ if (!S.multiple || S.model !== l)
4162
+ throw new Error("指定的父字段不是此模型的多对多关联");
4163
+ const y = Rt(e.data?.[S.name]);
4164
+ b = { [`${s.config.idField || "id"}__in`]: y.length ? y : [0] };
4165
+ } else {
4166
+ const y = Object.values(m).find(
4167
+ ($) => $.model === e.appModel && !$.multiple
4168
+ );
4169
+ if (y) b = { [y.name]: d };
4170
+ else if (g.generic_foreign_key) {
4171
+ const { ct_field: $, fk_field: w } = g.generic_foreign_key;
4172
+ if (!m[w] || v.content_type_id == null)
4173
+ throw new Error("通用外键缺少 fk_field 或父模型 content_type_id");
4174
+ b = { [$]: v.content_type_id, [w]: d };
4175
+ } else throw new Error(`无法确定 ${l} 的关联字段,请显式配置 ${l}:字段=id`);
4176
+ }
4177
+ return S || (c = Object.fromEntries(
4178
+ Object.entries(b).filter(
4179
+ ([y]) => m[y] && !m[y].read_only && !y.includes("__")
4180
+ )
4181
+ )), {
4182
+ ...r,
4183
+ name: l,
4184
+ model: s,
4185
+ multipleField: S,
4186
+ defaults: { ...c, ...r.defaults },
4187
+ label: r.label || s.config.verbose_name || l,
4188
+ icon: r.icon || s.config.icon,
4189
+ baseQueries: { ...r.baseQueries, ...b }
4190
+ };
4191
+ }
4192
+ const Ro = ["aria-busy"], Do = { key: 0 }, Yo = {
4193
+ __name: "Relations",
4194
+ props: {
4195
+ parent: { type: Object, required: !0 },
4196
+ items: Array,
4197
+ mobile: Boolean
4198
+ },
4199
+ emits: ["edit", "create", "error", "parent-updated"],
4200
+ setup(t, { expose: e, emit: n }) {
4201
+ const r = t, a = n, { registry: l, loadRelationView: o, revisions: s } = Ie(), u = ot([]), m = q(!1), h = q(""), g = q(""), v = ot(), d = ot(), b = q([]), c = q(!1);
4202
+ let S = 0;
4203
+ async function y() {
4204
+ const P = ++S;
4205
+ if ((r.parent.id ?? r.parent.data?.id) == null) {
4206
+ u.value = [];
4207
+ return;
4208
+ }
4209
+ m.value = !0, h.value = "";
4210
+ try {
4211
+ const I = r.parent.viewsConfig ?? await l.get(r.parent.appModel).loadViewsConfig(), k = await Promise.all(
4212
+ (r.items ?? I.relations ?? []).map(async (x, j) => {
4213
+ const D = typeof x == "object" ? x.key ?? `${x.name}:${j}` : `${x}:${j}`;
4214
+ try {
4215
+ const M = await ko(x, r.parent, l);
4216
+ if (typeof M.view == "string") {
4217
+ if (!o) throw new Error(`自定义视图 ${M.view} 需要 loadRelationView`);
4218
+ const K = await o(M.name, M.view);
4219
+ M.view = er(K.default ?? K);
4220
+ } else M.view && (M.view = er(M.view));
4221
+ return { ...M, key: D };
4222
+ } catch (M) {
4223
+ return {
4224
+ key: D,
4225
+ label: typeof x == "string" ? x : x.label || x.name,
4226
+ error: M.message
4227
+ };
4228
+ }
4229
+ })
4230
+ );
4231
+ if (P !== S) return;
4232
+ u.value = k, k.some((x) => x.key === g.value) || (g.value = k[0]?.key || "");
4233
+ } catch (I) {
4234
+ P === S && (h.value = I.message, a("error", I));
4235
+ } finally {
4236
+ P === S && (m.value = !1);
4237
+ }
4238
+ }
4239
+ async function $(P, I) {
4240
+ if (!c.value) {
4241
+ c.value = !0, h.value = "";
4242
+ try {
4243
+ const k = l.get(r.parent.appModel), x = r.parent.id ?? r.parent.data[k.config.idField || "id"], { data: j } = await l.http.patch(k.getDetailUrl(x), {
4244
+ [P.multipleField.name]: I
4245
+ });
4246
+ a("parent-updated", {
4247
+ ...r.parent.data,
4248
+ [P.multipleField.name]: j[P.multipleField.name] ?? I
4249
+ }), v.value = void 0, d.value = void 0, await yn(), await y();
4250
+ } catch (k) {
4251
+ h.value = k.message, a("error", k);
4252
+ } finally {
4253
+ c.value = !1;
4254
+ }
4255
+ }
4256
+ }
4257
+ function w(P) {
4258
+ b.value = [], v.value = P;
4259
+ }
4260
+ function N() {
4261
+ const P = v.value;
4262
+ return $(P, [
4263
+ .../* @__PURE__ */ new Set([...Rt(r.parent.data[P.multipleField.name]), ...b.value])
4264
+ ]);
4265
+ }
4266
+ function L(P, I) {
4267
+ const k = I[P.model.config.idField || "id"];
4268
+ return $(
4269
+ P,
4270
+ Rt(r.parent.data[P.multipleField.name]).filter(
4271
+ (x) => String(x) !== String(k)
4272
+ )
4273
+ );
4274
+ }
4275
+ async function V(P, I) {
4276
+ P.multipleField ? await $(P, [
4277
+ .../* @__PURE__ */ new Set([
4278
+ ...Rt(r.parent.data[P.multipleField.name]),
4279
+ I.data[P.model.config.idField || "id"]
4280
+ ])
4281
+ ]) : (d.value = void 0, s && (s[P.name] = (s[P.name] || 0) + 1), await y());
4282
+ }
4283
+ return Ee(() => [r.parent, r.items], y, { immediate: !0, deep: !0 }), Ee(() => u.value.map((P) => s?.[P.name] ?? 0).join(","), y), e({ refresh: y, relations: u }), (P, I) => (p(), R("section", { "aria-busy": m.value }, [
4284
+ m.value && !u.value.length ? (p(), R("p", Do, "加载关联模型…")) : Q("", !0),
4285
+ h.value ? (p(), _(A(Pe), {
4286
+ key: 1,
4287
+ title: h.value,
4288
+ type: "error",
4289
+ closable: !1
4290
+ }, null, 8, ["title"])) : Q("", !0),
4291
+ u.value.length ? (p(), _(A(Ir), {
4292
+ key: 2,
4293
+ modelValue: g.value,
4294
+ "onUpdate:modelValue": I[0] || (I[0] = (k) => g.value = k),
4295
+ type: "border-card"
4296
+ }, {
4297
+ default: C(() => [
4298
+ (p(!0), R(G, null, ne(u.value, (k) => (p(), _(A(jr), {
4299
+ key: k.key,
4300
+ name: k.key,
4301
+ label: k.label,
4302
+ lazy: ""
4303
+ }, {
4304
+ default: C(() => [
4305
+ k.error ? (p(), _(A(Pe), {
4306
+ key: 0,
4307
+ title: k.error,
4308
+ type: "error",
4309
+ closable: !1
4310
+ }, null, 8, ["title"])) : k.view ? (p(), _(Qe(k.view), Me({
4311
+ key: 1,
4312
+ ref_for: !0
4313
+ }, k, {
4314
+ parent: t.parent,
4315
+ "app-model": k.name,
4316
+ mobile: t.mobile
4317
+ }), null, 16, ["parent", "app-model", "mobile"])) : (p(), R(G, { key: 2 }, [
4318
+ k.multipleField ? (p(), _(A(ve), {
4319
+ key: 0,
4320
+ disabled: c.value,
4321
+ onClick: (x) => w(k)
4322
+ }, {
4323
+ default: C(() => [
4324
+ Z("添加已有" + Y(k.label), 1)
4325
+ ]),
4326
+ _: 2
4327
+ }, 1032, ["disabled", "onClick"])) : Q("", !0),
4328
+ (p(), _(co, {
4329
+ key: `${k.key}:${A(S)}`,
4330
+ "app-model": k.name,
4331
+ items: k.items,
4332
+ "base-queries": k.baseQueries,
4333
+ mobile: t.mobile,
4334
+ "create-mode": "event",
4335
+ "row-actions": k.multipleField ? [
4336
+ {
4337
+ name: "remove-relation",
4338
+ label: "移出关联",
4339
+ do: ({ row: x }) => L(k, x)
4340
+ }
4341
+ ] : void 0,
4342
+ onEdit: (x) => a("edit", { appModel: k.name, row: x }),
4343
+ onCreate: (x) => d.value = k
4344
+ }, null, 8, ["app-model", "items", "base-queries", "mobile", "row-actions", "onEdit", "onCreate"]))
4345
+ ], 64))
4346
+ ]),
4347
+ _: 2
4348
+ }, 1032, ["name", "label"]))), 128))
4349
+ ]),
4350
+ _: 1
4351
+ }, 8, ["modelValue"])) : Q("", !0),
4352
+ U(A(ii), {
4353
+ "model-value": !!v.value,
4354
+ title: "添加已有记录",
4355
+ onClose: I[2] || (I[2] = (k) => v.value = void 0)
4356
+ }, {
4357
+ footer: C(() => [
4358
+ U(A(ve), {
4359
+ loading: c.value,
4360
+ disabled: !b.value.length,
4361
+ onClick: N
4362
+ }, {
4363
+ default: C(() => [...I[5] || (I[5] = [
4364
+ Z("添加关联", -1)
4365
+ ])]),
4366
+ _: 1
4367
+ }, 8, ["loading", "disabled"])
4368
+ ]),
4369
+ default: C(() => [
4370
+ v.value ? (p(), _(Hr, {
4371
+ key: 0,
4372
+ modelValue: b.value,
4373
+ "onUpdate:modelValue": I[1] || (I[1] = (k) => b.value = k),
4374
+ "app-model": v.value.name,
4375
+ field: { multiple: !0, label: v.value.label }
4376
+ }, null, 8, ["modelValue", "app-model", "field"])) : Q("", !0)
4377
+ ]),
4378
+ _: 1
4379
+ }, 8, ["model-value"]),
4380
+ U(A(Pr), {
4381
+ "model-value": !!d.value,
4382
+ title: `新增${d.value?.label || ""}`,
4383
+ size: t.mobile ? "100%" : "66%",
4384
+ "destroy-on-close": "",
4385
+ onClose: I[4] || (I[4] = (k) => d.value = void 0)
4386
+ }, {
4387
+ default: C(() => [
4388
+ d.value ? (p(), _(wn, {
4389
+ key: 0,
4390
+ "app-model": d.value.name,
4391
+ defaults: d.value.defaults,
4392
+ mobile: t.mobile,
4393
+ onFormPosted: I[3] || (I[3] = (k) => V(d.value, k))
4394
+ }, null, 8, ["app-model", "defaults", "mobile"])) : Q("", !0)
4395
+ ]),
4396
+ _: 1
4397
+ }, 8, ["model-value", "title", "size"])
4398
+ ], 8, Ro));
4399
+ }
4400
+ };
4401
+ export {
4402
+ Eo as Actions,
4403
+ pi as AppModel,
4404
+ ea as Drawer,
4405
+ lr as DrfError,
4406
+ Wl as ForeignKey,
4407
+ al as Form,
4408
+ Bo as Layout,
4409
+ zo as MobileForm,
4410
+ wn as ModelForm,
4411
+ Yo as ModelRelations,
4412
+ sl as ModelSearch,
4413
+ Hr as ModelSelect,
4414
+ co as ModelTable,
4415
+ yi as Register,
4416
+ bo as SideBar,
4417
+ xr as TableWidget,
4418
+ yo as ViewTabs,
4419
+ Io as createAuth,
4420
+ Po as createDjango,
4421
+ Vo as createDjangoRouter,
4422
+ qo as createDrawerViewLoader,
4423
+ zr as createHttp,
4424
+ mi as createRegistry,
4425
+ Go as createRelationViewLoader,
4426
+ Wo as createViewsConfigLoader,
4427
+ at as displayValue,
4428
+ qr as emptyData,
4429
+ fi as fieldsFromOptions,
4430
+ Ho as genMenusFromApps,
4431
+ Uo as genModelRouters,
4432
+ Ur as joinErrors,
4433
+ bn as normalizeItems,
4434
+ jo as safeRedirect,
4435
+ Ie as useDjango,
4436
+ wo as useDrawer,
4437
+ il as useViewTab,
4438
+ di as writableData
4439
+ };