@yongdall/web 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
- import{Signal as e,Signal as t}from"signal-polyfill";import{ArrayStore as n,ArrayStore as r,ObjectStore as i,ObjectStore as a,Store as o,Store as s,renderStore as c,renderStore as l}from"@neeloong/form";import u,{default as d}from"dot-request";var f=Object.defineProperty,p=(e,t)=>{let n={};for(var r in e)f(n,r,{get:e[r],enumerable:!0});return t||f(n,Symbol.toStringTag,{value:`Module`}),n};function m(e,n){let r=!0;if(n?.aborted)return;let i=new t.subtle.Watcher(()=>{r&&(r=!1,queueMicrotask(()=>{r=!0;for(let e of i.getPending())e.get();i.watch()}))}),a=new t.Computed(e);i.watch(a),a.get(),n?.addEventListener(`abort`,()=>{i.unwatch(a)},{once:!0})}function h(e,t,{immediate:n,signal:r}={}){let i=Array.isArray(e),a=i?e:[e],o=null;m(()=>{let e=a.map(e=>e()),r=o;if(o=e,r){if(r.findIndex((t,n)=>!Object.is(t,e[n]))<0)return;t(i?[...e]:e[0],i?[...r]:r[0])}else{if(!n)return;t(i?[...e]:e[0])}},r)}function g(e){return new t.State(e)}function _(e,n){let r=new t.Computed(e);return typeof n==`function`?{get(){return r.get()},set:n}:{get(){return r.get()},set:()=>{}}}function v(e,t,n){let r=n;for(;;){let n=e.next(r);if(n.done)return n.value;r=t(n.value)}}async function y(e,t,n){let r=n;for(;;){let n=e.next(r);if(n.done)return n.value;r=await t(n.value)}}function b(e,t){let n=e;for(let e of t){let[t,...r]=typeof e==`string`?[e]:e;if(!n.length)continue;let i=[];it:for(let e of n){if(!e||typeof e!=`object`||!Object.hasOwn(e,t))continue;let n=e[t];for(let e of r){if(!Array.isArray(n))continue it;n=n[e]}i.push(n)}n=i.flat(1/0).filter(e=>e&&typeof e==`object`)}return n}function x(e,t){let n=[];for(let r of e)!r||typeof r!=`object`||Object.hasOwn(r,t)&&n.push(r[t]);return n}function*S(e,t,n){let r=[...n[0]],i=[...t,...r.map(e=>typeof e==`string`?e:e[0])],a=r.pop();if(!a)return null;let o=typeof a==`string`?a:a[0],s=b(e,r);if(!s.length)return!1;let[,c,l,u]=n;if(l===null){let e=x(s,o);return u?e.find(e=>e===null):e.find(e=>e!==null)}if(typeof c!=`object`||!c||Array.isArray(c)){let e=x(s,o);return e.length?yield{fields:i,operator:l,sign:u,value:c,values:e}:!1}if(c.filter||c.table||c.placeholder)return null;let d=c.field;if(!d)return null;let f=!1;for(let e of s){if(!e||typeof e!=`object`||!Object.hasOwn(e,d)||!Object.hasOwn(e,o))continue;f=null;let t=yield{fields:i,operator:l,sign:u,value:e[d],values:[e[o]]};if(t!==null)return t}return f}function*C(e,t,n){if(!Array.isArray(n)){let{and:r,or:i}=n;return yield*w(e,t,r,i)}if(n.length!==2)return yield*S(e,t,n);let r=null,i=b(e,n[0]);if(!i.length)return!1;let a=[...t,...n[0].map(e=>typeof e==`string`?e:e[0])];for(let e of n[1]){let t=yield*C(i,a,e);if(t!==null){if(!t)return!1;r=!0}}return r}function*w(e,t,n,r){let i=null;if(Array.isArray(n))for(let r of n){let n=yield*C(e,t,r);if(n!==null){if(!n)return!1;i=!0}}if(Array.isArray(r))for(let n of r){let r=yield*C(e,t,n);if(r!==null){if(r)return!0;i=!0}}return i}function T(e,t,n,r){return v(w([e].flat(),[],n,r),t,null)}async function ee(e,t,n,r){return y(w([e].flat(),[],n,r),t,null)}function*te(e){let t=[],n=!1;for(let r of e){let e=yield*ne(r);t.push(e||r),e&&(n=!0)}return n?t:null}function*ne(e){if(!Array.isArray(e)){let t=e.and&&(yield*re(e.and)),n=e.or&&(yield*re(e.or));return!t&&!n?null:{and:t||e.and,or:n||e.or}}if(e.length===2)return(yield*re(e[1]))?[e[0],e[1]]:null;let t=yield e[1];return t===null?null:[e[0],t,e[2],e[3]]}function*re(e){let t=[],n=!1;for(let r of e){let e=yield*ne(r);t.push(e||r),e&&(n=!0)}return n?t:null}function ie(e,t){if(!e)return[];function n(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let n=e.placeholder;return!n||typeof n!=`string`?null:t(n)}return v(te(e),n,null)||e}function ae(e){return e.map(({field:e,sub:t})=>t.length?[e,...t]:e)}function oe(e){if(e.children)return[ae(e.fields),e.children.map(oe)];let{fields:t,operator:n,value:r,sign:i}=e;return[ae(t),r,n,i]}const se=/^([-_\d\p{L}]+)((?:\[-?\d+\])*)$/u;function ce(e){let t=[];for(let n of e.split(`.`)){if(!n||n[0]===`?`)return null;let e=n.indexOf(`?`),r=se.exec(e>0?n.slice(0,e):n);if(!r)return null;let i=r[2]?.split(/\[|\]/).filter(Boolean).map(e=>parseInt(e)||0)||[],a=e>0?n.slice(e):void 0;t.push({field:r[1],group:a,sub:i})}return t}const E=e=>decodeURIComponent(e.replaceAll(`+`,` `));function le(e){let t=[],n=[],r=t,i=[],a=!1,o=!0;function s(){r.push(E(i.join())),i=[]}for(let t of e){if(t===`,`){a?a=!1:s(),o=!0;continue}if(t===`)`){(o||i.length)&&(s(),o=!1);let e=n.pop();if(!e)return null;e.push(r),r=e,a=!0;continue}if(a)return null;if(o=!1,t!==`(`){i.push(t);continue}if(i.length)return null;n.push(r),r=[]}return(o||i.length)&&s(),n.length?null:t.length===1?t[0]:t}const ue=/^([-_\d\p{L}]+)@([-_\d\p{L}]+)/u;function de(e){if(e===null)return!0;if(e[0]===`?`)return{placeholder:E(e.slice(1))};if(e[0]===`:`)return{field:E(e.slice(1))};if(e[0]===`@`||ue.test(e))return null;if(e.includes(`(`)||e.includes(`)`)){let t=le(e);if(t)return t}return e.includes(`,`)?e.split(`,`).map(e=>E(e.replaceAll(`+`,` `))):E(e)}function*fe(e){let t=e.map(e=>{let t=e.fields,n=t.findLastIndex(e=>e.group);if(n<0||n>=t.length-1)return[e,[],[]];let r=t[n];return r?[{...e,fields:t.slice(n+1)},t.slice(0,n+1),[...t.slice(0,n),{...r,group:void 0}]]:[e,[],[]]}),n=Object.groupBy(t,e=>JSON.stringify(e[1]));yield*n[`[]`]?.map(e=>oe(e[0]))||[],delete n[`[]`];let r=Object.values(n).filter(Boolean).map((e=[])=>e?.length?{fields:e[0][2]||[],children:e.map(e=>e[0])}:{fields:[],children:[]}).filter(e=>e.fields.length);r.length&&(yield*fe(r))}function pe(e){let t=Map.groupBy(e,e=>e.groups.shift()??null),n=t.get(null)||[],r=t.get(``)||[];return t.delete(null),t.delete(``),{or:[...r.map(e=>oe(e)),...[...t.values()].map(e=>pe(e))],and:[...fe(n)]}}function me(e,t=`&`){let n=[],r=[],i=[],a=0,o=0,s=0,c=!1,l={},u=[];for(let d of e.split(t)){if(d[0]===`=`){n.push(d.slice(1));continue}let e=d.indexOf(`=`),t=e<0?d:d.slice(0,e),f=e<0?null:d.slice(e+1);if(e<=0||`.!@^*<>{}[]()+|;,"'\`\\/`.includes(t[0]))continue;if(t[0]===`?`){l[E(t.slice(1))]=E(f||``);continue}if(t[0]===`:`){let e=t.slice(1);if(!f)continue;e===`sort`?i.push(...f.split(`,`).filter(Boolean).map(e=>{let t=e[0]===`-`;return[E(t?e.slice(1):e),t]}).filter(Boolean)):e===`select`?r.push(...f.split(`,`).map(E).filter(Boolean)):e===`limit`?f&&/^\d+$/.test(f)&&(a=parseInt(f)):e===`offset`?f&&/^\d+$/.test(f)&&(o=parseInt(f)):e===`page`?f&&/^\d+$/.test(f)&&(s=parseInt(f)):e===`total`&&f&&(c=!0);continue}let p=t.split(`~`),m=p.pop()||``,h=``;`!`.includes(m[m.length-1])&&(h=`!`,m=m.slice(0,-1));let g=m.split(`:`,3);if(g.length>2)continue;let _=ce(g[0]);if(!_)continue;let v=de(f);if(v===null)continue;let y=E(g[1]||``),b=p.indexOf(``),x=b<0?p:p.slice(0,b+1);u.push({groups:x,fields:_,operator:!y&&v===!0?null:y,sign:h,value:v===!0?null:v})}let{and:d,or:f}=pe(u),p={};n?.length&&(p.values=n),c&&(p.total=c),a&&a>0&&(p.limit=a),s&&s>0&&(p.page=s),o&&o>0&&(p.offset=o),r?.length&&(p.select=r),i?.length&&(p.sort=i);let m=d;m?.length&&(p.where=m);let h=f;return h?.length&&(p.orWhere=h),Array.isArray(l)&&l.length&&(p.placeholders=l),p}function he(e,t){let n=t.limit||e.limit||10,r=t.page??e.page,i=t.offset??(t.limit&&(t.page||t.page===0)?(Math.floor(Math.max(t.page||0,1))-1)*t.limit:null)??e.offset??(e.limit&&(e.page||e.page===0)?(Math.floor(Math.max(e.page||0,1))-1)*e.limit:null)??(Math.floor(Math.max(r||0,1))-1)*n,a=[...e.values||[],...t.values||[]],o=[...e.sort||[],...t.sort||[]],s=[...e.select||[],...t.select||[]],c=[...e.where||[],...t.where||[]],l=[...e.orWhere||[],...t.orWhere||[]],u=[...e.or||[],...t.or||[]],d={};return a?.length&&(d.values=a),n&&n>0&&(d.limit=n),(e.total||t.total)&&(d.total=!0),r&&r>0&&(d.page=r),i&&i>0&&(d.offset=i),s?.length&&(d.select=s),o?.length&&(d.sort=o),c?.length&&(d.where=c),l?.length&&(d.orWhere=l),u?.length&&(d.or=u),d}const D=e=>encodeURIComponent(e).replaceAll(`%20`,`+`);function ge(e){if(Array.isArray(e)){function t(e){return Array.isArray(e)?`(${e.map(t).join(`,`)})`:D(e)}let n=e.map(t).join(`,`);return e.length>1?n:`(${n})`}if(typeof e==`number`)return`${e}`;if(typeof e==`boolean`)return e?`1`:0;if(typeof e!=`object`)return D(e);let{field:t,placeholder:n}=e;return n?`?${D(n)}`:t?`:${D(t)}`:``}function _e(e){return e.map(e=>{let[t,...n]=typeof e==`string`?[e]:e;return`${D(t)}${n.map(()=>`[k]`).join(``)}`}).join(`.`)}function ve([e,t,n,r]){let i=n?`${_e(e)}:${D(n)}${r||``}`:`${_e(e)}${r||``}`;return n===null?i:t===null||typeof t==`function`?``:`${i}=${ge(t)}`}function ye(e){let t=0;return e.flatMap(e=>{if(e.length!==2)return ve(e);let n=ye(e[1]);if(!n.length)return[];let r=_e(e[0]);return n.length>1&&(r+=`?${(t++).toString(36)}`),n.map(e=>`${r}.${e}`)}).filter(Boolean)}function be(e){let t=0;return e.map(e=>Array.isArray(e)?ye([e]):[...ye(e.and||[]),...be(e.or||[])]).flatMap(e=>{if(!e)return[];let n=e.length===1?`~`:`${(t++).toString(36)}~`;return e.map(e=>`${n}${e}`)})}function xe({values:e,where:t,orWhere:n,sort:r,select:i,limit:a,offset:o,page:s,total:c,placeholders:l},u){let d=[];for(let t of e||[])t&&d.push(`=${D(t)}`);if(a&&a>0&&d.push(`:limit=${a}`),c&&d.push(`:total=${c}`),u?s&&s>0&&d.push(`:page=${s}`):o&&o>0&&d.push(`:offset=${o}`),i){let e=i.filter(Boolean).map(D).join(`,`);e&&d.push(`.select=${e}`)}if(r){let e=r.filter(Boolean).map(e=>{if(Array.isArray(e)){let[t,n]=e;if(t)return`${n?`-`:``}${D(t)}`}else if(e)return D(e);return``}).filter(Boolean).join(`,`);e&&d.push(`.sort=${e}`)}if(l&&typeof l==`object`&&!Array.isArray(l))for(let[e,t]of Object.entries(l))d.push(`?${D(e)}=${D(t)}`);for(let e of ye(t||[]))d.push(e);for(let e of be(n||[]))d.push(e);return d.join(`&`)}var Se=p({asyncExec:()=>ee,asyncRunGenerator:()=>y,exec:()=>T,fill:()=>ie,fillMatches:()=>re,merge:()=>he,parse:()=>me,runGenerator:()=>v,stringify:()=>xe});const Ce=()=>!0;function we(e,t){let n=[e].flat();for(let e of t.filter(Boolean)){let t=[];for(let r of n)!r||typeof r!=`object`||Object.hasOwn(r,e)&&t.push(r[e]);if(!t.length)return[];n=t.flat()}return n}function Te(e,t){if(!t.length)return e;if(!e||typeof e!=`object`)return;let[n,...r]=t;for(let t of[e].flat()){let e=Te(t[n],r);if(e!==void 0)return e}}function*Ee(e,t){for(let n of Object.values(e))for(let e of we(n,t))yield e}var De=class e{static build(t){let n=new e;return e.update(n,t)}static update(t,n){let r=!1;return typeof n==`function`?(Object.defineProperty(t.#e,`hooks`,{configurable:!0,get(){let e=n();return typeof e==`object`&&e||{}}}),r=!0):n&&typeof n==`object`&&(Object.defineProperty(t.#e,`hooks`,{configurable:!0,value:n}),r=!0),r&&e.reset(t),t}static reset(e){let t=e.#r,n=e.#e.resetFn;n.sort(([,e],[,t])=>e-t);let r=n.filter(([,e])=>e<=0),i=n.filter(([,e])=>e>0);for(let[e]of r)e();for(let e of Ee(t,[`reset`]))typeof e==`function`&&e();for(let[e]of i)e()}#e={hooks:Object.create(null),resetFn:[]};#t=[];#n=`Hook`;[Symbol.iterator](){return this.entries()}[Symbol.toStringTag](){return this.#n}[Symbol.toPrimitive](e){return e===`number`?NaN:`[${this[Symbol.toStringTag]()}]`}get#r(){return this.#e.hooks}get(t){let n=[...this.#t,t],r=new e;return r.#e=this.#e,r.#t=n,r.#n=`Hook(${n.join(`.`)})`,r}call(...e){for(let t of this.values())typeof t==`function`&&t(...e)}first(e){let t=this.#r;if(Object.hasOwn(t,e))return Te(t[e],this.#t.filter(Boolean))}*plugin(e){let t=this.#r;Object.hasOwn(t,e)&&(yield*we(t[e],this.#t.filter(Boolean)))}values(){return Ee(this.#r,this.#t)}*entries(){let e=this.#r,t=this.#t;for(let[n,r]of Object.entries(e))for(let e of we(r,t))yield[n,e]}*entriesObject(e=Ce){for(let[t,n]of this.entries())if(!(!n||typeof n!=`object`))for(let[r,i]of Object.entries(n))e(i)&&(yield[t,r,i])}named(e=Ce){let t=Object.create(null);for(let n of this.values())if(!(!n||typeof n!=`object`))for(let[r,i]of Object.entries(n))e(i)&&(t[r]=i);return t}listen(e,t){if(typeof e!=`function`)return()=>{};let n=this.#e.resetFn,r=[e,Number.isFinite(t)&&t||0];return n.push(r),n.sort(([,e],[,t])=>t-e),()=>{let e=n.findIndex(e=>e===r);e>=0&&n.splice(e,1)}}};const Oe=/\{([^}{}]+)\}/g;function ke(e){if(!e||typeof e!=`string`)return[];let t=[];for(let n=Oe.exec(e);n;n=Oe.exec(e))t.push(n[1]);return t}function O(e,t){if(!e||typeof e!=`string`)return``;let n=typeof t==`object`&&t||{};return e.replace(Oe,(e,t)=>Object.hasOwn(n,t)?n[t]??``:`{${t}}`)}function*Ae({constraints:e,organizationField:t}){if(t&&(yield t),e)for(let[t,n]of Object.entries(e)){if(!n)continue;let{value:e,values:r,user:i}=n;e===void 0?(Array.isArray(r)&&r.length||r instanceof Set&&r.size||i)&&(yield t):yield t}}const je=/^(?:(?<scope>@[a-zA-Z\d_.-]+)\/)?(?<name>[a-zA-Z\d_.-]+)$/,Me=/^(?<pluginId>(?:(?<scope>@[a-zA-Z\d_.-]+)\/)?(?<name>[a-zA-Z\d_.-]+))(?:\/(?<path>[^#]*))?(?:#(?<hash>.*))?$/;function Ne(e){return typeof e==`function`}const Pe=g({}),k=De.build(()=>Pe.get());function Fe(e){Pe.set(e),De.reset(k)}function Ie(e,t,n){let r=typeof t==`string`?t:``,i=t===!0||n===!0?`[]`:``;return!e||e===`.`?r?`:${r}${i}`:void 0:r?`${e}:${r}${i}`:e}const Le=_(()=>{let e=new Map;for(let t of k.get(`formFields`).values()){let{type:n,array:r,renderer:i,input:a}=t,o=Ie(typeof n==`string`?n:``,typeof i==`string`?i:``,!!r);o&&typeof a==`function`&&e.set(o,a)}return e}),Re=_(()=>{let e=new Map;for(let t of k.get(`formFields`).values()){let{type:n,array:r,renderer:i,filter:a,filters:o}=t,s=Ie(typeof n==`string`?n:``,typeof i==`string`?i:``,!!r);if(!s)continue;let c=e.get(s)||new Map;if(typeof a==`function`){let e=c.get(``);e?e.component=a:c.set(``,{component:a,label:`=`})}for(let[e,t]of Object.entries(o||{})){let n=Array.isArray(t)?t[0]:t;if(typeof n!=`function`)continue;let r=Array.isArray(t)?t[1]:``,i=c.get(e);if(!i){c.set(e,{component:n,label:typeof r==`string`?r:``});continue}i.component=n,typeof r==`string`&&(i.label=r)}c.size&&e.set(s,c)}return e});function*ze(e){if(e)for(let t of Array.isArray(e)?e:[e]){if(!t)continue;if(typeof t==`string`){yield[t];continue}if(typeof t!=`object`)continue;let e=t.component;!e||typeof e!=`string`||(yield[e,t])}}function*Be(e){if(!e)return;let t=typeof e==`string`?e:e.type,n=typeof e==`string`?``:e.renderer,r=typeof e==`string`?``:e.array?`[]`:``;if(!t){for(let[e,t]of ze(n))yield[`:${e}${r}`,t],yield[`${e}${r}`,t];return}if(typeof t==`object`){for(let[e,t]of ze(n))yield[`submodel:${e}${r}`,t],yield[`${e}${r}`,t];yield[`submodel${r}`];return}for(let[e,i]of ze(n))yield[`${t}:${e}${r}`,i],yield[`:${e}${r}`,i],yield[`${e}${r}`,i];yield[`${t}${r}`]}function Ve(e,t){let n=Le.get();for(let[t,r]of Be(e)){let e=n.get(t);if(e)return t=>e(t,r)}return t?null:(typeof e==`string`||e.type,()=>document.createElement(`div`))}function He(e){let t=Le.get();for(let[n]of Be(e))if(t.get(n))return!0;return typeof e==`string`||e.type,!1}const Ue=()=>document.createElement(`div`);function A(e,t){let n=Re.get();for(let[r,i]of Be(e)){let e=n.get(r)?.get(t);if(!e)continue;let a=e.component;return e=>a(e,i)}return Ue}function We(e){let t=Re.get(),n=Object.create(null);for(let[r]of Be(e)){let e=t.get(r);if(e)for(let[t,{label:r}]of e)n[t]||(n[t]=r)}return n}function Ge(e,t){let n=Re.get();for(let[r]of Be(e))if(n.get(r)?.has(t))return!0;return!1}const Ke={api:`/api`,file:`/fileCabinets`};var qe=Ke;function Je(e=new Date){let t=e.getTimezoneOffset();if(!t)return`Z`;let n=t<0?`+`:`-`;return t=Math.abs(t),n+[Math.floor(t/60),t%60].map(e=>`${e}`.padStart(2,`0`)).join(`:`)}function Ye(e){return[e.getHours(),e.getMinutes(),e.getSeconds()].map(e=>`${e}`.padStart(2,`0`)).join(`:`)}function Xe(e){return[`${e.getFullYear()}`.padStart(4,`0`),`${e.getMonth()+1}`.padStart(2,`0`),`${e.getDate()}`.padStart(2,`0`)].join(`-`)}function Ze(e){return Ye(e)+`.${e.getMilliseconds()}`.padStart(3,`0`)+Je(e)}function Qe(e){return Xe(e)+`T`+Ze(e)}var j=new class e extends d{build(){return new e}method(e,t){return super.method(`POST`,t).header(`X-Method`,e)}}().get().prefix(qe.api).stringifyJSON(e=>JSON.stringify(e,(e,t)=>t instanceof Date?Qe(t):typeof t==`bigint`?String(t):t instanceof Set?[...t]:t));const $e=await j.clone().get`application`.query({domain:location.hostname,port:location.port,path:location.pathname}).json(),M=window.yongdallPlugins,et=$e.application,tt=$e.pages||{},nt=$e.userMenus||[],N=new URL($e.path||`/workbench/`,location.origin);var rt=$e;function it(e,t,n){let r={};function i(...i){let a=t(...i);if(Object.hasOwn(r,a)&&!n?.(...i))return r[a];let o=e(...i);return r[a]=o,o}return i}const{authRequired:at,multiUser:ot}=rt,P=g(null),st=g(null),ct=_(()=>st.get()||P.get()),lt=it(e=>{let t=_(()=>P.get()?.plugins?.[e]||null),n=_(()=>st.get()?.plugins?.[e]||null),r=_(()=>ct.get()?.plugins?.[e]||null);return{get session(){return t.get()},get target(){return n.get()},get current(){return r.get()}}},e=>e||``),F=g(!1),ut=g(!1),dt=_(()=>ut.get()?!0:!(!at||F.get()||P.get()));function ft(e){return new Set(e.filter(e=>e&&typeof e==`string`))}function pt(e){let t=e.plugins;if(t&&typeof t==`object`)for(let[n,r]of k.get(`user`).get(`permissions`)){if(typeof r!=`function`||!Object.hasOwn(t,n))continue;let i=t[n];if(!i||typeof i!=`object`)continue;let a=r(i,e);if(a instanceof Set)return a}let n=e.permissions;return Array.isArray(n)?ft(n):new Set}function mt(e){let t=e.plugins;if(t&&typeof t==`object`)for(let[n,r]of k.get(`user`).get(`organizationPermissions`)){if(typeof r!=`function`||!Object.hasOwn(t,n))continue;let i=t[n];if(!i||typeof i!=`object`)continue;let a=r(i,e);if(a)return a}let n=e.organizationPermissions;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=Object.entries(n).filter(e=>Array.isArray(e[1]));if(e.length)return Object.fromEntries(e.map(([e,t])=>[e,ft(t)]))}let{organizationRolePermissions:r,organizationRoles:i}=e;return!i||typeof i!=`object`||Array.isArray(i)||!r||typeof r!=`object`||Array.isArray(r)?null:Object.fromEntries(Object.entries(i).map(([e,t])=>[e,ft(t.flatMap(e=>Object.hasOwn(r,e)&&r[e]||[]))]))}const ht=_(()=>{let e=ct.get();return e?pt(e):null}),gt=_(()=>{let e=ct.get();return e?mt(e):null}),_t=_(()=>{let e=gt.get();return e?new Set(Object.values(e).flatMap(e=>[...e])):null});function vt(){return F.get()?{has:()=>!0,get size(){return-1}}:new Set}const I={get multi(){return!!ot},get single(){return F.get()},get session(){return P.get()},get target(){return st.get()},get current(){return ct.get()},hasPermission(e){return ht.get()?.has(e)??F.get()},hasOrganizationPermission(e,t){if(typeof t!=`string`)return _t.get()?.has(e)??F.get();let n=gt.get();return n?Object.hasOwn(n,t)?n[t]?.has(e)??!1:!1:F.get()},get permissions(){return ht.get()||vt()},get organizationPermissions(){return gt.get()||new Proxy({},{get(){return vt()}})},get allOrganizationPermissions(){return _t.get()||vt()},get waitLogin(){return dt.get()},plugin(e){return lt(e)},async load(){let{session:e,target:t}=await j.clone().get`user`.json().then(e=>e||{},()=>({}));return st.set(t||null),e===!0?(F.set(!0),P.set(null)):(F.set(!1),P.set(e||null)),e&&ut.set(!1),!!e},exit(){st.set(null),P.set(null),j.clone().delete`user`.done()},login(e=!0){ut.set(!!e)}};function yt(e,t){if(!e)return!0;for(let[n,r]of Object.entries(e)){if(!r)continue;let{value:e,values:i,user:a}=r,o=t.value?.[n];if(e!==void 0){if(o!==e)return!1}else if(Array.isArray(i)&&i.length){if(!i.includes(o))return!1}else if(i instanceof Set&&i.size){if(!i.has(o))return!1}else if(a&&!I.single&&o!==I.current?.id)return!1}return!0}function bt({permission:e,organizationField:t,constraints:n},r,i,a){if(!yt(n,r))return!1;if(!e)return!0;if(!t)return I.hasPermission(e);if(t===`_`)return!!(a&&I.hasOrganizationPermission(e));if(a)return!0;if(t!==i){let n=String(r.value?.[t]||``);if((!a||n)&&I.hasOrganizationPermission(e,n||``))return!0}return!0}function xt(e,t,n,r,i){return!!e.filter(({authorizations:e})=>{if(e instanceof Set)return e.has(t);if(Array.isArray(e))return e.includes(t)}).find(e=>bt(e,n,r,i))}function St(e,t,n,r){let i=n?.length?t=>{if(!I.current)return!1;let r=t.root,i=r.new;return!xt(n,i?`create`:`update`,r,e,i)}:null;return typeof r==`function`&&i?e=>i(e)||!!r(e):i||(typeof r==`function`?e=>!!r(e):typeof t==`boolean`?t:null)}function Ct(e,t,n,r,i){let a=[];if(typeof i==`function`)a.push(i);else if(n===!0)return!0;return t.uncreatable&&a.push(e=>e.root.new),r&&a.push(r.length?t=>{if(!I.current)return!1;let n=t.root,i=n.new;return!xt(r,`read`,n,e,i)}:()=>!I.single),a.length?e=>{for(let t of a)if(t(e))return!0;return!1}:null}function wt(e,t){return typeof t==`function`?e=>!!t(e):typeof e==`boolean`?e:null}function Tt(e,t,n){let r=e.group||``,i=e.script||{},a=n?.filter(({group:e,fields:n})=>{if(e===r||Array.isArray(e)&&e.includes(r)||n===t||n===`*`)return!0;if(!Array.isArray(n))return!1;if(n.includes(t)||n.includes(`*`))return!0});return{meta:e,hidden:Ct(t,e,e.layout?.hidden,a,i?.hidden),readonly:St(t,e.readonly,a,i.readonly),required:wt(e.required,i.required),clearable:wt(e.clearable,i.clearable),disabled:wt(e.disabled,i.disabled),creatable:!e.uncreatable,immutable:e.immutable,label:e.label||t,description:e.description,placeholder:e.placeholder,step:e.step,max:e.max,min:e.min,default:i.default||e.default,validator:i.validator,validators:i.validators,events:{input:i.input,change:i.change,click:i.click,focus:i.focus,blur:i.blur}}}function Et(e,t,n){let r=Object.create(null);for(let[i,a]of Object.entries(e)){let e=t[i],o=a.type,s=a.layout||{};if(typeof o!=`object`||!o){r[i]={...Tt(a,i,n),type:o,array:!!a.array,component:typeof e==`function`?e:a.script?.component,layout:{field:i,colStart:s.colStart,colSpan:s.colSpan,colEnd:s.colEnd,rowStart:s.rowStart,rowSpan:s.rowSpan,rowEnd:s.rowEnd}};continue}let c=Object.entries(o).filter((([,e])=>!!e)),l=s.levelKey||``,u=[];if(l){if(Array.isArray(s.columns))for(let{action:e,actions:t,field:n,placeholder:r,width:i}of s.columns)if(n||i||r)(n||i)&&u.push({field:n,width:i}),r&&!i&&u.push({placeholder:r});else{let n=[e,t].flat().filter(Boolean);n&&u.push({actions:n})}if(!u.length){u.push({actions:[`collapse`,`move`]});let e=c.filter(([,e])=>e.layout?.head).sort(([,e],[,t])=>(e.layout?.head||0)-(t.layout?.head||0)).map(([e,t])=>e);for(let t of e)u.push({field:t});u.push({placeholder:1}),u.push({actions:[`add`,`remove`]})}}else{if(Array.isArray(s.columns))for(let{action:e,actions:t,field:n}of s.columns)if(n)u.push({field:n});else{let n=[e,t].flat().filter(Boolean);n&&u.push({actions:n})}if(!u.length){u.push({actions:[`add`,`trigger`,`move`,`remove`,`serial`]});let e=c.filter(([,e])=>e.layout?.head).sort(([,e],[,t])=>(e.layout?.head||0)-(t.layout?.head||0)).map(([e,t])=>e);for(let t of e)u.push({field:t})}}let d=Et(o,typeof e!=`function`&&e||{},n);r[i]={...Tt(a,i,n),layout:{field:i,fields:Object.entries(d).sort(([e],[t])=>(o[e]?.layoutOrder||0)-(o[t]?.layoutOrder||0)).map(([e,t])=>({...t.layout,field:e})),columns:u,arrayStyle:l?`tree`:`table`,levelKey:l,colStart:s.colStart,colSpan:s.colSpan,colEnd:s.colEnd,rowStart:s.rowStart,rowSpan:s.rowSpan,rowEnd:s.rowEnd},type:d,array:!!a.array,component:typeof e==`function`?e:a.script?.component}}return r}function Dt(e,t){if(typeof t==`function`)return t;let n=e.component;if(typeof n==`function`)return n;let i=e.meta;return Ve({type:e.type,array:e instanceof r,renderer:[t,i?.renderer,e.component].flat()},!0)||(e instanceof a||e instanceof r&&typeof e.type==`object`?null:()=>document.createElement(`div`))}function Ot(e,t,n,r){let i=Dt(e,n);if(!i)return null;let{relate:a}=r||{},o=e.meta,s=g(!1),c=!1,l=new Map;function u(t,n){e.emit(t,n)}let d=new Set,f=new AbortController().signal,p=r?.editable||!1,m=i({field:o,style:{...t},store:e,get editable(){return p},get name(){return e.index},get current(){return(e.parent||e.root).value},get required(){return e.required},get hidden(){return e.hidden},get readonly(){return e.readonly},get label(){return e.label||``},get placeholder(){return e.placeholder||``},get description(){return e.description||``},signal:f,listen(e,t){let n=t.bind(this),r=l.get(e);return r||(r=new Set,l.set(e,r)),r.add(n),()=>{r?.delete(n)}},emit(e,t){u(e,t)},get value(){return e.value},set value(t){c||(e.value=t)},get destroyed(){return s.get()},get nullable(){return o.nullable},get disabled(){return e.disabled},get clearable(){return e.clearable}});function h(e,...t){for(let n of[...l.get(e)||[]])n(...t)}let _=a?.(e,{focus(){h(`focus`)},scrollIntoView(){h(`scrollIntoView`)},root:m});return r?.signal?.addEventListener(`abort`,()=>{c=!0,s.set(!0);for(let e of d)e();_?.()},{once:!0}),m}function kt(e,t,{enableLink:n,design:r,layout:i,editable:a,signal:o}={}){let s={enableLink:n,design:r};return l(e,(e,t,n)=>Ot(e,s,t,n),t,i||{},{editable:a||!1,signal:o})}const At=_(()=>k.get(`formRenderers`).named());function jt(e){if(!e)return null;let t=At.get();if(!Object.hasOwn(t,e))return null;let n=t[e];if(!n)return null;let r=n.render;return typeof r==`function`?r:null}function Mt(e,t,n){(jt(n?.type)||kt)(e,t,n)}function Nt(e,t){let n=typeof t==`object`&&t||{},r=Et(e.fields,n,e.permissions);return s.create(r)}function Pt(e,t,n,r){let i=g(!1),a=!1,o=new Map,s=g(r[e]),c=Ve(t),l=new AbortController,u=l.signal;return{root:c({field:t,style:{...n},get editable(){return!1},get name(){return e},get current(){return r},get required(){return!1},get hidden(){return!1},get readonly(){return!0},get label(){return``},get placeholder(){return``},get description(){return``},signal:u,listen(e,t){let n=t.bind(this),r=o.get(e);return r||(r=new Set,o.set(e,r)),r.add(n),()=>{r?.delete(n)}},emit(){},get value(){return s.get()},set value(e){},get destroyed(){return i.get()},get nullable(){return!0},get disabled(){return!1},get clearable(){return!1}}),destroy(){a||(a=!0,i.set(!0),l.abort())},get value(){return s},set value(e){a||s.set(e)}}}const L=new AbortController().signal;function Ft(e,t,n,r){let i=t.split(`.`),a=!!r,o=typeof n==`string`?n:``;function s(e){if(!Array.isArray(e)||e.length===2||!!e[3]!==a||e[2]!==o)return!1;let t=e[0];if(t.length!==i.length)return!1;for(let[e,n]of t.entries())if((typeof n==`string`?n:n[0])!==i[e])return!1;return!0}function c(t){let n=e.get(),a=n.findIndex(s);if(a<0){t!=null&&e.set([...n,[i,t,o,r?`!`:``]]);return}if(t!==null){let r=[...n[a]];r[1]=t,e.set([...n.slice(0,a),r,...n.slice(a+1)])}else e.set([...n.slice(0,a),...n.slice(a+1)])}function l(){return e.get().find(s)?.[1]}let u=_(l);return{get(){return u.get()},set:c}}function It(e,t,n,r,i,a){let o=Ft(e,t,r),s=A(n,r),c=g(!1),l=s({field:n,style:{...i,quick:!0},get operator(){return r},get value(){return o.get()},set value(e){c.get()||o.set(e)},signal:a||L,get destroyed(){return c.get()}});return a?.aborted?c.set(!0):a?.addEventListener(`abort`,()=>{c.set(!0)},{once:!0}),l}function Lt(e,t,n,{fields:r,showLabel:i,inline:a,signal:o}){if(o?.aborted)return;let s={showLabel:i,inline:a};for(let{field:i,operator:a}of n){let n=Object.hasOwn(r,i)&&r[i];if(!n)continue;let c=n.type;if(!c||typeof c==`object`)continue;let l=It(e,i,n,a,s,o);t.appendChild(l),o?.addEventListener(`abort`,()=>{l.remove()},{once:!0})}}function Rt(e,t,n,r,i,a){let o=g(!1),s=n,c=r;return a.addEventListener(`abort`,()=>{o.set(!0)},{once:!0}),e({field:t,style:i,get operator(){return c.get()},get value(){return s.get()},set value(e){o.get()||(s.get(),s.set(e))},signal:a,get destroyed(){return o.get()}})}function zt(e,t,n,r,i){let a={...r};delete a.quick,delete a.showLabel;let o=i?.aborted||!1;i?.addEventListener(`abort`,()=>{o=!0},{once:!0});let s=We(e),c=document.createElement(`span`);c.classList.add(`FieldFilter-main`);let l=c.appendChild(document.createElement(`select`));l.classList.add(`FieldFilter-operator`);for(let[e,t]of Object.entries(s)){let n=document.createElement(`option`);n.value=e,n.label=t||e,l.appendChild(n)}let u=A(e,n.get()),d=new AbortController,f=Rt(u,e,t,n,a,i?AbortSignal.any([d.signal,i]):d.signal),p=c.appendChild(f);p.classList.add(`FieldFilter-value`);function m(r){if(o||typeof r!=`string`||r===n.get())return;r in s,l.value=r;let m=A(e,r);if(m===u){n.set(r);return}d.abort(),p.remove(),u=m,n.set(r),d=new AbortController,f=Rt(u,e,t,n,a,i?AbortSignal.any([d.signal,i]):d.signal),p=c.appendChild(f),p.classList.add(`FieldFilter-value`)}return l.addEventListener(`input`,()=>m(l.value)),m(l.value),c}function Bt(e,t,n){e.classList.add(`FieldFilter-filters`);let r=new AbortController,i=r.signal,a=Array.isArray(n)?structuredClone(n):[],o=new Map(Object.entries(t).filter(([,e])=>{let t=e.type;return!(!t||typeof t==`object`)})),s={quick:!1,showLabel:!1,inline:!0};function c(t){let n=e.appendChild(document.createElement(`div`));n.classList.add(`FieldFilter-field`);let r=document.createElement(`select`);r.classList.add(`FieldFilter-fieldName`),n.appendChild(r);let c=document.createElement(`button`);c.classList.add(`FieldFilter-remove`),c.type=`button`,n.appendChild(c),r.appendChild(document.createElement(`option`));for(let[e,t]of o){let n=t.type;if(!n||typeof n==`object`)continue;let i=document.createElement(`option`);i.value=e,i.label=t.label||e,r.appendChild(i)}let l=null;c.appendChild(document.createTextNode(`移除`)),c.addEventListener(`click`,()=>{l?.abort();let t=[...e.children].indexOf(n);t<0||(n.remove(),a.splice(t,1))});let u=g(),d=g(``);function f(){let t=[...e.children].indexOf(n);if(t<0)return;let r=a[t],i=u.get(),o=d.get();if(r&&r.length!==2){let e=r[0],t=e.length===1&&e[0],n=typeof t==`string`?t:Array.isArray(t)&&t.length===1?t[0]:``;if(!n&&!l||r&&l&&n===l.name&&r[2]===o&&r[1]===i)return}a.splice(t,1,l?[[l.name],i,o]:null)}if(r.addEventListener(`change`,()=>{let e=r.value,t=o.get(e);if(!l&&!t||l?.name===e)return;if(l?.abort(),!t){l=null,f();return}let a=new AbortController,p=AbortSignal.any([a.signal,i]);u.set(void 0),d.set(``);let h=zt(t,u,d,s,p);l={name:e,abort(){a.abort()}},n.insertBefore(h,c),p.addEventListener(`abort`,()=>{h.remove()}),m(f,p)}),!t)return;let p=t[0],h=p.length===1&&p[0],_=typeof h==`string`?h:Array.isArray(h)&&h.length===1?h[0]:``;if(r.value=_,!r.value)return;let v=r.value,y=o.get(v);if(!y)return;let b=new AbortController,x=AbortSignal.any([b.signal,i]);v===_?(u.set(t[1]),d.set(t[2]||``)):(u.set(void 0),d.set(``));let S=zt(y,u,d,s,x);l={name:v,abort(){b.abort()}},n.insertBefore(S,c),x.addEventListener(`abort`,()=>{S.remove()}),m(f,x)}function l(){for(let e of a)c(e)}l();let u=!1;return{root:e,add:()=>c(),destroy(){return u?a:(u=!0,e.innerHTML=``,r.abort(),a)}}}async function Vt(e,t,n,r){if(r?.aborted)return Promise.reject(r.reason);let{resolve:i,reject:a,promise:o}=Promise.withResolvers(),s=e.fields,c=Array.isArray(t)?structuredClone(t):[],l=new Map(Object.entries(s).filter(([,e])=>{let t=e.type;return!(!t||typeof t==`object`)})),u=document.createElement(`dialog`);u.classList.add(`FieldFilter-dialog`);let d=u.appendChild(document.createElement(`div`));d.classList.add(`FieldFilter-filters`);let f=u.appendChild(document.createElement(`form`));f.classList.add(`FieldFilter-form`);let p=f.appendChild(document.createElement(`select`));p.classList.add(`FieldFilter-add`);let h=f.appendChild(document.createElement(`button`));p.classList.add(`FieldFilter-ok`);let _=f.appendChild(document.createElement(`button`));p.classList.add(`FieldFilter-cancel`),h.value=`ok`,f.method=`dialog`,h.appendChild(document.createTextNode(`确认`)),_.appendChild(document.createTextNode(`取消`));let v=p.appendChild(document.createElement(`option`));v.label=`<添加>`;for(let[e,t]of l){let n=t.type;if(!n||typeof n==`object`)continue;let r=document.createElement(`option`);r.value=e,r.label=t.label||e,p.appendChild(r)}function y(e,t,n,i){let a=new AbortController,o=r?AbortSignal.any([r,a.signal]):a.signal,s=d.appendChild(document.createElement(`div`));s.classList.add(`FieldFilter-field`);let l=document.createElement(`span`);l.classList.add(`FieldFilter-fieldName`),s.appendChild(l),l.appendChild(document.createTextNode(n.label||t));let u={inline:!0},f=We(n);document.createElement(`span`).classList.add(`FieldFilter-main`);let p=s.appendChild(document.createElement(`select`));p.classList.add(`FieldFilter-operator`);for(let[e,t]of Object.entries(f)){let n=document.createElement(`option`);n.value=e,n.label=t||e,p.appendChild(n)}let h=document.createElement(`button`);h.classList.add(`FieldFilter-remove`),h.type=`button`,s.appendChild(h),h.appendChild(document.createTextNode(`移除`)),h.addEventListener(`click`,()=>{a.abort();let e=[...d.children].indexOf(s);e<0||(s.remove(),c.splice(e,1))});function _(e,t){let n=[...d.children].indexOf(s);if(n<0)return-1;let r=c[n];return!r||Object.is(e,r[1])||Object.is(t,r[2])?n:-1}let v=e[2]||``;p.value=v;let y=e[1];p.value!=v&&(v=p.value,y=null);let b=g(y),x=g(v);m(()=>{let e=b.get(),t=x.get(),n=_(e,t);n<0||c.splice(n,1,[i,e,t])},o);let S=A(n,x.get()),C=new AbortController,w=Rt(S,n,b,x,u,AbortSignal.any([C.signal,o]));p.value=x.get();let T=s.insertBefore(w,h);T.classList.add(`FieldFilter-value`),p.addEventListener(`input`,()=>{let e=p.value;if(e in f,typeof e!=`string`)return;let t=A(n,e);if(t===S){x.set(e);return}C.abort(),T.remove(),S=t,x.set(e),C=new AbortController,w=Rt(S,n,b,x,u,AbortSignal.any([C.signal,o])),T=s.insertBefore(w,h),T.classList.add(`FieldFilter-value`)})}for(let e of c){let t=e[0],n=t.length===1&&t[0],r=typeof n==`string`?n:Array.isArray(n)&&n.length===1?n[0]:``,i=l.get(r);i&&y(e,r,i,t)}return p.addEventListener(`change`,()=>{let e=p.value;p.value=``;let t=l.get(e);t&&y([[e],``,``],e,t,[[e]])}),u.addEventListener(`close`,()=>{if(d.innerHTML=``,u.remove(),r?.aborted)return a(r.reason);if(u.returnValue!==`ok`)return a(Error(`User canceled`));i(c.filter(Boolean))}),(n||document.body).appendChild(u),u.showModal(),o}function R(...e){let t=`/`;for(let n of e){let e=t.lastIndexOf(`?`);e>=0&&t.lastIndexOf(`#`)<e&&(t+=`#`),t+=`/`+n}t=t.split(`#`).map(e=>{let t=e.indexOf(`?`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t):``,i=n.split(`/`),a=i.shift()||``,o=[];for(let e of i)if(e&&e!==`.`){if(e===`..`){o.pop();continue}o.push(e)}return o.unshift(a),`${o.join(`/`)}${r}`}).join(`#`);let n=N.pathname;if(t.startsWith(n))return t;let r=t.indexOf(`?`),i=t.indexOf(`#`),a=r<0?i:i<0?r:Math.min(r,i),o=a<0?t:t.slice(0,a);return o.length!==n.length-1||!n.startsWith(o)?t:a<0?n:n+t.slice(a)}function Ht(e){return!e||typeof e!=`string`?!1:je.test(e)}function Ut(e){let{promise:t,resolve:n}=Promise.withResolvers();return e instanceof AbortSignal&&(e.aborted?n():e.addEventListener(`abort`,()=>{n()},{once:!0})),t}function Wt(e,t){if(!e||typeof e!=`string`)return null;let n=e.slice(0,2);if(n===`#!`||n===`#?`){let t=n.indexOf(`
2
- `);if(t<0)return null;e.slice(0,t),e=e.slice(t+1)}return null}let Gt={imports:{},scopes:{}};try{let{imports:e={},scopes:t={}}=JSON.parse(document.querySelector(`script[type=importmap]`)?.textContent||``);Gt={imports:e,scopes:t}}catch{}async function z(e,t,n){if(!e)return;e[0];let r=e.indexOf(`#`),i=r<0?e:e.slice(0,r);t&&typeof t==`string`&&(!i||i===`@`?i=t:i.startsWith(`@/`)&&(i=t+i.slice(1)));let a=await([t,n].find((e=>typeof e==`function`))||(e=>import(e)))(i).catch(e=>{console.error(e)});if(r<0)return a;let o=e.slice(r+1);if(!o)return a.default;let s=a;for(let e of o.split(`.`)){if(!s||typeof s!=`object`)return;s=s[e]}return s}function Kt(e,t){if(!t)return null;let n=t[e];if(n)return n;let r=0,i=``;for(let n of Object.entries(t)){let[t,a]=n;t[t.length-1]===`/`&&e.startsWith(t)&&t.length>r&&(r=t.length,i=a)}return r?(i[i.length-1]!==`/`&&(i+=`/`),i+e.slice(r)):null}function qt(e,t){let n=``,r=null;for(let[e,i]of Object.entries(Gt.scopes))t.startsWith(e)&&e.length>n.length&&(n=e,r=i);return Kt(e,r)||Kt(e,Gt.imports)||e}function Jt(e,t,n){let r=document.createElement(`link`);return new Promise((i,a)=>{r.addEventListener(`load`,()=>i(r)),r.addEventListener(`error`,e=>a(e.error));let o=!(n&&t)&&Me.exec(e)?.groups;if(o){let{pluginId:e,path:t}=o,n=Object.hasOwn(M,e)&&M[e]||{},i=`/assets/plugins/${e}/${n.version||`VERSION`}/`,a=location.origin+i,s=n.assets?.[t]||qt(t,i);if(s){r.href=new URL(s,a).href,r.rel=`stylesheet`,document.head.appendChild(r);return}}let s=t&&M[t]||{},c=s.version||`VERSION`,l=t?`/assets/plugins/${t}/${c}/`:``,u=t?location.origin+l:location.href;t&&e[0]!==`.`&&e[0];let d=s.assets?.[e]||l&&qt(e,l)||e;r.href=new URL(d,u).href,r.rel=`stylesheet`,document.head.appendChild(r)})}var B=class extends Error{constructor(e){super(`${e}`),this.status=e}};function V(e,t,...n){let r=Object.create(null),i=new Set,a=Object.create(null),o=Object.create(null),s=[],c=new Set;function l(t,n){let i=e(...n);return r[t]=i,i.then(e=>{let n=a[t];if(n)return n.set(e);a[t]=g(e);for(let e of s)e(t)},()=>{r[t]===i&&delete r[t]}),i}function u(e){c.has(e)||(c.add(e),requestIdleCallback(()=>{if(!c.has(e))return;c.delete(e);let t=o[e];t&&l(e,t)}))}for(let e of n)e.listen(u);function d(e,...n){let s=Array.isArray(e)?e.join(`
3
- `):e;o[s]=n;function c(e){return!e&&Object.hasOwn(r,s)&&r[s]||l(s,n)}function u(){(!Object.hasOwn(r,s)||!r[s]||i.has(s))&&(l(s,n),i.delete(s));let e=a[s];return e||(e=g(t),a[s]=e),e.get()}function d(){o[s]===n&&(delete o[s],delete a[s],delete r[s])}return{get:u,load:c,destroy:d}}function f(e){s.push(e)}return{create:d,listen:f}}function H(e){return{then(t,n){return e().then(t,n)},catch(t){return e().catch(t)},finally(t){return e().finally(t)}}}function Yt(e){return Promise.all(Array.isArray(e)?e.map(async e=>{let t=typeof e==`string`?e:e[0];if(!t||typeof t!=`string`)return;let n=await z(t);if(typeof n!=`function`)return n;let r=typeof e==`string`?null:e[1];return n(typeof r==`object`&&r||{})}):[])}async function Xt({type:e,scripts:t,...n},r){let i=Object.create(null),a=Object.create(null);for(let e of[await Yt(t),r].flat()){if(!e||typeof e!=`object`)continue;let{subFields:t,...n}=e;for(let[e,t]of Object.entries(n)){let n=a[e];n?n.push(t):a[e]=[t]}if(t)for(let[e,n]of Object.entries(t)){let t=i[e];t?t.push(n):i[e]=[n]}}return{...n,script:Qt(a),type:typeof e==`object`&&e?await Zt(e,i):e}}async function Zt(e,t){let n=Object.entries(e).map(([e,n])=>Promise.all([e,Xt(n,t[e])]));return Object.fromEntries(await Promise.all(n))}function U(e,t){if(!e)return null;let n=e.filter(e=>typeof e==`function`);return n.length?t?(...e)=>{for(let t of n)t(...e)}:async(...e)=>{for(let t of n)await t(...e)}:null}function Qt(e){return{input:U(e.input),change:U(e.change),click:U(e.click),focus:U(e.focus),blur:U(e.blur),add:e.add?.find(e=>typeof e==`function`),remove:U(e.remove),move:U(e.move)}}function $t({listScripts:e,documentScripts:t,...n}){return{input:U(n.input),change:U(n.change),beforeCreate:U(n.beforeCreate),beforeUpdate:U(n.beforeUpdate),beforeSave:U(n.beforeSave),beforeDestroy:U(n.beforeDestroy),beforeUpsert:U(n.beforeUpsert),listScripts:e?Object.assign({},...e):{},documentScripts:t?Object.assign({},...t):{}}}async function en({fields:e,scripts:t,...n}){let r=Object.create(null),i=Object.create(null);for(let e of await Yt(t)){if(!e||typeof e!=`object`)continue;let{fields:t,...n}=e;for(let[e,t]of Object.entries(n)){let n=i[e];n?n.push(t):i[e]=[t]}if(t)for(let[e,n]of Object.entries(t)){let t=r[e];t?t.push(n):r[e]=[n]}}return{...n,script:$t(i),fields:await Zt(e,r)}}const tn=V(e=>e.clone().body({}).json().then(e=>e.options),[]);function nn(e,t){let n=e.clone().append(`/documents`),r=e.clone().append(`/options`),{get:i,load:a}=tn.create(t,r);return{async query({values:e,where:t,orWhere:r,sort:i,limit:a=20,page:o,offset:s,select:c,total:l}={}){return n.clone().body({values:e,where:t,orWhere:r,sort:i,limit:a,page:o,offset:s,select:c,total:l}).json()},getOptions(){return i()},async options(e){if(!e||typeof e==`boolean`)return a(e);let{matches:t,limit:n=20,page:i,offset:o,select:s}=e;return r.clone().body({matches:t,limit:n,page:i,offset:o,select:s}).json().then(e=>e.options)},async option(e){return r.clone().append(`/${encodeURIComponent(e)}`).get().json()},async create(e){return n.clone().post().body({document:e}).json()},document(e){let t=n.clone().append(`/${encodeURIComponent(e)}`);async function r(){return t.get().json().then(e=>e.document)}return{get:r,async update(e){return t.clone().put().body({document:e}).json()},async delete(){return t.delete().json()},field(e){let n=t.clone().append`fields/${e}`;async function r(){return n.get().json().then(e=>e.value)}return{get:r,...H(r)}},...H(r)}}}}const rn=V(e=>e.result().then(e=>typeof e==`object`&&e||null,e=>Promise.reject(new B(e instanceof Response?e.status:100))),null),an=V(e=>e().then(async e=>e&&en(e)),null,rn);function on(e){let t=j.clone().path`models/${e||``}`,{get:n,load:r}=rn.create(e,t),{get:i,load:a}=an.create(e,r);return{loadModel:r,loadScript:a,getModel:n,getScript:i,...nn(t,[e,``].join(`
4
- `)),...H(r)}}const sn=V(e=>e.json().then(e=>typeof e==`object`&&e.values||[],()=>[]),[]);function cn(e){let t=j.clone().path`enumerations/${e||``}`,{get:n,load:r}=sn.create(e,t);return{load:r,get:n,...H(r)}}const ln=V(e=>e.result().then(e=>typeof e==`object`&&e||null,e=>Promise.reject(new B(e instanceof Response?e.status:100))),null);function un(e){let t=j.clone().path`formLayouts/${e||``}`,{get:n,load:r}=ln.create(e,t);return{load:r,get:n,...H(r)}}const dn=j.clone().path`permissions`;let W=null,fn=!1;const pn=g([]);function mn(){let e=dn.json().then(e=>Array.isArray(e)&&e||[]);return W=e,e.then(e=>pn.set(e),()=>{W===e&&(W=null)}),e}function hn(e){return!e&&W?W:mn()}function gn(){return(!W||fn)&&(mn(),fn=!1),pn.get()}var _n={load:hn,get:gn,...H(hn)};async function vn(e,t){let n=j.clone();n=t?n.get`menus/${e}/groups/${t}`:n.get`menus/${e}`;let{menus:r}=await n.json();return r}const yn=Object.create(null);function bn(e,t,n){let r=yn[e];r||(yn[e]=r=Object.create(null));let i=typeof t==`string`?t:``;if(t!==!0&&n!==!0){let e=r[i];if(e)return e}let a=vn(e,i);return r[i]=a,a.catch(()=>{r[i]===a&&(r[i]=null)}),a}let xn=class{#e;#t;#n;#r;#i=[];#a=document.createElement(`table`);#o=this.#a.appendChild(document.createElement(`thead`));#s=this.#o.appendChild(document.createElement(`tr`));#c=this.#a.appendChild(document.createElement(`tbody`));get root(){return this.#a}get createUrl(){return this.#e}set createUrl(e){let t=typeof e==`function`?e:null;this.#e!==t&&(this.#e=t,this.#l())}constructor(e,t){let n=Object.entries(t.fields).filter(([,{type:e}])=>e&&typeof e!=`object`),r=Object.entries(t.fields).filter(([,e])=>e.primary).map(([e])=>e);this.#n=t.labelPattern||``,this.#e=typeof e==`function`?e:null,this.#t=n,this.#r=r;let i=this.#s;i.innerHTML=``,i.appendChild(document.createElement(`th`)).appendChild(document.createTextNode(`#`));for(let[e,t]of n)i.appendChild(document.createElement(`th`)).appendChild(document.createTextNode(t.label||e))}#l(){let e=this.#c;e.innerHTML=``;let t=this.#r,n=this.#n,r=this.#t,i=this.#e;for(let a of this.#i){let o=e.appendChild(document.createElement(`tr`)),s=o.appendChild(document.createElement(`td`)),c=O(n,a)||t.map(e=>a[e]).join(`$`);if(i){let e=s.appendChild(document.createElement(`a`));e.href=i(t.map(e=>a[e]).join(`$`)),e.appendChild(document.createTextNode(c))}else s.appendChild(document.createTextNode(c));for(let[e,t]of r){let n=o.appendChild(document.createElement(`td`)),r=Pt(e,t,{inline:!0},a);n.appendChild(r.root)}}}setData(e){this.#i=e,this.#l()}destroy(){}},Sn=class{#e=document.createElement(`div`);get root(){return this.#e}get size(){return 5}set size(e){}get page(){return 1}set page(e){}get total(){return 0}set total(e){}listen(e){return()=>{}}destroy(){}},Cn=(e,t,n)=>null,wn=(e,t,n,r)=>null,Tn=()=>null;function En(e={}){xn=e.list||e.List||xn,Sn=e.pagination||e.Pagination||Sn;let t=e.createMenuButtons||e.menuButtons,n=e.createMenuButton||e.menuButton,r=e.createMenuItem||e.menuItem;typeof t==`function`&&(Cn=t),typeof n==`function`&&(wn=n),typeof r==`function`&&(Tn=r)}const Dn=[`uri`,`target`,`page`,`path`,`command`,`script`,`click`];function On(e,t){for(let n of t)delete e[n];return e}function kn(e,t=[]){let n=[],r=[];for(let{level:i,type:a,...o}of e){let e=Math.max(0,Math.floor(i))||0;r.length=e;let s=r.findLast(Boolean);if(a===`button`){let e=o;s?s.buttons.push(e):t.push(e);continue}let c=a===`divider`?null:{...o,buttons:[],children:[]};s?s.children.push(c):n.push(c),r[e]=c}return n}function An(e,t,n){let r=[];for(let i of e){if(!i){r.push(i);continue}let{children:e}=i;if(t&&!t(i))continue;if(!e?.length){r.push(i);continue}let a=An(e,t,n).filter((e,t,n)=>!!(e||t===0||n[t-1]));a.length&&(n&&a.filter(Boolean).length<=1?r.push(...a):(a[a.length-1]||a.pop(),a[0]||a.shift(),r.push({...i,children:a})))}if(n&&r.length===1){let[e]=r;if(e?.children?.length)return e.children}return r}function jn(e,t,...n){let r=e,i=n.pop();for(let e of n){let t=r.get(e);t||(t=new Map,r.set(e,t)),r=t}r.set(i,t)}function Mn(e,t,n,r){let i=new Map,a=new Map;for(let[t,n]of Map.groupBy(e,e=>e.groupType||``).entries())for(let[e,r]of Map.groupBy(n,e=>e.group||``).entries()){let n=[],o=kn(r,n);jn(a,n,t,e),jn(i,o,t,e)}let o=new Map,s=new Map;function c(e){for(let t=e.length-1;t>=0;t--){let n=e[t],{refType:r,refId:i}=n;if(!r||!i)continue;On(n,Dn);let a=s.get(r)?.get(i);e.splice(t,1,...a||[])}}function l(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!n)continue;if(n.children?.length){l(n.children);continue}let{refType:r,refId:i,refMode:a}=n;if(!r||!i)continue;On(n,Dn);let c=o.get(r)?.get(i),u=s.get(r)?.get(i);if(!c?.length&&!u?.length){e.splice(t,1);continue}a===`replace`?e.splice(t,1,...c||[]):(n.children=c||[],n.buttons=u||[])}}for(let e of[`builtin`,`module`,`group`]){let t=i.get(e);if(t){for(let e of t.values())l(e);o.set(e,t)}let n=a.get(e);if(n){for(let e of n.values())c(e);s.set(e,n)}i.delete(e),a.delete(e)}for(let e of i.values())for(let t of e.values())l(t);for(let e of a.values())for(let t of e.values())c(t);for(let[e,t]of a.entries())s.set(e,t);for(let[e,t]of i.entries())o.set(e,t);if(r)for(let e of s.get(t)?.get(n)||[])r.push(e);return o.get(t)?.get(n)||[]}const G={fromDefine(e,t){return kn(e,t)},build(e,t,n,r){return Mn(e,t,n,r)},filter(e,t,n){let r=An(e,t,n),i=[],a=!1;for(let e of r){if(e){a&&i.push(null),a=!1,i.push(e);continue}i.length&&(a=!0)}return i},createButton(e,t,n,r){return wn(e,t,n,r||L)},createButtons(e,t,n){return Cn(e,t,n||L)},createItem(e,t){return Tn(e,t||L)}},Nn=V(async e=>{let t=await e.result().then(e=>typeof e==`object`&&e||null,e=>Promise.reject(new B(e instanceof Response?e.status:100)));if(!t||typeof t!=`object`)return null;let n=[],r=G.fromDefine(t.menus||[],n),{where:i,orWhere:a}=me(t.hiddenFilter||``);return{...t,where:i,orWhere:a,menuButtons:n,menus:r,forms:Object.fromEntries(t.forms?.map(e=>[e.type,e])||[])}},null);function Pn({model:e,organization:t,user:n,workspace:r,page:i}){let a=[e,t,n,r,i].map(e=>e||``).join(`
5
- `),o=j.clone().path`page`;e&&(o=o.query({model:e})),t&&(o=o.query({organization:t})),n&&(o=o.query({user:n})),r&&(o=o.query({workspace:r})),et&&(o=o.query({application:et})),o=o.query({page:i});let{get:s,load:c}=Nn.create(a,o);return{loadPage:c,getPage:s,loadConfiguration(){return c().then(e=>typeof e==`object`&&e?.config)},...H(c)}}let Fn={main:null,details:null,setting:null,input:null,edit:null,copy:null};function In(){let{model:e,modelDetails:t,modelSetting:n,modelInput:r,modelEdit:i,modelCopy:a,user:o,userDetails:s,userSetting:c,userInput:l,userEdit:u,userCopy:d,workspace:f,workspaceDetails:p,workspaceSetting:m,workspaceInput:h,workspaceEdit:g,workspaceCopy:_}=tt;Fn={main:e?()=>z(e):null,details:t?()=>z(t):null,setting:n?()=>z(n):null,input:r?()=>z(r):null,edit:i?()=>z(i):null,copy:a?()=>z(a):null}}In();const Ln=_(()=>{let e={};for(let[t,n]of Object.entries(k.get(`configurationPages`).named()))if(n){if(typeof n==`function`){e[t]=()=>n;continue}if(typeof n==`string`){e[t]=()=>z(n);continue}}for(let[t,n]of Object.entries(rt.configurationPages||{}))e[t]=()=>z(n);return e});async function Rn(e){let{model:t,id:n,workspace:r,setting:i,edit:a,input:o,continuation:s}=e;if(s||i)return null;let c={type:`model`,model:t,workspace:r,id:``,input:``,edit:!1},l=`main`;n?(c.id=n,o?(c.input=o,l=`copy`):a?(c.edit=!0,l=`edit`):l=`details`):o&&(c.input=o,l=`input`);let u=await Pn({...c,page:l});if(!u&&!r){let e=await on(t).catch(e=>e instanceof B?e.status:Promise.reject(e));if(!e||typeof e!=`object`)return null;let n=e.pages,r=n&&Object.hasOwn(n,l)&&n[l];if(r===``)return null;u=typeof r==`string`?{widget:r}:typeof r==`object`&&r||{}}if(typeof u!=`object`)return u;let d=u?.widget;if(d===``)return null;let f=typeof d==`string`?()=>z(d):!r&&Fn[l]||null;return f?{ident:c,widget:f,page:typeof u==`object`&&u||null}:null}async function zn(e){let{id:t,edit:n,input:r,workspace:i,setting:a,continuation:o}=e;if(o||a)return null;let s={type:`workspace`,workspace:i,id:``,input:``,edit:!1},c=`main`;t?(s.id=t,r?(s.input=r,c=`copy`):n?(s.edit=!0,c=`edit`):c=`details`):r&&(s.input=r,c=`input`);let l=await Pn({...s,page:c});if(typeof l!=`object`)return l;let u=l?.widget;return u?{ident:s,widget:()=>z(u),page:typeof l==`object`&&l||null}:null}async function Bn(e){let{id:t,organization:n,edit:r,input:i,workspace:a,setting:o,continuation:s}=e;if(s||o)return null;let c={type:`organization`,organization:n,workspace:a,id:``,input:``,edit:!1},l=`main`;t?(c.id=t,i?(c.input=i,l=`copy`):r?(c.edit=!0,l=`edit`):l=`details`):i&&(c.input=i,l=`input`);let u=await Pn({...c,page:l}).catch(e=>e instanceof B?e.status:Promise.reject(e));if(typeof u!=`object`)return null;let d=u?.widget;return d?{ident:c,widget:()=>z(d),page:typeof u==`object`&&u||null}:null}async function Vn(e){let{id:t,user:n,edit:r,input:i,workspace:a,setting:o,continuation:s}=e;if(s||o)return null;let c={type:`user`,user:n,workspace:a,id:``,input:``,edit:!1},l=`main`;t?(c.id=t,i?(c.input=i,l=`copy`):r?(c.edit=!0,l=`edit`):l=`details`):i&&(c.input=i,l=`input`);let u=await Pn({...c,page:l}).catch(e=>e instanceof B?e.status:Promise.reject(e));if(typeof u!=`object`)return null;let d=u?.widget;return d?{ident:c,widget:()=>z(d),page:typeof u==`object`&&u||null}:null}async function Hn(e){let{type:t}=e;if(t===`model`)return Rn(e);if(t===`workspace`)return zn(e);if(t===`organization`)return Bn(e);if(t===`user`)return Vn(e);if(t===`configuration`){let t=Ln.get(),{continuation:n}=e,r=Object.hasOwn(t,n)?t[n]:null;return typeof r==`function`?{widget:r,ident:e,page:null}:null}let n=t&&t in tt&&tt[t];return typeof n==`string`?{widget:()=>z(n),ident:e,page:null}:null}const K=document.createElement(`div`),Un=document.querySelector(`head`),Wn=document.querySelector(`link[rel=icon]`)||document.createElement(`link`);Wn.rel=`icon`;const Gn=Wn.href;let Kn=Gn;function qn(e){let t=e||Gn;if(t!==Kn){if(Kn=t,!t){Wn.remove();return}Wn.href=t,Un.appendChild(Wn)}}const Jn=new Map;function Yn(e){let t=Symbol();return Jn.set(t,e),()=>{Jn.delete(t)}}const q=new Map;let J=[],Xn=g(void 0);function Zn(e){let t=e&&q.get(e);if(Xn.get()!==t&&(Xn.set(t),t)){let e=J.indexOf(t);e>0&&J.splice(e,1),e&&J.push(t)}}function Qn(){return[...q.values()]}function $n(e,t){q.set(e,t),Xn.set(t);for(let e of[...Jn.values()])e(t)}function er(e){let t=q.get(e);if(q.delete(e),!t)return;let n=J.indexOf(t);if(n>=0&&J.splice(n,1),Xn.get()!==t||(Xn.set(void 0),I.waitLogin))return;let r=J[0];Xr(r?.href||N.pathname,!1,!0)}function tr(){for(let e of[...q.values()])e.destroy()}function nr(e){e.appendChild(document.createTextNode(`主页`))}const rr=document.createElement(`div`),ir=rr.attachShadow({mode:`closed`});ir.innerHTML=`<style>
1
+ import{Signal as e,Signal as t}from"signal-polyfill";import{ArrayStore as n,ArrayStore as r,ObjectStore as i,ObjectStore as a,Store as o,Store as s,renderStore as c,renderStore as l}from"@neeloong/form";import u,{default as d}from"dot-request";var f=Object.defineProperty,p=(e,t)=>{let n={};for(var r in e)f(n,r,{get:e[r],enumerable:!0});return t||f(n,Symbol.toStringTag,{value:`Module`}),n};function m(e,n){let r=!0;if(n?.aborted)return;let i=new t.subtle.Watcher(()=>{r&&(r=!1,queueMicrotask(()=>{r=!0;for(let e of i.getPending())e.get();i.watch()}))}),a=new t.Computed(e);i.watch(a),a.get(),n?.addEventListener(`abort`,()=>{i.unwatch(a)},{once:!0})}function h(e,t,{immediate:n,signal:r}={}){let i=Array.isArray(e),a=i?e:[e],o=null;m(()=>{let e=a.map(e=>e()),r=o;if(o=e,r){if(r.findIndex((t,n)=>!Object.is(t,e[n]))<0)return;t(i?[...e]:e[0],i?[...r]:r[0])}else{if(!n)return;t(i?[...e]:e[0])}},r)}function g(e){return new t.State(e)}function _(e,n){let r=new t.Computed(e);return typeof n==`function`?{get(){return r.get()},set:n}:{get(){return r.get()},set:()=>{}}}function v(e,t,n){let r=n;for(;;){let n=e.next(r);if(n.done)return n.value;r=t(n.value)}}async function y(e,t,n){let r=n;for(;;){let n=e.next(r);if(n.done)return n.value;r=await t(n.value)}}function b(e,t){let n=e;for(let e of t){let[t,...r]=typeof e==`string`?[e]:e;if(!n.length)continue;let i=[];it:for(let e of n){if(!e||typeof e!=`object`||!Object.hasOwn(e,t))continue;let n=e[t];for(let e of r){if(!Array.isArray(n))continue it;n=n[e]}i.push(n)}n=i.flat(1/0).filter(e=>e&&typeof e==`object`)}return n}function x(e,t){let n=[];for(let r of e)!r||typeof r!=`object`||Object.hasOwn(r,t)&&n.push(r[t]);return n}function*S(e,t,n){let r=[...n[0]],i=[...t,...r],a=r.pop();if(!a)return null;let o=typeof a==`string`?a:a[0],s=b(e,r);if(!s.length)return!1;let[,c,l,u]=n;if(l===null){let e=x(s,o);return u?e.find(e=>e===null):e.find(e=>e!==null)}if(typeof c!=`object`||!c||Array.isArray(c)){let e=x(s,o);return e.length?yield{fields:i,operator:l,sign:u,value:c,values:e}:!1}if(c.filter||c.table||c.placeholder)return null;let d=c.field;if(!d)return null;let f=!1;for(let e of s){if(!e||typeof e!=`object`||!Object.hasOwn(e,d)||!Object.hasOwn(e,o))continue;f=null;let t=yield{fields:i,operator:l,sign:u,value:e[d],field:d,values:[e[o]]};if(t!==null)return t}return f}function*C(e,t,n){if(!Array.isArray(n)){let{and:r,or:i}=n;return yield*w(e,t,r,i)}if(n.length!==2)return yield*S(e,t,n);let r=null,i=b(e,n[0]);if(!i.length)return!1;let a=[...t,...n[0]];for(let e of n[1]){let t=yield*C(i,a,e);if(t!==null){if(!t)return!1;r=!0}}return r}function*w(e,t,n,r){let i=null;if(Array.isArray(n))for(let r of n){let n=yield*C(e,t,r);if(n!==null){if(!n)return!1;i=!0}}if(Array.isArray(r))for(let n of r){let r=yield*C(e,t,n);if(r!==null){if(r)return!0;i=!0}}return i}function T(e,t,n,r){return v(w([e].flat(),[],n,r),t,null)}async function ee(e,t,n,r){return y(w([e].flat(),[],n,r),t,null)}function*te(e){let t=[],n=!1;for(let r of e){let e=yield*ne(r);t.push(e||r),e&&(n=!0)}return n?t:null}function*ne(e){if(!Array.isArray(e)){let t=e.and&&(yield*re(e.and)),n=e.or&&(yield*re(e.or));return!t&&!n?null:{and:t||e.and,or:n||e.or}}if(e.length===2)return(yield*re(e[1]))?[e[0],e[1]]:null;let t=yield e[1];return t===null?null:[e[0],t,e[2],e[3]]}function*re(e){let t=[],n=!1;for(let r of e){let e=yield*ne(r);t.push(e||r),e&&(n=!0)}return n?t:null}function ie(e,t){if(!e)return[];function n(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let n=e.placeholder;return!n||typeof n!=`string`?null:t(n)}return v(te(e),n,null)||e}function ae(e){return e.map(({field:e,sub:t})=>t.length?[e,...t]:e)}function oe(e){if(e.children)return[ae(e.fields),e.children.map(oe)];let{fields:t,operator:n,value:r,sign:i}=e;return[ae(t),r,n,i]}const se=/^([-_\d\p{L}]+)((?:\[-?\d+\])*)$/u;function ce(e){let t=[];for(let n of e.split(`.`)){if(!n||n[0]===`?`)return null;let e=n.indexOf(`?`),r=se.exec(e>0?n.slice(0,e):n);if(!r)return null;let i=r[2]?.split(/\[|\]/).filter(Boolean).map(e=>parseInt(e)||0)||[],a=e>0?n.slice(e):void 0;t.push({field:r[1],group:a,sub:i})}return t}const E=e=>decodeURIComponent(e.replaceAll(`+`,` `));function le(e){let t=[],n=[],r=t,i=[],a=!1,o=!0;function s(){r.push(E(i.join())),i=[]}for(let t of e){if(t===`,`){a?a=!1:s(),o=!0;continue}if(t===`)`){(o||i.length)&&(s(),o=!1);let e=n.pop();if(!e)return null;e.push(r),r=e,a=!0;continue}if(a)return null;if(o=!1,t!==`(`){i.push(t);continue}if(i.length)return null;n.push(r),r=[]}return(o||i.length)&&s(),n.length?null:t.length===1?t[0]:t}const ue=/^([-_\d\p{L}]+)@([-_\d\p{L}]+)/u;function de(e){if(e===null)return!0;if(e[0]===`?`)return{placeholder:E(e.slice(1))};if(e[0]===`:`)return{field:E(e.slice(1))};if(e[0]===`@`||ue.test(e))return null;if(e.includes(`(`)||e.includes(`)`)){let t=le(e);if(t)return t}return e.includes(`,`)?e.split(`,`).map(e=>E(e.replaceAll(`+`,` `))):E(e)}function*fe(e){let t=e.map(e=>{let t=e.fields,n=t.findLastIndex(e=>e.group);if(n<0||n>=t.length-1)return[e,[],[]];let r=t[n];return r?[{...e,fields:t.slice(n+1)},t.slice(0,n+1),[...t.slice(0,n),{...r,group:void 0}]]:[e,[],[]]}),n=Object.groupBy(t,e=>JSON.stringify(e[1]));yield*n[`[]`]?.map(e=>oe(e[0]))||[],delete n[`[]`];let r=Object.values(n).filter(Boolean).map((e=[])=>e?.length?{fields:e[0][2]||[],children:e.map(e=>e[0])}:{fields:[],children:[]}).filter(e=>e.fields.length);r.length&&(yield*fe(r))}function pe(e){let t=Map.groupBy(e,e=>e.groups.shift()??null),n=t.get(null)||[],r=t.get(``)||[];return t.delete(null),t.delete(``),{or:[...r.map(e=>oe(e)),...[...t.values()].map(e=>pe(e))],and:[...fe(n)]}}function me(e,t=`&`){let n=[],r=[],i=[],a=0,o=0,s=0,c=!1,l={},u=[];for(let d of typeof e==`string`?e.split(t):[]){if(d[0]===`=`){n.push(d.slice(1));continue}let e=d.indexOf(`=`),t=e<0?d:d.slice(0,e),f=e<0?null:d.slice(e+1);if(e<=0||`.!@^*<>{}[]()+|;,"'\`\\/`.includes(t[0]))continue;if(t[0]===`?`){l[E(t.slice(1))]=E(f||``);continue}if(t[0]===`:`){let e=t.slice(1);if(!f)continue;e===`sort`?i.push(...f.split(`,`).filter(Boolean).map(e=>{let t=e[0]===`-`;return[E(t?e.slice(1):e),t]}).filter(Boolean)):e===`select`?r.push(...f.split(`,`).map(E).filter(Boolean)):e===`limit`?f&&/^\d+$/.test(f)&&(a=parseInt(f)):e===`offset`?f&&/^\d+$/.test(f)&&(o=parseInt(f)):e===`page`?f&&/^\d+$/.test(f)&&(s=parseInt(f)):e===`total`&&f&&(c=!0);continue}let p=t.split(`~`),m=p.pop()||``,h=``;`!`.includes(m[m.length-1])&&(h=`!`,m=m.slice(0,-1));let g=m.split(`:`,3);if(g.length>2)continue;let _=ce(g[0]);if(!_)continue;let v=de(f);if(v===null)continue;let y=E(g[1]||``),b=p.indexOf(``),x=b<0?p:p.slice(0,b+1);u.push({groups:x,fields:_,operator:!y&&v===!0?null:y,sign:h,value:v===!0?null:v})}let{and:d,or:f}=pe(u),p={};n?.length&&(p.values=n),c&&(p.total=c),a&&a>0&&(p.limit=a),s&&s>0&&(p.page=s),o&&o>0&&(p.offset=o),r?.length&&(p.select=r),i?.length&&(p.sort=i);let m=d;m?.length&&(p.where=m);let h=f;return h?.length&&(p.orWhere=h),Array.isArray(l)&&l.length&&(p.placeholders=l),p}function he(e,t){let n=t.limit||e.limit||10,r=t.page??e.page,i=t.offset??(t.limit&&(t.page||t.page===0)?(Math.floor(Math.max(t.page||0,1))-1)*t.limit:null)??e.offset??(e.limit&&(e.page||e.page===0)?(Math.floor(Math.max(e.page||0,1))-1)*e.limit:null)??(Math.floor(Math.max(r||0,1))-1)*n,a=[...e.values||[],...t.values||[]],o=[...e.sort||[],...t.sort||[]],s=[...e.select||[],...t.select||[]],c=[...e.where||[],...t.where||[]],l=[...e.orWhere||[],...t.orWhere||[]],u=[...e.or||[],...t.or||[]],d={};return a?.length&&(d.values=a),n&&n>0&&(d.limit=n),(e.total||t.total)&&(d.total=!0),r&&r>0&&(d.page=r),i&&i>0&&(d.offset=i),s?.length&&(d.select=s),o?.length&&(d.sort=o),c?.length&&(d.where=c),l?.length&&(d.orWhere=l),u?.length&&(d.or=u),d}const D=e=>encodeURIComponent(e).replaceAll(`%20`,`+`);function ge(e){if(Array.isArray(e)){function t(e){return Array.isArray(e)?`(${e.map(t).join(`,`)})`:D(e)}let n=e.map(t).join(`,`);return e.length>1?n:`(${n})`}if(typeof e==`number`)return`${e}`;if(typeof e==`boolean`)return e?`1`:0;if(typeof e!=`object`)return D(e);let{field:t,placeholder:n}=e;return n?`?${D(n)}`:t?`:${D(t)}`:``}function _e(e){return e.map(e=>{let[t,...n]=typeof e==`string`?[e]:e;return`${D(t)}${n.map(()=>`[k]`).join(``)}`}).join(`.`)}function ve([e,t,n,r]){let i=n?`${_e(e)}:${D(n)}${r||``}`:`${_e(e)}${r||``}`;return n===null?i:t===null||typeof t==`function`?``:`${i}=${ge(t)}`}function ye(e){let t=0;return e.flatMap(e=>{if(e.length!==2)return ve(e);let n=ye(e[1]);if(!n.length)return[];let r=_e(e[0]);return n.length>1&&(r+=`?${(t++).toString(36)}`),n.map(e=>`${r}.${e}`)}).filter(Boolean)}function be(e){let t=0;return e.map(e=>Array.isArray(e)?ye([e]):[...ye(e.and||[]),...be(e.or||[])]).flatMap(e=>{if(!e)return[];let n=e.length===1?`~`:`${(t++).toString(36)}~`;return e.map(e=>`${n}${e}`)})}function xe({values:e,where:t,orWhere:n,sort:r,select:i,limit:a,offset:o,page:s,total:c,placeholders:l},u){let d=[];for(let t of e||[])t&&d.push(`=${D(t)}`);if(a&&a>0&&d.push(`:limit=${a}`),c&&d.push(`:total=${c}`),u?s&&s>0&&d.push(`:page=${s}`):o&&o>0&&d.push(`:offset=${o}`),i){let e=i.filter(Boolean).map(D).join(`,`);e&&d.push(`.select=${e}`)}if(r){let e=r.filter(Boolean).map(e=>{if(Array.isArray(e)){let[t,n]=e;if(t)return`${n?`-`:``}${D(t)}`}else if(e)return D(e);return``}).filter(Boolean).join(`,`);e&&d.push(`.sort=${e}`)}if(l&&typeof l==`object`&&!Array.isArray(l))for(let[e,t]of Object.entries(l))d.push(`?${D(e)}=${D(t)}`);for(let e of ye(t||[]))d.push(e);for(let e of be(n||[]))d.push(e);return d.join(`&`)}function Se(e,t,n,...r){function*i(t,n,...r){let a=[];if(n)for(let r of n){let n=yield*e.build(i,t,r);if(n!=null){if(e.value?.(n)===!1)return n;a.push(n)}}orFor:for(let n of r){if(!n)continue;let r=[];for(let o of n){let n=Array.isArray(o)?yield*e.build(i,t,o):yield*i(t,o.and,o.or);if(n!=null){if(e.value?.(n)===!0){a.push(n);continue orFor}r.push(n)}}let o=r.length?e.or(r):null;if(o!=null){if(e.value?.(o)===!1)return o;a.push(o)}}return a.length?e.and(a):null}return i(t,n,...r)}var Ce=p({asyncExec:()=>ee,asyncRunGenerator:()=>y,exec:()=>T,fill:()=>ie,fillMatches:()=>re,merge:()=>he,parse:()=>me,runGenerator:()=>v,stringify:()=>xe,toWhere:()=>Se});const we=Error.prototype;function Te(e,t){if(!(t instanceof Error))throw t;for(let n=Object.getPrototypeOf(t);n;n=Object.getPrototypeOf(n)){let r=e.get(n);if(typeof r==`function`)return r(t);if(n===we)break}throw t}const Ee=()=>!0;function De(e,t){let n=[e].flat();for(let e of t.filter(Boolean)){let t=[];for(let r of n)!r||typeof r!=`object`||Object.hasOwn(r,e)&&t.push(r[e]);if(!t.length)return[];n=t.flat()}return n}function Oe(e,t){if(!t.length)return e;if(!e||typeof e!=`object`)return;let[n,...r]=t;for(let t of[e].flat()){let e=Oe(t[n],r);if(e!==void 0)return e}}function*ke(e,t){for(let n of Object.values(e))for(let e of De(n,t))yield e}var Ae=class e{static build(t){let n=new e;return e.update(n,t)}static update(t,n){let r=!1;return typeof n==`function`?(Object.defineProperty(t.#e,`hooks`,{configurable:!0,get(){let e=n();return typeof e==`object`&&e||{}}}),r=!0):n&&typeof n==`object`&&(Object.defineProperty(t.#e,`hooks`,{configurable:!0,value:n}),r=!0),r&&e.reset(t),t}static reset(e){let t=e.#r,n=e.#e.resetFn;n.sort(([,e],[,t])=>e-t);let r=n.filter(([,e])=>e<=0),i=n.filter(([,e])=>e>0);for(let[e]of r)e();for(let e of ke(t,[`reset`]))typeof e==`function`&&e();for(let[e]of i)e()}#e={hooks:Object.create(null),resetFn:[]};#t=[];#n=`Hook`;[Symbol.iterator](){return this.entries()}[Symbol.toStringTag](){return this.#n}[Symbol.toPrimitive](e){return e===`number`?NaN:`[${this[Symbol.toStringTag]()}]`}get#r(){return this.#e.hooks}get(t){let n=[...this.#t,t],r=new e;return r.#e=this.#e,r.#t=n,r.#n=`Hook(${n.join(`.`)})`,r}call(...e){for(let t of this.values())typeof t==`function`&&t(...e)}first(e){let t=this.#r;if(Object.hasOwn(t,e))return Oe(t[e],this.#t.filter(Boolean))}*plugin(e){let t=this.#r;Object.hasOwn(t,e)&&(yield*De(t[e],this.#t.filter(Boolean)))}values(){return ke(this.#r,this.#t)}*entries(){let e=this.#r,t=this.#t;for(let[n,r]of Object.entries(e))for(let e of De(r,t))yield[n,e]}*entriesObject(e=Ee){for(let[t,n]of this.entries())if(!(!n||typeof n!=`object`))for(let[r,i]of Object.entries(n))e(i)&&(yield[t,r,i])}named(e=Ee){let t=Object.create(null);for(let n of this.values())if(!(!n||typeof n!=`object`))for(let[r,i]of Object.entries(n))e(i)&&(t[r]=i);return t}listen(e,t){if(typeof e!=`function`)return()=>{};let n=this.#e.resetFn,r=[e,Number.isFinite(t)&&t||0];return n.push(r),n.sort(([,e],[,t])=>t-e),()=>{let e=n.findIndex(e=>e===r);e>=0&&n.splice(e,1)}}};const je=/\{([^}{}]+)\}/g;function Me(e){if(!e||typeof e!=`string`)return[];let t=[];for(let n=je.exec(e);n;n=je.exec(e))t.push(n[1]);return t}function O(e,t){if(!e||typeof e!=`string`)return``;let n=typeof t==`object`&&t||{};return e.replace(je,(e,t)=>Object.hasOwn(n,t)?n[t]??``:`${t}`)}function*Ne({constraints:e,organizationField:t}){if(t&&(yield t),e)for(let[t,n]of Object.entries(e)){if(!n)continue;let{value:e,values:r,user:i}=n;e===void 0?(Array.isArray(r)&&r.length||r instanceof Set&&r.size||i)&&(yield t):yield t}}const Pe=/^(?:(?<scope>@[a-zA-Z\d_.-]+)\/)?(?<name>[a-zA-Z\d_.-]+)$/,Fe=/^(?<pluginId>(?:(?<scope>@[a-zA-Z\d_.-]+)\/)?(?<name>[a-zA-Z\d_.-]+))(?:\/(?<path>[^#]*))?(?:#(?<hash>.*))?$/;function Ie(e){return typeof e==`function`}const Le=g({}),k=Ae.build(()=>Le.get());function Re(e){Le.set(e),Ae.reset(k)}function ze(e,t,n){let r=typeof t==`string`?t:``,i=t===!0||n===!0?`[]`:``;return!e||e===`.`?r?`:${r}${i}`:void 0:r?`${e}:${r}${i}`:`${e}${i}`}function Be(e){return typeof e==`boolean`?!e:e}const Ve=_(()=>{let e=new Map;for(let t of k.get(`formFields`).values()){let{type:n,array:r,renderer:i,input:a}=t,o=ze(typeof n==`string`?n:``,typeof i==`string`?i:``,!!r);o&&typeof a==`function`&&e.set(o,a)}return e}),He=_(()=>{let e={},t={};function n(e,t,{not:n,value:r,notValue:i,named:a,notNamed:o,field:s,notField:c},l=``){n&&(typeof r==`function`&&(i=(...e)=>Be(r(...e))),typeof s==`function`&&(c=(...e)=>Be(s(...e))),typeof a==`function`&&(o=(...e)=>Be(a(...e))));let u=Object.hasOwn(e,l)&&e[l]||{value:[],named:[],field:[],notValue:[],notNamed:[],notField:[]};e[l]=u,typeof r==`function`&&u.value.push(r),typeof i==`function`&&u.notValue.push(i),typeof a==`function`&&u.named.push(a),typeof o==`function`&&u.notNamed.push(o),typeof s==`function`&&u.field.push(s),typeof c==`function`&&u.notField.push(c);let d=typeof n==`string`&&n||``;if(!d)return;let f=Object.hasOwn(t,d)&&t[d]||{value:[],named:[],field:[],notValue:[],notNamed:[],notField:[]};t[d]=u,typeof r==`function`&&f.notValue.push(r),typeof i==`function`&&f.value.push(i),typeof a==`function`&&f.notNamed.push(a),typeof o==`function`&&f.named.push(o),typeof s==`function`&&f.notField.push(s),typeof c==`function`&&f.field.push(c)}for(let r of k.get(`formFields`).values()){let{type:i,array:a,renderer:o,filters:s}=r,c=ze(typeof i==`string`?i:``,typeof o==`string`?o:``,!!a)||(a?`[]`:``),l=Object.hasOwn(e,c)&&e[c]||{},u=Object.hasOwn(t,c)&&t[c]||{};n(l,u,r);for(let[e,t]of Object.entries(s||{}))!t||Array.isArray(t)||typeof t!=`object`||n(l,u,t,e);e[c]=l,t[c]=u}for(let n of Object.keys({...e,...t})){let r=Object.hasOwn(t,n)&&t[n];if(!r)continue;let i=Object.hasOwn(e,n)&&e[n]||{};e[n]=i;for(let e of Object.keys({...i,...r})){let t=Object.hasOwn(r,e)&&r[e];if(!t)continue;let n=Object.hasOwn(i,e)&&i[e]||{value:[],named:[],field:[],notValue:[],notNamed:[],notField:[]};if(i[e]=n,t){for(let e of t.value)n.value.push(e);for(let e of t.notValue)n.notValue.push(e);for(let e of t.named)n.named.push(e);for(let e of t.notNamed)n.notNamed.push(e);for(let e of t.field)n.field.push(e);for(let e of t.notField)n.notField.push(e)}}}return e}),Ue=_(()=>{let e=new Map;for(let t of k.get(`formFields`).values()){let{type:n,array:r,renderer:i,filter:a,filters:o}=t,s=ze(typeof n==`string`?n:``,typeof i==`string`?i:``,!!r);if(!s)continue;let c=e.get(s)||new Map;if(typeof a==`function`){let e=c.get(``);e?e.component=a:c.set(``,{component:a,label:`=`})}for(let[e,t]of Object.entries(o||{})){if(!t)continue;let n=Array.isArray(t)?t[0]:typeof t==`function`?t:t.filter;if(typeof n!=`function`)continue;let r=Array.isArray(t)?t[1]:typeof t==`object`?t.label:null,i=c.get(e);if(!i){c.set(e,{component:n,label:typeof r==`string`?r:``});continue}i.component=n,typeof r==`string`&&(i.label=r)}c.size&&e.set(s,c)}return e});function We(){return He.get()}function*Ge(e){if(e)for(let t of Array.isArray(e)?e:[e]){if(!t)continue;if(typeof t==`string`){yield[t];continue}if(typeof t!=`object`)continue;let e=t.component;!e||typeof e!=`string`||(yield[e,t])}}function*Ke(e){if(!e)return;let t=typeof e==`string`?e:e.type,n=typeof e==`string`?``:e.renderer,r=typeof e==`string`?``:e.array?`[]`:``;if(!t){for(let[e,t]of Ge(n))yield[`:${e}${r}`,t],yield[`${e}${r}`,t];return}if(typeof t==`object`){for(let[e,t]of Ge(n))yield[`submodel:${e}${r}`,t],yield[`${e}${r}`,t];yield[`submodel${r}`];return}for(let[e,i]of Ge(n))yield[`${t}:${e}${r}`,i],yield[`:${e}${r}`,i],yield[`${e}${r}`,i];yield[`${t}${r}`]}function qe(e,t){let n=Ve.get();for(let[t,r]of Ke(e)){let e=n.get(t);if(e)return t=>e(t,r)}return t?null:(typeof e==`string`||e.type,()=>document.createElement(`div`))}function Je(e){let t=Ve.get();for(let[n]of Ke(e))if(t.get(n))return!0;return typeof e==`string`||e.type,!1}const Ye=()=>document.createElement(`div`);function Xe(e,t){let n=Ue.get();for(let[r,i]of Ke(e)){let e=n.get(r)?.get(t);if(!e)continue;let a=e.component;return e=>a(e,i)}return Ye}function Ze(e){let t=Ue.get(),n=Object.create(null);for(let[r]of Ke(e)){let e=t.get(r);if(e)for(let[t,{label:r}]of e)n[t]||(n[t]=r)}return n}function Qe(e,t){let n=Ue.get();for(let[r]of Ke(e))if(n.get(r)?.has(t))return!0;return!1}function*$e(e,t){let n=He.get();for(let[r]of typeof e==`boolean`?e?[[`[]`],[``]]:[[``]]:Ke(e)){let e=Object.hasOwn(n,r)&&n[r];if(!e)continue;let i=Object.hasOwn(e,t)&&e[t];i&&(yield i)}}const et={api:`/api`,file:`/fileCabinets`};var tt=et;function nt(e=new Date){let t=e.getTimezoneOffset();if(!t)return`Z`;let n=t<0?`+`:`-`;return t=Math.abs(t),n+[Math.floor(t/60),t%60].map(e=>`${e}`.padStart(2,`0`)).join(`:`)}function rt(e){return[e.getHours(),e.getMinutes(),e.getSeconds()].map(e=>`${e}`.padStart(2,`0`)).join(`:`)}function it(e){return[`${e.getFullYear()}`.padStart(4,`0`),`${e.getMonth()+1}`.padStart(2,`0`),`${e.getDate()}`.padStart(2,`0`)].join(`-`)}function at(e){return rt(e)+`.${e.getMilliseconds()}`.padStart(3,`0`)+nt(e)}function ot(e){return it(e)+`T`+at(e)}var st=class e extends d{build(){return new e}method(e,t){return super.method(`POST`,t).header(`X-Method`,e)}};function ct(e){return e.json().then(e=>Promise.reject(e?.error))}function lt(e){return e.status,ct(e)}const ut=new st().get().prefix(tt.api).stringifyJSON(e=>JSON.stringify(e,(e,t)=>t instanceof Date?ot(t):typeof t==`bigint`?String(t):t instanceof Set?[...t]:t)).errorHandler(ct);var A=ut.clone().errorHandler(lt);const j=await ut.clone().get`application`.query({domain:location.hostname,port:location.port,path:location.pathname}).json(),M=window.yongdallPlugins,dt=j.id,ft=j.pages||{},pt=new URL(j.path||`/workbench/`,location.origin),mt=pt.href,ht=pt.pathname,gt=g(j.menus||[]),_t=g(j.userMenus||[]),vt=g(!1);async function yt(){if(!vt.get()){vt.set(!0);try{let e=await ut.clone().get`applications`.append(`${dt}`).json();if(!j||typeof e!=`object`)return;gt.set(e.menus||[]),_t.set(e.userMenus||[])}finally{vt.set(!1)}}}const N={get id(){return dt},get path(){return ht},get root(){return mt},get theme(){return j.theme},get route(){return j.route},get authenticator(){return j.authenticator},get skin(){return j.skin},get menus(){return gt.get()},get userMenus(){return _t.get()},get logo(){return j.logo},get title(){return j.title},get company(){return j.company},get help(){return j.help},get refreshing(){return vt.get()},refresh:yt};function bt(e,t,n){let r={};function i(...i){let a=t(...i);if(Object.hasOwn(r,a)&&!n?.(...i))return r[a];let o=e(...i);return r[a]=o,o}return i}const{authRequired:xt,multiUser:St}=j,P=g(null),Ct=g(null),wt=_(()=>Ct.get()||P.get()),Tt=bt(e=>{let t=_(()=>P.get()?.plugins?.[e]||null),n=_(()=>Ct.get()?.plugins?.[e]||null),r=_(()=>wt.get()?.plugins?.[e]||null);return{get session(){return t.get()},get target(){return n.get()},get current(){return r.get()}}},e=>e||``),F=g(!1),Et=g(!1),Dt=_(()=>Et.get()?!0:!(!xt||F.get()||P.get()));function Ot(e){return new Set(e.filter(e=>e&&typeof e==`string`))}function kt(e){let t=e.plugins;if(t&&typeof t==`object`)for(let[n,r]of k.get(`user`).get(`permissions`)){if(typeof r!=`function`||!Object.hasOwn(t,n))continue;let i=t[n];if(!i||typeof i!=`object`)continue;let a=r(i,e);if(a instanceof Set)return a}let n=e.permissions;return Array.isArray(n)?Ot(n):new Set}function At(e){let t=e.plugins;if(t&&typeof t==`object`)for(let[n,r]of k.get(`user`).get(`organizationPermissions`)){if(typeof r!=`function`||!Object.hasOwn(t,n))continue;let i=t[n];if(!i||typeof i!=`object`)continue;let a=r(i,e);if(a)return a}let n=e.organizationPermissions;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=Object.entries(n).filter(e=>Array.isArray(e[1]));if(e.length)return Object.fromEntries(e.map(([e,t])=>[e,Ot(t)]))}let{organizationRolePermissions:r,organizationRoles:i}=e;return!i||typeof i!=`object`||Array.isArray(i)||!r||typeof r!=`object`||Array.isArray(r)?null:Object.fromEntries(Object.entries(i).map(([e,t])=>[e,Ot(t.flatMap(e=>Object.hasOwn(r,e)&&r[e]||[]))]))}const jt=_(()=>{let e=wt.get();return e?kt(e):null}),Mt=_(()=>{let e=wt.get();return e?At(e):null}),Nt=_(()=>{let e=Mt.get();return e?new Set(Object.values(e).flatMap(e=>[...e])):null});function Pt(){return F.get()?{has:()=>!0,get size(){return-1}}:new Set}const I={get multi(){return!!St},get single(){return F.get()},get session(){return P.get()},get target(){return Ct.get()},get current(){return wt.get()},hasPermission(e){return jt.get()?.has(e)??F.get()},hasOrganizationPermission(e,t){if(typeof t!=`string`)return Nt.get()?.has(e)??F.get();let n=Mt.get();return n?Object.hasOwn(n,t)?n[t]?.has(e)??!1:!1:F.get()},get permissions(){return jt.get()||Pt()},get organizationPermissions(){return Mt.get()||new Proxy({},{get(){return Pt()}})},get allOrganizationPermissions(){return Nt.get()||Pt()},get waitLogin(){return Dt.get()},plugin(e){return Tt(e)},async load(){let{session:e,target:t}=await ut.clone().get`user`.json().then(e=>e||{},()=>({}));return Ct.set(t||null),e===!0?(F.set(!0),P.set(null)):(F.set(!1),P.set(e||null)),e&&Et.set(!1),!!e},exit(){Ct.set(null),P.set(null),ut.clone().delete`user`.done()},login(e=!0){Et.set(!!e)}};function Ft(e,t,n){if(!e)return!0;let r=typeof e==`string`?e.split(`
2
+ `):e;if(!Array.isArray(r))return!0;let i=r.filter(e=>e&&typeof e==`string`);if(!i.length)return!0;for(let e of i)if(e[0]===`#`){if(n?.has(e.slice(1)))return!0}else if(t.has(e))return!0;return!1}function It(e,t){if(!e||!t||typeof t!=`object`)return!0;for(let[n,r]of Object.entries(e)){if(!r)continue;let{value:e,values:i,user:a}=r,o=t[n];if(e!==void 0){if(o!==e)return!1}else if(Array.isArray(i)&&i.length){if(!i.includes(o))return!1}else if(i instanceof Set&&i.size){if(!i.has(o))return!1}else if(a&&!I.single&&o!==I.current?.id)return!1}return!0}function Lt({permission:e,organizationField:t,constraints:n},r,i,a){if(!It(n,r))return!1;if(!e)return!0;if(!t)return I.hasPermission(e);if(t===`_`)return!!(i&&I.hasOrganizationPermission(e));if(i||t===a)return!0;let o=String(r?.[t]||``);return(!i||o)&&I.hasOrganizationPermission(e,o||``),!0}function Rt(e,t,n){let r=e.filter(({authorizations:e})=>{if(e instanceof Set||Array.isArray(e))return!0}).filter(e=>Lt(e,t,n)).flatMap(({authorizations:e})=>e?[...e]:[]);return new Set(r)}function zt(e,t,n,r,i){return!!t.filter(({authorizations:t})=>{if(t instanceof Set)return t.has(e);if(Array.isArray(t))return t.includes(e)}).find(e=>Lt(e,n,r,i))}function Bt(e,t,n){let r=t.filter(({authorizations:t})=>{if(t instanceof Set)return t.has(e);if(Array.isArray(t))return t.includes(e)}).filter(({permission:e,organizationField:t})=>e?t?I.hasOrganizationPermission(e):I.hasPermission(e):!0);if(!r?.length)return new Set;let i=new Set(r.flatMap(e=>e.group||``)),a=new Set(r.flatMap(e=>e.fields||``));if(i.delete(``),a.delete(``),!(i.size+a.size))return new Set;function*o(e,t){for(let[n,r]of e){if(!r)continue;let e=[...t,n],s=e.join(`.`);if(!r.primary&&!i.has(r.group||``)&&!a.has(s)&&!a.has(`*`))continue;yield s;let{type:c}=r;!c||typeof c!=`object`||(yield*o(Object.entries(c),e))}}return new Set(o(Object.entries(n.fields),[]))}function Vt(e){return new Proxy({},{get(t,n,r){return e.value?.[n]},set(){return!1}})}function Ht(e,t,n,r){let i=n?.length?t=>{let r=t.root,i=r.new;return!zt(i?`create`:`update`,n,Vt(r),i,e)}:null;return typeof r==`function`&&i?e=>i(e)||!!r(e):i||(typeof r==`function`?e=>!!r(e):typeof t==`boolean`?t:null)}function Ut(e,t,n,r,i){let a=[];if(typeof i==`function`)a.push(i);else if(n===!0)return!0;return t.uncreatable&&a.push(e=>e.root.new),r&&a.push(r.length?t=>{let n=t.root,i=n.new;return!zt(`read`,r,Vt(n),i,e)}:()=>!I.single),a.length?e=>{for(let t of a)if(t(e))return!0;return!1}:null}function Wt(e,t){return typeof t==`function`?e=>!!t(e):typeof e==`boolean`?e:null}function Gt(e,t,n){let r=e.group||``,i=e.script||{},a=n?.filter(({group:e,fields:n})=>{if(e===r||Array.isArray(e)&&e.includes(r)||n===t||n===`*`)return!0;if(!Array.isArray(n))return!1;if(n.includes(t)||n.includes(`*`))return!0});return{meta:e,hidden:Ut(t,e,e.layout?.hidden,a,i?.hidden),readonly:Ht(t,e.readonly,a,i.readonly),required:Wt(e.required,i.required),clearable:Wt(e.clearable,i.clearable),disabled:Wt(e.disabled,i.disabled),creatable:!e.uncreatable,immutable:e.immutable,label:e.label||t,description:e.description,placeholder:e.placeholder,step:e.step,max:e.max,min:e.min,default:i.default||e.default,validator:i.validator,validators:i.validators,events:{input:i.input,change:i.change,click:i.click,focus:i.focus,blur:i.blur}}}function Kt(e,t,n){let r=Object.create(null);for(let[i,a]of Object.entries(e)){let e=t[i],o=a.type,s=a.layout||{};if(typeof o!=`object`||!o){r[i]={...Gt(a,i,n),type:o,array:!!a.array,component:typeof e==`function`?e:a.script?.component,layout:{field:i,colStart:s.colStart,colSpan:s.colSpan,colEnd:s.colEnd,rowStart:s.rowStart,rowSpan:s.rowSpan,rowEnd:s.rowEnd}};continue}let c=Object.entries(o).filter((([,e])=>!!e)),l=s.levelKey||``,u=[];if(l){if(Array.isArray(s.columns))for(let{action:e,actions:t,field:n,placeholder:r,width:i}of s.columns)if(n||i||r)(n||i)&&u.push({field:n,width:i}),r&&!i&&u.push({placeholder:r});else{let n=[e,t].flat().filter(Boolean);n&&u.push({actions:n})}if(!u.length){u.push({actions:[`collapse`,`move`]});let e=c.filter(([,e])=>e.layout?.head).sort(([,e],[,t])=>(e.layout?.head||0)-(t.layout?.head||0)).map(([e,t])=>e);for(let t of e)u.push({field:t});u.push({placeholder:1}),u.push({actions:[`add`,`remove`]})}}else{if(Array.isArray(s.columns))for(let{action:e,actions:t,field:n}of s.columns)if(n)u.push({field:n});else{let n=[e,t].flat().filter(Boolean);n&&u.push({actions:n})}if(!u.length){u.push({actions:[`add`,`trigger`,`move`,`remove`,`serial`]});let e=c.filter(([,e])=>e.layout?.head).sort(([,e],[,t])=>(e.layout?.head||0)-(t.layout?.head||0)).map(([e,t])=>e);for(let t of e)u.push({field:t})}}let d=Kt(o,typeof e!=`function`&&e||{},n);r[i]={...Gt(a,i,n),layout:{field:i,fields:Object.entries(d).sort(([e],[t])=>(o[e]?.layoutOrder||0)-(o[t]?.layoutOrder||0)).map(([e,t])=>({...t.layout,field:e})),columns:u,arrayStyle:l?`tree`:`table`,levelKey:l,colStart:s.colStart,colSpan:s.colSpan,colEnd:s.colEnd,rowStart:s.rowStart,rowSpan:s.rowSpan,rowEnd:s.rowEnd},type:d,array:!!a.array,component:typeof e==`function`?e:a.script?.component}}return r}function qt(e,t){if(typeof t==`function`)return t;let n=e.component;if(typeof n==`function`)return n;let i=e.meta;return qe({type:e.type,array:e instanceof r,renderer:[t,i?.renderer,e.component].flat()},!0)||(e instanceof a||e instanceof r&&typeof e.type==`object`?null:()=>document.createElement(`div`))}function Jt(e,t,n,r){let i=qt(e,n);if(!i)return null;let{relate:a}=r||{},o=e.meta,s=g(!1),c=!1,l=new Map;function u(t,n){e.emit(t,n)}let d=new Set,f=new AbortController().signal,p=r?.editable||!1,m=i({field:o,style:{...t},store:e,get editable(){return p},get name(){return e.index},get current(){return(e.parent||e.root).value},get required(){return e.required},get hidden(){return e.hidden},get readonly(){return e.readonly},get label(){return e.label||``},get placeholder(){return e.placeholder||``},get description(){return e.description||``},signal:f,listen(e,t){let n=t.bind(this),r=l.get(e);return r||(r=new Set,l.set(e,r)),r.add(n),()=>{r?.delete(n)}},emit(e,t){u(e,t)},get value(){return e.value},set value(t){c||(e.value=t)},get destroyed(){return s.get()},get nullable(){return o.nullable},get disabled(){return e.disabled},get clearable(){return e.clearable}});function h(e,...t){for(let n of[...l.get(e)||[]])n(...t)}let _=a?.(e,{focus(){h(`focus`)},scrollIntoView(){h(`scrollIntoView`)},root:m});return r?.signal?.addEventListener(`abort`,()=>{c=!0,s.set(!0);for(let e of d)e();_?.()},{once:!0}),m}function Yt(e,t,{enableLink:n,design:r,layout:i,editable:a,signal:o}={}){let s={enableLink:n,design:r};return l(e,(e,t,n)=>Jt(e,s,t,n),t,i||{},{editable:a||!1,signal:o})}const L=new AbortController().signal,Xt=_(()=>k.get(`formRenderers`).named());function Zt(e){if(!e)return null;let t=Xt.get();if(!Object.hasOwn(t,e))return null;let n=t[e];if(!n)return null;let r=n.render;return typeof r==`function`?r:null}function Qt(e,t,n){let{type:r,editable:i,signal:a,model:o,layout:s,enableLink:c,design:l}=n||{};(Zt(r)||Yt)(e,t,{model:o||null,layout:s||null,editable:!!i,signal:a||L,enableLink:!!c,design:!!l})}function $t(e,t){let n=typeof t==`object`&&t||{},r=Kt(e.fields,n,e.permissions);return s.create(r)}function en(e,t,n,r){let i=g(!1),a=!1,o=new Map,s=g(r[e]),c=qe(t),l=new AbortController,u=l.signal;return{root:c({field:t,style:{...n},get editable(){return!1},get name(){return e},get current(){return r},get required(){return!1},get hidden(){return!1},get readonly(){return!0},get label(){return``},get placeholder(){return``},get description(){return``},signal:u,listen(e,t){let n=t.bind(this),r=o.get(e);return r||(r=new Set,o.set(e,r)),r.add(n),()=>{r?.delete(n)}},emit(){},get value(){return s.get()},set value(e){},get destroyed(){return i.get()},get nullable(){return!0},get disabled(){return!1},get clearable(){return!1}}),destroy(){a||(a=!0,i.set(!0),l.abort())},get value(){return s},set value(e){a||s.set(e)}}}function tn(e,t,n,r){let i=t.split(`.`),a=!!r,o=typeof n==`string`?n:``;function s(e){if(!Array.isArray(e)||e.length===2||!!e[3]!==a||e[2]!==o)return!1;let t=e[0];if(t.length!==i.length)return!1;for(let[e,n]of t.entries())if((typeof n==`string`?n:n[0])!==i[e])return!1;return!0}function c(t){let n=e.get(),a=n.findIndex(s);if(a<0){t!=null&&e.set([...n,[i,t,o,r?`!`:``]]);return}if(t!==null){let r=[...n[a]];r[1]=t,e.set([...n.slice(0,a),r,...n.slice(a+1)])}else e.set([...n.slice(0,a),...n.slice(a+1)])}function l(){return e.get().find(s)?.[1]}let u=_(l);return{get(){return u.get()},set:c}}function nn(e,t,n,r,i,a){let o=tn(e,t,r),s=Xe(n,r),c=g(!1),l=s({field:n,style:{...i,quick:!0},get operator(){return r},get value(){return o.get()},set value(e){c.get()||o.set(e)},signal:a||L,get destroyed(){return c.get()}});return a?.aborted?c.set(!0):a?.addEventListener(`abort`,()=>{c.set(!0)},{once:!0}),l}function rn(e,t,n,{fields:r,showLabel:i,inline:a,signal:o}){if(o?.aborted)return;let s={showLabel:i,inline:a};for(let{field:i,operator:a}of n){let n=Object.hasOwn(r,i)&&r[i];if(!n)continue;let c=n.type;if(!c||typeof c==`object`)continue;let l=nn(e,i,n,a,s,o);t.appendChild(l),o?.addEventListener(`abort`,()=>{l.remove()},{once:!0})}}function an(e,t,n,r,i,a){let o=g(!1),s=n,c=r;return a.addEventListener(`abort`,()=>{o.set(!0)},{once:!0}),e({field:t,style:i,get operator(){return c.get()},get value(){return s.get()},set value(e){o.get()||(s.get(),s.set(e))},signal:a,get destroyed(){return o.get()}})}function on(e,t,n,r,i){let a={...r};delete a.quick,delete a.showLabel;let o=i?.aborted||!1;i?.addEventListener(`abort`,()=>{o=!0},{once:!0});let s=Ze(e),c=document.createElement(`span`);c.classList.add(`FieldFilter-main`);let l=c.appendChild(document.createElement(`select`));l.classList.add(`FieldFilter-operator`);for(let[e,t]of Object.entries(s)){let n=document.createElement(`option`);n.value=e,n.label=t||e,l.appendChild(n)}let u=Xe(e,n.get()),d=new AbortController,f=an(u,e,t,n,a,i?AbortSignal.any([d.signal,i]):d.signal),p=c.appendChild(f);p.classList.add(`FieldFilter-value`);function m(r){if(o||typeof r!=`string`||r===n.get())return;r in s,l.value=r;let m=Xe(e,r);if(m===u){n.set(r);return}d.abort(),p.remove(),u=m,n.set(r),d=new AbortController,f=an(u,e,t,n,a,i?AbortSignal.any([d.signal,i]):d.signal),p=c.appendChild(f),p.classList.add(`FieldFilter-value`)}return l.addEventListener(`input`,()=>m(l.value)),m(l.value),c}function sn(e,t,n){e.classList.add(`FieldFilter-filters`);let r=new AbortController,i=r.signal,a=Array.isArray(n)?structuredClone(n):[],o=new Map(Object.entries(t).filter(([,e])=>{let t=e.type;return!(!t||typeof t==`object`)})),s={quick:!1,showLabel:!1,inline:!0};function c(t){let n=e.appendChild(document.createElement(`div`));n.classList.add(`FieldFilter-field`);let r=document.createElement(`select`);r.classList.add(`FieldFilter-fieldName`),n.appendChild(r);let c=document.createElement(`button`);c.classList.add(`FieldFilter-remove`),c.type=`button`,n.appendChild(c),r.appendChild(document.createElement(`option`));for(let[e,t]of o){let n=t.type;if(!n||typeof n==`object`)continue;let i=document.createElement(`option`);i.value=e,i.label=t.label||e,r.appendChild(i)}let l=null;c.appendChild(document.createTextNode(`移除`)),c.addEventListener(`click`,()=>{l?.abort();let t=[...e.children].indexOf(n);t<0||(n.remove(),a.splice(t,1))});let u=g(),d=g(``);function f(){let t=[...e.children].indexOf(n);if(t<0)return;let r=a[t],i=u.get(),o=d.get();if(r&&r.length!==2){let e=r[0],t=e.length===1&&e[0],n=typeof t==`string`?t:Array.isArray(t)&&t.length===1?t[0]:``;if(!n&&!l||r&&l&&n===l.name&&r[2]===o&&r[1]===i)return}a.splice(t,1,l?[[l.name],i,o]:null)}if(r.addEventListener(`change`,()=>{let e=r.value,t=o.get(e);if(!l&&!t||l?.name===e)return;if(l?.abort(),!t){l=null,f();return}let a=new AbortController,p=AbortSignal.any([a.signal,i]);u.set(void 0),d.set(``);let h=on(t,u,d,s,p);l={name:e,abort(){a.abort()}},n.insertBefore(h,c),p.addEventListener(`abort`,()=>{h.remove()}),m(f,p)}),!t)return;let p=t[0],h=p.length===1&&p[0],_=typeof h==`string`?h:Array.isArray(h)&&h.length===1?h[0]:``;if(r.value=_,!r.value)return;let v=r.value,y=o.get(v);if(!y)return;let b=new AbortController,x=AbortSignal.any([b.signal,i]);v===_?(u.set(t[1]),d.set(t[2]||``)):(u.set(void 0),d.set(``));let S=on(y,u,d,s,x);l={name:v,abort(){b.abort()}},n.insertBefore(S,c),x.addEventListener(`abort`,()=>{S.remove()}),m(f,x)}function l(){for(let e of a)c(e)}l();let u=!1;return{root:e,add:()=>c(),destroy(){return u?a:(u=!0,e.innerHTML=``,r.abort(),a)}}}async function cn(e,t,n,r){if(r?.aborted)return Promise.reject(r.reason);let{resolve:i,reject:a,promise:o}=Promise.withResolvers(),s=e.fields,c=Array.isArray(t)?structuredClone(t):[],l=new Map(Object.entries(s).filter(([,e])=>{let t=e.type;return!(!t||typeof t==`object`)})),u=document.createElement(`dialog`);u.classList.add(`FieldFilter-dialog`);let d=u.appendChild(document.createElement(`div`));d.classList.add(`FieldFilter-filters`);let f=u.appendChild(document.createElement(`form`));f.classList.add(`FieldFilter-form`);let p=f.appendChild(document.createElement(`select`));p.classList.add(`FieldFilter-add`);let h=f.appendChild(document.createElement(`button`));p.classList.add(`FieldFilter-ok`);let _=f.appendChild(document.createElement(`button`));p.classList.add(`FieldFilter-cancel`),h.value=`ok`,f.method=`dialog`,h.appendChild(document.createTextNode(`确认`)),_.appendChild(document.createTextNode(`取消`));let v=p.appendChild(document.createElement(`option`));v.label=`<添加>`;for(let[e,t]of l){let n=t.type;if(!n||typeof n==`object`)continue;let r=document.createElement(`option`);r.value=e,r.label=t.label||e,p.appendChild(r)}function y(e,t,n,i){let a=new AbortController,o=r?AbortSignal.any([r,a.signal]):a.signal,s=d.appendChild(document.createElement(`div`));s.classList.add(`FieldFilter-field`);let l=document.createElement(`span`);l.classList.add(`FieldFilter-fieldName`),s.appendChild(l),l.appendChild(document.createTextNode(n.label||t));let u={inline:!0},f=Ze(n);document.createElement(`span`).classList.add(`FieldFilter-main`);let p=s.appendChild(document.createElement(`select`));p.classList.add(`FieldFilter-operator`);for(let[e,t]of Object.entries(f)){let n=document.createElement(`option`);n.value=e,n.label=t||e,p.appendChild(n)}let h=document.createElement(`button`);h.classList.add(`FieldFilter-remove`),h.type=`button`,s.appendChild(h),h.appendChild(document.createTextNode(`移除`)),h.addEventListener(`click`,()=>{a.abort();let e=[...d.children].indexOf(s);e<0||(s.remove(),c.splice(e,1))});function _(e,t){let n=[...d.children].indexOf(s);if(n<0)return-1;let r=c[n];return!r||Object.is(e,r[1])||Object.is(t,r[2])?n:-1}let v=e[2]||``;p.value=v;let y=e[1];p.value!=v&&(v=p.value,y=null);let b=g(y),x=g(v);m(()=>{let e=b.get(),t=x.get(),n=_(e,t);n<0||c.splice(n,1,[i,e,t])},o);let S=Xe(n,x.get()),C=new AbortController,w=an(S,n,b,x,u,AbortSignal.any([C.signal,o]));p.value=x.get();let T=s.insertBefore(w,h);T.classList.add(`FieldFilter-value`),p.addEventListener(`input`,()=>{let e=p.value;if(e in f,typeof e!=`string`)return;let t=Xe(n,e);if(t===S){x.set(e);return}C.abort(),T.remove(),S=t,x.set(e),C=new AbortController,w=an(S,n,b,x,u,AbortSignal.any([C.signal,o])),T=s.insertBefore(w,h),T.classList.add(`FieldFilter-value`)})}for(let e of c){let t=e[0],n=t.length===1&&t[0],r=typeof n==`string`?n:Array.isArray(n)&&n.length===1?n[0]:``,i=l.get(r);i&&y(e,r,i,t)}return p.addEventListener(`change`,()=>{let e=p.value;p.value=``;let t=l.get(e);t&&y([[e],``,``],e,t,[[e]])}),u.addEventListener(`close`,()=>{if(d.innerHTML=``,u.remove(),r?.aborted)return a(r.reason);if(u.returnValue!==`ok`)return a(Error(`User canceled`));i(c.filter(Boolean))}),(n||document.body).appendChild(u),u.showModal(),o}function R(...e){let t=`/`;for(let n of e){let e=t.lastIndexOf(`?`);e>=0&&t.lastIndexOf(`#`)<e&&(t+=`#`),t+=`/`+n}t=t.split(`#`).map(e=>{let t=e.indexOf(`?`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t):``,i=n.split(`/`),a=i.shift()||``,o=[];for(let e of i)if(e&&e!==`.`){if(e===`..`){o.pop();continue}o.push(e)}return o.unshift(a),`${o.join(`/`)}${r}`}).join(`#`);let n=N.path;if(t.startsWith(n))return t;let r=t.indexOf(`?`),i=t.indexOf(`#`),a=r<0?i:i<0?r:Math.min(r,i),o=a<0?t:t.slice(0,a);return o.length!==n.length-1||!n.startsWith(o)?t:a<0?n:n+t.slice(a)}function ln(e){return!e||typeof e!=`string`?!1:Pe.test(e)}function un(e,t){let{promise:n,resolve:r,reject:i}=Promise.withResolvers();return e instanceof AbortSignal&&(e.aborted?t?i(e.reason):r():e.addEventListener(`abort`,()=>{t?i(e.reason):r()},{once:!0})),n}function dn(e,t){if(!e||typeof e!=`string`)return null;let n=e.slice(0,2);if(n===`#!`||n===`#?`){let t=n.indexOf(`
3
+ `);if(t<0)return null;e.slice(0,t),e=e.slice(t+1)}return null}let fn={imports:{},scopes:{}};try{let{imports:e={},scopes:t={}}=JSON.parse(document.querySelector(`script[type=importmap]`)?.textContent||``);fn={imports:e,scopes:t}}catch{}async function z(e,t,n){if(!e)return;e[0];let r=e.indexOf(`#`),i=r<0?e:e.slice(0,r);t&&typeof t==`string`&&(!i||i===`@`?i=t:i.startsWith(`@/`)&&(i=t+i.slice(1)));let a=await([t,n].find((e=>typeof e==`function`))||(e=>import(e)))(i).catch(e=>{console.error(e)});if(r<0)return a;let o=e.slice(r+1);if(!o)return a.default;let s=a;for(let e of o.split(`.`)){if(!s||typeof s!=`object`)return;s=s[e]}return s}function pn(e,t){if(!t)return null;let n=t[e];if(n)return n;let r=0,i=``;for(let n of Object.entries(t)){let[t,a]=n;t[t.length-1]===`/`&&e.startsWith(t)&&t.length>r&&(r=t.length,i=a)}return r?(i[i.length-1]!==`/`&&(i+=`/`),i+e.slice(r)):null}function mn(e,t){let n=``,r=null;for(let[e,i]of Object.entries(fn.scopes))t.startsWith(e)&&e.length>n.length&&(n=e,r=i);return pn(e,r)||pn(e,fn.imports)||e}function hn(e,t,n){let r=document.createElement(`link`);return new Promise((i,a)=>{r.addEventListener(`load`,()=>i(r)),r.addEventListener(`error`,e=>a(e.error));let o=!(n&&t)&&Fe.exec(e)?.groups;if(o){let{pluginId:e,path:t}=o,n=Object.hasOwn(M,e)&&M[e]||{},i=`/assets/plugins/${e}/${n.version||`VERSION`}/`,a=location.origin+i,s=n.assets?.[t]||mn(t,i);if(s){r.href=new URL(s,a).href,r.rel=`stylesheet`,document.head.appendChild(r);return}}let s=t&&M[t]||{},c=s.version||`VERSION`,l=t?`/assets/plugins/${t}/${c}/`:``,u=t?location.origin+l:location.href;t&&e[0]!==`.`&&e[0];let d=s.assets?.[e]||l&&mn(e,l)||e;r.href=new URL(d,u).href,r.rel=`stylesheet`,document.head.appendChild(r)})}var B=class extends Error{constructor(e){super(`${e}`),this.status=e}};function V(e,t,...n){let r=Object.create(null),i=new Set,a=Object.create(null),o=Object.create(null),s=[],c=new Set;function l(t,n){let i=e(...n);return r[t]=i,i.then(e=>{let n=a[t];if(n)return n.set(e);a[t]=g(e);for(let e of s)e(t)},()=>{r[t]===i&&delete r[t]}),i}function u(e){c.has(e)||(c.add(e),requestIdleCallback(()=>{if(!c.has(e))return;c.delete(e);let t=o[e];t&&l(e,t)}))}for(let e of n)e.listen(u);function d(e,...n){let s=Array.isArray(e)?e.join(`
4
+ `):e;o[s]=n;function c(e){return!e&&Object.hasOwn(r,s)&&r[s]||l(s,n)}function u(){(!Object.hasOwn(r,s)||!r[s]||i.has(s))&&(l(s,n),i.delete(s));let e=a[s];return e||(e=g(t),a[s]=e),e.get()}function d(){o[s]===n&&(delete o[s],delete a[s],delete r[s])}return{get:u,load:c,destroy:d}}function f(e){s.push(e)}return{create:d,listen:f}}function H(e){return{then(t,n){return e().then(t,n)},catch(t){return e().catch(t)},finally(t){return e().finally(t)}}}function gn(e){return Promise.all(Array.isArray(e)?e.map(async e=>{let t=typeof e==`string`?e:e[0];if(!t||typeof t!=`string`)return;let n=await z(t);if(typeof n!=`function`)return n;let r=typeof e==`string`?null:e[1];return n(typeof r==`object`&&r||{})}):[])}async function _n({type:e,scripts:t,...n},r){let i=Object.create(null),a=Object.create(null);for(let e of[await gn(t),r].flat()){if(!e||typeof e!=`object`)continue;let{subFields:t,...n}=e;for(let[e,t]of Object.entries(n)){let n=a[e];n?n.push(t):a[e]=[t]}if(t)for(let[e,n]of Object.entries(t)){let t=i[e];t?t.push(n):i[e]=[n]}}return{...n,script:yn(a),type:typeof e==`object`&&e?await vn(e,i):e}}async function vn(e,t){let n=Object.entries(e).map(([e,n])=>Promise.all([e,_n(n,t[e])]));return Object.fromEntries(await Promise.all(n))}function U(e,t){if(!e)return null;let n=e.filter(e=>typeof e==`function`);return n.length?t?(...e)=>{for(let t of n)t(...e)}:async(...e)=>{for(let t of n)await t(...e)}:null}function yn(e){return{input:U(e.input),change:U(e.change),click:U(e.click),focus:U(e.focus),blur:U(e.blur),add:e.add?.find(e=>typeof e==`function`),remove:U(e.remove),move:U(e.move)}}function bn({listScripts:e,documentScripts:t,...n}){return{input:U(n.input),change:U(n.change),beforeCreate:U(n.beforeCreate),beforeUpdate:U(n.beforeUpdate),beforeSave:U(n.beforeSave),beforeDestroy:U(n.beforeDestroy),beforeUpsert:U(n.beforeUpsert),listScripts:e?Object.assign({},...e):{},documentScripts:t?Object.assign({},...t):{}}}async function xn({fields:e,scripts:t,...n}){let r=Object.create(null),i=Object.create(null);for(let e of await gn(t)){if(!e||typeof e!=`object`)continue;let{fields:t,...n}=e;for(let[e,t]of Object.entries(n)){let n=i[e];n?n.push(t):i[e]=[t]}if(t)for(let[e,n]of Object.entries(t)){let t=r[e];t?t.push(n):r[e]=[n]}}return{...n,script:bn(i),fields:await vn(e,r)}}const Sn=V(e=>e.clone().body({}).json().then(e=>e.options),[]);function Cn(e,t){let n=e.clone().append(`/documents`),r=e.clone().append(`/options`),{get:i,load:a}=Sn.create(t,r);return{async query({values:e,where:t,orWhere:r,sort:i,limit:a=20,page:o,offset:s,select:c,total:l}={}){return n.clone().body({values:e,where:t,orWhere:r,sort:i,limit:a,page:o,offset:s,select:c,total:l}).json()},getOptions(){return i()},async options(e){if(!e||typeof e==`boolean`)return a(e);let{values:t,where:n,orWhere:i,sort:o,limit:s=20,page:c,offset:l,select:u,total:d}=e;return r.clone().body({values:t,where:n,orWhere:i,sort:o,limit:s,page:c,offset:l,select:u,total:d}).json()},async option(e){return r.clone().append(`/${encodeURIComponent(e)}`).get().json()},async create(e){return n.clone().post().body({document:e}).json()},document(e){let t=n.clone().append(`/${encodeURIComponent(e)}`);async function r(){return t.get().json().then(e=>e.document)}return{get:r,async update(e){return t.clone().put().body({document:e}).json()},async delete(){return t.delete().done()},field(e){let n=t.clone().append`fields/${e}`;async function r(){return n.get().json().then(e=>e.value)}return{get:r,...H(r)}},...H(r)}}}}const wn=V(e=>e.result().then(e=>typeof e==`object`&&e||null,e=>Promise.reject(new B(e instanceof Response?e.status:100))),null),Tn=V(e=>e().then(async e=>e&&xn(e)),null,wn);function En(e){let t=A.clone().path`models/${e||``}`,{get:n,load:r}=wn.create(e,t),{get:i,load:a}=Tn.create(e,r);return{loadModel:r,loadScript:a,getModel:n,getScript:i,...Cn(t,[e,``].join(`
5
+ `)),...H(r)}}const Dn=V(e=>e.json().then(e=>typeof e==`object`&&e.values||[],()=>[]),[]);function On(e){let t=A.clone().path`enumerations/${e||``}`,{get:n,load:r}=Dn.create(e,t);return{load:r,get:n,...H(r)}}const kn=V(e=>e.result().then(e=>typeof e==`object`&&e||null,e=>Promise.reject(new B(e instanceof Response?e.status:100))),null);function An(e){let t=A.clone().path`formLayouts/${e||``}`,{get:n,load:r}=kn.create(e,t);return{load:r,get:n,...H(r)}}const jn=A.clone().path`permissions`;let W=null,Mn=!1;const Nn=g([]);function Pn(){let e=jn.json().then(e=>Array.isArray(e)&&e||[]);return W=e,e.then(e=>Nn.set(e),()=>{W===e&&(W=null)}),e}function Fn(e){return!e&&W?W:Pn()}function In(){return(!W||Mn)&&(Pn(),Mn=!1),Nn.get()}var Ln={load:Fn,get:In,...H(Fn)};async function Rn(e,t){let n=A.clone();n=t?n.get`menus/${e}/groups/${t}`:n.get`menus/${e}`;let{menus:r}=await n.json();return r}const zn=Object.create(null);function Bn(e,t,n){let r=zn[e];r||(zn[e]=r=Object.create(null));let i=typeof t==`string`?t:``;if(t!==!0&&n!==!0){let e=r[i];if(e)return e}let a=Rn(e,i);return r[i]=a,a.catch(()=>{r[i]===a&&(r[i]=null)}),a}let Vn=class{#e;#t;#n;#r;#i=[];#a=document.createElement(`table`);#o=this.#a.appendChild(document.createElement(`thead`));#s=this.#o.appendChild(document.createElement(`tr`));#c=this.#a.appendChild(document.createElement(`tbody`));get root(){return this.#a}get createUrl(){return this.#e}set createUrl(e){let t=typeof e==`function`?e:null;this.#e!==t&&(this.#e=t,this.#l())}constructor(e,t){let n=Object.entries(t.fields).filter(([,{type:e}])=>e&&typeof e!=`object`),r=Object.entries(t.fields).filter(([,e])=>e.primary).map(([e])=>e);this.#n=t.labelPattern||``,this.#e=typeof e==`function`?e:null,this.#t=n,this.#r=r;let i=this.#s;i.innerHTML=``,i.appendChild(document.createElement(`th`)).appendChild(document.createTextNode(`#`));for(let[e,t]of n)i.appendChild(document.createElement(`th`)).appendChild(document.createTextNode(t.label||e))}#l(){let e=this.#c;e.innerHTML=``;let t=this.#r,n=this.#n,r=this.#t,i=this.#e;for(let a of this.#i){let o=e.appendChild(document.createElement(`tr`)),s=o.appendChild(document.createElement(`td`)),c=O(n,a)||t.map(e=>a[e]).join(`$`);if(i){let e=s.appendChild(document.createElement(`a`));e.href=i(t.map(e=>a[e]).join(`$`)),e.appendChild(document.createTextNode(c))}else s.appendChild(document.createTextNode(c));for(let[e,t]of r){let n=o.appendChild(document.createElement(`td`)),r=en(e,t,{inline:!0},a);n.appendChild(r.root)}}}setData(e){this.#i=e,this.#l()}destroy(){}},Hn=class{#e=document.createElement(`div`);get root(){return this.#e}get size(){return 5}set size(e){}get page(){return 1}set page(e){}get total(){return 0}set total(e){}listen(e){return()=>{}}destroy(){}},Un=(e,t,n)=>null,Wn=(e,t,n,r)=>null,Gn=()=>null;function Kn(e={}){Vn=e.list||e.List||Vn,Hn=e.pagination||e.Pagination||Hn;let t=e.createMenuButtons||e.menuButtons,n=e.createMenuButton||e.menuButton,r=e.createMenuItem||e.menuItem;typeof t==`function`&&(Un=t),typeof n==`function`&&(Wn=n),typeof r==`function`&&(Gn=r)}const qn=[`uri`,`target`,`page`,`path`,`command`,`script`,`click`];function Jn(e,t){for(let n of t)delete e[n];return e}function Yn(e,t=[]){let n=[],r=[];for(let{level:i,type:a,...o}of e){let e=Math.max(0,Math.floor(i))||0;r.length=e;let s=r.findLast(Boolean);if(a===`button`){let e=o;s?s.buttons.push(e):t.push(e);continue}let c=a===`divider`?null:{...o,buttons:[],children:[]};s?s.children.push(c):n.push(c),r[e]=c}return n}function Xn(e,t,n){let r=[];for(let i of e){if(!i){r.push(i);continue}let{children:e}=i;if(t&&!t(i))continue;if(!e?.length){r.push(i);continue}let a=Xn(e,t,n).filter((e,t,n)=>!!(e||t===0||n[t-1]));a.length&&(n&&a.filter(Boolean).length<=1?r.push(...a):(a[a.length-1]||a.pop(),a[0]||a.shift(),r.push({...i,children:a})))}if(n&&r.length===1){let[e]=r;if(e?.children?.length)return e.children}return r}function Zn(e,t,...n){let r=e,i=n.pop();for(let e of n){let t=r.get(e);t||(t=new Map,r.set(e,t)),r=t}r.set(i,t)}function Qn(e,t,n,r){let i=new Map,a=new Map;for(let[t,n]of Map.groupBy(e,e=>e.groupType||``).entries())for(let[e,r]of Map.groupBy(n,e=>e.group||``).entries()){let n=[],o=Yn(r,n);Zn(a,n,t,e),Zn(i,o,t,e)}let o=new Map,s=new Map;function c(e){for(let t=e.length-1;t>=0;t--){let n=e[t],{refType:r,refId:i}=n;if(!r||!i)continue;Jn(n,qn);let a=s.get(r)?.get(i);e.splice(t,1,...a||[])}}function l(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!n)continue;if(n.children?.length){l(n.children);continue}let{refType:r,refId:i,refMode:a}=n;if(!r||!i)continue;Jn(n,qn);let c=o.get(r)?.get(i),u=s.get(r)?.get(i);if(!c?.length&&!u?.length){e.splice(t,1);continue}a===`replace`?e.splice(t,1,...c||[]):(n.children=c||[],n.buttons=u||[])}}for(let e of[`builtin`,`module`,`group`]){let t=i.get(e);if(t){for(let e of t.values())l(e);o.set(e,t)}let n=a.get(e);if(n){for(let e of n.values())c(e);s.set(e,n)}i.delete(e),a.delete(e)}for(let e of i.values())for(let t of e.values())l(t);for(let e of a.values())for(let t of e.values())c(t);for(let[e,t]of a.entries())s.set(e,t);for(let[e,t]of i.entries())o.set(e,t);if(r)for(let e of s.get(t)?.get(n)||[])r.push(e);return o.get(t)?.get(n)||[]}const G={fromDefine(e,t){return Yn(e,t)},build(e,t,n,r){return Qn(e,t,n,r)},filter(e,t,n){let r=Xn(e,t,n),i=[],a=!1;for(let e of r){if(e){a&&i.push(null),a=!1,i.push(e);continue}i.length&&(a=!0)}return i},createButton(e,t,n,r){return Wn(e,t,n,r||L)},createButtons(e,t,n){return Un(e,t,n||L)},createItem(e,t){return Gn(e,t||L)}},$n=V(async e=>{let t=await e.result().then(e=>typeof e==`object`&&e||null,e=>Promise.reject(new B(e instanceof Response?e.status:100)));if(!t||typeof t!=`object`)return null;let n=[],r=G.fromDefine(t.menus||[],n),{where:i,orWhere:a}=me(t.hiddenFilter||``);return{...t,where:i,orWhere:a,menuButtons:n,menus:r,forms:Object.fromEntries(t.forms?.map(e=>[e.type,e])||[])}},null);function er({model:e,organization:t,user:n,workspace:r,page:i}){let a=[e,t,n,r,i].map(e=>e||``).join(`
6
+ `),o=A.clone().path`page`;e&&(o=o.query({model:e})),t&&(o=o.query({organization:t})),n&&(o=o.query({user:n})),r&&(o=o.query({workspace:r}));let s=N.id;s&&(o=o.query({application:s})),o=o.query({page:i});let{get:c,load:l}=$n.create(a,o);return{loadPage:l,getPage:c,loadConfiguration(){return l().then(e=>typeof e==`object`&&e?.config)},...H(l)}}let tr={main:null,details:null,setting:null,input:null,edit:null,copy:null};function nr(){let{model:e,modelDetails:t,modelSetting:n,modelInput:r,modelEdit:i,modelCopy:a,user:o,userDetails:s,userSetting:c,userInput:l,userEdit:u,userCopy:d,workspace:f,workspaceDetails:p,workspaceSetting:m,workspaceInput:h,workspaceEdit:g,workspaceCopy:_}=ft;tr={main:e?()=>z(e):null,details:t?()=>z(t):null,setting:n?()=>z(n):null,input:r?()=>z(r):null,edit:i?()=>z(i):null,copy:a?()=>z(a):null}}nr();const rr=_(()=>{let e={};for(let[t,n]of Object.entries(k.get(`configurationPages`).named()))if(n){if(typeof n==`function`){e[t]=()=>n;continue}if(typeof n==`string`){e[t]=()=>z(n);continue}}for(let[t,n]of Object.entries(j.configurationPages||{}))e[t]=()=>z(n);return e});async function ir(e){let{model:t,id:n,workspace:r,setting:i,edit:a,input:o,continuation:s}=e;if(s||i)return null;let c={type:`model`,model:t,workspace:r,id:``,input:``,edit:!1},l=`main`;n?(c.id=n,o?(c.input=o,l=`copy`):a?(c.edit=!0,l=`edit`):l=`details`):o&&(c.input=o,l=`input`);let u=await er({...c,page:l});if(!u&&!r){let e=await En(t).catch(e=>e instanceof B?e.status:Promise.reject(e));if(!e||typeof e!=`object`)return null;let n=e.pages,r=n&&Object.hasOwn(n,l)&&n[l];if(r===``)return null;u=typeof r==`string`?{widget:r}:typeof r==`object`&&r||{}}if(typeof u!=`object`)return u;let d=u?.widget;if(d===``)return null;let f=typeof d==`string`?()=>z(d):!r&&tr[l]||null;return f?{ident:c,widget:f,page:typeof u==`object`&&u||null}:null}async function ar(e){let{id:t,edit:n,input:r,workspace:i,setting:a,continuation:o}=e;if(o||a)return null;let s={type:`workspace`,workspace:i,id:``,input:``,edit:!1},c=`main`;t?(s.id=t,r?(s.input=r,c=`copy`):n?(s.edit=!0,c=`edit`):c=`details`):r&&(s.input=r,c=`input`);let l=await er({...s,page:c});if(typeof l!=`object`)return l;let u=l?.widget;return u?{ident:s,widget:()=>z(u),page:typeof l==`object`&&l||null}:null}async function or(e){let{id:t,organization:n,edit:r,input:i,workspace:a,setting:o,continuation:s}=e;if(s||o)return null;let c={type:`organization`,organization:n,workspace:a,id:``,input:``,edit:!1},l=`main`;t?(c.id=t,i?(c.input=i,l=`copy`):r?(c.edit=!0,l=`edit`):l=`details`):i&&(c.input=i,l=`input`);let u=await er({...c,page:l}).catch(e=>e instanceof B?e.status:Promise.reject(e));if(typeof u!=`object`)return null;let d=u?.widget;return d?{ident:c,widget:()=>z(d),page:typeof u==`object`&&u||null}:null}async function sr(e){let{id:t,user:n,edit:r,input:i,workspace:a,setting:o,continuation:s}=e;if(s||o)return null;let c={type:`user`,user:n,workspace:a,id:``,input:``,edit:!1},l=`main`;t?(c.id=t,i?(c.input=i,l=`copy`):r?(c.edit=!0,l=`edit`):l=`details`):i&&(c.input=i,l=`input`);let u=await er({...c,page:l}).catch(e=>e instanceof B?e.status:Promise.reject(e));if(typeof u!=`object`)return null;let d=u?.widget;return d?{ident:c,widget:()=>z(d),page:typeof u==`object`&&u||null}:null}async function cr(e){let{type:t}=e;if(t===`model`)return ir(e);if(t===`workspace`)return ar(e);if(t===`organization`)return or(e);if(t===`user`)return sr(e);if(t===`configuration`){let t=rr.get(),{continuation:n}=e,r=Object.hasOwn(t,n)?t[n]:null;return typeof r==`function`?{widget:r,ident:e,page:null}:null}let n=t&&t in ft&&ft[t];return typeof n==`string`?{widget:()=>z(n),ident:e,page:null}:null}const K=document.createElement(`div`),lr=document.querySelector(`head`),ur=document.querySelector(`link[rel=icon]`)||document.createElement(`link`);ur.rel=`icon`;const dr=ur.href;let fr=dr;function pr(e){let t=e||dr;if(t!==fr){if(fr=t,!t){ur.remove();return}ur.href=t,lr.appendChild(ur)}}const mr=new Map;function hr(e){let t=Symbol();return mr.set(t,e),()=>{mr.delete(t)}}const q=new Map;let J=[],gr=g(void 0);function _r(e){let t=e&&q.get(e);if(gr.get()!==t&&(gr.set(t),t)){let e=J.indexOf(t);e>0&&J.splice(e,1),e&&J.push(t)}}function vr(){return[...q.values()]}function yr(e,t){q.set(e,t),gr.set(t);for(let e of[...mr.values()])e(t)}function br(e){let t=q.get(e);if(q.delete(e),!t)return;let n=J.indexOf(t);if(n>=0&&J.splice(n,1),gr.get()!==t||(gr.set(void 0),I.waitLogin))return;let r=J[0];yi(r?.href||N.path,!1,!0)}function xr(){for(let e of[...q.values()])e.destroy()}function Sr(e){e.appendChild(document.createTextNode(`主页`))}const Cr=document.createElement(`div`),wr=Cr.attachShadow({mode:`closed`});wr.innerHTML=`<style>
6
7
  div::after, div::before {
7
8
  content: '';
8
9
  height: 100px;
@@ -30,10 +31,10 @@ opacity: 0;
30
31
  z-index: 1;
31
32
  }
32
33
  }
33
- </style><div></div>`;const ar=document.createElement(`div`);ar.appendChild(rr);var or=ar;function sr(e){ar.hidden=!e}K.appendChild(or);let cr=sr;const lr=g(void 0),Y=g(null);function ur(e,t){if(cr===e)return;cr&&cr(!1);let n=lr.get();cr=e,lr.set(t),n?.hide(),e&&e(!0)}const X=document.createElement(`div`);X.hidden=!0;function dr(e){X.hidden=!e}K.appendChild(X);const fr=g(`?`),pr=g(`#`),mr=new Map;mr.set(`update`,new Set([()=>(X.innerHTML=``,nr(X))]));function hr(e){for(let t of[...mr.get(e)||[]])t()}var gr=class{get container(){return X}get current(){return cr===dr}get home(){return!0}get search(){return fr.get()}get hash(){return pr.get()}open(e,t){Jr(e[0]===`/`?e:R(N.pathname,e),t)}listen(e,t){let n=t.bind(this),r=mr.get(e);return r||(r=new Set,mr.set(e,r)),r.add(n),()=>{r?.delete(n)}}};function _r(e){return typeof e==`function`?(hr(`destroy`),X.innerHTML=``,mr.clear(),e(new gr),!0):!1}function vr(){let e=Y.get();e&&(Y.set(null),e.hide()),ur(dr),Zn(),hr(`update`)}function yr(e,t){fr.set(e||`?`),pr.set(t||`#`),vr()}let br=null;function xr(e){let t=Y.get();if(t){if(!e){br!==null&&(clearTimeout(br),br=null),ur(t.toggle,t);return}br===null&&(br=setTimeout(()=>{br=null,ur(sr),Zn()},300))}}function Sr(e,t){let n=Y.get();if(n===e){xr(t),Zn(n);return}let r=n;n||hr(`update`);let i=e;Y.set(i),r?.hide(),xr(t),Zn(i)}var Cr=p({decode:()=>wr,encode:()=>Tr,parse:()=>Er,stringify:()=>Dr});function wr(e){return decodeURIComponent(e.replace(/\+/g,`%20`))}function Tr(e){return encodeURIComponent(typeof e==`string`?e:Dr(e)).replace(/%20/g,`+`).replace(/%3A/g,`:`).replace(/%3D/g,`=`).replace(/%26/g,`&`).replace(/%24/g,`$`).replace(/%40/g,`@`)}function Er(e){if(!e)return{type:`home`};switch(e){case`!`:case`!`:return{type:`todo`};case`-`:case`-`:return{type:`settings`};case`=`:case`=`:return{type:`search`};case`:`:case`:`:return{type:`status`};case`+`:case`+`:return{type:`devtools`};case`&`:case`@`:case`~`:case`_`:case`*`:}function t(t,n){let{index:r}=t.exec(e)||{index:-1};if(r<0)return;let i=e.substring(r+1)||n;return e=e.substring(0,r),i}let n=t(/[==]/);e=e.replaceAll(/[~~]+/g,`~`).replaceAll(/[!!]+/g,`!`).replaceAll(/[@@]+/g,`@`).replaceAll(/[&&]+/g,`&`).replaceAll(/[**]/g,`*`).replaceAll(/[::]+/g,`:`).replaceAll(/[((]+/g,`(`).replaceAll(/[))]+/g,`)`);let r=n?!!t(/(?<!\*)\*$/,`*`):void 0,i=r?void 0:t(/\*.*/,`*`)?.replace(/[~!@&()].*/,``),a=!!t(/!$/,i||n?void 0:`!`),o=/(?=[~!@&])/,s=new Map([[`&`,[]],[`@`,[]],[`~`,[]],[`!`,[]],[`*`,[]]]),c=[];for(let t of e.split(o))(s.get(t[0])||c).push(t);let l=s.get(`!`)?.join(``).slice(1)||``,u=s.get(`~`)?.join(``).slice(1)||``,d=s.get(`&`)?.join(``).slice(1)||``,f=s.get(`@`)?.join(``).slice(1)||``,p=c.join(``);return p?{type:`model`,model:p,workspace:u,continuation:l,setting:a,edit:r,input:i,id:n}:d?{type:`organization`,organization:d,workspace:u,continuation:l,setting:a,edit:r,input:i,id:n}:f?{type:`user`,user:f,workspace:u,continuation:l,setting:a,edit:r,input:i,id:n}:u?{type:`workspace`,workspace:u,continuation:l,setting:a,edit:r,input:i,id:n}:l?{type:`configuration`,continuation:l,setting:a,edit:r,input:i,id:n}:{type:`home`}}function Dr(e){switch(e.type){case`home`:return`/`;case`settings`:return`-`;case`todo`:return`!`;case`search`:return`=`;case`status`:return`:`;case`devtools`:return`+`}let{model:t,user:n,organization:r,workspace:i,continuation:a,setting:o,input:s,edit:c,id:l}=e,u=``;return t?u=t:r?u+=`&${r}`:n&&(u+=`@${n}`),i&&(u+=`~${i}`),a&&(u+=`!${a}`),o?(u+=`!`,u):l?(s?u+=`*${s}`:c&&(u+=`*`),u+=`=${l}`,u):(s&&(s===`*`?u+=`*`:u+=`*${s}`),u)}let Or=e=>{let t=e.indexOf(`/`),n=wr(t<0?e:e.slice(0,t)),r=t<0?`/`:e.slice(t),i=Er(n),a=Tr(Dr(i));return{page:i,pageRoot:a,path:r,redirect:a!==n}},kr=Dr;function Ar(e){Or=e.parse,kr=e.stringify}var Z=class{#e=g(!1);constructor(e){e instanceof AbortSignal?(this.#t=e,e.aborted?this.#e.set(!0):e.addEventListener(`abort`,()=>{this.#e.set(!0)},{once:!0})):this.#t=L}get destroyed(){return this.#e.get()}#t;get signal(){return this.#t}},jr=class extends Z{#e=g(``);#t=g(!0);#n=g(!1);#r=g(!1);#i=g(!0);#a=()=>{};#o;#s;#c=g(``);#l=g(``);#u=g(``);#d=_(()=>R(this.#s,`${this.#c.get()}${this.#l.get()}${this.#u.get()}`));#f=_(()=>`${this.#o}/${this.#c.get()}${this.#l.get()}${this.#u.get()}`);#p;#m;#h;#g;#_;#v;constructor({pageId:e,define:t,ident:n,root:r,path:i,search:a,hash:o,pageHandler:s,open:c,setRootPath:l}){let u=new AbortController;super(u.signal),this.#v=u,this.#s=r,this.#c.set(i),this.#l.set(a),this.#u.set(o),this.#p=t,this.#m=n,this.#o=e,this.#h=s,this.#g=c,this.#_=l;let d=this.#y;s.toggle=e=>{for(let t of[...d])t(e)},s.hide=()=>{this.#a()},s.update=(e,t,n)=>{this.#c.set(e),this.#l.set(t),this.#u.set(n),Sr(s,this.#i.get())};let f=t?.title;f&&(this.title=f),$n(s,this)}#y=new Set;onToggle(e,t){if(t?.aborted)return;let n=this.#y;n.add(e),t.addEventListener(`abort`,()=>{n.delete(e)},{once:!0})}get bootLoading(){return this.#i.get()}get define(){return this.#p}get ident(){return this.#m}get root(){return this.#s}get path(){return this.#c.get()}get search(){return this.#l.get()}get hash(){return this.#u.get()}get href(){return this.#d.get()}get current(){return this.#h===Y.get()}get shown(){return this.#h===lr.get()}get title(){return this.#e.get()}set title(e){this.#e.set(e)}get unsaved(){return this.#n.get()}set unsaved(e){this.#n.set(e)}get loading(){return this.#t.get()}set loading(e){this.#t.set(e),e||this.#i.set(!1),this.#h===Y.get()&&(this.#i.get()||xr(!1))}toUrl(e,t){if(t){if(typeof t==`string`)return R(N.pathname,t,e);if(typeof t==`object`)return R(N.pathname,kr(t),e)}return e[0]===`/`?e:R(this.#s,e)}open(e,t,n){this.#g(this.toUrl(e,typeof t==`boolean`?``:t),typeof t==`boolean`?t:n)}setPath(e,t){let n=e.indexOf(`#`);if(this.#u.set(n>=0?e.slice(n):``),n>=0&&(e=e.slice(0,n)),e){let t=e.indexOf(`?`);this.#l.set(t>=0?e.slice(t):``),t>=0&&(e=e.slice(0,t))}e&&this.#c.set(e),this.#h===Y.get()&&this.#_(this.#f.get(),t)}show(e){this.#h!==Y.get()&&this.#_(this.#f.get(),e)}get destroyDeferred(){return!this.destroyed&&this.#r.get()}destroy(e){let t=()=>{this.#a=()=>{};let e=this.#v;return e.signal.aborted?!1:(e.abort(),er(this.#h),!0)};return e?this.#r.get()||this.destroyed?!1:(this.#r.set(!0),lr.get()===this.#h?(this.#a=t,!0):t()):t()}};const Mr={404:{title:`您所请求的页面无法找到`,description:`服务器无法正常提供信息。
34
- 目标页面可能已经被更改、删除或移到其他位置,或您所输入页面地址错误。`}};let Nr=function(e,t){let n=(typeof t==`number`||typeof t==`string`)&&Object.hasOwn(Mr,t)&&Mr[t]||Mr[404],r=n?.title||`Error`,i=n?.description,a=document.createElement(`div`),o=a.appendChild(document.createElement(`div`)),s=o.appendChild(document.createElement(`div`)),c=o.appendChild(document.createElement(`div`));if(a.style.marginBlock=`8%`,a.style.marginInline=`auto`,a.style.inlineSize=`600px`,a.style.maxInlineSize=`100%`,a.style.padding=`20px`,s.style.paddingBlock=`20px`,s.style.fontSize=`20px`,s.style.color=`#8e8e8e`,s.style.textAlign=`center`,c.style.fontSize=`13px`,c.style.lineHeight=`1.3em`,c.style.color=`#b5b5b5`,s.appendChild(document.createTextNode(r)),e.title=r||`Error`,i&&typeof i==`string`)for(let e of i.split(`
35
- `))c.appendChild(document.createTextNode(e)),c.appendChild(document.createElement(`br`));e.container.appendChild(a),e.loading=!1};function Pr(e){if(typeof e!=`function`)return!1;Nr=e}var Fr=class extends Z{#e=document.createElement(`div`);get container(){return this.#e}constructor(e,t){super(t);let n=e.appendChild(this.#e);e.className=`Page-footer`,n.className=`Page-footer-main`}},Ir=class extends Z{#e=document.createElement(`div`);#t=document.createElement(`div`);get container(){return this.#e}#n=()=>{};setMenu(e,t=G.createItem){if(this.destroyed)return;this.#n();let n=this.#t,r=new AbortController,i=G.createButtons(e,t,AbortSignal.any([r.signal,this.signal]));i&&n.appendChild(i),this.#n=()=>{r.abort(),i?.remove(),this.#n=()=>{}}}constructor(e,t){super(t);let n=e.appendChild(this.#e),r=e.appendChild(this.#t);e.className=`Page-header`,n.className=`Page-header-main`,r.className=`Page-header-menu`}},Lr=class extends Z{#e=document.createElement(`div`);#t=this.#e.appendChild(document.createElement(`div`));get container(){return this.#t}get panel(){return this.#e.classList.contains(`Page-panel`)}set panel(e){e?this.#e.classList.add(`Page-panel`):this.#e.classList.remove(`Page-panel`)}#n;#r;#i=g(!1);get inserted(){return this.#i.get()}insert(){this.destroyed||(this.#i.set(!0),this.#e.nextSibling!==this.#r&&this.#n.insertBefore(this.#e,this.#r))}remove(){this.#e.remove(),this.#i.set(!1)}constructor(e,t,n,r){super(r);let i=e.insertBefore(document.createComment(``),t);this.#n=e,this.#r=i;let a=this.#e,o=this.#t;a.className=`Page-section`,o.className=`Page-section-main`,n&&e.insertBefore(a,i),this.signal.addEventListener(`abort`,()=>{a.remove(),i.remove(),this.#i.set(!1)},{once:!0})}},Rr=class extends Z{#e=document.createElement(`div`);#t=this.#e.appendChild(document.createElement(`div`));#n=this.#e.appendChild(document.createElement(`div`));#r=this.#t.appendChild(document.createElement(`div`));#i=this.#t.appendChild(document.createElement(`div`));#a=this.#n.appendChild(document.createElement(`div`));get container(){return this.#a}get panel(){return this.#n.classList.contains(`Page-panel`)}set panel(e){e?this.#n.classList.add(`Page-panel`):this.#n.classList.remove(`Page-panel`)}get title(){return this.#r.textContent||``}set title(e){this.#r.textContent=e}#o=null;#s;#c;setMenu(e,t,n=G.createItem){if(this.signal.aborted)return;this.#o?.abort();let r=new AbortController;this.#o=r;let i=AbortSignal.any([r.signal,this.signal]),a=G.createButton(e,t,n,i);a&&(this.#t.appendChild(a),i.addEventListener(`abort`,()=>{a.remove()},{once:!0}))}#l=g(!1);get inserted(){return this.#l.get()}insert(){this.destroyed||(this.#l.set(!0),this.#e.nextSibling!==this.#c&&this.#s.insertBefore(this.#e,this.#c))}remove(){this.#e.remove(),this.#l.set(!1)}constructor(e,t,n,r){super(r);let i=e.insertBefore(document.createComment(``),t);this.#s=e,this.#c=i;let a=this.#e,o=this.#t,s=this.#n,c=this.#r,l=this.#i,u=this.#a;a.className=`Page-sider`,o.className=`Page-sider-header`,s.className=`Page-sider-body`,u.className=`Page-sider-body-main`,c.className=`Page-sider-title`,l.className=`Page-sider-buttons`,n&&e.insertBefore(a,i),this.signal.addEventListener(`abort`,()=>{a.remove(),i.remove(),this.#l.set(!1)},{once:!0})}};function zr(e,t,n,r){return new Rr(e,t,n,r)}var Br=class{#e=document.createElement(`div`);#t=this.#e.appendChild(document.createElement(`div`));#n=this.#e.appendChild(document.createElement(`div`));#r=this.#n.appendChild(document.createElement(`div`));#i=this.#r.appendChild(document.createElement(`div`));#a=!1;#o=null;#s=null;#c=`scroll`;get destroyed(){return this.#a}get container(){return this.#i}get mode(){return this.#c}set mode(e){let t=this.#e;t.classList.remove(`Page-mode-${this.#c}`),this.#c=e,t.classList.add(`Page-mode-${e}`)}get panel(){return this.#r.classList.contains(`Page-panel`)}set panel(e){e?this.#r.classList.add(`Page-panel`):this.#r.classList.remove(`Page-panel`)}get show(){return!this.#e.hidden}toggle(e){this.#e.hidden=!e}destroy(){return this.#a?!1:(this.#a=!0,this.#e.remove(),this.#p.abort(),!0)}#l=null;#u=null;createHeader(e){if(this.#a)throw Error(`页面组件已被销毁`);if(e?.aborted){let t=this.#u;t&&t.abort(e.reason),e.throwIfAborted()}if(this.#o)return this.#o;let t=document.createElement(`div`),n=new AbortController;this.#n.insertBefore(t,this.#n.firstChild),this.#l=t,this.#u=n;let r=new Ir(t,AbortSignal.any([this.signal,n.signal,...e?[e]:[]]));return this.#o=r,r.signal.addEventListener(`abort`,()=>{this.#u=null,this.#o=null,this.#l=null,t.remove()},{once:!0}),this.#o}#d=null;#f=null;createFooter(e){if(this.#a)throw Error(`页面组件已被销毁`);if(e?.aborted){let t=this.#f;t&&t.abort(e.reason),e.throwIfAborted()}if(this.#s)return this.#s;let t=document.createElement(`div`),n=new AbortController;this.#n.appendChild(t),this.#d=t,this.#f=n;let r=new Fr(t,AbortSignal.any([this.signal,n.signal,...e?[e]:[]]));return this.#s=r,r.signal.addEventListener(`abort`,()=>{this.#f=null,this.#s=null,this.#d=null,t.remove()},{once:!0}),this.#s}createSection(e,t,n){if(this.#a)throw Error(`页面组件已被销毁`);n?.throwIfAborted();let r=this.#n,i=null;switch(e){case`start`:i=this.#l||r.firstChild;break;case`before`:i=this.#i;break;default:case`after`:i=this.#i.nextSibling;break;case`end`:i=this.#d;break}return new Lr(r,i,t!==!1,n instanceof AbortSignal?AbortSignal.any([n,this.#m]):this.#m)}#p=new AbortController;#m=this.#p.signal;get signal(){return this.#m}get siderOpen(){return!this.#t.hidden}set siderOpen(e){this.#t.hidden=!e}createSider(e,t){if(this.#a)throw Error(`页面组件已被销毁`);t?.throwIfAborted();let n=this.#t;return zr(n,null,e!==!1,t instanceof AbortSignal?AbortSignal.any([t,this.#m]):this.#m)}constructor(e){this.#n.className=`Page-main`,this.#r.className=`Page-body`,this.#i.className=`Page-body-main`,this.#t.className=`Page-sides`;let t=this.#e;t.className=`Page`,t.hidden=!e,K.appendChild(t)}};let Vr=e=>new Br(e);function Hr(e){if(typeof e!=`function`)return!1;Vr=e}var Ur=class e extends Z{#e=g(!1);#t;#n;#r;#i;constructor(e){let t=new AbortController;super(AbortSignal.any([t.signal,e.signal])),this.#i=e,this.#r=t;let n=Vr(e.current&&!e.bootLoading);if(this.#t=n,this.#n=n.container,this.signal.aborted){n.destroy?.();return}this.signal.addEventListener(`abort`,()=>{n.destroy?.()},{once:!0}),e.onToggle(t=>{n.toggle(t&&!e.bootLoading)},this.signal)}setError(t){this.destroyed||(this.#r.abort(),Nr(new e(this.#i),t))}get bootLoading(){return this.#i.bootLoading}get define(){return this.#i.define}get ident(){return this.#i.ident}get root(){return this.#i.root}get path(){return this.#i.path}get search(){return this.#i.search}get hash(){return this.#i.hash}get href(){return this.#i.href}get current(){return this.#i.current}get shown(){return this.#i.shown}get title(){return this.#i.title}set title(e){this.#i.title=e}get unsaved(){return this.#i.unsaved}set unsaved(e){this.#i.unsaved=e}get loading(){return this.#i.loading}set loading(e){this.#i.loading=e}get container(){return this.#n}get panel(){return this.#t.panel}set panel(e){this.#t.panel=!!e}get mode(){return this.#t.mode}set mode(e){[`scroll`,`flex`].includes(e)&&(this.#t.mode=e)}createHeader(e){return this.#t.createHeader(e)}createFooter(e){return this.#t.createFooter(e)}createSider(e,t){return this.#t.createSider(e,t)}createSection(e,t,n){return this.#t.createSection(e,t,n)}renderSides(e,t){for(let n of e){let{widget:e}=n;if(!e)continue;let r=new AbortController,i=this.#t.createSider(!1,r.signal);i&&z(e).then(e=>{if(typeof e!=`function`){r.abort();return}i.insert(),e(i,n,t)})}}toUrl(e,t){return this.#i.toUrl(e,t)}open(e,t,n){return this.#i.open(e,t,n)}setPath(e,t){return this.#i.setPath(e,t)}show(e){return this.#i.show(e)}get destroyDeferred(){return!this.destroyed&&this.#e.get()}destroy(e){return this.#i.destroy(e)}};const Q=new Map;async function Wr(e,t,n,r,i,a,o,s){let c=r,l=Q.get(c);if(l){l.update(i,a,o);return}let u={toggle(){},hide(){},update(e,t,n){i=e,a=t,o=n,Sr(u,!0)}};Q.set(c,u),Sr(u,!0);let d=await Hn(t).catch(()=>null);if(u!==Y.get()){Q.delete(c);return}if(!d){let r=new jr({root:`${n}${c}`,define:null,ident:t,pageId:c,path:i,search:a,hash:o,pageHandler:u,open:e,setRootPath:s});r.signal.addEventListener(`abort`,()=>{Q.delete(c)},{once:!0}),new Ur(r).setError(404);return}let f=d.ident,p=kr(f);if(c!==p){if(t=f,Q.get(c)!==u)return;if(Q.delete(c),Q.get(p)){s(`${p}/${i}${a}${o}`,!0);return}c=p,Q.set(c,u),s(`${p}/${i}${a}${o}`,!0)}let m=await d.widget();if(u!==Y.get()){Q.delete(c);return}let h=new jr({root:`${n}${c}`,define:d.page||null,ident:t,pageId:c,path:i,search:a,hash:o,pageHandler:u,open:e,setRootPath:s});h.signal.addEventListener(`abort`,()=>{Q.delete(c)},{once:!0});let g=new Ur(h);if(typeof m!=`function`){g.setError();return}try{await m(g)}catch(e){console.error(e),g.setError(e)}}function Gr(e,t){t?history.replaceState({},``,e):history.pushState({},``,e)}function Kr(e,t){Gr(R(N.pathname,e),t),qr()}function qr(){let e=N.pathname,{pathname:t,search:n,hash:r}=location,i=t.replace(/(^|[\\\/])[\\\/]*/,`/`);if(!i||i===`/`||i===e||i+`/`===e){e!==t&&history.replaceState({},``,`${e}${n}${r}`),yr(n,r);return}i=i.slice(i.startsWith(`${e}`)?e.length:1);let{path:a,redirect:o,page:s,pageRoot:c}=Or(i);(`${e}${i}`!==t||o)&&history.replaceState({},``,`${e}${c}${a}${n}${r}`),Wr(Jr,s,e,c,a,n,r,Kr)}function Jr(e,t){Xr(e,t)||(location.href=e)}const Yr=new Set;function Xr(e,t,n){let r=new URL(e,location.href);if(!n){for(let e of[...Yr])if(e(r)===!1)return!1}if(r.origin!==location.origin||!r.pathname.startsWith(N.pathname))return!1;let i=r.href;return i!==location.href&&Gr(i,t),qr(),!0}function Zr(e){if(!e.defaultPrevented)for(let t of e.composedPath()){if(!(t instanceof HTMLAnchorElement))continue;let n=t.href;if(n){if((t.target||`_self`)!==`_self`)return!1;Xr(n,!!t.getAttribute(`replace`))&&e.preventDefault();return}}}function Qr(){window.addEventListener(`click`,Zr),window.addEventListener(`popstate`,qr),qr()}function $r(){window.removeEventListener(`click`,Zr),window.removeEventListener(`popstate`,qr),tr()}const ei=it(e=>_(()=>{let t=[];for(let[n,r]of k.get(`enumerations`).get(e))for(let e of typeof r==`function`?r():[r])t.push({...e,plugin:n});return t}),e=>e);function ti(e){return ei(e).get()}function ni(e){return _(Array.isArray(e)?()=>e:()=>[])}const ri=it((e,t)=>{if(!t)return _(()=>[]);if(e===`model`){let e=on(t);return _(()=>e.getOptions())}if(e===`serverEnumeration`){let e=cn(t);return _(()=>e.get())}if(e===`webEnumeration`)return _(()=>ti(t));if(e===`enumeration`){let e=cn(t),n=_(()=>e.get()),r=_(()=>ti(t));return _(()=>[...n.get(),...r.get()])}return _(()=>[])},(e,t)=>t?[e,t].join(`
36
- `):``);function ii(e,{id:t,label:n,value:r,parent:i,children:a,sequence:o,disabled:s}={}){let c=t||`id`,l=r||`value`,u=n||`label`,d=c.includes(`{`)?c:`{${c}}`,f=l.includes(`{`)?l:`{${l}}`,p=u.includes(`{`)?u:`{${u}}`,m=s;if(i){let t=i.includes(`{`)?i:`{${i}}`;return _(()=>{let n=e.get().map(e=>{let n=typeof e==`object`&&e?O(d,e):e,r=typeof e==`object`&&e?O(f,e):e,i=String(typeof e==`object`&&e&&O(p,e)||r),a=!!(typeof e==`object`&&m&&e?.[m]);return{id:n,value:r,label:i,data:e,parentId:typeof e==`object`&&e?O(t,e):``,disabled:a,children:[]}}),r=new Set(n.map(e=>String(e.value))),i=Object.groupBy(n,e=>e.parentId??``),a=Object.keys(i).filter(e=>!r.has(e)),o=a.flatMap(e=>i[e]||[]);for(let e of a)delete i[e];let s=[...o];for(let e;e=s.shift();){let t=i[e.id];if(delete i[e.id],t?.length){e.children=t;for(let e of t)s.push(e)}}for(let e=Object.keys(i);e.length;e=Object.keys(i)){let t=e[0],n=i[t];if(delete i[t],n?.length){for(let e of n)o.push(e),s.push(e);for(let e;e=s.shift();){let t=i[e.id];if(delete i[e.id],t?.length){e.children=t;for(let e of t)s.push(e)}}}}return o})}let h=a;function g(e){return e.map(e=>{if(typeof e!=`object`||!e)return{id:e,value:e,label:String(e),data:e,children:[]};let t=O(d,e),n=O(f,e),r=String(O(p,e)||n),i=!!(m&&e[m]);if(!h)return{id:t,value:n,label:r,data:e,disabled:i,children:[]};let a=e[h];return{id:t,value:n,label:r,data:e,disabled:i,children:g(a)}})}return _(()=>g(e.get()))}function ai({operator:e,sign:t,value:n,values:r}){if(!e){for(let e of r)if(e==n)return!t;return!!t}return null}function oi(e,t,n,r){let i=[];for(let a of e){let e=oi(a.children,t,n,r),o=a.disabled||!(T(a.data,t,n,r)??!0);!e.length&&o||i.push({...a,children:e,disabled:o})}return i}function si({type:e,name:t,values:n,...r},i,a=ai){let o=ii(e?ri(e,t||``):ni(n),r);if(i===!1)return o;let s=r.filter;if(!s||typeof s!=`string`)return o;let c=me(s);if(!c||!c.where?.length&&!c.orWhere?.length)return o;let l=typeof i==`function`?_(()=>[ie(c.where,i),ie(c.orWhere,i)]):g([c.where,c.orWhere]);return _(()=>{let[e,t]=l.get();return oi(o.get(),a,e,t)})}function ci({type:e,name:t,values:n,configurator:r=`configurator`,parent:i,children:a,filter:o},s,c=ai){let l=e?ri(e,t||``):ni(n),u=i||!a?l:_(()=>{let e=a;function*t(n){if(Array.isArray(n))for(let r of n){if(typeof r!=`object`||!r){yield r;continue}e&&(yield*t(r[e])),yield r}}return[...t(l.get())]});if(!o||typeof o!=`string`)return _(()=>u.get()[0]?.[r]);let d=me(o);if(!d||!d.where?.length&&!d.orWhere?.length)return _(()=>u.get()[0]?.[r]);let f=typeof s==`function`?_(()=>[ie(d.where,s),ie(d.orWhere,s)]):g([d.where,d.orWhere]);return _(()=>{let[e,t]=f.get();for(let n of u.get())if(T(n,c,e,t)??!0)return n?.[r];return null})}function li(e){return Object.entries(e.fields).filter(e=>e[1].primary).sort(([,{primary:e}],[,{primary:t}])=>(e||0)-(t||0)).map(([e])=>e)}function ui(e,t){return li(e).map(e=>t[e]).join(`$`)}const di={exec(e,t,n){let{model:r}=e;if(!r)return;let i=n.indexOf(`:`);if(i<0)return;let a=n.slice(i+1);switch(e.type){case`documents`:{let t=(r.script?.listScripts||{})[a];return typeof t==`function`?t({model:r,get checkedDocuments(){return e.checkedDocuments},get documents(){return e.documents}}):void 0}case`document`:case`editDocument`:{let{store:t}=e;if(!t)return;let n=(r.script?.documentScripts||{})[a];return typeof n==`function`?n({model:r,get document(){return e.document},get store(){return t}}):void 0}}}},fi=_(()=>({script:di,...k.get(`commands`).named()}));function pi(e,t,n){let r=n.command;if(!r)return;let i=r.indexOf(`:`);if(i<0)return;let a=r.slice(0,i);if(!a)return;let o=fi.get(),s=Object.hasOwn(o,a)&&o[a];if(!s)return;let c=Object.hasOwn(s,e)&&s[e];if(typeof c==`function`)return c(t,n,r)}const mi={disabled(e,t){return pi(`disabled`,e,t)||!1},toHref(e,t){return pi(`toHref`,e,t)||``},exec(e,t){return pi(`exec`,e,t)}},hi={user:`
34
+ </style><div></div>`;const Tr=document.createElement(`div`);Tr.appendChild(Cr);var Er=Tr;function Dr(e){Tr.hidden=!e}K.appendChild(Er);let Or=Dr;const kr=g(void 0),Y=g(null);function Ar(e,t){if(Or===e)return;Or&&Or(!1);let n=kr.get();Or=e,kr.set(t),n?.hide(),e&&e(!0)}const X=document.createElement(`div`);X.hidden=!0;function jr(e){X.hidden=!e}K.appendChild(X);const Mr=g(`?`),Nr=g(`#`),Pr=new Map;Pr.set(`update`,new Set([()=>(X.innerHTML=``,Sr(X))]));function Fr(e){for(let t of[...Pr.get(e)||[]])t()}var Ir=class{get container(){return X}get current(){return Or===jr}get home(){return!0}get search(){return Mr.get()}get hash(){return Nr.get()}open(e,t){_i(e[0]===`/`?e:R(N.path,e),t)}listen(e,t){let n=t.bind(this),r=Pr.get(e);return r||(r=new Set,Pr.set(e,r)),r.add(n),()=>{r?.delete(n)}}};function Lr(e){return typeof e==`function`?(Fr(`destroy`),X.innerHTML=``,Pr.clear(),e(new Ir),!0):!1}function Rr(){let e=Y.get();e&&(Y.set(null),e.hide()),Ar(jr),_r(),Fr(`update`)}function zr(e,t){Mr.set(e||`?`),Nr.set(t||`#`),Rr()}let Br=null;function Vr(e){let t=Y.get();if(t){if(!e){Br!==null&&(clearTimeout(Br),Br=null),Ar(t.toggle,t);return}Br===null&&(Br=setTimeout(()=>{Br=null,Ar(Dr),_r()},300))}}function Hr(e,t){let n=Y.get();if(n===e){Vr(t),_r(n);return}let r=n;n||Fr(`update`);let i=e;Y.set(i),r?.hide(),Vr(t),_r(i)}var Ur=p({decode:()=>Wr,encode:()=>Gr,parse:()=>Kr,stringify:()=>qr});function Wr(e){return decodeURIComponent(e.replace(/\+/g,`%20`))}function Gr(e){return encodeURIComponent(typeof e==`string`?e:qr(e)).replace(/%20/g,`+`).replace(/%3A/g,`:`).replace(/%3D/g,`=`).replace(/%26/g,`&`).replace(/%24/g,`$`).replace(/%40/g,`@`)}function Kr(e){if(!e)return{type:`home`};switch(e){case`!`:case`!`:return{type:`todo`};case`-`:case`-`:return{type:`settings`};case`=`:case`=`:return{type:`search`};case`:`:case`:`:return{type:`status`};case`+`:case`+`:return{type:`devtools`};case`&`:case`@`:case`~`:case`_`:case`*`:}function t(t,n){let{index:r}=t.exec(e)||{index:-1};if(r<0)return;let i=e.substring(r+1)||n;return e=e.substring(0,r),i}let n=t(/[==]/);e=e.replaceAll(/[~~]+/g,`~`).replaceAll(/[!!]+/g,`!`).replaceAll(/[@@]+/g,`@`).replaceAll(/[&&]+/g,`&`).replaceAll(/[**]/g,`*`).replaceAll(/[::]+/g,`:`).replaceAll(/[((]+/g,`(`).replaceAll(/[))]+/g,`)`);let r=n?!!t(/(?<!\*)\*$/,`*`):void 0,i=r?void 0:t(/\*.*/,`*`)?.replace(/[~!@&()].*/,``),a=!!t(/!$/,i||n?void 0:`!`),o=/(?=[~!@&])/,s=new Map([[`&`,[]],[`@`,[]],[`~`,[]],[`!`,[]],[`*`,[]]]),c=[];for(let t of e.split(o))(s.get(t[0])||c).push(t);let l=s.get(`!`)?.join(``).slice(1)||``,u=s.get(`~`)?.join(``).slice(1)||``,d=s.get(`&`)?.join(``).slice(1)||``,f=s.get(`@`)?.join(``).slice(1)||``,p=c.join(``);return p?{type:`model`,model:p,workspace:u,continuation:l,setting:a,edit:r,input:i,id:n}:d?{type:`organization`,organization:d,workspace:u,continuation:l,setting:a,edit:r,input:i,id:n}:f?{type:`user`,user:f,workspace:u,continuation:l,setting:a,edit:r,input:i,id:n}:u?{type:`workspace`,workspace:u,continuation:l,setting:a,edit:r,input:i,id:n}:l?{type:`configuration`,continuation:l,setting:a,edit:r,input:i,id:n}:{type:`home`}}function qr(e){switch(e.type){case`home`:return`/`;case`settings`:return`-`;case`todo`:return`!`;case`search`:return`=`;case`status`:return`:`;case`devtools`:return`+`}let{model:t,user:n,organization:r,workspace:i,continuation:a,setting:o,input:s,edit:c,id:l}=e,u=``;return t?u=t:r?u+=`&${r}`:n&&(u+=`@${n}`),i&&(u+=`~${i}`),a&&(u+=`!${a}`),o?(u+=`!`,u):l?(s?u+=`*${s}`:c&&(u+=`*`),u+=`=${l}`,u):(s&&(s===`*`?u+=`*`:u+=`*${s}`),u)}let Jr=e=>{let t=e.indexOf(`/`),n=Wr(t<0?e:e.slice(0,t)),r=t<0?`/`:e.slice(t),i=Kr(n),a=Gr(qr(i));return{page:i,pageRoot:a,path:r,redirect:a!==n}},Yr=e=>Gr(qr(e));function Xr(e){Jr=e.parse,Yr=e.stringify}var Z=class{#e=g(!1);constructor(e){e instanceof AbortSignal?(this.#t=e,e.aborted?this.#e.set(!0):e.addEventListener(`abort`,()=>{this.#e.set(!0)},{once:!0})):this.#t=L}get destroyed(){return this.#e.get()}#t;get signal(){return this.#t}},Zr=class extends Z{#e=g(``);#t=g(!0);#n=g(!1);#r=g(!1);#i=g(!0);#a=()=>{};#o;#s;#c=g(``);#l=g(``);#u=g(``);#d=_(()=>R(this.#s,`${this.#c.get()}${this.#l.get()}${this.#u.get()}`));#f=_(()=>`${this.#o}/${this.#c.get()}${this.#l.get()}${this.#u.get()}`);#p;#m;#h;#g;#_;#v;constructor({pageId:e,define:t,ident:n,root:r,path:i,search:a,hash:o,pageHandler:s,open:c,setRootPath:l}){let u=new AbortController;super(u.signal),this.#v=u,this.#s=r,this.#c.set(i),this.#l.set(a),this.#u.set(o),this.#p=t,this.#m=n,this.#o=e,this.#h=s,this.#g=c,this.#_=l;let d=this.#y;s.toggle=e=>{for(let t of[...d])t(e)},s.hide=()=>{this.#a()},s.update=(e,t,n)=>{this.#c.set(e),this.#l.set(t),this.#u.set(n),Hr(s,this.#i.get())};let f=t?.title;f&&(this.title=f),yr(s,this)}#y=new Set;onToggle(e,t){if(t?.aborted)return;let n=this.#y;n.add(e),t.addEventListener(`abort`,()=>{n.delete(e)},{once:!0})}get bootLoading(){return this.#i.get()}get define(){return this.#p}get ident(){return this.#m}get root(){return this.#s}get path(){return this.#c.get()}get search(){return this.#l.get()}get hash(){return this.#u.get()}get href(){return this.#d.get()}get current(){return this.#h===Y.get()}get shown(){return this.#h===kr.get()}get title(){return this.#e.get()}set title(e){this.#e.set(e)}get unsaved(){return this.#n.get()}set unsaved(e){this.#n.set(e)}get loading(){return this.#t.get()}set loading(e){this.#t.set(e),e||this.#i.set(!1),this.#h===Y.get()&&(this.#i.get()||Vr(!1))}toUrl(e,t){if(t){if(typeof t==`string`)return R(N.path,t,e);if(typeof t==`object`)return R(N.path,Yr(t),e)}return e[0]===`/`?e:R(this.#s,e)}open(e,t,n){this.#g(this.toUrl(e,typeof t==`boolean`?``:t),typeof t==`boolean`?t:n)}setPath(e,t){let n=e.indexOf(`#`);if(this.#u.set(n>=0?e.slice(n):``),n>=0&&(e=e.slice(0,n)),e){let t=e.indexOf(`?`);this.#l.set(t>=0?e.slice(t):``),t>=0&&(e=e.slice(0,t))}e&&this.#c.set(e),this.#h===Y.get()&&this.#_(this.#f.get(),t)}show(e){this.#h!==Y.get()&&this.#_(this.#f.get(),e)}get destroyDeferred(){return!this.destroyed&&this.#r.get()}destroy(e){let t=()=>{this.#a=()=>{};let e=this.#v;return e.signal.aborted?!1:(e.abort(),br(this.#h),!0)};return e?this.#r.get()||this.destroyed?!1:(this.#r.set(!0),kr.get()===this.#h?(this.#a=t,!0):t()):t()}};const Qr={404:{title:`您所请求的页面无法找到`,description:`服务器无法正常提供信息。
35
+ 目标页面可能已经被更改、删除或移到其他位置,或您所输入页面地址错误。`}};let $r=function(e,t){let n=(typeof t==`number`||typeof t==`string`)&&Object.hasOwn(Qr,t)&&Qr[t]||Qr[404],r=n?.title||`Error`,i=n?.description,a=document.createElement(`div`),o=a.appendChild(document.createElement(`div`)),s=o.appendChild(document.createElement(`div`)),c=o.appendChild(document.createElement(`div`));if(a.style.marginBlock=`8%`,a.style.marginInline=`auto`,a.style.inlineSize=`600px`,a.style.maxInlineSize=`100%`,a.style.padding=`20px`,s.style.paddingBlock=`20px`,s.style.fontSize=`20px`,s.style.color=`#8e8e8e`,s.style.textAlign=`center`,c.style.fontSize=`13px`,c.style.lineHeight=`1.3em`,c.style.color=`#b5b5b5`,s.appendChild(document.createTextNode(r)),e.title=r||`Error`,i&&typeof i==`string`)for(let e of i.split(`
36
+ `))c.appendChild(document.createTextNode(e)),c.appendChild(document.createElement(`br`));e.container.appendChild(a),e.loading=!1};function ei(e){if(typeof e!=`function`)return!1;$r=e}var ti=class extends Z{#e=document.createElement(`div`);get container(){return this.#e}constructor(e,t){super(t);let n=e.appendChild(this.#e);e.className=`Page-footer`,n.className=`Page-footer-main`}},ni=class extends Z{#e=document.createElement(`div`);#t=document.createElement(`div`);get container(){return this.#e}#n=()=>{};setMenu(e,t=G.createItem){if(this.destroyed)return;this.#n();let n=this.#t,r=new AbortController,i=G.createButtons(e,t,AbortSignal.any([r.signal,this.signal]));i&&n.appendChild(i),this.#n=()=>{r.abort(),i?.remove(),this.#n=()=>{}}}constructor(e,t){super(t);let n=e.appendChild(this.#e),r=e.appendChild(this.#t);e.className=`Page-header`,n.className=`Page-header-main`,r.className=`Page-header-menu`}},ri=class extends Z{#e=document.createElement(`div`);#t=this.#e.appendChild(document.createElement(`div`));get container(){return this.#t}get panel(){return this.#e.classList.contains(`Page-panel`)}set panel(e){e?this.#e.classList.add(`Page-panel`):this.#e.classList.remove(`Page-panel`)}#n;#r;#i=g(!1);get inserted(){return this.#i.get()}insert(){this.destroyed||(this.#i.set(!0),this.#e.nextSibling!==this.#r&&this.#n.insertBefore(this.#e,this.#r))}remove(){this.#e.remove(),this.#i.set(!1)}constructor(e,t,n,r){super(r);let i=e.insertBefore(document.createComment(``),t);this.#n=e,this.#r=i;let a=this.#e,o=this.#t;a.className=`Page-section`,o.className=`Page-section-main`,n&&e.insertBefore(a,i),this.signal.addEventListener(`abort`,()=>{a.remove(),i.remove(),this.#i.set(!1)},{once:!0})}},ii=class extends Z{#e=document.createElement(`div`);#t=this.#e.appendChild(document.createElement(`div`));#n=this.#e.appendChild(document.createElement(`div`));#r=this.#t.appendChild(document.createElement(`div`));#i=this.#t.appendChild(document.createElement(`div`));#a=this.#n.appendChild(document.createElement(`div`));get container(){return this.#a}get panel(){return this.#n.classList.contains(`Page-panel`)}set panel(e){e?this.#n.classList.add(`Page-panel`):this.#n.classList.remove(`Page-panel`)}get title(){return this.#r.textContent||``}set title(e){this.#r.textContent=e}#o=null;#s;#c;setMenu(e,t,n=G.createItem){if(this.signal.aborted)return;this.#o?.abort();let r=new AbortController;this.#o=r;let i=AbortSignal.any([r.signal,this.signal]),a=G.createButton(e,t,n,i);a&&(this.#t.appendChild(a),i.addEventListener(`abort`,()=>{a.remove()},{once:!0}))}#l=g(!1);get inserted(){return this.#l.get()}insert(){this.destroyed||(this.#l.set(!0),this.#e.nextSibling!==this.#c&&this.#s.insertBefore(this.#e,this.#c))}remove(){this.#e.remove(),this.#l.set(!1)}constructor(e,t,n,r){super(r);let i=e.insertBefore(document.createComment(``),t);this.#s=e,this.#c=i;let a=this.#e,o=this.#t,s=this.#n,c=this.#r,l=this.#i,u=this.#a;a.className=`Page-sider`,o.className=`Page-sider-header`,s.className=`Page-sider-body`,u.className=`Page-sider-body-main`,c.className=`Page-sider-title`,l.className=`Page-sider-buttons`,n&&e.insertBefore(a,i),this.signal.addEventListener(`abort`,()=>{a.remove(),i.remove(),this.#l.set(!1)},{once:!0})}};function ai(e,t,n,r){return new ii(e,t,n,r)}var oi=class{#e=document.createElement(`div`);#t=this.#e.appendChild(document.createElement(`div`));#n=this.#e.appendChild(document.createElement(`div`));#r=this.#n.appendChild(document.createElement(`div`));#i=this.#r.appendChild(document.createElement(`div`));#a=!1;#o=null;#s=null;#c=`scroll`;get destroyed(){return this.#a}get container(){return this.#i}get mode(){return this.#c}set mode(e){let t=this.#e;t.classList.remove(`Page-mode-${this.#c}`),this.#c=e,t.classList.add(`Page-mode-${e}`)}get panel(){return this.#r.classList.contains(`Page-panel`)}set panel(e){e?this.#r.classList.add(`Page-panel`):this.#r.classList.remove(`Page-panel`)}get show(){return!this.#e.hidden}toggle(e){this.#e.hidden=!e}destroy(){return this.#a?!1:(this.#a=!0,this.#e.remove(),this.#p.abort(),!0)}#l=null;#u=null;createHeader(e){if(this.#a)throw Error(`页面组件已被销毁`);if(e?.aborted){let t=this.#u;t&&t.abort(e.reason),e.throwIfAborted()}if(this.#o)return this.#o;let t=document.createElement(`div`),n=new AbortController;this.#n.insertBefore(t,this.#n.firstChild),this.#l=t,this.#u=n;let r=new ni(t,AbortSignal.any([this.signal,n.signal,...e?[e]:[]]));return this.#o=r,r.signal.addEventListener(`abort`,()=>{this.#u=null,this.#o=null,this.#l=null,t.remove()},{once:!0}),this.#o}#d=null;#f=null;createFooter(e){if(this.#a)throw Error(`页面组件已被销毁`);if(e?.aborted){let t=this.#f;t&&t.abort(e.reason),e.throwIfAborted()}if(this.#s)return this.#s;let t=document.createElement(`div`),n=new AbortController;this.#n.appendChild(t),this.#d=t,this.#f=n;let r=new ti(t,AbortSignal.any([this.signal,n.signal,...e?[e]:[]]));return this.#s=r,r.signal.addEventListener(`abort`,()=>{this.#f=null,this.#s=null,this.#d=null,t.remove()},{once:!0}),this.#s}createSection(e,t,n){if(this.#a)throw Error(`页面组件已被销毁`);n?.throwIfAborted();let r=this.#n,i=null;switch(e){case`start`:i=this.#l||r.firstChild;break;case`before`:i=this.#i;break;default:case`after`:i=this.#i.nextSibling;break;case`end`:i=this.#d;break}return new ri(r,i,t!==!1,n instanceof AbortSignal?AbortSignal.any([n,this.#m]):this.#m)}#p=new AbortController;#m=this.#p.signal;get signal(){return this.#m}get siderOpen(){return!this.#t.hidden}set siderOpen(e){this.#t.hidden=!e}createSider(e,t){if(this.#a)throw Error(`页面组件已被销毁`);t?.throwIfAborted();let n=this.#t;return ai(n,null,e!==!1,t instanceof AbortSignal?AbortSignal.any([t,this.#m]):this.#m)}constructor(e){this.#n.className=`Page-main`,this.#r.className=`Page-body`,this.#i.className=`Page-body-main`,this.#t.className=`Page-sides`;let t=this.#e;t.className=`Page`,t.hidden=!e,K.appendChild(t)}};let si=e=>new oi(e);function ci(e){if(typeof e!=`function`)return!1;si=e}var li=class e extends Z{#e=g(!1);#t;#n;#r;#i;constructor(e){let t=new AbortController;super(AbortSignal.any([t.signal,e.signal])),this.#i=e,this.#r=t;let n=si(e.current&&!e.bootLoading);if(this.#t=n,this.#n=n.container,this.signal.aborted){n.destroy?.();return}this.signal.addEventListener(`abort`,()=>{n.destroy?.()},{once:!0}),e.onToggle(t=>{n.toggle(t&&!e.bootLoading)},this.signal)}setError(t){this.destroyed||(this.#r.abort(),$r(new e(this.#i),t))}get bootLoading(){return this.#i.bootLoading}get define(){return this.#i.define}get ident(){return this.#i.ident}get root(){return this.#i.root}get path(){return this.#i.path}get search(){return this.#i.search}get hash(){return this.#i.hash}get href(){return this.#i.href}get current(){return this.#i.current}get shown(){return this.#i.shown}get title(){return this.#i.title}set title(e){this.#i.title=e}get unsaved(){return this.#i.unsaved}set unsaved(e){this.#i.unsaved=e}get loading(){return this.#i.loading}set loading(e){this.#i.loading=e}get container(){return this.#n}get panel(){return this.#t.panel}set panel(e){this.#t.panel=!!e}get mode(){return this.#t.mode}set mode(e){[`scroll`,`flex`].includes(e)&&(this.#t.mode=e)}createHeader(e){return this.#t.createHeader(e)}createFooter(e){return this.#t.createFooter(e)}createSider(e,t){return this.#t.createSider(e,t)}createSection(e,t,n){return this.#t.createSection(e,t,n)}renderSides(e,t){for(let n of e){let{widget:e}=n;if(!e)continue;let r=new AbortController,i=this.#t.createSider(!1,r.signal);i&&z(e).then(e=>{if(typeof e!=`function`){r.abort();return}i.insert(),e(i,n,t)})}}toUrl(e,t){return this.#i.toUrl(e,t)}open(e,t,n){return this.#i.open(e,t,n)}setPath(e,t){return this.#i.setPath(e,t)}show(e){return this.#i.show(e)}get destroyDeferred(){return!this.destroyed&&this.#e.get()}destroy(e){return this.#i.destroy(e)}};const Q=new Map;async function ui(e,t,n,r,i,a,o,s){let c=r,l=Q.get(c);if(l){l.update(i,a,o);return}let u={toggle(){},hide(){},update(e,t,n){i=e,a=t,o=n,Hr(u,!0)}};Q.set(c,u),Hr(u,!0);let d=await cr(t).catch(()=>null);if(u!==Y.get()){Q.delete(c);return}if(!d){let r=new Zr({root:`${n}${c}`,define:null,ident:t,pageId:c,path:i,search:a,hash:o,pageHandler:u,open:e,setRootPath:s});r.signal.addEventListener(`abort`,()=>{Q.delete(c)},{once:!0}),new li(r).setError(404);return}let f=d.ident,p=Yr(f);if(c!==p){if(t=f,Q.get(c)!==u)return;if(Q.delete(c),Q.get(p)){s(`${p}/${i}${a}${o}`,!0);return}c=p,Q.set(c,u),s(`${p}/${i}${a}${o}`,!0)}let m=await d.widget();if(u!==Y.get()){Q.delete(c);return}let h=new Zr({root:`${n}${c}`,define:d.page||null,ident:t,pageId:c,path:i,search:a,hash:o,pageHandler:u,open:e,setRootPath:s});h.signal.addEventListener(`abort`,()=>{Q.delete(c)},{once:!0});let g=new li(h);if(typeof m!=`function`){g.setError();return}try{await m(g)}catch(e){console.error(e),g.setError(e)}}function di(e,t){t?history.replaceState({},``,e):history.pushState({},``,e)}const fi=new Map;function pi(e){let{pathname:t,search:n,hash:r}=new URL(location.href);e(t,n,r);let i=Symbol();return fi.set(i,e),()=>{fi.delete(i)}}function mi(){let{pathname:e,search:t,hash:n}=new URL(location.href);for(let r of[...fi.values()])r(e,t,n)}function hi(e,t){di(R(N.path,e),t),gi()}function gi(){let e=N.path,{pathname:t,search:n,hash:r}=location,i=t.replace(/(^|[\\\/])[\\\/]*/,`/`);if(!i||i===`/`||i===e||i+`/`===e){e!==t&&di(`${e}${n}${r}`,!0),mi(),zr(n,r);return}i=i.slice(i.startsWith(`${e}`)?e.length:1);let{path:a,redirect:o,page:s,pageRoot:c}=Jr(i);(`${e}${i}`!==t||o)&&di(`${e}${c}${a}${n}${r}`,!0),mi(),ui(_i,s,e,c,a,n,r,hi)}function _i(e,t){yi(e,t)||(location.href=e)}const vi=new Set;function yi(e,t,n){let r=new URL(e,location.href);if(!n){for(let e of[...vi])if(e(r)===!1)return!1}if(r.origin!==location.origin||!r.pathname.startsWith(N.path))return!1;let i=r.href;return i!==location.href&&di(i,t),gi(),!0}function bi(e){if(!e.defaultPrevented)for(let t of e.composedPath()){if(!(t instanceof HTMLAnchorElement))continue;let n=t.href;if(n){if((t.target||`_self`)!==`_self`)return;yi(n,!!t.getAttribute(`replace`))&&e.preventDefault();return}}}function xi(){window.addEventListener(`click`,bi),window.addEventListener(`popstate`,gi),gi()}function Si(){window.removeEventListener(`click`,bi),window.removeEventListener(`popstate`,gi),xr()}const Ci=bt(e=>_(()=>{let t=[];for(let[n,r]of k.get(`enumerations`).get(e))for(let e of typeof r==`function`?r():[r])t.push({...e,plugin:n});return t}),e=>e);function wi(e){return Ci(e).get()}function Ti(e){return _(Array.isArray(e)?()=>e:()=>[])}const Ei=bt((e,t)=>{if(!t)return _(()=>[]);if(e===`model`){let e=En(t);return _(()=>e.getOptions())}if(e===`serverEnumeration`){let e=On(t);return _(()=>e.get())}if(e===`webEnumeration`)return _(()=>wi(t));if(e===`enumeration`){let e=On(t),n=_(()=>e.get()),r=_(()=>wi(t));return _(()=>[...n.get(),...r.get()])}return _(()=>[])},(e,t)=>t?[e,t].join(`
37
+ `):``);function Di(e,{id:t,label:n,value:r,parent:i,children:a,sequence:o,disabled:s}={}){let c=t||`id`,l=r||`value`,u=n||`label`,d=c.includes(`{`)?c:`{${c}}`,f=l.includes(`{`)?l:`{${l}}`,p=u.includes(`{`)?u:`{${u}}`,m=s;if(i){let t=i.includes(`{`)?i:`{${i}}`;return _(()=>{let n=e.get().map(e=>{let n=typeof e==`object`&&e?O(d,e):e,r=typeof e==`object`&&e?O(f,e):e,i=String(typeof e==`object`&&e&&O(p,e)||r),a=!!(typeof e==`object`&&m&&e?.[m]);return{id:n,value:r,label:i,data:e,parentId:typeof e==`object`&&e?O(t,e):``,disabled:a,children:[]}}),r=new Set(n.map(e=>String(e.value))),i=Object.groupBy(n,e=>e.parentId??``),a=Object.keys(i).filter(e=>!r.has(e)),o=a.flatMap(e=>i[e]||[]);for(let e of a)delete i[e];let s=[...o];for(let e;e=s.shift();){let t=i[e.id];if(delete i[e.id],t?.length){e.children=t;for(let e of t)s.push(e)}}for(let e=Object.keys(i);e.length;e=Object.keys(i)){let t=e[0],n=i[t];if(delete i[t],n?.length){for(let e of n)o.push(e),s.push(e);for(let e;e=s.shift();){let t=i[e.id];if(delete i[e.id],t?.length){e.children=t;for(let e of t)s.push(e)}}}}return o})}let h=a;function g(e){return e.map(e=>{if(typeof e!=`object`||!e)return{id:e,value:e,label:String(e),data:e,children:[]};let t=O(d,e),n=O(f,e),r=String(O(p,e)||n),i=!!(m&&e[m]);if(!h)return{id:t,value:n,label:r,data:e,disabled:i,children:[]};let a=e[h];return{id:t,value:n,label:r,data:e,disabled:i,children:g(a)}})}return _(()=>g(e.get()))}function Oi({operator:e,sign:t,value:n,values:r}){let i=!!t;for(let t of $e(!r.find(e=>!Array.isArray(e)),e)){for(let e of i?t.notValue:t.value){let t=e(r,n);if(typeof t==`boolean`)return t}if(i)for(let e of t.value){let t=e(r,n);if(typeof t==`boolean`)return!t}}if(!e){for(let e of r)if(e==n)return!i;return i}return null}function ki(e,t){let n=e,r=t.fields.map(e=>Array.isArray(e)?e[0]:e);if(!r.length)return null;let i=r.pop()||``;for(let e of r){let t=Object.hasOwn(n,e)&&n[e]?.type;if(!t||typeof t!=`object`)return null;n=t}let a=Object.hasOwn(n,i)&&n[i];if(!a)return null;let o=t.field,s=o&&Object.hasOwn(n,o)&&n[o]||null,c=!!t.sign,{value:l,values:u}=t;for(let e of $e(a,t.operator))if(s){for(let t of c?e.notField:e.field){let e=t(u,l,a,s);if(typeof e==`boolean`)return e}if(c)for(let t of e.field){let e=t(u,l,a,s);if(typeof e==`boolean`)return!e}}else{for(let t of c?e.notValue:e.value){let e=t(u,l,a);if(typeof e==`boolean`)return e}if(c)for(let t of e.value){let e=t(u,l,a);if(typeof e==`boolean`)return!e}}return null}function Ai(e,t,n,r){let i=[];for(let a of e){let e=Ai(a.children,t,n,r),o=a.disabled||!(T(a.data,t,n,r)??!0);!e.length&&o||i.push({...a,children:e,disabled:o})}return i}function ji(e,t,n,r){if(typeof e==`function`)return e;if(t!==`model`)return Oi;let i=n||r;if(!i)return Oi;let a=En(i);return e=>{let t=a.getModel();return t?ki(t.fields,e):Oi(e)}}function Mi({type:e,name:t,model:n,values:r,...i},a,o){let s=Di(e?Ei(e,t||e===`model`&&n||``):Ti(r),i);if(a===!1)return s;let c=i.filter;if(!c||typeof c!=`string`)return s;let l=me(c);if(!l||!l.where?.length&&!l.orWhere?.length)return s;let u=typeof a==`function`?_(()=>[ie(l.where,a),ie(l.orWhere,a)]):g([l.where,l.orWhere]),d=_(()=>ji(o,e,t,n));return _(()=>{let[e,t]=u.get();return Ai(s.get(),d.get(),e,t)})}function Ni({type:e,name:t,model:n,values:r,configurator:i=`configurator`,parent:a,children:o,filter:s},c,l){let u=e?Ei(e,t||e===`model`&&n||``):Ti(r),d=a||!o?u:_(()=>{let e=o;function*t(n){if(Array.isArray(n))for(let r of n){if(typeof r!=`object`||!r){yield r;continue}e&&(yield*t(r[e])),yield r}}return[...t(u.get())]});if(!s||typeof s!=`string`)return _(()=>d.get()[0]?.[i]);let f=me(s);if(!f||!f.where?.length&&!f.orWhere?.length)return _(()=>d.get()[0]?.[i]);let p=typeof c==`function`?_(()=>[ie(f.where,c),ie(f.orWhere,c)]):g([f.where,f.orWhere]),m=_(()=>ji(l,e,t,n));return _(()=>{let[e,t]=p.get();for(let n of d.get())if(T(n,m.get(),e,t)??!0)return n?.[i];return null})}function Pi(e){return Object.entries(e.fields).filter(e=>e[1].primary).sort(([,{primary:e}],[,{primary:t}])=>(e||0)-(t||0)).map(([e])=>e)}function Fi(e,t){return(Array.isArray(t)?t:Pi(t)).map(t=>e[t]).join(`$`)}const Ii={exec(e,t,n){let{model:r}=e;if(!r)return;let i=n.indexOf(`:`);if(i<0)return;let a=n.slice(i+1);switch(e.type){case`documents`:{let t=(r.script?.listScripts||{})[a];return typeof t==`function`?t({model:r,get checkedDocuments(){return e.checkedDocuments},get documents(){return e.documents}}):void 0}case`document`:case`editDocument`:{let{store:t}=e;if(!t)return;let n=(r.script?.documentScripts||{})[a];return typeof n==`function`?n({model:r,get document(){return e.document},get store(){return t}}):void 0}}}},Li=_(()=>({script:Ii,...k.get(`commands`).named()}));function Ri(e,t,n){let r=n.command;if(!r)return;let i=r.indexOf(`:`);if(i<0)return;let a=r.slice(0,i);if(!a)return;let o=Li.get(),s=Object.hasOwn(o,a)&&o[a];if(!s)return;let c=Object.hasOwn(s,e)&&s[e];if(typeof c==`function`)return c(t,n,r)}const zi={disabled(e,t){return Ri(`disabled`,e,t)||!1},toHref(e,t){return Ri(`toHref`,e,t)||``},exec(e,t){return Ri(`exec`,e,t)}},Bi={user:`
37
38
  M 0.4 0.65
38
39
  A 0.3 0.3 0 1 1 0.6 0.65
39
40
  A 0.3 0.3 0 0 1 0.4 0.65
@@ -73,8 +74,7 @@ A 0.4 0.4 0 0 1 0.7951270912674742 0.23
73
74
  L 0.7673948391424188 0.23
74
75
  A 0.38 0.38 0 0 0 0.2326051608575812 0.23
75
76
  Z
76
- `},gi=_(()=>({...hi,...k.get(`icons`).named(),logo:`
77
+ `},Vi=_(()=>({...Bi,...k.get(`icons`).named(),logo:`
77
78
  M 0.29739625333333336 0.04334391666666666 M 0.06325983999999997 0.34186114333333334 H 0.08357982999999995 V 0.27435362333333335 L 0.1393469133333333 0.18517144333333335 H 0.1169949233333333 L 0.07500027666666663 0.25606563000000004 H 0.07364560999999996 L 0.03142518666666665 0.18517144333333332 H 0.007944309999999984 L 0.06325983999999997 0.2745794 Z M 0.29739625333333336 0.04334391666666666 M 0.21046684333333332 0.34411892 C 0.24659127 0.34411892 0.26668548233333333 0.32944337333333334 0.26668548233333333 0.28090117333333336 C 0.26668548233333333 0.2323589766666667 0.24659127 0.21768343000000004 0.21046684333333332 0.21768343000000004 C 0.17434241666666667 0.21768343000000004 0.15402242666666668 0.2323589766666667 0.15402242666666668 0.28090117333333336 C 0.15402242666666668 0.32944337333333334 0.17434241666666667 0.34411892 0.21046684333333332 0.34411892 Z M 0.21046684333333332 0.32763715000000004 C 0.18405085666666665 0.32763715000000004 0.17479397333333332 0.31657404666666666 0.17479397333333332 0.28090117333333336 C 0.17479397333333332 0.24545408000000002 0.18314774666666667 0.23393942 0.21046684333333332 0.23393942 C 0.23710860666666667 0.23393942 0.24613971333333332 0.24545408000000002 0.24613971333333332 0.28090117333333336 C 0.24613971333333332 0.3165740466666667 0.2382374966666667 0.32763715000000004 0.21046684333333332 0.32763715000000004 Z M 0.29739625333333336 0.04334391666666666 M 0.3592538966666667 0.21768342999999998 C 0.34435257 0.21768342999999998 0.3274192466666667 0.22152165 0.32019436133333334 0.23732608666666666 V 0.21994120666666667 H 0.30077748233333335 V 0.34186114333333334 H 0.3201943613333333 V 0.2594522966666667 C 0.32674191366666666 0.2380034166666667 0.3418690166666667 0.23506831000000003 0.35722189666666665 0.23506831000000003 C 0.37641300000000005 0.23506831000000003 0.3804769966666667 0.2459056366666667 0.3804769966666667 0.26464518333333337 V 0.34186114333333334 H 0.4001196533333333 V 0.2574202966666667 C 0.4001196533333333 0.2341651966666667 0.39108854666666665 0.21768343000000004 0.3592538966666667 0.21768343000000004 Z M 0.5233938433333333 0.21994120666666667 V 0.24274475 C 0.5186525133333334 0.22829498000000004 0.50849252 0.21768342999999998 0.48388275333333336 0.21768342999999998 C 0.4432427733333333 0.21768342999999998 0.43330855666666673 0.24613141333333333 0.43330855666666673 0.2797722866666667 C 0.43330855666666673 0.31679982333333334 0.4432427733333333 0.3418611433333334 0.48388275333333336 0.3418611433333334 C 0.5073636300000001 0.3418611433333334 0.5182009566666667 0.3335073700000001 0.5233938433333333 0.31905760000000005 V 0.3312495933333333 C 0.5233938433333333 0.35924602333333333 0.5105245166666667 0.37030913 0.4834311966666667 0.37030913 C 0.47281964666666665 0.37030913 0.46288543 0.36940602 0.4536285466666667 0.3675997966666667 V 0.38408158333333337 C 0.4615307633333333 0.3856620166666667 0.47259386999999997 0.38701668333333333 0.48320541999999994 0.38701668333333333 C 0.5245227333333333 0.38701668333333333 0.5428107233333334 0.36692246333333334 0.5428107233333334 0.33328159333333335 V 0.21994120666666667 Z M 0.48659208666666665 0.32560515333333334 C 0.45769254333333337 0.32560515333333334 0.45408010000000004 0.3050593833333333 0.45408010000000004 0.2797722866666667 C 0.45408010000000004 0.25606563 0.45701521 0.23393942 0.48659208666666665 0.23393942 C 0.51616896 0.23393942 0.5240711766666667 0.2517758566666667 0.5240711766666667 0.2797722866666667 C 0.5240711766666667 0.3088976033333333 0.51616896 0.32560515333333334 0.48659208666666665 0.32560515333333334 Z M 0.29739625333333336 0.04334391666666666 M 0.5841279533333333 0.18517144333333332 V 0.34186114333333334 H 0.6292834866666667 C 0.6742132533333334 0.34186114333333334 0.7049190200000001 0.32402471 0.7049190200000001 0.2635162933333333 C 0.7049190200000001 0.19826654999999999 0.6742132533333334 0.1851714433333333 0.6292834866666667 0.1851714433333333 Z M 0.6044479433333334 0.32402471000000005 V 0.20278210333333335 H 0.6288319333333333 C 0.6604408199999999 0.20278210333333335 0.6839216866666666 0.21361943000000003 0.6839216866666666 0.2635162933333334 C 0.6839216866666666 0.31070382666666674 0.6615696866666667 0.32402471000000005 0.6288319333333333 0.32402471000000005 Z M 0.7900370533333333 0.21768342999999998 C 0.78123172 0.21768342999999998 0.7712974866666666 0.21836076000000001 0.7622663866666667 0.21948964999999998 V 0.23664875333333335 C 0.77107172 0.23484252999999997 0.7810059533333333 0.23393942 0.7891339533333334 0.23393942 C 0.8137436866666667 0.23393942 0.8191623533333334 0.24409941666666665 0.8191623533333334 0.25877496333333333 V 0.26893495666666667 H 0.7819090533333334 C 0.75300952 0.26893495666666667 0.7335926199999999 0.27886917666666666 0.7335926199999999 0.30776871666666666 C 0.7335926199999999 0.33102381666666664 0.7464619533333333 0.34411892 0.7755872866666667 0.34411892 C 0.7941010533333333 0.34411892 0.8119374866666667 0.33644248000000004 0.8191623533333333 0.3233473766666667 L 0.8220974866666666 0.34186114333333334 H 0.8385792533333333 V 0.2553883 C 0.8385792533333333 0.23348786666666665 0.8286450200000001 0.21768342999999998 0.7900370533333333 0.21768342999999998 Z M 0.7773934866666666 0.32786293000000005 C 0.7602343866666667 0.32786293000000005 0.7536868533333334 0.32108960000000003 0.7536868533333334 0.30754294000000004 C 0.7536868533333334 0.2885776166666667 0.76316952 0.2845136166666667 0.7832637200000001 0.2845136166666667 H 0.8191623533333334 V 0.30460783 C 0.8128405866666667 0.31905760000000005 0.7979392533333334 0.32786293000000005 0.7773934866666666 0.32786293000000005 Z M 0.9069897533333334 0.34321581 C 0.9124084200000001 0.34321581 0.9162466533333335 0.3427642533333333 0.9198590866666666 0.34186114333333334 V 0.32583092999999996 C 0.9164724200000001 0.32673404 0.9133115200000002 0.3269598166666667 0.9106021866666667 0.3269598166666667 C 0.9026999866666667 0.3269598166666667 0.8993133200000001 0.32470203999999997 0.8993133200000001 0.31228427 V 0.17027012 H 0.8798964533333333 V 0.31725137999999997 C 0.8798964533333333 0.33553936999999995 0.8889275533333334 0.34321580999999995 0.9069897533333334 0.34321580999999995 Z M 0.9715620200000001 0.34321581 C 0.9769806533333334 0.34321581 0.9808188866666668 0.3427642533333333 0.98443132 0.34186114333333334 V 0.32583092999999996 C 0.9810446533333335 0.32673404 0.9778837866666668 0.3269598166666667 0.9751744533333333 0.3269598166666667 C 0.9672722200000001 0.3269598166666667 0.9638855533333334 0.32470203999999997 0.9638855533333334 0.31228427 V 0.17027012 H 0.9444686866666666 V 0.31725137999999997 C 0.9444686866666666 0.33553936999999995 0.9534997866666667 0.34321580999999995 0.9715620200000001 0.34321580999999995 Z M 0.29739625333333336 0.04334391666666666 M 0.20087005 0.5902171833333334 L 0.1977091533333333 0.5730580500000001 C 0.18867801999999997 0.57802515 0.17513132 0.5838954166666667 0.1575206133333333 0.5911203166666668 V 0.5143556833333334 H 0.20087004999999997 V 0.4827467166666667 H 0.1575206133333333 V 0.4005634166666667 L 0.1263632033333333 0.39920871666666674 V 0.4827467166666667 H 0.07940130999999999 V 0.5143556833333334 H 0.12636320333333334 V 0.6037638833333334 C 0.10514004 0.6118919166666668 0.08572310333333333 0.6186652499999999 0.06811239666666666 0.62408395 L 0.07578885666666665 0.6574991500000001 C 0.09249645333333331 0.6516288833333335 0.10965560666666664 0.6453071166666667 0.1263632033333333 0.6385337500000001 V 0.7432948833333335 C 0.1263632033333333 0.7581962833333334 0.12004140999999997 0.7636149500000001 0.10152758666666664 0.7654211833333334 L 0.08211064999999997 0.7676789500000002 L 0.09294800999999996 0.8001910500000001 L 0.11010716333333329 0.7979332500000001 C 0.1466832533333333 0.7934176833333335 0.15752061333333328 0.7875474500000001 0.15752061333333328 0.7541322500000002 V 0.6258901833333335 L 0.20357938999999997 0.6060216833333334 Z M 0.21757764666666665 0.60105455 C 0.21667453333333334 0.7058156833333333 0.21125585333333333 0.7306513166666667 0.17603443333333332 0.7929661166666667 L 0.20538561666666666 0.8069643833333334 C 0.21848075999999997 0.7848381166666667 0.22796344999999998 0.7631633833333334 0.2347368 0.7423917833333333 C 0.24151014999999998 0.7216201833333333 0.24557416 0.6976876833333334 0.24783194333333333 0.6705942833333334 H 0.3173716663333333 V 0.7934176833333334 H 0.3485290766666667 V 0.6705942833333335 H 0.4185203566666667 V 0.7383277833333335 C 0.4185203566666667 0.7590993833333335 0.4149079033333333 0.7604540500000001 0.39323318333333335 0.7631633833333334 L 0.37336469 0.7649696166666667 L 0.3846536066666667 0.7974816833333335 L 0.4036189866666667 0.7952239166666668 C 0.43929196333333337 0.7907083500000002 0.45058088 0.7830318833333334 0.45058088 0.7482620166666668 V 0.42404435000000007 H 0.21757764666666665 Z M 0.24963817 0.53241795 V 0.4565564166666667 H 0.3173716663333333 V 0.5324179500000001 Z M 0.34852907666666666 0.4565564166666667 H 0.4185203566666667 V 0.53241795 H 0.3485290766666667 Z M 0.24918661333333333 0.63853375 C 0.24963817 0.6331150833333334 0.24963817 0.6249870500000001 0.24963817 0.61369815 V 0.5640269166666667 H 0.3173716663333333 V 0.63853375 Z M 0.4185203566666667 0.5640269166666667 V 0.63853375 H 0.3485290766666667 V 0.5640269166666667 Z M 0.6610059533333333 0.5107432166666667 V 0.7184592833333333 H 0.8745922533333332 V 0.5107432166666667 H 0.7720888866666666 C 0.7761528866666666 0.49900274999999994 0.7797653533333333 0.4868107166666666 0.7829262533333332 0.4737155833333333 H 0.9116198866666666 V 0.4448159499999999 H 0.8262756866666666 C 0.8384677199999999 0.4299145833333333 0.8493050533333332 0.41501321666666663 0.8587877533333332 0.40011184999999994 L 0.8294365866666666 0.38430734999999994 C 0.8253725533333333 0.39198381666666665 0.81859922 0.4019180833333333 0.8100196533333334 0.41365854999999996 C 0.8014400533333333 0.4253990166666666 0.7937635866666666 0.4357848166666666 0.78608712 0.4448159499999999 H 0.7305456533333333 L 0.74047992 0.43804261666666666 C 0.7373190199999999 0.43126924999999994 0.7319003533333334 0.4222381166666666 0.7251269866666666 0.4114007499999999 C 0.7183536533333332 0.40011184999999994 0.7129349533333332 0.3919838166666666 0.7084193866666666 0.38611358333333323 L 0.6826806533333333 0.4014665166666666 C 0.6899055533333333 0.41049764999999994 0.7011944866666665 0.42901148333333333 0.7088709533333333 0.4448159499999999 H 0.6307516533333333 V 0.4737155833333333 H 0.7481563866666666 C 0.7440923533333332 0.4886169499999999 0.7404799199999998 0.5012605499999999 0.7368674533333333 0.5107432166666667 Z M 0.6199142900000001 0.48861695 C 0.6140440533333333 0.47732801666666663 0.6045613633333333 0.46242665 0.59146622 0.44436438333333333 C 0.5788226333333334 0.42585058333333337 0.5679852733333334 0.4118523166666667 0.5594056966666667 0.40236961666666665 L 0.5318607433333333 0.42178655 C 0.5413434300000001 0.43262391666666666 0.5517292333333335 0.44707375 0.5639212633333334 0.46558755 C 0.5761132933333333 0.48410138333333336 0.5851444266666667 0.4994543166666666 0.5910146633333333 0.51254945 Z M 0.6939695866666667 0.53648195 H 0.84162862 V 0.5712518166666667 H 0.6939695866666667 Z M 0.8027947200000001 0.7586478166666666 C 0.77073422 0.7586478166666666 0.7418345866666667 0.7581962833333333 0.7169989533333333 0.7568415833333333 C 0.6573934866666666 0.75322915 0.63617032 0.74781045 0.6045613633333333 0.7008485833333333 V 0.5473193166666667 H 0.5205718266666667 V 0.58118605 H 0.5729523966666666 V 0.7017516833333334 L 0.5169593733333333 0.7609056166666668 L 0.5354731966666667 0.7911599166666667 C 0.5571479133333334 0.7708398500000001 0.57521018 0.7518744833333335 0.5896599933333334 0.7347153166666668 C 0.6262360833333334 0.7803225500000001 0.6483623533333335 0.7857412166666669 0.7120318533333334 0.7884505500000001 C 0.7368674533333334 0.78980525 0.7657670866666667 0.7902567833333334 0.7978276200000001 0.7902567833333334 C 0.8253725533333334 0.7902567833333334 0.8651095533333334 0.7893536833333334 0.9170385533333335 0.78754745 L 0.9224572533333333 0.7559384833333334 C 0.87052822 0.7577447166666667 0.8307912533333335 0.7586478166666667 0.8027947200000001 0.7586478166666667 Z M 0.84162862 0.6317604166666667 H 0.6939695866666667 V 0.59699055 H 0.84162862 Z M 0.84162862 0.6570475833333334 V 0.69272055 H 0.6939695866666667 V 0.6570475833333334 Z
78
- `}));function _i(e,t){let n=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);n.setAttribute(`fill`,`currentColor`),n.classList.add(`icon`);let r=_(()=>{let t=gi.get();return Object.hasOwn(t,e)&&t[e]||null});if(t instanceof AbortSignal&&t.aborted)return n;let i=t instanceof AbortSignal?t:L;function a(e){if(Array.isArray(e)&&e.length<=2){let[t,r]=e;n.setAttribute(`viewBox`,r||`0 0 1 1`);let i=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);n.appendChild(i),i.setAttribute(`d`,t);return}if(n.setAttribute(`viewBox`,`0 0 1 1`),e){if(typeof e==`string`){let t=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);n.appendChild(t),t.setAttribute(`d`,e);return}typeof e==`function`&&e({root:n},i)}}return t?h(()=>r.get(),a,{signal:i,immediate:!0}):a(r.get()),n}async function vi({types:e,excludeAcceptAllOption:t}={}){if(`showOpenFilePicker`in window&&typeof showOpenFilePicker==`function`){let[n]=await showOpenFilePicker({types:e,excludeAcceptAllOption:!!(t&&Array.isArray(e)&&e.length)});return n?n.getFile():null}let n=document.createElement(`input`);n.type=`file`;let r=Array.isArray(e)&&e.map(e=>Object.entries(e.accept)).flat(3)||``;return r&&(n.accept=r.join(`,`)),new Promise((e,t)=>{n.addEventListener(`change`,()=>{e(n.files?.[0]||null)}),n.addEventListener(`error`,e=>{t(e.error)}),n.click()})}function yi(e,t){let n=e.path;n[0]===`/`&&(n=n.slice(1));let r=`+file://${e.domain}/${n}`;return t?`${r}#${t}`:r}function bi(e){if(!e||typeof e!=`string`)return null;let t=e.indexOf(`#`),n=decodeURIComponent((t>=0?e.slice(t+1):``)||e.replace(/[#?].*/,``).split(`/`).filter(Boolean).pop()||``);if(/^\+file:\/\//.test(e)){let{pathname:t,hostname:r}=new URL(e.slice(1)),i=t.split(`/`).filter(Boolean).join(`/`);return i?{name:n,href:`${Ke.file}/${r||`_`}/files/${i}`}:null}return{name:n,href:e}}function xi(e){if(!Ht(e))throw Error(`无效的 plugin: ${e}`);return{importStyle(t){return Jt(t,e,!0)},import(t){return z(t,e)},request:j.clone().prefix(`${qe.api}/plugins/${e}`),user:I.plugin(e)}}function Si(e){let t;return()=>t||=Promise.resolve().then(()=>e())}async function Ci(){let e=Object.entries(M).map(([e,{hooks:t}])=>typeof t==`string`?t?`/#?`.includes(t[0])?[e,z(`${e}${t}`)]:[e,z(`${e}/${t}`)]:[e,z(`${e}`)]:[``,``]),t=Object.entries(M).flatMap(([e,{styles:t}])=>[t].flat().map(t=>{if(!(!t||typeof t!=`string`))return Jt(t,e,!0)})),n=await Promise.all(e.filter(([e])=>e).map(e=>Promise.all(e))).then(e=>e.filter(([,e])=>e&&typeof e==`object`));await Promise.all(t),Fe(Object.fromEntries(n))}async function wi(e){let t=[];for(let[n,r]of e||[])t.push(Jt(n,r,!0));for(let[e,n]of k.get(`styles`))typeof n==`string`&&t.push(Jt(n,e,!0));await Promise.all(t)}let Ti=()=>({}),Ei=()=>({}),$=()=>{},Di=!1;async function Oi(){if(Di)return;Di=!0,$();let e=!1;$=()=>{e=!0,Di=!1};let{classNames:t,elements:n,rootClassName:r,setup:i,pageManager:a}=await Ei();if(e)return;let o=[];for(let e of[t,k.get(`className`).values()].flat())e&&typeof e==`string`&&document.body.classList.add(e);r&&typeof r==`string`&&K.classList.add(r);for(let e of[n,k.get(`elements`).values()].flat())e instanceof Element&&document.body.appendChild(e);a&&o.push(Yn(a));for(let e of k.get(`pageManager`).values())e&&o.push(Yn(e));Qr();let s=new AbortController;$=()=>{$=()=>{},s.abort(),Di=!1,$r();for(let e of o)e();for(let e of[n,k.get(`elements`).values()].flat())e instanceof Element&&e.remove();r&&typeof r==`string`&&K.classList.remove(r);for(let e of[t,k.get(`className`).values()].flat())e&&typeof e==`string`&&document.body.classList.remove(e)},i?.(s.signal)}async function ki(){$();let e=!1;$=()=>{e=!0};let t=await Ti();if(e)return;let{classNames:n,elements:r,rootClassName:i}=t;for(let e of[n].flat())e&&typeof e==`string`&&document.body.classList.add(e);i&&typeof i==`string`&&K.classList.add(i);for(let e of[r].flat())e instanceof Element&&document.body.appendChild(e);let a=new AbortController;$=()=>{$=()=>{},a.abort();for(let e of[r].flat())e instanceof Element&&e.remove();i&&typeof i==`string`&&K.classList.remove(i);for(let e of[n].flat())e&&typeof e==`string`&&document.body.classList.remove(e)},await t.login?.(a.signal),!a.signal.aborted&&await I.load()}let Ai=!1;async function ji(e,t,n){Ai||(Ai=!0,Ti=Si(async()=>{let t=await e(),{styleFiles:n}=t;return await wi(n),t}),Ei=Si(async()=>{let[e,r]=await Promise.all([t(),n()]);r&&Ar(r);let{home:i,components:a,styleFiles:o,createPage:s,renderError:c}=e;return await wi(o),_r(i),En(a),Hr(s),Pr(c),e}),await Ci(),await I.load(),h(()=>I.waitLogin,e=>{e?ki():Oi()},{immediate:!0}))}function Mi(e,t,n){if(!e)return!0;let r=typeof e==`string`?e.split(`
79
- `):e;if(!Array.isArray(r))return!0;let i=r.filter(e=>e&&typeof e==`string`);if(!i.length)return!0;for(let e of i)if(e[0]===`#`){if(n?.has(e.slice(1)))return!0}else if(t.has(e))return!0;return!1}function Ni(e,t){if(!e||!t||typeof t!=`object`)return!0;for(let[n,r]of Object.entries(e)){if(!r)continue;let{value:e,values:i,user:a}=r,o=t[n];if(e!==void 0){if(o!==e)return!1}else if(Array.isArray(i)&&i.length){if(!i.includes(o))return!1}else if(i instanceof Set&&i.size){if(!i.has(o))return!1}else if(a&&!I.single&&o!==I.current?.id)return!1}return!0}function Pi({permission:e,organizationField:t,constraints:n},r,i,a){if(!Ni(n,i))return!1;if(!e)return!0;if(!t)return!!r.has(e);if(t===`_`)return!!(a&&I.hasOrganizationPermission(e));if(a)return!0;let o=String(i?.[t]||``);return(!a||o)&&I.hasOrganizationPermission(e,o||``),!0}function Fi(e,t,n,r){let i=e.filter(({authorizations:e})=>{if(e instanceof Set||Array.isArray(e))return!0}).filter(e=>Pi(e,t,n,r)).flatMap(({authorizations:e})=>e?[...e]:[]);return new Set(i)}export{n as ArrayStore,mi as Command,u as DotRequest,Z as GeneralContext,De as Hook,Cr as Ident,xn as List,G as Menu,i as ObjectStore,Br as Page,Fr as PageFooter,Ir as PageHeader,Lr as PageSection,Rr as PageSider,Sn as Pagination,B as ResponseError,Se as Search,e as Signal,o as Store,I as User,Yn as addManager,k as allHooks,xi as buildPlugin,rt as configuration,_ as createComputed,Bt as createFilters,_i as createIcon,Lt as createQuickFilters,Pt as createShowField,g as createState,Nt as createStore,Ot as createStoreField,m as effect,cn as enumerationsService,Wt as execScript,Mi as filterPermission,ci as findConfigurator,Me as findPluginIdRegex,un as formLayoutsService,Fi as getAuthorizations,Ve as getField,A as getFieldFilter,We as getFieldFilterOperators,Qn as getPages,ke as getPatternFields,li as getPrimaryFields,He as hasField,Ge as hasFieldFilter,Jt as importStyle,z as importWidget,Ne as isFunction,Ht as isPluginId,bn as loadMenu,si as loadOptions,on as modelService,L as neverAbortedSignal,Ke as pathRoots,_n as permissionsService,je as pluginIdRegex,M as plugins,Mt as renderForm,c as renderStore,kt as renderStoreForm,j as request,K as root,O as runPattern,vi as selectFile,qn as setIcon,Vt as showFilterDialog,ji as start,Pi as testPermission,Ni as testPermissionConstraints,bi as toFileLink,yi as toFileURL,ui as toId,Et as toSchema,R as toUrl,Fe as updateHooks,nt as userMenus,Ut as waitAbortSignal,h as watch,N as webRoot,Ae as yieldPermissionConstraintFields};
79
+ `}));function Hi(e,t){let n=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);n.setAttribute(`fill`,`currentColor`),n.classList.add(`icon`);let r=_(()=>{let t=Vi.get();return Object.hasOwn(t,e)&&t[e]||null});if(t instanceof AbortSignal&&t.aborted)return n;let i=t instanceof AbortSignal?t:L;function a(e){if(Array.isArray(e)&&e.length<=2){let[t,r]=e;n.setAttribute(`viewBox`,r||`0 0 1 1`);let i=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);n.appendChild(i),i.setAttribute(`d`,t);return}if(n.setAttribute(`viewBox`,`0 0 1 1`),e){if(typeof e==`string`){let t=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);n.appendChild(t),t.setAttribute(`d`,e);return}typeof e==`function`&&e({root:n},i)}}return t?h(()=>r.get(),a,{signal:i,immediate:!0}):a(r.get()),n}async function Ui({types:e,excludeAcceptAllOption:t}={}){if(`showOpenFilePicker`in window&&typeof showOpenFilePicker==`function`){let[n]=await showOpenFilePicker({types:e,excludeAcceptAllOption:!!(t&&Array.isArray(e)&&e.length)});return n?n.getFile():null}let n=document.createElement(`input`);n.type=`file`;let r=Array.isArray(e)&&e.map(e=>Object.entries(e.accept)).flat(3)||``;return r&&(n.accept=r.join(`,`)),new Promise((e,t)=>{n.addEventListener(`change`,()=>{e(n.files?.[0]||null)}),n.addEventListener(`error`,e=>{t(e.error)}),n.click()})}function Wi(e,t){let n=e.path;n[0]===`/`&&(n=n.slice(1));let r=`+file://${e.domain}/${n}`;return t?`${r}#${t}`:r}function Gi(e){if(!e||typeof e!=`string`)return null;let t=e.indexOf(`#`),n=decodeURIComponent((t>=0?e.slice(t+1):``)||e.replace(/[#?].*/,``).split(`/`).filter(Boolean).pop()||``);if(/^\+file:\/\//.test(e)){let{pathname:t,hostname:r}=new URL(e.slice(1)),i=t.split(`/`).filter(Boolean).join(`/`);return i?{name:n,href:`${et.file}/${r||`_`}/files/${i}`}:null}return{name:n,href:e}}function Ki(e){if(!ln(e))throw Error(`无效的 plugin: ${e}`);return{importStyle(t){return hn(t,e,!0)},import(t){return z(t,e)},request:A.clone().prefix(`${tt.api}/plugins/${e}`),user:I.plugin(e)}}function qi(e){let t;return()=>t||=Promise.resolve().then(()=>e())}async function Ji(){let e=Object.entries(M).map(([e,{hooks:t}])=>typeof t==`string`?t?`/#?`.includes(t[0])?[e,z(`${e}${t}`)]:[e,z(`${e}/${t}`)]:[e,z(`${e}`)]:[``,``]),t=Object.entries(M).flatMap(([e,{styles:t}])=>[t].flat().map(t=>{if(!(!t||typeof t!=`string`))return hn(t,e,!0)})),n=await Promise.all(e.filter(([e])=>e).map(e=>Promise.all(e))).then(e=>e.filter(([,e])=>e&&typeof e==`object`));await Promise.all(t),Re(Object.fromEntries(n))}async function Yi(e){let t=[];for(let[n,r]of e||[])t.push(hn(n,r,!0));for(let[e,n]of k.get(`styles`))typeof n==`string`&&t.push(hn(n,e,!0));await Promise.all(t)}let Xi=()=>({}),Zi=()=>({}),$=()=>{},Qi=!1;async function $i(){if(Qi)return;Qi=!0,$();let e=!1;$=()=>{e=!0,Qi=!1};let{classNames:t,elements:n,rootClassName:r,setup:i,pageManager:a,updatePath:o}=await Zi();if(e)return;let s=[];for(let e of[t,k.get(`className`).values()].flat())e&&typeof e==`string`&&document.body.classList.add(e);r&&typeof r==`string`&&K.classList.add(r);for(let e of[n,k.get(`elements`).values()].flat())e instanceof Element&&document.body.appendChild(e);typeof a==`function`&&s.push(hr(a)),typeof o==`function`&&s.push(pi(o));for(let e of k.get(`pageManager`).values())e&&s.push(hr(e));xi();let c=new AbortController;$=()=>{$=()=>{},c.abort(),Qi=!1,Si();for(let e of s)e();for(let e of[n,k.get(`elements`).values()].flat())e instanceof Element&&e.remove();r&&typeof r==`string`&&K.classList.remove(r);for(let e of[t,k.get(`className`).values()].flat())e&&typeof e==`string`&&document.body.classList.remove(e)},i?.(c.signal)}async function ea(){$();let e=!1;$=()=>{e=!0};let t=await Xi();if(e)return;let{classNames:n,elements:r,rootClassName:i}=t;for(let e of[n].flat())e&&typeof e==`string`&&document.body.classList.add(e);i&&typeof i==`string`&&K.classList.add(i);for(let e of[r].flat())e instanceof Element&&document.body.appendChild(e);let a=new AbortController;$=()=>{$=()=>{},a.abort();for(let e of[r].flat())e instanceof Element&&e.remove();i&&typeof i==`string`&&K.classList.remove(i);for(let e of[n].flat())e&&typeof e==`string`&&document.body.classList.remove(e)},await t.login?.(a.signal),!a.signal.aborted&&await I.load()}let ta=!1;async function na(e,t,n){ta||(ta=!0,Xi=qi(async()=>{let t=await e(),{styleFiles:n}=t;return await Yi(n),t}),Zi=qi(async()=>{let[e,r]=await Promise.all([t(),n()]);r&&Xr(r);let{home:i,components:a,styleFiles:o,createPage:s,renderError:c}=e;return await Yi(o),Lr(i),Kn(a),ci(s),ei(c),e}),await Ji(),await I.load(),h(()=>I.waitLogin,e=>{e?ea():$i()},{immediate:!0}))}export{n as ArrayStore,zi as Command,u as DotRequest,Z as GeneralContext,Ae as Hook,Ur as Ident,Vn as List,G as Menu,i as ObjectStore,oi as Page,ti as PageFooter,ni as PageHeader,ri as PageSection,ii as PageSider,Hn as Pagination,B as ResponseError,Ce as Search,e as Signal,o as Store,I as User,hr as addManager,k as allHooks,N as application,Ki as buildPlugin,_ as createComputed,sn as createFilters,Hi as createIcon,rn as createQuickFilters,en as createShowField,g as createState,$t as createStore,Jt as createStoreField,m as effect,On as enumerationsService,dn as execScript,Ft as filterPermission,Ni as findConfigurator,Fe as findPluginIdRegex,An as formLayoutsService,We as getAllFilterFns,Rt as getAuthorizations,qe as getField,Xe as getFieldFilter,Ze as getFieldFilterOperators,$e as getFilterFns,vr as getPages,Me as getPatternFields,Bt as getPermissionFields,Pi as getPrimaryFields,Je as hasField,Qe as hasFieldFilter,hn as importStyle,z as importWidget,Ie as isFunction,ln as isPluginId,Bn as loadMenu,Mi as loadOptions,ki as modelFilter,En as modelService,L as neverAbortedSignal,et as pathRoots,Ln as permissionsService,Pe as pluginIdRegex,M as plugins,Qt as renderForm,c as renderStore,Yt as renderStoreForm,A as request,K as root,O as runPattern,Ui as selectFile,pr as setIcon,cn as showFilterDialog,na as start,Lt as testPermission,It as testPermissionConstraints,zt as testPermissions,Gi as toFileLink,Wi as toFileURL,Fi as toId,Kt as toSchema,R as toUrl,Te as transformError,Re as updateHooks,un as waitAbortSignal,h as watch,Ne as yieldPermissionConstraintFields};
80
80
  //# sourceMappingURL=index.mjs.map