UNPKG

tms-vue3-ui

Version:

Vue3基础UI库,提供JSONSchema编辑器,支持基于JSONSchema生成表单。

1,614 lines 346 kB
var Os = Object.defineProperty; var As = (e, t, n) => t in e ? Os(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; var ee = (e, t, n) => As(e, typeof t != "symbol" ? t + "" : t, n); import { defineComponent as le, h as oe, resolveComponent as Z, openBlock as F, createElementBlock as re, createVNode as A, withCtx as T, ref as Te, createElementVNode as ne, Fragment as Re, renderList as Fe, createBlock as Q, createTextVNode as Ve, unref as Ui, createCommentVNode as H, reactive as Es, computed as he, toRaw as ue, watch as Zt, onMounted as Ps, normalizeClass as Is, toDisplayString as Rs, resolveDynamicComponent as nt, renderSlot as Ls } from "vue"; const _e = { formItem: le({ props: ["label"], render() { var e, t; return oe("div", {}, [ oe("div", { class: ["tvu-jse__label"] }, this.label), (t = (e = this.$slots).default) == null ? void 0 : t.call(e) ]); } }), input: le({ props: ["modelValue"], emits: ["update:modelValue"], render() { return oe("input", { value: this.modelValue, class: ["tvu-input"], onInput: (e) => { this.$emit("update:modelValue", e.target.value); } }); } }), textarea: le({ props: ["modelValue"], emits: ["update:modelValue"], render() { return oe("textarea", { value: this.modelValue, class: ["tvu-input"], onInput: (e) => { this.$emit("update:modelValue", e.target.value); } }); } }), json: le({ props: ["modelValue"], emits: ["update:modelValue"], render() { return oe("textarea", { value: JSON.stringify(this.modelValue, null, 2), class: ["tvu-input"], onInput: (e) => { try { let t = JSON.parse(e.target.value); this.$emit("update:modelValue", t); } catch { } } }); } }), upload: le({ props: ["fileList", "uploadFile", "removeFile"], render() { var t, n, r; let e = (t = this.fileList) == null ? void 0 : t.map((l) => oe("div", { class: "tvu-jse__attachment" }, [ oe("div", l.name), oe( "button", { onClick: () => { this.removeFile(l); } }, "删除文件" ) ])); return e ?? (e = []), oe("div", { class: ["tvu-jse__upload"] }, [ ...e, oe( "div", { onClick: () => { const l = document.createElement("input"); l.setAttribute("type", "file"), document.body.appendChild(l), l.addEventListener("change", async (o) => { const h = o.target; if (h.files) { const f = h.files[0]; this.uploadFile(f); } }), l.click(); } }, (r = (n = this.$slots).default) == null ? void 0 : r.call(n) ) ]); } }), checkbox: le({ props: ["label", "value", "modelValue"], render() { let e = { type: "checkbox", value: this.value, onChange: () => { Array.isArray(this.modelValue) ? this.modelValue.includes(this.value) ? this.modelValue.splice(this.modelValue.indexOf(this.value), 1) : this.modelValue.push(this.value) : typeof this.modelValue == "boolean" ? this.$emit("update:modelValue", !this.modelValue) : this.$emit("update:modelValue", !0); } }; return Array.isArray(this.modelValue) ? this.modelValue.includes(this.value) && (e.checked = !0) : this.modelValue === !0 && (e.checked = !0), oe("div", { class: ["tvu-jse__checkbox"] }, [ oe("div", oe("input", e)), oe("div", {}, this.label) ]); } }), select: le({ props: ["modelValue"], emits: ["update:modelValue"], render() { var e, t; return oe( "select", { value: this.modelValue, class: ["tvu-input"], onChange: (n) => { this.$emit("update:modelValue", n.target.value); } }, (t = (e = this.$slots).default) == null ? void 0 : t.call(e) ); } }), option: le({ render() { return oe("option", {}); } }), button: le({ render() { var e, t; return oe( "button", { class: ["tvu-button"], ...this.$attrs }, (t = (e = this.$slots).default) == null ? void 0 : t.call(e) ); } }) }, Ms = { "tvu-form-item": { ..._e.formItem }, "tvu-input": { ..._e.input }, "tvu-textarea": { ..._e.textarea }, "tvu-json": { ..._e.json }, "tvu-input-number": { ..._e.input }, "tvu-upload": { ..._e.upload }, "tvu-checkbox": { ..._e.checkbox }, "tvu-select": { ..._e.select }, "tvu-option": { ..._e.option }, "tvu-button": { ..._e.button } }, Ns = { class: "tvu-jse__field__file-attrs" }, js = /* @__PURE__ */ le({ __name: "File", props: { formatAttrs: { type: Object, required: !0 } }, setup(e) { return (t, n) => { const r = Z("tvu-input"), l = Z("tvu-form-item"); return F(), re("div", Ns, [ A(l, { class: "tvu-jse__field", label: "文件类型" }, { default: T(() => [ A(r, { modelValue: e.formatAttrs.accept, "onUpdate:modelValue": n[0] || (n[0] = (o) => e.formatAttrs.accept = o), placeholder: "标准格式,如'png,jpeg'" }, null, 8, ["modelValue"]) ]), _: 1 /* STABLE */ }), A(l, { class: "tvu-jse__field", label: "文件最大" }, { default: T(() => [ A(r, { modelValue: e.formatAttrs.size, "onUpdate:modelValue": n[1] || (n[1] = (o) => e.formatAttrs.size = o), modelModifiers: { number: !0 }, placeholder: "请输入数字,默认以MB为单位" }, null, 8, ["modelValue"]) ]), _: 1 /* STABLE */ }), A(l, { class: "tvu-jse__field", label: "文件个数" }, { default: T(() => [ A(r, { modelValue: e.formatAttrs.limit, "onUpdate:modelValue": n[2] || (n[2] = (o) => e.formatAttrs.limit = o), modelModifiers: { number: !0 }, placeholder: "请输入数字,0无意义" }, null, 8, ["modelValue"]) ]), _: 1 /* STABLE */ }) ]); }; } }), qs = { class: "tvu-jse__enum-config" }, Ts = { class: "tvu-jse__enum-groups" }, Vs = { class: "tvu-jse__enum-options" }, Fs = { class: "tvu-jse__enum-default" }, Bs = { class: "tvu-jse__enum-range" }, Ds = /* @__PURE__ */ le({ __name: "EnumConfig", props: { fieldAttrs: { type: Object, required: !0 }, fieldAttrsType: { type: String, default: "oneOf", required: !0 } }, setup(e) { const t = e, n = Te(t.fieldAttrs.default), r = () => { n.value ? t.fieldAttrs.default = n.value : delete t.fieldAttrs.default; }, l = () => { var c, u, d; let p = { id: `g${Date.now()}`, label: "newGroup", assocEnum: { property: "", value: "" } }; Array.isArray((c = t.fieldAttrs) == null ? void 0 : c.enumGroups) || (t.fieldAttrs.enumGroups = []), (d = (u = t.fieldAttrs) == null ? void 0 : u.enumGroups) == null || d.push(p); }, o = (p, c) => { var u, d; (d = (u = t.fieldAttrs) == null ? void 0 : u.enumGroups) == null || d.splice(c, 1); }, h = () => { var p; (p = t.fieldAttrs[t.fieldAttrsType]) == null || p.push({ label: "新选项", value: "newKey" }); }, f = (p, c) => { var u; (u = t.fieldAttrs[t.fieldAttrsType]) == null || u.splice(c, 1); }; return (p, c) => { const u = Z("tvu-input"), d = Z("tvu-button"), a = Z("tvu-form-item"), s = Z("tvu-option"), i = Z("tvu-select"), m = Z("tvu-input-number"); return F(), re("div", qs, [ ne("div", Ts, [ (F(!0), re( Re, null, Fe(e.fieldAttrs.enumGroups, (v, y) => (F(), Q( a, { class: "tvu-jse__enum-group tvu-jse__field", key: y }, { default: T(() => [ c[4] || (c[4] = ne( "div", null, "分组ID", -1 /* HOISTED */ )), A(u, { modelValue: v.id, "onUpdate:modelValue": (_) => v.id = _ }, null, 8, ["modelValue", "onUpdate:modelValue"]), c[5] || (c[5] = ne( "div", null, "分组名称", -1 /* HOISTED */ )), A(u, { modelValue: v.label, "onUpdate:modelValue": (_) => v.label = _ }, null, 8, ["modelValue", "onUpdate:modelValue"]), c[6] || (c[6] = ne( "div", null, "分组生效属性名", -1 /* HOISTED */ )), A(u, { modelValue: v.assocEnum.property, "onUpdate:modelValue": (_) => v.assocEnum.property = _ }, null, 8, ["modelValue", "onUpdate:modelValue"]), c[7] || (c[7] = ne( "div", null, "分组生效属性值", -1 /* HOISTED */ )), A(u, { modelValue: v.assocEnum.value, "onUpdate:modelValue": (_) => v.assocEnum.value = _ }, null, 8, ["modelValue", "onUpdate:modelValue"]), A(d, { onClick: (_) => o(v, y) }, { default: T(() => c[3] || (c[3] = [ Ve("删除分组") ])), _: 2 /* DYNAMIC */ }, 1032, ["onClick"]) ]), _: 2 /* DYNAMIC */ }, 1024 /* DYNAMIC_SLOTS */ ))), 128 /* KEYED_FRAGMENT */ )), A(d, { onClick: l }, { default: T(() => c[8] || (c[8] = [ Ve("新增分组") ])), _: 1 /* STABLE */ }) ]), ne("div", Vs, [ (F(!0), re( Re, null, Fe(e.fieldAttrs[e.fieldAttrsType], (v, y) => (F(), Q( a, { class: "tvu-jse__enum-option tvu-jse__field", key: y }, { default: T(() => [ c[10] || (c[10] = ne( "div", null, "选项值", -1 /* HOISTED */ )), A(u, { modelValue: v.value, "onUpdate:modelValue": (_) => v.value = _ }, null, 8, ["modelValue", "onUpdate:modelValue"]), c[11] || (c[11] = ne( "div", null, "选项显示内容", -1 /* HOISTED */ )), A(u, { modelValue: v.label, "onUpdate:modelValue": (_) => v.label = _ }, null, 8, ["modelValue", "onUpdate:modelValue"]), c[12] || (c[12] = ne( "div", null, "选项所属分组", -1 /* HOISTED */ )), A(u, { modelValue: v.group, "onUpdate:modelValue": (_) => v.group = _ }, null, 8, ["modelValue", "onUpdate:modelValue"]), A(d, { onClick: (_) => f(v, y) }, { default: T(() => c[9] || (c[9] = [ Ve("删除选项") ])), _: 2 /* DYNAMIC */ }, 1032, ["onClick"]) ]), _: 2 /* DYNAMIC */ }, 1024 /* DYNAMIC_SLOTS */ ))), 128 /* KEYED_FRAGMENT */ )), A(d, { onClick: h }, { default: T(() => c[13] || (c[13] = [ Ve("新增选项") ])), _: 1 /* STABLE */ }) ]), ne("div", Fs, [ A(a, { class: "tvu-jse__field", label: "默认选项" }, { default: T(() => [ A(i, { modelValue: n.value, "onUpdate:modelValue": c[0] || (c[0] = (v) => n.value = v), onChange: r }, { default: T(() => [ A(s, { label: "无", value: "" }), (F(!0), re( Re, null, Fe(e.fieldAttrs[e.fieldAttrsType], (v, y) => (F(), Q(s, { label: v.label, value: v.value }, null, 8, ["label", "value"]))), 256 /* UNKEYED_FRAGMENT */ )) ]), _: 1 /* STABLE */ }, 8, ["modelValue"]) ]), _: 1 /* STABLE */ }) ]), ne("div", Bs, [ A(a, { class: "tvu-jse__field", label: "至少选" }, { default: T(() => [ A(m, { modelValue: e.fieldAttrs.minItems, "onUpdate:modelValue": c[1] || (c[1] = (v) => e.fieldAttrs.minItems = v), modelModifiers: { number: !0 } }, null, 8, ["modelValue"]) ]), _: 1 /* STABLE */ }), A(a, { class: "tvu-jse__field", label: "最多选" }, { default: T(() => [ A(m, { modelValue: e.fieldAttrs.maxItems, "onUpdate:modelValue": c[2] || (c[2] = (v) => e.fieldAttrs.maxItems = v), modelModifiers: { number: !0 } }, null, 8, ["modelValue"]) ]), _: 1 /* STABLE */ }) ]) ]); }; } }), Hs = /* @__PURE__ */ le({ __name: "Attachment", props: { schemaProp: { type: Object, required: !0 }, onUpload: { type: Function } }, setup(e) { const t = e, { schemaProp: n, onUpload: r } = t, l = (h) => { let f = n.attachment; f.splice( f.indexOf(f.find((p) => p.name === h.name)), 1 ); }, o = (h) => { var d; const { accept: f, size: p, limit: c } = (d = n.items) == null ? void 0 : d.formatAttrs, u = h.name.split(".").pop(); if (!f.split(",").includes(u)) { alert(`不支持文件${h.name}的格式,仅支持${f}`); return; } if (c && n.attachment.length >= c) { alert(`只允许上传${c}个文件`); return; } if (p && h.size / 1024 / 1024 > p) { alert(`上传文件大小过大,超过${p}M`); return; } n.attachment || (n.attachment = []), r == null || r(h).then((a) => { n.attachment.push(a); }); }; return (h, f) => { const p = Z("tvu-button"), c = Z("tvu-upload"), u = Z("tvu-form-item"); return F(), Q(u, { label: "上传模板" }, { default: T(() => [ A(c, { action: "#", multiple: "", "file-list": Ui(n).attachment, "upload-file": o, "remove-file": l }, { default: T(() => [ A(p, null, { default: T(() => f[0] || (f[0] = [ Ve("上传文件") ])), _: 1 /* STABLE */ }) ]), _: 1 /* STABLE */ }, 8, ["file-list"]) ]), _: 1 /* STABLE */ }); }; } }), Us = /* @__PURE__ */ le({ __name: "Autofill", props: { autofill: { type: Object, required: !0 } }, setup(e) { return (t, n) => { const r = Z("tvu-input"), l = Z("tvu-form-item"), o = Z("tvu-option"), h = Z("tvu-select"), f = Z("tvu-json"); return F(), re( Re, null, [ A(l, { class: "tvu-jse__field", label: "获取填充值地址" }, { default: T(() => [ A(r, { modelValue: e.autofill.url, "onUpdate:modelValue": n[0] || (n[0] = (p) => e.autofill.url = p) }, null, 8, ["modelValue"]) ]), _: 1 /* STABLE */ }), A(l, { class: "tvu-jse__field", label: "HTTP方法" }, { default: T(() => [ A(h, { modelValue: e.autofill.method, "onUpdate:modelValue": n[1] || (n[1] = (p) => e.autofill.method = p) }, { default: T(() => [ A(o, { label: "GET", value: "GET" }), A(o, { label: "POST", value: "POST" }) ]), _: 1 /* STABLE */ }, 8, ["modelValue"]) ]), _: 1 /* STABLE */ }), A(l, { class: "tvu-jse__field tvu-jse__field--json", label: "查询参数" }, { default: T(() => [ A(f, { modelValue: e.autofill.params, "onUpdate:modelValue": n[2] || (n[2] = (p) => e.autofill.params = p) }, null, 8, ["modelValue"]) ]), _: 1 /* STABLE */ }), e.autofill.method === "POST" ? (F(), Q(l, { key: 0, class: "tvu-jse__field tvu-jse__field--json", label: "POST请求消息体" }, { default: T(() => [ A(f, { modelValue: e.autofill.body, "onUpdate:modelValue": n[3] || (n[3] = (p) => e.autofill.body = p) }, null, 8, ["modelValue"]) ]), _: 1 /* STABLE */ })) : H("v-if", !0), A(l, { class: "tvu-jse__field", label: "填充位置" }, { default: T(() => [ A(h, { modelValue: e.autofill.target, "onUpdate:modelValue": n[4] || (n[4] = (p) => e.autofill.target = p) }, { default: T(() => [ A(o, { label: "作为填入值", value: "value" }), A(o, { label: "作为可选项", value: "items" }) ]), _: 1 /* STABLE */ }, 8, ["modelValue"]) ]), _: 1 /* STABLE */ }), A(l, { class: "tvu-jse__field", label: "执行策略" }, { default: T(() => [ A(h, { modelValue: e.autofill.runPolicy, "onUpdate:modelValue": n[5] || (n[5] = (p) => e.autofill.runPolicy = p) }, { default: T(() => [ A(o, { label: "表单创建时执行1次", value: "onCreate" }), A(o, { label: "依赖参数更新时执行1次", value: "onParamChange" }), A(o, { label: "用户执行", value: "onUser" }) ]), _: 1 /* STABLE */ }, 8, ["modelValue"]) ]), _: 1 /* STABLE */ }) ], 64 /* STABLE_FRAGMENT */ ); }; } }), Gs = /* @__PURE__ */ le({ __name: "Lookup", props: { prop: { type: Object, required: !0 } }, setup(e) { return (t, n) => { const r = Z("tvu-json"), l = Z("tvu-form-item"); return F(), Q(l, { class: "tvu-jse__field", label: "获取填充值地址" }, { default: T(() => [ A(r, { modelValue: e.prop.lookup, "onUpdate:modelValue": n[0] || (n[0] = (o) => e.prop.lookup = o) }, null, 8, ["modelValue"]) ]), _: 1 /* STABLE */ }); }; } }); var it = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function we(e) { return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; } var st = { exports: {} }, Yt = {}, Xt, tn; function Ft() { return tn || (tn = 1, Xt = { ROOT: 0, GROUP: 1, POSITION: 2, SET: 3, RANGE: 4, REPETITION: 5, REFERENCE: 6, CHAR: 7 }), Xt; } var xe = {}, rn; function Gi() { if (rn) return xe; rn = 1; const e = Ft(), t = () => [{ type: e.RANGE, from: 48, to: 57 }], n = () => [ { type: e.CHAR, value: 95 }, { type: e.RANGE, from: 97, to: 122 }, { type: e.RANGE, from: 65, to: 90 } ].concat(t()), r = () => [ { type: e.CHAR, value: 9 }, { type: e.CHAR, value: 10 }, { type: e.CHAR, value: 11 }, { type: e.CHAR, value: 12 }, { type: e.CHAR, value: 13 }, { type: e.CHAR, value: 32 }, { type: e.CHAR, value: 160 }, { type: e.CHAR, value: 5760 }, { type: e.RANGE, from: 8192, to: 8202 }, { type: e.CHAR, value: 8232 }, { type: e.CHAR, value: 8233 }, { type: e.CHAR, value: 8239 }, { type: e.CHAR, value: 8287 }, { type: e.CHAR, value: 12288 }, { type: e.CHAR, value: 65279 } ], l = () => [ { type: e.CHAR, value: 10 }, { type: e.CHAR, value: 13 }, { type: e.CHAR, value: 8232 }, { type: e.CHAR, value: 8233 } ]; return xe.words = () => ({ type: e.SET, set: n(), not: !1 }), xe.notWords = () => ({ type: e.SET, set: n(), not: !0 }), xe.ints = () => ({ type: e.SET, set: t(), not: !1 }), xe.notInts = () => ({ type: e.SET, set: t(), not: !0 }), xe.whitespace = () => ({ type: e.SET, set: r(), not: !1 }), xe.notWhitespace = () => ({ type: e.SET, set: r(), not: !0 }), xe.anyChar = () => ({ type: e.SET, set: l(), not: !0 }), xe; } var nn; function Ws() { return nn || (nn = 1, function(e) { const t = Ft(), n = Gi(), r = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?", l = { 0: 0, t: 9, n: 10, v: 11, f: 12, r: 13 }; e.strToChars = function(o) { var h = /(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|(0?[0-7]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g; return o = o.replace(h, function(f, p, c, u, d, a, s, i) { if (c) return f; var m = p ? 8 : u ? parseInt(u, 16) : d ? parseInt(d, 16) : a ? parseInt(a, 8) : s ? r.indexOf(s) : l[i], v = String.fromCharCode(m); return /[[\]{}^$.|?*+()]/.test(v) && (v = "\\" + v), v; }), o; }, e.tokenizeClass = (o, h) => { for (var f = [], p = /\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(?:\\)?([^\]]))|(\])|(?:\\)?([^])/g, c, u; (c = p.exec(o)) != null; ) if (c[1]) f.push(n.words()); else if (c[2]) f.push(n.ints()); else if (c[3]) f.push(n.whitespace()); else if (c[4]) f.push(n.notWords()); else if (c[5]) f.push(n.notInts()); else if (c[6]) f.push(n.notWhitespace()); else if (c[7]) f.push({ type: t.RANGE, from: (c[8] || c[9]).charCodeAt(0), to: c[10].charCodeAt(0) }); else if (u = c[12]) f.push({ type: t.CHAR, value: u.charCodeAt(0) }); else return [f, p.lastIndex]; e.error(h, "Unterminated character class"); }, e.error = (o, h) => { throw new SyntaxError("Invalid regular expression: /" + o + "/: " + h); }; }(Yt)), Yt; } var Me = {}, sn; function Js() { if (sn) return Me; sn = 1; const e = Ft(); return Me.wordBoundary = () => ({ type: e.POSITION, value: "b" }), Me.nonWordBoundary = () => ({ type: e.POSITION, value: "B" }), Me.begin = () => ({ type: e.POSITION, value: "^" }), Me.end = () => ({ type: e.POSITION, value: "$" }), Me; } var an; function Ks() { if (an) return st.exports; an = 1; const e = Ws(), t = Ft(), n = Gi(), r = Js(); return st.exports = (l) => { var o = 0, h, f, p = { type: t.ROOT, stack: [] }, c = p, u = p.stack, d = [], a = (b) => { e.error(l, `Nothing to repeat at column ${b - 1}`); }, s = e.strToChars(l); for (h = s.length; o < h; ) switch (f = s[o++], f) { // Handle escaped characters, inclues a few sets. case "\\": switch (f = s[o++], f) { case "b": u.push(r.wordBoundary()); break; case "B": u.push(r.nonWordBoundary()); break; case "w": u.push(n.words()); break; case "W": u.push(n.notWords()); break; case "d": u.push(n.ints()); break; case "D": u.push(n.notInts()); break; case "s": u.push(n.whitespace()); break; case "S": u.push(n.notWhitespace()); break; default: /\d/.test(f) ? u.push({ type: t.REFERENCE, value: parseInt(f, 10) }) : u.push({ type: t.CHAR, value: f.charCodeAt(0) }); } break; // Positionals. case "^": u.push(r.begin()); break; case "$": u.push(r.end()); break; // Handle custom sets. case "[": var i; s[o] === "^" ? (i = !0, o++) : i = !1; var m = e.tokenizeClass(s.slice(o), l); o += m[1], u.push({ type: t.SET, set: m[0], not: i }); break; // Class of any character except \n. case ".": u.push(n.anyChar()); break; // Push group onto stack. case "(": var v = { type: t.GROUP, stack: [], remember: !0 }; f = s[o], f === "?" && (f = s[o + 1], o += 2, f === "=" ? v.followedBy = !0 : f === "!" ? v.notFollowedBy = !0 : f !== ":" && e.error( l, `Invalid group, character '${f}' after '?' at column ${o - 1}` ), v.remember = !1), u.push(v), d.push(c), c = v, u = v.stack; break; // Pop group out of stack. case ")": d.length === 0 && e.error(l, `Unmatched ) at column ${o - 1}`), c = d.pop(), u = c.options ? c.options[c.options.length - 1] : c.stack; break; // Use pipe character to give more choices. case "|": c.options || (c.options = [c.stack], delete c.stack); var y = []; c.options.push(y), u = y; break; // Repetition. // For every repetition, remove last element from last stack // then insert back a RANGE object. // This design is chosen because there could be more than // one repetition symbols in a regex i.e. `a?+{2,3}`. case "{": var _ = /^(\d+)(,(\d+)?)?\}/.exec(s.slice(o)), x, g; _ !== null ? (u.length === 0 && a(o), x = parseInt(_[1], 10), g = _[2] ? _[3] ? parseInt(_[3], 10) : 1 / 0 : x, o += _[0].length, u.push({ type: t.REPETITION, min: x, max: g, value: u.pop() })) : u.push({ type: t.CHAR, value: 123 }); break; case "?": u.length === 0 && a(o), u.push({ type: t.REPETITION, min: 0, max: 1, value: u.pop() }); break; case "+": u.length === 0 && a(o), u.push({ type: t.REPETITION, min: 1, max: 1 / 0, value: u.pop() }); break; case "*": u.length === 0 && a(o), u.push({ type: t.REPETITION, min: 0, max: 1 / 0, value: u.pop() }); break; // Default is a character that is not `\[](){}?+*^$`. default: u.push({ type: t.CHAR, value: f.charCodeAt(0) }); } return d.length !== 0 && e.error(l, "Unterminated group"), p; }, st.exports.types = t, st.exports; } var $t, on; function zs() { if (on) return $t; on = 1; class e { constructor(r, l) { this.low = r, this.high = l, this.length = 1 + l - r; } overlaps(r) { return !(this.high < r.low || this.low > r.high); } touches(r) { return !(this.high + 1 < r.low || this.low - 1 > r.high); } // Returns inclusive combination of SubRanges as a SubRange. add(r) { return new e( Math.min(this.low, r.low), Math.max(this.high, r.high) ); } // Returns subtraction of SubRanges as an array of SubRanges. // (There's a case where subtraction divides it in 2) subtract(r) { return r.low <= this.low && r.high >= this.high ? [] : r.low > this.low && r.high < this.high ? [ new e(this.low, r.low - 1), new e(r.high + 1, this.high) ] : r.low <= this.low ? [new e(r.high + 1, this.high)] : [new e(this.low, r.low - 1)]; } toString() { return this.low == this.high ? this.low.toString() : this.low + "-" + this.high; } } class t { constructor(r, l) { this.ranges = [], this.length = 0, r != null && this.add(r, l); } _update_length() { this.length = this.ranges.reduce((r, l) => r + l.length, 0); } add(r, l) { var o = (h) => { for (var f = 0; f < this.ranges.length && !h.touches(this.ranges[f]); ) f++; for (var p = this.ranges.slice(0, f); f < this.ranges.length && h.touches(this.ranges[f]); ) h = h.add(this.ranges[f]), f++; p.push(h), this.ranges = p.concat(this.ranges.slice(f)), this._update_length(); }; return r instanceof t ? r.ranges.forEach(o) : (l == null && (l = r), o(new e(r, l))), this; } subtract(r, l) { var o = (h) => { for (var f = 0; f < this.ranges.length && !h.overlaps(this.ranges[f]); ) f++; for (var p = this.ranges.slice(0, f); f < this.ranges.length && h.overlaps(this.ranges[f]); ) p = p.concat(this.ranges[f].subtract(h)), f++; this.ranges = p.concat(this.ranges.slice(f)), this._update_length(); }; return r instanceof t ? r.ranges.forEach(o) : (l == null && (l = r), o(new e(r, l))), this; } intersect(r, l) { var o = [], h = (f) => { for (var p = 0; p < this.ranges.length && !f.overlaps(this.ranges[p]); ) p++; for (; p < this.ranges.length && f.overlaps(this.ranges[p]); ) { var c = Math.max(this.ranges[p].low, f.low), u = Math.min(this.ranges[p].high, f.high); o.push(new e(c, u)), p++; } }; return r instanceof t ? r.ranges.forEach(h) : (l == null && (l = r), h(new e(r, l))), this.ranges = o, this._update_length(), this; } index(r) { for (var l = 0; l < this.ranges.length && this.ranges[l].length <= r; ) r -= this.ranges[l].length, l++; return this.ranges[l].low + r; } toString() { return "[ " + this.ranges.join(", ") + " ]"; } clone() { return new t(this); } numbers() { return this.ranges.reduce((r, l) => { for (var o = l.low; o <= l.high; ) r.push(o), o++; return r; }, []); } subranges() { return this.ranges.map((r) => ({ low: r.low, high: r.high, length: 1 + r.high - r.low })); } } return $t = t, $t; } var er, un; function Qs() { if (un) return er; un = 1; const e = Ks(), t = zs(), n = e.types; return er = class Qe { /** * @constructor * @param {RegExp|String} regexp * @param {String} m */ constructor(l, o) { if (this._setDefaults(l), l instanceof RegExp) this.ignoreCase = l.ignoreCase, this.multiline = l.multiline, l = l.source; else if (typeof l == "string") this.ignoreCase = o && o.indexOf("i") !== -1, this.multiline = o && o.indexOf("m") !== -1; else throw new Error("Expected a regexp or string"); this.tokens = e(l); } /** * Checks if some custom properties have been set for this regexp. * * @param {RandExp} randexp * @param {RegExp} regexp */ _setDefaults(l) { this.max = l.max != null ? l.max : Qe.prototype.max != null ? Qe.prototype.max : 100, this.defaultRange = l.defaultRange ? l.defaultRange : this.defaultRange.clone(), l.randInt && (this.randInt = l.randInt); } /** * Generates the random string. * * @return {String} */ gen() { return this._gen(this.tokens, []); } /** * Generate random string modeled after given tokens. * * @param {Object} token * @param {Array.<String>} groups * @return {String} */ _gen(l, o) { var h, f, p, c, u; switch (l.type) { case n.ROOT: case n.GROUP: if (l.followedBy || l.notFollowedBy) return ""; for (l.remember && l.groupNumber === void 0 && (l.groupNumber = o.push(null) - 1), h = l.options ? this._randSelect(l.options) : l.stack, f = "", c = 0, u = h.length; c < u; c++) f += this._gen(h[c], o); return l.remember && (o[l.groupNumber] = f), f; case n.POSITION: return ""; case n.SET: var d = this._expand(l); return d.length ? String.fromCharCode(this._randSelect(d)) : ""; case n.REPETITION: for (p = this.randInt( l.min, l.max === 1 / 0 ? l.min + this.max : l.max ), f = "", c = 0; c < p; c++) f += this._gen(l.value, o); return f; case n.REFERENCE: return o[l.value - 1] || ""; case n.CHAR: var a = this.ignoreCase && this._randBool() ? this._toOtherCase(l.value) : l.value; return String.fromCharCode(a); } } /** * If code is alphabetic, converts to other case. * If not alphabetic, returns back code. * * @param {Number} code * @return {Number} */ _toOtherCase(l) { return l + (97 <= l && l <= 122 ? -32 : 65 <= l && l <= 90 ? 32 : 0); } /** * Randomly returns a true or false value. * * @return {Boolean} */ _randBool() { return !this.randInt(0, 1); } /** * Randomly selects and returns a value from the array. * * @param {Array.<Object>} arr * @return {Object} */ _randSelect(l) { return l instanceof t ? l.index(this.randInt(0, l.length - 1)) : l[this.randInt(0, l.length - 1)]; } /** * expands a token to a DiscontinuousRange of characters which has a * length and an index function (for random selecting) * * @param {Object} token * @return {DiscontinuousRange} */ _expand(l) { if (l.type === e.types.CHAR) return new t(l.value); if (l.type === e.types.RANGE) return new t(l.from, l.to); { let o = new t(); for (let h = 0; h < l.set.length; h++) { let f = this._expand(l.set[h]); if (o.add(f), this.ignoreCase) for (let p = 0; p < f.length; p++) { let c = f.index(p), u = this._toOtherCase(c); c !== u && o.add(u); } } return l.not ? this.defaultRange.clone().subtract(o) : this.defaultRange.clone().intersect(o); } } /** * Randomly generates and returns a number between a and b (inclusive). * * @param {Number} a * @param {Number} b * @return {Number} */ randInt(l, o) { return l + Math.floor(Math.random() * (1 + o - l)); } /** * Default range of characters to generate from. */ get defaultRange() { return this._range = this._range || new t(32, 126); } set defaultRange(l) { this._range = l; } /** * * Enables use of randexp with a shorter call. * * @param {RegExp|String| regexp} * @param {String} m * @return {String} */ static randexp(l, o) { var h; return typeof l == "string" && (l = new RegExp(l, o)), l._randexp === void 0 ? (h = new Qe(l, o), l._randexp = h) : (h = l._randexp, h._setDefaults(l)), h.gen(); } /** * Enables sugary /regexp/.gen syntax. */ static sugar() { RegExp.prototype.gen = function() { return Qe.randexp(this); }; } }, er; } Qs(); var at = { exports: {} }, tr, ln; function Zs() { if (ln) return tr; ln = 1; var e = 1e3, t = e * 60, n = t * 60, r = n * 24, l = r * 7, o = r * 365.25; tr = function(u, d) { d = d || {}; var a = typeof u; if (a === "string" && u.length > 0) return h(u); if (a === "number" && isFinite(u)) return d.long ? p(u) : f(u); throw new Error( "val is not a non-empty string or a valid number. val=" + JSON.stringify(u) ); }; function h(u) { if (u = String(u), !(u.length > 100)) { var d = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( u ); if (d) { var a = parseFloat(d[1]), s = (d[2] || "ms").toLowerCase(); switch (s) { case "years": case "year": case "yrs": case "yr": case "y": return a * o; case "weeks": case "week": case "w": return a * l; case "days": case "day": case "d": return a * r; case "hours": case "hour": case "hrs": case "hr": case "h": return a * n; case "minutes": case "minute": case "mins": case "min": case "m": return a * t; case "seconds": case "second": case "secs": case "sec": case "s": return a * e; case "milliseconds": case "millisecond": case "msecs": case "msec": case "ms": return a; default: return; } } } } function f(u) { var d = Math.abs(u); return d >= r ? Math.round(u / r) + "d" : d >= n ? Math.round(u / n) + "h" : d >= t ? Math.round(u / t) + "m" : d >= e ? Math.round(u / e) + "s" : u + "ms"; } function p(u) { var d = Math.abs(u); return d >= r ? c(u, d, r, "day") : d >= n ? c(u, d, n, "hour") : d >= t ? c(u, d, t, "minute") : d >= e ? c(u, d, e, "second") : u + " ms"; } function c(u, d, a, s) { var i = d >= a * 1.5; return Math.round(u / a) + " " + s + (i ? "s" : ""); } return tr; } var rr, cn; function Ys() { if (cn) return rr; cn = 1; function e(t) { r.debug = r, r.default = r, r.coerce = c, r.disable = f, r.enable = o, r.enabled = p, r.humanize = Zs(), r.destroy = u, Object.keys(t).forEach((d) => { r[d] = t[d]; }), r.names = [], r.skips = [], r.formatters = {}; function n(d) { let a = 0; for (let s = 0; s < d.length; s++) a = (a << 5) - a + d.charCodeAt(s), a |= 0; return r.colors[Math.abs(a) % r.colors.length]; } r.selectColor = n; function r(d) { let a, s = null, i, m; function v(...y) { if (!v.enabled) return; const _ = v, x = Number(/* @__PURE__ */ new Date()), g = x - (a || x); _.diff = g, _.prev = a, _.curr = x, a = x, y[0] = r.coerce(y[0]), typeof y[0] != "string" && y.unshift("%O"); let b = 0; y[0] = y[0].replace(/%([a-zA-Z%])/g, (w, E) => { if (w === "%%") return "%"; b++; const V = r.formatters[E]; if (typeof V == "function") { const I = y[b]; w = V.call(_, I), y.splice(b, 1), b--; } return w; }), r.formatArgs.call(_, y), (_.log || r.log).apply(_, y); } return v.namespace = d, v.useColors = r.useColors(), v.color = r.selectColor(d), v.extend = l, v.destroy = r.destroy, Object.defineProperty(v, "enabled", { enumerable: !0, configurable: !1, get: () => s !== null ? s : (i !== r.namespaces && (i = r.namespaces, m = r.enabled(d)), m), set: (y) => { s = y; } }), typeof r.init == "function" && r.init(v), v; } function l(d, a) { const s = r(this.namespace + (typeof a > "u" ? ":" : a) + d); return s.log = this.log, s; } function o(d) { r.save(d), r.namespaces = d, r.names = [], r.skips = []; const a = (typeof d == "string" ? d : "").trim().replace(" ", ",").split(",").filter(Boolean); for (const s of a) s[0] === "-" ? r.skips.push(s.slice(1)) : r.names.push(s); } function h(d, a) { let s = 0, i = 0, m = -1, v = 0; for (; s < d.length; ) if (i < a.length && (a[i] === d[s] || a[i] === "*")) a[i] === "*" ? (m = i, v = s, i++) : (s++, i++); else if (m !== -1) i = m + 1, v++, s = v; else return !1; for (; i < a.length && a[i] === "*"; ) i++; return i === a.length; } function f() { const d = [ ...r.names, ...r.skips.map((a) => "-" + a) ].join(","); return r.enable(""), d; } function p(d) { for (const a of r.skips) if (h(d, a)) return !1; for (const a of r.names) if (h(d, a)) return !0; return !1; } function c(d) { return d instanceof Error ? d.stack || d.message : d; } function u() { console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); } return r.enable(r.load()), r; } return rr = e, rr; } var fn; function Xs() { return fn || (fn = 1, function(e, t) { t.formatArgs = r, t.save = l, t.load = o, t.useColors = n, t.storage = h(), t.destroy = /* @__PURE__ */ (() => { let p = !1; return () => { p || (p = !0, console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")); }; })(), t.colors = [ "#0000CC", "#0000FF", "#0033CC", "#0033FF", "#0066CC", "#0066FF", "#0099CC", "#0099FF", "#00CC00", "#00CC33", "#00CC66", "#00CC99", "#00CCCC", "#00CCFF", "#3300CC", "#3300FF", "#3333CC", "#3333FF", "#3366CC", "#3366FF", "#3399CC", "#3399FF", "#33CC00", "#33CC33", "#33CC66", "#33CC99", "#33CCCC", "#33CCFF", "#6600CC", "#6600FF", "#6633CC", "#6633FF", "#66CC00", "#66CC33", "#9900CC", "#9900FF", "#9933CC", "#9933FF", "#99CC00", "#99CC33", "#CC0000", "#CC0033", "#CC0066", "#CC0099", "#CC00CC", "#CC00FF", "#CC3300", "#CC3333", "#CC3366", "#CC3399", "#CC33CC", "#CC33FF", "#CC6600", "#CC6633", "#CC9900", "#CC9933", "#CCCC00", "#CCCC33", "#FF0000", "#FF0033", "#FF0066", "#FF0099", "#FF00CC", "#FF00FF", "#FF3300", "#FF3333", "#FF3366", "#FF3399", "#FF33CC", "#FF33FF", "#FF6600", "#FF6633", "#FF9900", "#FF9933", "#FFCC00", "#FFCC33" ]; function n() { if (typeof window < "u" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) return !0; if (typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) return !1; let p; return typeof document < "u" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 typeof window < "u" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages typeof navigator < "u" && navigator.userAgent && (p = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(p[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); } function r(p) { if (p[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + p[0] + (this.useColors ? "%c " : " ") + "+" + e.exports.humanize(this.diff), !this.useColors) return; const c = "color: " + this.color; p.splice(1, 0, c, "color: inherit"); let u = 0, d = 0; p[0].replace(/%[a-zA-Z%]/g, (a) => { a !== "%%" && (u++, a === "%c" && (d = u)); }), p.splice(d, 0, c); } t.log = console.debug || console.log || (() => { }); function l(p) { try { p ? t.storage.setItem("debug", p) : t.storage.removeItem("debug"); } catch { } } function o() { let p; try { p = t.storage.getItem("debug"); } catch { } return !p && typeof process < "u" && "env" in process && (p = process.env.DEBUG), p; } function h() { try { return localStorage; } catch { } } e.exports = Ys()(t); const { formatters: f } = e.exports; f.j = function(p) { try { return JSON.stringify(p); } catch (c) { return "[UnexpectedJSONParseError]: " + c.message; } }; }(at, at.exports)), at.exports; } var $s = Xs(); const Ee = /* @__PURE__ */ we($s), Wi = Ee("json-schema:model"); var Wr; (function(e) { e.value = "value", e.items = "items"; })(Wr || (Wr = {})); var Jr; (function(e) { e.onCreate = "onCreate", e.onParamChange = "onParamChange", e.onUser = "onUser"; })(Jr || (Jr = {})); class qt { constructor(t, n, r) { ee(this, "_parent"); ee(this, "_path"); ee(this, "_name"); ee(this, "attrs"); ee(this, "existIf"); ee(this, "lookup"); ee(this, "items"); ee(this, "attachment"); ee(this, "isPattern", !1); ee(this, "children"); ee(this, "patternChildren"); ee(this, "isOneOf", !1); ee(this, "isOneOfDefault", !1); ee(this, "isOneOfInclusiveGroup", ""); ee(this, "isOneOfExclusiveGroup", ""); ee(this, "isOneOfChildren", /* @__PURE__ */ new Map()); this._path = t, this._name = n, this.attrs = { type: r ?? "" }; } get parent() { return this._parent; } set parent(t) { this._parent = t; } get path() { if (this._parent) { let t = this._parent.fullname; return this._parent.attrs.type === "array" && (t += "[*]"), t; } return this._path; } set path(t) { this._path = t; } get name() { return this._name; } set name(t) { this._name = t; } get fullname() { return this.name ? this.path ? this.path + (this.name === "[*]" ? "" : ".") + this.name : this.name : this.path; } get fullRegExp() { var l; let t = Wi.extend("fullRegExp"), { fullname: n } = this, r = n.replace(/^\^/, "").replace(/\$$/, "").replace(/\.\^/g, ".").replace(/\$\./g, ".").replace(/\$\[/g, "[").replaceAll("[*]", "\\[\\d+\\]").replace(new RegExp("\\.", "g"), "\\."); return this.attrs.type === "array" && ((l = this.items) == null ? void 0 : l.type) !== "object" && (t(`属性定义【${n}】为数组类型,数组项目的类型不是对象,需要解决子项目属性匹配`), r += "(\\[\\d+\\])?"), r = "^" + r + "$", t(`属性定义【${n}】的正则表达式为【${r}】`), new RegExp(r); } get parentFullname() { return this.path.replace(/\[\*\]$/, ""); } get isArrayItem() { return /\[\*\]$/.test(this.path); } toJSON() { let t = { ...this }; return delete t.children, delete t.patternChildren, t; } readableValue(t, n) { var l, o, h, f, p, c, u, d; const { attrs: r } = this; switch (r.type) { case "boolean": return t ? "是" : "否"; case "number": case "string": if ((l = r.enum) != null && l.length) if ((o = r.enumGroups) != null && o.length) { const a = r.enumGroups.find((i) => i.assocEnum.value === n[i.assocEnum.property]); if (!a) return ""; const s = r.enum.find((i) =>