@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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var oi=0;function y(i="zx"){return oi+=1,`${i}-${Date.now().toString(36)}-${oi.toString(36)}`}function se(i,t){let e=Tt(i)?ai(i):{};if(!Tt(t))return ee(t);for(let[s,r]of Object.entries(t))Tt(r)&&Tt(e[s])?e[s]=se(e[s],r):e[s]=ee(r);return e}function S(i){return!!(i&&typeof i=="object"&&i.nodeType===1)}function Et(i,t,e){return Math.min(e,Math.max(t,i))}function zs(i){return String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Tt(i){if(i===null||typeof i!="object")return!1;let t=Object.getPrototypeOf(i);return t===Object.prototype||t===null}function ai(i){let t={};for(let[e,s]of Object.entries(i))t[e]=ee(s);return t}function ee(i){return Tt(i)?ai(i):Array.isArray(i)?i.map(ee):i}var Nt=null;function a(i,t,...e){let s=document.createElement(i),r=t;fn(r)||(e.unshift(r),r={});for(let[n,o]of Object.entries(r))pn(s,n,o);return mn(s,e),s}a.scope=function(t,e){let s=Nt;Nt=t;try{return e()}finally{Nt=s}};a.raw=function(t){let e=document.createElement("template");return e.innerHTML=String(t),e.content};function G(i){return{children:Array.from(i.childNodes),attributes:Array.from(i.attributes,t=>[t.name,t.value])}}function Q(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 li(i){return String(i).replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}function Z(i){if(i==null)return null;if(S(i))return i;if(typeof i=="string")return document.querySelector(i);if(typeof i.toElement=="function"){let t=i.toElement();return S(t)?t:null}return null}function fn(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 pn(i,t,e){if(t==="ref"){Nt&&typeof e=="string"&&(Nt[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[r,n]of Object.entries(e))r.startsWith("--")||r.includes("-")?i.style.setProperty(r,String(n)):i.style[r]=n;return}if(t==="dataset"&&e&&typeof e=="object"){for(let[r,n]of Object.entries(e))n==null?delete i.dataset[r]:i.dataset[r]=String(n);return}if(/^on[a-z]/.test(t)&&typeof e=="function"){i.addEventListener(t.slice(2),e);return}if(e==null)return;let s=_n(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 _n(i){return i.startsWith("aria-")?i:/^aria[A-Z]/.test(i)?"aria-"+i.slice(4).toLowerCase():null}function mn(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 r=s;if(typeof r.nodeType=="number")e.append(s);else if(typeof r.toElement=="function"){let n=r.toElement();n&&e.append(n)}}}var ci=null,gn="en";function ie(){return gn}function O(i,t){let e=ci?ci(i):i;return E(e==null?i:String(e),t)}function E(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,(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 s=s.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}),s}var Mt=new WeakMap;function bt(i=globalThis){let t=i?.Element?.prototype;t&&(typeof t.store!="function"&&Object.defineProperty(t,"store",{configurable:!0,writable:!0,value:function(s,r){let n=Mt.get(this);return n||(n=new Map,Mt.set(this,n)),n.set(s,r),this}}),typeof t.retrieve!="function"&&Object.defineProperty(t,"retrieve",{configurable:!0,writable:!0,value:function(s,r=null){let n=Mt.get(this);return n?.has(s)?n.get(s):(arguments.length>1&&(n||(n=new Map,Mt.set(this,n)),n.set(s,r)),r)}}),typeof t.eliminate!="function"&&Object.defineProperty(t,"eliminate",{configurable:!0,writable:!0,value:function(s){return Mt.get(this)?.delete(s),this}}))}function Y(i){if(i&&typeof i=="object"&&typeof i.toElement=="function")return i.toElement()??!1;if(i&&typeof i=="object"&&typeof i.nodeType=="number")return i;if(typeof i=="string"||typeof i=="number")return document.createTextNode(String(i));if(!i||typeof i!="object"||Array.isArray(i))return!1;let t=i,e={},s=[],r=new Set(["tag","html","styles","classes","child","children","_adopt","events"]);for(let[o,l]of Object.entries(t))r.has(o)||(/^on[A-Z]/.test(o)&&typeof l=="function"?s.push([o.slice(2).toLowerCase(),l]):o==="class"?e.class=l:o==="text"?e.textContent=l==null?"":String(l):e[o]=l);if(t.styles&&typeof t.styles=="object"&&(e.style=t.styles),t.classes!=null){let o=Array.isArray(t.classes)?t.classes:[t.classes];e.class=[e.class,...o].flat().filter(Boolean)}let n=a(String(t.tag??"div"),e);for(let[o,l]of s)n.addEventListener(o,l);if(t.events&&typeof t.events=="object")for(let[o,l]of Object.entries(t.events))typeof l=="function"&&n.addEventListener(o,l);if(t.html!=null&&n.append(a.raw(String(t.html))),Cs(n,t._adopt),Cs(n,t.child),Array.isArray(t.children))for(let o of t.children)Cs(n,o);else if(t.children&&typeof t.children=="object"){let o=[];for(let[l,c]of Object.entries(t.children)){let h=Y(c);h&&(n.append(h),n[`_${l}`]=h.retrieve?.("com")??h,o.push(l))}n.store?.("children",o)}return n}function hi(i=globalThis){bt(i),i.__=Y;let t=i.String?.prototype;t&&typeof t.htmlSpecialChars!="function"&&Object.defineProperty(t,"htmlSpecialChars",{configurable:!0,writable:!0,value:function(){return li(String(this))}});let e=i.Array?.prototype;return e&&typeof e.findBy!="function"&&Object.defineProperty(e,"findBy",{configurable:!0,writable:!0,value:function(r,n){let o=typeof r=="string"?l=>l?.[r]===n:r;if(typeof o!="function")return null;for(let l=this.length-1;l>=0;l-=1)if(o(this[l])===!0)return this[l];return null}}),i._===void 0&&(i._=(s,r)=>O(String(s),r)),i}function Cs(i,t){if(t==null)return;let e=Array.isArray(t)?t:[t];for(let s of e){let r=Y(s);r&&i.append(r)}}var x=class{static legacyName="gx.ui.Container";constructor(t={},e={}){bn(this.constructor),this.gx=this.constructor.legacyName,this.options={...e,...t&&typeof t=="object"?t:{}},this._events=new Map,this._mappedListeners=[],this._domAbort=new AbortController,this._zx=null,this._ui={},this._display=this._ui,this._uiMap={},this._optionSetters={},this._destroyed=!1;for(let[s,r]of Object.entries(this.options))/^on[A-Z]/.test(s)&&typeof r=="function"&&this.addEvent(s,r)}addEvent(t,e){if(typeof e!="function")return this;let s=Ds(t),r=this._events.get(s)??new Set;return r.add(e),this._events.set(s,r),this}removeEvent(t,e){let s=Ds(t);if(e===void 0)this._events.delete(s);else{let r=this._events.get(s);r?.delete(e),r?.size===0&&this._events.delete(s)}return this}fireEvent(t,e=[]){let s=Array.isArray(e)?e:[e],r=[...this._events.get(Ds(t))??[]];for(let n of r)n.apply(this,s);return this}setOptions(t){if(!t||typeof t!="object")return this;for(let[e,s]of Object.entries(t))this.setOption(e,s);return this}setOption(t,e){let s=String(t);if(this.options[s]=e,/^on[A-Z]/.test(s)&&typeof e=="function")return this.addEvent(s,e),this;let r=this._optionSetters[s];return typeof r=="function"?r.call(this,e):typeof r=="string"&&typeof this[r]=="function"?this[r](e):yn(this.constructor,s),this}toElement(){return this._zx?.toElement?.()??this._zx?.el??null}display(t="root"){let e=t||"root";if(e==="root")return this.toElement();let s=this._uiMap[e];return typeof s=="function"?s.call(this)??this.toElement():typeof s=="string"?this._zx?.refs?.[s]??this.toElement():s?.nodeType===1?s:this._ui[e]??this.toElement()}getCoordinates(){let t=this.toElement()?.getBoundingClientRect?.();return t?{width:t.width,height:t.height,top:t.top,left:t.left}:{width:0,height:0,top:0,left:0}}setStyle(t,e){let s=this.toElement();return s?(String(t).startsWith("--")||String(t).includes("-")?s.style.setProperty(String(t),String(e)):s.style[t]=e,this):this}setCoordinates(t={}){for(let e of["width","height","top","right","bottom","left"]){if(t[e]==null)continue;let s=typeof t[e]=="number"?`${t[e]}px`:t[e];this.setStyle(e,s)}return this}destroy(){if(this._destroyed)return;this._destroyed=!0,this._domAbort.abort();let t=this.toElement();t?.retrieve?.("com")===this&&t.eliminate("com");for(let[e,s]of this._mappedListeners)this._zx?.off?.(e,s);this._mappedListeners.length=0,this._events.clear(),this._zx?.destroy?.()}_attach(t,e={}){this._zx=t,this._uiMap={...e.ui??{}},this._optionSetters={...e.setters??{}};let s=this.toElement();if(s){bt(globalThis),s.store?.("com",this),this._ui.root=s;for(let r of Object.keys(this._uiMap))this._ui[r]=this.display(r)}for(let[r,n]of Object.entries(e.events??{})){let o=typeof n=="string"?{type:n}:n,l=c=>{let h=c.detail??{};if(o.filter&&!o.filter.call(this,h,c))return;let u=o.args?o.args.call(this,h,c):[];this.fireEvent(r,u)};t.on?.(o.type,l),this._mappedListeners.push([o.type,l])}return this}_listen(t,e,s,r={}){return t.addEventListener(e,s,{...r,signal:this._domAbort.signal}),this}_mirrorAct(t,e){t?.classList.toggle("act",!!e)}};function bn(i){Object.hasOwn(i,"_compatWarned")&&i._compatWarned||(Object.defineProperty(i,"_compatWarned",{configurable:!0,value:!0,writable:!0}),console.warn(`${i.legacyName} is running on the Zx compat layer \u2014 migrate to ${xn(i.legacyName)}`))}function yn(i,t){Object.hasOwn(i,"_compatOptionWarnings")||Object.defineProperty(i,"_compatOptionWarnings",{configurable:!0,value:new Set}),!i._compatOptionWarnings.has(t)&&(i._compatOptionWarnings.add(t),console.warn(`${i.legacyName}.setOption("${t}") cannot update the wrapped Zx component dynamically`))}function xn(i){return`zx.${i.split(".").at(-1)}`}function Ds(i){let t=String(i??"");return(/^on[A-Z]/.test(t)?t.slice(2):t).toLowerCase()}var re=new WeakMap,p=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#t=new AbortController;#e=!1;#s=!1;#i=!1;constructor(t,e={}){super();let s=this.constructor;this.#e=t===null;let r=Z(t);if(t!==null&&!r)throw new TypeError("Component target could not be resolved");this.el=r,this.refs={};let n=vn(s,e),o=[];for(let[h,u]of Object.entries(n))/^on[a-z]/.test(h)&&typeof u=="function"&&(o.push([h.slice(2),u]),delete n[h]);n.msg&&typeof n.msg=="object"&&Object.freeze(n.msg),this.options=Object.freeze(n);for(let[h,u]of o)this.on(h,u);let l;try{l=a.scope(this.refs,()=>this.render())}catch(h){throw this.#t.abort(),h}if(this.#e){let h=S(l)?l:this.el;if(!S(h))throw this.#t.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=h}if(!S(this.el))throw this.#t.abort(),new TypeError("Component requires a root Element");let c=s.cssName;if(typeof c=="string"&&c){let h=`zx-${c}`;this.#i=!this.el.classList.contains(h),this.el.classList.add(h)}re.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=ui(t,e,{cancelable:!0});return this.dispatchEvent(s),this.el&&this.el.dispatchEvent(ui(`zx-${t}`,e,{bubbles:!0,composed:!0,cancelable:!0})),s}listen(t,e,s,r={}){let n=typeof r=="boolean"?{capture:r}:{...r};return t.addEventListener(e,s,{...n,signal:this.#t.signal}),this}toElement(){return this.el}msg(t,...e){let s=this.options.msg,r=this.options.lang??this.options.language??ie(),n=s?.[r]?.[t];if(n!=null)return E(String(n),e);let o=s?.[t];return o!=null?E(String(o),e):O(t,e)}destroy(){if(this.#s)return;this.#s=!0,this.#t.abort(),re.get(this.el)===this&&re.delete(this.el);let t=this.constructor.cssName;this.#i&&typeof t=="string"&&this.el&&this.el.classList.remove(`zx-${t}`),this.#e&&this.el&&this.el.remove()}static from(t){return re.get(t)??null}};function vn(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 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=se(n,l.msg)));return Object.assign(r,t&&typeof t=="object"?t:{}),t?.msg&&typeof t.msg=="object"&&(o=!0,n=se(n,t.msg)),o&&(r.msg=n),r}function ui(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 b=class i extends p{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??a("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=Sn(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):y("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"}),h=a("div",{class:"zx-field__description",id:n},String(this.options.description??"")),u=a("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),f=a("div",{class:"zx-field__body"},c,h,u);this._ownedNodes.push(l,f),t.append(l,f);let g=i.#t.get(e);if(g)try{this.adapter=An(g(this,this.options))}catch(_){let w=_ instanceof Error?_.message:String(_);console.warn(`[zx.Field] Adapter "${e}" failed: ${w}`),this.adapter=fi(w,this.controlId)}else{let _=this.msg("field.unknown",e);console.warn(`[zx.Field] ${_}`),this.adapter=fi(_,this.controlId)}let d=this.adapter.el;return d.id||(d.id=this.controlId),l.htmlFor=d.id,kn(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=u,this._syncDescription(),this.initialValue=wn(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 p))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();zn(this.el,this._rootAttributes??new Map),super.destroy()}};function Ts(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=_i(t);return e!==null&&Number.isInteger(e)?{valid:!0,value:e}:{valid:!1,value:t}}function Es(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=_i(t);return e!==null?{valid:!0,value:e}:{valid:!1,value:t}}function _i(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 r=[...s.matchAll(/\./g)].map(c=>c.index),n=[...s.matchAll(/,/g)].map(c=>c.index),o;if(r.length&&n.length){let c=r.at(-1)>n.at(-1)?".":",",h=c==="."?",":".",u=s.lastIndexOf(c),f=s.slice(0,u),g=s.slice(u+1);if(!/^\d+$/.test(g)||!di(f,h))return null;o=f.split(h).join("")+"."+g}else if(n.length>1||r.length>1){let c=n.length?",":".";if(!di(s,c))return null;o=s.split(c).join("")}else n.length===1?o=s.replace(",","."):o=s;if(!/^(?:\d+(?:\.\d+)?|\.\d+)$/.test(o))return null;let l=Number(e+o);return Number.isFinite(l)?l:null}function di(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 wn(i,t){return t!==void 0?t:i==="checkbox"?!1:""}function An(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 fi(i,t){let e=a("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 Sn(i,t){return new Map(t.map(e=>[e,i.getAttribute(e)]))}function zn(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}function Ot(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 ne(i,t){return(e,s)=>{let r=a(i,Ot(s,{type:i==="input"?t:void 0,placeholder:s.placeholder,required:s.required,disabled:s.disabled}));return Ns(r)}}function Ns(i){return{el:i,get:()=>i.value,set:t=>{i.value=t==null?"":String(t)},focus:()=>i.focus(),setDisabled:t=>{i.disabled=t}}}function mi(i){return(t,e)=>{let s=i==="int"?Ts:Es,r=a("input",Ot(e,{type:"text",inputMode:i==="int"?"numeric":"decimal",placeholder:e.placeholder,required:e.required,disabled:e.disabled}));return t.listen(r,"blur",()=>{let n=s(r.value);if(!n.valid){t.setHighlight(t.msg(`field.${i}`),"danger");return}n.value!==""&&(r.value=String(n.value)),t.clearHighlight()}),{...Ns(r),get:()=>s(r.value).value}}}var Cn=(i,t)=>{let e=a("input",Ot(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}}},Dn=(i,t)=>{let e=a("select",Ot(t,{required:t.required,disabled:t.disabled}));for(let[s,r]of gi(t.options))e.append(a("option",{value:s},r));return Ns(e)},Tn=(i,t)=>{let e=a("div",{class:"zx-field__option-list",role:"radiogroup"}),s=t.id?String(t.id):y("zx-option-list"),r=gi(t.options).map(([n,o],l)=>{let c=a("input",{type:"radio",name:s,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))}}},En=(i,t)=>{let e=a("div",Ot(t,{class:"zx-field__static"})),s=null;return{el:e,get:()=>e.textContent,set:n=>{pi(s),s=null,n&&typeof n=="object"&&typeof n.nodeType=="number"?(s={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:()=>pi(s)}};function pi(i){i&&(i.parent?i.parent.insertBefore(i.node,i.next?.parentNode===i.parent?i.next:null):i.node.remove())}var Nn=(i,t)=>{if(typeof t.adapter!="function")throw new TypeError("Custom fields require options.adapter");return t.adapter(i,t)};function gi(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)]):[]}b.register("text",ne("input","text"));b.register("password",ne("input","password"));b.register("textarea",ne("textarea","text"));b.register("checkbox",Cn);b.register("int",mi("int"));b.register("float",mi("float"));b.register("select",Dn);b.register("optionlist",Tn);b.register("hidden",ne("input","hidden"));b.register("html",En);b.register("custom",Nn);function J(i,t,e){let s=bi(t).split(/\s+/).filter(Boolean);return s.length===0?i.slice():i.filter(r=>{let n=Mn(r,e).map(bi);return s.every(o=>n.some(l=>l.includes(o)))})}function Mn(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 bi(i){return String(i??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var ot=class extends p{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=y("zx-checklist-label"),s=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(s,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 h=this._itemValue(c);l.checked?this._checked.add(h):this._checked.delete(h),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(r=>this._itemValue(r)).filter(r=>e.has(r)));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=J(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=J(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let t=this._visibleItems.map((e,s)=>{let r=y("zx-checklist-item"),n=a("input",{type:"checkbox",id:r,checked:this._checked.has(this._itemValue(e)),dataset:{index:s}});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){On(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 On(i,t){return i.size===t.size&&Array.from(i).every(e=>t.has(e))}function yi(){b.register("checklist",(i,t)=>{let e=i.own(new ot(null,{...t.props??{}})),s=!1,r=!1,n=()=>{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=>{r||i.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=>{s=!!o,n()}}})}var xi=["January","February","March","April","May","June","July","August","September","October","November","December"],vi=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ki=/%[demYyHMSaAbBs]/g;function v(i,t){return!(i instanceof Date)||Number.isNaN(i.getTime())?"":String(t).replace(ki,e=>{switch(e){case"%d":return yt(i.getDate());case"%e":return String(i.getDate());case"%m":return yt(i.getMonth()+1);case"%Y":return String(i.getFullYear()).padStart(4,"0");case"%y":return yt(i.getFullYear()%100);case"%H":return yt(i.getHours());case"%M":return yt(i.getMinutes());case"%S":return yt(i.getSeconds());case"%a":return wi("weekday",i.getDay(),vi[i.getDay()]);case"%A":return Ms("weekday",i.getDay(),vi[i.getDay()]);case"%b":return wi("month",i.getMonth(),xi[i.getMonth()]);case"%B":return Ms("month",i.getMonth(),xi[i.getMonth()]);case"%s":return String(Math.floor(i.getTime()/1e3));default:return e}})}function I(i,t){let e=[],s="^",r=0;for(let _ of String(t).matchAll(ki)){s+=Ai(String(t).slice(r,_.index));let w=_[0],k=In(w);if(k===null)return null;s+=`(${k})`,e.push(w),r=_.index+w.length}s+=Ai(String(t).slice(r))+"$";let n=new RegExp(s).exec(String(i));if(!n)return null;let o=Object.create(null);if(e.forEach((_,w)=>{o[_]=Number(n[w+1])}),o["%s"]!==void 0){let _=o["%s"]*1e3,w=new Date(_);return Number.isNaN(w.getTime())?null:w}let l=o["%Y"]??Fn(o["%y"])??1970,c=(o["%m"]??1)-1,h=o["%d"]??o["%e"]??1,u=o["%H"]??0,f=o["%M"]??0,g=o["%S"]??0,d=new Date(0);return d.setHours(0,0,0,0),d.setFullYear(l,c,h),d.setHours(u,f,g,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()!==h||o["%e"]!==void 0&&d.getDate()!==h||o["%H"]!==void 0&&d.getHours()!==u||o["%M"]!==void 0&&d.getMinutes()!==f||o["%S"]!==void 0&&d.getSeconds()!==g?null:d}function Os(i,t,e){let s=i.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,s)))}function C(i,t){return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()&&i.getDate()===t.getDate()}function A(i,t){let e=new Date(i.getTime());return e.setDate(e.getDate()+t),e}function X(i,t){let e=new Date(i.getTime()),s=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(s,r)),e}function It(i=ie()){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 yt(i){return String(i).padStart(2,"0")}function Ms(i,t,e){let s=`date.${i}.${t}`,r=O(s);return r===s?e:r}function wi(i,t,e){let s=`date.${i}.short.${t}`,r=O(s);return r!==s?r:Ms(i,t,e).slice(0,3)}function In(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 Fn(i){if(i!==void 0)return i>=69?1900+i:2e3+i}function Ai(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Si=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),Ln=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),zi=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"}),Vn=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"});function Ci(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(),r=t.slice(e+1);if(s==="builtin"||s==="zx")return{provider:"builtin",name:r,style:null,classes:null};if(Object.hasOwn(zi,s))return{provider:"fa",name:r,style:zi[s],classes:null}}return{provider:null,name:t,style:null,classes:null}}function Is(i,t={}){let{style:e="solid",family:s="classic",fixedWidth:r=!1,translate:n=!0}=t,o=String(i).replace(/^fa-/,""),l=n?Vn[o]??o:o,c=[],h=Ln[s];return h&&c.push(h),c.push(Si[e]??Si.solid,`fa-${l}`),r&&c.push("fa-fw"),c}var Di="http://www.w3.org/2000/svg",oe=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"]}),Pn=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list"}),Bn=Object.create(null),at={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function m(i,t={}){let e=Ci(i);if(e.classes)return Fs(e.classes,t);let s=Pn[e.name]??e.name;return e.provider==="builtin"?Ti(s,t):e.provider==="fa"?Fs(Is(s,{style:e.style??t.style??at.style,family:t.family??at.family,fixedWidth:t.fixedWidth??at.fixedWidth}),t):at.provider==="fontawesome"?Fs(Is(s,{style:t.style??at.style,family:t.family??at.family,fixedWidth:t.fixedWidth??at.fixedWidth}),t):Ti(s,t)}function Ti(i,t){let e=Bn[i]??oe[i];if(!e)throw new RangeError(`Unknown icon: ${i}`);let[s,r]=e,{size:n=16}=t,o=document.createElementNS(Di,"svg"),l=document.createElementNS(Di,"path");return o.setAttribute("class",Ni("zx-icon",t.class)),o.setAttribute("viewBox",s),o.setAttribute("width",String(n)),o.setAttribute("height",String(n)),o.setAttribute("fill","currentColor"),o.setAttribute("focusable","false"),Ei(o,t.label??null),l.setAttribute("d",r),o.append(l),o}function Fs(i,t){let{size:e=16}=t,s=document.createElement("i");return s.className=Ni("zx-icon",...i,t.class),s.style.fontSize=typeof e=="number"?`${e}px`:String(e),Ei(s,t.label??null),s}function Ei(i,t){if(t===null){i.setAttribute("aria-hidden","true");return}i.setAttribute("role","img"),i.setAttribute("aria-label",t)}function Ni(...i){return i.flat().filter(Boolean).join(" ")}var jn=5,j=class extends p{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=Mi(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=a("div",{class:"zx-time-picker__segments",role:"group",ariaLabel:"Time"});if(this._content=s,this._addSpin(s,"h","Hour",23),s.append(a("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"m","Minute",59),this.options.seconds&&(s.append(a("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"s","Second",59)),t.append(s),this.options.clock){let r=y("zx-time-picker-clock");s.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 s=Mi(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,r){let n=a("input",{class:"zx-time-picker__spin",type:"text",role:"spinbutton",inputMode:"numeric",maxLength:2,autocomplete:"off",ariaLabel:s,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,s){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return;t.preventDefault();let r=t.key==="ArrowUp"?1:-1,n=e==="m"?$n(this.options.step):1,o=xt(t.currentTarget.value,0,s),l=s+1,c=(o+r*n+l*n)%l;t.currentTarget.value=lt(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=lt(xt(t.value,0,s)),this._commitFromInputs();let r=this._inputs.indexOf(t);this._inputs[r+1]?.focus()}_commitFromInputs(){let t={h:0,m:0,s:0};for(let s of this._inputs){let r=s.dataset.segment,n=r==="h"?23:59;t[r]=xt(s.value,0,n)}let e=!this._value||!Kn(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=lt(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",s=>{let r=s.target.closest?.(".zx-time-picker__mark");r&&this._pick(Number(r.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"),r=e.indexOf(s);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=lt(this._display.h),this.refs.headMinute.textContent=lt(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?Rn():Hn(),r=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(r.length!==s.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(...s.map(l=>this._buildMark(l,e)))}else s.forEach((l,c)=>this._syncMark(r[c],l,e));let n=t&&!qn(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 s=a("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 r=e.value===s;t.setAttribute("aria-checked",String(r)),t.tabIndex=r?0:-1}};function Rn(){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:lt(e),angle:t*30,ring:"inner"})}return i}function Hn(){let i=[];for(let t=0;t<60;t+=jn)i.push({value:t,label:lt(t),angle:t*6,ring:"outer"});return i}function qn(i){return i>=1&&i<=12}function Mi(i){return i instanceof Date&&!Number.isNaN(i.getTime())?{h:i.getHours(),m:i.getMinutes(),s:i.getSeconds()}:!i||typeof i!="object"?null:{h:xt(i.h,0,23),m:xt(i.m,0,59),s:xt(i.s,0,59)}}function xt(i,t,e){let s=Number.parseInt(String(i??""),10);return Number.isFinite(s)?Math.max(t,Math.min(e,s)):t}function $n(i){let t=Math.round(Number(i));return Number.isFinite(t)&&t>0&&t<=59?t:5}function lt(i){return String(i).padStart(2,"0")}function Kn(i,t){return i.h===t.h&&i.m===t.m&&i.s===t.s}var L=class extends p{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=F(ae(this.options.min)),this._max=F(ae(this.options.max)),this._value=this._normalizeValue(ae(this.options.value)),this._focused=F(this._value)??this._clampFocus(F(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=Yn(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",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 j(null,{value:this._value,seconds:!1}),this._timePicker.on("change",s=>{let r=s.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 Ls(this._value)}set(t,{silent:e=!1}={}){let s=this._normalizeValue(ae(t));return this._value=s,s&&(this._focused=F(s),this._viewYear=s.getFullYear(),this._viewMonth=s.getMonth()),this._timePicker?.set(s,{silent:!0}),this._renderCalendar(),e||this.emit("change",{date:Ls(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=F(e);return this._min&&s<this._min&&Oi(e,this._min),this._max&&s>this._max&&Oi(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 s=0;s<7;s+=1){let r=A(e,(this._weekStart+s)%7);t.append(a("th",{scope:"col",ariaLabel:v(r,"%A")},v(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,s=A(t,-e);this.refs.heading.textContent=v(t,"%B %Y"),this.refs.heading.setAttribute("aria-label",`Choose month and year, ${v(t,"%B %Y")}`);let r=[];for(let n=0;n<6;n+=1){let o=A(s,n*7),l=a("tr");this.options.showWeekNumbers&&l.append(a("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:`Week ${Ii(o)}`},String(Ii(o))));for(let c=0;c<7;c+=1){let h=A(o,c),u=!!(this._value&&C(h,this._value)),f=!this._inRange(h),g=a("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:C(h,this._focused)?0:-1,ariaSelected:String(u),ariaDisabled:String(f),ariaCurrent:C(h,new Date)?"date":null,ariaLabel:`${v(h,"%e")} ${v(h,"%B %Y")}`,dataset:{date:v(h,"%Y-%m-%d"),otherMonth:h.getMonth()===this._viewMonth?null:"true"}},v(h,"%e"));l.append(a("td",{role:"presentation"},g))}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 s=I(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=I(e.dataset.date,"%Y-%m-%d");if(!s)return;let r=null;if(t.key==="ArrowLeft")r=A(s,-1);else if(t.key==="ArrowRight")r=A(s,1);else if(t.key==="ArrowUp")r=A(s,-7);else if(t.key==="ArrowDown")r=A(s,7);else if(t.key==="PageUp")r=X(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")r=X(s,t.shiftKey?12:1);else if(t.key==="Home")r=A(s,-((s.getDay()-this._weekStart+7)%7));else if(t.key==="End")r=A(s,6-(s.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._inRange(s)&&this._selectDate(s);return}r&&(t.preventDefault(),this._moveFocus(r))}_moveFocus(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;this._focused=F(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 r=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;this._value=e,this._focused=F(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._timePicker?.set(e,{silent:!0}),this._renderCalendar(),r&&this._emitMonthChange(),this.emit("change",{date:Ls(e)})}_pageMonth(t){this._closeQuickPick();let e=X(this._focused,t);this._focused=F(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(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}},v(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),r=null;if(t.key==="ArrowLeft")r=s-1;else if(t.key==="ArrowRight")r=s+1;else if(t.key==="ArrowUp")r=s-3;else if(t.key==="ArrowDown")r=s+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(s);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=F(e),this._viewMonth=t,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(t){let e=F(t);return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_buttonForDate(t){return this.refs.days.querySelector(`[data-date="${v(t,"%Y-%m-%d")}"]`)}};function ae(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function F(i){return i?new Date(i.getFullYear(),i.getMonth(),i.getDate()):null}function Ls(i){return i?new Date(i.getTime()):null}function Oi(i,t){i.setFullYear(t.getFullYear(),t.getMonth(),t.getDate())}function Yn(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:It()}function Ii(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 ct=class extends L{static cssName="month-picker";static defaults={value:null,min:null,max:null};render(){let t=this.el??a("div");this._min=ce(le(this.options.min)),this._max=ce(le(this.options.max)),this._value=this._normalizeMonth(le(this.options.value));let e=this._value??ce(new Date);this._year=e.getFullYear(),this._focusedMonth=e.getMonth();let s=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=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",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(le(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=ce(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),r=!!(this._value&&Un(s,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(s)),ariaLabel:v(s,"%B %Y"),dataset:{month:e}},v(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),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=-(s%3);else if(t.key==="End")r=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(r===null)return;t.preventDefault();let n=this._year*12+s+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 le(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function ce(i){return i?new Date(i.getFullYear(),i.getMonth(),1):null}function Un(i,t){return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()}function Fi(){b.register("month",(i,t)=>{let e=i.own(new ct(null,{...t.props??{},value:t.value})),s=!1,r=()=>{e.el.setAttribute("aria-disabled",String(s));for(let n of e.el.querySelectorAll("button"))n.disabled=s};return i.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>i.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=>{s=!!n,r()}}})}var Wn=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top"]);function R(i,t,e={}){if(!(i instanceof Element)||!(t instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let s=Wn.has(e.placement)?e.placement:"bottom-start",r=Number(e.offset??4),n=e.flip??!0,o=e.matchWidth??!1,l=i.getAttribute("style"),c=t.getAttribute("style"),h=t.getAttribute("popover"),u=!1,f=null,g=()=>{},d=()=>{};if(t.setAttribute("popover","manual"),typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a")){let w=`--${y("zx-a")}`;i.style.setProperty("anchor-name",w),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.setProperty("position-anchor",w),t.style.setProperty("position-area",Li(s)),t.style.setProperty("inset-area",Li(s)),t.style.setProperty("position-try-fallbacks",n?"flip-block, flip-inline, flip-block flip-inline":"none"),t.style.setProperty(s.startsWith("top")?"margin-block-end":"margin-block-start",`${r}px`),g=()=>{o&&(t.style.minWidth=`${i.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(f=new ResizeObserver(g),f.observe(i))}else t.style.position="fixed",t.style.inset="auto",t.style.margin="0",g=()=>Gn(i,t,{placement:s,offset:r,flip:n,matchWidth:o}),window.addEventListener("scroll",g,{capture:!0,passive:!0}),window.addEventListener("resize",g,{passive:!0}),typeof ResizeObserver=="function"&&(f=new ResizeObserver(g),f.observe(i)),d=()=>{window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g)};return Qn(t),g(),{update(){u||g()},destroy(){u||(u=!0,f?.disconnect(),d(),Zn(t),Vs(i,"style",l),Vs(t,"style",c),Vs(t,"popover",h))}}}function Li(i){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"}[i]}function Gn(i,t,{placement:e,offset:s,flip:r,matchWidth:n}){let o=i.getBoundingClientRect();n&&(t.style.minWidth=`${o.width}px`);let l=t.getBoundingClientRect(),c=document.documentElement.clientWidth||window.innerWidth,h=document.documentElement.clientHeight||window.innerHeight,u=e,f=e.startsWith("bottom"),g=o.bottom+s,d=o.top-s-l.height;r&&(f&&g+l.height>h&&d>=0?u=e.replace("bottom","top"):!f&&d<0&&g+l.height<=h&&(u=e.replace("top","bottom")));let _;u.endsWith("-end")?_=o.right-l.width:u.endsWith("-start")?_=o.left:_=o.left+(o.width-l.width)/2;let w=u.startsWith("bottom")?g:d;t.style.left=`${Math.round(Et(_,0,Math.max(0,c-l.width)))}px`,t.style.top=`${Math.round(Et(w,0,Math.max(0,h-l.height)))}px`}function Qn(i){if(typeof i.showPopover=="function")try{i.showPopover()}catch{}}function Zn(i){if(typeof i.hidePopover=="function")try{i.hidePopover()}catch{}}function Vs(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}var Jn=6,Hi=864e5;function Ft(i,t){let e=T(ht(i)),s=T(ht(t));return e&&s&&e.getTime()>s.getTime()?{start:s,end:e}:{start:e,end:s}}function he(i,t){let e=Ft(i,t);return!e.start||!e.end?0:Math.round((Bi(e.end)-Bi(e.start))/Hi)}function Xn(i,t,e){let s=T(ht(i));if(!s)return null;let r=Ft(t,e);return!r.start&&!r.end?null:r.end?r.start?s.getTime()<r.start.getTime()||s.getTime()>r.end.getTime()?null:C(s,r.start)?"start":C(s,r.end)?"end":"middle":C(s,r.end)?"end":null:C(s,r.start)?"start":null}function ue(i,t={}){let e=T(ht(t.min)),s=T(ht(t.max)),r=fe(t.minNights)??0,n=fe(t.maxNights),{start:o,end:l}=Ft(i?.start,i?.end);return o&&(o=Bs(o,e,s)),l&&(l=Bs(l,e,s)),!o||!l?{start:o,end:l}:(n!==null&&he(o,l)>n&&(l=A(o,n)),r>0&&he(o,l)<r&&(l=A(o,r),s&&l.getTime()>s.getTime()&&(l=new Date(s.getTime()),o=A(l,-r),e&&o.getTime()<e.getTime()))?{start:null,end:null}:{start:o,end:l})}var de=class extends p{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=oo(t,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=T(ht(this.options.min)),this._max=T(ht(this.options.max)),this._minNights=fe(this.options.minNights)??0,this._maxNights=fe(this.options.maxNights),this._weekStart=io(this.options.weekStart),this._monthCount=ro(this.options.months),this._presets=so(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let e=ue({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=tt(this._start)??this._clampFocus(T(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=a("div",{class:"zx-date-range-picker__surface"},this._presets.length?a("div",{ref:"presets",class:"zx-date-range-picker__presets",role:"group",ariaLabel:z("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=[s,r],t.append(s,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:tt(this._start),end:tt(this._end)}}set(t={},{silent:e=!1}={}){let s=ue({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=tt(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=[],ao(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=T(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=he(this._start,e);return!(s<this._minNights||this._maxNights!==null&&s>this._maxNights)}_choose(t){let e=T(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?tt(this._start):null,this._committedEnd=t?tt(this._end):null}_abandon(){return this._picking?(this._start=tt(this._committedStart),this._end=tt(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(t){return Bs(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=ji(t)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<e)return!1;let r=s<0?s:s-(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(),s=ji(t)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<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=T(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(n=>n.name===e.dataset.preset);if(!s)return;let r=s.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,s=e?.closest?.("[data-nav]");if(s){this._pageView(s.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?T(t):null;!e&&!this._hover||e&&this._hover&&C(e,this._hover)||(this._hover=e,this._paint())}_onDayKeydown(t){let e=this._cellFor(t.target);if(!e)return;let s=e.date,r=null;if(t.key==="ArrowLeft")r=A(s,-1);else if(t.key==="ArrowRight")r=A(s,1);else if(t.key==="ArrowUp")r=A(s,-7);else if(t.key==="ArrowDown")r=A(s,7);else if(t.key==="PageUp")r=X(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")r=X(s,t.shiftKey?12:1);else if(t.key==="Home")r=A(s,-((s.getDay()-this._weekStart+7)%7));else if(t.key==="End")r=A(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}!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=v(t,"%B %Y"),s=(t.getDay()-this._weekStart+7)%7,r=A(t,-s),n=[];for(let o=0;o<Jn;o+=1){let l=A(r,o*7),c=a("tr"),h=no(l,t);this.options.showWeekNumbers&&c.append(a("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:h?z("daterange.week","Week %1",[Ri(l)]):null},h?String(Ri(l)):""));for(let u=0;u<7;u+=1){let f=A(l,u),g=a("td",{role:"presentation"});if(f.getMonth()===t.getMonth()&&f.getFullYear()===t.getFullYear()){let d=a("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:v(f,"%Y-%m-%d")}},v(f,"%e"));g.append(d),this._dayCells.push({date:f,cell:g,button:d})}c.append(g)}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:z("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:z("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:z("daterange.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let s=0;s<7;s+=1){let r=A(e,(this._weekStart+s)%7);t.append(a("th",{scope:"col",ariaLabel:v(r,"%A")},v(r,"%a")))}return t}_paint(){let t=new Date,e=null;for(let s of this._dayCells)C(s.date,this._focused)&&(e=s);e||(e=this._dayCells[0]??null);for(let s of this._dayCells){let{date:r,cell:n,button:o}=s,l=this._dayState(r);Ps(n,"range",l.range),Ps(n,"rangeEdge",l.edge),Ps(o,"range",l.range),o.tabIndex=s===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)),C(r,t)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(t){if(this._start&&this._end){let s=Xn(t,this._start,this._end);if(!s)return{range:null,edge:null};let r=C(this._start,this._end);return s==="start"?{range:s,edge:r?"both":"start"}:s==="end"?{range:s,edge:r?"both":"end"}:{range:s,edge:null}}if(!this._start)return{range:null,edge:null};let e=this._previewEnd();return C(t,this._start)?{range:"start",edge:e?"start":"both"}:e?t.getTime()>this._start.getTime()&&t.getTime()<=e.getTime()?{range:"preview",edge:C(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=T(t);return e.getTime()<=this._start.getTime()?null:this._selectable(e)?e:null}_dayLabel(t,e){let s=v(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",[v(this._start,"%e %B %Y")]);let t=he(this._start,this._end),e=t===1?z("daterange.night","1 night"):z("daterange.nights","%1 nights",[t]);return`${eo(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=>C(e.date,t))?.button??null}};function to(){return[{name:"today",label:z("daterange.preset.today","Today"),range:()=>Vi(H())},{name:"yesterday",label:z("daterange.preset.yesterday","Yesterday"),range:()=>Vi(A(H(),-1))},{name:"last7",label:z("daterange.preset.last7","Last 7 days"),range:()=>({start:A(H(),-6),end:H()})},{name:"last30",label:z("daterange.preset.last30","Last 30 days"),range:()=>({start:A(H(),-29),end:H()})},{name:"thisMonth",label:z("daterange.preset.thisMonth","This month"),range:()=>Pi(H(),0)},{name:"lastMonth",label:z("daterange.preset.lastMonth","Last month"),range:()=>Pi(H(),-1)},{name:"thisQuarter",label:z("daterange.preset.thisQuarter","This quarter"),range:()=>{let i=H(),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=H();return{start:new Date(i.getFullYear(),0,1),end:new Date(i.getFullYear(),11,31)}}}]}function z(i,t,e){let s=O(i);return E(s===i?t:s,e)}function eo(i,t){if(C(i,t))return v(i,"%e %B %Y");let e=v(t,"%e %B %Y");return i.getFullYear()!==t.getFullYear()?`${v(i,"%e %B %Y")} \u2013 ${e}`:i.getMonth()!==t.getMonth()?`${v(i,"%e %B")} \u2013 ${e}`:`${v(i,"%e")} \u2013 ${e}`}function so(i){return i===!0?to():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 H(){return T(new Date)}function Vi(i){return{start:i,end:new Date(i.getTime())}}function Pi(i,t){return{start:new Date(i.getFullYear(),i.getMonth()+t,1),end:new Date(i.getFullYear(),i.getMonth()+t+1,0)}}function ht(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function T(i){return!i||Number.isNaN(i.getTime())?null:new Date(i.getFullYear(),i.getMonth(),i.getDate())}function tt(i){return i?new Date(i.getTime()):null}function Bs(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 Bi(i){return Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())}function ji(i){return i.getFullYear()*12+i.getMonth()}function fe(i){if(i==null||i==="")return null;let t=Number(i);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):null}function io(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:It()}function ro(i){let t=Number(i);return Number.isInteger(t)&&t>=1&&t<=4?t:2}function no(i,t){for(let e=0;e<7;e+=1){let s=A(i,e);if(s.getMonth()===t.getMonth()&&s.getFullYear()===t.getFullYear())return!0}return!1}function Ri(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())/Hi+1)/7)}function Ps(i,t,e){e==null?delete i.dataset[t]:i.dataset[t]=e}function oo(i,t){return new Map(t.map(e=>[e,i.getAttribute(e)]))}function ao(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}var lo={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function qi(i,t,e){let s=String(i??"").trim();if(s==="")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*",h=n===""?[s]:s.split(new RegExp(`${l}${zs(n)}${c}`));if(h.length>2)return null;let u=I(h[0].trim(),t);if(!u)return null;if(h.length===1)return{start:u,end:new Date(u.getTime())};if(h[1].trim()==="")return{start:u,end:null};let f=I(h[1].trim(),t);return f?Ft(u,f):null}function co(i,t,e){let s=i?.start??null,r=i?.end??null;return!s&&!r?"":r?s?`${v(s,t)}${e}${v(r,t)}`:v(r,t):v(s,t)}var pe=class extends p{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=y("zx-date-range-box-popover"),s=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:$i("daterange.clear","Clear date range")},m("x",{size:13})),a("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:$i("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=s,t.append(s),this._picker=new de(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(),js(this.el,"data-state",this._originalState),js(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=qi(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(qi(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()!==""?I(t.trim(),this._format):null}_clamp(t){return ue(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=>lo[e]??e);return`${t}${this._separator}${t}`}_syncDisplay(){this.refs.input.value=co(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"&&js(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 $i(i,t,e){let s=O(i);return E(s===i?t:s,e)}function js(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}function Ki(){b.register("daterange",(i,t)=>{let e=i.own(new pe(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 q=class extends p{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=ho(this.options.format,this.options.time),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._min=Yi(this.options.min),this._max=Yi(this.options.max),this._value=this._normalizeValue(this.options.value);let e=y("zx-datebox-popover"),s=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??uo(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=s,t.append(s),this._picker=new L(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=I(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=I(t,this._format)),!e||Number.isNaN(e.getTime())?null:Os(e,this._min,this._max)}_syncDisplay(){this.refs.input.value=this._value?v(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}},Rs=function(t,e={}){return new q(t,{...e,time:!0})};function Yi(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function ho(i,t){let e=String(i||"%d.%m.%Y");return t&&!/%[HM]/.test(e)?`${e} %H:%M`:e}function uo(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 Wi(){Ui("date",i=>new q(null,i)),Ui("datetime",i=>Rs(null,i))}function Ui(i,t){b.register(i,(e,s)=>{let r=e.own(t({...s.props??{},value:s.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 ut=class extends p{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=y("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"},fo(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",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 r=s instanceof Error?s:new Error(String(s));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??[]),s=this.options.multiple?e:e.slice(0,1);if(s.length===0)return!1;let r=s.find(o=>!_o(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:s.find(o=>o.size>Number(this.options.maxSize));return n?(this._selectionError(new Error(`${n.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[r,n]of Object.entries(this.options.headers??{}))s.setRequestHeader(r,String(n));this.listen(s.upload,"progress",r=>{r.lengthComputable&&this._setProgress(r.loaded/r.total*100)}),this.listen(s,"load",()=>{if(s.status<200||s.status>=300){e(new Error(`Upload failed with HTTP ${s.status}`));return}t(go(s.responseText))}),this.listen(s,"error",()=>e(new Error("Upload request failed"))),this.listen(s,"abort",()=>e(bo())),s.send(mo(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 fo(i){let t=[];return i.accept&&t.push(String(i.accept)),i.maxSize!=null&&t.push(`up to ${po(Number(i.maxSize))}`),t.join(" \xB7 ")||"Choose from this device"}function po(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/1024)} KB`:`${Math.round(i/(1024*1024))} MB`}function _o(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 mo(i,t,e){let s=new FormData;for(let r of i)s.append(t,r);for(let[r,n]of Object.entries(e??{}))Gi(s,r,n);return s}function Gi(i,t,e){if(e==null)return;if(Array.isArray(e)){for(let r of e)Gi(i,t,r);return}typeof Blob=="function"&&e instanceof Blob?i.append(t,e):i.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function go(i){if(!i)return null;try{return JSON.parse(i)}catch{return i}}function bo(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let i=new Error("Upload aborted");return i.name="AbortError",i}function Qi(){b.register("upload",(i,t)=>{let e=i.own(new ut(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 Zi=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),Ji=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),dt=class extends p{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 Zi[this.options.reorder]??Zi.both}_renderRows(t=-1,e="value"){let s=Xi(this.options.options),r=this.options.options!==null,{drag:n,buttons:o}=this._reorder(),l=this._values.length-1,c=this._values.map((h,u)=>{let f=!r||s.some(([d])=>d===h)?s:[[h,h],...s],g=r?a("select",{class:"zx-multi-value-editor__value",ariaLabel:`Value ${u+1}`,dataset:{index:u}},f.map(([d,_])=>a("option",{value:d,selected:d===h},_))):a("input",{class:"zx-multi-value-editor__value",type:"text",value:h,ariaLabel:`Value ${u+1}`,dataset:{index:u}});return a("div",{class:"zx-multi-value-editor__row",dataset:{row:u}},n?a("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:`Reorder value ${u+1}. Use the arrow keys to move it.`,dataset:{action:"grab",index:u}},m("drag",{size:12})):null,g,a("div",{class:"zx-multi-value-editor__controls"},o?a("button",{class:"zx-btn",type:"button",ariaDisabled:String(u===0),ariaLabel:`Move value ${u+1} up`,dataset:{action:"up",index:u}},m("chevron-up",{size:12})):null,o?a("button",{class:"zx-btn",type:"button",ariaDisabled:String(u===l),ariaLabel:`Move value ${u+1} down`,dataset:{action:"down",index:u}},m("chevron-down",{size:12})):null,a("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${u+1}`,dataset:{action:"remove",index:u}},m("x",{size:12}))))});this._rows.replaceChildren(...c),t>=0&&c[Math.min(t,c.length-1)]?.querySelector(Ji[e]??Ji.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,r=Number(e.dataset.index);if(s==="add"){let n=Xi(this.options.options);this._values.push(this.options.options===null?"":n[0]?.[0]??""),this._renderRows(this._values.length-1),this._emitChange()}else s==="remove"&&Number.isInteger(r)?(this._values.splice(r,1),this._renderRows(Math.min(r,this._values.length-1)),this._emitChange()):(s==="up"||s==="down")&&Number.isInteger(r)&&this._move(r,r+(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),r=t.key==="ArrowUp"?s-1:t.key==="ArrowDown"?s+1:t.key==="Home"?0:t.key==="End"?this._values.length-1:-1;r<0||r>=this._values.length||(t.preventDefault(),this._move(s,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 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,r]of e.entries()){let n=r.getBoundingClientRect();if(t<n.top+n.height/2)return s}return e.length}_showDrop(t){let e=[...this._rows.children],s=t===this._dragIndex||t===this._dragIndex+1;for(let[r,n]of e.entries()){let o=n;!s&&r===t?o.dataset.drop="before":!s&&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,s){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,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 Xi(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 tr(){b.register("multivalueeditor",(i,t)=>{let e=i.own(new dt(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]})),s=new WeakMap,r=!1,n=()=>{e.el.setAttribute("aria-disabled",String(r));for(let o of e.el.querySelectorAll("input, button, select, textarea"))r?(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}),n()},focus:()=>e.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),setDisabled:o=>{r=!!o,n()}}})}var vt=class extends p{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:G(this.el);let t=this.el??a("div");this.el=t;let e=yo(this.options.step);this._step=e,this._precision=this.options.precision===null?xo(e):Math.max(0,Math.trunc(Number(this.options.precision)||0));let s=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=[s,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(s,"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 s=this._coerce(t),r=s!==this._value;return this._value=s,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=Hs(t,this.options.group?this._separators():null);return e===null?null:qs(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,n=Hs(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=er(l+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=Hs(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,s=this._rangeMin,r=this._rangeMax;if(s===null?e.removeAttribute("aria-valuemin"):e.setAttribute("aria-valuemin",String(s)),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 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&&Q(t,this._snapshot)}};function Hs(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 n=e.replace(/[^\d,.\-+eE]/g,""),o=n.lastIndexOf(","),l=n.lastIndexOf(".");s=n,o>=0&&o>l?s=n.replace(/\./g,"").replace(",","."):o>=0&&(s=n.replace(/,/g,""))}if(!/\d/.test(s))return null;let r=Number(s);return Number.isFinite(r)?r:null}function qs(i,{min:t,max:e,step:s,precision:r}){let n=i;if(s>0){let o=t??0;n=o+Math.round((i-o)/s)*s}return n=er(n,r),t!==null&&n<t?t:e!==null&&n>e?e:n}function yo(i){let t=Number(i);return Number.isFinite(t)&&t>0?t:1}function xo(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 er(i,t){return Number.isFinite(i)?Number(i.toFixed(Math.min(15,Math.max(0,t)))):i}function sr(){b.register("number",(i,t)=>{let e=i.own(new vt(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",r=>r.stopImmediatePropagation()),e.on("change",r=>{s||i.emit("change",{value:r.detail.value})}),{el:e.el,get:()=>e.get(),set:r=>{s=!0;try{e.set(r===""||r===null||r===void 0?null:r,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}var _e=class extends p{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:G(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=y("zx-rating");let e=a("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 r=a("span",{class:"zx-rating__symbol"},a("span",{class:"zx-rating__glyph",ariaHidden:"true"},m(this.options.icon,{size:Lt[this.options.size]??Lt.md})),a("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},m(this.options.icon,{size:Lt[this.options.size]??Lt.md})));this.options.allowHalf?r.append(this._radio(s-.5,"half"),this._radio(s,"full")):r.append(this._radio(s,"full")),e.append(r)}return t.replaceChildren(e,a("span",{ref:"readout",class:"zx-rating__readout"})),t.dataset.size=Lt[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),r=s!==this._value;return this._value=s,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 s=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(s,"click",r=>{this._choose(t,r.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 r=this.msg(t,...s);return r===t?E(e,s):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"],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,r)=>{let n=Math.min(1,Math.max(0,t-r));s.style.setProperty("--zx-rating-fill",`${n*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(vo(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&&Q(t,this._snapshot)}},Lt={sm:14,md:18,lg:24};function vo(i,t){return t<1?i.toFixed(1):String(i)}function ir(){b.register("rating",(i,t)=>{let e=i.own(new _e(null,{label:t.label?String(t.label):void 0,...t.props??{}})),s=!1;return e.on("change",r=>{s||i.emit("change",{value:r.detail.value})}),{el:e.el,get:()=>e.get()||null,set:r=>{s=!0;try{e.set(Number(r)||0,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}var Lh=["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 rr(i,t,{orientation:e="vertical",wrap:s=!0}={}){let r=new AbortController,n=new Map,o=!1;function l(){return Array.from(i.querySelectorAll(t)).filter(d=>(c(d),wo(d)))}function c(d){n.has(d)||n.set(d,d.getAttribute("tabindex"))}function h(d=null){let _=l(),w=d&&_.includes(d)?d:_.find(k=>k.tabIndex===0)??_[0];for(let k of _){let B=k===w?0:-1;k.tabIndex!==B&&(k.tabIndex=B)}}function u(d){let _=l(),w=d.target?.closest?.(t)??null,k=_.indexOf(w);if(k<0)return;let B=e==="horizontal"?"ArrowLeft":"ArrowUp",dn=e==="horizontal"?"ArrowRight":"ArrowDown",M=null;d.key==="Home"?M=0:d.key==="End"?M=_.length-1:d.key===B?M=k-1:d.key===dn&&(M=k+1),!(M===null||_.length===0)&&(s?M=(M+_.length)%_.length:M=Math.max(0,Math.min(_.length-1,M)),d.preventDefault(),h(_[M]),_[M].focus())}function f(d){let _=d.target?.closest?.(t)??null;_&&i.contains(_)&&h(_)}i.addEventListener("keydown",u,{signal:r.signal}),i.addEventListener("focusin",f,{signal:r.signal});let g=typeof MutationObserver=="function"?new MutationObserver(()=>h()):null;return g?.observe(i,{childList:!0,subtree:!0,attributes:!0}),h(),{focusFirst(){let d=l()[0];d&&(h(d),d.focus())},focusLast(){let d=l(),_=d[d.length-1];_&&(h(_),_.focus())},destroy(){if(!o){o=!0,r.abort(),g?.disconnect();for(let[d,_]of n)_===null?d.removeAttribute("tabindex"):d.setAttribute("tabindex",_);n.clear()}}}}function me(i,t){let e="",s=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;s!==null&&clearTimeout(s),e+=o.toLocaleLowerCase(),e.split("").every(h=>h===e[0])&&(e=e[0]),s=setTimeout(()=>{e="",s=null},500);let l=i(),c=l.findIndex(h=>Ao(h).startsWith(e));c>=0&&t(l[c],c)}}function wo(i){return!(!(i instanceof HTMLElement)||i.hidden||i.getAttribute("aria-hidden")==="true"||i.matches(":disabled"))}function Ao(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 ko=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],So=["Lowest","Low","Normal","High","Highest"],N=class i extends p{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=y("zx-select-list"),s=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"},s,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 h=a("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},c);return t.replaceChildren(l,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._disabled=!!this.options.disabled,this._handleTypeahead=me(()=>this._optionEntries.filter(u=>!u.clear).map(u=>u.element),(u,f)=>{this._open||this.open(),this._setActive(this._itemEntryIndex(f))}),this.listen(s,"click",()=>this.open()),this.listen(s,"input",()=>this._onInput()),this.listen(s,"keydown",u=>this._onKeydown(u)),this.listen(o,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(r,"click",()=>{this.set(null),this.focus()}),this.listen(h,"pointerdown",u=>u.preventDefault()),this.listen(h,"click",u=>this._onOptionClick(u)),this.listen(document,"pointerdown",u=>{this._open&&!t.contains(u.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,r=t==null?null:this._findItem(t);this._selected=r,this._syncInputValue(),this._renderOptions();let n=this.value;return!e&&!Object.is(s,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 s=e.value??null,r=new i(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(ko.map((n,o)=>({ID:o,name:r._message(n,So[o]),level:o}))),r.set(s,{silent:!0}),r}static permission(t,e={}){let{groups:s=[],value:r=!0,valueKey:n="ID",labelKey:o="name",...l}=e,c=typeof s=="function"?s:null,h=c?[]:s,u=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],f=new i(t,{filter:c??"local",...l,value:null,items:h,fixedItems:[],valueKey:g=>u.includes(g)?g.ID:$s(g,n),labelKey:g=>u.includes(g)?g.name:String($s(g,o)??"")});return u[0].name=f._message("permission.private","Private"),u[1].name=f._message("permission.public","Public"),f.setFixedItems(u),f.set(r,{silent:!0}),f}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(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&&zo(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=J(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((s,r)=>{r===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.placeholder||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(a("div",{class:"zx-select__separator",role:"presentation"}));for(let s of this._visibleItems){if(this.options.groupKey){let r=this._read(s,this.options.groupKey);Object.is(r,e)||(t.append(a("div",{class:"zx-select__group",role:"presentation"},String(r??""))),e=r)}this._appendOption(s,!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,s){let r=e?this._selected===null:this._selected!==null&&Object.is(this._itemValue(t),this.value),n=this._optionEntries.length,o=e?String(s??""):this._renderItem(t),l=a("div",{class:"zx-select__option",id:y("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 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.refs.clear.hidden=!this.options.clearable||this._selected===null}_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(n=>n===t);if(s!==void 0)return s;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 $s(t,e)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(t){return J(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 $s(i,t){return typeof t=="function"?t(i):i===null||typeof i!="object"?i:i[t]}function zo(i){return i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey}function nr(){b.register("zxselect",(i,t)=>{let e=i.own(new N(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.value,set:s=>e.set(s,{silent:!0}),focus:()=>e.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var ge=class extends p{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:G(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=y("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}),s=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(s),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&&Co.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 s=this._snap(t),r=s!==this._value;return this._value=s,this._paint(),r&&!e&&this.emit("change",{value:s}),this}setRange(t,e,s){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,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[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 s of t){let r=typeof s=="number"?s:Number(s?.value);if(!Number.isFinite(r))continue;let n=typeof s=="number"?this._format(r):String(s.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)?qs(e,{min:this._min,max:this._max,step:this._step,precision:Do(this._step)}):this._min}_ratio(t){return Et((t-this._min)/(this._max-this._min),0,1)}_format(t){let e=this.options.formatValue;return typeof e=="function"?String(e(t)):`${To(t)}${this.options.unit??""}`}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&Q(t,this._snapshot)}},Co=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function Do(i){let t=String(i),e=/e-(\d+)$/i.exec(t);return e?Number(e[1]):(t.split(".")[1]??"").length}function To(i){return String(Number(i.toFixed(6)))}function or(){b.register("slider",(i,t)=>{let e=i.own(new ge(null,{label:t.label?String(t.label):void 0,hideLabel:!0,disabled:!!t.disabled,...t.props??{}})),s=!1;return e.on("change",r=>{s||i.emit("change",{value:r.detail.value})}),{el:e.el,get:()=>e.get(),set:r=>{s=!0;try{e.set(Number(r)||0,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}var be=class extends p{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:G(this.el);let t=this.el??a("div");this.el=t;let e=y("zx-tag-picker-list"),s=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"},s,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",h=>{let u=h.target;u.closest(".zx-tag-picker__remove")||u.closest(".zx-tag-picker__toggle")||(h.target!==r&&(h.preventDefault(),this.focus()),this._open||this.open())}),this.listen(s,"click",h=>{let u=h.target.closest(".zx-tag-picker__remove");if(!u||this._disabled||this._readonly)return;h.stopPropagation();let f=[...s.children].indexOf(u.closest(".zx-tag-picker__tag")),g=this._selected[f];g!==void 0&&(this.removeValue(this._valueOf(g)),this.focus())}),this.listen(r,"input",()=>this._onInput()),this.listen(r,"keydown",h=>this._onKeydown(h)),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",h=>h.preventDefault()),this.listen(c,"click",h=>this._onOptionClick(h)),this.listen(document,"pointerdown",h=>{this._open&&!t.contains(h.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:[],r=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),n=[];for(let l of s){if(n.length>=r)break;let c=this._resolve(l);c!==null&&!n.some(h=>this._sameValue(h,c))&&n.push(c)}let o=!Eo(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 s=this._resolve(t);return s===null?this:this._selected.some(r=>this._sameValue(r,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),r=this._selected.findIndex(o=>Object.is(this._valueOf(o),s));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&&Q(t,this._snapshot)}_renderTags(){let t=this._selected.map(e=>{let s=this._labelOf(e),r=this.options.renderTag?this.options.renderTag(e):s,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",[s])},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:y("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 s=this.refs.input.value.trim();if(this._canCreate(s)){let n=a("div",{class:"zx-tag-picker__option",id:y("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",[s])));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 s=this._entries.find(r=>r.element===e);s&&this._commitEntry(s)}_commitEntry(t){if(!t)return;let e=this.refs.input;if(t.create){let s=e.value.trim(),r=this._createItem(s);this._items=this._items.concat([r]),this.addValue(r),this.emit("create",{value:this._valueOf(r),item:r})}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 r=e===t;s.element.toggleAttribute("data-active",r),r&&(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=J(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(r=>ar(this._labelOf(r))===ar(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(n=>Object.is(this._valueOf(n),e));if(s!==void 0)return s;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,s=[]){let r=this.msg(t,...s);return r!==t?r:s.reduce((n,o,l)=>n.replaceAll(`%${l+1}`,String(o)),e)}};function ar(i){return String(i??"").trim().toLocaleLowerCase()}function Eo(i,t,e){return i.length!==t.length?!1:i.every((s,r)=>Object.is(e(s),e(t[r])))}function lr(){b.register("tagpicker",(i,t)=>{let e=i.own(new be(null,{placeholder:t.placeholder,...t.props??{}})),s=!1;return i.listen(e.el,"change",r=>r.stopImmediatePropagation()),e.on("change",r=>{s||i.emit("change",{value:r.detail.values})}),{el:e.el,get:()=>e.getValues(),set:r=>{s=!0;try{e.setValues(Array.isArray(r)?r:[],{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}function cr(i,t="minutes"){let e=Math.round(Math.abs(ur(ft(i),t)));return{hours:Math.floor(e/3600),minutes:Math.floor(e/60)%60,seconds:e%60,negative:ft(i)<0}}function hr(i,t="minutes"){Vt(t);let e=Math.abs(Math.trunc(ft(i?.hours))),s=Math.abs(Math.trunc(ft(i?.minutes))),r=Math.abs(Math.trunc(ft(i?.seconds))),n=i?.negative?-1:1;return dr(n*(e*3600+s*60+r),t)}var pt=class extends p{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){Vt(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 hr(this._readParts(),t)}set(t,e=this.options.unit,s={}){e&&typeof e=="object"&&(s=e,e=this.options.unit),Vt(e);let r=ft(t);return!this.options.signed&&r<0&&(r=0),this.options.seconds||(r=dr(Math.round(ur(r,e)/60)*60,e)),this._parts=cr(r,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,r){let n=a("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:s,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 s=e.dataset.segment,r=e.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;t[s]=Math.max(0,Math.min(r,Math.trunc(ft(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]):No(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 ft(i){let t=Number(i);return Number.isFinite(t)?t:0}function ur(i,t){return Vt(t),t==="hours"?i*3600:t==="minutes"?i*60:i}function dr(i,t){return Vt(t),t==="hours"?i/3600:t==="minutes"?i/60:i}function Vt(i){if(i!=="hours"&&i!=="minutes"&&i!=="seconds")throw new RangeError(`Unknown time unit: ${i}`)}function No(i){return String(i).padStart(2,"0")}function fr(){b.register("time",(i,t)=>{let e=i.own(new pt(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 U=class extends p{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:Mo(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,e.type="button",e.setAttribute("role","switch");let s=[a("span",{class:"zx-toggle__track",ariaHidden:"true"},a("span",{class:"zx-toggle__thumb"}))];return this.options.label!==null&&s.push(a("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&&Oo(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function Mo(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Oo(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 pr(){b.register("toggle",(i,t)=>{let e=i.own(new U(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 _t=class extends p{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=_r(this.options.values,!!this.options.unique);let e=y("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",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=_r(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,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?`${s}. Press Delete to remove.`:s,dataset:{index:r}},a("span",{class:"zx-value-list__value"},s),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 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 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,s+o));t.ctrlKey&&r&&this.options.sortable?this._move(s,l,!0):this._list.querySelector(`[data-index="${l}"]`)?.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[r]=this._values.splice(t,1);this._values.splice(e,0,r),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 _r(i,t){if(!Array.isArray(i))return[];let e=i.map(s=>String(s));return t?[...new Set(e)]:e}function mr(){b.register("valuelist",(i,t)=>{let e=i.own(new _t(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 ye=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),Io=["xl","lg","md","sm"];function gr(i){let t=Number(i);if(!Number.isFinite(t))return"xs";for(let e of Io)if(t>=ye[e])return e;return"xs"}function br(i,t={}){if(typeof i!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in t&&!S(t.target)&&t.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let e=t.target??globalThis,s=S(e)?e:null,r=null,n=!1,o=null,l=()=>s?s.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,c=()=>{if(n)return;let f=l();if(s&&f===0)return;let g=gr(f);g!==r&&(r=g,i(r,f))};c();let h=0,u=()=>{h||n||(h=requestAnimationFrame(()=>{h=0,c()}))};return s&&typeof ResizeObserver=="function"?(o=new ResizeObserver(u),o.observe(s)):globalThis.addEventListener?.("resize",c,{passive:!0}),{current:()=>r??gr(l()),destroy:()=>{n||(n=!0,h&&cancelAnimationFrame(h),o?.disconnect(),globalThis.removeEventListener?.("resize",c))}}}var $=class{base;headers;onError;timeout;constructor({base:t="",headers:e={},onError:s=null,timeout:r=3e4}={}){this.base=String(t),this.headers=Object.freeze({...e}),this.onError=s,this.timeout=Number(r)}async request(t,e={}){let{method:s="GET",data:r=null,files:n=null,query:o=null,headers:l={}}=e,c=new AbortController,h=this.timeout>0?setTimeout(()=>c.abort(),this.timeout):null,u=new Headers(this.headers);for(let[d,_]of Object.entries(l))u.set(d,_);u.set("Accept",u.get("Accept")??"application/json");let f;n!==null?(f=Lo(r,n),u.delete("Content-Type")):r!==null&&s.toUpperCase()!=="GET"&&s.toUpperCase()!=="HEAD"&&(f=JSON.stringify(r),u.set("Content-Type",u.get("Content-Type")??"application/json"));let g=Fo(this.base+t,o);try{let d=await fetch(g,{method:s.toUpperCase(),headers:u,body:f,signal:c.signal}),_=await d.text(),w=null;if(_!=="")try{w=JSON.parse(_)}catch(k){let B=new Error("Invalid JSON response",{cause:k});throw B.response=d,B}if(!d.ok){try{Ks(w)}catch(B){throw B.response=d,B}let k=new Error(`HTTP ${d.status} ${d.statusText}`.trim());throw k.response=d,k}return Ks(w)}catch(d){let _=d instanceof Error?d:new Error(String(d));if(this.onError)try{this.onError(_,{path:t,options:e})}catch{}throw _}finally{h!==null&&clearTimeout(h)}}get(t,e=null){return this.request(t,{method:"GET",query:e})}post(t,e=null){return this.request(t,{method:"POST",data:e})}put(t,e=null){return this.request(t,{method:"PUT",data:e})}delete(t,e=null){return this.request(t,{method:"DELETE",data:e})}};function wt(i,t="",e={}){let{apiBase:s="../remotecall/",...r}=e,n=`${s}${i}${t?`:${t}`:""}/`;return new $({...r,base:n})}function Ks(i){if(i&&typeof i=="object"){if(Object.prototype.hasOwnProperty.call(i,"error")&&i.error!=null){let t=typeof i.error=="string"?i.error:JSON.stringify(i.error);throw new Error(t||"Server error")}if(Object.prototype.hasOwnProperty.call(i,"result"))return i.result}return i}function Fo(i,t){if(t==null)return i;let e;if(typeof t=="string")e=t.replace(/^\?/,"");else if(t instanceof URLSearchParams)e=t.toString();else{let s=new URLSearchParams;for(let[r,n]of Object.entries(t))yr(s,r,n);e=s.toString()}return e?i+(i.includes("?")?"&":"?")+e:i}function yr(i,t,e){if(e!=null)if(Array.isArray(e))for(let s of e)yr(i,t,s);else i.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function Lo(i,t){let e=new FormData;if(i&&typeof i=="object"&&!Array.isArray(i))for(let[r,n]of Object.entries(i))xr(e,r,n);else i!=null&&e.append("data",typeof i=="string"?i:JSON.stringify(i));let s=Vo(t)||Array.isArray(t)?Array.from(t):[t];for(let r of s)e.append("files",r);return e}function xr(i,t,e){if(e!=null)if(Array.isArray(e))for(let s of e)xr(i,t,s);else{let s=typeof Blob=="function"&&e instanceof Blob;i.append(t,typeof e=="object"&&!s?JSON.stringify(e):e)}}function Vo(i){return typeof FileList=="function"&&i instanceof FileList}var Pt=class extends p{static cssName="check-button";static defaults={label:"",checked:!1,icon:!0,disabled:!1};render(){let t=!this.el,e=this.el??a("button");if(this.el=e,e.localName!=="button")throw new TypeError("CheckButton target must be a button element");this._createdRoot=t,this._original=t?null:Po(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,this._labels=vr(this.options.label),e.type="button";let s=[];return this.options.icon&&s.push(a("span",{class:"zx-check-button__icon",ariaHidden:"true"},a("span",{class:"zx-check-button__off"},m("square",{size:15})),a("span",{class:"zx-check-button__on"},m("check",{size:15})))),s.push(a("span",{class:"zx-check-button__label",ref:"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}),this)}toggle(){return this.set(!this._checked)}setLabel(t){return this._labels=vr(t),this._sync(),this}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&&Bo(this.el,this._original))}_sync(){this.el.setAttribute("aria-pressed",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled),this.refs.label.textContent=this._checked?this._labels.on:this._labels.off}};function vr(i){return Array.isArray(i)?{on:String(i[0]??""),off:String(i[1]??"")}:{on:String(i??""),off:String(i??"")}}function Po(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Bo(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 xe=class extends p{static cssName="modal";static defaults={content:null,width:"auto",closable:!0,lightDismiss:!1,destroyOnClose:!1};#t;#e=!1;#s=!1;constructor(t=null,e={}){super(null,e),this.#i(this.options.width),wr(this.refs.content,this.options.content),this.listen(this.el,"cancel",s=>{let r=this.emit("cancel");(!this.options.closable||r.defaultPrevented)&&s.preventDefault()}),this.listen(this.el,"close",()=>{this.el.dataset.state="closed",delete this.el.dataset.zxOverlayOrder;let s=this.#e?this.#t:this.el.returnValue||void 0;this.#t=void 0,this.#e=!1,this.emit("close",{result:s}),this.options.destroyOnClose&&!this.#s&&this.destroy()}),this.listen(this.el,"click",s=>{!this.options.lightDismiss||s.target!==this.el||!jo(this.el,s)||this.close()})}render(){let t=a("dialog",{class:"zx-modal"},a("div",{class:"zx-modal__content",ref:"content"}));return t.dataset.state="closed",document.body.append(t),t}open(){if(this.isOpen())return this;this.el.dataset.zxOverlayOrder=String(Ro()),this.el.returnValue="";try{this.el.showModal()}catch(t){throw delete this.el.dataset.zxOverlayOrder,t}return this.el.dataset.state="open",this.emit("open"),this}close(t){return this.isOpen()?(this.#t=t,this.#e=!0,this.el.close(typeof t=="string"?t:""),this):this}setContent(t){return wr(this.refs.content,t),this}isOpen(){return this.el.open}destroy(){this.#s||(this.#s=!0,this.isOpen()&&this.el.close(),super.destroy())}#i(t){typeof t=="number"&&Number.isFinite(t)?this.el.style.inlineSize=`${Math.max(0,t)}px`:this.el.style.inlineSize=String(t??"auto")}};function wr(i,t){if(i.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t.nodeType=="number"&&i.append(t)}function jo(i,t){let e=i.getBoundingClientRect();return t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom}function Ro(){let i=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...i)+1}var Ho=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(","),At=class i extends xe{static cssName="dialog";static defaults={title:"",size:"md",buttons:[],closable:!0};#t=new Map;#e=null;#s=[];#i="";#r=null;constructor(t=null,e={}){super(null,e),this.#l(this.options.size),this.#i=String(this.options.title??""),this.#o(this.#i),this.#s=ve(this.options.buttons),this.#a(this.#s),this.refs.close.hidden=!this.options.closable,this.listen(this.refs.close,"click",()=>this.close()),this.listen(this.refs.footer,"click",s=>{let r=s.target.closest?.("[data-dialog-button]");if(!r||!this.refs.footer.contains(r))return;let n=this.#n[Number(r.dataset.dialogButton)];n&&this.#h(n)}),this.on("close",()=>this.#c())}#n=[];render(){let t=y("zx-dialog-title"),e=a("dialog",{class:"zx-modal zx-dialog",ariaLabelledby:t},a("header",{class:"zx-dialog__header"},a("h2",{class:"zx-dialog__title",id:t,ref:"title"}),a("button",{class:"zx-btn zx-dialog__close",ref:"close",type:"button","data-kind":"ghost",ariaLabel:"Close",title:"Close"},"\xD7")),a("div",{class:"zx-modal__content zx-dialog__body",ref:"content"}),a("footer",{class:"zx-dialog__footer",ref:"footer"}));return e.dataset.state="closed",document.body.append(e),e}open(){return this.isOpen()?this:(this.#r=document.activeElement instanceof Element?document.activeElement:null,super.open(),queueMicrotask(()=>{if(!this.isOpen())return;let e=this.el.querySelector("[autofocus]:not([disabled])")??this.el.querySelector(Ho);e instanceof HTMLElement&&e.focus()}),this)}setTitle(t){return this.#i=String(t??""),this.#o(this.#i),this}setContent(t){return this.#t.clear(),this.#e=null,qo(this.refs.content,t),this}setButtons(t){return this.#s=ve(t),this.#a(this.#s),this}addView(t,e){let s=String(t);this.#t.get(s)?.content.remove();let n=a("section",{class:"zx-dialog__view",hidden:!0,ariaHidden:"true"});Ar(n,e?.content??null);let o={key:s,content:n,buttons:e&&Object.hasOwn(e,"buttons")?ve(e.buttons??[]):null,title:e&&Object.hasOwn(e,"title")?String(e.title??""):null};return this.#t.set(s,o),this.#t.size===1||this.#e?.key===s?this.showView(s):this.refs.content.append(n),o}showView(t){let e=this.#t.get(String(t));if(!e)throw new RangeError(`Unknown dialog view: ${t}`);this.#e||this.refs.content.replaceChildren();for(let s of this.#t.values()){s.content.isConnected||this.refs.content.append(s.content);let r=s===e;s.content.hidden=!r,s.content.setAttribute("aria-hidden",String(!r))}return this.#e=e,this.#o(e.title??this.#i),this.#a(e.buttons??this.#s),e}getView(t){return this.#t.get(String(t))??null}static alert({title:t="",message:e="",okLabel:s="OK"}={}){return new Promise(r=>{let n=!1,o=()=>{n||(n=!0,l.close(),r())},l=new i(null,{title:t,content:e,buttons:[{label:s,kind:"primary",action:o,autofocus:!0}]});l.once("close",()=>{n||(n=!0,r()),l.destroy()}),l.open()})}static confirm({title:t="",message:e="",okLabel:s="OK",cancelLabel:r="Cancel",danger:n=!1}={}){return new Promise(o=>{let l=!1,c=u=>{l||(l=!0,h.close(u),o(u))},h=new i(null,{title:t,content:e,buttons:[{label:r,action:()=>c(!1)},{label:s,kind:n?"danger":"primary",action:()=>c(!0),autofocus:!0}]});h.once("close",()=>{l||(l=!0,o(!1)),h.destroy()}),h.open()})}static prompt({title:t="",message:e="",value:s="",placeholder:r=""}={}){return new Promise(n=>{let o=!1,l=a("input",{class:"zx-dialog__prompt-input",value:String(s),placeholder:String(r),autofocus:!0,ariaLabel:String(t||"Prompt value")}),c=a("div",{class:"zx-dialog__prompt"},a("div",{class:"zx-dialog__prompt-message"},e),l),h=f=>{o||(o=!0,u.close(f),n(f))},u=new i(null,{title:t,content:c,buttons:[{label:"Cancel",action:()=>h(null)},{label:"OK",kind:"primary",action:()=>h(l.value)}]});u.listen(l,"keydown",f=>{f.key==="Enter"&&(f.preventDefault(),h(l.value))}),u.once("close",()=>{o||(o=!0,n(null)),u.destroy()}),u.open()})}#l(t){let e={sm:400,md:600,lg:840},s=typeof t=="number"&&Number.isFinite(t)?t:e[t]??e.md;this.el.style.inlineSize=`${Math.max(0,s)}px`}#o(t){this.refs.title.textContent=t}#a(t){this.#n=ve(t),this.refs.footer.replaceChildren(),this.refs.footer.hidden=this.#n.length===0,this.#n.forEach((e,s)=>{this.refs.footer.append(a("button",{class:"zx-btn",type:"button","data-kind":e.kind??"default","data-size":"md","data-dialog-button":String(s),autofocus:!!e.autofocus},a("span",{class:"zx-btn__label"},e.label)))})}#h(t){let e=t.action??"close";e==="close"?this.close():e==="cancel"?this.emit("cancel").defaultPrevented||this.close():typeof e=="function"&&e(this)}#c(){this.#r?.isConnected&&typeof this.#r.focus=="function"&&this.#r.focus(),this.#r=null}};function ve(i){return Array.isArray(i)?i.map(t=>({...t,label:String(t.label??"")})):[]}function qo(i,t){i.replaceChildren(),Ar(i,t)}function Ar(i,t){if(t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t.nodeType=="number"&&i.append(t)}var Bt=class extends p{static cssName="groupbox";static defaults={title:"",open:!0};constructor(t,e={}){let s=t,r=null;if(t!==null){let n=Z(t);if(n&&n.localName!=="details"){let o=document.createElement("details"),l=Array.from(n.childNodes),c=n.parentNode,h=n.nextSibling;c&&c.insertBefore(o,n),o.append(...l),n.remove(),r={original:n,details:o,children:l,parent:c,next:h},s=o}}try{super(s,e)}catch(n){throw r&&kr(r),n}this._adoption=r}render(){let t=!this.el,e=this.el??a("details");if(e.localName!=="details")throw new TypeError("Groupbox requires a details element");this._createdRoot=t,this._original=t?null:$o(e);let s=Array.from(e.childNodes).filter(o=>!(o.nodeType===1&&o.localName==="summary")),r=a("summary",{class:"zx-groupbox__summary",ref:"summary"},a("span",{class:"zx-groupbox__chevron",ariaHidden:"true"},m("chevron-right",{size:16})),a("span",{class:"zx-groupbox__title",ref:"title"},String(this.options.title))),n=a("div",{class:"zx-groupbox__content",ref:"content"},s);return e.replaceChildren(r,n),e.open=!!this.options.open,this._lastOpen=e.open,this.listen(e,"toggle",()=>{let o=e.open;o!==this._lastOpen&&(this._lastOpen=o,this.emit(o?"open":"close"))}),e}open(){return this.el.setAttribute("open",""),this}close(){return this.el.removeAttribute("open"),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.el.open}setTitle(t){return this.refs.title.textContent=String(t),this}setContent(t){let e=t instanceof p?t.toElement():t;if(this.refs.content.replaceChildren(),typeof e=="string")this.refs.content.append(document.createTextNode(e));else if(e&&typeof e.nodeType=="number")this.refs.content.append(e);else throw new TypeError("Groupbox content must be a string, Node, or Component");return this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),this._adoption?kr(this._adoption):!this._createdRoot&&this._original&&Ko(this.el,this._original))}};function $o(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Ko(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 kr(i){if(i.original.replaceChildren(...i.children),i.details.parentNode)i.details.replaceWith(i.original);else if(i.parent){let t=i.next?.parentNode===i.parent?i.next:null;i.parent.insertBefore(i.original,t)}}var jt=class extends p{static cssName="search";static defaults={placeholder:"",value:"",clearable:!0,debounce:250};render(){let t=!this.el,e=this.el??a("form");this._createdRoot=t,this._original=t?null:Yo(e),this._inputTimer=null,e.setAttribute("role","search");let s=a("input",{class:"zx-search__input",ref:"input",type:"search",placeholder:String(this.options.placeholder),value:String(this.options.value),ariaLabel:String(this.options.placeholder||"Search")}),r=this.options.clearable?a("button",{class:"zx-search__clear",ref:"clear",type:"button",ariaLabel:"Clear search",title:"Clear search"},m("x",{size:15})):null,n=a("button",{class:"zx-search__submit",ref:"submit",type:e.localName==="form"?"submit":"button",ariaLabel:"Submit search",title:"Search"},m("search",{size:16}));return e.replaceChildren(...[s,r,n].filter(Boolean)),this._syncClear(),this.listen(s,"input",()=>{this._syncClear(),this._scheduleInput()}),e.localName==="form"?this.listen(e,"submit",o=>{o.preventDefault(),this.emit("submit",{value:this.get()})}):(this.listen(s,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this.emit("submit",{value:this.get()}))}),this.listen(n,"click",()=>this.emit("submit",{value:this.get()}))),r&&this.listen(r,"click",()=>this.clear()),e}get(){return this.refs.input.value}set(t,{silent:e=!1}={}){return this._inputTimer!==null&&(clearTimeout(this._inputTimer),this._inputTimer=null),this.refs.input.value=String(t),this._syncClear(),e||this._scheduleInput(),this}focus(){return this.refs.input.focus(),this}clear(){return this.set(""),this.emit("clear"),this.focus(),this}destroy(){this._cleaned||(this._cleaned=!0,this._inputTimer!==null&&clearTimeout(this._inputTimer),super.destroy(),!this._createdRoot&&this._original&&Uo(this.el,this._original))}_scheduleInput(){this._inputTimer!==null&&clearTimeout(this._inputTimer);let t=Math.max(0,Number(this.options.debounce)||0);this._inputTimer=setTimeout(()=>{this._inputTimer=null,this.emit("input",{value:this.get()})},t)}_syncClear(){this.refs.clear&&(this.refs.clear.hidden=this.get()==="")}};function Yo(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Uo(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 Wo=new Set(["divided","bracket","line","segmented"]),Rt=class extends p{static cssName="tabbox";static defaults={tabs:[],active:null,variant:"divided",keepAlive:!0};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??a("section");if(this.el=e,this._createdRoot=t,this._original=t?null:Qo(e),this._cleaned=!1,this._tabs=[],this._active=null,this._keepAlive=!!this.options.keepAlive,this._initializing=!0,!Wo.has(this.options.variant))throw new RangeError(`Unknown tabbox variant: ${this.options.variant}`);e.dataset.variant=this.options.variant;let s=a("div",{class:"zx-tabbox__tablist",ref:"tablist",role:"tablist",ariaOrientation:"horizontal"}),r=a("div",{class:"zx-tabbox__panels",ref:"panels"});if(e.replaceChildren(s,r),!Array.isArray(this.options.tabs))throw new TypeError("Tabbox tabs must be an array");for(let l of this.options.tabs)this.addTab(l);this._initializing=!1;let n=this.options.active===null?null:this._find(this.options.active),o=n&&!n.definition.disabled?n:this._enabledTabs()[0];return o&&this._applyActive(o),this.listen(s,"click",l=>{let c=l.target.closest?.('[role="tab"]');if(!c||!s.contains(c))return;let h=this._recordForTab(c);if(!(!h||h.definition.disabled)){if(l.target.closest?.(".zx-tabbox__close")){this._closeTab(h);return}this._setFocused(h),this.openTab(h.definition.name)}}),this.listen(s,"keydown",l=>this._onKeydown(l)),e}addTab(t,e={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Tab definition must be an object");if(typeof t.name!="string"||t.name==="")throw new TypeError("Tab name must be a non-empty string");if(this._find(t.name))throw new RangeError(`Tab already exists: ${t.name}`);if(!Go(t.content))throw new TypeError("Tab content must be a Node, Component, or function");let s={name:t.name,title:String(t.title??""),content:t.content,icon:t.icon?String(t.icon):null,closable:!!t.closable,disabled:!!t.disabled},r=y("zx-tab"),n=y("zx-tabpanel"),o=a("span",{class:"zx-tabbox__title"},s.title),l=a("span",{class:"zx-tabbox__badge",hidden:!0}),c=[];s.icon&&c.push(a("span",{class:"zx-tabbox__icon",ariaHidden:"true"},m(s.icon,{size:16}))),c.push(o,l),s.closable&&c.push(a("span",{class:"zx-tabbox__close zx-icon-btn",ariaHidden:"true",title:"Close"},m("x",{size:14})));let h=a("button",{class:"zx-tabbox__tab",type:"button",id:r,role:"tab",tabindex:"-1",ariaControls:n,ariaSelected:"false",ariaDisabled:s.disabled?"true":null,dataset:{closable:s.closable?"true":null}},c),u=a("div",{class:"zx-tabbox__panel",id:n,role:"tabpanel",tabindex:"0",ariaLabelledby:r,hidden:!0}),f={definition:s,tab:h,title:o,badge:l,panel:u,built:!1},g=Number.isFinite(e.index)?Math.trunc(e.index):this._tabs.length,d=Math.max(0,Math.min(this._tabs.length,g)),_=this._tabs[d]??null;return this._tabs.splice(d,0,f),this.refs.tablist.insertBefore(h,_?.tab??null),this._keepAlive&&this.refs.panels.insertBefore(u,_?.panel??null),!this._initializing&&!this._active&&!s.disabled&&this._applyActive(f),this}removeTab(t){return this._removeTab(t,!1),this}openTab(t){let e=this._find(t);if(!e||e.definition.disabled||e===this._active)return this;let s=this._active?.definition.name??null;return this.emit("change",{name:e.definition.name,previous:s}).defaultPrevented?this:(this._applyActive(e),this)}show(t){return this.openTab(t)}getActive(){return this._active?.definition.name??null}setTitle(t,e){let s=this._require(t);return s.definition.title=String(e??""),s.title.textContent=s.definition.title,this}setBadge(t,e){let s=this._require(t);return s.badge.textContent=e===null?"":String(e),s.badge.hidden=e===null,this}enableTab(t){let e=this._require(t);return e.definition.disabled?(e.definition.disabled=!1,e.tab.removeAttribute("aria-disabled"),this._active||this._applyActive(e),this):this}disableTab(t){let e=this._require(t);if(e.definition.disabled)return this;if(e===this._active){let s=this._enabledTabs().find(r=>r!==e)??null;if(s){if(this.openTab(s.definition.name),this._active===e)return this}else e.tab.setAttribute("aria-selected","false"),e.tab.tabIndex=-1,e.panel.hidden=!0,this._keepAlive||e.panel.remove(),this._active=null}return e.definition.disabled=!0,e.tab.setAttribute("aria-disabled","true"),e.tab.tabIndex=-1,this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&Zo(this.el,this._original))}_onKeydown(t){let e=t.target.closest?.('[role="tab"]');if(!e||!this.refs.tablist.contains(e))return;let s=this._recordForTab(e);if(!s)return;let r=this._enabledTabs();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let n=t.key==="ArrowRight"?1:-1,o=r.indexOf(s),l=r[(o+n+r.length)%r.length];l&&this._setFocused(l);return}if(t.key==="Home"||t.key==="End"){t.preventDefault();let n=t.key==="Home"?r[0]:r[r.length-1];n&&this._setFocused(n);return}if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.openTab(s.definition.name);return}t.key==="Delete"&&s.definition.closable&&(t.preventDefault(),this._closeTab(s))}_closeTab(t){let e=this._tabs.indexOf(t),s=t.tab.contains(document.activeElement);if(!this._removeTab(t.definition.name,!0))return;let r=this._tabs[Math.min(e,this._tabs.length-1)]??this._tabs[e-1],n=r&&!r.definition.disabled?r:this._active;n&&this._setFocused(n,s)}_removeTab(t,e){let s=this._find(t);if(!s)return!1;let r=this._tabs.indexOf(s),o=this._tabs.filter(c=>c!==s).filter(c=>!c.definition.disabled),l=o.find(c=>this._tabs.indexOf(c)>r)??o.at(-1)??null;return s===this._active&&l&&this.emit("change",{name:l.definition.name,previous:s.definition.name}).defaultPrevented?!1:(this._tabs.splice(r,1),s.tab.remove(),s.panel.remove(),s===this._active&&(this._active=null,l&&this._applyActive(l)),e&&this.emit("close",{name:s.definition.name}),!0)}_applyActive(t){this._ensureContent(t);let e=this._active;e&&e!==t&&(e.tab.setAttribute("aria-selected","false"),e.panel.hidden=!0,this._keepAlive||e.panel.remove()),this._active=t,t.tab.setAttribute("aria-selected","true"),t.panel.hidden=!1,t.panel.parentNode!==this.refs.panels&&this.refs.panels.append(t.panel),this._setFocused(t,!1)}_ensureContent(t){if(t.built)return;let e=typeof t.definition.content=="function"?t.definition.content():t.definition.content,s=e instanceof p?e.toElement():e;if(!s||typeof s.nodeType!="number")throw new TypeError(`Tab content factory for ${t.definition.name} must return a Node or Component`);t.panel.append(s),t.built=!0}_setFocused(t,e=!0){for(let s of this._tabs)s.tab.tabIndex=s===t?0:-1;e&&t.tab.focus()}_enabledTabs(){return this._tabs.filter(t=>!t.definition.disabled)}_find(t){return this._tabs.find(e=>e.definition.name===t)??null}_require(t){let e=this._find(t);if(!e)throw new RangeError(`Unknown tab: ${t}`);return e}_recordForTab(t){return this._tabs.find(e=>e.tab===t)??null}};function Go(i){return typeof i=="function"||i instanceof p?!0:!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function Qo(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Zo(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 Jo(i,t){return String(i).localeCompare(String(t))}function Xo(i,t){return i-t}function ta(i,t){return i.getTime()-t.getTime()}function ea(i,t,e="asc"){let s=i==null,r=t==null;if(s||r)return s&&r?0:s?1:-1;let n;return i instanceof Date&&t instanceof Date?n=ta(i,t):typeof i=="number"&&typeof t=="number"?n=Xo(i,t):n=Jo(i,t),e==="desc"?-n:n}function sa(i,t="asc"){return(e,s)=>ea(i(e),i(s),t)}function Sr(i,t,e="asc"){let s=sa(t,e);return i.map((r,n)=>({row:r,index:n})).sort((r,n)=>s(r.row,n.row)||r.index-n.index).map(({row:r})=>r)}var ia=new Set(["text","number","select","date","checkbox","textarea"]),ra='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',kt=class extends p{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=da(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=ha(this.options.editMode),this._edit=null,this._editMessage=null,this._stacked=!1,this._width=null,this._growStep=_a(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:y("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),Cr(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 Cr(t),this._data.push(...t),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._renderBody(),this._emitDataChange(),this}updateRow(t,e){let s=this._data.findIndex(n=>Object.is(this._idFor(n),t));if(s<0)return this;let r=this._selected.delete(t);return this._data[s]=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 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._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 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(),s.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))),s=new Set;if(this.options.selectable!==!1){for(let r of t)if(e.has(r)&&s.add(r),this.options.selectable==="single"&&s.size>0)break}return pa(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)}startEdit(t,e){if(this._editMode===!1)return this;let s=this._columns.find(u=>u.id===e);if(!s)return this;let r=this._data.find(u=>Object.is(this._idFor(u),t));if(r===void 0||Ht(s,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(u=>Object.is(this._idFor(u),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(u=>Ht(u,o)!==!1):[s],h=new Map;for(let u of c){let f=zr(l,u.id);if(!f)continue;let g=this._createEditor(f,u,o,n);g&&h.set(u.id,g)}return h.size===0?this:(this._edit={id:t,columnId:e,row:o,cells:h,tr:l},l.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,g]of t.cells)s[f]=g.read();let r=this._columns.filter(f=>t.cells.has(f.id)),n=ca(s,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(f=>f.id===n.columnId)??null,columnId:n.columnId,value:s[n.columnId],message:n.message}),this._focusEditor(n.columnId),this;this._clearInvalid();let o=la(e,s),l=t.columnId;if(this.emit("editcommit",{row:e,id:t.id,column:this._columns.find(f=>f.id===l)??null,columnId:l,value:s[l],previous:e?.[l],changes:o}).defaultPrevented)return this;let h=this._editHasFocus(),u={...e,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(t.id,u),h&&this._focusCell(this._idFor(u),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,s=this._rendered;return this._rendered=Math.min(this._data.length,this._rendered+e),this._rendered===s?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,s){let r=this.msg(t,...s);return r===t?E(e,s):r}_watchWidth(){this._width?.destroy(),this._width=null;let t=this.options.responsive;!t||!(t in ye)||(this._width=br((e,s)=>this._setStacked(s>0&&s<ye[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[s,r]of e)s&&(t?s.setAttribute("role",r):s.removeAttribute("role"));for(let[s,r]of[["tr","row"],["td","cell"],["th","columnheader"]])for(let n of this._table.querySelectorAll(s))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=>fa(r.width)),s=e.reduce((r,n)=>r+n,0);this._table.dataset.layout=s>0?"fixed":"auto",this._columns.forEach((r,n)=>{let o=a("col");e[n]>0?o.style.width=`${e[n]/s*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 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=a("th",{scope:"col"});if(e.align&&(s.dataset.align=e.align),e.headerTitle&&(s.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)}),s.append(r)}else s.append(a("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,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,s)=>t.append(this._createRow(e,s))),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 s=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(s))),this._rowMeta.set(r,{row:t,id:s,index:e});let o=this._rowElements.get(s)??[];if(o.push(r),this._rowElements.set(s,o),this.options.selectable==="multi"){let l=a("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",checked:this._selected.has(s),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,Ht(l,t)!==!1&&(c.dataset.editable="true",c.tabIndex=-1,this._offerRovingCell(c,s,l.id))),this._renderCellContent(c,l,t,e),r.append(c)}),r}_renderCellContent(t,e,s,r){let n=typeof e.render=="function"?e.render(s,r):s?.[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&&we(e))return;let s=e?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let r=this._rowMeta.get(s);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&&we(e))return;let s=e?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let r=this._rowMeta.get(s);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,s,r){let n=Ht(e,s);if(n===!1)return null;let o=s?.[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 h=a("div",{class:"zx-table__editor",dataset:{editor:n}});t.replaceChildren(c,h),t.dataset.editing="true";let u={column:e,type:n,td:t,host:h,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(n==="custom"){u.custom=o,u.read=()=>mt(e,u.custom,s);let d={value:o,row:s,column:e,commit:w=>{u.custom=w,this.commitEdit()},cancel:()=>this.cancelEdit()},_=e.editor(s,d);return _&&typeof _.toElement=="function"?(typeof _.destroy=="function"&&(u.component=_),h.append(_.toElement())):_&&h.append(_),u.control=h.querySelector(ra)??h,u}if(n==="number"){let d=new vt(null,{...l,value:o??null});return h.append(d.el),u.component=d,u.control=d.getInput(),u.read=()=>(d.set(d.getInput().value,{silent:!0}),mt(e,d.get(),s)),u}if(n==="select"){let d=na(e.options,s),_=d.find(k=>Object.is(k.value,o))??d.find(k=>String(k.value)===String(o??"")),w=new N(null,{...l,items:d,valueKey:"value",labelKey:"label",value:_?_.value:null});return h.append(w.el),u.component=w,u.control=w.refs.input,u.read=()=>mt(e,w.value,s),u}if(n==="date"){let d=new q(null,{...l,value:o??null});h.append(d.el),u.component=d;let _=d.refs.input;return u.control=_,u.read=()=>{let w=String(_.value??"").trim(),k=d.get();return w===""?mt(e,null,s):(d.set(w,{silent:!0}),d.get()===null&&d.set(k,{silent:!0}),mt(e,d.get(),s))},u}if(n==="checkbox"){let d=new U(null,{...l,checked:!!o});return h.append(d.el),u.component=d,u.control=d.el,u.read=()=>mt(e,d.get(),s),u}let f=n==="textarea",g=a(f?"textarea":"input",{...l,class:f?"zx-table__editor-input zx-table__editor-textarea":"zx-table__editor-input",...f?{}:{type:"text"},ariaLabel:l.ariaLabel??`${e.label} row ${r+1}`,value:oa(e,o,s)});return h.append(g),u.control=g,u.read=()=>mt(e,g.value,s),u}_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?zr(s,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)),s=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,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(),r=this.getRow(e.id)??e.row,n=this._columns.find(o=>o.id===e.columnId)??null;this._teardownEdit(),s&&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 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&&we(e)){if(ua(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 r=this._rowMeta.get(s.parentElement);r&&(t.preventDefault(),this.startEdit(r.id,String(s.dataset.column)))}_moveEdit(t){let e=this._edit;if(!e)return;let s=t.shiftKey?-1:1,r=this._data.findIndex(o=>Object.is(this._idFor(o),e.id)),n=this._nextEditableCell(r,e.columnId,s);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,s){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+=s,o>=r?(n+=1,o=0):o<0&&(n-=1,o=r-1),n<0||n>=this._data.length)return null;let h=this._data[n],u=this._columns[o];if(Ht(u,h)!==!1)return{id:this._idFor(h),columnId:u.id,index:n}}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 r=this._rowMeta.get(s.parentElement);r&&this._setRovingCell(s,r.id,String(s.dataset.column))}_handleDocumentPointerDown(t){if(!this._edit)return;let e=t.target?.nodeType===1?t.target:t.target?.parentElement;e&&we(e)||e&&this._tbody.contains(e)||this.commitEdit()}_offerRovingCell(t,e,s){if(this._rovingMatched)return;let r=this._rovingKey!==null&&Object.is(this._rovingKey.id,e)&&this._rovingKey.columnId===s;!r&&this._rovingCell||(r&&this._rovingCell&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=r)}_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 r=this._data.findIndex(n=>Object.is(this._idFor(n),this._selectionAnchorId));if(s&&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 s=this._selected.has(t);for(let r of e){r.setAttribute("aria-selected",String(s));let n=r.querySelector(".zx-table__row-checkbox");n&&(n.checked=s)}}this._syncSelectAll()}_syncSelectAll(){if(!this._selectAll)return;let t=this._visibleData(),e=t.reduce((s,r)=>s+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(s=>s.id===this._sort.id);if(!t)return;let e=typeof t.sortValue=="function"?t.sortValue:s=>s?.[t.id];this._data=Sr(this._data,e,this._sort.dir)}_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 Ht(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?"text":typeof e=="string"&&ia.has(e)?e:!1}function na(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,r])=>({value:s,label:String(r??"")})):[]}function oa(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 mt(i,t,e){return typeof i?.parse=="function"?i.parse(t,e):t}function aa(i,t){return Object.is(i,t)?!0:i instanceof Date&&t instanceof Date?i.getTime()===t.getTime():!1}function la(i,t){let e={};for(let[s,r]of Object.entries(t??{}))aa(i?.[s],r)||(e[s]=r);return e}function ca(i,t,e,s="Invalid value"){for(let r of t??[]){if(typeof r?.validate!="function"||!Object.prototype.hasOwnProperty.call(i??{},r.id))continue;let n=r.validate(i[r.id],e);if(typeof n=="string")return{columnId:r.id,message:n};if(n===!1)return{columnId:r.id,message:s}}return null}function ha(i){return i==="cell"||i==="row"?i:i===!0?"cell":!1}function we(i){return!!i?.closest?.(".zx-table__editor")}function ua(i){return i.closest("[popover]")?!0:i.getAttribute?.("aria-expanded")==="true"}function zr(i,t){for(let e of i.cells)if(e.dataset.column===t)return e;return null}function da(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 fa(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 Cr(i){if(!Array.isArray(i))throw new TypeError("Table data must be an array")}function pa(i,t){return i.size===t.size&&[...i].every(e=>t.has(e))}function _a(i){let t=Math.trunc(Number(i));return Number.isFinite(t)&&t>0?t:null}var ma=Object.freeze({label:"",icon:null,kind:"default",size:"md",disabled:!1});function W(i={}){let t={...ma,...i},e=a("button",{class:"zx-btn",type:"button",disabled:!!t.disabled,title:t.title,dataset:{kind:ga(t.kind),size:ba(t.size)}});return t.icon&&e.append(m(t.icon,{size:16})),t.label!==""&&e.append(a("span",{class:"zx-btn__label"},String(t.label))),!t.label&&t.title&&e.setAttribute("aria-label",t.title),typeof t.onclick=="function"&&(e.onclick=t.onclick),e}function Ys(i){let t=a("div",{class:"zx-btn-group",role:"group"});return t.append(...i),t}function ga(i){return["primary","danger","ghost"].includes(String(i))?i:"default"}function ba(i){return i==="sm"?"sm":"md"}var Tr=Symbol("zxDropdownPointerDismiss"),Er=Symbol("zxDropdownEscapeDismiss"),St=class extends p{static cssName="dropdown";static defaults={content:null,placement:"bottom-start",offset:4,matchWidth:!1,openOn:"click",closeOnSelect:!1};#t;#e=null;#s=new Map;#i=!1;constructor(t,e={}){let s=Z(t);if(!s)throw new TypeError("Dropdown anchor could not be resolved");super(null,e),this.#t=s,this.#r("aria-expanded"),this.#r("aria-controls"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("aria-controls",this.el.id),this.setContent(this.options.content),this.options.openOn==="click"&&this.listen(this.#t,"click",()=>this.toggle()),this.listen(this.el,"click",()=>{this.options.closeOnSelect&&this.close()})}render(){let t=a("div",{id:y("zx-dropdown"),popover:"manual"});return t.dataset.state="closed",document.body.append(t),t}open(){return this.isOpen()||this.#i?this:(this.#e=R(this.#t,this.el,{placement:this.options.placement,offset:Number(this.options.offset),matchWidth:!!this.options.matchWidth}),this.el.dataset.state="open",this.el.dataset.zxOverlayOrder=String(xa()),this.#t.setAttribute("aria-expanded","true"),va(),this.emit("open"),this)}close(){return this.isOpen()?(this.#e?.destroy(),this.#e=null,this.el.dataset.state="closed",delete this.el.dataset.zxOverlayOrder,this.#t.setAttribute("aria-expanded","false"),this.emit("close"),wa(),this):this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.#e!==null}setContent(t){return ya(this.el,t),this.#e?.update(),this}getPanel(){return this.el}destroy(){if(!this.#i){this.#i=!0,this.close();for(let[t,e]of this.#s)Aa(this.#t,t,e);super.destroy()}}[Tr](t){if(!this.isOpen())return;let e=t.composedPath();e.includes(this.el)||e.includes(this.#t)||this.close()}[Er](t){if(t.key!=="Escape"||!this.isOpen())return;t.preventDefault();let e=this.el.contains(document.activeElement);this.close(),e&&this.#t instanceof HTMLElement&&this.#t.focus()}#r(t){this.#s.set(t,this.#t.getAttribute(t))}},qt=class extends p{constructor(){super(null),this.listen(document,"pointerdown",t=>{let e=Dr();e instanceof St&&e[Tr](t)}),this.listen(document,"keydown",t=>{if(t.key!=="Escape")return;let e=Dr();e instanceof St&&e[Er](t)})}render(){let t=a("span",{hidden:!0,"data-zx-dropdown-dismiss-manager":""});return document.body.append(t),t}};function ya(i,t){if(i.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t.nodeType=="number"&&i.append(t)}function Dr(){let i=null,t=-1;for(let e of document.querySelectorAll("[data-zx-overlay-order]")){let s=Number(e.getAttribute("data-zx-overlay-order"))||0;s>t&&(t=s,i=e)}return i?p.from(i):null}function xa(){let i=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...i)+1}function va(){let i=document.querySelector("[data-zx-dropdown-dismiss-manager]"),t=i?p.from(i):null;return t instanceof qt?t:new qt}function wa(){if(document.querySelector('.zx-dropdown[data-state="open"]'))return;let i=document.querySelector("[data-zx-dropdown-dismiss-manager]"),t=i?p.from(i):null;t instanceof qt&&t.destroy()}function Aa(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}var Ae='[role="menuitem"]',et=class extends p{static cssName="menu-button";static defaults={label:"",icon:null,kind:"default",items:[],placement:"bottom-start"};#t;#e;#s;#i;#r=[];#n=null;#l=!1;#o=!1;constructor(t=null,e={}){let s=t===null?null:Z(t);if(t!==null&&(!s||s.tagName!=="BUTTON"))throw new TypeError("MenuButton target must resolve to a button");let r=s?{attributes:Array.from(s.attributes,o=>[o.name,o.value]),children:Array.from(s.childNodes)}:null,n=Object.hasOwn(e,"label");super(t,e),this.#l=s===null,this.#n=r,this.el.classList.add("zx-btn"),this.el.setAttribute("type","button"),this.el.setAttribute("data-kind",String(this.options.kind)),this.el.setAttribute("data-size","md"),this.#t=new St(this.el,{openOn:"manual",placement:this.options.placement,content:null}),this.#e=this.#t.getPanel(),this.#e.classList.add("zx-menu-button__menu"),this.#e.setAttribute("role","menu"),this.el.setAttribute("aria-haspopup","menu"),s&&n&&this.setLabel(this.options.label),this.setItems(this.options.items),this.#s=rr(this.#e,Ae),this.#i=me(()=>this.#u(),o=>o.focus()),this.#t.on("open",()=>this.emit("open")),this.#t.on("close",()=>this.emit("close")),this.listen(this.el,"click",()=>{this.isOpen()?this.close():(this.open(),this.#s.focusFirst())}),this.listen(this.el,"keydown",o=>this.#a(o)),this.listen(this.#e,"click",o=>{let l=o.target.closest?.(Ae);l&&this.#e.contains(l)&&this.#c(l)}),this.listen(this.#e,"keydown",o=>this.#h(o))}render(){return this.el?this.el:a("button",{class:"zx-btn",type:"button","data-kind":this.options.kind,"data-size":"md"},Nr(this.options.label,this.options.icon))}setItems(t){return this.#r=Array.isArray(t)?t.slice():[],this.#e.replaceChildren(),this.#r.forEach((e,s)=>{if(e==="-"){this.#e.append(a("div",{class:"zx-menu-button__separator",role:"separator"}));return}let r=[];e.icon&&r.push(a("span",{class:"zx-menu-button__icon"},m(e.icon))),r.push(a("span",{class:"zx-menu-button__label"},e.label)),this.#e.append(a("button",{class:"zx-menu-button__item",type:"button",role:"menuitem",tabindex:"-1","data-menu-item":String(s),"data-danger":e.danger?"true":null,ariaDisabled:e.disabled?"true":null},r))}),this}open(){return this.#t.open(),this}close(){return this.#t.close(),this}isOpen(){return this.#t.isOpen()}setLabel(t){return this.el.replaceChildren(...Nr(t,this.options.icon)),this}destroy(){if(!this.#o&&(this.#o=!0,this.#s.destroy(),this.#t.destroy(),super.destroy(),!this.#l&&this.#n)){for(let t of Array.from(this.el.attributes))this.el.removeAttribute(t.name);for(let[t,e]of this.#n.attributes)this.el.setAttribute(t,e);this.el.replaceChildren(...this.#n.children)}}#a(t){["ArrowDown","ArrowUp","Enter"," "].includes(t.key)&&(t.preventDefault(),this.open(),t.key==="ArrowUp"?this.#s.focusLast():this.#s.focusFirst())}#h(t){if(t.key==="Escape"){t.preventDefault(),this.close(),this.el.focus();return}if(t.key==="Tab"){this.close();return}if(t.key==="Enter"||t.key===" "){let e=t.target.closest?.(Ae);if(!e||!this.#e.contains(e))return;t.preventDefault(),this.#c(e);return}this.#i(t)}#c(t){let e=Number(t.getAttribute("data-menu-item")),s=this.#r[e];if(!(!s||s==="-"||s.disabled)){this.emit("select",{value:s.value,item:s});try{s.onselect?.(s.value,s,this)}finally{this.close()}}}#u(){return Array.from(this.#e.querySelectorAll(Ae))}};function Nr(i,t){let e=[];return t&&e.push(a("span",{class:"zx-btn__icon"},m(t))),e.push(a("span",{class:"zx-btn__label"},String(i??""))),e}var $t=class extends p{static cssName="panel";static defaults={title:"",content:null,open:!0,collapsible:!0,buttons:[],footer:null,footerButtons:[]};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??a("section");this.el=e,this._createdRoot=t,this._original=t?null:ka(e),this._cleaned=!1,this._open=!!this.options.open,this._collapsible=!!this.options.collapsible,this._hasFooterContent=!1;let s=t?[]:Array.from(e.childNodes),r=y("zx-panel-body"),n=a("span",{class:"zx-panel__title",ref:"title"}),o=[];this._collapsible&&o.push(a("span",{class:"zx-panel__chevron",ariaHidden:"true"},m("chevron-right",{size:16}))),o.push(n);let l=this._collapsible?a("button",{class:"zx-panel__toggle",ref:"toggle",type:"button",ariaControls:r,ariaExpanded:String(this._open)},o):a("div",{class:"zx-panel__toggle",ref:"toggle"},o),c=a("div",{class:"zx-panel__header",ref:"header"},l,a("div",{class:"zx-panel__buttons",ref:"buttons",role:"group",ariaLabel:"Panel actions"})),h=a("div",{class:"zx-panel__content",ref:"content"}),u=a("div",{class:"zx-panel__body",ref:"body",id:r},h),f=a("div",{class:"zx-panel__footer",ref:"footer",hidden:!0},a("div",{class:"zx-panel__footer-content",ref:"footerContent"}),a("div",{class:"zx-panel__footer-buttons",ref:"footerButtons",role:"group",ariaLabel:"Panel footer actions"}));return e.replaceChildren(c,u,f),this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):h.append(...s),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),this.setFooterButtons(this.options.footerButtons),this._syncOpenState(),this._collapsible&&this.listen(l,"click",()=>this.toggle()),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return Mr(this.refs.content,t,"Panel content"),this}setButtons(t){return this.refs.buttons.replaceChildren(...this._buildButtons(t,"Panel buttons")),this}setFooter(t){return Mr(this.refs.footerContent,t,"Panel footer"),this._hasFooterContent=t!==null,this._syncFooter(),this}setFooterButtons(t){return this.refs.footerButtons.replaceChildren(...this._buildButtons(t,"Panel footer buttons")),this._syncFooter(),this}open(){return this._open?this:(this._open=!0,this._syncOpenState(),this.emit("open"),this)}close(){return this._open?(this._open=!1,this._syncOpenState(),this.emit("close"),this):this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this._open}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&Sa(this.el,this._original))}_syncOpenState(){this.el.setAttribute("data-state",this._open?"open":"closed"),this.refs.body.hidden=!this._open,this._collapsible&&this.refs.toggle.setAttribute("aria-expanded",String(this._open))}_syncFooter(){this.refs.footer.hidden=!this._hasFooterContent&&this.refs.footerButtons.childElementCount===0}_buildButtons(t,e){if(!Array.isArray(t))throw new TypeError(`${e} must be an array`);return t.map(s=>{if(S(s))return s;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError(`${e} must be Elements or button descriptors`);let r={...s},n=r.onclick;delete r.onclick;let o=W(r);return typeof n=="function"&&this.listen(o,"click",n),o})}};function ka(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Sa(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 Mr(i,t,e){if(i.replaceChildren(),t===null)return;if(typeof t=="string"){i.append(document.createTextNode(t));return}let s=t instanceof p?t.toElement():t;if(s&&typeof s.nodeType=="number"){i.append(s);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}var za=Object.freeze(["default","settings","accounts","billing","calendar","campaigns","clocking","collection","contacts","contracts","enhancements","inventory","links","mailinglists","messages","notes","opportunities","pricelists","procurement","projects","tasks","tickets","pwd","system","usermgmt","usersettings","users","groups"]),Kt=class extends p{static cssName="master-panel";static defaults={title:"",content:null,buttons:[],module:null,footer:null};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??a("section");this.el=e,this._createdRoot=t,this._original=t?null:Ca(e),this._cleaned=!1;let s=t?[]:Array.from(e.childNodes),r=a("header",{class:"zx-master-panel__header"},a("h1",{class:"zx-master-panel__title",ref:"title"}),a("div",{class:"zx-master-panel__buttons",ref:"buttons",role:"group",ariaLabel:"Panel actions"})),n=a("div",{class:"zx-master-panel__content",ref:"content"}),o=a("footer",{class:"zx-master-panel__footer",ref:"footer",hidden:!0});e.replaceChildren(r,n,o);let l=Ta(this.options.module);return e.dataset.module=l,e.style.setProperty("--zx-master-panel-accent",`var(--zx-module-${l})`),this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):n.append(...s),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return Or(this.refs.content,t,"MasterPanel content"),this}setButtons(t){if(!Array.isArray(t))throw new TypeError("MasterPanel buttons must be an array");let e=t.map(s=>{if(S(s))return s;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("MasterPanel buttons must be Elements or button descriptors");let r={...s},n=r.onclick;delete r.onclick;let o=W(r);return typeof n=="function"&&this.listen(o,"click",n),o});return this.refs.buttons.replaceChildren(...e),this}setFooter(t){return Or(this.refs.footer,t,"MasterPanel footer"),this.refs.footer.hidden=t===null,this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&Da(this.el,this._original))}};function Ca(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Da(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 Or(i,t,e){if(i.replaceChildren(),t===null)return;if(typeof t=="string"){i.append(document.createTextNode(t));return}let s=t instanceof p?t.toElement():t;if(s&&typeof s.nodeType=="number"){i.append(s);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}function Ta(i){let t=String(i??"default").toLowerCase();return za.includes(t)?t:"default"}var Yt=class extends p{static cssName="navigation-bar";static defaults={title:"",items:[],active:null,actions:[]};constructor(t,e={}){super(t,e),this._overflow=new et(this.refs.moreTrigger,{label:"More",icon:"dots",kind:"ghost",items:[],placement:"bottom-end"}),this._overflow.on("select",s=>{let r=this._find(String(s.detail.value));!r||r.definition.disabled||(this.setActive(r.definition.name),r.definition.onselect?.(r.definition.name,r.definition,this),r.definition.href&&globalThis.location?.assign(r.definition.href))}),this._syncOverflow()}render(){let t=!this.el,e=this.el??a("section");this.el=e,this._createdRoot=t,this._original=t?null:Na(e),this._cleaned=!1,this._items=[],this._activeName=null,this._tabMode=!1,this._overflow=null;let s=a("header",{class:"zx-navigation-bar__bar"},a("div",{class:"zx-navigation-bar__brand",ref:"title"}),a("nav",{class:"zx-navigation-bar__navigation",ariaLabel:"Primary navigation"},a("div",{class:"zx-navigation-bar__items",ref:"items"}),a("div",{class:"zx-navigation-bar__more",ref:"more"},a("button",{class:"zx-navigation-bar__more-trigger",ref:"moreTrigger"}))),a("div",{class:"zx-navigation-bar__actions",ref:"actions",role:"group",ariaLabel:"Application actions"})),r=a("div",{class:"zx-navigation-bar__panels",ref:"panels",hidden:!0});return e.replaceChildren(s,r),this.setTitle(this.options.title),this.setItems(this.options.items),this.setActions(this.options.actions),this.listen(this.refs.items,"keydown",n=>this._onTabKeydown(n)),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setItems(t){if(!Array.isArray(t))throw new TypeError("NavigationBar items must be an array");let e=this._activeName,s=new Set,r=t.map(h=>{if(!h||typeof h!="object"||Array.isArray(h))throw new TypeError("Navigation item must be an object");if(typeof h.name!="string"||h.name==="")throw new TypeError("Navigation item name must be a non-empty string");if(s.has(h.name))throw new RangeError(`Navigation item already exists: ${h.name}`);if(s.add(h.name),Object.hasOwn(h,"content")&&!Ea(h.content))throw new TypeError(`Navigation panel content for ${h.name} is invalid`);let u={name:h.name,title:String(h.title??""),badge:h.badge==null?null:String(h.badge),href:h.href==null?void 0:String(h.href),disabled:!!h.disabled,onselect:typeof h.onselect=="function"?h.onselect:void 0};return Object.hasOwn(h,"content")&&(u.content=h.content),u}),n=r.some(h=>Object.hasOwn(h,"content"));if(n&&r.some(h=>!Object.hasOwn(h,"content")))throw new TypeError("NavigationBar panel items must all define content");this._items=[],this._activeName=null,this._tabMode=n,this.refs.items.replaceChildren(),this.refs.panels.replaceChildren(),this.refs.panels.hidden=!this._tabMode,this._tabMode?(this.refs.items.setAttribute("role","tablist"),this.refs.items.setAttribute("aria-orientation","horizontal")):(this.refs.items.removeAttribute("role"),this.refs.items.removeAttribute("aria-orientation"));for(let h of r)this._appendItem(h);let o=e??this.options.active,l=o===null?null:this._find(o),c=l&&!l.definition.disabled?l:this._enabledItems()[0];return c&&this._applyActive(c),this._syncOverflow(),this}setActive(t){let e=this._find(t);return!e||e.definition.disabled||t===this._activeName?this:(this._applyActive(e),this.emit("change",{name:e.definition.name}),this)}setBadge(t,e){let s=this._require(t);return s.definition.badge=e===null?null:String(e),s.badge.textContent=s.definition.badge??"",s.badge.hidden=s.definition.badge===null,this._syncOverflow(),this}setActions(t){if(!Array.isArray(t))throw new TypeError("NavigationBar actions must be an array");let e=t.map(s=>{if(S(s))return s;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("NavigationBar actions must be Elements or button descriptors");let r={...s},n=r.onclick;delete r.onclick;let o=W(r);return typeof n=="function"&&this.listen(o,"click",n),o});return this.refs.actions.replaceChildren(...e),this}destroy(){this._cleaned||(this._cleaned=!0,this._overflow?.destroy(),super.destroy(),!this._createdRoot&&this._original&&Ma(this.el,this._original))}_appendItem(t){let e=y("zx-navigation-item"),s=y("zx-navigation-panel"),r=a("span",{class:"zx-navigation-bar__badge",hidden:t.badge===null},t.badge??""),n={class:"zx-navigation-bar__item",id:e,ariaDisabled:t.disabled?"true":null},o;this._tabMode?o=a("button",{...n,type:"button",role:"tab",tabindex:"-1",ariaControls:s,ariaSelected:"false"},a("span",{class:"zx-navigation-bar__label"},t.title),r):t.href?o=a("a",{...n,href:t.href},a("span",{class:"zx-navigation-bar__label"},t.title),r):o=a("button",{...n,type:"button"},a("span",{class:"zx-navigation-bar__label"},t.title),r);let l=null;this._tabMode&&(l=a("div",{class:"zx-navigation-bar__panel",id:s,role:"tabpanel",tabindex:"0",ariaLabelledby:e,hidden:!0}),this.refs.panels.append(l));let c={definition:t,item:o,badge:r,panel:l,built:!1};this._items.push(c),this.refs.items.append(o),this.listen(o,"click",h=>{if(c.definition.disabled){h.preventDefault();return}this.setActive(c.definition.name),c.definition.onselect?.(c.definition.name,c.definition,this)})}_applyActive(t){this._tabMode&&this._ensurePanel(t);for(let e of this._items){let s=e===t;this._tabMode?(e.item.setAttribute("aria-selected",String(s)),e.item.tabIndex=s?0:-1,e.panel&&(e.panel.hidden=!s)):s?e.item.setAttribute("aria-current","page"):e.item.removeAttribute("aria-current")}this._activeName=t.definition.name}_ensurePanel(t){if(!t.panel||t.built)return;let e=t.definition.content,s=typeof e=="function"?e():e,r=s instanceof p?s.toElement():s;if(!r||typeof r.nodeType!="number")throw new TypeError(`Navigation panel factory for ${t.definition.name} must return a Node or Component`);t.panel.append(r),t.built=!0}_onTabKeydown(t){if(!this._tabMode)return;let e=t.target.closest?.('[role="tab"]');if(!e||!this.refs.items.contains(e))return;let s=this._items.find(n=>n.item===e);if(!s)return;let r=this._enabledItems();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let n=t.key==="ArrowRight"?1:-1,o=r.indexOf(s),l=r[(o+n+r.length)%r.length];l&&this._focusTab(l);return}if(t.key==="Home"||t.key==="End"){t.preventDefault();let n=t.key==="Home"?r[0]:r[r.length-1];n&&this._focusTab(n);return}(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.setActive(s.definition.name))}_syncOverflow(){this._overflow&&(this.refs.more.dataset.empty=this._items.length===0?"true":"false",this._overflow.setItems(this._items.map(t=>({label:t.definition.badge===null?t.definition.title:`${t.definition.title} (${t.definition.badge})`,value:t.definition.name,disabled:t.definition.disabled}))))}_focusTab(t){for(let e of this._items)e.item.tabIndex=e===t?0:-1;t.item.focus()}_enabledItems(){return this._items.filter(t=>!t.definition.disabled)}_find(t){return this._items.find(e=>e.definition.name===t)??null}_require(t){let e=this._find(t);if(!e)throw new RangeError(`Unknown navigation item: ${t}`);return e}};function Ea(i){return typeof i=="function"||i instanceof p?!0:!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function Na(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Ma(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 Ws=class{#t;#e=[];#s=[];#i;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.#i=e}enqueue(t){return this.#e.length<this.#t?(this.#e.push(t),this.#i(t),"active"):(this.#s.push(t),"pending")}remove(t){let e=this.#s.indexOf(t);if(e!==-1)return this.#s.splice(e,1),"pending";let s=this.#e.indexOf(t);if(s===-1)return null;if(this.#e.splice(s,1),this.#s.length>0){let r=this.#s.shift();this.#e.push(r),this.#i(r)}return"active"}isActive(t){return this.#e.includes(t)}clear(){let t={active:this.#e.slice(),pending:this.#s.slice()};return this.#e.length=0,this.#s.length=0,t}get activeCount(){return this.#e.length}get pendingCount(){return this.#s.length}},st=class i extends p{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:Ba(e),this._entries=new Set,this._queue=new Ws(Fa(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:Oa(e.kind??this.options.kind),timeout:Ia(e.timeout??this.options.timeout),closable:e.closable??!!this.options.closable},r=this._createEntry(t,s);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)Us(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&ja(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 r=!1;return{update:(n,o)=>{r||s.closed||(e.pct=Va(n),o!==void 0&&(e.text=String(o)),ke(s,e))},done:()=>{r||s.closed||(r=!0,e.pct=100,ke(s,e),s.remaining=600,this._queue.isActive(s)&&this._schedule(s))},fail:n=>{r||s.closed||(r=!0,n!==void 0&&(e.text=String(n)),s.kind="error",s.node.dataset.kind="error",s.node.setAttribute("role","alert"),s.iconHost.replaceChildren(m("error",{size:18})),ke(s,e),s.remaining=4e3,this._queue.isActive(s)&&this._schedule(s))}}}_createEntry(t,e,s=null){let r=a("span",{class:"zx-message__icon",ariaHidden:"true"},m(e.kind,{size:18})),n=a("div",{class:"zx-message__content"});La(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(s){o.dataset.progress="";let c=a("span",{class:"zx-message__progress-fill"}),h=a("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:s.text},c);n.append(h),l.progressBar=h,l.progressFill=c,ke(l,s)}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,Us(t),!this._queue.isActive(t)){this._queue.remove(t),t.node.remove(),this._entries.delete(t);return}if(t.node.dataset.state="closing",!Pa()){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)&&(Us(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 i(t),typeof t.showPopover=="function"&&t.showPopover(),this.#t}};function Oa(i){return i==="danger"?"error":["success","warning","error"].includes(String(i))?i:"info"}function Ia(i){let t=Number(i);return Number.isFinite(t)?Math.max(0,t):4e3}function Fa(i){let t=Number(i);return Number.isInteger(t)&&t>0?t:5}function La(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function Va(i){let t=Number(i);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function ke(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 Us(i){i.timer!==null&&clearTimeout(i.timer),i.exitTimer!==null&&clearTimeout(i.exitTimer),i.timer=null,i.exitTimer=null}function Pa(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function Ba(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function ja(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 Ut=class extends p{static cssName="permission";static defaults={value:!0,groups:[],groupsValueKey:"ID",groupsLabelKey:"name"};render(){this._mode="public",this._groupValue=null,this._groupSelect=null,this._createdRoot=!1,this._originalChildren=[],this._root=null,this._originalState=null,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._originalState=t.getAttribute("data-state"));let e=y("zx-permission"),s=a("div",{class:"zx-permission__choices",role:"radiogroup",ariaLabel:this._message("permission.label","Permission")}),r=this._choice(e,"private",this._message("permission.private","Private")),n=this._choice(e,"public",this._message("permission.public","Public")),o=this._choice(e,"group",this._message("permission.group","Group")),l=a("div",{ref:"groupHost",class:"zx-permission__groups"});s.append(r.label,n.label,o.label,l),t.replaceChildren(s),this.refs.private=r.input,this.refs.public=n.input,this.refs.group=o.input,this._groupSelect=new N(l,{items:Array.isArray(this.options.groups)?this.options.groups:[],valueKey:this.options.groupsValueKey,labelKey:this.options.groupsLabelKey,placeholder:this._message("permission.group","Group")}),this._groupSelect.refs.input.setAttribute("aria-label",this._message("permission.group","Group"));for(let c of[r.input,n.input,o.input])this.listen(c,"change",()=>{c.checked&&(c.value==="group"?this._selectGroupMode():this.set(c.value))});return this.listen(l,"zx-change",c=>{if(c.stopPropagation(),this._mode!=="group")return;let h=this.get();this._groupValue=c.detail.value;let u=this.get();Object.is(h,u)||this.emit("change",{value:u})}),this.set(this.options.value,{silent:!0}),t}get(){return this._mode==="private"?"private":this._mode==="public"?"public":this._groupValue}set(t,{silent:e=!1}={}){let s=this.get();t===!0||t==="public"?this._mode="public":t===!1||t==="private"?this._mode="private":(this._mode="group",this._groupValue=t,this._groupSelect?.set(t,{silent:!0})),this._sync();let r=this.get();return!e&&!Object.is(s,r)&&this.emit("change",{value:r}),this}destroy(){this._groupSelect?.destroy(),this._groupSelect=null,!this._createdRoot&&this.el&&(this.el.replaceChildren(...this._originalChildren),this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState)),super.destroy()}_selectGroupMode(){let t=this.get();if(this._mode="group",this._groupValue==null){let s=Array.isArray(this.options.groups)?this.options.groups[0]:null;this._groupValue=s==null?null:Ra(s,this.options.groupsValueKey)}this._groupSelect?.set(this._groupValue,{silent:!0}),this._sync();let e=this.get();Object.is(t,e)||this.emit("change",{value:e})}_sync(){this.refs.private.checked=this._mode==="private",this.refs.public.checked=this._mode==="public",this.refs.group.checked=this._mode==="group",this._mode==="group"?this._groupSelect?.enable():this._groupSelect?.disable(),this._root?.setAttribute("data-state",this._mode)}_choice(t,e,s){let r=a("input",{type:"radio",name:t,value:e});return{label:a("label",{class:"zx-permission__choice"},r,a("span",{},s)),input:r}}_message(t,e){let s=this.msg(t);return s===t?e:s}};function Ra(i,t){return typeof t=="function"?t(i):i===null||typeof i!="object"?i:i[t]}function Ir(i){return String(i??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLocaleLowerCase()}function Ha(i,t){let e=Ir(t).trim().split(/\s+/).filter(Boolean);if(e.length===0)return!0;let s=Ir(i.flat(1/0).join(" "));return e.every(r=>s.includes(r))}function Qs(i){return i!=null&&!(typeof i=="string"&&i.trim()==="")}function Fr(i,t){if(typeof t.get=="function")return Gs(t.get(i));let e=t.fields??t.field??t.id;return(Array.isArray(e)?e:[e]).flatMap(r=>Gs(typeof r=="function"?r(i):r==null?void 0:i?.[r]))}function Lr(i,t){let e=[],s=new Map;for(let r of i)for(let n of Fr(r,t)){let o=Vr(n);o.value==null||o.value===""||s.has(o.value)||(s.set(o.value,!0),e.push(o))}return e}function gt(i,t,e){return i.filter(s=>t.every(r=>{let n=e?.[r.id];if(!Qs(n))return!0;if(r.type==="custom")return typeof r.predicate!="function"||!!r.predicate(s,n);let o=Fr(s,r);return r.type==="text"?Ha(o,n):r.type==="select"?o.some(l=>qa(Vr(l).value,n)):!0}))}function Gs(i){return Array.isArray(i)?i.flat(1/0):[i]}function Vr(i){if(i&&typeof i=="object"&&!(i instanceof Date)){if(Object.prototype.hasOwnProperty.call(i,"value"))return{value:i.value,label:String(i.label??i.value??"")};if(Object.prototype.hasOwnProperty.call(i,"field"))return{value:i.field,label:String(i.label??i.field??"")}}return{value:i,label:String(i??"")}}function qa(i,t){return Object.is(i,t)?!0:i==null||t==null?!1:String(i)===String(t)}var Wt=class extends p{static cssName="data-filter";static defaults={filters:[],data:[],autoApply:!0,clearLabel:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??a("div");this._originalChildren=this.el?Array.from(this.el.childNodes):null,this._filters=Array.isArray(this.options.filters)?this.options.filters.map(s=>({...s})):[],this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._state={},this._entries=new Map,this._customOrigins=new Map,this._restored=!1;let e=new Set;for(let s of this._filters){if(Zs(s),e.has(s.id))throw new RangeError(`Duplicate filter id: ${s.id}`);e.add(s.id),s.type==="custom"&&!this._customOrigins.has(s.element)&&this._customOrigins.set(s.element,{parent:s.element.parentNode,nextSibling:s.element.nextSibling}),this._state[s.id]=s.type==="custom"?Js(s.element):""}this._filtered=gt(this._data,this._filters,this._state),this._controls=a("div",{class:"zx-data-filter__controls"}),this._badge=a("span",{class:"zx-data-filter__badge",ariaLive:"polite",hidden:!0},"0"),this._clearButton=a("button",{class:"zx-data-filter__clear",type:"button",hidden:!0},this.options.clearLabel==null?this.msg("dataFilter.clear"):String(this.options.clearLabel)),t.replaceChildren(this._controls,this._badge,this._clearButton),this.listen(this._clearButton,"click",()=>this.clear());for(let s of this._filters)this._appendFilter(s);return this._syncActiveState(),t}setData(t){Ya(t),this._data=[...t];for(let e of this._filters){if(e.type!=="select")continue;let s=this._entries.get(e.id);s&&this._populateSelect(e,s)}return this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=gt(this._data,this._filters,this._state),this}apply(){this._filtered=gt(this._data,this._filters,this._state);let t=[...this._filtered];return this.emit("filter",{rows:t,state:this.getState()}),t}clear(){for(let t of this._filters)this._state[t.id]="";return this._syncControls(),this._syncActiveState(),this.apply(),this}getState(){return{...this._state}}setState(t){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("DataFilter state must be an object");for(let e of this._filters)this._state[e.id]=Object.prototype.hasOwnProperty.call(t,e.id)?t[e.id]:"";return this._syncControls(),this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=gt(this._data,this._filters,this._state),this}addFilter(t){Zs(t);let e={...t};return this._filters.push(e),this._state[e.id]=e.type==="custom"?Js(e.element):"",this._appendFilter(e),this._filtered=gt(this._data,this._filters,this._state),this._syncActiveState(),this}destroy(){this._restored||(this._originalChildren&&this.el.replaceChildren(...this._originalChildren),Ua(this._customOrigins),this._restored=!0),super.destroy()}_appendFilter(t){if(Zs(t),this._entries.has(t.id))throw new RangeError(`Duplicate filter id: ${t.id}`);let e,s={element:null,options:[]};if(t.type==="select")e=a("select",{ariaLabel:t.label}),s.element=e,this._populateSelect(t,s),this.listen(e,"change",()=>{let n=Number(e.value)-1;this._state[t.id]=n>=0?s.options[n]?.value??"":"",this._controlChanged()});else if(t.type==="text")e=a("input",{type:"search",placeholder:t.placeholder??"",ariaLabel:t.label,autocomplete:"off"}),s.element=e,this.listen(e,"input",()=>{this._state[t.id]=e.value,this._controlChanged()});else{e=t.element,this._customOrigins.has(e)||this._customOrigins.set(e,{parent:e.parentNode,nextSibling:e.nextSibling}),s.element=e;let n=e.matches?.('input:not([type="checkbox"]):not([type="radio"]), textarea')?"input":"change";this.listen(e,n,()=>{this._state[t.id]=Js(e),this._controlChanged()})}this._entries.set(t.id,s);let r=a("label",{class:"zx-data-filter__field"},a("span",{class:"zx-data-filter__label"},t.label),e);this._controls.append(r)}_populateSelect(t,e){let s=this._state[t.id];e.options=Array.isArray(t.options)?t.options.map($a):Lr(this._data,t);let r=a("option",{value:""},t.emptyLabel??this.msg("dataFilter.all")),n=document.createDocumentFragment();n.append(r),e.options.forEach((l,c)=>{n.append(a("option",{value:String(c+1)},l.label))}),e.element.replaceChildren(n);let o=e.options.findIndex(l=>Pr(l.value,s));e.element.value=o>=0?String(o+1):"",o<0&&(this._state[t.id]="")}_controlChanged(){this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=gt(this._data,this._filters,this._state)}_syncControls(){for(let t of this._filters){let e=this._entries.get(t.id);if(!e)continue;let s=this._state[t.id];if(t.type==="select"){let r=e.options.findIndex(n=>Pr(n.value,s));e.element.value=r>=0?String(r+1):"",r<0&&(this._state[t.id]="")}else Ka(e.element,s)}}_syncActiveState(){let t=this._filters.reduce((e,s)=>e+Number(Qs(this._state[s.id])),0);this._badge.textContent=String(t),this._badge.hidden=t===0,this._clearButton.hidden=t===0}};function Zs(i){if(!i||typeof i!="object")throw new TypeError("Filter definition must be an object");if(!["select","text","custom"].includes(i.type))throw new TypeError(`Unknown filter type: ${i.type}`);if(typeof i.id!="string"||!i.id)throw new TypeError("Filter definition requires an id");if(i.type==="custom"){if(!i.element||i.element.nodeType!==1)throw new TypeError("Custom filter requires an Element");if(typeof i.predicate!="function")throw new TypeError("Custom filter requires a predicate")}}function $a(i){return i&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,"value")?{value:i.value,label:String(i.label??i.value??"")}:{value:i,label:String(i??"")}}function Js(i){return"checked"in i&&["checkbox","radio"].includes(i.type)?i.checked:"value"in i?i.value:i.getAttribute("data-value")??""}function Ka(i,t){"checked"in i&&["checkbox","radio"].includes(i.type)?i.checked=!!t:"value"in i?i.value=t==null?"":String(t):t==null||t===""?i.removeAttribute("data-value"):i.setAttribute("data-value",String(t))}function Pr(i,t){return Object.is(i,t)?!0:i==null||t==null?!1:String(i)===String(t)}function Ya(i){if(!Array.isArray(i))throw new TypeError("DataFilter data must be an array")}function Ua(i){let t=[...i];for(let e=t.length;t.length>0&&e>=0;e-=1){let s=0;for(let r=t.length-1;r>=0;r-=1){let[n,o]=t[r];if(!o.parent)n.remove();else{if(o.nextSibling&&o.nextSibling.parentNode!==o.parent)continue;o.parent.insertBefore(n,o.nextSibling)}t.splice(r,1),s+=1}if(s===0)break}for(let[e,s]of t)s.parent?s.parent.append(e):e.remove()}var it=class extends p{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 s=this.options.fields&&typeof this.options.fields=="object"?this.options.fields:{};for(let[r,n]of Object.entries(s))this.addField(r,n);return t}addField(t,e){let s=String(t);if(this._fields.has(s))throw new Error(`Field "${s}" already exists`);let r,n=!1;if(e instanceof b)r=e;else if(S(e)||e instanceof p){let o=e;r=new b(null,{id:s,type:"custom",label:s,value:Ga(o),disabled:Qa(o),adapter:()=>Wa(o)}),n=!0}else{let o=e&&typeof e=="object"?e:{};r=new b(null,{...o,id:o.id??s}),n=!0}return n?this._ownedFields.add(r):this._origins.set(r,{parent:r.el.parentNode,next:r.el.nextSibling}),this._fields.set(s,r),this._fieldIdAttributes.set(r,r.el.getAttribute("data-field-id")),r.el.dataset.fieldId=s,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,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,r]of Object.entries(t))this._fields.get(s)?.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 s=0;for(let[r,n]of this._fields){let o=t?.[r];o?(n.setHighlight(String(o),e),s+=1):n.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 Wa(i){let t=S(i)?i:i.toElement(),e=t.parentNode,s=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 i.getValue=="function"?i.getValue():typeof i.getValues=="function"?i.getValues():"value"in t?t.value:null,set:(l,c)=>{typeof i.setValue=="function"?i.setValue(l,c):typeof i.setValues=="function"&&l&&typeof l=="object"?i.setValues(l,c):"value"in t&&(t.value=l??"")},focus:()=>{typeof i.focus=="function"?i.focus():typeof t.focus=="function"&&t.focus()},setDisabled:l=>{typeof i.setDisabled=="function"?i.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,s?.parentNode===e?s:null):t.remove()}}}function Ga(i){let t=S(i)?i:i.toElement();return typeof i.getValue=="function"?i.getValue():typeof i.getValues=="function"?i.getValues():"value"in t?t.value:null}function Qa(i){let t=S(i)?i:i.toElement();return"disabled"in t?!!t.disabled:t.getAttribute("aria-disabled")==="true"}var Gt=class extends p{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",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 it),s=e?new it(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",r=>{let n=r.target,o=n instanceof Element?n.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 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:s,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 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,r)=>s+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&&Xs(l))c=this.msg("form.required");else if(!Xs(l)&&o.options.type==="int"){let h=Ts(l);h.valid?o.setValue(h.value,{silent:!0}):c=this.msg("form.int")}else if(!Xs(l)&&o.options.type==="float"){let h=Es(l);h.valid?o.setValue(h.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 s=this._actionDescriptors[Number(e.dataset.actionIndex)],r=s?.onClick??s?.onclick??s?.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 Xs(i){return i==null||i===""||i===!1||Array.isArray(i)&&i.length===0}function Za(){nr(),yi(),Wi(),Fi(),Ki(),fr(),mr(),tr(),Qi(),pr(),sr(),ir(),lr(),or()}Za();function K(i){return i==null?null:typeof i=="string"?document.querySelector(i):i?.nodeType===1?i:null}function D(i){return i==null||typeof i=="string"||typeof i=="number"||i?.nodeType||typeof i?.toElement=="function"||typeof i=="function"?i:Y(i)||String(i)}function ti(i){let t=String(i??"").toLowerCase().replace(/^s_msg_32_/,"").replace(/^icon-/,"");return t.includes("error")||t.includes("danger")||t.includes("remove")?"error":t.includes("success")||t.includes("ok")||t.includes("check")?"success":t.includes("warn")?"warning":"info"}function Qt(i,t,e){Object.hasOwn(i,"_compatWarned")||(Object.defineProperty(i,"_compatWarned",{value:!0}),console.warn(`${t} is running on the Zx compat layer \u2014 migrate to zx.${e}`))}function Br(i,t,e){let s=`_compatMethod_${t}`;Object.hasOwn(i,s)||(Object.defineProperty(i,s,{value:!0}),console.warn(`${i.legacyName}.${t} has no direct Zx equivalent; use ${e}`))}function Zt(i){return i==null?"":String(typeof i=="string"||typeof i=="number"?i:i.label??i.title??i.text??i.name??i.value??"")}var Se=class extends x{static legacyName="gx.zeyos.Toggle";constructor(t,e={}){super(e,{on:!1,value:!0});let{target:s,host:r}=Ie(t),n=new U(s,{checked:!!e.on,value:e.value??!0,label:e.label??null,disabled:!!e.disabled});r&&r.append(n.toElement()),this._attach(n,{events:{check:{type:"change",filter:o=>o.checked,args:()=>[this]},uncheck:{type:"change",filter:o=>!o.checked,args:()=>[this]},change:{type:"change",args:o=>[o.checked]}},setters:{on:o=>o?this.setChecked():this.setUnchecked(),value:o=>{n.options.value=o}}}),n.on("change",()=>this._syncAct()),this._syncAct()}getState(){return this._zx.get()}getValue(){return this._zx.getValue()}toggle(){return this._zx.toggle(),this._syncAct(),this}setChecked(t=!1){return this._zx.set(!0,{silent:!!t}),this._syncAct(),this}setUnchecked(t=!1){return this._zx.set(!1,{silent:!!t}),this._syncAct(),this}_syncAct(){this._mirrorAct(this.toElement(),this.getState())}},ze=class extends x{static legacyName="gx.zeyos.Msgbox";constructor(t={}){super(t,{closable:!0,content:!1});let e=new st(null,{timeout:0,closable:t.closable!==!1,maxVisible:1});document.body.append(e.toElement()),this._handle=null,this._content=t.content||"",this._attach(e,{ui:{frame:"root",content:"root",img:"root"}})}setContent(t){return this._content=D(t),this}show(t,e="info"){return t!=null&&this.setContent(t),this._handle?.close(),this._handle=this._zx.show(this._content,{kind:ti(e),timeout:0,closable:this.options.closable!==!1}),this._mirrorAct(this.toElement(),!0),this}hide(){return this._handle?.close(),this._handle=null,this._mirrorAct(this.toElement(),!1),this}},Ce=class extends x{static legacyName="gx.bootstrap.Message";constructor(t,e={}){super(e,{duration:3e3});let s=new st(K(t),{timeout:Number(e.duration)||0,closable:!0,maxVisible:e.maxVisible??5});K(t)||document.body.append(s.toElement()),this._handles=new Map,this._progress=null,this._progressValue=0,this._attach(s,{ui:{windows:"root",status:"root"}})}addMessage(t,e="info",s=!0,r=!1,n=!0){let o=document.createElement("span");o.hidden=!0;let l=this._zx.show(D(t),{kind:ti(e),closable:s!==!1,timeout:n===!1?0:Number(this.options.duration)||0});return this._handles.set(o,l),o}closeMessage(t){return this._handles.get(t)?.close(),this._handles.delete(t),this}clear(){for(let t of this._handles.values())t.close();return this._handles.clear(),this}showStatus(t,e="",s=!1){return this._progress||(this._progress=st.progress(String(e))),this._progressValue=Number(t)||0,this._progress.update(this._progressValue,String(e)),this}incProgress(t,e){return this.setProgress(this._progressValue+(Number(t)||0),e)}setProgress(t,e,s){return this._progress||(this._progress=st.progress(String(e??""))),this._progressValue=Number(t)||0,this._progress.update(this._progressValue,e==null?void 0:String(e)),this}hideStatus(){return this._progress?.done(),this._progress=null,this._progressValue=0,this}},De=class extends x{constructor(t={}){super(t,{width:600,closable:!0,content:null});let e=new At(null,{title:String(t.title??""),size:Ja(t.width),closable:t.closable!==!1,lightDismiss:!!(t.overlayDismiss??t.clickable),content:D(t.content)});this._attach(e,{events:{show:{type:"open",args:()=>[this]},hide:{type:"close",args:s=>[s.result,this]},open:{type:"open",args:()=>[this]}},ui:{modal:"root",aside:"content",body:"content",content:"content",title:"title",footer:"footer",cross:"close"},setters:{content:"setContent",title:"setTitle",open:s=>s?this.show():this.hide()}}),this.isOpen=!1,t.footer&&e.setButtons(qr(t.footer)),t.open&&this.show()}show(t){return this.isOpen=!0,this._showArgument=t,this._zx.open(),this}hide(t){return this.isOpen=!1,this._zx.close(t),this}setContent(t){return this._zx.setContent(D(t)),this}setTitle(t){return this._zx.setTitle(t),this}getContent(){return this._zx.refs.content}setPosition(t,e){return Br(this.constructor,"setPosition","CSS dialog positioning"),this}},Te=class extends De{static legacyName="gx.zeyos.Popup"},zt=class extends De{static legacyName="gx.bootstrap.Popup"},ei=Object.freeze({});function si(i,t,e={}){Qt(si,"gx.bootstrap.PopupAlert","Dialog.alert");let s=typeof e=="string"?{type:e}:e;return new Promise(r=>{let n=new zt({...s,title:i,content:t,width:s.width??400});n._zx.setButtons([{label:s.okLabel??"Ok",kind:"primary",autofocus:!0,action:()=>{typeof s.onOk=="function"&&s.onOk()===!1||(n.hide(),r())}}]),n._zx.once("close",()=>n.destroy()),n.show()})}function ii(i,t,e={}){Qt(ii,"gx.bootstrap.PopupConfirm","Dialog.confirm");let s=typeof e=="string"?{type:e}:e;return new Promise(r=>{let n=new zt({...s,title:i,content:t,width:s.width??400,closable:!1});n._zx.setButtons([{label:s.cancelLabel??"Cancel",action:()=>{n.hide(),r(ei)}},{label:s.okLabel??"Ok",kind:"primary",action:()=>{typeof s.onOk=="function"&&s.onOk()===!1||(n.hide(),r())}}]),n._zx.once("close",()=>n.destroy()),n.show()})}var Ee=class extends x{static legacyName="gx.zeyos.Dialog";constructor(t,e={}){super(e,{title:"",height:400});let s=new At(null,{title:String(e.title??""),content:null});this._frames={},this._current=null,this._attach(s,{ui:{title:"title",content:"content",footer:"footer"},setters:{title:"setTitle"}})}setTitle(t){return this._zx.setTitle(Zt(t)),this}addFrame(t,e,s){let r=qr(e?.footer),n=this._zx.addView(String(t),{title:e?.title==null?void 0:Zt(e.title),content:D(e?.content),buttons:r});return this._frames[t]={title:e?.title??null,content:n.content,footer:r,view:n},(!this._current&&s!==!1||s===!0)&&this.openFrame(t),this}openFrame(t){return this._zx.showView(String(t)),this._current=this._frames[t],this._current}getFrame(t){return this._frames[t]??null}addSubmitFrame(t,e,s,r){return this.addFrame(t,{title:this.options.title,content:jr(e),footer:{close:{label:"Close",click:()=>this._zx.close()},ok:{label:"OK",primary:!0,click:()=>s?.()}}},r),e}addFormFrame(t,e,s,r){let n={},o=document.createElement("div");for(let[l,c]of Object.entries(e??{})){let h=document.createElement("p");h.textContent=c?.[0]==null?"":String(c[0]),o.append(h);let u=c?.[1],f=D(u);f?.nodeType?o.append(f):f?.toElement?.()&&o.append(f.toElement()),n[l]=u}return this.addSubmitFrame(t,o,s,r),n}addSuccessFrame(t,e,s,r){let n=jr(e);if(s){let o=document.createElement("a");o.href=s,o.textContent="Open",n.append(o)}return this.addFrame(t,{title:this.options.title,content:n},r)}getFormValues(t){let e={};for(let[s,r]of Object.entries(t??{}))r?.value!=null?e[s]=r.value:typeof r?.getValue=="function"?e[s]=r.getValue():typeof r?.getValues=="function"?e[s]=r.getValues():typeof r?.getId=="function"?e[s]=r.getId():typeof r?.get=="function"&&(e[s]=r.get());return e}},Ne=class extends x{static legacyName="gx.zeyos.Dropdown";constructor(t,e={}){super(e,{items:{},label:"",resettable:!1,compact:!1,upside:!1});let{target:s,host:r}=Ie(t);this._items=Rr(e.items,e.resettable,e.emptyCaption),this._selected=null;let n=new et(s,{label:String(e.label??""),items:this._items,placement:e.upside?"top-start":"bottom-start"});r&&r.append(n.toElement()),this._attach(n,{events:{change:{type:"select",args:o=>(this._selected=o.value==null?null:o.item,n.setLabel(o.value==null?String(e.label??""):String(o.item.label)),[o.value,o.item.label,this])}},ui:{frame:"root",button:"root",section:()=>document.querySelector(`[aria-labelledby="${n.el.id}"]`)},setters:{items:"setItems"}})}setItems(t){return this._items=Rr(t,this.options.resettable,this.options.emptyCaption),this._zx.setItems(this._items),this}selectItem(t,e){let s=this._items.find(r=>r!=="-"&&r.value==t);return this._selected=s??{value:t,label:e??String(t)},this._zx.setLabel(e??this._selected.label),this.fireEvent("change",[t,e??this._selected.label,this]),this._zx.close(),this}reset(){return this._selected=null,this._zx.setLabel(String(this.options.label??"")),this.fireEvent("change",[null,this.options.emptyCaption,this]),this._zx.close(),this}getSelected(){return this._selected?{value:this._selected.value,label:this._selected.label}:null}getValue(){return this._selected?.value??""}show(){return this._zx.open(),this}close(){return this._zx.close(),this}toggle(){return this._zx.isOpen()?this._zx.close():this._zx.open(),this}},Me=class extends x{static legacyName="gx.bootstrap.MenuButton";constructor(t,e={}){super(e,{entries:[],label:"",orientation:"left",direction:"down"});let{target:s,host:r}=Ie(t);this._entries=[];let n=new et(s,{label:String(e.label??""),items:[],kind:Hr(e.style),placement:`${e.direction==="up"?"top":"bottom"}-${e.orientation==="right"?"end":"start"}`});r&&r.append(n.toElement()),this._attach(n,{events:{change:{type:"select",args:o=>[o.value,o.item,this]}},ui:{button:"root",frame:"root",menu:"root"}});for(let o of e.entries??[])this.add(o)}add(t,e){if(!t)return this._entries.push("-"),this._zx.setItems(this._entries),null;let s={label:String(t),icon:e,value:this._entries.length};return this._entries.push(s),this._zx.setItems(this._entries),this.toElement()}divider(){return this.add(!1),this}toggle(){return this._zx.isOpen()?this._zx.close():this._zx.open(),this}open(){return this._zx.open(),this}close(){return this._zx.close(),this}setLabel(t){return this._zx.setLabel(t),this}setStyle(t){return this.toElement().setAttribute("data-kind",Hr(t)),this}},Oe=class extends x{static legacyName="gx.bootstrap.CheckButton";constructor(t,e={}){super(e,{label:"",value:!1});let{target:s,host:r}=Ie(t),n=new Pt(s,{label:e.label,checked:!!e.value,disabled:!!e.disabled});r&&r.append(n.toElement()),this._attach(n,{events:{change:{type:"change",args:o=>[o.checked]},check:{type:"change",filter:o=>o.checked,args:()=>[]},uncheck:{type:"change",filter:o=>!o.checked,args:()=>[]}},ui:{button:"root",indicator:"root",group:"root"},setters:{value:"set",disabled:"setDisabled",label:"setLabel"}})}get(){return this._zx.get()}toggle(t=!1){return this._zx.set(!this.get(),{silent:!!t}),!1}check(t=!1){return this._zx.set(!0,{silent:!!t}),this}uncheck(t=!1){return this._zx.set(!1,{silent:!!t}),this}set(t){return t?this.check():this.uncheck()}setDisabled(t){return t?this._zx.disable():this._zx.enable(),this}setLabel(t){return this._zx.setLabel(t),this}};function Ie(i){let t=K(i);return t?.localName==="button"?{target:t,host:null}:{target:null,host:t}}function Ja(i){if(typeof i=="number"&&Number.isFinite(i))return i;let t=Number.parseFloat(String(i??""));return Number.isFinite(t)?t:"md"}function qr(i){return i?(Array.isArray(i)?i:i?.nodeType?[i]:Object.values(i)).map(e=>e?.nodeType?{label:e.textContent??"",action:()=>e.click?.()}:{label:String(e?.label??""),kind:e?.primary?"primary":"default",action:()=>e?.click?.()}):[]}function jr(i){let t=document.createElement("div"),e=Array.isArray(i)?i:[i];for(let s of e){let r=D(s);r?.nodeType?t.append(r):r!=null&&t.append(document.createTextNode(String(r)))}return t}function Rr(i={},t=!1,e=null){let s=[];t&&s.push({label:String(e??"Empty"),value:null});for(let[r,n]of Object.entries(i??{})){let o=n&&typeof n=="object"?n:null;s.push({label:String(o?.text??o?.label??n),value:r,onselect:typeof o?.onClick=="function"?o.onClick:void 0})}return s}function Hr(i){let t=String(i??"").toLowerCase();return t.includes("danger")||t.includes("error")?"danger":t.includes("primary")||t.includes("success")?"primary":t.includes("link")||t.includes("ghost")?"ghost":"default"}var Xa=Object.freeze({data:"items",elementIndex:"valueKey",elementLabel:"labelKey",elementSelect:"renderValue",allowEmpty:"clearable",resetable:"clearable",searchfields:"searchKeys",height:"listHeight"}),tl=Object.freeze({data:"items",listValue:"valueKey",listFormat:"labelKey",listActive:"checkedKey",defaultState:"defaultChecked"}),Sp=Object.freeze({cols:"columns"}),zp=Object.freeze({horizontal:"layout",default:"value"}),el=Object.freeze({string:"text",integer:"int",gxselect:"zxselect",date:"date",month:"month",time:"time",optionlist:"optionlist",html:"html",multivalueeditor:"multivalueeditor",checklist:"checklist"});function $r(i,t){let e={};if(!i||typeof i!="object")return e;for(let[s,r]of Object.entries(i))/^on[A-Z]/.test(s)||(e[t[s]??s]=r);return e}function Fe(i={}){let t=$r(i,Xa);return Object.hasOwn(i,"data")&&(t.items=Array.isArray(i.data)?i.data.slice():[]),(Object.hasOwn(i,"allowEmpty")||Object.hasOwn(i,"resetable"))&&(t.clearable=!!(i.allowEmpty||i.resetable)),i.msg&&typeof i.msg=="object"&&i.msg.noSelection!=null&&(t.placeholder=String(i.msg.noSelection)),Object.hasOwn(i,"height")&&(t.listHeight=Ur(i.height,280)),delete t.elementDefault,delete t.parseDefault,delete t.queryParam,delete t.requestData,delete t.requestHeader,delete t.url,delete t.method,delete t.entity,delete t.limit,t}function Le(i={}){let t=$r(i,tl);return typeof i.getItemValue=="function"&&(t.valueKey=i.getItemValue),Object.hasOwn(i,"height")&&(t.height=Ur(i.height,280)),delete t.url,delete t.method,delete t.requestData,delete t.decodeResponse,delete t.width,delete t.onClick,t}function Ve(i){if(typeof i=="string")return i.replaceAll(" "," ");let t=Array.isArray(i)?i:["d",".","M",".","y"],e={d:"%d",m:"%m",M:"%m",y:"%Y",h:"%H",i:"%M",s:"%S"};return t.map(s=>e[s]??String(s).replaceAll(" "," ")).join("")}function sl(i,t){if(typeof t=="string")return t;if(typeof t!="number"||!Number.isFinite(t))return null;let e=i[Math.trunc(t)-1];return e?.name==null?null:String(e.name)}function Kr(i={}){let t=Array.isArray(i.frames)?i.frames:[];return{tabs:t.map(e=>({name:String(e.name??""),title:String(e.title??""),content:e.content,closable:!!e.closable,disabled:!!e.disabled})),active:sl(t,i.show??1),height:i.height??null}}function ri(i={},t=nl){let e=Array.isArray(i.cols)?i.cols:[],s=typeof i.structure=="function"?i.structure:c=>e.map(h=>c?.[h.id]),r=new WeakMap,n=(c,h)=>{if(c&&typeof c=="object"){let g=r.get(c);if(g?.index===h)return g.cells}let u=s(c,h),f=Array.isArray(u)?u:Array.isArray(u?.row)?u.row:[];return c&&typeof c=="object"&&r.set(c,{index:h,cells:f}),f},o=e.map((c,h)=>({id:String(c.id??h),label:String(c.label??""),width:c.width??"auto",align:il(c.align??c["text-align"]),sortable:c.filter!=null||c.filterable!==!1,render:(u,f)=>t(n(u,f)[h])})),l=e.find(c=>c.filter!=null);return{columns:o,data:Array.isArray(i.data)?i.data.slice():[],sort:l?{id:String(l.id),dir:rl(l.mode??l.filter)}:null,sortMode:"server",selectable:i.selectable===!0?"single":["single","multi"].includes(i.selectable)?i.selectable:!1,height:i.height??null,stickyHeader:i.scroll!==!1,rowId:typeof i.rowId=="function"||typeof i.rowId=="string"?i.rowId:ol}}function Yr(i={}){let t=el[String(i.type??"text").toLowerCase()]??String(i.type??"text").toLowerCase(),e={id:i.id??null,type:t,label:i.label??"",description:i.description??"",value:Object.hasOwn(i,"value")?i.value:i.default,placeholder:i.placeholder??"",required:!!i.required,disabled:!!i.disabled,options:i.options??null,layout:i.horizontal===!1?"stack":i.horizontal?"inline":"stack",props:{}};return t==="html"&&(e.value=i.content??e.value),e}var rt=Object.freeze({select:(i,t)=>[i.item??null,t],noselect:(i,t)=>[null,t],tableClick:i=>[i.row,i.event?.target?.closest?.("tr")??null,i.event],tableFilter:(i,t)=>[t?._legacyColumn?.(i.id)??{id:i.id},i.dir],tabChange:i=>[i.name]});function Ur(i,t){let e=typeof i=="string"?Number.parseFloat(i):Number(i);return Number.isFinite(e)?Math.max(0,e):t}function il(i){let t=String(i??"start");return["center","end","left","right"].includes(t)?t:"start"}function rl(i){return i==="desc"?"desc":"asc"}function nl(i){return i&&typeof i=="object"&&!Array.isArray(i)&&Object.hasOwn(i,"label")?i.label:i}function ol(i){return i?.ID??i?.id??i}var Pe=class extends x{static legacyName="gx.zeyos.Checklist";constructor(t,e={}){super(e,{data:[],listValue:"ID",listFormat:"name",listActive:"on"});let s=Le(e);s.items=Array.isArray(e.data)?e.data:Array.isArray(e.items)?e.items:[],s.load=e.url?()=>this._load(e.url,e.requestData):null;let r=new ot(t,s);this._http=null,this._attach(r,{events:{complete:{type:"loaded",args:n=>[n.items]},change:{type:"change",args:n=>[n.values]}},ui:{frame:"root",table:"list",tbody:"list",search:"search"},setters:{data:"setData"}})}getValues(t){let e=this._zx.getValues();return t==null?e:e.map(s=>s?.[t]).filter(s=>s!=null)}setValues(t){return this._zx.setValues(t??[]),t}reset(){return this._zx.uncheckAll(),this}search(t){return this._zx.search(t),this}setData(t){return this._zx.setItems(Array.isArray(t)?t:[]),this}async load(t=this.options.url,e=this.options.requestData){let s=await this._load(t,e);return this._zx.setItems(s),this.fireEvent("complete",[s]),this}async loadFromURL(t,e,s){let r=await this.load(t,e);return s?.(this),r}async _load(t,e){this._http??=new $({headers:this.options.requestHeader??{}});try{let s=String(this.options.method??"GET").toUpperCase(),r=await this._http.request(String(t??""),s==="GET"?{method:s,query:e??{}}:{method:s,data:e??{}});return typeof this.options.decodeResponse=="function"&&(r=this.options.decodeResponse(r)),Array.isArray(r)?r:[]}catch(s){throw this.fireEvent("failure",[s]),s}}},Be=class extends Pe{static legacyName="gx.zeyos.Checklist"},je=class extends Pe{static legacyName="gx.bootstrap.Checklist"},Re=class extends x{static legacyName="gx.zeyos.Permission";constructor(t,e={}){super(e,{value:!0,groups:[]});let s=new Ut(t,{value:e.value??!0,groups:e.groups??e.data??[],groupsValueKey:e.groupsValueKey??e.elementIndex??"ID",groupsLabelKey:e.groupsLabelKey??e.elementLabel??"name"});this._attach(s,{events:{change:{type:"change",args:r=>[r.value]}},setters:{value:"set"}})}get(){return this._zx.get()}set(t,e=!1){return this._zx.set(t,{silent:e}),this}},He=class extends x{static legacyName="gx.zeyos.Table";constructor(t,e={}){super(e,{cols:[],data:[]});let s={...e};typeof e.structure=="function"&&(s.structure=(o,l)=>e.structure(o,l,this));let r=ri(s,Wr),n=new kt(t,r);this._cols=Array.isArray(e.cols)?e.cols.map(o=>({...o})):[],this._filter=r.sort?this._legacyColumn(r.sort.id):null,this._filter&&(this._filter.mode=r.sort.dir),this._attach(n,{events:{click:{type:"rowclick",args:o=>rt.tableClick(o)},dblclick:{type:"rowdblclick",args:o=>rt.tableClick(o)},filter:{type:"sort",args:o=>{let l=this._legacyColumn(o.id);return l.mode=o.dir,this._filter=l,[l,o.dir]}},complete:{type:"datachange",args:o=>[o.rows]}},ui:{table:()=>n._table,tbody:()=>n._tbody,thead:()=>n._thead,tableDiv:()=>n._scroll},setters:{data:"setData",height:"setHeight"}})}setData(t){return this._zx.setData(Array.isArray(t)?t:[]),this}addData(t){return this._zx.addData(Array.isArray(t)?t:[t]),this}empty(){return this._zx.empty(),this}setSort(t,e,s=!1){let r=String(typeof t=="object"?t.id:t);return this._zx.setSort(r,e,{silent:!!s}),this._filter=this._legacyColumn(r),this._filter.mode=this._zx._sort?.dir??e??"asc",this}getFilter(){return this._filter??!1}getData(){return this._zx.getData()}setHeight(t){let e=typeof t=="number"?`${t}px`:String(t);return this._zx._scroll.style.blockSize=e,this}_legacyColumn(t){return this._cols.find(e=>String(e.id)===String(t))??{id:t}}},qe=class extends He{static legacyName="gx.zeyos.Table"},$e=class extends He{static legacyName="gx.bootstrap.Table"},Ke=class extends x{static legacyName="gx.ui.SimpleTable";constructor(t,e={}){t&&typeof t=="object"&&!t.nodeType&&!Array.isArray(t)&&(e=t,t=null),super(e,{cols:[],data:[]});let s={...e,rowId:n=>n};typeof e.structure=="function"&&(s.structure=(n,o)=>e.structure(n,o,this));let r=new kt(t,ri(s,Wr));this._attach(r,{events:{click:{type:"rowclick",args:n=>[n.row,n.index]}},ui:{table:()=>r._table,tbody:()=>r._tbody,thead:()=>r._thead}})}setData(t){return this._zx.setData(Array.isArray(t)?t:[]),this}addData(t){return this._zx.addData(Array.isArray(t)?t:[t]),this}createRow(t,e=this._zx.getData().length){let s=this._zx.getData();return s.splice(Math.max(0,e),0,t),this._zx.setData(s),this.display("tbody")?.querySelectorAll?.("tr[data-row]")?.[e]??null}addRow(t,e){return this.createRow(t,e)}updateRow(t,e){let s=this._zx.getData();return e>=0&&e<s.length&&(s[e]=t),this._zx.setData(s),this.display("tbody")?.querySelectorAll?.("tr[data-row]")?.[e]??null}removeRow(t){let e=this._zx.getData();return e.splice(t,1),this._zx.setData(e),this}getRows(){return this._zx.getData()}empty(){return this._zx.empty(),this}},Ye=class extends x{static legacyName="gx.bootstrap.DataFilter";constructor(t,e={}){super(e);let s=new Wt(t,{data:[],filters:[],autoApply:!0});this.origin=[],this.filtered=[],this.filter=[],this._attach(s,{events:{filtered:{type:"filter",args:r=>(this.filtered=r.rows,[r.rows])}},ui:{clear:()=>s._controls,clearBtn:()=>s._clearButton}})}addSelectFilter(t,e,s,r,n){let o={type:"select",id:String(t),label:String(e),fields:Array.isArray(s)?s:[s]};return this.filter.push({identifier:t,fields:o.fields,method:n??this.selectFilter,type:"Select"}),this._zx.addFilter(o),this}addFulltextFilter(t,e,s,r,n){let o={type:"text",id:String(t),label:String(s??""),placeholder:String(s??""),fields:Array.isArray(e)?e:[e]};return this.filter.push({identifier:t,fields:o.fields,method:n??this.fulltextFilter,type:"Fulltext"}),this._zx.addFilter(o),this}addCustomElement(t){return this.toElement().insertBefore(t,this._zx._controls),this}initData(t){return this.origin=Array.isArray(t)?t:[],this._zx.setData(this.origin),this}doFilter(){return this.filtered=this._zx.apply(),this.filtered}clearFilter(){return this._zx.clear(),this}getFilter(t){return this.filter.find(e=>e.identifier==t)??null}fulltextFilter(t,e){return new RegExp(String(t),"i").test(String(e??""))}selectFilter(t,e){return t==e}};function Wr(i){if(i?.nodeType||!i||typeof i!="object"||Array.isArray(i))return i;let t=document.createElement("span"),e=i.label;e?.nodeType?t.append(e):e!=null&&t.append(document.createTextNode(String(e))),i.className&&t.classList.add(...String(i.className).split(/\s+/).filter(Boolean));for(let[s,r]of Object.entries(i))["label","className","styles"].includes(s)||/^on/i.test(s)||r==null||["title","colspan","rowspan"].includes(s.toLowerCase())&&t.setAttribute(s,String(r));return t}var Ue=class extends x{static legacyName="gx.zeyos.Datebox";constructor(t,e={}){super(e,{timestamp:0,unit:"milliseconds",format:["d",".","M",".","y"," ","h",":","i"]});let s=e.timestamp==null||Number(e.timestamp)===0?new Date:Ct(e.timestamp,e.unit??"milliseconds"),r=Ve(e.format),n=new q(t,{value:s,format:r,time:/%[HMS]/.test(r),disabled:!!e.disabled});this._attach(n,{events:{update:{type:"change",args:()=>[this.get()]}},ui:{input:"input",fieldset:"control"},setters:{timestamp:"set",disabled:o=>o?this.disable():this.enable()}})}set(t,e=this.options.unit??"milliseconds"){return this._zx.set(Ct(t,e)),this}get(t=this.options.unit??"milliseconds"){let e=this._zx.get("date");return e?t==="date"?e:t==="seconds"?e.getTime()/1e3:e.getTime():null}enable(){return this._zx.enable(),this}disable(){return this._zx.disable(),this}},Jt=class extends x{static legacyName="gx.zeyos.DatePicker";static Picker=L;constructor(t,e={}){super(e,{date:!1,format:"%a %d.%m.%Y %H:%M",return_format:"%s"});let s=Ct(e.date||new Date,e.unit??"milliseconds"),r=this.constructor.Picker,n=new r(t,al(s,e,r));this._date=s,this._attach(n,{events:{select:{type:"change",args:o=>(this._date=o.date?new Date(o.date.getTime()):this._dateFromTime(o.time),[this._date])}},ui:{input:"root"},setters:{date:"set"}})}set(t){let e=Ct(t,"milliseconds");return this._date=e,this.constructor.Picker===j?this._zx.set(e):this._zx.set(e),this}get(t=this.options.return_format){let e=this._readDate();return e?t==null?e:t==="%s"||t==="seconds"?Math.floor(e.getTime()/1e3):t==="date"?e:v(e,String(t)):null}getSeconds(){let t=this._readDate();return t?t.getTime()/1e3:null}setReadOnly(t){return this.toElement().setAttribute("aria-disabled",String(!!t)),this}setFormat(t,e){return this.options.format=t,this.options.timePicker=e,this}_readDate(){if(this.constructor.Picker===j){let t=this._zx.get();return t?this._dateFromTime(t):this._date}return this._zx.get()}_dateFromTime(t){let e=this._date?new Date(this._date.getTime()):new Date;return t&&e.setHours(Number(t.h)||0,Number(t.m)||0,Number(t.s)||0,0),e}},We=class extends Jt{static legacyName="gx.zeyos.DatePicker";static Picker=L},Ge=class extends Jt{static legacyName="gx.zeyos.MonthPicker";static Picker=ct},Qe=class extends Jt{static legacyName="gx.zeyos.TimePicker";static Picker=j},Xt=class extends x{static legacyName="gx.ui.Timebox";constructor(t,e={}){super(e,{time:0,unit:"minutes",seconds:!0,prefix:!1,disabled:!1});let s=new pt(t,{value:Number(e.time)||0,unit:ni(e.unit),seconds:e.seconds!==!1,signed:!!e.prefix,disabled:!!(e.disabled||e.readonly)});this._attach(s,{events:{change:{type:"change",args:r=>[r.value]}},ui:{prefix:"sign"},setters:{time:"set",disabled:r=>r?this.disable():this.enable()}})}set(t,e=this.options.unit){return this._zx.set(t??0,ni(e)),this}get(t=this.options.unit,e=0){let s=this._zx.get(ni(t)),r=10**(Number(e)||0);return Math.round(s*r)/r}update(){return this.set(this.get())}enable(){return this.options.disabled=!1,this._zx.enable(),this.fireEvent("disabled",[!1]),this}disable(){return this.options.disabled=!0,this._zx.disable(),this.fireEvent("disabled",[!0]),this}disabled(){return!!this.options.disabled}setPrefix(t){let e=Math.abs(this.get());return this.set(t?e:-e),this}},Ze=class extends Xt{static legacyName="gx.ui.Timebox"},Je=class extends Xt{static legacyName="gx.zeyos.Timebox"},Xe=class extends Xt{static legacyName="gx.bootstrap.Timebox"};function Ct(i,t){if(i==null)return null;if(i instanceof Date)return new Date(i.getTime());if(typeof i=="number"||/^-?\d+(?:\.\d+)?$/.test(String(i))){let s=Number(i);return new Date(t==="seconds"?s*1e3:s)}let e=new Date(String(i));return Number.isNaN(e.getTime())?null:e}function al(i,t,e){return e===j?{value:i,seconds:/%S/.test(t.format??"")}:{value:i,min:Ct(t.min??null,"milliseconds"),max:Ct(t.max??null,"milliseconds"),time:e===L&&t.timePicker!==!1,showWeekNumbers:!!t.weeknumbers}}function ni(i){return["seconds","minutes","hours"].includes(String(i))?String(i):"minutes"}var Gr=Object.freeze({list:"list",plus:"plus",clock:"clock",range:"filter",reload:"reload",clear:"x",settings:"gear",eye:"eye",trash:"trash",fields:"list",search:"search",lock:"lock",checked:"check",question:"info"}),Qr=Object.freeze({Icon(i){ts();let t=Gr[i]??(oe[i]?i:null);if(!t)throw new RangeError(`Unsupported legacy icon: ${i}`);return m(t)},Button(i,t="",e,s={}){ts();let r=W({label:String(i??""),icon:e?Gr[e]??e:null,kind:ll(t),disabled:!!s.disabled,title:s.title,onclick:s.onclick??s.onClick});for(let n of["id","name","value"])s[n]!=null&&r.setAttribute(n,String(s[n]));return r},ButtonsGroup(i){return ts(),Ys(Array.isArray(i)?i:[])}});function ts(){Qt(ts,"gx.zeyos.Factory","button/icon")}function ll(i){let t=String(i??"").toLowerCase();return t==="dark"||t==="em"?"primary":t.includes("danger")||t.includes("error")?"danger":t.includes("ghost")||t.includes("link")?"ghost":"default"}var es=class extends x{static legacyName="gx.bootstrap.Form";constructor(t,e={}){super(e,{fields:{},horizontal:["col-md-3","col-md-9"],columns:!1});let s=new Gt(t,{fieldsets:[],actions:Zr(e.actions)});this._fieldsets=[],this._attach(s,{events:{submit:{type:"submit",args:r=>[r.values,this]},change:{type:"change",args:r=>[r.id,r.value,this]},invalid:{type:"invalid",args:r=>[r.errors,this]}},ui:{body:()=>s._body,actions:()=>s._actions}}),e.fields&&typeof e.fields=="object"&&this.addFieldset({fields:e.fields,title:e.title,horizontal:e.horizontal,columns:e.columns})}addFieldset(t){let e=t instanceof Dt?t:new Dt(null,{horizontal:this.options.horizontal,columns:this.options.columns,...t});return this._fieldsets.push(e),this._zx.addFieldset(e._zx),e}addActions(t){let e=Zr(t);if(e.length)this._zx.setActions(e);else{let s=Array.isArray(t)?t:[t];for(let r of s){let n=D(r);n?.nodeType===1&&this._zx._actions.prepend(n)}this._zx._actions.hidden=!1}return this}getValue(t){return this.getField(t)?.getValue()??null}getValues(){return Object.assign({},...this._fieldsets.map(t=>t.getValues()))}getField(t){for(let e of this._fieldsets){let s=e.getField(t);if(s)return s}return null}getFieldsets(){return this._fieldsets.slice()}setValue(t,e){return this.getField(t)?.setValue(e),this}setValues(t){for(let e of this._fieldsets)e.setValues(t);return this}setHighlights(t={},e="error"){return this._fieldsets.reduce((s,r)=>s+r.setHighlights(t,e),0)}setHintHighlights(t={},e="error"){return this.setHighlights(t,e)}reset(){for(let t of this._fieldsets)t.reset().setHighlights();return this}},Dt=class extends x{static legacyName="gx.bootstrap.Fieldset";constructor(t,e={}){super(e,{fields:{},title:null,columns:1});let s=Number(e.columns)||1,r=new it(t,{title:e.title??"",columns:Math.max(1,Math.min(3,s)),fields:{}});this._fields={},this._attach(r,{ui:{columns:()=>r._grid}}),e.fields&&typeof e.fields=="object"&&this.addFields(e.fields)}addFields(t){for(let[e,s]of Object.entries(t??{}))this.addFieldItem(e,s);return this}addFieldItem(t,e){if(this.hasField(t))throw new Error(`Field "${t}" already exists.`);let s=e;return e instanceof V||(e?.type!=null?s=new V({...e,id:t}):e?.field!=null?s=new V({...e,id:t,type:e.type??"custom"}):e?.nodeType||e?._zx?s=new V({id:t,label:t,type:"custom",field:e}):s=new V({...e??{},id:t})),this._fields[t]=s,this._zx.addField(t,s instanceof V?s._zx:s?._zx??s),s}addField(t,e,s={}){return this.addFieldItem(t,new V({...s,id:t,type:e}))}clear(){return this._zx.clear(),this._fields={},this}hasField(t){return Object.hasOwn(this._fields,t)}getField(t){return this._fields[t]??null}getFields(){return{...this._fields}}getValue(t){return this._fields[t]?.getValue?.()??null}getValues(){let t={};for(let[e,s]of Object.entries(this._fields))e.startsWith("__")||(t[e]=s.getValue?.());return t}setValue(t,e){return this._fields[t]?.setValue?.(e),this}setValues(t){for(let[e,s]of Object.entries(t??{}))this.setValue(e,s);return this}reset(){for(let t of Object.values(this._fields))t.reset?.();return this}focus(t){return this._fields[t]?.focus?.(),this}setHighlights(t={},e="error"){let s=0;for(let[r,n]of Object.entries(this._fields)){let o=t?.[r];o&&typeof o=="object"?(n.setHighlight(o.label,o.type??e),s+=1):o?(n.setHighlight(o,e),s+=1):n.setHighlight()}return s}setHintHighlights(t={},e="error"){return this.setHighlights(t,e)}},V=class extends x{static legacyName="gx.bootstrap.Field";constructor(t={}){super(t,{label:"",type:"text",description:"",default:null});let e=cl(t),s=new b(null,e);this._type=e.type,this._attach(s,{events:{setValue:{type:"change",args:r=>[r.value]},change:{type:"change",args:r=>[r.value]}},ui:{label:()=>s.el.querySelector(".zx-field__label"),field:()=>s.getInput(),controlwrapper:()=>s.el.querySelector(".zx-field__control"),highlight:()=>s.el.querySelector(".zx-field__highlight"),description:()=>s.el.querySelector(".zx-field__description"),hint:()=>s.el.querySelector(".zx-field__control")},setters:{value:"setValue",default:"setValue",disabled:"setDisabled"}})}setLabel(t){let e=this.display("label");return e&&(e.textContent=Zt(t)),this}setHelp(t){let e=this.display("description");return e&&(e.textContent=String(t??"")),this}getValue(){return this._zx.getValue()}setValue(t){return this._zx.setValue(t),this}setDisabled(t){return this._zx.setDisabled(t),this}setHighlight(t,e="warning"){return t?this._zx.setHighlight(String(t),ul(e)):this._zx.clearHighlight(),this}setHintHighlight(t,e="warning"){return this.setHighlight(t,e)}reset(){return this._zx.reset(),this}focus(){return this._zx.focus(),this}},ss=class extends x{static legacyName="gx.bootstrap.ValueList";constructor(t,e={}){super(e,{deletable:!0});let s=new _t(t,{values:e.values??e.default??[],deletable:e.deletable!==!1});this._attach(s,{events:{change:{type:"change",args:r=>[r.values]},click:{type:"add",args:r=>[r.value]}},ui:{textbox:()=>s._input,list:()=>s._list}})}addValue(t){return this._zx.addValue(t)}getValues(){return this._zx.getValues()}setValues(t){return this._zx.setValues(t??[]),this}enable(){return this._zx.enable(),this}disable(){return this._zx.disable(),this}focus(){return this._zx.focus(),this}},is=class extends x{static legacyName="gx.bootstrap.MultiValueEditor";constructor(t,e={}){super(e,{options:!1,default:!1});let s=Jr(e.default||e.values||e.options),r=new dt(t,{values:s,options:null});this._attach(r,{events:{change:{type:"change",args:n=>[JSON.stringify(n.values)]}},ui:{optionsbox:()=>r._rows,btnAdd:()=>r._add}})}getValue(){return JSON.stringify(this._zx.getValues())}setValue(t){return this._zx.setValues(Jr(t)),this}},rs=class extends x{static legacyName="gx.bootstrap.FieldUpload";constructor(t={}){super(t,{inputname:"upload",uploadurl:"./index.php",params:{},imageurl:""});let e=new ut(null,{url:t.uploadurl??t.url??"./index.php",paramName:t.inputname??t.paramName??"upload",params:t.params??{},accept:t.accept??null,multiple:!!t.multiple,autoUpload:t.autoUpload!==!1,http:t.http??null});this._value=null,this._attach(e,{events:{success:{type:"success",args:s=>(this._handleResponse(s.response),[s.response])},failure:{type:"error",args:s=>(t.showError?.(this,s.error),[s.error])},progress:{type:"progress",args:s=>[s.percent]}},ui:{select:()=>e._input,placeholder:()=>e._preview,progress:()=>e._progress}}),t.default&&this.setValue(t.default),t.disabled&&this.setDisabled(!0)}setValue(t){return this._value=t,this.setImage(t),this}getValue(){return null}setImage(t){if(this._zx._preview.replaceChildren(),t){let e=document.createElement("img");e.src=String(this.options.imageurl??"")+String(t),e.alt="",this._zx._preview.append(e)}return this}setDisabled(t){return this._zx.setDisabled(t),this}reset(){return this._zx.clear(),this}_handleResponse(t){typeof this.options.parseResponse=="function"&&this.options.parseResponse(this,t,e=>{e!=null&&this.setValue(e)})}};function cl(i){let t=Yr(i),e=i.options&&typeof i.options=="object"&&!Array.isArray(i.options)?i.options:{};if(i.field!=null||typeof i.type!="string"&&i.type!=null){let s=i.field??i.type,r=typeof s=="function"?new s(null,Object.keys(e).length?e:i):s;return t.type="custom",t.adapter=()=>hl(r),t}if(t.type==="zxselect")t.props=Fe({...e,...i}),t.props.items=Array.isArray(i.data)?i.data:e.data??[],t.props.valueKey=i.elementIndex??e.elementIndex??"ID",t.props.labelKey=i.elementLabel??e.elementLabel??"name";else if(t.type==="checklist")t.props=Le(Object.keys(e).length?e:i),t.props.items=e.data??i.data??[];else if(t.type==="date"||t.type==="datetime"){let s=Object.keys(e).length?e:i;t.props={format:Ve(s.format??"%d.%m.%Y"),time:t.type==="datetime"},t.value=Xr(t.value??s.date)}else if(t.type==="month")t.props={...e},t.value=Xr(t.value??e.date??i.date);else if(t.type==="time"){let s=Object.keys(e).length?e:i;t.props={unit:s.unit??"minutes",seconds:s.seconds!==!1,signed:!!s.prefix},t.value=t.value??s.time??0}else t.type==="html"&&(t.value=D(i.content??t.value));return t}function hl(i){let t=i?._zx?.toElement?.()??i?.toElement?.()??i;if(!t?.nodeType)throw new TypeError("Custom legacy field must provide a DOM element");return{el:t,get:()=>i?.getValue?.()??i?.getValues?.()??i?.get?.()??("value"in t?t.value:null),set:e=>{typeof i?.setValue=="function"?i.setValue(e):typeof i?.setValues=="function"?i.setValues(e):typeof i?.set=="function"?i.set(e):"value"in t&&(t.value=e==null?"":String(e))},focus:()=>i?.focus?.()??t.focus?.(),setDisabled:e=>{typeof i?.setDisabled=="function"?i.setDisabled(e):e?i?.disable?.():i?.enable?.(),"disabled"in t&&(t.disabled=e)}}}function Zr(i){return(Array.isArray(i)?i:i&&typeof i=="object"&&!i.nodeType?Object.values(i):[]).filter(e=>e&&typeof e=="object"&&!e.nodeType&&!e.tag).map((e,s)=>({id:e.id??String(s),label:e.label??e.text??"",icon:e.icon??null,kind:dl(e.kind??e.type??(e.primary?"primary":"default")),type:e.submit?"submit":e.type==="reset"?"reset":"button",onClick:e.onClick??e.onclick??e.click}))}function ul(i){let t=String(i??"").toLowerCase();return t==="error"||t==="danger"?"danger":t==="success"||t==="primary"?"success":t==="warning"?"warning":"default"}function dl(i){let t=String(i??"").toLowerCase();return t==="error"||t==="danger"?"danger":t==="primary"||t==="success"?"primary":t==="ghost"||t==="link"?"ghost":"default"}function Jr(i){if(Array.isArray(i))return i;if(!i)return[];try{let t=JSON.parse(String(i));return Array.isArray(t)?t:[]}catch{return[]}}function Xr(i){if(i instanceof Date||i==null)return i;if(typeof i=="number")return new Date(i*(Math.abs(i)<1e12?1e3:1));let t=new Date(String(i));return Number.isNaN(t.getTime())?null:t}var ns=class extends x{static legacyName="gx.zeyos.Client";constructor(t={}){super(t,{url:"./remotecall.php"}),this._http=new $({base:String(t.url??"./remotecall.php"),headers:t.headers??{},timeout:t.timeout??3e4})}post(t,e,s,r){return this.request(e,"POST",s,r,t)}get(t,e,s,r){return this.request(e,"GET",s,r,t)}async request(t,e="GET",s,r,n=""){fl(this,s),this.fireEvent("request");try{let o=String(e).toUpperCase(),l=await this._http.request(String(n??""),o==="GET"?{method:o,query:t}:{method:o,data:t});if(r&&pl(l)!==r)throw new TypeError(`Invalid server response: expected ${r}`);return typeof s=="function"&&s.call(this,l),this.fireEvent("success",[l]),l}catch(o){throw this.fireEvent("failure",[o]),o}finally{this.fireEvent("complete")}}},os=class extends x{static legacyName="gx.zeyos.Request";constructor(t={}){super(t,{service:!1,accesskey:!1}),this._files=null,this.setService(t.service??"",t.accesskey??""),typeof t.showError=="function"&&(this.showError=t.showError)}setService(t,e=""){return this.options.service=t,this.options.accesskey=e,this.baseUrl=`${this.options.apiBase??"../remotecall/"}${t}${e?`:${e}`:""}/`,this._http=wt(String(t),String(e),{apiBase:this.options.apiBase??"../remotecall/",headers:this.options.headers??{},timeout:this.options.timeout??3e4}),this}async send(t,e,s,r="GET"){this.fireEvent("request");try{let n=String(r??"GET").toUpperCase(),o={method:n};n==="GET"?o.query=e:o.data=e,this._files&&(o.files=this._files);let l=await this._http.request(String(t??""),o);return this._files=null,this.fireEvent("success",[l]),s?.call(this,l,"200 OK"),l}catch(n){this._files=null;let o=n instanceof Error?n:new Error(String(n));throw this.fireEvent("failure",[o]),this.fireEvent("error",[o.message,o.response??null,o.response?.headers??null]),this.fireEvent("exception",[o,null]),this.showError?.(o.message),o}finally{this.fireEvent("complete")}}post(t,e,s){return this.send(t,e,s,"POST")}get(t,e,s){return this.send(t,e,s,"GET")}put(t,e,s){return this.send(t,e,s,"PUT")}delete(t,e,s){return this.send(t,e,s,"DELETE")}upload(t,e,s,r){return this._files=_l(s),this.send(t,e,r,"POST")}openLink(t){return window.open(this.baseUrl+String(t??""),"_blank")}showError(t){console.error(t)}};function fl(i,t){if(!(!t||typeof t!="object"))for(let[e,s]of Object.entries(t))i.addEvent(e,s)}function pl(i){return Array.isArray(i)?"array":i===null?"null":typeof i=="object"?"object":typeof i}function _l(i){return(i==null?[]:Array.from(i)).flatMap(e=>typeof File<"u"&&e instanceof File?[e]:e?.files?Array.from(e.files):[])}var as=class extends x{static legacyName="gx.zeyos.Groupbox";constructor(t,e={}){super(e,{title:"",open:!0});let s=new Bt(K(t),{title:String(e.title??""),open:e.open!==!1});this._attach(s,{events:{open:{type:"open",args:()=>[this]},close:{type:"close",args:()=>[this]}},ui:{title:"summary",inner:"content"},setters:{title:"setTitle",open:r=>r?this.open():this.close()}}),Object.hasOwn(e,"content")&&s.setContent(D(e.content)),this._syncAct()}toggle(){return this._zx.toggle(),this._syncAct(),this}open(){return this._zx.open(),this._syncAct(),this}close(){return this._zx.close(),this._syncAct(),this}isOpen(){return this._zx.isOpen()}setTitle(t){return this._zx.setTitle(t),this}_syncAct(){this._mirrorAct(this.display("title"),this.isOpen())}},ls=class extends x{static legacyName="gx.zeyos.Panel";constructor(t,e="",s=null,r=!0){super({title:e,content:s,open:r});let n=new $t(K(t),{title:String(e??""),content:D(s),open:r!==!1});this._attach(n,{events:{open:"open",close:"close"},ui:{title:"toggle",header:"header",inner:"content",content:"content"},setters:{title:"setTitle",content:"setContent",open:o=>o?this.open():this.close()}})}toggle(){return this._zx.toggle(),this}open(){return this._zx.open(),this}close(){return this._zx.close(),this}isOpen(){return this._zx.isOpen()}setContent(t){return this._zx.setContent(D(t)),this}setTitle(t){return this._zx.setTitle(t),this}},cs=class extends x{static legacyName="gx.zeyos.MasterPanel";constructor(t,e="",s=null,r=[]){super({title:e,content:s,buttons:r});let n=new Kt(K(t),{title:String(e??""),content:D(s),buttons:ps(r)});this._attach(n,{ui:{title:"title",inner:"content",content:"content",buttons:"buttons"},setters:{title:"setTitle",content:"setContent",buttons:o=>n.setButtons(ps(o))}})}setContent(t){return this._zx.setContent(D(t)),this}setTitle(t){return this._zx.setTitle(t),this}},te=class extends x{static legacyName="gx.zeyos.Tabbox";constructor(t,e={}){super(e,{frames:[],show:1});let s=Kr(e),r=new Rt(K(t),{tabs:s.tabs.map(fs),active:s.active});this._attach(r,{events:{change:{type:"change",args:n=>rt.tabChange(n)},close:{type:"close",args:n=>[n.name]}},ui:{tablist:"tablist",content:"panels",div:"tablist"},setters:{show:"openTab",height:n=>this.setStyle("height",n)}}),s.height!=null&&this.setStyle("height",s.height),r.on("change",()=>queueMicrotask(()=>this._syncAct())),this._syncAct()}addTab(t,e,s){let r=typeof t=="object"?t:{name:t,title:e,content:s};return this._zx.addTab(fs(r)),this._syncAct(),this}closeTab(t){return this._zx.removeTab(String(t)),this._syncAct(),this}openTab(t){let e=typeof t=="number"?this._zx._tabs?.[t-1]?.definition.name:String(t);return e&&this._zx.openTab(e),this._syncAct(),this}setTabTitle(t,e){return this._zx.setTitle(String(t),e),this}setHighlight(t,e,s){return this._zx.setBadge(String(t),e==null||e===""?null:String(e)),this}getActive(){return this._zx.getActive()}_syncAct(){for(let t of this.display("tablist")?.querySelectorAll?.('[role="tab"]')??[])this._mirrorAct(t,t.getAttribute("aria-selected")==="true")}},hs=class extends te{static legacyName="gx.bootstrap.Tabbox"},us=class extends x{static legacyName="gx.bootstrap.NavigationBar";constructor(t,e={}){super(e,{frames:[],title:"",buttons:[]});let s=Array.isArray(e.frames)?e.frames:[];this._frames=s.map(o=>({...o}));let r=typeof e.show=="number"?s[e.show-1]?.name:e.show,n=new Yt(K(t),{title:String(e.title??""),items:s.map(fs),active:r==null?null:String(r),actions:ps(e.buttons??[])});this._attach(n,{events:{change:{type:"change",args:o=>[o.name]}},ui:{title:"title",tablist:"items",content:"panels",buttons:"actions"},setters:{title:"setTitle"}}),n.on("change",()=>queueMicrotask(()=>this._syncAct())),this._syncAct()}addTab(t,e,s){let r=typeof t=="object"?{...t}:{name:t,title:e,content:s};return this._frames.push(r),this._rebuild(),this}closeTab(t){return this._frames=this._frames.filter(e=>String(e.name)!==String(t)),this._rebuild(),this}openTab(t){return this._zx.setActive(String(t)),this._syncAct(),this}setTitle(t){return this._zx.setTitle(typeof t=="string"?t:t?.textContent??""),this}setTabTitle(t,e){let s=this._frames.find(r=>String(r.name)===String(t));return s&&(s.title=e),this._rebuild(),this}setNavigationButtons(t){return this._zx.setActions(ps(t)),this}setHighlight(t,e,s){return this._zx.setBadge(String(t),e==null||e===""?null:String(e)),this}_rebuild(){let t=this._zx._activeName;this._zx.setItems(this._frames.map(fs)),t&&this._frames.some(e=>String(e.name)===String(t))&&this._zx.setActive(t),this._syncAct()}_syncAct(){for(let t of this.display("tablist")?.querySelectorAll?.('[role="tab"]')??[])this._mirrorAct(t,t.getAttribute("aria-selected")==="true")}},ds=class extends x{static legacyName="gx.zeyos.Search";constructor(t={}){super(t);let e=new jt(null,{placeholder:t.placeholder??"",debounce:t.debounce??0});this._attach(e,{events:{input:{type:"input",args:(s,r)=>[this,e.refs.input,r]}},ui:{input:"input",submit:"submit",button:"submit"}}),this._listen(e.refs.input,"keydown",s=>{s.key==="Enter"&&this.fireEvent("keypress",[this,e.refs.input,s])}),this._listen(e.refs.submit,"click",s=>this.fireEvent("click",[this,e.refs.input,s]))}get(){return this._zx.get()}set(t){return this._zx.set(t),this}};function fs(i){let t=D(i.content);return(typeof t=="string"||typeof t=="number"||t==null)&&(t=document.createTextNode(t==null?"":String(t))),{name:String(i.name??""),title:String(i.title??""),content:t,closable:!!i.closable,disabled:!!i.disabled}}function ps(i){return(Array.isArray(i)?i:[i]).filter(Boolean).map(t=>t?.toElement?.()??t).filter(t=>t?.nodeType===1)}var P=class extends x{static legacyName="gx.zeyos.Select";static filterMode=!1;constructor(t,e={}){super(e,{data:[],elementIndex:"ID",elementLabel:"name",elementSelect:"name",value:null});let s=Fe(e);s.items=ml(e),s.valueKey=gl(e.elementIndex??"ID"),s.labelKey=bl(e.elementLabel??"name"),s.renderItem=typeof e.elementLabel=="function"?e.elementLabel:null,s.renderValue=yl(e.elementSelect??e.elementLabel??"name"),s.value=e.value??null,s.filter=this.constructor.filterMode==="local"?"local":["async","rest"].includes(this.constructor.filterMode)?n=>this._load(n):!1,s.debounce=e.debounce??200;let r=this.constructor.filterMode==="priority"?N.priority(t,s):new N(t,s);this._attach(r,{events:{select:{type:"change",filter:n=>n.item!=null,args:n=>rt.select(n,this)},noselect:{type:"change",filter:n=>n.item==null,args:n=>rt.noselect(n,this)},show:{type:"open",args:()=>[this]},hide:{type:"close",args:()=>[this]},requestSuccess:{type:"loaded",args:n=>[n.items]}},ui:{fieldset:"control",textbox:"input",dropdown:"list",icon:"toggle"},setters:{data:"setData",value:"setId",disabled:n=>n?this.disable():this.enable()}}),this._http=null,this.data=s.items}set(t,e=!1){return this._zx.set(t,{silent:!!e}),this}setId(t,e=!1){let s=this.data?.find(r=>ks(r,this.options.elementIndex??"ID")==t);return this._zx.set(s??t,{silent:!!e}),this}getId(t){return t==null?this._zx.value:ks(t,this.options.elementIndex??"ID")}getValue(){return this._zx.value}getSelected(){return this._zx.selected}setData(t){return this.data=Array.isArray(t)?t.slice():[],this._zx.setItems(this.data),this}getRows(){return Array.from(this.display("dropdown")?.querySelectorAll?.('[role="option"]')??[])}reset(t=!1){return this._zx.set(null,{silent:!!t}),this}enable(){return this._zx.enable(),this}disable(){return this._zx.disable(),this}show(){return this._zx.open(),this}hide(){return this._zx.close(),this}isOpen(){return this.toElement().getAttribute("data-state")==="open"}search(){return this._zx.open(),this}showLoader(){return this}hideLoader(){return this}async _load(t){try{let e=this.constructor.filterMode==="rest"?await this._loadRest(t):await this._loadUrl(t),s=Array.isArray(e)?e:[];return this.data=s,s}catch(e){throw this.fireEvent("requestFailure",[e]),e}}_loadUrl(t){this._http??=new $({headers:this.options.requestHeader??{}});let e={...this.options.requestData??{}},s=typeof this.options.queryParam=="function"?this.options.queryParam(t,e):{...e,[this.options.queryParam??"query"]:t},r=String(this.options.method??"GET").toUpperCase();return this._http.request(String(this.options.url??"./"),r==="GET"?{method:r,query:s}:{method:r,data:s})}_loadRest(t){return this._http??=wt(String(this.options.entity??""),String(this.options.accesskey??""),{apiBase:this.options.apiBase??"../remotecall/"}),this._http.get("",{...this.options.requestData??{},search:t,limit:this.options.limit??50})}},_s=class extends P{static legacyName="gx.zeyos.Select"},ms=class extends P{static legacyName="gx.zeyos.SelectFilter";static filterMode="local"},gs=class extends P{static legacyName="gx.zeyos.SelectDyn";static filterMode="async"},bs=class extends P{static legacyName="gx.zeyos.SelectPrio";static filterMode="priority"},ys=class extends P{static legacyName="gx.bootstrap.Select"},xs=class extends P{static legacyName="gx.bootstrap.SelectFilter";static filterMode="local"},vs=class extends P{static legacyName="gx.bootstrap.SelectDyn";static filterMode="async"},ws=class extends P{static legacyName="gx.bootstrap.SelectDynREST";static filterMode="rest";async setEntityId(t){let e=this.data?.find(s=>Object.is(ks(s,this.options.elementIndex??"ID"),t));if(e){this.set(e);return}if(!(t==null||t===""))try{this._http??=wt(String(this.options.entity??""),String(this.options.accesskey??""),{apiBase:this.options.apiBase??"../remotecall/"});let s=await this._http.get(String(t));s&&this.set(s)}catch(s){throw this.fireEvent("requestFailure",[s]),s}}},As=class extends P{static legacyName="gx.bootstrap.SelectPrio";static filterMode="priority"};function ml(i){let t=Array.isArray(i.data)?i.data.slice():[];return i.elementDefault==null?t:[i.elementDefault,...t]}function gl(i){return typeof i=="function"?i:String(i)}function bl(i){return typeof i!="function"?String(i):t=>tn(i(t))}function yl(i){return t=>tn(ks(t,i))}function ks(i,t){return typeof t=="function"?t(i):i?.[t]}function tn(i){return i?.nodeType?i.textContent??"":String(i??"")}function nt(i,t){return class{constructor(){throw new Error(`${i} is not emulated by Zx; migrate to ${t}`)}}}var en=nt("gx.core.Settings","plain option objects"),sn=nt("gx.ui.Container","zx.Component"),rn=nt("gx.ui.Collapse","CSS transitions"),nn=nt("gx.ui.Blend","CSS transitions"),on=nt("gx.ui.Hud","zx.Dialog"),an=nt("gx.ui.Toggling","zx.Toggle"),ln=nt("gx.ui.HGroup","CSS layout"),cn=nt("gx.ui.Templates","native template elements");var hn=Object.freeze({initValue:xl,initNum:vl,formatTime:wl,getMinutes:Al,formatNum:kl,getNumber:Sl,printf:zl,parseResult:Cl,Parse:Y,isArray:Array.isArray,isObject:i=>i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(typeof Node<"u"&&i instanceof Node)&&!(i instanceof Date),isFunction:i=>typeof i=="function",isString:i=>typeof i=="string",isNumber:i=>typeof i=="number"&&Number.isFinite(i),isElement:i=>typeof Element<"u"&&i instanceof Element,isNode:i=>typeof Node<"u"&&i instanceof Node,Console:(i,t)=>{typeof console>"u"||(t instanceof Error?console.error(i,t.stack):console.log(`${i}: ${t}`))}});function xl(i,t,e){return i?.[t]==null?e:i[t]}function vl(i){return typeof i=="number"?i:typeof i=="string"?Number.parseFloat(i):0}function wl(i){let t=i;if(typeof t=="string"){if(/^[0-9]+:[0-9]{2}$/.test(t))return t;if(/^[0-9]+:[0-9]{2,}$/.test(t))return t.replace(/[^0-9]/g,"").replace(/([0-9]{2})$/,":$1");t=Number.parseInt(t.replace(/[^0-9]/g,""),10)}if(t==null||Number.isNaN(Number(t)))return"0:00";let e=Number(t),s=e<0?"-":"";return e=Math.abs(e),`${s}${Math.floor(e/60)}:${Dl(e%60)}`}function Al(i){let t=String(i??"").replace(/[^0-9:]/,"").split(":");return t.length===1?Number.parseInt(t[0],10):Number.parseInt(t[0],10)*60+Number.parseInt(t[1],10)}function kl(i,t=".",e=",",s=2){let r=i;typeof r=="string"&&(r=Number.parseFloat(r.replace(new RegExp(`[^0-9${un(t)}]`),"").replace(t,"."))),Number.isNaN(Number(r))&&(r=0);let n=typeof s=="number"?s:2,o=Math.round(Number(r)*10**n).toString();for(let c=o.length;c<=n;c+=1)o=`0${o}`;let l=o.length-n;n>0&&(o=`${o.slice(0,l)}${t}${o.slice(l)}`);for(let c=l-3;c>0;c-=3)o=`${o.slice(0,c)}${e}${o.slice(c)}`;return o}function Sl(i,t="."){return Number.parseFloat(String(i??"").replace(new RegExp(`[^0-9${un(t)}]`),"").replace(t,"."))}function zl(i,t=[]){let e=Array.isArray(t)?t:[t],s=0;return String(i??"").replace(/%arg%/g,r=>s<e.length?String(e[s++]):r)}function Cl(i){let t=typeof i=="string"?JSON.parse(i):i;if(!t||typeof t!="object")throw new Error("Invalid server response");if(t.error)throw new Error(String(t.error.message??t.error));if(!Object.hasOwn(t,"result")||t.result==null)throw new Error("Undefined result");return t.result}function Dl(i){return String(i).padStart(2,"0")}function un(i){return String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Tl=Object.freeze({installGlobals:hi,installElementStorage:bt,parse:Y,GxWrapper:x}),Ss={core:{Settings:en},ui:{Container:sn,SimpleTable:Ke,Timebox:Ze,Collapse:rn,Blend:nn,Hud:on,Toggling:an,HGroup:ln,Templates:cn},util:hn,zeyos:{Toggle:Se,Msgbox:ze,Popup:Te,Dialog:Ee,Dropdown:Ne,Select:_s,SelectFilter:ms,SelectDyn:gs,SelectPrio:bs,Checklist:Be,Permission:Re,Table:qe,Tabbox:te,Panel:ls,MasterPanel:cs,Groupbox:as,Search:ds,Datebox:Ue,DatePicker:We,TimePicker:Qe,MonthPicker:Ge,Timebox:Je,Client:ns,Request:os,Factory:Qr},bootstrap:{Message:Ce,Popup:zt,PopupAlert:si,PopupConfirm:ii,PopupConfirmCanceled:ei,MenuButton:Me,CheckButton:Oe,Select:ys,SelectFilter:xs,SelectDyn:vs,SelectDynREST:ws,SelectPrio:As,Checklist:je,Table:$e,Tabbox:hs,NavigationBar:us,Timebox:Xe,Form:es,Fieldset:Dt,Field:V,ValueList:ss,MultiValueEditor:is,FieldUpload:rs,DataFilter:Ye},compat:Tl};function El(i=globalThis){return bt(i),i.gx=Ss,Ss}Ss.install=El;var y_=Ss;export{x as GxWrapper,y_ as default,Ss as gx,El as install,bt as installElementStorage,hi as installGlobals,Y as parse};
|