UNPKG

tms-vue3-ui

Version:

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

1,604 lines 350 kB
var Es = Object.defineProperty; var Ps = (e, t, n) => t in e ? Es(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; var te = (e, t, n) => Ps(e, typeof t != "symbol" ? t + "" : t, n); import { defineComponent as le, h as oe, resolveComponent as Z, createElementBlock as ne, openBlock as F, createVNode as A, withCtx as T, ref as Ve, createElementVNode as ie, Fragment as Le, renderList as Be, createBlock as Q, createTextVNode as Fe, unref as Ji, createCommentVNode as H, reactive as Is, computed as de, toRaw as ue, watch as Zt, onMounted as Rs, normalizeClass as Ls, toDisplayString as Ms, resolveDynamicComponent as rt, renderSlot as Ns } from "vue"; const Se = { 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) ); } }) }, js = { "tvu-form-item": { ...Se.formItem }, "tvu-input": { ...Se.input }, "tvu-textarea": { ...Se.textarea }, "tvu-json": { ...Se.json }, "tvu-input-number": { ...Se.input }, "tvu-upload": { ...Se.upload }, "tvu-checkbox": { ...Se.checkbox }, "tvu-select": { ...Se.select }, "tvu-option": { ...Se.option }, "tvu-button": { ...Se.button } }, qs = { class: "tvu-jse__field__file-attrs" }, Ts = /* @__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(), ne("div", qs, [ 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 */ }) ]); }; } }), Vs = { class: "tvu-jse__enum-config" }, Fs = { class: "tvu-jse__enum-groups" }, Bs = { class: "tvu-jse__enum-options" }, Ds = { class: "tvu-jse__enum-default" }, Hs = { class: "tvu-jse__enum-range" }, Us = /* @__PURE__ */ le({ __name: "EnumConfig", props: { fieldAttrs: { type: Object, required: !0 }, fieldAttrsType: { type: String, default: "oneOf", required: !0 } }, setup(e) { const t = e, n = Ve(t.fieldAttrs.default), r = () => { n.value ? t.fieldAttrs.default = n.value : delete t.fieldAttrs.default; }, l = () => { var c, a, 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 = (a = t.fieldAttrs) == null ? void 0 : a.enumGroups) == null || d.push(p); }, o = (p, c) => { var a, d; (d = (a = t.fieldAttrs) == null ? void 0 : a.enumGroups) == null || d.splice(c, 1); }, h = () => { var p; (p = t.fieldAttrs[t.fieldAttrsType]) == null || p.push({ label: "新选项", value: "newKey" }); }, f = (p, c) => { var a; (a = t.fieldAttrs[t.fieldAttrsType]) == null || a.splice(c, 1); }; return (p, c) => { const a = Z("tvu-input"), d = Z("tvu-button"), u = Z("tvu-form-item"), s = Z("tvu-option"), i = Z("tvu-select"), m = Z("tvu-input-number"); return F(), ne("div", Vs, [ ie("div", Fs, [ (F(!0), ne( Le, null, Be(e.fieldAttrs.enumGroups, (v, y) => (F(), Q( u, { class: "tvu-jse__enum-group tvu-jse__field", key: y }, { default: T(() => [ c[4] || (c[4] = ie( "div", null, "分组ID", -1 /* HOISTED */ )), A(a, { modelValue: v.id, "onUpdate:modelValue": (_) => v.id = _ }, null, 8, ["modelValue", "onUpdate:modelValue"]), c[5] || (c[5] = ie( "div", null, "分组名称", -1 /* HOISTED */ )), A(a, { modelValue: v.label, "onUpdate:modelValue": (_) => v.label = _ }, null, 8, ["modelValue", "onUpdate:modelValue"]), c[6] || (c[6] = ie( "div", null, "分组生效属性名", -1 /* HOISTED */ )), A(a, { modelValue: v.assocEnum.property, "onUpdate:modelValue": (_) => v.assocEnum.property = _ }, null, 8, ["modelValue", "onUpdate:modelValue"]), c[7] || (c[7] = ie( "div", null, "分组生效属性值", -1 /* HOISTED */ )), A(a, { 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] = [ Fe("删除分组") ])), _: 2 /* DYNAMIC */ }, 1032, ["onClick"]) ]), _: 2 /* DYNAMIC */ }, 1024 /* DYNAMIC_SLOTS */ ))), 128 /* KEYED_FRAGMENT */ )), A(d, { onClick: l }, { default: T(() => c[8] || (c[8] = [ Fe("新增分组") ])), _: 1 /* STABLE */ }) ]), ie("div", Bs, [ (F(!0), ne( Le, null, Be(e.fieldAttrs[e.fieldAttrsType], (v, y) => (F(), Q( u, { class: "tvu-jse__enum-option tvu-jse__field", key: y }, { default: T(() => [ c[10] || (c[10] = ie( "div", null, "选项值", -1 /* HOISTED */ )), A(a, { modelValue: v.value, "onUpdate:modelValue": (_) => v.value = _ }, null, 8, ["modelValue", "onUpdate:modelValue"]), c[11] || (c[11] = ie( "div", null, "选项显示内容", -1 /* HOISTED */ )), A(a, { modelValue: v.label, "onUpdate:modelValue": (_) => v.label = _ }, null, 8, ["modelValue", "onUpdate:modelValue"]), c[12] || (c[12] = ie( "div", null, "选项所属分组", -1 /* HOISTED */ )), A(a, { modelValue: v.group, "onUpdate:modelValue": (_) => v.group = _ }, null, 8, ["modelValue", "onUpdate:modelValue"]), A(d, { onClick: (_) => f(v, y) }, { default: T(() => c[9] || (c[9] = [ Fe("删除选项") ])), _: 2 /* DYNAMIC */ }, 1032, ["onClick"]) ]), _: 2 /* DYNAMIC */ }, 1024 /* DYNAMIC_SLOTS */ ))), 128 /* KEYED_FRAGMENT */ )), A(d, { onClick: h }, { default: T(() => c[13] || (c[13] = [ Fe("新增选项") ])), _: 1 /* STABLE */ }) ]), ie("div", Ds, [ A(u, { 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), ne( Le, null, Be(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 */ }) ]), ie("div", Hs, [ A(u, { 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(u, { 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 */ }) ]) ]); }; } }), Gs = /* @__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, a = h.name.split(".").pop(); if (!f.split(",").includes(a)) { 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((u) => { n.attachment.push(u); }); }; return (h, f) => { const p = Z("tvu-button"), c = Z("tvu-upload"), a = Z("tvu-form-item"); return F(), Q(a, { label: "上传模板" }, { default: T(() => [ A(c, { action: "#", multiple: "", "file-list": Ji(n).attachment, "upload-file": o, "remove-file": l }, { default: T(() => [ A(p, null, { default: T(() => f[0] || (f[0] = [ Fe("上传文件") ])), _: 1 /* STABLE */ }) ]), _: 1 /* STABLE */ }, 8, ["file-list"]) ]), _: 1 /* STABLE */ }); }; } }), Ws = /* @__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(), ne( Le, 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 */ ); }; } }), Js = /* @__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 nt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function Pe(e) { return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; } var it = { exports: {} }, Yt = {}, Xt, rn; function Vt() { return rn || (rn = 1, Xt = { ROOT: 0, GROUP: 1, POSITION: 2, SET: 3, RANGE: 4, REPETITION: 5, REFERENCE: 6, CHAR: 7 }), Xt; } var xe = {}, nn; function Ki() { if (nn) return xe; nn = 1; const e = Vt(), 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 sn; function Ks() { return sn || (sn = 1, function(e) { const t = Vt(), n = Ki(), 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, a, d, u, s, i) { if (c) return f; var m = p ? 8 : a ? parseInt(a, 16) : d ? parseInt(d, 16) : u ? parseInt(u, 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, a; (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 (a = c[12]) f.push({ type: t.CHAR, value: a.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 Ne = {}, an; function zs() { if (an) return Ne; an = 1; const e = Vt(); return Ne.wordBoundary = () => ({ type: e.POSITION, value: "b" }), Ne.nonWordBoundary = () => ({ type: e.POSITION, value: "B" }), Ne.begin = () => ({ type: e.POSITION, value: "^" }), Ne.end = () => ({ type: e.POSITION, value: "$" }), Ne; } var on; function Qs() { if (on) return it.exports; on = 1; const e = Ks(), t = Vt(), n = Ki(), r = zs(); return it.exports = (l) => { var o = 0, h, f, p = { type: t.ROOT, stack: [] }, c = p, a = p.stack, d = [], u = (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": a.push(r.wordBoundary()); break; case "B": a.push(r.nonWordBoundary()); break; case "w": a.push(n.words()); break; case "W": a.push(n.notWords()); break; case "d": a.push(n.ints()); break; case "D": a.push(n.notInts()); break; case "s": a.push(n.whitespace()); break; case "S": a.push(n.notWhitespace()); break; default: /\d/.test(f) ? a.push({ type: t.REFERENCE, value: parseInt(f, 10) }) : a.push({ type: t.CHAR, value: f.charCodeAt(0) }); } break; // Positionals. case "^": a.push(r.begin()); break; case "$": a.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], a.push({ type: t.SET, set: m[0], not: i }); break; // Class of any character except \n. case ".": a.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), a.push(v), d.push(c), c = v, a = v.stack; break; // Pop group out of stack. case ")": d.length === 0 && e.error(l, `Unmatched ) at column ${o - 1}`), c = d.pop(), a = 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), a = 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 ? (a.length === 0 && u(o), x = parseInt(_[1], 10), g = _[2] ? _[3] ? parseInt(_[3], 10) : 1 / 0 : x, o += _[0].length, a.push({ type: t.REPETITION, min: x, max: g, value: a.pop() })) : a.push({ type: t.CHAR, value: 123 }); break; case "?": a.length === 0 && u(o), a.push({ type: t.REPETITION, min: 0, max: 1, value: a.pop() }); break; case "+": a.length === 0 && u(o), a.push({ type: t.REPETITION, min: 1, max: 1 / 0, value: a.pop() }); break; case "*": a.length === 0 && u(o), a.push({ type: t.REPETITION, min: 0, max: 1 / 0, value: a.pop() }); break; // Default is a character that is not `\[](){}?+*^$`. default: a.push({ type: t.CHAR, value: f.charCodeAt(0) }); } return d.length !== 0 && e.error(l, "Unterminated group"), p; }, it.exports.types = t, it.exports; } var $t, un; function Zs() { if (un) return $t; un = 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), a = Math.min(this.ranges[p].high, f.high); o.push(new e(c, a)), 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, ln; function Ys() { if (ln) return er; ln = 1; const e = Qs(), 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, a; 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, a = h.length; c < a; 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 u = this.ignoreCase && this._randBool() ? this._toOtherCase(l.value) : l.value; return String.fromCharCode(u); } } /** * 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), a = this._toOtherCase(c); c !== a && o.add(a); } } 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; } Ys(); var st = { exports: {} }, tr, cn; function Xs() { if (cn) return tr; cn = 1; var e = 1e3, t = e * 60, n = t * 60, r = n * 24, l = r * 7, o = r * 365.25; tr = function(a, d) { d = d || {}; var u = typeof a; if (u === "string" && a.length > 0) return h(a); if (u === "number" && isFinite(a)) return d.long ? p(a) : f(a); throw new Error( "val is not a non-empty string or a valid number. val=" + JSON.stringify(a) ); }; function h(a) { if (a = String(a), !(a.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( a ); if (d) { var u = parseFloat(d[1]), s = (d[2] || "ms").toLowerCase(); switch (s) { case "years": case "year": case "yrs": case "yr": case "y": return u * o; case "weeks": case "week": case "w": return u * l; case "days": case "day": case "d": return u * r; case "hours": case "hour": case "hrs": case "hr": case "h": return u * n; case "minutes": case "minute": case "mins": case "min": case "m": return u * t; case "seconds": case "second": case "secs": case "sec": case "s": return u * e; case "milliseconds": case "millisecond": case "msecs": case "msec": case "ms": return u; default: return; } } } } function f(a) { var d = Math.abs(a); return d >= r ? Math.round(a / r) + "d" : d >= n ? Math.round(a / n) + "h" : d >= t ? Math.round(a / t) + "m" : d >= e ? Math.round(a / e) + "s" : a + "ms"; } function p(a) { var d = Math.abs(a); return d >= r ? c(a, d, r, "day") : d >= n ? c(a, d, n, "hour") : d >= t ? c(a, d, t, "minute") : d >= e ? c(a, d, e, "second") : a + " ms"; } function c(a, d, u, s) { var i = d >= u * 1.5; return Math.round(a / u) + " " + s + (i ? "s" : ""); } return tr; } var rr, fn; function $s() { if (fn) return rr; fn = 1; function e(t) { r.debug = r, r.default = r, r.coerce = c, r.disable = f, r.enable = o, r.enabled = p, r.humanize = Xs(), r.destroy = a, Object.keys(t).forEach((d) => { r[d] = t[d]; }), r.names = [], r.skips = [], r.formatters = {}; function n(d) { let u = 0; for (let s = 0; s < d.length; s++) u = (u << 5) - u + d.charCodeAt(s), u |= 0; return r.colors[Math.abs(u) % r.colors.length]; } r.selectColor = n; function r(d) { let u, s = null, i, m; function v(...y) { if (!v.enabled) return; const _ = v, x = Number(/* @__PURE__ */ new Date()), g = x - (u || x); _.diff = g, _.prev = u, _.curr = x, u = 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, u) { const s = r(this.namespace + (typeof u > "u" ? ":" : u) + d); return s.log = this.log, s; } function o(d) { r.save(d), r.namespaces = d, r.names = [], r.skips = []; const u = (typeof d == "string" ? d : "").trim().replace(" ", ",").split(",").filter(Boolean); for (const s of u) s[0] === "-" ? r.skips.push(s.slice(1)) : r.names.push(s); } function h(d, u) { let s = 0, i = 0, m = -1, v = 0; for (; s < d.length; ) if (i < u.length && (u[i] === d[s] || u[i] === "*")) u[i] === "*" ? (m = i, v = s, i++) : (s++, i++); else if (m !== -1) i = m + 1, v++, s = v; else return !1; for (; i < u.length && u[i] === "*"; ) i++; return i === u.length; } function f() { const d = [ ...r.names, ...r.skips.map((u) => "-" + u) ].join(","); return r.enable(""), d; } function p(d) { for (const u of r.skips) if (h(d, u)) return !1; for (const u of r.names) if (h(d, u)) return !0; return !1; } function c(d) { return d instanceof Error ? d.stack || d.message : d; } function a() { 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 pn; function ea() { return pn || (pn = 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 a = 0, d = 0; p[0].replace(/%[a-zA-Z%]/g, (u) => { u !== "%%" && (a++, u === "%c" && (d = a)); }), 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 = $s()(t); const { formatters: f } = e.exports; f.j = function(p) { try { return JSON.stringify(p); } catch (c) { return "[UnexpectedJSONParseError]: " + c.message; } }; }(st, st.exports)), st.exports; } var ta = ea(); const Ie = /* @__PURE__ */ Pe(ta), ra = Ie("json-schema:model"); var Jr; (function(e) { e.value = "value", e.items = "items"; })(Jr || (Jr = {})); var Kr; (function(e) { e.onCreate = "onCreate", e.onParamChange = "onParamChange", e.onUser = "onUser"; })(Kr || (Kr = {})); class jt { constructor(t, n, r) { te(this, "_parent"); te(this, "_path"); te(this, "_name"); te(this, "attrs"); te(this, "existIf"); te(this, "lookup"); te(this, "items"); te(this, "attachment"); te(this, "isPattern", !1); te(this, "children"); te(this, "patternChildren"); te(this, "isOneOf", !1); te(this, "isOneOfDefault", !1); te(this, "isOneOfInclusiveGroup", ""); te(this, "isOneOfExclusiveGroup", ""); te(this, "isOneOfChildren", /* @__PURE__ */ new Map()); this._path = t, this._name = n, this.attrs = { type: r ?? "" }; } get title() { return this.attrs.title ?? this.name; } get fullTitle() { if (this.parent) { let t = this.parent.fullTitle; return this.parent.attrs.type === "array" && (t += "[*]"), t ? t + "." + this.title : this.title; } return this.title; } 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 r, l, o; let { fullname: t } = this, n = t.replace(/^\^/, "").replace(/\$$/, "").replace(/\.\^/g, ".").replace(/\$\./g, ".").replace(/\$\[/g, "[").replaceAll("[*]", "\\[\\d+\\]").replace(new RegExp("\\.", "g"), "\\."); return this.attrs.type === "array" && ((r = this.items) == null ? void 0 : r.type) !== "object" && ((l = this.items) == null ? void 0 : l.type) !== "array" ? ((o = this.items) == null ? void 0 : o.type) === "json" ? n += "(\\[\\d+\\])?([.\\[].*)?" : n += "(\\[\\d+\\])?" : this.attrs.type === "json" && (n += "([.\\[].*)?"), n = "^" + n + "$", new RegExp(n); } get fullRegExpNoChild() { let { fullname: t } = this, n = t.replace(/^\^/, "").replace(/\$$/, "").replace(/\.\^/g, ".").replace(/\$\./g, ".").replace(/\$\[/g, "[").replaceAll("[*]", "\\[\\d+\\]").replace(new RegExp("\\.", "g"), "\\."); return n = "^" + n + "$", new RegExp(n); } get parentFullname() { return this.path.replace(/\[\*\]