ff-dist/dist/common/main-CkGDWxCl.js
2024-12-24 17:20:07 +08:00

1018 lines
76 KiB
JavaScript

var xa = Object.defineProperty;
var Ft = (e) => {
throw TypeError(e);
};
var va = (e, t, a) => t in e ? xa(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
var S = (e, t, a) => va(e, typeof t != "symbol" ? t + "" : t, a), Rt = (e, t, a) => t.has(e) || Ft("Cannot " + a);
var m = (e, t, a) => (Rt(e, t, "read from private field"), a ? a.call(e) : t.get(e)), F = (e, t, a) => t.has(e) ? Ft("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, a), D = (e, t, a, n) => (Rt(e, t, "write to private field"), n ? n.call(e, a) : t.set(e, a), a);
var Ot = (e, t, a, n) => ({
set _(r) {
D(e, t, r, a);
},
get _() {
return m(e, t, n);
}
});
import { jsx as d, jsxs as O } from "react/jsx-runtime";
import k, { useEffect as L, useState as T, useCallback as Y, useMemo as H, useRef as U, useContext as oe, useId as Ye, useLayoutEffect as Sa } from "react";
import u from "lodash";
import Ht from "immutability-helper";
import { Form as _e, Input as $a, Button as ut, Pagination as Pa, Tree as Na, Breadcrumb as Ta, Table as Ea, Empty as Fa, Popconfirm as Ra, Tooltip as Oa, Popover as La } from "antd";
import { useMergedState as ja } from "rc-util";
import A from "classnames";
import Z, { FieldContext as Kt, Field as Jt } from "rc-field-form";
import { useParams as Aa, generatePath as Va, createBrowserRouter as Ia, useInRouterContext as Ma, Navigate as za } from "react-router-dom";
import b from "prop-types";
import * as Lt from "react-is";
import { useNotification as Ba } from "rc-notification";
import { N as Fe, a as Re, T as gt, S as qa } from "./vender-DMK1apIA.js";
import "rc-util/lib/hooks/useMergedState";
import Da from "rc-drawer";
import Ua from "rc-dialog";
var $e, je, Pe, le, ke, xe;
class _t {
constructor(t, a) {
F(this, $e, /* @__PURE__ */ new Map());
F(this, je, !0);
F(this, Pe, []);
F(this, le);
F(this, ke, () => m(this, le));
F(this, xe, () => Promise.resolve());
S(this, "get", (...t) => new Promise((a, n) => {
const r = JSON.stringify(t);
if (m(this, $e).has(r)) return a(m(this, xe).call(this, m(this, le), ...t));
if (m(this, le) === void 0) m(this, Pe).push([t, a, n]), m(this, je) && (D(this, je, !1), Promise.resolve(typeof m(this, ke) == "function" ? m(this, ke).call(this) : m(this, ke)).then((s) => D(this, le, s || null)).finally(() => {
m(this, Pe).forEach(([s, i, o]) => {
try {
const l = m(this, xe).call(this, m(this, le), ...s);
m(this, $e).set(JSON.stringify(s), l), i(l);
} catch (l) {
o(l);
}
}), m(this, Pe).length = 0;
}));
else {
const s = m(this, xe).call(this, m(this, le), ...t);
m(this, $e).set(r, s), a(s);
}
}));
D(this, xe, a), D(this, ke, t);
}
}
$e = new WeakMap(), je = new WeakMap(), Pe = new WeakMap(), le = new WeakMap(), ke = new WeakMap(), xe = new WeakMap();
const tr = () => d("div", { children: "Empty" }), Be = k.createContext({ ele: {}, mount: () => {
}, unmount: () => {
} }), G = ({ rootClassName: e, className: t, children: a, actions: n, title: r, subTitle: s, extras: i, style: o = {} }) => {
const { mount: l, unmount: c } = k.useContext(Be);
return n && G.Action({ children: n }), r && G.Title({ children: r }), s && G.SubTitle({ children: s }), i && G.Extra({ children: i }), L(() => (l("rootClassName", e), () => c(e)), [e]), d("div", { className: A("ff-container", t), style: o, children: a });
}, Je = (e) => ({ children: t, className: a }) => {
const { mount: n, unmount: r } = k.useContext(Be);
return L(() => (n(e, k.createElement("div", { key: `ff-${e}`, className: A(`ff-popup-${e}`, a) }, t)), () => r(e)), [a, t]), null;
};
G.Action = Je("actions"), G.Title = Je("title"), G.SubTitle = Je("sub-title"), G.Extra = Je("extras"), G.propTypes = { className: b.string, style: b.object, title: b.any, subTitle: b.any, actions: b.any, extras: b.any };
const ar = () => d(G, { className: "ff-loading", children: O("div", { className: "loader", children: [O("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] }), O("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] }), O("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] }), O("div", { className: "square", children: [d("span", {}), d("span", {}), d("span", {})] })] }) }), nr = () => d("div", { children: "NotFound" }), Gt = ({ children: e }) => {
const [t, a] = T({}), n = Y((s, i) => a((o) => ({ ...o, [s]: i })), []), r = Y((s) => a((i) => ({ ...i, [s]: void 0 })), []);
return typeof (e == null ? void 0 : e.type) == "string" ? e : d(Be.Provider, { value: { ele: t, mount: n, unmount: r }, children: k.cloneElement(e, { className: t.rootClassName, title: t.title, subTitle: t["sub-title"], actions: t.actions, extras: t.extras }) });
};
Gt.propTypes = { children: b.element.isRequired };
const jt = { 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"] }, vt = ({ type: e, props: t }) => d("i", { ...t, children: d("svg", { viewBox: "0 0 1024 1024", width: "1em", height: "1em", fill: "currentColor", children: (jt[e] || jt.info).map((a, n) => d("path", { d: a }, n)) }) }), Yt = ({ className: e, content: t, icon: a, $close: n }) => O(k.Fragment, { children: [a && d("div", { className: A("ff-notification-icon", e), children: d(vt, { type: a }) }), t] }), Wa = ({}) => d(G, { children: "Confirm" });
var ge, Ne;
const te = class te {
constructor() {
F(this, Ne, /* @__PURE__ */ new Map());
S(this, "init", (t) => D(this, Ne, new Map(t)));
S(this, "check", (t) => !m(this, Ne).has(t) || m(this, Ne).get(t));
if (m(te, ge)) return m(te, ge);
}
};
ge = new WeakMap(), Ne = new WeakMap(), F(te, ge, null), S(te, "getInstance", () => (m(te, ge) || D(te, ge, new te()), m(te, ge)));
let pt = te;
const Ha = pt.getInstance(), Ka = (e, t, a = "children") => {
if (u.isEmpty(e)) return {};
const n = u.find(e, ["value", t]);
if (!u.isEmpty(n)) return n;
const r = e.length;
for (let s = 0; s < r; s++) {
const { [a]: i } = e[s], o = Ka(i, t, a);
if (!u.isEmpty(o)) return o;
}
return {};
}, Xt = (e = "Input", t = "@pkg/ff/grid-layout-forms") => e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`;
var pe, Ae;
const ae = class ae {
constructor() {
F(this, Ae, null);
S(this, "init", (t) => D(this, Ae, t));
S(this, "get", (t, a) => u.get(m(this, Ae), t, a));
if (m(ae, pe)) return m(ae, pe);
}
};
pe = new WeakMap(), Ae = new WeakMap(), F(ae, pe, null), S(ae, "getInstance", () => (m(ae, pe) || D(ae, pe, new ae()), m(ae, pe)));
let mt = ae;
const Oe = mt.getInstance(), At = { null2json: (e) => Object.create(), null2array: (e) => [], null2number: (e) => 0, null2bool: (e) => !1, null2string: (e) => "", null2integer: (e) => 0, null2float: (e) => 0, string2json: (e) => e ? JSON.parse(e) : "{}", string2array: (e) => e.substr(0, 1) === "[" && e.substr(-1) === "]" ? JSON.parse(e) : e.split(","), string2number: (e) => e == "" ? 0 : +e, string2integer: (e) => e == "" ? 0 : +e, string2float: (e) => e == "" ? 0 : +e, string2bool: (e) => {
switch (`${e}`.toLowerCase()) {
case "0":
case "false":
case "[]":
case "{}":
return !1;
}
return !!e;
}, string2string: (e) => e, json2json: (e) => e, json2array: (e) => e ? Object.values(e) : [], json2number: (e) => Object.keys(e).length, json2integer: (e) => Object.keys(e).length, json2float: (e) => Object.keys(e).length, json2bool: (e) => Object.keys(e).length > 0, json2string: (e) => e ? JSON.stringify(e) : "", array2json: (e) => ({ ...e }), array2array: (e) => e, array2number: (e) => e.length, array2integer: (e) => e.length, array2float: (e) => e.length, array2bool: (e) => e.length > 0, array2string: (e) => JSON.stringify(e), number2json: (e) => ({}), number2array: (e) => [e], number2number: (e) => e, number2integer: (e) => e, number2float: (e) => e, number2bool: (e) => !!e, number2string: (e) => e.toString(), boolean2json: (e) => ({}), boolean2array: (e) => [], boolean2number: (e) => +e, boolean2integer: (e) => +e, boolean2float: (e) => +e, boolean2bool: (e) => e, boolean2string: (e) => e ? "true" : "false" }, Q = (e, t) => {
let a = "string";
a = Array.isArray(e) ? "array" : typeof e, u.isObject(e) && (a = "json");
const n = `${a}2${t}`;
return Reflect.has(At, n) ? At[n](e) : e;
}, Qt = (e = {}, t = {}, a = {}, n = "") => Zt(e, (r, s) => s === "type" && r === "code") ? ea(e, t, a, n) : ta(e, t, n), Zt = (e, t = () => !1) => u.some(e, (a) => !!u.some(a, t) || (u.isEmpty(a) || !u.isPlainObject(a) && !u.isArray(a) ? void 0 : Zt(a, t))), ea = async (e = {}, t = {}, a = {}, n = "") => {
let r = /* @__PURE__ */ Object.create(null);
for (let s in e) {
let i;
if (Reflect.has(e[s], "type") && ["code", "field", "router", "query", "string"].includes(e[s].type)) {
const { type: o, value: l = "", default: c = n } = e[s];
switch (o) {
case "code":
i = await Ce.exec(l, t, a);
break;
case "field":
i = u.get(t, l) ?? u.get(t, l.substring(l.indexOf(".") + 1));
break;
case "router":
case "query":
i = de.getPageParams(l);
break;
case "string":
i = l;
}
i ?? (i = c);
} else i = await ea(e[s], t, a, n);
u.set(r, s, i);
}
return r;
}, ta = (e = {}, t = {}, a = "") => Object.keys(e || {}).reduce((n, r) => {
if (u.isPlainObject(e[r])) {
let s;
if (Reflect.has(e[r], "type") && ["field", "router", "query", "string"].includes(e[r].type)) {
const { type: i, value: o = "", default: l = a } = e[r];
switch (i) {
case "field":
s = u.get(t, o) ?? u.get(t, o.substring(o.indexOf(".") + 1));
break;
case "router":
case "query":
s = de.getPageParams(o);
break;
case "string":
s = o;
}
s ?? (s = l);
} else s = ta(e[r], t, a);
u.set(n, r, s);
}
return n;
}, {}), lt = (e, t) => e && typeof e == "object" ? Array.isArray(e) ? e.map((a) => lt(a, t)) : Object.keys(e).reduce((a, n) => (t[n] ? a[t[n]] = lt(e[n], t) : a[n] = lt(e[n], t), a), {}) : e, rr = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
const t = 16 * Math.random() | 0;
return (e === "x" ? t : 3 & t | 8).toString(16);
}), sr = (e) => {
var t, a;
return e ? (a = (t = e.match(/^@pkg(?:[^\/]*\/){3}(?<name>[^\/]+)/)) == null ? void 0 : t.groups) == null ? void 0 : a.name : "";
}, ir = (e) => {
var t, a;
return e ? (a = (t = e.match(/^@pkg(?:[^\/]*\/){2}(?<category>[^\/]+)/)) == null ? void 0 : t.groups) == null ? void 0 : a.category : "";
}, or = (e) => {
var t, a;
return e ? (a = (t = e.match(/^@pkg(?:[^\/]*\/){1}(?<owner>[^\/]+)/)) == null ? void 0 : t.groups) == null ? void 0 : a.owner : "";
};
var Qe, Ve, Ie, Ze;
const et = class et {
constructor(...t) {
F(this, Ve, []);
F(this, Ie, (t) => {
var a;
for (let n of t) Array.isArray(n[0]) ? m(this, Ie).call(this, n) : m(this, Ve).push(m(a = et, Qe).call(a, n[0], n[1]));
});
S(this, "toValue", async (t, a = null) => {
const n = { getValue: () => t, getRecord: () => a };
return await m(this, Ve).reduce(async (r, s) => {
try {
const i = await r;
return (await s).call(n, i);
} catch (i) {
return console.error(i), r;
}
}, t);
});
S(this, "toRender", (t, a, n = null) => k.createElement(m(this, Ze), { value: t, record: a }, n));
F(this, Ze, ({ value: t, record: a, children: n }) => {
const [r, s] = T(n);
return rt(() => {
let i = !1;
return s(n), this.toValue(t, a).then((o) => Q(o, "string")).then((o) => !i && s(o)).catch((o) => !i && s(`${o}`)), () => i = !0;
}, [t, a]), r;
});
m(this, Ie).call(this, t);
}
};
Qe = new WeakMap(), Ve = new WeakMap(), Ie = new WeakMap(), Ze = new WeakMap(), F(et, Qe, u.memoize((t, a) => ie.getWidgetComponent(t).then((n) => {
var r;
return ((r = n.default) == null ? void 0 : r.call(n, a)) || ((s) => s);
}), (t, a) => `${t}::${Q(a, "string")}`));
let Xe = et;
const Ja = (e, t = {}) => H(() => e == null ? void 0 : e.map(({ widgetByJs: a, widgetByJsSetting: n, ...r }, s) => a ? { ...r, render: (i, o) => new Xe([a, n]).toRender(i, o, "-") } : r), [e, t]), lr = (e) => {
const [t, a] = T({});
return L(() => {
let n = !1;
return e && R.get(`/api/_/${e}`).then((r) => u.pick(r, ["uuid", "name", "code", "resource", "marginX", "marginY", "cols", "rowHeight", "primaryKey", "columns", "itemOperations", "batchOperations", "isConditionFormLayout", "layout", "tabs", "pageSize", "layoutConfig"])).then((r) => !n && a(r)), () => n = !0;
}, [e]), t;
}, cr = (e, t = {}) => {
const [a, n] = T({ dataSource: [] });
return qe(() => {
let r = !1;
return e && R.get(`/api/${e}/${R.encode({ page: 1, ...t })}`).then((s) => !r && n(s)), () => r = !0;
}, [e, t]), a;
}, aa = (e = [], t = /* @__PURE__ */ new Map(), a = "id", n) => {
const r = Y(n ? (s) => u.get(s, a, u.get(s, [n, a])) : (s) => u.get(s, a), [a, n]);
return Y((s) => e == null ? void 0 : e.filter((i) => !i.uuid || !t.has(i.uuid) || t.get(i.uuid).includes(`${r(s)}`)), [e, t, r]);
}, ht = (e = [], t = [], a = /* @__PURE__ */ new Map(), n = "id", r) => {
const s = Y(r ? (i) => u.get(i, n, u.get(i, [r, n])) : (i) => u.get(i, n), [n, r]);
return H(() => {
if (u.isEmpty(t) || !t.some(({ uuid: o }) => Ha.check(o))) return !1;
if (u.isEmpty(a) || u.isEmpty(e)) return !0;
const i = e.map((o) => `${s(o)}`);
return t.some(({ uuid: o }) => !o || !a.has(o) || a.get(o).some((l) => i.includes(`${l}`)));
}, [t, e, a, s]);
}, _a = (e, t, a = "id", n = null) => {
const r = nt(), s = U(!1), i = U(e.dataSource), o = U(e.itemOperationsAccess);
return L(() => (i.current = e.dataSource, o.current = e.itemOperationsAccess, () => s.current = !1), [e.dataSource, e.itemOperationsAccess]), s.current && (e.dataSource = i.current, e.itemOperationsAccess = o.current), [e, (l = 0, c = null) => {
var g, p;
if (s.current = !1, l === 1) return (g = e.onReload) == null ? void 0 : g.call(e);
if (l === 2) {
const h = u.get(c, "__PARENT_ID__", ""), y = u.get(c, a, u.get(c, [n, a], "")), f = u.findIndex(i.current, ["__PARENT_ID__", h]), w = u.findIndex(f > -1 ? u.get(i.current, [f, "children"]) : i.current, [a, y]);
if (w === -1) return (p = e.onReload) == null ? void 0 : p.call(e);
Promise.all([R.get(`/api/${t}/detail/${y}`), R.post(`/api/${t}/list-operations-access`, { ids: y })]).then(([C, v]) => {
const E = u.get(i.current, f > -1 ? [f, "children", w, "children"] : [w, "children"]);
i.current = Ht(i.current, f > -1 ? { [f]: { children: { $splice: [[w, 1, { ...C, children: E }]] } } } : { $splice: [[w, 1, { ...C, children: E }]] });
const $ = new Map(v);
o.current.forEach((z, V) => {
var B;
(B = $.get(V)) != null && B.some((I) => I == y) || o.current.set(V, z.filter((I) => I !== y));
}), $.forEach((z, V) => {
o.current.has(V) ? o.current.set(V, u.uniq([...o.current.get(V) || [], ...z])) : o.current.set(V, z);
});
}).then(() => {
s.current = !0, r();
});
}
}];
}, Ga = (e, t) => {
const a = nt(), n = U(t), r = U(/* @__PURE__ */ new Map()), s = U([]), i = u.throttle((l) => {
s.current = [], R.list(e, u.pick({ ...n.current, ...l }, ["tab", "page", "pageSize", "condition", "sider", "keyword"])).then(({ keyword: c, condition: g, total: p, tab: h, sider: y, page: f, pageSize: w, operationsAccess: C, dataSource: v }) => {
n.current = { tab: h, condition: g, sider: y, keyword: c, total: p, pageSize: w, page: v != null && v.length ? f : 1 }, s.current = v, r.current = new Map(C), a();
});
}, 380, { leading: !1, trailing: !0 });
rt(() => {
s.current = [], e && i(t);
}, [e, t]);
const o = H(() => u.pick(n.current, ["total", "tab", "page", "pageSize", "condition", "sider", "keyword"]), [n.current]);
return Object.assign(o, { onTabChange: (l) => i({ tab: l, page: 1 }), onPageChange: (l, c) => i({ page: l, pageSize: c }), onPageSizeChange: (l) => i({ pageSize: l, page: 1 }), onConditionChange: (l, c) => i({ keyword: c, condition: Ht(n.current.condition || {}, { $merge: l || {} }), page: 1 }), onSiderChange: (l) => i({ sider: l, page: 1 }), onKeywordChange: (l) => i({ keyword: l, page: 1 }), itemOperationsAccess: r.current, dataSource: s.current, onReload: i });
}, Ya = ({ listCode: e, className: t, layouts: a, dataSource: n, isPaginate: r, isItemOperations: s, isBatchOperations: i, batchOperations: o, itemOperations: l, itemOperationsAccess: c, resource: g, primaryKey: p, title: h, itemGridLayout: y, $setting: f, tabs: w, isConditionFormLayout: C, isTreeSider: v, treeSiderConfig: E }) => {
const { classNames: $, onClickCallback: z } = oe(ee), V = aa(l, c, p, g), B = Y((I, P, x) => d(Xa, { className: A("ff-data-list-framework-item", $.item), operations: s ? V(P) : [], data: g ? { [g]: P } : P, children: I, onClickCallback: z }), [g, p, s, z, l, c]);
return O("div", { className: A("ff-data-list-framework", t), children: [d(a.sider, { isTreeSider: v, ...E }), O("div", { className: A("ff-data-list-container", $ == null ? void 0 : $.container), children: [d(a.filter, { isConditionFormLayout: C }), d(a.toolbar, { title: h, tabs: w }), d(dn, { ...y, style: { "--col-num": (f == null ? void 0 : f.colNum) || 1 }, primaryKey: p, itemRender: B, dataSource: n }), d(a.footer, { isPaginate: r, isOperations: i, operations: o })] })] });
}, Xa = ({ className: e, operations: t, children: a, data: n, onClickCallback: r }) => O("div", { className: A("data-list-grid-layout-item-container", e), children: [a, !!(t != null && t.length) && d("div", { className: "data-list-grid-layout-item-actions", children: t.map((s) => d("span", { className: "data-list-grid-layout-item-action", children: d(N.Link, { uuid: s.uuid, type: s.type, name: s.name, widget: s.widget, widgetType: s.widgetType, widgetProps: s.widgetProps, widgetSetting: s.widgetSetting, widgetContainerProps: s.widgetContainerSetting, data: n, confirm: s.confirm, onAfterClick: (i) => i !== !1 && (r == null ? void 0 : r(s.isRefresh, n)) }, s.uuid || Ye()) }, (s == null ? void 0 : s.uuid) || Ye())) })] }), Qa = ({ listCode: e, className: t, layouts: a, dataSource: n, columns: r, isItemOperations: s, isBatchOperations: i, batchOperations: o, itemOperations: l, itemOperationsAccess: c, resource: g, primaryKey: p, title: h, tabs: y, isPaginate: f, isTreeSider: w, treeSiderConfig: C, isConditionFormLayout: v, ...E }) => {
const { classNames: $, onClickCallback: z } = oe(ee), V = aa(l, c, p, g), B = ht(n, l, c, p, g);
return O("div", { className: A("ff-data-table-framework", t), children: [d(a.sider, { isTreeSider: w, ...C }), O("div", { className: A("ff-data-table-container", $ == null ? void 0 : $.container), children: [d(a.filter, { isConditionFormLayout: v }), d(a.toolbar, { title: h, tabs: y }), d(rn, { ...E, primaryKey: p, className: "ff-data-table-content", columns: r, dataSource: n, operationRender: B ? (I) => {
var P;
return d("div", { className: "ff-data-table-actions", children: (P = V(I)) == null ? void 0 : P.map((x, j) => d(N.Link, { size: "small", uuid: x.uuid, type: x.type, name: x.name, widget: x.widget, widgetType: x.widgetType, widgetProps: x.widgetProps, widgetData: x.widgetData, widgetSetting: x.widgetSetting, widgetContainerProps: x.widgetContainerSetting, data: I, confirm: x.confirm, onAfterClick: (M) => M !== !1 && (z == null ? void 0 : z(x.isRefresh, I)) }, x.uuid || j)) });
} : null }), d(a.footer, { isPaginate: f, isOperations: i, operations: o })] })] });
}, ee = k.createContext({ listCode: "", classNames: {}, getBase62params: (e, t) => {
}, onReload: () => {
}, onClickCallback: () => {
}, onConditionChange: () => {
}, onTabChange: () => {
}, onSiderChange: () => {
}, onKeywordChange: () => {
}, onPageChange: () => {
}, onPageSizeChange: () => {
} }), na = (e, t, a, n, r = {}, s = 0) => {
const i = { "--grid-layout-h": `${n}`, "--grid-layout-w": `${a}`, "--grid-layout-x": `${e}`, "--grid-layout-y": `${t}`, "--grid-layout-row-height-offset": "0px" };
return r != null && r.autoHeight ? i.height = "fit-content" : i["--grid-layout-row"] = `${n}`, r != null && r.alignItems && (i["--grid-layout-box-align-items"] = r.alignItems), r != null && r.justifyContent && (i["--grid-layout-box-justify-content"] = r.justifyContent), i["--grid-layout-box-margin"] = Vt(r == null ? void 0 : r.marginTop, r == null ? void 0 : r.marginRight, r == null ? void 0 : r.marginBottom, r == null ? void 0 : r.marginLeft), i["--grid-layout-box-padding"] = Vt(r == null ? void 0 : r.paddingTop, r == null ? void 0 : r.paddingRight, r == null ? void 0 : r.paddingBottom, r == null ? void 0 : r.paddingLeft), s && (i.height = `${s}px`), i;
}, Vt = (e, t, a, n) => `${e || 0}px ${t || 0}px ${a || 0}px ${n || 0}px`, dr = (e = "Text", t = "@pkg/ff/grid-layouts") => e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, ra = ({ className: e, isConditionFormLayout: t }) => {
var h, y;
const [a, n] = T({}), { listCode: r, onKeywordChange: s, onConditionChange: i, getBase62params: o, classNames: l } = k.useContext(ee), { keyword: c, condition: g } = (o == null ? void 0 : o()) || {}, [p] = _e.useForm();
return L(() => {
r && t && R.get(`/api/_/${r}/list-condition-form-layout`).then(({ resource: f, marginX: w, marginY: C, rowHeight: v, cols: E, fields: $ }) => {
n({ resource: f, itemMargin: [w, C], rowHeight: v, cols: E, fields: $ });
}).catch(() => n({}));
}, [r, t]), L(() => {
p.setFieldsValue({ keyword: c, ...g });
}, [JSON.stringify([c, g])]), d("div", { className: A("ff-data-list-filter", l.filter, e), children: d(_e, { form: p, layout: "vertical", autoComplete: "off", onFinish: ((h = a.fields) == null ? void 0 : h.length) > 1 ? (f) => i({ [a.resource]: f[a.resource] }, f.keyword) : () => {
}, onValuesChange: (f) => {
u.isEmpty(u.omit(f, ["keyword"])) || p.submit();
}, children: ((y = a.fields) == null ? void 0 : y.length) > 1 ? d($t, { ...a, children: d(Za, { onReset: () => {
const { keyword: f, condition: w } = o("init") || {};
p.setFieldsValue({ keyword: f, ...w });
} }) }) : d("div", { className: "ff-data-list-filter-default-form ff-grid-layout-form", children: d("div", { className: "grid-layout-item", style: na(20, 0, 5, 2), children: d(_e.Item, { name: ["keyword"], children: d($a.Search, { allowClear: !0, enterButton: "搜索", placeholder: "多关键字 | 分割", onSearch: (f) => s(f) }) }) }) }) }) });
}, Za = ({ cols: e, fields: t, onReset: a }) => {
const [n, r] = T(!1), s = H(() => t == null ? void 0 : t.toReversed().some((i) => i.y > 1 || i.x + i.w >= e - 5), [e, t]);
return O(_e.Item, { label: " ", style: { "--item-span": 5 }, className: A("ff-data-list-filter-actions", { expanded: n }), children: [d(ut, { onClick: a, children: "重置" }), d(ut, { type: "primary", htmlType: "submit", children: "查询" }), s && d(N.Link, { className: "ff-data-list-filter-expanded-button", widget: () => r((i) => !i), type: "primary", name: n ? "关闭" : "展开", icon: n ? "icon-up" : "icon-down", iconPosition: "end" })] });
};
ra.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 en = ({ className: e, operations: t, isOperations: a, isPaginate: n }) => {
const { onPageChange: r, onPageSizeChange: s, onClickCallback: i, getBase62params: o } = k.useContext(ee), { total: l, page: c, pageSize: g } = (o == null ? void 0 : o()) || {};
return a && !u.isEmpty(t) || n ? O("div", { className: A("ff-data-list-footer", e), children: [d("div", { className: "ff-data-list-actions", children: t == null ? void 0 : t.map((p, h) => d(N, { 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: (y) => y !== !1 && (i == null ? void 0 : i(p.isRefresh, null)) }, p.uuid || h)) }), n && d(Pa, { size: "small", total: l, pageSize: g, showSizeChanger: !1, showTotal: (p) => `${c} 页 / 总共 ${p}`, onChange: r, onShowSizeChange: s })] }) : null;
}, tn = [{ 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: d("span", { style: { color: "#1677ff" }, children: "sss" }), key: "0-0-1-0" }] }] }], an = ({ className: e, width: t = 280, isTreeSider: a }) => {
const { classNames: n } = oe(ee);
return a ? d(Na.DirectoryTree, { className: A("ff-data-list-sider", n.sider, e), style: { "--sider-width": t }, showLine: !0, showIcon: !1, treeData: tn }) : null;
}, nn = ({ className: e, title: t, tabs: a }) => {
const { getBase62params: n, onTabChange: r, onReload: s, classNames: i } = oe(ee), { tab: o } = (n == null ? void 0 : n()) || {}, [l, c] = ja((a == null ? void 0 : a[0].value) ?? (a == null ? void 0 : a[0].code), { value: o, onChange: r });
return O("div", { className: A("ff-data-list-toolbar", i.toolbar, e), children: [d("div", { className: "ff-data-list-title", children: t }), d(Ta, { className: "ff-data-list-tabs", itemRender: ({ label: g, code: p, value: h }) => d("span", { onClick: () => c(h ?? p), className: A("ff-data-list-tab", { active: (h ?? p) == l }), children: g }), items: a }), O("div", { className: "ff-data-list-actions", children: [d(N.Link, { icon: "icon-reload", widget: () => s() }), d(N.Link, { icon: "icon-setting" })] })] });
}, sa = ({ isItemGridLayout: e, theme: t, themeProps: a, onClickCallback: n, onReload: r, listCode: s, total: i = 0, page: o = 0, onPageChange: l, pageSize: c = 30, onPageSizeChange: g, tab: p, onTabChange: h, keyword: y, onKeywordChange: f, condition: w, onConditionChange: C, sider: v, onSiderChange: E, layouts: $, classNames: z = {}, ...V }) => {
const [B, I] = T(), P = H(() => {
let x = { sider: an, filter: ra, footer: en, toolbar: nn };
$ === !1 ? x = { sider: null, filter: null, footer: null, toolbar: null } : u.isPlainObject($) && (x = Object.assign({}, x, $));
for (const j in x) x[j] || (x[j] = () => d(k.Fragment, {}));
return x;
}, [$]);
return L(() => {
t ? ie.getWidgetComponent(t).then((x) => {
if (!x) throw `${t} not found`;
return x;
}).catch((x) => ({ default: () => `${x}` })).then((x) => I(k.createElement(x.default, { ...V, layouts: P, $setting: a }))) : I(d(e ? Ya : Qa, { ...V, layouts: P, $setting: a }));
}, [t, a]), d(ee.Provider, { value: { classNames: z, listCode: s, onClickCallback: n, onReload: r, getBase62params: (x, j) => {
const M = { tab: p, page: o, pageSize: c, keyword: y, sider: v, condition: w, total: i };
return x && x != "init" ? M[x] ?? j : M;
}, onPageChange: l, onPageSizeChange: g, onTabChange: h, onSiderChange: E, onKeywordChange: f, onConditionChange: C }, children: B && k.cloneElement(B, V) });
};
sa.propTypes = { classNames: b.exact({ sider: b.string, filter: b.string, footer: b.string, toolbar: b.string, container: b.string, content: b.string, item: b.string }), layouts: b.oneOfType([b.exact({ sider: b.elementType, filter: b.elementType, footer: b.elementType, toolbar: b.elementType }), b.bool]) };
var me, ce, ve, tt;
const ne = class ne {
constructor() {
F(this, ce, null);
F(this, ve, /* @__PURE__ */ new Map());
F(this, tt, () => {
if (m(this, ce)) return m(this, ce).port.postMessage({ command: "status", data: [] });
D(this, ce, new SharedWorker(new URL("/ff-worker/res-ws.js", self.location))), m(this, ce).port.onmessage = (t) => {
var a, n;
(a = t.data) != null && a.uuid ? m(this, ve).forEach((r, s) => {
var i;
(r == "*" || (i = r == null ? void 0 : r.includes) != null && i.call(r, t.data.uuid)) && s(t.data);
}) : ((n = t.data) == null ? void 0 : n.readyState) == WebSocket.CLOSED && R.get("/api/user-api-token").then(({ token: r, expire_at: s }) => {
m(this, ce).port.postMessage({ command: "initWs", data: [`ws${u.trimStart(R.appUrl, "http")}api/user-resource-status-ws?token=${r}`] });
});
}, m(this, ce).port.postMessage({ command: "status", data: [] });
});
S(this, "subscribe", (t, a = []) => (a ? Array.isArray(a) && a.length == 0 ? a = "*" : Array.isArray(a) || (a = [a].flat()) : a = "*", m(this, ve).set(t, a), m(this, ve).size == 1 && m(this, tt).call(this), () => this.unsubscribe(t)));
S(this, "unsubscribe", (t) => m(this, ve).delete(t));
if (m(ne, me)) return m(ne, me);
}
};
me = new WeakMap(), ce = new WeakMap(), ve = new WeakMap(), tt = new WeakMap(), F(ne, me, null), S(ne, "getInstance", () => (m(ne, me) || D(ne, me, new ne()), m(ne, me)));
let ft = ne;
const ia = ft.getInstance(), St = k.forwardRef(({ listCode: e, base62params: t, className: a, theme: n, themeProps: r, layouts: s, classNames: i }, o) => {
const [{ resource: l, primaryKey: c, batchOperations: g = [], itemOperations: p = [], columns: h = [], themeConfig: y, theme: f, isConditionFormLayout: w = !1, isTreeSider: C, treeSiderConfig: v, isItemGridLayout: E, itemGridLayout: $, title: z, isPaginate: V, tabs: B }, I] = T({ isItemGridLayout: !1, itemGridLayout: {} }), P = Ga(e, t), [{ dataSource: x, itemOperationsAccess: j, condition: M, tab: W, keyword: ue, page: K, total: Ue, pageSize: st, sider: We, onConditionChange: it, onTabChange: Tt, onKeywordChange: ha, onPageChange: fa, onPageSizeChange: ya, onSiderChange: wa, onReload: ot }, Et] = _a(P, e, c, l), ba = ht(p, x, j, c), Ca = ht(g);
return L(() => {
let He = null;
return e && R.get(`/api/_/${e}`).resp(({ data: Ke, res: ka }) => {
Ke != null && Ke.isDynamicRefresh && (He = ia.subscribe(() => ot(), ka)), I(Ke);
}).catch(() => I({})), () => He == null ? void 0 : He();
}, [e]), k.useImperativeHandle(o, () => ({ onReload: ot, onClickCallback: Et })), d(sa, { listCode: e, title: z, classNames: i, layouts: s, resource: l, primaryKey: c, theme: n || f, themeProps: r || y, isTreeSider: C, treeSiderConfig: v, isPaginate: V, tabs: B, isItemOperations: ba, isBatchOperations: Ca, batchOperations: g, itemOperations: p, isItemGridLayout: E, columns: h, itemGridLayout: $, isConditionFormLayout: w, itemOperationsAccess: j, dataSource: x, onConditionChange: it, onTabChange: Tt, onKeywordChange: ha, onPageChange: fa, onPageSizeChange: ya, onSiderChange: wa, condition: M, tab: W, keyword: ue, page: K, total: Ue, pageSize: st, sider: We, className: A("ff-data-list-helper", a), onReload: ot, onClickCallback: Et });
}), oa = (e, t, a = !0) => a !== !0 && a-- <= 0 ? [] : u.isArray(e) && !u.isEmpty(e) ? e.reduce((n, r) => (Reflect.has(r, t) && Reflect.has(r, "children") && n.push(r[t]), Reflect.has(r, "children") && !u.isEmpty(r.children) ? n.concat(oa(r.children, t, a)) : n), []) : [], rn = ({ className: e, primaryKey: t, columns: a = [], dataSource: n = [], operationRender: r, operationWidth: s = 180, ...i }) => {
const { classNames: o } = oe(ee);
Ye();
const l = U(null), c = U(null), [g, p] = T([]), [h, y] = T({ width: 0, height: 0 });
L(() => {
p(oa(n, t));
}, [n, t]), Sa(() => {
const w = new ResizeObserver(() => {
var C;
y({ width: ((C = l.current) == null ? void 0 : C.nativeElement.querySelector(".ant-table-body").scrollWidth) || c.current.offsetWidth, height: c.current.offsetHeight });
});
return c.current && w.observe(c.current), () => {
c.current && w.unobserve(c.current);
};
}, []);
const f = Ja(a);
return d("div", { ref: c, className: A("ff-data-list-table", o.content, e), children: h.height ? d(Ea, { ...i, ref: l, rowKey: (w) => (w == null ? void 0 : w[t]) ?? Math.random(), columns: f == null ? void 0 : f.concat(r ? [{ title: "操作", align: "center", fixed: "right", width: `${Math.ceil(s / h.width * 100).toFixed(2)}%`, render: (w, C, v) => r(C, v) }] : []), dataSource: n, size: "middle", scroll: { x: "max-content", y: h.height - 50 }, pagination: !1, expandable: { defaultExpandAllRows: !0, expandRowByClick: !0, onExpandedRowsChange: p, expandedRowKeys: g } }) : null });
}, sn = "RC_FORM_INTERNAL_HOOKS", on = (e, { initialValue: t, initialValueLanguage: a, convertJs: n, convertJsSetting: r, type: s = "string" }, i = null) => {
const o = U(!1), l = oe(Kt), [c, g] = T(), [p, h] = T(a != "javascript" && e ? l.getFieldValue(e) : void 0), { registerWatch: y } = l.getInternalHooks(sn) || {};
return L(() => y == null ? void 0 : y((f, w, C) => {
if (!o.current) return;
const v = u.get(w, e);
u.isEqual(v, p) || h(Q(v, s));
}), [p]), L(() => {
a == "javascript" && t ? Ce.exec(t, {}, { getFieldValueForBasicForm: (f) => i ? i.getFieldValue(f) : l.getFieldValue(f), getFieldValue: (f) => l.getFieldValue(f) }).then((f) => h(Q(f, s))).catch((f) => notification.error({ message: `布局数据错误: ${JSON.stringify(f)}` })).finally(() => o.current = !0) : (t && h(Q(t ?? l.getFieldValue(e), s)), o.current = !0);
}, [t, a]), qe(() => {
o.current && n && new Xe([n, r]).toValue(p, l.getFieldsValue(!0)).then(g).catch((f) => {
g(f), console.error("布局数据转换错误: ", f, n);
});
}, [p, n, r]), [c ?? p, p];
}, la = (e, t, a = null) => H(() => {
var n;
return (n = u.sortBy(e, ["y", "x"])) == null ? void 0 : n.map(({ i: r, x: s, y: i, w: o, h: l, field: { boxStyle: c, ...g } }, p) => d("div", { className: "grid-layout-item", style: na(s, i, o, l, c), children: d(t, { ...g, basicForm: a }) }, r ?? p));
}, [e]), ln = ({ widget: e, widgetPrefix: t = "@pkg/ff/grid-layouts", basicForm: a, ...n }) => {
const r = e != null && e.startsWith("@") || e != null && e.startsWith("blob:") ? e : `${t}/${e}`, [s, i] = T();
return L(() => {
r && ie.getWidgetComponent(r).then(({ defaultProps: o = {}, default: l }) => ({ default: cn(l, o, a) })).catch((o) => ({ default: () => `${o}` })).then((o) => i(k.createElement(o.default, n)));
}, [r]), s;
}, cn = (e, t = {}, a = null) => (n) => {
const { code: r, label: s, extras: i, isVirtual: o, initialValue: l, initialValueLanguage: c, convertJs: g, convertJsSetting: p, value: h, ...y } = u.merge({}, t, n), [f, w] = on(o ? null : r, { initialValue: l, initialValueLanguage: c, convertJs: g, convertJsSetting: p, type: (y == null ? void 0 : y.type) || "string" }, a), C = H(() => {
const $ = Object.keys((t == null ? void 0 : t.extras) || {});
return u.over([u.partialRight(u.pick, $), u.partialRight(u.omit, $)]);
}, [t == null ? void 0 : t.extras]), [v, E] = C(y);
return d(e, { ...E, value: f, rawValue: w, $setting: Object.assign({}, i, v) });
}, ca = ({ className: e, cols: t = 12, rowHeight: a = 21, containerPadding: n = [0, 0], itemMargin: r = [4, 0], formProps: s = {}, fields: i = [], data: o, basicForm: l = null, ...c }) => {
const [g] = Z.useForm(), p = la(i, ln, l), h = H(() => [{ name: "__PROPS__", value: s }], [s]);
return qe(() => (g.setFieldsValue(o), () => g.resetFields()), [o]), d(Z, { fields: h, form: g, component: !1, children: d("div", { ...c, className: A("ff-grid-layout", e), style: { "--grid-layout-item-margin-y": `${(r == null ? void 0 : r[0]) || 0}px`, "--grid-layout-item-margin-x": `${(r == null ? void 0 : r[1]) || 0}px`, "--grid-layout-container-padding-y": `${(n == null ? void 0 : n[0]) || 0}px`, "--grid-layout-container-padding-x": `${(n == null ? void 0 : n[1]) || 0}px`, "--grid-layout-cols": t, "--grid-layout-row-height": `${a}px` }, children: p }) });
}, ur = (It = ca, function({ code: e, data: t, ...a }) {
const [n, r] = T({ resource: null, cols: 12, rowHeight: 21, fields: [] });
return L(() => {
e && R.get(`/api/_/${e}`).then((s) => r(u.pick(s, ["resource", "cols", "rowHeight", "fields"])));
}, [e]), (n == null ? void 0 : n.resource) && d(It, { ...a, rowHeight: n.rowHeight, cols: n.cols, fields: n.fields, data: n != null && n.resource ? { [n == null ? void 0 : n.resource]: t } : {} });
});
var It;
const dn = ({ cols: e, rowHeight: t, itemMargin: a, fields: n, primaryKey: r, dataSource: s, itemClassName: i, itemRender: o = (p, h, y) => p, empty: l = d(Fa, { description: null }), className: c, style: g = {} }) => {
const { classNames: p } = oe(ee), h = Ye(), y = H(() => d(ca, { cols: e, rowHeight: t, itemMargin: a, fields: n, className: i }), [n, e, t, a]);
return d("div", { className: A("ff-data-list-content", p.content, c), style: g, children: u.isEmpty(s) ? l : s.map((f, w) => {
const C = o(k.cloneElement(y, { data: f }), f, w);
return k.cloneElement(C, { key: `${h}-${(f == null ? void 0 : f[r]) || w}` });
}) });
}, un = ({ component: e }) => {
const { base62params: t } = Aa();
return d(G, { children: d(St, { listCode: e, base62params: R.decode(t) }) });
}, gn = () => "Empty", pn = ({ component: e, $setting: t }) => {
const [a, n] = T();
L(() => {
if (!e) return n(d(gn, { description: null }));
ie.getWidgetComponent(e).catch((s) => ({ default: () => `${s}` })).then((s) => k.createElement(s.default, { $setting: t })).then(n);
}, [e]);
const r = de.getPageParams() || {};
return a ? k.cloneElement(a, r) : null;
};
var he, X, fe, ye, Me, ze;
const re = class re {
constructor() {
F(this, X, /* @__PURE__ */ new Map());
F(this, fe, {});
F(this, ye, null);
S(this, "init", (t, a) => {
D(this, X, t), D(this, fe, a);
});
S(this, "get", (t) => (m(this, X).has(t) || (t = Array.from(m(this, X).keys()).find((a) => m(this, X).get(a).uri === t)), m(this, X).get(t) || {}));
S(this, "redirect", (t, a, n = {}) => {
const { uri: r, type: s, widgetProps: i } = this.get(t) || {};
let o = Va(r || t, s != "list" ? a : u.mapValues(a, (c) => R.encode(c)));
const l = new URLSearchParams();
for (const c in i || {}) (i == null ? void 0 : i.type) == "query" && l.append(c, a[c]);
return l.size > 0 && (o = `${o}?${l.toString()}`), m(this, ye).navigate(o, n);
});
S(this, "getMenus", (t) => {
var a;
return ((a = m(this, fe)) == null ? void 0 : a[t]) || [];
});
S(this, "findMenuPathByUuid", (t) => {
let a = [];
for (const n in m(this, fe)) if (a = m(this, Me).call(this, m(this, fe)[n], t, [n]), a.length > 1) return a;
return a;
});
S(this, "getMenusByRouteUuid", (t) => m(this, ze).call(this, t, Object.values(m(this, fe)).flat()));
F(this, Me, (t, a, n = []) => {
if (u.isEmpty(t)) return n;
for (const { uuid: r, children: s } of t) {
if (r == a) return n.concat(r);
if (!u.isEmpty(s)) return n.concat(r, m(this, Me).call(this, s, a));
}
return n;
});
F(this, ze, (t, a) => {
var r;
let n = [];
for (const s of a) s.widgetType == "redirect" && (s.uuid == t || s.widget == t ? n.push(s) : (r = s.children) != null && r.length && (n = n.concat(m(this, ze).call(this, t, s.children))));
return n;
});
S(this, "getCurrentMenu", () => {
const { uuid: t } = this.getCurrentRoute() || {};
if (!t) return;
const a = this.getMenusByRouteUuid(t);
return u.isEmpty(a) ? void 0 : a[0];
});
S(this, "getCurrentRoute", (t = 0) => {
var n;
const a = (n = m(this, ye).state.matches[m(this, ye).state.matches.length - 1 - t]) == null ? void 0 : n.route;
if (!a) return null;
for (let [r, s] of m(this, X)) if (s.uri === a.path) return s;
return null;
});
S(this, "getPageParams", (t) => {
var s, i;
const { location: a = {}, matches: n = [] } = ((s = m(this, ye)) == null ? void 0 : s.state) || {}, r = ((i = n[n.length - 1]) == null ? void 0 : i.params) || {};
return a.search && new URLSearchParams(a.search).forEach((o, l) => {
r[l] = o;
}), t ? u.get(r, t) : r;
});
S(this, "createBrowserRouter", (t = {}) => {
if (m(this, X).size == 0) return null;
const a = Oe.get("Common.WEBSITE_DEFAULT_THEME", "@pkg/ff/frameworks/DefaultTheme"), n = Oe.get(ie.checkUserToken() ? "Common.WEBSITE_LOGIN_REDIRECT" : "Common.WEBSITE_DEFAULT", "/index"), r = { [a]: 0 }, s = (o, l) => () => ie.getWidgetComponent(o).then((c) => c.default || function() {
return `${o}`;
}).then((c) => ({ Component: () => k.createElement(Gt, {}, k.createElement(c, l)) })), i = Array.from(m(this, X).values()).reduce((o, { uuid: l, uri: c, name: g, type: p, component: h, widgetSetting: y, isLogin: f, isLayout: w, extra: C }) => {
let v = {}, E = 0;
switch (p) {
case "list":
v.element = k.createElement(un, { component: h });
break;
case "fsdpf-component":
v.element = k.createElement(pn, { key: h, component: h, $setting: y });
}
if (C != null && C.layout) {
if (!r[C == null ? void 0 : C.layout]) return r[C == null ? void 0 : C.layout] = o.length, [...o, { path: "/", lazy: s(C == null ? void 0 : C.layout, {}), children: [{ path: c, ...v }] }];
E = r[C == null ? void 0 : C.layout];
}
return w && E > -1 ? (o[E].children.push({ path: c, ...v }), o) : [...o, { path: c, ...v }];
}, [{ path: "/", lazy: s(a, {}), children: [] }]);
return i.push({ index: !0, element: k.createElement(mn, { to: n, replace: !0 }) }), D(this, ye, Ia(i, t));
});
if (m(re, he)) return m(re, he);
}
};
he = new WeakMap(), X = new WeakMap(), fe = new WeakMap(), ye = new WeakMap(), Me = new WeakMap(), ze = new WeakMap(), F(re, he, null), S(re, "getInstance", () => (m(re, he) || D(re, he, new re()), m(re, he)));
let yt = re;
const mn = ({ to: e, replace: t }) => Ma() ? k.createElement(za, { to: e, replace: t }) : (window.document.location = e, "redirect"), de = yt.getInstance(), Se = new Worker(new URL("/ff-worker/index.js", self.location)), Mt = { getConfigure: (e) => Oe.get(e), route: { redirect: (...e) => de.redirect(...e), getPageParams: (...e) => de.getPageParams(...e), getCurrentRoute: () => de.getCurrentRoute() }, popup: { notification: (...e) => _.notification(...e), success: (...e) => _.success(...e), error: (...e) => _.error(...e), form: (...e) => _.form(...e), modal: (...e) => _.modal(...e), confirm: (...e) => _.confirm(...e) } };
var at, Te, we;
const q = class q {
constructor() {
S(this, "exec", (t, a = {}, n = {}, r = "") => new Promise((s, i) => {
const o = Ot(q, at)._++;
m(q, Te).set(o, n), q.mQueue.set(o, [s, i]), Se.postMessage({ id: o, session: r, category: "eval", method: t, args: a });
}));
S(this, "clear", (t) => Se.postMessage({ session: t, category: "clear" }));
if (m(q, we)) return m(q, we);
Promise.resolve().then(() => Mn).then((t) => {
Mt.http = t.http;
}), Se.addEventListener("message", ({ data: { id: t, task_id: a, method: n, args: r, category: s, data: i, error: o, session: l } }) => {
if (s === "eval" && q.mQueue.has(t)) o !== null ? q.mQueue.get(t)[1](o) : q.mQueue.get(t)[0](i), m(q, Te).delete(t), q.mQueue.delete(t);
else if (s === "util") try {
const c = u.get(Mt, n.split("/")) || u.get(m(q, Te).get(a), n.split("/"));
if (!u.isFunction(c)) throw `${n} not found`;
Promise.resolve(Reflect.apply(c, void 0, r)).then((g) => {
Se.postMessage({ id: t, task_id: a, category: s, method: n, args: r, session: l, data: g, error: null });
}).catch((g) => {
Se.postMessage({ id: t, task_id: a, category: s, method: n, args: r, session: l, data: null, error: g });
});
} catch (c) {
Se.postMessage({ id: t, task_id: a, category: s, method: n, args: r, session: l, data: null, error: c });
}
}, !1);
}
};
at = new WeakMap(), Te = new WeakMap(), we = new WeakMap(), S(q, "mQueue", /* @__PURE__ */ new Map()), F(q, at, 0), F(q, Te, /* @__PURE__ */ new Map()), F(q, we, null), S(q, "getInstance", () => (m(q, we) || D(q, we, new q()), m(q, we)));
let wt = q;
const Ce = wt.getInstance(), nt = () => {
const e = U(!0), [, t] = k.useReducer((a) => a + 1, 0);
return L(() => () => e.current = !1, []), () => e.current && t();
}, gr = (e) => {
const t = U();
return L(() => {
t.current = e;
}, [e]), t.current;
}, pr = (e) => {
const [t, a] = T(e), n = U(null), r = Y((s, i) => {
n.current = i, a(s);
}, []);
return L(() => {
n.current && (n.current(t), n.current = null);
}, [t]), [t, r];
}, qe = (e = (n) => {
}, t, a = u.isEqual) => {
const n = k.useRef();
a(t, n.current) || (n.current = u.cloneDeep(t)), k.useEffect(e, [n.current]);
}, rt = qe, da = (e, t = "string") => {
var a;
if (!Array.isArray(e)) return e;
for (let n = 0; n < e.length; n++) e[n].value = Q((a = e[n]) == null ? void 0 : a.value, t), e[n] && Reflect.has(e[n], "children") && (e[n].children = da(e[n].children, t));
return e;
}, mr = (e, t = "json", a = "string", n, r = null) => {
const [s] = Z.useForm(n), [i, o] = T([{ label: "无", value: "", disabled: !0 }]), l = U([]), c = Z.useWatch((g) => l.current.length === 0 ? null : u.pick(g, l.current), s) || null;
return L(() => {
Array.isArray(e) ? o(e) : t === "javascript" && e ? Ce.exec(e, {}, { getFieldValue: (g) => (l.current.includes(g) || l.current.push(g), s.getFieldValue(g)), getFieldValueForBasicForm: (g) => (l.current.includes(g) || l.current.push(g), r ? r.getFieldValue(g) : s.getFieldValue(g)) }).then((g) => {
o(Q(g, "array"));
}) : e && o(Q(e, "array"));
}, [e, t, c]), da(i, a);
}, hr = (e) => {
const [t, a] = T(), n = { type: "GET" };
if (typeof e == "string" ? n.url = e : u.isPlainObject(e) && Object.assign(n, e), !(n != null && n.url)) throw "url is required";
const r = (s) => R.request(n, !1).resp((i) => (console.log("useSubscribeRequest", s), a(i), i));
return qe(() => {
let s = null;
return r().then((i) => {
s = ia.subscribe(u.throttle(r, 180, { leading: !1, trailing: !0 }), i.res);
}), () => s == null ? void 0 : s();
}, n), t;
}, hn = (e) => {
const [t, a] = k.useState({ gridItems: [], hideItems: [] });
return k.useEffect(() => {
e && R.get(`/api/_/${e}`).then(({ pk: n, uuid: r, code: s, resource: i, align: o, cols: l, rowHeight: c, marginX: g, marginY: p, listenChangeFields: h, listenChangeFieldsFunc: y, fields: f }) => ({ pk: n, uuid: r, code: s, resource: i, align: o, cols: l, rowHeight: c, marginX: g, marginY: p, listenChangeFields: h, listenChangeFieldsFunc: y, ...f.reduce((w, C) => {
var v;
return (v = C == null ? void 0 : C.field) != null && v.hidden ? w.hides.push(C == null ? void 0 : C.field) : w.items.push(C), w;
}, { items: [], hides: [] }) })).then(a);
}, [e]), t;
}, fn = ({ max: e = 0, min: t = 0, type: a = "", message: n, pattern: r, required: s = !1, validator: i } = {}, o, l) => {
const [c, g] = T([]);
return L(() => {
const p = [];
if (s) {
let h = l;
switch (l) {
case "number":
case "string":
case "array":
break;
case "bool":
h = "boolean";
break;
case "json":
h = "object";
}
p.push({ type: h, required: !0, whitespace: !0, message: "该项必填" });
}
switch (a) {
case "string":
p.push({ type: a, max: e, min: t, message: n || (t && e ? `字符必须在 ${t} ~ ${e} 之间` : `${e ? "最多能有" : "最少要有"} ${t || e} 个字符`) });
break;
case "pattern":
p.push({ type: "string", pattern: r, message: n });
break;
case "validator":
i && p.push(({ getFieldValue: h }) => ({ validator: async (y, f) => {
const w = await Ce.exec(i, { value: f, fieldName: o }, { getFieldValue: h });
return u.isString(w) && w ? Promise.reject(w) : u.isBoolean(w) && !w ? Promise.reject(n) : Promise.resolve();
} }));
}
g(p);
}, [e, t, a, n, r, s, i]), c;
}, yn = (e, t, a) => {
const [n, r] = T(null);
return L(() => {
const { initDataUri: s = `/api/${e}`, initDataMethod: i = "GET" } = a || {};
t && R.request({ method: i, url: u.trimEnd(`${s}/${t}`, "/") }).then((o) => {
r(o);
});
}, [e, t, a]), n;
}, ua = (e, t, a = {}, n = {}, r = {}) => {
const s = oe(Kt), i = nt(), o = U(!0), l = U([]), [c, g] = T(t), p = Z.useWatch((h) => JSON.stringify(u.pick(h, l.current)), s) || "{}";
return rt(() => {
e && Ce.exec(e, a, { ...n, getFieldValueForBasicForm: (h) => r ? r.getFieldValue(h) : null, getFieldValue: u.wrap(s.getFieldValue, (h, y) => (l.current.some((f) => u.isEqual(f, y)) || (l.current.push(y), i()), h == null ? void 0 : h(y))), isFieldTouched: s.isFieldTouched, isFieldsTouched: s.isFieldsTouched }).then((h) => o.current && g(h));
}, [e, p, s, a, n]), L(() => () => o.current = !1, []), c;
}, wn = (e, t, a = [], n = {}) => {
const r = U({});
if (!t) return [e, r.current];
const s = U(), i = u.debounce(nt(), 180), o = ["disabled", "required"], l = (p, h) => {
o.includes(p) && (r.current[p] = h), i();
}, c = H(() => ({ setDisabled: (p) => l("disabled", p), setRequired: (p) => l("required", p), getDisabled: () => r.current.disabled, getRequired: () => r.current.required }), [t]), g = ua(t, -1, {}, c, n) ?? -1;
if (s.current != g && (g >= 0 || !u.isEmpty(a == null ? void 0 : a[g]))) {
s.current = g;
const { widget: p, widgetPrefix: h, props: y } = a == null ? void 0 : a[g];
e = Xt(p, h), r.current = u.merge(y, u.pick(r.current, o));
}
return [e, r.current];
}, fr = ({ value: e, onChange: t }, a = null) => {
const n = U(), [r] = Z.useForm(a);
return rt(() => {
u.isEqual(n.current, e) || r.setFieldsValue(e);
}, [e]), L(() => () => r.resetFields(), []), [H(() => r.__INTERNAL__ ? r : { ...r, __INTERNAL__: {} }, [r]), (s, i) => {
n.current = i, t(i);
}];
}, bn = ({ type: e, initialValue: t, initialValueLanguage: a, onChange: n, basicForm: r }) => {
const s = ua(a == "javascript" && t, a == "javascript" ? void 0 : t, {}, {}, r);
return L(() => {
a == "javascript" ? n(Q(s, e)) : t && n(Q(t, e));
}, [e, t, s]), null;
}, ga = ({ widget: e = "Input", widgetPrefix: t = "@pkg/ff/grid-layout-forms", widgetDecorator: a, subWidgets: n = [], basicForm: r, ...s }) => {
const i = Xt(e, t), [o, l] = wn(i, a, n, r), [c, g] = T();
return L(() => {
o && ie.getWidgetComponent(o).then(({ defaultProps: p = {}, default: h }) => ({ default: Cn(h, p, r) })).catch((p) => ({ default: () => `${p}` })).then((p) => g(k.createElement(p.default, s)));
}, [o]), c && k.cloneElement(c, { ...s, ...l });
}, Cn = (e, t = {}, a = null) => (n) => {
const { type: r, code: s, label: i, noStyle: o, placeholder: l, required: c = !1, extras: g, validators: p, help: h, isVirtual: y, $isReserved: f, initialValue: w, initialValueLanguage: C, ...v } = u.omit(u.merge({}, t, n), ["convertJs", "convertJsSetting", "widget", "widgetPerfix", "widgetDecorator", "subWidgets", "boxStyle"]), E = fn(Object.assign({}, p, c ? { required: !0 } : {}), s, r), $ = H(() => {
const P = Object.keys((t == null ? void 0 : t.extras) || {});
return u.over([u.partialRight(u.pick, P), u.partialRight(u.omit, P)]);
}, [t == null ? void 0 : t.extras]), [z, V] = $(v), B = { label: i, noStyle: o, colon: !1, layout: "vertical" }, I = Y((P) => P == null ? void 0 : Q(P, r), [r]);
return d(Jt, { name: s, rules: E, initialValue: I(w), normalize: I, children: (P, x, j) => {
var M;
return d(e, { type: r, rcform: j, basicForm: a, itemProps: { validateStatus: x.errors.length > 0 ? "error" : "success", tooltip: h, help: x.errors.length > 0 ? x.errors.join("、") : null, required: ((M = E == null ? void 0 : E[0]) == null ? void 0 : M.required) || !1, ...B }, fieldProps: { placeholder: l, ...V, ...P }, $setting: Object.assign({}, g, z) });
} });
}, $t = ({ cols: e = 24, rowHeight: t = 16, itemMargin: a = [8, 16], containerPadding: n = [0, 0], fields: r = [], children: s, basicForm: i = null }) => {
const o = la(r, ga, i);
return O("div", { className: "ff-grid-layout-form", style: { "--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": `${(n == null ? void 0 : n[0]) || 0}px`, "--grid-layout-container-padding-x": `${(n == null ? void 0 : n[1]) || 0}px`, "--grid-layout-cols": e, "--grid-layout-row-height": `${t}px` }, children: [o, s && k.cloneElement(s, { cols: e, rowHeight: t, itemMargin: a, containerPadding: n, fields: r })] });
};
$t.propTypes = { fields: b.array };
const kn = (zt = $t, ({ code: e, layout: t, name: a, primaryKey: n = 0, style: r = {}, formProps: s = {}, form: i, basicForm: o, isPreview: l = !1, className: c, onFinish: g, onValuesChange: p = () => {
}, ...h }) => {
const { align: y, autoComplete: f, resource: w, items: C, hides: v, rowHeight: E, marginX: $, marginY: z, cols: V, listenChangeFields: B, listenChangeFieldsFunc: I, pk: P, uuid: x } = hn(e), [j] = Z.useForm(i), M = H(() => [{ name: "__PK__", value: P }, { name: "__PROPS__", value: s }, { name: "__RESOURCE__", value: w }, { name: "__LAYOUT_KEY__", value: e }, { name: "__LAYOUT_UUID__", value: x }, { name: "__PRIMARY_KEY__", value: n }], [P, e, x, w, n, s]);
return O(Z, { className: c, name: a || e, layout: t || y, fields: M, form: j, autoComplete: f, style: { ...r, position: "relative" }, onFinish: g, onValuesChange: (W, ue) => (({ changedValues: K, allValues: Ue, listenChangeFields: st, listenChangeFieldsFunc: We, onValuesChange: it, code: Tt }) => {
it(K, Ue), We && Array.isArray(st) && Ce.exec(We, { changedValues: K, allValues: Ue }, { getFieldValue: j.getFieldValue, setFieldValue: j.setFieldValue, setFieldsValue: j.setFieldsValue, isFieldTouched: j.isFieldTouched, isFieldsTouched: j.isFieldsTouched });
})({ changedValues: W, allValues: ue, listenChangeFields: B, listenChangeFieldsFunc: I, onValuesChange: p, code: e }), children: [d(zt, { ...h, form: j, basicForm: o, code: e, fields: C, cols: V, rowHeight: E, itemMargin: [$, z] }), v == null ? void 0 : v.map((W) => {
var ue;
return d(Jt, { name: W.code, children: d(bn, { form: j, basicForm: o, name: W.code, type: W.type, initialValue: W.initialValue, initialValueLanguage: (ue = W.extras) == null ? void 0 : ue.initialValueLanguage }) }, JSON.stringify(W.code));
})] }, e);
});
var zt;
const pa = ({ $setting: e, $close: t, extras: a, code: n, primaryKey: r, ...s }) => {
const [i] = Z.useForm(), o = yn(n, r, e);
return L(() => {
o && i.setFieldsValue(o);
}, [o]), d(G, { actions: O(k.Fragment, { children: [d(N, { name: "保存", type: "primary", widget: () => {
const l = i.getFieldValue("__RESOURCE__"), { initDataUri: c = `/api/${n}` } = e || {};
i.validateFields(!0).then((g) => l ? u.pick(g, [l]) : g).then((g) => R.post(r ? `${c}/${r}` : `${c}`, g).msg(t)).catch(() => _.error("请先完善表单信息", { duration: 2e3 }));
} }), d(N, { name: "取消", widget: () => t(!1) })] }), extras: a, children: d(kn, { form: i, code: n, primaryKey: r, ...s }) });
}, xn = (e, t, a, { isReplaceRouteHistory: n = !1 } = {}) => de.redirect(a, t, { replace: n }), vn = (e, t = {}, a, n = {}) => {
var s;
const r = (s = n.router) == null ? void 0 : s.reduce((i, [o, l, c]) => {
const g = u.get(t, ["router", o]);
if (!g && g !== 0 && l) throw `请传入 ${c}`;
return `${i}/${g}`;
}, `/api/${a}`);
return R.del(r, t.param).msg();
}, Bt = (e, t, a, { status: { loading: n, disabled: r }, setStatus: s }) => {
const i = { loading: (o) => o === void 0 ? n : s((l) => ({ ...l, loading: o })), disabled: (o) => o === void 0 ? r : s((l) => ({ ...l, disabled: o })) };
return u.isFunction(a) ? a.call(null, { ...t, ...i }) : u.isString(a) && a ? Ce.exec(a, t, i) : null;
}, qt = (e, t, a, n, r) => u.isString(a) && a ? ie.getWidgetComponent(a).then(({ default: s }) => _.modal(s, { ...t, $setting: n }, r != null && r.title ? { ...r, title: u.template(r.title)(e) } : r)).catch((s) => {
_.error(a, { content: s.toString() });
}) : _.modal(a, { ...t, $setting: n }, r != null && r.title ? { ...r, title: u.template(r.title)(e) } : r), Sn = (e, t, a, n, r) => _.modal(pa, { ...t, $setting: n, code: a }, r != null && r.title ? { ...r, title: u.template(r.title)(e) } : r), $n = (e, t, a, n, r) => _.modal(St, { base62params: t, $setting: n, listCode: a }, r != null && r.title ? { ...r, title: u.template(r.title)(e) } : r), Pn = ({ widget: e, widgetType: t, widgetData: a, widgetProps: n, widgetSetting: r, widgetContainerProps: s }, { onAfterClick: i, onBeforeClick: o }) => {
const l = oe(ee), [c, g] = T({ leading: !0, trailing: !1 }), p = H(() => {
switch (t) {
case "redirect":
return u.partialRight(xn, e, r);
case "func":
return u.partialRight(Bt, (r == null ? void 0 : r.code) ?? e, { status: c, setStatus: g });
case "fsdpf-component":
return u.partialRight(qt, e, r, s);
case "grid-layout-form":
return u.partialRight(Sn, e, r, s);
case "data-list":
return u.partialRight($n, e, r, s);
case "destroy":
return u.partialRight(vn, e, r, s);
default:
if (Nt(e) || k.isValidElement(e)) return u.partialRight(qt, e, r, s);
if (u.isFunction(e)) return u.partialRight(Bt, (r == null ? void 0 : r.code) || e, { status: c, setStatus: g });
}
return (...h) => console.error("useButton unknown widgetType", t, ...h);
}, [e, t]);
return [u.debounce((h) => (o == null || o(h), Promise.resolve(Qt(n, h, { list: l })).then((y) => p(h, { ...a, ...y })).then((y) => i == null ? void 0 : i(y)).catch(console.error)), 300, { leading: !0, trailing: !1 }), c];
}, Dt = /* @__PURE__ */ new Set(), bt = (e = [], t = 0) => {
const a = e[t];
if (a.length && !Dt.has(a)) {
const n = document.createElement("script");
n.setAttribute("src", a), n.setAttribute("data-namespace", a), e.length > t + 1 && (n.onload = () => {
bt(e, t + 1);
}, n.onerror = () => {
bt(e, t + 1);
}), Dt.add(a), document.body.appendChild(n);
}
}, Ct = ({ className: e, type: t, style: a = {}, ...n }) => d("span", { role: "img", className: A("ff-iconfont", e), style: a, ...n, children: d("svg", { style: { width: "1em", height: "1em", fill: "currentColor", overflow: "hidden" }, viewBox: "0 0 1024 1024", children: d("use", { xlinkHref: `#${t}` }) }) });
Ct.propTypes = { className: b.string, type: b.string.isRequired, style: b.object }, Ct.init = bt;
const De = (e) => function({ className: t, children: a, name: n, icon: r, type: s = "default", iconPosition: i = "start", noAuthType: o, onAfterClick: l, onBeforeClick: c, data: g, loading: p, disabled: h, tooltip: y, confirm: f, widget: w, widgetType: C, widgetData: v, widgetProps: E, widgetSetting: $, widgetContainerProps: z, ...V }) {
const B = u.isEmpty(y) || !y.enabled ? {} : y, I = u.isEmpty(f) ? { enabled: !1 } : Object.assign({ enabled: !0 }, f), P = { type: "primary", className: A("ff-button", t), iconPosition: i };
s === "danger" ? P.danger = !0 : s === "default" && (P.type = s), e === "link" || e === "dashed" ? (P.type = e, s === "default" && (P.className = A(P.className, "ff-default"))) : e !== "circle" && e !== "round" || (P.shape = e), r && (P.icon = d(Ct, { type: r }));
const [x, j] = T(!1), [M, { disabled: W, loading: ue }] = Pn({ widget: w, widgetType: C, widgetData: v, widgetProps: E, widgetSetting: $, widgetContainerProps: z }, { onAfterClick: l, onBeforeClick: c });
return d(Ra, { okText: "确定", cancelText: "取消", getPopupContainer: (K) => K, ...I, disabled: W || h, open: x, onOpenChange: (K) => {
if (!K) return j(K);
I.enabled ? j(K) : M(g);
}, onConfirm: () => {
M(g);
}, onClick: (K) => {
K.stopPropagation();
}, children: d(Oa, { getPopupContainer: (K) => K, ...B, title: x ? null : B == null ? void 0 : B.title, trigger: ["hover", "click"], children: d(ut, { loading: ue || p, disabled: W || h, ...P, ...V, children: a || n }) }) });
}, N = De("default"), Nn = De("link"), Tn = De("circle"), En = De("round"), Fn = De("dashed"), Ut = ({ data: e, widget: t, widgetType: a = "fsdpf-component", widgetData: n, widgetProps: r, widgetSetting: s, widgetContainerProps: i, onAfterClick: o, onBeforeClick: l, children: c, extras: g }) => {
const p = oe(ee), [h, y] = T(!1), [f, w] = T("hover"), [C, v] = T({}), [E, $] = T(), { placement: z, align: V, arrow: B = { pointAtCenter: !0 }, getPopupContainer: I, ...P } = i || {};
L(() => {
a == "grid-layout-form" ? $(k.createElement(pa, { ...n, $setting: s, code: t })) : a == "data-list" ? $(k.createElement(St, { base62params: e, $setting: s, listCode: t })) : u.isString(t) ? ie.getWidgetComponent(t).then(({ default: M }) => {
$(k.createElement(M, { ...n, $setting: s }));
}).catch((M) => $(M.toString())) : Nt(t) ? $(k.createElement(t, { ...n, $setting: s })) : k.isValidElement(t) && $(k.cloneElement(t, { ...n, $setting: s }));
}, [t, a, n]), L(() => {
Promise.resolve(Qt(r, e, { list: p })).then(v);
}, [r, e]);
const x = (M, W = !1) => (y(M), !M && w("hover"), M ? l == null ? void 0 : l(C) : o == null ? void 0 : o(W)), j = (M) => {
y(!0), w("click");
};
return d(La, { zIndex: 1080, placement: z, onPopupClick: j, onClick: j, open: h, align: V, arrow: B, trigger: f, getPopupContainer: I, content: d(Rn, { ...P, extras: g, children: E && k.cloneElement(E, { ...C, $close: (M) => x(!1, M) }) }), children: c, onOpenChange: x });
}, Rn = ({ title: e, className: t, children: a, extras: n, width: r, height: s, ...i }) => {
const [o, l] = T({}), c = Y((y, f) => l((w) => ({ ...w, [y]: f })), []), g = Y((y) => l((f) => ({ ...f, [y]: void 0 })), []), p = e ? k.createElement("div", { className: "ff-popup-title" }, e) : o == null ? void 0 : o.title, h = n ?? k.createElement("div", { className: "ff-popup-reserved-extras" }, n);
return d(Be.Provider, { value: { ele: o, mount: c, unmount: g }, children: O("div", { className: A("ff-popup ff-popover", t), style: { width: r, height: s }, ...i, children: [O("div", { className: "ff-popup-header", children: [p, o == null ? void 0 : o["sub-title"]] }), a, O("div", { className: "ff-popup-footer", children: [h, o == null ? void 0 : o.extras, o == null ? void 0 : o.actions] })] }) });
};
Ut.propTypes = { widgetType: b.oneOf(["fsdpf-component", "grid-layout-form", "data-list"]) }, N.propTypes = { type: b.oneOf(["primary", "default", "danger", ""]), name: b.string, icon: b.string, iconPosition: b.oneOf(["start", "end"]), data: b.any, widget: b.any, widgetType: b.oneOf(["destroy", "redirect", "func", "fsdpf-component", "grid-layout-form", "grid-layout", "data-list"]), widgetData: b.object, widgetProps: b.object, widgetSetting: b.object, widgetContainerProps: b.object, tooltip: b.exact({ title: b.string.isRequired, placement: b.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: b.oneOfType([b.bool, b.number]), getPopupContainer: b.func }), confirm: b.exact({ title: b.string.isRequired, cancelText: b.string, okText: b.string, okType: b.oneOf(["primary", "default", "danger", ""]), placement: b.oneOf(["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"]), enabled: b.oneOfType([b.bool, b.number]), getPopupContainer: b.func, arrow: b.oneOfType([b.bool, b.exact({ pointAtCenter: b.bool })]) }) }, N.Link = Nn, N.Link.defaultProps = N.defaultProps, N.Link.propTypes = N.propTypes, N.Circle = Tn, N.Circle.defaultProps = N.defaultProps, N.Circle.propTypes = N.propTypes, N.Round = En, N.Round.defaultProps = N.defaultProps, N.Round.propTypes = N.propTypes, N.Dashed = Fn, N.Dashed.defaultProps = N.defaultProps, N.Dashed.propTypes = N.propTypes, N.Popover = Ut;
const On = ({ fields: e, formProps: t, $close: a }) => {
const [n] = Z.useForm(), r = H(() => [{ name: "__PROPS__", value: t }], [t]);
return d(G, { actions: O(k.Fragment, { children: [d(N, { name: "取消", widget: () => a(!1) }), d(N, { name: "确定", type: "primary", widget: () => n.validateFields(!0).then(a) })] }), children: d(Z, { fields: r, form: n, className: "ff-modal-form", children: e == null ? void 0 : e.map(({ code: s, ...i }) => d(ga, { code: s, ...i }, s)) }) });
}, Ln = ({ className: e, $close: t, children: a, title: n, subTitle: r, actions: s, extras: i, zIndex: o, ...l }) => O(Da, { ...l, prefixCls: "ff-drawer", className: A("ff-popup", e), maskMotion: { motionAppear: !0, motionName: "mask-motion" }, motion: (c) => ({ motionAppear: !0, motionName: `panel-motion-${c}` }), children: [O("div", { className: "ff-popup-header", children: [d("button", { "aria-label": "Close", className: "ff-popup-close", onClick: l.onClose, children: d(vt, { type: "close" }) }), n, r] }), d("div", { className: "ff-popup-body", children: a }), O("div", { className: "ff-popup-footer", children: [i, s] })] }), jn = ({ className: e, $close: t, $event: a, children: n, title: r, subTitle: s, actions: i, extras: o, zIndex: l, placement: c, ...g }) => {
const p = (a == null ? void 0 : a.pageX) === void 0 ? { animation: null, maskAnimation: null, mousePosition: { x: null, y: null } } : { animation: "zoom", maskAnimation: "fade", mousePosition: { x: a == null ? void 0 : a.pageX, y: a == null ? void 0 : a.pageY } };
return d(Ua, { ...g, ...p, prefixCls: "ff-modal", modalRender: () => O("div", { className: A("ff-modal-content ff-popup", e), children: [O("div", { className: "ff-popup-header", children: [d("button", { "aria-label": "Close", className: "ff-popup-close", onClick: g.onClose, children: d(vt, { type: "close" }) }), r, s] }), d("div", { className: "ff-popup-body", children: n }), O("div", { className: "ff-popup-footer", children: [o, i] })] }) });
}, ma = ({ placement: e, $close: t, $event: a, children: n, title: r, ...s }) => {
const [i, o] = T({}), [l, c] = T(!0), g = Y((f, w) => o((C) => ({ ...C, [f]: w })), []), p = Y((f) => o((w) => ({ ...w, [f]: void 0 })), []);
let h = { ...s, className: i.rootClassName, title: i.title || r && k.createElement("div", { className: A("ff-popup-title") }, r), subTitle: i["sub-title"], actions: i.actions, extras: i.extras, children: n, $close: t, $event: a, onClose: () => c(!1) };
const y = () => {
t(!1);
};
return d(Be.Provider, { value: { ele: i, mount: g, unmount: p }, children: e && e !== "center" ? d(Ln, { ...h, placement: e, open: l, afterOpenChange: (f) => !f && y() }) : d(jn, { ...h, visible: l, afterClose: y }) });
};
ma.propTypes = { placement: b.oneOf(["center", "left", "top", "right", "bottom"]) };
const J = () => {
const [e, t] = Ba({ maxCount: 6, motion: { motionName: "ff-notification-fade", motionAppear: !0, motionEnter: !0, motionLeave: !0, onLeaveStart: (s) => {
const { offsetHeight: i } = s;
return { height: i };
}, onLeaveActive: () => ({ height: 0, opacity: 0, margin: 0 }) }, prefixCls: "ff-notification" }), [, a] = k.useReducer((s) => s + 1, 0);
L(() => {
J.$onClick = n, J.$queue.forEach(([s, i, o], l, c) => {
r([i, o], ...s), delete c[l];
});
}, []);
const n = (s, i = {}, o = {}) => new Promise((l, c) => r([l, c], s, i, o)), r = ([s, i], o, l = {}, c = {}) => {
const g = J.$index++, p = (h) => ((y, f) => (J.$popups.delete(y), a(), f == null ? void 0 : f()))(g, () => s(h));
if (o === Yt) return e.open({ ...c, key: g, content: k.createElement(o, { ...l, $close: () => e.close(g) }) });
J.$popups.set(g, k.createElement(ma, { zIndex: g, maskClosable: !1, $event: l == null ? void 0 : l.$event, ...c, key: g, $close: p }, k.isValidElement(o) ? k.cloneElement(o, { ...l, $close: p }) : o != null && o.name || Lt.isForwardRef(o) || (o == null ? void 0 : o.$$typeof) === Lt.ForwardRef ? k.createElement(o, { ...l, $close: p }) : o)), a();
};
return O(k.Fragment, { children: [Array.from(J.$popups).map(([s, i]) => i), t] });
};
J.$popups = /* @__PURE__ */ new Map(), J.$index = 0, J.$queue = [], J.$onClick = (...e) => new Promise((t, a) => {
J.$queue.push([e, t, a]);
});
const Wt = (e, t, a = {}) => J.$onClick(e, t, a), ct = (e, { showProgress: t, duration: a, ...n } = { duration: 1.5 }) => J.$onClick(Yt, { content: e, ...n }, { showProgress: t, duration: a }), _ = { modal: Wt, confirm: (e, t = {}) => J.$onClick(Wa, { content: e, ...t }, { placement: "center" }), form: (e, t = {}, a = {}) => Wt(On, { formProps: a, fields: e }, { placement: "center", ...t }).then((n) => {
if (n === !1) throw !1;
return n;
}), notification: ct, success: (e, t = { duration: 1.5 }) => ct(e, { ...t, className: "ff-notification-success", icon: "check" }), error: (e, t = { duration: 1.5 }) => ct(e, { ...t, className: "ff-notification-error", icon: "close" }) };
Fe.configure({ showSpinner: !1 }), Re.interceptors.request.use((e) => {
e.headers.Platform = "web", e.headers.SaaS = window.localStorage.getItem("SaaS");
const t = window.localStorage.getItem(Ge);
return e.headers.Authorization = t ? `Bearer ${t} ` : void 0, Fe.inc(), e;
}, (e) => (Fe.done(), Promise.reject({ code: -1, msg: e }))), Re.interceptors.response.use(({ data: e, headers: t }) => (Fe.done(), { ...e, res: t == null ? void 0 : t.res }), function(e) {
return Fe.done(), Promise.reject(e.message);
}), window.addEventListener("unhandledrejection", gt.onUnhandledRejection), gt.onMsg = (e, t) => _[[0, 1].includes(e) ? "success" : "error"](t).then(() => e === 20300 && de.redirect(Oe.get("Common.WEBSITE_LOGIN_PAGE")));
const kt = { appUrl: "", init: (e, t, a) => {
kt.appUrl = a, Re.defaults.baseURL = a, Re.defaults.timeout = 15e3, Object.assign(kt, new gt(e, t, Re));
} }, R = kt;
class Pt extends Error {
constructor(t, a) {
super(a), Error.captureStackTrace && Error.captureStackTrace(this, Pt), !a instanceof Le && (this.name = `${t} Error Runtime`);
}
}
class Le extends Error {
constructor(t, ...a) {
super(...a), Error.captureStackTrace && Error.captureStackTrace(this, Le), this.name = `${t} Not Found`;
}
}
const dt = "mine", Ge = "token";
var be, Ee;
const se = class se {
constructor() {
F(this, Ee, /* @__PURE__ */ new Map());
S(this, "setVendor", (t, a) => m(this, Ee).set(t, new _t(a, async (n, r) => {
var i, o;
if (!(n != null && n.default)) throw "@pkg not found";
let s = () => r;
switch ("function") {
case typeof (s = (i = n.default) == null ? void 0 : i[`./${r}/index.jsx`]):
case typeof (s = (o = n.default) == null ? void 0 : o[`./${r}/index.js`]):
return s();
}
throw new Le(r);
})));
S(this, "getWidgetComponent", async (t) => {
if (!t) throw "getWidgetComponent widget is required";
if (t != null && t.startsWith("blob:") || t != null && t.startsWith("http:") || t != null && t.startsWith("https:")) return await import(t);
const [, a] = t == null ? void 0 : t.split("@pkg/");
if (!a) throw new Le(t);
try {
return m(this, Ee).has("pkg") ? await m(this, Ee).get("pkg").get(a) : await import(`${R.appUrl}/api/pkg-import/web?name=${t}`);
} catch (n) {
throw new Pt(t, n);
}
});
S(this, "getRoutes", () => R.get("/api/my-router").then((t) => [...t, { 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: a, ...n }) => [a, { uuid: a, ...n }])).then((t) => new Map(t)));
S(this, "getMenus", () => R.get("/api/my-menu"));
S(this, "getConfigure", () => R.get("api/init-configure"));
S(this, "getWidgetOperationAuth", () => R.get("/api/init-widget-operation-auth").then((t) => t.reduce((a, { uuid: n, auth: r }) => [...a, [n, r]], [])));
S(this, "getPhoneNumber", (t) => R.get(`/api/user-wx-phone-number/${t}`));
S(this, "getUserToken", () => {
const t = window.localStorage.getItem(Ge);
if (!t) return "";
const a = t.split(".");
if (!Array.isArray(a) || a.length !== 3) throw "登录令牌无效!";
const { iat: n } = JSON.parse(window.atob(a[1]));
if (Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - n > 2592e3) throw "登录令牌已过期, 请重新登录!";
return t;
});
S(this, "checkUserToken", () => {
try {
return !!this.getUserToken();
} catch {
return !1;
}
});
S(this, "getUserInfo", (t = !0) => {
var a;
try {
const n = this.getUserToken();
if (!n) return Promise.resolve(null);
const { iat: r } = JSON.parse(window.atob((a = n == null ? void 0 : n.split(".")) == null ? void 0 : a[1])), { iat: s, ...i } = R.decode(window.localStorage.getItem(dt) || "", {});
return s === r ? Promise.resolve(i) : R.get("/api/mine-info").then(({ User: o = null }) => (window.localStorage.setItem(dt, R.encode({ ...o, iat: r })), o));
} catch (n) {
console.error(n), t && _.error("请登录").then(this.logout);
}
return Promise.resolve(null);
});
S(this, "login", (t, a, n = {}) => R.post("/api/user-token", { username: t, passwd: qa.hash(a), platform: "web", ...n }).then(({ token: r }) => (window.localStorage.setItem(Ge, r), r)));
S(this, "logout", (t) => (window.localStorage.removeItem(dt), window.localStorage.removeItem(Ge), t == null ? void 0 : t()));
if (m(se, be)) return m(se, be);
}
};
be = new WeakMap(), Ee = new WeakMap(), F(se, be, null), S(se, "getInstance", () => (m(se, be) || D(se, be, new se()), m(se, be)));
let xt = se;
const ie = xt.getInstance(), An = k.createContext({ user: {}, initUser: () => {
}, initUserComplete: !1 }), Vn = k.createContext({ set: () => {
}, get: () => {
}, assign: () => {
}, currentRoute: () => {
} }), Nt = (e) => !!(e != null && e.name) && (e.prototype instanceof k.Component || /^[A-Z]/.test(e.name)), In = (e, t) => {
if (!e || typeof window > "u") return;
let a = document.querySelector(`style[ff-style-token="${t}"]`);
return a ? (a.innerHTML = e, e) : (a = document.createElement("style"), a.setAttribute("ff-style-token", t), a.setAttribute("type", "text/css"), a.innerHTML = e, document.head.appendChild(a), e);
}, Mn = Object.freeze(Object.defineProperty({ __proto__: null, AppContext: An, AppGlobalParamsContext: Vn, cache: _t, configure: Oe, default: ie, func: Ce, http: R, insertStyle: In, isReactComponent: Nt, route: de }, Symbol.toStringTag, { value: "Module" }));
export {
ua as $,
Ya as A,
Qa as B,
Ja as C,
Xe as D,
lr as E,
cr as F,
ur as G,
sn as H,
aa as I,
ht as J,
_a as K,
Ga as L,
nt as M,
gr as N,
pr as O,
qe as P,
rt as Q,
ia as R,
mr as S,
hr as T,
kn as U,
$t as V,
ga as W,
pa as X,
hn as Y,
fn as Z,
yn as _,
Xt as a,
wn as a0,
fr as a1,
Ct as a2,
N as a3,
Ha as a4,
Pn as a5,
G as a6,
Be as a7,
Gt as a8,
J as a9,
_ as aa,
tr as ab,
ar as ac,
nr as ad,
ie as ae,
Nt as af,
In as ag,
R as ah,
_t as ai,
Oe as aj,
Ce as ak,
de as al,
An as am,
Vn as an,
Qt as b,
sr as c,
Zt as d,
ir as e,
or as f,
Ka as g,
na as h,
dr as i,
oa as j,
ca as k,
ln as l,
on as m,
la as n,
sa as o,
ra as p,
nn as q,
lt as r,
an as s,
Q as t,
rr as u,
en as v,
St as w,
ee as x,
rn as y,
dn as z
};