@zeyos/zx 2.3.0 → 4.0.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/CHANGELOG.md +138 -0
- package/DESIGN-SYSTEM.md +96 -0
- package/README.md +29 -39
- package/dist/types/components/account-menu/account-menu.d.ts +144 -0
- package/dist/types/components/app-sidebar/app-sidebar.d.ts +243 -0
- package/dist/types/components/avatar/avatar.d.ts +100 -0
- package/dist/types/components/card/card.d.ts +128 -0
- package/dist/types/components/chart/chart.d.ts +322 -0
- package/dist/types/components/date-picker/month-picker.d.ts +6 -0
- package/dist/types/components/dialog/dialog.d.ts +9 -0
- package/dist/types/components/dock/dock.d.ts +495 -0
- package/dist/types/components/dropdown/dropdown.d.ts +2 -2
- package/dist/types/components/field/field.d.ts +14 -0
- package/dist/types/components/field-upload/field-upload.d.ts +37 -4
- package/dist/types/components/form/form.d.ts +25 -3
- package/dist/types/components/grid/grid.d.ts +172 -0
- package/dist/types/components/launcher/launcher.d.ts +359 -0
- package/dist/types/components/layout/layout.d.ts +4 -4
- package/dist/types/components/menu-button/menu-button.d.ts +10 -2
- package/dist/types/components/modal/modal.d.ts +25 -0
- package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +7 -1
- package/dist/types/components/questionnaire/items.d.ts +327 -0
- package/dist/types/components/questionnaire/questionnaire.d.ts +449 -0
- package/dist/types/components/select/select.d.ts +51 -0
- package/dist/types/components/sheet/sheet-stack.d.ts +167 -0
- package/dist/types/components/sheet/sheet.d.ts +294 -0
- package/dist/types/components/split-view/split-view.d.ts +2 -21
- package/dist/types/components/table/table.d.ts +223 -15
- package/dist/types/components/tooltip/tooltip.d.ts +2 -2
- package/dist/types/components/value-list/value-list.d.ts +24 -3
- package/dist/types/core/dom.d.ts +122 -0
- package/dist/types/core/drag-axis.d.ts +111 -0
- package/dist/types/core/position.d.ts +4 -2
- package/dist/types/index.d.ts +13 -2
- package/dist/types/internal/app-rail.d.ts +265 -0
- package/dist/types/zeyos/icons.d.ts +5 -0
- package/dist/types/zeyos/index.d.ts +2 -1
- package/dist/types/zeyos/launcher.d.ts +147 -0
- package/dist/types/zeyos/select.d.ts +39 -0
- package/dist/zx-zeyos.esm.js +1870 -133
- package/dist/zx-zeyos.esm.min.js +1 -1
- package/dist/zx.css +2006 -267
- package/dist/zx.esm.js +8987 -2757
- package/dist/zx.esm.min.js +3 -3
- package/dist/zx.global.js +8987 -2757
- package/dist/zx.global.min.js +3 -3
- package/dist/zx.min.css +1 -1
- package/docs/api.json +4396 -2344
- package/docs/llms.md +463 -86
- package/docs/llms.txt +32 -19
- package/package.json +10 -17
- package/src/components/account-menu/account-menu.css +70 -0
- package/src/components/account-menu/account-menu.js +208 -0
- package/src/components/app-rail/app-rail.css +107 -0
- package/src/components/app-sidebar/app-sidebar.css +80 -0
- package/src/components/app-sidebar/app-sidebar.js +588 -0
- package/src/components/avatar/avatar.css +61 -0
- package/src/components/avatar/avatar.js +222 -0
- package/src/components/button/button.css +0 -1
- package/src/components/card/card.css +149 -0
- package/src/components/card/card.js +285 -0
- package/src/components/chart/chart.css +61 -0
- package/src/components/chart/chart.js +523 -0
- package/src/components/date-picker/month-picker.js +9 -0
- package/src/components/dialog/dialog.js +11 -4
- package/src/components/dock/dock.css +228 -0
- package/src/components/dock/dock.js +977 -0
- package/src/components/dropdown/dropdown.js +1 -1
- package/src/components/field/field.js +2 -0
- package/src/components/field-upload/field-upload.js +9 -4
- package/src/components/form/form.js +6 -3
- package/src/components/grid/grid.css +6 -0
- package/src/components/grid/grid.js +220 -0
- package/src/components/launcher/launcher.css +210 -0
- package/src/components/launcher/launcher.js +765 -0
- package/src/components/layout/layout.js +2 -2
- package/src/components/menu-button/menu-button.js +27 -2
- package/src/components/modal/modal.css +5 -1
- package/src/components/modal/modal.js +37 -2
- package/src/components/multi-value-editor/multi-value-editor.js +2 -1
- package/src/components/questionnaire/items.js +370 -0
- package/src/components/questionnaire/questionnaire.css +387 -0
- package/src/components/questionnaire/questionnaire.js +1033 -0
- package/src/components/select/field-adapter.js +9 -4
- package/src/components/select/select.css +144 -11
- package/src/components/select/select.js +259 -27
- package/src/components/sheet/sheet-stack.js +304 -0
- package/src/components/sheet/sheet.css +351 -0
- package/src/components/sheet/sheet.js +551 -0
- package/src/components/split-view/split-view.js +76 -161
- package/src/components/table/table.css +43 -0
- package/src/components/table/table.js +531 -52
- package/src/components/tooltip/tooltip.js +5 -2
- package/src/components/value-list/value-list.js +6 -3
- package/src/core/dom.js +322 -0
- package/src/core/drag-axis.js +203 -0
- package/src/core/position.js +68 -22
- package/src/index.js +20 -2
- package/src/internal/app-rail.js +718 -0
- package/src/zeyos/icons.js +8 -3
- package/src/zeyos/index.js +7 -1
- package/src/zeyos/launcher.js +338 -0
- package/src/zeyos/modules.js +1 -0
- package/src/zeyos/select.js +115 -1
- package/styles/tokens/dark.css +2 -3
- package/styles/tokens/global.css +6 -6
- package/styles/tokens/modules.css +1 -0
- package/styles/tokens/semantic.css +5 -3
- package/styles/tokens/themes.css +1 -1
- package/styles/zx.css +11 -1
- package/MIGRATION.md +0 -598
- package/dist/types/compat/base.d.ts +0 -156
- package/dist/types/compat/globals.d.ts +0 -20
- package/dist/types/compat/index.d.ts +0 -128
- package/dist/types/compat/map/basic.d.ts +0 -175
- package/dist/types/compat/map/data.d.ts +0 -102
- package/dist/types/compat/map/date-time.d.ts +0 -80
- package/dist/types/compat/map/factory.d.ts +0 -9
- package/dist/types/compat/map/form.d.ts +0 -98
- package/dist/types/compat/map/helpers.d.ts +0 -12
- package/dist/types/compat/map/http.d.ts +0 -36
- package/dist/types/compat/map/layout.d.ts +0 -106
- package/dist/types/compat/map/options.d.ts +0 -80
- package/dist/types/compat/map/select.d.ts +0 -95
- package/dist/types/compat/map/stubs.d.ts +0 -32
- package/dist/types/compat/map/utilities.d.ts +0 -37
- package/dist/types/compat-entry.d.ts +0 -5
- package/dist/types/components/permission/permission.d.ts +0 -96
- package/dist/zx-compat.esm.js +0 -17484
- package/dist/zx-compat.esm.min.js +0 -1
- package/dist/zx-compat.global.js +0 -23635
- package/dist/zx-compat.global.min.js +0 -3
- package/src/compat/base.js +0 -291
- package/src/compat/globals.js +0 -165
- package/src/compat/index.js +0 -84
- package/src/compat/map/basic.js +0 -464
- package/src/compat/map/data.js +0 -232
- package/src/compat/map/date-time.js +0 -177
- package/src/compat/map/factory.js +0 -45
- package/src/compat/map/form.js +0 -330
- package/src/compat/map/helpers.js +0 -46
- package/src/compat/map/http.js +0 -117
- package/src/compat/map/layout.js +0 -256
- package/src/compat/map/options.js +0 -267
- package/src/compat/map/select.js +0 -198
- package/src/compat/map/stubs.js +0 -26
- package/src/compat/map/utilities.js +0 -113
- package/src/compat-entry.js +0 -11
- package/src/components/permission/permission.css +0 -47
- package/src/components/permission/permission.js +0 -201
package/dist/zx-zeyos.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function $(s){if(s==null)return null;if(!(s instanceof Date))throw new TypeError("Expected a Date");let t=s.getTime();if(!Number.isFinite(t))throw new RangeError("Invalid Date");return Math.floor(t/1e3)}function lt(s){if(s==null)return null;let t=Number(s);if(!Number.isFinite(t))throw new TypeError("Expected finite Unix seconds");return new Date(t*1e3)}function je(s){return(Array.isArray(s)?s:s?[s]:[]).flatMap(e=>{if(!e||typeof e!="object")return[];let i=e.rawField??e.field??e.id;if(i==null||String(i).trim()==="")return[];let r=String(i).trim().replace(/^[+-]/,"");return[`${e.dir==="desc"?"-":"+"}${r}`]})}function As(s,t=[]){if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("DataFilter state must be an object");let e=Ss(s,t),i={},r=0;for(let n of e){if(!n.id||!Object.prototype.hasOwnProperty.call(s,n.id))continue;let o=s[n.id];if(o===void 0||o===null&&n.includeNull!==!0||typeof o=="string"&&o.trim()===""&&n.includeEmpty!==!0)continue;if(typeof n.toFilter=="function"){let h=n.toFilter(o,s);h&&typeof h=="object"&&!Array.isArray(h)&&Object.assign(i,h);continue}let l=typeof n.transform=="function"?n.transform(o,s):zs(o,n);if(l===void 0)continue;n.operator&&(l={[n.operator]:l});let c=Array.isArray(n.fields)?n.fields.filter(h=>typeof h=="string"&&h):[];if(c.length>1){for(;Object.prototype.hasOwnProperty.call(i,String(r));)r+=1;i[String(r)]=["OR",...c.map(h=>({[h]:l}))],r+=1;continue}let u=c[0]??n.rawField??n.field??n.id;typeof u=="string"&&u&&(i[u]=l)}return i}function tt(s={}){let{fields:t,sort:e,filters:i={},search:r,limit:n,offset:o,visibility:l=0,count:c=!1}=s;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("ZeyOS filters must be an object");let u={};Array.isArray(t)?u.fields=[...t]:t&&typeof t=="object"&&(u.fields={...t});let h={...i},p=Object.prototype.hasOwnProperty.call(s,"visibility");l!==void 0&&(p||!Object.prototype.hasOwnProperty.call(h,"visibility"))&&(h.visibility=l),Object.keys(h).length&&(u.filters=h);let f=Ds(e,t),d=je(f);return d.length&&(u.sort=d),r!=null&&String(r).trim()&&(u.query=String(r).trim()),n!=null&&(u.limit=n),o!=null&&(u.offset=o),c&&(u.count=!0),u}function Ss(s,t){return Array.isArray(t)&&t.length?t.map(e=>({...e})):t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length?Object.entries(t).map(([e,i])=>typeof i=="string"?{id:e,field:i}:{...i,id:e}):Object.keys(s).map(e=>({id:e,field:e}))}function zs(s,t){let e=String(t.format??t.type??"").toLowerCase();return s instanceof Date&&["date","datetime","date-time"].includes(e)?$(s):Array.isArray(s)&&["date","datetime","date-time"].includes(e)?s.map(i=>i instanceof Date?$(i):i):s}function Ds(s,t){if(!s||!t||Array.isArray(t)||typeof t!="object")return s;let e=i=>{if(!i||typeof i!="object")return i;let r=i.id;return!r||!Object.prototype.hasOwnProperty.call(t,r)?i:{...i,rawField:t[r]}};return Array.isArray(s)?s.map(e):e(s)}var zt=Object.create(null),Ve=new Set;function z(s,t){let e=St(s);if(!e)throw new TypeError("ZeyOS field type must not be empty");if(!t||typeof t!="object")throw new TypeError("Field type strategy must be an object");for(let i of["field","column"]){let r=t[i];if(typeof r!="function"&&(!r||typeof r!="object"||Array.isArray(r)))throw new TypeError(`Field type strategy requires a ${i} builder or descriptor`)}return zt[e]=t,t}function Dt(s){let t=Be(s),e=qe(t),i=$e(e.field,t),r={id:t.id,type:"text",label:Ye(t),...i};return t.description!=null&&(r.description=String(t.description)),(t.required===!0||t.nullable===!1)&&(r.required=!0),Rs(t)&&(r.readonly=!0,r.disabled=!0,r.props={...r.props??{},readOnly:!0}),r}function ie(s){let t=Be(s),e=qe(t);return{id:t.id,label:Ye(t),sortable:t.sortable!==!1,...$e(e.column,t)}}function ct(s,t,e={}){let i=s?.schema;if(!i||typeof i.fields!="function"||typeof i.describe!="function")throw new TypeError("ZeyOS client must expose schema.fields() and schema.describe()");let r=i.describe(t),n=Pe(r?.fields),o=Pe(i.fields(t)),l=new Map;for(let[f,d]of o)l.set(f,{...d,...n.get(f)??{}});for(let[f,d]of n)l.has(f)||l.set(f,{...d});let c=Array.isArray(e.fields)?e.fields.map(String):[...l.keys()],u=new Set(Array.isArray(e.exclude)?e.exclude.map(String):[]),h=e.labels&&typeof e.labels=="object"?e.labels:{},p=[];for(let f of c){if(u.has(f)||!l.has(f))continue;let d=l.get(f)??{},_={...d,id:f,name:f,resource:String(t)},y=d.enums??d.enum??qs(i,t,f);y!=null&&(_.enums=y,_.enum==null&&(_.enum=y)),Object.prototype.hasOwnProperty.call(h,f)&&(_.label=String(h[f])),p.push(_)}return p}var Re={field:{type:"text"},column:{}},Cs={field:{type:"int"},column:{align:"right"}},Ms={field:{type:"float"},column:s=>({align:"right",render:Qe(s)})},Is={field:{type:"float"},column:s=>({align:"right",render:Qe(s,!0)})},Ts={field:s=>({type:"zxselect",props:{entity:Ke(s)}}),column:s=>({render:t=>Ws(O(t,s),t,s)})},Es={field:{type:"toggle"},column:s=>({align:"center",render:t=>O(t,s)?"\u2713":"",sortValue:t=>+!!O(t,s)})},Ns={field:s=>({type:Bs(s),options:se(s)}),column:s=>({render:We(s)})},Fs={field:{type:"zxselect",props:{preset:"priority"}},column:s=>({render:We(s,$s())})},Os={field:{type:"float",props:{min:0,max:100}},column:s=>({align:"right",render:t=>Ys(O(t,s)),sortValue:t=>Ct(O(t,s))})},Ls=He("date"),js=He("datetime");for(let s of["string","text","character","character varying","varchar","email","tel","url","uri"])z(s,Re);for(let s of["integer","smallint","bigint","int","int2","int4","int8","int32","int64"])z(s,Cs);for(let s of["number","numeric","decimal","real","double","double precision","float"])z(s,Ms);for(let s of["money","currency","price","pricebilling","priceprocurement","priceproduction"])z(s,Is);for(let s of["entity","t_entity"])z(s,Ts);for(let s of["boolean","checked"])z(s,Es);for(let s of["list","enum"])z(s,Ns);for(let s of["progress","percent"])z(s,Os);for(let s of["date"])z(s,Ls);for(let s of["datetime","date-time"])z(s,js);z("priority",Fs);z("text[]",{field:{type:"valuelist"},column:{}});z("json",{field:{type:"textarea"},column:{}});z("longtext",{field:{type:"textarea"},column:{}});for(let s of["email","tel","url","uri"])z(s,{field:{type:"text",props:{type:s==="uri"?"url":s}},column:{}});function He(s){return{field:{type:s},column:t=>({render:e=>Ks(O(e,t),s==="datetime"),sortValue:e=>Us(O(e,t))})}}function qe(s){let t=Vs(s),e=zt[t];return e||(Ve.has(t)||(Ve.add(t),console.warn(`[zx.zeyos] Unknown field type or format "${t||"unknown"}" for "${s.id}"; using text.`)),Re)}function Vs(s){let t=St(s.format??s.semanticFormat??s.semanticType??s.widget);if(t&&zt[t])return t;if(Ke(s)||St(s.type)==="t_entity")return"entity";if(String(s.id).toLowerCase()==="priority")return"priority";if(s.enums!=null||s.enum!=null)return"enum";let e=St(s.type);if(e==="bigint"||e==="int64"){let i=String(s.id).toLowerCase();if(i==="date"&&s.indexed)return"date";if(/(?:date|time)$/.test(i))return"datetime"}return Hs(s,e)?"longtext":e&&zt[e]?e:e.endsWith("[]")?"text[]":e==="json"||e==="jsonb"?"json":/^character varying(?:\(\d+\))?$/.test(e)?"character varying":e||t}function Be(s){if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("Field metadata must be an object");let t=s.id??s.name??s.field??s.identifier??s.reference;if(t==null||String(t).trim()==="")throw new TypeError("Field metadata requires an id or name");return{...s,id:String(t)}}function $e(s,t){let e=typeof s=="function"?s(t):s;return e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}function St(s){return String(s??"").trim().toLowerCase().replace(/\s+/g," ")}function Ye(s){let t=s.label??s.title??s.displayName;return t==null||t===""?Ps(s.id):String(t)}function Ps(s){let t=String(s??"").split(".").at(-1)??"";if(t==="ID")return"ID";let e=t.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):t}function Rs(s){return s.readonly===!0||s.readOnly===!0||s.writable===!1||s.mutable===!1}function Hs(s,t){if(s.long===!0||s.multiline===!0)return!0;let e=Number(s.maxLength??t.match(/^character varying\((\d+)\)$/)?.[1]);return Number.isFinite(e)&&e>255}function Ke(s){for(let t of[s.entity,s.fk,s.relation,s.reference,s.references]){if(typeof t=="string"&&t)return t;if(t&&typeof t=="object"){let e=t.resource??t.target??t.table??t.entity;if(typeof e=="string"&&e)return e}}return null}function Pe(s){let t=new Map;if(Array.isArray(s)){for(let e of s)if(typeof e=="string")t.set(e,{});else if(e&&typeof e=="object"){let i=e.id??e.name??e.field;i!=null&&t.set(String(i),{...e})}}else if(s&&typeof s=="object")for(let[e,i]of Object.entries(s))t.set(e,i&&typeof i=="object"?{...i}:{});return t}function qs(s,t,e){if(typeof s.enums!="function")return null;let i=s.enums(t,e);return i&&typeof i=="object"&&!Array.isArray(i)&&Object.prototype.hasOwnProperty.call(i,e)?i[e]:i??null}function se(s){return Ue(s.enums??s.enum??s.options)}function Ue(s){if(typeof s=="string")try{return Ue(JSON.parse(s))}catch{return{}}return Array.isArray(s)?Object.fromEntries(s.map((t,e)=>{if(Array.isArray(t)){let[i=e,r=i]=t;return[String(i),String(r)]}if(t&&typeof t=="object"){let i=t.value??t.id??e;return[String(i),String(t.label??t.name??i)]}return[String(e),String(t)]})):s&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([t,e])=>[t,String(e)])):{}}function Bs(s){return Object.keys(se(s)).length<=5?"optionlist":"select"}function $s(){return{0:"LOWEST",1:"LOW",2:"MEDIUM",3:"HIGH",4:"HIGHEST"}}function We(s,t={}){let e={...t,...se(s)};return i=>{let r=O(i,s);return r==null?"":e[String(r)]??String(r)}}function Qe(s,t=!1){let e;try{e=new Intl.NumberFormat(s.locale,t&&s.currency?{style:"currency",currency:String(s.currency)}:{})}catch{e=new Intl.NumberFormat}return i=>{let r=Ct(O(i,s));return r==null?"":e.format(r)}}function Ct(s){if(s==null||s==="")return null;let t=Number(s);return Number.isFinite(t)?t:null}function Ys(s){let t=Ct(s);return t==null?"":`${new Intl.NumberFormat().format(t)}%`}function Ks(s,t){if(s==null||s==="")return"";try{let e=s instanceof Date?s:lt(s);return!e||!Number.isFinite(e.getTime())?"":new Intl.DateTimeFormat(void 0,t?{dateStyle:"medium",timeStyle:"short"}:{dateStyle:"medium"}).format(e)}catch{return""}}function Us(s){return s instanceof Date?$(s):Ct(s)}function O(s,t){if(!s||typeof s!="object")return;if(Object.prototype.hasOwnProperty.call(s,t.id))return s[t.id];let e=String(t.path??t.field??t.id).split("."),i=s;for(let r of e){if(!i||typeof i!="object")return;i=i[r]}return i}function Ws(s,t,e){if(s&&typeof s=="object"){let r=s.label??s.name??s.title??s.number??s.ID??s.id;return r==null?"":String(r)}let i=e.labelField;if(typeof i=="string"&&t[i]!=null)return String(t[i]);for(let r of[`${e.id}.name`,`${e.id}_label`,`${e.id}Label`])if(t[r]!=null)return String(t[r]);return s==null?"":String(s)}var Ze=0;function w(s="zx"){return Ze+=1,`${s}-${Date.now().toString(36)}-${Ze.toString(36)}`}function It(s,t){let e=ut(s)?Ge(s):{};if(!ut(t))return Mt(t);for(let[i,r]of Object.entries(t))ut(r)&&ut(e[i])?e[i]=It(e[i],r):e[i]=Mt(r);return e}function D(s){return!!(s&&typeof s=="object"&&s.nodeType===1)}function ht(s,t,e){return Math.min(e,Math.max(t,s))}function re(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ut(s){if(s===null||typeof s!="object")return!1;let t=Object.getPrototypeOf(s);return t===Object.prototype||t===null}function Ge(s){let t={};for(let[e,i]of Object.entries(s))t[e]=Mt(i);return t}function Mt(s){return ut(s)?Ge(s):Array.isArray(s)?s.map(Mt):s}var dt=null;function a(s,t,...e){let i=document.createElement(s),r=t;Qs(r)||(e.unshift(r),r={});for(let[n,o]of Object.entries(r))Zs(i,n,o);return Xs(i,e),i}a.scope=function(t,e){let i=dt;dt=t;try{return e()}finally{dt=i}};a.raw=function(t){let e=document.createElement("template");return e.innerHTML=String(t),e.content};function j(s){return{children:Array.from(s.childNodes),attributes:Array.from(s.attributes,t=>[t.name,t.value])}}function V(s,t){if(t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}}function ne(s){if(s==null)return null;if(D(s))return s;if(typeof s=="string")return document.querySelector(s);if(typeof s.toElement=="function"){let t=s.toElement();return D(t)?t:null}return null}function Qs(s){if(s===null||typeof s!="object"||Array.isArray(s))return!1;let t=s;return typeof t.nodeType=="number"?!1:typeof t.toElement!="function"}function Zs(s,t,e){if(t==="ref"){dt&&typeof e=="string"&&(dt[e]=s);return}if(t==="class"){s.className=Array.isArray(e)?e.flat(1/0).filter(Boolean).join(" "):String(e??"");return}if(t==="style"){if(typeof e=="string")s.style.cssText=e;else if(e&&typeof e=="object")for(let[r,n]of Object.entries(e))r.startsWith("--")||r.includes("-")?s.style.setProperty(r,String(n)):s.style[r]=n;return}if(t==="dataset"&&e&&typeof e=="object"){for(let[r,n]of Object.entries(e))n==null?delete s.dataset[r]:s.dataset[r]=String(n);return}if(/^on[a-z]/.test(t)&&typeof e=="function"){s.addEventListener(t.slice(2),e);return}if(e==null)return;let i=Gs(t);if(i!==null)s.setAttribute(i,String(e));else if(t in s)try{s[t]=e}catch{s.setAttribute(t,String(e))}else typeof e=="boolean"?e?s.setAttribute(t,""):s.removeAttribute(t):s.setAttribute(t,String(e))}function Gs(s){return s.startsWith("aria-")?s:/^aria[A-Z]/.test(s)?"aria-"+s.slice(4).toLowerCase():null}function Xs(s,t){let e=s;for(let i of t.flat(1/0)){if(i==null)continue;if(typeof i=="string"||typeof i=="number"){e.append(document.createTextNode(String(i)));continue}if(typeof i!="object")continue;let r=i;if(typeof r.nodeType=="number")e.append(i);else if(typeof r.toElement=="function"){let n=r.toElement();n&&e.append(n)}}}var Xe=null,Je="en";function oe(s){Je=String(s||"en")}function ft(){return Je}function E(s,t){let e=Xe?Xe(s):s;return M(e==null?s:String(e),t)}function M(s,t){if(t==null)return String(s);let e=Array.isArray(t)?t:typeof t=="object"?null:[t],i=String(s).replace(/%(\d+)/g,(n,o)=>{let l=Number(o)-1,c;return e?c=e[l]:Object.prototype.hasOwnProperty.call(t,o)&&(c=t[o]),c==null?n:String(c)}),r=0;return i=i.replace(/%([A-Za-z_][\w.-]*)%/g,(n,o)=>{if(!e&&Object.prototype.hasOwnProperty.call(t,o)){let l=t[o];return l==null?n:String(l)}if(e&&r<e.length){let l=e[r];return r+=1,l==null?n:String(l)}return n}),i}var Tt=new WeakMap,g=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#t=new AbortController;#e=!1;#i=!1;#s=!1;constructor(t,e={}){super();let i=this.constructor;this.#e=t===null;let r=ne(t);if(t!==null&&!r)throw new TypeError("Component target could not be resolved");this.el=r,this.refs={};let n=Js(i,e),o=[];for(let[u,h]of Object.entries(n))/^on[a-z]/.test(u)&&typeof h=="function"&&(o.push([u.slice(2),h]),delete n[u]);n.msg&&typeof n.msg=="object"&&Object.freeze(n.msg),this.options=Object.freeze(n);for(let[u,h]of o)this.on(u,h);let l;try{l=a.scope(this.refs,()=>this.render())}catch(u){throw this.#t.abort(),u}if(this.#e){let u=D(l)?l:this.el;if(!D(u))throw this.#t.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=u}if(!D(this.el))throw this.#t.abort(),new TypeError("Component requires a root Element");let c=i.cssName;if(typeof c=="string"&&c){let u=`zx-${c}`;this.#s=!this.el.classList.contains(u),this.el.classList.add(u)}Tt.set(this.el,this)}render(){return this.el??null}on(t,e){return this.addEventListener(t,e,{signal:this.#t.signal}),this}off(t,e){return this.removeEventListener(t,e),this}once(t,e){return this.addEventListener(t,e,{once:!0,signal:this.#t.signal}),this}addEvent(t,e){return this.on(t,e)}emit(t,e={}){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("Event detail must be an object");let i=ti(t,e,{cancelable:!0});return this.dispatchEvent(i),this.el&&this.el.dispatchEvent(ti(`zx-${t}`,e,{bubbles:!0,composed:!0,cancelable:!0})),i}listen(t,e,i,r={}){let n=typeof r=="boolean"?{capture:r}:{...r};return t.addEventListener(e,i,{...n,signal:this.#t.signal}),this}toElement(){return this.el}msg(t,...e){let i=this.options.msg,r=this.options.lang??this.options.language??ft(),n=i?.[r]?.[t];if(n!=null)return M(String(n),e);let o=i?.[t];return o!=null?M(String(o),e):E(t,e)}destroy(){if(this.#i)return;this.#i=!0,this.#t.abort(),Tt.get(this.el)===this&&Tt.delete(this.el);let t=this.constructor.cssName;this.#s&&typeof t=="string"&&this.el&&this.el.classList.remove(`zx-${t}`),this.#e&&this.el&&this.el.remove()}static from(t){return Tt.get(t)??null}};function Js(s,t){let e=[],i=s;for(;i&&i!==Function.prototype;)Object.prototype.hasOwnProperty.call(i,"defaults")&&e.unshift(i.defaults),i=Object.getPrototypeOf(i);let r={},n={},o=!1;for(let l of e)!l||typeof l!="object"||(Object.assign(r,l),l.msg&&typeof l.msg=="object"&&(o=!0,n=It(n,l.msg)));return Object.assign(r,t&&typeof t=="object"?t:{}),t?.msg&&typeof t.msg=="object"&&(o=!0,n=It(n,t.msg)),o&&(r.msg=n),r}function ti(s,t,e){if(typeof CustomEvent=="function")return new CustomEvent(s,{...e,detail:t});let i=new Event(s,e);return Object.defineProperty(i,"detail",{configurable:!0,enumerable:!0,value:t}),i}var b=class s extends g{static cssName="field";static defaults={id:null,type:"text",label:"",description:"",value:void 0,placeholder:"",required:!1,disabled:!1,options:null,layout:"stack",props:{},msg:{"field.int":"Enter a whole number.","field.float":"Enter a valid number.","field.unknown":"Unknown field type: %1"}};static#t=new Map;static register(t,e){let i=String(t).trim().toLowerCase();if(!i)throw new TypeError("Field adapter type must not be empty");if(typeof e!="function")throw new TypeError("Field adapter must be a function");return s.#t.set(i,e),this}static has(t){return s.#t.has(String(t).trim().toLowerCase())}render(){let t=this.el??a("div");this.el=t;let e=String(this.options.type||"text").toLowerCase(),i=this.options.layout==="inline"?"inline":"stack";this._ownedComponents=new Set,this._ownedNodes=[],this._rootAttributes=sr(t,["data-layout","data-field-type","data-disabled","data-state"]),t.dataset.layout=i,t.dataset.fieldType=e,this.controlId=this.options.id?String(this.options.id):w("zx-field");let r=`${this.controlId}-label`,n=`${this.controlId}-description`,o=`${this.controlId}-highlight`,l=a("label",{class:"zx-field__label",id:r,htmlFor:this.controlId},String(this.options.label??""),this.options.required?a("span",{class:"zx-field__required",ariaHidden:"true"}," *"):null),c=a("div",{class:"zx-field__control"}),u=a("div",{class:"zx-field__description",id:n},String(this.options.description??"")),h=a("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),p=a("div",{class:"zx-field__body"},c,u,h);this._ownedNodes.push(l,p),t.append(l,p);let f=s.#t.get(e);if(f)try{this.adapter=er(f(this,this.options))}catch(_){let y=_ instanceof Error?_.message:String(_);console.warn(`[zx.Field] Adapter "${e}" failed: ${y}`),this.adapter=ii(y,this.controlId)}else{let _=this.msg("field.unknown",e);console.warn(`[zx.Field] ${_}`),this.adapter=ii(_,this.controlId)}let d=this.adapter.el;return d.id||(d.id=this.controlId),l.htmlFor=d.id,ir(d)||d.setAttribute("aria-labelledby",r),this._baseDescribedBy=d.getAttribute("aria-describedby")??"",c.append(d),this._descriptionId=String(this.options.description??"")?n:"",this._highlightId=o,this._highlight=h,this._syncDescription(),this.initialValue=tr(e,this.options.value),this.adapter.set(this.initialValue,{silent:!0}),this.setDisabled(!!this.options.disabled),this.listen(d,"change",()=>{this.emit("change",{value:this.getValue()})}),t}getValue(){return this.adapter.get()}setValue(t,{silent:e=!1}={}){return this.adapter.set(t,{silent:e}),e||this.emit("change",{value:this.getValue()}),this}focus(){return this.adapter.focus(),this}reset(){return this.setValue(this.initialValue,{silent:!0}),this.clearHighlight(),this}setDisabled(t){let e=!!t;return this.adapter.setDisabled(e),this.el.dataset.disabled=String(e),this}setHighlight(t,e="danger"){if(!t)return this.clearHighlight();let i=["danger","warning","success"].includes(e)?e:"danger";return this.el.dataset.state=i,this._highlight.textContent=String(t??""),this._highlight.hidden=!t,i==="danger"&&t?(this._highlight.setAttribute("role","alert"),this.adapter.el.setAttribute("aria-invalid","true"),this.emit("invalid",{message:String(t)})):(this._highlight.removeAttribute("role"),this.adapter.el.removeAttribute("aria-invalid")),this._syncDescription(!!t),this}clearHighlight(){return delete this.el.dataset.state,this._highlight.textContent="",this._highlight.hidden=!0,this._highlight.removeAttribute("role"),this.adapter.el.removeAttribute("aria-invalid"),this._syncDescription(!1),this}getInput(){return this.adapter.el}own(t){if(!(t instanceof g))throw new TypeError("Field.own() requires a Component");return this._ownedComponents.add(t),t}_syncDescription(t=!1){let e=[this._baseDescribedBy,this._descriptionId,t?this._highlightId:""].flatMap(i=>i.split(/\s+/)).filter(Boolean);e.length?this.adapter.el.setAttribute("aria-describedby",[...new Set(e)].join(" ")):this.adapter.el.removeAttribute("aria-describedby")}destroy(){this.adapter?.destroy?.();for(let t of this._ownedComponents??[])t.destroy();this._ownedComponents?.clear();for(let t of this._ownedNodes??[])t.remove();rr(this.el,this._rootAttributes??new Map),super.destroy()}};function ae(s){if(typeof s=="number")return Number.isInteger(s)?{valid:!0,value:s}:{valid:!1,value:String(s)};let t=String(s??"").trim();if(t==="")return{valid:!0,value:""};let e=ri(t);return e!==null&&Number.isInteger(e)?{valid:!0,value:e}:{valid:!1,value:t}}function le(s){if(typeof s=="number")return Number.isFinite(s)?{valid:!0,value:s}:{valid:!1,value:String(s)};let t=String(s??"").trim();if(t==="")return{valid:!0,value:""};let e=ri(t);return e!==null?{valid:!0,value:e}:{valid:!1,value:t}}function ri(s){let t=s.replace(/[\s\u00a0]/g,"");if(!/^[+-]?[\d.,]+$/.test(t))return null;let e=/^[+-]/.test(t)?t[0]:"",i=e?t.slice(1):t;if(!/\d/.test(i))return null;let r=[...i.matchAll(/\./g)].map(c=>c.index),n=[...i.matchAll(/,/g)].map(c=>c.index),o;if(r.length&&n.length){let c=r.at(-1)>n.at(-1)?".":",",u=c==="."?",":".",h=i.lastIndexOf(c),p=i.slice(0,h),f=i.slice(h+1);if(!/^\d+$/.test(f)||!ei(p,u))return null;o=p.split(u).join("")+"."+f}else if(n.length>1||r.length>1){let c=n.length?",":".";if(!ei(i,c))return null;o=i.split(c).join("")}else n.length===1?o=i.replace(",","."):o=i;if(!/^(?:\d+(?:\.\d+)?|\.\d+)$/.test(o))return null;let l=Number(e+o);return Number.isFinite(l)?l:null}function ei(s,t){let e=s.split(t);return e.length>0&&/^\d{1,3}$/.test(e[0])&&e.slice(1).every(i=>/^\d{3}$/.test(i))}function tr(s,t){return t!==void 0?t:s==="checkbox"?!1:""}function er(s){if(!s||typeof s!="object")throw new TypeError("Adapter must return an object");if(!(s.el&&s.el.nodeType===1))throw new TypeError("Adapter must provide an Element");for(let t of["get","set","focus","setDisabled"])if(typeof s[t]!="function")throw new TypeError(`Adapter is missing ${t}()`);return s}function ii(s,t){let e=a("div",{class:"zx-field__error-control",id:t,role:"alert",tabIndex:-1},s);return{el:e,get:()=>null,set:()=>{},focus:()=>e.focus(),setDisabled:()=>{}}}function ir(s){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(s.tagName)}function sr(s,t){return new Map(t.map(e=>[e,s.getAttribute(e)]))}function rr(s,t){for(let[e,i]of t)i===null?s.removeAttribute(e):s.setAttribute(e,i)}function pt(s,t){let e={...s.props??{}};for(let i of Object.keys(e))(/^on[a-z]/i.test(i)||i==="content")&&delete e[i];return{...e,...t}}function Et(s,t){return(e,i)=>{let r=a(s,pt(i,{type:s==="input"?t:void 0,placeholder:i.placeholder,required:i.required,disabled:i.disabled}));return ce(r)}}function ce(s){return{el:s,get:()=>s.value,set:t=>{s.value=t==null?"":String(t)},focus:()=>s.focus(),setDisabled:t=>{s.disabled=t}}}function ni(s){return(t,e)=>{let i=s==="int"?ae:le,r=a("input",pt(e,{type:"text",inputMode:s==="int"?"numeric":"decimal",placeholder:e.placeholder,required:e.required,disabled:e.disabled}));return t.listen(r,"blur",()=>{let n=i(r.value);if(!n.valid){t.setHighlight(t.msg(`field.${s}`),"danger");return}n.value!==""&&(r.value=String(n.value)),t.clearHighlight()}),{...ce(r),get:()=>i(r.value).value}}}var nr=(s,t)=>{let e=a("input",pt(t,{type:"checkbox",required:t.required,disabled:t.disabled}));return{el:e,get:()=>e.checked,set:i=>{e.checked=!!i},focus:()=>e.focus(),setDisabled:i=>{e.disabled=i}}},or=(s,t)=>{let e=a("select",pt(t,{required:t.required,disabled:t.disabled}));for(let[i,r]of oi(t.options))e.append(a("option",{value:i},r));return ce(e)},ar=(s,t)=>{let e=a("div",{class:"zx-field__option-list",role:"radiogroup"}),i=t.id?String(t.id):w("zx-option-list"),r=oi(t.options).map(([n,o],l)=>{let c=a("input",{type:"radio",name:i,value:n,required:!!t.required&&l===0,disabled:t.disabled});return e.append(a("label",{class:"zx-field__option"},c,a("span",{},o))),c});return{el:e,get:()=>r.find(n=>n.checked)?.value??"",set:n=>{for(let o of r)o.checked=String(n??"")===o.value},focus:()=>(r.find(n=>n.checked)??r[0])?.focus(),setDisabled:n=>{for(let o of r)o.disabled=n;e.setAttribute("aria-disabled",String(n))}}},lr=(s,t)=>{let e=a("div",pt(t,{class:"zx-field__static"})),i=null;return{el:e,get:()=>e.textContent,set:n=>{si(i),i=null,n&&typeof n=="object"&&typeof n.nodeType=="number"?(i={node:n,parent:n.parentNode,next:n.nextSibling},e.replaceChildren(n)):e.textContent=n==null?"":String(n)},focus:()=>{},setDisabled:n=>{e.setAttribute("aria-disabled",String(n))},destroy:()=>si(i)}};function si(s){s&&(s.parent?s.parent.insertBefore(s.node,s.next?.parentNode===s.parent?s.next:null):s.node.remove())}var cr=(s,t)=>{if(typeof t.adapter!="function")throw new TypeError("Custom fields require options.adapter");return t.adapter(s,t)};function oi(s){return Array.isArray(s)?s.map(t=>[String(t),String(t)]):s&&typeof s=="object"?Object.entries(s).map(([t,e])=>[t,String(e)]):[]}b.register("text",Et("input","text"));b.register("password",Et("input","password"));b.register("textarea",Et("textarea","text"));b.register("checkbox",nr);b.register("int",ni("int"));b.register("float",ni("float"));b.register("select",or);b.register("optionlist",ar);b.register("hidden",Et("input","hidden"));b.register("html",lr);b.register("custom",cr);function P(s,t,e){let i=ai(t).split(/\s+/).filter(Boolean);return i.length===0?s.slice():s.filter(r=>{let n=ur(r,e).map(ai);return i.every(o=>n.some(l=>l.includes(o)))})}function ur(s,t){return s===null||typeof s!="object"?[s]:!Array.isArray(t)||t.length===0?[s]:t.map(e=>typeof e=="function"?e(s):s[e])}function ai(s){return String(s??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var Nt=class extends g{static cssName="checklist";static defaults={items:[],valueKey:"ID",labelKey:"name",checkedKey:"on",search:!0,height:280,defaultChecked:!1,load:null};render(){this._items=[],this._visibleItems=[],this._checked=new Set,this._query="",this._loadSequence=0,this._createdRoot=!1,this._active=!0,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let t=this.el??a("div");this.el=t,this._createdRoot||(this._originalChildren=Array.from(t.childNodes));for(let o of["role","aria-labelledby","data-state"])this._originalAttributes.set(o,t.getAttribute(o));let e=w("zx-checklist-label"),i=a("div",{class:"zx-checklist__label",id:e},this._message("checklist.label","Checklist")),r=a("input",{ref:"search",class:"zx-checklist__search",type:"search",autocomplete:"off",placeholder:this._message("checklist.search","Search"),ariaLabel:this._message("checklist.search","Search checklist"),hidden:!this.options.search}),n=a("div",{ref:"list",class:"zx-checklist__list"});return n.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,t.replaceChildren(i,r,n),t.setAttribute("role","group"),t.setAttribute("aria-labelledby",e),this.listen(r,"input",()=>this.search(r.value)),this.listen(n,"change",o=>{let l=o.target;if(!l?.matches?.('input[type="checkbox"][data-index]'))return;let c=this._visibleItems[Number(l.dataset.index)];if(c===void 0)return;let u=this._itemValue(c);l.checked?this._checked.add(u):this._checked.delete(u),this.emit("change",{values:this.getValues()})}),this._replaceItems(this.options.items),typeof this.options.load=="function"&&queueMicrotask(()=>{this._active&&this.reload().catch(()=>{})}),t}setItems(t){return this._replaceItems(t),this}getValues(){return this._items.map(t=>this._itemValue(t)).filter(t=>this._checked.has(t))}setValues(t){let e=new Set(t==null?[]:Array.from(t)),i=new Set(this._items.map(r=>this._itemValue(r)).filter(r=>e.has(r)));return this._replaceChecked(i),this}checkAll(){return this._replaceChecked(new Set(this._items.map(t=>this._itemValue(t)))),this}uncheckAll(){return this._replaceChecked(new Set),this}search(t){this._query=String(t??"");let e=this.refs.search;return e.value!==this._query&&(e.value=this._query),this._visibleItems=P(this._items,this._query,[this.options.labelKey]),this._renderItems(),this}async reload(){if(!this._active||typeof this.options.load!="function")return this;let t=++this._loadSequence;this.el.setAttribute("data-state","loading"),this.refs.list.setAttribute("aria-busy","true");try{let e=await this.options.load();if(t!==this._loadSequence)return this;this._replaceItems(e),this.emit("loaded",{items:this._items.slice()})}finally{t===this._loadSequence&&(this.el.removeAttribute("data-state"),this.refs.list.setAttribute("aria-busy","false"))}return this}destroy(){this._active=!1,this._loadSequence+=1;let t=this.el;if(!this._createdRoot&&t){t.replaceChildren(...this._originalChildren);for(let[e,i]of this._originalAttributes)i===null?t.removeAttribute(e):t.setAttribute(e,i)}super.destroy()}_replaceItems(t){this._items=Array.isArray(t)?t.slice():[],this._checked=new Set(this._items.filter(e=>!!this._initialChecked(e)).map(e=>this._itemValue(e))),this._visibleItems=P(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let t=this._visibleItems.map((e,i)=>{let r=w("zx-checklist-item"),n=a("input",{type:"checkbox",id:r,checked:this._checked.has(this._itemValue(e)),dataset:{index:i}});return a("label",{class:"zx-checklist__item",for:r},n,a("span",{},this._itemLabel(e)))});t.length===0&&t.push(a("div",{class:"zx-checklist__empty",role:"status"},this._message("checklist.empty","No matches"))),this.refs.list.replaceChildren(...t)}_replaceChecked(t){hr(this._checked,t)||(this._checked=t,this._renderItems(),this.emit("change",{values:this.getValues()}))}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){return String(this._read(t,this.options.labelKey)??"")}_initialChecked(t){let e;return typeof this.options.checkedKey=="function"?e=this.options.checkedKey(t):t!==null&&typeof t=="object"&&(e=t[this.options.checkedKey]),e??this.options.defaultChecked}_read(t,e){return typeof e=="function"?e(t):t===null||typeof t!="object"?t:t[e]}_message(t,e){let i=this.msg(t);return i===t?e:i}};function hr(s,t){return s.size===t.size&&Array.from(s).every(e=>t.has(e))}function li(){b.register("checklist",(s,t)=>{let e=s.own(new Nt(null,{...t.props??{}})),i=!1,r=!1,n=()=>{e.el.setAttribute("aria-disabled",String(i));for(let o of e.el.querySelectorAll("input, button, select, textarea"))o.disabled=i};return s.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>{r||s.emit("change",{value:o.detail.values})}),e.on("loaded",n),{el:e.el,get:()=>e.getValues(),set:o=>{r=!0;try{e.setValues(Array.isArray(o)?o:[])}finally{r=!1}n()},focus:()=>{(e.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])")??e.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus()},setDisabled:o=>{i=!!o,n()}}})}var ci=["January","February","March","April","May","June","July","August","September","October","November","December"],ui=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],fi=/%[demYyHMSaAbBs]/g;function x(s,t){return!(s instanceof Date)||Number.isNaN(s.getTime())?"":String(t).replace(fi,e=>{switch(e){case"%d":return et(s.getDate());case"%e":return String(s.getDate());case"%m":return et(s.getMonth()+1);case"%Y":return String(s.getFullYear()).padStart(4,"0");case"%y":return et(s.getFullYear()%100);case"%H":return et(s.getHours());case"%M":return et(s.getMinutes());case"%S":return et(s.getSeconds());case"%a":return hi("weekday",s.getDay(),ui[s.getDay()]);case"%A":return ue("weekday",s.getDay(),ui[s.getDay()]);case"%b":return hi("month",s.getMonth(),ci[s.getMonth()]);case"%B":return ue("month",s.getMonth(),ci[s.getMonth()]);case"%s":return String(Math.floor(s.getTime()/1e3));default:return e}})}function N(s,t){let e=[],i="^",r=0;for(let _ of String(t).matchAll(fi)){i+=di(String(t).slice(r,_.index));let y=_[0],v=dr(y);if(v===null)return null;i+=`(${v})`,e.push(y),r=_.index+y.length}i+=di(String(t).slice(r))+"$";let n=new RegExp(i).exec(String(s));if(!n)return null;let o=Object.create(null);if(e.forEach((_,y)=>{o[_]=Number(n[y+1])}),o["%s"]!==void 0){let _=o["%s"]*1e3,y=new Date(_);return Number.isNaN(y.getTime())?null:y}let l=o["%Y"]??fr(o["%y"])??1970,c=(o["%m"]??1)-1,u=o["%d"]??o["%e"]??1,h=o["%H"]??0,p=o["%M"]??0,f=o["%S"]??0,d=new Date(0);return d.setHours(0,0,0,0),d.setFullYear(l,c,u),d.setHours(h,p,f,0),Number.isNaN(d.getTime())||o["%Y"]!==void 0&&d.getFullYear()!==o["%Y"]||o["%y"]!==void 0&&d.getFullYear()%100!==o["%y"]||o["%m"]!==void 0&&d.getMonth()!==c||o["%d"]!==void 0&&d.getDate()!==u||o["%e"]!==void 0&&d.getDate()!==u||o["%H"]!==void 0&&d.getHours()!==h||o["%M"]!==void 0&&d.getMinutes()!==p||o["%S"]!==void 0&&d.getSeconds()!==f?null:d}function pi(s,t,e){let i=s.getTime(),r=t instanceof Date?t.getTime():-1/0,n=e instanceof Date?e.getTime():1/0;return new Date(Math.min(n,Math.max(r,i)))}function S(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}function k(s,t){let e=new Date(s.getTime());return e.setDate(e.getDate()+t),e}function Y(s,t){let e=new Date(s.getTime()),i=e.getDate();e.setDate(1),e.setMonth(e.getMonth()+t);let r=new Date(e.getFullYear(),e.getMonth()+1,0).getDate();return e.setDate(Math.min(i,r)),e}function Ft(s=ft()){if(!s||s.toLowerCase()==="en")return 1;try{let t=new Intl.Locale(s),e=t.getWeekInfo?.()??t.weekInfo;if(e?.firstDay)return e.firstDay%7}catch{}return 1}function et(s){return String(s).padStart(2,"0")}function ue(s,t,e){let i=`date.${s}.${t}`,r=E(i);return r===i?e:r}function hi(s,t,e){let i=`date.${s}.short.${t}`,r=E(i);return r!==i?r:ue(s,t,e).slice(0,3)}function dr(s){return{"%d":"\\d{1,2}","%e":"\\d{1,2}","%m":"\\d{1,2}","%Y":"\\d{4}","%y":"\\d{2}","%H":"\\d{1,2}","%M":"\\d{1,2}","%S":"\\d{1,2}","%s":"-?\\d+"}[s]??null}function fr(s){if(s!==void 0)return s>=69?1900+s:2e3+s}function di(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var _i=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),pr=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),mi=Object.freeze({fa:null,fas:"solid",far:"regular",fal:"light",fat:"thin",fad:"duotone",fab:"brands",fak:"kit",solid:"solid",regular:"regular",light:"light",thin:"thin",duotone:"duotone",brands:"brands",kit:"kit",custom:"kit"}),_r=Object.freeze({x:"xmark",search:"magnifying-glass",calendar:"calendar-days",reload:"arrows-rotate",dots:"ellipsis",info:"circle-info",warning:"triangle-exclamation",error:"circle-exclamation",success:"circle-check",drag:"grip-vertical"}),he=new Map;function gi(s){let t=String(s).trim();if(/\s/.test(t)||t.startsWith("fa-"))return{provider:"fa",name:"",style:null,classes:t.split(/\s+/).filter(Boolean)};let e=t.indexOf(":");if(e>0){let i=t.slice(0,e).toLowerCase(),r=t.slice(e+1);if(i==="builtin"||i==="zx")return{provider:"builtin",name:r,style:null,classes:null};if(Object.hasOwn(mi,i))return{provider:"fa",name:r,style:mi[i],classes:null}}return{provider:null,name:t,style:null,classes:null}}function de(s,t={}){let{style:e="solid",family:i="classic",fixedWidth:r=!1,translate:n=!0}=t,o=String(s).replace(/^fa-/,""),l=n?_r[o]??o:o,c=[],u=pr[i];return u&&c.push(u),c.push(_i[e]??_i.solid,`fa-${l}`),r&&c.push("fa-fw"),c}function fe(s){let t=String(s).trim();if(/^(https?:)?\/\//.test(t)||t.startsWith("/")||t.endsWith(".js"))return t;if(!/^[a-z0-9]+$/.test(t))throw new RangeError(`Invalid Font Awesome kit token: ${s}`);return`https://kit.fontawesome.com/${t}.js`}function bi(s){let t=fe(s),e=he.get(t);if(e)return e;let i=new Promise((r,n)=>{let o=new URL(t,document.baseURI).href,l=[...document.scripts].find(u=>u.src===o);if(l&&globalThis.FontAwesomeKitConfig){r();return}let c=l??document.createElement("script");c.addEventListener("load",()=>r(),{once:!0}),c.addEventListener("error",()=>{he.delete(t),n(new Error(`Font Awesome kit failed to load: ${t}`))},{once:!0}),!l&&(c.src=t,c.async=!0,c.crossOrigin="anonymous",document.head.append(c))});return he.set(t,i),i}var yi="http://www.w3.org/2000/svg",vi=Object.freeze({"chevron-down":["0 0 512 512","M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"],"chevron-up":["0 0 512 512","M233.4 105.4c12.5-12.5 32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L256 173.3 86.6 342.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l192-192z"],"chevron-left":["0 0 320 512","M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 256 246.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"],"chevron-right":["0 0 320 512","M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"],check:["0 0 448 512","M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"],x:["0 0 384 512","M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"],plus:["0 0 448 512","M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32V224H48c-17.7 0-32 14.3-32 32s14.3 32 32 32H192V432c0 17.7 14.3 32 32 32s32-14.3 32-32V288H400c17.7 0 32-14.3 32-32s-14.3-32-32-32H256V80z"],minus:["0 0 448 512","M432 256c0 17.7-14.3 32-32 32L48 288c-17.7 0-32-14.3-32-32s14.3-32 32-32l352 0c17.7 0 32 14.3 32 32z"],search:["0 0 512 512","M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"],calendar:["0 0 448 512","M128 0c17.7 0 32 14.3 32 32V64H288V32c0-17.7 14.3-32 32-32s32 14.3 32 32V64h48c26.5 0 48 21.5 48 48v48H0V112C0 85.5 21.5 64 48 64H96V32c0-17.7 14.3-32 32-32zM0 192H448V464c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V192z"],clock:["0 0 512 512","M256 0a256 256 0 1 1 0 512A256 256 0 1 1 256 0zM232 120V256c0 8 4 15.5 10.7 20l96 64c11 7.4 25.9 4.4 33.3-6.7s4.4-25.9-6.7-33.3L280 243.2V120c0-13.3-10.7-24-24-24s-24 10.7-24 24z"],trash:["0 0 448 512","M135.2 17.7L128 32H32C14.3 32 0 46.3 0 64S14.3 96 32 96H416c17.7 0 32-14.3 32-32s-14.3-32-32-32H320l-7.2-14.3C307.4 6.8 296.3 0 284.2 0H163.8c-12.1 0-23.2 6.8-28.6 17.7zM416 128H32L53.2 467c1.6 25.3 22.6 45 47.9 45H346.9c25.3 0 46.3-19.7 47.9-45L416 128z"],gear:["0 0 512 512","M481.9 166.6c3.2 8.7 .5 18.4-6.4 24.6l-43.3 39.4c1.1 8.3 1.7 16.8 1.7 25.4s-.6 17.1-1.7 25.4l43.3 39.4c6.9 6.2 9.6 15.9 6.4 24.6c-4.4 11.9-9.7 23.3-15.8 34.3l-4.7 8.1c-6.6 11-14 21.4-22.1 31.2c-5.9 7.2-15.7 9.6-24.5 6.8l-55.7-17.7c-13.4 10.3-28.2 18.9-44 25.4l-12.5 57.1c-2 9.1-9 16.3-18.2 17.8c-13.8 2.3-28 3.5-42.5 3.5s-28.7-1.2-42.5-3.5c-9.2-1.5-16.2-8.7-18.2-17.8l-12.5-57.1c-15.8-6.5-30.6-15.1-44-25.4L83.1 425.9c-8.8 2.8-18.6 .3-24.5-6.8c-8.1-9.8-15.5-20.2-22.1-31.2l-4.7-8.1c-6.1-11-11.4-22.4-15.8-34.3c-3.2-8.7-.5-18.4 6.4-24.6l43.3-39.4C64.6 273.1 64 264.6 64 256s.6-17.1 1.7-25.4L22.4 191.2c-6.9-6.2-9.6-15.9-6.4-24.6c4.4-11.9 9.7-23.3 15.8-34.3l4.7-8.1c6.6-11 14-21.4 22.1-31.2c5.9-7.2 15.7-9.6 24.5-6.8l55.7 17.7c13.4-10.3 28.2-18.9 44-25.4l12.5-57.1c2-9.1 9-16.3 18.2-17.8C227.3 1.2 241.5 0 256 0s28.7 1.2 42.5 3.5c9.2 1.5 16.2 8.7 18.2 17.8l12.5 57.1c15.8 6.5 30.6 15.1 44 25.4l55.7-17.7c8.8-2.8 18.6-.3 24.5 6.8c8.1 9.8 15.5 20.2 22.1 31.2l4.7 8.1c6.1 11 11.4 22.4 15.8 34.3zM256 336a80 80 0 1 0 0-160 80 80 0 1 0 0 160z"],eye:["0 0 576 512","M288 32c-80.8 0-145.5 36.8-192.6 80.6C48.6 156 17.3 208 2.5 243.7c-3.3 7.9-3.3 16.7 0 24.6C17.3 304 48.6 356 95.4 399.4C142.5 443.2 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C433.5 68.8 368.8 32 288 32zM144 256a144 144 0 1 1 288 0 144 144 0 1 1-288 0zm144-64c0 35.3-28.7 64-64 64c-7.1 0-13.9-1.2-20.3-3.3c-5.5-1.8-11.9 1.6-11.7 7.4c.3 6.9 1.3 13.8 3.2 20.7c13.7 51.2 66.4 81.6 117.6 67.9s81.6-66.4 67.9-117.6c-11.1-41.5-47.8-69.4-88.6-71.1c-5.8-.2-9.2 6.1-7.4 11.7c2.1 6.4 3.3 13.2 3.3 20.3z"],lock:["0 0 448 512","M144 144v48H304V144c0-44.2-35.8-80-80-80s-80 35.8-80 80zM80 192V144C80 64.5 144.5 0 224 0s144 64.5 144 144v48h16c35.3 0 64 28.7 64 64V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V256c0-35.3 28.7-64 64-64H80z"],reload:["0 0 512 512","M386.3 160H336c-17.7 0-32 14.3-32 32s14.3 32 32 32H464c17.7 0 32-14.3 32-32V64c0-17.7-14.3-32-32-32s-32 14.3-32 32v51.2L414.4 97.6c-87.5-87.5-229.3-87.5-316.8 0s-87.5 229.3 0 316.8s229.3 87.5 316.8 0c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0c-62.5 62.5-163.8 62.5-226.3 0s-62.5-163.8 0-226.3s163.8-62.5 226.3 0L386.3 160z"],list:["0 0 512 512","M40 48C26.7 48 16 58.7 16 72v48c0 13.3 10.7 24 24 24H88c13.3 0 24-10.7 24-24V72c0-13.3-10.7-24-24-24H40zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zM16 232v48c0 13.3 10.7 24 24 24H88c13.3 0 24-10.7 24-24V232c0-13.3-10.7-24-24-24H40c-13.3 0-24 10.7-24 24zM40 368c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24H88c13.3 0 24-10.7 24-24V392c0-13.3-10.7-24-24-24H40z"],filter:["0 0 512 512","M3.9 54.9C10.5 40.9 24.5 32 40 32H472c15.5 0 29.5 8.9 36.1 22.9s4.6 30.5-5.2 42.5L320 320.9V448c0 12.1-6.8 23.2-17.7 28.6s-23.8 4.3-33.5-3l-64-48c-8.1-6-12.8-15.5-12.8-25.6V320.9L9 97.3C-.7 85.4-2.8 68.8 3.9 54.9z"],dots:["0 0 448 512","M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1-112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"],info:["0 0 512 512","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"],warning:["0 0 512 512","M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0-64 0 32 32 0 1 0 64 0z"],error:["0 0 512 512","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24V264c0 13.3-10.7 24-24 24s-24-10.7-24-24V152c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1-64 0z"],success:["0 0 512 512","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"],upload:["0 0 512 512","M288 109.3V352c0 17.7-14.3 32-32 32s-32-14.3-32-32V109.3l-73.4 73.4c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l128-128c12.5-12.5 32.8-12.5 45.3 0l128 128c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L288 109.3zM64 352H192c0 35.3 28.7 64 64 64s64-28.7 64-64H448c35.3 0 64 28.7 64 64v32c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V416c0-35.3 28.7-64 64-64z"],drag:["0 0 320 512","M40 352l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40zm192 0l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40zM40 176l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40zm192 0l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40zM40 0L88 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40L40 128C17.9 128 0 110.1 0 88L0 40C0 17.9 17.9 0 40 0zM232 0l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40z"],star:["0 0 576 512","M287.9 0c9.2 0 17.6 5.2 21.6 13.5l68.6 141.3 153.2 22.6c9 1.3 16.5 7.6 19.3 16.3s.5 18.1-5.9 24.5L433.6 328.4l26.2 155.6c1.5 9-2.2 18.1-9.7 23.5s-17.3 6-25.3 1.7l-137-73.2L151 509.1c-8.1 4.3-17.9 3.7-25.3-1.7s-11.2-14.5-9.7-23.5l26.2-155.6L31.1 218.2c-6.5-6.4-8.7-15.9-5.9-24.5s10.3-14.9 19.3-16.3l153.2-22.6L266.3 13.5C270.4 5.2 278.7 0 287.9 0z"],heart:["0 0 512 512","M47.6 300.4L228.3 469.1c7.5 7 17.4 10.9 27.7 10.9s20.2-3.9 27.7-10.9L464.4 300.4c30.4-28.3 47.6-68 47.6-109.5v-5.8c0-69.9-50.5-129.5-119.4-141C347 36.5 300.6 51.4 268 84L256 96 244 84c-32.6-32.6-79-47.5-124.6-39.9C50.5 55.6 0 115.2 0 185.1v5.8c0 41.5 17.2 81.2 47.6 109.5z"],tag:["0 0 448 512","M0 80V229.5c0 17 6.7 33.3 18.7 45.3l176 176c25 25 65.5 25 90.5 0L418.7 317.3c25-25 25-65.5 0-90.5l-176-176c-12-12-28.3-18.7-45.3-18.7H48C21.5 32 0 53.5 0 80zm112 32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"],folder:["0 0 512 512","M64 480H448c35.3 0 64-28.7 64-64V160c0-35.3-28.7-64-64-64H298.5c-17 0-33.3-6.7-45.3-18.7L226.7 50.7c-12-12-28.3-18.7-45.3-18.7H64C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64z"],"folder-open":["0 0 576 512","M88.7 223.8L0 375.8V96C0 60.7 28.7 32 64 32H181.5c17 0 33.3 6.7 45.3 18.7l26.5 26.5c12 12 28.3 18.7 45.3 18.7H416c35.3 0 64 28.7 64 64v32H144c-22.8 0-43.8 12.1-55.3 31.8zm27.6 16.1C122.1 230 132.6 224 144 224H544c11.5 0 22 6.1 27.7 16.1s5.7 22.2-.1 32.1l-112 192C453.9 474 443.4 480 432 480H32c-11.5 0-22-6.1-27.7-16.1s-5.7-22.2 .1-32.1l112-192z"],file:["0 0 384 512","M0 64C0 28.7 28.7 0 64 0H224V128c0 17.7 14.3 32 32 32H384V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V64zm384 64H256V0L384 128z"],copy:["0 0 448 512","M208 0L332.1 0c12.7 0 24.9 5.1 33.9 14.1l67.9 67.9c9 9 14.1 21.2 14.1 33.9L448 336c0 26.5-21.5 48-48 48l-192 0c-26.5 0-48-21.5-48-48l0-288c0-26.5 21.5-48 48-48zM48 128l80 0 0 64-64 0 0 256 192 0 0-32 64 0 0 48c0 26.5-21.5 48-48 48L48 512c-26.5 0-48-21.5-48-48L0 176c0-26.5 21.5-48 48-48z"],square:["0 0 448 512","M384 80c8.8 0 16 7.2 16 16V416c0 8.8-7.2 16-16 16H64c-8.8 0-16-7.2-16-16V96c0-8.8 7.2-16 16-16H384zM64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64z"],code:["0 0 640 512","M392.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6zm80.6 120.1c-12.5 12.5-12.5 32.8 0 45.3L562.7 256l-89.4 89.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l112-112c12.5-12.5 12.5-32.8 0-45.3l-112-112c-12.5-12.5-32.8-12.5-45.3 0zm-306.7 0c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3l112 112c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l89.4-89.4c12.5-12.5 12.5-32.8 0-45.3z"],book:["0 0 448 512","M96 0C43 0 0 43 0 96V416c0 53 43 96 96 96H384h32c17.7 0 32-14.3 32-32s-14.3-32-32-32V384c17.7 0 32-14.3 32-32V32c0-17.7-14.3-32-32-32H384 96zm0 384H352v64H96c-17.7 0-32-14.3-32-32s14.3-32 32-32zm32-240c0-8.8 7.2-16 16-16H336c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-8.8 0-16-7.2-16-16zm16 48H336c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-8.8 0-16-7.2-16-16s7.2-16 16-16z"]}),mr=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list"}),gr=Object.create(null),L={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function _e(){return{...L}}function me(s={}){for(let t of["provider","style","family","fixedWidth","kit"])s[t]!==void 0&&(L[t]=s[t]);return _e()}function wi(s={}){return me({...s,provider:"fontawesome"})}async function ge(s){let t=typeof s=="string"?{kit:s}:{...s},{kit:e,activate:i=!0,...r}=t;if(!e)throw new TypeError("loadFontAwesome() needs a kit token or URL");return me({...r,kit:fe(e)}),await bi(e),i?wi():_e()}function m(s,t={}){let e=gi(s);if(e.classes)return pe(e.classes,t);let i=mr[e.name]??e.name;return e.provider==="builtin"?xi(i,t):e.provider==="fa"?pe(de(i,{style:e.style??t.style??L.style,family:t.family??L.family,fixedWidth:t.fixedWidth??L.fixedWidth}),t):L.provider==="fontawesome"?pe(de(i,{style:t.style??L.style,family:t.family??L.family,fixedWidth:t.fixedWidth??L.fixedWidth}),t):xi(i,t)}function xi(s,t){let e=gr[s]??vi[s];if(!e)throw new RangeError(`Unknown icon: ${s}`);let[i,r]=e,{size:n=16}=t,o=document.createElementNS(yi,"svg"),l=document.createElementNS(yi,"path");return o.setAttribute("class",Ai("zx-icon",t.class)),o.setAttribute("viewBox",i),o.setAttribute("width",String(n)),o.setAttribute("height",String(n)),o.setAttribute("fill","currentColor"),o.setAttribute("focusable","false"),ki(o,t.label??null),l.setAttribute("d",r),o.append(l),o}function pe(s,t){let{size:e=16}=t,i=document.createElement("i");return i.className=Ai("zx-icon",...s,t.class),i.style.fontSize=typeof e=="number"?`${e}px`:String(e),ki(i,t.label??null),i}function ki(s,t){if(t===null){s.setAttribute("aria-hidden","true");return}s.setAttribute("role","img"),s.setAttribute("aria-label",t)}function Ai(...s){return s.flat().filter(Boolean).join(" ")}var br=5,Ot=class extends g{static cssName="time-picker";static defaults={value:null,seconds:!1,step:5,clock:!0};render(){let t=this.el??a("div");this.el=t;let e=Si(this.options.value);this._value=e,this._display=e??{h:0,m:0,s:0},this._inputs=[],this._clockOpen=!1,this._clockUnit="h",this._clock=null;let i=a("div",{class:"zx-time-picker__segments",role:"group",ariaLabel:"Time"});if(this._content=i,this._addSpin(i,"h","Hour",23),i.append(a("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(i,"m","Minute",59),this.options.seconds&&(i.append(a("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(i,"s","Second",59)),t.append(i),this.options.clock){let r=w("zx-time-picker-clock");i.append(a("button",{ref:"clockToggle",class:"zx-icon-btn zx-time-picker__clock-toggle",type:"button",ariaLabel:"Pick the time on a clock",ariaExpanded:"false",ariaControls:r},m("clock",{size:15}))),this._clock=this._buildClock(r),t.append(this._clock),this.listen(this.refs.clockToggle,"click",()=>this.toggleClock())}return this._writeInputs(),t}get(){return this._value?{...this._value}:null}set(t,{silent:e=!1}={}){let i=Si(t);return this._value=i,this._display=i??{h:0,m:0,s:0},this._writeInputs(),!e&&i&&this.emit("change",{time:{...i}}),this}openClock(t="h"){return this._clock?(this._clockOpen=!0,this._clockUnit=t==="m"?"m":"h",this._syncClock(),this):this}closeClock(){return this._clock?(this._clockOpen=!1,this._syncClock(),this):this}toggleClock(){return this._clockOpen?this.closeClock():this.openClock("h")}destroy(){this._content?.remove(),this._clock?.remove(),this._clock=null,super.destroy()}_addSpin(t,e,i,r){let n=a("input",{class:"zx-time-picker__spin",type:"text",role:"spinbutton",inputMode:"numeric",maxLength:2,autocomplete:"off",ariaLabel:i,ariaValueMin:"0",ariaValueMax:String(r),dataset:{segment:e}});this._inputs.push(n),t.append(n),this.listen(n,"focus",()=>n.select()),this.listen(n,"keydown",o=>this._onKeydown(o,e,r)),this.listen(n,"input",()=>this._onInput(n,e,r)),this.listen(n,"blur",()=>this._commitFromInputs())}_onKeydown(t,e,i){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return;t.preventDefault();let r=t.key==="ArrowUp"?1:-1,n=e==="m"?wr(this.options.step):1,o=it(t.currentTarget.value,0,i),l=i+1,c=(o+r*n+l*n)%l;t.currentTarget.value=K(c),this._commitFromInputs()}_onInput(t,e,i){if(t.value=t.value.replace(/\D/g,"").slice(0,2),t.value.length<2)return;t.value=K(it(t.value,0,i)),this._commitFromInputs();let r=this._inputs.indexOf(t);this._inputs[r+1]?.focus()}_commitFromInputs(){let t={h:0,m:0,s:0};for(let i of this._inputs){let r=i.dataset.segment,n=r==="h"?23:59;t[r]=it(i.value,0,n)}let e=!this._value||!kr(this._value,t);this._value=t,this._display=t,this._writeInputs(),e&&this.emit("change",{time:{...t}})}_writeInputs(){for(let t of this._inputs){let e=t.dataset.segment;t.value=K(this._display[e]),t.setAttribute("aria-valuenow",String(this._display[e])),t.setAttribute("aria-valuetext",t.value)}this._syncClock()}_buildClock(t){let e=a("div",{class:"zx-time-picker__clock",id:t,hidden:!0},a("div",{class:"zx-time-picker__clock-head"},a("button",{ref:"headHour",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:"Select the hour",dataset:{unit:"h"}}),a("span",{class:"zx-time-picker__clock-colon",ariaHidden:"true"},":"),a("button",{ref:"headMinute",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:"Select the minutes",dataset:{unit:"m"}})),a("div",{ref:"dial",class:"zx-time-picker__dial",role:"radiogroup"},a("span",{ref:"hand",class:"zx-time-picker__hand",ariaHidden:"true"}),a("span",{class:"zx-time-picker__pivot",ariaHidden:"true"})));return this.listen(this.refs.headHour,"click",()=>this.openClock("h")),this.listen(this.refs.headMinute,"click",()=>this.openClock("m")),this.listen(this.refs.dial,"click",i=>{let r=i.target.closest?.(".zx-time-picker__mark");r&&this._pick(Number(r.dataset.value))}),this.listen(this.refs.dial,"keydown",i=>this._onDialKeydown(i)),e}_pick(t){let e={...this._display,[this._clockUnit]:t},i=this._clockUnit==="h";this.set(e),i&&this.openClock("m")}_onDialKeydown(t){let e=[...this.refs.dial.querySelectorAll(".zx-time-picker__mark")],i=t.target.closest?.(".zx-time-picker__mark"),r=e.indexOf(i);if(r<0)return;let n={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[t.key],o=null;n!==void 0?o=(r+n+e.length)%e.length:t.key==="Home"?o=0:t.key==="End"&&(o=e.length-1),o!==null&&(t.preventDefault(),this._pick(Number(e[o].dataset.value)),this.refs.dial.querySelector(`[data-value="${e[o].dataset.value}"]`)?.focus())}_syncClock(){if(!this._clock)return;let t=this._clockUnit==="h";if(this._clock.hidden=!this._clockOpen,this.refs.clockToggle.setAttribute("aria-expanded",String(this._clockOpen)),this.refs.headHour.textContent=K(this._display.h),this.refs.headMinute.textContent=K(this._display.m),this.refs.headHour.setAttribute("aria-pressed",String(t)),this.refs.headMinute.setAttribute("aria-pressed",String(!t)),this.refs.dial.setAttribute("aria-label",t?"Hour":"Minutes"),!this._clockOpen)return;let e=t?this._display.h:this._display.m,i=t?yr():xr(),r=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(r.length!==i.length||this.refs.dial.dataset.unit!==this._clockUnit){for(let l of r)l.remove();this.refs.dial.dataset.unit=this._clockUnit,this.refs.dial.append(...i.map(l=>this._buildMark(l,e)))}else i.forEach((l,c)=>this._syncMark(r[c],l,e));let n=t&&!vr(e)?"inner":"outer",o=t?e%12*30:e*6;this.refs.hand.dataset.ring=n,this.refs.hand.style.setProperty("--zx-clock-angle",`${o}deg`)}_buildMark(t,e){let i=a("button",{class:"zx-time-picker__mark",type:"button",role:"radio",dataset:{value:String(t.value),ring:t.ring}},t.label);return i.style.setProperty("--zx-clock-angle",`${t.angle}deg`),this._syncMark(i,t,e),i}_syncMark(t,e,i){let r=e.value===i;t.setAttribute("aria-checked",String(r)),t.tabIndex=r?0:-1}};function yr(){let s=[];for(let t=1;t<=12;t+=1)s.push({value:t,label:String(t),angle:t%12*30,ring:"outer"});for(let t=0;t<12;t+=1){let e=t===0?0:12+t;s.push({value:e,label:K(e),angle:t*30,ring:"inner"})}return s}function xr(){let s=[];for(let t=0;t<60;t+=br)s.push({value:t,label:K(t),angle:t*6,ring:"outer"});return s}function vr(s){return s>=1&&s<=12}function Si(s){return s instanceof Date&&!Number.isNaN(s.getTime())?{h:s.getHours(),m:s.getMinutes(),s:s.getSeconds()}:!s||typeof s!="object"?null:{h:it(s.h,0,23),m:it(s.m,0,59),s:it(s.s,0,59)}}function it(s,t,e){let i=Number.parseInt(String(s??""),10);return Number.isFinite(i)?Math.max(t,Math.min(e,i)):t}function wr(s){let t=Math.round(Number(s));return Number.isFinite(t)&&t>0&&t<=59?t:5}function K(s){return String(s).padStart(2,"0")}function kr(s,t){return s.h===t.h&&s.m===t.m&&s.s===t.s}var st=class extends g{static cssName="date-picker";static defaults={value:null,min:null,max:null,weekStart:1,showWeekNumbers:!1,time:!1};render(){let t=this.el??a("div");this._min=T(Lt(this.options.min)),this._max=T(Lt(this.options.max)),this._value=this._normalizeValue(Lt(this.options.value)),this._focused=T(this._value)??this._clampFocus(T(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=Ar(this.options.weekStart),this._quickOpen=!1,this._timePicker=null;let e=a("div",{class:"zx-date-picker__surface"},a("div",{class:"zx-date-picker__header"},a("button",{ref:"previous",class:"zx-date-picker__nav",type:"button",ariaLabel:"Previous month"},m("chevron-left")),a("button",{ref:"heading",class:"zx-date-picker__heading",type:"button",ariaExpanded:"false","aria-haspopup":"grid"}),a("button",{ref:"next",class:"zx-date-picker__nav",type:"button",ariaLabel:"Next month"},m("chevron-right"))),a("div",{ref:"quickPanel",class:"zx-date-picker__quick",hidden:!0},a("div",{class:"zx-date-picker__quick-header"},a("button",{ref:"quickPrevious",class:"zx-date-picker__nav",type:"button",ariaLabel:"Previous year"},m("chevron-left")),a("span",{ref:"quickYear",class:"zx-date-picker__quick-year",ariaLive:"polite"}),a("button",{ref:"quickNext",class:"zx-date-picker__nav",type:"button",ariaLabel:"Next year"},m("chevron-right"))),a("div",{ref:"quickGrid",class:"zx-date-picker__quick-grid",role:"grid"})),a("table",{ref:"grid",class:"zx-date-picker__grid",role:"grid",ariaLabel:"Calendar"},a("thead",{ref:"weekdays"}),a("tbody",{ref:"days"})));return this._content=e,t.append(e),this.listen(this.refs.previous,"click",()=>this._pageMonth(-1)),this.listen(this.refs.next,"click",()=>this._pageMonth(1)),this.listen(this.refs.heading,"click",()=>this._toggleQuickPick()),this.listen(this.refs.quickPrevious,"click",()=>this._stepQuickYear(-1)),this.listen(this.refs.quickNext,"click",()=>this._stepQuickYear(1)),this.listen(this.refs.quickGrid,"click",i=>this._onQuickClick(i)),this.listen(this.refs.quickGrid,"keydown",i=>this._onQuickKeydown(i)),this.listen(this.refs.days,"click",i=>this._onDayClick(i)),this.listen(this.refs.days,"keydown",i=>this._onDayKeydown(i)),this._renderWeekdays(),this._renderCalendar(),this.options.time&&(this._timePicker=new Ot(null,{value:this._value,seconds:!1}),this._timePicker.on("change",i=>{let r=i.detail.time,n=this._value??this._focused,o=new Date(n.getTime());o.setHours(r.h,r.m,r.s,0),this.set(o)}),e.append(this._timePicker.el)),t}get(){return be(this._value)}set(t,{silent:e=!1}={}){let i=this._normalizeValue(Lt(t));return this._value=i,i&&(this._focused=T(i),this._viewYear=i.getFullYear(),this._viewMonth=i.getMonth()),this._timePicker?.set(i,{silent:!0}),this._renderCalendar(),e||this.emit("change",{date:be(this._value)}),this}focus(){return this._closeQuickPick(),this._buttonForDate(this._focused)?.focus(),this}destroy(){this._timePicker?.destroy(),this._timePicker=null,this._content?.remove(),super.destroy()}_normalizeValue(t){if(!t)return null;let e=new Date(t.getTime()),i=T(e);return this._min&&i<this._min&&zi(e,this._min),this._max&&i>this._max&&zi(e,this._max),e}_clampFocus(t){return this._min&&t<this._min?new Date(this._min.getTime()):this._max&&t>this._max?new Date(this._max.getTime()):t}_renderWeekdays(){let t=a("tr");this.options.showWeekNumbers&&t.append(a("th",{class:"zx-date-picker__week-heading",scope:"col",ariaLabel:"Week number"},"#"));let e=new Date(2023,0,1);for(let i=0;i<7;i+=1){let r=k(e,(this._weekStart+i)%7);t.append(a("th",{scope:"col",ariaLabel:x(r,"%A")},x(r,"%a")))}this.refs.weekdays.replaceChildren(t)}_renderCalendar(){if(!this.refs?.days)return;let t=new Date(this._viewYear,this._viewMonth,1),e=(t.getDay()-this._weekStart+7)%7,i=k(t,-e);this.refs.heading.textContent=x(t,"%B %Y"),this.refs.heading.setAttribute("aria-label",`Choose month and year, ${x(t,"%B %Y")}`);let r=[];for(let n=0;n<6;n+=1){let o=k(i,n*7),l=a("tr");this.options.showWeekNumbers&&l.append(a("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:`Week ${Di(o)}`},String(Di(o))));for(let c=0;c<7;c+=1){let u=k(o,c),h=!!(this._value&&S(u,this._value)),p=!this._inRange(u),f=a("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:S(u,this._focused)?0:-1,ariaSelected:String(h),ariaDisabled:String(p),ariaCurrent:S(u,new Date)?"date":null,ariaLabel:`${x(u,"%e")} ${x(u,"%B %Y")}`,dataset:{date:x(u,"%Y-%m-%d"),otherMonth:u.getMonth()===this._viewMonth?null:"true"}},x(u,"%e"));l.append(a("td",{role:"presentation"},f))}r.push(l)}this.refs.days.replaceChildren(...r),this._quickOpen&&this._renderQuickPick()}_onDayClick(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let i=N(e.dataset.date,"%Y-%m-%d");i&&this._inRange(i)&&this._selectDate(i)}_onDayKeydown(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let i=N(e.dataset.date,"%Y-%m-%d");if(!i)return;let r=null;if(t.key==="ArrowLeft")r=k(i,-1);else if(t.key==="ArrowRight")r=k(i,1);else if(t.key==="ArrowUp")r=k(i,-7);else if(t.key==="ArrowDown")r=k(i,7);else if(t.key==="PageUp")r=Y(i,t.shiftKey?-12:-1);else if(t.key==="PageDown")r=Y(i,t.shiftKey?12:1);else if(t.key==="Home")r=k(i,-((i.getDay()-this._weekStart+7)%7));else if(t.key==="End")r=k(i,6-(i.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._inRange(i)&&this._selectDate(i);return}r&&(t.preventDefault(),this._moveFocus(r))}_moveFocus(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;this._focused=T(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._renderCalendar(),e&&this._emitMonthChange(),this._buttonForDate(t)?.focus()}_selectDate(t){let e=new Date(t.getTime()),i=this._timePicker?.get();i?e.setHours(i.h,i.m,i.s,0):this._value&&e.setHours(this._value.getHours(),this._value.getMinutes(),this._value.getSeconds(),this._value.getMilliseconds());let r=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;this._value=e,this._focused=T(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._timePicker?.set(e,{silent:!0}),this._renderCalendar(),r&&this._emitMonthChange(),this.emit("change",{date:be(e)})}_pageMonth(t){this._closeQuickPick();let e=Y(this._focused,t);this._focused=T(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._renderCalendar(),this._emitMonthChange()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_toggleQuickPick(){if(this._quickOpen){this._closeQuickPick(),this.refs.heading.focus();return}this._quickOpen=!0,this.refs.quickPanel.hidden=!1,this.refs.heading.setAttribute("aria-expanded","true"),this._renderQuickPick(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_closeQuickPick(){this._quickOpen&&(this._quickOpen=!1,this.refs.quickPanel.hidden=!0,this.refs.heading.setAttribute("aria-expanded","false"))}_renderQuickPick(){this.refs.quickYear.textContent=String(this._viewYear);let t=[];for(let e=0;e<12;e+=1){let i=new Date(this._viewYear,e,1);t.push(a("button",{class:"zx-date-picker__quick-month",type:"button",role:"gridcell",tabindex:e===this._viewMonth?0:-1,ariaSelected:String(e===this._viewMonth),dataset:{month:e}},x(i,"%b")))}this.refs.quickGrid.replaceChildren(...t)}_stepQuickYear(t){this._viewYear+=t,this._renderQuickPick(),this._emitMonthChange(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_onQuickClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.quickGrid.contains(e)||this._chooseQuickMonth(Number(e.dataset.month))}_onQuickKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.quickGrid.contains(e))return;let i=Number(e.dataset.month),r=null;if(t.key==="ArrowLeft")r=i-1;else if(t.key==="ArrowRight")r=i+1;else if(t.key==="ArrowUp")r=i-3;else if(t.key==="ArrowDown")r=i+3;else if(t.key==="Home")r=0;else if(t.key==="End")r=11;else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._chooseQuickMonth(i);return}else if(t.key==="Escape"){t.preventDefault(),this._closeQuickPick(),this.refs.heading.focus();return}if(r===null)return;t.preventDefault(),r=Math.max(0,Math.min(11,r));let n=this.refs.quickGrid.querySelectorAll("[data-month]");for(let o of n)o.tabIndex=Number(o.dataset.month)===r?0:-1;n[r]?.focus()}_chooseQuickMonth(t){let e=new Date(this._viewYear,t,Math.min(this._focused.getDate(),new Date(this._viewYear,t+1,0).getDate()));this._focused=T(e),this._viewMonth=t,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(t){let e=T(t);return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_buttonForDate(t){return this.refs.days.querySelector(`[data-date="${x(t,"%Y-%m-%d")}"]`)}};function Lt(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function T(s){return s?new Date(s.getFullYear(),s.getMonth(),s.getDate()):null}function be(s){return s?new Date(s.getTime()):null}function zi(s,t){s.setFullYear(t.getFullYear(),t.getMonth(),t.getDate())}function Ar(s){let t=Number(s);return Number.isInteger(t)&&t>=0&&t<=6?t:Ft()}function Di(s){let t=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-i.getTime())/864e5+1)/7)}var Pt=class extends st{static cssName="month-picker";static defaults={value:null,min:null,max:null};render(){let t=this.el??a("div");this._min=Vt(jt(this.options.min)),this._max=Vt(jt(this.options.max)),this._value=this._normalizeMonth(jt(this.options.value));let e=this._value??Vt(new Date);this._year=e.getFullYear(),this._focusedMonth=e.getMonth();let i=a("div",{class:"zx-month-picker__surface"},a("div",{class:"zx-month-picker__header"},a("button",{ref:"previousYear",class:"zx-month-picker__nav",type:"button",ariaLabel:"Previous year"},m("chevron-left")),a("span",{ref:"year",class:"zx-month-picker__year",ariaLive:"polite"}),a("button",{ref:"nextYear",class:"zx-month-picker__nav",type:"button",ariaLabel:"Next year"},m("chevron-right"))),a("div",{ref:"grid",class:"zx-month-picker__grid",role:"grid",ariaLabel:"Choose month"}));return this._content=i,t.append(i),this.listen(this.refs.previousYear,"click",()=>this._stepYear(-1)),this.listen(this.refs.nextYear,"click",()=>this._stepYear(1)),this.listen(this.refs.grid,"click",r=>this._onMonthClick(r)),this.listen(this.refs.grid,"keydown",r=>this._onMonthKeydown(r)),this._renderMonths(),t}get(){return this._value?new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeMonth(jt(t)),this._value&&(this._year=this._value.getFullYear(),this._focusedMonth=this._value.getMonth()),this._renderMonths(),e||this.emit("change",{date:this.get()}),this}focus(){return this._button(this._focusedMonth)?.focus(),this}destroy(){this._content?.remove(),super.destroy()}_normalizeMonth(t){if(!t)return null;let e=Vt(t);return this._min&&e<this._min&&(e=new Date(this._min.getTime())),this._max&&e>this._max&&(e=new Date(this._max.getTime())),e}_renderMonths(){if(!this.refs?.grid)return;this.refs.year.textContent=String(this._year);let t=[];for(let e=0;e<12;e+=1){let i=new Date(this._year,e,1),r=!!(this._value&&Sr(i,this._value));t.push(a("button",{class:"zx-month-picker__month",type:"button",role:"gridcell",tabindex:e===this._focusedMonth?0:-1,ariaSelected:String(r),ariaDisabled:String(!this._inRange(i)),ariaLabel:x(i,"%B %Y"),dataset:{month:e}},x(i,"%b")))}this.refs.grid.replaceChildren(...t)}_stepYear(t){this._year+=t,this._renderMonths()}_onMonthClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.grid.contains(e)||this._selectMonth(Number(e.dataset.month))}_onMonthKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.grid.contains(e))return;let i=Number(e.dataset.month),r=null;if(t.key==="ArrowLeft")r=-1;else if(t.key==="ArrowRight")r=1;else if(t.key==="ArrowUp")r=-3;else if(t.key==="ArrowDown")r=3;else if(t.key==="Home")r=-(i%3);else if(t.key==="End")r=2-i%3;else if(t.key==="PageUp"){t.preventDefault(),this._stepYear(-1),this.focus();return}else if(t.key==="PageDown"){t.preventDefault(),this._stepYear(1),this.focus();return}else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._selectMonth(i);return}if(r===null)return;t.preventDefault();let n=this._year*12+i+r;this._year=Math.floor(n/12),this._focusedMonth=(n%12+12)%12,this._renderMonths(),this.focus()}_selectMonth(t){let e=new Date(this._year,t,1);this._inRange(e)&&(this._focusedMonth=t,this._value=e,this._renderMonths(),this.emit("change",{date:this.get()}))}_inRange(t){return!(this._min&&t<this._min)&&!(this._max&&t>this._max)}_button(t){return this.refs.grid.querySelector(`[data-month="${t}"]`)}};function jt(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function Vt(s){return s?new Date(s.getFullYear(),s.getMonth(),1):null}function Sr(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()}function Ci(){b.register("month",(s,t)=>{let e=s.own(new Pt(null,{...t.props??{},value:t.value})),i=!1,r=()=>{e.el.setAttribute("aria-disabled",String(i));for(let n of e.el.querySelectorAll("button"))n.disabled=i};return s.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>s.emit("change",{value:n.detail.date})),{el:e.el,get:()=>e.get(),set:n=>{e.set(n instanceof Date?n:null,{silent:!0}),r()},focus:()=>e.focus(),setDisabled:n=>{i=!!n,r()}}})}var zr=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top"]);function R(s,t,e={}){if(!(s instanceof Element)||!(t instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let i=zr.has(e.placement)?e.placement:"bottom-start",r=Number(e.offset??4),n=e.flip??!0,o=e.matchWidth??!1,l=s.getAttribute("style"),c=t.getAttribute("style"),u=t.getAttribute("popover"),h=!1,p=null,f=()=>{},d=()=>{};if(t.setAttribute("popover","manual"),typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a")){let y=`--${w("zx-a")}`;s.style.setProperty("anchor-name",y),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.setProperty("position-anchor",y),t.style.setProperty("position-area",Mi(i)),t.style.setProperty("inset-area",Mi(i)),t.style.setProperty("position-try-fallbacks",n?"flip-block, flip-inline, flip-block flip-inline":"none"),t.style.setProperty(i.startsWith("top")?"margin-block-end":"margin-block-start",`${r}px`),f=()=>{o&&(t.style.minWidth=`${s.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(p=new ResizeObserver(f),p.observe(s))}else t.style.position="fixed",t.style.inset="auto",t.style.margin="0",f=()=>Dr(s,t,{placement:i,offset:r,flip:n,matchWidth:o}),window.addEventListener("scroll",f,{capture:!0,passive:!0}),window.addEventListener("resize",f,{passive:!0}),typeof ResizeObserver=="function"&&(p=new ResizeObserver(f),p.observe(s)),d=()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)};return Cr(t),f(),{update(){h||f()},destroy(){h||(h=!0,p?.disconnect(),d(),Mr(t),ye(s,"style",l),ye(t,"style",c),ye(t,"popover",u))}}}function Mi(s){return{"bottom-start":"block-end span-inline-end","bottom-end":"block-end span-inline-start","top-start":"block-start span-inline-end","top-end":"block-start span-inline-start",bottom:"block-end",top:"block-start"}[s]}function Dr(s,t,{placement:e,offset:i,flip:r,matchWidth:n}){let o=s.getBoundingClientRect();n&&(t.style.minWidth=`${o.width}px`);let l=t.getBoundingClientRect(),c=document.documentElement.clientWidth||window.innerWidth,u=document.documentElement.clientHeight||window.innerHeight,h=e,p=e.startsWith("bottom"),f=o.bottom+i,d=o.top-i-l.height;r&&(p&&f+l.height>u&&d>=0?h=e.replace("bottom","top"):!p&&d<0&&f+l.height<=u&&(h=e.replace("top","bottom")));let _;h.endsWith("-end")?_=o.right-l.width:h.endsWith("-start")?_=o.left:_=o.left+(o.width-l.width)/2;let y=h.startsWith("bottom")?f:d;t.style.left=`${Math.round(ht(_,0,Math.max(0,c-l.width)))}px`,t.style.top=`${Math.round(ht(y,0,Math.max(0,u-l.height)))}px`}function Cr(s){if(typeof s.showPopover=="function")try{s.showPopover()}catch{}}function Mr(s){if(typeof s.hidePopover=="function")try{s.hidePopover()}catch{}}function ye(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}var Ir=6,Oi=864e5;function _t(s,t){let e=C(U(s)),i=C(U(t));return e&&i&&e.getTime()>i.getTime()?{start:i,end:e}:{start:e,end:i}}function Rt(s,t){let e=_t(s,t);return!e.start||!e.end?0:Math.round((Ei(e.end)-Ei(e.start))/Oi)}function Tr(s,t,e){let i=C(U(s));if(!i)return null;let r=_t(t,e);return!r.start&&!r.end?null:r.end?r.start?i.getTime()<r.start.getTime()||i.getTime()>r.end.getTime()?null:S(i,r.start)?"start":S(i,r.end)?"end":"middle":S(i,r.end)?"end":null:S(i,r.start)?"start":null}function Ht(s,t={}){let e=C(U(t.min)),i=C(U(t.max)),r=Bt(t.minNights)??0,n=Bt(t.maxNights),{start:o,end:l}=_t(s?.start,s?.end);return o&&(o=ve(o,e,i)),l&&(l=ve(l,e,i)),!o||!l?{start:o,end:l}:(n!==null&&Rt(o,l)>n&&(l=k(o,n)),r>0&&Rt(o,l)<r&&(l=k(o,r),i&&l.getTime()>i.getTime()&&(l=new Date(i.getTime()),o=k(l,-r),e&&o.getTime()<e.getTime()))?{start:null,end:null}:{start:o,end:l})}var qt=class extends g{static cssName="date-range-picker";static defaults={start:null,end:null,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??a("div");this.el=t,this._rootAttributes=Vr(t,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=C(U(this.options.min)),this._max=C(U(this.options.max)),this._minNights=Bt(this.options.minNights)??0,this._maxNights=Bt(this.options.maxNights),this._weekStart=Or(this.options.weekStart),this._monthCount=Lr(this.options.months),this._presets=Fr(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let e=Ht({start:this.options.start,end:this.options.end},this._bounds());this._start=e.start,this._end=e.end,this._picking=!!(e.start&&!e.end),this._remember(),this._focused=H(this._start)??this._clampFocus(C(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),t.setAttribute("role","group"),t.setAttribute("aria-label",A("daterange.label","Date range")),t.dataset.months=String(this._monthCount),this._presets.length&&(t.dataset.presets="true");let i=a("div",{class:"zx-date-range-picker__surface"},this._presets.length?a("div",{ref:"presets",class:"zx-date-range-picker__presets",role:"group",ariaLabel:A("daterange.presets","Date range presets")},this._presets.map(n=>a("button",{class:"zx-date-range-picker__preset",type:"button",dataset:{preset:n.name}},n.label))):null,a("div",{ref:"calendars",class:"zx-date-range-picker__calendars"})),r=a("div",{ref:"status",class:"zx-date-range-picker__status",role:"status",ariaLive:"polite"});return this._nodes=[i,r],t.append(i,r),this.refs.presets&&this.listen(this.refs.presets,"click",n=>this._onPresetClick(n)),this.listen(this.refs.calendars,"click",n=>this._onCalendarClick(n)),this.listen(this.refs.calendars,"keydown",n=>this._onDayKeydown(n)),this.listen(this.refs.calendars,"mouseover",n=>this._onDayHover(n)),this.listen(this.refs.calendars,"mouseleave",()=>this._setHover(null)),this._renderCalendars(),this._announce(),t}get(){return{start:H(this._start),end:H(this._end)}}set(t={},{silent:e=!1}={}){let i=Ht({start:t?.start??null,end:t?.end??null},this._bounds());return this._start=i.start,this._end=i.end,this._picking=!!(i.start&&!i.end),this._remember(),this._hover=null,i.start?(this._focused=H(i.start),this._setView(i.start)):this._paint(),this._announce(),e||this.emit("change",this.get()),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}focus(){return this._buttonForDate(this._focused)?.focus(),this}enable(){return this._disabled=!1,this._paint(),this._syncDisabled(),this}disable(){return this._disabled=!0,this._hover=null,this._paint(),this._syncDisabled(),this}destroy(){for(let t of this._nodes??[])t.remove();this._nodes=[],this._dayCells=[],Pr(this.el,this._rootAttributes??new Map),super.destroy()}_bounds(){return{min:this._min,max:this._max,minNights:this._minNights,maxNights:this._maxNights}}_selectable(t){let e=C(t);if(!e||this._min&&e.getTime()<this._min.getTime()||this._max&&e.getTime()>this._max.getTime())return!1;if(!this._picking||!this._start||e.getTime()<=this._start.getTime())return!0;let i=Rt(this._start,e);return!(i<this._minNights||this._maxNights!==null&&i>this._maxNights)}_choose(t){let e=C(t);if(this._disabled||!e||!this._selectable(e))return;this._picking&&this._start&&e.getTime()>this._start.getTime()?(this._end=e,this._picking=!1,this._remember()):(this._start=e,this._end=null,this._picking=!0),this._focused=e,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),this._picking||this.emit("change",this.get())}_remember(){let t=!!(this._start&&this._end);this._committedStart=t?H(this._start):null,this._committedEnd=t?H(this._end):null}_abandon(){return this._picking?(this._start=H(this._committedStart),this._end=H(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(t){return ve(t,this._min,this._max)}_visibleMonthCount(){let t=this.refs.calendars?.children??[],e=0;for(let i of t)i.getClientRects().length>0&&(e+=1);return e||this._monthCount}_setView(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;if(this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),!e){this._paint();return}this._renderCalendars(),this._emitMonthChange()}_ensureVisible(t){let e=this._visibleMonthCount(),i=Ni(t)-(this._viewYear*12+this._viewMonth);if(i>=0&&i<e)return!1;let r=i<0?i:i-(e-1),n=new Date(this._viewYear,this._viewMonth+r,1);return this._viewYear=n.getFullYear(),this._viewMonth=n.getMonth(),!0}_pageView(t){if(this._disabled)return;let e=new Date(this._viewYear,this._viewMonth+t,1);this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._focused=this._focusInView(this._focused),this._renderCalendars(),this._emitMonthChange()}_focusInView(t){let e=this._visibleMonthCount(),i=Ni(t)-(this._viewYear*12+this._viewMonth);if(i>=0&&i<e)return t;let r=new Date(this._viewYear,this._viewMonth+1,0).getDate();return new Date(this._viewYear,this._viewMonth,Math.min(t.getDate(),r))}_moveFocus(t){let e=C(t);this._focused=e,this._ensureVisible(e)?(this._renderCalendars(),this._emitMonthChange()):this._paint(),this._buttonForDate(e)?.focus()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_onPresetClick(t){let e=t.target?.closest?.("[data-preset]");if(!e||this._disabled)return;let i=this._presets.find(n=>n.name===e.dataset.preset);if(!i)return;let r=i.range();this.set({start:r?.start??null,end:r?.end??null},{silent:!0}),this.emit("select",this.get()),this.emit("change",this.get())}_onCalendarClick(t){let e=t.target,i=e?.closest?.("[data-nav]");if(i){this._pageView(i.dataset.nav==="next"?1:-1);return}let r=this._cellFor(e);r&&this._choose(r.date)}_onDayHover(t){let e=this._cellFor(t.target);this._setHover(e?e.date:null)}_setHover(t){if(this._disabled||!this._picking)return;let e=t?C(t):null;!e&&!this._hover||e&&this._hover&&S(e,this._hover)||(this._hover=e,this._paint())}_onDayKeydown(t){let e=this._cellFor(t.target);if(!e)return;let i=e.date,r=null;if(t.key==="ArrowLeft")r=k(i,-1);else if(t.key==="ArrowRight")r=k(i,1);else if(t.key==="ArrowUp")r=k(i,-7);else if(t.key==="ArrowDown")r=k(i,7);else if(t.key==="PageUp")r=Y(i,t.shiftKey?-12:-1);else if(t.key==="PageDown")r=Y(i,t.shiftKey?12:1);else if(t.key==="Home")r=k(i,-((i.getDay()-this._weekStart+7)%7));else if(t.key==="End")r=k(i,6-(i.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._choose(i);return}else if(t.key==="Escape"){if(!this._abandon())return;t.preventDefault(),t.stopPropagation();return}!r||this._disabled||(t.preventDefault(),this._moveFocus(r))}_renderCalendars(){if(!this.refs?.calendars)return;this._dayCells=[];let t=[];for(let e=0;e<this._monthCount;e+=1)t.push(this._renderMonth(new Date(this._viewYear,this._viewMonth+e,1)));this.refs.calendars.replaceChildren(...t),this._paint(),this._syncDisabled()}_renderMonth(t){let e=x(t,"%B %Y"),i=(t.getDay()-this._weekStart+7)%7,r=k(t,-i),n=[];for(let o=0;o<Ir;o+=1){let l=k(r,o*7),c=a("tr"),u=jr(l,t);this.options.showWeekNumbers&&c.append(a("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:u?A("daterange.week","Week %1",[Fi(l)]):null},u?String(Fi(l)):""));for(let h=0;h<7;h+=1){let p=k(l,h),f=a("td",{role:"presentation"});if(p.getMonth()===t.getMonth()&&p.getFullYear()===t.getFullYear()){let d=a("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:x(p,"%Y-%m-%d")}},x(p,"%e"));f.append(d),this._dayCells.push({date:p,cell:f,button:d})}c.append(f)}n.push(c)}return a("div",{class:"zx-date-range-picker__month"},a("div",{class:"zx-date-range-picker__header"},a("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"previous"},ariaLabel:A("daterange.previousMonth","Previous month")},m("chevron-left")),a("div",{class:"zx-date-range-picker__caption",ariaHidden:"true"},e),a("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"next"},ariaLabel:A("daterange.nextMonth","Next month")},m("chevron-right"))),a("table",{class:"zx-date-range-picker__grid",role:"grid",ariaLabel:e},a("thead",{},this._weekdayRow()),a("tbody",{},...n)))}_weekdayRow(){let t=a("tr");this.options.showWeekNumbers&&t.append(a("th",{class:"zx-date-range-picker__week-heading",scope:"col",ariaLabel:A("daterange.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let i=0;i<7;i+=1){let r=k(e,(this._weekStart+i)%7);t.append(a("th",{scope:"col",ariaLabel:x(r,"%A")},x(r,"%a")))}return t}_paint(){let t=new Date,e=null;for(let i of this._dayCells)S(i.date,this._focused)&&(e=i);e||(e=this._dayCells[0]??null);for(let i of this._dayCells){let{date:r,cell:n,button:o}=i,l=this._dayState(r);xe(n,"range",l.range),xe(n,"rangeEdge",l.edge),xe(o,"range",l.range),o.tabIndex=i===e?0:-1,o.setAttribute("aria-selected",String(l.range!==null&&l.range!=="preview")),o.setAttribute("aria-disabled",String(!this._selectable(r))),o.setAttribute("aria-label",this._dayLabel(r,l.range)),S(r,t)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(t){if(this._start&&this._end){let i=Tr(t,this._start,this._end);if(!i)return{range:null,edge:null};let r=S(this._start,this._end);return i==="start"?{range:i,edge:r?"both":"start"}:i==="end"?{range:i,edge:r?"both":"end"}:{range:i,edge:null}}if(!this._start)return{range:null,edge:null};let e=this._previewEnd();return S(t,this._start)?{range:"start",edge:e?"start":"both"}:e?t.getTime()>this._start.getTime()&&t.getTime()<=e.getTime()?{range:"preview",edge:S(t,e)?"end":null}:{range:null,edge:null}:{range:null,edge:null}}_previewEnd(){if(!this._picking||!this._start||this._disabled)return null;let t=this._hover??this._focused;if(!t)return null;let e=C(t);return e.getTime()<=this._start.getTime()?null:this._selectable(e)?e:null}_dayLabel(t,e){let i=x(t,"%A, %e %B %Y");return e==="start"?`${i}, ${A("daterange.day.start","range start")}`:e==="end"?`${i}, ${A("daterange.day.end","range end")}`:e==="middle"?`${i}, ${A("daterange.day.middle","in selected range")}`:i}_syncDisabled(){this.el.setAttribute("aria-disabled",String(this._disabled));for(let t of this.el.querySelectorAll("button"))t.disabled=this._disabled}_announce(){this.refs?.status&&(this.refs.status.textContent=this._selectionLabel())}_selectionLabel(){if(!this._start)return A("daterange.status.empty","No date range selected");if(!this._end)return A("daterange.status.start","%1 selected, choose an end date",[x(this._start,"%e %B %Y")]);let t=Rt(this._start,this._end),e=t===1?A("daterange.night","1 night"):A("daterange.nights","%1 nights",[t]);return`${Nr(this._start,this._end)}, ${e}`}_cellFor(t){let e=t?.closest?.("[data-date]");return e?this._dayCells.find(i=>i.button===e)??null:null}_buttonForDate(t){return this._dayCells.find(e=>S(e.date,t))?.button??null}};function Er(){return[{name:"today",label:A("daterange.preset.today","Today"),range:()=>Ii(F())},{name:"yesterday",label:A("daterange.preset.yesterday","Yesterday"),range:()=>Ii(k(F(),-1))},{name:"last7",label:A("daterange.preset.last7","Last 7 days"),range:()=>({start:k(F(),-6),end:F()})},{name:"last30",label:A("daterange.preset.last30","Last 30 days"),range:()=>({start:k(F(),-29),end:F()})},{name:"thisMonth",label:A("daterange.preset.thisMonth","This month"),range:()=>Ti(F(),0)},{name:"lastMonth",label:A("daterange.preset.lastMonth","Last month"),range:()=>Ti(F(),-1)},{name:"thisQuarter",label:A("daterange.preset.thisQuarter","This quarter"),range:()=>{let s=F(),t=Math.floor(s.getMonth()/3)*3;return{start:new Date(s.getFullYear(),t,1),end:new Date(s.getFullYear(),t+3,0)}}},{name:"thisYear",label:A("daterange.preset.thisYear","This year"),range:()=>{let s=F();return{start:new Date(s.getFullYear(),0,1),end:new Date(s.getFullYear(),11,31)}}}]}function A(s,t,e){let i=E(s);return M(i===s?t:i,e)}function Nr(s,t){if(S(s,t))return x(s,"%e %B %Y");let e=x(t,"%e %B %Y");return s.getFullYear()!==t.getFullYear()?`${x(s,"%e %B %Y")} \u2013 ${e}`:s.getMonth()!==t.getMonth()?`${x(s,"%e %B")} \u2013 ${e}`:`${x(s,"%e")} \u2013 ${e}`}function Fr(s){return s===!0?Er():Array.isArray(s)?s.filter(t=>t&&typeof t.range=="function").map((t,e)=>({name:String(t.name??`preset-${e}`),label:String(t.label??t.name??""),range:t.range})):[]}function F(){return C(new Date)}function Ii(s){return{start:s,end:new Date(s.getTime())}}function Ti(s,t){return{start:new Date(s.getFullYear(),s.getMonth()+t,1),end:new Date(s.getFullYear(),s.getMonth()+t+1,0)}}function U(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function C(s){return!s||Number.isNaN(s.getTime())?null:new Date(s.getFullYear(),s.getMonth(),s.getDate())}function H(s){return s?new Date(s.getTime()):null}function ve(s,t,e){return t&&s.getTime()<t.getTime()?new Date(t.getTime()):e&&s.getTime()>e.getTime()?new Date(e.getTime()):new Date(s.getTime())}function Ei(s){return Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())}function Ni(s){return s.getFullYear()*12+s.getMonth()}function Bt(s){if(s==null||s==="")return null;let t=Number(s);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):null}function Or(s){let t=Number(s);return Number.isInteger(t)&&t>=0&&t<=6?t:Ft()}function Lr(s){let t=Number(s);return Number.isInteger(t)&&t>=1&&t<=4?t:2}function jr(s,t){for(let e=0;e<7;e+=1){let i=k(s,e);if(i.getMonth()===t.getMonth()&&i.getFullYear()===t.getFullYear())return!0}return!1}function Fi(s){let t=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-i.getTime())/Oi+1)/7)}function xe(s,t,e){e==null?delete s.dataset[t]:s.dataset[t]=e}function Vr(s,t){return new Map(t.map(e=>[e,s.getAttribute(e)]))}function Pr(s,t){for(let[e,i]of t)i===null?s.removeAttribute(e):s.setAttribute(e,i)}var Rr={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function Li(s,t,e){let i=String(s??"").trim();if(i==="")return{start:null,end:null};let r=String(e??" \u2013 "),n=r.trim(),o=n!==""&&String(t).includes(n)&&/^\s|\s$/.test(r),l=o?"\\s+":"\\s*",c=o?"(?:\\s+|$)":"\\s*",u=n===""?[i]:i.split(new RegExp(`${l}${re(n)}${c}`));if(u.length>2)return null;let h=N(u[0].trim(),t);if(!h)return null;if(u.length===1)return{start:h,end:new Date(h.getTime())};if(u[1].trim()==="")return{start:h,end:null};let p=N(u[1].trim(),t);return p?_t(h,p):null}function Hr(s,t,e){let i=s?.start??null,r=s?.end??null;return!i&&!r?"":r?i?`${x(i,t)}${e}${x(r,t)}`:x(r,t):x(i,t)}var $t=class extends g{static cssName="date-range-box";static defaults={start:null,end:null,format:"%d.%m.%Y",separator:" \u2013 ",placeholder:null,clearable:!0,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??a("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._format=String(this.options.format||"%d.%m.%Y"),this._separator=String(this.options.separator??" \u2013 "),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._range=this._coerce({start:this.options.start,end:this.options.end});let e=w("zx-date-range-box-popover"),i=a("div",{class:"zx-date-range-box__content"},a("div",{ref:"control",class:"zx-date-range-box__control"},a("input",{ref:"input",class:"zx-date-range-box__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??this._placeholder(),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),a("button",{ref:"clear",class:"zx-icon-btn zx-date-range-box__clear",type:"button",ariaLabel:ji("daterange.clear","Clear date range")},m("x",{size:13})),a("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:ji("daterange.choose","Choose date range"),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},m("calendar"))),a("div",{ref:"popover",id:e,class:"zx-date-range-box__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=i,t.append(i),this._picker=new qt(null,{start:this._range.start,end:this._range.end,min:this.options.min,max:this.options.max,months:this.options.months,weekStart:this.options.weekStart,showWeekNumbers:this.options.showWeekNumbers,minNights:this.options.minNights,maxNights:this.options.maxNights,presets:this.options.presets}),this.refs.popover.append(this._picker.el),this._picker.on("select",r=>{this._range={start:r.detail.start,end:r.detail.end},this._setValid(),this._syncDisplay()}),this._picker.on("change",r=>{this._apply({start:r.detail.start,end:r.detail.end},{push:!1}),r.detail.start&&r.detail.end&&this._close(!0)}),this.listen(this.refs.input,"blur",()=>{this._open||this._commitText()}),this.listen(this.refs.input,"keydown",r=>this._onInputKeydown(r)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",r=>{r.key==="ArrowDown"&&(r.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.clear(),this.focus()}),this.listen(document,"keydown",r=>{!this._open||r.key!=="Escape"||(r.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",r=>{this._open&&!t.contains(r.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return t==="seconds"?{start:this._range.start?Math.floor(this._range.start.getTime()/1e3):null,end:this._range.end?Math.floor(this._range.end.getTime()/1e3):null}:{start:this._range.start?new Date(this._range.start.getTime()):null,end:this._range.end?new Date(this._range.end.getTime()):null}}set(t,{silent:e=!1}={}){return this._apply(this._coerce(t),{silent:e}),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}open(){return this._disabled||this._open?this:(this._picker.set(this._range,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=R(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),we(this.el,"data-state",this._originalState),we(this.el,"aria-disabled",this._originalAriaDisabled),super.destroy()}_apply(t,{silent:e=!1,push:i=!0}={}){this._range=t,i&&this._picker?.set(this._range,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",this.get())}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set({start:null,end:null});return}let e=Li(t,this._format,this._separator);if(!e){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:t});return}this._apply(this._clamp(e))}_coerce(t){return t==null?{start:null,end:null}:typeof t=="string"?this._clamp(Li(t,this._format,this._separator)??{start:null,end:null}):Array.isArray(t)?this._clamp({start:this._toDate(t[0]),end:this._toDate(t[1])}):typeof t!="object"?{start:null,end:null}:this._clamp({start:this._toDate(t.start),end:this._toDate(t.end)})}_toDate(t){return t instanceof Date?Number.isNaN(t.getTime())?null:new Date(t.getTime()):typeof t=="number"&&Number.isFinite(t)?new Date(t*1e3):typeof t=="string"&&t.trim()!==""?N(t.trim(),this._format):null}_clamp(t){return Ht(t,{min:this.options.min,max:this.options.max,minNights:this.options.minNights,maxNights:this.options.maxNights})}_placeholder(){let t=this._format.replace(/%[demYy]/g,e=>Rr[e]??e);return`${t}${this._separator}${t}`}_syncDisplay(){this.refs.input.value=Hr(this._range,this._format,this._separator),this.refs.clear.hidden=!this.options.clearable||!(this._range.start||this._range.end)}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled)),this._disabled?this._picker?.disable():this._picker?.enable()}_setValid(){this.el.dataset.state==="invalid"&&we(this.el,"data-state",this._originalState),this.refs.input.removeAttribute("aria-invalid")}_close(t){this._open&&(this._position?.destroy(),this._position=null,this._open=!1,this.refs.popover.dataset.state="closed",this.refs.input.setAttribute("aria-expanded","false"),this.refs.toggle.setAttribute("aria-expanded","false"),t&&this.focus(),this.emit("close"))}};function ji(s,t,e){let i=E(s);return M(i===s?t:i,e)}function we(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}function Vi(){b.register("daterange",(s,t)=>{let e=s.own(new $t(null,{...t.props??{},disabled:!!t.disabled,start:t.value?.start??null,end:t.value?.end??null}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:{start:i.detail.start,end:i.detail.end}})),{el:e.el,get:()=>e.get(),set:i=>e.set(i,{silent:!0}),focus:()=>e.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var W=class extends g{static cssName="datebox";static defaults={value:null,format:"%d.%m.%Y",time:!1,min:null,max:null,placeholder:null,clearable:!0,disabled:!1};render(){let t=this.el??a("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._format=qr(this.options.format,this.options.time),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._min=Pi(this.options.min),this._max=Pi(this.options.max),this._value=this._normalizeValue(this.options.value);let e=w("zx-datebox-popover"),i=a("div",{class:"zx-datebox__content"},a("div",{ref:"control",class:"zx-datebox__control"},a("input",{ref:"input",class:"zx-datebox__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??Br(this._format),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),a("button",{ref:"clear",class:"zx-icon-btn zx-datebox__clear",type:"button",ariaLabel:"Clear date"},m("x",{size:13})),a("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:"Choose date","aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},m("calendar"))),a("div",{ref:"popover",id:e,class:"zx-datebox__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=i,t.append(i),this._picker=new st(null,{value:this._value,min:this._min,max:this._max,time:!!this.options.time}),this.refs.popover.append(this._picker.el),this._picker.on("change",r=>{this.set(r.detail.date),this.options.time||this._close(!0)}),this.listen(this.refs.input,"blur",()=>this._commitText()),this.listen(this.refs.input,"keydown",r=>this._onInputKeydown(r)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",r=>{r.key==="ArrowDown"&&(r.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.set(null),this.focus()}),this.listen(document,"keydown",r=>{!this._open||r.key!=="Escape"||(r.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",r=>{this._open&&!t.contains(r.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return this._value?t==="seconds"?Math.floor(this._value.getTime()/1e3):new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeValue(t),this._picker?.set(this._value,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",{date:this._copyValue()}),this}open(){return this._disabled||this._open?this:(this._picker.set(this._value,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=R(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set(null);return}let e=N(t,this._format);if(!e){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:t});return}this.set(e)}_normalizeValue(t){let e=null;return t instanceof Date&&!Number.isNaN(t.getTime())?e=new Date(t.getTime()):typeof t=="number"&&Number.isFinite(t)?e=new Date(t*1e3):typeof t=="string"&&(e=N(t,this._format)),!e||Number.isNaN(e.getTime())?null:pi(e,this._min,this._max)}_syncDisplay(){this.refs.input.value=this._value?x(this._value,this._format):"",this.refs.clear.hidden=!this.options.clearable||!this._value}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled))}_setValid(){this.el.dataset.state==="invalid"&&(this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState)),this.refs.input.removeAttribute("aria-invalid")}_close(t){this._open&&(this._position?.destroy(),this._position=null,this._open=!1,this.refs.popover.dataset.state="closed",this.refs.input.setAttribute("aria-expanded","false"),this.refs.toggle.setAttribute("aria-expanded","false"),t&&this.focus(),this.emit("close"))}_copyValue(){return this._value?new Date(this._value.getTime()):null}},Ri=function(t,e={}){return new W(t,{...e,time:!0})};function Pi(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function qr(s,t){let e=String(s||"%d.%m.%Y");return t&&!/%[HM]/.test(e)?`${e} %H:%M`:e}function Br(s){return s.replace(/%[demYyHMS]/g,t=>({"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY","%H":"HH","%M":"MM","%S":"SS"})[t]??t)}function qi(){Hi("date",s=>new W(null,s)),Hi("datetime",s=>Ri(null,s))}function Hi(s,t){b.register(s,(e,i)=>{let r=e.own(t({...i.props??{},value:i.value}));return e.listen(r.el,"change",n=>n.stopImmediatePropagation()),r.on("change",n=>e.emit("change",{value:n.detail.date})),{el:r.el,get:()=>r.get(),set:n=>r.set(n,{silent:!0}),focus:()=>r.focus(),setDisabled:n=>n?r.disable():r.enable()}})}var Yt=class extends g{static cssName="field-upload";static defaults={url:"",paramName:"upload",params:{},headers:{},multiple:!1,accept:null,maxSize:null,autoUpload:!0,preview:!0,http:null};render(){let t=this.el??a("div");this.el=t,this._ownedNodes=[],this._files=[],this._disabled=!1,this._running=!1,this._runId=0,this._xhr=null,this._transportController=null,this._previewUrl=null,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled");let e=w("zx-upload");return this._input=a("input",{class:"zx-field-upload__input",id:e,type:"file",multiple:!!this.options.multiple,accept:this.options.accept??void 0,tabIndex:-1}),this._dropzone=a("button",{class:"zx-field-upload__dropzone",type:"button",ariaControls:e,ariaLabel:this.options.multiple?"Choose files or drop them here":"Choose a file or drop it here"},a("span",{class:"zx-field-upload__prompt"},this.options.multiple?"Drop files here or choose files":"Drop a file here or choose a file"),a("span",{class:"zx-field-upload__hint"},$r(this.options))),this._preview=a("div",{class:"zx-field-upload__preview"}),this._progress=a("progress",{class:"zx-field-upload__progress",max:100,value:0,ariaLabel:"Upload progress"}),this._progressText=a("span",{class:"zx-field-upload__progress-text"},"0%"),this._abort=a("button",{class:"zx-btn zx-field-upload__abort",type:"button"},"Abort"),this._progressWrap=a("div",{class:"zx-field-upload__progress-wrap",hidden:!0},this._progress,this._progressText,this._abort),this._status=a("div",{class:"zx-field-upload__status",role:"status",ariaLive:"polite"}),this._ownedNodes.push(this._input,this._dropzone,this._preview,this._progressWrap,this._status),t.append(...this._ownedNodes),this.listen(this._dropzone,"click",()=>{!this._disabled&&!this._running&&this._input.click()}),this.listen(this._input,"change",()=>this._selectFiles(this._input.files)),this.listen(this._dropzone,"dragenter",i=>this._handleDragOver(i)),this.listen(this._dropzone,"dragover",i=>this._handleDragOver(i)),this.listen(this._dropzone,"dragleave",i=>{(!(i.relatedTarget instanceof Node)||!this._dropzone.contains(i.relatedTarget))&&this._setState("idle")}),this.listen(this._dropzone,"drop",i=>{i.preventDefault(),!(this._disabled||this._running)&&(this._setState("idle"),this._selectFiles(i.dataTransfer?.files??[]))}),this.listen(this._abort,"click",()=>this.abort()),this.setDisabled(!1),t}async upload(t=null){if(t!==null&&!this._setFiles(t)||this._disabled||this._running||this._files.length===0)return null;this._running=!0,this._runId+=1;let e=this._runId;this._setState("uploading"),this._progressWrap.hidden=!1,this._abort.hidden=!1,this._setProgress(0),this._status.textContent="Uploading\u2026";try{let i=this.options.http?await this._uploadInjected():await this._uploadXhr();return e!==this._runId?null:(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setProgress(100),this._setState("success"),this._status.textContent="Upload complete.",this.emit("success",{response:i}),i)}catch(i){if(e!==this._runId)return null;let r=i instanceof Error?i:new Error(String(i));return r.name==="AbortError"?(this._finishAbort(),null):(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("error"),this._status.textContent=r.message,this.emit("error",{error:r}),null)}}abort(){return this._running?(this._xhr?.abort(),this._transportController?.abort(),this._finishAbort(),this):this}clear(){return this._running&&this.abort(),this._files=[],this._input.value="",this._revokePreview(),this._preview.replaceChildren(),this._progress.value=0,this._progressText.textContent="0%",this._progressWrap.hidden=!0,this._status.textContent="",this._setState("idle"),this}setDisabled(t){return this._disabled=!!t,this._input.disabled=this._disabled,this._dropzone.disabled=this._disabled,this.el.dataset.disabled=String(this._disabled),this}_selectFiles(t){this._setFiles(t)&&(this._input.value="",this.options.autoUpload&&this.upload())}_setFiles(t){if(this._disabled||this._running)return!1;let e=Array.from(t??[]),i=this.options.multiple?e:e.slice(0,1);if(i.length===0)return!1;let r=i.find(o=>!Kr(o,this.options.accept));if(r)return this._selectionError(new Error(`${r.name} is not an accepted file type.`)),!1;let n=this.options.maxSize==null?null:i.find(o=>o.size>Number(this.options.maxSize));return n?(this._selectionError(new Error(`${n.name} exceeds the maximum file size.`)),!1):(this._files=i,this._renderPreview(),this._status.textContent=i.map(o=>o.name).join(", "),this._setState("selected"),this.emit("select",{files:this._files.slice()}),!0)}_handleDragOver(t){t.preventDefault(),!this._disabled&&!this._running&&this._setState("dragover")}_uploadInjected(){let t=this.options.http;this._transportController=new AbortController;let e={files:this._files.slice(),paramName:String(this.options.paramName),params:{...this.options.params},headers:{...this.options.headers},signal:this._transportController.signal,onProgress:i=>this._setProgress(i)};return typeof t.upload=="function"?t.upload(String(this.options.url),e):typeof t.request=="function"?t.request(String(this.options.url),{method:"POST",data:e.params,files:e.files,headers:e.headers,signal:e.signal,onProgress:e.onProgress,paramName:e.paramName}):Promise.reject(new TypeError("Injected upload transport requires upload() or request()"))}_uploadXhr(){return typeof XMLHttpRequest!="function"?Promise.reject(new Error("XMLHttpRequest is not available")):new Promise((t,e)=>{let i=new XMLHttpRequest;this._xhr=i,i.open("POST",String(this.options.url));for(let[r,n]of Object.entries(this.options.headers??{}))i.setRequestHeader(r,String(n));this.listen(i.upload,"progress",r=>{r.lengthComputable&&this._setProgress(r.loaded/r.total*100)}),this.listen(i,"load",()=>{if(i.status<200||i.status>=300){e(new Error(`Upload failed with HTTP ${i.status}`));return}t(Wr(i.responseText))}),this.listen(i,"error",()=>e(new Error("Upload request failed"))),this.listen(i,"abort",()=>e(Qr())),i.send(Ur(this._files,String(this.options.paramName),this.options.params))})}_setProgress(t){let e=Math.max(0,Math.min(100,Number(t)||0));this._progress.value=e,this._progressText.textContent=`${Math.round(e)}%`,this.emit("progress",{percent:e})}_finishAbort(){this._running&&(this._runId+=1,this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("idle"),this._status.textContent="Upload aborted.",this.emit("abort",{}))}_selectionError(t){this._setState("error"),this._status.textContent=t.message,this.emit("error",{error:t})}_renderPreview(){this._revokePreview(),this._preview.replaceChildren();let t=this._files[0];!this.options.preview||!t?.type?.startsWith("image/")||typeof URL>"u"||typeof URL.createObjectURL!="function"||(this._previewUrl=URL.createObjectURL(t),this._preview.append(a("img",{class:"zx-field-upload__image",src:this._previewUrl,alt:`Preview of ${t.name}`})))}_revokePreview(){this._previewUrl&&typeof URL<"u"&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(this._previewUrl),this._previewUrl=null}_setState(t){t==="idle"?this.el.removeAttribute("data-state"):this.el.dataset.state=t}destroy(){this._running&&this.abort(),this._revokePreview();for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function $r(s){let t=[];return s.accept&&t.push(String(s.accept)),s.maxSize!=null&&t.push(`up to ${Yr(Number(s.maxSize))}`),t.join(" \xB7 ")||"Choose from this device"}function Yr(s){return s<1024?`${s} B`:s<1024*1024?`${Math.round(s/1024)} KB`:`${Math.round(s/(1024*1024))} MB`}function Kr(s,t){if(!t)return!0;let e=String(s.type??"").toLowerCase();return String(t).split(",").map(i=>i.trim().toLowerCase()).filter(Boolean).some(i=>i.startsWith(".")?s.name.toLowerCase().endsWith(i):i.endsWith("/*")?e.startsWith(i.slice(0,-1)):e===i)}function Ur(s,t,e){let i=new FormData;for(let r of s)i.append(t,r);for(let[r,n]of Object.entries(e??{}))Bi(i,r,n);return i}function Bi(s,t,e){if(e==null)return;if(Array.isArray(e)){for(let r of e)Bi(s,t,r);return}typeof Blob=="function"&&e instanceof Blob?s.append(t,e):s.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function Wr(s){if(!s)return null;try{return JSON.parse(s)}catch{return s}}function Qr(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let s=new Error("Upload aborted");return s.name="AbortError",s}function $i(){b.register("upload",(s,t)=>{let e=s.own(new Yt(null,{...t.props??{}}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("select",()=>s.emit("change",{value:null})),{el:e.el,get:()=>null,set:()=>e.clear(),focus:()=>e.el.querySelector(".zx-field-upload__dropzone")?.focus(),setDisabled:i=>e.setDisabled(i)}})}var Yi=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),Ki=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),Kt=class extends g{static cssName="multi-value-editor";static defaults={values:[],options:null,addLabel:"Add value",reorder:"both"};render(){let t=this.el??a("div");return this.el=t,this._values=Array.isArray(this.options.values)?this.options.values.map(String):[],this._ownedNodes=[],this._initialState=t.getAttribute("data-state"),this._dragIndex=-1,this._armed=null,this._rows=a("div",{class:"zx-multi-value-editor__rows"}),this._add=a("button",{class:"zx-btn zx-multi-value-editor__add",type:"button",dataset:{action:"add"}},String(this.options.addLabel??"Add value")),this._ownedNodes.push(this._rows,this._add),t.append(this._rows,this._add),this.listen(t,"click",e=>this._handleClick(e)),this.listen(this._rows,"change",e=>this._handleChange(e)),this.listen(this._rows,"keydown",e=>this._handleKeydown(e)),this._reorder().drag&&(this.listen(this._rows,"pointerdown",e=>this._handlePointerDown(e)),this.listen(this._rows,"dragstart",e=>this._handleDragStart(e)),this.listen(this._rows,"dragover",e=>this._handleDragOver(e)),this.listen(this._rows,"dragleave",e=>this._handleDragLeave(e)),this.listen(this._rows,"drop",e=>this._handleDrop(e)),this.listen(this._rows,"dragend",()=>this._finishDrag()),this.listen(document,"pointerup",()=>this._disarm()),this.listen(document,"pointercancel",()=>this._disarm())),this._renderRows(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=Array.isArray(t)?t.map(String):[],this._renderRows(),e||this.emit("change",{values:this.getValues()}),this}_reorder(){return Yi[this.options.reorder]??Yi.both}_renderRows(t=-1,e="value"){let i=Ui(this.options.options),r=this.options.options!==null,{drag:n,buttons:o}=this._reorder(),l=this._values.length-1,c=this._values.map((u,h)=>{let p=!r||i.some(([d])=>d===u)?i:[[u,u],...i],f=r?a("select",{class:"zx-multi-value-editor__value",ariaLabel:`Value ${h+1}`,dataset:{index:h}},p.map(([d,_])=>a("option",{value:d,selected:d===u},_))):a("input",{class:"zx-multi-value-editor__value",type:"text",value:u,ariaLabel:`Value ${h+1}`,dataset:{index:h}});return a("div",{class:"zx-multi-value-editor__row",dataset:{row:h}},n?a("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:`Reorder value ${h+1}. Use the arrow keys to move it.`,dataset:{action:"grab",index:h}},m("drag",{size:12})):null,f,a("div",{class:"zx-multi-value-editor__controls"},o?a("button",{class:"zx-btn",type:"button",ariaDisabled:String(h===0),ariaLabel:`Move value ${h+1} up`,dataset:{action:"up",index:h}},m("chevron-up",{size:12})):null,o?a("button",{class:"zx-btn",type:"button",ariaDisabled:String(h===l),ariaLabel:`Move value ${h+1} down`,dataset:{action:"down",index:h}},m("chevron-down",{size:12})):null,a("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${h+1}`,dataset:{action:"remove",index:h}},m("x",{size:12}))))});this._rows.replaceChildren(...c),t>=0&&c[Math.min(t,c.length-1)]?.querySelector(Ki[e]??Ki.value)?.focus()}_handleClick(t){let e=t.target instanceof Element?t.target.closest("[data-action]"):null;if(!e||!this.el.contains(e)||e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.action,r=Number(e.dataset.index);if(i==="add"){let n=Ui(this.options.options);this._values.push(this.options.options===null?"":n[0]?.[0]??""),this._renderRows(this._values.length-1),this._emitChange()}else i==="remove"&&Number.isInteger(r)?(this._values.splice(r,1),this._renderRows(Math.min(r,this._values.length-1)),this._emitChange()):(i==="up"||i==="down")&&Number.isInteger(r)&&this._move(r,r+(i==="up"?-1:1),i)}_handleChange(t){let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e||!("value"in e))return;let i=Number(e.dataset.index);!Number.isInteger(i)||i<0||i>=this._values.length||(this._values[i]=e.value,this._emitChange())}_handleKeydown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(!e)return;let i=Number(e.dataset.index),r=t.key==="ArrowUp"?i-1:t.key==="ArrowDown"?i+1:t.key==="Home"?0:t.key==="End"?this._values.length-1:-1;r<0||r>=this._values.length||(t.preventDefault(),this._move(i,r,"handle"))}_handlePointerDown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(this._disarm(),!e||e.disabled)return;let i=e.closest(".zx-multi-value-editor__row");i&&(i.draggable=!0,this._armed=i)}_disarm(){this._armed&&(this._armed.draggable=!1),this._armed=null}_handleDragStart(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__row"):null;if(!e||e!==this._armed){t.preventDefault();return}this._dragIndex=Number(e.dataset.row),e.dataset.dragging="true",this.el.setAttribute("data-state","dragging"),t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move")}_handleDragOver(t){this._dragIndex<0||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._showDrop(this._dropTarget(t.clientY)))}_handleDragLeave(t){let e=t.relatedTarget;e instanceof Node&&this._rows.contains(e)||this._clearDrop()}_handleDrop(t){if(this._dragIndex<0)return;t.preventDefault();let e=this._dragIndex,i=this._dropTarget(t.clientY);this._finishDrag(),this._move(e,i>e?i-1:i,"handle")}_finishDrag(){this._dragIndex=-1,this._disarm(),this._clearDrop();for(let t of this._rows.children)delete t.dataset.dragging;this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_dropTarget(t){let e=[...this._rows.children];for(let[i,r]of e.entries()){let n=r.getBoundingClientRect();if(t<n.top+n.height/2)return i}return e.length}_showDrop(t){let e=[...this._rows.children],i=t===this._dragIndex||t===this._dragIndex+1;for(let[r,n]of e.entries()){let o=n;!i&&r===t?o.dataset.drop="before":!i&&t===e.length&&r===e.length-1?o.dataset.drop="after":delete o.dataset.drop}}_clearDrop(){for(let t of this._rows.children)delete t.dataset.drop}_move(t,e,i){let r=this._values.length;if(t===e||t<0||e<0||t>=r||e>=r)return!1;let[n]=this._values.splice(t,1);return this._values.splice(e,0,n),this._renderRows(e,i),this._emitChange(),!0}_emitChange(){this.emit("change",{values:this.getValues()})}destroy(){this._initialState===null?this.el?.removeAttribute("data-state"):this.el?.setAttribute("data-state",this._initialState);for(let t of this._ownedNodes??[])t.remove();super.destroy()}};function Ui(s){return Array.isArray(s)?s.map(t=>[String(t),String(t)]):s&&typeof s=="object"?Object.entries(s).map(([t,e])=>[t,String(e)]):[]}function Wi(){b.register("multivalueeditor",(s,t)=>{let e=s.own(new Kt(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]})),i=new WeakMap,r=!1,n=()=>{e.el.setAttribute("aria-disabled",String(r));for(let o of e.el.querySelectorAll("input, button, select, textarea"))r?(i.has(o)||i.set(o,!!o.disabled),o.disabled=!0):i.has(o)&&(o.disabled=i.get(o),i.delete(o))};return s.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>s.emit("change",{value:o.detail.values})),{el:e.el,get:()=>e.getValues(),set:o=>{e.setValues(Array.isArray(o)?o:[],{silent:!0}),n()},focus:()=>e.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),setDisabled:o=>{r=!!o,n()}}})}var rt=class extends g{static cssName="number-field";static defaults={value:null,min:null,max:null,step:1,largeStep:10,precision:null,wrap:!1,placeholder:"",label:null,unit:null,disabled:!1,readonly:!1,required:!1,name:null,group:!1,locale:null};render(){this._value=null,this._disabled=!1,this._readonly=!1,this._editing=!1,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:j(this.el);let t=this.el??a("div");this.el=t;let e=Zr(this.options.step);this._step=e,this._precision=this.options.precision===null?Gr(e):Math.max(0,Math.trunc(Number(this.options.precision)||0));let i=this._stepButton("down","minus"),r=this._stepButton("up","plus"),n=a("input",{ref:"input",class:"zx-number-field__input",type:"text",role:"spinbutton",inputMode:this._precision>0?"decimal":"numeric",autocomplete:"off",spellcheck:!1,placeholder:String(this.options.placeholder??""),ariaLabel:this.options.label??void 0,name:this.options.name??void 0,required:!!this.options.required}),o=[i,n];return this.options.unit!==null&&o.push(a("span",{ref:"unit",class:"zx-number-field__unit",ariaHidden:"true"},String(this.options.unit))),o.push(r),t.replaceChildren(...o),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(n,"input",()=>this._onInput()),this.listen(n,"keydown",l=>this._onKeydown(l)),this.listen(n,"focus",()=>{this._editing=!0,this._syncInput()}),this.listen(n,"blur",()=>{this._commit(),this._editing=!1,this._syncInput()}),this.listen(i,"click",()=>this._stepBy(-1)),this.listen(r,"click",()=>this._stepBy(1)),this.listen(n,"wheel",l=>{document.activeElement!==n||this._disabled||this._readonly||(l.preventDefault(),this._stepBy(l.deltaY<0?1:-1))},{passive:!1}),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=this._coerce(t),r=i!==this._value;return this._value=i,this._syncInput(),r&&!e&&this.emit("change",{value:this._value}),this}stepUp(t=1){return this._stepBy(t)}stepDown(t=1){return this._stepBy(-t)}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}focus(){return this.refs.input.focus(),this}getInput(){return this.refs.input}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}setRange(t,e){return this._min=t==null?null:Number(t),this._max=e==null?null:Number(e),this.set(this._value,{silent:!0})}_stepButton(t,e){return a("button",{ref:t,class:"zx-number-field__step",type:"button",tabIndex:-1,ariaHidden:"true",dataset:{step:t}},m(e,{size:13}))}get _rangeMin(){return this._min!==void 0?this._min:this.options.min===null||this.options.min===void 0?null:Number(this.options.min)}get _rangeMax(){return this._max!==void 0?this._max:this.options.max===null||this.options.max===void 0?null:Number(this.options.max)}_coerce(t){let e=ke(t,this.options.group?this._separators():null);return e===null?null:Ae(e,{min:this._rangeMin,max:this._rangeMax,step:this._step,precision:this._precision})}_stepBy(t){if(this._disabled||this._readonly)return this;let e=this._rangeMin,i=this._rangeMax,n=ke(this.refs.input.value)??this._value,o=n===null?e??0:n,l=n===null&&t>0&&e!==null?e-this._step*t:o,c=Qi(l+this._step*t,this._precision);return this.options.wrap&&e!==null&&i!==null&&(c>i?c=e:c<e&&(c=i)),this.set(c),this}_separators(){if(this._localeSeparators)return this._localeSeparators;let t=new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:1}).formatToParts(1234.5);return this._localeSeparators={group:t.find(e=>e.type==="group")?.value??",",decimal:t.find(e=>e.type==="decimal")?.value??"."},this._localeSeparators}_onInput(){let t=ke(this.refs.input.value,this.options.group?this._separators():null);this._syncAria(t),this.emit("input",{value:t})}_onKeydown(t){if(this._disabled||this._readonly)return;let e=Math.max(1,Math.trunc(Number(this.options.largeStep)||1)),r={ArrowUp:()=>this._stepBy(1),ArrowDown:()=>this._stepBy(-1),PageUp:()=>this._stepBy(e),PageDown:()=>this._stepBy(-e),Home:()=>this._rangeMin===null?null:this.set(this._rangeMin),End:()=>this._rangeMax===null?null:this.set(this._rangeMax),Enter:()=>this._commit()}[t.key];r&&(t.key==="Home"&&this._rangeMin===null||t.key==="End"&&this._rangeMax===null||(t.preventDefault(),r()))}_commit(){this.set(this.refs.input.value)}_syncInput(){let t=this.refs.input,e=this._value===null?"":this._format(this._value,this._editing);t.value!==e&&(t.value=e),this._syncAria(this._value)}_syncAria(t){let e=this.refs.input,i=this._rangeMin,r=this._rangeMax;if(i===null?e.removeAttribute("aria-valuemin"):e.setAttribute("aria-valuemin",String(i)),r===null?e.removeAttribute("aria-valuemax"):e.setAttribute("aria-valuemax",String(r)),t===null)e.removeAttribute("aria-valuenow"),e.setAttribute("aria-valuetext",this._message("numberField.empty","Empty"));else{e.setAttribute("aria-valuenow",String(t));let n=this.options.unit===null?"":` ${this.options.unit}`;e.setAttribute("aria-valuetext",`${this._format(t,!1)}${n}`)}this.el.toggleAttribute("data-empty",t===null)}_format(t,e){return this.options.group?new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:this._precision,maximumFractionDigits:this._precision,useGrouping:!e}).format(t):t.toFixed(this._precision)}_message(t,e){let i=this.msg(t);return i===t?e:i}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.up.disabled=this._disabled||this._readonly,this.refs.down.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&V(t,this._snapshot)}};function ke(s,t=null){if(typeof s=="number")return Number.isFinite(s)?s:null;if(s==null)return null;let e=String(s).trim();if(e==="")return null;let i;if(t)i=e.split(t.group).join("").replace(t.decimal,".").replace(/[^\d.\-+eE]/g,"");else{let n=e.replace(/[^\d,.\-+eE]/g,""),o=n.lastIndexOf(","),l=n.lastIndexOf(".");i=n,o>=0&&o>l?i=n.replace(/\./g,"").replace(",","."):o>=0&&(i=n.replace(/,/g,""))}if(!/\d/.test(i))return null;let r=Number(i);return Number.isFinite(r)?r:null}function Ae(s,{min:t,max:e,step:i,precision:r}){let n=s;if(i>0){let o=t??0;n=o+Math.round((s-o)/i)*i}return n=Qi(n,r),t!==null&&n<t?t:e!==null&&n>e?e:n}function Zr(s){let t=Number(s);return Number.isFinite(t)&&t>0?t:1}function Gr(s){let t=String(s),e=t.match(/e-(\d+)/i);if(e)return Number(e[1]);let i=t.split(".")[1];return i?i.length:0}function Qi(s,t){return Number.isFinite(s)?Number(s.toFixed(Math.min(15,Math.max(0,t)))):s}function Zi(){b.register("number",(s,t)=>{let e=s.own(new rt(null,{label:t.label?String(t.label):void 0,placeholder:t.placeholder,required:t.required,...t.props??{}})),i=!1;return s.listen(e.el,"change",r=>r.stopImmediatePropagation()),e.on("change",r=>{i||s.emit("change",{value:r.detail.value})}),{el:e.el,get:()=>e.get(),set:r=>{i=!0;try{e.set(r===""||r===null||r===void 0?null:r,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}var Ut=class extends g{static cssName="rating";static defaults={value:0,max:5,allowHalf:!1,clearable:!0,readonly:!1,disabled:!1,label:"Rating",icon:"star",labels:null,showValue:!1,count:null,size:"md"};render(){this._value=0,this._preview=null,this._disabled=!1,this._readonly=!1,this._radios=[],this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:j(this.el);let t=this.el??a("div");this.el=t,this._max=Math.max(1,Math.trunc(Number(this.options.max)||5)),this._step=this.options.allowHalf?.5:1,this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this._name=w("zx-rating");let e=a("div",{ref:"symbols",class:"zx-rating__symbols",role:"radiogroup",ariaLabel:String(this.options.label??"Rating")});for(let i=1;i<=this._max;i+=1){let r=a("span",{class:"zx-rating__symbol"},a("span",{class:"zx-rating__glyph",ariaHidden:"true"},m(this.options.icon,{size:mt[this.options.size]??mt.md})),a("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},m(this.options.icon,{size:mt[this.options.size]??mt.md})));this.options.allowHalf?r.append(this._radio(i-.5,"half"),this._radio(i,"full")):r.append(this._radio(i,"full")),e.append(r)}return t.replaceChildren(e,a("span",{ref:"readout",class:"zx-rating__readout"})),t.dataset.size=mt[this.options.size]?this.options.size:"md",this.listen(e,"keydown",i=>this._onKeydown(i)),this.listen(e,"pointerleave",()=>this._setPreview(null)),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=this._clamp(t),r=i!==this._value;return this._value=i,this._preview=null,this._sync(),r&&!e&&this.emit("change",{value:this._value}),this}clear({silent:t=!1}={}){return this.set(0,{silent:t})}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}setCount(t){return this._count=t,this._syncReadout(),this}focus(){return(this._radios.find(e=>e.tabIndex===0)??this._radios[0])?.focus(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}_radio(t,e){let i=a("button",{class:"zx-rating__radio",type:"button",role:"radio",tabIndex:-1,ariaChecked:"false",ariaLabel:this._stepLabel(t),dataset:{value:String(t),part:e}});return this.listen(i,"click",r=>{this._choose(t,r.detail>0)}),this.listen(i,"pointerenter",()=>this._setPreview(t)),this.listen(i,"focus",()=>this._setPreview(t)),this.listen(i,"blur",()=>this._setPreview(null)),this._radios.push(i),i}_stepLabel(t){let e=this.options.labels;if(Array.isArray(e)){let i=Math.round(t/this._step)-1;if(e[i]!=null)return String(e[i])}return this._message("rating.value","%1 of %2",[t,this._max])}_message(t,e,i){let r=this.msg(t,...i);return r===t?M(e,i):r}_choose(t,e){this._disabled||this._readonly||(e&&this.options.clearable&&t===this._value?this.set(0):this.set(t))}_onKeydown(t){if(this._disabled||this._readonly)return;let e=["ArrowRight","ArrowDown"],i=["ArrowLeft","ArrowUp"];if(e.includes(t.key))t.preventDefault(),this.set(this._value>=this._max?this._step:(this._value||0)+this._step);else if(i.includes(t.key))t.preventDefault(),this.set(this._value<=this._step?this._max:this._value-this._step);else if(t.key==="Home")t.preventDefault(),this.set(this._step);else if(t.key==="End")t.preventDefault(),this.set(this._max);else if((t.key==="Delete"||t.key==="Backspace")&&this.options.clearable)t.preventDefault(),this.set(0);else return;this.focus()}_setPreview(t){let e=this._disabled||this._readonly?null:t;e!==this._preview&&(this._preview=e,this._paint(),this.emit("hover",{value:this._preview}))}_clamp(t){let e=Number(t);if(!Number.isFinite(e)||e<=0)return 0;let i=Math.round(e/this._step)*this._step;return Math.min(this._max,Math.max(0,i))}_sync(){for(let e of this._radios){let i=Number(e.dataset.value);e.setAttribute("aria-checked",String(i===this._value))}let t=this._radios.find(e=>e.getAttribute("aria-checked")==="true");for(let e of this._radios)e.tabIndex=-1;(t??this._radios[0]).tabIndex=0,this._paint(),this._syncReadout()}_paint(){let t=this._preview??this._value;this.refs.symbols.querySelectorAll(".zx-rating__symbol").forEach((i,r)=>{let n=Math.min(1,Math.max(0,t-r));i.style.setProperty("--zx-rating-fill",`${n*100}%`),i.toggleAttribute("data-preview",this._preview!==null)}),this.el.dataset.value=String(t)}_syncReadout(){let t=this.refs.readout;if(!t)return;let e=this._count===void 0?this.options.count:this._count,i=[];this.options.showValue&&i.push(Xr(this._value,this._step)),e!=null&&i.push(this._message("rating.count","%1 ratings",[e])),t.textContent=i.join(" \xB7 ")}_syncDisabled(){let t=this._disabled||this._readonly;for(let e of this._radios)e.disabled=this._disabled;this.refs.symbols.setAttribute("aria-readonly",String(this._readonly)),this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this.el.toggleAttribute("data-inert",t),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&V(t,this._snapshot)}},mt={sm:14,md:18,lg:24};function Xr(s,t){return t<1?s.toFixed(1):String(s)}function Gi(){b.register("rating",(s,t)=>{let e=s.own(new Ut(null,{label:t.label?String(t.label):void 0,...t.props??{}})),i=!1;return e.on("change",r=>{i||s.emit("change",{value:r.detail.value})}),{el:e.el,get:()=>e.get()||null,set:r=>{i=!0;try{e.set(Number(r)||0,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}var zl=["a[href]","area[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","iframe","object","embed",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(",");function Xi(s,t){let e="",i=null;return function(n){let o=typeof n=="string"?n:n.key;if(typeof n!="string"&&(n.ctrlKey||n.metaKey||n.altKey)||!o||o.length!==1||/\s/.test(o))return;i!==null&&clearTimeout(i),e+=o.toLocaleLowerCase(),e.split("").every(u=>u===e[0])&&(e=e[0]),i=setTimeout(()=>{e="",i=null},500);let l=s(),c=l.findIndex(u=>Jr(u).startsWith(e));c>=0&&t(l[c],c)}}function Jr(s){if(typeof s=="string"||typeof s=="number")return String(s).trim().toLocaleLowerCase();if(s&&typeof s=="object"&&"textContent"in s)return String(s.textContent??"").trim().toLocaleLowerCase();if(s&&typeof s=="object"){let t=s,e=t.label??t.text??t.value;if(e!=null)return String(e).trim().toLocaleLowerCase()}return String(s??"").trim().toLocaleLowerCase()}var tn=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],en=["Lowest","Low","Normal","High","Highest"],I=class s extends g{static cssName="select";static defaults={items:[],fixedItems:[],valueKey:"ID",labelKey:"name",renderItem:null,renderValue:null,value:null,disabled:!1,placeholder:"",clearable:!1,filter:!1,searchKeys:null,minQuery:0,debounce:200,listHeight:280,groupKey:null};render(){this._items=[],this._visibleItems=[],this._fixedItems=[],this._visibleFixed=[],this._selected=null,this._optionEntries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._createdRoot=!1,this._root=null,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let t=this.el??a("div");this.el=t,this._root=t,this._createdRoot||(this._originalChildren=Array.from(t.childNodes)),this._rememberAttribute(t,"data-state"),this._rememberAttribute(t,"data-loading"),this._rememberAttribute(t,"aria-disabled");let e=w("zx-select-list"),i=a("input",{ref:"input",class:"zx-select__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:this.options.filter?"list":"none",placeholder:String(this.options.placeholder??""),readOnly:!this.options.filter}),r=a("button",{ref:"clear",class:"zx-icon-btn zx-select__clear",type:"button",tabIndex:-1,ariaLabel:this._message("select.clear","Clear selection"),hidden:!0},m("x",{size:13})),n=a("span",{ref:"loading",class:"zx-select__loading",role:"status",ariaLabel:this._message("select.loading","Loading"),hidden:!0}),o=a("button",{ref:"toggle",class:"zx-select__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("select.toggle","Toggle options")},m("chevron-down",{size:16})),l=a("div",{ref:"control",class:"zx-select__control"},i,r,n,o),c=a("div",{ref:"list",class:"zx-select__list",id:e,role:"listbox"});c.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let u=a("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},c);return t.replaceChildren(l,u),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visibleItems=this._items.slice(),this._fixedItems=Array.isArray(this.options.fixedItems)?this.options.fixedItems.slice():[],this._visibleFixed=this._fixedItems.slice(),this._disabled=!!this.options.disabled,this._handleTypeahead=Xi(()=>this._optionEntries.filter(h=>!h.clear).map(h=>h.element),(h,p)=>{this._open||this.open(),this._setActive(this._itemEntryIndex(p))}),this.listen(i,"click",()=>this.open()),this.listen(i,"input",()=>this._onInput()),this.listen(i,"keydown",h=>this._onKeydown(h)),this.listen(o,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(r,"click",()=>{this.set(null),this.focus()}),this.listen(u,"pointerdown",h=>h.preventDefault()),this.listen(u,"click",h=>this._onOptionClick(h)),this.listen(document,"pointerdown",h=>{this._open&&!t.contains(h.target)&&this.close()},{capture:!0}),this._renderOptions(),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._selected===null?null:this._itemValue(this._selected)}set value(t){this.set(t)}get selected(){return this._selected}set(t,{silent:e=!1}={}){let i=this.value,r=t==null?null:this._findItem(t);this._selected=r,this._syncInputValue(),this._renderOptions();let n=this.value;return!e&&!Object.is(i,n)&&this.emit("change",{value:n,item:r}),this}setItems(t){let e=this.value;return this._items=Array.isArray(t)?t.slice():[],this._visibleItems=this._items.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setFixedItems(t){let e=this.value;return this._fixedItems=Array.isArray(t)?t.slice():[],this._visibleFixed=this._fixedItems.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t}),this}open(){return this._disabled||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=R(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._selectedEntryIndex()),this._activeIndex<0&&this._optionEntries.length>0&&this._setActive(0),this.options.filter&&this._selected!==null&&this.refs.input.select(),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(""),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._setLoading(!1),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._visibleItems=this._items.slice(),this._visibleFixed=this._fixedItems.slice(),this._syncInputValue(),this.emit("close",{}),this):this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}static priority(t,e={}){let i=e.value??null,r=new s(t,{...e,value:null,items:[],renderItem(n){return a("span",{class:"zx-select__priority"},a("span",{class:"zx-select__priority-icon",dataset:{level:n.level},ariaHidden:"true"}),a("span",{},String(n.name)))}});return r.setItems(tn.map((n,o)=>({ID:o,name:r._message(n,en[o]),level:o}))),r.set(i,{silent:!0}),r}static permission(t,e={}){let{groups:i=[],value:r=!0,valueKey:n="ID",labelKey:o="name",...l}=e,c=typeof i=="function"?i:null,u=c?[]:i,h=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],p=new s(t,{filter:c??"local",...l,value:null,items:u,fixedItems:[],valueKey:f=>h.includes(f)?f.ID:Se(f,n),labelKey:f=>h.includes(f)?f.name:String(Se(f,o)??"")});return h[0].name=p._message("permission.private","Private"),h[1].name=p._message("permission.public","Public"),p.setFixedItems(h),p.set(r,{silent:!0}),p}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;if(!this._createdRoot&&t){t.replaceChildren(...this._originalChildren);for(let[e,i]of this._originalAttributes)i===null?t.removeAttribute(e):t.setAttribute(e,i)}super.destroy()}_onKeydown(t){if(!this._disabled){if(t.key==="ArrowDown"){t.preventDefault(),this._open?this._moveActive(1):this.open();return}if(t.key==="ArrowUp"){t.preventDefault(),this._open?this._moveActive(-1):(this.open(),this._setActive(this._optionEntries.length-1));return}if(t.key==="Home"&&this._open){t.preventDefault(),this._setActive(0);return}if(t.key==="End"&&this._open){t.preventDefault(),this._setActive(this._optionEntries.length-1);return}if(t.key==="Enter"&&this._open){t.preventDefault(),this._chooseEntry(this._optionEntries[this._activeIndex]);return}if(t.key==="Escape"&&this._open){t.preventDefault(),this.close();return}if(t.key==="Tab"&&this._open){this.close();return}!this.options.filter&&sn(t)&&this._handleTypeahead(t)}}_onInput(){if(!this.options.filter)return;let t=this.refs.input.value;this._open||this.open(),this.options.filter==="local"?(this._visibleFixed=this._matchFixed(t),this._visibleItems=P(this._items,t,this._searchKeys()),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update()):typeof this.options.filter=="function"&&this._scheduleAsyncQuery(t)}_onOptionClick(t){let e=t.target?.closest?.('[role="option"]');!e||!this.refs.panel.contains(e)||this._chooseEntry(this._optionEntries[Number(e.getAttribute("data-index"))])}_chooseEntry(t){t&&(this.set(t.clear?null:t.item),this.close(),this.focus())}_moveActive(t){let e=this._optionEntries.length;e!==0&&this._setActive((this._activeIndex+t+e)%e)}_setActive(t){this._activeIndex=t>=0&&t<this._optionEntries.length?t:-1,this._optionEntries.forEach((i,r)=>{r===this._activeIndex?i.element.setAttribute("data-active","true"):i.element.removeAttribute("data-active")});let e=this._optionEntries[this._activeIndex]?.element;e?(this.refs.input.setAttribute("aria-activedescendant",e.id),e.scrollIntoView?.({block:"nearest"})):this.refs.input.removeAttribute("aria-activedescendant")}_renderOptions(){let t=this.refs.list;if(!t)return;t.replaceChildren(),this._optionEntries=[];let e=Symbol("initial-group");this.options.clearable&&this._appendOption(null,!0,this.options.placeholder||this._message("select.none","No selection"));for(let i of this._visibleFixed)this._appendOption(i,!1);this._visibleFixed.length>0&&this._visibleItems.length>0&&!this.options.groupKey&&t.append(a("div",{class:"zx-select__separator",role:"presentation"}));for(let i of this._visibleItems){if(this.options.groupKey){let r=this._read(i,this.options.groupKey);Object.is(r,e)||(t.append(a("div",{class:"zx-select__group",role:"presentation"},String(r??""))),e=r)}this._appendOption(i,!1)}this._visibleItems.length===0&&this._visibleFixed.length===0&&!this._loading&&t.append(a("div",{class:"zx-select__empty",role:"status"},this._message("select.empty","No matches"))),this._setActive(-1)}_appendOption(t,e,i){let r=e?this._selected===null:this._selected!==null&&Object.is(this._itemValue(t),this.value),n=this._optionEntries.length,o=e?String(i??""):this._renderItem(t),l=a("div",{class:"zx-select__option",id:w("zx-select-option"),role:"option",ariaSelected:String(r),dataset:{index:n}},a("span",{class:"zx-select__option-content"},o));r&&l.append(m("check",{size:15})),this.refs.list.append(l),this._optionEntries.push({item:t,clear:e,element:l})}_renderItem(t){if(typeof this.options.renderItem=="function"){let e=this.options.renderItem(t);return e&&typeof e=="object"&&"nodeType"in e?e:String(e??"")}return this._itemLabel(t)}_scheduleAsyncQuery(t){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._requestSequence+=1;let e=this._requestSequence;if(this._visibleFixed=this._matchFixed(t),t.length<Math.max(0,Number(this.options.minQuery)||0)){this._setLoading(!1),this._visibleItems=[],this._renderOptions();return}this._setLoading(!0),this._renderOptions(),this._position?.update();let i=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runAsyncQuery(t,e)},i)}async _runAsyncQuery(t,e){if(!(e!==this._requestSequence||typeof this.options.filter!="function")){this.emit("query",{query:t});try{let i=await this.options.filter(t);if(e!==this._requestSequence||!this._open)return;this._items=Array.isArray(i)?i.slice():[],this._visibleItems=this._items.slice(),this._setLoading(!1),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update(),this.emit("loaded",{items:this._items.slice()})}catch{if(e!==this._requestSequence||!this._open)return;this._items=[],this._visibleItems=[],this._setLoading(!1),this._renderOptions(),this._position?.update()}}}_cancelQuery(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._requestSequence+=1}_setLoading(t){this._loading=t,this.refs.loading.hidden=!t,this.refs.input.setAttribute("aria-busy",String(t)),this.refs.list.setAttribute("aria-busy",String(t)),t?this._root?.setAttribute("data-loading","true"):this._root?.removeAttribute("data-loading")}_syncInputValue(){if(!this.refs.input)return;let t=this.refs.input;t.value=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),this.refs.clear.hidden=!this.options.clearable||this._selected===null}_syncDisabled(){let t=this.refs.input,e=this.refs.clear,i=this.refs.toggle;t.disabled=this._disabled,e.disabled=this._disabled,i.disabled=this._disabled,this._root?.setAttribute("aria-disabled",String(this._disabled))}_findItem(t){let e=this._fixedItems.length===0?this._items:[...this._fixedItems,...this._items],i=e.find(n=>n===t);if(i!==void 0)return i;let r=t!==null&&typeof t=="object"?this._itemValue(t):t;return e.find(n=>Object.is(this._itemValue(n),r))??null}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){let e=this._read(t,this.options.labelKey);return String(e??"")}_read(t,e){return Se(t,e)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(t){return P(this._fixedItems,t,this._searchKeys())}_selectedEntryIndex(){return this._selected===null?this.options.clearable?0:-1:this._optionEntries.findIndex(t=>!t.clear&&Object.is(this._itemValue(t.item),this.value))}_itemEntryIndex(t){return t+(this.options.clearable?1:0)}_rememberAttribute(t,e){this._originalAttributes.set(e,t.getAttribute(e))}_message(t,e){let i=this.msg(t);return i===t?e:i}};function Se(s,t){return typeof t=="function"?t(s):s===null||typeof s!="object"?s:s[t]}function sn(s){return s.key.length===1&&!s.ctrlKey&&!s.metaKey&&!s.altKey}function Ji(){b.register("zxselect",(s,t)=>{let e=s.own(new I(null,{...t.props??{},value:t.value}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.value})),{el:e.el,get:()=>e.value,set:i=>e.set(i,{silent:!0}),focus:()=>e.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var Wt=class extends g{static cssName="slider";static defaults={value:0,min:0,max:100,step:1,label:"",hideLabel:!1,showValue:!0,showBounds:!1,showInput:!1,unit:"",marks:null,disabled:!1,readonly:!1,size:"md",formatValue:null};render(){this._value=0,this._readonly=!!this.options.readonly,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:j(this.el);let t=this.el??a("div");this.el=t,this._min=Number(this.options.min)||0,this._max=Number(this.options.max),(!Number.isFinite(this._max)||this._max<=this._min)&&(this._max=this._min+100),this._step=Math.abs(Number(this.options.step))||1,this._id=w("zx-slider");let e=a("input",{ref:"input",class:"zx-slider__input",type:"range",id:this._id,min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled}),i=a("div",{class:"zx-slider__track"},e,this._marks()),r=a("div",{class:"zx-slider__control"});return this.options.showBounds&&r.append(a("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._min))),r.append(i),this.options.showBounds&&r.append(a("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._max))),this.options.showInput&&r.append(this._numberBox()),t.replaceChildren(a("div",{class:"zx-slider__head"},a("label",{ref:"label",class:"zx-slider__label",for:this._id},String(this.options.label??"")),a("span",{ref:"output",class:"zx-slider__value",ariaHidden:"true"})),r),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(e,"input",()=>this._onInput()),this.listen(e,"change",()=>this._onCommit()),this.listen(e,"keydown",n=>{this._readonly&&rn.has(n.key)&&n.preventDefault()}),this.set(this.options.value,{silent:!0}),this._syncState(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=this._snap(t),r=i!==this._value;return this._value=i,this._paint(),r&&!e&&this.emit("change",{value:i}),this}setRange(t,e,i){let r=Number(t),n=Number(e);if(!Number.isFinite(r)||!Number.isFinite(n)||n<=r)throw new RangeError("Slider range requires min < max");this._min=r,this._max=n,i!==void 0&&(this._step=Math.abs(Number(i))||1);let{input:o}=this.refs;o.min=String(this._min),o.max=String(this._max),o.step=String(this._step);for(let[l,c]of[...this.el.querySelectorAll(".zx-slider__bound")].entries())c.textContent=this._format(l===0?this._min:this._max);return this.set(this._value,{silent:!0})}focus(){return this.refs.input.focus(),this}enable(){return this.refs.input.disabled=!1,this.refs.number&&(this.refs.number.disabled=!1),this._syncState(),this}disable(){return this.refs.input.disabled=!0,this.refs.number&&(this.refs.number.disabled=!0),this._syncState(),this}setReadonly(t){return this._readonly=!!t,this.refs.number&&(this.refs.number.readOnly=this._readonly),this._syncState(),this}setLabel(t){return this.refs.label.textContent=String(t??""),this}_numberBox(){let t=a("input",{ref:"number",class:"zx-slider__number",type:"number",min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled,readOnly:this._readonly,ariaLabel:String(this.options.label??"Value")});return this.listen(t,"input",()=>{if(this._readonly)return;let e=Number(t.value);t.value===""||!Number.isFinite(e)||(this._value=this._snap(e),this.refs.input.value=String(this._value),this._paintTrack(),this.emit("input",{value:this._value}))}),this.listen(t,"change",()=>{if(this._readonly){t.value=String(this._value);return}this.set(t.value===""?this._min:Number(t.value))}),t}_marks(){let t=this.options.marks;if(!Array.isArray(t)||t.length===0)return null;let e=a("div",{class:"zx-slider__marks",ariaHidden:"true"});for(let i of t){let r=typeof i=="number"?i:Number(i?.value);if(!Number.isFinite(r))continue;let n=typeof i=="number"?this._format(r):String(i.label??this._format(r));e.append(a("span",{class:"zx-slider__mark",style:{"--zx-slider-mark":`${this._ratio(r)*100}%`}},n))}return e}_onInput(){if(this._readonly){this.refs.input.value=String(this._value);return}this._value=this._snap(this.refs.input.value),this._paintTrack(),this.refs.number&&(this.refs.number.value=String(this._value)),this.emit("input",{value:this._value})}_onCommit(){if(this._readonly){this.refs.input.value=String(this._value);return}this.emit("change",{value:this._value})}_paint(){this.refs.input.value=String(this._value),this.refs.number&&(this.refs.number.value=String(this._value)),this._paintTrack()}_paintTrack(){this.el.style.setProperty("--zx-slider-fill",`${this._ratio(this._value)*100}%`);let{output:t}=this.refs;t.textContent=this.options.showValue?this._format(this._value):""}_syncState(){let t=this.refs.input.disabled;this.el.toggleAttribute("data-disabled",t),this.el.toggleAttribute("data-readonly",this._readonly),this.refs.input.setAttribute("aria-readonly",String(this._readonly))}_snap(t){let e=Number(t);return Number.isFinite(e)?Ae(e,{min:this._min,max:this._max,step:this._step,precision:nn(this._step)}):this._min}_ratio(t){return ht((t-this._min)/(this._max-this._min),0,1)}_format(t){let e=this.options.formatValue;return typeof e=="function"?String(e(t)):`${on(t)}${this.options.unit??""}`}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&V(t,this._snapshot)}},rn=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function nn(s){let t=String(s),e=/e-(\d+)$/i.exec(t);return e?Number(e[1]):(t.split(".")[1]??"").length}function on(s){return String(Number(s.toFixed(6)))}function ts(){b.register("slider",(s,t)=>{let e=s.own(new Wt(null,{label:t.label?String(t.label):void 0,hideLabel:!0,disabled:!!t.disabled,...t.props??{}})),i=!1;return e.on("change",r=>{i||s.emit("change",{value:r.detail.value})}),{el:e.el,get:()=>e.get(),set:r=>{i=!0;try{e.set(Number(r)||0,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}var Qt=class extends g{static cssName="tag-picker";static defaults={items:[],values:[],valueKey:"ID",labelKey:"name",searchKeys:null,filter:"local",minQuery:0,debounce:200,allowCreate:!1,max:null,closeOnSelect:!1,placeholder:"",listHeight:260,disabled:!1,readonly:!1,renderItem:null,renderTag:null};render(){this._items=[],this._selected=[],this._visible=[],this._entries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._readonly=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._activeId=null,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:j(this.el);let t=this.el??a("div");this.el=t;let e=w("zx-tag-picker-list"),i=a("span",{ref:"tags",class:"zx-tag-picker__tags"}),r=a("input",{ref:"input",class:"zx-tag-picker__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:"list",ariaLabel:this._message("tagPicker.input","Add a value"),placeholder:String(this.options.placeholder??"")}),n=a("button",{ref:"toggle",class:"zx-tag-picker__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("tagPicker.toggle","Toggle options")},m("chevron-down",{size:15})),o=a("div",{ref:"control",class:"zx-tag-picker__control"},i,r,n),l=a("div",{ref:"list",class:"zx-tag-picker__list",id:e,role:"listbox",ariaMultiSelectable:"true"});l.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let c=a("div",{ref:"panel",class:"zx-tag-picker__panel",popover:"manual"},l);return t.replaceChildren(o,c),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visible=this._items.slice(),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(o,"pointerdown",u=>{let h=u.target;h.closest(".zx-tag-picker__remove")||h.closest(".zx-tag-picker__toggle")||(u.target!==r&&(u.preventDefault(),this.focus()),this._open||this.open())}),this.listen(i,"click",u=>{let h=u.target.closest(".zx-tag-picker__remove");if(!h||this._disabled||this._readonly)return;u.stopPropagation();let p=[...i.children].indexOf(h.closest(".zx-tag-picker__tag")),f=this._selected[p];f!==void 0&&(this.removeValue(this._valueOf(f)),this.focus())}),this.listen(r,"input",()=>this._onInput()),this.listen(r,"keydown",u=>this._onKeydown(u)),this.listen(r,"blur",()=>this.el.removeAttribute("data-focus")),this.listen(r,"focus",()=>this.el.setAttribute("data-focus","")),this.listen(n,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(c,"pointerdown",u=>u.preventDefault()),this.listen(c,"click",u=>this._onOptionClick(u)),this.listen(document,"pointerdown",u=>{this._open&&!t.contains(u.target)&&this.close()},{capture:!0}),this.setValues(this.options.values,{silent:!0}),this._syncDisabled(),t}get values(){return this.getValues()}set values(t){this.setValues(t)}getValues(){return this._selected.map(t=>this._valueOf(t))}getItems(){return this._selected.slice()}setValues(t,{silent:e=!1}={}){let i=Array.isArray(t)?t:[],r=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),n=[];for(let l of i){if(n.length>=r)break;let c=this._resolve(l);c!==null&&!n.some(u=>this._sameValue(u,c))&&n.push(c)}let o=!an(n,this._selected,l=>this._valueOf(l));return this._selected=n,this._renderTags(),this._renderOptions(),o&&!e&&this._emitChange(),this}addValue(t,{silent:e=!1}={}){if(this.isFull())return this;let i=this._resolve(t);return i===null?this:this._selected.some(r=>this._sameValue(r,i))?this:(this._selected.push(i),this._renderTags(),this._renderOptions(),e||(this.emit("add",{value:this._valueOf(i),item:i}),this._emitChange()),this)}removeValue(t,{silent:e=!1}={}){let i=this._valueOf(this._resolve(t)??t),r=this._selected.findIndex(o=>Object.is(this._valueOf(o),i));if(r<0)return this;let[n]=this._selected.splice(r,1);return this._renderTags(),this._renderOptions(),e||(this.emit("remove",{value:this._valueOf(n),item:n}),this._emitChange()),this}clear({silent:t=!1}={}){return this.setValues([],{silent:t})}reset({silent:t=!1}={}){return this.setValues(this.options.values,{silent:t})}setItems(t){return this._cancelQuery(),this._items=Array.isArray(t)?t.slice():[],typeof this.options.filter=="function"?this._visible=this._items.slice():this._applyLocalFilter(this.refs.input.value),this._renderOptions(),this._position?.update(),this}isFull(){let t=this.options.max;return t!=null&&this._selected.length>=Number(t)}open(){return this._disabled||this._readonly||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=R(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._entries.length>0?0:-1),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(this.refs.input.value),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._activeId=null,this.refs.input.value="",this._syncInputWidth(),this._applyLocalFilter(""),this.emit("close",{}),this):this}focus(){return this.refs.input.focus(),this}enable(){return this._disabled=!1,this._renderTags(),this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._renderTags(),this._syncDisabled(),this}setReadonly(t){return t&&this.close(),this._readonly=!!t,this._renderTags(),this._syncDisabled(),this}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;super.destroy(),!this._createdRoot&&t&&V(t,this._snapshot)}_renderTags(){let t=this._selected.map(e=>{let i=this._labelOf(e),r=this.options.renderTag?this.options.renderTag(e):i,n=a("span",{class:"zx-tag-picker__tag"},a("span",{class:"zx-tag-picker__tag-label"},r));return!this._readonly&&!this._disabled&&n.append(a("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[i])},m("x",{size:11}))),n});this.refs.tags.replaceChildren(...t),this.el.toggleAttribute("data-empty",this._selected.length===0),this._syncPlaceholder()}_renderOptions(){let t=this.refs.list;this._entries=[];let e=[];for(let n of this._visible){let o=this._valueOf(n),l=this._isSelected(o),c=a("div",{class:"zx-tag-picker__option",id:w("zx-tag-picker-option"),role:"option",ariaSelected:String(l)},a("span",{class:"zx-tag-picker__check",ariaHidden:"true"},l?m("check",{size:13}):null),a("span",{class:"zx-tag-picker__option-label"},this.options.renderItem?this.options.renderItem(n):this._labelOf(n)));!l&&this.isFull()&&c.setAttribute("aria-disabled","true"),this._entries.push({item:n,element:c,create:!1}),e.push(c)}let i=this.refs.input.value.trim();if(this._canCreate(i)){let n=a("div",{class:"zx-tag-picker__option",id:w("zx-tag-picker-option"),role:"option",ariaSelected:"false",dataset:{create:"true"}},a("span",{class:"zx-tag-picker__check",ariaHidden:"true"},m("plus",{size:13})),a("span",{class:"zx-tag-picker__option-label"},this._message("tagPicker.create","Create \u201C%1\u201D",[i])));this._entries.push({item:null,element:n,create:!0}),e.push(n)}e.length===0&&e.push(a("div",{class:"zx-tag-picker__empty"},this._loading?this._message("tagPicker.loading","Loading\u2026"):this._message("tagPicker.empty","No matches"))),t.replaceChildren(...e);let r=this._entries.findIndex(n=>this._entryId(n)===this._activeId);this._setActive(r>=0?r:this._entries.length>0?0:-1)}_entryId(t){return t.create?"\0create":String(this._valueOf(t.item))}_syncPlaceholder(){let t=this.refs.input;t.placeholder=this._selected.length===0?String(this.options.placeholder??""):""}_onInput(){let t=this.refs.input.value;this._syncInputWidth(),this._open||this.open(),typeof this.options.filter=="function"?this._scheduleAsyncQuery(t):this._applyLocalFilter(t),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update()}_onKeydown(t){if(this._disabled||this._readonly)return;let e=this.refs.input;switch(t.key){case"ArrowDown":t.preventDefault(),this._open?this._move(1):this.open();return;case"ArrowUp":t.preventDefault(),this._open&&this._move(-1);return;case"Home":this._open&&e.value===""&&(t.preventDefault(),this._setActive(0));return;case"End":this._open&&e.value===""&&(t.preventDefault(),this._setActive(this._entries.length-1));return;case"Enter":{if(!this._open||this._activeIndex<0)return;t.preventDefault(),this._commitEntry(this._entries[this._activeIndex]);return}case"Escape":this._open&&(t.preventDefault(),this.close());return;case"Backspace":e.value===""&&this._selected.length>0&&(t.preventDefault(),this.removeValue(this._valueOf(this._selected[this._selected.length-1])));return;case"Tab":this._open&&this.close();return;default:}}_onOptionClick(t){let e=t.target.closest(".zx-tag-picker__option");if(!e)return;let i=this._entries.find(r=>r.element===e);i&&this._commitEntry(i)}_commitEntry(t){if(!t)return;let e=this.refs.input;if(t.create){let i=e.value.trim(),r=this._createItem(i);this._items=this._items.concat([r]),this.addValue(r),this.emit("create",{value:this._valueOf(r),item:r})}else{let i=this._valueOf(t.item);if(this._isSelected(i))this.removeValue(i);else if(!this.isFull())this.addValue(t.item);else return}e.value="",this._syncInputWidth(),this._applyLocalFilter(""),this._renderOptions(),this.options.closeOnSelect?this.close():(this._setActive(this._entries.length>0?0:-1),this._position?.update()),this.focus()}_move(t){if(this._entries.length===0)return;let e=this._activeIndex<0?t>0?0:this._entries.length-1:Math.min(this._entries.length-1,Math.max(0,this._activeIndex+t));this._setActive(e)}_setActive(t){this._activeIndex=t,this._activeId=this._entries[t]?this._entryId(this._entries[t]):null;for(let[e,i]of this._entries.entries()){let r=e===t;i.element.toggleAttribute("data-active",r),r&&(this.refs.input.setAttribute("aria-activedescendant",i.element.id),i.element.scrollIntoView({block:"nearest"}))}t<0&&this.refs.input.removeAttribute("aria-activedescendant")}_applyLocalFilter(t){if(typeof this.options.filter=="function")return;let e=this.options.searchKeys??[this.options.labelKey];this._visible=P(this._items,t,e)}_scheduleAsyncQuery(t){this._cancelQuery();let e=String(t??"");if(e.length<Number(this.options.minQuery??0)){this._visible=[],this._renderOptions();return}this._visible=[],this._setLoading(!0),this._renderOptions();let i=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runQuery(e)},i)}async _runQuery(t){let e=this._requestSequence+1;this._requestSequence=e,this._setLoading(!0),this.emit("query",{query:t});try{let i=await this.options.filter(t);if(e!==this._requestSequence)return;this._items=Array.isArray(i)?i.slice():[],this._visible=this._items.slice()}catch(i){if(e!==this._requestSequence)return;this._visible=[],this.emit("error",{error:i})}finally{e===this._requestSequence&&(this._setLoading(!1),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update())}}_cancelQuery(){this._queryTimer!==null&&(clearTimeout(this._queryTimer),this._queryTimer=null),this._requestSequence+=1,this._setLoading(!1)}_setLoading(t){this._loading=t,this.el.toggleAttribute("data-loading",t)}_isSelected(t){return this._selected.some(e=>Object.is(this._valueOf(e),t))}_canCreate(t){if(!this.options.allowCreate||t===""||this.isFull())return!1;let e=i=>i.some(r=>es(this._labelOf(r))===es(t));return!e(this._items)&&!e(this._selected)}_createItem(t,e=t){return typeof this.options.valueKey!="string"||typeof this.options.labelKey!="string"?t:{[this.options.valueKey]:e,[this.options.labelKey]:t,created:!0}}_resolve(t){if(t==null)return null;let e=this._valueOf(t),i=this._items.find(n=>Object.is(this._valueOf(n),e));if(i!==void 0)return i;let r=this._selected.find(n=>Object.is(this._valueOf(n),e));return r!==void 0?r:typeof t=="object"?t:this._createItem(String(t),t)}_sameValue(t,e){return Object.is(this._valueOf(t),this._valueOf(e))}_valueOf(t){let e=this.options.valueKey;return typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]:t}_labelOf(t){let e=this.options.labelKey;return String(typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]??"":t??"")}_emitChange(){this.emit("change",{values:this.getValues(),items:this.getItems()})}_syncInputWidth(){let t=this.refs.input,e=t.value.length;t.style.inlineSize=e===0?"":`${Math.min(40,e+1)}ch`}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.toggle.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}_message(t,e,i=[]){let r=this.msg(t,...i);return r!==t?r:i.reduce((n,o,l)=>n.replaceAll(`%${l+1}`,String(o)),e)}};function es(s){return String(s??"").trim().toLocaleLowerCase()}function an(s,t,e){return s.length!==t.length?!1:s.every((i,r)=>Object.is(e(i),e(t[r])))}function is(){b.register("tagpicker",(s,t)=>{let e=s.own(new Qt(null,{placeholder:t.placeholder,...t.props??{}})),i=!1;return s.listen(e.el,"change",r=>r.stopImmediatePropagation()),e.on("change",r=>{i||s.emit("change",{value:r.detail.values})}),{el:e.el,get:()=>e.getValues(),set:r=>{i=!0;try{e.setValues(Array.isArray(r)?r:[],{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}function ln(s,t="minutes"){let e=Math.round(Math.abs(ss(Q(s),t)));return{hours:Math.floor(e/3600),minutes:Math.floor(e/60)%60,seconds:e%60,negative:Q(s)<0}}function cn(s,t="minutes"){gt(t);let e=Math.abs(Math.trunc(Q(s?.hours))),i=Math.abs(Math.trunc(Q(s?.minutes))),r=Math.abs(Math.trunc(Q(s?.seconds))),n=s?.negative?-1:1;return rs(n*(e*3600+i*60+r),t)}var Zt=class extends g{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){gt(this.options.unit);let t=this.el??a("div");this.el=t,this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._disabled=!!this.options.disabled,this._parts={hours:0,minutes:0,seconds:0,negative:!1},this._inputs=[];let e=a("div",{class:"zx-timebox__content",role:"group",ariaLabel:this.options.seconds?"Duration in hours, minutes, and seconds":"Duration in hours and minutes"});return this._content=e,this.options.signed&&(e.append(a("button",{ref:"sign",class:"zx-timebox__sign",type:"button",ariaLabel:"Toggle duration sign",ariaPressed:"false"},"+")),this.listen(this.refs.sign,"click",()=>{this._disabled||(this._parts.negative=!this._parts.negative,this._writeParts(),this._emitChange())})),this._addSegment(e,"hours","Hours",!1),e.append(a("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"minutes","Minutes",!0),this.options.seconds&&(e.append(a("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"seconds","Seconds",!0)),t.append(e),this.set(this.options.value,this.options.unit,{silent:!0}),this._syncDisabled(),t}get(t=this.options.unit){return cn(this._readParts(),t)}set(t,e=this.options.unit,i={}){e&&typeof e=="object"&&(i=e,e=this.options.unit),gt(e);let r=Q(t);return!this.options.signed&&r<0&&(r=0),this.options.seconds||(r=rs(Math.round(ss(r,e)/60)*60,e)),this._parts=ln(r,e),this.options.signed||(this._parts.negative=!1),this._writeParts(),i.silent||this._emitChange(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}destroy(){this._content?.remove(),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_addSegment(t,e,i,r){let n=a("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:i,maxLength:r?2:null,dataset:{segment:e,bounded:String(r)}});this._inputs.push(n),t.append(n),this.listen(n,"focus",()=>n.select()),this.listen(n,"input",()=>{e==="hours"&&this.options.signed&&n.value.trim().startsWith("-")&&(this._parts.negative=!0);let o=n.value.replace(/\D/g,"");n.value=r?o.slice(0,2):o}),this.listen(n,"change",()=>this._commitSegments()),this.listen(n,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this._commitSegments(),n.select())})}_readParts(){let t={...this._parts};for(let e of this._inputs){let i=e.dataset.segment,r=e.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;t[i]=Math.max(0,Math.min(r,Math.trunc(Q(e.value))))}return t}_commitSegments(){this._parts=this._readParts(),this._writeParts(),this._emitChange()}_writeParts(){for(let t of this._inputs){let e=t.dataset.segment;t.value=e==="hours"?String(this._parts[e]):un(this._parts[e])}this.refs.sign&&(this.refs.sign.textContent=this._parts.negative?"-":"+",this.refs.sign.setAttribute("aria-pressed",String(this._parts.negative)),this.refs.sign.dataset.state=this._parts.negative?"negative":"positive")}_syncDisabled(){for(let t of this._inputs)t.disabled=this._disabled;this.refs.sign&&(this.refs.sign.disabled=this._disabled),this.el.setAttribute("aria-disabled",String(this._disabled))}_emitChange(){this.emit("change",{value:this.get(this.options.unit)})}};function Q(s){let t=Number(s);return Number.isFinite(t)?t:0}function ss(s,t){return gt(t),t==="hours"?s*3600:t==="minutes"?s*60:s}function rs(s,t){return gt(t),t==="hours"?s/3600:t==="minutes"?s/60:s}function gt(s){if(s!=="hours"&&s!=="minutes"&&s!=="seconds")throw new RangeError(`Unknown time unit: ${s}`)}function un(s){return String(s).padStart(2,"0")}function ns(){b.register("time",(s,t)=>{let e=s.own(new Zt(null,{...t.props??{},value:t.value}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.value})),{el:e.el,get:()=>e.get(),set:i=>e.set(Number(i)||0,{silent:!0}),focus:()=>e.el.querySelector("input:not([disabled]), button:not([disabled])")?.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var nt=class extends g{static cssName="toggle";static defaults={checked:!1,value:!0,label:null,disabled:!1};render(){let t=!this.el,e=this.el??a("button");if(this.el=e,e.localName!=="button")throw new TypeError("Toggle target must be a button element");this._createdRoot=t,this._original=t?null:hn(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,e.type="button",e.setAttribute("role","switch");let i=[a("span",{class:"zx-toggle__track",ariaHidden:"true"},a("span",{class:"zx-toggle__thumb"}))];return this.options.label!==null&&i.push(a("span",{class:"zx-toggle__label"},String(this.options.label))),e.replaceChildren(...i),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let i=!!t;return i===this._checked?this:(this._checked=i,this._sync(),e||this.emit("change",{checked:this._checked,value:this.getValue()}),this)}toggle(){return this.set(!this._checked)}getValue(){return this._checked?this.options.value:!1}enable(){return this._disabled=!1,this.el.removeAttribute("disabled"),this}disable(){return this._disabled=!0,this.el.setAttribute("disabled",""),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&dn(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function hn(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function dn(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function os(){b.register("toggle",(s,t)=>{let e=s.own(new nt(null,{...t.props??{},checked:!!t.value}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.value})),{el:e.el,get:()=>e.getValue(),set:i=>e.set(!!i,{silent:!0}),focus:()=>e.el.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var Gt=class extends g{static cssName="value-list";static defaults={values:[],placeholder:"",deletable:!0,sortable:!0,unique:!0,validate:null};render(){let t=this.el??a("div");this._ownedNodes=[],this._disabled=!1,this._dragIndex=-1,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled"),this._values=as(this.options.values,!!this.options.unique);let e=w("zx-value-list-instructions");return this._list=a("ul",{class:"zx-value-list__list",role:"listbox",ariaLabel:"Values",ariaOrientation:"horizontal"}),this._input=a("input",{class:"zx-value-list__input",type:"text",placeholder:String(this.options.placeholder??""),ariaLabel:"Add value",ariaDescribedby:e}),this._status=a("div",{class:"zx-value-list__status",role:"status",ariaLive:"polite"}),this._instructions=a("span",{class:"zx-value-list__instructions",id:e},"Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder."),this._ownedNodes.push(this._list,this._input,this._status,this._instructions),t.append(this._list,this._input,this._status,this._instructions),this.listen(this._input,"keydown",i=>this._handleInputKeydown(i)),this.listen(this._list,"keydown",i=>this._handleChipKeydown(i)),this.listen(this._list,"click",i=>this._handleChipClick(i)),this.listen(this._list,"dragstart",i=>this._handleDragStart(i)),this.listen(this._list,"dragover",i=>{this._dragIndex>=0&&!this._disabled&&i.preventDefault()}),this.listen(this._list,"drop",i=>this._handleDrop(i)),this.listen(this._list,"dragend",()=>this._finishDrag()),this.listen(t,"click",i=>{i.target===t&&!this._disabled&&this.focus()}),this._renderChips(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=as(t,!!this.options.unique),this._renderChips(),e||this.emit("change",{values:this.getValues()}),this}addValue(t){if(this._disabled)return!1;let e=String(t??"").trim();if(!e)return!1;if(this.options.unique&&this._values.includes(e))return this._showError("This value already exists."),!1;if(typeof this.options.validate=="function"){let i=this.options.validate(e);if(i!==!0)return this._showError(typeof i=="string"?i:"This value is not valid."),!1}return this._status.textContent="",this._input.removeAttribute("aria-invalid"),this._values.push(e),this._renderChips(),this.emit("add",{value:e}),this.emit("change",{values:this.getValues()}),!0}removeValue(t){if(this._disabled||!this.options.deletable)return!1;let e=this._values.indexOf(String(t));return e<0?!1:(this._removeAt(e),!0)}focus(){return this._input.focus(),this}enable(){return this._disabled=!1,this._input.disabled=!1,this.el.dataset.disabled="false",this._renderChips(),this}disable(){return this._disabled=!0,this._input.disabled=!0,this.el.dataset.disabled="true",this._renderChips(),this}_renderChips(t=-1){let e=this._values.map((i,r)=>a("li",{class:"zx-value-list__chip",role:"option",tabIndex:this._disabled?-1:0,draggable:!!this.options.sortable&&!this._disabled,ariaSelected:"false",ariaDisabled:String(this._disabled),ariaLabel:this.options.deletable?`${i}. Press Delete to remove.`:i,dataset:{index:r}},a("span",{class:"zx-value-list__value"},i),this.options.deletable?a("span",{class:"zx-value-list__remove",dataset:{remove:""},ariaHidden:"true"},"\xD7"):null));this._list.replaceChildren(...e),t>=0&&e[Math.min(t,e.length-1)]?.focus()}_handleInputKeydown(t){this._disabled||(t.key==="Enter"?(t.preventDefault(),this.addValue(this._input.value)&&(this._input.value="")):t.key==="Backspace"&&this._input.value===""&&this._values.length&&this.options.deletable&&(t.preventDefault(),this._removeAt(this._values.length-1)))}_handleChipKeydown(t){if(this._disabled)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e)return;let i=Number(e.dataset.index);if((t.key==="Delete"||t.key==="Backspace")&&this.options.deletable){t.preventDefault(),this._removeAt(i,Math.min(i,this._values.length-2));return}let r=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0,n=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0,o=r||n;if(!o)return;t.preventDefault();let l=Math.max(0,Math.min(this._values.length-1,i+o));t.ctrlKey&&r&&this.options.sortable?this._move(i,l,!0):this._list.querySelector(`[data-index="${l}"]`)?.focus()}_handleChipClick(t){let e=t.target instanceof Element?t.target:null,i=e?.closest("[data-index]");!i||this._disabled||(e.closest("[data-remove]")&&this.options.deletable?this._removeAt(Number(i.dataset.index)):i.focus())}_handleDragStart(t){if(this._disabled||!this.options.sortable)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;e&&(this._dragIndex=Number(e.dataset.index),this.el.dataset.state="dragging",t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"))}_handleDrop(t){if(this._dragIndex<0||this._disabled)return;t.preventDefault();let e=t.target instanceof Element?t.target.closest("[data-index]"):null,i=e?Number(e.dataset.index):this._values.length-1;this._move(this._dragIndex,i,!0),this._finishDrag()}_finishDrag(){this._dragIndex=-1,this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_move(t,e,i){if(t===e||t<0||e<0||t>=this._values.length||e>=this._values.length)return;let[r]=this._values.splice(t,1);this._values.splice(e,0,r),this._renderChips(i?e:-1),this.emit("change",{values:this.getValues()})}_removeAt(t,e=-1){let[i]=this._values.splice(t,1);i!==void 0&&(this._renderChips(e),e<0&&this._values.length===0&&this._input.focus(),this.emit("remove",{value:i}),this.emit("change",{values:this.getValues()}))}_showError(t){this._status.textContent=t,this._input.setAttribute("aria-invalid","true")}destroy(){for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function as(s,t){if(!Array.isArray(s))return[];let e=s.map(i=>String(i));return t?[...new Set(e)]:e}function ls(){b.register("valuelist",(s,t)=>{let e=s.own(new Gt(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.values})),{el:e.el,get:()=>e.getValues(),set:i=>e.setValues(Array.isArray(i)?i:[],{silent:!0}),focus:()=>e.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var Xt=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),fn=["xl","lg","md","sm"];function cs(s){let t=Number(s);if(!Number.isFinite(t))return"xs";for(let e of fn)if(t>=Xt[e])return e;return"xs"}function us(s,t={}){if(typeof s!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in t&&!D(t.target)&&t.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let e=t.target??globalThis,i=D(e)?e:null,r=null,n=!1,o=null,l=()=>i?i.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,c=()=>{if(n)return;let p=l();if(i&&p===0)return;let f=cs(p);f!==r&&(r=f,s(r,p))};c();let u=0,h=()=>{u||n||(u=requestAnimationFrame(()=>{u=0,c()}))};return i&&typeof ResizeObserver=="function"?(o=new ResizeObserver(h),o.observe(i)):globalThis.addEventListener?.("resize",c,{passive:!0}),{current:()=>r??cs(l()),destroy:()=>{n||(n=!0,u&&cancelAnimationFrame(u),o?.disconnect(),globalThis.removeEventListener?.("resize",c))}}}function pn(s,t){return String(s).localeCompare(String(t))}function _n(s,t){return s-t}function mn(s,t){return s.getTime()-t.getTime()}function gn(s,t,e="asc"){let i=s==null,r=t==null;if(i||r)return i&&r?0:i?1:-1;let n;return s instanceof Date&&t instanceof Date?n=mn(s,t):typeof s=="number"&&typeof t=="number"?n=_n(s,t):n=pn(s,t),e==="desc"?-n:n}function bn(s,t="asc"){return(e,i)=>gn(s(e),s(i),t)}function hs(s,t,e="asc"){let i=bn(t,e);return s.map((r,n)=>({row:r,index:n})).sort((r,n)=>i(r.row,n.row)||r.index-n.index).map(({row:r})=>r)}var yn=new Set(["text","number","select","date","checkbox","textarea"]),xn='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',yt=class extends g{static cssName="table";static defaults={columns:[],data:[],rowId:"ID",sort:null,sortMode:"local",selectable:!1,stickyHeader:!0,responsive:!1,growing:!1,height:null,emptyText:null,rowClass:null,zebra:!0,editMode:!1};constructor(t,e={}){super(t,e)}render(){let t=this.el??a("div");return this.el=t,this._originalChildren=this.el?Array.from(this.el.childNodes):null,this._columns=Array.isArray(this.options.columns)?this.options.columns.map(e=>({...e})):[],this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._selected=new Set,this._selectionAnchorId=null,this._sort=Cn(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=zn(this.options.editMode),this._edit=null,this._editMessage=null,this._stacked=!1,this._width=null,this._growStep=Tn(this.options.growing),this._rendered=this._growStep??1/0,this._more=null,this._rovingKey=null,this._rovingCell=null,this._rovingMatched=!1,this._sort&&this.options.sortMode==="local"&&this._sortData(),this._table=a("table",{class:"zx-table__table"}),this._colgroup=a("colgroup",{class:"zx-table__columns"}),this._thead=a("thead",{class:"zx-table__head"}),this._tbody=a("tbody",{class:"zx-table__body"}),this._table.append(this._colgroup,this._thead,this._tbody),this._scroll=a("div",{class:"zx-table__scroll",dataset:{stickyHeader:String(!!this.options.stickyHeader),zebra:String(!!this.options.zebra)}},this._table),this.options.height!=null&&(this._scroll.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._editMode===!1?t.replaceChildren(this._scroll):(t.dataset.editMode=this._editMode,this._editMessage=a("div",{class:"zx-table__message",id:w("zx-table-message"),role:"status",ariaLive:"polite"}),t.replaceChildren(this._scroll,this._editMessage)),this._renderColumns(),this._renderHeader(),this._renderBody(),this._watchWidth(),this.listen(this._tbody,"click",e=>this._handleBodyClick(e)),this.listen(this._tbody,"dblclick",e=>this._handleBodyDoubleClick(e)),this._editMode!==!1&&(this.listen(this._tbody,"keydown",e=>this._handleEditKeydown(e)),this.listen(this._tbody,"focusin",e=>this._handleEditFocusIn(e)),this.listen(document,"pointerdown",e=>this._handleDocumentPointerDown(e),{capture:!0})),t}setLoading(t=!0){return t?this.el.dataset.loading="true":delete this.el.dataset.loading,this.el.setAttribute("aria-busy",String(!!t)),this}setData(t){this._rendered=this._growStep??1/0,this.setLoading(!1),fs(t),this._data=[...t],this._sort&&this.options.sortMode==="local"&&this._sortData();let e=this._pruneSelection();return this._renderBody(),e&&this._emitSelectionChange(),this._emitDataChange(),this}addData(t){return fs(t),this._data.push(...t),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._renderBody(),this._emitDataChange(),this}updateRow(t,e){let i=this._data.findIndex(n=>Object.is(this._idFor(n),t));if(i<0)return this;let r=this._selected.delete(t);return this._data[i]=e,r&&this._selected.add(this._idFor(e)),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._renderBody(),r&&!Object.is(t,this._idFor(e))&&this._emitSelectionChange(),this._emitDataChange(),this}removeRow(t){let e=this._data.findIndex(r=>Object.is(this._idFor(r),t));if(e<0)return this;this._data.splice(e,1);let i=this._selected.delete(t);return Object.is(this._selectionAnchorId,t)&&(this._selectionAnchorId=null),this._renderBody(),i&&this._emitSelectionChange(),this._emitDataChange(),this}getRow(t){return this._data.find(e=>Object.is(this._idFor(e),t))??null}getData(){return[...this._data]}empty(){let t=this._selected.size>0;return this._data=[],this._selected.clear(),this._selectionAnchorId=null,this._renderBody(),t&&this._emitSelectionChange(),this._emitDataChange(),this}setSort(t,e,i={}){if(this._abortEdit({focus:!1}),!this._columns.find(o=>o.id===t))throw new RangeError(`Unknown table column: ${t}`);let n=e??(this._sort?.id===t&&this._sort.dir==="asc"?"desc":"asc");if(n!=="asc"&&n!=="desc")throw new TypeError('Table sort direction must be "asc" or "desc"');return this._sort={id:t,dir:n},this.options.sortMode==="local"&&(this._sortData(),this._renderBody()),this._syncSortHeader(),i.silent||this.emit("sort",{id:t,dir:n}),this}getSelection(){return this._data.filter(t=>this._selected.has(this._idFor(t)))}setSelection(t){if(!Array.isArray(t))throw new TypeError("Table selection must be an array of row ids");let e=new Set(this._data.map(r=>this._idFor(r))),i=new Set;if(this.options.selectable!==!1){for(let r of t)if(e.has(r)&&i.add(r),this.options.selectable==="single"&&i.size>0)break}return In(this._selected,i)?this:(this._selected=i,this._syncSelection(),this._emitSelectionChange(),this)}clearSelection(){return this._selected.size===0?this:(this._selected.clear(),this._selectionAnchorId=null,this._syncSelection(),this._emitSelectionChange(),this)}startEdit(t,e){if(this._editMode===!1)return this;let i=this._columns.find(h=>h.id===e);if(!i)return this;let r=this._data.find(h=>Object.is(this._idFor(h),t));if(r===void 0||bt(i,r)===!1)return this;if(this._edit){if(Object.is(this._edit.id,t)&&this._edit.cells.has(e))return this._edit.columnId=e,this._focusEditor(e),this;if(this.commitEdit(),this._edit)return this}let n=this._data.findIndex(h=>Object.is(this._idFor(h),t));if(n<0)return this;let o=this._data[n],l=this._rowElements.get(t)?.[0];if(!l)return this;let c=this._editMode==="row"?this._columns.filter(h=>bt(h,o)!==!1):[i],u=new Map;for(let h of c){let p=ds(l,h.id);if(!p)continue;let f=this._createEditor(p,h,o,n);f&&u.set(h.id,f)}return u.size===0?this:(this._edit={id:t,columnId:e,row:o,cells:u,tr:l},l.dataset.editing="true",this.emit("editstart",{row:o,id:t,column:i,columnId:e,value:o?.[e]}),this._focusEditor(e),this)}commitEdit(){let t=this._edit;if(!t)return this;let e=this.getRow(t.id)??t.row,i={};for(let[p,f]of t.cells)i[p]=f.read();let r=this._columns.filter(p=>t.cells.has(p.id)),n=Sn(i,r,e,this._msgOr("table.invalid","Invalid value"));if(n)return this._markInvalid(n.columnId,n.message),t.columnId=n.columnId,this.emit("editinvalid",{row:e,id:t.id,column:this._columns.find(p=>p.id===n.columnId)??null,columnId:n.columnId,value:i[n.columnId],message:n.message}),this._focusEditor(n.columnId),this;this._clearInvalid();let o=An(e,i),l=t.columnId;if(this.emit("editcommit",{row:e,id:t.id,column:this._columns.find(p=>p.id===l)??null,columnId:l,value:i[l],previous:e?.[l],changes:o}).defaultPrevented)return this;let u=this._editHasFocus(),h={...e,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(t.id,h),u&&this._focusCell(this._idFor(h),l),this}cancelEdit(){return this._abortEdit({focus:!0}),this}isEditing(){return this._edit!==null}getEditing(){return this._edit?{id:this._edit.id,columnId:this._edit.columnId}:null}_visibleData(){return this._rendered===1/0?this._data:this._data.slice(0,this._rendered)}growBy(t){if(!this._growStep)return this;let e=Number(t)>0?Math.trunc(Number(t)):this._growStep,i=this._rendered;return this._rendered=Math.min(this._data.length,this._rendered+e),this._rendered===i?this:(this._renderBody(),this.emit("grow",{rendered:this._rendered,total:this._data.length}),this)}showAll(){return this.growBy(this._data.length)}getRenderedCount(){return Math.min(this._rendered,this._data.length)}_syncGrowing(){if(!this._growStep)return;let t=this._data.length-this.getRenderedCount();if(t<=0){this._more?.remove(),this._more=null;return}let e=this._message("table.more","Show %1 more",[t]);this._more||(this._more=a("button",{class:"zx-table__more",type:"button",onclick:()=>this.growBy()}),this.el.append(this._more)),this._more.textContent=e,this._more.setAttribute("aria-label",e)}_message(t,e,i){let r=this.msg(t,...i);return r===t?M(e,i):r}_watchWidth(){this._width?.destroy(),this._width=null;let t=this.options.responsive;!t||!(t in Xt)||(this._width=us((e,i)=>this._setStacked(i>0&&i<Xt[t]),{target:this.el}))}_setStacked(t){this._stacked!==t&&(this._stacked=t,this.el.toggleAttribute("data-stacked",t),this._applyStackedRoles(t),this.emit("stackedchange",{stacked:t}))}_applyStackedRoles(t){let e=[[this._table,"table"],[this._thead,"rowgroup"],[this._tbody,"rowgroup"]];for(let[i,r]of e)i&&(t?i.setAttribute("role",r):i.removeAttribute("role"));for(let[i,r]of[["tr","row"],["td","cell"],["th","columnheader"]])for(let n of this._table.querySelectorAll(i))t?n.setAttribute("role",r):n.removeAttribute("role")}isStacked(){return!!this._stacked}destroy(){this._teardownEdit(),this._width?.destroy(),this._width=null,this.el&&delete this.el.dataset.editMode,!this._restored&&this._originalChildren&&(this.el.replaceChildren(...this._originalChildren),this._restored=!0),super.destroy()}_renderColumns(){let t=document.createDocumentFragment();this.options.selectable==="multi"&&t.append(a("col",{class:"zx-table__selection-column"}));let e=this._columns.map(r=>Mn(r.width)),i=e.reduce((r,n)=>r+n,0);this._table.dataset.layout=i>0?"fixed":"auto",this._columns.forEach((r,n)=>{let o=a("col");e[n]>0?o.style.width=`${e[n]/i*100}%`:r.width&&r.width!=="auto"&&(o.style.width=String(r.width)),t.append(o)}),this._colgroup.replaceChildren(t)}_renderHeader(){let t=a("tr",{class:"zx-table__header-row"});if(this._growStep&&t.setAttribute("aria-rowindex","1"),this.options.selectable==="multi"){this._selectAll=a("input",{class:"zx-table__checkbox zx-table__select-all",type:"checkbox",ariaLabel:"Select all rows"});let e=a("th",{class:"zx-table__selection-header",scope:"col"},this._selectAll);t.append(e),this.listen(this._selectAll,"click",()=>{if(this._selectAll.checked)for(let i of this._visibleData())this._selected.add(this._idFor(i));else for(let i of this._visibleData())this._selected.delete(this._idFor(i));this._selectionAnchorId=null,this._syncSelection(),this._emitSelectionChange()})}else this._selectAll=null;this._headers=new Map;for(let e of this._columns){let i=a("th",{scope:"col"});if(e.align&&(i.dataset.align=e.align),e.headerTitle&&(i.title=e.headerTitle),e.sortable){let r=a("button",{class:"zx-table__sort-button",type:"button"},a("span",{class:"zx-table__header-label"},e.label));this.listen(r,"click",()=>{let n=this._sort?.id===e.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(e.id,n)}),i.append(r)}else i.append(a("span",{class:"zx-table__header-label"},e.label));this._headers.set(e.id,i),t.append(i)}this._thead.replaceChildren(t),this._syncSortHeader()}_renderBody(){this._abortEdit({focus:!1});let t=document.createDocumentFragment();this._rowMeta=new WeakMap,this._rowElements=new Map,this._rovingCell=null,this._rovingMatched=!1,this._data.length===0?t.append(a("tr",{class:"zx-table__empty-row"},a("td",{class:"zx-table__empty",colspan:this._columns.length+(this.options.selectable==="multi"?1:0)},this._emptyContent()))):this._visibleData().forEach((e,i)=>t.append(this._createRow(e,i))),this._tbody.replaceChildren(t),this._growStep&&this._table.setAttribute("aria-rowcount",String(this._data.length+1)),this._syncSelectAll(),this._syncGrowing(),this._stacked&&this._applyStackedRoles(!0)}_emptyContent(){let t=this.options.emptyText;return t==null?this.msg("table.empty"):typeof t=="function"?t():t}_createRow(t,e){let i=this._idFor(t),r=a("tr",{dataset:{row:""}});this._growStep&&r.setAttribute("aria-rowindex",String(e+2));let n=typeof this.options.rowClass=="function"?this.options.rowClass(t):"";n&&r.classList.add(...String(n).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&r.setAttribute("aria-selected",String(this._selected.has(i))),this._rowMeta.set(r,{row:t,id:i,index:e});let o=this._rowElements.get(i)??[];if(o.push(r),this._rowElements.set(i,o),this.options.selectable==="multi"){let l=a("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",checked:this._selected.has(i),ariaLabel:`Select row ${e+1}`});r.append(a("td",{class:"zx-table__selection-cell"},l))}return this._columns.forEach(l=>{let c=a("td");l.align&&(c.dataset.align=l.align),c.dataset.label=l.label,l.popin===!1&&(c.dataset.popin="false"),this._editMode!==!1&&(c.dataset.column=l.id,bt(l,t)!==!1&&(c.dataset.editable="true",c.tabIndex=-1,this._offerRovingCell(c,i,l.id))),this._renderCellContent(c,l,t,e),r.append(c)}),r}_renderCellContent(t,e,i,r){let n=typeof e.render=="function"?e.render(i,r):i?.[e.id];n&&typeof n=="object"&&typeof n.nodeType=="number"?t.replaceChildren(n):n!=null?t.replaceChildren(document.createTextNode(String(n))):t.replaceChildren()}_handleBodyClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(this._edit&&Jt(e))return;let i=e?.closest("tr[data-row]");if(!i||!this._tbody.contains(i))return;let r=this._rowMeta.get(i);if(!r)return;this._edit&&this.commitEdit();let n=e.closest(".zx-table__row-checkbox");if(n&&this.options.selectable==="multi"){this._toggleMultiSelection(r,n.checked,t.shiftKey);return}this.emit("rowclick",{...r,event:t}),this.options.selectable==="single"&&!this._selected.has(r.id)&&(this._selected=new Set([r.id]),this._selectionAnchorId=r.id,this._syncSelection(),this._emitSelectionChange())}_handleBodyDoubleClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(e?.closest(".zx-table__row-checkbox")||this._edit&&Jt(e))return;let i=e?.closest("tr[data-row]");if(!i||!this._tbody.contains(i))return;let r=this._rowMeta.get(i);if(r){if(this._editMode!==!1){let n=e?.closest('td[data-editable="true"]');if(n&&this._tbody.contains(n)){this.startEdit(r.id,String(n.dataset.column));return}}this.emit("rowdblclick",{...r,event:t})}}_createEditor(t,e,i,r){let n=bt(e,i);if(n===!1)return null;let o=i?.[e.id],l=e.editorProps&&typeof e.editorProps=="object"?e.editorProps:{},c=a("span",{class:"zx-table__cell-shadow",ariaHidden:"true"});c.append(...t.childNodes);let u=a("div",{class:"zx-table__editor",dataset:{editor:n}});t.replaceChildren(c,u),t.dataset.editing="true";let h={column:e,type:n,td:t,host:u,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(n==="custom"){h.custom=o,h.read=()=>Z(e,h.custom,i);let d={value:o,row:i,column:e,commit:y=>{h.custom=y,this.commitEdit()},cancel:()=>this.cancelEdit()},_=e.editor(i,d);return _&&typeof _.toElement=="function"?(typeof _.destroy=="function"&&(h.component=_),u.append(_.toElement())):_&&u.append(_),h.control=u.querySelector(xn)??u,h}if(n==="number"){let d=new rt(null,{...l,value:o??null});return u.append(d.el),h.component=d,h.control=d.getInput(),h.read=()=>(d.set(d.getInput().value,{silent:!0}),Z(e,d.get(),i)),h}if(n==="select"){let d=vn(e.options,i),_=d.find(v=>Object.is(v.value,o))??d.find(v=>String(v.value)===String(o??"")),y=new I(null,{...l,items:d,valueKey:"value",labelKey:"label",value:_?_.value:null});return u.append(y.el),h.component=y,h.control=y.refs.input,h.read=()=>Z(e,y.value,i),h}if(n==="date"){let d=new W(null,{...l,value:o??null});u.append(d.el),h.component=d;let _=d.refs.input;return h.control=_,h.read=()=>{let y=String(_.value??"").trim(),v=d.get();return y===""?Z(e,null,i):(d.set(y,{silent:!0}),d.get()===null&&d.set(v,{silent:!0}),Z(e,d.get(),i))},h}if(n==="checkbox"){let d=new nt(null,{...l,checked:!!o});return u.append(d.el),h.component=d,h.control=d.el,h.read=()=>Z(e,d.get(),i),h}let p=n==="textarea",f=a(p?"textarea":"input",{...l,class:p?"zx-table__editor-input zx-table__editor-textarea":"zx-table__editor-input",...p?{}:{type:"text"},ariaLabel:l.ariaLabel??`${e.label} row ${r+1}`,value:wn(e,o,i)});return u.append(f),h.control=f,h.read=()=>Z(e,f.value,i),h}_focusEditor(t){let e=this._edit?.cells.get(t),i=e?.control;!i||typeof i.focus!="function"||(i.focus(),e.type==="text"&&typeof i.select=="function"&&i.select())}_focusCell(t,e){let i=this._rowElements.get(t)?.[0];(i?ds(i,e):null)?.focus()}_teardownEdit(){let t=this._edit;if(!t)return;this._edit=null;let e=this._data.findIndex(r=>Object.is(this._idFor(r),t.id)),i=e<0?t.row:this._data[e];for(let r of t.cells.values())r.destroy(),delete r.td.dataset.editing,delete r.td.dataset.invalid,this._renderCellContent(r.td,r.column,i,e<0?0:e);t.cells.clear(),delete t.tr.dataset.editing,this._clearInvalid()}_abortEdit({focus:t=!0}={}){let e=this._edit;if(!e)return;let i=t&&this._editHasFocus(),r=this.getRow(e.id)??e.row,n=this._columns.find(o=>o.id===e.columnId)??null;this._teardownEdit(),i&&this._focusCell(e.id,e.columnId),this.emit("editcancel",{row:r,id:e.id,column:n,columnId:e.columnId})}_editHasFocus(){let t=document.activeElement;return!!(t&&this.el?.contains(t))}_markInvalid(t,e){this._clearInvalid();let i=this._edit?.cells.get(t);i&&(i.td.dataset.invalid="true",i.control?.setAttribute("aria-invalid","true"),this._editMessage&&(i.control?.setAttribute("aria-describedby",this._editMessage.id),this._editMessage.textContent=e))}_clearInvalid(){if(this._edit)for(let t of this._edit.cells.values())delete t.td.dataset.invalid,t.control?.removeAttribute("aria-invalid"),t.control?.removeAttribute("aria-describedby");this._editMessage&&(this._editMessage.textContent="")}_handleEditKeydown(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(!e)return;if(this._edit&&Jt(e)){if(Dn(e))return;if(t.key==="Escape"){if(t.defaultPrevented)return;t.preventDefault(),this.cancelEdit();return}if(t.key==="Enter"){if(e.localName==="textarea"&&t.shiftKey)return;t.preventDefault(),this.commitEdit();return}t.key==="Tab"&&this._moveEdit(t);return}if(t.key!=="Enter"&&t.key!=="F2")return;let i=e.closest('td[data-editable="true"]');if(!i||!this._tbody.contains(i))return;let r=this._rowMeta.get(i.parentElement);r&&(t.preventDefault(),this.startEdit(r.id,String(i.dataset.column)))}_moveEdit(t){let e=this._edit;if(!e)return;let i=t.shiftKey?-1:1,r=this._data.findIndex(o=>Object.is(this._idFor(o),e.id)),n=this._nextEditableCell(r,e.columnId,i);if(n&&Object.is(n.id,e.id)&&e.cells.has(n.columnId)){t.preventDefault(),e.columnId=n.columnId,this._focusEditor(n.columnId);return}if(!n){this.commitEdit(),this._edit&&t.preventDefault();return}t.preventDefault(),this.commitEdit(),this._edit||this.startEdit(n.id,n.columnId)}_nextEditableCell(t,e,i){let r=this._columns.length;if(t<0||r===0)return null;let n=t,o=this._columns.findIndex(c=>c.id===e),l=this._data.length*r+r;for(let c=0;c<l;c+=1){if(o+=i,o>=r?(n+=1,o=0):o<0&&(n-=1,o=r-1),n<0||n>=this._data.length)return null;let u=this._data[n],h=this._columns[o];if(bt(h,u)!==!1)return{id:this._idFor(u),columnId:h.id,index:n}}return null}_handleEditFocusIn(t){let i=(t.target?.nodeType===1?t.target:null)?.closest('td[data-editable="true"]');if(!i||!this._tbody.contains(i))return;let r=this._rowMeta.get(i.parentElement);r&&this._setRovingCell(i,r.id,String(i.dataset.column))}_handleDocumentPointerDown(t){if(!this._edit)return;let e=t.target?.nodeType===1?t.target:t.target?.parentElement;e&&Jt(e)||e&&this._tbody.contains(e)||this.commitEdit()}_offerRovingCell(t,e,i){if(this._rovingMatched)return;let r=this._rovingKey!==null&&Object.is(this._rovingKey.id,e)&&this._rovingKey.columnId===i;!r&&this._rovingCell||(r&&this._rovingCell&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=r)}_setRovingCell(t,e,i){this._rovingCell&&this._rovingCell!==t&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=!0,this._rovingKey={id:e,columnId:i}}_msgOr(t,e){let i=this.msg(t);return i===t?e:i}_toggleMultiSelection(t,e,i){let r=this._data.findIndex(n=>Object.is(this._idFor(n),this._selectionAnchorId));if(i&&r>=0){let n=Math.min(r,t.index),o=Math.max(r,t.index);for(let l=n;l<=o;l+=1){let c=this._idFor(this._data[l]);e?this._selected.add(c):this._selected.delete(c)}}else e?this._selected.add(t.id):this._selected.delete(t.id);this._selectionAnchorId=t.id,this._syncSelection(),this._emitSelectionChange()}_syncSelection(){for(let[t,e]of this._rowElements){let i=this._selected.has(t);for(let r of e){r.setAttribute("aria-selected",String(i));let n=r.querySelector(".zx-table__row-checkbox");n&&(n.checked=i)}}this._syncSelectAll()}_syncSelectAll(){if(!this._selectAll)return;let t=this._visibleData(),e=t.reduce((i,r)=>i+Number(this._selected.has(this._idFor(r))),0);this._selectAll.disabled=t.length===0,this._selectAll.checked=t.length>0&&e===t.length,this._selectAll.indeterminate=e>0&&e<t.length}_syncSortHeader(){if(this._headers)for(let[t,e]of this._headers)this._sort?.id===t?e.setAttribute("aria-sort",this._sort.dir==="asc"?"ascending":"descending"):e.removeAttribute("aria-sort")}_sortData(){if(!this._sort)return;let t=this._columns.find(i=>i.id===this._sort.id);if(!t)return;let e=typeof t.sortValue=="function"?t.sortValue:i=>i?.[t.id];this._data=hs(this._data,e,this._sort.dir)}_pruneSelection(){let t=new Set(this._data.map(i=>this._idFor(i))),e=this._selected.size;for(let i of this._selected)t.has(i)||this._selected.delete(i);return t.has(this._selectionAnchorId)||(this._selectionAnchorId=null),e!==this._selected.size}_idFor(t){return typeof this.options.rowId=="function"?this.options.rowId(t):t?.[this.options.rowId]}_emitSelectionChange(){let t=this.getSelection();this.emit("selectionchange",{rows:t,ids:t.map(e=>this._idFor(e))})}_emitDataChange(){this.emit("datachange",{rows:this.getData()})}};function bt(s,t){if(!s||typeof s!="object")return!1;if(typeof s.editor=="function")return typeof s.editable=="function"&&s.editable(t)===!1?!1:"custom";let e=typeof s.editable=="function"?s.editable(t):s.editable;return e===!0?"text":typeof e=="string"&&yn.has(e)?e:!1}function vn(s,t){let e=typeof s=="function"?s(t):s;return Array.isArray(e)?e.map(i=>i!==null&&typeof i=="object"?{value:i.value,label:String(i.label??i.value??"")}:{value:i,label:String(i??"")}):e!==null&&typeof e=="object"?Object.entries(e).map(([i,r])=>({value:i,label:String(r??"")})):[]}function wn(s,t,e){if(typeof s?.format=="function"){let i=s.format(t,e);return i==null?"":String(i)}return t==null?"":String(t)}function Z(s,t,e){return typeof s?.parse=="function"?s.parse(t,e):t}function kn(s,t){return Object.is(s,t)?!0:s instanceof Date&&t instanceof Date?s.getTime()===t.getTime():!1}function An(s,t){let e={};for(let[i,r]of Object.entries(t??{}))kn(s?.[i],r)||(e[i]=r);return e}function Sn(s,t,e,i="Invalid value"){for(let r of t??[]){if(typeof r?.validate!="function"||!Object.prototype.hasOwnProperty.call(s??{},r.id))continue;let n=r.validate(s[r.id],e);if(typeof n=="string")return{columnId:r.id,message:n};if(n===!1)return{columnId:r.id,message:i}}return null}function zn(s){return s==="cell"||s==="row"?s:s===!0?"cell":!1}function Jt(s){return!!s?.closest?.(".zx-table__editor")}function Dn(s){return s.closest("[popover]")?!0:s.getAttribute?.("aria-expanded")==="true"}function ds(s,t){for(let e of s.cells)if(e.dataset.column===t)return e;return null}function Cn(s,t){return!s||typeof s!="object"||!t.some(e=>e.id===s.id)?null:{id:s.id,dir:s.dir==="desc"?"desc":"asc"}}function Mn(s){if(typeof s!="string")return 0;let t=/^(\d*\.?\d+)fr$/.exec(s.trim());return t?Math.max(0,Number(t[1])):0}function fs(s){if(!Array.isArray(s))throw new TypeError("Table data must be an array")}function In(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}function Tn(s){let t=Math.trunc(Number(s));return Number.isFinite(t)&&t>0?t:null}var De=class{#t;#e=[];#i=[];#s;constructor(t=5,e=()=>{}){if(!Number.isInteger(t)||t<1)throw new RangeError("Queue limit must be positive");if(typeof e!="function")throw new TypeError("Activation callback must be a function");this.#t=t,this.#s=e}enqueue(t){return this.#e.length<this.#t?(this.#e.push(t),this.#s(t),"active"):(this.#i.push(t),"pending")}remove(t){let e=this.#i.indexOf(t);if(e!==-1)return this.#i.splice(e,1),"pending";let i=this.#e.indexOf(t);if(i===-1)return null;if(this.#e.splice(i,1),this.#i.length>0){let r=this.#i.shift();this.#e.push(r),this.#s(r)}return"active"}isActive(t){return this.#e.includes(t)}clear(){let t={active:this.#e.slice(),pending:this.#i.slice()};return this.#e.length=0,this.#i.length=0,t}get activeCount(){return this.#e.length}get pendingCount(){return this.#i.length}},G=class s extends g{static cssName="message";static defaults={kind:"info",timeout:4e3,closable:!0,maxVisible:5};static#t=null;render(){let t=!this.el,e=this.el??a("div");return this._createdRoot=t,this._original=t?null:Vn(e),this._entries=new Set,this._queue=new De(Fn(this.options.maxVisible),i=>{this._activate(i)}),e.replaceChildren(),e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e}show(t,e={}){let i={kind:En(e.kind??this.options.kind),timeout:Nn(e.timeout??this.options.timeout),closable:e.closable??!!this.options.closable},r=this._createEntry(t,i);return this._entries.add(r),this._queue.enqueue(r),{close:()=>this._close(r)}}static info(t,e={}){return this.show(t,{...e,kind:"info"})}static success(t,e={}){return this.show(t,{...e,kind:"success"})}static warning(t,e={}){return this.show(t,{...e,kind:"warning"})}static error(t,e={}){return this.show(t,{...e,kind:"error"})}static show(t,e={}){return this.#e().show(t,e)}static progress(t){return this.#e()._progress(t)}destroy(){if(!this._cleaned){this._cleaned=!0;for(let t of this._entries)ze(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&Pn(this.el,this._original)}}_progress(t){let e={pct:0,text:String(t)},i=this._createEntry(e.text,{kind:"info",timeout:0,closable:!1},e);this._entries.add(i),this._queue.enqueue(i);let r=!1;return{update:(n,o)=>{r||i.closed||(e.pct=Ln(n),o!==void 0&&(e.text=String(o)),te(i,e))},done:()=>{r||i.closed||(r=!0,e.pct=100,te(i,e),i.remaining=600,this._queue.isActive(i)&&this._schedule(i))},fail:n=>{r||i.closed||(r=!0,n!==void 0&&(e.text=String(n)),i.kind="error",i.node.dataset.kind="error",i.node.setAttribute("role","alert"),i.iconHost.replaceChildren(m("error",{size:18})),te(i,e),i.remaining=4e3,this._queue.isActive(i)&&this._schedule(i))}}}_createEntry(t,e,i=null){let r=a("span",{class:"zx-message__icon",ariaHidden:"true"},m(e.kind,{size:18})),n=a("div",{class:"zx-message__content"});On(t)?n.append(t):n.append(document.createTextNode(String(t)));let o=a("div",{class:"zx-message__toast",role:e.kind==="error"?"alert":"status",dataset:{kind:e.kind,state:"queued"}},r,n),l={node:o,content:n,iconHost:r,kind:e.kind,timeout:e.timeout,remaining:e.timeout,startedAt:0,timer:null,exitTimer:null,closed:!1,progressBar:null,progressFill:null};if(i){o.dataset.progress="";let c=a("span",{class:"zx-message__progress-fill"}),u=a("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:i.text},c);n.append(u),l.progressBar=u,l.progressFill=c,te(l,i)}if(e.closable){let c=a("button",{class:"zx-icon-btn zx-message__close",type:"button",ariaLabel:"Close message",title:"Close"},m("x",{size:14}));o.append(c),this.listen(c,"click",()=>this._close(l))}return this.listen(o,"mouseenter",()=>this._pause(l)),this.listen(o,"mouseleave",()=>this._resume(l)),l}_activate(t){t.closed||(t.node.dataset.state="open",this.el.append(t.node),this._schedule(t))}_schedule(t){t.closed||t.remaining<=0||(t.startedAt=Date.now(),t.timer=setTimeout(()=>this._close(t),t.remaining))}_pause(t){t.closed||t.timer===null||(clearTimeout(t.timer),t.timer=null,t.remaining=Math.max(0,t.remaining-(Date.now()-t.startedAt)))}_resume(t){if(!(t.closed||t.timer!==null)){if(t.remaining<=0){this._close(t);return}this._schedule(t)}}_close(t){if(t.closed)return;if(t.closed=!0,ze(t),!this._queue.isActive(t)){this._queue.remove(t),t.node.remove(),this._entries.delete(t);return}if(t.node.dataset.state="closing",!jn()){this._finish(t);return}let e=i=>{i.target===t.node&&this._finish(t)};this.listen(t.node,"animationend",e,{once:!0}),t.exitTimer=setTimeout(()=>this._finish(t),260)}_finish(t){this._entries.has(t)&&(ze(t),t.node.remove(),this._entries.delete(t),this._queue.remove(t))}static#e(){if(this.#t)return this.#t;let t=a("div",{class:"zx-message-region",popover:"manual",role:"status",ariaLive:"polite"});return document.body.append(t),this.#t=new s(t),typeof t.showPopover=="function"&&t.showPopover(),this.#t}};function En(s){return s==="danger"?"error":["success","warning","error"].includes(String(s))?s:"info"}function Nn(s){let t=Number(s);return Number.isFinite(t)?Math.max(0,t):4e3}function Fn(s){let t=Number(s);return Number.isInteger(t)&&t>0?t:5}function On(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Ln(s){let t=Number(s);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function te(s,t){s.content.firstChild.textContent=t.text,s.progressBar?.setAttribute("aria-valuenow",String(t.pct)),s.progressBar?.setAttribute("aria-label",t.text),s.progressFill&&(s.progressFill.style.inlineSize=`${t.pct}%`)}function ze(s){s.timer!==null&&clearTimeout(s.timer),s.exitTimer!==null&&clearTimeout(s.exitTimer),s.timer=null,s.exitTimer=null}function jn(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function Vn(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Pn(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}var xt=class extends g{static cssName="fieldset";static defaults={title:"",columns:1,fields:{}};render(){let t=this.el??a("fieldset");this._fields=new Map,this._ownedFields=new Set,this._origins=new Map,this._fieldIdAttributes=new Map,this._ownedNodes=[],this._columnAttribute=t.getAttribute("data-columns");let e=[1,2,3].includes(Number(this.options.columns))?Number(this.options.columns):1;if(t.dataset.columns=String(e),this.options.title){let r=a("legend",{class:"zx-fieldset__legend"},String(this.options.title));this._ownedNodes.push(r),t.append(r)}this._grid=a("div",{class:"zx-fieldset__grid"}),this._ownedNodes.push(this._grid),t.append(this._grid);let i=this.options.fields&&typeof this.options.fields=="object"?this.options.fields:{};for(let[r,n]of Object.entries(i))this.addField(r,n);return t}addField(t,e){let i=String(t);if(this._fields.has(i))throw new Error(`Field "${i}" already exists`);let r,n=!1;if(e instanceof b)r=e;else if(D(e)||e instanceof g){let o=e;r=new b(null,{id:i,type:"custom",label:i,value:Hn(o),disabled:qn(o),adapter:()=>Rn(o)}),n=!0}else{let o=e&&typeof e=="object"?e:{};r=new b(null,{...o,id:o.id??i}),n=!0}return n?this._ownedFields.add(r):this._origins.set(r,{parent:r.el.parentNode,next:r.el.nextSibling}),this._fields.set(i,r),this._fieldIdAttributes.set(r,r.el.getAttribute("data-field-id")),r.el.dataset.fieldId=i,this._grid.append(r.el),r}getField(t){return this._fields.get(String(t))??null}hasField(t){return this._fields.has(String(t))}getFields(){return Object.fromEntries(this._fields)}getValues(){let t={};for(let[e,i]of this._fields)t[e]=i.getValue();return t}setValues(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[i,r]of Object.entries(t))this._fields.get(i)?.setValue(r,{silent:e});return this}getValue(t){return this._fields.get(String(t))?.getValue()??null}setValue(t,e){return this._fields.get(String(t))?.setValue(e),this}reset(){for(let t of this._fields.values())t.reset();return this}clear(){for(let t of[...this._fields.values()])this._releaseField(t);return this._fields.clear(),this}focus(t){return this._fields.get(String(t))?.focus(),this}setHighlights(t={},e="danger"){let i=0;for(let[r,n]of this._fields){let o=t?.[r];o?(n.setHighlight(String(o),e),i+=1):n.clearHighlight()}return i}clearHighlights(){for(let t of this._fields.values())t.clearHighlight();return this}_releaseField(t){let e=this._fieldIdAttributes.get(t);if(e==null?t.el.removeAttribute("data-field-id"):t.el.setAttribute("data-field-id",e),this._fieldIdAttributes.delete(t),this._ownedFields.has(t)){t.destroy(),this._ownedFields.delete(t);return}let i=this._origins.get(t);i?.parent?i.parent.insertBefore(t.el,i.next?.parentNode===i.parent?i.next:null):t.el.remove(),this._origins.delete(t)}destroy(){this.clear();for(let t of this._ownedNodes??[])t.remove();this._columnAttribute===null?this.el.removeAttribute("data-columns"):this.el.setAttribute("data-columns",this._columnAttribute),super.destroy()}};function Rn(s){let t=D(s)?s:s.toElement(),e=t.parentNode,i=t.nextSibling,r=new Map(["id","aria-labelledby","aria-describedby","aria-disabled","aria-invalid"].map(l=>[l,t.getAttribute(l)])),n="disabled"in t?t.disabled:void 0,o="value"in t?t.value:void 0;return{el:t,get:()=>typeof s.getValue=="function"?s.getValue():typeof s.getValues=="function"?s.getValues():"value"in t?t.value:null,set:(l,c)=>{typeof s.setValue=="function"?s.setValue(l,c):typeof s.setValues=="function"&&l&&typeof l=="object"?s.setValues(l,c):"value"in t&&(t.value=l??"")},focus:()=>{typeof s.focus=="function"?s.focus():typeof t.focus=="function"&&t.focus()},setDisabled:l=>{typeof s.setDisabled=="function"?s.setDisabled(l):"disabled"in t?t.disabled=l:t.setAttribute("aria-disabled",String(l))},destroy:()=>{for(let[l,c]of r)c===null?t.removeAttribute(l):t.setAttribute(l,c);n!==void 0&&(t.disabled=n),o!==void 0&&(t.value=o),e?e.insertBefore(t,i?.parentNode===e?i:null):t.remove()}}}function Hn(s){let t=D(s)?s:s.toElement();return typeof s.getValue=="function"?s.getValue():typeof s.getValues=="function"?s.getValues():"value"in t?t.value:null}function qn(s){let t=D(s)?s:s.toElement();return"disabled"in t?!!t.disabled:t.getAttribute("aria-disabled")==="true"}var vt=class extends g{static cssName="form";static defaults={fieldsets:[],actions:[],novalidate:!0,msg:{"form.required":"This field is required.","form.int":"Enter a whole number.","form.float":"Enter a valid number."}};render(){let t=this.el??a("form");this._fieldsets=[],this._ownedFieldsets=new Set,this._origins=new Map,this._ownedNodes=[],this._novalidateAttribute=t.getAttribute("novalidate"),t.toggleAttribute("novalidate",!!this.options.novalidate),this._body=a("div",{class:"zx-form__body"}),this._actions=a("div",{class:"zx-form__actions"}),this._ownedNodes.push(this._body,this._actions),t.append(this._body,this._actions),this.listen(t,"submit",i=>{i.preventDefault(),this.submit()}),this.listen(t,"reset",i=>{i.preventDefault(),this.reset()}),this.listen(this._actions,"click",i=>this._handleAction(i));let e=Array.isArray(this.options.fieldsets)?this.options.fieldsets:[];for(let i of e)this.addFieldset(i);return this.setActions(Array.isArray(this.options.actions)?this.options.actions:[]),t}addFieldset(t){let e=!(t instanceof xt),i=e?new xt(null,t??{}):t;return this._fieldsets.includes(i)||(e?this._ownedFieldsets.add(i):this._origins.set(i,{parent:i.el.parentNode,next:i.el.nextSibling}),this._fieldsets.push(i),this._body.append(i.el),this.listen(i.el,"zx-change",r=>{let n=r.target,o=n instanceof Element?n.dataset.fieldId:null;o&&this.emit("change",{id:o,value:i.getValue(o)})})),i}setActions(t){return this._actionDescriptors=Array.isArray(t)?t.map(e=>({...e})):[],this._actions.replaceChildren(...this._actionDescriptors.map((e,i)=>{let r=String(e.label??e.id??"Action");return a("button",{class:"zx-btn",type:["submit","reset"].includes(e.type)?e.type:"button",disabled:!!e.disabled,title:e.title,ariaLabel:!r&&e.title?e.title:void 0,dataset:{actionIndex:i,kind:["primary","danger","ghost"].includes(e.kind)?e.kind:"default",size:e.size==="sm"?"sm":"md"}},e.icon?m(e.icon,{size:16}):null,r?a("span",{class:"zx-btn__label"},r):null)})),this._actions.hidden=this._actionDescriptors.length===0,this}getValues(){return Object.assign({},...this._fieldsets.map(t=>t.getValues()))}setValues(t,{silent:e=!1}={}){for(let i of this._fieldsets)i.setValues(t,{silent:e});return this}getField(t){for(let e of this._fieldsets){let i=e.getField(t);if(i)return i}return null}setValue(t,e){return this.getField(t)?.setValue(e),this}getValue(t){return this.getField(t)?.getValue()??null}reset(){for(let t of this._fieldsets)t.reset().clearHighlights();return this}setHighlights(t,e="danger"){return this._fieldsets.reduce((i,r)=>i+r.setHighlights(t,e),0)}clearHighlights(){for(let t of this._fieldsets)t.clearHighlights();return this}submit(){let t={},e=null;for(let r of this._fieldsets)for(let[n,o]of Object.entries(r.getFields())){let l=o.getValue(),c="";if(o.options.required&&Ce(l))c=this.msg("form.required");else if(!Ce(l)&&o.options.type==="int"){let u=ae(l);u.valid?o.setValue(u.value,{silent:!0}):c=this.msg("form.int")}else if(!Ce(l)&&o.options.type==="float"){let u=le(l);u.valid?o.setValue(u.value,{silent:!0}):c=this.msg("form.float")}c?(t[n]=c,o.setHighlight(c,"danger"),e??=o):o.clearHighlight()}return Object.keys(t).length?(this.emit("invalid",{errors:t}),e?.focus(),!1):!this.emit("submit",{values:this.getValues()}).defaultPrevented}_handleAction(t){let e=t.target instanceof Element?t.target.closest("[data-action-index]"):null;if(!e||!this._actions.contains(e))return;let i=this._actionDescriptors[Number(e.dataset.actionIndex)],r=i?.onClick??i?.onclick??i?.handler;typeof r=="function"&&r(t,this)}destroy(){for(let t of this._fieldsets??[])if(this._ownedFieldsets.has(t))t.destroy();else{let e=this._origins.get(t);e?.parent?e.parent.insertBefore(t.el,e.next?.parentNode===e.parent?e.next:null):t.el.remove()}this._fieldsets=[];for(let t of this._ownedNodes??[])t.remove();this._novalidateAttribute===null?this.el.removeAttribute("novalidate"):this.el.setAttribute("novalidate",this._novalidateAttribute),super.destroy()}};function Ce(s){return s==null||s===""||s===!1||Array.isArray(s)&&s.length===0}function Bn(){Ji(),li(),qi(),Ci(),Vi(),ns(),ls(),Wi(),$i(),os(),Zi(),Gi(),is(),ts()}Bn();function q(s,{onError:t,locale:e}={}){if(!s||typeof s!="object"||!s.api||typeof s.api!="object")throw new TypeError("connect() requires a ZeyOS client with an api namespace");if(t!=null&&typeof t!="function")throw new TypeError("onError must be a function");let i=e??$n(s);i&&oe(String(i));let r=(o,l)=>t?t(o,l):G.error(Kn(o)),n=async(o,l,c)=>{let u=Yn(s,o,l);try{return await s.api[u](c)}catch(h){try{r(h,{operation:u,resource:l})}catch{}throw h}};return{client:s,list:(o,l={})=>n("list",o,l),get:(o,l,c={})=>n("get",o,ps(l)?l:{ID:l,...c}),create:(o,l)=>n("create",o,l),update:(o,l,c)=>n("update",o,c===void 0&&ps(l)?l:{ID:l,body:c??{}}),reportError:r}}function $n(s){return s.locale??s.language??s.config?.locale??s.metadata?.locale??null}function Yn(s,t,e){let i=String(e??"").trim();if(!i)throw new TypeError("ZeyOS resource must not be empty");let r=typeof s.schema?.operations=="function"?s.schema.operations(i):[];if(Array.isArray(r)&&r.length){let f=r.filter(d=>typeof d=="string"&&d.toLowerCase().startsWith(t)).sort((d,_)=>d.length-_.length);if(f.length)return f[0]}let n=Array.isArray(r)&&r.length?r:typeof s.schema?.operationIds=="function"?s.schema.operationIds():Object.keys(s.api);if(n.includes(i)&&i.toLowerCase().startsWith(t))return i;let o=_s(i),l=ms(o),c=n.filter(f=>{if(typeof f!="string"||!f.toLowerCase().startsWith(t))return!1;let d=_s(f.slice(t.length));return d===o||d===l||ms(d)===l});if(c.length)return c.sort((f,d)=>f.length-d.length)[0];let u=t==="list"?[`list${Me(i)}`]:[`${t}${Me(Un(i))}`,`${t}${Me(i)}`],h=new Set(Object.keys(s.api)),p=u.find(f=>h.has(f));if(p)return p;throw new RangeError(`No ${t} operation found for ZeyOS resource "${i}"`)}function ps(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}function Kn(s){return s instanceof Error&&s.message||s&&typeof s=="object"&&typeof s.message=="string"?s.message:String(s??"ZeyOS request failed")}function _s(s){return String(s).replace(/[^a-z\d]/gi,"").toLowerCase()}function ms(s){return s.endsWith("ies")?`${s.slice(0,-3)}y`:s.endsWith("sses")?s.slice(0,-2):s.endsWith("s")&&!s.endsWith("ss")?s.slice(0,-1):s}function Un(s){let t=String(s);return/ies$/i.test(t)?`${t.slice(0,-3)}y`:/s$/i.test(t)&&!/ss$/i.test(t)?t.slice(0,-1):t}function Me(s){return String(s).split(/[^a-z\d]+/i).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}var X=Object.freeze({accounts:{label:"Accounts",icon:"zeyos-accounts",color:"#bc3885",fa:"building"},actionsteps:{label:"Action Steps",icon:"zeyos-actionsteps",color:"#f67f00",fa:"clock"},appointments:{label:"Appointments",icon:"zeyos-appointments",color:"#bd1e32",fa:"calendar-check"},billing:{label:"Billing",icon:"zeyos-billing",color:"#535494",fa:"file-invoice-dollar"},calendar:{label:"Calendar",icon:"zeyos-calendar",color:"#bd1e32",fa:"calendar-days"},campaigns:{label:"Campaigns",icon:"zeyos-campaigns",color:"#f16528",fa:"bullhorn"},collection:{label:"Collection",icon:"zeyos-collection",color:"#0d60ae",fa:"hand-holding-dollar"},contacts:{label:"Contacts",icon:"zeyos-contacts",color:"#8c6641",fa:"address-book"},contracts:{label:"Contracts",icon:"zeyos-contracts",color:"#823e89",fa:"file-contract"},coupons:{label:"Coupons",icon:"zeyos-coupons",color:"#10775c",fa:"ticket-simple"},devices:{label:"Devices",icon:"zeyos-devices",color:"#064e4f",fa:"desktop"},documents:{label:"Documents",icon:"zeyos-documents",color:"#808000",fa:"file"},dunning:{label:"Dunning",icon:"zeyos-dunning",color:"#0d60ae",fa:"file-invoice-dollar"},events:{label:"Events",icon:"zeyos-events",color:"#bd1e32",fa:"calendar-day"},inventory:{label:"Inventory",icon:"zeyos-inventory",color:"#064e4f",fa:"warehouse"},items:{label:"Items",icon:"zeyos-items",color:"#064e4f",fa:"box-open"},ledgers:{label:"Ledgers",icon:"zeyos-ledgers",color:"#4679c8",fa:"book-open"},line:{label:"Line Items",icon:"zeyos-line",color:"#064e4f",fa:"list-ul"},links:{label:"Links",icon:"zeyos-links",color:"#405e76",fa:"bookmark"},mailinglists:{label:"Mailing Lists",icon:"zeyos-mailinglists",color:"#0299ac",fa:"envelope-open-text"},messages:{label:"Messages",icon:"zeyos-messages",color:"#31a8e0",fa:"message"},"messages-unread":{label:"Unread Messages",icon:"zeyos-messages-unread",color:"#31a8e0",fa:"envelope"},notes:{label:"Notes",icon:"zeyos-notes",color:"#008853",fa:"note-sticky"},opportunities:{label:"Opportunities",icon:"zeyos-opportunities",color:"#7b67ae",fa:"handshake"},payments:{label:"Payments",icon:"zeyos-payments",color:"#4679c8",fa:"sack-dollar"},pricelists:{label:"Price Lists",icon:"zeyos-pricelists",color:"#10775c",fa:"clipboard-list"},procurement:{label:"Procurement",icon:"zeyos-procurement",color:"#006e9f",fa:"truck"},production:{label:"Production",icon:"zeyos-production",color:"#226375",fa:"industry"},projects:{label:"Projects",icon:"zeyos-projects",color:"#db532d",fa:"diagram-project"},stocktransactions:{label:"Stock Transactions",icon:"zeyos-stocktransactions",color:"#064e4f",fa:"arrow-right-arrow-left"},storages:{label:"Storages",icon:"zeyos-storages",color:"#064e4f",fa:"boxes-stacked"},tasks:{label:"Tasks",icon:"zeyos-tasks",color:"#e2b301",fa:"list-check"},text:{label:"Text Blocks",icon:"zeyos-text",color:"#064e4f",fa:"file-lines"},tickets:{label:"Tickets",icon:"zeyos-tickets",color:"#f04639",fa:"ticket"},"transactions-billing":{label:"Billing Transactions",icon:"zeyos-transactions-billing",color:"#535494",fa:"file-invoice"},"transactions-collection":{label:"Collection Transactions",icon:"zeyos-transactions-collection",color:"#0d60ae",fa:"money-bill-transfer"},"transactions-procurement":{label:"Procurement Transactions",icon:"zeyos-transactions-procurement",color:"#006e9f",fa:"cart-shopping"},"transactions-production":{label:"Production Transactions",icon:"zeyos-transactions-production",color:"#226375",fa:"gears"},zeyos:{label:"ZeyOS",icon:"zeyos",color:"#007a55",fa:"cloud"},default:{label:"Default",icon:"zeyos-default",color:"#21cc75",fa:"cube"},admin:{label:"Administration",icon:"zeyos-admin",color:"#4b5563",fa:"screwdriver-wrench"},applications:{label:"Applications",icon:"zeyos-applications",color:"#2563eb",fa:"window-maximize"},auth:{label:"Credentials",icon:"zeyos-auth",color:"#a16207",fa:"shield-halved"},categories:{label:"Categories",icon:"zeyos-categories",color:"#9a3412",fa:"folder-tree"},channels:{label:"Channels",icon:"zeyos-channels",color:"#0891b2",fa:"share-nodes"},control:{label:"Control Center",icon:"zeyos-control",color:"#0f766e",fa:"sliders"},davservers:{label:"DAV Servers",icon:"zeyos-davservers",color:"#475569",fa:"server"},dev:{label:"Development",icon:"zeyos-dev",color:"#1f2937",fa:"code"},error:{label:"Errors",icon:"zeyos-error",color:"#b91c1c",fa:"triangle-exclamation"},global:{label:"Global",icon:"zeyos-global",color:"#0369a1",fa:"globe"},groups:{label:"Groups",icon:"zeyos-groups",color:"#007a55",fa:"users"},logout:{label:"Logout",icon:"zeyos-logout",color:"#9f1239",fa:"right-from-bracket"},objects:{label:"Custom Objects",icon:"zeyos-objects",color:"#7e22ce",fa:"cubes"},participants:{label:"Participants",icon:"zeyos-participants",color:"#4338ca",fa:"user-group"},permissions:{label:"Permissions",icon:"zeyos-permissions",color:"#5b21b6",fa:"user-lock"},records:{label:"Records",icon:"zeyos-records",color:"#57534e",fa:"database"},resources:{label:"Resources",icon:"zeyos-resources",color:"#15803d",fa:"layer-group"},services:{label:"Services",icon:"zeyos-services",color:"#b45309",fa:"bell-concierge"},system:{label:"System",icon:"zeyos-system",color:"#374151",fa:"gear"},users:{label:"Users",icon:"zeyos-users",color:"#007a55",fa:"user"},weblets:{label:"Weblets",icon:"zeyos-weblets",color:"#4f46e5",fa:"window-restore"}}),bs=Object.freeze({addresses:"contacts",clocking:"actionsteps",comments:"notes",couponcodes:"coupons",customers:"accounts",customfields:"objects",davids:"davservers",documentversions:"documents",enhancements:"applications",extdata:"objects",feedservers:"channels",files:"documents",filters:"records",forks:"applications",imports:"records",invoices:"transactions-billing",linecoupon:"line",logins:"auth",mailservers:"channels",notifications:"messages","participants-campaigns":"participants","participants-mailinglists":"participants",prices:"pricelists",pwd:"auth",purchaseorders:"transactions-procurement",sessions:"auth",settings:"system",suppliers:"accounts",tags:"categories",tokens:"auth",transactions:"transactions-billing",usergroups:"groups",usermgmt:"users",usersettings:"system",userfields:"objects",userfilters:"records"}),wt=Object.freeze({light:"#ffffff",dark:"#141414"}),kt=Object.create(null);function ee(s){let t=String(s??"").trim().toLowerCase().replaceAll(/[._\s]+/g,"-");if(!t)return"default";if(Object.hasOwn(kt,t)||Object.hasOwn(X,t))return t;let e=bs[t];return e||"default"}function ot(s){let t=ee(s);return kt[t]??X[t]??X.default}function Wn(s){return ot(s).color}function Qn(s,{standard:t=!1}={}){let e=ot(s);return t?e.fa:e.icon}function Zn(){return[...new Set([...Object.keys(X),...Object.keys(kt)])].sort()}function Gn(s){for(let[t,e]of Object.entries(s)){let i=String(t).trim().toLowerCase().replaceAll(/[._\s]+/g,"-"),r=typeof e=="string"?{color:e}:e,n=kt[i]??X[i]??X.default;kt[i]=Object.freeze({label:r.label??n.label,icon:r.icon??n.icon,color:r.color??n.color,fa:r.fa??n.fa})}}function Te(s){let t=Ie(s);if(t===null)return wt.light;let e=gs(t,Ie(wt.light)??1),i=gs(t,Ie(wt.dark)??0);return e>=i?wt.light:wt.dark}function Ie(s){let t=/^#([\da-f]{3}|[\da-f]{6})$/i.exec(String(s).trim());if(!t)return null;let e=t[1].length===3?[...t[1]].map(o=>o+o).join(""):t[1],[i,r,n]=[0,2,4].map(o=>{let l=Number.parseInt(e.slice(o,o+2),16)/255;return l<=.04045?l/12.92:((l+.055)/1.055)**2.4});return .2126*i+.7152*r+.0722*n}function gs(s,t){return(Math.max(s,t)+.05)/(Math.min(s,t)+.05)}var ys="https://kit.fontawesome.com/ae8320b210.js";function Xn(s={}){return ge({kit:ys,...s})}function xs(s,t={}){let{standard:e=!1,...i}=t,r=ot(s);return m(e?`fa:${r.fa}`:`kit:${r.icon}`,i)}function Jn(s,t={}){let{size:e=24,iconSize:i="1em",label:r=null,title:n=!1,standard:o=!1}=t,l=ee(s),c=ot(s),u=a("span",{class:["zx-module-icon",t.class].flat().filter(Boolean),dataset:{module:l},style:{"--zx-module-color":c.color,"--zx-module-glyph":Te(c.color),"--zx-module-icon-size":typeof e=="number"?`${e}px`:String(e)},title:n?c.label:null},xs(s,{size:i,standard:o}));return r===null?u.setAttribute("aria-hidden","true"):(u.setAttribute("role","img"),u.setAttribute("aria-label",r)),u}function Ee(s,t,e={}){let{fields:i,labelKey:r=ro(s,t),valueKey:n="ID",searchFields:o=no(s,t),limit:l=50,filters:c={},value:u=null,...h}=e,p=q(s),f=i??so(n,r,o);return{...h,valueKey:n,labelKey:r,value:u,filter:async d=>{let _=await p.list(t,tt({search:d,filters:c,fields:f,searchFields:o,limit:l}));return Ne(s,_).data}}}function to(s,t,e={}){let i=Ee(s,t,e),r=e.value??null,n=new I(null,i);return n.ready=eo(n,s,t,r),n}function Ne(s,t){return typeof s?.normalizeListResult=="function"?vs(s.normalizeListResult(t)):vs(t)}function vs(s){if(Array.isArray(s))return{data:s};if(!s||typeof s!="object")return{data:[]};let t=Array.isArray(s.data)?s.data:[],e=s.count==null||s.count===""?null:Number(s.count);return Number.isFinite(e)?{data:t,count:e}:{data:t}}async function eo(s,t,e,i){if(i==null)return s;let r=i&&typeof i=="object"?i:await q(t).get(e,i),n=io(r);return s.setItems([n]),s.set(n,{silent:!0}),s}function io(s){if(s&&typeof s=="object"&&!Array.isArray(s)){let t=s.data;return t&&typeof t=="object"&&!Array.isArray(t)?t:s}throw new TypeError("ZeyOS get operation did not return a record")}function so(s,t,e){let i=[s,t,...e].filter(r=>typeof r=="string"&&r);return i.length?[...new Set(i)]:void 0}function ro(s,t){let e=oo(s,t);for(let i of["name","lastname","customernum","transactionnum","number","title","ID"])if(e.includes(i))return i;return e[0]??"ID"}function no(s,t){let e=s?.schema?.describe?.(t)?.fields;return!e||typeof e!="object"||Array.isArray(e)?[]:Object.entries(e).flatMap(([i,r])=>{if(!r||typeof r!="object")return[];let n=String(r.type??"").toLowerCase();return r.indexed&&/text|character|varchar/.test(n)?[i]:[]})}function oo(s,t){let e=s?.schema?.fields?.(t);if(Array.isArray(e))return e.map(String);if(e&&typeof e=="object")return Object.keys(e);let i=s?.schema?.describe?.(t)?.fields;return i&&typeof i=="object"?Object.keys(i):[]}function ao(s,t,e={}){let i=ct(s,t,e),r={},n=[];for(let o of i){let l=Dt(o),c=l.type==="zxselect"&&typeof l.props?.entity=="string"?l.props.entity:null;c&&(n.push({id:String(o.id),resource:c}),l.props={...Ee(s,c,{clearable:!l.required,placeholder:`Select ${String(l.label).toLowerCase()}`})}),r[String(o.id)]=l}return{fieldMeta:i,fields:r,entityFields:n,formOptions:{fieldsets:[{title:String(e.title??""),columns:po(e.columns),fields:r}]},mapFromRecord:o=>co(o,i),mapToRecord:o=>uo(o,i)}}function lo(s,t,e={}){if(e.onSaved!=null&&typeof e.onSaved!="function")throw new TypeError("zeyosForm onSaved must be a function");let i=ao(s,t,e),r=q(s),n=new vt(null,i.formOptions),o=e.value?.ID??e.id??null,l=!1,c=null,u=async d=>{if(!d||typeof d!="object"||Array.isArray(d))throw new TypeError("ZeyOS form value must be a record");return await Promise.all(i.entityFields.map(async({id:_,resource:y})=>{let v=d[_];if(v==null)return;let B=v&&typeof v=="object"?v:Fe(await r.get(y,v)),at=I.from(n.getField(_)?.getInput());at instanceof I&&at.setItems([B])})),l||n.setValues(i.mapFromRecord(d),{silent:!0}),d},h=async d=>{if(d==null||d==="")throw new TypeError("zeyosForm.load() requires an id");let _=Fe(await r.get(t,d));return o=_.ID??d,await u(_),_},p=()=>l?Promise.reject(new Error("Cannot save a destroyed ZeyOS form")):c||(n.submit()?(c=(async()=>{let d;try{d=i.mapToRecord(n.getValues()),delete d.ID}catch(v){throw r.reportError(v,{operation:"serialize",resource:t}),v}let _=o==null?await r.create(t,d):await r.update(t,{ID:o,...d}),y=Fe(_);if(o=y.ID??o,e.onSaved)try{await e.onSaved(y)}catch(v){throw r.reportError(v,{operation:"onSaved",resource:t}),v}return G.success(`${_o(y,t)} saved successfully.`),y})().finally(()=>{c=null}),c):Promise.resolve(null)),f=Object.prototype.hasOwnProperty.call(e,"id")?h(e.id):e.value?u(e.value):Promise.resolve(null);return{form:n,ready:f,load:h,save:p,getForm:()=>n,destroy(){l||(l=!0,n.destroy())}}}function co(s,t){let e={};for(let i of t){let r=String(i.id),n=s[r];e[r]=ws(i)&&n!=null&&n!==""?lt(n):n}return e}function uo(s,t){let e={};for(let i of t){let r=String(i.id),n=s[r];if(ws(i))n=n==null||n===""?null:$(n);else if(ho(i)&&fo(i.type)&&n!==""&&n!=null){let o=Number(n);Number.isFinite(o)&&(n=o)}e[r]=n}return e}function ws(s){let t=Dt(s);return t.type==="date"||t.type==="datetime"}function ho(s){return s.enums!=null||s.enum!=null}function fo(s){return/^(?:smallint|integer|bigint|int|int2|int4|int8|numeric|decimal)$/i.test(String(s??""))}function po(s){let t=Number(s??2);return[1,2,3].includes(t)?t:2}function Fe(s){if(s&&typeof s=="object"&&!Array.isArray(s)){let t=s.data;return t&&typeof t=="object"&&!Array.isArray(t)?t:s}throw new TypeError("ZeyOS operation did not return a record")}function _o(s,t){for(let e of["transactionnum","name","lastname","customernum","number","ID"])if(s[e]!=null&&s[e]!=="")return String(s[e]);return String(t)}function mo(s,t,e={}){let i=ct(s,t,{fields:e.fields,labels:e.labels}),r={},n=i.map(l=>{let c={...l},u=bo(c);if(u){let f=yo(s,u);c.labelField=`${c.id}_label`,r[c.labelField]=`${c.id}.${f}`}r[c.id]=c.id;let h=xo(c),p=ie(h?{...c,format:"money"}:c);return h&&(p.render=f=>vo(f?.[c.id],f?.currency),wo(s,t,"currency")&&(r.currency="currency")),p}),o=e.rowId??"ID";return typeof o=="string"&&!Object.prototype.hasOwnProperty.call(r,o)&&(r[o]=o),{fieldMeta:i,columns:n,projection:r,tableOptions:{columns:n,data:[],rowId:o,sort:e.sort??null,sortMode:"server",selectable:e.selectable??!1,height:e.height??null,onrowclick:typeof e.onRowClick=="function"?l=>e.onRowClick(l.detail.row,l):void 0}}}function go(s,t,e={}){let i=mo(s,t,e),r=q(s),n=new yt(null,i.tableOptions),o=ko(e.pageSize),l=e.sort??null,c=ks(e.filters??{}),u=String(e.search??""),h=0,p=null,f=!1,d=0,_=async(v={})=>{Object.prototype.hasOwnProperty.call(v,"search")&&(u=String(v.search??"")),Object.prototype.hasOwnProperty.call(v,"filters")&&(c=ks(v.filters??{}));let B=Ao(v.page??0),at=tt({fields:i.projection,sort:l,filters:c,search:u,limit:o,offset:B*o,count:!0}),Oe=++d;n.setLoading(!0);try{let J=Ne(s,await r.list(t,at)),At=J.count??null,Le=At==null?J.data.length===o:B*o+J.data.length<At;return Oe===d&&(h=B,p=At,f=Le,B===0?n.setData(J.data):n.addData(J.data)),{data:J.data,count:At,page:B,hasMore:Le,query:at}}finally{Oe===d&&n.setLoading(!1)}},y={table:n,load:_,setSearch:v=>_({search:v,page:0}),setFilters:v=>_({filters:v,page:0}),loadMore:()=>f?_({page:h+1}):Promise.resolve({data:[],count:p,page:h,hasMore:!1,query:tt({fields:i.projection,sort:l,filters:c,search:u,limit:o,offset:h*o,count:!0})}),get count(){return p},get page(){return h},get hasMore(){return f},destroy:()=>n.destroy()};return n.on("sort",v=>{l={id:String(v.detail.id),dir:v.detail.dir==="desc"?"desc":"asc"},_({page:0}).catch(()=>{})}),y}function bo(s){for(let t of[s.entity,s.fk,s.relation,s.reference,s.references]){if(typeof t=="string"&&t)return t;if(t&&typeof t=="object"){let e=t.resource??t.target??t.table??t.entity;if(typeof e=="string"&&e)return e}}return null}function yo(s,t){let e=s?.schema?.fields?.(t),i=Array.isArray(e)?e.map(String):Object.keys(e??{});for(let r of["name","lastname","customernum","transactionnum","number","title","ID"])if(i.includes(r))return r;return i[0]??"ID"}function xo(s){let t=String(s.format??"").toLowerCase();return/money|currency|price/.test(t)||/(?:amount|price)$/.test(String(s.id).toLowerCase())}function vo(s,t){if(s==null||s==="")return"";let e=Number(s);if(!Number.isFinite(e))return"";let i=typeof t=="string"&&/^[A-Z]{3}$/.test(t)?t:null;try{return new Intl.NumberFormat(void 0,i?{style:"currency",currency:i}:{}).format(e)}catch{return new Intl.NumberFormat().format(e)}}function wo(s,t,e){let i=s?.schema?.fields?.(t);return Array.isArray(i)?i.includes(e):!!(i&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,e))}function ko(s){let t=Number(s??50);return Number.isInteger(t)&&t>0?t:50}function Ao(s){let t=Number(s);if(!Number.isInteger(t)||t<0)throw new RangeError("ZeyOS table page must be a non-negative integer");return t}function ks(s){if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("ZeyOS table filters must be an object");return{...s}}export{ys as ZEYOS_ICON_KIT,tt as buildListQuery,q as connect,As as dataFilterStateToFilters,$ as dateToUnixSeconds,ie as fieldToZxColumn,Dt as fieldToZxField,bs as moduleAliases,Jn as moduleChip,Wn as moduleColor,Te as moduleGlyphColor,xs as moduleIcon,Qn as moduleIconName,ot as moduleInfo,Zn as moduleKeys,ee as normalizeModuleName,z as registerFieldType,Gn as registerModules,ct as resolveFields,je as tableSortToQuery,lt as unixSecondsToDate,Xn as useZeyosIcons,lo as zeyosForm,X as zeyosModules,to as zeyosSelect,go as zeyosTable};
|
|
1
|
+
function Z(i){if(i==null)return null;if(!(i instanceof Date))throw new TypeError("Expected a Date");let t=i.getTime();if(!Number.isFinite(t))throw new RangeError("Invalid Date");return Math.floor(t/1e3)}function pt(i){if(i==null)return null;let t=Number(i);if(!Number.isFinite(t))throw new TypeError("Expected finite Unix seconds");return new Date(t*1e3)}function ri(i){return(Array.isArray(i)?i:i?[i]:[]).flatMap(e=>{if(!e||typeof e!="object")return[];let s=e.rawField??e.field??e.id;if(s==null||String(s).trim()==="")return[];let n=String(s).trim().replace(/^[+-]/,"");return[`${e.dir==="desc"?"-":"+"}${n}`]})}function pn(i,t=[]){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("DataFilter state must be an object");let e=mn(i,t),s={},n=0;for(let r of e){if(!r.id||!Object.prototype.hasOwnProperty.call(i,r.id))continue;let o=i[r.id];if(o===void 0||o===null&&r.includeNull!==!0||typeof o=="string"&&o.trim()===""&&r.includeEmpty!==!0)continue;if(typeof r.toFilter=="function"){let h=r.toFilter(o,i);h&&typeof h=="object"&&!Array.isArray(h)&&Object.assign(s,h);continue}let a=typeof r.transform=="function"?r.transform(o,i):_n(o,r);if(a===void 0)continue;r.operator&&(a={[r.operator]:a});let c=Array.isArray(r.fields)?r.fields.filter(h=>typeof h=="string"&&h):[];if(c.length>1){for(;Object.prototype.hasOwnProperty.call(s,String(n));)n+=1;s[String(n)]=["OR",...c.map(h=>({[h]:a}))],n+=1;continue}let u=c[0]??r.rawField??r.field??r.id;typeof u=="string"&&u&&(s[u]=a)}return s}function ot(i={}){let{fields:t,sort:e,filters:s={},search:n,limit:r,offset:o,visibility:a=0,count:c=!1}=i;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("ZeyOS filters must be an object");let u={};Array.isArray(t)?u.fields=[...t]:t&&typeof t=="object"&&(u.fields={...t});let h={...s},f=Object.prototype.hasOwnProperty.call(i,"visibility");a!==void 0&&(f||!Object.prototype.hasOwnProperty.call(h,"visibility"))&&(h.visibility=a),Object.keys(h).length&&(u.filters=h);let p=gn(e,t),d=ri(p);return d.length&&(u.sort=d),n!=null&&String(n).trim()&&(u.query=String(n).trim()),r!=null&&(u.limit=r),o!=null&&(u.offset=o),c&&(u.count=!0),u}function mn(i,t){return Array.isArray(t)&&t.length?t.map(e=>({...e})):t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length?Object.entries(t).map(([e,s])=>typeof s=="string"?{id:e,field:s}:{...s,id:e}):Object.keys(i).map(e=>({id:e,field:e}))}function _n(i,t){let e=String(t.format??t.type??"").toLowerCase();return i instanceof Date&&["date","datetime","date-time"].includes(e)?Z(i):Array.isArray(i)&&["date","datetime","date-time"].includes(e)?i.map(s=>s instanceof Date?Z(s):s):i}function gn(i,t){if(!i||!t||Array.isArray(t)||typeof t!="object")return i;let e=s=>{if(!s||typeof s!="object")return s;let n=s.id;return!n||!Object.prototype.hasOwnProperty.call(t,n)?s:{...s,rawField:t[n]}};return Array.isArray(i)?i.map(e):e(i)}var Tt=Object.create(null),oi=new Set;function C(i,t){let e=Mt(i);if(!e)throw new TypeError("ZeyOS field type must not be empty");if(!t||typeof t!="object")throw new TypeError("Field type strategy must be an object");for(let s of["field","column"]){let n=t[s];if(typeof n!="function"&&(!n||typeof n!="object"||Array.isArray(n)))throw new TypeError(`Field type strategy requires a ${s} builder or descriptor`)}return Tt[e]=t,t}function Et(i){let t=hi(i),e=ui(t),s=di(e.field,t),n={id:t.id,type:"text",label:fi(t),...s};return t.description!=null&&(n.description=String(t.description)),(t.required===!0||t.nullable===!1)&&(n.required=!0),Mn(t)&&(n.readonly=!0,n.disabled=!0,n.props={...n.props??{},readOnly:!0}),n}function me(i){let t=hi(i),e=ui(t);return{id:t.id,label:fi(t),sortable:t.sortable!==!1,...di(e.column,t)}}function mt(i,t,e={}){let s=i?.schema;if(!s||typeof s.fields!="function"||typeof s.describe!="function")throw new TypeError("ZeyOS client must expose schema.fields() and schema.describe()");let n=s.describe(t),r=ai(n?.fields),o=ai(s.fields(t)),a=new Map;for(let[p,d]of o)a.set(p,{...d,...r.get(p)??{}});for(let[p,d]of r)a.has(p)||a.set(p,{...d});let c=Array.isArray(e.fields)?e.fields.map(String):[...a.keys()],u=new Set(Array.isArray(e.exclude)?e.exclude.map(String):[]),h=e.labels&&typeof e.labels=="object"?e.labels:{},f=[];for(let p of c){if(u.has(p)||!a.has(p))continue;let d=a.get(p)??{},m={...d,id:p,name:p,resource:String(t)},g=d.enums??d.enum??En(s,t,p);g!=null&&(m.enums=g,m.enum==null&&(m.enum=g)),Object.prototype.hasOwnProperty.call(h,p)&&(m.label=String(h[p])),f.push(m)}return f}var li={field:{type:"text"},column:{}},bn={field:{type:"int"},column:{align:"right"}},yn={field:{type:"float"},column:i=>({align:"right",render:gi(i)})},xn={field:{type:"float"},column:i=>({align:"right",render:gi(i,!0)})},vn={field:i=>({type:"zxselect",props:{entity:pi(i)}}),column:i=>({render:t=>jn(P(t,i),t,i)})},wn={field:{type:"toggle"},column:i=>({align:"center",render:t=>P(t,i)?"\u2713":"",sortValue:t=>+!!P(t,i)})},kn={field:i=>({type:Nn(i),options:_e(i)}),column:i=>({render:_i(i)})},Sn={field:{type:"zxselect",props:{preset:"priority"}},column:i=>({render:_i(i,Fn())})},An={field:{type:"float",props:{min:0,max:100}},column:i=>({align:"right",render:t=>Ln(P(t,i)),sortValue:t=>Nt(P(t,i))})},zn=ci("date"),Dn=ci("datetime");for(let i of["string","text","character","character varying","varchar","email","tel","url","uri"])C(i,li);for(let i of["integer","smallint","bigint","int","int2","int4","int8","int32","int64"])C(i,bn);for(let i of["number","numeric","decimal","real","double","double precision","float"])C(i,yn);for(let i of["money","currency","price","pricebilling","priceprocurement","priceproduction"])C(i,xn);for(let i of["entity","t_entity"])C(i,vn);for(let i of["boolean","checked"])C(i,wn);for(let i of["list","enum"])C(i,kn);for(let i of["progress","percent"])C(i,An);for(let i of["date"])C(i,zn);for(let i of["datetime","date-time"])C(i,Dn);C("priority",Sn);C("text[]",{field:{type:"valuelist"},column:{}});C("json",{field:{type:"textarea"},column:{}});C("longtext",{field:{type:"textarea"},column:{}});for(let i of["email","tel","url","uri"])C(i,{field:{type:"text",props:{type:i==="uri"?"url":i}},column:{}});function ci(i){return{field:{type:i},column:t=>({render:e=>On(P(e,t),i==="datetime"),sortValue:e=>Rn(P(e,t))})}}function ui(i){let t=Cn(i),e=Tt[t];return e||(oi.has(t)||(oi.add(t),console.warn(`[zx.zeyos] Unknown field type or format "${t||"unknown"}" for "${i.id}"; using text.`)),li)}function Cn(i){let t=Mt(i.format??i.semanticFormat??i.semanticType??i.widget);if(t&&Tt[t])return t;if(pi(i)||Mt(i.type)==="t_entity")return"entity";if(String(i.id).toLowerCase()==="priority")return"priority";if(i.enums!=null||i.enum!=null)return"enum";let e=Mt(i.type);if(e==="bigint"||e==="int64"){let s=String(i.id).toLowerCase();if(s==="date"&&i.indexed)return"date";if(/(?:date|time)$/.test(s))return"datetime"}return Tn(i,e)?"longtext":e&&Tt[e]?e:e.endsWith("[]")?"text[]":e==="json"||e==="jsonb"?"json":/^character varying(?:\(\d+\))?$/.test(e)?"character varying":e||t}function hi(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Field metadata must be an object");let t=i.id??i.name??i.field??i.identifier??i.reference;if(t==null||String(t).trim()==="")throw new TypeError("Field metadata requires an id or name");return{...i,id:String(t)}}function di(i,t){let e=typeof i=="function"?i(t):i;return e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}function Mt(i){return String(i??"").trim().toLowerCase().replace(/\s+/g," ")}function fi(i){let t=i.label??i.title??i.displayName;return t==null||t===""?In(i.id):String(t)}function In(i){let t=String(i??"").split(".").at(-1)??"";if(t==="ID")return"ID";let e=t.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):t}function Mn(i){return i.readonly===!0||i.readOnly===!0||i.writable===!1||i.mutable===!1}function Tn(i,t){if(i.long===!0||i.multiline===!0)return!0;let e=Number(i.maxLength??t.match(/^character varying\((\d+)\)$/)?.[1]);return Number.isFinite(e)&&e>255}function pi(i){for(let t of[i.entity,i.fk,i.relation,i.reference,i.references]){if(typeof t=="string"&&t)return t;if(t&&typeof t=="object"){let e=t.resource??t.target??t.table??t.entity;if(typeof e=="string"&&e)return e}}return null}function ai(i){let t=new Map;if(Array.isArray(i)){for(let e of i)if(typeof e=="string")t.set(e,{});else if(e&&typeof e=="object"){let s=e.id??e.name??e.field;s!=null&&t.set(String(s),{...e})}}else if(i&&typeof i=="object")for(let[e,s]of Object.entries(i))t.set(e,s&&typeof s=="object"?{...s}:{});return t}function En(i,t,e){if(typeof i.enums!="function")return null;let s=i.enums(t,e);return s&&typeof s=="object"&&!Array.isArray(s)&&Object.prototype.hasOwnProperty.call(s,e)?s[e]:s??null}function _e(i){return mi(i.enums??i.enum??i.options)}function mi(i){if(typeof i=="string")try{return mi(JSON.parse(i))}catch{return{}}return Array.isArray(i)?Object.fromEntries(i.map((t,e)=>{if(Array.isArray(t)){let[s=e,n=s]=t;return[String(s),String(n)]}if(t&&typeof t=="object"){let s=t.value??t.id??e;return[String(s),String(t.label??t.name??s)]}return[String(e),String(t)]})):i&&typeof i=="object"?Object.fromEntries(Object.entries(i).map(([t,e])=>[t,String(e)])):{}}function Nn(i){return Object.keys(_e(i)).length<=5?"optionlist":"select"}function Fn(){return{0:"LOWEST",1:"LOW",2:"MEDIUM",3:"HIGH",4:"HIGHEST"}}function _i(i,t={}){let e={...t,..._e(i)};return s=>{let n=P(s,i);return n==null?"":e[String(n)]??String(n)}}function gi(i,t=!1){let e;try{e=new Intl.NumberFormat(i.locale,t&&i.currency?{style:"currency",currency:String(i.currency)}:{})}catch{e=new Intl.NumberFormat}return s=>{let n=Nt(P(s,i));return n==null?"":e.format(n)}}function Nt(i){if(i==null||i==="")return null;let t=Number(i);return Number.isFinite(t)?t:null}function Ln(i){let t=Nt(i);return t==null?"":`${new Intl.NumberFormat().format(t)}%`}function On(i,t){if(i==null||i==="")return"";try{let e=i instanceof Date?i:pt(i);return!e||!Number.isFinite(e.getTime())?"":new Intl.DateTimeFormat(void 0,t?{dateStyle:"medium",timeStyle:"short"}:{dateStyle:"medium"}).format(e)}catch{return""}}function Rn(i){return i instanceof Date?Z(i):Nt(i)}function P(i,t){if(!i||typeof i!="object")return;if(Object.prototype.hasOwnProperty.call(i,t.id))return i[t.id];let e=String(t.path??t.field??t.id).split("."),s=i;for(let n of e){if(!s||typeof s!="object")return;s=s[n]}return s}function jn(i,t,e){if(i&&typeof i=="object"){let n=i.label??i.name??i.title??i.number??i.ID??i.id;return n==null?"":String(n)}let s=e.labelField;if(typeof s=="string"&&t[s]!=null)return String(t[s]);for(let n of[`${e.id}.name`,`${e.id}_label`,`${e.id}Label`])if(t[n]!=null)return String(t[n]);return i==null?"":String(i)}var bi=0;function v(i="zx"){return bi+=1,`${i}-${Date.now().toString(36)}-${bi.toString(36)}`}function Lt(i,t){let e=_t(i)?yi(i):{};if(!_t(t))return Ft(t);for(let[s,n]of Object.entries(t))_t(n)&&_t(e[s])?e[s]=Lt(e[s],n):e[s]=Ft(n);return e}function I(i){return!!(i&&typeof i=="object"&&i.nodeType===1)}function gt(i,t,e){return Math.min(e,Math.max(t,i))}function ge(i){return String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _t(i){if(i===null||typeof i!="object")return!1;let t=Object.getPrototypeOf(i);return t===Object.prototype||t===null}function yi(i){let t={};for(let[e,s]of Object.entries(i))t[e]=Ft(s);return t}function Ft(i){return _t(i)?yi(i):Array.isArray(i)?i.map(Ft):i}var bt=null;function be(i){if(typeof i!="string")return null;let t=i.trim();if(!t)return null;try{let e=new URL(t,globalThis.location?.href??"https://zx.invalid/").protocol;if(["javascript:","data:","vbscript:"].includes(e.toLowerCase()))return null}catch{return null}return t}function l(i,t,...e){let s=document.createElement(i),n=t;qn(n)||(e.unshift(n),n={});for(let[r,o]of Object.entries(n))Vn(s,r,o);return Bn(s,e),s}l.scope=function(t,e){let s=bt;bt=t;try{return e()}finally{bt=s}};l.raw=function(t){let e=document.createElement("template");return e.innerHTML=String(t),e.content};function O(i){return{children:Array.from(i.childNodes),attributes:Array.from(i.attributes,t=>[t.name,t.value])}}function R(i,t){if(t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}}function ye(i){if(i==null)return null;if(I(i))return i;if(typeof i=="string")return document.querySelector(i);if(typeof i.toElement=="function"){let t=i.toElement();return I(t)?t:null}return null}function qn(i){if(i===null||typeof i!="object"||Array.isArray(i))return!1;let t=i;return typeof t.nodeType=="number"?!1:typeof t.toElement!="function"}function Vn(i,t,e){if(t==="ref"){bt&&typeof e=="string"&&(bt[e]=i);return}if(t==="class"){i.className=Array.isArray(e)?e.flat(1/0).filter(Boolean).join(" "):String(e??"");return}if(t==="style"){if(typeof e=="string")i.style.cssText=e;else if(e&&typeof e=="object")for(let[n,r]of Object.entries(e))n.startsWith("--")||n.includes("-")?i.style.setProperty(n,String(r)):i.style[n]=r;return}if(t==="dataset"&&e&&typeof e=="object"){for(let[n,r]of Object.entries(e))r==null?delete i.dataset[n]:i.dataset[n]=String(r);return}if(/^on[a-z]/.test(t)&&typeof e=="function"){i.addEventListener(t.slice(2),e);return}if(e==null)return;let s=Pn(t);if(s!==null)i.setAttribute(s,String(e));else if(t in i)try{i[t]=e}catch{i.setAttribute(t,String(e))}else typeof e=="boolean"?e?i.setAttribute(t,""):i.removeAttribute(t):i.setAttribute(t,String(e))}function Pn(i){return i.startsWith("aria-")?i:/^aria[A-Z]/.test(i)?"aria-"+i.slice(4).toLowerCase():null}function Bn(i,t){let e=i;for(let s of t.flat(1/0)){if(s==null)continue;if(typeof s=="string"||typeof s=="number"){e.append(document.createTextNode(String(s)));continue}if(typeof s!="object")continue;let n=s;if(typeof n.nodeType=="number")e.append(s);else if(typeof n.toElement=="function"){let r=n.toElement();r&&e.append(r)}}}var xi=null,vi="en";function xe(i){vi=String(i||"en")}function B(){return vi}function j(i,t){let e=xi?xi(i):i;return F(e==null?i:String(e),t)}function F(i,t){if(t==null)return String(i);let e=Array.isArray(t)?t:typeof t=="object"?null:[t],s=String(i).replace(/%(\d+)/g,(r,o)=>{let a=Number(o)-1,c;return e?c=e[a]:Object.prototype.hasOwnProperty.call(t,o)&&(c=t[o]),c==null?r:String(c)}),n=0;return s=s.replace(/%([A-Za-z_][\w.-]*)%/g,(r,o)=>{if(!e&&Object.prototype.hasOwnProperty.call(t,o)){let a=t[o];return a==null?r:String(a)}if(e&&n<e.length){let a=e[n];return n+=1,a==null?r:String(a)}return r}),s}var Ot=new WeakMap,y=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#t=new AbortController;#e=!1;#i=!1;#s=!1;constructor(t,e={}){super();let s=this.constructor;this.#e=t===null;let n=ye(t);if(t!==null&&!n)throw new TypeError("Component target could not be resolved");this.el=n,this.refs={};let r=Hn(s,e),o=[];for(let[u,h]of Object.entries(r))/^on[a-z]/.test(u)&&typeof h=="function"&&(o.push([u.slice(2),h]),delete r[u]);r.msg&&typeof r.msg=="object"&&Object.freeze(r.msg),this.options=Object.freeze(r);for(let[u,h]of o)this.on(u,h);let a;try{a=l.scope(this.refs,()=>this.render())}catch(u){throw this.#t.abort(),u}if(this.#e){let u=I(a)?a:this.el;if(!I(u))throw this.#t.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=u}if(!I(this.el))throw this.#t.abort(),new TypeError("Component requires a root Element");let c=s.cssName;if(typeof c=="string"&&c){let u=`zx-${c}`;this.#s=!this.el.classList.contains(u),this.el.classList.add(u)}Ot.set(this.el,this)}render(){return this.el??null}on(t,e){return this.addEventListener(t,e,{signal:this.#t.signal}),this}off(t,e){return this.removeEventListener(t,e),this}once(t,e){return this.addEventListener(t,e,{once:!0,signal:this.#t.signal}),this}addEvent(t,e){return this.on(t,e)}emit(t,e={}){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("Event detail must be an object");let s=wi(t,e,{cancelable:!0});return this.dispatchEvent(s),this.el&&this.el.dispatchEvent(wi(`zx-${t}`,e,{bubbles:!0,composed:!0,cancelable:!0})),s}listen(t,e,s,n={}){let r=typeof n=="boolean"?{capture:n}:{...n};return t.addEventListener(e,s,{...r,signal:this.#t.signal}),this}toElement(){return this.el}msg(t,...e){let s=this.options.msg,n=this.options.lang??this.options.language??B(),r=s?.[n]?.[t];if(r!=null)return F(String(r),e);let o=s?.[t];return o!=null?F(String(o),e):j(t,e)}destroy(){if(this.#i)return;this.#i=!0,this.#t.abort(),Ot.get(this.el)===this&&Ot.delete(this.el);let t=this.constructor.cssName;this.#s&&typeof t=="string"&&this.el&&this.el.classList.remove(`zx-${t}`),this.#e&&this.el&&this.el.remove()}static from(t){return Ot.get(t)??null}};function Hn(i,t){let e=[],s=i;for(;s&&s!==Function.prototype;)Object.prototype.hasOwnProperty.call(s,"defaults")&&e.unshift(s.defaults),s=Object.getPrototypeOf(s);let n={},r={},o=!1;for(let a of e)!a||typeof a!="object"||(Object.assign(n,a),a.msg&&typeof a.msg=="object"&&(o=!0,r=Lt(r,a.msg)));return Object.assign(n,t&&typeof t=="object"?t:{}),t?.msg&&typeof t.msg=="object"&&(o=!0,r=Lt(r,t.msg)),o&&(n.msg=r),n}function wi(i,t,e){if(typeof CustomEvent=="function")return new CustomEvent(i,{...e,detail:t});let s=new Event(i,e);return Object.defineProperty(s,"detail",{configurable:!0,enumerable:!0,value:t}),s}var x=class i extends y{static cssName="field";static defaults={id:null,type:"text",label:"",description:"",value:void 0,placeholder:"",required:!1,disabled:!1,options:null,layout:"stack",props:{},msg:{"field.int":"Enter a whole number.","field.float":"Enter a valid number.","field.unknown":"Unknown field type: %1"}};static#t=new Map;static register(t,e){let s=String(t).trim().toLowerCase();if(!s)throw new TypeError("Field adapter type must not be empty");if(typeof e!="function")throw new TypeError("Field adapter must be a function");return i.#t.set(s,e),this}static has(t){return i.#t.has(String(t).trim().toLowerCase())}render(){let t=this.el??l("div");this.el=t;let e=String(this.options.type||"text").toLowerCase(),s=this.options.layout==="inline"?"inline":"stack";this._ownedComponents=new Set,this._ownedNodes=[],this._rootAttributes=Un(t,["data-layout","data-field-type","data-disabled","data-state"]),t.dataset.layout=s,t.dataset.fieldType=e,this.controlId=this.options.id?String(this.options.id):v("zx-field");let n=`${this.controlId}-label`,r=`${this.controlId}-description`,o=`${this.controlId}-highlight`,a=l("label",{class:"zx-field__label",id:n,htmlFor:this.controlId},String(this.options.label??""),this.options.required?l("span",{class:"zx-field__required",ariaHidden:"true"}," *"):null),c=l("div",{class:"zx-field__control"}),u=l("div",{class:"zx-field__description",id:r},String(this.options.description??"")),h=l("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),f=l("div",{class:"zx-field__body"},c,u,h);this._ownedNodes.push(a,f),t.append(a,f);let p=i.#t.get(e);if(p)try{this.adapter=Yn(p(this,this.options))}catch(m){let g=m instanceof Error?m.message:String(m);console.warn(`[zx.Field] Adapter "${e}" failed: ${g}`),this.adapter=Si(g,this.controlId)}else{let m=this.msg("field.unknown",e);console.warn(`[zx.Field] ${m}`),this.adapter=Si(m,this.controlId)}let d=this.adapter.el;return d.id||(d.id=this.controlId),a.htmlFor=d.id,Kn(d)||d.setAttribute("aria-labelledby",n),this._baseDescribedBy=d.getAttribute("aria-describedby")??"",c.append(d),this._descriptionId=String(this.options.description??"")?r:"",this._highlightId=o,this._highlight=h,this._syncDescription(),this.initialValue=$n(e,this.options.value),this.adapter.set(this.initialValue,{silent:!0}),this.setDisabled(!!this.options.disabled),this.listen(d,"change",()=>{this.emit("change",{value:this.getValue()})}),t}getValue(){return this.adapter.get()}setValue(t,{silent:e=!1}={}){return this.adapter.set(t,{silent:e}),e||this.emit("change",{value:this.getValue()}),this}focus(){return this.adapter.focus(),this}reset(){return this.setValue(this.initialValue,{silent:!0}),this.clearHighlight(),this}setDisabled(t){let e=!!t;return this.adapter.setDisabled(e),this.el.dataset.disabled=String(e),this}setHighlight(t,e="danger"){if(!t)return this.clearHighlight();let s=["danger","warning","success"].includes(e)?e:"danger";return this.el.dataset.state=s,this._highlight.textContent=String(t??""),this._highlight.hidden=!t,s==="danger"&&t?(this._highlight.setAttribute("role","alert"),this.adapter.el.setAttribute("aria-invalid","true"),this.emit("invalid",{message:String(t)})):(this._highlight.removeAttribute("role"),this.adapter.el.removeAttribute("aria-invalid")),this._syncDescription(!!t),this}clearHighlight(){return delete this.el.dataset.state,this._highlight.textContent="",this._highlight.hidden=!0,this._highlight.removeAttribute("role"),this.adapter.el.removeAttribute("aria-invalid"),this._syncDescription(!1),this}getInput(){return this.adapter.el}own(t){if(!(t instanceof y))throw new TypeError("Field.own() requires a Component");return this._ownedComponents.add(t),t}_syncDescription(t=!1){let e=[this._baseDescribedBy,this._descriptionId,t?this._highlightId:""].flatMap(s=>s.split(/\s+/)).filter(Boolean);e.length?this.adapter.el.setAttribute("aria-describedby",[...new Set(e)].join(" ")):this.adapter.el.removeAttribute("aria-describedby")}destroy(){this.adapter?.destroy?.();for(let t of this._ownedComponents??[])t.destroy();this._ownedComponents?.clear();for(let t of this._ownedNodes??[])t.remove();Wn(this.el,this._rootAttributes??new Map),super.destroy()}};function ve(i){if(typeof i=="number")return Number.isInteger(i)?{valid:!0,value:i}:{valid:!1,value:String(i)};let t=String(i??"").trim();if(t==="")return{valid:!0,value:""};let e=zi(t);return e!==null&&Number.isInteger(e)?{valid:!0,value:e}:{valid:!1,value:t}}function we(i){if(typeof i=="number")return Number.isFinite(i)?{valid:!0,value:i}:{valid:!1,value:String(i)};let t=String(i??"").trim();if(t==="")return{valid:!0,value:""};let e=zi(t);return e!==null?{valid:!0,value:e}:{valid:!1,value:t}}function zi(i){let t=i.replace(/[\s\u00a0]/g,"");if(!/^[+-]?[\d.,]+$/.test(t))return null;let e=/^[+-]/.test(t)?t[0]:"",s=e?t.slice(1):t;if(!/\d/.test(s))return null;let n=[...s.matchAll(/\./g)].map(c=>c.index),r=[...s.matchAll(/,/g)].map(c=>c.index),o;if(n.length&&r.length){let c=n.at(-1)>r.at(-1)?".":",",u=c==="."?",":".",h=s.lastIndexOf(c),f=s.slice(0,h),p=s.slice(h+1);if(!/^\d+$/.test(p)||!ki(f,u))return null;o=f.split(u).join("")+"."+p}else if(r.length>1||n.length>1){let c=r.length?",":".";if(!ki(s,c))return null;o=s.split(c).join("")}else r.length===1?o=s.replace(",","."):o=s;if(!/^(?:\d+(?:\.\d+)?|\.\d+)$/.test(o))return null;let a=Number(e+o);return Number.isFinite(a)?a:null}function ki(i,t){let e=i.split(t);return e.length>0&&/^\d{1,3}$/.test(e[0])&&e.slice(1).every(s=>/^\d{3}$/.test(s))}function $n(i,t){return t!==void 0?t:i==="checkbox"?!1:""}function Yn(i){if(!i||typeof i!="object")throw new TypeError("Adapter must return an object");if(!(i.el&&i.el.nodeType===1))throw new TypeError("Adapter must provide an Element");for(let t of["get","set","focus","setDisabled"])if(typeof i[t]!="function")throw new TypeError(`Adapter is missing ${t}()`);return i}function Si(i,t){let e=l("div",{class:"zx-field__error-control",id:t,role:"alert",tabIndex:-1},i);return{el:e,get:()=>null,set:()=>{},focus:()=>e.focus(),setDisabled:()=>{}}}function Kn(i){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(i.tagName)}function Un(i,t){return new Map(t.map(e=>[e,i.getAttribute(e)]))}function Wn(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}function yt(i,t){let e={...i.props??{}};for(let s of Object.keys(e))(/^on[a-z]/i.test(s)||s==="content")&&delete e[s];return{...e,...t}}function Rt(i,t){return(e,s)=>{let n=l(i,yt(s,{type:i==="input"?t:void 0,placeholder:s.placeholder,required:s.required,disabled:s.disabled}));return ke(n)}}function ke(i){return{el:i,get:()=>i.value,set:t=>{i.value=t==null?"":String(t)},focus:()=>i.focus(),setDisabled:t=>{i.disabled=t}}}function Di(i){return(t,e)=>{let s=i==="int"?ve:we,n=l("input",yt(e,{type:"text",inputMode:i==="int"?"numeric":"decimal",placeholder:e.placeholder,required:e.required,disabled:e.disabled}));return t.listen(n,"blur",()=>{let r=s(n.value);if(!r.valid){t.setHighlight(t.msg(`field.${i}`),"danger");return}r.value!==""&&(n.value=String(r.value)),t.clearHighlight()}),{...ke(n),get:()=>s(n.value).value}}}var Qn=(i,t)=>{let e=l("input",yt(t,{type:"checkbox",required:t.required,disabled:t.disabled}));return{el:e,get:()=>e.checked,set:s=>{e.checked=!!s},focus:()=>e.focus(),setDisabled:s=>{e.disabled=s}}},Zn=(i,t)=>{let e=l("select",yt(t,{required:t.required,disabled:t.disabled}));for(let[s,n]of Ci(t.options))e.append(l("option",{value:s},n));return ke(e)},Gn=(i,t)=>{let e=l("div",{class:"zx-field__option-list",role:"radiogroup"}),s=t.id?String(t.id):v("zx-option-list"),n=Ci(t.options).map(([r,o],a)=>{let c=l("input",{type:"radio",name:s,value:r,required:!!t.required&&a===0,disabled:t.disabled});return e.append(l("label",{class:"zx-field__option"},c,l("span",{},o))),c});return{el:e,get:()=>n.find(r=>r.checked)?.value??"",set:r=>{for(let o of n)o.checked=String(r??"")===o.value},focus:()=>(n.find(r=>r.checked)??n[0])?.focus(),setDisabled:r=>{for(let o of n)o.disabled=r;e.setAttribute("aria-disabled",String(r))}}},Xn=(i,t)=>{let e=l("div",yt(t,{class:"zx-field__static"})),s=null;return{el:e,get:()=>e.textContent,set:r=>{Ai(s),s=null,r&&typeof r=="object"&&typeof r.nodeType=="number"?(s={node:r,parent:r.parentNode,next:r.nextSibling},e.replaceChildren(r)):e.textContent=r==null?"":String(r)},focus:()=>{},setDisabled:r=>{e.setAttribute("aria-disabled",String(r))},destroy:()=>Ai(s)}};function Ai(i){i&&(i.parent?i.parent.insertBefore(i.node,i.next?.parentNode===i.parent?i.next:null):i.node.remove())}var Jn=(i,t)=>{if(typeof t.adapter!="function")throw new TypeError("Custom fields require options.adapter");return t.adapter(i,t)};function Ci(i){return Array.isArray(i)?i.map(t=>[String(t),String(t)]):i&&typeof i=="object"?Object.entries(i).map(([t,e])=>[t,String(e)]):[]}x.register("text",Rt("input","text"));x.register("password",Rt("input","password"));x.register("textarea",Rt("textarea","text"));x.register("checkbox",Qn);x.register("int",Di("int"));x.register("float",Di("float"));x.register("select",Zn);x.register("optionlist",Gn);x.register("hidden",Rt("input","hidden"));x.register("html",Xn);x.register("custom",Jn);function K(i,t,e){let s=Ii(t).split(/\s+/).filter(Boolean);return s.length===0?i.slice():i.filter(n=>{let r=tr(n,e).map(Ii);return s.every(o=>r.some(a=>a.includes(o)))})}function tr(i,t){return i===null||typeof i!="object"?[i]:!Array.isArray(t)||t.length===0?[i]:t.map(e=>typeof e=="function"?e(i):i[e])}function Ii(i){return String(i??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var jt=class extends y{static cssName="checklist";static defaults={items:[],valueKey:"ID",labelKey:"name",checkedKey:"on",search:!0,height:280,defaultChecked:!1,load:null};render(){this._items=[],this._visibleItems=[],this._checked=new Set,this._query="",this._loadSequence=0,this._createdRoot=!1,this._active=!0,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._createdRoot||(this._originalChildren=Array.from(t.childNodes));for(let o of["role","aria-labelledby","data-state"])this._originalAttributes.set(o,t.getAttribute(o));let e=v("zx-checklist-label"),s=l("div",{class:"zx-checklist__label",id:e},this._message("checklist.label","Checklist")),n=l("input",{ref:"search",class:"zx-checklist__search",type:"search",autocomplete:"off",placeholder:this._message("checklist.search","Search"),ariaLabel:this._message("checklist.search","Search checklist"),hidden:!this.options.search}),r=l("div",{ref:"list",class:"zx-checklist__list"});return r.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,t.replaceChildren(s,n,r),t.setAttribute("role","group"),t.setAttribute("aria-labelledby",e),this.listen(n,"input",()=>this.search(n.value)),this.listen(r,"change",o=>{let a=o.target;if(!a?.matches?.('input[type="checkbox"][data-index]'))return;let c=this._visibleItems[Number(a.dataset.index)];if(c===void 0)return;let u=this._itemValue(c);a.checked?this._checked.add(u):this._checked.delete(u),this.emit("change",{values:this.getValues()})}),this._replaceItems(this.options.items),typeof this.options.load=="function"&&queueMicrotask(()=>{this._active&&this.reload().catch(()=>{})}),t}setItems(t){return this._replaceItems(t),this}getValues(){return this._items.map(t=>this._itemValue(t)).filter(t=>this._checked.has(t))}setValues(t){let e=new Set(t==null?[]:Array.from(t)),s=new Set(this._items.map(n=>this._itemValue(n)).filter(n=>e.has(n)));return this._replaceChecked(s),this}checkAll(){return this._replaceChecked(new Set(this._items.map(t=>this._itemValue(t)))),this}uncheckAll(){return this._replaceChecked(new Set),this}search(t){this._query=String(t??"");let e=this.refs.search;return e.value!==this._query&&(e.value=this._query),this._visibleItems=K(this._items,this._query,[this.options.labelKey]),this._renderItems(),this}async reload(){if(!this._active||typeof this.options.load!="function")return this;let t=++this._loadSequence;this.el.setAttribute("data-state","loading"),this.refs.list.setAttribute("aria-busy","true");try{let e=await this.options.load();if(t!==this._loadSequence)return this;this._replaceItems(e),this.emit("loaded",{items:this._items.slice()})}finally{t===this._loadSequence&&(this.el.removeAttribute("data-state"),this.refs.list.setAttribute("aria-busy","false"))}return this}destroy(){this._active=!1,this._loadSequence+=1;let t=this.el;if(!this._createdRoot&&t){t.replaceChildren(...this._originalChildren);for(let[e,s]of this._originalAttributes)s===null?t.removeAttribute(e):t.setAttribute(e,s)}super.destroy()}_replaceItems(t){this._items=Array.isArray(t)?t.slice():[],this._checked=new Set(this._items.filter(e=>!!this._initialChecked(e)).map(e=>this._itemValue(e))),this._visibleItems=K(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let t=this._visibleItems.map((e,s)=>{let n=v("zx-checklist-item"),r=l("input",{type:"checkbox",id:n,checked:this._checked.has(this._itemValue(e)),dataset:{index:s}});return l("label",{class:"zx-checklist__item",for:n},r,l("span",{},this._itemLabel(e)))});t.length===0&&t.push(l("div",{class:"zx-checklist__empty",role:"status"},this._message("checklist.empty","No matches"))),this.refs.list.replaceChildren(...t)}_replaceChecked(t){er(this._checked,t)||(this._checked=t,this._renderItems(),this.emit("change",{values:this.getValues()}))}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){return String(this._read(t,this.options.labelKey)??"")}_initialChecked(t){let e;return typeof this.options.checkedKey=="function"?e=this.options.checkedKey(t):t!==null&&typeof t=="object"&&(e=t[this.options.checkedKey]),e??this.options.defaultChecked}_read(t,e){return typeof e=="function"?e(t):t===null||typeof t!="object"?t:t[e]}_message(t,e){let s=this.msg(t);return s===t?e:s}};function er(i,t){return i.size===t.size&&Array.from(i).every(e=>t.has(e))}function Mi(){x.register("checklist",(i,t)=>{let e=i.own(new jt(null,{...t.props??{}})),s=!1,n=!1,r=()=>{e.el.setAttribute("aria-disabled",String(s));for(let o of e.el.querySelectorAll("input, button, select, textarea"))o.disabled=s};return i.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>{n||i.emit("change",{value:o.detail.values})}),e.on("loaded",r),{el:e.el,get:()=>e.getValues(),set:o=>{n=!0;try{e.setValues(Array.isArray(o)?o:[])}finally{n=!1}r()},focus:()=>{(e.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])")??e.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus()},setDisabled:o=>{s=!!o,r()}}})}var Ti=["January","February","March","April","May","June","July","August","September","October","November","December"],Ei=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Li=/%[demYyHMSaAbBs]/g;function w(i,t){return!(i instanceof Date)||Number.isNaN(i.getTime())?"":String(t).replace(Li,e=>{switch(e){case"%d":return at(i.getDate());case"%e":return String(i.getDate());case"%m":return at(i.getMonth()+1);case"%Y":return String(i.getFullYear()).padStart(4,"0");case"%y":return at(i.getFullYear()%100);case"%H":return at(i.getHours());case"%M":return at(i.getMinutes());case"%S":return at(i.getSeconds());case"%a":return Ni("weekday",i.getDay(),Ei[i.getDay()]);case"%A":return Se("weekday",i.getDay(),Ei[i.getDay()]);case"%b":return Ni("month",i.getMonth(),Ti[i.getMonth()]);case"%B":return Se("month",i.getMonth(),Ti[i.getMonth()]);case"%s":return String(Math.floor(i.getTime()/1e3));default:return e}})}function q(i,t){let e=[],s="^",n=0;for(let m of String(t).matchAll(Li)){s+=Fi(String(t).slice(n,m.index));let g=m[0],b=ir(g);if(b===null)return null;s+=`(${b})`,e.push(g),n=m.index+g.length}s+=Fi(String(t).slice(n))+"$";let r=new RegExp(s).exec(String(i));if(!r)return null;let o=Object.create(null);if(e.forEach((m,g)=>{o[m]=Number(r[g+1])}),o["%s"]!==void 0){let m=o["%s"]*1e3,g=new Date(m);return Number.isNaN(g.getTime())?null:g}let a=o["%Y"]??sr(o["%y"])??1970,c=(o["%m"]??1)-1,u=o["%d"]??o["%e"]??1,h=o["%H"]??0,f=o["%M"]??0,p=o["%S"]??0,d=new Date(0);return d.setHours(0,0,0,0),d.setFullYear(a,c,u),d.setHours(h,f,p,0),Number.isNaN(d.getTime())||o["%Y"]!==void 0&&d.getFullYear()!==o["%Y"]||o["%y"]!==void 0&&d.getFullYear()%100!==o["%y"]||o["%m"]!==void 0&&d.getMonth()!==c||o["%d"]!==void 0&&d.getDate()!==u||o["%e"]!==void 0&&d.getDate()!==u||o["%H"]!==void 0&&d.getHours()!==h||o["%M"]!==void 0&&d.getMinutes()!==f||o["%S"]!==void 0&&d.getSeconds()!==p?null:d}function Oi(i,t,e){let s=i.getTime(),n=t instanceof Date?t.getTime():-1/0,r=e instanceof Date?e.getTime():1/0;return new Date(Math.min(r,Math.max(n,s)))}function D(i,t){return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()&&i.getDate()===t.getDate()}function S(i,t){let e=new Date(i.getTime());return e.setDate(e.getDate()+t),e}function G(i,t){let e=new Date(i.getTime()),s=e.getDate();e.setDate(1),e.setMonth(e.getMonth()+t);let n=new Date(e.getFullYear(),e.getMonth()+1,0).getDate();return e.setDate(Math.min(s,n)),e}function qt(i=B()){if(!i||i.toLowerCase()==="en")return 1;try{let t=new Intl.Locale(i),e=t.getWeekInfo?.()??t.weekInfo;if(e?.firstDay)return e.firstDay%7}catch{}return 1}function at(i){return String(i).padStart(2,"0")}function Se(i,t,e){let s=`date.${i}.${t}`,n=j(s);return n===s?e:n}function Ni(i,t,e){let s=`date.${i}.short.${t}`,n=j(s);return n!==s?n:Se(i,t,e).slice(0,3)}function ir(i){return{"%d":"\\d{1,2}","%e":"\\d{1,2}","%m":"\\d{1,2}","%Y":"\\d{4}","%y":"\\d{2}","%H":"\\d{1,2}","%M":"\\d{1,2}","%S":"\\d{1,2}","%s":"-?\\d+"}[i]??null}function sr(i){if(i!==void 0)return i>=69?1900+i:2e3+i}function Fi(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ri=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),nr=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),ji=Object.freeze({fa:null,fas:"solid",far:"regular",fal:"light",fat:"thin",fad:"duotone",fab:"brands",fak:"kit",solid:"solid",regular:"regular",light:"light",thin:"thin",duotone:"duotone",brands:"brands",kit:"kit",custom:"kit"}),rr=Object.freeze({x:"xmark",search:"magnifying-glass",calendar:"calendar-days",reload:"arrows-rotate",dots:"ellipsis",info:"circle-info",warning:"triangle-exclamation",error:"circle-exclamation",success:"circle-check",drag:"grip-vertical"}),Ae=new Map;function qi(i){let t=String(i).trim();if(/\s/.test(t)||t.startsWith("fa-"))return{provider:"fa",name:"",style:null,classes:t.split(/\s+/).filter(Boolean)};let e=t.indexOf(":");if(e>0){let s=t.slice(0,e).toLowerCase(),n=t.slice(e+1);if(s==="builtin"||s==="zx")return{provider:"builtin",name:n,style:null,classes:null};if(Object.hasOwn(ji,s))return{provider:"fa",name:n,style:ji[s],classes:null}}return{provider:null,name:t,style:null,classes:null}}function ze(i,t={}){let{style:e="solid",family:s="classic",fixedWidth:n=!1,translate:r=!0}=t,o=String(i).replace(/^fa-/,""),a=r?rr[o]??o:o,c=[],u=nr[s];return u&&c.push(u),c.push(Ri[e]??Ri.solid,`fa-${a}`),n&&c.push("fa-fw"),c}function De(i){let t=String(i).trim();if(/^(https?:)?\/\//.test(t)||t.startsWith("/")||t.endsWith(".js"))return t;if(!/^[a-z0-9]+$/.test(t))throw new RangeError(`Invalid Font Awesome kit token: ${i}`);return`https://kit.fontawesome.com/${t}.js`}function Vi(i){let t=De(i),e=Ae.get(t);if(e)return e;let s=new Promise((n,r)=>{let o=new URL(t,document.baseURI).href,a=[...document.scripts].find(u=>u.src===o);if(a&&globalThis.FontAwesomeKitConfig){n();return}let c=a??document.createElement("script");c.addEventListener("load",()=>n(),{once:!0}),c.addEventListener("error",()=>{Ae.delete(t),r(new Error(`Font Awesome kit failed to load: ${t}`))},{once:!0}),!a&&(c.src=t,c.async=!0,c.crossOrigin="anonymous",document.head.append(c))});return Ae.set(t,s),s}var Pi="http://www.w3.org/2000/svg",Hi=Object.freeze({"chevron-down":["0 0 512 512","M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"],"chevron-up":["0 0 512 512","M233.4 105.4c12.5-12.5 32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L256 173.3 86.6 342.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l192-192z"],"chevron-left":["0 0 320 512","M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 256 246.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"],"chevron-right":["0 0 320 512","M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"],check:["0 0 448 512","M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"],x:["0 0 384 512","M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"],plus:["0 0 448 512","M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32V224H48c-17.7 0-32 14.3-32 32s14.3 32 32 32H192V432c0 17.7 14.3 32 32 32s32-14.3 32-32V288H400c17.7 0 32-14.3 32-32s-14.3-32-32-32H256V80z"],minus:["0 0 448 512","M432 256c0 17.7-14.3 32-32 32L48 288c-17.7 0-32-14.3-32-32s14.3-32 32-32l352 0c17.7 0 32 14.3 32 32z"],search:["0 0 512 512","M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"],calendar:["0 0 448 512","M128 0c17.7 0 32 14.3 32 32V64H288V32c0-17.7 14.3-32 32-32s32 14.3 32 32V64h48c26.5 0 48 21.5 48 48v48H0V112C0 85.5 21.5 64 48 64H96V32c0-17.7 14.3-32 32-32zM0 192H448V464c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V192z"],clock:["0 0 512 512","M256 0a256 256 0 1 1 0 512A256 256 0 1 1 256 0zM232 120V256c0 8 4 15.5 10.7 20l96 64c11 7.4 25.9 4.4 33.3-6.7s4.4-25.9-6.7-33.3L280 243.2V120c0-13.3-10.7-24-24-24s-24 10.7-24 24z"],trash:["0 0 448 512","M135.2 17.7L128 32H32C14.3 32 0 46.3 0 64S14.3 96 32 96H416c17.7 0 32-14.3 32-32s-14.3-32-32-32H320l-7.2-14.3C307.4 6.8 296.3 0 284.2 0H163.8c-12.1 0-23.2 6.8-28.6 17.7zM416 128H32L53.2 467c1.6 25.3 22.6 45 47.9 45H346.9c25.3 0 46.3-19.7 47.9-45L416 128z"],gear:["0 0 512 512","M481.9 166.6c3.2 8.7 .5 18.4-6.4 24.6l-43.3 39.4c1.1 8.3 1.7 16.8 1.7 25.4s-.6 17.1-1.7 25.4l43.3 39.4c6.9 6.2 9.6 15.9 6.4 24.6c-4.4 11.9-9.7 23.3-15.8 34.3l-4.7 8.1c-6.6 11-14 21.4-22.1 31.2c-5.9 7.2-15.7 9.6-24.5 6.8l-55.7-17.7c-13.4 10.3-28.2 18.9-44 25.4l-12.5 57.1c-2 9.1-9 16.3-18.2 17.8c-13.8 2.3-28 3.5-42.5 3.5s-28.7-1.2-42.5-3.5c-9.2-1.5-16.2-8.7-18.2-17.8l-12.5-57.1c-15.8-6.5-30.6-15.1-44-25.4L83.1 425.9c-8.8 2.8-18.6 .3-24.5-6.8c-8.1-9.8-15.5-20.2-22.1-31.2l-4.7-8.1c-6.1-11-11.4-22.4-15.8-34.3c-3.2-8.7-.5-18.4 6.4-24.6l43.3-39.4C64.6 273.1 64 264.6 64 256s.6-17.1 1.7-25.4L22.4 191.2c-6.9-6.2-9.6-15.9-6.4-24.6c4.4-11.9 9.7-23.3 15.8-34.3l4.7-8.1c6.6-11 14-21.4 22.1-31.2c5.9-7.2 15.7-9.6 24.5-6.8l55.7 17.7c13.4-10.3 28.2-18.9 44-25.4l12.5-57.1c2-9.1 9-16.3 18.2-17.8C227.3 1.2 241.5 0 256 0s28.7 1.2 42.5 3.5c9.2 1.5 16.2 8.7 18.2 17.8l12.5 57.1c15.8 6.5 30.6 15.1 44 25.4l55.7-17.7c8.8-2.8 18.6-.3 24.5 6.8c8.1 9.8 15.5 20.2 22.1 31.2l4.7 8.1c6.1 11 11.4 22.4 15.8 34.3zM256 336a80 80 0 1 0 0-160 80 80 0 1 0 0 160z"],eye:["0 0 576 512","M288 32c-80.8 0-145.5 36.8-192.6 80.6C48.6 156 17.3 208 2.5 243.7c-3.3 7.9-3.3 16.7 0 24.6C17.3 304 48.6 356 95.4 399.4C142.5 443.2 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C433.5 68.8 368.8 32 288 32zM144 256a144 144 0 1 1 288 0 144 144 0 1 1-288 0zm144-64c0 35.3-28.7 64-64 64c-7.1 0-13.9-1.2-20.3-3.3c-5.5-1.8-11.9 1.6-11.7 7.4c.3 6.9 1.3 13.8 3.2 20.7c13.7 51.2 66.4 81.6 117.6 67.9s81.6-66.4 67.9-117.6c-11.1-41.5-47.8-69.4-88.6-71.1c-5.8-.2-9.2 6.1-7.4 11.7c2.1 6.4 3.3 13.2 3.3 20.3z"],lock:["0 0 448 512","M144 144v48H304V144c0-44.2-35.8-80-80-80s-80 35.8-80 80zM80 192V144C80 64.5 144.5 0 224 0s144 64.5 144 144v48h16c35.3 0 64 28.7 64 64V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V256c0-35.3 28.7-64 64-64H80z"],reload:["0 0 512 512","M386.3 160H336c-17.7 0-32 14.3-32 32s14.3 32 32 32H464c17.7 0 32-14.3 32-32V64c0-17.7-14.3-32-32-32s-32 14.3-32 32v51.2L414.4 97.6c-87.5-87.5-229.3-87.5-316.8 0s-87.5 229.3 0 316.8s229.3 87.5 316.8 0c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0c-62.5 62.5-163.8 62.5-226.3 0s-62.5-163.8 0-226.3s163.8-62.5 226.3 0L386.3 160z"],list:["0 0 512 512","M40 48C26.7 48 16 58.7 16 72v48c0 13.3 10.7 24 24 24H88c13.3 0 24-10.7 24-24V72c0-13.3-10.7-24-24-24H40zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zM16 232v48c0 13.3 10.7 24 24 24H88c13.3 0 24-10.7 24-24V232c0-13.3-10.7-24-24-24H40c-13.3 0-24 10.7-24 24zM40 368c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24H88c13.3 0 24-10.7 24-24V392c0-13.3-10.7-24-24-24H40z"],filter:["0 0 512 512","M3.9 54.9C10.5 40.9 24.5 32 40 32H472c15.5 0 29.5 8.9 36.1 22.9s4.6 30.5-5.2 42.5L320 320.9V448c0 12.1-6.8 23.2-17.7 28.6s-23.8 4.3-33.5-3l-64-48c-8.1-6-12.8-15.5-12.8-25.6V320.9L9 97.3C-.7 85.4-2.8 68.8 3.9 54.9z"],dots:["0 0 448 512","M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1-112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"],info:["0 0 512 512","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"],warning:["0 0 512 512","M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0-64 0 32 32 0 1 0 64 0z"],error:["0 0 512 512","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24V264c0 13.3-10.7 24-24 24s-24-10.7-24-24V152c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1-64 0z"],success:["0 0 512 512","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"],upload:["0 0 512 512","M288 109.3V352c0 17.7-14.3 32-32 32s-32-14.3-32-32V109.3l-73.4 73.4c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l128-128c12.5-12.5 32.8-12.5 45.3 0l128 128c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L288 109.3zM64 352H192c0 35.3 28.7 64 64 64s64-28.7 64-64H448c35.3 0 64 28.7 64 64v32c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V416c0-35.3 28.7-64 64-64z"],drag:["0 0 320 512","M40 352l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40zm192 0l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40zM40 176l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40zm192 0l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40zM40 0L88 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40L40 128C17.9 128 0 110.1 0 88L0 40C0 17.9 17.9 0 40 0zM232 0l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40z"],star:["0 0 576 512","M287.9 0c9.2 0 17.6 5.2 21.6 13.5l68.6 141.3 153.2 22.6c9 1.3 16.5 7.6 19.3 16.3s.5 18.1-5.9 24.5L433.6 328.4l26.2 155.6c1.5 9-2.2 18.1-9.7 23.5s-17.3 6-25.3 1.7l-137-73.2L151 509.1c-8.1 4.3-17.9 3.7-25.3-1.7s-11.2-14.5-9.7-23.5l26.2-155.6L31.1 218.2c-6.5-6.4-8.7-15.9-5.9-24.5s10.3-14.9 19.3-16.3l153.2-22.6L266.3 13.5C270.4 5.2 278.7 0 287.9 0z"],heart:["0 0 512 512","M47.6 300.4L228.3 469.1c7.5 7 17.4 10.9 27.7 10.9s20.2-3.9 27.7-10.9L464.4 300.4c30.4-28.3 47.6-68 47.6-109.5v-5.8c0-69.9-50.5-129.5-119.4-141C347 36.5 300.6 51.4 268 84L256 96 244 84c-32.6-32.6-79-47.5-124.6-39.9C50.5 55.6 0 115.2 0 185.1v5.8c0 41.5 17.2 81.2 47.6 109.5z"],tag:["0 0 448 512","M0 80V229.5c0 17 6.7 33.3 18.7 45.3l176 176c25 25 65.5 25 90.5 0L418.7 317.3c25-25 25-65.5 0-90.5l-176-176c-12-12-28.3-18.7-45.3-18.7H48C21.5 32 0 53.5 0 80zm112 32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"],folder:["0 0 512 512","M64 480H448c35.3 0 64-28.7 64-64V160c0-35.3-28.7-64-64-64H298.5c-17 0-33.3-6.7-45.3-18.7L226.7 50.7c-12-12-28.3-18.7-45.3-18.7H64C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64z"],"folder-open":["0 0 576 512","M88.7 223.8L0 375.8V96C0 60.7 28.7 32 64 32H181.5c17 0 33.3 6.7 45.3 18.7l26.5 26.5c12 12 28.3 18.7 45.3 18.7H416c35.3 0 64 28.7 64 64v32H144c-22.8 0-43.8 12.1-55.3 31.8zm27.6 16.1C122.1 230 132.6 224 144 224H544c11.5 0 22 6.1 27.7 16.1s5.7 22.2-.1 32.1l-112 192C453.9 474 443.4 480 432 480H32c-11.5 0-22-6.1-27.7-16.1s-5.7-22.2 .1-32.1l112-192z"],file:["0 0 384 512","M0 64C0 28.7 28.7 0 64 0H224V128c0 17.7 14.3 32 32 32H384V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V64zm384 64H256V0L384 128z"],copy:["0 0 448 512","M208 0L332.1 0c12.7 0 24.9 5.1 33.9 14.1l67.9 67.9c9 9 14.1 21.2 14.1 33.9L448 336c0 26.5-21.5 48-48 48l-192 0c-26.5 0-48-21.5-48-48l0-288c0-26.5 21.5-48 48-48zM48 128l80 0 0 64-64 0 0 256 192 0 0-32 64 0 0 48c0 26.5-21.5 48-48 48L48 512c-26.5 0-48-21.5-48-48L0 176c0-26.5 21.5-48 48-48z"],square:["0 0 448 512","M384 80c8.8 0 16 7.2 16 16V416c0 8.8-7.2 16-16 16H64c-8.8 0-16-7.2-16-16V96c0-8.8 7.2-16 16-16H384zM64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64z"],code:["0 0 640 512","M392.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6zm80.6 120.1c-12.5 12.5-12.5 32.8 0 45.3L562.7 256l-89.4 89.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l112-112c12.5-12.5 12.5-32.8 0-45.3l-112-112c-12.5-12.5-32.8-12.5-45.3 0zm-306.7 0c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3l112 112c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l89.4-89.4c12.5-12.5 12.5-32.8 0-45.3z"],book:["0 0 448 512","M96 0C43 0 0 43 0 96V416c0 53 43 96 96 96H384h32c17.7 0 32-14.3 32-32s-14.3-32-32-32V384c17.7 0 32-14.3 32-32V32c0-17.7-14.3-32-32-32H384 96zm0 384H352v64H96c-17.7 0-32-14.3-32-32s14.3-32 32-32zm32-240c0-8.8 7.2-16 16-16H336c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-8.8 0-16-7.2-16-16zm16 48H336c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-8.8 0-16-7.2-16-16s7.2-16 16-16z"]}),or=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list"}),ar=Object.create(null),H={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function Ie(){return{...H}}function Me(i={}){for(let t of["provider","style","family","fixedWidth","kit"])i[t]!==void 0&&(H[t]=i[t]);return Ie()}function $i(i={}){return Me({...i,provider:"fontawesome"})}async function Te(i){let t=typeof i=="string"?{kit:i}:{...i},{kit:e,activate:s=!0,...n}=t;if(!e)throw new TypeError("loadFontAwesome() needs a kit token or URL");return Me({...n,kit:De(e)}),await Vi(e),s?$i():Ie()}function _(i,t={}){let e=qi(i);if(e.classes)return Ce(e.classes,t);let s=or[e.name]??e.name;return e.provider==="builtin"?Bi(s,t):e.provider==="fa"?Ce(ze(s,{style:e.style??t.style??H.style,family:t.family??H.family,fixedWidth:t.fixedWidth??H.fixedWidth}),t):H.provider==="fontawesome"?Ce(ze(s,{style:t.style??H.style,family:t.family??H.family,fixedWidth:t.fixedWidth??H.fixedWidth}),t):Bi(s,t)}function Bi(i,t){let e=ar[i]??Hi[i];if(!e)throw new RangeError(`Unknown icon: ${i}`);let[s,n]=e,{size:r=16}=t,o=document.createElementNS(Pi,"svg"),a=document.createElementNS(Pi,"path");return o.setAttribute("class",Ki("zx-icon",t.class)),o.setAttribute("viewBox",s),o.setAttribute("width",String(r)),o.setAttribute("height",String(r)),o.setAttribute("fill","currentColor"),o.setAttribute("focusable","false"),Yi(o,t.label??null),a.setAttribute("d",n),o.append(a),o}function Ce(i,t){let{size:e=16}=t,s=document.createElement("i");return s.className=Ki("zx-icon",...i,t.class),s.style.fontSize=typeof e=="number"?`${e}px`:String(e),Yi(s,t.label??null),s}function Yi(i,t){if(t===null){i.setAttribute("aria-hidden","true");return}i.setAttribute("role","img"),i.setAttribute("aria-label",t)}function Ki(...i){return i.flat().filter(Boolean).join(" ")}var lr=5,Vt=class extends y{static cssName="time-picker";static defaults={value:null,seconds:!1,step:5,clock:!0};render(){let t=this.el??l("div");this.el=t;let e=Ui(this.options.value);this._value=e,this._display=e??{h:0,m:0,s:0},this._inputs=[],this._clockOpen=!1,this._clockUnit="h",this._clock=null;let s=l("div",{class:"zx-time-picker__segments",role:"group",ariaLabel:"Time"});if(this._content=s,this._addSpin(s,"h","Hour",23),s.append(l("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"m","Minute",59),this.options.seconds&&(s.append(l("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"s","Second",59)),t.append(s),this.options.clock){let n=v("zx-time-picker-clock");s.append(l("button",{ref:"clockToggle",class:"zx-icon-btn zx-time-picker__clock-toggle",type:"button",ariaLabel:"Pick the time on a clock",ariaExpanded:"false",ariaControls:n},_("clock",{size:15}))),this._clock=this._buildClock(n),t.append(this._clock),this.listen(this.refs.clockToggle,"click",()=>this.toggleClock())}return this._writeInputs(),t}get(){return this._value?{...this._value}:null}set(t,{silent:e=!1}={}){let s=Ui(t);return this._value=s,this._display=s??{h:0,m:0,s:0},this._writeInputs(),!e&&s&&this.emit("change",{time:{...s}}),this}openClock(t="h"){return this._clock?(this._clockOpen=!0,this._clockUnit=t==="m"?"m":"h",this._syncClock(),this):this}closeClock(){return this._clock?(this._clockOpen=!1,this._syncClock(),this):this}toggleClock(){return this._clockOpen?this.closeClock():this.openClock("h")}destroy(){this._content?.remove(),this._clock?.remove(),this._clock=null,super.destroy()}_addSpin(t,e,s,n){let r=l("input",{class:"zx-time-picker__spin",type:"text",role:"spinbutton",inputMode:"numeric",maxLength:2,autocomplete:"off",ariaLabel:s,ariaValueMin:"0",ariaValueMax:String(n),dataset:{segment:e}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"keydown",o=>this._onKeydown(o,e,n)),this.listen(r,"input",()=>this._onInput(r,e,n)),this.listen(r,"blur",()=>this._commitFromInputs())}_onKeydown(t,e,s){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return;t.preventDefault();let n=t.key==="ArrowUp"?1:-1,r=e==="m"?dr(this.options.step):1,o=lt(t.currentTarget.value,0,s),a=s+1,c=(o+n*r+a*r)%a;t.currentTarget.value=X(c),this._commitFromInputs()}_onInput(t,e,s){if(t.value=t.value.replace(/\D/g,"").slice(0,2),t.value.length<2)return;t.value=X(lt(t.value,0,s)),this._commitFromInputs();let n=this._inputs.indexOf(t);this._inputs[n+1]?.focus()}_commitFromInputs(){let t={h:0,m:0,s:0};for(let s of this._inputs){let n=s.dataset.segment,r=n==="h"?23:59;t[n]=lt(s.value,0,r)}let e=!this._value||!fr(this._value,t);this._value=t,this._display=t,this._writeInputs(),e&&this.emit("change",{time:{...t}})}_writeInputs(){for(let t of this._inputs){let e=t.dataset.segment;t.value=X(this._display[e]),t.setAttribute("aria-valuenow",String(this._display[e])),t.setAttribute("aria-valuetext",t.value)}this._syncClock()}_buildClock(t){let e=l("div",{class:"zx-time-picker__clock",id:t,hidden:!0},l("div",{class:"zx-time-picker__clock-head"},l("button",{ref:"headHour",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:"Select the hour",dataset:{unit:"h"}}),l("span",{class:"zx-time-picker__clock-colon",ariaHidden:"true"},":"),l("button",{ref:"headMinute",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:"Select the minutes",dataset:{unit:"m"}})),l("div",{ref:"dial",class:"zx-time-picker__dial",role:"radiogroup"},l("span",{ref:"hand",class:"zx-time-picker__hand",ariaHidden:"true"}),l("span",{class:"zx-time-picker__pivot",ariaHidden:"true"})));return this.listen(this.refs.headHour,"click",()=>this.openClock("h")),this.listen(this.refs.headMinute,"click",()=>this.openClock("m")),this.listen(this.refs.dial,"click",s=>{let n=s.target.closest?.(".zx-time-picker__mark");n&&this._pick(Number(n.dataset.value))}),this.listen(this.refs.dial,"keydown",s=>this._onDialKeydown(s)),e}_pick(t){let e={...this._display,[this._clockUnit]:t},s=this._clockUnit==="h";this.set(e),s&&this.openClock("m")}_onDialKeydown(t){let e=[...this.refs.dial.querySelectorAll(".zx-time-picker__mark")],s=t.target.closest?.(".zx-time-picker__mark"),n=e.indexOf(s);if(n<0)return;let r={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[t.key],o=null;r!==void 0?o=(n+r+e.length)%e.length:t.key==="Home"?o=0:t.key==="End"&&(o=e.length-1),o!==null&&(t.preventDefault(),this._pick(Number(e[o].dataset.value)),this.refs.dial.querySelector(`[data-value="${e[o].dataset.value}"]`)?.focus())}_syncClock(){if(!this._clock)return;let t=this._clockUnit==="h";if(this._clock.hidden=!this._clockOpen,this.refs.clockToggle.setAttribute("aria-expanded",String(this._clockOpen)),this.refs.headHour.textContent=X(this._display.h),this.refs.headMinute.textContent=X(this._display.m),this.refs.headHour.setAttribute("aria-pressed",String(t)),this.refs.headMinute.setAttribute("aria-pressed",String(!t)),this.refs.dial.setAttribute("aria-label",t?"Hour":"Minutes"),!this._clockOpen)return;let e=t?this._display.h:this._display.m,s=t?cr():ur(),n=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(n.length!==s.length||this.refs.dial.dataset.unit!==this._clockUnit){for(let a of n)a.remove();this.refs.dial.dataset.unit=this._clockUnit,this.refs.dial.append(...s.map(a=>this._buildMark(a,e)))}else s.forEach((a,c)=>this._syncMark(n[c],a,e));let r=t&&!hr(e)?"inner":"outer",o=t?e%12*30:e*6;this.refs.hand.dataset.ring=r,this.refs.hand.style.setProperty("--zx-clock-angle",`${o}deg`)}_buildMark(t,e){let s=l("button",{class:"zx-time-picker__mark",type:"button",role:"radio",dataset:{value:String(t.value),ring:t.ring}},t.label);return s.style.setProperty("--zx-clock-angle",`${t.angle}deg`),this._syncMark(s,t,e),s}_syncMark(t,e,s){let n=e.value===s;t.setAttribute("aria-checked",String(n)),t.tabIndex=n?0:-1}};function cr(){let i=[];for(let t=1;t<=12;t+=1)i.push({value:t,label:String(t),angle:t%12*30,ring:"outer"});for(let t=0;t<12;t+=1){let e=t===0?0:12+t;i.push({value:e,label:X(e),angle:t*30,ring:"inner"})}return i}function ur(){let i=[];for(let t=0;t<60;t+=lr)i.push({value:t,label:X(t),angle:t*6,ring:"outer"});return i}function hr(i){return i>=1&&i<=12}function Ui(i){return i instanceof Date&&!Number.isNaN(i.getTime())?{h:i.getHours(),m:i.getMinutes(),s:i.getSeconds()}:!i||typeof i!="object"?null:{h:lt(i.h,0,23),m:lt(i.m,0,59),s:lt(i.s,0,59)}}function lt(i,t,e){let s=Number.parseInt(String(i??""),10);return Number.isFinite(s)?Math.max(t,Math.min(e,s)):t}function dr(i){let t=Math.round(Number(i));return Number.isFinite(t)&&t>0&&t<=59?t:5}function X(i){return String(i).padStart(2,"0")}function fr(i,t){return i.h===t.h&&i.m===t.m&&i.s===t.s}var ct=class extends y{static cssName="date-picker";static defaults={value:null,min:null,max:null,weekStart:1,showWeekNumbers:!1,time:!1};render(){let t=this.el??l("div");this._min=L(Pt(this.options.min)),this._max=L(Pt(this.options.max)),this._value=this._normalizeValue(Pt(this.options.value)),this._focused=L(this._value)??this._clampFocus(L(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=pr(this.options.weekStart),this._quickOpen=!1,this._timePicker=null;let e=l("div",{class:"zx-date-picker__surface"},l("div",{class:"zx-date-picker__header"},l("button",{ref:"previous",class:"zx-date-picker__nav",type:"button",ariaLabel:"Previous month"},_("chevron-left")),l("button",{ref:"heading",class:"zx-date-picker__heading",type:"button",ariaExpanded:"false","aria-haspopup":"grid"}),l("button",{ref:"next",class:"zx-date-picker__nav",type:"button",ariaLabel:"Next month"},_("chevron-right"))),l("div",{ref:"quickPanel",class:"zx-date-picker__quick",hidden:!0},l("div",{class:"zx-date-picker__quick-header"},l("button",{ref:"quickPrevious",class:"zx-date-picker__nav",type:"button",ariaLabel:"Previous year"},_("chevron-left")),l("span",{ref:"quickYear",class:"zx-date-picker__quick-year",ariaLive:"polite"}),l("button",{ref:"quickNext",class:"zx-date-picker__nav",type:"button",ariaLabel:"Next year"},_("chevron-right"))),l("div",{ref:"quickGrid",class:"zx-date-picker__quick-grid",role:"grid"})),l("table",{ref:"grid",class:"zx-date-picker__grid",role:"grid",ariaLabel:"Calendar"},l("thead",{ref:"weekdays"}),l("tbody",{ref:"days"})));return this._content=e,t.append(e),this.listen(this.refs.previous,"click",()=>this._pageMonth(-1)),this.listen(this.refs.next,"click",()=>this._pageMonth(1)),this.listen(this.refs.heading,"click",()=>this._toggleQuickPick()),this.listen(this.refs.quickPrevious,"click",()=>this._stepQuickYear(-1)),this.listen(this.refs.quickNext,"click",()=>this._stepQuickYear(1)),this.listen(this.refs.quickGrid,"click",s=>this._onQuickClick(s)),this.listen(this.refs.quickGrid,"keydown",s=>this._onQuickKeydown(s)),this.listen(this.refs.days,"click",s=>this._onDayClick(s)),this.listen(this.refs.days,"keydown",s=>this._onDayKeydown(s)),this._renderWeekdays(),this._renderCalendar(),this.options.time&&(this._timePicker=new Vt(null,{value:this._value,seconds:!1}),this._timePicker.on("change",s=>{let n=s.detail.time,r=this._value??this._focused,o=new Date(r.getTime());o.setHours(n.h,n.m,n.s,0),this.set(o)}),e.append(this._timePicker.el)),t}get(){return Ee(this._value)}set(t,{silent:e=!1}={}){let s=this._normalizeValue(Pt(t));return this._value=s,s&&(this._focused=L(s),this._viewYear=s.getFullYear(),this._viewMonth=s.getMonth()),this._timePicker?.set(s,{silent:!0}),this._renderCalendar(),e||this.emit("change",{date:Ee(this._value)}),this}focus(){return this._closeQuickPick(),this._buttonForDate(this._focused)?.focus(),this}destroy(){this._timePicker?.destroy(),this._timePicker=null,this._content?.remove(),super.destroy()}_normalizeValue(t){if(!t)return null;let e=new Date(t.getTime()),s=L(e);return this._min&&s<this._min&&Wi(e,this._min),this._max&&s>this._max&&Wi(e,this._max),e}_clampFocus(t){return this._min&&t<this._min?new Date(this._min.getTime()):this._max&&t>this._max?new Date(this._max.getTime()):t}_renderWeekdays(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-picker__week-heading",scope:"col",ariaLabel:"Week number"},"#"));let e=new Date(2023,0,1);for(let s=0;s<7;s+=1){let n=S(e,(this._weekStart+s)%7);t.append(l("th",{scope:"col",ariaLabel:w(n,"%A")},w(n,"%a")))}this.refs.weekdays.replaceChildren(t)}_renderCalendar(){if(!this.refs?.days)return;let t=new Date(this._viewYear,this._viewMonth,1),e=(t.getDay()-this._weekStart+7)%7,s=S(t,-e);this.refs.heading.textContent=w(t,"%B %Y"),this.refs.heading.setAttribute("aria-label",`Choose month and year, ${w(t,"%B %Y")}`);let n=[];for(let r=0;r<6;r+=1){let o=S(s,r*7),a=l("tr");this.options.showWeekNumbers&&a.append(l("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:`Week ${Qi(o)}`},String(Qi(o))));for(let c=0;c<7;c+=1){let u=S(o,c),h=!!(this._value&&D(u,this._value)),f=!this._inRange(u),p=l("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:D(u,this._focused)?0:-1,ariaSelected:String(h),ariaDisabled:String(f),ariaCurrent:D(u,new Date)?"date":null,ariaLabel:`${w(u,"%e")} ${w(u,"%B %Y")}`,dataset:{date:w(u,"%Y-%m-%d"),otherMonth:u.getMonth()===this._viewMonth?null:"true"}},w(u,"%e"));a.append(l("td",{role:"presentation"},p))}n.push(a)}this.refs.days.replaceChildren(...n),this._quickOpen&&this._renderQuickPick()}_onDayClick(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let s=q(e.dataset.date,"%Y-%m-%d");s&&this._inRange(s)&&this._selectDate(s)}_onDayKeydown(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let s=q(e.dataset.date,"%Y-%m-%d");if(!s)return;let n=null;if(t.key==="ArrowLeft")n=S(s,-1);else if(t.key==="ArrowRight")n=S(s,1);else if(t.key==="ArrowUp")n=S(s,-7);else if(t.key==="ArrowDown")n=S(s,7);else if(t.key==="PageUp")n=G(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=G(s,t.shiftKey?12:1);else if(t.key==="Home")n=S(s,-((s.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=S(s,6-(s.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._inRange(s)&&this._selectDate(s);return}n&&(t.preventDefault(),this._moveFocus(n))}_moveFocus(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;this._focused=L(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._renderCalendar(),e&&this._emitMonthChange(),this._buttonForDate(t)?.focus()}_selectDate(t){let e=new Date(t.getTime()),s=this._timePicker?.get();s?e.setHours(s.h,s.m,s.s,0):this._value&&e.setHours(this._value.getHours(),this._value.getMinutes(),this._value.getSeconds(),this._value.getMilliseconds());let n=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;this._value=e,this._focused=L(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._timePicker?.set(e,{silent:!0}),this._renderCalendar(),n&&this._emitMonthChange(),this.emit("change",{date:Ee(e)})}_pageMonth(t){this._closeQuickPick();let e=G(this._focused,t);this._focused=L(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._renderCalendar(),this._emitMonthChange()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_toggleQuickPick(){if(this._quickOpen){this._closeQuickPick(),this.refs.heading.focus();return}this._quickOpen=!0,this.refs.quickPanel.hidden=!1,this.refs.heading.setAttribute("aria-expanded","true"),this._renderQuickPick(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_closeQuickPick(){this._quickOpen&&(this._quickOpen=!1,this.refs.quickPanel.hidden=!0,this.refs.heading.setAttribute("aria-expanded","false"))}_renderQuickPick(){this.refs.quickYear.textContent=String(this._viewYear);let t=[];for(let e=0;e<12;e+=1){let s=new Date(this._viewYear,e,1);t.push(l("button",{class:"zx-date-picker__quick-month",type:"button",role:"gridcell",tabindex:e===this._viewMonth?0:-1,ariaSelected:String(e===this._viewMonth),dataset:{month:e}},w(s,"%b")))}this.refs.quickGrid.replaceChildren(...t)}_stepQuickYear(t){this._viewYear+=t,this._renderQuickPick(),this._emitMonthChange(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_onQuickClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.quickGrid.contains(e)||this._chooseQuickMonth(Number(e.dataset.month))}_onQuickKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.quickGrid.contains(e))return;let s=Number(e.dataset.month),n=null;if(t.key==="ArrowLeft")n=s-1;else if(t.key==="ArrowRight")n=s+1;else if(t.key==="ArrowUp")n=s-3;else if(t.key==="ArrowDown")n=s+3;else if(t.key==="Home")n=0;else if(t.key==="End")n=11;else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._chooseQuickMonth(s);return}else if(t.key==="Escape"){t.preventDefault(),this._closeQuickPick(),this.refs.heading.focus();return}if(n===null)return;t.preventDefault(),n=Math.max(0,Math.min(11,n));let r=this.refs.quickGrid.querySelectorAll("[data-month]");for(let o of r)o.tabIndex=Number(o.dataset.month)===n?0:-1;r[n]?.focus()}_chooseQuickMonth(t){let e=new Date(this._viewYear,t,Math.min(this._focused.getDate(),new Date(this._viewYear,t+1,0).getDate()));this._focused=L(e),this._viewMonth=t,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(t){let e=L(t);return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_buttonForDate(t){return this.refs.days.querySelector(`[data-date="${w(t,"%Y-%m-%d")}"]`)}};function Pt(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function L(i){return i?new Date(i.getFullYear(),i.getMonth(),i.getDate()):null}function Ee(i){return i?new Date(i.getTime()):null}function Wi(i,t){i.setFullYear(t.getFullYear(),t.getMonth(),t.getDate())}function pr(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:qt()}function Qi(i){let t=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let s=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-s.getTime())/864e5+1)/7)}var $t=class extends ct{static cssName="month-picker";static defaults={value:null,min:null,max:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??l("div");this._min=Ht(Bt(this.options.min)),this._max=Ht(Bt(this.options.max)),this._value=this._normalizeMonth(Bt(this.options.value));let e=this._value??Ht(new Date);this._year=e.getFullYear(),this._focusedMonth=e.getMonth();let s=l("div",{class:"zx-month-picker__surface"},l("div",{class:"zx-month-picker__header"},l("button",{ref:"previousYear",class:"zx-month-picker__nav",type:"button",ariaLabel:"Previous year"},_("chevron-left")),l("span",{ref:"year",class:"zx-month-picker__year",ariaLive:"polite"}),l("button",{ref:"nextYear",class:"zx-month-picker__nav",type:"button",ariaLabel:"Next year"},_("chevron-right"))),l("div",{ref:"grid",class:"zx-month-picker__grid",role:"grid",ariaLabel:"Choose month"}));return this._content=s,t.append(s),this.listen(this.refs.previousYear,"click",()=>this._stepYear(-1)),this.listen(this.refs.nextYear,"click",()=>this._stepYear(1)),this.listen(this.refs.grid,"click",n=>this._onMonthClick(n)),this.listen(this.refs.grid,"keydown",n=>this._onMonthKeydown(n)),this._renderMonths(),t}get(){return this._value?new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeMonth(Bt(t)),this._value&&(this._year=this._value.getFullYear(),this._focusedMonth=this._value.getMonth()),this._renderMonths(),e||this.emit("change",{date:this.get()}),this}focus(){return this._button(this._focusedMonth)?.focus(),this}destroy(){this._content?.remove(),super.destroy()}_normalizeMonth(t){if(!t)return null;let e=Ht(t);return this._min&&e<this._min&&(e=new Date(this._min.getTime())),this._max&&e>this._max&&(e=new Date(this._max.getTime())),e}_renderMonths(){if(!this.refs?.grid)return;this.refs.year.textContent=String(this._year);let t=[];for(let e=0;e<12;e+=1){let s=new Date(this._year,e,1),n=!!(this._value&&mr(s,this._value));t.push(l("button",{class:"zx-month-picker__month",type:"button",role:"gridcell",tabindex:e===this._focusedMonth?0:-1,ariaSelected:String(n),ariaDisabled:String(!this._inRange(s)),ariaLabel:w(s,"%B %Y"),dataset:{month:e}},w(s,"%b")))}this.refs.grid.replaceChildren(...t)}_stepYear(t){this._year+=t,this._renderMonths()}_onMonthClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.grid.contains(e)||this._selectMonth(Number(e.dataset.month))}_onMonthKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.grid.contains(e))return;let s=Number(e.dataset.month),n=null;if(t.key==="ArrowLeft")n=-1;else if(t.key==="ArrowRight")n=1;else if(t.key==="ArrowUp")n=-3;else if(t.key==="ArrowDown")n=3;else if(t.key==="Home")n=-(s%3);else if(t.key==="End")n=2-s%3;else if(t.key==="PageUp"){t.preventDefault(),this._stepYear(-1),this.focus();return}else if(t.key==="PageDown"){t.preventDefault(),this._stepYear(1),this.focus();return}else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._selectMonth(s);return}if(n===null)return;t.preventDefault();let r=this._year*12+s+n;this._year=Math.floor(r/12),this._focusedMonth=(r%12+12)%12,this._renderMonths(),this.focus()}_selectMonth(t){let e=new Date(this._year,t,1);this._inRange(e)&&(this._focusedMonth=t,this._value=e,this._renderMonths(),this.emit("change",{date:this.get()}))}_inRange(t){return!(this._min&&t<this._min)&&!(this._max&&t>this._max)}_button(t){return this.refs.grid.querySelector(`[data-month="${t}"]`)}};function Bt(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function Ht(i){return i?new Date(i.getFullYear(),i.getMonth(),1):null}function mr(i,t){return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()}function Zi(){x.register("month",(i,t)=>{let e=i.own(new $t(null,{...t.props??{},value:t.value})),s=!1,n=()=>{e.el.setAttribute("aria-disabled",String(s));for(let r of e.el.querySelectorAll("button"))r.disabled=s};return i.listen(e.el,"change",r=>r.stopImmediatePropagation()),e.on("change",r=>i.emit("change",{value:r.detail.date})),{el:e.el,get:()=>e.get(),set:r=>{e.set(r instanceof Date?r:null,{silent:!0}),n()},focus:()=>e.focus(),setDisabled:r=>{s=!!r,n()}}})}var _r=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function U(i,t,e={}){if(!(i instanceof Element)||!(t instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let s=_r.has(e.placement)?e.placement:"bottom-start",n=Number(e.offset??4),r=e.flip??!0,o=e.matchWidth??!1,a=i.getAttribute("style"),c=t.getAttribute("style"),u=t.getAttribute("popover"),h=!1,f=null,p=()=>{},d=()=>{};if(t.setAttribute("popover","manual"),typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a")){let g=`--${v("zx-a")}`;i.style.setProperty("anchor-name",g),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.setProperty("position-anchor",g);let b=gr(s,getComputedStyle(i).direction==="rtl");t.style.setProperty("position-area",b),t.style.setProperty("inset-area",b),t.style.setProperty("position-try-fallbacks",r?"flip-block, flip-inline, flip-block flip-inline":"none");let k=s.startsWith("top")?"margin-bottom":s.startsWith("bottom")?"margin-top":s.startsWith("left")?"margin-right":"margin-left";t.style.setProperty(k,`${n}px`),p=()=>{o&&(t.style.minWidth=`${i.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(f=new ResizeObserver(p),f.observe(i))}else t.style.position="fixed",t.style.inset="auto",t.style.margin="0",p=()=>br(i,t,{placement:s,offset:n,flip:r,matchWidth:o}),window.addEventListener("scroll",p,{capture:!0,passive:!0}),window.addEventListener("resize",p,{passive:!0}),typeof ResizeObserver=="function"&&(f=new ResizeObserver(p),f.observe(i)),d=()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)};return yr(t),p(),{update(){h||p()},destroy(){h||(h=!0,f?.disconnect(),d(),xr(t),Ne(i,"style",a),Ne(t,"style",c),Ne(t,"popover",u))}}}function gr(i,t){return{"bottom-start":t?"bottom span-left":"bottom span-right","bottom-end":t?"bottom span-right":"bottom span-left","top-start":t?"top span-left":"top span-right","top-end":t?"top span-right":"top span-left","right-start":"right span-bottom","right-end":"right span-top","left-start":"left span-bottom","left-end":"left span-top",bottom:"bottom",top:"top",right:"right",left:"left"}[i]}function br(i,t,{placement:e,offset:s,flip:n,matchWidth:r}){let o=i.getBoundingClientRect();r&&(t.style.minWidth=`${o.width}px`);let a=t.getBoundingClientRect(),c=document.documentElement.clientWidth||window.innerWidth,u=document.documentElement.clientHeight||window.innerHeight,h=e,f=Gi(e),p=o.bottom+s,d=o.top-s-a.height,m=o.right+s,g=o.left-s-a.width;n&&(f==="bottom"&&p+a.height>u&&d>=0?h=Yt(e,"bottom","top"):f==="top"&&d<0&&p+a.height<=u?h=Yt(e,"top","bottom"):f==="right"&&m+a.width>c&&g>=0?h=Yt(e,"right","left"):f==="left"&&g<0&&m+a.width<=c&&(h=Yt(e,"left","right")));let b=Gi(h),k,T;if(b==="bottom"||b==="top"){let A=getComputedStyle(i).direction==="rtl";h.endsWith("-end")?k=A?o.left:o.right-a.width:h.endsWith("-start")?k=A?o.right-a.width:o.left:k=o.left+(o.width-a.width)/2,T=b==="bottom"?p:d}else k=b==="right"?m:g,h.endsWith("-end")?T=o.bottom-a.height:h.endsWith("-start")?T=o.top:T=o.top+(o.height-a.height)/2;t.style.left=`${Math.round(gt(k,0,Math.max(0,c-a.width)))}px`,t.style.top=`${Math.round(gt(T,0,Math.max(0,u-a.height)))}px`}function Gi(i){return i.split("-")[0]}function Yt(i,t,e){return i.replace(t,e)}function yr(i){if(typeof i.showPopover=="function")try{i.showPopover()}catch{}}function xr(i){if(typeof i.hidePopover=="function")try{i.hidePopover()}catch{}}function Ne(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}var vr=6,ss=864e5;function xt(i,t){let e=E(J(i)),s=E(J(t));return e&&s&&e.getTime()>s.getTime()?{start:s,end:e}:{start:e,end:s}}function Kt(i,t){let e=xt(i,t);return!e.start||!e.end?0:Math.round((ts(e.end)-ts(e.start))/ss)}function wr(i,t,e){let s=E(J(i));if(!s)return null;let n=xt(t,e);return!n.start&&!n.end?null:n.end?n.start?s.getTime()<n.start.getTime()||s.getTime()>n.end.getTime()?null:D(s,n.start)?"start":D(s,n.end)?"end":"middle":D(s,n.end)?"end":null:D(s,n.start)?"start":null}function Ut(i,t={}){let e=E(J(t.min)),s=E(J(t.max)),n=Qt(t.minNights)??0,r=Qt(t.maxNights),{start:o,end:a}=xt(i?.start,i?.end);return o&&(o=Le(o,e,s)),a&&(a=Le(a,e,s)),!o||!a?{start:o,end:a}:(r!==null&&Kt(o,a)>r&&(a=S(o,r)),n>0&&Kt(o,a)<n&&(a=S(o,n),s&&a.getTime()>s.getTime()&&(a=new Date(s.getTime()),o=S(a,-n),e&&o.getTime()<e.getTime()))?{start:null,end:null}:{start:o,end:a})}var Wt=class extends y{static cssName="date-range-picker";static defaults={start:null,end:null,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._rootAttributes=Ir(t,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=E(J(this.options.min)),this._max=E(J(this.options.max)),this._minNights=Qt(this.options.minNights)??0,this._maxNights=Qt(this.options.maxNights),this._weekStart=zr(this.options.weekStart),this._monthCount=Dr(this.options.months),this._presets=Ar(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let e=Ut({start:this.options.start,end:this.options.end},this._bounds());this._start=e.start,this._end=e.end,this._picking=!!(e.start&&!e.end),this._remember(),this._focused=W(this._start)??this._clampFocus(E(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),t.setAttribute("role","group"),t.setAttribute("aria-label",z("daterange.label","Date range")),t.dataset.months=String(this._monthCount),this._presets.length&&(t.dataset.presets="true");let s=l("div",{class:"zx-date-range-picker__surface"},this._presets.length?l("div",{ref:"presets",class:"zx-date-range-picker__presets",role:"group",ariaLabel:z("daterange.presets","Date range presets")},this._presets.map(r=>l("button",{class:"zx-date-range-picker__preset",type:"button",dataset:{preset:r.name}},r.label))):null,l("div",{ref:"calendars",class:"zx-date-range-picker__calendars"})),n=l("div",{ref:"status",class:"zx-date-range-picker__status",role:"status",ariaLive:"polite"});return this._nodes=[s,n],t.append(s,n),this.refs.presets&&this.listen(this.refs.presets,"click",r=>this._onPresetClick(r)),this.listen(this.refs.calendars,"click",r=>this._onCalendarClick(r)),this.listen(this.refs.calendars,"keydown",r=>this._onDayKeydown(r)),this.listen(this.refs.calendars,"mouseover",r=>this._onDayHover(r)),this.listen(this.refs.calendars,"mouseleave",()=>this._setHover(null)),this._renderCalendars(),this._announce(),t}get(){return{start:W(this._start),end:W(this._end)}}set(t={},{silent:e=!1}={}){let s=Ut({start:t?.start??null,end:t?.end??null},this._bounds());return this._start=s.start,this._end=s.end,this._picking=!!(s.start&&!s.end),this._remember(),this._hover=null,s.start?(this._focused=W(s.start),this._setView(s.start)):this._paint(),this._announce(),e||this.emit("change",this.get()),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}focus(){return this._buttonForDate(this._focused)?.focus(),this}enable(){return this._disabled=!1,this._paint(),this._syncDisabled(),this}disable(){return this._disabled=!0,this._hover=null,this._paint(),this._syncDisabled(),this}destroy(){for(let t of this._nodes??[])t.remove();this._nodes=[],this._dayCells=[],Mr(this.el,this._rootAttributes??new Map),super.destroy()}_bounds(){return{min:this._min,max:this._max,minNights:this._minNights,maxNights:this._maxNights}}_selectable(t){let e=E(t);if(!e||this._min&&e.getTime()<this._min.getTime()||this._max&&e.getTime()>this._max.getTime())return!1;if(!this._picking||!this._start||e.getTime()<=this._start.getTime())return!0;let s=Kt(this._start,e);return!(s<this._minNights||this._maxNights!==null&&s>this._maxNights)}_choose(t){let e=E(t);if(this._disabled||!e||!this._selectable(e))return;this._picking&&this._start&&e.getTime()>this._start.getTime()?(this._end=e,this._picking=!1,this._remember()):(this._start=e,this._end=null,this._picking=!0),this._focused=e,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),this._picking||this.emit("change",this.get())}_remember(){let t=!!(this._start&&this._end);this._committedStart=t?W(this._start):null,this._committedEnd=t?W(this._end):null}_abandon(){return this._picking?(this._start=W(this._committedStart),this._end=W(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(t){return Le(t,this._min,this._max)}_visibleMonthCount(){let t=this.refs.calendars?.children??[],e=0;for(let s of t)s.getClientRects().length>0&&(e+=1);return e||this._monthCount}_setView(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;if(this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),!e){this._paint();return}this._renderCalendars(),this._emitMonthChange()}_ensureVisible(t){let e=this._visibleMonthCount(),s=es(t)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<e)return!1;let n=s<0?s:s-(e-1),r=new Date(this._viewYear,this._viewMonth+n,1);return this._viewYear=r.getFullYear(),this._viewMonth=r.getMonth(),!0}_pageView(t){if(this._disabled)return;let e=new Date(this._viewYear,this._viewMonth+t,1);this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._focused=this._focusInView(this._focused),this._renderCalendars(),this._emitMonthChange()}_focusInView(t){let e=this._visibleMonthCount(),s=es(t)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<e)return t;let n=new Date(this._viewYear,this._viewMonth+1,0).getDate();return new Date(this._viewYear,this._viewMonth,Math.min(t.getDate(),n))}_moveFocus(t){let e=E(t);this._focused=e,this._ensureVisible(e)?(this._renderCalendars(),this._emitMonthChange()):this._paint(),this._buttonForDate(e)?.focus()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_onPresetClick(t){let e=t.target?.closest?.("[data-preset]");if(!e||this._disabled)return;let s=this._presets.find(r=>r.name===e.dataset.preset);if(!s)return;let n=s.range();this.set({start:n?.start??null,end:n?.end??null},{silent:!0}),this.emit("select",this.get()),this.emit("change",this.get())}_onCalendarClick(t){let e=t.target,s=e?.closest?.("[data-nav]");if(s){this._pageView(s.dataset.nav==="next"?1:-1);return}let n=this._cellFor(e);n&&this._choose(n.date)}_onDayHover(t){let e=this._cellFor(t.target);this._setHover(e?e.date:null)}_setHover(t){if(this._disabled||!this._picking)return;let e=t?E(t):null;!e&&!this._hover||e&&this._hover&&D(e,this._hover)||(this._hover=e,this._paint())}_onDayKeydown(t){let e=this._cellFor(t.target);if(!e)return;let s=e.date,n=null;if(t.key==="ArrowLeft")n=S(s,-1);else if(t.key==="ArrowRight")n=S(s,1);else if(t.key==="ArrowUp")n=S(s,-7);else if(t.key==="ArrowDown")n=S(s,7);else if(t.key==="PageUp")n=G(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=G(s,t.shiftKey?12:1);else if(t.key==="Home")n=S(s,-((s.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=S(s,6-(s.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._choose(s);return}else if(t.key==="Escape"){if(!this._abandon())return;t.preventDefault(),t.stopPropagation();return}!n||this._disabled||(t.preventDefault(),this._moveFocus(n))}_renderCalendars(){if(!this.refs?.calendars)return;this._dayCells=[];let t=[];for(let e=0;e<this._monthCount;e+=1)t.push(this._renderMonth(new Date(this._viewYear,this._viewMonth+e,1)));this.refs.calendars.replaceChildren(...t),this._paint(),this._syncDisabled()}_renderMonth(t){let e=w(t,"%B %Y"),s=(t.getDay()-this._weekStart+7)%7,n=S(t,-s),r=[];for(let o=0;o<vr;o+=1){let a=S(n,o*7),c=l("tr"),u=Cr(a,t);this.options.showWeekNumbers&&c.append(l("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:u?z("daterange.week","Week %1",[is(a)]):null},u?String(is(a)):""));for(let h=0;h<7;h+=1){let f=S(a,h),p=l("td",{role:"presentation"});if(f.getMonth()===t.getMonth()&&f.getFullYear()===t.getFullYear()){let d=l("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:w(f,"%Y-%m-%d")}},w(f,"%e"));p.append(d),this._dayCells.push({date:f,cell:p,button:d})}c.append(p)}r.push(c)}return l("div",{class:"zx-date-range-picker__month"},l("div",{class:"zx-date-range-picker__header"},l("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"previous"},ariaLabel:z("daterange.previousMonth","Previous month")},_("chevron-left")),l("div",{class:"zx-date-range-picker__caption",ariaHidden:"true"},e),l("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"next"},ariaLabel:z("daterange.nextMonth","Next month")},_("chevron-right"))),l("table",{class:"zx-date-range-picker__grid",role:"grid",ariaLabel:e},l("thead",{},this._weekdayRow()),l("tbody",{},...r)))}_weekdayRow(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-range-picker__week-heading",scope:"col",ariaLabel:z("daterange.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let s=0;s<7;s+=1){let n=S(e,(this._weekStart+s)%7);t.append(l("th",{scope:"col",ariaLabel:w(n,"%A")},w(n,"%a")))}return t}_paint(){let t=new Date,e=null;for(let s of this._dayCells)D(s.date,this._focused)&&(e=s);e||(e=this._dayCells[0]??null);for(let s of this._dayCells){let{date:n,cell:r,button:o}=s,a=this._dayState(n);Fe(r,"range",a.range),Fe(r,"rangeEdge",a.edge),Fe(o,"range",a.range),o.tabIndex=s===e?0:-1,o.setAttribute("aria-selected",String(a.range!==null&&a.range!=="preview")),o.setAttribute("aria-disabled",String(!this._selectable(n))),o.setAttribute("aria-label",this._dayLabel(n,a.range)),D(n,t)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(t){if(this._start&&this._end){let s=wr(t,this._start,this._end);if(!s)return{range:null,edge:null};let n=D(this._start,this._end);return s==="start"?{range:s,edge:n?"both":"start"}:s==="end"?{range:s,edge:n?"both":"end"}:{range:s,edge:null}}if(!this._start)return{range:null,edge:null};let e=this._previewEnd();return D(t,this._start)?{range:"start",edge:e?"start":"both"}:e?t.getTime()>this._start.getTime()&&t.getTime()<=e.getTime()?{range:"preview",edge:D(t,e)?"end":null}:{range:null,edge:null}:{range:null,edge:null}}_previewEnd(){if(!this._picking||!this._start||this._disabled)return null;let t=this._hover??this._focused;if(!t)return null;let e=E(t);return e.getTime()<=this._start.getTime()?null:this._selectable(e)?e:null}_dayLabel(t,e){let s=w(t,"%A, %e %B %Y");return e==="start"?`${s}, ${z("daterange.day.start","range start")}`:e==="end"?`${s}, ${z("daterange.day.end","range end")}`:e==="middle"?`${s}, ${z("daterange.day.middle","in selected range")}`:s}_syncDisabled(){this.el.setAttribute("aria-disabled",String(this._disabled));for(let t of this.el.querySelectorAll("button"))t.disabled=this._disabled}_announce(){this.refs?.status&&(this.refs.status.textContent=this._selectionLabel())}_selectionLabel(){if(!this._start)return z("daterange.status.empty","No date range selected");if(!this._end)return z("daterange.status.start","%1 selected, choose an end date",[w(this._start,"%e %B %Y")]);let t=Kt(this._start,this._end),e=t===1?z("daterange.night","1 night"):z("daterange.nights","%1 nights",[t]);return`${Sr(this._start,this._end)}, ${e}`}_cellFor(t){let e=t?.closest?.("[data-date]");return e?this._dayCells.find(s=>s.button===e)??null:null}_buttonForDate(t){return this._dayCells.find(e=>D(e.date,t))?.button??null}};function kr(){return[{name:"today",label:z("daterange.preset.today","Today"),range:()=>Xi(V())},{name:"yesterday",label:z("daterange.preset.yesterday","Yesterday"),range:()=>Xi(S(V(),-1))},{name:"last7",label:z("daterange.preset.last7","Last 7 days"),range:()=>({start:S(V(),-6),end:V()})},{name:"last30",label:z("daterange.preset.last30","Last 30 days"),range:()=>({start:S(V(),-29),end:V()})},{name:"thisMonth",label:z("daterange.preset.thisMonth","This month"),range:()=>Ji(V(),0)},{name:"lastMonth",label:z("daterange.preset.lastMonth","Last month"),range:()=>Ji(V(),-1)},{name:"thisQuarter",label:z("daterange.preset.thisQuarter","This quarter"),range:()=>{let i=V(),t=Math.floor(i.getMonth()/3)*3;return{start:new Date(i.getFullYear(),t,1),end:new Date(i.getFullYear(),t+3,0)}}},{name:"thisYear",label:z("daterange.preset.thisYear","This year"),range:()=>{let i=V();return{start:new Date(i.getFullYear(),0,1),end:new Date(i.getFullYear(),11,31)}}}]}function z(i,t,e){let s=j(i);return F(s===i?t:s,e)}function Sr(i,t){if(D(i,t))return w(i,"%e %B %Y");let e=w(t,"%e %B %Y");return i.getFullYear()!==t.getFullYear()?`${w(i,"%e %B %Y")} \u2013 ${e}`:i.getMonth()!==t.getMonth()?`${w(i,"%e %B")} \u2013 ${e}`:`${w(i,"%e")} \u2013 ${e}`}function Ar(i){return i===!0?kr():Array.isArray(i)?i.filter(t=>t&&typeof t.range=="function").map((t,e)=>({name:String(t.name??`preset-${e}`),label:String(t.label??t.name??""),range:t.range})):[]}function V(){return E(new Date)}function Xi(i){return{start:i,end:new Date(i.getTime())}}function Ji(i,t){return{start:new Date(i.getFullYear(),i.getMonth()+t,1),end:new Date(i.getFullYear(),i.getMonth()+t+1,0)}}function J(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function E(i){return!i||Number.isNaN(i.getTime())?null:new Date(i.getFullYear(),i.getMonth(),i.getDate())}function W(i){return i?new Date(i.getTime()):null}function Le(i,t,e){return t&&i.getTime()<t.getTime()?new Date(t.getTime()):e&&i.getTime()>e.getTime()?new Date(e.getTime()):new Date(i.getTime())}function ts(i){return Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())}function es(i){return i.getFullYear()*12+i.getMonth()}function Qt(i){if(i==null||i==="")return null;let t=Number(i);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):null}function zr(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:qt()}function Dr(i){let t=Number(i);return Number.isInteger(t)&&t>=1&&t<=4?t:2}function Cr(i,t){for(let e=0;e<7;e+=1){let s=S(i,e);if(s.getMonth()===t.getMonth()&&s.getFullYear()===t.getFullYear())return!0}return!1}function is(i){let t=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let s=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-s.getTime())/ss+1)/7)}function Fe(i,t,e){e==null?delete i.dataset[t]:i.dataset[t]=e}function Ir(i,t){return new Map(t.map(e=>[e,i.getAttribute(e)]))}function Mr(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}var Tr={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function ns(i,t,e){let s=String(i??"").trim();if(s==="")return{start:null,end:null};let n=String(e??" \u2013 "),r=n.trim(),o=r!==""&&String(t).includes(r)&&/^\s|\s$/.test(n),a=o?"\\s+":"\\s*",c=o?"(?:\\s+|$)":"\\s*",u=r===""?[s]:s.split(new RegExp(`${a}${ge(r)}${c}`));if(u.length>2)return null;let h=q(u[0].trim(),t);if(!h)return null;if(u.length===1)return{start:h,end:new Date(h.getTime())};if(u[1].trim()==="")return{start:h,end:null};let f=q(u[1].trim(),t);return f?xt(h,f):null}function Er(i,t,e){let s=i?.start??null,n=i?.end??null;return!s&&!n?"":n?s?`${w(s,t)}${e}${w(n,t)}`:w(n,t):w(s,t)}var Zt=class extends y{static cssName="date-range-box";static defaults={start:null,end:null,format:"%d.%m.%Y",separator:" \u2013 ",placeholder:null,clearable:!0,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._format=String(this.options.format||"%d.%m.%Y"),this._separator=String(this.options.separator??" \u2013 "),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._range=this._coerce({start:this.options.start,end:this.options.end});let e=v("zx-date-range-box-popover"),s=l("div",{class:"zx-date-range-box__content"},l("div",{ref:"control",class:"zx-date-range-box__control"},l("input",{ref:"input",class:"zx-date-range-box__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??this._placeholder(),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),l("button",{ref:"clear",class:"zx-icon-btn zx-date-range-box__clear",type:"button",ariaLabel:rs("daterange.clear","Clear date range")},_("x",{size:13})),l("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:rs("daterange.choose","Choose date range"),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},_("calendar"))),l("div",{ref:"popover",id:e,class:"zx-date-range-box__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=s,t.append(s),this._picker=new Wt(null,{start:this._range.start,end:this._range.end,min:this.options.min,max:this.options.max,months:this.options.months,weekStart:this.options.weekStart,showWeekNumbers:this.options.showWeekNumbers,minNights:this.options.minNights,maxNights:this.options.maxNights,presets:this.options.presets}),this.refs.popover.append(this._picker.el),this._picker.on("select",n=>{this._range={start:n.detail.start,end:n.detail.end},this._setValid(),this._syncDisplay()}),this._picker.on("change",n=>{this._apply({start:n.detail.start,end:n.detail.end},{push:!1}),n.detail.start&&n.detail.end&&this._close(!0)}),this.listen(this.refs.input,"blur",()=>{this._open||this._commitText()}),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.clear(),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return t==="seconds"?{start:this._range.start?Math.floor(this._range.start.getTime()/1e3):null,end:this._range.end?Math.floor(this._range.end.getTime()/1e3):null}:{start:this._range.start?new Date(this._range.start.getTime()):null,end:this._range.end?new Date(this._range.end.getTime()):null}}set(t,{silent:e=!1}={}){return this._apply(this._coerce(t),{silent:e}),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}open(){return this._disabled||this._open?this:(this._picker.set(this._range,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=U(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),Oe(this.el,"data-state",this._originalState),Oe(this.el,"aria-disabled",this._originalAriaDisabled),super.destroy()}_apply(t,{silent:e=!1,push:s=!0}={}){this._range=t,s&&this._picker?.set(this._range,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",this.get())}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set({start:null,end:null});return}let e=ns(t,this._format,this._separator);if(!e){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:t});return}this._apply(this._clamp(e))}_coerce(t){return t==null?{start:null,end:null}:typeof t=="string"?this._clamp(ns(t,this._format,this._separator)??{start:null,end:null}):Array.isArray(t)?this._clamp({start:this._toDate(t[0]),end:this._toDate(t[1])}):typeof t!="object"?{start:null,end:null}:this._clamp({start:this._toDate(t.start),end:this._toDate(t.end)})}_toDate(t){return t instanceof Date?Number.isNaN(t.getTime())?null:new Date(t.getTime()):typeof t=="number"&&Number.isFinite(t)?new Date(t*1e3):typeof t=="string"&&t.trim()!==""?q(t.trim(),this._format):null}_clamp(t){return Ut(t,{min:this.options.min,max:this.options.max,minNights:this.options.minNights,maxNights:this.options.maxNights})}_placeholder(){let t=this._format.replace(/%[demYy]/g,e=>Tr[e]??e);return`${t}${this._separator}${t}`}_syncDisplay(){this.refs.input.value=Er(this._range,this._format,this._separator),this.refs.clear.hidden=!this.options.clearable||!(this._range.start||this._range.end)}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled)),this._disabled?this._picker?.disable():this._picker?.enable()}_setValid(){this.el.dataset.state==="invalid"&&Oe(this.el,"data-state",this._originalState),this.refs.input.removeAttribute("aria-invalid")}_close(t){this._open&&(this._position?.destroy(),this._position=null,this._open=!1,this.refs.popover.dataset.state="closed",this.refs.input.setAttribute("aria-expanded","false"),this.refs.toggle.setAttribute("aria-expanded","false"),t&&this.focus(),this.emit("close"))}};function rs(i,t,e){let s=j(i);return F(s===i?t:s,e)}function Oe(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}function os(){x.register("daterange",(i,t)=>{let e=i.own(new Zt(null,{...t.props??{},disabled:!!t.disabled,start:t.value?.start??null,end:t.value?.end??null}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:{start:s.detail.start,end:s.detail.end}})),{el:e.el,get:()=>e.get(),set:s=>e.set(s,{silent:!0}),focus:()=>e.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var tt=class extends y{static cssName="datebox";static defaults={value:null,format:"%d.%m.%Y",time:!1,min:null,max:null,placeholder:null,clearable:!0,disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._format=Nr(this.options.format,this.options.time),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._min=as(this.options.min),this._max=as(this.options.max),this._value=this._normalizeValue(this.options.value);let e=v("zx-datebox-popover"),s=l("div",{class:"zx-datebox__content"},l("div",{ref:"control",class:"zx-datebox__control"},l("input",{ref:"input",class:"zx-datebox__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??Fr(this._format),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),l("button",{ref:"clear",class:"zx-icon-btn zx-datebox__clear",type:"button",ariaLabel:"Clear date"},_("x",{size:13})),l("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:"Choose date","aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},_("calendar"))),l("div",{ref:"popover",id:e,class:"zx-datebox__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=s,t.append(s),this._picker=new ct(null,{value:this._value,min:this._min,max:this._max,time:!!this.options.time}),this.refs.popover.append(this._picker.el),this._picker.on("change",n=>{this.set(n.detail.date),this.options.time||this._close(!0)}),this.listen(this.refs.input,"blur",()=>this._commitText()),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.set(null),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return this._value?t==="seconds"?Math.floor(this._value.getTime()/1e3):new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeValue(t),this._picker?.set(this._value,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",{date:this._copyValue()}),this}open(){return this._disabled||this._open?this:(this._picker.set(this._value,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=U(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set(null);return}let e=q(t,this._format);if(!e){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:t});return}this.set(e)}_normalizeValue(t){let e=null;return t instanceof Date&&!Number.isNaN(t.getTime())?e=new Date(t.getTime()):typeof t=="number"&&Number.isFinite(t)?e=new Date(t*1e3):typeof t=="string"&&(e=q(t,this._format)),!e||Number.isNaN(e.getTime())?null:Oi(e,this._min,this._max)}_syncDisplay(){this.refs.input.value=this._value?w(this._value,this._format):"",this.refs.clear.hidden=!this.options.clearable||!this._value}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled))}_setValid(){this.el.dataset.state==="invalid"&&(this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState)),this.refs.input.removeAttribute("aria-invalid")}_close(t){this._open&&(this._position?.destroy(),this._position=null,this._open=!1,this.refs.popover.dataset.state="closed",this.refs.input.setAttribute("aria-expanded","false"),this.refs.toggle.setAttribute("aria-expanded","false"),t&&this.focus(),this.emit("close"))}_copyValue(){return this._value?new Date(this._value.getTime()):null}},ls=function(t,e={}){return new tt(t,{...e,time:!0})};function as(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function Nr(i,t){let e=String(i||"%d.%m.%Y");return t&&!/%[HM]/.test(e)?`${e} %H:%M`:e}function Fr(i){return i.replace(/%[demYyHMS]/g,t=>({"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY","%H":"HH","%M":"MM","%S":"SS"})[t]??t)}function us(){cs("date",i=>new tt(null,i)),cs("datetime",i=>ls(null,i))}function cs(i,t){x.register(i,(e,s)=>{let n=e.own(t({...s.props??{},value:s.value}));return e.listen(n.el,"change",r=>r.stopImmediatePropagation()),n.on("change",r=>e.emit("change",{value:r.detail.date})),{el:n.el,get:()=>n.get(),set:r=>n.set(r,{silent:!0}),focus:()=>n.focus(),setDisabled:r=>r?n.disable():n.enable()}})}var Gt=class extends y{static cssName="field-upload";static defaults={url:"",paramName:"upload",params:{},headers:{},multiple:!1,accept:null,maxSize:null,autoUpload:!0,preview:!0,http:null};render(){let t=this.el??l("div");this.el=t,this._ownedNodes=[],this._files=[],this._disabled=!1,this._running=!1,this._runId=0,this._xhr=null,this._transportController=null,this._previewUrl=null,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled");let e=v("zx-upload");return this._input=l("input",{class:"zx-field-upload__input",id:e,type:"file",multiple:!!this.options.multiple,accept:this.options.accept??void 0,tabIndex:-1}),this._dropzone=l("button",{class:"zx-field-upload__dropzone",type:"button",ariaControls:e,ariaLabel:this.options.multiple?"Choose files or drop them here":"Choose a file or drop it here"},l("span",{class:"zx-field-upload__prompt"},this.options.multiple?"Drop files here or choose files":"Drop a file here or choose a file"),l("span",{class:"zx-field-upload__hint"},Lr(this.options))),this._preview=l("div",{class:"zx-field-upload__preview"}),this._progress=l("progress",{class:"zx-field-upload__progress",max:100,value:0,ariaLabel:"Upload progress"}),this._progressText=l("span",{class:"zx-field-upload__progress-text"},"0%"),this._abort=l("button",{class:"zx-btn zx-field-upload__abort",type:"button"},"Abort"),this._progressWrap=l("div",{class:"zx-field-upload__progress-wrap",hidden:!0},this._progress,this._progressText,this._abort),this._status=l("div",{class:"zx-field-upload__status",role:"status",ariaLive:"polite"}),this._ownedNodes.push(this._input,this._dropzone,this._preview,this._progressWrap,this._status),t.append(...this._ownedNodes),this.listen(this._dropzone,"click",()=>{!this._disabled&&!this._running&&this._input.click()}),this.listen(this._input,"change",()=>this._selectFiles(this._input.files)),this.listen(this._dropzone,"dragenter",s=>this._handleDragOver(s)),this.listen(this._dropzone,"dragover",s=>this._handleDragOver(s)),this.listen(this._dropzone,"dragleave",s=>{(!(s.relatedTarget instanceof Node)||!this._dropzone.contains(s.relatedTarget))&&this._setState("idle")}),this.listen(this._dropzone,"drop",s=>{s.preventDefault(),!(this._disabled||this._running)&&(this._setState("idle"),this._selectFiles(s.dataTransfer?.files??[]))}),this.listen(this._abort,"click",()=>this.abort()),this.setDisabled(!1),t}async upload(t=null){if(t!==null&&!this._setFiles(t)||this._disabled||this._running||this._files.length===0)return null;this._running=!0,this._runId+=1;let e=this._runId;this._setState("uploading"),this._progressWrap.hidden=!1,this._abort.hidden=!1,this._setProgress(0),this._status.textContent="Uploading\u2026";try{let s=this.options.http?await this._uploadInjected():await this._uploadXhr();return e!==this._runId?null:(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setProgress(100),this._setState("success"),this._status.textContent="Upload complete.",this.emit("success",{response:s}),s)}catch(s){if(e!==this._runId)return null;let n=s instanceof Error?s:new Error(String(s));return n.name==="AbortError"?(this._finishAbort(),null):(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("error"),this._status.textContent=n.message,this.emit("error",{error:n}),null)}}abort(){return this._running?(this._xhr?.abort(),this._transportController?.abort(),this._finishAbort(),this):this}clear(){return this._running&&this.abort(),this._files=[],this._input.value="",this._revokePreview(),this._preview.replaceChildren(),this._progress.value=0,this._progressText.textContent="0%",this._progressWrap.hidden=!0,this._status.textContent="",this._setState("idle"),this}setDisabled(t){return this._disabled=!!t,this._input.disabled=this._disabled,this._dropzone.disabled=this._disabled,this.el.dataset.disabled=String(this._disabled),this}_selectFiles(t){this._setFiles(t)&&(this._input.value="",this.options.autoUpload&&this.upload())}_setFiles(t){if(this._disabled||this._running)return!1;let e=Array.from(t??[]),s=this.options.multiple?e:e.slice(0,1);if(s.length===0)return!1;let n=s.find(o=>!Rr(o,this.options.accept));if(n)return this._selectionError(new Error(`${n.name} is not an accepted file type.`)),!1;let r=this.options.maxSize==null?null:s.find(o=>o.size>Number(this.options.maxSize));return r?(this._selectionError(new Error(`${r.name} exceeds the maximum file size.`)),!1):(this._files=s,this._renderPreview(),this._status.textContent=s.map(o=>o.name).join(", "),this._setState("selected"),this.emit("select",{files:this._files.slice()}),!0)}_handleDragOver(t){t.preventDefault(),!this._disabled&&!this._running&&this._setState("dragover")}_uploadInjected(){let t=this.options.http;this._transportController=new AbortController;let e={files:this._files.slice(),paramName:String(this.options.paramName),params:{...this.options.params},headers:{...this.options.headers},signal:this._transportController.signal,onProgress:s=>this._setProgress(s)};return typeof t.upload=="function"?t.upload(String(this.options.url),e):typeof t.request=="function"?t.request(String(this.options.url),{method:"POST",data:e.params,files:e.files,headers:e.headers,signal:e.signal,onProgress:e.onProgress,paramName:e.paramName}):Promise.reject(new TypeError("Injected upload transport requires upload() or request()"))}_uploadXhr(){return typeof XMLHttpRequest!="function"?Promise.reject(new Error("XMLHttpRequest is not available")):new Promise((t,e)=>{let s=new XMLHttpRequest;this._xhr=s,s.open("POST",String(this.options.url));for(let[n,r]of Object.entries(this.options.headers??{}))s.setRequestHeader(n,String(r));this.listen(s.upload,"progress",n=>{n.lengthComputable&&this._setProgress(n.loaded/n.total*100)}),this.listen(s,"load",()=>{if(s.status<200||s.status>=300){e(new Error(`Upload failed with HTTP ${s.status}`));return}t(qr(s.responseText))}),this.listen(s,"error",()=>e(new Error("Upload request failed"))),this.listen(s,"abort",()=>e(Vr())),s.send(jr(this._files,String(this.options.paramName),this.options.params))})}_setProgress(t){let e=Math.max(0,Math.min(100,Number(t)||0));this._progress.value=e,this._progressText.textContent=`${Math.round(e)}%`,this.emit("progress",{percent:e})}_finishAbort(){this._running&&(this._runId+=1,this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("idle"),this._status.textContent="Upload aborted.",this.emit("abort",{}))}_selectionError(t){this._setState("error"),this._status.textContent=t.message,this.emit("error",{error:t})}_renderPreview(){this._revokePreview(),this._preview.replaceChildren();let t=this._files[0];!this.options.preview||!t?.type?.startsWith("image/")||typeof URL>"u"||typeof URL.createObjectURL!="function"||(this._previewUrl=URL.createObjectURL(t),this._preview.append(l("img",{class:"zx-field-upload__image",src:this._previewUrl,alt:`Preview of ${t.name}`})))}_revokePreview(){this._previewUrl&&typeof URL<"u"&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(this._previewUrl),this._previewUrl=null}_setState(t){t==="idle"?this.el.removeAttribute("data-state"):this.el.dataset.state=t}destroy(){this._running&&this.abort(),this._revokePreview();for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function Lr(i){let t=[];return i.accept&&t.push(String(i.accept)),i.maxSize!=null&&t.push(`up to ${Or(Number(i.maxSize))}`),t.join(" \xB7 ")||"Choose from this device"}function Or(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/1024)} KB`:`${Math.round(i/(1024*1024))} MB`}function Rr(i,t){if(!t)return!0;let e=String(i.type??"").toLowerCase();return String(t).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean).some(s=>s.startsWith(".")?i.name.toLowerCase().endsWith(s):s.endsWith("/*")?e.startsWith(s.slice(0,-1)):e===s)}function jr(i,t,e){let s=new FormData;for(let n of i)s.append(t,n);for(let[n,r]of Object.entries(e??{}))hs(s,n,r);return s}function hs(i,t,e){if(e==null)return;if(Array.isArray(e)){for(let n of e)hs(i,t,n);return}typeof Blob=="function"&&e instanceof Blob?i.append(t,e):i.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function qr(i){if(!i)return null;try{return JSON.parse(i)}catch{return i}}function Vr(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let i=new Error("Upload aborted");return i.name="AbortError",i}function ds(){x.register("upload",(i,t)=>{let e=i.own(new Gt(null,{...t.props??{}}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("select",()=>i.emit("change",{value:null})),{el:e.el,get:()=>null,set:()=>e.clear(),focus:()=>e.el.querySelector(".zx-field-upload__dropzone")?.focus(),setDisabled:s=>e.setDisabled(s)}})}var fs=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),ps=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),Xt=class extends y{static cssName="multi-value-editor";static defaults={values:[],options:null,addLabel:"Add value",reorder:"both"};render(){let t=this.el??l("div");return this.el=t,this._values=Array.isArray(this.options.values)?this.options.values.map(String):[],this._ownedNodes=[],this._initialState=t.getAttribute("data-state"),this._dragIndex=-1,this._armed=null,this._rows=l("div",{class:"zx-multi-value-editor__rows"}),this._add=l("button",{class:"zx-btn zx-multi-value-editor__add",type:"button",dataset:{action:"add"}},String(this.options.addLabel??"Add value")),this._ownedNodes.push(this._rows,this._add),t.append(this._rows,this._add),this.listen(t,"click",e=>this._handleClick(e)),this.listen(this._rows,"change",e=>this._handleChange(e)),this.listen(this._rows,"keydown",e=>this._handleKeydown(e)),this._reorder().drag&&(this.listen(this._rows,"pointerdown",e=>this._handlePointerDown(e)),this.listen(this._rows,"dragstart",e=>this._handleDragStart(e)),this.listen(this._rows,"dragover",e=>this._handleDragOver(e)),this.listen(this._rows,"dragleave",e=>this._handleDragLeave(e)),this.listen(this._rows,"drop",e=>this._handleDrop(e)),this.listen(this._rows,"dragend",()=>this._finishDrag()),this.listen(document,"pointerup",()=>this._disarm()),this.listen(document,"pointercancel",()=>this._disarm())),this._renderRows(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=Array.isArray(t)?t.map(String):[],this._renderRows(),e||this.emit("change",{values:this.getValues()}),this}_reorder(){return fs[this.options.reorder]??fs.both}_renderRows(t=-1,e="value"){let s=ms(this.options.options),n=this.options.options!==null,{drag:r,buttons:o}=this._reorder(),a=this._values.length-1,c=this._values.map((u,h)=>{let f=!n||s.some(([d])=>d===u)?s:[[u,u],...s],p=n?l("select",{class:"zx-multi-value-editor__value",ariaLabel:`Value ${h+1}`,dataset:{index:h}},f.map(([d,m])=>l("option",{value:d,selected:d===u},m))):l("input",{class:"zx-multi-value-editor__value",type:"text",value:u,ariaLabel:`Value ${h+1}`,dataset:{index:h}});return l("div",{class:"zx-multi-value-editor__row",dataset:{row:h}},r?l("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:`Reorder value ${h+1}. Use the arrow keys to move it.`,dataset:{action:"grab",index:h}},_("drag",{size:12})):null,p,l("div",{class:"zx-multi-value-editor__controls"},o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(h===0),ariaLabel:`Move value ${h+1} up`,dataset:{action:"up",index:h}},_("chevron-up",{size:12})):null,o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(h===a),ariaLabel:`Move value ${h+1} down`,dataset:{action:"down",index:h}},_("chevron-down",{size:12})):null,l("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${h+1}`,dataset:{action:"remove",index:h}},_("x",{size:12}))))});this._rows.replaceChildren(...c),t>=0&&c[Math.min(t,c.length-1)]?.querySelector(ps[e]??ps.value)?.focus()}_handleClick(t){let e=t.target instanceof Element?t.target.closest("[data-action]"):null;if(!e||!this.el.contains(e)||e.getAttribute("aria-disabled")==="true")return;let s=e.dataset.action,n=Number(e.dataset.index);if(s==="add"){let r=ms(this.options.options);this._values.push(this.options.options===null?"":r[0]?.[0]??""),this._renderRows(this._values.length-1),this._emitChange()}else s==="remove"&&Number.isInteger(n)?(this._values.splice(n,1),this._renderRows(Math.min(n,this._values.length-1)),this._emitChange()):(s==="up"||s==="down")&&Number.isInteger(n)&&this._move(n,n+(s==="up"?-1:1),s)}_handleChange(t){let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e||!("value"in e))return;let s=Number(e.dataset.index);!Number.isInteger(s)||s<0||s>=this._values.length||(this._values[s]=e.value,this._emitChange())}_handleKeydown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(!e)return;let s=Number(e.dataset.index),n=t.key==="ArrowUp"?s-1:t.key==="ArrowDown"?s+1:t.key==="Home"?0:t.key==="End"?this._values.length-1:-1;n<0||n>=this._values.length||(t.preventDefault(),this._move(s,n,"handle"))}_handlePointerDown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(this._disarm(),!e||e.disabled)return;let s=e.closest(".zx-multi-value-editor__row");s&&(s.draggable=!0,this._armed=s)}_disarm(){this._armed&&(this._armed.draggable=!1),this._armed=null}_handleDragStart(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__row"):null;if(!e||e!==this._armed){t.preventDefault();return}this._dragIndex=Number(e.dataset.row),e.dataset.dragging="true",this.el.setAttribute("data-state","dragging"),t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move")}_handleDragOver(t){this._dragIndex<0||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._showDrop(this._dropTarget(t.clientY)))}_handleDragLeave(t){let e=t.relatedTarget;e instanceof Node&&this._rows.contains(e)||this._clearDrop()}_handleDrop(t){if(this._dragIndex<0)return;t.preventDefault();let e=this._dragIndex,s=this._dropTarget(t.clientY);this._finishDrag(),this._move(e,s>e?s-1:s,"handle")}_finishDrag(){this._dragIndex=-1,this._disarm(),this._clearDrop();for(let t of this._rows.children)delete t.dataset.dragging;this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_dropTarget(t){let e=[...this._rows.children];for(let[s,n]of e.entries()){let r=n.getBoundingClientRect();if(t<r.top+r.height/2)return s}return e.length}_showDrop(t){let e=[...this._rows.children],s=t===this._dragIndex||t===this._dragIndex+1;for(let[n,r]of e.entries()){let o=r;!s&&n===t?o.dataset.drop="before":!s&&t===e.length&&n===e.length-1?o.dataset.drop="after":delete o.dataset.drop}}_clearDrop(){for(let t of this._rows.children)delete t.dataset.drop}_move(t,e,s){let n=this._values.length;if(t===e||t<0||e<0||t>=n||e>=n)return!1;let[r]=this._values.splice(t,1);return this._values.splice(e,0,r),this._renderRows(e,s),this._emitChange(),!0}_emitChange(){this.emit("change",{values:this.getValues()})}destroy(){this._initialState===null?this.el?.removeAttribute("data-state"):this.el?.setAttribute("data-state",this._initialState);for(let t of this._ownedNodes??[])t.remove();super.destroy()}};function ms(i){return Array.isArray(i)?i.map(t=>[String(t),String(t)]):i&&typeof i=="object"?Object.entries(i).map(([t,e])=>[t,String(e)]):[]}function _s(){x.register("multivalueeditor",(i,t)=>{let e=i.own(new Xt(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]})),s=new WeakMap,n=!1,r=()=>{e.el.setAttribute("aria-disabled",String(n));for(let o of e.el.querySelectorAll("input, button, select, textarea"))n?(s.has(o)||s.set(o,!!o.disabled),o.disabled=!0):s.has(o)&&(o.disabled=s.get(o),s.delete(o))};return i.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>i.emit("change",{value:o.detail.values})),{el:e.el,get:()=>e.getValues(),set:o=>{e.setValues(Array.isArray(o)?o:[],{silent:!0}),r()},focus:()=>e.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),setDisabled:o=>{n=!!o,r()}}})}var ut=class extends y{static cssName="number-field";static defaults={value:null,min:null,max:null,step:1,largeStep:10,precision:null,wrap:!1,placeholder:"",label:null,unit:null,disabled:!1,readonly:!1,required:!1,name:null,group:!1,locale:null};render(){this._value=null,this._disabled=!1,this._readonly=!1,this._editing=!1,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:O(this.el);let t=this.el??l("div");this.el=t;let e=Pr(this.options.step);this._step=e,this._precision=this.options.precision===null?Br(e):Math.max(0,Math.trunc(Number(this.options.precision)||0));let s=this._stepButton("down","minus"),n=this._stepButton("up","plus"),r=l("input",{ref:"input",class:"zx-number-field__input",type:"text",role:"spinbutton",inputMode:this._precision>0?"decimal":"numeric",autocomplete:"off",spellcheck:!1,placeholder:String(this.options.placeholder??""),ariaLabel:this.options.label??void 0,name:this.options.name??void 0,required:!!this.options.required}),o=[s,r];return this.options.unit!==null&&o.push(l("span",{ref:"unit",class:"zx-number-field__unit",ariaHidden:"true"},String(this.options.unit))),o.push(n),t.replaceChildren(...o),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(r,"input",()=>this._onInput()),this.listen(r,"keydown",a=>this._onKeydown(a)),this.listen(r,"focus",()=>{this._editing=!0,this._syncInput()}),this.listen(r,"blur",()=>{this._commit(),this._editing=!1,this._syncInput()}),this.listen(s,"click",()=>this._stepBy(-1)),this.listen(n,"click",()=>this._stepBy(1)),this.listen(r,"wheel",a=>{document.activeElement!==r||this._disabled||this._readonly||(a.preventDefault(),this._stepBy(a.deltaY<0?1:-1))},{passive:!1}),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=this._coerce(t),n=s!==this._value;return this._value=s,this._syncInput(),n&&!e&&this.emit("change",{value:this._value}),this}stepUp(t=1){return this._stepBy(t)}stepDown(t=1){return this._stepBy(-t)}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}focus(){return this.refs.input.focus(),this}getInput(){return this.refs.input}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}setRange(t,e){return this._min=t==null?null:Number(t),this._max=e==null?null:Number(e),this.set(this._value,{silent:!0})}_stepButton(t,e){return l("button",{ref:t,class:"zx-number-field__step",type:"button",tabIndex:-1,ariaHidden:"true",dataset:{step:t}},_(e,{size:13}))}get _rangeMin(){return this._min!==void 0?this._min:this.options.min===null||this.options.min===void 0?null:Number(this.options.min)}get _rangeMax(){return this._max!==void 0?this._max:this.options.max===null||this.options.max===void 0?null:Number(this.options.max)}_coerce(t){let e=Re(t,this.options.group?this._separators():null);return e===null?null:je(e,{min:this._rangeMin,max:this._rangeMax,step:this._step,precision:this._precision})}_stepBy(t){if(this._disabled||this._readonly)return this;let e=this._rangeMin,s=this._rangeMax,r=Re(this.refs.input.value)??this._value,o=r===null?e??0:r,a=r===null&&t>0&&e!==null?e-this._step*t:o,c=gs(a+this._step*t,this._precision);return this.options.wrap&&e!==null&&s!==null&&(c>s?c=e:c<e&&(c=s)),this.set(c),this}_separators(){if(this._localeSeparators)return this._localeSeparators;let t=new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:1}).formatToParts(1234.5);return this._localeSeparators={group:t.find(e=>e.type==="group")?.value??",",decimal:t.find(e=>e.type==="decimal")?.value??"."},this._localeSeparators}_onInput(){let t=Re(this.refs.input.value,this.options.group?this._separators():null);this._syncAria(t),this.emit("input",{value:t})}_onKeydown(t){if(this._disabled||this._readonly)return;let e=Math.max(1,Math.trunc(Number(this.options.largeStep)||1)),n={ArrowUp:()=>this._stepBy(1),ArrowDown:()=>this._stepBy(-1),PageUp:()=>this._stepBy(e),PageDown:()=>this._stepBy(-e),Home:()=>this._rangeMin===null?null:this.set(this._rangeMin),End:()=>this._rangeMax===null?null:this.set(this._rangeMax),Enter:()=>this._commit()}[t.key];n&&(t.key==="Home"&&this._rangeMin===null||t.key==="End"&&this._rangeMax===null||(t.preventDefault(),n()))}_commit(){this.set(this.refs.input.value)}_syncInput(){let t=this.refs.input,e=this._value===null?"":this._format(this._value,this._editing);t.value!==e&&(t.value=e),this._syncAria(this._value)}_syncAria(t){let e=this.refs.input,s=this._rangeMin,n=this._rangeMax;if(s===null?e.removeAttribute("aria-valuemin"):e.setAttribute("aria-valuemin",String(s)),n===null?e.removeAttribute("aria-valuemax"):e.setAttribute("aria-valuemax",String(n)),t===null)e.removeAttribute("aria-valuenow"),e.setAttribute("aria-valuetext",this._message("numberField.empty","Empty"));else{e.setAttribute("aria-valuenow",String(t));let r=this.options.unit===null?"":` ${this.options.unit}`;e.setAttribute("aria-valuetext",`${this._format(t,!1)}${r}`)}this.el.toggleAttribute("data-empty",t===null)}_format(t,e){return this.options.group?new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:this._precision,maximumFractionDigits:this._precision,useGrouping:!e}).format(t):t.toFixed(this._precision)}_message(t,e){let s=this.msg(t);return s===t?e:s}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.up.disabled=this._disabled||this._readonly,this.refs.down.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&R(t,this._snapshot)}};function Re(i,t=null){if(typeof i=="number")return Number.isFinite(i)?i:null;if(i==null)return null;let e=String(i).trim();if(e==="")return null;let s;if(t)s=e.split(t.group).join("").replace(t.decimal,".").replace(/[^\d.\-+eE]/g,"");else{let r=e.replace(/[^\d,.\-+eE]/g,""),o=r.lastIndexOf(","),a=r.lastIndexOf(".");s=r,o>=0&&o>a?s=r.replace(/\./g,"").replace(",","."):o>=0&&(s=r.replace(/,/g,""))}if(!/\d/.test(s))return null;let n=Number(s);return Number.isFinite(n)?n:null}function je(i,{min:t,max:e,step:s,precision:n}){let r=i;if(s>0){let o=t??0;r=o+Math.round((i-o)/s)*s}return r=gs(r,n),t!==null&&r<t?t:e!==null&&r>e?e:r}function Pr(i){let t=Number(i);return Number.isFinite(t)&&t>0?t:1}function Br(i){let t=String(i),e=t.match(/e-(\d+)/i);if(e)return Number(e[1]);let s=t.split(".")[1];return s?s.length:0}function gs(i,t){return Number.isFinite(i)?Number(i.toFixed(Math.min(15,Math.max(0,t)))):i}function bs(){x.register("number",(i,t)=>{let e=i.own(new ut(null,{label:t.label?String(t.label):void 0,placeholder:t.placeholder,required:t.required,...t.props??{}})),s=!1;return i.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get(),set:n=>{s=!0;try{e.set(n===""||n===null||n===void 0?null:n,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var Jt=class extends y{static cssName="rating";static defaults={value:0,max:5,allowHalf:!1,clearable:!0,readonly:!1,disabled:!1,label:"Rating",icon:"star",labels:null,showValue:!1,count:null,size:"md"};render(){this._value=0,this._preview=null,this._disabled=!1,this._readonly=!1,this._radios=[],this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:O(this.el);let t=this.el??l("div");this.el=t,this._max=Math.max(1,Math.trunc(Number(this.options.max)||5)),this._step=this.options.allowHalf?.5:1,this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this._name=v("zx-rating");let e=l("div",{ref:"symbols",class:"zx-rating__symbols",role:"radiogroup",ariaLabel:String(this.options.label??"Rating")});for(let s=1;s<=this._max;s+=1){let n=l("span",{class:"zx-rating__symbol"},l("span",{class:"zx-rating__glyph",ariaHidden:"true"},_(this.options.icon,{size:vt[this.options.size]??vt.md})),l("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},_(this.options.icon,{size:vt[this.options.size]??vt.md})));this.options.allowHalf?n.append(this._radio(s-.5,"half"),this._radio(s,"full")):n.append(this._radio(s,"full")),e.append(n)}return t.replaceChildren(e,l("span",{ref:"readout",class:"zx-rating__readout"})),t.dataset.size=vt[this.options.size]?this.options.size:"md",this.listen(e,"keydown",s=>this._onKeydown(s)),this.listen(e,"pointerleave",()=>this._setPreview(null)),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=this._clamp(t),n=s!==this._value;return this._value=s,this._preview=null,this._sync(),n&&!e&&this.emit("change",{value:this._value}),this}clear({silent:t=!1}={}){return this.set(0,{silent:t})}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}setCount(t){return this._count=t,this._syncReadout(),this}focus(){return(this._radios.find(e=>e.tabIndex===0)??this._radios[0])?.focus(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}_radio(t,e){let s=l("button",{class:"zx-rating__radio",type:"button",role:"radio",tabIndex:-1,ariaChecked:"false",ariaLabel:this._stepLabel(t),dataset:{value:String(t),part:e}});return this.listen(s,"click",n=>{this._choose(t,n.detail>0)}),this.listen(s,"pointerenter",()=>this._setPreview(t)),this.listen(s,"focus",()=>this._setPreview(t)),this.listen(s,"blur",()=>this._setPreview(null)),this._radios.push(s),s}_stepLabel(t){let e=this.options.labels;if(Array.isArray(e)){let s=Math.round(t/this._step)-1;if(e[s]!=null)return String(e[s])}return this._message("rating.value","%1 of %2",[t,this._max])}_message(t,e,s){let n=this.msg(t,...s);return n===t?F(e,s):n}_choose(t,e){this._disabled||this._readonly||(e&&this.options.clearable&&t===this._value?this.set(0):this.set(t))}_onKeydown(t){if(this._disabled||this._readonly)return;let e=["ArrowRight","ArrowDown"],s=["ArrowLeft","ArrowUp"];if(e.includes(t.key))t.preventDefault(),this.set(this._value>=this._max?this._step:(this._value||0)+this._step);else if(s.includes(t.key))t.preventDefault(),this.set(this._value<=this._step?this._max:this._value-this._step);else if(t.key==="Home")t.preventDefault(),this.set(this._step);else if(t.key==="End")t.preventDefault(),this.set(this._max);else if((t.key==="Delete"||t.key==="Backspace")&&this.options.clearable)t.preventDefault(),this.set(0);else return;this.focus()}_setPreview(t){let e=this._disabled||this._readonly?null:t;e!==this._preview&&(this._preview=e,this._paint(),this.emit("hover",{value:this._preview}))}_clamp(t){let e=Number(t);if(!Number.isFinite(e)||e<=0)return 0;let s=Math.round(e/this._step)*this._step;return Math.min(this._max,Math.max(0,s))}_sync(){for(let e of this._radios){let s=Number(e.dataset.value);e.setAttribute("aria-checked",String(s===this._value))}let t=this._radios.find(e=>e.getAttribute("aria-checked")==="true");for(let e of this._radios)e.tabIndex=-1;(t??this._radios[0]).tabIndex=0,this._paint(),this._syncReadout()}_paint(){let t=this._preview??this._value;this.refs.symbols.querySelectorAll(".zx-rating__symbol").forEach((s,n)=>{let r=Math.min(1,Math.max(0,t-n));s.style.setProperty("--zx-rating-fill",`${r*100}%`),s.toggleAttribute("data-preview",this._preview!==null)}),this.el.dataset.value=String(t)}_syncReadout(){let t=this.refs.readout;if(!t)return;let e=this._count===void 0?this.options.count:this._count,s=[];this.options.showValue&&s.push(Hr(this._value,this._step)),e!=null&&s.push(this._message("rating.count","%1 ratings",[e])),t.textContent=s.join(" \xB7 ")}_syncDisabled(){let t=this._disabled||this._readonly;for(let e of this._radios)e.disabled=this._disabled;this.refs.symbols.setAttribute("aria-readonly",String(this._readonly)),this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this.el.toggleAttribute("data-inert",t),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&R(t,this._snapshot)}},vt={sm:14,md:18,lg:24};function Hr(i,t){return t<1?i.toFixed(1):String(i)}function ys(){x.register("rating",(i,t)=>{let e=i.own(new Jt(null,{label:t.label?String(t.label):void 0,...t.props??{}})),s=!1;return e.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get()||null,set:n=>{s=!0;try{e.set(Number(n)||0,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var Vc=["a[href]","area[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","iframe","object","embed",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(",");function xs(i,t){let e="",s=null;return function(r){let o=typeof r=="string"?r:r.key;if(typeof r!="string"&&(r.ctrlKey||r.metaKey||r.altKey)||!o||o.length!==1||/\s/.test(o))return;s!==null&&clearTimeout(s),e+=o.toLocaleLowerCase(),e.split("").every(u=>u===e[0])&&(e=e[0]),s=setTimeout(()=>{e="",s=null},500);let a=i(),c=a.findIndex(u=>$r(u).startsWith(e));c>=0&&t(a[c],c)}}function $r(i){if(typeof i=="string"||typeof i=="number")return String(i).trim().toLocaleLowerCase();if(i&&typeof i=="object"&&"textContent"in i)return String(i.textContent??"").trim().toLocaleLowerCase();if(i&&typeof i=="object"){let t=i,e=t.label??t.text??t.value;if(e!=null)return String(e).trim().toLocaleLowerCase()}return String(i??"").trim().toLocaleLowerCase()}var Yr=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],vs=["Lowest","Low","Medium","High","Highest"],Kr=Object.freeze([["backlog","status.backlog","Backlog","dotted","muted"],["todo","status.todo","Todo","ring","neutral"],["in-progress","status.inProgress","In Progress","progress","warning"],["in-review","status.inReview","In Review","review","info"],["ready","status.ready","Ready to Merge","ready","accent"],["waiting","status.waiting","Waiting for feedback","waiting","warning"],["done","status.done","Done","done","info"],["canceled","status.canceled","Canceled","canceled","muted"],["duplicate","status.duplicate","Duplicate","duplicate","muted"]]),M=class i extends y{static cssName="select";static defaults={items:[],fixedItems:[],valueKey:"ID",labelKey:"name",renderItem:null,renderValue:null,renderValueAdornment:null,renderNone:null,noneLabel:null,actions:[],value:null,disabled:!1,placeholder:"",clearable:!1,filter:!1,searchKeys:null,minQuery:0,debounce:200,listHeight:280,groupKey:null};render(){this._items=[],this._visibleItems=[],this._fixedItems=[],this._visibleFixed=[],this._actions=[],this._selected=null,this._optionEntries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._createdRoot=!1,this._root=null,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._root=t,this._createdRoot||(this._originalChildren=Array.from(t.childNodes)),this._rememberAttribute(t,"data-state"),this._rememberAttribute(t,"data-loading"),this._rememberAttribute(t,"aria-disabled");let e=v("zx-select-list"),s=l("input",{ref:"input",class:"zx-select__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:this.options.filter?"list":"none",placeholder:String(this.options.placeholder??""),readOnly:!this.options.filter}),n=l("span",{ref:"valueAdornment",class:"zx-select__value-adornment",ariaHidden:"true",hidden:!0}),r=l("button",{ref:"clear",class:"zx-icon-btn zx-select__clear",type:"button",tabIndex:-1,ariaLabel:this._message("select.clear","Clear selection"),hidden:!0},_("x",{size:13})),o=l("span",{ref:"loading",class:"zx-select__loading",role:"status",ariaLabel:this._message("select.loading","Loading"),hidden:!0}),a=l("button",{ref:"toggle",class:"zx-select__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("select.toggle","Toggle options")},_("chevron-down",{size:16})),c=l("div",{ref:"control",class:"zx-select__control"},n,s,r,o,a),u=l("div",{ref:"list",class:"zx-select__list",id:e,role:"listbox"});u.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let h=l("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},u);return t.replaceChildren(c,h),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visibleItems=this._items.slice(),this._fixedItems=Array.isArray(this.options.fixedItems)?this.options.fixedItems.slice():[],this._visibleFixed=this._fixedItems.slice(),this._actions=ws(this.options.actions),this._disabled=!!this.options.disabled,this._handleTypeahead=xs(()=>this._optionEntries.filter(f=>!f.clear&&!f.action).map(f=>f.element),(f,p)=>{this._open||this.open(),this._setActive(this._itemEntryIndex(p))}),this.listen(s,"click",()=>this.open()),this.listen(s,"input",()=>this._onInput()),this.listen(s,"keydown",f=>this._onKeydown(f)),this.listen(a,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(r,"click",()=>{this.set(null),this.focus()}),this.listen(h,"pointerdown",f=>f.preventDefault()),this.listen(h,"click",f=>this._onOptionClick(f)),this.listen(document,"pointerdown",f=>{this._open&&!t.contains(f.target)&&this.close()},{capture:!0}),this._renderOptions(),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._selected===null?null:this._itemValue(this._selected)}set value(t){this.set(t)}get selected(){return this._selected}set(t,{silent:e=!1}={}){let s=this.value,n=t==null?null:this._findItem(t);this._selected=n,this._syncInputValue(),this._renderOptions();let r=this.value;return!e&&!Object.is(s,r)&&this.emit("change",{value:r,item:n}),this}setItems(t){let e=this.value;return this._items=Array.isArray(t)?t.slice():[],this._visibleItems=this._items.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setFixedItems(t){let e=this.value;return this._fixedItems=Array.isArray(t)?t.slice():[],this._visibleFixed=this._fixedItems.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setActions(t){return this._actions=ws(t),this._renderOptions(),this._position?.update(),this}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t}),this}open(){return this._disabled||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=U(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._selectedEntryIndex()),this._activeIndex<0&&this._optionEntries.length>0&&this._setActive(0),this.options.filter&&this._selected!==null&&this.refs.input.select(),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(""),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._setLoading(!1),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._visibleItems=this._items.slice(),this._visibleFixed=this._fixedItems.slice(),this._syncInputValue(),this.emit("close",{}),this):this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}static priority(t,e={}){let s=e.value??null,n=new i(t,{...e,value:null,items:[],renderItem(r){return Wr(r,!0)},renderValueAdornment(r){return Ss(r.level)}});return n.setItems(Yr.map((r,o)=>{let a=o===2?n.msg("priority.medium"):r;return(a==="priority.medium"||o!==2)&&(a=n._message(r,vs[o])),{ID:o,name:a,level:o}})),n.set(s,{silent:!0}),n}static status(t,e={}){let{items:s=null,value:n=null,...r}=e,o=new i(t,{...r,value:null,items:[],renderItem(c){return Zr(c)},renderValueAdornment(c){return As(c)}}),a=Array.isArray(s)?s.map(Qr).filter(Boolean):Kr.map(([c,u,h,f,p],d)=>({ID:c,name:o._message(u,h),indicator:f,tone:p,shortcut:String(d+1)}));return o.setItems(a),o.set(n,{silent:!0}),o}static permission(t,e={}){let{groups:s=[],value:n=!0,valueKey:r="ID",labelKey:o="name",filter:a="local",...c}=e,u=typeof s=="function"?s:null,h=u?[]:s,f=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],p=new i(t,{filter:u??a,...c,value:null,items:h,fixedItems:[],valueKey:d=>f.includes(d)?d.ID:Ve(d,r),labelKey:d=>f.includes(d)?d.name:String(Ve(d,o)??"")});return f[0].name=p._message("permission.private","Private"),f[1].name=p._message("permission.public","Public"),p.setFixedItems(f),p.set(n,{silent:!0}),p}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;if(!this._createdRoot&&t){t.replaceChildren(...this._originalChildren);for(let[e,s]of this._originalAttributes)s===null?t.removeAttribute(e):t.setAttribute(e,s)}super.destroy()}_onKeydown(t){if(!this._disabled){if(this._open&&ks(t)){let e=this._optionEntries.findIndex(s=>!s.clear&&!s.action&&String(s.item?.shortcut??"")===t.key);if(e>=0){t.preventDefault(),this._setActive(e),this._chooseEntry(this._optionEntries[e]);return}}if(t.key==="ArrowDown"){t.preventDefault(),this._open?this._moveActive(1):this.open();return}if(t.key==="ArrowUp"){t.preventDefault(),this._open?this._moveActive(-1):(this.open(),this._setActive(this._optionEntries.length-1));return}if(t.key==="Home"&&this._open){t.preventDefault(),this._setActive(0);return}if(t.key==="End"&&this._open){t.preventDefault(),this._setActive(this._optionEntries.length-1);return}if(t.key==="Enter"&&this._open){t.preventDefault(),this._chooseEntry(this._optionEntries[this._activeIndex]);return}if(t.key==="Escape"&&this._open){t.preventDefault(),this.close();return}if(t.key==="Tab"&&this._open){this.close();return}!this.options.filter&&ks(t)&&this._handleTypeahead(t)}}_onInput(){if(!this.options.filter)return;let t=this.refs.input.value;this._syncValueAdornment(),this._open||this.open(),this.options.filter==="local"?(this._visibleFixed=this._matchFixed(t),this._visibleItems=K(this._items,t,this._searchKeys()),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update()):typeof this.options.filter=="function"&&this._scheduleAsyncQuery(t)}_onOptionClick(t){let e=t.target?.closest?.('[role="option"]');!e||!this.refs.panel.contains(e)||this._chooseEntry(this._optionEntries[Number(e.getAttribute("data-index"))])}_chooseEntry(t){if(t){if(t.action){let e={id:t.action.id,action:t.action,query:this.refs.input.value,select:this};this.emit("action",e).defaultPrevented||t.action.invoke?.(e),this.close(),this.focus();return}this.set(t.clear?null:t.item),this.close(),this.focus()}}_moveActive(t){let e=this._optionEntries.length;e!==0&&this._setActive((this._activeIndex+t+e)%e)}_setActive(t){this._activeIndex=t>=0&&t<this._optionEntries.length?t:-1,this._optionEntries.forEach((s,n)=>{n===this._activeIndex?s.element.setAttribute("data-active","true"):s.element.removeAttribute("data-active")});let e=this._optionEntries[this._activeIndex]?.element;e?(this.refs.input.setAttribute("aria-activedescendant",e.id),e.scrollIntoView?.({block:"nearest"})):this.refs.input.removeAttribute("aria-activedescendant")}_renderOptions(){let t=this.refs.list;if(!t)return;t.replaceChildren(),this._optionEntries=[];let e=Symbol("initial-group");this.options.clearable&&this._appendOption(null,!0,this.options.noneLabel??this._message("select.none","No selection"));for(let s of this._visibleFixed)this._appendOption(s,!1);this._visibleFixed.length>0&&this._visibleItems.length>0&&!this.options.groupKey&&t.append(l("div",{class:"zx-select__separator",role:"presentation"}));for(let s of this._visibleItems){if(this.options.groupKey){let n=this._read(s,this.options.groupKey);Object.is(n,e)||(t.append(l("div",{class:"zx-select__group",role:"presentation"},String(n??""))),e=n)}this._appendOption(s,!1)}if(this._actions.length>0){(this._visibleFixed.length>0||this._visibleItems.length>0||this.options.clearable)&&t.append(l("div",{class:"zx-select__separator",role:"presentation"}));let s=Symbol("initial-action-group");for(let n of this._actions)n.group&&n.group!==s&&(t.append(l("div",{class:"zx-select__group",role:"presentation"},n.group)),s=n.group),this._appendAction(n)}this._visibleItems.length===0&&this._visibleFixed.length===0&&this._actions.length===0&&!this._loading&&t.append(l("div",{class:"zx-select__empty",role:"status"},this._message("select.empty","No matches"))),this._setActive(-1)}_appendOption(t,e,s){let n=e?this._selected===null:this._selected!==null&&Object.is(this._itemValue(t),this.value),r=this._optionEntries.length,o=e&&typeof this.options.renderNone=="function"?qe(this.options.renderNone(String(s??""))):e?String(s??""):this._renderItem(t),a=l("div",{class:"zx-select__option",id:v("zx-select-option"),role:"option",ariaSelected:String(n),dataset:{index:r}},l("span",{class:"zx-select__option-content"},o));n&&a.append(_("check",{size:15})),this.refs.list.append(a),this._optionEntries.push({item:t,clear:e,action:null,element:a})}_appendAction(t){let e=this._optionEntries.length,s=Ur(t.icon),n=l("div",{class:"zx-select__option zx-select__action",id:v("zx-select-option"),role:"option",ariaSelected:"false",dataset:{index:e,kind:"action"}},l("span",{class:"zx-select__option-content zx-select__action-content"},s?l("span",{class:"zx-select__action-icon",ariaHidden:"true"},s):null,l("span",{class:"zx-select__action-copy"},l("span",{class:"zx-select__action-label"},t.label),t.description?l("span",{class:"zx-select__action-description"},t.description):null)));this.refs.list.append(n),this._optionEntries.push({item:null,clear:!1,action:t,element:n})}_renderItem(t){if(typeof this.options.renderItem=="function"){let e=this.options.renderItem(t);return qe(e)}return this._itemLabel(t)}_scheduleAsyncQuery(t){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._requestSequence+=1;let e=this._requestSequence;if(this._visibleFixed=this._matchFixed(t),t.length<Math.max(0,Number(this.options.minQuery)||0)){this._setLoading(!1),this._visibleItems=[],this._renderOptions();return}this._setLoading(!0),this._renderOptions(),this._position?.update();let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runAsyncQuery(t,e)},s)}async _runAsyncQuery(t,e){if(!(e!==this._requestSequence||typeof this.options.filter!="function")){this.emit("query",{query:t});try{let s=await this.options.filter(t);if(e!==this._requestSequence||!this._open)return;this._items=Array.isArray(s)?s.slice():[],this._visibleItems=this._items.slice(),this._setLoading(!1),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update(),this.emit("loaded",{items:this._items.slice()})}catch{if(e!==this._requestSequence||!this._open)return;this._items=[],this._visibleItems=[],this._setLoading(!1),this._renderOptions(),this._position?.update()}}}_cancelQuery(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._requestSequence+=1}_setLoading(t){this._loading=t,this.refs.loading.hidden=!t,this.refs.input.setAttribute("aria-busy",String(t)),this.refs.list.setAttribute("aria-busy",String(t)),t?this._root?.setAttribute("data-loading","true"):this._root?.removeAttribute("data-loading")}_syncInputValue(){if(!this.refs.input)return;let t=this.refs.input;t.value=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),this._syncValueAdornment(),this.refs.clear.hidden=!this.options.clearable||this._selected===null}_syncValueAdornment(){let t=this.refs.valueAdornment;if(!t)return;let e=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),s=String(this.refs.input?.value??"");if(this._selected===null||typeof this.options.renderValueAdornment!="function"||this.options.filter&&s!==e){t.replaceChildren(),t.hidden=!0;return}let n=this.options.renderValueAdornment(this._selected),r=qe(n);t.replaceChildren(r instanceof Node?r:document.createTextNode(r)),t.hidden=n==null||typeof r=="string"&&r===""}_syncDisabled(){let t=this.refs.input,e=this.refs.clear,s=this.refs.toggle;t.disabled=this._disabled,e.disabled=this._disabled,s.disabled=this._disabled,this._root?.setAttribute("aria-disabled",String(this._disabled))}_findItem(t){let e=this._fixedItems.length===0?this._items:[...this._fixedItems,...this._items],s=e.find(r=>r===t);if(s!==void 0)return s;let n=t!==null&&typeof t=="object"?this._itemValue(t):t;return e.find(r=>Object.is(this._itemValue(r),n))??null}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){let e=this._read(t,this.options.labelKey);return String(e??"")}_read(t,e){return Ve(t,e)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(t){return K(this._fixedItems,t,this._searchKeys())}_selectedEntryIndex(){return this._selected===null?this.options.clearable?0:-1:this._optionEntries.findIndex(t=>!t.clear&&Object.is(this._itemValue(t.item),this.value))}_itemEntryIndex(t){return t+(this.options.clearable?1:0)}_rememberAttribute(t,e){this._originalAttributes.set(e,t.getAttribute(e))}_message(t,e){let s=this.msg(t);return s===t?e:s}};function qe(i){return i&&typeof i=="object"&&"nodeType"in i?i:String(i??"")}function ws(i){return Array.isArray(i)?i.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>({...t,label:String(t.label),description:t.description==null?void 0:String(t.description),group:t.group==null?void 0:String(t.group)})):[]}function Ur(i){return typeof i=="string"?_(i):i instanceof Node?i.cloneNode(!0):null}function Wr(i,t){return l("span",{class:"zx-select__priority"},Ss(i.level),t?l("span",{},String(i.name)):null)}function Ss(i){let t=Math.max(0,Math.min(4,Math.trunc(Number(i)||0)));return l("span",{class:"zx-select__priority-icon",dataset:{level:t},ariaHidden:"true"},Array.from({length:5},(e,s)=>l("span",{dataset:{filled:String(s<=t)}})))}function Qr(i){if(!i||typeof i!="object"||i.ID==null||i.name==null)return null;let t=["dotted","ring","progress","review","ready","waiting","done","canceled","duplicate"],e=["muted","neutral","warning","info","accent","success","danger"];return{...i,name:String(i.name),indicator:t.includes(String(i.indicator))?String(i.indicator):"ring",tone:e.includes(String(i.tone))?String(i.tone):"muted",description:i.description==null?"":String(i.description),shortcut:i.shortcut==null?"":String(i.shortcut)}}function Zr(i){return l("span",{class:"zx-select__status"},As(i),l("span",{class:"zx-select__status-copy"},l("span",{class:"zx-select__status-label"},String(i.name)),i.description?l("span",{class:"zx-select__status-description"},i.description):null),i.shortcut?l("kbd",{class:"zx-select__status-shortcut"},i.shortcut):null)}function As(i){let t=String(i.indicator??"ring"),e=l("span",{class:"zx-select__status-indicator",dataset:{indicator:t,tone:String(i.tone??"muted")},ariaHidden:"true"});return t==="done"&&e.append(_("check",{size:8})),t==="canceled"&&e.append(_("x",{size:7})),e}function Ve(i,t){return typeof t=="function"?t(i):i===null||typeof i!="object"?i:i[t]}function ks(i){return i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey}function zs(){x.register("zxselect",(i,t)=>{let e=t.props??{},s=e.preset,n={...e,value:t.value};delete n.preset;let r=i.own(s==="priority"?M.priority(null,n):s==="status"?M.status(null,n):new M(null,n));return i.listen(r.el,"change",o=>o.stopImmediatePropagation()),r.on("change",o=>i.emit("change",{value:o.detail.value})),{el:r.el,get:()=>r.value,set:o=>r.set(o,{silent:!0}),focus:()=>r.focus(),setDisabled:o=>o?r.disable():r.enable()}})}var te=class extends y{static cssName="slider";static defaults={value:0,min:0,max:100,step:1,label:"",hideLabel:!1,showValue:!0,showBounds:!1,showInput:!1,unit:"",marks:null,disabled:!1,readonly:!1,size:"md",formatValue:null};render(){this._value=0,this._readonly=!!this.options.readonly,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:O(this.el);let t=this.el??l("div");this.el=t,this._min=Number(this.options.min)||0,this._max=Number(this.options.max),(!Number.isFinite(this._max)||this._max<=this._min)&&(this._max=this._min+100),this._step=Math.abs(Number(this.options.step))||1,this._id=v("zx-slider");let e=l("input",{ref:"input",class:"zx-slider__input",type:"range",id:this._id,min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled}),s=l("div",{class:"zx-slider__track"},e,this._marks()),n=l("div",{class:"zx-slider__control"});return this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._min))),n.append(s),this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._max))),this.options.showInput&&n.append(this._numberBox()),t.replaceChildren(l("div",{class:"zx-slider__head"},l("label",{ref:"label",class:"zx-slider__label",for:this._id},String(this.options.label??"")),l("span",{ref:"output",class:"zx-slider__value",ariaHidden:"true"})),n),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(e,"input",()=>this._onInput()),this.listen(e,"change",()=>this._onCommit()),this.listen(e,"keydown",r=>{this._readonly&&Gr.has(r.key)&&r.preventDefault()}),this.set(this.options.value,{silent:!0}),this._syncState(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=this._snap(t),n=s!==this._value;return this._value=s,this._paint(),n&&!e&&this.emit("change",{value:s}),this}setRange(t,e,s){let n=Number(t),r=Number(e);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)throw new RangeError("Slider range requires min < max");this._min=n,this._max=r,s!==void 0&&(this._step=Math.abs(Number(s))||1);let{input:o}=this.refs;o.min=String(this._min),o.max=String(this._max),o.step=String(this._step);for(let[a,c]of[...this.el.querySelectorAll(".zx-slider__bound")].entries())c.textContent=this._format(a===0?this._min:this._max);return this.set(this._value,{silent:!0})}focus(){return this.refs.input.focus(),this}enable(){return this.refs.input.disabled=!1,this.refs.number&&(this.refs.number.disabled=!1),this._syncState(),this}disable(){return this.refs.input.disabled=!0,this.refs.number&&(this.refs.number.disabled=!0),this._syncState(),this}setReadonly(t){return this._readonly=!!t,this.refs.number&&(this.refs.number.readOnly=this._readonly),this._syncState(),this}setLabel(t){return this.refs.label.textContent=String(t??""),this}_numberBox(){let t=l("input",{ref:"number",class:"zx-slider__number",type:"number",min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled,readOnly:this._readonly,ariaLabel:String(this.options.label??"Value")});return this.listen(t,"input",()=>{if(this._readonly)return;let e=Number(t.value);t.value===""||!Number.isFinite(e)||(this._value=this._snap(e),this.refs.input.value=String(this._value),this._paintTrack(),this.emit("input",{value:this._value}))}),this.listen(t,"change",()=>{if(this._readonly){t.value=String(this._value);return}this.set(t.value===""?this._min:Number(t.value))}),t}_marks(){let t=this.options.marks;if(!Array.isArray(t)||t.length===0)return null;let e=l("div",{class:"zx-slider__marks",ariaHidden:"true"});for(let s of t){let n=typeof s=="number"?s:Number(s?.value);if(!Number.isFinite(n))continue;let r=typeof s=="number"?this._format(n):String(s.label??this._format(n));e.append(l("span",{class:"zx-slider__mark",style:{"--zx-slider-mark":`${this._ratio(n)*100}%`}},r))}return e}_onInput(){if(this._readonly){this.refs.input.value=String(this._value);return}this._value=this._snap(this.refs.input.value),this._paintTrack(),this.refs.number&&(this.refs.number.value=String(this._value)),this.emit("input",{value:this._value})}_onCommit(){if(this._readonly){this.refs.input.value=String(this._value);return}this.emit("change",{value:this._value})}_paint(){this.refs.input.value=String(this._value),this.refs.number&&(this.refs.number.value=String(this._value)),this._paintTrack()}_paintTrack(){this.el.style.setProperty("--zx-slider-fill",`${this._ratio(this._value)*100}%`);let{output:t}=this.refs;t.textContent=this.options.showValue?this._format(this._value):""}_syncState(){let t=this.refs.input.disabled;this.el.toggleAttribute("data-disabled",t),this.el.toggleAttribute("data-readonly",this._readonly),this.refs.input.setAttribute("aria-readonly",String(this._readonly))}_snap(t){let e=Number(t);return Number.isFinite(e)?je(e,{min:this._min,max:this._max,step:this._step,precision:Xr(this._step)}):this._min}_ratio(t){return gt((t-this._min)/(this._max-this._min),0,1)}_format(t){let e=this.options.formatValue;return typeof e=="function"?String(e(t)):`${Jr(t)}${this.options.unit??""}`}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&R(t,this._snapshot)}},Gr=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function Xr(i){let t=String(i),e=/e-(\d+)$/i.exec(t);return e?Number(e[1]):(t.split(".")[1]??"").length}function Jr(i){return String(Number(i.toFixed(6)))}function Ds(){x.register("slider",(i,t)=>{let e=i.own(new te(null,{label:t.label?String(t.label):void 0,hideLabel:!0,disabled:!!t.disabled,...t.props??{}})),s=!1;return e.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get(),set:n=>{s=!0;try{e.set(Number(n)||0,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var ee=class extends y{static cssName="tag-picker";static defaults={items:[],values:[],valueKey:"ID",labelKey:"name",searchKeys:null,filter:"local",minQuery:0,debounce:200,allowCreate:!1,max:null,closeOnSelect:!1,placeholder:"",listHeight:260,disabled:!1,readonly:!1,renderItem:null,renderTag:null};render(){this._items=[],this._selected=[],this._visible=[],this._entries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._readonly=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._activeId=null,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:O(this.el);let t=this.el??l("div");this.el=t;let e=v("zx-tag-picker-list"),s=l("span",{ref:"tags",class:"zx-tag-picker__tags"}),n=l("input",{ref:"input",class:"zx-tag-picker__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:"list",ariaLabel:this._message("tagPicker.input","Add a value"),placeholder:String(this.options.placeholder??"")}),r=l("button",{ref:"toggle",class:"zx-tag-picker__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("tagPicker.toggle","Toggle options")},_("chevron-down",{size:15})),o=l("div",{ref:"control",class:"zx-tag-picker__control"},s,n,r),a=l("div",{ref:"list",class:"zx-tag-picker__list",id:e,role:"listbox",ariaMultiSelectable:"true"});a.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let c=l("div",{ref:"panel",class:"zx-tag-picker__panel",popover:"manual"},a);return t.replaceChildren(o,c),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visible=this._items.slice(),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(o,"pointerdown",u=>{let h=u.target;h.closest(".zx-tag-picker__remove")||h.closest(".zx-tag-picker__toggle")||(u.target!==n&&(u.preventDefault(),this.focus()),this._open||this.open())}),this.listen(s,"click",u=>{let h=u.target.closest(".zx-tag-picker__remove");if(!h||this._disabled||this._readonly)return;u.stopPropagation();let f=[...s.children].indexOf(h.closest(".zx-tag-picker__tag")),p=this._selected[f];p!==void 0&&(this.removeValue(this._valueOf(p)),this.focus())}),this.listen(n,"input",()=>this._onInput()),this.listen(n,"keydown",u=>this._onKeydown(u)),this.listen(n,"blur",()=>this.el.removeAttribute("data-focus")),this.listen(n,"focus",()=>this.el.setAttribute("data-focus","")),this.listen(r,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(c,"pointerdown",u=>u.preventDefault()),this.listen(c,"click",u=>this._onOptionClick(u)),this.listen(document,"pointerdown",u=>{this._open&&!t.contains(u.target)&&this.close()},{capture:!0}),this.setValues(this.options.values,{silent:!0}),this._syncDisabled(),t}get values(){return this.getValues()}set values(t){this.setValues(t)}getValues(){return this._selected.map(t=>this._valueOf(t))}getItems(){return this._selected.slice()}setValues(t,{silent:e=!1}={}){let s=Array.isArray(t)?t:[],n=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),r=[];for(let a of s){if(r.length>=n)break;let c=this._resolve(a);c!==null&&!r.some(u=>this._sameValue(u,c))&&r.push(c)}let o=!to(r,this._selected,a=>this._valueOf(a));return this._selected=r,this._renderTags(),this._renderOptions(),o&&!e&&this._emitChange(),this}addValue(t,{silent:e=!1}={}){if(this.isFull())return this;let s=this._resolve(t);return s===null?this:this._selected.some(n=>this._sameValue(n,s))?this:(this._selected.push(s),this._renderTags(),this._renderOptions(),e||(this.emit("add",{value:this._valueOf(s),item:s}),this._emitChange()),this)}removeValue(t,{silent:e=!1}={}){let s=this._valueOf(this._resolve(t)??t),n=this._selected.findIndex(o=>Object.is(this._valueOf(o),s));if(n<0)return this;let[r]=this._selected.splice(n,1);return this._renderTags(),this._renderOptions(),e||(this.emit("remove",{value:this._valueOf(r),item:r}),this._emitChange()),this}clear({silent:t=!1}={}){return this.setValues([],{silent:t})}reset({silent:t=!1}={}){return this.setValues(this.options.values,{silent:t})}setItems(t){return this._cancelQuery(),this._items=Array.isArray(t)?t.slice():[],typeof this.options.filter=="function"?this._visible=this._items.slice():this._applyLocalFilter(this.refs.input.value),this._renderOptions(),this._position?.update(),this}isFull(){let t=this.options.max;return t!=null&&this._selected.length>=Number(t)}open(){return this._disabled||this._readonly||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=U(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._entries.length>0?0:-1),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(this.refs.input.value),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._activeId=null,this.refs.input.value="",this._syncInputWidth(),this._applyLocalFilter(""),this.emit("close",{}),this):this}focus(){return this.refs.input.focus(),this}enable(){return this._disabled=!1,this._renderTags(),this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._renderTags(),this._syncDisabled(),this}setReadonly(t){return t&&this.close(),this._readonly=!!t,this._renderTags(),this._syncDisabled(),this}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;super.destroy(),!this._createdRoot&&t&&R(t,this._snapshot)}_renderTags(){let t=this._selected.map(e=>{let s=this._labelOf(e),n=this.options.renderTag?this.options.renderTag(e):s,r=l("span",{class:"zx-tag-picker__tag"},l("span",{class:"zx-tag-picker__tag-label"},n));return!this._readonly&&!this._disabled&&r.append(l("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[s])},_("x",{size:11}))),r});this.refs.tags.replaceChildren(...t),this.el.toggleAttribute("data-empty",this._selected.length===0),this._syncPlaceholder()}_renderOptions(){let t=this.refs.list;this._entries=[];let e=[];for(let r of this._visible){let o=this._valueOf(r),a=this._isSelected(o),c=l("div",{class:"zx-tag-picker__option",id:v("zx-tag-picker-option"),role:"option",ariaSelected:String(a)},l("span",{class:"zx-tag-picker__check",ariaHidden:"true"},a?_("check",{size:13}):null),l("span",{class:"zx-tag-picker__option-label"},this.options.renderItem?this.options.renderItem(r):this._labelOf(r)));!a&&this.isFull()&&c.setAttribute("aria-disabled","true"),this._entries.push({item:r,element:c,create:!1}),e.push(c)}let s=this.refs.input.value.trim();if(this._canCreate(s)){let r=l("div",{class:"zx-tag-picker__option",id:v("zx-tag-picker-option"),role:"option",ariaSelected:"false",dataset:{create:"true"}},l("span",{class:"zx-tag-picker__check",ariaHidden:"true"},_("plus",{size:13})),l("span",{class:"zx-tag-picker__option-label"},this._message("tagPicker.create","Create \u201C%1\u201D",[s])));this._entries.push({item:null,element:r,create:!0}),e.push(r)}e.length===0&&e.push(l("div",{class:"zx-tag-picker__empty"},this._loading?this._message("tagPicker.loading","Loading\u2026"):this._message("tagPicker.empty","No matches"))),t.replaceChildren(...e);let n=this._entries.findIndex(r=>this._entryId(r)===this._activeId);this._setActive(n>=0?n:this._entries.length>0?0:-1)}_entryId(t){return t.create?"\0create":String(this._valueOf(t.item))}_syncPlaceholder(){let t=this.refs.input;t.placeholder=this._selected.length===0?String(this.options.placeholder??""):""}_onInput(){let t=this.refs.input.value;this._syncInputWidth(),this._open||this.open(),typeof this.options.filter=="function"?this._scheduleAsyncQuery(t):this._applyLocalFilter(t),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update()}_onKeydown(t){if(this._disabled||this._readonly)return;let e=this.refs.input;switch(t.key){case"ArrowDown":t.preventDefault(),this._open?this._move(1):this.open();return;case"ArrowUp":t.preventDefault(),this._open&&this._move(-1);return;case"Home":this._open&&e.value===""&&(t.preventDefault(),this._setActive(0));return;case"End":this._open&&e.value===""&&(t.preventDefault(),this._setActive(this._entries.length-1));return;case"Enter":{if(!this._open||this._activeIndex<0)return;t.preventDefault(),this._commitEntry(this._entries[this._activeIndex]);return}case"Escape":this._open&&(t.preventDefault(),this.close());return;case"Backspace":e.value===""&&this._selected.length>0&&(t.preventDefault(),this.removeValue(this._valueOf(this._selected[this._selected.length-1])));return;case"Tab":this._open&&this.close();return;default:}}_onOptionClick(t){let e=t.target.closest(".zx-tag-picker__option");if(!e)return;let s=this._entries.find(n=>n.element===e);s&&this._commitEntry(s)}_commitEntry(t){if(!t)return;let e=this.refs.input;if(t.create){let s=e.value.trim(),n=this._createItem(s);this._items=this._items.concat([n]),this.addValue(n),this.emit("create",{value:this._valueOf(n),item:n})}else{let s=this._valueOf(t.item);if(this._isSelected(s))this.removeValue(s);else if(!this.isFull())this.addValue(t.item);else return}e.value="",this._syncInputWidth(),this._applyLocalFilter(""),this._renderOptions(),this.options.closeOnSelect?this.close():(this._setActive(this._entries.length>0?0:-1),this._position?.update()),this.focus()}_move(t){if(this._entries.length===0)return;let e=this._activeIndex<0?t>0?0:this._entries.length-1:Math.min(this._entries.length-1,Math.max(0,this._activeIndex+t));this._setActive(e)}_setActive(t){this._activeIndex=t,this._activeId=this._entries[t]?this._entryId(this._entries[t]):null;for(let[e,s]of this._entries.entries()){let n=e===t;s.element.toggleAttribute("data-active",n),n&&(this.refs.input.setAttribute("aria-activedescendant",s.element.id),s.element.scrollIntoView({block:"nearest"}))}t<0&&this.refs.input.removeAttribute("aria-activedescendant")}_applyLocalFilter(t){if(typeof this.options.filter=="function")return;let e=this.options.searchKeys??[this.options.labelKey];this._visible=K(this._items,t,e)}_scheduleAsyncQuery(t){this._cancelQuery();let e=String(t??"");if(e.length<Number(this.options.minQuery??0)){this._visible=[],this._renderOptions();return}this._visible=[],this._setLoading(!0),this._renderOptions();let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runQuery(e)},s)}async _runQuery(t){let e=this._requestSequence+1;this._requestSequence=e,this._setLoading(!0),this.emit("query",{query:t});try{let s=await this.options.filter(t);if(e!==this._requestSequence)return;this._items=Array.isArray(s)?s.slice():[],this._visible=this._items.slice()}catch(s){if(e!==this._requestSequence)return;this._visible=[],this.emit("error",{error:s})}finally{e===this._requestSequence&&(this._setLoading(!1),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update())}}_cancelQuery(){this._queryTimer!==null&&(clearTimeout(this._queryTimer),this._queryTimer=null),this._requestSequence+=1,this._setLoading(!1)}_setLoading(t){this._loading=t,this.el.toggleAttribute("data-loading",t)}_isSelected(t){return this._selected.some(e=>Object.is(this._valueOf(e),t))}_canCreate(t){if(!this.options.allowCreate||t===""||this.isFull())return!1;let e=s=>s.some(n=>Cs(this._labelOf(n))===Cs(t));return!e(this._items)&&!e(this._selected)}_createItem(t,e=t){return typeof this.options.valueKey!="string"||typeof this.options.labelKey!="string"?t:{[this.options.valueKey]:e,[this.options.labelKey]:t,created:!0}}_resolve(t){if(t==null)return null;let e=this._valueOf(t),s=this._items.find(r=>Object.is(this._valueOf(r),e));if(s!==void 0)return s;let n=this._selected.find(r=>Object.is(this._valueOf(r),e));return n!==void 0?n:typeof t=="object"?t:this._createItem(String(t),t)}_sameValue(t,e){return Object.is(this._valueOf(t),this._valueOf(e))}_valueOf(t){let e=this.options.valueKey;return typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]:t}_labelOf(t){let e=this.options.labelKey;return String(typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]??"":t??"")}_emitChange(){this.emit("change",{values:this.getValues(),items:this.getItems()})}_syncInputWidth(){let t=this.refs.input,e=t.value.length;t.style.inlineSize=e===0?"":`${Math.min(40,e+1)}ch`}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.toggle.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}_message(t,e,s=[]){let n=this.msg(t,...s);return n!==t?n:s.reduce((r,o,a)=>r.replaceAll(`%${a+1}`,String(o)),e)}};function Cs(i){return String(i??"").trim().toLocaleLowerCase()}function to(i,t,e){return i.length!==t.length?!1:i.every((s,n)=>Object.is(e(s),e(t[n])))}function Is(){x.register("tagpicker",(i,t)=>{let e=i.own(new ee(null,{placeholder:t.placeholder,...t.props??{}})),s=!1;return i.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{s||i.emit("change",{value:n.detail.values})}),{el:e.el,get:()=>e.getValues(),set:n=>{s=!0;try{e.setValues(Array.isArray(n)?n:[],{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}function eo(i,t="minutes"){let e=Math.round(Math.abs(Ms(et(i),t)));return{hours:Math.floor(e/3600),minutes:Math.floor(e/60)%60,seconds:e%60,negative:et(i)<0}}function io(i,t="minutes"){wt(t);let e=Math.abs(Math.trunc(et(i?.hours))),s=Math.abs(Math.trunc(et(i?.minutes))),n=Math.abs(Math.trunc(et(i?.seconds))),r=i?.negative?-1:1;return Ts(r*(e*3600+s*60+n),t)}var ie=class extends y{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){wt(this.options.unit);let t=this.el??l("div");this.el=t,this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._disabled=!!this.options.disabled,this._parts={hours:0,minutes:0,seconds:0,negative:!1},this._inputs=[];let e=l("div",{class:"zx-timebox__content",role:"group",ariaLabel:this.options.seconds?"Duration in hours, minutes, and seconds":"Duration in hours and minutes"});return this._content=e,this.options.signed&&(e.append(l("button",{ref:"sign",class:"zx-timebox__sign",type:"button",ariaLabel:"Toggle duration sign",ariaPressed:"false"},"+")),this.listen(this.refs.sign,"click",()=>{this._disabled||(this._parts.negative=!this._parts.negative,this._writeParts(),this._emitChange())})),this._addSegment(e,"hours","Hours",!1),e.append(l("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"minutes","Minutes",!0),this.options.seconds&&(e.append(l("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"seconds","Seconds",!0)),t.append(e),this.set(this.options.value,this.options.unit,{silent:!0}),this._syncDisabled(),t}get(t=this.options.unit){return io(this._readParts(),t)}set(t,e=this.options.unit,s={}){e&&typeof e=="object"&&(s=e,e=this.options.unit),wt(e);let n=et(t);return!this.options.signed&&n<0&&(n=0),this.options.seconds||(n=Ts(Math.round(Ms(n,e)/60)*60,e)),this._parts=eo(n,e),this.options.signed||(this._parts.negative=!1),this._writeParts(),s.silent||this._emitChange(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}destroy(){this._content?.remove(),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_addSegment(t,e,s,n){let r=l("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:s,maxLength:n?2:null,dataset:{segment:e,bounded:String(n)}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"input",()=>{e==="hours"&&this.options.signed&&r.value.trim().startsWith("-")&&(this._parts.negative=!0);let o=r.value.replace(/\D/g,"");r.value=n?o.slice(0,2):o}),this.listen(r,"change",()=>this._commitSegments()),this.listen(r,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this._commitSegments(),r.select())})}_readParts(){let t={...this._parts};for(let e of this._inputs){let s=e.dataset.segment,n=e.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;t[s]=Math.max(0,Math.min(n,Math.trunc(et(e.value))))}return t}_commitSegments(){this._parts=this._readParts(),this._writeParts(),this._emitChange()}_writeParts(){for(let t of this._inputs){let e=t.dataset.segment;t.value=e==="hours"?String(this._parts[e]):so(this._parts[e])}this.refs.sign&&(this.refs.sign.textContent=this._parts.negative?"-":"+",this.refs.sign.setAttribute("aria-pressed",String(this._parts.negative)),this.refs.sign.dataset.state=this._parts.negative?"negative":"positive")}_syncDisabled(){for(let t of this._inputs)t.disabled=this._disabled;this.refs.sign&&(this.refs.sign.disabled=this._disabled),this.el.setAttribute("aria-disabled",String(this._disabled))}_emitChange(){this.emit("change",{value:this.get(this.options.unit)})}};function et(i){let t=Number(i);return Number.isFinite(t)?t:0}function Ms(i,t){return wt(t),t==="hours"?i*3600:t==="minutes"?i*60:i}function Ts(i,t){return wt(t),t==="hours"?i/3600:t==="minutes"?i/60:i}function wt(i){if(i!=="hours"&&i!=="minutes"&&i!=="seconds")throw new RangeError(`Unknown time unit: ${i}`)}function so(i){return String(i).padStart(2,"0")}function Es(){x.register("time",(i,t)=>{let e=i.own(new ie(null,{...t.props??{},value:t.value}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:s.detail.value})),{el:e.el,get:()=>e.get(),set:s=>e.set(Number(s)||0,{silent:!0}),focus:()=>e.el.querySelector("input:not([disabled]), button:not([disabled])")?.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var ht=class extends y{static cssName="toggle";static defaults={checked:!1,value:!0,label:null,disabled:!1};render(){let t=!this.el,e=this.el??l("button");if(this.el=e,e.localName!=="button")throw new TypeError("Toggle target must be a button element");this._createdRoot=t,this._original=t?null:no(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,e.type="button",e.setAttribute("role","switch");let s=[l("span",{class:"zx-toggle__track",ariaHidden:"true"},l("span",{class:"zx-toggle__thumb"}))];return this.options.label!==null&&s.push(l("span",{class:"zx-toggle__label"},String(this.options.label))),e.replaceChildren(...s),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let s=!!t;return s===this._checked?this:(this._checked=s,this._sync(),e||this.emit("change",{checked:this._checked,value:this.getValue()}),this)}toggle(){return this.set(!this._checked)}getValue(){return this._checked?this.options.value:!1}enable(){return this._disabled=!1,this.el.removeAttribute("disabled"),this}disable(){return this._disabled=!0,this.el.setAttribute("disabled",""),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&ro(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function no(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function ro(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function Ns(){x.register("toggle",(i,t)=>{let e=i.own(new ht(null,{...t.props??{},checked:!!t.value}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:s.detail.value})),{el:e.el,get:()=>e.getValue(),set:s=>e.set(!!s,{silent:!0}),focus:()=>e.el.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var se=class extends y{static cssName="value-list";static defaults={values:[],placeholder:"",deletable:!0,sortable:!0,unique:!0,validate:null};render(){let t=this.el??l("div");this._ownedNodes=[],this._disabled=!1,this._dragIndex=-1,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled"),this._values=Fs(this.options.values,!!this.options.unique);let e=v("zx-value-list-instructions");return this._list=l("ul",{class:"zx-value-list__list",role:"listbox",ariaLabel:"Values",ariaOrientation:"horizontal"}),this._input=l("input",{class:"zx-value-list__input",type:"text",placeholder:String(this.options.placeholder??""),ariaLabel:"Add value",ariaDescribedby:e}),this._status=l("div",{class:"zx-value-list__status",role:"status",ariaLive:"polite"}),this._instructions=l("span",{class:"zx-value-list__instructions",id:e},"Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder."),this._ownedNodes.push(this._list,this._input,this._status,this._instructions),t.append(this._list,this._input,this._status,this._instructions),this.listen(this._input,"keydown",s=>this._handleInputKeydown(s)),this.listen(this._list,"keydown",s=>this._handleChipKeydown(s)),this.listen(this._list,"click",s=>this._handleChipClick(s)),this.listen(this._list,"dragstart",s=>this._handleDragStart(s)),this.listen(this._list,"dragover",s=>{this._dragIndex>=0&&!this._disabled&&s.preventDefault()}),this.listen(this._list,"drop",s=>this._handleDrop(s)),this.listen(this._list,"dragend",()=>this._finishDrag()),this.listen(t,"click",s=>{s.target===t&&!this._disabled&&this.focus()}),this._renderChips(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=Fs(t,!!this.options.unique),this._renderChips(),e||this.emit("change",{values:this.getValues()}),this}addValue(t){if(this._disabled)return!1;let e=String(t??"").trim();if(!e)return!1;if(this.options.unique&&this._values.includes(e))return this._showError("This value already exists."),!1;if(typeof this.options.validate=="function"){let s=this.options.validate(e);if(s!==!0)return this._showError(typeof s=="string"?s:"This value is not valid."),!1}return this._status.textContent="",this._input.removeAttribute("aria-invalid"),this._values.push(e),this._renderChips(),this.emit("add",{value:e}),this.emit("change",{values:this.getValues()}),!0}removeValue(t){if(this._disabled||!this.options.deletable)return!1;let e=this._values.indexOf(String(t));return e<0?!1:(this._removeAt(e),!0)}focus(){return this._input.focus(),this}enable(){return this._disabled=!1,this._input.disabled=!1,this.el.dataset.disabled="false",this._renderChips(),this}disable(){return this._disabled=!0,this._input.disabled=!0,this.el.dataset.disabled="true",this._renderChips(),this}_renderChips(t=-1){let e=this._values.map((s,n)=>l("li",{class:"zx-value-list__chip",role:"option",tabIndex:this._disabled?-1:0,draggable:!!this.options.sortable&&!this._disabled,ariaSelected:"false",ariaDisabled:String(this._disabled),ariaLabel:this.options.deletable?`${s}. Press Delete to remove.`:s,dataset:{index:n}},l("span",{class:"zx-value-list__value"},s),this.options.deletable?l("span",{class:"zx-value-list__remove",dataset:{remove:""},ariaHidden:"true"},"\xD7"):null));this._list.replaceChildren(...e),t>=0&&e[Math.min(t,e.length-1)]?.focus()}_handleInputKeydown(t){this._disabled||(t.key==="Enter"?(t.preventDefault(),this.addValue(this._input.value)&&(this._input.value="")):t.key==="Backspace"&&this._input.value===""&&this._values.length&&this.options.deletable&&(t.preventDefault(),this._removeAt(this._values.length-1)))}_handleChipKeydown(t){if(this._disabled)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e)return;let s=Number(e.dataset.index);if((t.key==="Delete"||t.key==="Backspace")&&this.options.deletable){t.preventDefault(),this._removeAt(s,Math.min(s,this._values.length-2));return}let n=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0,r=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0,o=n||r;if(!o)return;t.preventDefault();let a=Math.max(0,Math.min(this._values.length-1,s+o));t.ctrlKey&&n&&this.options.sortable?this._move(s,a,!0):this._list.querySelector(`[data-index="${a}"]`)?.focus()}_handleChipClick(t){let e=t.target instanceof Element?t.target:null,s=e?.closest("[data-index]");!s||this._disabled||(e.closest("[data-remove]")&&this.options.deletable?this._removeAt(Number(s.dataset.index)):s.focus())}_handleDragStart(t){if(this._disabled||!this.options.sortable)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;e&&(this._dragIndex=Number(e.dataset.index),this.el.dataset.state="dragging",t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"))}_handleDrop(t){if(this._dragIndex<0||this._disabled)return;t.preventDefault();let e=t.target instanceof Element?t.target.closest("[data-index]"):null,s=e?Number(e.dataset.index):this._values.length-1;this._move(this._dragIndex,s,!0),this._finishDrag()}_finishDrag(){this._dragIndex=-1,this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_move(t,e,s){if(t===e||t<0||e<0||t>=this._values.length||e>=this._values.length)return;let[n]=this._values.splice(t,1);this._values.splice(e,0,n),this._renderChips(s?e:-1),this.emit("change",{values:this.getValues()})}_removeAt(t,e=-1){let[s]=this._values.splice(t,1);s!==void 0&&(this._renderChips(e),e<0&&this._values.length===0&&this._input.focus(),this.emit("remove",{value:s}),this.emit("change",{values:this.getValues()}))}_showError(t){this._status.textContent=t,this._input.setAttribute("aria-invalid","true")}destroy(){for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function Fs(i,t){if(!Array.isArray(i))return[];let e=i.map(s=>String(s));return t?[...new Set(e)]:e}function Ls(){x.register("valuelist",(i,t)=>{let e=i.own(new se(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:s.detail.values})),{el:e.el,get:()=>e.getValues(),set:s=>e.setValues(Array.isArray(s)?s:[],{silent:!0}),focus:()=>e.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var ne=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),oo=["xl","lg","md","sm"];function Os(i){let t=Number(i);if(!Number.isFinite(t))return"xs";for(let e of oo)if(t>=ne[e])return e;return"xs"}function Rs(i,t={}){if(typeof i!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in t&&!I(t.target)&&t.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let e=t.target??globalThis,s=I(e)?e:null,n=null,r=!1,o=null,a=()=>s?s.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,c=()=>{if(r)return;let f=a();if(s&&f===0)return;let p=Os(f);p!==n&&(n=p,i(n,f))};c();let u=0,h=()=>{u||r||(u=requestAnimationFrame(()=>{u=0,c()}))};return s&&typeof ResizeObserver=="function"?(o=new ResizeObserver(h),o.observe(s)):globalThis.addEventListener?.("resize",c,{passive:!0}),{current:()=>n??Os(a()),destroy:()=>{r||(r=!0,u&&cancelAnimationFrame(u),o?.disconnect(),globalThis.removeEventListener?.("resize",c))}}}var ao=0,lo=20,co=3;var js=new Map;function re(i,t={}){let e=He(i);if(e===null)return"";let{locale:s=B(),decimals:n,minDecimals:r,maxDecimals:o,group:a=!0}=t;return Pe(s,Be({decimals:n,minDecimals:r,maxDecimals:o,group:a}),e)}function Vs(i,t,e={}){let s=He(i);if(s===null)return"";let{locale:n=B(),decimals:r}=e,o=ho(t);if(o===null)return re(s,{locale:n,decimals:r});let a=Be({decimals:r,group:!0});return Pe(n,{...a,style:"currency",currency:o},s)}function Ps(i,t={}){let e=He(i);if(e===null)return"";let{locale:s=B(),decimals:n=0}=t;return Pe(s,{...Be({decimals:n,group:!0}),style:"percent"},e)}function Pe(i,t,e){let s=`${i}\0${JSON.stringify(t)}`,n=js.get(s);return n===void 0&&(n=uo(i,t),js.set(s,n)),n.format(e)}function uo(i,t){try{return new Intl.NumberFormat(i,t)}catch{try{return new Intl.NumberFormat(void 0,t)}catch{return new Intl.NumberFormat}}}function Be({decimals:i,minDecimals:t,maxDecimals:e,group:s=!0}){let n={useGrouping:s!==!1},r=qs(t??i),o=qs(e??i);return r!==null&&(n.minimumFractionDigits=r),o!==null?(n.maximumFractionDigits=o,r!==null&&r>o&&(n.minimumFractionDigits=o)):r!==null&&(n.maximumFractionDigits=Math.max(r,co)),n}function qs(i){if(i==null)return null;let t=Number(i);return Number.isFinite(t)?Math.min(lo,Math.max(ao,Math.round(t))):null}function He(i){if(i==null||i==="")return null;let t=typeof i=="number"?i:Number(i);return Number.isFinite(t)?t:null}function ho(i){if(typeof i!="string")return null;let t=i.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function fo(i,t){return String(i).localeCompare(String(t))}function po(i,t){return i-t}function mo(i,t){return i.getTime()-t.getTime()}function _o(i,t,e="asc"){let s=i==null,n=t==null;if(s||n)return s&&n?0:s?1:-1;let r;return i instanceof Date&&t instanceof Date?r=mo(i,t):typeof i=="number"&&typeof t=="number"?r=po(i,t):r=fo(i,t),e==="desc"?-r:r}function go(i,t="asc"){return(e,s)=>_o(i(e),i(s),t)}function $e(i,t,e="asc"){let s=go(t,e);return i.map((n,r)=>({row:n,index:r})).sort((n,r)=>s(n.row,r.row)||n.index-r.index).map(({row:n})=>n)}var bo=new Set(["text","number","select","date","checkbox","textarea"]),yo='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',St=class extends y{static cssName="table";static defaults={columns:[],data:[],rowId:"ID",sort:null,sortMode:"local",selectable:!1,stickyHeader:!0,responsive:!1,growing:!1,height:null,emptyText:null,rowClass:null,zebra:!0,editMode:!1,hierarchy:!1};constructor(t,e={}){super(t,e)}render(){let t=this.el===null,e=this.el??l("div");if(this.el=e,this._createdRoot=t,this._original=t?null:O(e),this._columns=Array.isArray(this.options.columns)?this.options.columns.map(s=>({...s})):[],this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._selected=new Set,this._selectionAnchorId=null,this._sort=Eo(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=Mo(this.options.editMode),this._edit=null,this._editMessage=null,this._stacked=!1,this._width=null,this._growStep=Lo(this.options.growing),this._rendered=this._growStep??1/0,this._more=null,this._rovingKey=null,this._rovingCell=null,this._rovingMatched=!1,this._hierarchy=Co(this.options.hierarchy,this._columns),this._expanded=Io(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let s of oe(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(s);return this._reconcileExpanded(),this._table=l("table",{class:"zx-table__table"}),this._hierarchy&&this._table.setAttribute("role","treegrid"),this._colgroup=l("colgroup",{class:"zx-table__columns"}),this._thead=l("thead",{class:"zx-table__head"}),this._tbody=l("tbody",{class:"zx-table__body"}),this._table.append(this._colgroup,this._thead,this._tbody),this._scroll=l("div",{class:"zx-table__scroll",dataset:{stickyHeader:String(!!this.options.stickyHeader),zebra:String(!!this.options.zebra)}},this._table),this.options.height!=null&&(this._scroll.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._editMode===!1?e.replaceChildren(this._scroll):(e.dataset.editMode=this._editMode,this._editMessage=l("div",{class:"zx-table__message",id:v("zx-table-message"),role:"status",ariaLive:"polite"}),e.replaceChildren(this._scroll,this._editMessage)),this._renderColumns(),this._renderHeader(),this._renderBody(),this._watchWidth(),this.listen(this._tbody,"click",s=>this._handleBodyClick(s)),this.listen(this._tbody,"dblclick",s=>this._handleBodyDoubleClick(s)),this._editMode!==!1&&(this.listen(this._tbody,"keydown",s=>this._handleEditKeydown(s)),this.listen(this._tbody,"focusin",s=>this._handleEditFocusIn(s)),this.listen(document,"pointerdown",s=>this._handleDocumentPointerDown(s),{capture:!0})),e}setLoading(t=!0){return t?this.el.dataset.loading="true":delete this.el.dataset.loading,this.el.setAttribute("aria-busy",String(!!t)),this}setData(t){this._rendered=this._growStep??1/0,this.setLoading(!1),$s(t),this._data=[...t],this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded();let e=this._pruneSelection();return this._renderBody(),e&&this._emitSelectionChange(),this._emitDataChange(),this}addData(t){return $s(t),this._data.push(...t),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),this._emitDataChange(),this}updateRow(t,e){let s=this._data.findIndex(r=>Object.is(this._idFor(r),t));if(s<0)return this;let n=this._selected.delete(t);return this._data[s]=e,n&&this._selected.add(this._idFor(e)),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),n&&!Object.is(t,this._idFor(e))&&this._emitSelectionChange(),this._emitDataChange(),this}removeRow(t){let e=this._data.findIndex(n=>Object.is(this._idFor(n),t));if(e<0)return this;this._data.splice(e,1),this._reconcileExpanded();let s=this._selected.delete(t);return Object.is(this._selectionAnchorId,t)&&(this._selectionAnchorId=null),this._renderBody(),s&&this._emitSelectionChange(),this._emitDataChange(),this}getRow(t){return this._data.find(e=>Object.is(this._idFor(e),t))??null}getData(){return[...this._data]}empty(){let t=this._selected.size>0;return this._data=[],this._expanded.clear(),this._selected.clear(),this._selectionAnchorId=null,this._renderBody(),t&&this._emitSelectionChange(),this._emitDataChange(),this}setSort(t,e,s={}){if(this._abortEdit({focus:!1}),!this._columns.find(o=>o.id===t))throw new RangeError(`Unknown table column: ${t}`);let r=e??(this._sort?.id===t&&this._sort.dir==="asc"?"desc":"asc");if(r!=="asc"&&r!=="desc")throw new TypeError('Table sort direction must be "asc" or "desc"');return this._sort={id:t,dir:r},this.options.sortMode==="local"&&(this._sortData(),this._renderBody()),this._syncSortHeader(),s.silent||this.emit("sort",{id:t,dir:r}),this}getSelection(){return this._data.filter(t=>this._selected.has(this._idFor(t)))}setSelection(t){if(!Array.isArray(t))throw new TypeError("Table selection must be an array of row ids");let e=new Set(this._data.map(n=>this._idFor(n))),s=new Set;if(this.options.selectable!==!1){for(let n of t)if(e.has(n)&&s.add(n),this.options.selectable==="single"&&s.size>0)break}return Fo(this._selected,s)?this:(this._selected=s,this._syncSelection(),this._emitSelectionChange(),this)}clearSelection(){return this._selected.size===0?this:(this._selected.clear(),this._selectionAnchorId=null,this._syncSelection(),this._emitSelectionChange(),this)}toggleRow(t,e={}){return this._expanded.has(t)?this.collapseRow(t,e):this.expandRow(t,e)}expandRow(t,e={}){return this._setRowExpanded(t,!0,e)}collapseRow(t,e={}){return this._setRowExpanded(t,!1,e)}expandAll(t={}){if(!this._hierarchy)return this;let s=oe(this._data,this.options.rowId,this._hierarchy.parentId).filter(n=>!this._expanded.has(n));for(let n of s)this._expanded.add(n);if(s.length&&this._renderBody(),!t.silent)for(let n of s)this._emitRowToggle(n,!0);return this}collapseAll(t={}){if(!this._hierarchy||this._expanded.size===0)return this;let e=[...this._expanded];if(this._expanded.clear(),this._renderBody(),!t.silent)for(let s of e)this._emitRowToggle(s,!1);return this}getExpanded(){return this._data.map(t=>this._idFor(t)).filter(t=>this._expanded.has(t))}startEdit(t,e){if(this._editMode===!1)return this;let s=this._columns.find(h=>h.id===e);if(!s)return this;let n=this._data.find(h=>Object.is(this._idFor(h),t));if(n===void 0||kt(s,n)===!1)return this;if(this._edit){if(Object.is(this._edit.id,t)&&this._edit.cells.has(e))return this._edit.columnId=e,this._focusEditor(e),this;if(this.commitEdit(),this._edit)return this}let r=this._data.findIndex(h=>Object.is(this._idFor(h),t));if(r<0)return this;let o=this._data[r],a=this._rowElements.get(t)?.[0];if(!a)return this;let c=this._editMode==="row"?this._columns.filter(h=>kt(h,o)!==!1):[s],u=new Map;for(let h of c){let f=Hs(a,h.id);if(!f)continue;let p=this._createEditor(f,h,o,r);p&&u.set(h.id,p)}return u.size===0?this:(this._edit={id:t,columnId:e,row:o,cells:u,tr:a},a.dataset.editing="true",this.emit("editstart",{row:o,id:t,column:s,columnId:e,value:o?.[e]}),this._focusEditor(e),this)}commitEdit(){let t=this._edit;if(!t)return this;let e=this.getRow(t.id)??t.row,s={};for(let[f,p]of t.cells)s[f]=p.read();let n=this._columns.filter(f=>t.cells.has(f.id)),r=Do(s,n,e,this._msgOr("table.invalid","Invalid value"));if(r)return this._markInvalid(r.columnId,r.message),t.columnId=r.columnId,this.emit("editinvalid",{row:e,id:t.id,column:this._columns.find(f=>f.id===r.columnId)??null,columnId:r.columnId,value:s[r.columnId],message:r.message}),this._focusEditor(r.columnId),this;this._clearInvalid();let o=zo(e,s),a=t.columnId;if(this.emit("editcommit",{row:e,id:t.id,column:this._columns.find(f=>f.id===a)??null,columnId:a,value:s[a],previous:e?.[a],changes:o}).defaultPrevented)return this;let u=this._editHasFocus(),h={...e,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(t.id,h),u&&this._focusCell(this._idFor(h),a),this}cancelEdit(){return this._abortEdit({focus:!0}),this}isEditing(){return this._edit!==null}getEditing(){return this._edit?{id:this._edit.id,columnId:this._edit.columnId}:null}_visibleData(){return this._visibleEntries().map(t=>t.row)}_projectedData(){return this._hierarchy?vo(this._data,this.options.rowId,this._hierarchy.parentId,this._expanded):this._data.map((t,e)=>({row:t,id:this._idFor(t),index:e,depth:0,hasChildren:!1,parentId:null}))}_visibleEntries(){let t=this._projectedData();return this._rendered===1/0?t:t.slice(0,this._rendered)}growBy(t){if(!this._growStep)return this;let e=Number(t)>0?Math.trunc(Number(t)):this._growStep,s=this._rendered,n=this._projectedData().length;return this._rendered=Math.min(n,this._rendered+e),this._rendered===s?this:(this._renderBody(),this.emit("grow",{rendered:this._rendered,total:n}),this)}showAll(){return this.growBy(this._projectedData().length)}getRenderedCount(){return Math.min(this._rendered,this._projectedData().length)}_syncGrowing(){if(!this._growStep)return;let t=this._projectedData().length-this.getRenderedCount();if(t<=0){this._more?.remove(),this._more=null;return}let e=this._message("table.more","Show %1 more",[t]);this._more||(this._more=l("button",{class:"zx-table__more",type:"button",onclick:()=>this.growBy()}),this.el.append(this._more)),this._more.textContent=e,this._more.setAttribute("aria-label",e)}_message(t,e,s){let n=this.msg(t,...s);return n===t?F(e,s):n}_watchWidth(){this._width?.destroy(),this._width=null;let t=this.options.responsive;!t||!(t in ne)||(this._width=Rs((e,s)=>this._setStacked(s>0&&s<ne[t]),{target:this.el}))}_setStacked(t){this._stacked!==t&&(this._stacked=t,this.el.toggleAttribute("data-stacked",t),this._applyStackedRoles(t),this.emit("stackedchange",{stacked:t}))}_applyStackedRoles(t){let e=[[this._table,this._hierarchy?"treegrid":"table"],[this._thead,"rowgroup"],[this._tbody,"rowgroup"]];for(let[s,n]of e)s&&(t?s.setAttribute("role",n):s===this._table&&this._hierarchy?s.setAttribute("role","treegrid"):s.removeAttribute("role"));for(let[s,n]of[["tr","row"],["td","cell"],["th","columnheader"]])for(let r of this._table.querySelectorAll(s))t?r.setAttribute("role",n):r.removeAttribute("role")}isStacked(){return!!this._stacked}destroy(){this._teardownEdit(),this._width?.destroy(),this._width=null,!this._restored&&!this._createdRoot&&(R(this.el,this._original),this._restored=!0),super.destroy()}_renderColumns(){let t=document.createDocumentFragment();this.options.selectable==="multi"&&t.append(l("col",{class:"zx-table__selection-column"}));let e=this._columns.map(n=>No(n.width)),s=e.reduce((n,r)=>n+r,0);this._table.dataset.layout=s>0?"fixed":"auto",this._columns.forEach((n,r)=>{let o=l("col");e[r]>0?o.style.width=`${e[r]/s*100}%`:n.width&&n.width!=="auto"&&(o.style.width=String(n.width)),t.append(o)}),this._colgroup.replaceChildren(t)}_renderHeader(){let t=l("tr",{class:"zx-table__header-row"});if(this._growStep&&t.setAttribute("aria-rowindex","1"),this.options.selectable==="multi"){this._selectAll=l("input",{class:"zx-table__checkbox zx-table__select-all",type:"checkbox",ariaLabel:"Select all rows"});let e=l("th",{class:"zx-table__selection-header",scope:"col"},this._selectAll);t.append(e),this.listen(this._selectAll,"click",()=>{if(this._selectAll.checked)for(let s of this._visibleData())this._selected.add(this._idFor(s));else for(let s of this._visibleData())this._selected.delete(this._idFor(s));this._selectionAnchorId=null,this._syncSelection(),this._emitSelectionChange()})}else this._selectAll=null;this._headers=new Map;for(let e of this._columns){let s=l("th",{scope:"col"}),n=e.align??(Ye(e)?"end":null);if(n&&(s.dataset.align=n),e.headerTitle&&(s.title=e.headerTitle),e.sortable){let r=l("button",{class:"zx-table__sort-button",type:"button"},l("span",{class:"zx-table__header-label"},e.label));this.listen(r,"click",()=>{let o=this._sort?.id===e.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(e.id,o)}),s.append(r)}else s.append(l("span",{class:"zx-table__header-label"},e.label));this._headers.set(e.id,s),t.append(s)}this._thead.replaceChildren(t),this._syncSortHeader()}_renderBody(){this._abortEdit({focus:!1});let t=document.createDocumentFragment();this._rowMeta=new WeakMap,this._rowElements=new Map,this._rovingCell=null,this._rovingMatched=!1;let e=this._projectedData();this._hierarchyMeta=new Map(e.map(s=>[s.id,s])),this._data.length===0?t.append(l("tr",{class:"zx-table__empty-row"},l("td",{class:"zx-table__empty",colspan:this._columns.length+(this.options.selectable==="multi"?1:0)},this._emptyContent()))):this._visibleEntries().forEach((s,n)=>{t.append(this._createRow(s.row,s.index,{...s,visibleIndex:n}))}),this._tbody.replaceChildren(t),this._growStep&&this._table.setAttribute("aria-rowcount",String(e.length+1)),this._syncSelectAll(),this._syncGrowing(),this._stacked&&this._applyStackedRoles(!0)}_emptyContent(){let t=this.options.emptyText;return t==null?this.msg("table.empty"):typeof t=="function"?t():t}_createRow(t,e,s){let n=this._idFor(t),r=l("tr",{dataset:{row:""}});this._growStep&&r.setAttribute("aria-rowindex",String(s.visibleIndex+2));let o=typeof this.options.rowClass=="function"?this.options.rowClass(t):"";o&&r.classList.add(...String(o).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&r.setAttribute("aria-selected",String(this._selected.has(n))),this._hierarchy&&(r.setAttribute("aria-level",String(s.depth+1)),s.hasChildren&&r.setAttribute("aria-expanded",String(this._expanded.has(n)))),this._rowMeta.set(r,{row:t,id:n,index:e,visibleIndex:s.visibleIndex});let a=this._rowElements.get(n)??[];if(a.push(r),this._rowElements.set(n,a),this.options.selectable==="multi"){let c=l("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",checked:this._selected.has(n),ariaLabel:`Select row ${e+1}`});r.append(l("td",{class:"zx-table__selection-cell"},c))}return this._columns.forEach(c=>{let u=l("td"),h=c.align??(Ye(c)?"end":null);h&&(u.dataset.align=h),u.dataset.label=c.label,c.popin===!1&&(u.dataset.popin="false"),this._editMode!==!1&&(u.dataset.column=c.id,kt(c,t)!==!1&&(u.dataset.editable="true",u.tabIndex=-1,this._offerRovingCell(u,n,c.id))),this._renderCellContent(u,c,t,e,s),r.append(u)}),r}_renderCellContent(t,e,s,n,r=this._hierarchyMeta?.get(this._idFor(s))){let o=xo(e,s,n),a=l("span",{class:"zx-table__cell-content"});if(o&&typeof o=="object"&&typeof o.nodeType=="number"?a.append(o):o!=null&&a.append(document.createTextNode(String(o))),!this._hierarchy||e.id!==this._hierarchy.column||!r){t.replaceChildren(...a.childNodes);return}let c=l("span",{class:"zx-table__tree-cell"});if(c.style.setProperty("--zx-table-depth",String(r.depth)),r.hasChildren){let u=this._expanded.has(r.id);c.append(l("button",{class:"zx-table__tree-toggle",type:"button",ariaExpanded:String(u),ariaLabel:`${u?"Collapse":"Expand"} row ${n+1}`},_(u?"chevron-down":"chevron-right",{size:14})))}else c.append(l("span",{class:"zx-table__tree-spacer",ariaHidden:"true"}));c.append(a),t.replaceChildren(c)}_handleBodyClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(this._edit&&ae(e))return;let s=e?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s);if(!n||this._edit&&(this.commitEdit(),this._edit))return;if(e.closest(".zx-table__tree-toggle")){this.toggleRow(n.id);return}let o=e.closest(".zx-table__row-checkbox");if(o&&this.options.selectable==="multi"){this._toggleMultiSelection(n,o.checked,t.shiftKey);return}this.emit("rowclick",{...n,event:t}),this.options.selectable==="single"&&!this._selected.has(n.id)&&(this._selected=new Set([n.id]),this._selectionAnchorId=n.id,this._syncSelection(),this._emitSelectionChange())}_handleBodyDoubleClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(e?.closest(".zx-table__row-checkbox")||this._edit&&ae(e))return;let s=e?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s);if(n){if(this._editMode!==!1){let r=e?.closest('td[data-editable="true"]');if(r&&this._tbody.contains(r)){this.startEdit(n.id,String(r.dataset.column));return}}this.emit("rowdblclick",{...n,event:t})}}_createEditor(t,e,s,n){let r=kt(e,s);if(r===!1)return null;let o=s?.[e.id],a=e.editorProps&&typeof e.editorProps=="object"?e.editorProps:{},c=l("span",{class:"zx-table__cell-shadow",ariaHidden:"true"});c.append(...t.childNodes);let u=l("div",{class:"zx-table__editor",dataset:{editor:r}});t.replaceChildren(c,u),t.dataset.editing="true";let h={column:e,type:r,td:t,host:u,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(r==="custom"){h.custom=o,h.read=()=>it(e,h.custom,s);let d={value:o,row:s,column:e,commit:g=>{h.custom=g,this.commitEdit()},cancel:()=>this.cancelEdit()},m=e.editor(s,d);return m&&typeof m.toElement=="function"?(typeof m.destroy=="function"&&(h.component=m),u.append(m.toElement())):m&&u.append(m),h.control=u.querySelector(yo)??u,h}if(r==="number"){let d=st(e.locale,s),m=Ys(e,s),g=e.type==="currency"?st(e.currency,s):e.type==="unit"?st(e.unit,s):null,b={...d!=null&&!Object.prototype.hasOwnProperty.call(a,"locale")?{locale:d}:{},...m!=null&&!Object.prototype.hasOwnProperty.call(a,"precision")?{precision:m}:{},...g!=null&&!Object.prototype.hasOwnProperty.call(a,"unit")?{unit:String(g)}:{}},k=new ut(null,{...b,...a,value:o??null});return u.append(k.el),h.component=k,h.control=k.getInput(),h.read=()=>(k.set(k.getInput().value,{silent:!0}),it(e,k.get(),s)),h}if(r==="select"){let d=ko(e.options,s),m=d.find(b=>Object.is(b.value,o))??d.find(b=>String(b.value)===String(o??"")),g=new M(null,{...a,items:d,valueKey:"value",labelKey:"label",value:m?m.value:null});return u.append(g.el),h.component=g,h.control=g.refs.input,h.read=()=>it(e,g.value,s),h}if(r==="date"){let d=new tt(null,{...a,value:o??null});u.append(d.el),h.component=d;let m=d.refs.input;return h.control=m,h.read=()=>{let g=String(m.value??"").trim(),b=d.get();return g===""?it(e,null,s):(d.set(g,{silent:!0}),d.get()===null&&d.set(b,{silent:!0}),it(e,d.get(),s))},h}if(r==="checkbox"){let d=new ht(null,{...a,checked:!!o});return u.append(d.el),h.component=d,h.control=d.el,h.read=()=>it(e,d.get(),s),h}let f=r==="textarea",p=l(f?"textarea":"input",{...a,class:f?"zx-table__editor-input zx-table__editor-textarea":"zx-table__editor-input",...f?{}:{type:"text"},ariaLabel:a.ariaLabel??`${e.label} row ${n+1}`,value:So(e,o,s)});return u.append(p),h.control=p,h.read=()=>it(e,p.value,s),h}_focusEditor(t){let e=this._edit?.cells.get(t),s=e?.control;!s||typeof s.focus!="function"||(s.focus(),e.type==="text"&&typeof s.select=="function"&&s.select())}_focusCell(t,e){let s=this._rowElements.get(t)?.[0];(s?Hs(s,e):null)?.focus()}_teardownEdit(){let t=this._edit;if(!t)return;this._edit=null;let e=this._data.findIndex(n=>Object.is(this._idFor(n),t.id)),s=e<0?t.row:this._data[e];for(let n of t.cells.values())n.destroy(),delete n.td.dataset.editing,delete n.td.dataset.invalid,this._renderCellContent(n.td,n.column,s,e<0?0:e);t.cells.clear(),delete t.tr.dataset.editing,this._clearInvalid()}_abortEdit({focus:t=!0}={}){let e=this._edit;if(!e)return;let s=t&&this._editHasFocus(),n=this.getRow(e.id)??e.row,r=this._columns.find(o=>o.id===e.columnId)??null;this._teardownEdit(),s&&this._focusCell(e.id,e.columnId),this.emit("editcancel",{row:n,id:e.id,column:r,columnId:e.columnId})}_editHasFocus(){let t=document.activeElement;return!!(t&&this.el?.contains(t))}_markInvalid(t,e){this._clearInvalid();let s=this._edit?.cells.get(t);s&&(s.td.dataset.invalid="true",s.control?.setAttribute("aria-invalid","true"),this._editMessage&&(s.control?.setAttribute("aria-describedby",this._editMessage.id),this._editMessage.textContent=e))}_clearInvalid(){if(this._edit)for(let t of this._edit.cells.values())delete t.td.dataset.invalid,t.control?.removeAttribute("aria-invalid"),t.control?.removeAttribute("aria-describedby");this._editMessage&&(this._editMessage.textContent="")}_handleEditKeydown(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(!e)return;if(this._edit&&ae(e)){if(To(e))return;if(t.key==="Escape"){if(t.defaultPrevented)return;t.preventDefault(),this.cancelEdit();return}if(t.key==="Enter"){if(e.localName==="textarea"&&t.shiftKey)return;t.preventDefault(),this.commitEdit();return}t.key==="Tab"&&this._moveEdit(t);return}if(t.key!=="Enter"&&t.key!=="F2")return;let s=e.closest('td[data-editable="true"]');if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s.parentElement);n&&(t.preventDefault(),this.startEdit(n.id,String(s.dataset.column)))}_moveEdit(t){let e=this._edit;if(!e)return;let s=t.shiftKey?-1:1,n=this._data.findIndex(o=>Object.is(this._idFor(o),e.id)),r=this._nextEditableCell(n,e.columnId,s);if(r&&Object.is(r.id,e.id)&&e.cells.has(r.columnId)){t.preventDefault(),e.columnId=r.columnId,this._focusEditor(r.columnId);return}if(!r){this.commitEdit(),this._edit&&t.preventDefault();return}t.preventDefault(),this.commitEdit(),this._edit||this.startEdit(r.id,r.columnId)}_nextEditableCell(t,e,s){let n=this._columns.length;if(t<0||n===0)return null;let r=this._visibleData(),o=this._idFor(this._data[t]),a=r.findIndex(h=>Object.is(this._idFor(h),o));if(a<0)return null;let c=this._columns.findIndex(h=>h.id===e),u=r.length*n+n;for(let h=0;h<u;h+=1){if(c+=s,c>=n?(a+=1,c=0):c<0&&(a-=1,c=n-1),a<0||a>=r.length)return null;let f=r[a],p=this._columns[c];if(kt(p,f)!==!1)return{id:this._idFor(f),columnId:p.id,index:this._data.indexOf(f)}}return null}_handleEditFocusIn(t){let s=(t.target?.nodeType===1?t.target:null)?.closest('td[data-editable="true"]');if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s.parentElement);n&&this._setRovingCell(s,n.id,String(s.dataset.column))}_handleDocumentPointerDown(t){if(!this._edit)return;let e=t.target?.nodeType===1?t.target:t.target?.parentElement;e&&ae(e)||e&&this._tbody.contains(e)||this.commitEdit()}_offerRovingCell(t,e,s){if(this._rovingMatched)return;let n=this._rovingKey!==null&&Object.is(this._rovingKey.id,e)&&this._rovingKey.columnId===s;!n&&this._rovingCell||(n&&this._rovingCell&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=n)}_setRovingCell(t,e,s){this._rovingCell&&this._rovingCell!==t&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=!0,this._rovingKey={id:e,columnId:s}}_msgOr(t,e){let s=this.msg(t);return s===t?e:s}_toggleMultiSelection(t,e,s){let n=this._visibleData(),r=n.findIndex(o=>Object.is(this._idFor(o),this._selectionAnchorId));if(s&&r>=0){let o=t.visibleIndex??n.findIndex(u=>Object.is(this._idFor(u),t.id)),a=Math.min(r,o),c=Math.max(r,o);for(let u=a;u<=c;u+=1){let h=this._idFor(n[u]);e?this._selected.add(h):this._selected.delete(h)}}else e?this._selected.add(t.id):this._selected.delete(t.id);this._selectionAnchorId=t.id,this._syncSelection(),this._emitSelectionChange()}_syncSelection(){for(let[t,e]of this._rowElements){let s=this._selected.has(t);for(let n of e){n.setAttribute("aria-selected",String(s));let r=n.querySelector(".zx-table__row-checkbox");r&&(r.checked=s)}}this._syncSelectAll()}_syncSelectAll(){if(!this._selectAll)return;let t=this._visibleData(),e=t.reduce((s,n)=>s+Number(this._selected.has(this._idFor(n))),0);this._selectAll.disabled=t.length===0,this._selectAll.checked=t.length>0&&e===t.length,this._selectAll.indeterminate=e>0&&e<t.length}_syncSortHeader(){if(this._headers)for(let[t,e]of this._headers)this._sort?.id===t?e.setAttribute("aria-sort",this._sort.dir==="asc"?"ascending":"descending"):e.removeAttribute("aria-sort")}_sortData(){if(!this._sort)return;let t=this._columns.find(s=>s.id===this._sort.id);if(!t)return;let e=typeof t.sortValue=="function"?t.sortValue:s=>s?.[t.id];this._data=this._hierarchy?wo(this._data,this.options.rowId,this._hierarchy.parentId,e,this._sort.dir):$e(this._data,e,this._sort.dir)}_setRowExpanded(t,e,s){return this._hierarchy?oe(this._data,this.options.rowId,this._hierarchy.parentId).some(r=>Object.is(r,t))?this._expanded.has(t)===e?this:(e?this._expanded.add(t):this._expanded.delete(t),this._renderBody(),s.silent||this._emitRowToggle(t,e),this):this:this}_emitRowToggle(t,e){let s=this.getRow(t);s&&this.emit("rowtoggle",{row:s,id:t,expanded:e})}_reconcileExpanded(){if(!this._hierarchy){this._expanded.clear();return}let t=oe(this._data,this.options.rowId,this._hierarchy.parentId),e=new Set(t);for(let s of this._expanded)e.has(s)||this._expanded.delete(s)}_pruneSelection(){let t=new Set(this._data.map(s=>this._idFor(s))),e=this._selected.size;for(let s of this._selected)t.has(s)||this._selected.delete(s);return t.has(this._selectionAnchorId)||(this._selectionAnchorId=null),e!==this._selected.size}_idFor(t){return typeof this.options.rowId=="function"?this.options.rowId(t):t?.[this.options.rowId]}_emitSelectionChange(){let t=this.getSelection();this.emit("selectionchange",{rows:t,ids:t.map(e=>this._idFor(e))})}_emitDataChange(){this.emit("datachange",{rows:this.getData()})}};function xo(i,t,e=0){if(typeof i?.render=="function")return i.render(t,e);let s=t?.[i?.id],n=i?.type??"text";if(n==="text")return s;let r=st(i.locale,t),o=Ys(i,t),a={...r!=null?{locale:String(r)}:{},...o!=null?{decimals:o}:{}};if(n==="number")return re(s,a);if(n==="currency"){let c=st(i.currency,t);return Vs(s,c==null?null:String(c),a)}if(n==="percent")return Ps(s,a);if(n==="unit"){let c=re(s,a),u=st(i.unit,t);return c&&u!=null&&String(u)!==""?`${c}\xA0${u}`:c}return s}function vo(i,t,e,s=[]){let n=Ke(i,t,e),r=s instanceof Set?s:new Set(s),o=[],a=n.roots.slice().reverse().map(c=>({node:c,depth:0}));for(;a.length;){let{node:c,depth:u}=a.pop();if(o.push({row:c.row,id:c.id,index:c.index,depth:u,hasChildren:c.children.length>0,parentId:c.parent?.id??null}),!!r.has(c.id))for(let h=c.children.length-1;h>=0;h-=1)a.push({node:c.children[h],depth:u+1})}return o}function wo(i,t,e,s,n){let r=Ke(i,t,e),o=u=>$e(u,h=>s(h.row),n),a=[],c=o(r.roots).reverse();for(;c.length;){let u=c.pop();a.push(u.row);let h=o(u.children);for(let f=h.length-1;f>=0;f-=1)c.push(h[f])}return a}function kt(i,t){if(!i||typeof i!="object")return!1;if(typeof i.editor=="function")return typeof i.editable=="function"&&i.editable(t)===!1?!1:"custom";let e=typeof i.editable=="function"?i.editable(t):i.editable;return e===!0?Ye(i)?"number":"text":typeof e=="string"&&bo.has(e)?e:!1}function ko(i,t){let e=typeof i=="function"?i(t):i;return Array.isArray(e)?e.map(s=>s!==null&&typeof s=="object"?{value:s.value,label:String(s.label??s.value??"")}:{value:s,label:String(s??"")}):e!==null&&typeof e=="object"?Object.entries(e).map(([s,n])=>({value:s,label:String(n??"")})):[]}function So(i,t,e){if(typeof i?.format=="function"){let s=i.format(t,e);return s==null?"":String(s)}return t==null?"":String(t)}function it(i,t,e){return typeof i?.parse=="function"?i.parse(t,e):t}function Ao(i,t){return Object.is(i,t)?!0:i instanceof Date&&t instanceof Date?i.getTime()===t.getTime():!1}function zo(i,t){let e={};for(let[s,n]of Object.entries(t??{}))Ao(i?.[s],n)||(e[s]=n);return e}function Do(i,t,e,s="Invalid value"){for(let n of t??[]){if(typeof n?.validate!="function"||!Object.prototype.hasOwnProperty.call(i??{},n.id))continue;let r=n.validate(i[n.id],e);if(typeof r=="string")return{columnId:n.id,message:r};if(r===!1)return{columnId:n.id,message:s}}return null}function st(i,t){return typeof i=="function"?i(t):i}function Ys(i,t){let e=st(i?.decimals,t);if(e==null)return null;let s=Number(e);return Number.isFinite(s)?Math.max(0,Math.trunc(s)):null}function Ye(i){return["number","currency","percent","unit"].includes(i?.type)}function Ke(i,t,e){let s=(Array.isArray(i)?i:[]).map((a,c)=>({row:a,id:Bs(t,a),index:c,parent:null,children:[]})),n=new Map;for(let a of s)n.has(a.id)||n.set(a.id,a);let r=new Map;for(let a of s){let c=n.get(Bs(e,a.row))??null;r.set(a,c===a?null:c)}for(let a of s){let c=new Set([a]),u=r.get(a)??null;for(;u;){if(c.has(u)){r.set(u,null);break}c.add(u),u=r.get(u)??null}}let o=[];for(let a of s)a.parent=r.get(a)??null,a.parent?a.parent.children.push(a):o.push(a);return{roots:o,nodes:s}}function oe(i,t,e){return Ke(i,t,e).nodes.filter(s=>s.children.length>0).map(s=>s.id)}function Bs(i,t){return typeof i=="function"?i(t):t?.[i]}function Co(i,t){if(!i||typeof i!="object")return null;let e=i.parentId;if(typeof e!="string"&&typeof e!="function")return null;let s=typeof i.column=="string"?i.column:null,n=t.some(r=>r.id===s)?s:t[0]?.id;return n?{...i,parentId:e,column:n}:null}function Io(i){return new Set(Array.isArray(i)?i:[])}function Mo(i){return i==="cell"||i==="row"?i:i===!0?"cell":!1}function ae(i){return!!i?.closest?.(".zx-table__editor")}function To(i){return i.closest("[popover]")?!0:i.getAttribute?.("aria-expanded")==="true"}function Hs(i,t){for(let e of i.cells)if(e.dataset.column===t)return e;return null}function Eo(i,t){return!i||typeof i!="object"||!t.some(e=>e.id===i.id)?null:{id:i.id,dir:i.dir==="desc"?"desc":"asc"}}function No(i){if(typeof i!="string")return 0;let t=/^(\d*\.?\d+)fr$/.exec(i.trim());return t?Math.max(0,Number(t[1])):0}function $s(i){if(!Array.isArray(i))throw new TypeError("Table data must be an array")}function Fo(i,t){return i.size===t.size&&[...i].every(e=>t.has(e))}function Lo(i){let t=Math.trunc(Number(i));return Number.isFinite(t)&&t>0?t:null}var ue=class extends y{static cssName="launcher";static defaults={items:[],sources:[],query:"",debounce:250,minQuery:0,maxResults:100,placeholder:"Search applications and records",label:"Launcher",closeLabel:"Close launcher",resultsLabel:"Launcher results",emptyText:"No results",loadingText:"Searching\u2026",shortcut:"mod+k",hints:{move:"Move",open:"Open",close:"Close"}};constructor(t=null,e={}){super(t,e)}render(){if(this.el!==null&&!(this.el instanceof HTMLDialogElement))throw new TypeError("Launcher target must be a <dialog> element");this._createdRoot=this.el===null;let t=this.el??l("dialog");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,u=>[u.name,u.value]),children:Array.from(t.childNodes)},this._items=Ue(this.options.items),this._sources=Ws(this.options.sources),this._sourceItems=new Map,this._query=String(this.options.query??""),this._renderedQuery=null,this._results=[],this._active=-1,this._request=null,this._requestSequence=0,this._queryTimer=null,this._busy=!1,this._destroyed=!1;let e=v("zx-launcher-results"),s=l("input",{ref:"input",class:"zx-launcher__input",type:"search",role:"combobox",autocomplete:"off",spellcheck:!1,ariaAutocomplete:"list",ariaControls:e,ariaExpanded:"false",ariaLabel:this.options.label,placeholder:this.options.placeholder,value:this._query}),n=l("button",{ref:"close",class:"zx-icon-btn zx-launcher__close",type:"button",ariaLabel:this.options.closeLabel},_("x")),r=l("div",{ref:"status",class:"zx-launcher__status",role:"status",ariaLive:"polite"}),o=l("div",{ref:"results",class:"zx-launcher__results",id:e,role:"listbox",ariaLabel:this.options.resultsLabel}),a=this.options.shortcut==="mod+k"?l("kbd",{class:"zx-launcher__shortcut",ariaHidden:"true"},Oo()):null,c=Ro(this.options.hints);return t.setAttribute("aria-label",String(this.options.label)),t.replaceChildren(l("div",{class:"zx-launcher__surface"},l("div",{class:"zx-launcher__search",dataset:{shortcut:a?"true":"false"}},_("search"),s,a,n),r,o,c)),t.dataset.state="closed",this._createdRoot&&document.body.append(t),this.listen(s,"input",()=>{this._query=s.value,this.emit("query",{query:this._query.trim()}),this._refresh()}),this.listen(s,"keydown",u=>this._onKeydown(u)),this.listen(n,"click",()=>this.close()),this.listen(o,"click",u=>{let h=u.target?.closest?.("[data-launcher-index]");!h||!o.contains(h)||this._activate(Number(h.getAttribute("data-launcher-index")),u)}),this.listen(o,"pointermove",u=>{let h=u.target?.closest?.("[data-launcher-index]");if(!h||!o.contains(h))return;let f=Number(h.getAttribute("data-launcher-index"));!Number.isInteger(f)||this._results[f]?.disabled||f===this._active||(this._active=f,this._syncActive())}),this.listen(t,"cancel",u=>{u.preventDefault(),this.close()}),this.listen(t,"close",()=>{t.dataset.state="closed",s.setAttribute("aria-expanded","false"),this._abortRequest(),this.emit("close")}),this.listen(document,"keydown",u=>this._onDocumentKeydown(u)),this._renderResults(),t}open(){return this.isOpen()||this._destroyed?this:(this.el.showModal(),this.el.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this._refresh(),queueMicrotask(()=>{this.isOpen()&&(this.refs.input.focus(),this.refs.input.select())}),this.emit("open"),this)}close(){return this.isOpen()&&this.el.close(),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return!!this.el.open}focus(){return this.refs.input.focus(),this.refs.input.select(),this}setQuery(t){return this._query=String(t??""),this.refs.input.value=this._query,this.emit("query",{query:this._query.trim()}),this._refresh(),this}getQuery(){return this._query}setItems(t){return this._items=Ue(t),this._renderResults(),this}setCurrent(t){let e=t==null?null:String(t);return this._items=this._items.map(s=>({...s,current:e!==null&&String(s.id)===e})),this._renderResults(),this}setSources(t){return this._abortRequest(),this._sources=Ws(t),this._sourceItems.clear(),this._refresh(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this._original;if(this._abortRequest(),this.isOpen()&&this.el.close(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_refresh(){if(this._sourceItems.clear(),this._renderResults(),this._abortRequest(),this._sources.length===0)return;let t=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>this._loadSources(),t)}async _loadSources(){this._queryTimer=null;let t=this._query.trim(),e=this._sources.filter(r=>le(r.when,t)&&t.length>=Math.max(Number(this.options.minQuery)||0,Number(r.minQuery)||0));if(e.length===0)return;let s=new AbortController,n=++this._requestSequence;this._request=s,this._setBusy(!0),await Promise.all(e.map(async r=>{try{let o=await r.load(t,{signal:s.signal});if(s.signal.aborted||n!==this._requestSequence)return;this._sourceItems.set(r.id,Ue(o).map((a,c)=>({...a,_source:r.id,_sourceOrder:r.order==="source",group:a.group??r.label??"",itemOrder:a.itemOrder??(r.order==="source"?c:void 0)}))),this._renderResults()}catch(o){if(s.signal.aborted||n!==this._requestSequence)return;this.emit("error",{source:r,error:o})}})),!(s.signal.aborted||n!==this._requestSequence)&&(this._request=null,this._setBusy(!1))}_setBusy(t){this._busy=t,this.el.setAttribute("aria-busy",String(t)),this._renderStatus()}_abortRequest(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._request?.abort(),this._request=null,this._requestSequence+=1,this._busy&&this._setBusy(!1)}_renderResults(){let t=this._query,e=this._renderedQuery===t&&this._active>=0&&this._results[this._active]?String(this._results[this._active].id):null,s=this._query.trim(),n=this._items.filter(d=>le(d.when,s)),r=Ks(n,s,this.options.maxResults),o=this._sources.flatMap(d=>{let m=this._sourceItems.get(String(d.id))??[];return d.order==="source"?m.filter(g=>le(g.when,s)):Ks(m.filter(g=>le(g.when,s)),s,this.options.maxResults)}),a=new Set,c=[...r.map(d=>({...d,_source:null})),...o].filter(d=>{let m=String(d.id);return a.has(m)?!1:(a.add(m),!0)}).slice(0,Math.max(0,Number(this.options.maxResults)||0)),u=new Map;for(let d of c){let m=String(d.group??"");u.has(m)||u.set(m,[]),u.get(m).push(d)}this._results=[...u.values()].flat(),this._renderedQuery=t;let h=e===null?-1:this._results.findIndex(d=>!d.disabled&&String(d.id)===e);this._active=h>=0?h:this._results.findIndex(d=>!d.disabled);let f=[],p=0;for(let[d,m]of u){let g=m.map(b=>this._option(b,p++));d?f.push(l("div",{class:"zx-launcher__group",role:"group",ariaLabel:d,dataset:{layout:m.every(b=>b.kind==="application")?"grid":"list"}},l("div",{class:"zx-launcher__group-label",ariaHidden:"true"},d),g)):f.push(...g)}this.refs.results.replaceChildren(...f),this._syncActive(),this._renderStatus()}_option(t,e){let s=be(t.href),n=s?"a":"button",r=[],o=jo(t);return o&&r.push(l("span",{class:"zx-launcher__icon",ariaHidden:"true"},o)),r.push(l("span",{class:"zx-launcher__copy"},l("span",{class:"zx-launcher__label"},t.label),t.description?l("span",{class:"zx-launcher__description"},t.description):null)),t.badge!=null&&r.push(l("span",{class:"zx-launcher__badge"},String(t.badge))),l(n,{class:"zx-launcher__option",type:n==="button"?"button":null,href:s,target:t.target??null,rel:n==="a"?"noopener":null,role:"option",id:v("zx-launcher-option"),tabIndex:-1,ariaSelected:"false",ariaDisabled:t.disabled?"true":null,ariaCurrent:t.current?"page":null,dataset:{launcherIndex:e,pinned:t.pinned!==void 0&&t.pinned!==!1?"true":null,kind:qo(t.kind)}},r)}_renderStatus(){this._busy?this.refs.status.textContent=String(this.options.loadingText):this._results.length===0?this.refs.status.textContent=String(this.options.emptyText):this.refs.status.textContent="",this.refs.status.hidden=!this.refs.status.textContent}_syncActive(){let t=[...this.refs.results.querySelectorAll("[data-launcher-index]")];for(let s of t){let n=Number(s.getAttribute("data-launcher-index"))===this._active;s.setAttribute("aria-selected",String(n))}let e=t.find(s=>Number(s.getAttribute("data-launcher-index"))===this._active);e?this.refs.input.setAttribute("aria-activedescendant",e.id):this.refs.input.removeAttribute("aria-activedescendant")}_onKeydown(t){if(t.key==="Escape"){this.close();return}if(t.key==="Enter"){if(this._active<0)return;t.preventDefault(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.click();return}let e=this._results.map((n,r)=>n.disabled?-1:r).filter(n=>n>=0);if(e.length===0)return;if(/^Arrow(?:Left|Right|Up|Down)$/.test(t.key)){let n=this._spatialIndex(t.key,e);if(n!==null){t.preventDefault(),this._active=n,this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"});return}if(t.key==="ArrowLeft"||t.key==="ArrowRight")return}let s=e.indexOf(this._active);if(t.key==="Home"||t.key==="PageUp")s=0;else if(t.key==="End"||t.key==="PageDown")s=e.length-1;else if(t.key==="ArrowDown")s=(s+1+e.length)%e.length;else if(t.key==="ArrowUp")s=(s-1+e.length)%e.length;else return;t.preventDefault(),this._active=e[s],this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest"})}_spatialIndex(t,e){let s=this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`);if(!(s instanceof HTMLElement)||(t==="ArrowLeft"||t==="ArrowRight")&&this._results[this._active]?.kind!=="application")return null;let n=[...this.refs.results.querySelectorAll("[data-launcher-index]")].filter(o=>e.includes(Number(o.getAttribute("data-launcher-index")))&&(t!=="ArrowLeft"&&t!=="ArrowRight"||o.getAttribute("data-kind")==="application")),r=Vo(n,s,t);return r?Number(r.getAttribute("data-launcher-index")):null}_activate(t,e){let s=this._results[t];if(!s||s.disabled){e.preventDefault();return}if(this.emit("select",{item:s,value:s.value??s.id,source:s._source??null,query:this._query.trim()}).defaultPrevented){e.preventDefault();return}s.href||(e.preventDefault(),s.invoke?.()),this.close()}_onDocumentKeydown(t){if(this.options.shortcut!=="mod+k"||t.isComposing||t.key.toLowerCase()!=="k"||Number(t.metaKey)+Number(t.ctrlKey)!==1||t.altKey||t.shiftKey)return;let e=document.activeElement;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)return;let s=document.querySelector("dialog:modal");s&&s!==this.el||(t.preventDefault(),this.open())}};function Oo(){let i=String(navigator.userAgentData?.platform??navigator.platform??"");return/mac|iphone|ipad/i.test(i)?"\u2318 K":"Ctrl K"}function Ro(i){if(i===!1)return null;let t=i&&typeof i=="object"?i:{};return l("footer",{class:"zx-launcher__hints",ariaHidden:"true"},l("span",{},l("kbd",{},"\u2191\u2193\u2190\u2192"),t.move??"Move"),l("span",{},l("kbd",{},"\u21B5"),t.open??"Open"),l("span",{},l("kbd",{},"Esc"),t.close??"Close"))}function jo(i){let t=i.icon;if(typeof t=="function"&&(t=t(i)),typeof t=="string")return _(t);if(t instanceof Node)return t.cloneNode(!0);if(t&&typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();return e instanceof Node?e.cloneNode(!0):null}return null}function qo(i){return i==="application"||i==="record"?i:"action"}function le(i,t){return i==="empty"?t==="":i==="query"?t!=="":!0}function Vo(i,t,e){let s=t.getBoundingClientRect();if(s.width===0&&s.height===0)return null;let n=s.left+s.width/2,r=s.top+s.height/2,o=null,a=1/0;for(let c of i){if(c===t)continue;let u=c.getBoundingClientRect(),h=u.left+u.width/2-n,f=u.top+u.height/2-r,p=!1,d=1/0;e==="ArrowLeft"?(p=h<-2&&Math.abs(f)<Math.max(s.height,u.height)/2,d=Math.abs(h)+Math.abs(f)*4):e==="ArrowRight"?(p=h>2&&Math.abs(f)<Math.max(s.height,u.height)/2,d=Math.abs(h)+Math.abs(f)*4):e==="ArrowUp"?(p=f<-2,d=Math.abs(f)*10+Math.abs(h)):e==="ArrowDown"&&(p=f>2,d=Math.abs(f)*10+Math.abs(h)),p&&d<a&&(o=c,a=d)}return o}function Ks(i,t,e=100){let s=dt(t).trim(),n=i.map((o,a)=>({item:o,order:a,score:Po(o,s)})).filter(({score:o})=>o<1/0);n.sort((o,a)=>{let c=ce(o.item.groupOrder),u=ce(a.item.groupOrder);if(c!==u)return c-u;if(s===""){let h=Us(o.item.pinned,o.order),f=Us(a.item.pinned,a.order);if(h!==f)return h-f}return o.score-a.score||ce(o.item.itemOrder)-ce(a.item.itemOrder)||Bo(o.item.label,a.item.label)||o.order-a.order});let r=Math.max(0,Number(e)||0);return n.slice(0,r||0).map(({item:o,score:a})=>({...o,_score:a}))}function Po(i,t){if(!t)return i.pinned?-1:0;let e=dt(i.label),s=dt(i.id),n=dt(Array.isArray(i.keywords)?i.keywords.join(" "):i.keywords??"");return e===t?0:e.startsWith(t)?10:e.split(/[^\p{L}\p{N}]+/u).some(o=>o.startsWith(t))?20:e.includes(t)||n.includes(t)?30:s.includes(t)?40:e.split(/[^\p{L}\p{N}]+/u).filter(Boolean).map(o=>o[0]).join("").startsWith(t)?50:1/0}function Us(i,t){return typeof i=="number"&&Number.isFinite(i)?i:i?t:Number.MAX_SAFE_INTEGER}function ce(i){return typeof i=="number"&&Number.isFinite(i)?i:Number.MAX_SAFE_INTEGER}function dt(i){return String(i??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function Bo(i,t){let e=dt(i),s=dt(t);if(e<s)return-1;if(e>s)return 1;let n=String(i??"").normalize("NFC"),r=String(t??"").normalize("NFC");return n<r?-1:n>r?1:0}function Ue(i){return Array.isArray(i)?i.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>Ho(t)):[]}function Ho(i){let t={...i,label:String(i.label)};if(i.href==null)return t;let e=be(i.href);return e!==null?t.href=e:(delete t.href,typeof t.invoke!="function"&&(t.disabled=!0)),t}function Ws(i){return Array.isArray(i)?i.filter(t=>t&&typeof t=="object"&&t.id!=null&&typeof t.load=="function").map(t=>({...t,id:String(t.id)})):[]}var Qe=class{#t;#e=[];#i=[];#s;constructor(t=5,e=()=>{}){if(!Number.isInteger(t)||t<1)throw new RangeError("Queue limit must be positive");if(typeof e!="function")throw new TypeError("Activation callback must be a function");this.#t=t,this.#s=e}enqueue(t){return this.#e.length<this.#t?(this.#e.push(t),this.#s(t),"active"):(this.#i.push(t),"pending")}remove(t){let e=this.#i.indexOf(t);if(e!==-1)return this.#i.splice(e,1),"pending";let s=this.#e.indexOf(t);if(s===-1)return null;if(this.#e.splice(s,1),this.#i.length>0){let n=this.#i.shift();this.#e.push(n),this.#s(n)}return"active"}isActive(t){return this.#e.includes(t)}clear(){let t={active:this.#e.slice(),pending:this.#i.slice()};return this.#e.length=0,this.#i.length=0,t}get activeCount(){return this.#e.length}get pendingCount(){return this.#i.length}},nt=class i extends y{static cssName="message";static defaults={kind:"info",timeout:4e3,closable:!0,maxVisible:5};static#t=null;render(){let t=!this.el,e=this.el??l("div");return this._createdRoot=t,this._original=t?null:Zo(e),this._entries=new Set,this._queue=new Qe(Ko(this.options.maxVisible),s=>{this._activate(s)}),e.replaceChildren(),e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e}show(t,e={}){let s={kind:$o(e.kind??this.options.kind),timeout:Yo(e.timeout??this.options.timeout),closable:e.closable??!!this.options.closable},n=this._createEntry(t,s);return this._entries.add(n),this._queue.enqueue(n),{close:()=>this._close(n)}}static info(t,e={}){return this.show(t,{...e,kind:"info"})}static success(t,e={}){return this.show(t,{...e,kind:"success"})}static warning(t,e={}){return this.show(t,{...e,kind:"warning"})}static error(t,e={}){return this.show(t,{...e,kind:"error"})}static show(t,e={}){return this.#e().show(t,e)}static progress(t){return this.#e()._progress(t)}destroy(){if(!this._cleaned){this._cleaned=!0;for(let t of this._entries)We(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&Go(this.el,this._original)}}_progress(t){let e={pct:0,text:String(t)},s=this._createEntry(e.text,{kind:"info",timeout:0,closable:!1},e);this._entries.add(s),this._queue.enqueue(s);let n=!1;return{update:(r,o)=>{n||s.closed||(e.pct=Wo(r),o!==void 0&&(e.text=String(o)),he(s,e))},done:()=>{n||s.closed||(n=!0,e.pct=100,he(s,e),s.remaining=600,this._queue.isActive(s)&&this._schedule(s))},fail:r=>{n||s.closed||(n=!0,r!==void 0&&(e.text=String(r)),s.kind="error",s.node.dataset.kind="error",s.node.setAttribute("role","alert"),s.iconHost.replaceChildren(_("error",{size:18})),he(s,e),s.remaining=4e3,this._queue.isActive(s)&&this._schedule(s))}}}_createEntry(t,e,s=null){let n=l("span",{class:"zx-message__icon",ariaHidden:"true"},_(e.kind,{size:18})),r=l("div",{class:"zx-message__content"});Uo(t)?r.append(t):r.append(document.createTextNode(String(t)));let o=l("div",{class:"zx-message__toast",role:e.kind==="error"?"alert":"status",dataset:{kind:e.kind,state:"queued"}},n,r),a={node:o,content:r,iconHost:n,kind:e.kind,timeout:e.timeout,remaining:e.timeout,startedAt:0,timer:null,exitTimer:null,closed:!1,progressBar:null,progressFill:null};if(s){o.dataset.progress="";let c=l("span",{class:"zx-message__progress-fill"}),u=l("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:s.text},c);r.append(u),a.progressBar=u,a.progressFill=c,he(a,s)}if(e.closable){let c=l("button",{class:"zx-icon-btn zx-message__close",type:"button",ariaLabel:"Close message",title:"Close"},_("x",{size:14}));o.append(c),this.listen(c,"click",()=>this._close(a))}return this.listen(o,"mouseenter",()=>this._pause(a)),this.listen(o,"mouseleave",()=>this._resume(a)),a}_activate(t){t.closed||(t.node.dataset.state="open",this.el.append(t.node),this._schedule(t))}_schedule(t){t.closed||t.remaining<=0||(t.startedAt=Date.now(),t.timer=setTimeout(()=>this._close(t),t.remaining))}_pause(t){t.closed||t.timer===null||(clearTimeout(t.timer),t.timer=null,t.remaining=Math.max(0,t.remaining-(Date.now()-t.startedAt)))}_resume(t){if(!(t.closed||t.timer!==null)){if(t.remaining<=0){this._close(t);return}this._schedule(t)}}_close(t){if(t.closed)return;if(t.closed=!0,We(t),!this._queue.isActive(t)){this._queue.remove(t),t.node.remove(),this._entries.delete(t);return}if(t.node.dataset.state="closing",!Qo()){this._finish(t);return}let e=s=>{s.target===t.node&&this._finish(t)};this.listen(t.node,"animationend",e,{once:!0}),t.exitTimer=setTimeout(()=>this._finish(t),260)}_finish(t){this._entries.has(t)&&(We(t),t.node.remove(),this._entries.delete(t),this._queue.remove(t))}static#e(){if(this.#t)return this.#t;let t=l("div",{class:"zx-message-region",popover:"manual",role:"status",ariaLive:"polite"});return document.body.append(t),this.#t=new i(t),typeof t.showPopover=="function"&&t.showPopover(),this.#t}};function $o(i){return i==="danger"?"error":["success","warning","error"].includes(String(i))?i:"info"}function Yo(i){let t=Number(i);return Number.isFinite(t)?Math.max(0,t):4e3}function Ko(i){let t=Number(i);return Number.isInteger(t)&&t>0?t:5}function Uo(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function Wo(i){let t=Number(i);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function he(i,t){i.content.firstChild.textContent=t.text,i.progressBar?.setAttribute("aria-valuenow",String(t.pct)),i.progressBar?.setAttribute("aria-label",t.text),i.progressFill&&(i.progressFill.style.inlineSize=`${t.pct}%`)}function We(i){i.timer!==null&&clearTimeout(i.timer),i.exitTimer!==null&&clearTimeout(i.exitTimer),i.timer=null,i.exitTimer=null}function Qo(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function Zo(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Go(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}var At=class extends y{static cssName="fieldset";static defaults={title:"",columns:1,fields:{}};render(){let t=this.el??l("fieldset");this._fields=new Map,this._ownedFields=new Set,this._origins=new Map,this._fieldIdAttributes=new Map,this._ownedNodes=[],this._columnAttribute=t.getAttribute("data-columns");let e=[1,2,3].includes(Number(this.options.columns))?Number(this.options.columns):1;if(t.dataset.columns=String(e),this.options.title){let n=l("legend",{class:"zx-fieldset__legend"},String(this.options.title));this._ownedNodes.push(n),t.append(n)}this._grid=l("div",{class:"zx-fieldset__grid"}),this._ownedNodes.push(this._grid),t.append(this._grid);let s=this.options.fields&&typeof this.options.fields=="object"?this.options.fields:{};for(let[n,r]of Object.entries(s))this.addField(n,r);return t}addField(t,e){let s=String(t);if(this._fields.has(s))throw new Error(`Field "${s}" already exists`);let n,r=!1;if(e instanceof x)n=e;else if(I(e)||e instanceof y){let o=e;n=new x(null,{id:s,type:"custom",label:s,value:Jo(o),disabled:ta(o),adapter:()=>Xo(o)}),r=!0}else{let o=e&&typeof e=="object"?e:{};n=new x(null,{...o,id:o.id??s}),r=!0}return r?this._ownedFields.add(n):this._origins.set(n,{parent:n.el.parentNode,next:n.el.nextSibling}),this._fields.set(s,n),this._fieldIdAttributes.set(n,n.el.getAttribute("data-field-id")),n.el.dataset.fieldId=s,this._grid.append(n.el),n}getField(t){return this._fields.get(String(t))??null}hasField(t){return this._fields.has(String(t))}getFields(){return Object.fromEntries(this._fields)}getValues(){let t={};for(let[e,s]of this._fields)t[e]=s.getValue();return t}setValues(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[s,n]of Object.entries(t))this._fields.get(s)?.setValue(n,{silent:e});return this}getValue(t){return this._fields.get(String(t))?.getValue()??null}setValue(t,e){return this._fields.get(String(t))?.setValue(e),this}reset(){for(let t of this._fields.values())t.reset();return this}clear(){for(let t of[...this._fields.values()])this._releaseField(t);return this._fields.clear(),this}focus(t){return this._fields.get(String(t))?.focus(),this}setHighlights(t={},e="danger"){let s=0;for(let[n,r]of this._fields){let o=t?.[n];o?(r.setHighlight(String(o),e),s+=1):r.clearHighlight()}return s}clearHighlights(){for(let t of this._fields.values())t.clearHighlight();return this}_releaseField(t){let e=this._fieldIdAttributes.get(t);if(e==null?t.el.removeAttribute("data-field-id"):t.el.setAttribute("data-field-id",e),this._fieldIdAttributes.delete(t),this._ownedFields.has(t)){t.destroy(),this._ownedFields.delete(t);return}let s=this._origins.get(t);s?.parent?s.parent.insertBefore(t.el,s.next?.parentNode===s.parent?s.next:null):t.el.remove(),this._origins.delete(t)}destroy(){this.clear();for(let t of this._ownedNodes??[])t.remove();this._columnAttribute===null?this.el.removeAttribute("data-columns"):this.el.setAttribute("data-columns",this._columnAttribute),super.destroy()}};function Xo(i){let t=I(i)?i:i.toElement(),e=t.parentNode,s=t.nextSibling,n=new Map(["id","aria-labelledby","aria-describedby","aria-disabled","aria-invalid"].map(a=>[a,t.getAttribute(a)])),r="disabled"in t?t.disabled:void 0,o="value"in t?t.value:void 0;return{el:t,get:()=>typeof i.getValue=="function"?i.getValue():typeof i.getValues=="function"?i.getValues():"value"in t?t.value:null,set:(a,c)=>{typeof i.setValue=="function"?i.setValue(a,c):typeof i.setValues=="function"&&a&&typeof a=="object"?i.setValues(a,c):"value"in t&&(t.value=a??"")},focus:()=>{typeof i.focus=="function"?i.focus():typeof t.focus=="function"&&t.focus()},setDisabled:a=>{typeof i.setDisabled=="function"?i.setDisabled(a):"disabled"in t?t.disabled=a:t.setAttribute("aria-disabled",String(a))},destroy:()=>{for(let[a,c]of n)c===null?t.removeAttribute(a):t.setAttribute(a,c);r!==void 0&&(t.disabled=r),o!==void 0&&(t.value=o),e?e.insertBefore(t,s?.parentNode===e?s:null):t.remove()}}}function Jo(i){let t=I(i)?i:i.toElement();return typeof i.getValue=="function"?i.getValue():typeof i.getValues=="function"?i.getValues():"value"in t?t.value:null}function ta(i){let t=I(i)?i:i.toElement();return"disabled"in t?!!t.disabled:t.getAttribute("aria-disabled")==="true"}var zt=class extends y{static cssName="form";static defaults={fieldsets:[],actions:[],novalidate:!0,msg:{"form.required":"This field is required.","form.int":"Enter a whole number.","form.float":"Enter a valid number."}};render(){let t=this.el??l("form");this._fieldsets=[],this._ownedFieldsets=new Set,this._origins=new Map,this._ownedNodes=[],this._novalidateAttribute=t.getAttribute("novalidate"),t.toggleAttribute("novalidate",!!this.options.novalidate),this._body=l("div",{class:"zx-form__body"}),this._actions=l("div",{class:"zx-form__actions"}),this._ownedNodes.push(this._body,this._actions),t.append(this._body,this._actions),this.listen(t,"submit",s=>{s.preventDefault(),this.submit()}),this.listen(t,"reset",s=>{s.preventDefault(),this.reset()}),this.listen(this._actions,"click",s=>this._handleAction(s));let e=Array.isArray(this.options.fieldsets)?this.options.fieldsets:[];for(let s of e)this.addFieldset(s);return this.setActions(Array.isArray(this.options.actions)?this.options.actions:[]),t}addFieldset(t){let e=!(t instanceof At),s=e?new At(null,t??{}):t;return this._fieldsets.includes(s)||(e?this._ownedFieldsets.add(s):this._origins.set(s,{parent:s.el.parentNode,next:s.el.nextSibling}),this._fieldsets.push(s),this._body.append(s.el),this.listen(s.el,"zx-change",n=>{let r=n.target,o=r instanceof Element?r.dataset.fieldId:null;o&&this.emit("change",{id:o,value:s.getValue(o)})})),s}setActions(t){return this._actionDescriptors=Array.isArray(t)?t.map(e=>({...e})):[],this._actions.replaceChildren(...this._actionDescriptors.map((e,s)=>{let n=String(e.label??e.id??"Action");return l("button",{class:"zx-btn",type:["submit","reset"].includes(e.type)?e.type:"button",disabled:!!e.disabled,title:e.title,ariaLabel:!n&&e.title?e.title:void 0,dataset:{actionIndex:s,kind:["primary","danger","ghost"].includes(e.kind)?e.kind:"default",size:e.size==="sm"?"sm":"md"}},e.icon?_(e.icon,{size:16}):null,n?l("span",{class:"zx-btn__label"},n):null)})),this._actions.hidden=this._actionDescriptors.length===0,this}getValues(){return Object.assign({},...this._fieldsets.map(t=>t.getValues()))}setValues(t,{silent:e=!1}={}){for(let s of this._fieldsets)s.setValues(t,{silent:e});return this}getField(t){for(let e of this._fieldsets){let s=e.getField(t);if(s)return s}return null}setValue(t,e){return this.getField(t)?.setValue(e),this}getValue(t){return this.getField(t)?.getValue()??null}reset(){for(let t of this._fieldsets)t.reset().clearHighlights();return this}setHighlights(t,e="danger"){return this._fieldsets.reduce((s,n)=>s+n.setHighlights(t,e),0)}clearHighlights(){for(let t of this._fieldsets)t.clearHighlights();return this}submit(){let t={},e=null;for(let n of this._fieldsets)for(let[r,o]of Object.entries(n.getFields())){let a=o.getValue(),c="";if(o.options.required&&Ze(a))c=this.msg("form.required");else if(!Ze(a)&&o.options.type==="int"){let u=ve(a);u.valid?o.setValue(u.value,{silent:!0}):c=this.msg("form.int")}else if(!Ze(a)&&o.options.type==="float"){let u=we(a);u.valid?o.setValue(u.value,{silent:!0}):c=this.msg("form.float")}c?(t[r]=c,o.setHighlight(c,"danger"),e??=o):o.clearHighlight()}return Object.keys(t).length?(this.emit("invalid",{errors:t}),e?.focus(),!1):!this.emit("submit",{values:this.getValues()}).defaultPrevented}_handleAction(t){let e=t.target instanceof Element?t.target.closest("[data-action-index]"):null;if(!e||!this._actions.contains(e))return;let s=this._actionDescriptors[Number(e.dataset.actionIndex)],n=s?.onClick??s?.onclick??s?.handler;typeof n=="function"&&n(t,this)}destroy(){for(let t of this._fieldsets??[])if(this._ownedFieldsets.has(t))t.destroy();else{let e=this._origins.get(t);e?.parent?e.parent.insertBefore(t.el,e.next?.parentNode===e.parent?e.next:null):t.el.remove()}this._fieldsets=[];for(let t of this._ownedNodes??[])t.remove();this._novalidateAttribute===null?this.el.removeAttribute("novalidate"):this.el.setAttribute("novalidate",this._novalidateAttribute),super.destroy()}};function Ze(i){return i==null||i===""||i===!1||Array.isArray(i)&&i.length===0}function ea(){zs(),Mi(),us(),Zi(),os(),Es(),Ls(),_s(),ds(),Ns(),bs(),ys(),Is(),Ds()}ea();function Q(i,{onError:t,locale:e}={}){if(!i||typeof i!="object"||!i.api||typeof i.api!="object")throw new TypeError("connect() requires a ZeyOS client with an api namespace");if(t!=null&&typeof t!="function")throw new TypeError("onError must be a function");let s=e??ia(i);s&&xe(String(s));let n=(o,a)=>t?t(o,a):nt.error(na(o)),r=async(o,a,c)=>{let u=sa(i,o,a);try{return await i.api[u](c)}catch(h){try{n(h,{operation:u,resource:a})}catch{}throw h}};return{client:i,list:(o,a={})=>r("list",o,a),get:(o,a,c={})=>r("get",o,Qs(a)?a:{ID:a,...c}),create:(o,a)=>r("create",o,a),update:(o,a,c)=>r("update",o,c===void 0&&Qs(a)?a:{ID:a,body:c??{}}),reportError:n}}function ia(i){return i.locale??i.language??i.config?.locale??i.metadata?.locale??null}function sa(i,t,e){let s=String(e??"").trim();if(!s)throw new TypeError("ZeyOS resource must not be empty");let n=typeof i.schema?.operations=="function"?i.schema.operations(s):[];if(Array.isArray(n)&&n.length){let p=n.filter(d=>typeof d=="string"&&d.toLowerCase().startsWith(t)).sort((d,m)=>d.length-m.length);if(p.length)return p[0]}let r=Array.isArray(n)&&n.length?n:typeof i.schema?.operationIds=="function"?i.schema.operationIds():Object.keys(i.api);if(r.includes(s)&&s.toLowerCase().startsWith(t))return s;let o=Zs(s),a=Gs(o),c=r.filter(p=>{if(typeof p!="string"||!p.toLowerCase().startsWith(t))return!1;let d=Zs(p.slice(t.length));return d===o||d===a||Gs(d)===a});if(c.length)return c.sort((p,d)=>p.length-d.length)[0];let u=t==="list"?[`list${Ge(s)}`]:[`${t}${Ge(ra(s))}`,`${t}${Ge(s)}`],h=new Set(Object.keys(i.api)),f=u.find(p=>h.has(p));if(f)return f;throw new RangeError(`No ${t} operation found for ZeyOS resource "${s}"`)}function Qs(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function na(i){return i instanceof Error&&i.message||i&&typeof i=="object"&&typeof i.message=="string"?i.message:String(i??"ZeyOS request failed")}function Zs(i){return String(i).replace(/[^a-z\d]/gi,"").toLowerCase()}function Gs(i){return i.endsWith("ies")?`${i.slice(0,-3)}y`:i.endsWith("sses")?i.slice(0,-2):i.endsWith("s")&&!i.endsWith("ss")?i.slice(0,-1):i}function ra(i){let t=String(i);return/ies$/i.test(t)?`${t.slice(0,-3)}y`:/s$/i.test(t)&&!/ss$/i.test(t)?t.slice(0,-1):t}function Ge(i){return String(i).split(/[^a-z\d]+/i).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}var rt=Object.freeze({accounts:{label:"Accounts",icon:"zeyos-accounts",color:"#bc3885",fa:"building"},actionsteps:{label:"Action Steps",icon:"zeyos-actionsteps",color:"#f67f00",fa:"clock"},appointments:{label:"Appointments",icon:"zeyos-appointments",color:"#bd1e32",fa:"calendar-check"},billing:{label:"Billing",icon:"zeyos-billing",color:"#535494",fa:"file-invoice-dollar"},calendar:{label:"Calendar",icon:"zeyos-calendar",color:"#bd1e32",fa:"calendar-days"},campaigns:{label:"Campaigns",icon:"zeyos-campaigns",color:"#f16528",fa:"bullhorn"},collection:{label:"Collection",icon:"zeyos-collection",color:"#0d60ae",fa:"hand-holding-dollar"},contacts:{label:"Contacts",icon:"zeyos-contacts",color:"#8c6641",fa:"address-book"},contracts:{label:"Contracts",icon:"zeyos-contracts",color:"#823e89",fa:"file-contract"},coupons:{label:"Coupons",icon:"zeyos-coupons",color:"#10775c",fa:"ticket-simple"},devices:{label:"Devices",icon:"zeyos-devices",color:"#064e4f",fa:"desktop"},documents:{label:"Documents",icon:"zeyos-documents",color:"#808000",fa:"file"},dunning:{label:"Dunning",icon:"zeyos-dunning",color:"#0d60ae",fa:"file-invoice-dollar"},events:{label:"Events",icon:"zeyos-events",color:"#bd1e32",fa:"calendar-day"},inventory:{label:"Inventory",icon:"zeyos-inventory",color:"#064e4f",fa:"warehouse"},items:{label:"Items",icon:"zeyos-items",color:"#064e4f",fa:"box-open"},ledgers:{label:"Ledgers",icon:"zeyos-ledgers",color:"#4679c8",fa:"book-open"},line:{label:"Line Items",icon:"zeyos-line",color:"#064e4f",fa:"list-ul"},links:{label:"Links",icon:"zeyos-links",color:"#405e76",fa:"bookmark"},mailinglists:{label:"Mailing Lists",icon:"zeyos-mailinglists",color:"#0299ac",fa:"envelope-open-text"},messages:{label:"Messages",icon:"zeyos-messages",color:"#31a8e0",fa:"message"},"messages-unread":{label:"Unread Messages",icon:"zeyos-messages-unread",color:"#31a8e0",fa:"envelope"},notes:{label:"Notes",icon:"zeyos-notes",color:"#008853",fa:"note-sticky"},opportunities:{label:"Opportunities",icon:"zeyos-opportunities",color:"#7b67ae",fa:"handshake"},payments:{label:"Payments",icon:"zeyos-payments",color:"#4679c8",fa:"sack-dollar"},pricelists:{label:"Price Lists",icon:"zeyos-pricelists",color:"#10775c",fa:"clipboard-list"},procurement:{label:"Procurement",icon:"zeyos-procurement",color:"#006e9f",fa:"truck"},production:{label:"Production",icon:"zeyos-production",color:"#226375",fa:"industry"},projects:{label:"Projects",icon:"zeyos-projects",color:"#db532d",fa:"diagram-project"},stocktransactions:{label:"Stock Transactions",icon:"zeyos-stocktransactions",color:"#064e4f",fa:"arrow-right-arrow-left"},storages:{label:"Storages",icon:"zeyos-storages",color:"#064e4f",fa:"boxes-stacked"},tasks:{label:"Tasks",icon:"zeyos-tasks",color:"#e2b301",fa:"list-check"},text:{label:"Text Blocks",icon:"zeyos-text",color:"#064e4f",fa:"file-lines"},tickets:{label:"Tickets",icon:"zeyos-tickets",color:"#f04639",fa:"ticket"},"transactions-billing":{label:"Billing Transactions",icon:"zeyos-transactions-billing",color:"#535494",fa:"file-invoice"},"transactions-collection":{label:"Collection Transactions",icon:"zeyos-transactions-collection",color:"#0d60ae",fa:"money-bill-transfer"},"transactions-procurement":{label:"Procurement Transactions",icon:"zeyos-transactions-procurement",color:"#006e9f",fa:"cart-shopping"},"transactions-production":{label:"Production Transactions",icon:"zeyos-transactions-production",color:"#226375",fa:"gears"},zeyos:{label:"ZeyOS",icon:"zeyos",color:"#007a55",fa:"cloud"},default:{label:"Default",icon:"zeyos-default",color:"#21cc75",fa:"cube"},admin:{label:"Administration",icon:"zeyos-admin",color:"#4b5563",fa:"screwdriver-wrench"},applications:{label:"Applications",icon:"zeyos-applications",color:"#2563eb",fa:"window-maximize"},auth:{label:"Credentials",icon:"zeyos-auth",color:"#a16207",fa:"shield-halved"},categories:{label:"Categories",icon:"zeyos-categories",color:"#9a3412",fa:"folder-tree"},channels:{label:"Channels",icon:"zeyos-channels",color:"#0891b2",fa:"share-nodes"},control:{label:"Control Center",icon:"zeyos-control",color:"#0f766e",fa:"sliders"},davservers:{label:"DAV Servers",icon:"zeyos-davservers",color:"#475569",fa:"server"},dev:{label:"Development",icon:"zeyos-dev",color:"#1f2937",fa:"code"},error:{label:"Errors",icon:"zeyos-error",color:"#b91c1c",fa:"triangle-exclamation"},global:{label:"Global",icon:"zeyos-global",color:"#0369a1",fa:"globe"},groups:{label:"Groups",icon:"zeyos-groups",color:"#007a55",fa:"users"},logout:{label:"Logout",icon:"zeyos-logout",color:"#9f1239",fa:"right-from-bracket"},objects:{label:"Custom Objects",icon:"zeyos-objects",color:"#7e22ce",fa:"cubes"},participants:{label:"Participants",icon:"zeyos-participants",color:"#4338ca",fa:"user-group"},permissions:{label:"Permissions",icon:"zeyos-permissions",color:"#5b21b6",fa:"user-lock"},records:{label:"Records",icon:"zeyos-records",color:"#57534e",fa:"database"},resources:{label:"Resources",icon:"zeyos-resources",color:"#15803d",fa:"layer-group"},services:{label:"Services",icon:"zeyos-services",color:"#b45309",fa:"bell-concierge"},system:{label:"System",icon:"zeyos-system",color:"#374151",fa:"gear"},users:{label:"Users",icon:"zeyos-users",color:"#007a55",fa:"user"},weblets:{label:"Weblets",icon:"zeyos-weblets",color:"#4f46e5",fa:"window-restore"}}),Js=Object.freeze({main:"zeyos",addresses:"contacts",clocking:"actionsteps",comments:"notes",couponcodes:"coupons",customers:"accounts",customfields:"objects",davids:"davservers",documentversions:"documents",enhancements:"applications",extdata:"objects",feedservers:"channels",files:"documents",filters:"records",forks:"applications",imports:"records",invoices:"transactions-billing",linecoupon:"line",logins:"auth",mailservers:"channels",notifications:"messages","participants-campaigns":"participants","participants-mailinglists":"participants",prices:"pricelists",pwd:"auth",purchaseorders:"transactions-procurement",sessions:"auth",settings:"system",suppliers:"accounts",tags:"categories",tokens:"auth",transactions:"transactions-billing",usergroups:"groups",usermgmt:"users",usersettings:"system",userfields:"objects",userfilters:"records"}),Dt=Object.freeze({light:"#ffffff",dark:"#141414"}),Ct=Object.create(null);function de(i){let t=String(i??"").trim().toLowerCase().replaceAll(/[._\s]+/g,"-");if(!t)return"default";if(Object.hasOwn(Ct,t)||Object.hasOwn(rt,t))return t;let e=Js[t];return e||"default"}function $(i){let t=de(i);return Ct[t]??rt[t]??rt.default}function oa(i){return $(i).color}function aa(i,{standard:t=!1}={}){let e=$(i);return t?e.fa:e.icon}function la(){return[...new Set([...Object.keys(rt),...Object.keys(Ct)])].sort()}function ca(i){for(let[t,e]of Object.entries(i)){let s=String(t).trim().toLowerCase().replaceAll(/[._\s]+/g,"-"),n=typeof e=="string"?{color:e}:e,r=Ct[s]??rt[s]??rt.default;Ct[s]=Object.freeze({label:n.label??r.label,icon:n.icon??r.icon,color:n.color??r.color,fa:n.fa??r.fa})}}function Je(i){let t=Xe(i);if(t===null)return Dt.light;let e=Xs(t,Xe(Dt.light)??1),s=Xs(t,Xe(Dt.dark)??0);return e>=s?Dt.light:Dt.dark}function Xe(i){let t=/^#([\da-f]{3}|[\da-f]{6})$/i.exec(String(i).trim());if(!t)return null;let e=t[1].length===3?[...t[1]].map(o=>o+o).join(""):t[1],[s,n,r]=[0,2,4].map(o=>{let a=Number.parseInt(e.slice(o,o+2),16)/255;return a<=.04045?a/12.92:((a+.055)/1.055)**2.4});return .2126*s+.7152*n+.0722*r}function Xs(i,t){return(Math.max(i,t)+.05)/(Math.min(i,t)+.05)}var tn="https://kit.fontawesome.com/ae8320b210.js";function ua(i={}){return Te({kit:tn,...i})}function en(i,t={}){let{standard:e=!1,...s}=t,n=$(i);return _(e?`fa:${n.fa}`:`kit:${n.icon}`,s)}function ft(i,t={}){let{size:e=24,iconSize:s="1em",label:n=null,title:r=!1,standard:o=!1,color:a=null}=t,c=de(i),u=$(i),h=a||u.color,f=l("span",{class:["zx-module-icon",t.class].flat().filter(Boolean),dataset:{module:c},style:{"--zx-module-color":h,"--zx-module-glyph":Je(h),"--zx-module-icon-size":typeof e=="number"?`${e}px`:String(e)},title:r?u.label:null},en(i,{size:s,standard:o}));return n===null?f.setAttribute("aria-hidden","true"):(f.setAttribute("role","img"),f.setAttribute("aria-label",n)),f}var ha=Object.freeze(["accounts","actionsteps","admin","auth","billing","calendar","campaigns","collection","contacts","contracts","control","coupons","dev","documents","inventory","mailinglists","main","messages","links","notes","objects","opportunities","payments","pricelists","procurement","production","projects","tasks","tickets"]);function sn(i={},t={}){let{standardIcons:e=!1,items:s=[],sources:n=[],...r}=t,o=ei(i.labels),a={standardIcons:e,renderApplicationIcon:i.renderApplicationIcon,renderWebletIcon:i.renderWebletIcon},c=nn(i,a),u=typeof i.loadRecent=="function"?[]:fe(i.recent??[],{query:"",labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:e}),h=[];return typeof i.loadRecent=="function"&&h.push({id:"zeyos-recent",minQuery:0,when:"empty",order:"source",load:async(f,p)=>fe(await i.loadRecent(p),{query:"",labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:e})}),typeof i.search=="function"&&h.push({id:"zeyos-records",minQuery:1,when:"query",order:"source",load:async(f,p)=>fe(await i.search(f,p),{query:f,labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:e})}),h.push(...n),{...r,items:[...c,...u,...s],sources:h,hints:t.hints??{move:o.move,open:o.open,close:o.close}}}function da(i={},t={}){return new ue(null,sn(i,t))}function nn(i={},t={}){let e=ei(i.labels),s=Array.isArray(i.pinned)?i.pinned.map(String):[],n=new Set,r=[],o=(a,c=null,u=null)=>{let h=pa(a,c,u);if(!h||n.has(h.identifier)||h.type==="module"&&typeof i.canUseModule=="function"&&!i.canUseModule(h.module))return;n.add(h.identifier);let f=rn(h.raw,i.resolveApplication),p=s.indexOf(h.identifier),d=()=>(typeof t.renderApplicationIcon=="function"?t.renderApplicationIcon(h.raw,h):h.type==="weblet"&&typeof t.renderWebletIcon=="function"?t.renderWebletIcon(h.raw,h):null)??ft(h.module,{size:36,standard:!!t.standardIcons,color:h.color});r.push({id:h.identifier,label:h.label,keywords:[h.identifier,h.module],group:e.applications,groupOrder:0,kind:"application",icon:d,pinned:p>=0?p:void 0,current:h.identifier===i.activeIdentifier,disabled:!f.href&&typeof f.invoke!="function",...f,_zeyos:h})};for(let a of Array.isArray(i.menuApps)?i.menuApps:[])o(a);if(Array.isArray(i.modules))for(let a of i.modules)typeof a=="string"?o([a,$(a).label]):o(a,a?.id??a?.module,a?.label);else for(let[a,c]of Object.entries(i.modules??{}))o([a,c]);return r}function fe(i,t={}){let e=String(t.query??""),s=ei(t.labels),n=ma(i,e),r=new Map;return n.flatMap(({raw:o,group:a},c)=>{let u=_a(o,a,e);if(!u)return[];let h=e===""?s.recent:u.group===""?s.results:s.entities[u.group]??u.group;r.has(h)||r.set(h,r.size+1);let f=rn(u.raw,t.resolveRecord);return[{id:`record:${u.entity}:${u.fork??""}:${u.ID}`,label:u.name,description:u.sec,keywords:[u.entity,u.ID,u.fork??""],group:h,groupOrder:r.get(h),itemOrder:c,kind:"record",when:e===""?"empty":"query",icon:()=>(typeof t.renderRecordIcon=="function"?t.renderRecordIcon(u.raw,u):null)??ft(u.entity,{size:28,standard:!!t.standardIcons}),disabled:!f.href&&typeof f.invoke!="function",...f,_zeyos:u}]})}function fa(i={}){return i.weblet!=null&&i.weblet!==""?`weblet#${i.weblet}`:i.fork!=null&&i.fork!==""?`fork#${i.fork}`:String(i.module??"")}function pa(i,t,e){if(Array.isArray(i)){if(i.length<2)return null;if(i.length===2){let r=String(i[0]);return{raw:i,identifier:r,label:String(i[1]),module:r,type:"module",color:null}}if(i.length===4){let r=String(i[2]||"default");return{raw:i,identifier:`fork#${i[0]}`,label:String(i[1]),module:r,type:"fork",color:ti(i[3])}}return{raw:i,identifier:`weblet#${i[0]}`,label:String(i[1]),module:"weblets",type:"weblet",color:ti(i[8])}}if(!i||typeof i!="object")return null;let s=String(i.identifier??i.id??t??"");if(!s)return null;let n=s.startsWith("fork#")?"fork":s.startsWith("weblet#")?"weblet":"module";return{raw:i,identifier:s,label:String(i.label??e??$(s).label),module:String(i.module??(n==="module"?s:n==="fork"?"default":"weblets")),type:n,color:ti(i.color)}}function ma(i,t){if(Array.isArray(i))return i.map(s=>({raw:s,group:s?.group??""}));if(!i||typeof i!="object")return[];let e=[];for(let[s,n]of Object.entries(i))if(Array.isArray(n))for(let r of n){if(!Array.isArray(r)){e.push({raw:r,group:s});continue}let o=s===""&&r.length>=5?{ID:r[0],fork:r[1],name:r[2],sec:r[3],entity:r[4],group:s}:{ID:r[0],fork:r[1],name:r[2],sec:r[3],entity:s,group:s};e.push({raw:o,group:s})}return e}function _a(i,t,e){return Array.isArray(i)?e===""&&i.length>=4?{raw:i,entity:String(i[0]),ID:i[1],fork:i[2]??null,name:String(i[3]),sec:String(i[4]??""),group:""}:null:!i||typeof i!="object"||i.ID==null||i.name==null?null:{raw:i,entity:String(i.entity??t??"records"),ID:i.ID,fork:i.fork??null,name:String(i.name),sec:String(i.sec??""),group:String(i.group??t??"")}}function rn(i,t){let e=i&&typeof i=="object"&&!Array.isArray(i)?i:{},s=typeof t=="function"?t(i):null,n=s&&typeof s=="object"?s:{};return Object.fromEntries(["href","target","invoke","value"].flatMap(r=>{let o=n[r]??e[r];return o===void 0?[]:[[r,o]]}))}function ti(i){let t=String(i??"").trim();if(!t)return null;let e=t.startsWith("#")?t:`#${t}`;return/^#[\da-f]{3}(?:[\da-f]{3})?$/i.test(e)?e:null}function ei(i){let t=i&&typeof i=="object"?i:{};return{applications:String(t.applications??"Applications"),recent:String(t.recent??"Recent"),results:String(t.results??"Top results"),entities:t.entities&&typeof t.entities=="object"?t.entities:{},move:String(t.move??"Move"),open:String(t.open??"Open"),close:String(t.close??"Close")}}function It(i,t,e={}){let{fields:s,labelKey:n=un(i,t),valueKey:r="ID",searchFields:o=hn(i,t),limit:a=50,filters:c={},value:u=null,...h}=e,f=Q(i),p=s??cn(r,n,o);return{...h,valueKey:r,labelKey:n,value:u,filter:async d=>{let m=await f.list(t,ot({search:d,filters:c,fields:p,searchFields:o,limit:a}));return ii(i,m).data}}}function ga(i,t,e={}){let s=It(i,t,e),n=e.value??null,r=new M(null,s);return r.ready=ln(r,i,t,n),r}function an(i,t,e={}){let{fields:s,labelKey:n=un(i,t),valueKey:r="ID",searchFields:o=hn(i,t),subtitleKey:a=null,moduleKey:c=()=>t,groupKey:u=null,none:h=!0,create:f=!1,renderIcon:p=xa,renderItem:d,renderValueAdornment:m,...g}=e,b=s??cn(r,n,[...o,...[a,c,u].filter(A=>typeof A=="string")]),k=It(i,t,{...g,fields:b,labelKey:n,valueKey:r,searchFields:o,groupKey:u,clearable:h===!1?!!g.clearable:!0}),T=(A,N=!1)=>{if(p===null)return null;let Y=pe(A,c)??t;return p(A,{resource:t,module:String(Y),selected:N})};if(k.renderItem=d??(A=>{let N=T(A);return l("span",{class:"zx-select__entity"},N?l("span",{class:"zx-select__entity-icon",ariaHidden:"true"},N):null,l("span",{class:"zx-select__entity-copy"},l("span",{class:"zx-select__entity-label"},String(pe(A,n)??"")),a&&pe(A,a)!=null?l("span",{class:"zx-select__entity-subtitle"},String(pe(A,a))):null))}),k.renderValueAdornment=m??(A=>T(A,!0)),h!==!1&&(k.noneLabel=typeof h=="string"?h:g.noneLabel??"No selection",k.renderNone=g.renderNone??(A=>l("span",{class:"zx-select__entity-none"},l("span",{class:"zx-select__entity-none-icon",ariaHidden:"true"}),l("span",{},A)))),f){let A=f===!0?{}:f,N=typeof A.oninvoke=="function"?A.oninvoke:null;k.actions=[...Array.isArray(k.actions)?k.actions:[],{id:A.id??"create",label:A.label??"Create new\u2026",group:A.group??"New",icon:A.icon??"plus",invoke:Y=>N?.({...Y,resource:t})}]}return k}function ba(i,t,e={}){let s=an(i,t,e),n=e.value??null,r=new M(null,s);return r.ready=ln(r,i,t,n),r}function ii(i,t){return typeof i?.normalizeListResult=="function"?on(i.normalizeListResult(t)):on(t)}function on(i){if(Array.isArray(i))return{data:i};if(!i||typeof i!="object")return{data:[]};let t=Array.isArray(i.data)?i.data:[],e=i.count==null||i.count===""?null:Number(i.count);return Number.isFinite(e)?{data:t,count:e}:{data:t}}async function ln(i,t,e,s){if(s==null)return i;let n=s&&typeof s=="object"?s:await Q(t).get(e,s),r=ya(n);return i.setItems([r]),i.set(r,{silent:!0}),i}function ya(i){if(i&&typeof i=="object"&&!Array.isArray(i)){let t=i.data;return t&&typeof t=="object"&&!Array.isArray(t)?t:i}throw new TypeError("ZeyOS get operation did not return a record")}function pe(i,t){return typeof t=="function"?t(i):i&&typeof i=="object"&&typeof t=="string"?i[t]:null}function xa(i,t){let e=ft(String(t.module??"default"),{size:20});return e.replaceChildren(_("square",{size:10})),e}function cn(i,t,e){let s=[i,t,...e].filter(n=>typeof n=="string"&&n);return s.length?[...new Set(s)]:void 0}function un(i,t){let e=va(i,t);for(let s of["name","lastname","customernum","transactionnum","number","title","ID"])if(e.includes(s))return s;return e[0]??"ID"}function hn(i,t){let e=i?.schema?.describe?.(t)?.fields;return!e||typeof e!="object"||Array.isArray(e)?[]:Object.entries(e).flatMap(([s,n])=>{if(!n||typeof n!="object")return[];let r=String(n.type??"").toLowerCase();return n.indexed&&/text|character|varchar/.test(r)?[s]:[]})}function va(i,t){let e=i?.schema?.fields?.(t);if(Array.isArray(e))return e.map(String);if(e&&typeof e=="object")return Object.keys(e);let s=i?.schema?.describe?.(t)?.fields;return s&&typeof s=="object"?Object.keys(s):[]}function wa(i,t,e={}){let s=mt(i,t,e),n={},r=[];for(let o of s){let a=Et(o),c=a.type==="zxselect"&&typeof a.props?.entity=="string"?a.props.entity:null;c&&(r.push({id:String(o.id),resource:c}),a.props={...It(i,c,{clearable:!a.required,placeholder:`Select ${String(a.label).toLowerCase()}`})}),n[String(o.id)]=a}return{fieldMeta:s,fields:n,entityFields:r,formOptions:{fieldsets:[{title:String(e.title??""),columns:Ca(e.columns),fields:n}]},mapFromRecord:o=>Sa(o,s),mapToRecord:o=>Aa(o,s)}}function ka(i,t,e={}){if(e.onSaved!=null&&typeof e.onSaved!="function")throw new TypeError("zeyosForm onSaved must be a function");let s=wa(i,t,e),n=Q(i),r=new zt(null,s.formOptions),o=e.value?.ID??e.id??null,a=!1,c=null,u=async d=>{if(!d||typeof d!="object"||Array.isArray(d))throw new TypeError("ZeyOS form value must be a record");return await Promise.all(s.entityFields.map(async({id:m,resource:g})=>{let b=d[m];if(b==null)return;let k=b&&typeof b=="object"?b:si(await n.get(g,b)),T=M.from(r.getField(m)?.getInput());T instanceof M&&T.setItems([k])})),a||r.setValues(s.mapFromRecord(d),{silent:!0}),d},h=async d=>{if(d==null||d==="")throw new TypeError("zeyosForm.load() requires an id");let m=si(await n.get(t,d));return o=m.ID??d,await u(m),m},f=()=>a?Promise.reject(new Error("Cannot save a destroyed ZeyOS form")):c||(r.submit()?(c=(async()=>{let d;try{d=s.mapToRecord(r.getValues()),delete d.ID}catch(b){throw n.reportError(b,{operation:"serialize",resource:t}),b}let m=o==null?await n.create(t,d):await n.update(t,{ID:o,...d}),g=si(m);if(o=g.ID??o,e.onSaved)try{await e.onSaved(g)}catch(b){throw n.reportError(b,{operation:"onSaved",resource:t}),b}return nt.success(`${Ia(g,t)} saved successfully.`),g})().finally(()=>{c=null}),c):Promise.resolve(null)),p=Object.prototype.hasOwnProperty.call(e,"id")?h(e.id):e.value?u(e.value):Promise.resolve(null);return{form:r,ready:p,load:h,save:f,getForm:()=>r,destroy(){a||(a=!0,r.destroy())}}}function Sa(i,t){let e={};for(let s of t){let n=String(s.id),r=i[n];e[n]=dn(s)&&r!=null&&r!==""?pt(r):r}return e}function Aa(i,t){let e={};for(let s of t){let n=String(s.id),r=i[n];if(dn(s))r=r==null||r===""?null:Z(r);else if(za(s)&&Da(s.type)&&r!==""&&r!=null){let o=Number(r);Number.isFinite(o)&&(r=o)}e[n]=r}return e}function dn(i){let t=Et(i);return t.type==="date"||t.type==="datetime"}function za(i){return i.enums!=null||i.enum!=null}function Da(i){return/^(?:smallint|integer|bigint|int|int2|int4|int8|numeric|decimal)$/i.test(String(i??""))}function Ca(i){let t=Number(i??2);return[1,2,3].includes(t)?t:2}function si(i){if(i&&typeof i=="object"&&!Array.isArray(i)){let t=i.data;return t&&typeof t=="object"&&!Array.isArray(t)?t:i}throw new TypeError("ZeyOS operation did not return a record")}function Ia(i,t){for(let e of["transactionnum","name","lastname","customernum","number","ID"])if(i[e]!=null&&i[e]!=="")return String(i[e]);return String(t)}function Ma(i,t,e={}){let s=mt(i,t,{fields:e.fields,labels:e.labels}),n={},r=s.map(a=>{let c={...a},u=Ea(c);if(u){let p=Na(i,u);c.labelField=`${c.id}_label`,n[c.labelField]=`${c.id}.${p}`}n[c.id]=c.id;let h=Fa(c),f=me(h?{...c,format:"money"}:c);return h&&(f.render=p=>La(p?.[c.id],p?.currency),Oa(i,t,"currency")&&(n.currency="currency")),f}),o=e.rowId??"ID";return typeof o=="string"&&!Object.prototype.hasOwnProperty.call(n,o)&&(n[o]=o),{fieldMeta:s,columns:r,projection:n,tableOptions:{columns:r,data:[],rowId:o,sort:e.sort??null,sortMode:"server",selectable:e.selectable??!1,height:e.height??null,onrowclick:typeof e.onRowClick=="function"?a=>e.onRowClick(a.detail.row,a):void 0}}}function Ta(i,t,e={}){let s=Ma(i,t,e),n=Q(i),r=new St(null,s.tableOptions),o=Ra(e.pageSize),a=e.sort??null,c=fn(e.filters??{}),u=String(e.search??""),h=0,f=null,p=!1,d=0,m=async(b={})=>{Object.prototype.hasOwnProperty.call(b,"search")&&(u=String(b.search??"")),Object.prototype.hasOwnProperty.call(b,"filters")&&(c=fn(b.filters??{}));let k=ja(b.page??0),T=ot({fields:s.projection,sort:a,filters:c,search:u,limit:o,offset:k*o,count:!0}),A=++d;r.setLoading(!0);try{let N=ii(i,await n.list(t,T)),Y=N.count??null,ni=Y==null?N.data.length===o:k*o+N.data.length<Y;return A===d&&(h=k,f=Y,p=ni,k===0?r.setData(N.data):r.addData(N.data)),{data:N.data,count:Y,page:k,hasMore:ni,query:T}}finally{A===d&&r.setLoading(!1)}},g={table:r,load:m,setSearch:b=>m({search:b,page:0}),setFilters:b=>m({filters:b,page:0}),loadMore:()=>p?m({page:h+1}):Promise.resolve({data:[],count:f,page:h,hasMore:!1,query:ot({fields:s.projection,sort:a,filters:c,search:u,limit:o,offset:h*o,count:!0})}),get count(){return f},get page(){return h},get hasMore(){return p},destroy:()=>r.destroy()};return r.on("sort",b=>{a={id:String(b.detail.id),dir:b.detail.dir==="desc"?"desc":"asc"},m({page:0}).catch(()=>{})}),g}function Ea(i){for(let t of[i.entity,i.fk,i.relation,i.reference,i.references]){if(typeof t=="string"&&t)return t;if(t&&typeof t=="object"){let e=t.resource??t.target??t.table??t.entity;if(typeof e=="string"&&e)return e}}return null}function Na(i,t){let e=i?.schema?.fields?.(t),s=Array.isArray(e)?e.map(String):Object.keys(e??{});for(let n of["name","lastname","customernum","transactionnum","number","title","ID"])if(s.includes(n))return n;return s[0]??"ID"}function Fa(i){let t=String(i.format??"").toLowerCase();return/money|currency|price/.test(t)||/(?:amount|price)$/.test(String(i.id).toLowerCase())}function La(i,t){if(i==null||i==="")return"";let e=Number(i);if(!Number.isFinite(e))return"";let s=typeof t=="string"&&/^[A-Z]{3}$/.test(t)?t:null;try{return new Intl.NumberFormat(void 0,s?{style:"currency",currency:s}:{}).format(e)}catch{return new Intl.NumberFormat().format(e)}}function Oa(i,t,e){let s=i?.schema?.fields?.(t);return Array.isArray(s)?s.includes(e):!!(s&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,e))}function Ra(i){let t=Number(i??50);return Number.isInteger(t)&&t>0?t:50}function ja(i){let t=Number(i);if(!Number.isInteger(t)||t<0)throw new RangeError("ZeyOS table page must be a non-negative integer");return t}function fn(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("ZeyOS table filters must be an object");return{...i}}export{tn as ZEYOS_ICON_KIT,ha as ZEYOS_LAUNCHER_APPLICATIONS,ot as buildListQuery,an as buildZeyosEntitySelectConfig,sn as buildZeyosLauncherConfig,It as buildZeyosSelectConfig,Q as connect,pn as dataFilterStateToFilters,Z as dateToUnixSeconds,me as fieldToZxColumn,Et as fieldToZxField,Js as moduleAliases,ft as moduleChip,oa as moduleColor,Je as moduleGlyphColor,en as moduleIcon,aa as moduleIconName,$ as moduleInfo,la as moduleKeys,de as normalizeModuleName,nn as normalizeZeyosLauncherApplications,fe as normalizeZeyosLauncherRecords,C as registerFieldType,ca as registerModules,mt as resolveFields,ri as tableSortToQuery,pt as unixSecondsToDate,ua as useZeyosIcons,fa as zeyosActiveIdentifier,ba as zeyosEntitySelect,ka as zeyosForm,da as zeyosLauncher,rt as zeyosModules,ga as zeyosSelect,Ta as zeyosTable};
|