@servicestack/react
Version:
ServiceStack's React Component Library - A comprehensive collection of React components for building modern web applications.
1,538 lines • 276 kB
JavaScript
import { lastRightPart as Ut, leftPart as Kn, map as st, toDate as St, mapGet as Se, toCamelCase as Ua, toDateTime as Qa, chop as Wa, apiValue as Ka, isDate as Zn, dateFmt as Za, fromXsdDuration as ws, timeFmt12 as _a, omit as Tt, appendQueryString as rn, enc as pr, indexOfAny as Ga, createBus as Ja, toKebabCase as os, ApiResult as ct, nameOf as Xa, lastLeftPart as xs, setQueryString as Ya, toTime as el, ResponseStatus as On, ResponseError as mr, sanitize as tl, errorResponseExcept as nl, humanize as Ue, toPascalCase as gt, errorResponse as At, trimEnd as rl, uniqueKeys as yr, humanify as ks, delaySet as Cs, HttpMethods as $r, rightPart as zn, queryString as vr, combinePaths as sl, omitEmpty as cs, each as al } from "@servicestack/client";
import at, { createContext as wn, useContext as yt, useState as F, useRef as Xe, useEffect as be, useMemo as c, forwardRef as wt, useImperativeHandle as xt, useCallback as S } from "react";
import { jsx as t, jsxs as d, Fragment as xn } from "react/jsx-runtime";
const Ns = "png,jpg,jpeg,jfif,gif,svg,webp".split(","), Ls = {
img: "png,jpg,jpeg,gif,svg,webp,png,jpg,jpeg,gif,bmp,tif,tiff,webp,ai,psd,ps".split(","),
vid: "avi,m4v,mov,mp4,mpg,mpeg,wmv,webm".split(","),
aud: "mp3,mpa,ogg,wav,wma,mid,webm".split(","),
ppt: "key,odp,pps,ppt,pptx".split(","),
xls: "xls,xlsm,xlsx,ods,csv,tsv".split(","),
doc: "doc,docx,pdf,rtf,tex,txt,md,rst,xls,xlsm,xlsx,ods,key,odp,pps,ppt,pptx".split(","),
zip: "zip,tar,gz,7z,rar,gzip,deflate,br,iso,dmg,z,lz,lz4,lzh,s7z,apl,arg,jar,war".split(","),
exe: "exe,bat,sh,cmd,com,app,msi,run,vb,vbs,js,ws,wsh".split(","),
att: "bin,oct,dat".split(",")
//attachment
}, ds = Object.keys(Ls), Mt = (e, n) => `<svg xmlns='http://www.w3.org/2000/svg' aria-hidden='true' role='img' preserveAspectRatio='xMidYMid meet' viewBox='${e}'>${n}</svg>`, Bn = {
img: Mt("4 4 16 16", "<path fill='currentColor' d='M20 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2zm-2 0H6v6.38l2.19-2.19l5.23 5.23l1-1a1.59 1.59 0 0 1 2.11.11L18 16V6zm-5 3.5a1.5 1.5 0 1 1 3 0a1.5 1.5 0 0 1-3 0z'/>"),
vid: Mt("0 0 24 24", "<path fill='currentColor' d='m14 2l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8m4 18V9h-5V4H6v16h12m-2-2l-2.5-1.7V18H8v-5h5.5v1.7L16 13v5Z'/>"),
aud: Mt("0 0 24 24", "<path fill='currentColor' d='M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6zm10-9h-4v3.88a2.247 2.247 0 0 0-3.5 1.87c0 1.24 1.01 2.25 2.25 2.25S13 17.99 13 16.75V13h3v-2z'/>"),
ppt: Mt("0 0 48 48", "<g fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='4'><path d='M4 8h40'/><path d='M8 8h32v26H8V8Z' clip-rule='evenodd'/><path d='m22 16l5 5l-5 5m-6 16l8-8l8 8'/></g>"),
xls: Mt("0 0 256 256", "<path fill='currentColor' d='M200 26H72a14 14 0 0 0-14 14v26H40a14 14 0 0 0-14 14v96a14 14 0 0 0 14 14h18v26a14 14 0 0 0 14 14h128a14 14 0 0 0 14-14V40a14 14 0 0 0-14-14Zm-42 76h44v52h-44Zm44-62v50h-44V80a14 14 0 0 0-14-14h-2V38h58a2 2 0 0 1 2 2ZM70 40a2 2 0 0 1 2-2h58v28H70ZM38 176V80a2 2 0 0 1 2-2h104a2 2 0 0 1 2 2v96a2 2 0 0 1-2 2H40a2 2 0 0 1-2-2Zm32 40v-26h60v28H72a2 2 0 0 1-2-2Zm130 2h-58v-28h2a14 14 0 0 0 14-14v-10h44v50a2 2 0 0 1-2 2ZM69.2 148.4L84.5 128l-15.3-20.4a6 6 0 1 1 9.6-7.2L92 118l13.2-17.6a6 6 0 0 1 9.6 7.2L99.5 128l15.3 20.4a6 6 0 0 1-9.6 7.2L92 138l-13.2 17.6a6 6 0 1 1-9.6-7.2Z'/>"),
doc: Mt("0 0 32 32", "<path fill='currentColor' d='M26 30H11a2.002 2.002 0 0 1-2-2v-6h2v6h15V6h-9V4h9a2.002 2.002 0 0 1 2 2v22a2.002 2.002 0 0 1-2 2Z'/><path fill='currentColor' d='M17 10h7v2h-7zm-1 5h8v2h-8zm-1 5h9v2h-9zm-6-1a5.005 5.005 0 0 1-5-5V3h2v11a3 3 0 0 0 6 0V5a1 1 0 0 0-2 0v10H8V5a3 3 0 0 1 6 0v9a5.005 5.005 0 0 1-5 5z'/>"),
zip: Mt("0 0 16 16", "<g fill='currentColor'><path d='M6.5 7.5a1 1 0 0 1 1-1h1a1 1 0 0 1 1 1v.938l.4 1.599a1 1 0 0 1-.416 1.074l-.93.62a1 1 0 0 1-1.109 0l-.93-.62a1 1 0 0 1-.415-1.074l.4-1.599V7.5zm2 0h-1v.938a1 1 0 0 1-.03.243l-.4 1.598l.93.62l.93-.62l-.4-1.598a1 1 0 0 1-.03-.243V7.5z'/><path d='M2 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2zm5.5-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H9v1H8v1h1v1H8v1h1v1H7.5V5h-1V4h1V3h-1V2h1V1z'/></g>"),
exe: Mt("0 0 16 16", "<path fill='currentColor' fill-rule='evenodd' d='M14 4.5V14a2 2 0 0 1-2 2h-1v-1h1a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5ZM2.575 15.202H.785v-1.073H2.47v-.606H.785v-1.025h1.79v-.648H0v3.999h2.575v-.647ZM6.31 11.85h-.893l-.823 1.439h-.036l-.832-1.439h-.931l1.227 1.983l-1.239 2.016h.861l.853-1.415h.035l.85 1.415h.908l-1.254-1.992L6.31 11.85Zm1.025 3.352h1.79v.647H6.548V11.85h2.576v.648h-1.79v1.025h1.684v.606H7.334v1.073Z'/>"),
att: Mt("0 0 24 24", "<path fill='currentColor' d='M14 0a5 5 0 0 1 5 5v12a7 7 0 1 1-14 0V9h2v8a5 5 0 0 0 10 0V5a3 3 0 1 0-6 0v12a1 1 0 1 0 2 0V6h2v11a3 3 0 1 1-6 0V5a5 5 0 0 1 5-5Z'/>")
}, ll = /[\r\n%#()<>?[\\\]^`{|}]/g, us = 1024, il = ["Bytes", "KB", "MB", "GB", "TB"], ol = (() => {
const e = "application/", n = e + "vnd.openxmlformats-officedocument.", r = "image/", s = "text/", a = "audio/", l = "video/", o = {
jpg: r + "jpeg",
tif: r + "tiff",
svg: r + "svg+xml",
ico: r + "x-icon",
ts: s + "typescript",
py: s + "x-python",
sh: s + "x-sh",
mp3: a + "mpeg3",
mpg: l + "mpeg",
ogv: l + "ogg",
xlsx: n + "spreadsheetml.sheet",
xltx: n + "spreadsheetml.template",
docx: n + "wordprocessingml.document",
dotx: n + "wordprocessingml.template",
pptx: n + "presentationml.presentation",
potx: n + "presentationml.template",
ppsx: n + "presentationml.slideshow",
mdb: e + "vnd.ms-access"
};
function i(m, x) {
m.split(",").forEach(($) => o[$] = x);
}
function u(m, x) {
m.split(",").forEach(($) => o[$] = x($));
}
return u("jpeg,gif,png,tiff,bmp,webp", (m) => r + m), u("jsx,csv,css", (m) => s + m), u("aac,ac3,aiff,m4a,m4b,m4p,mid,midi,wav", (m) => a + m), u("3gpp,avi,dv,divx,ogg,mp4,webm", (m) => l + m), u("rtf,pdf", (m) => e + m), i("htm,html,shtm", s + "html"), i("js,mjs,cjs", s + "javascript"), i("yml,yaml", e + "yaml"), i("bat,cmd", e + "bat"), i("xml,csproj,fsproj,vbproj", s + "xml"), i("txt,ps1", s + "plain"), i("qt,mov", l + "quicktime"), i("doc,dot", e + "msword"), i("xls,xlt,xla", e + "excel"), i("ppt,oit,pps,ppa", e + "vnd.ms-powerpoint"), i("cer,crt,der", e + "x-x509-ca-cert"), i("gz,tgz,zip,rar,lzh,z", e + "x-compressed"), i("aaf,aca,asd,bin,cab,chm,class,cur,db,dat,deploy,dll,dsp,exe,fla,ics,inf,mix,msi,mso,obj,ocx,prm,prx,psd,psp,qxd,sea,snp,so,sqlite,toc,ttf,u32,xmp,xsn,xtp", e + "octet-stream"), o;
})();
let br = [];
function Ms(e) {
return e = e.replace(/"/g, "'"), e = e.replace(/>\s+</g, "><"), e = e.replace(/\s{2,}/g, " "), e.replace(ll, encodeURIComponent);
}
function Rr(e) {
return "data:image/svg+xml;utf8," + Ms(e);
}
function Ss(e) {
let n = URL.createObjectURL(e);
return br.push(n), n;
}
function Ts() {
br.forEach((e) => {
try {
URL.revokeObjectURL(e);
} catch (n) {
console.error("URL.revokeObjectURL", n);
}
}), br = [];
}
function Ir(e) {
if (!e) return null;
let n = Kn(e, "?");
return Ut(n, "/");
}
function kn(e) {
let n = Ir(e);
return n == null || n.indexOf(".") === -1 ? null : Ut(n, ".").toLowerCase();
}
function Dr(e) {
let n = kn(e.name);
return n && Ns.indexOf(n) >= 0 ? Ss(e) : Ht(e.name);
}
function Pr(e) {
if (!e) return !1;
if (e.startsWith("blob:") || e.startsWith("data:"))
return !0;
let n = kn(e);
return n && Ns.indexOf(n) >= 0 || !1;
}
function Ht(e) {
if (!e) return null;
let n = kn(e);
return n == null || Pr(e) ? e : pn(n) || Rr(Bn.doc);
}
function pn(e) {
let n = As(e);
return n && Rr(n) || null;
}
function As(e) {
if (Bn[e])
return Bn[e];
for (let n = 0; n < ds.length; n++) {
let r = ds[n];
if (Ls[r].indexOf(e) >= 0)
return Bn[r];
}
return null;
}
function Fr(e, n = 2) {
if (e === 0) return "0 Bytes";
const r = n < 0 ? 0 : n, s = Math.floor(Math.log(e) / Math.log(us));
return parseFloat((e / Math.pow(us, s)).toFixed(r)) + " " + il[s];
}
function cl(e) {
return e.files && Array.from(e.files).map((n) => ({ fileName: n.name, contentLength: n.size, filePath: Dr(n) }));
}
function _n(e, n) {
e.onerror = null, e.src = jr(e.src, n) || "";
}
function jr(e, n) {
return pn(Ut(e, ".").toLowerCase()) || (n ? pn(n) || n : null) || pn("doc");
}
function wr(e) {
if (!e)
throw new Error("fileNameOrExt required");
const n = Ut(e, ".").toLowerCase();
return ol[n] || "application/" + n;
}
function dl() {
return {
extSvg: As,
extSrc: pn,
getExt: kn,
encodeSvg: Ms,
canPreview: Pr,
getFileName: Ir,
getMimeType: wr,
formatBytes: Fr,
filePathUri: Ht,
svgToDataUri: Rr,
fileImageUri: Dr,
objectUrl: Ss,
flush: Ts,
inputFiles: cl,
iconOnError: _n,
iconFallbackSrc: jr
};
}
class ul {
view;
includeTypes;
constructor(n) {
Object.assign(this, n);
}
getTypeName() {
return "MetadataApp";
}
getMethod() {
return "GET";
}
createResponse() {
return {};
}
}
const on = wn(void 0), cn = wn(void 0), Gn = wn(void 0);
wn(void 0);
function $t() {
return yt(on);
}
const sn = "/metadata/app.json", fl = {
Boolean: "checkbox",
DateTime: "date",
DateOnly: "date",
DateTimeOffset: "date",
TimeSpan: "time",
TimeOnly: "time",
Byte: "number",
Short: "number",
Int64: "number",
Int32: "number",
UInt16: "number",
UInt32: "number",
UInt64: "number",
Single: "number",
Double: "number",
Decimal: "number",
String: "text",
Guid: "text",
Uri: "text"
}, ml = {
number: "Int32",
checkbox: "Boolean",
date: "DateTime",
"datetime-local": "DateTime",
time: "TimeSpan"
}, xr = {
Byte: "byte",
Int16: "short",
Int32: "int",
Int64: "long",
UInt16: "ushort",
Unt32: "uint",
UInt64: "ulong",
Single: "float",
Double: "double",
Decimal: "decimal"
};
[...Object.keys(xr), ...Object.values(xr)];
const hl = {
String: "string",
Boolean: "bool",
...xr
};
function En(e) {
return hl[e] || e;
}
function $s(e, n) {
return e ? (n || (n = []), e === "Nullable`1" ? En(n[0]) + "?" : e.endsWith("[]") ? `List<${En(e.substring(0, e.length - 2))}>` : n.length === 0 ? En(e) : Kn(En(e), "`") + "<" + n.join(",") + ">") : "";
}
function gl(e) {
return e && $s(e.name, e.genericArgs);
}
class Qt {
Query;
QueryInto;
Create;
Update;
Patch;
Delete;
get AnyQuery() {
return this.Query || this.QueryInto;
}
get AnyUpdate() {
return this.Patch || this.Update;
}
get dataModel() {
return this.AnyQuery?.dataModel;
}
toArray() {
return [this.Query, this.QueryInto, this.Create, this.Update, this.Patch, this.Delete].filter((r) => !!r).map((r) => r);
}
get empty() {
return !this.Query && !this.QueryInto && !this.Create && !this.Update && !this.Patch && !this.Delete;
}
add(n) {
Ye.isQueryInto(n) && !this.QueryInto ? this.QueryInto = n : Ye.isQuery(n) && !this.Query ? this.Query = n : Ye.isCreate(n) && !this.Create ? this.Create = n : Ye.isUpdate(n) && !this.Update ? this.Update = n : Ye.isPatch(n) && !this.Patch ? this.Patch = n : Ye.isDelete(n) && !this.Delete && (this.Delete = n);
}
static from(n) {
const r = new Qt();
return n.forEach((s) => {
r.add(s);
}), r;
}
static forType(n, r) {
let s = new Qt();
if (H.config.apisResolver && n) {
const a = H.config.apisResolver(n, r);
a && (s.Query = a.Query, s.QueryInto = a.QueryInto, s.Create = a.Create, s.Update = a.Update, s.Patch = a.Patch, s.Delete = a.Delete);
}
return n && (r ??= H.metadata?.api, r?.operations.forEach((a) => {
a.dataModel?.name == n && s.add(a);
})), s;
}
}
const Ye = {
Create: "ICreateDb`1",
Update: "IUpdateDb`1",
Patch: "IPatchDb`1",
Delete: "IDeleteDb`1",
AnyRead: ["QueryDb`1", "QueryDb`2"],
AnyWrite: ["ICreateDb`1", "IUpdateDb`1", "IPatchDb`1", "IDeleteDb`1"],
isAnyQuery: (e) => st(e.request.inherits, (n) => Ye.AnyRead.indexOf(n.name) >= 0),
isQuery: (e) => st(e.request.inherits, (n) => n.name === "QueryDb`1"),
isQueryInto: (e) => st(e.request.inherits, (n) => n.name === "QueryDb`2"),
isCrud: (e) => e.request.implements?.some((n) => Ye.AnyWrite.indexOf(n.name) >= 0),
isCreate: (e) => Vn(e, Ye.Create),
isUpdate: (e) => Vn(e, Ye.Update),
isPatch: (e) => Vn(e, Ye.Patch),
isDelete: (e) => Vn(e, Ye.Delete),
model: (e) => e ? st(e.inherits, (n) => Ye.AnyRead.indexOf(n.name) >= 0) ? e.inherits?.genericArgs[0] : e.implements?.find((n) => Ye.AnyWrite.indexOf(n.name) >= 0)?.genericArgs[0] : null
};
function pl(e) {
return e.input?.type || Jn(Or(e));
}
function Rs(e) {
return e.endsWith("?") ? Wa(e, 1) : e;
}
function Jn(e) {
return fl[Rs(e)];
}
function yl(e) {
return e && ml[e] || "String";
}
function Or(e) {
return e.type === "Nullable`1" ? e.genericArgs[0] : e.type;
}
function kr(e) {
return e && Jn(e) == "number" || !1;
}
function Is(e) {
return e && e.toLowerCase() == "string" || !1;
}
function vl(e) {
return e == "List`1" || e.startsWith("List<") || e.endsWith("[]");
}
function Ds(e) {
if (!e?.type) return !1;
const n = Or(e);
return e.isValueType && n.indexOf("`") == -1 || e.isEnum ? !1 : Jn(e.type) == null;
}
function Ps(e) {
if (!e?.type) return !1;
const n = Or(e);
if (e.isValueType && n.indexOf("`") == -1 || e.isEnum) return !0;
const r = e.input?.type;
return r && (r == "hidden" || r == "file" || r == "tag" || r == "combobox" || H.components?.[r]) ? !0 : Jn(e.type) != null;
}
function an(e, n) {
let r = typeof e == "string" ? Xn(e) : e;
r || (console.warn(`Metadata not found for: ${e}`), r = { request: { name: e } });
let s = (
/** @class */
/* @__PURE__ */ (function() {
return function(l) {
Object.assign(this, l);
};
})()
), a = (
/** @class */
(function() {
function l(o) {
Object.assign(this, o);
}
return l.prototype.createResponse = function() {
return r.returnsVoid ? void 0 : new s();
}, l.prototype.getTypeName = function() {
return r.request.name;
}, l.prototype.getMethod = function() {
return r.method || "POST";
}, l;
})()
);
return new a(n);
}
function bl(e, n, r = {}) {
let s = (
/** @class */
/* @__PURE__ */ (function() {
return function(l) {
Object.assign(this, l);
};
})()
), a = (
/** @class */
(function() {
function l(o) {
Object.assign(this, o);
}
return l.prototype.createResponse = function() {
return typeof r.createResponse == "function" ? r.createResponse() : new s();
}, l.prototype.getTypeName = function() {
return e;
}, l.prototype.getMethod = function() {
return r.method || "POST";
}, l;
})()
);
return new a(n);
}
function yn(e, n) {
return e ? (Object.keys(e).forEach((r) => {
let s = e[r];
typeof s == "string" ? s.startsWith("/Date") && (e[r] = nr(St(s))) : s != null && typeof s == "object" && (Array.isArray(s) ? e[r] = Array.from(s) : e[r] = Object.assign({}, s));
}), e) : {};
}
function wl(e, n) {
let r = {};
return Array.from(e.elements).forEach((s) => {
let a = s;
if (!a.id || a.value == null || a.value === "") return;
const l = a.id.toLowerCase(), o = n && n.find((x) => x.name.toLowerCase() == l);
let i = o?.type, u = o?.genericArgs?.[0], m = a.type === "checkbox" ? a.checked : a.value;
kr(i) ? m = Number(m) : i === "List`1" && typeof m == "string" && (m = m.split(",").map((x) => kr(u) ? Number(x) : x)), r[a.id] = m;
}), r;
}
function Er(e) {
return e?.api?.operations && e.api.operations.length > 0;
}
function xl(e) {
if (!Vr() && e?.assert && !H.metadata)
throw new Error("useMetadata() not configured, see: https://docs.servicestack.net/vue/use-metadata");
return H.metadata;
}
function vn(e) {
return e && Er(e) ? (e.date = Qa(/* @__PURE__ */ new Date()), H.metadata = e, H.config.storage?.setItem(sn, JSON.stringify(e)), !0) : !1;
}
function kl() {
H.metadata = null, H.config.storage?.removeItem(sn);
}
function Vr() {
if (H.metadata != null) return !0;
let e = globalThis.Server;
if (Er(e))
vn(e);
else {
const n = H.config.storage?.getItem(sn);
if (n)
try {
vn(JSON.parse(n));
} catch {
console.error(`Could not JSON.parse ${sn} from storage`);
}
}
return H.metadata != null;
}
async function fs(e, n) {
let r = n ? await n() : await fetch(e);
if (r.ok) {
let s = await r.text();
vn(JSON.parse(s));
} else
console.error(`Could not download ${n ? "AppMetadata" : e}: ${r.statusText}`);
Er(H.metadata) || console.warn("AppMetadata is not available");
}
async function Cl(e) {
const { olderThan: n, resolvePath: r, resolve: s, client: a } = e || {};
let l = Vr() && n !== 0;
if (l && n) {
let o = St(H.metadata?.date);
(!o || (/* @__PURE__ */ new Date()).getTime() - o.getTime() > n) && (l = !1);
}
if (!l) {
if ((r || s) && (await fs(r || sn, s), H.metadata != null))
return;
if (a != null) {
const o = await a.api(new ul());
o.succeeded && vn(o.response);
}
if (H.metadata != null) return;
await fs(sn);
}
return H.metadata;
}
function kt(e, n) {
if (H.config.typeResolver) {
let o = H.config.typeResolver(e, n);
if (o) return o;
}
let r = H.metadata?.api;
if (!r || !e) return null;
let s = r.types.find((o) => o.name.toLowerCase() === e.toLowerCase() && (!n || o.namespace == n));
if (s) return s;
let a = Xn(e);
if (a) return a.request;
let l = r.operations.find((o) => o.response && o.response.name.toLowerCase() === e.toLowerCase() && (!n || o.response.namespace == n));
return l ? l.response : null;
}
function Xn(e) {
if (H.config.apiResolver) {
const s = H.config.apiResolver(e);
if (s) return s;
}
let n = H.metadata?.api;
return n ? n.operations.find((s) => s.request.name.toLowerCase() === e.toLowerCase()) : null;
}
function Nl({ dataModel: e }) {
const n = H.metadata?.api;
if (!n) return [];
let r = n.operations;
if (e) {
const s = typeof e == "string" ? kt(e) : e;
r = r.filter((a) => Fs(a.dataModel, s));
}
return r;
}
function Hr(e) {
return e ? kt(e.name, e.namespace) : null;
}
function Fs(e, n) {
return e && n && e.name === n.name && (!e.namespace || !n.namespace || e.namespace === n.namespace);
}
function Ll(e, n) {
let r = kt(e);
return r && r.properties && r.properties.find((a) => a.name.toLowerCase() === n.toLowerCase());
}
function js(e) {
return Os(kt(e));
}
function Os(e) {
if (e && e.isEnum && e.enumNames != null) {
let n = {};
for (let r = 0; r < e.enumNames.length; r++) {
const s = (e.enumDescriptions ? e.enumDescriptions[r] : null) || e.enumNames[r], a = (e.enumValues != null ? e.enumValues[r] : null) || e.enumNames[r];
n[a] = s;
}
return n;
}
return null;
}
function Es(e) {
if (!e) return null;
let n = {}, r = e.input && e.input.allowableEntries;
if (r) {
for (let a = 0; a < r.length; a++) {
let l = r[a];
n[l.key] = l.value;
}
return n;
}
let s = e.allowableValues || (e.input ? e.input.allowableValues : null);
if (s) {
for (let a = 0; a < s.length; a++) {
let l = s[a];
n[l] = l;
}
return n;
}
if (e.isEnum) {
const a = e.genericArgs && e.genericArgs.length == 1 ? e.genericArgs[0] : e.type, l = kt(a);
if (l)
return Os(l);
}
return null;
}
function zr(e) {
if (!e) return;
const n = [];
return Object.keys(e).forEach((r) => n.push({ key: r, value: e[r] })), n;
}
function Ml(e, n) {
const s = ((a, l) => Object.assign({
id: a,
name: a,
type: l
}, n))(e.name, n?.type || pl(e) || "text");
return e.isEnum && (s.type = "select", s.allowableEntries = zr(Es(e))), s;
}
function Sl(e) {
let n = [];
if (e) {
const r = mt(e), s = Xn(e.name), a = Hr(s?.dataModel);
r.forEach((l) => {
if (!Ps(l)) return;
const o = Ml(l, l.input);
if (o.id = Ua(o.id), o.type == "file" && l.uploadTo && !o.accept) {
const i = H.metadata?.plugins.filesUpload?.locations.find((u) => u.name == l.uploadTo);
i && !o.accept && i.allowExtensions && (o.accept = i.allowExtensions.map((u) => u.startsWith(".") ? u : `.${u}`).join(","));
}
if (a) {
const i = a.properties?.find((u) => u.name == l.name);
l.ref || (l.ref = i?.ref);
}
if (o.options)
try {
const i = {
input: o,
$typeFields: r.map((m) => m.name),
$dataModelFields: a ? mt(a).map((m) => m.name) : [],
...H.config.scopeWhitelist
}, u = sr(o.options, i);
Object.keys(u).forEach((m) => {
o[m] = u[m];
});
} catch {
console.error(`failed to evaluate '${o.options}'`);
}
n.push(o);
});
}
return n;
}
function Br(e, n) {
if (!n.type)
return console.error("enumDescriptions missing {type:'EnumType'} options"), [`${e}`];
const r = kt(n.type);
if (!r?.enumValues)
return console.error(`Could not find metadata for ${n.type}`), [`${e}`];
const s = [];
for (let a = 0; a < r.enumValues.length; a++) {
const l = parseInt(r.enumValues[a]);
l > 0 && (l & e) === l && s.push(r.enumDescriptions?.[a] || r.enumNames?.[a] || `${e}`);
}
return s;
}
function Vs(e) {
return (n) => typeof n == "number" ? Br(n, { type: e }) : n;
}
function mt(e) {
if (!e) return [];
let n = [], r = {};
function s(a) {
a.forEach((l) => {
r[l.name] || (r[l.name] = 1, n.push(l));
});
}
for (; e; )
e.properties && s(e.properties), e = e.inherits ? Hr(e.inherits) : null;
return n.map((a) => a.type.endsWith("[]") ? { ...a, type: "List`1", genericArgs: [a.type.substring(0, a.type.length - 2)] } : a);
}
function Vn(e, n) {
return e.request.implements?.some((r) => r.name === n) || !1;
}
function Wt(e) {
return e ? Hs(e, mt(e)) : null;
}
function Hs(e, n) {
let r = n.find((l) => l.name.toLowerCase() === "id");
if (r && r.isPrimaryKey) return r;
let a = n.find((l) => l.isPrimaryKey) || r;
if (!a) {
let l = Ye.model(e);
if (l)
return st(kt(l), (o) => Wt(o));
console.error(`Primary Key not found in ${e.name}`);
}
return a || null;
}
function Tl(e, n) {
return st(Wt(e), (r) => Se(n, r.name));
}
function zs(e, n, r) {
return e && e.valueType === "none" ? "" : r.key === "%In" || r.key === "%Between" ? `(${r.value})` : Al(n, r.value);
}
function Al(e, n) {
return e ? (e = Rs(e), kr(e) || e === "Boolean" ? n : vl(e) ? `[${n}]` : `'${n}'`) : n;
}
function Dt(e, n) {
return { name: e, value: n };
}
const $l = [
Dt("=", "%"),
Dt("!=", "%!"),
Dt(">=", ">%"),
Dt(">", "%>"),
Dt("<=", "%<"),
Dt("<", "<%"),
Dt("In", "%In"),
Dt("Between", "%Between"),
{ name: "Starts With", value: "%StartsWith", types: "string" },
{ name: "Contains", value: "%Contains", types: "string" },
{ name: "Ends With", value: "%EndsWith", types: "string" },
{ name: "Exists", value: "%IsNotNull", valueType: "none" },
{ name: "Not Exists", value: "%IsNull", valueType: "none" }
];
function ut(e) {
if (!e && typeof yt == "function")
try {
e = yt(cn);
} catch {
}
return Vr(), {
loadMetadata: (r) => Cl({ ...r, client: e }),
getMetadata: xl,
setMetadata: vn,
clearMetadata: kl,
metadataApp: H.metadata?.app || null,
metadataApi: H.metadata?.api || null,
filterDefinitions: H.metadata?.plugins?.autoQuery?.viewerConventions || $l,
typeOf: kt,
typeOfRef: Hr,
typeEquals: Fs,
apiOf: Xn,
findApis: Nl,
typeName: gl,
typeName2: $s,
property: Ll,
enumOptions: js,
propertyOptions: Es,
createFormLayout: Sl,
typeProperties: mt,
supportsProp: Ps,
Crud: Ye,
Apis: Qt,
getPrimaryKey: Wt,
getPrimaryKeyByProps: Hs,
getId: Tl,
createDto: an,
makeDto: bl,
toFormValues: yn,
formValues: wl,
isComplexProp: Ds,
asKvps: zr,
expandEnumFlags: Br,
enumFlagsConverter: Vs
};
}
class lt {
static Lookup = {};
static async getOrFetchValue(n, r, s, a, l, o, i) {
const u = lt.getValue(s, i, l);
return u ?? (await lt.fetchLookupIds(n, r, s, a, l, o, [i]), lt.getValue(s, i, l));
}
static getValue(n, r, s) {
const a = lt.Lookup[n];
if (a) {
const l = a[r];
if (l)
return s = s.toLowerCase(), l[s];
}
}
static setValue(n, r, s, a) {
const l = lt.Lookup[n] ?? (lt.Lookup[n] = {}), o = l[r] ?? (l[r] = {});
s = s.toLowerCase(), o[s] = a;
}
static setRefValue(n, r) {
const s = Se(r, n.refId);
if (s == null || n.refLabel == null)
return null;
const a = Se(r, n.refLabel);
return lt.setValue(n.model, s, n.refLabel, a), a;
}
static async fetchLookupIds(n, r, s, a, l, o, i) {
const u = r.operations.find((m) => Ye.isAnyQuery(m) && m.dataModel?.name == s);
if (u) {
const m = lt.Lookup[s] ?? (lt.Lookup[s] = {}), x = [];
Object.keys(m).forEach((E) => {
const T = m[E];
Se(T, l) && x.push(E);
});
const $ = i.filter((E) => !x.includes(E));
if ($.length == 0)
return;
const p = o ? null : `${a},${l}`, w = {
[a + "In"]: $.join(",")
};
p && (w.fields = p);
const I = an(u, w), k = await n.api(I, { jsconfig: "edv,eccn" });
if (k.succeeded)
(Se(k.response, "results") || []).forEach((T) => {
if (!Se(T, a)) {
console.error(`result[${a}] == null`, T);
return;
}
const O = `${Se(T, a)}`, y = Se(T, l);
l = l.toLowerCase();
const L = m[O] ?? (m[O] = {});
L[l] = `${y}`;
});
else {
console.error(`Failed to call ${u.request.name}`);
return;
}
}
}
}
let Cr = () => (/* @__PURE__ */ new Date()).getTime(), Rl = ["/", "T", ":", "-"], vt = {
//locale: null,
assumeUtc: !0,
//number: null,
date: {
method: "Intl.DateTimeFormat",
options: "{dateStyle:'medium'}"
},
maxFieldLength: 150,
maxNestedFields: 2,
maxNestedFieldLength: 30
}, Il = new Intl.RelativeTimeFormat(vt.locale, {}), ms = 1440 * 60 * 1e3 * 365, hr = {
year: ms,
month: ms / 12,
day: 1440 * 60 * 1e3,
hour: 3600 * 1e3,
minute: 60 * 1e3,
second: 1e3
}, zt = {
currency: qs,
bytes: Us,
link: Qs,
linkTel: Ws,
linkMailTo: Ks,
icon: Zs,
iconRounded: _s,
attachment: Gs,
hidden: Js,
time: Xs,
relativeTime: Ur,
relativeTimeFromMs: er,
enumFlags: ea,
formatDate: dn,
formatNumber: qr
};
"iconOnError" in globalThis || (globalThis.iconOnError = _n);
class Dl {
static currency = { method: "currency" };
static bytes = { method: "bytes" };
static link = { method: "link" };
static linkTel = { method: "linkTel" };
static linkMailTo = { method: "linkMailTo" };
static icon = { method: "icon" };
static iconRounded = { method: "iconRounded" };
static attachment = { method: "attachment" };
static time = { method: "time" };
static relativeTime = { method: "relativeTime" };
static relativeTimeFromMs = { method: "relativeTimeFromMs" };
static date = { method: "formatDate" };
static number = { method: "formatNumber" };
static hidden = { method: "hidden" };
static enumFlags = { method: "enumFlags" };
}
function Pl(e) {
vt = Object.assign({}, vt, e);
}
function Fl(e) {
Object.keys(e || {}).forEach((n) => {
typeof e[n] == "function" && (zt[n] = e[n]);
});
}
function Bs() {
return zt;
}
function Cn(e, n) {
return n ? bt("span", e, n) : e;
}
function qs(e, n) {
const r = Tt(n, ["currency"]);
return Cn(new Intl.NumberFormat(void 0, { style: "currency", currency: n?.currency || "USD" }).format(e), r);
}
function Us(e, n) {
return Cn(Fr(e), n);
}
function Qs(e, n) {
return bt("a", e, rr({ ...n, href: e }));
}
function Ws(e, n) {
return bt("a", e, rr({ ...n, href: `tel:${e}` }));
}
function Ks(e, n) {
n || (n = {});
let { subject: r, body: s } = n, a = Tt(n, ["subject", "body"]), l = {};
return r && (l.subject = r), s && (l.body = s), bt("a", e, rr({ ...a, href: `mailto:${rn(e, l)}` }));
}
function Zs(e, n) {
return bt("img", void 0, Object.assign({ class: "w-6 h-6", title: e, src: tn(e), onerror: "iconOnError(this)" }, n));
}
function _s(e, n) {
return bt("img", void 0, Object.assign({ class: "w-8 h-8 rounded-full", title: e, src: tn(e), onerror: "iconOnError(this)" }, n));
}
function Gs(e, n) {
let r = Ir(e), a = kn(r) == null || Pr(e) ? tn(e) : jr(e);
const l = tn(a);
let o = n && (n["icon-class"] || n.iconClass), i = bt("img", void 0, Object.assign({ class: "w-6 h-6", src: l, onerror: "iconOnError(this,'att')" }, o ? { class: o } : null)), u = `<span class="pl-1">${r}</span>`;
return bt("a", i + u, Object.assign({ class: "flex", href: tn(e), title: e }, n ? Tt(n, ["icon-class", "iconClass"]) : null));
}
function Js(e) {
return "";
}
function Xs(e, n) {
let r = typeof e == "string" ? new Date(ws(e) * 1e3) : Zn(e) ? St(e) : null;
return Cn(r ? _a(r) : e, n);
}
function dn(e, n) {
if (e == null) return "";
let r = typeof e == "number" ? new Date(e) : typeof e == "string" ? St(e) : e;
if (!Zn(r))
return console.warn(`${r} is not a Date value`), e == null ? "" : `${e}`;
let s = vt.date ? tr(vt.date) : null;
return Cn(typeof s == "function" ? s(r) : Za(r), n);
}
function qr(e, n) {
if (typeof e != "number") return e;
let r = vt.number ? tr(vt.number) : null, s = typeof r == "function" ? r(e) : `${e}`;
return s === "" && (console.warn(`formatNumber(${e}) => ${s}`, r), s = `${e}`), Cn(s, n);
}
function qn(e) {
const n = Math.floor(e / 1e3), r = Math.floor(n / 60), s = Math.floor(r / 60), a = Math.floor(s / 24);
return a > 0 ? `${a}d ${qn(e - a * 24 * 60 * 6e4)}` : s > 0 ? `${s}h ${qn(e - s * 60 * 6e4)}` : r > 0 ? `${r}m ${qn(e - r * 6e4)}` : n > 0 ? `${n}s` : `${e}ms`;
}
function jl(e) {
return e >= 1e9 ? (e / 1e9).toFixed(1) + "b" : e >= 1e6 ? (e / 1e6).toFixed(1) + "m" : e >= 1e3 ? (e / 1e3).toFixed(1) + "k" : e.toLocaleString();
}
function Ys(e, n, r) {
let s = Ka(e), a = n ? tr(n) : null;
if (typeof a == "function") {
let o = r;
if (n?.options)
try {
o = sr(n.options, r);
} catch (i) {
console.error(`Could not evaluate '${n.options}'`, i, ", with scope:", r);
}
return a(e, o);
}
let l = s != null ? Zn(s) ? dn(s, r) : typeof s == "number" ? qr(s, r) : s : null;
return l ?? "";
}
function Yn(e, n, r) {
return Kt(e) ? Ys(e, n, r) : zl(e, n, r);
}
function Ol(e) {
if (e == null) return NaN;
if (typeof e == "number")
return e;
if (Zn(e))
return e.getTime() - Cr();
if (typeof e == "string") {
let n = Number(e);
if (!isNaN(n))
return n;
if (e[0] === "P" || e.startsWith("-P"))
return ws(e) * 1e3 * -1;
if (Ga(e, Rl) >= 0)
return St(e).getTime() - Cr();
}
return NaN;
}
function er(e, n) {
for (let r in hr)
if (Math.abs(e) > hr[r] || r === "second")
return (n || Il).format(Math.round(e / hr[r]), r);
}
function Ur(e, n) {
let r = Ol(e);
return isNaN(r) ? "" : er(r, n);
}
function El(e, n) {
return er(e.getTime() - (n ? n.getTime() : Cr()));
}
function ea(e, n) {
return Br(e, n).join(", ");
}
function tr(e) {
if (!e) return null;
let { method: n, options: r } = e, s = `${n}(${r})`, a = zt[s] || zt[n];
if (typeof a == "function") return a;
let l = e.locale || vt.locale;
if (n.startsWith("Intl.")) {
let o = l ? `'${l}'` : "undefined", i = `return new ${n}(${o},${r || "undefined"})`;
try {
let u = Function(i)();
return a = n === "Intl.DateTimeFormat" ? (m) => u.format(St(m)) : n === "Intl.NumberFormat" ? (m) => u.format(Number(m)) : n === "Intl.RelativeTimeFormat" ? (m) => Ur(m, u) : (m) => u.format(m), zt[s] = a;
} catch (u) {
console.error(`Invalid format: ${i}`, u);
}
} else {
let o = globalThis[n];
if (typeof o == "function") {
let i = r != null ? Function("return " + r)() : void 0;
return a = (u) => o(u, i, l), zt[s] = a;
}
console.error(`No '${n}' function exists`, Object.keys(zt));
}
return null;
}
function ta(e, n) {
return e ? e.length > n ? e.substring(0, n) + "..." : e : "";
}
function na(e) {
return e.substring(0, 6) === "/Date(" ? dn(St(e)) : e;
}
function Vl(e) {
return Qr(ln(e)).replace(/"/g, "");
}
function ra(e) {
if (e == null || e === "") return "";
if (typeof e == "string")
try {
return JSON.parse(e);
} catch {
console.warn("couldn't parse as JSON", e);
}
return e;
}
function Qr(e, n = 4) {
return e = ra(e), typeof e != "object" ? typeof e == "string" ? e : `${e}` : JSON.stringify(e, void 0, n);
}
function Hl(e) {
return e = ra(e), typeof e != "object" ? typeof e == "string" ? e : `${e}` : (e = Object.assign({}, e), e = ln(e), Qr(e));
}
function ln(e) {
if (e == null) return null;
if (typeof e == "string") return na(e);
if (Kt(e)) return e;
if (e instanceof Date) return dn(e);
if (Array.isArray(e)) return e.map(ln);
if (typeof e == "object") {
let n = {};
return Object.keys(e).forEach((r) => {
r != "__type" && (n[r] = ln(e[r]));
}), n;
}
return e;
}
function zl(e, n, r) {
let s = e;
if (Array.isArray(e)) {
if (Kt(e[0]))
return s.join(",");
e[0] != null && (s = e[0]);
}
if (s == null) return "";
if (s instanceof Date) return dn(s, r);
let a = Object.keys(s), l = [];
for (let o = 0; o < Math.min(vt.maxNestedFields, a.length); o++) {
let i = a[o], u = `${ln(s[i])}`;
l.push(`<b class="font-medium">${i}</b>: ${pr(ta(na(u), vt.maxNestedFieldLength))}`);
}
return a.length > 2 && l.push("..."), bt("span", "{ " + l.join(", ") + " }", Object.assign({ title: pr(Vl(e)) }, r));
}
function ki() {
return {
Formats: Dl,
setDefaultFormats: Pl,
getFormatters: Bs,
setFormatters: Fl,
formatValue: Yn,
formatter: tr,
dateInputFormat: nr,
currency: qs,
bytes: Us,
link: Qs,
linkTel: Ws,
linkMailTo: Ks,
icon: Zs,
iconRounded: _s,
attachment: Gs,
hidden: Js,
time: Xs,
relativeTime: Ur,
relativeTimeFromDate: El,
relativeTimeFromMs: er,
enumFlags: ea,
formatDate: dn,
formatNumber: qr,
humanifyMs: qn,
humanifyNumber: jl,
indentJson: Qr,
prettyJson: Hl,
scrub: ln,
truncate: ta,
apiValueFmt: Ys,
iconOnError: _n
};
}
class Bl {
callbacks = {};
register(n, r) {
this.callbacks[n] = r;
}
has(n) {
return !!this.callbacks[n];
}
invoke(n, r) {
const s = this.callbacks[n];
typeof s == "function" && s(n, r);
}
}
class ql {
store = /* @__PURE__ */ new Map();
get length() {
return this.store.size;
}
getItem(n) {
return this.store.get(n) ?? null;
}
setItem(n, r) {
this.store.set(n, r);
}
removeItem(n) {
this.store.delete(n);
}
clear() {
this.store.clear();
}
key(n) {
return Array.from(this.store.keys())[n] ?? null;
}
}
class Ul {
get length() {
return localStorage.length;
}
getItem(n) {
return localStorage.getItem(n);
}
setItem(n, r) {
localStorage.setItem(n, r);
}
removeItem(n) {
localStorage.removeItem(n);
}
clear() {
localStorage.clear();
}
key(n) {
return localStorage.key(n);
}
}
let hs = null, gs = null, Hn = /* @__PURE__ */ new Set();
class H {
static config = {
redirectSignIn: "/signin",
redirectSignOut: "/auth/logout",
navigate: (n) => location.href = n,
assetsPathResolver: (n) => n,
fallbackPathResolver: (n) => n,
storage: typeof localStorage < "u" ? new Ul() : new ql(),
tableIcon: { svg: "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><g fill='none' stroke='currentColor' stroke-width='1.5'><path d='M5 12v6s0 3 7 3s7-3 7-3v-6'/><path d='M5 6v6s0 3 7 3s7-3 7-3V6'/><path d='M12 3c7 0 7 3 7 3s0 3-7 3s-7-3-7-3s0-3 7-3Z'/></g></svg>" },
scopeWhitelist: {
enumFlagsConverter: Vs,
...Bs()
}
};
static autoQueryGridDefaults = {
deny: [],
hide: [],
toolbarButtonClass: void 0,
tableStyle: "stripedRows",
take: 25,
maxFieldLength: 150
};
static events = Ja();
static get user() {
return hs;
}
static set user(n) {
hs = n, Hn.forEach((r) => r());
}
static get metadata() {
return gs;
}
static set metadata(n) {
gs = n, Hn.forEach((r) => r());
}
static subscribe(n) {
return Hn.add(n), () => Hn.delete(n);
}
static components = {};
static component(n) {
const r = H.components[n];
if (r) return r;
const s = os(n), a = Object.keys(H.components).find((l) => os(l) === s);
return a && H.components[a] || null;
}
static interceptors = new Bl();
}
function Ql(e) {
H.config = Object.assign(H.config, e);
}
function Wl(e) {
H.autoQueryGridDefaults = Object.assign(H.autoQueryGridDefaults, e);
}
function Pt(e) {
return e && H.config.assetsPathResolver ? H.config.assetsPathResolver(e) : e;
}
function Nr(e) {
return e && H.config.fallbackPathResolver ? H.config.fallbackPathResolver(e) : e;
}
function Kl(e, n) {
H.interceptors.register(e, n);
}
function Zl(e, n) {
H.components[e] = n;
}
function _l(e) {
Object.assign(H.components, e);
}
function Gl(e) {
H.config.linkComponent = e;
}
function Nn() {
const e = H.events;
return {
config: H.config,
setConfig: Ql,
events: e,
autoQueryGridDefaults: H.autoQueryGridDefaults,
setAutoQueryGridDefaults: Wl,
assetsPathResolver: Pt,
fallbackPathResolver: Nr,
registerInterceptor: Kl,
registerComponent: Zl,
registerComponents: _l,
setLinkComponent: Gl
};
}
function nr(e) {
if (e == null || typeof e == "object") return "";
const n = St(e);
return n == null || n.toString() == "Invalid Date" ? "" : n.toISOString().substring(0, 10) ?? "";
}
function sa(e) {
if (e == null || typeof e == "object") return "";
const n = St(e);
return n == null || n.toString() == "Invalid Date" ? "" : n.toISOString().substring(0, 19) ?? "";
}
function aa(e) {
return e == null ? "" : el(e);
}
function Lr(e, n) {
return H.config.inputValue ? H.config.inputValue(e, n) : e === "date" ? nr(n) : e === "datetime-local" ? sa(n) : e === "time" ? aa(n) : e === "number" || e === "range" ? n == null ? "" : Number(n) : n ?? "";
}
function Jl(e, n) {
typeof e == "function" ? e(n) : e.current = n;
}
function la(e) {
return e;
}
function Ln(e, n, r) {
r ? (n(e.entering.cls + " " + e.entering.from), setTimeout(() => n(e.entering.cls + " " + e.entering.to), 0)) : (n(e.leaving.cls + " " + e.leaving.from), setTimeout(() => n(e.leaving.cls + " " + e.leaving.to), 0));
}
function Un(e) {
if (typeof document > "u") return;
let n = e?.after || document.activeElement, r = n && n.form;
if (r) {
let s = ':not([disabled]):not([tabindex="-1"])', a = r.querySelectorAll(`a:not([disabled]), button${s}, input[type=text]${s}, [tabindex]${s}`), l = Array.prototype.filter.call(
a,
(i) => i.offsetWidth > 0 || i.offsetHeight > 0 || i === n
), o = l.indexOf(n);
o > -1 && (l[o + 1] || l[0]).focus();
}
}
function Ft(e) {
if (!e) return null;
if (typeof e == "string")
return e;
const n = typeof e == "function" ? new e() : typeof e == "object" ? e : null;
if (!n)
throw new Error(`Invalid DTO Type '${typeof e}'`);
if (typeof n.getTypeName != "function")
throw new Error(`${JSON.stringify(n)} is not a Request DTO`);
const r = n.getTypeName();
if (!r)
throw new Error("DTO Required");
return r;
}
function bt(e, n, r) {
r || (r = {});
let s = r.cls || r.className || r.class;
return s && (r = Tt(r, ["cls", "class", "className"]), r.class = s), n == null ? `<${e}` + Mr(r) + "/>" : `<${e}` + Mr(r) + `>${n || ""}</${e}>`;
}
function Mr(e) {
return Object.keys(e).reduce((n, r) => `${n} ${r}="${pr(e[r])}"`, "");
}
function rr(e) {
return Object.assign({ target: "_blank", rel: "noopener", class: "text-blue-600" }, e);
}
function tn(e) {
return Pt(e);
}
let Xl = ["string", "number", "boolean", "null", "undefined"];
function Kt(e) {
return Xl.indexOf(typeof e) >= 0 || e instanceof Date;
}
function bn(e) {
return !Kt(e);
}
function Qn(e) {
return typeof e == "string" ? JSON.parse(e) : null;
}
function Wr(e, n) {
if (typeof history < "u") {
const r = n ? rn(xs(location.href, "?"), e) : Ya(location.href, e);
history.pushState({}, "", r);
}
}
function sr(e, n) {
if (["function", "Function", "eval", "=>", ";"].some((a) => e.includes(a)))
throw new Error(`Unsafe script: '${e}'`);
const s = Object.assign(
Object.keys(globalThis).reduce((a, l) => (a[l] = void 0, a), {}),
n
);
return new Function("with(this) { return (" + e + ") }").call(s);
}
function Sr(e) {
typeof navigator < "u" && navigator.clipboard.writeText(e);
}
function Kr(e) {
const n = H.config.storage.getItem(e);
return n ? JSON.parse(n) : null;
}
function ar(e, n) {
return rn(`swr.${Xa(e)}`, n ? Object.assign({}, e, n) : e);
}
function Yl(e) {
if (e.request) {
const n = ar(e.request, e.args);
H.config.storage.removeItem(n);
}
}
async function ia(e, n, r, s, a) {
const l = ar(n, s);
r(new ct({ response: Kr(l) }));
const o = await e.api(n, s, a);
if (o.succeeded && o.response) {
o.response._date = (/* @__PURE__ */ new Date()).valueOf();
const i = JSON.stringify(o.response);
H.config.storage.setItem(l, i), r(o);
}
return o;
}
function oa(e, n) {
let r = null;
return (...s) => {
r && clearTimeout(r), r = setTimeout(() => {
e(...s);
}, n || 100);
};
}
function Bt(e) {
return typeof e == "string" ? e.split(",") : e || [];
}
function qt(e, n) {
const r = Bt(n);
return e.reduce((s, a) => (s[a] = !r.includes(a), s), {});
}
function ei(e) {
return new Promise((n) => setTimeout(n, e));
}
function ca(e) {
const n = [], r = [];
for (const s of e) {
const a = s.toLowerCase();
r.includes(a) || (n.push(s), r.push(a));
}
return n;
}
function Ci() {
return {
dateInputFormat: nr,
dateTimeInputFormat: sa,
timeInputFormat: aa,
textInputValue: Lr,
setRef: Jl,
unRefs: la,
transition: Ln,
focusNextElement: Un,
getTypeName: Ft,
htmlTag: bt,
htmlAttrs: Mr,
linkAttrs: rr,
toAppUrl: tn,
isPrimitive: Kt,
isComplexType: bn,
pushState: Wr,
scopedExpr: sr,
copyText: Sr,
fromCache: Kr,
swrCacheKey: ar,
swrClear: Yl,
swrApi: ia,
asStrings: Bt,
asOptions: qt,
createDebounce: oa,
delay: ei,
uniqueIgnoreCase: ca
};
}
function Mn(e) {
const [n, r] = F(!1), [s, a] = F(), [l, o] = F(), i = yt(cn), u = e ?? i, m = () => a(void 0);
function x({ message: y, errorCode: L, fieldName: g, errors: N }) {
L || (L = "Exception"), N || (N = []);
const W = g ? new On({
errorCode: L,
message: y,
errors: [new mr({ fieldName: g, errorCode: L, message: y })]
}) : new On({ errorCode: L, message: y, errors: N });
return a(W), W;
}
function $({ fieldName: y, message: L, errorCode: g }) {
g || (g = "Exception"), a((N) => {
if (N) {
let W = new On(N);
return W.errors = [
...(W.errors || []).filter((P) => P.fieldName?.toLowerCase() !== y?.toLowerCase()),
new mr({ fieldName: y, message: L, errorCode: g })
], W;
} else
return new On({
errorCode: g,
message: L,
errors: [new mr({ fieldName: y, errorCode: g, message: L })]
});
});
}
async function p(y, L, g) {
r(!0);
let N = await u.api(y, L, g);
return r(!1), o(N.response), a(N.error), N;
}
async function w(y, L, g) {
r(!0);
let N = await u.apiVoid(y, L, g);
return r(!1), o(N.response), a(N.error), N;
}
async function I(y, L, g, N) {
r(!0);
let W = await u.apiForm(y, L, g, N);
return r(!1), o(W.response), a(W.error), W;
}
async function k(y, L, g, N) {
r(!0);
let W = await u.apiFormVoid(y, L, g, N);
return r(!1), o(W.response), a(W.error), W;
}
async function E(y, L, g, N) {
return ia(u, y, L, g, N);
}
function T(y, L) {
const [g, N] = F(new ct()), W = Xe(oa(async (P) => {
const b = await u.api(P);
N(b);
}, L?.delayMs));
return be(() => {
const P = y(), b = Kr(ar(P));
b && N(new ct({ response: b })), L?.delayMs === 0 ? u.api(P).then((J) => N(J)) : W.current(P);
}, [y, L?.args, L?.method, L?.delayMs]), be(() => {
u.api(y(), L?.args, L?.method).then((P) => N(P));
}, []), g;
}
return {
setError: x,
addFieldError: $,
clearErrors: m,
loading: n,
error: s,
api: p,
apiVoid: w,
apiForm: I,
apiFormVoid: k,
swr: E,
swrEffect: T,
unRefs: la
};
}
function da(e) {
return e && e.SessionId ? tl(e) : e;
}
function ua(e) {
e ? (H.user = da(e), H.events.publish("signIn", e)) : Zr();
}
function Zr() {
H.user = null, H.events.publish("signOut", null);
}
function ti() {
return H.user;
}
const _r = (e) => e?.roles || [], Gr = (e) => e?.permissions || [];
function Jr(e) {
return _r(H.user).indexOf(e) >= 0;
}
function fa(e) {
return Gr(H.user).indexOf(e) >= 0;
}
function lr() {
return Jr("Admin");
}
function nn(e) {
if (!e) return !1;
if (!e.requiresAuth)
return !0;
const n = H.user;
if (!n)
return !1;
if (lr())
return !0;
let [r, s] = [_r(n), Gr(n)], [a, l, o, i] = [
e.requiredRoles || [],
e.requiredPermissions || [],
e.requiresAnyRole || [],
e.requiresAnyPermission || []
];
return !(!a.every((u) => r.indexOf(u) >= 0) || o.length > 0 && !o.some((u) => r.indexOf(u) >= 0) || !l.every((u) => s.indexOf(u) >= 0) || i.length > 0 && !i.every((u) => s.indexOf(u) >= 0));
}
function ma(e) {
if (!e || !e.requiresAuth) return null;
const n = H.user;
if (!n)
return `<b>${e.request.name}</b> requires Authentication`;
if (lr())
return null;
let [r, s] = [_r(n), Gr(n)], [a, l, o, i] = [
e.requiredRoles || [],
e.requiredPermissions || [],
e.requiresAnyRole || [],
e.requiresAnyPermission || []
], u = a.filter((x) => r.indexOf(x) < 0);
if (u.length > 0)
return `Requires ${u.map((x) => "<b>" + x + "</b>").join(", ")} Role` + (u.length > 1 ? "s" : "");
let m = l.filter((x) => s.indexOf(x) < 0);
return m.length > 0 ? `Requires ${m.map((x) => "<b>" + x + "</b>").join(", ")} Permission` + (m.length > 1 ? "s" : "") : o.length > 0 && !o.some((x) => r.indexOf(x) >= 0) ? `Requires any ${o.filter((x) => r.indexOf(x) < 0).map((x) => "<b>" + x + "</b>").join(", ")} Role` + (u.length > 1 ? "s" : "") : i.length > 0 && !i.every((x) => s.indexOf(x) >= 0) ? `Requires any ${i.filter((x) => s.indexOf(x) < 0).map((x) => "<b>" + x + "</b>").join(", ")} Permission` + (m.length > 1 ? "s" : "") : null;
}
function Xr() {
const [, e] = F(0);
be(() => {
const s = H.subscribe(() => e((a) => a + 1));
return () => {
s();
};
}, []);
const n = c(() => H.user || null, [H.user]), r = c(() => H.user != null, [H.user]);
return { signIn: ua, signOut: Zr, user: n, toAuth: da, isAuthenticated: r, hasRole: Jr, hasPermission: fa, isAdmin: lr, canAccess: nn, invalidAccessMessage: ma };
}
function Ni() {
return {
signIn: ua,
signOut: Zr,
getAuth: ti,
hasRole: Jr,
hasPermission: fa,
isAdmin: lr,
canAccess: nn,
invalidAccessMessage: ma
};
}
function ot(e, n) {
return Array.isArray(e) ? e.indexOf(n) >= 0 : e == n || e.includes(n);
}
const Wn = {
blue: "text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-200",
purple: "text-purple-600 dark:text-purple-400 hover:text-purple-800 dark:hover:text-purple-200",
red: "text-red-700 dark:text-red-400 hover:text-red-900 dark:hover:text-red-200",
green: "text-green-600 dark:text-green-400 hover:text-green-800 dark:hover:text-green-200",
sky: "text-sky-600 dark:text-sky-400 hover:text-sky-800 dark:hover:text-sky-200",
cyan: "text-cyan-600 dark:text-cyan-400 hover:text-cyan-800 dark:hover:text-cyan-200",
indigo: "text-indigo-600 dark:text-indigo-400 hover:text-indigo-800 dark:hover:text-indigo-200"
}, ht = {
base: "block w-full sm:text-sm rounded-md dark:text-white dark:bg-gray-900 disabled:bg-slate-50 dark:disabled:bg-slate-900 disabled:text-slate-500 disabled:border-slate-200 dark:disabled:border-slate-700 disabled:shadow-none",
invalid: "pr-10 border-red-300 text-red-900 placeholder-red-300 focus:outline-none focus:ring-red-500 focus:border-red-500",
valid: "shadow-sm focus:ring-indigo-500 focus:border-indigo-500 border-gray-300 dark:border-gray-600"
}, hn = {
panelClass: "shadow sm:rounded-md",
formClass: "space-y-6 bg-white dark:bg-black py-6 px-4 sm:p-6",
headingClass: "text-lg font-medium leading-6 text-gray-900 dark:text-gray-100",
subHeadingClass: "mt-1 text-sm text-gray-500 dark:text-gray-400"
}, gn = {
panelClass: "pointer-events-auto w-screen xl:max-w-3xl md:max-w-xl max-w-lg",
formClass: "flex h-full flex-col divide-y divide-gray-200 dark:divide-gray-700 shadow-xl bg-white dark:bg-black",
titlebarClass: "bg-gray-50 dark:bg-gray-900 px-4 py-6 sm:px-6",
headingClass: "text-lg font-medium text-gray-900 dark:text-gray-100",
subHeadingClass: "mt-1 text-sm text-gray-500 dark:text-gray-400",
closeButtonClass: "rounded-md bg-gray-50 dark:bg-gray-900 text-gray-400 dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:ring-offset-black"
}, Tr = {
modalClass: "relative transform overflow-hidden rounded-lg bg-white dark:bg-black text-left shadow-xl transition-all sm:my-8",
sizeClass: "sm:max-w-prose lg:max-w-screen-md xl:max-w-scr