var Tn = Object.defineProperty; var yr = (t) => { throw TypeError(t); }; var On = (t, e, r) => e in t ? Tn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r; var O = (t, e, r) => On(t, typeof e != "symbol" ? e + "" : e, r), wr = (t, e, r) => e.has(t) || yr("Cannot " + r); var d = (t, e, r) => (wr(t, e, "read from private field"), r ? r.call(t) : e.get(t)), N = (t, e, r) => e.has(t) ? yr("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), K = (t, e, r, n) => (wr(t, e, "write to private field"), n ? n.call(t, r) : e.set(t, r), r); import { jsx as h, jsxs as D } from "react/jsx-runtime"; import E, { useEffect as z, useState as V, useCallback as H, useRef as J, useContext as ue, useMemo as W, useId as Vt, isValidElement as Rn, useLayoutEffect as Fn } from "react"; import pe from "pathe"; import S from "prop-types"; import j from "classnames"; import { useNotification as jn } from "rc-notification"; import w from "lodash"; import { useMountedState as An, useDeepCompareEffect as Gt, useUpdateEffect as Xt, usePrevious as Ar, useAsync as br } from "react-use"; import se, { Field as Zt, FieldContext as Ir } from "rc-field-form"; import { _ as Cr, C as Qt, L as In, M as Ft, N as Qe, b as Ve, s as Dt, c as Ln, S as Vn } from "./vendor.js"; import Dn from "rc-util/lib/hooks/useMergedState"; import ie from "immutability-helper"; import { Space as Mt, Form as yt, Input as Mn, Button as bt, Pagination as Bn, Tree as Un, Breadcrumb as Wn, Empty as Bt, Table as kr, Popover as zn, Popconfirm as qn, Tooltip as Kn, Divider as _n } from "antd"; import { useMergedState as Jn } from "rc-util"; import { generatePath as Hn, useInRouterContext as Lr, useParams as Yn, useLocation as Gn, createBrowserRouter as Xn, Navigate as Zn } from "react-router-dom"; import Qn from "rc-drawer"; import ei from "rc-dialog"; import * as Sr from "react-is"; var qe, tt, Ke, xe, De, Me; class ti { constructor(e, r) { N(this, qe, /* @__PURE__ */ new Map()); N(this, tt, !0); N(this, Ke, []); N(this, xe); N(this, De, () => d(this, xe)); N(this, Me, () => Promise.resolve()); O(this, "get", (...e) => new Promise((r, n) => { const i = JSON.stringify(e); if (d(this, qe).has(i)) return r(d(this, Me).call(this, d(this, xe), ...e)); if (d(this, xe) === void 0) d(this, Ke).push([e, r, n]), d(this, tt) && (K(this, tt, !1), Promise.resolve(typeof d(this, De) == "function" ? d(this, De).call(this) : d(this, De)).then((o) => K(this, xe, o || null)).finally(() => { d(this, Ke).forEach(([o, s, a]) => { try { const l = d(this, Me).call(this, d(this, xe), ...o); d(this, qe).set(JSON.stringify(o), l), s(l); } catch (l) { a(l); } }), d(this, Ke).length = 0; })); else { const o = d(this, Me).call(this, d(this, xe), ...e); d(this, qe).set(i, o), r(o); } })); K(this, Me, r), K(this, De, e); } } qe = new WeakMap(), tt = new WeakMap(), Ke = new WeakMap(), xe = new WeakMap(), De = new WeakMap(), Me = new WeakMap(); const ri = () => h("div", { children: "Empty" }), Ze = E.createContext({ ele: {}, mount: () => { }, unmount: () => { } }), re = ({ rootClassName: t, className: e, children: r, actions: n, title: i, subTitle: o, extras: s, style: a = {} }) => { const { mount: l, unmount: c } = E.useContext(Ze); return re.Action({ children: n }), re.Title({ children: i }), re.SubTitle({ children: o }), re.Extra({ children: s }), z(() => (l("rootClassName", t), () => c("rootClassName")), [t]), h("div", { className: j("ff-container", e), style: a, children: r }); }, ft = (t) => ({ children: e, className: r }) => { const { mount: n, unmount: i } = E.useContext(Ze); return z(() => (e && n(t, E.createElement("div", { key: `ff-${t}`, className: j(`ff-popup-${t}`, r) }, e)), () => i(t)), [r, e]), null; }; re.Action = ft("actions"), re.Title = ft("title"), re.SubTitle = ft("subTitle"), re.Extra = ft("extras"), re.propTypes = { className: S.string, style: S.object, title: S.any, subTitle: S.any, actions: S.any, extras: S.any }; const Po = () => h(re, { className: "ff-loading", children: D("div", { className: "loader", children: [D("div", { className: "square", children: [h("span", {}), h("span", {}), h("span", {})] }), D("div", { className: "square", children: [h("span", {}), h("span", {}), h("span", {})] }), D("div", { className: "square", children: [h("span", {}), h("span", {}), h("span", {})] }), D("div", { className: "square", children: [h("span", {}), h("span", {}), h("span", {})] })] }) }), vo = () => h("div", { children: "NotFound" }), Vr = ({ children: t }) => { const [e, r] = V({}), n = H((o, s) => r((a) => ({ ...a, [o]: s })), []), i = H((o) => r((s) => ({ ...s, [o]: void 0 })), []); return typeof (t == null ? void 0 : t.type) == "string" ? t : h(Ze.Provider, { value: { ele: e, mount: n, unmount: i }, children: E.cloneElement(t, { className: e.rootClassName, title: e.title, subTitle: e.subTitle, actions: e.actions, extras: e.extras }) }); }; Vr.propTypes = { children: S.element.isRequired }; const Er = { close: ["M563.8 512l262.5-312.9c4.4-5.2 0.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9c-4.4 5.2-0.7 13.1 6.1 13.1h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"], check: ["M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474c-6.1-7.7-15.3-12.2-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1 0.4-12.8-6.3-12.8z"], info: ["M512 224m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z", "M544 392h-64c-4.4 0-8 3.6-8 8v464c0 4.4 3.6 8 8 8h64c4.4 0 8-3.6 8-8V400c0-4.4-3.6-8-8-8z"] }, er = ({ type: t, props: e }) => h("i", { ...e, children: h("svg", { viewBox: "0 0 1024 1024", width: "1em", height: "1em", fill: "currentColor", children: (Er[t] || Er.info).map((r, n) => h("path", { d: r }, n)) }) }), Dr = ({ className: t, content: e, icon: r, $close: n }) => D(E.Fragment, { children: [r && h("div", { className: j("ff-notification-icon", t), children: h(er, { type: r }) }), e] }), ni = ({}) => h(re, { children: "Confirm" }); var Oe, _e; const ge = class ge { constructor() { N(this, _e, /* @__PURE__ */ new Map()); O(this, "init", (e) => K(this, _e, new Map(e))); O(this, "check", (e) => !d(this, _e).has(e) || d(this, _e).get(e)); if (d(ge, Oe)) return d(ge, Oe); } }; Oe = new WeakMap(), _e = new WeakMap(), N(ge, Oe, null), O(ge, "getInstance", () => (d(ge, Oe) || K(ge, Oe, new ge()), d(ge, Oe))); let Ut = ge; const Mr = Ut.getInstance(), ii = (t, e, r = "children") => { if (w.isEmpty(t)) return {}; const n = w.find(t, ["value", e]); if (!w.isEmpty(n)) return n; const i = t.length; for (let o = 0; o < i; o++) { const { [r]: s } = t[o], a = ii(s, e, r); if (!w.isEmpty(a)) return a; } return {}; }, Br = (t = "Input", e = "@pkg/ff/grid-layout-forms") => t != null && t.startsWith("@") || t != null && t.startsWith("blob:") ? t : `${e}/${t}`; var Re, rt; const he = class he { constructor() { N(this, rt, null); O(this, "init", (e) => K(this, rt, e)); O(this, "get", (e, r) => w.get(d(this, rt), e, r)); if (d(he, Re)) return d(he, Re); } }; Re = new WeakMap(), rt = new WeakMap(), N(he, Re, null), O(he, "getInstance", () => (d(he, Re) || K(he, Re, new he()), d(he, Re))); let Wt = he; const We = Wt.getInstance(); var Je, St, nt, it, Et; const Te = class Te { constructor(...e) { N(this, nt, []); N(this, it, (e) => { var r; for (let n of e) Array.isArray(n[0]) ? d(this, it).call(this, n) : d(this, nt).push(d(r = Te, St).call(r, n[0], n[1])); }); O(this, "toValue", async (e, r = null) => { const n = { getValue: () => e, getRecord: () => r }; let i = e; for (const o of d(this, nt)) try { const s = await o; if (typeof s != "function") { console.warn("middleware is not a function, skip:", s); continue; } i = await s.call(n, i); } catch (s) { console.error("middleware error, skip:", s); } return i; }); O(this, "toRender", (e, r, n = null) => E.createElement(d(this, Et), { value: e, record: r }, n)); N(this, Et, ({ value: e, record: r, children: n }) => { const [i, o] = V(n), s = An(); return Gt(() => { o(n), this.toValue(e, r).then((a) => s() && o(a)).catch((a) => s() && o(`${a}`)); }, [e, r]), i; }); d(this, it).call(this, e); } }; Je = new WeakMap(), St = new WeakMap(), nt = new WeakMap(), it = new WeakMap(), Et = new WeakMap(), N(Te, Je, null), N(Te, St, w.memoize((e, r) => { if (typeof e == "function") return e(r); if (typeof e == "string") return X.getWidgetComponent(e).then((n) => { var i; return ((i = n.default) == null ? void 0 : i.call(n, r)) || ((o) => o); }); throw new TypeError("middleware must be a string or a function"); }, (...e) => { var r; return d(Te, Je) || K(Te, Je, Fi()), d(r = Te, Je).call(r, ...e); })); let Ct = Te; const ae = E.createContext({ listCode: "", classNames: {}, getBase62params: (t, e) => { }, getSelectedRows: () => [], onReload: () => { }, onClickCallback: () => { }, onConditionChange: () => { }, onTabChange: () => { }, onSiderChange: () => { }, onKeywordChange: () => { }, onPageChange: () => { }, onPageSizeChange: () => { }, reload: () => { }, setPage: () => { }, setPageSize: () => { }, setTab: () => { }, setSider: () => { }, setKeyword: () => { }, setCondition: () => { } }), $r = ({ className: t, record: e, column: r, ...n }) => { if (r != null && r.editableByJs && (r != null && r.uuid)) { const { formSetting: i = { primaryKey: "id" }, widgetSetting: o = {}, widgetContainerSetting: s = {} } = (r == null ? void 0 : r.editableByJsSetting) || {}; return h(R.Popover, { widget: Ur, widgetData: { record: e, column: r }, widgetSetting: { widgetSetting: o, formSetting: i }, widgetContainerProps: { title: r != null && r.title ? `${r.title} - 编辑` : "编辑", width: 260, zIndex: 1050, arrow: !0, ...s }, children: h("td", { className: j("ff-data-list-cell-editable", t), ...n }) }); } return h("td", { className: t, ...n }); }, Ur = ({ record: t, column: e, $close: r, $setting: n }) => { const i = J(Oi(w.get(t, e == null ? void 0 : e.dataIndex))), { listCode: o, onClickCallback: s } = ue(ae), [a] = se.useForm(), { formSetting: l, widgetSetting: c } = n, { primaryKey: u = "id", help: p, validators: m } = l || {}, g = () => { a.setFieldsValue({ value: w.get(t, e == null ? void 0 : e.dataIndex), __PROPS__: t }); }; return Nt(() => g(), [t, e == null ? void 0 : e.dataIndex, o]), h(re, { actions: D(E.Fragment, { children: [h(R, { size: "small", onClick: g, children: "重置" }), D(Mt.Compact, { block: !0, children: [h(R, { size: "small", widget: r, children: "取消" }), h(R, { type: "primary", size: "small", widget: () => a.validateFields().then(({ value: f }) => { const y = w.get(t, u.substring(u.indexOf(".") + 1)); if (!y) throw "获取更新主键失败!"; B.put(`/api/${o}-storeBy-${e == null ? void 0 : e.uuid}/${y}`, { value: f }).msg(() => s(2, t)).then(r); }).catch(console.warn), children: "保存" })] })] }), children: D(se, { form: a, children: [h(nr, { label: "", code: "value", type: i.current, widget: e == null ? void 0 : e.editableByJs, help: p, extras: c, validators: m }), h(Zt, { noStyle: !0, name: ["__PROPS__"], children: () => { } })] }) }); }; Ur.displayName = "DataListCellEditableContainer"; const oi = (t) => function(e) { return t(e, getRecord()); }, si = async ({ widgetByJs: t, widgetByJsSetting: e }) => { const r = await X.getWidgetComponent(t).then((n) => n.default || ((i) => i)); return function(n) { return h(r, { value: n, $setting: e }); }; }, ai = (t, e = {}) => W(() => { var r; return (r = t == null ? void 0 : t.filter(Boolean)) == null ? void 0 : r.map(({ widgetByJs: n, widgetByJsSetting: i, middlewares: o, ...s }, a) => { const l = (c) => ({ record: c, column: s }); return o || (o = []), n && o.push([si, { widgetByJs: n, widgetByJsSetting: i }]), o.length > 0 ? (s != null && s.render && o.push([oi, s.render]), { ...s, onCell: l, render: (c, u) => new Ct(o).toRender(c, u, "-") }) : { ...s, onCell: l }; }); }, [t, e]), li = (t = {}) => W(() => { var e; return t.body ?? (t.body = { cell: $r }), (e = t.body).cell ?? (e.cell = $r), t; }, [t]), No = (t) => { const [e, r] = V({}); return z(() => { let n = !1; return t && B.get(`/api/_/${t}`).then((i) => w.pick(i, ["uuid", "name", "code", "resource", "marginX", "marginY", "cols", "rowHeight", "primaryKey", "columns", "itemOperations", "batchOperations", "isConditionFormLayout", "layout", "tabs", "pageSize", "layoutConfig", "selectionType"])).then((i) => !n && r(i)), () => n = !0; }, [t]), e; }, To = (t, e = {}) => { const [r, n] = V({ dataSource: [] }); return gt(() => { let i = !1; return t && B.get(`/api/${t}/${B.encode({ page: 1, ...e })}`).then((o) => !i && n(o)), () => i = !0; }, [t, e]), r; }, Wr = (t = [], e = /* @__PURE__ */ new Map(), r = "id", n) => { const i = H(n ? (o) => w.get(o, r, w.get(o, [n, r])) : (o) => w.get(o, r), [r, n]); return H((o) => t == null ? void 0 : t.filter((s) => !s.uuid || !e.has(s.uuid) || e.get(s.uuid).some((a) => a == i(o))), [t, e, i]); }, zt = (t = [], e = /* @__PURE__ */ new Map(), r = [], n = "id", i) => { const o = H(i ? (s) => w.get(s, n, w.get(s, [i, n])) : (s) => w.get(s, n), [n, i]); return W(() => { if (w.isEmpty(t) || !t.some(({ uuid: a }) => Mr.check(a))) return !1; if (w.isEmpty(e) || w.isEmpty(r)) return !0; const s = r.map((a) => o(a)); return t.some(({ uuid: a }) => !a || !e.has(a) || e.get(a).some((l) => s.some((c) => c == l))); }, [t, r, e, o]); }, ci = (t, e, r = "id", n = null) => { const i = vt(), o = J(!1), s = J(t.dataSource), a = J(t.itemOperationsAccess); return z(() => (s.current = t.dataSource, a.current = t.itemOperationsAccess, () => o.current = !1), [t.dataSource, t.itemOperationsAccess]), o.current && (t.dataSource = s.current, t.itemOperationsAccess = a.current), [t, (l = 0, c = null) => { var u, p; if (o.current = !1, l === 1) return (u = t.onReload) == null ? void 0 : u.call(t); if (l === 2) { const m = w.get(c, "__PARENT_ID__", ""), g = w.get(c, r, w.get(c, [n, r], "")), f = w.findIndex(s.current, ["__PARENT_ID__", m]), y = w.findIndex(f > -1 ? w.get(s.current, [f, "children"]) : s.current, [r, g]); if (y === -1) return (p = t.onReload) == null ? void 0 : p.call(t); Promise.all([B.get(`/api/${e}/detail/${g}`), B.post(`/api/${e}/list-operations-access`, { ids: g })]).then(([k, b]) => { const $ = w.get(s.current, f > -1 ? [f, "children", y, "children"] : [y, "children"]); s.current = ie(s.current, f > -1 ? { [f]: { children: { $splice: [[y, 1, { ...k, children: $ }]] } } } : { $splice: [[y, 1, { ...k, children: $ }]] }); const C = new Map(b); a.current.forEach((x, F) => { var I; (I = C.get(F)) != null && I.some((T) => T == g) || a.current.set(F, x.filter((T) => T !== g)); }), C.forEach((x, F) => { a.current.has(F) ? a.current.set(F, w.uniq([...a.current.get(F) || [], ...x])) : a.current.set(F, x); }); }).then(() => { o.current = !0, i(); }); } }]; }, di = (t, e) => { const r = vt(), n = J(e), i = J(/* @__PURE__ */ new Map()), o = J([]), s = w.throttle((l) => { o.current = [], B.list(t, w.pick({ ...n.current, ...l }, ["tab", "page", "pageSize", "condition", "sider", "keyword"])).then(({ keyword: c, condition: u, total: p, tab: m, sider: g, page: f, pageSize: y, operationsAccess: k, dataSource: b }) => { n.current = { tab: m, condition: u, sider: g, keyword: c, total: p, pageSize: y, page: b != null && b.length ? f : 1 }, o.current = b, i.current = new Map(k), r(); }); }, 380, { leading: !1, trailing: !0 }); Nt(() => { o.current = [], t && s(e); }, [t, e]); const a = W(() => w.pick(n.current, ["total", "tab", "page", "pageSize", "condition", "sider", "keyword", "primaryKey"]), [n.current]); return Object.assign(a, { onTabChange: (l) => s({ tab: l, page: 1 }), onPageChange: (l, c) => s({ page: l, pageSize: c }), onPageSizeChange: (l) => s({ pageSize: l, page: 1 }), onConditionChange: (l, c) => s({ keyword: c, condition: ie(n.current.condition || {}, { $merge: l || {} }), page: 1 }), onSiderChange: (l) => s({ sider: l, page: 1 }), onKeywordChange: (l) => s({ keyword: l, page: 1 }), itemOperationsAccess: i.current, dataSource: o.current, onReload: s, payload: e == null ? void 0 : e.payload }); }, ui = ({ listCode: t, className: e, layouts: r = {}, dataSource: n, isPaginate: i, isItemOperations: o, isBatchOperations: s, batchOperations: a, itemOperations: l, itemOperationsAccess: c, resource: u, primaryKey: p, title: m, itemGridLayout: g, $setting: f, tabs: y, isConditionFormLayout: k, isTreeSider: b, treeSiderConfig: $, rowSelection: C }) => { const { classNames: x, onClickCallback: F } = ue(ae), I = w.pick(f, ["column", "colWidth", "beforeRender", "afterRender", "style", "itemMargin", "containerPadding"]), T = f == null ? void 0 : f.isMarkSelected, v = Wr(l, c, p, u), A = H((P, L, M) => h(pi, { isMarkSelected: T, className: j("ff-data-list-framework-item", x == null ? void 0 : x.item), operations: o ? v(L) : [], data: u ? { [u]: L } : L, children: P, onClickCallback: F }), [T, u, p, o, F, l, c]); return D("div", { className: j("ff-data-list-framework", e), children: [h(r.sider, { isTreeSider: b, ...$ }), D("div", { className: j("ff-data-list-container", x == null ? void 0 : x.container), children: [h(r.filter, { isConditionFormLayout: k }), h(r.toolbar, { title: m, tabs: y }), h(Pi, { ...g, ...I, rowSelection: C, empty: h(r.empty, { className: x == null ? void 0 : x.empty }), primaryKey: p, itemRender: A, dataSource: n }), h(r.footer, { isPaginate: i, isOperations: s, operations: a })] })] }); }, pi = ({ className: t, operations: e, children: r, data: n, onClickCallback: i, onSelect: o, isMarkSelected: s, isSelected: a, selectionType: l }) => D("div", { className: j("data-list-grid-layout-item", { "is-mark-selected": s, "is-selected": a, "is-selectable": !!l }, t), onClick: o, children: [h("div", { className: "data-list-grid-layout-item-container", children: r }), !!(e != null && e.length) && h("div", { className: "data-list-grid-layout-item-actions", children: e.map((c) => h("span", { className: "data-list-grid-layout-item-action", children: h(R.Link, { uuid: c.uuid, type: c.type, name: c.name, widget: c.widget, widgetType: c.widgetType, widgetProps: c.widgetProps, widgetSetting: c.widgetSetting, widgetContainerProps: c.widgetContainerSetting, data: n, confirm: c.confirm, onAfterClick: (u) => u !== !1 && (i == null ? void 0 : i(c.isRefresh, n)) }, c.uuid || Vt()) }, (c == null ? void 0 : c.uuid) || Vt())) })] }), gi = ({ listCode: t, className: e, layouts: r = {}, dataSource: n, columns: i, isItemOperations: o, isBatchOperations: s, batchOperations: a, itemOperations: l, itemOperationsAccess: c, resource: u, primaryKey: p, title: m, tabs: g, isPaginate: f, rowSelection: y, isTreeSider: k, treeSiderConfig: b, isConditionFormLayout: $, ...C }) => { const { classNames: x, onClickCallback: F } = ue(ae), I = Wr(l, c, p, u), T = zt(l, c, n, p, u); return D("div", { className: j("ff-data-table-framework", e), children: [h(r.sider, { isTreeSider: k, ...b }), D("div", { className: j("ff-data-table-container", x == null ? void 0 : x.container), children: [h(r.filter, { isConditionFormLayout: $ }), h(r.toolbar, { title: m, tabs: g }), h(Ci, { ...C, primaryKey: p, className: "ff-data-table-content", columns: i, dataSource: n, rowSelection: y, operationRender: T ? (v) => { var A; return h("div", { className: "ff-data-table-actions", children: (A = I(v)) == null ? void 0 : A.map((P, L) => h(R, { size: "small", uuid: P.uuid, type: P.type, name: P.name, widget: P.widget, widgetType: P.widgetType, widgetProps: P.widgetProps, widgetData: P.widgetData, widgetSetting: P.widgetSetting, widgetContainerProps: P.widgetContainerSetting, data: v, confirm: P.confirm, onAfterClick: (M) => M !== !1 && (F == null ? void 0 : F(P.isRefresh, v)) }, P.uuid || L)) }); } : null }), h(r.footer, { isPaginate: f, isOperations: s, operations: a })] })] }); }, tr = (t = [], e, r = null) => { var n; return (n = w.sortBy(t, ["y", "x"])) == null ? void 0 : n.map(({ i, x: o, y: s, w: a, h: l, field: { boxStyle: c, ...u } = {} }, p) => h("div", { className: "grid-layout-item", style: zr(o, s, a, l, c), children: h(e, { ...u, basicForm: r }) }, i ?? p)); }, zr = (t, e, r, n, i = {}, o = 0) => { const s = { "--grid-layout-h": `${n}`, "--grid-layout-w": `${r}`, "--grid-layout-x": `${t}`, "--grid-layout-y": `${e}`, "--grid-layout-row-height-offset": "0px" }; return i != null && i.autoHeight ? s.height = "fit-content" : s["--grid-layout-row"] = `${n}`, i != null && i.alignItems && (s["--grid-layout-box-align-items"] = i.alignItems), i != null && i.justifyContent && (s["--grid-layout-box-justify-content"] = i.justifyContent), s["--grid-layout-box-margin"] = xr(i == null ? void 0 : i.marginTop, i == null ? void 0 : i.marginRight, i == null ? void 0 : i.marginBottom, i == null ? void 0 : i.marginLeft), s["--grid-layout-box-padding"] = xr(i == null ? void 0 : i.paddingTop, i == null ? void 0 : i.paddingRight, i == null ? void 0 : i.paddingBottom, i == null ? void 0 : i.paddingLeft), o && (s.height = `${o}px`), s; }, xr = (t, e, r, n) => `${t || 0}px ${e || 0}px ${r || 0}px ${n || 0}px`, Oo = (t = "Text", e = "@pkg/ff/grid-layouts") => t != null && t.startsWith("@") || t != null && t.startsWith("blob:") ? t : `${e}/${t}`, qr = (t) => Object.keys(t).reduce((e, r) => (/^on[A-Z]/.test(r) && (e[r] = t[r]), e), {}), Kr = ({ className: t, isConditionFormLayout: e }) => { var m, g; const [r, n] = V({}), { listCode: i, onKeywordChange: o, onConditionChange: s, getBase62params: a, classNames: l } = E.useContext(ae), { keyword: c, condition: u } = (a == null ? void 0 : a()) || {}, [p] = yt.useForm(); return z(() => { i && e && B.get(`/api/_/${i}/list-condition-form-layout`).then(({ resource: f, marginX: y, marginY: k, rowHeight: b, cols: $, fields: C }) => { n({ resource: f, itemMargin: [y, k], rowHeight: b, cols: $, fields: C }); }).catch(() => n({})); }, [i, e]), z(() => { p.setFieldsValue({ keyword: c, ...u }); }, [JSON.stringify([c, u])]), h("div", { className: j("ff-data-list-filter", l.filter, t), children: h(yt, { form: p, layout: "vertical", autoComplete: "off", onFinish: ((m = r.fields) == null ? void 0 : m.length) > 1 ? (f) => s({ [r.resource]: f[r.resource] }, f.keyword) : () => { }, onValuesChange: (f) => { w.isEmpty(w.omit(f, ["keyword"])) || p.submit(); }, children: ((g = r.fields) == null ? void 0 : g.length) > 1 ? h(ir, { ...r, children: h(hi, { onReset: () => { const { keyword: f, condition: y } = a("init") || {}; p.setFieldsValue({ keyword: f, ...y }); } }) }) : h("div", { className: "ff-data-list-filter-default-form ff-grid-layout-form", children: h("div", { className: "grid-layout-item", style: zr(20, 0, 5, 2), children: h(yt.Item, { name: ["keyword"], children: h(Mn.Search, { allowClear: !0, enterButton: "搜索", placeholder: "多关键字 | 分割", onSearch: (f) => o(f) }) }) }) }) }) }); }, hi = ({ cols: t, fields: e, onReset: r }) => { const [n, i] = V(!1), o = W(() => e == null ? void 0 : e.toReversed().some((s) => s.y > 1 || s.x + s.w >= t - 5), [t, e]); return D(yt.Item, { label: " ", style: { "--item-span": 5 }, className: j("ff-data-list-filter-actions", { expanded: n }), children: [h(bt, { onClick: r, children: "重置" }), h(bt, { type: "primary", htmlType: "submit", children: "查询" }), o && h(R.Link, { className: "ff-data-list-filter-expanded-button", widget: () => i((s) => !s), type: "primary", name: n ? "关闭" : "展开", icon: n ? "icon-up" : "icon-down", iconPosition: "end" })] }); }; Kr.reservedFields = [{ x: 0, y: 0, h: 3, w: 5, field: { isVirtual: !0, widgetPrefix: "@pkg/ff/grid-layout-forms", widget: "Input", code: "keyword", label: "关键字", placeholder: "多关键字 | 分割", extras: { prefix: "icon-search" } } }]; const mi = ({ className: t, operations: e, isOperations: r, isPaginate: n }) => { const { onPageChange: i, onPageSizeChange: o, onClickCallback: s, getBase62params: a } = E.useContext(ae), { total: l, page: c, pageSize: u } = (a == null ? void 0 : a()) || {}; return r && !w.isEmpty(e) || n ? D("div", { className: j("ff-data-list-footer", t), children: [h("div", { className: "ff-data-list-actions", children: e == null ? void 0 : e.map((p, m) => h(R, { uuid: p.uuid, type: p.type, name: p.name, widget: p.widget, widgetType: p.widgetType, widgetProps: p.widgetProps, widgetData: p.widgetData, widgetSetting: p.widgetSetting, widgetContainerProps: p.widgetContainerSetting, onAfterClick: (g) => g !== !1 && (s == null ? void 0 : s(p.isRefresh, null)) }, p.uuid || m)) }), n && h(Bn, { size: "small", total: l, pageSize: u, showSizeChanger: !1, showTotal: (p) => `第 ${c} 页 / 总共 ${p} 条`, onChange: i, onShowSizeChange: o })] }) : null; }, fi = [{ title: "parent 1", key: "0-0", children: [{ title: "parent 1-0", key: "0-0-0", disabled: !0, children: [{ title: "leaf", key: "0-0-0-0", disableCheckbox: !0 }, { title: "leaf", key: "0-0-0-1" }] }, { title: "parent 1-1", key: "0-0-1", children: [{ title: h("span", { style: { color: "#1677ff" }, children: "sss" }), key: "0-0-1-0" }] }] }], yi = ({ className: t, width: e = 280, isTreeSider: r }) => { const { classNames: n } = ue(ae); return r ? h(Un.DirectoryTree, { className: j("ff-data-list-sider", n.sider, t), style: { "--sider-width": e }, showLine: !0, showIcon: !1, treeData: fi }) : null; }, wi = ({ className: t, title: e, tabs: r }) => { const { getBase62params: n, onTabChange: i, onReload: o, classNames: s } = ue(ae), { tab: a } = (n == null ? void 0 : n()) || {}, [l, c] = Jn((r == null ? void 0 : r[0].value) ?? (r == null ? void 0 : r[0].code), { value: a, onChange: i }); return D("div", { className: j("ff-data-list-toolbar", s.toolbar, t), children: [h("div", { className: "ff-data-list-title", children: e }), h(Wn, { className: "ff-data-list-tabs", itemRender: ({ label: u, code: p, value: m }) => h("span", { onClick: () => c(m ?? p), className: j("ff-data-list-tab", { active: (m ?? p) == l }), children: u }), items: r }), D("div", { className: "ff-data-list-actions", children: [h(R.Link, { icon: "icon-reload", widget: () => o() }), h(R.Link, { icon: "icon-setting" })] })] }); }, bi = ({ className: t, ...e }) => h(Bt, { className: j(t, "ff-data-list-empty"), image: Bt.PRESENTED_IMAGE_SIMPLE, ...e }), _r = ({ isItemGridLayout: t, theme: e, themeProps: r, onClickCallback: n, onReload: i, listCode: o, total: s = 0, page: a = 0, onPageChange: l, pageSize: c = 30, onPageSizeChange: u, tab: p, onTabChange: m, keyword: g, onKeywordChange: f, condition: y, onConditionChange: k, sider: b, onSiderChange: $, layouts: C, classNames: x = {}, payload: F = {}, dataSource: I = [], rowSelection: T, getSelectedRows: v, primaryKey: A, ...P }) => { const [L, M] = V(), U = v ?? (() => I), Z = H((q, le) => { const _ = { tab: p, page: a, pageSize: c, keyword: g, sider: b, condition: y, total: s, payload: F }; return q && q != "init" ? w.get(_, q, le) : _; }, [JSON.stringify(y), JSON.stringify(F), p, a, c, g, b, s]), $e = W(() => { let q = { sider: yi, filter: Kr, footer: mi, toolbar: wi, empty: bi }; C === !1 ? q = { sider: null, filter: null, footer: null, toolbar: null, empty: null } : w.isPlainObject(C) && (q = Object.assign({}, q, C)); for (const le in q) if (q[le]) { if (Rn(q[le])) { const _ = q[le]; q[le] = (mt) => E.cloneElement(_, mt); } } else q[le] = () => h(E.Fragment, {}); return q; }, [C]); return z(() => { e ? X.getWidgetComponent(e).then((q) => { if (!q) throw `${e} not found`; return q; }).catch((q) => ({ default: () => `${q}` })).then((q) => M(E.createElement(q.default, { ...P, layouts: $e, $setting: r }))) : M(h(t ? ui : gi, { ...P, layouts: $e, $setting: r })); }, [e, r]), h(ae.Provider, { value: { classNames: x, listCode: o, onClickCallback: n, onReload: i, getBase62params: Z, onPageChange: l, onPageSizeChange: u, onTabChange: m, onSiderChange: $, onKeywordChange: f, onConditionChange: k, setPage: l, setPageSize: u, setTab: m, setSider: $, setKeyword: f, setCondition: k, getSelectedRows: U }, children: L && E.cloneElement(L, { dataSource: I, primaryKey: A, rowSelection: T, ...P }) }); }; _r.propTypes = { classNames: S.exact({ sider: S.string, filter: S.string, footer: S.string, toolbar: S.string, container: S.string, content: S.string, item: S.string, empty: S.string }), layouts: S.oneOfType([S.exact({ sider: S.oneOfType([S.elementType, S.element]), filter: S.oneOfType([S.elementType, S.element]), footer: S.oneOfType([S.elementType, S.element]), toolbar: S.oneOfType([S.elementType, S.element]), empty: S.oneOfType([S.elementType, S.element]) }), S.bool]) }; var Fe, Pe, Be, $t; const me = class me { constructor() { N(this, Pe, null); N(this, Be, /* @__PURE__ */ new Map()); N(this, $t, () => { if (d(this, Pe)) return d(this, Pe).port.postMessage({ command: "status", data: [] }); K(this, Pe, new SharedWorker(new URL("/ff-worker/res-ws.js", self.location))), d(this, Pe).port.onmessage = (e) => { var r, n; (r = e.data) != null && r.uuid ? d(this, Be).forEach((i, o) => { var s; (i == "*" || (s = i == null ? void 0 : i.includes) != null && s.call(i, e.data.uuid)) && o(e.data); }) : ((n = e.data) == null ? void 0 : n.readyState) == WebSocket.CLOSED && B.get("/api/user-api-token").then(({ token: i, expire_at: o }) => { d(this, Pe).port.postMessage({ command: "initWs", data: [`ws${w.trimStart(B.appUrl, "http")}api/user-resource-status-ws?token=${i}`] }); }); }, d(this, Pe).port.postMessage({ command: "status", data: [] }); }); O(this, "subscribe", (e, r = []) => (r ? Array.isArray(r) && r.length == 0 ? r = "*" : Array.isArray(r) || (r = [r].flat()) : r = "*", d(this, Be).set(e, r), d(this, Be).size == 1 && d(this, $t).call(this), () => this.unsubscribe(e))); O(this, "unsubscribe", (e) => d(this, Be).delete(e)); if (d(me, Fe)) return d(me, Fe); } }; Fe = new WeakMap(), Pe = new WeakMap(), Be = new WeakMap(), $t = new WeakMap(), N(me, Fe, null), O(me, "getInstance", () => (d(me, Fe) || K(me, Fe, new me()), d(me, Fe))); let qt = me; const Jr = qt.getInstance(), rr = E.forwardRef(({ listCode: t, base62params: e, className: r, theme: n, themeProps: i, layouts: o, classNames: s, rowSelection: a = null, onDataSourceChange: l }, c) => { const [{ resource: u, primaryKey: p, batchOperations: m = [], itemOperations: g = [], columns: f = [], isConditionFormLayout: y = !1, isTreeSider: k, treeSiderConfig: b, theme: $, themeConfig: C, isItemGridLayout: x, itemGridLayout: { themeConfig: F, ...I } = {}, title: T, isPaginate: v, tabs: A, selectionType: P }, L] = V({ isItemGridLayout: !1, itemGridLayout: {} }), { type: M = P, selectedRowKeys: U, defaultSelectedRowKeys: Z, onChange: $e, ...q } = a ?? {}, le = di(t, e), [{ dataSource: _, itemOperationsAccess: mt, condition: cn, tab: dn, keyword: un, page: lr, total: cr, pageSize: dr, sider: pn, onConditionChange: gn, onTabChange: hn, onKeywordChange: mn, onPageChange: fn, onPageSizeChange: yn, onSiderChange: wn, onReload: Ot, payload: bn }, ur] = ci(le, t, p, u), Cn = Cr(l); Xt(() => { Cn(_, { primaryKey: p, page: lr, pageSize: dr, total: cr }); }, [_]); const [pr, kn] = Dn([], { defaultValue: Z ?? [], value: U }), [gr, Sn] = V([]), hr = H(() => M ? gr : _, [M, gr, _]), En = zt(g, mt, _, p), $n = zt(m); z(() => { let Q = null; return t && B.get(`/api/_/${t}`).resp(({ data: Le, res: Rt }) => { Le != null && Le.isDynamicRefresh && (Q = Jr.subscribe(() => Ot(), Rt)), L(Le); }).catch(() => L({})), () => Q == null ? void 0 : Q(); }, [t]), E.useImperativeHandle(c, () => ({ onReload: Ot, onClickCallback: ur, getSelectedRows: hr })); const mr = Cr((Q, Le) => { Sn((Rt) => { const fr = new Map(Rt.map((ce) => [ce == null ? void 0 : ce[p], ce])); return Le.forEach((ce) => fr.set(ce == null ? void 0 : ce[p], ce)), Q.map((ce) => fr.get(ce)).filter(Boolean); }), kn(Q), $e == null || $e(Q, Le); }), xn = W(() => M ? { columnWidth: 80, ...q, type: M, selectedRowKeys: pr, onChange: mr } : void 0, [M, pr, mr, a]), Pn = W(() => w.merge({}, C, i), [C, i]), vn = W(() => g == null ? void 0 : g.map((Q) => w.isEmpty(Q == null ? void 0 : Q.confirm) ? Q : { ...Q, confirm: Object.assign({}, Q.confirm, { getPopupContainer: () => document.body }) }), [g]), Nn = W(() => ({ ...I, themeProps: F }), [I, F]); return h(_r, { listCode: t, title: T, classNames: s, layouts: o, resource: u, primaryKey: p, theme: n || $, themeProps: Pn, isTreeSider: k, treeSiderConfig: b, isPaginate: v, rowSelection: xn, getSelectedRows: hr, tabs: A, isItemOperations: En, itemOperations: vn, isBatchOperations: $n, batchOperations: m, isItemGridLayout: x, columns: f, itemGridLayout: Nn, isConditionFormLayout: y, itemOperationsAccess: mt, dataSource: _, onConditionChange: gn, onTabChange: hn, onKeywordChange: mn, onPageChange: fn, onPageSizeChange: yn, onSiderChange: wn, condition: cn, tab: dn, keyword: un, page: lr, total: cr, pageSize: dr, sider: pn, payload: bn, className: j("ff-data-list-helper", r), onReload: Ot, onClickCallback: ur }); }), Hr = (t, e, r = !0) => r !== !0 && r-- <= 0 ? [] : w.isArray(t) && !w.isEmpty(t) ? t.reduce((n, i) => (Reflect.has(i, e) && Reflect.has(i, "children") && n.push(i[e]), Reflect.has(i, "children") && !w.isEmpty(i.children) ? n.concat(Hr(i.children, e, r)) : n), []) : [], Ci = ({ className: t, primaryKey: e, columns: r = [], dataSource: n = [], operationRender: i, operationWidth: o = 180, components: s = {}, rowSelection: a, ...l }) => { const { classNames: c } = ue(ae), u = J(null), p = J(null), [m, g] = V([]), [f, y] = V({ width: 0, height: 0 }); z(() => { g(Hr(n, e)); }, [n, e]), Fn(() => { const C = new ResizeObserver(() => { var x; y({ width: ((x = u.current) == null ? void 0 : x.nativeElement.querySelector(".ant-table-body").scrollWidth) || p.current.offsetWidth, height: p.current.offsetHeight }); }); return p.current && C.observe(p.current), () => { p.current && C.unobserve(p.current); }; }, []); const k = W(() => { if (!(f != null && f.width) || !(r != null && r.length)) return r; const C = (a ? a.columnWidth ?? 32 : 0) + (i ? o : 0), x = r.reduce((T, v) => T + (v != null && v.isWidthFixed && v.width ? v.width : 0), 0), F = r.filter((T) => !(T != null && T.isWidthFixed)).reduce((T, v) => T + ((v == null ? void 0 : v.width) ?? 100), 0); if (x + F + C >= f.width) return r; const I = f.width - x - C; return r.map((T) => T != null && T.isWidthFixed ? T : { ...T, width: Math.floor(I * ((T == null ? void 0 : T.width) ?? 100) / F) }); }, [r, f.width, a, i, o]), b = ai(k), $ = li(s); return h("div", { ref: p, className: j("ff-data-list-table", c.content, t), children: f.height ? h(kr, { bordered: !0, ...l, components: $, ref: u, rowKey: (C) => (C == null ? void 0 : C[e]) ?? Math.random(), rowSelection: a, columns: (() => { var x, F; const C = [...b ?? []]; return a && C.splice((F = (x = C[0]) == null ? void 0 : x.key) != null && F.startsWith("__") ? 1 : 0, 0, kr.SELECTION_COLUMN), i && C.push({ title: "操作", align: "center", fixed: "right", className: "ff-data-list-table-operations", width: `${Math.ceil(o / f.width * 100).toFixed(2)}%`, render: (I, T, v) => i(T, v) }), C; })(), dataSource: n, size: "middle", scroll: { x: "max-content", y: f.height - 50 }, pagination: !1, expandable: { defaultExpandAllRows: !0, expandRowByClick: !0, onExpandedRowsChange: g, expandedRowKeys: m } }) : null }); }, ki = "RC_FORM_INTERNAL_HOOKS", Si = (t) => { const [e, r] = E.useState({ items: [] }); return z(() => { t && B.get(`/api/_/${t}`).then(({ uuid: n, code: i, name: o, resource: s, primaryKey: a, marginX: l, marginY: c, cols: u, rowHeight: p, fields: m, theme: g, themeSetting: f, groups: y }) => ({ uuid: n, code: i, name: o, resource: s, primaryKey: a, marginX: l, marginY: c, cols: u, rowHeight: p, theme: g, themeProps: f, groups: y, items: m })).then(r); }, [t]), e; }, Ei = (t, { initialValue: e, initialValueLanguage: r, convertJs: n, convertJsSetting: i, type: o = "string" }, s = null) => { const a = J(!1), l = ue(Ir), [c, u] = V(), [p, m] = V(r != "javascript" && t ? l.getFieldValue(t) : void 0), { registerWatch: g } = l.getInternalHooks(ki) || {}; return z(() => g == null ? void 0 : g((f, y, k) => { if (!a.current) return; const b = w.get(y, t); w.isEqual(b, p) || m(oe(b, o)); }), [p]), z(() => { r == "javascript" && e ? ze.exec(e, {}, { getFieldValueForBasicForm: (f) => s ? s.getFieldValue(f) : l.getFieldValue(f), getFieldValue: (f) => l.getFieldValue(f) }).then((f) => m(oe(f, o))).catch((f) => notification.error({ message: `布局数据错误: ${JSON.stringify(f)}` })).finally(() => a.current = !0) : (e && m(oe(e ?? l.getFieldValue(t), o)), a.current = !0); }, [e, r]), gt(() => { a.current && n && new Ct([n, i]).toValue(p, l.getFieldsValue(!0)).then(u).catch((f) => { u(f), console.error("布局数据转换错误: ", f, n); }); }, [p, n, i]), [c ?? p, p]; }, Ro = (t, e, r = null) => W(() => tr(t, e, r), [t]), Yr = (t, e, r = {}, n = {}, i = {}, o = null) => { const s = ue(Ir), a = vt(), l = J(!0), c = J([]), [u, p] = V(e), [m, g] = V(), f = se.useWatch((y) => JSON.stringify(w.pick(y, c.current)), s) || "{}"; return Nt(() => { t && ze.exec(t, r, { ...n, getFieldValueForBasicForm: (y) => i ? i.getFieldValue(y) : null, getFieldValue: w.wrap(s.getFieldValue, (y, k) => (c.current.some((b) => w.isEqual(b, k)) || (c.current.push(k), a()), y == null ? void 0 : y(k))), isFieldTouched: s.isFieldTouched, isFieldsTouched: s.isFieldsTouched }).then((y) => { l.current && (p(y), g(null)); }).catch((y) => { l.current && (p(e), g(y)); }); }, [t, f, s, r, n]), z(() => () => l.current = !1, []), t ? [o ? oe(u, o) : u, m] : [o ? oe(e, o) : e, null]; }, $i = ({ widget: t, widgetPrefix: e = "@pkg/ff/grid-layouts", basicForm: r, ...n }) => { const i = t != null && t.startsWith("@") || t != null && t.startsWith("blob:") ? t : `${e}/${t}`, [o, s] = V(); return z(() => { i && X.getWidgetComponent(i).then(({ defaultProps: a = {}, default: l }) => ({ default: xi(l, a, r) })).catch((a) => ({ default: () => `${a}` })).then((a) => s(E.createElement(a.default, n))); }, [i]), o; }, xi = (t, e = {}, r = null) => (n) => { const { code: i, label: o, extras: s, isVirtual: a, initialValue: l, initialValueLanguage: c, convertJs: u, convertJsSetting: p, value: m, ...g } = w.merge({}, e, n), [f, y] = Ei(a ? null : i, { initialValue: l, initialValueLanguage: c, convertJs: u, convertJsSetting: p, type: (g == null ? void 0 : g.type) || "string" }, r), k = W(() => { const C = Object.keys((e == null ? void 0 : e.extras) || {}); return w.over([w.partialRight(w.pick, C), w.partialRight(w.omit, C)]); }, [e == null ? void 0 : e.extras]), [b, $] = k(g); return h(t, { ...$, value: f, rawValue: y, $setting: Object.assign({}, s, b) }); }, Gr = ({ theme: t, basicForm: e, items: r = [{ key: "default", label: "默认" }], fields: n = [], itemRender: i, chunks: o = [], children: s, $setting: a = {}, ...l }) => { const [c, u] = V(); z(() => { t ? X.getWidgetComponent(t).then((m) => { if (!(m != null && m.default)) throw "not found"; return m; }).catch((m) => ({ default: () => `${t} ${m}` })).then((m) => u(E.createElement(m.default, {}))) : u(null); }, [t]); const p = W(() => r == null ? void 0 : r.map((m) => ({ ...m, children: i(m, n == null ? void 0 : n.filter((g) => !(g != null && g.group) && m.key == "default" || g.group == m.key), m.key == "default" ? s : null) })).concat(o), [r, s, o]); return c && E.cloneElement(c, { items: p, basicForm: e, $setting: { ...a, ...l } }); }, Xr = ({ name: t, form: e = null, basicForm: r = null, style: n = {}, className: i, cols: o = 12, rowHeight: s = 21, containerPadding: a = [0, 0], itemMargin: l = [4, 0], formProps: c = {}, formFields: u = [], fields: p = [], data: m, theme: g, themeProps: f = {}, groups: y = [{ key: "default", label: "默认" }], children: k, ...b }) => { const [$] = se.useForm(e), C = W(() => [{ name: "__PROPS__", value: c }].concat(u), [c, u]); gt(() => ($.setFieldsValue(m), () => $.resetFields()), [m]); const x = (F, I, T) => { const v = tr(I, $i, r), A = qr(b); return D("div", { ...A, className: j("ff-grid-layout", i), style: { ...n, "--grid-layout-item-margin-y": `${(l == null ? void 0 : l[0]) || 0}px`, "--grid-layout-item-margin-x": `${(l == null ? void 0 : l[1]) || 0}px`, "--grid-layout-container-padding-y": `${(a == null ? void 0 : a[0]) || 0}px`, "--grid-layout-container-padding-x": `${(a == null ? void 0 : a[1]) || 0}px`, "--grid-layout-cols": o, "--grid-layout-row-height": `${s}px` }, children: [v, T && E.cloneElement(T, { cols: o, rowHeight: s, itemMargin: l, containerPadding: a, fields: I, basicForm: r })] }); }; return h(se, { ...b, fields: C, form: $, component: !1, children: g ? h(Gr, { ...f, items: y, theme: g, itemRender: x, fields: p, children: k, basicForm: r }) : x(0, p, k) }); }, Fo = /* @__PURE__ */ ((t) => function({ code: e, data: r, ...n }) { const { uuid: i, resource: o, items: s, hides: a, rowHeight: l, marginX: c, marginY: u, cols: p, theme: m, themeProps: g, groups: f } = Si(e) || {}, y = W(() => [{ name: "__RESOURCE__", value: o }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: i }], [e, i, o]); return o && h(t, { name: e, theme: m, themeProps: g, groups: f, ...n, fields: s, formFields: y, rowHeight: l, cols: p, itemMargin: [c, u], data: o ? { [o]: r } : r }); })(Xr), Pi = ({ column: t = 0, colWidth: e = 0, cols: r, rowHeight: n, itemMargin: i, containerPadding: o, fields: s, primaryKey: a, dataSource: l, beforeRender: c = null, afterRender: u = null, itemClassName: p, itemRender: m = (x, F, I) => x, empty: g = h(Bt, { description: null }), className: f, style: y = {}, theme: k, themeProps: b = {}, groups: $ = [{ key: "default", label: "默认" }], rowSelection: C }) => { const { classNames: x } = ue(ae), F = H((v) => { if (!C) return; const { selectedRowKeys: A = [], onChange: P, type: L = "checkbox" } = C, M = v == null ? void 0 : v[a]; let U; U = L === "radio" ? [M] : A.includes(M) ? A.filter((Z) => Z !== M) : [...A, M], P == null || P(U, l.filter((Z) => U.includes(Z == null ? void 0 : Z[a]))); }, [C, a, l]), I = W(() => h(Xr, { groups: $, theme: k, themeProps: b, cols: r, rowHeight: n, itemMargin: i, containerPadding: o, fields: s, className: p }), [s, r, n, i, o, $, k, b]), T = w.isEmpty(l); return D("div", { className: j("ff-data-list-content", x.content, f), style: Object.assign({}, y, t && { "--col-num": t }, e && { "--col-width": e }), children: [c == null ? void 0 : c(l), T ? g : l.map((v, A) => { var U; const P = (v == null ? void 0 : v[a]) ?? A, L = `${P}-${Ri(v)}`, M = m(E.cloneElement(I, { data: v }), v, A); return E.cloneElement(M, { key: L, ...C && { isSelected: (U = C == null ? void 0 : C.selectedRowKeys) == null ? void 0 : U.includes(P), selectionType: C.type ?? "checkbox", onSelect: () => F(v) } }); }), u == null ? void 0 : u(l)] }); }, vi = ({ component: t, $props: e }) => { const { base62params: r } = Pt(e, {}); return h(re, { children: h(rr, { listCode: t, base62params: B.decode(r) }) }); }, jo = () => h(Zr, {}), Zr = () => "Empty", Ni = ({ component: t, $setting: e, $props: r }) => { const [n, i] = V(), [o, s] = nn(r); return z(() => { if (!t) return i(h(Zr, { description: null })); X.getWidgetComponent(t).catch((a) => ({ default: () => `${a}` })).then((a) => E.createElement(a.default, { $setting: e })).then(i); }, [t]), n ? E.cloneElement(n, { ...o, $setProps: s }) : null; }, Ao = () => "NotFoundPage"; var je, de, Ae, we, ot, st; const fe = class fe { constructor() { N(this, de, /* @__PURE__ */ new Map()); N(this, Ae, {}); N(this, we, null); O(this, "init", (e, r) => { K(this, de, e), K(this, Ae, r); }); O(this, "get", (e) => (d(this, de).has(e) || (e = Array.from(d(this, de).keys()).find((r) => d(this, de).get(r).uri === e)), d(this, de).get(e) || {})); O(this, "redirect", (e, r, n = {}) => { var f; const { uri: i, type: o, widgetProps: s } = this.get(e) || {}, { router: a, query: l, ...c } = r || {}, u = Object.assign({}, c, a), p = Object.assign({}, c, l); o == "list" && (u.base62params = B.encode(u != null && u.base62params ? u.base62params : u)); let m = Hn(i || e, u); const g = new URLSearchParams(); for (const y in s || {}) ((f = s[y]) == null ? void 0 : f.type) == "query" && Object.has(p, y) && g.append(y, JSON.stringify(p[y])); return g.size > 0 && (m = `${m}?${g.toString()}`), n != null && n.isOpenWindow ? window.open(m) : d(this, we).navigate(m, { replace: !!(n != null && n.isReplaceRouteHistory) }); }); O(this, "getMenus", (e) => { var r; return ((r = d(this, Ae)) == null ? void 0 : r[e]) || []; }); O(this, "findMenuPathByUuid", (e) => { let r = []; for (const n in d(this, Ae)) if (r = d(this, ot).call(this, d(this, Ae)[n], e, [n]), r.length > 1) return r; return r; }); O(this, "getMenusByRouteUuid", (e) => d(this, st).call(this, e, Object.values(d(this, Ae)).flat())); N(this, ot, (e, r, n = []) => { if (w.isEmpty(e)) return n; for (const { uuid: i, children: o } of e) { if (i == r) return n.concat(i); if (!w.isEmpty(o)) return n.concat(i, d(this, ot).call(this, o, r)); } return n; }); N(this, st, (e, r) => { var i; let n = []; for (const o of r) o.widgetType == "redirect" && (o.uuid == e || o.widget == e ? n.push(o) : (i = o.children) != null && i.length && (n = n.concat(d(this, st).call(this, e, o.children)))); return n; }); O(this, "getCurrentMenu", () => { const { uuid: e } = this.getCurrentRoute() || {}; if (!e) return; const r = this.getMenusByRouteUuid(e); return w.isEmpty(r) ? void 0 : r[0]; }); O(this, "getCurrentRoute", (e = 0) => { var n; const r = (n = d(this, we).state.matches[d(this, we).state.matches.length - 1 - e]) == null ? void 0 : n.route; if (!r) return null; for (let [i, o] of d(this, de)) if (o.uri === r.path) return o; return null; }); O(this, "getPageParams", (e) => { var s, a; const { location: r = {}, matches: n = [] } = ((s = d(this, we)) == null ? void 0 : s.state) || {}, i = { ...((a = n[n.length - 1]) == null ? void 0 : a.params) || {} }, o = r.search; return o && new URLSearchParams(o).forEach((l, c) => { i[c] = l; }), e ? w.get(i, e) : i; }); O(this, "usePageParams", (e) => { var n; let r = Lr() ? { ...Yn(), ...Object.fromEntries(new URLSearchParams(((n = Gn()) == null ? void 0 : n.search) ?? "")) } : this.getPageParams(); return e ? w.get(r, e) : r; }); O(this, "createBrowserRouter", (e = {}) => { if (d(this, de).size == 0) return null; if (d(this, we)) return d(this, we); const r = We.get("Common.WEBSITE_DEFAULT_THEME", "@pkg/ff/frameworks/DefaultTheme"), n = We.get(X.checkUserToken() ? "Common.WEBSITE_LOGIN_REDIRECT" : "Common.WEBSITE_DEFAULT", "/index"), i = { [r]: 0 }, o = (a, l) => () => Promise.all([X.getWidgetComponent(a), Pt(l)]).then(([c, u]) => [c.default || function() { return `${a}`; }, u]).then(([c, u]) => ({ Component: () => E.createElement(Vr, {}, E.createElement(c, { $setting: u })) })), s = Array.from(d(this, de).values()).reduce((a, { uuid: l, uri: c, name: u, type: p, component: m, widgetSetting: g, widgetProps: f, isLogin: y, isLayout: k, extra: b }) => { let $ = {}, C = 0; switch (p) { case "list": $.element = E.createElement(vi, { component: m, $props: f }); break; case "fsdpf-component": $.element = E.createElement(Ni, { key: c, component: m, $setting: g, $props: f }); } const x = (b == null ? void 0 : b.theme) ?? (b == null ? void 0 : b.layout); if (x) { const F = (b == null ? void 0 : b.themeProps) ?? (b == null ? void 0 : b.layoutProps); if (!i[x]) return i[x] = a.length, [...a, { path: "/", lazy: o(x, F), children: [{ path: c, ...$ }] }]; C = i[x]; } return k && C > -1 ? (a[C].children.push({ path: c, ...$ }), a) : [...a, { path: c, ...$ }]; }, [{ path: "/", lazy: o(r, {}), children: [] }]); return s.push({ index: !0, element: E.createElement(Ti, { to: n, replace: !0 }) }), K(this, we, Xn(s, e)); }); if (d(fe, je)) return d(fe, je); } }; je = new WeakMap(), de = new WeakMap(), Ae = new WeakMap(), we = new WeakMap(), ot = new WeakMap(), st = new WeakMap(), N(fe, je, null), O(fe, "getInstance", () => (d(fe, je) || K(fe, je, new fe()), d(fe, je))); let Kt = fe; const Ti = ({ to: t, replace: e }) => Lr() ? E.createElement(Zn, { to: t, replace: e }) : (window.document.location = t, "redirect"), Se = Kt.getInstance(); Qt.chainableTypes = [In]; const ze = Qt.getInstance(new URL("/ff-worker-pipe/worker.js", self.location), { type: "module" }); Qt.fns = { http: Object.fromEntries(["get", "post", "put", "del", "list", "decode", "encode", "cache", "refreshCache"].map((t) => [t, (...e) => B[t](...e)])), generateUUID: () => Ai(), user: { logout: () => X.logout(() => window.location.replace(We.get("Common.WEBSITE_LOGIN_PAGE", "/index"))), getUserInfo: (t = !0) => X.getUserInfo(t), checkUserToken: () => X.checkUserToken(), getUserToken: () => X.getUserToken() }, getConfigure: (t) => We.get(t), route: Object.fromEntries(["redirect", "getPageParams", "getCurrentRoute", "get", "getMenus", "findMenuPathByUuid"].map((t) => [t, (...e) => Se[t](...e)])), popup: Object.fromEntries(["notification", "success", "error", "form", "modal", "confirm"].map((t) => [t, (...e) => Ee[t](...e)])) }; const Pr = { null2json: (t) => Object.create(), null2array: (t) => [], null2number: (t) => 0, null2bool: (t) => !1, null2string: (t) => "", null2integer: (t) => 0, null2float: (t) => 0, string2json: (t) => t ? JSON.parse(t) : "{}", string2array: (t) => t.substr(0, 1) === "[" && t.substr(-1) === "]" ? JSON.parse(t) : t.split(","), string2number: (t) => t == "" ? 0 : +t, string2integer: (t) => t == "" ? 0 : +t, string2float: (t) => t == "" ? 0 : +t, string2bool: (t) => { switch (`${t}`.toLowerCase()) { case "0": case "false": case "[]": case "{}": return !1; } return !!t; }, string2string: (t) => t, json2json: (t) => t, json2array: (t) => t ? Object.values(t) : [], json2number: (t) => Object.keys(t).length, json2integer: (t) => Object.keys(t).length, json2float: (t) => Object.keys(t).length, json2bool: (t) => Object.keys(t).length > 0, json2string: (t) => t ? JSON.stringify(t) : "", array2json: (t) => ({ ...t }), array2array: (t) => t, array2number: (t) => t.length, array2integer: (t) => t.length, array2float: (t) => t.length, array2bool: (t) => t.length > 0, array2string: (t) => JSON.stringify(t), number2json: (t) => ({}), number2array: (t) => [t], number2number: (t) => t, number2integer: (t) => t, number2float: (t) => t, number2bool: (t) => !!t, number2string: (t) => t.toString(), boolean2json: (t) => ({}), boolean2array: (t) => [], boolean2number: (t) => +t, boolean2integer: (t) => +t, boolean2float: (t) => +t, boolean2bool: (t) => t, boolean2string: (t) => t ? "true" : "false" }, oe = (t, e) => { let r = "string"; r = Array.isArray(t) ? "array" : typeof t, w.isObject(t) && (r = "json"); const n = `${r}2${e}`; return Reflect.has(Pr, n) ? Pr[n](t) : t; }, Oi = (t) => t === null ? "null" : Array.isArray(t) ? "array" : typeof t == "object" ? "json" : typeof t == "boolean" ? "bool" : typeof t == "string" ? "string" : typeof t == "number" ? Number.isInteger(t) ? "integer" : "float" : typeof t, Pt = (t = {}, e = {}, r = {}, n = "") => Qr(t, (i, o) => o === "type" && i === "code") ? en(t, e, r, n) : tn(t, e, n), Qr = (t, e = () => !1) => w.some(t, (r) => !!w.some(r, e) || (w.isEmpty(r) || !w.isPlainObject(r) && !w.isArray(r) ? void 0 : Qr(r, e))), en = async (t = {}, e = {}, r = {}, n = "") => { let i = /* @__PURE__ */ Object.create(null); for (let o in t) { let s; if (Reflect.has(t[o], "type") && ["code", "field", "router", "query", "string"].includes(t[o].type)) { const { type: a, value: l = "", default: c = n } = t[o]; switch (a) { case "code": try { s = await ze.exec(l, e, r); } catch (u) { console.error("getWidgetPropsData", u); } break; case "field": s = w.get(e, l) ?? w.get(e, l.substring(l.indexOf(".") + 1)); break; case "router": case "query": s = Se.getPageParams(l); break; case "string": s = l; } s ?? (s = c); } else s = await en(t[o], e, r, n); w.set(i, o, s); } return i; }, tn = (t = {}, e = {}, r = "") => Object.keys(t || {}).reduce((n, i) => { if (w.isPlainObject(t[i])) { let o; if (Reflect.has(t[i], "type") && ["field", "router", "query", "string"].includes(t[i].type)) { const { type: s, value: a = "", default: l = r } = t[i]; switch (s) { case "field": o = w.get(e, a) ?? w.get(e, a.substring(a.indexOf(".") + 1)); break; case "router": case "query": o = Se.getPageParams(a); break; case "string": o = a; } o ?? (o = l); } else o = tn(t[i], e, r); w.set(n, i, o); } return n; }, {}), jt = (t, e) => t && typeof t == "object" ? Array.isArray(t) ? t.map((r) => jt(r, e)) : Object.keys(t).reduce((r, n) => (e[n] ? r[e[n]] = jt(t[n], e) : r[n] = jt(t[n], e), r), {}) : t, Io = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => { const e = 16 * Math.random() | 0; return (t === "x" ? e : 3 & e | 8).toString(16); }), Lo = (t) => { var e, r; return t ? (r = (e = t.match(/^@pkg(?:[^\/]*\/){3}(?[^\/]+)/)) == null ? void 0 : e.groups) == null ? void 0 : r.name : ""; }, Vo = (t) => { var e, r; return t ? (r = (e = t.match(/^@pkg(?:[^\/]*\/){2}(?[^\/]+)/)) == null ? void 0 : e.groups) == null ? void 0 : r.category : ""; }, Do = (t) => { var e, r; return t ? (r = (e = t.match(/^@pkg(?:[^\/]*\/){1}(?[^\/]+)/)) == null ? void 0 : e.groups) == null ? void 0 : r.owner : ""; }, Ri = (t, e = 32, r = "auto") => { const n = _t(t), i = r === "auto" ? "x64" : r; if (e === 32) return Ft.x86.hash32(n).toString(); if (e === 128) return i === "x64" ? Ft.x64.hash128(n) : Ft.x86.hash128(n); throw new Error("bits 只能是 32 或 128"); }, _t = (t) => t == null ? "null" : typeof t == "string" ? t : typeof t == "number" || typeof t == "boolean" ? String(t) : typeof t == "function" ? t.toString() : Array.isArray(t) ? "[" + t.map(_t).join(",") + "]" : typeof t == "object" ? "{" + Object.keys(t).sort().map((e) => `${e}:${_t(t[e])}`).join(",") + "}" : String(t), Fi = () => { let t = 1; const e = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new Map(); return (...n) => n.length === 0 ? "" : n.map((i) => { return String((o = i) === null || typeof o != "object" && typeof o != "function" ? (r.has(o) || r.set(o, t++), r.get(o)) : (e.has(o) || e.set(o, t++), e.get(o))); var o; }).join("::"); }, ji = (t) => { if (!t || typeof t != "string" || t.startsWith("/") || t.startsWith("./") || t.startsWith("../")) return !1; try { let e = t.startsWith("//") ? `http:${t}` : t; return e.includes("://") || e.startsWith("//") || (e = `http://${e}`), !!new URL(e).hostname; } catch { return !1; } }, Mo = (t, e = "") => { if (!t || typeof t != "string" || ji(t)) return t; let r = e; return !r && typeof window < "u" && window.location && (r = `${window.location.protocol}//${window.location.host}`), t.startsWith("/") ? r ? `${r}${t}` : t : r ? `${r}/${t}` : t; }, Ai = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : typeof crypto < "u" && crypto.getRandomValues ? "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (t) => (+t ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +t / 4).toString(16)) : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => { const e = 16 * Math.random() | 0; return (t === "x" ? e : 3 & e | 8).toString(16); }), vt = () => { const t = J(!0), [, e] = E.useReducer((r) => r + 1, 0); return z(() => () => t.current = !1, []), () => t.current && e(); }, Bo = (t) => { const [e, r] = V(t), n = J(null), i = H((o, s) => { n.current = s, r(o); }, []); return z(() => { n.current && (n.current(e), n.current = null); }, [e]), [e, i]; }, gt = (t = (n) => { }, e, r = w.isEqual) => { const n = E.useRef(); r(e, n.current) || (n.current = w.cloneDeep(e)), E.useEffect(t, [n.current]); }, Nt = gt, rn = (t, e = "string") => { var r; if (!Array.isArray(t)) return t; for (let n = 0; n < t.length; n++) t[n].value = oe((r = t[n]) == null ? void 0 : r.value, e), t[n] && Reflect.has(t[n], "children") && (t[n].children = rn(t[n].children, e)); return t; }, Uo = (t, e = "json", r = "string", n = null, i = null) => { const [o] = se.useForm(n), [s, a] = V([{ label: "无", value: "", disabled: !0 }]), l = J([]), c = se.useWatch((u) => l.current.length === 0 ? null : w.pick(u, l.current), o) || null; return z(() => { Array.isArray(t) ? a(t) : e === "javascript" && t ? ze.exec(t, {}, { getFieldValue: (u) => (l.current.includes(u) || l.current.push(u), o.getFieldValue(u)), getFieldValueForBasicForm: (u) => (l.current.includes(u) || l.current.push(u), i ? i.getFieldValue(u) : o.getFieldValue(u)) }).then((u) => { a(oe(u, "array")); }).catch((u) => console.error("useOptions", u)) : t && a(oe(t, "array")); }, [t, e, c]), rn(s, r); }, Wo = (t) => { const [e, r] = V(), n = { type: "GET" }; if (typeof t == "string" ? n.url = t : w.isPlainObject(t) && Object.assign(n, t), !(n != null && n.url)) throw "url is required"; const i = (o) => B.request(n, !1).resp((s) => (console.log("useSubscribeRequest", o), r(s), s)); return gt(() => { let o = null; return i().then((s) => { o = Jr.subscribe(w.throttle(i, 180, { leading: !1, trailing: !0 }), s.res); }), () => o == null ? void 0 : o(); }, n), e; }, Ii = (t, e) => H((r) => { const n = {}; for (const [i, o] of Object.entries(r)) { const s = t == null ? void 0 : t[i]; if ((s == null ? void 0 : s.type) === "router" || (s == null ? void 0 : s.type) === "query") { const a = Se.getCurrentRoute(); a != null && a.uuid && Se.redirect(a.uuid, { ...Se.getPageParams(), [s.type]: { [s.value || i]: o } }, { isReplaceRouteHistory: !0 }); } else n[i] = o; } Object.keys(n).length > 0 && e(n); }, [t, e]), nn = (t, e = {}, r = {}, n = []) => { const [i, o] = V({}), [s, a] = V({}), l = Ar(s), c = Se.usePageParams(); Gt(() => { Promise.resolve(Pt(t, e, r)).then(a); }, [t, e, c, ...n]), Xt(() => { const m = l ?? {}, g = Object.keys({ ...m, ...s }).reduce((f, y) => (m[y] !== s[y] && (f[y] = s[y]), f), {}); Object.keys(g).length > 0 && o((f) => ({ ...f, ...g })); }, [s]); const u = Ii(t, (m) => { o((g) => ({ ...g, ...m })); }), p = W(() => Object.fromEntries(Object.entries(i).filter(([m, g]) => g !== s[m])), [i, s]); return [i, u, p]; }, Li = (t) => { const [e, r] = E.useState({ items: [], hides: [] }); return E.useEffect(() => { t && B.get(`/api/_/${t}`).then(({ pk: n, uuid: i, code: o, resource: s, align: a, cols: l, rowHeight: c, marginX: u, marginY: p, listenChangeFields: m, listenChangeFieldsFunc: g, fields: f, theme: y, themeSetting: k, groups: b }) => ({ pk: n, uuid: i, code: o, resource: s, align: a, cols: l, rowHeight: c, marginX: u, marginY: p, theme: y, themeProps: k, groups: b, listenChangeFields: m, listenChangeFieldsFunc: g, ...f.reduce(($, C) => { var x; return (x = C == null ? void 0 : C.field) != null && x.hidden ? $.hides.push(C == null ? void 0 : C.field) : $.items.push(C), $; }, { items: [], hides: [] }) })).then(r); }, [t]), e; }, Vi = ({ max: t = 0, min: e = 0, type: r = "", message: n, pattern: i, required: o = !1, validator: s } = {}, a, l) => { const [c, u] = V([]); return z(() => { const p = []; if (o) { let m = l; switch (l) { case "number": case "string": case "array": break; case "bool": m = "boolean"; break; case "json": m = "object"; } p.push({ type: m, required: !0, whitespace: !0, message: "该项必填" }); } switch (r) { case "string": p.push({ type: r, max: t, min: e, message: n || (e && t ? `字符必须在 ${e} ~ ${t} 之间` : `${t ? "最多能有" : "最少要有"} ${e || t} 个字符`) }); break; case "pattern": p.push({ type: "string", pattern: i, message: n }); break; case "validator": s && p.push(({ getFieldValue: m }) => ({ validator: async (g, f) => { const y = await ze.exec(s, { value: f, fieldName: a }, { getFieldValue: m }); return w.isString(y) && y ? Promise.reject(y) : w.isBoolean(y) && !y ? Promise.reject(n) : Promise.resolve(); } })); } u(p); }, [t, e, r, n, i, o, s]), c; }, Di = (t, e, r) => { const [n, i] = V(null); return z(() => { const { initDataUri: o = `/api/${t}`, initDataMethod: s = "GET" } = r || {}; e && B.request({ method: s, url: w.trimEnd(`${o}/${e}`, "/") }).then((a) => { i(a); }); }, [t, e, r]), n; }, Mi = (t, e, r) => H((n, i = { serialize: (o) => o, onSuccess: () => { }, onFail: (o) => (o == null ? void 0 : o.errorFields) && Ee.error("请先完善表单信息", { duration: 2e3 }) }) => { const o = n.getFieldValue("__RESOURCE__"), { submitDataUri: s = `/api/${t}`, submitDataMethod: a = "POST" } = r || {}; return n.validateFields().then((l) => o ? w.pick(l, [o]) : l).then(i.serialize).then((l) => B.request({ method: a, url: w.trimEnd(`${s}/${e || ""}`, "/"), data: l }).msg(i.onSuccess)).catch(i.onFail); }, [t, e, r]), Bi = (t, e, r, n) => { const i = Di(e, r, n); z(() => { i ? t.setFieldsValue(i) : t.resetFields(); }, [t, i]); const o = Mi(e, r, n); return w.partial(o, t); }, Ui = (t, e, r = [], n = {}) => { const i = J({}), o = J(), s = w.debounce(vt(), 180), a = ["disabled", "required"], l = (m, g) => { a.includes(m) && (i.current[m] = g), s(); }, c = W(() => ({ setDisabled: (m) => l("disabled", m), setRequired: (m) => l("required", m), getDisabled: () => i.current.disabled, getRequired: () => i.current.required }), [e]), [u, p] = Yr(e, -1, {}, c, n); if (!p && o.current != u && (u >= 0 || !w.isEmpty(r == null ? void 0 : r[u]))) { o.current = u; const { widget: m, widgetPrefix: g, props: f } = r == null ? void 0 : r[u]; t = Br(m, g), i.current = w.merge(f, w.pick(i.current, a)); } return [t, i.current]; }, vr = (t) => t === void 0 || t === !1 ? "" : (Array.isArray(t) ? t : [t]).join("_"), zo = ({ value: t, onChange: e }, r = null) => { const n = J(), [i] = se.useForm(r), o = J({}); return Nt(() => { w.isEqual(n.current, t) || i.setFieldsValue(t); }, [t]), z(() => () => i.resetFields(), []), [W(() => i.__INTERNAL__ ? i : { ...i, __INTERNAL__: { itemRef: (s) => (a) => { const l = vr(s); a ? o.current[l] = a : delete o.current[l]; } }, scrollToField: (s, a = {}) => { console.warn("useMergedFormValuesChange scrollToField not work, unreferenced antd form"); }, focusField: (s) => { console.warn("useMergedFormValuesChange focusField not work, unreferenced antd form"); }, getFieldInstance: (s) => { const a = vr(s); return o.current[a]; } }, [i]), (s, a) => { n.current = a, e == null || e(a); }]; }, qo = (t, e) => { const r = oe(w.isEmpty(t) ? [] : t, "array"), n = J([]), i = J(0), o = () => "row-" + i.current++; return n.current.length !== r.length && (n.current = Array.from({ length: r.length }, (s, a) => n.current[a] ?? o())), { items: r, keyAt: (s) => n.current[s], append: (...s) => { n.current = ie(n.current, { $push: s.map(o) }), e(ie(r, { $push: s })); }, prepend: (...s) => { n.current = ie(n.current, { $unshift: s.map(o) }), e(ie(r, { $unshift: s })); }, insert: (s, ...a) => { n.current = ie(n.current, { $splice: [[s, 0, ...a.map(o)]] }), e(ie(r, { $splice: [[s, 0, ...a]] })); }, remove: (...s) => { const a = new Set(s); n.current = n.current.filter((l, c) => !a.has(c)), e(r.filter((l, c) => !a.has(c))); }, clear: () => { n.current = [], e([]); }, update: (s, a) => e(ie(r, { [s]: { $set: a } })), reset: (s) => { e(oe(w.isEmpty(s) ? [] : s, "array")); }, swap: (s, a) => { n.current = ie(n.current, { [s]: { $set: n.current[a] }, [a]: { $set: n.current[s] } }), e(ie(r, { [s]: { $set: r[a] }, [a]: { $set: r[s] } })); }, move: (s, a) => { n.current = ie(n.current, { $splice: [[s, 1], [a, 0, n.current[s]]] }), e(ie(r, { $splice: [[s, 1], [a, 0, r[s]]] })); } }; }, nr = ({ widget: t = "Input", widgetPrefix: e = "@pkg/ff/grid-layout-forms", widgetDecorator: r, subWidgets: n = [], basicForm: i, ...o }) => { const s = Br(t, e), [a, l] = Ui(s, r, n, i), [c, u] = V(); return z(() => { a && X.getWidgetComponent(a).then(({ defaultProps: p = {}, default: m }) => ({ default: Wi(m, p, i) })).catch((p) => ({ default: () => `${p}` })).then((p) => u(E.createElement(p.default, o))); }, [a]), c && E.cloneElement(c, { ...o, ...l }); }, Wi = (t, e = {}, r = null) => (n) => { const { type: i, code: o, label: s, noStyle: a, style: l, placeholder: c, required: u = !1, extras: p, validators: m, help: g, isVirtual: f, $isReserved: y, initialValue: k, initialValueLanguage: b, ...$ } = w.omit(w.merge({}, e, n), ["convertJs", "convertJsSetting", "widget", "widgetPerfix", "widgetDecorator", "subWidgets", "boxStyle"]), C = Vi(Object.assign({}, m, u ? { required: !0 } : {}), o, i), x = W(() => { const A = Object.keys((e == null ? void 0 : e.extras) || {}); return w.over([w.partialRight(w.pick, A), w.partialRight(w.omit, A)]); }, [e == null ? void 0 : e.extras]), [F, I] = x($), T = { label: s, noStyle: a, style: l, colon: !1, layout: "vertical" }, v = H((A) => A == null ? void 0 : oe(A, i), [i]); return h(Zt, { name: o, rules: C, initialValue: v(k), normalize: v, children: (A, P, L) => { var M; return h(t, { type: i, rcform: L, basicForm: r, itemProps: { validateStatus: P.errors.length > 0 ? "error" : "success", tooltip: g || null, help: P.errors.length > 0 ? P.errors.join("、") : null, required: ((M = C == null ? void 0 : C[0]) == null ? void 0 : M.required) || !1, ...T }, fieldProps: { placeholder: c, ...I, ...A }, $setting: Object.assign({}, p, F) }); } }); }, ir = ({ name: t, form: e = null, basicForm: r = null, style: n = {}, className: i, cols: o = 24, rowHeight: s = 16, itemMargin: a = [8, 16], containerPadding: l = [0, 0], fields: c = [], hides: u = [], primaryKey: p = 0, formProps: m = {}, formFields: g = [], listenChangeFields: f, listenChangeFieldsFunc: y, onValuesChange: k, theme: b, themeProps: $ = {}, groups: C = [{ key: "default", label: "默认" }], children: x, ...F }) => { const [I] = se.useForm(e), T = H((P, L) => { k == null || k(P, L), y && Array.isArray(f) && ze.exec(y, { changedValues: P, allValues: L }, { getFieldValue: I.getFieldValue, setFieldValue: I.setFieldValue, setFieldsValue: I.setFieldsValue, isFieldTouched: I.isFieldTouched, isFieldsTouched: I.isFieldsTouched }).catch((M) => console.error("onFormValuesChange", t, M)); }, [t, I, k, f, y]), v = W(() => [{ name: "__PROPS__", value: m }, { name: "__PRIMARY_KEY__", value: p }].concat(g), [p, m, g]), A = (P, L, M) => { const U = tr(L, nr, r), Z = qr(F); return D("div", { ...Z, className: j("ff-grid-layout-form", i), style: { ...n, "--grid-layout-item-margin-x": `${(a == null ? void 0 : a[0]) ?? 8}px`, "--grid-layout-item-margin-y": `${(a == null ? void 0 : a[1]) ?? 16}px`, "--grid-layout-container-padding-y": `${(l == null ? void 0 : l[0]) || 0}px`, "--grid-layout-container-padding-x": `${(l == null ? void 0 : l[1]) || 0}px`, "--grid-layout-cols": o, "--grid-layout-row-height": `${s}px` }, children: [U, M && E.cloneElement(M, { cols: o, rowHeight: s, itemMargin: a, containerPadding: l, fields: L, basicForm: r })] }); }; return D(se, { ...F, form: I, fields: v, onValuesChange: T, children: [b ? h(Gr, { ...$, items: C, theme: b, itemRender: A, fields: c, children: x, basicForm: r }) : A(0, c, x), u == null ? void 0 : u.map((P) => { var L; return h(Zt, { name: P.code, children: h(zi, { form: I, basicForm: r, name: P.code, type: P.type, initialValue: P.initialValue, initialValueLanguage: (L = P.extras) == null ? void 0 : L.initialValueLanguage }) }, JSON.stringify(P.code)); })] }); }, zi = ({ type: t, initialValue: e, initialValueLanguage: r, onChange: n, basicForm: i }) => { const [o, s] = Yr(r == "javascript" && e, r == "javascript" ? void 0 : e, {}, {}, i); return z(() => { r == "javascript" ? n(oe(o, t)) : e && n(oe(e, t)); }, [t, e, o]), null; }; ir.propTypes = { fields: S.array, hides: S.array }; const qi = /* @__PURE__ */ ((t) => ({ code: e, isPreview: r = !1, ...n }) => { const { align: i, autoComplete: o, resource: s, items: a, hides: l, rowHeight: c, marginX: u, marginY: p, cols: m, listenChangeFields: g, listenChangeFieldsFunc: f, pk: y, uuid: k, theme: b, themeProps: $, groups: C } = Li(e), x = W(() => [{ name: "__PK__", value: y }, { name: "__RESOURCE__", value: s }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: k }], [y, e, k, s]); return h(t, { name: e, autoComplete: o, theme: b, themeProps: $, groups: C, ...n, formFields: x, listenChangeFields: g, listenChangeFieldsFunc: f, fields: a, hides: l, cols: m, rowHeight: c, itemMargin: [u, p] }); })(ir), on = ({ $setting: t, $close: e, extras: r, code: n, primaryKey: i, ...o }) => { const [s] = se.useForm(), a = Bi(s, n, i, t); return h(re, { actions: D(E.Fragment, { children: [h(R, { name: (t == null ? void 0 : t.okText) || "保存", type: "primary", widget: () => a({ onSuccess: e }) }), h(R, { name: (t == null ? void 0 : t.cancelText) || "取消", widget: () => e(!1) })] }), extras: r, children: h(qi, { form: s, code: n, primaryKey: i, ...o }) }); }, Nr = /* @__PURE__ */ new Set(), Jt = (t = [], e = 0) => { const r = t[e]; if (r.length && !Nr.has(r)) { const n = document.createElement("script"); n.setAttribute("src", r), n.setAttribute("data-namespace", r), t.length > e + 1 && (n.onload = () => { Jt(t, e + 1); }, n.onerror = () => { Jt(t, e + 1); }), Nr.add(r), document.body.appendChild(n); } }, kt = ({ className: t, type: e, style: r = {}, rotate: n, spin: i, twoToneColor: o, compact: s, ...a }) => h("span", { role: "img", className: j("ff-iconfont", s && "ff-iconfont--compact", t), style: r, ...a, children: h("svg", { style: { width: "1em", height: "1em", fill: "currentColor", overflow: "hidden", ...n != null && { transform: `rotate(${n}deg)` }, ...i && { animation: "ff-iconfont-spin 1s linear infinite" }, ...o && { "--ff-icon-second-color": o } }, viewBox: "0 0 1024 1024", children: h("use", { xlinkHref: `#${e}` }) }) }); kt.propTypes = { className: S.string, type: S.string.isRequired, style: S.object }, kt.init = Jt; const Ki = (t, e, r, n) => Se.redirect(r, e, n), _i = (t, e = {}, r, n = {}) => { var o; const i = (o = n.router) == null ? void 0 : o.reduce((s, [a, l, c]) => { const u = w.get(e, ["router", a]); if (!u && u !== 0 && l) throw `请传入 ${c}`; return `${s}/${u}`; }, `/api/${r}`); return B.del(i, e.param).msg(); }, Tr = (t, e, r, { status: { loading: n, disabled: i }, setStatus: o, listFn: s }) => { const a = { loading: (l) => l === void 0 ? n : o((c) => ({ ...c, loading: l })), disabled: (l) => l === void 0 ? i : o((c) => ({ ...c, disabled: l })), list: s }; return w.isFunction(r) ? r.call(null, e, a) : w.isString(r) && r ? ze.exec(r, e, a) : null; }, Or = (t, e, r, n, i) => w.isString(r) && r ? X.getWidgetComponent(r).then(({ default: o }) => Ee.modal(o, { ...e, $setting: n }, i != null && i.title ? { ...i, title: w.template(i.title)(t) } : i)).catch((o) => { Ee.error(r, { content: o.toString() }); }) : Ee.modal(r, { ...e, $setting: n }, i != null && i.title ? { ...i, title: w.template(i.title)(t) } : i), Ji = (t, e, r, n, i) => Ee.modal(on, { ...e, $setting: n, code: r }, i != null && i.title ? { ...i, title: w.template(i.title)(t) } : i), Hi = (t, e, r, n, i) => Ee.modal(rr, { ...n, base62params: e, listCode: r }, i != null && i.title ? { ...i, title: w.template(i.title)(t) } : i), Yi = ({ widget: t, widgetType: e, widgetData: r, widgetProps: n, widgetSetting: i, widgetContainerProps: o }, { onAfterClick: s, onBeforeClick: a } = {}) => { const l = ue(ae), [c, u] = V({ leading: !0, trailing: !1 }), p = J(null), [m, g] = W(() => { switch (e) { case "redirect": return [w.partialRight(Ki, t, i), null]; case "func": return [w.partialRight(Tr, (i == null ? void 0 : i.code) ?? t, { status: c, setStatus: u, listFn: l }), null]; case "component": case "fsdpf-component": return [w.partialRight(Or, t, i, o), (y) => ({ $setting: y })]; case "grid-layout-form": return [w.partialRight(Ji, t, i, o), (y) => ({ $setting: y })]; case "data-list": return [w.partialRight(Hi, t, i, o), (y) => y]; case "destroy": return [w.partialRight(_i, t, i, o), null]; default: if (sr(t) || E.isValidElement(t)) return [w.partialRight(Or, t, i, o), (y) => ({ $setting: y })]; if (w.isFunction(t)) return [w.partialRight(Tr, (i == null ? void 0 : i.code) || t, { status: c, setStatus: u }), null]; } return [(...y) => console.error("useButton unknown widgetType", e, ...y), null]; }, [t, e, i, o, l.getBase62params, l.getSelectedRows]), f = w.debounce((y) => (a == null || a(y), Promise.resolve(Pt(n, y, { list: l })).then((k) => { const b = m(y, { ...r, ...k }); return b != null && b.update && g && (p.current = ($, C) => b.update(g($), C)), b; }).then((k) => s == null ? void 0 : s(k)).catch(console.error)), 300, { leading: !0, trailing: !1 }); return Xt(() => { var y; (y = p.current) == null || y.call(p, i, o); }, [i, o]), [f, c]; }, sn = ({ type: t, name: e, className: r, icon: n, iconPosition: i, size: o }, s = "default") => W(() => { const a = { type: "primary", className: j("ff-button", r), iconPosition: i, size: o }; return t === "danger" ? a.danger = !0 : t === "default" && (a.type = t), s === "link" || s === "dashed" ? (a.type = s, t === "default" && (a.className = j(a.className, "ff-default"))) : s !== "circle" && s !== "round" || (a.shape = s), n && (a.icon = h(kt, { type: n })), e && (a.children = e), a; }, [s, t, r, n, i]), Tt = ({ data: t, widget: e, widgetType: r = "fsdpf-component", widgetData: n, widgetProps: i, widgetSetting: o, widgetContainerProps: s, onAfterClick: a, onBeforeClick: l, children: c, extras: u }) => { const p = ue(ae), [m, g] = V(!1), [f, y] = V("hover"), [k, b] = nn(i, t, { list: p }, [p.getBase62params, p.getSelectedRows]), [$, C] = V(), { placement: x, align: F, zIndex: I, arrow: T = { pointAtCenter: !0 }, getPopupContainer: v, isPopupMountBodyContainer: A = !0, ...P } = s || {}; z(() => { r == "grid-layout-form" ? C(E.createElement(on, { ...n, $setting: o, code: e })) : r == "data-list" ? C(E.createElement(rr, { base62params: t, $setting: o, listCode: e })) : w.isString(e) ? X.getWidgetComponent(e).then(({ default: U }) => { C(E.createElement(U, { ...n, $setting: o })); }).catch((U) => C(U.toString())) : E.isValidElement(e) ? C(E.cloneElement(e, { ...n, $setting: o })) : (sr(e) || w.isFunction(e) && ["component", "fsdpf-component"].includes(r)) && C(E.createElement(e, { ...n, $setting: o })); }, [e, r, n]); const L = (U, Z = !1) => (g(U), !U && y("hover"), U ? l == null ? void 0 : l(k) : a == null ? void 0 : a(Z)), M = (U) => { g(!0), y("click"); }; return h(zn, { zIndex: I, placement: x, onPopupClick: M, onClick: M, open: m, align: F, arrow: T, trigger: f, getPopupContainer: v || A ? void 0 : (U) => U, content: h(Gi, { ...P, extras: u, children: $ && E.cloneElement($, { ...k, $setProps: b, $close: (U) => L(!1, U) }) }), children: c, onOpenChange: L }); }, Gi = ({ title: t, className: e, classNames: r, children: n, extras: i, width: o, height: s, style: a, ...l }) => { const [c, u] = V({}), p = H((y, k) => u((b) => ({ ...b, [y]: k })), []), m = H((y) => u((k) => ({ ...k, [y]: void 0 })), []), g = t ? E.createElement("div", { className: "ff-popup-title" }, t) : c == null ? void 0 : c.title, f = i ?? E.createElement("div", { className: "ff-popup-reserved-extras" }, i); return h(Ze.Provider, { value: { ele: c, mount: p, unmount: m }, children: D("div", { className: j("ff-popup ff-popover", e, c.rootClassName), style: { ...a, width: o ?? 260, height: s }, ...l, children: [D("div", { className: j("ff-popup-header", "ff-popover-header", r == null ? void 0 : r.header), children: [g, c == null ? void 0 : c.subTitle] }), h("div", { className: j("ff-popup-body", "ff-popover-body", r == null ? void 0 : r.body), children: n }), D("div", { className: j("ff-popup-footer", "ff-popover-footer", r == null ? void 0 : r.footer), children: [f, c == null ? void 0 : c.extras, c == null ? void 0 : c.actions] })] }) }); }; Tt.propTypes = { widgetType: S.oneOf(["fsdpf-component", "grid-layout-form", "data-list"]) }; const ht = (t) => function({ className: e, variant: r, children: n, name: i, icon: o, type: s = "default", iconPosition: a = "start", noAuthType: l, onAfterClick: c, onBeforeClick: u, data: p, loading: m, disabled: g, tooltip: f, confirm: y, widget: k = () => { }, widgetType: b, widgetData: $, widgetProps: C, widgetSetting: x, widgetContainerProps: F, ...I }) { const { mode: T, ...v } = F || {}, A = sn({ className: e, name: i, type: s, icon: o, iconPosition: a }, r ?? t), P = h(bt, { ...A, ...I, children: n || i }); if (T === "popover" && !["destroy", "redirect", "func"].includes(b)) return h(Tt, { data: p, widget: k, widgetType: b, widgetData: $, widgetProps: C, widgetSetting: x, widgetContainerProps: v, onAfterClick: c, onBeforeClick: u, children: P }); const L = w.isEmpty(f) || !f.enabled ? {} : f, M = w.isEmpty(y) ? { enabled: !1 } : Object.assign({ enabled: !0 }, y), [U, Z] = V(!1), [$e, { disabled: q, loading: le }] = Yi({ widget: k, widgetType: b, widgetData: $, widgetProps: C, widgetSetting: x, widgetContainerProps: v }, { onAfterClick: c, onBeforeClick: u }); return h(qn, { okText: "确定", cancelText: "取消", getPopupContainer: (_) => _, ...M, disabled: q || g, open: U, onOpenChange: (_) => { if (!_) return Z(_); M.enabled ? Z(_) : $e(p); }, onConfirm: (_) => { $e(p, _); }, onClick: (_) => { _.stopPropagation(); }, children: h(Kn, { getPopupContainer: (_) => _, ...L, title: U ? null : L == null ? void 0 : L.title, trigger: ["hover", "click"], children: E.cloneElement(P, { loading: le || m, disabled: q || g }) }) }); }, R = ht("default"); R.propTypes = { type: S.oneOf(["primary", "default", "danger", ""]), size: S.oneOf(["large", "middle", "small"]), name: S.string, icon: S.string, iconPosition: S.oneOf(["start", "end"]), data: S.any, widget: S.any, widgetType: S.oneOf(["destroy", "redirect", "func", "component", "fsdpf-component", "grid-layout-form", "grid-layout", "data-list"]), widgetData: S.object, widgetProps: S.object, widgetSetting: S.object, widgetContainerProps: S.object, tooltip: S.exact({ title: S.string.isRequired, placement: S.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: S.oneOfType([S.bool, S.number]), getPopupContainer: S.func }), confirm: S.exact({ title: S.string.isRequired, cancelText: S.string, okText: S.string, okType: S.oneOf(["primary", "default", "danger", ""]), placement: S.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: S.oneOfType([S.bool, S.number]), getPopupContainer: S.func, arrow: S.oneOfType([S.bool, S.exact({ pointAtCenter: S.bool })]) }) }; const Xi = ht("link"), Zi = ht("circle"), Qi = ht("round"), eo = ht("dashed"), Rr = ({ options: t = [], triggerWeights: e = ["grid-layout-form", "grid-layout", "fsdpf-component", "print"], onAfterClick: r = (g, f, y) => { }, onBeforeClick: n = (g, f, y) => { }, labelVariant: i = "link", labelSize: o, labelRender: s, btnVariant: a, btnSize: l, btnRender: c = (g, f) => h(R, { ...g, data: f }, g.uuid || Vt()), widgetContainerProps: u = {}, children: p, data: m }) => { if (w.isEmpty(t)) return p; l ?? (l = o), a ?? (a = i); const [g, f] = W(() => (t || []).reduce((b, $) => { const C = e.indexOf($.widgetType); return C === -1 ? b[1].push($) : b[0] ? C < e.indexOf(b[0].widgetType) ? (b[1].push(b[0]), b[0] = $) : b[1].push($) : b[0] = $, b; }, [null, []]), [t, e]); s ? p = s(g, m) || p : p || (p = h(bt, { ...sn(Object.assign(g != null && g.name || g != null && g.icon ? {} : { icon: "icon-location" }, g, { size: o }), i) })); const y = f.map((b) => c(Object.assign({ uuid: b.uuid, type: b.type, name: b.name, widget: b.widget, widgetType: b.widgetType, widgetProps: b.widgetProps, widgetData: b.widgetData, widgetSetting: b.widgetSetting, widgetContainerProps: b.widgetContainerSetting, confirm: b.confirm, onAfterClick: w.partialRight(r, b, m), onBeforeClick: w.partialRight(n, b, m) }, { size: l, variant: a }), m)); let k = y; return (y == null ? void 0 : y.length) > 1 && (k = a == "link" ? h(Mt, { split: h(_n, { type: "vertical" }), size: l, children: y }) : h(Mt.Compact, { size: l, children: y })), g ? h(Tt, { widget: g == null ? void 0 : g.widget, widgetType: g == null ? void 0 : g.widgetType, widgetProps: g == null ? void 0 : g.widgetProps, widgetSetting: g == null ? void 0 : g.widgetSetting, widgetContainerProps: Object.assign({}, u, g == null ? void 0 : g.widgetContainerProps), data: m, widgetData: g == null ? void 0 : g.widgetData, extras: k, onAfterClick: w.partialRight(r, g, m), onBeforeClick: w.partialRight(n, g, m), children: p }) : k; }; Rr.propTypes = { triggerWeights: S.array, options: S.arrayOf(S.shape({ ...R.propTypes, widgetType: R.propTypes.widgetType.isRequired })), btnSize: R.propTypes.size, btnRender: S.func, btnVariant: S.oneOf(["", "default", "link", "circle", "round", "dashed"]), labelVariant: S.oneOf(["", "default", "link", "circle", "round", "dashed"]), labelRender: S.func, labelSize: R.propTypes.size, onAfterClick: S.func, onBeforeClick: S.func, widgetContainerProps: R.propTypes.widgetContainerProps, data: R.propTypes.data }, R.Link = Xi, R.Link.defaultProps = R.defaultProps, R.Link.propTypes = R.propTypes, R.Circle = Zi, R.Circle.defaultProps = R.defaultProps, R.Circle.propTypes = R.propTypes, R.Round = Qi, R.Round.defaultProps = R.defaultProps, R.Round.propTypes = R.propTypes, R.Dashed = eo, R.Dashed.defaultProps = R.defaultProps, R.Dashed.propTypes = R.propTypes, R.Popover = Tt, R.GroupPopover = Rr; const to = ({ fields: t, formProps: e, $close: r }) => { const [n] = se.useForm(), i = W(() => [{ name: "__PROPS__", value: e }], [e]); return h(re, { actions: D(E.Fragment, { children: [h(R, { name: "取消", widget: () => r(!1) }), h(R, { name: "确定", type: "primary", widget: () => n.validateFields(!0).then(r) })] }), children: h(se, { fields: i, form: n, className: "ff-modal-form", children: t == null ? void 0 : t.map(({ code: o, ...s }) => h(nr, { code: o, ...s }, o)) }) }); }, ro = ({ className: t, classNames: e, $close: r, children: n, title: i, subTitle: o, actions: s, extras: a, ...l }) => D(Qn, { ...l, prefixCls: "ff-drawer", className: j("ff-popup", t), maskMotion: { motionAppear: !0, motionName: "mask-motion" }, motion: (c) => ({ motionAppear: !0, motionName: `panel-motion-${c}` }), children: [D("div", { className: j("ff-popup-header", "ff-drawer-header", e == null ? void 0 : e.header), children: [h("button", { "aria-label": "Close", className: j("ff-popup-close", "ff-drawer-close", e == null ? void 0 : e.close), onClick: l.onClose, children: h(er, { type: "close" }) }), i, o] }), h("div", { className: j("ff-popup-body", "ff-drawer-body", e == null ? void 0 : e.body), children: n }), D("div", { className: j("ff-popup-footer", "ff-drawer-footer", e == null ? void 0 : e.footer), children: [a, s] })] }), no = ({ className: t, classNames: e, $close: r, $event: n, children: i, title: o, subTitle: s, actions: a, extras: l, placement: c, ...u }) => { const { style: p, rest: m } = ((f, y = ["height", "width", "style"]) => { const k = { ...f }, b = {}; for (const $ of y) $ === "style" ? Object.assign(b, k.style) : k[$] !== void 0 && (b[$] = k[$]), delete k[$]; return { style: b, rest: k }; })(u), g = (n == null ? void 0 : n.pageX) === void 0 ? { animation: null, maskAnimation: null, mousePosition: { x: null, y: null } } : { animation: "zoom", maskAnimation: "fade", mousePosition: { x: n == null ? void 0 : n.pageX, y: n == null ? void 0 : n.pageY } }; return h(ei, { ...m, ...g, prefixCls: "ff-modal", className: j("ff-popup", t), modalRender: () => D(E.Fragment, { children: [h("button", { className: j("ff-popup-close", "ff-modal-close", e == null ? void 0 : e.close), onClick: m.onClose, children: h(er, { type: "close" }) }), D("div", { className: j("ff-modal-content"), style: p, children: [D("div", { className: j("ff-popup-header", "ff-modal-header", e == null ? void 0 : e.header), children: [o, s] }), h("div", { className: j("ff-popup-body", "ff-modal-body", e == null ? void 0 : e.body), children: i }), D("div", { className: j("ff-popup-footer", "ff-modal-footer", e == null ? void 0 : e.footer), children: [l, a] })] })] }) }); }, an = ({ placement: t, $close: e, $event: r, children: n, title: i, ...o }) => { const [s, a] = V({}), [l, c] = V(!0), u = H((f, y) => a((k) => ({ ...k, [f]: y })), []), p = H((f) => a((y) => ({ ...y, [f]: void 0 })), []); let m = { ...o, className: s.rootClassName, title: s.title || i && E.createElement("div", { className: j("ff-popup-title") }, i), subTitle: s.subTitle, actions: s.actions, extras: s.extras, children: n, $close: e, $event: r, onClose: () => c(!1) }; const g = () => { e(!1); }; return h(Ze.Provider, { value: { ele: s, mount: u, unmount: p }, children: t && t !== "center" ? h(ro, { ...m, placement: t, open: l, afterOpenChange: (f) => !f && g() }) : h(no, { ...m, visible: l, afterClose: g }) }); }; an.propTypes = { placement: S.oneOf(["center", "left", "top", "right", "bottom"]) }; const io = ({ widget: t, widgetProps: e, $close: r, onSetProps: n }) => { const [i, o] = V(e || {}), s = Ar(e); Gt(() => { const l = s ?? {}, c = e ?? {}, u = Object.keys({ ...l, ...c }).reduce((p, m) => (l[m] !== c[m] && (p[m] = c[m]), p), {}); Object.keys(u).length > 0 && o((p) => ({ ...p, ...u })); }, [e]); const a = H((l) => { o((c) => ({ ...c, ...l })), n == null || n(l); }, [n]); return E.isValidElement(t) ? E.cloneElement(t, { ...i, $close: r, $setProps: a }) : t != null && t.name || Sr.isForwardRef(t) || (t == null ? void 0 : t.$$typeof) === Sr.ForwardRef ? E.createElement(t, { ...i, $close: r, $setProps: a }) : t; }, G = () => { const [t, e] = jn({ maxCount: 6, motion: { motionName: "ff-notification-fade", motionAppear: !0, motionEnter: !0, motionLeave: !0, onLeaveStart: (o) => { const { offsetHeight: s } = o; return { height: s }; }, onLeaveActive: () => ({ height: 0, opacity: 0, margin: 0 }) }, prefixCls: "ff-notification" }), [, r] = E.useReducer((o) => o + 1, 0); z(() => { G.$onClick = n, G.$queue.forEach(([o, s, a, l]) => { l == null || l(i([s, a], ...o)); }), G.$queue = []; }, []); const n = (o, s = {}, a = {}) => { let l; const c = new Promise((u, p) => { l = i([u, p], o, s, a); }); return c.update = l, c; }, i = ([o, s], a, l = {}, c = {}) => { const u = G.$index++, p = (f) => ((y, k) => (G.$popups.delete(y), r(), k == null ? void 0 : k()))(u, () => o(f)); if (a === Dr) return t.open({ ...c, key: u, content: E.createElement(a, { ...l, $close: () => t.close(u) }), onClose: () => p() }), () => { }; const { $setProps: m, ...g } = l; return G.$popups.set(u, { widget: a, widgetProps: g, widgetContainerProps: c, $close: p, onSetProps: m }), r(), (f, y) => { const k = G.$popups.get(u); k && (G.$popups.set(u, { ...k, widgetProps: f ? { ...k.widgetProps, ...f } : k.widgetProps, widgetContainerProps: y ? { ...k.widgetContainerProps, ...y } : k.widgetContainerProps }), r()); }; }; return D(E.Fragment, { children: [Array.from(G.$popups).map(([o, { widget: s, widgetProps: a, widgetContainerProps: l, $close: c, onSetProps: u }]) => h(an, { maskClosable: !1, $event: a == null ? void 0 : a.$event, ...l, $close: c, children: h(io, { widget: s, widgetProps: a, $close: c, onSetProps: u }) }, o)), e] }); }; G.$popups = /* @__PURE__ */ new Map(), G.$index = 0, G.$queue = [], G.$onClick = (...t) => { const e = new Promise((r, n) => { G.$queue.push([t, r, n, (i) => { e.update = i; }]); }); return e; }; const Fr = (t, e, r = {}) => G.$onClick(t, e, r), At = (t, { showProgress: e, duration: r, ...n } = { duration: 1.5 }) => G.$onClick(Dr, { content: t, ...n }, { showProgress: e, duration: r }), Ee = { modal: Fr, confirm: (t, e = {}) => G.$onClick(ni, { content: t, ...e }, { placement: "center" }), form: (t, e = {}, r = {}) => Fr(to, { formProps: r, fields: t }, { placement: "center", ...e }).then((n) => { if (n === !1) throw !1; return n; }), notification: At, success: (t, e = { duration: 1.5 }) => At(t, { ...e, className: "ff-notification-success", icon: "check" }), error: (t, e = { duration: 1.5 }) => At(t, { ...e, className: "ff-notification-error", icon: "close" }) }; Qe.configure({ showSpinner: !1 }); const ln = () => { const t = window.localStorage.getItem(wt); return Object.freeze({ Platform: "web", SaaS: window.localStorage.getItem("SaaS"), Authorization: t ? `Bearer ${t} ` : void 0 }); }; Ve.interceptors.request.use((t) => (Object.assign(t.headers, ln()), Qe.inc(), t), (t) => (Qe.done(), Promise.reject({ code: -1, msg: t }))), Ve.interceptors.response.use(({ data: t, headers: e }) => (Qe.done(), { ...t, res: e == null ? void 0 : e.res }), function(t) { return Qe.done(), Promise.reject(t.message); }), window.addEventListener("unhandledrejection", Dt.onUnhandledRejection), Dt.onMsg = (t, e) => Ee[[0, 1].includes(t) ? "success" : "error"](e).then(() => t === 20300 && Se.redirect(We.get("Common.WEBSITE_LOGIN_PAGE"))); var He, Ue, Ye; const ee = class ee { constructor() { O(this, "appUrl", ""); N(this, He, null); return d(ee, Ue) || (K(ee, Ye, new Dt()), K(ee, Ue, new Proxy(this, { get(e, r) { if (r in e) { const n = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e), r); return n != null && n.get ? Reflect.get(e, r, e) : typeof e[r] == "function" ? e[r].bind(e) : e[r]; } return d(ee, Ye)[r]; } }))), d(ee, Ue); } init(e, r, n) { Ve.defaults.baseURL = this.appUrl = n, Ve.defaults.timeout = 15e3, d(ee, Ye).init(e, r, Ve); } get driver() { return Ve; } get headers() { return ln(); } mock(e = {}) { return d(this, He) ?? K(this, He, new Ln(Ve, { onNoMatch: "passthrough", ...e })); } unmock() { var e; (e = d(this, He)) == null || e.restore(), K(this, He, null); } }; He = new WeakMap(), Ue = new WeakMap(), Ye = new WeakMap(), N(ee, Ue), N(ee, Ye), O(ee, "getInstance", () => d(ee, Ue) ?? K(ee, Ue, new ee())); let Ht = ee; const B = Ht.getInstance(); class or extends Error { constructor(e, r) { super(r), Error.captureStackTrace && Error.captureStackTrace(this, or), !r instanceof et && (this.name = `${e} Error Runtime`); } } class et extends Error { constructor(e, ...r) { super(...r), Error.captureStackTrace && Error.captureStackTrace(this, et), this.name = `${e} Not Found`; } } const It = "mine", wt = "token", Lt = "user-login-intended-url"; var Ie, Ge, at; const ye = class ye { constructor() { N(this, Ge, /* @__PURE__ */ new Map()); N(this, at, (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)); O(this, "setPkgVersion", (e) => { K(this, at, e); }); O(this, "setVendor", (e, r) => d(this, Ge).set(e, new ti(r, async (n, i) => { var s, a; if (!(n != null && n.default)) throw "@pkg not found"; let o = () => i; switch ("function") { case typeof (o = (s = n.default) == null ? void 0 : s[`./${i}/index.jsx`]): case typeof (o = (a = n.default) == null ? void 0 : a[`./${i}/index.js`]): return o(); } throw new et(i); }))); O(this, "getWidgetComponent", async (e) => { if (!e) throw "getWidgetComponent widget is required"; if (e != null && e.startsWith("blob:") || e != null && e.startsWith("http:") || e != null && e.startsWith("https:")) return await import(e); const [, r] = e == null ? void 0 : e.split("@pkg/"); if (!r) throw new et(e); try { return d(this, Ge).has("pkg") ? await d(this, Ge).get("pkg").get(r) : await import(`${B.appUrl}/api/pkg-import/web?name=${e}&v=${d(this, at)}`); } catch (n) { throw new or(e, n); } }); O(this, "getRoutes", () => B.get("/api/my-router").then((e) => [...e, { uuid: "data-list-setting", isLayout: !0, uri: "/data-list-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/DataListSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "grid-layout-setting", isLayout: !0, uri: "/grid-layout-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/GridLayoutSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "grid-layout-form-setting", isLayout: !0, uri: "/grid-layout-form-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/GridLayoutFormSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "resource-api-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ResourceApiSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "charts-setting", isLayout: !0, uri: "/resource-api-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ChartsSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "fsm-setting", isLayout: !0, uri: "/fsm-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/FsmSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "component-setting", isLayout: !0, uri: "/component-setting/:category/:categoryUuid", type: "fsdpf-component", component: "@pkg/ff-design/components/ComponentSetting", extra: { layout: "@pkg/ff-design/frameworks/DesignTheme" } }, { uuid: "login", uri: "/login", name: "登录", type: "fsdpf-component", isLogin: !1, component: "@pkg/ff/components/Login" }, { uuid: "not-found", uri: "*", name: "Not Found", type: "fsdpf-component", isLogin: !1, component: "@pkg/ff/components/NotFound" }].map(({ uuid: r, ...n }) => [r, { uuid: r, ...n }])).then((e) => new Map(e))); O(this, "getMenus", () => B.get("/api/my-menu")); O(this, "getConfigure", () => B.get("api/init-configure")); O(this, "getWidgetOperationAuth", () => B.get("/api/init-widget-operation-auth").then((e) => e.reduce((r, { uuid: n, auth: i }) => [...r, [n, i]], []))); O(this, "getPhoneNumber", (e) => B.get(`/api/user-wx-phone-number/${e}`)); O(this, "getUserToken", () => { const e = window.localStorage.getItem(wt); if (!e) return ""; const r = e.split("."); if (!Array.isArray(r) || r.length !== 3) throw "登录令牌无效!"; const { iat: n } = JSON.parse(window.atob(r[1])); if (Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - n > 2592e3) throw "登录令牌已过期, 请重新登录!"; return e; }); O(this, "checkUserToken", () => { try { return !!this.getUserToken(); } catch { return !1; } }); O(this, "getUserInfo", (e = !0) => { var r; try { const n = this.getUserToken(); if (!n) return Promise.resolve(null); const { iat: i } = JSON.parse(window.atob((r = n == null ? void 0 : n.split(".")) == null ? void 0 : r[1])), { iat: o, ...s } = B.decode(window.localStorage.getItem(It) || "", {}); return o === i ? Promise.resolve(s) : B.get("/api/mine-info").then(({ User: a = null }) => (window.localStorage.setItem(It, B.encode({ ...a, iat: i })), a)).catch((a) => (console.error(a), e && Ee.error("请登录").then(this.logout), null)); } catch (n) { console.error(n), e && Ee.error("请登录").then(this.logout); } return Promise.resolve(null); }); O(this, "login", (e, r, n = {}) => B.post("/api/user-token", { username: e, passwd: Vn.hash(r), platform: "web", ...n }).then(({ token: i }) => (window.localStorage.setItem(wt, i), i)).then(async (i) => (await this.initAppEnv(), i))); O(this, "setLoginIntendedUrl", (e) => sessionStorage.setItem(Lt, e)); O(this, "getLoginIntendedUrl", (e = !1) => { const r = sessionStorage.getItem(Lt); return e && sessionStorage.removeItem(Lt), r; }); O(this, "logout", (e) => (window.localStorage.removeItem(It), window.localStorage.removeItem(wt), e == null ? void 0 : e())); O(this, "initAppEnv", async () => { const [e, r, n, i] = await Promise.all([this.getWidgetOperationAuth(), this.getRoutes(), this.getMenus(), this.getConfigure()]); return Mr.init(e), We.init(i), Se.init(r, n), kt.init(We.get("Common.ICONFONT")), { widgetOperationAuth: e, routes: r, menus: n, configures: i }; }); if (d(ye, Ie)) return d(ye, Ie); } }; Ie = new WeakMap(), Ge = new WeakMap(), at = new WeakMap(), N(ye, Ie, null), O(ye, "getInstance", () => (d(ye, Ie) || K(ye, Ie, new ye()), d(ye, Ie))); let Yt = ye; const X = Yt.getInstance(), Ko = E.createContext({ user: {}, initUser: () => { }, initUserComplete: !1 }), _o = E.createContext({ set: () => { }, get: () => { }, assign: () => { }, currentRoute: () => { } }), sr = (t) => { if (!t) return !1; if (t.prototype instanceof E.Component || t.$$typeof) return !0; if (typeof t == "function") { const e = t.displayName || t.name; return !e || /^[A-Z]/.test(e); } return !1; }, Jo = (t, e) => { if (!t || typeof window > "u") return; let r = document.querySelector(`style[ff-style-token="${e}"]`); return r ? (r.innerHTML = t, t) : (r = document.createElement("style"), r.setAttribute("ff-style-token", e), r.setAttribute("type", "text/css"), r.innerHTML = t, document.head.appendChild(r), t); }; var ve, Xe, Ne, be, Ce, ne, te, Y, ke, lt, ct, dt, ut, xt, pt; const ar = class ar { constructor(e, r = "/") { N(this, ve, "/"); N(this, Xe, /* @__PURE__ */ new Set()); N(this, Ne, (e) => { for (const r of d(this, Xe)) try { r(e); } catch (n) { console.error("Error in VirtualFS event listener:", n); } }); N(this, be, (e) => { const r = Date.now(); if (e && (e.lastModified = r), d(this, ve) != "/") { const n = d(this, Y).call(this, d(this, ve)); n && (n.lastModified = r); } this.root.lastModified = r; }); N(this, Ce, (e) => { let r = pe.normalize(e); return r.startsWith("/") || (r = "/" + r), r.length > 1 && r.endsWith("/") && (r = r.slice(0, -1)), r; }); N(this, ne, (e) => { const r = pe.join(d(this, ve), e); return d(this, Ce).call(this, r); }); N(this, te, (e) => { if (!e || typeof e != "string") return !1; const r = d(this, Ce).call(this, e); return !r.includes("..") && r.startsWith("/"); }); N(this, Y, (e) => { var o; const r = d(this, Ce).call(this, e); if (r === "/") return this.root; const n = r.split("/").filter((s) => s); let i = this.root; for (const s of n) { if (i.type !== "dir") return null; const a = (o = i.children) == null ? void 0 : o.find((l) => l.name === s); if (!a) return null; i = a; } return i; }); N(this, ke, (e) => { const r = d(this, Ce).call(this, e), n = pe.basename(r), i = pe.dirname(r); return { parent: d(this, Y).call(this, i), name: n }; }); N(this, lt, (e, r, n) => n === !1 ? e : n === "root" ? e.map((i) => pe.join(r, i)) : n === !0 || n === "working" ? e.map((i) => pe.relative(d(this, ve), pe.join(r, i))) : e); N(this, ct, async (e, r, n, i = "") => { const o = [], s = d(this, Y).call(this, e); if (!s || s.type !== "dir") return o; const a = s.children; for (const l of a) { const c = l.name, u = e === "/" ? `/${c}` : `${e}/${c}`, p = i ? `${i}/${c}` : c; try { if (l.type === "file") r(n ? p : c) && o.push(p); else if (l.type === "dir" && n) { const m = await d(this, ct).call(this, u, r, n, p); o.push(...m); } } catch { continue; } } return o; }); N(this, dt, async (e, r, n, i = "") => { const o = [], s = Array.isArray(r) ? r : [r], a = d(this, Y).call(this, e); if (!a || a.type !== "dir") return o; if (!n) { for (const c of s) if (d(this, ut).call(this, c)) { const u = await d(this, xt).call(this, e, c); o.push(...u); } else { const u = pe.join(e, c), p = d(this, Ce).call(this, u); d(this, Y).call(this, p) && o.push(c); } return o; } const l = a.children; for (const c of l) { const u = c.name, p = e === "/" ? `/${u}` : `${e}/${u}`, m = i ? `${i}/${u}` : u; try { if (c.type === "file") for (const g of s) { let f = !1; if (f = d(this, ut).call(this, g) ? d(this, pt).call(this, u, g) : u === g, f) { o.push(m); break; } } else if (c.type === "dir") { const g = await d(this, dt).call(this, p, r, n, m); o.push(...g); } } catch { continue; } } return o; }); N(this, ut, (e) => /[*?[\]{}]/.test(e)); N(this, xt, async (e, r) => { const n = [], i = d(this, Y).call(this, e); if (!i || i.type !== "dir") return n; const o = i.children.map((s) => s.name); for (const s of o) d(this, pt).call(this, s, r) && n.push(s); return n; }); N(this, pt, (e, r) => { const n = r.replace(/\./g, "\\.").replace(/\*/g, ".*").replace(/\?/g, ".").replace(/\{([^}]+)\}/g, (i, o) => "(" + o.split(",").join("|") + ")"); return new RegExp(`^${n}$`).test(e); }); var n, i, o; K(this, ve, r), this.root = { name: "/", type: "dir", children: [], lastModified: Date.now() }, Array.isArray(e) ? this.root.children = e : e && typeof e == "object" && (e.name && e.name !== "/" ? this.root.children.push(e) : (this.root = e, (n = this.root).name ?? (n.name = "/"), (i = this.root).children ?? (i.children = []), (o = this.root).lastModified ?? (o.lastModified = Date.now()))); } async stat(e) { const r = d(this, ne).call(this, e); if (!d(this, te).call(this, r)) throw new Error(`EINVAL: invalid path '${e}'`); const n = d(this, Y).call(this, r); if (!n) throw new Error(`ENOENT: no such file or directory, stat '${e}'`); return { isFile: () => n.type === "file", isDirectory: () => n.type === "dir", lastModified: n.lastModified }; } async dir(e) { const r = d(this, ne).call(this, e); if (!d(this, te).call(this, r)) throw new Error(`EINVAL: invalid path '${e}'`); const n = d(this, Y).call(this, r); if (!n) throw new Error(`ENOENT: no such file or directory, scandir '${e}'`); if (n.type !== "dir") throw new Error(`ENOTDIR: not a directory, scandir '${e}'`); return n.children.map((i) => i.name); } async readFile(e) { const r = d(this, ne).call(this, e); if (!d(this, te).call(this, r)) throw new Error(`EINVAL: invalid path '${e}'`); const n = d(this, Y).call(this, r); if (!n) throw new Error(`ENOENT: no such file or directory, open '${e}'`); if (n.type !== "file") throw new Error("EISDIR: illegal operation on a directory, read"); return n.content || ""; } async writeFile(e, r) { const n = d(this, ne).call(this, e); if (!d(this, te).call(this, n)) throw new Error(`EINVAL: invalid path '${e}'`); const { parent: i, name: o } = d(this, ke).call(this, n); if (!i) throw new Error(`ENOENT: no such file or directory, open '${e}'`); if (i.type !== "dir") throw new Error("ENOTDIR: not a directory"); const s = i.children.findIndex((c) => c.name === o), a = s >= 0, l = { name: o, type: "file", content: r, lastModified: Date.now() }; a ? i.children[s] = l : i.children.push(l), d(this, be).call(this, i), d(this, Ne).call(this, { action: a ? "update" : "create", path: n, type: "file", timestamp: Date.now() }); } async mkdir(e, r = {}) { const n = d(this, ne).call(this, e); if (!d(this, te).call(this, n)) throw new Error(`EINVAL: invalid path '${e}'`); const { recursive: i } = r; if (i) { const o = n.split("/").filter((a) => a); let s = "/"; for (const a of o) if (s = pe.join(s, a), !d(this, Y).call(this, s)) { const { parent: l, name: c } = d(this, ke).call(this, s); if (l && l.type === "dir") { const u = { name: c, type: "dir", children: [], lastModified: Date.now() }; l.children.push(u), d(this, be).call(this, l), d(this, Ne).call(this, { action: "create", path: d(this, Ce).call(this, s), type: "dir", timestamp: Date.now() }); } } } else { const { parent: o, name: s } = d(this, ke).call(this, n); if (!o) throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`); if (o.type !== "dir") throw new Error("ENOTDIR: not a directory"); if (o.children.find((l) => l.name === s)) throw new Error(`EEXIST: file already exists, mkdir '${e}'`); const a = { name: s, type: "dir", children: [], lastModified: Date.now() }; o.children.push(a), d(this, be).call(this, o), d(this, Ne).call(this, { action: "create", path: n, type: "dir", timestamp: Date.now() }); } } async unlink(e) { const r = d(this, ne).call(this, e); if (!d(this, te).call(this, r)) throw new Error(`EINVAL: invalid path '${e}'`); const { parent: n, name: i } = d(this, ke).call(this, r); if (!n) throw new Error(`ENOENT: no such file or directory, unlink '${e}'`); const o = n.children.findIndex((s) => s.name === i); if (o < 0) throw new Error(`ENOENT: no such file or directory, unlink '${e}'`); if (n.children[o].type !== "file") throw new Error(`EISDIR: illegal operation on a directory, unlink '${e}'`); n.children.splice(o, 1), d(this, be).call(this, n), d(this, Ne).call(this, { action: "delete", path: r, type: "file", timestamp: Date.now() }); } async rmdir(e, r = {}) { const n = d(this, ne).call(this, e); if (!d(this, te).call(this, n)) throw new Error(`EINVAL: invalid path '${e}'`); const { parent: i, name: o } = d(this, ke).call(this, n); if (!i) throw new Error(`ENOENT: no such file or directory, rmdir '${e}'`); const s = i.children.findIndex((l) => l.name === o); if (s < 0) throw new Error(`ENOENT: no such file or directory, rmdir '${e}'`); const a = i.children[s]; if (a.type !== "dir") throw new Error(`ENOTDIR: not a directory, rmdir '${e}'`); if (!r.recursive && a.children.length > 0) throw new Error(`ENOTEMPTY: directory not empty, rmdir '${e}'`); i.children.splice(s, 1), d(this, be).call(this, i), d(this, Ne).call(this, { action: "delete", path: n, type: "dir", timestamp: Date.now() }); } async rename(e, r) { const n = d(this, ne).call(this, e), i = d(this, ne).call(this, r); if (!d(this, te).call(this, n)) throw new Error(`EINVAL: invalid path '${e}'`); if (!d(this, te).call(this, i)) throw new Error(`EINVAL: invalid path '${r}'`); if (!d(this, Y).call(this, n)) throw new Error(`ENOENT: no such file or directory, rename '${e}' -> '${r}'`); const { parent: o, name: s } = d(this, ke).call(this, n), { parent: a, name: l } = d(this, ke).call(this, i); if (!a) throw new Error(`ENOENT: no such file or directory, rename '${e}' -> '${r}'`); if (d(this, Y).call(this, i)) throw new Error(`EEXIST: file already exists, rename '${e}' -> '${r}'`); const c = o.children.findIndex((p) => p.name === s), u = { ...o.children[c], name: l, lastModified: Date.now() }; o.children.splice(c, 1), a.children.push(u), d(this, be).call(this, o), o !== a && d(this, be).call(this, a), d(this, Ne).call(this, { action: "rename", path: i, oldPath: n, type: u.type, timestamp: Date.now() }); } async exists(e) { const r = d(this, ne).call(this, e); return d(this, te).call(this, r) ? d(this, Y).call(this, r) !== null : !1; } getLastModified() { return this.root.lastModified; } subscribe(e) { if (typeof e != "function") throw new Error("Callback must be a function"); return d(this, Xe).add(e), () => { d(this, Xe).delete(e); }; } getWorkingDirectory() { return d(this, ve); } scope(e = "/") { const r = d(this, Ce).call(this, e); if (!d(this, te).call(this, r)) throw new Error(`EINVAL: invalid path '${e}'`); const n = d(this, Y).call(this, r); if (!n) throw new Error(`ENOENT: no such file or directory '${e}'`); if (n.type !== "dir") throw new Error(`ENOTDIR: not a directory '${e}'`); return n.children ?? (n.children = []), n.lastModified ?? (n.lastModified = Date.now()), new ar(this.root, r); } async findFiles(e, r, n = {}) { const i = d(this, ne).call(this, e); if (!d(this, te).call(this, i)) throw new Error(`EINVAL: invalid path '${e}'`); const o = d(this, Y).call(this, i); if (!o) throw new Error(`ENOENT: no such file or directory '${e}'`); if (o.type !== "dir") throw new Error(`ENOTDIR: not a directory '${e}'`); const { recursive: s = !1, fullPath: a = !1 } = n; if (typeof r == "function") { const c = await d(this, ct).call(this, i, r, s); return d(this, lt).call(this, c, i, a); } const l = await d(this, dt).call(this, i, r, s); return d(this, lt).call(this, l, i, a); } }; ve = new WeakMap(), Xe = new WeakMap(), Ne = new WeakMap(), be = new WeakMap(), Ce = new WeakMap(), ne = new WeakMap(), te = new WeakMap(), Y = new WeakMap(), ke = new WeakMap(), lt = new WeakMap(), ct = new WeakMap(), dt = new WeakMap(), ut = new WeakMap(), xt = new WeakMap(), pt = new WeakMap(); let jr = ar; const oo = async (t, e = "/", r = "") => { try { const n = await t.stat(e), i = e === "/" ? "/" : pe.basename(e), o = { title: i, key: r ? `${r}${e}` : e, isLeaf: n.isFile() }; if (n.isDirectory()) { const s = await t.dir(e); if (s.length > 0) { o.children = []; const a = [], l = []; for (const c of s) { const u = e === "/" ? `/${c}` : `${e}/${c}`; try { (await t.stat(u)).isDirectory() ? a.push(c) : l.push(c); } catch (p) { console.warn(`Failed to stat ${u}:`, p.message); } } a.sort(), l.sort(); for (const c of [...a, ...l]) { const u = e === "/" ? `/${c}` : `${e}/${c}`; try { const p = await oo(t, u, r); o.children.push(p); } catch (p) { console.warn(`Failed to process ${u}:`, p.message); } } } } return o; } catch { return null; } }; class so extends E.Component { constructor() { super(...arguments); O(this, "state", { error: null }); O(this, "reset", () => { var r, n; (n = (r = this.props).onReset) == null || n.call(r), this.setState({ error: null }); }); } static getDerivedStateFromError(r) { return { error: r }; } componentDidCatch(r, n) { var i, o; console.error("[ErrorBoundary]", r), (o = (i = this.props).onError) == null || o.call(i, r, n); } componentDidUpdate(r) { const { resetKeys: n } = this.props; this.state.error && (n != null && n.length) && n.some((i, o) => { var s; return i !== ((s = r.resetKeys) == null ? void 0 : s[o]); }) && this.reset(); } render() { const { error: r } = this.state; if (r) { const { fallback: n } = this.props; return typeof n == "function" ? n(r, this.reset) : n !== void 0 ? n : String(r); } return this.props.children; } } const Ho = ({ widget: t, widgetProps: e, widgetSetting: r, theme: n, themeProps: i, className: o, classNames: s, style: a, styles: l, fallback: c = null, fallbackOnError: u, onError: p }) => { const [m, g] = V({}), f = H((A, P) => g((L) => ({ ...L, [A]: P })), []), y = H((A) => g((P) => ({ ...P, [A]: void 0 })), []), { loading: k, value: b, error: $ } = br(async () => { if (!t) return null; if (E.isValidElement(t)) return t; if (sr(t)) return E.createElement(t); const { default: A } = await X.getWidgetComponent(t); return E.createElement(A); }, [t]), { value: C } = br(async () => { if (!n) return null; if (typeof n == "function") return n; const { default: A } = await X.getWidgetComponent(n); return (P) => E.createElement(A, P); }, [n]); if (k) return c; if (!t || b === null) return h(ri, {}); if ($) return p == null || p($, null), typeof u == "function" ? u($, null) : u ?? String($); const x = E.cloneElement(b, { ...e, $setting: r }), F = { ele: m, mount: f, unmount: y }, { rootClassName: I, ...T } = m, v = { ...T, children: x, className: j(o, I), classNames: s, style: a, styles: l, $setting: i }; return h(so, { fallback: u, onError: p, children: h(Ze.Provider, { value: F, children: C ? C(v) : x }) }); }; export { Mo as $, li as A, No as B, To as C, Ct as D, Wr as E, zt as F, Fo as G, ki as H, ci as I, di as J, vi as K, Ni as L, jo as M, Ao as N, oe as O, Oi as P, Pt as Q, Jr as R, Qr as S, jt as T, Io as U, Lo as V, Vo as W, Do as X, Ri as Y, Fi as Z, ji as _, Br as a, Ai as a0, vt as a1, Bo as a2, gt as a3, Nt as a4, Uo as a5, Wo as a6, Ii as a7, nn as a8, qi as a9, B as aA, ti as aB, We as aC, ze as aD, Se as aE, Ko as aF, _o as aG, jr as aH, oo as aI, io as aJ, so as aK, Ho as aL, ir as aa, nr as ab, on as ac, Li as ad, Vi as ae, Di as af, Mi as ag, Bi as ah, Ui as ai, zo as aj, qo as ak, kt as al, R as am, Mr as an, Yi as ao, re as ap, Ze as aq, Vr as ar, G as as, Ee as at, ri as au, Po as av, vo as aw, X as ax, sr as ay, Jo as az, zr as b, Oo as c, qr as d, tr as e, Hr as f, ii as g, Xr as h, $i as i, Gr as j, Ei as k, Ro as l, Yr as m, _r as n, Kr as o, wi as p, yi as q, mi as r, rr as s, ae as t, Si as u, Ci as v, Pi as w, ui as x, gi as y, ai as z };