@zeyos/zx 4.3.4 → 4.4.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 +155 -0
- package/README.md +7 -0
- package/dist/types/components/activity-item/activity-item.d.ts +351 -0
- package/dist/types/components/activity-list/activity-list.d.ts +195 -0
- package/dist/types/components/app-sidebar/app-sidebar.d.ts +28 -0
- package/dist/types/components/button/button.d.ts +8 -0
- package/dist/types/components/calendar/calendar.d.ts +19 -0
- package/dist/types/components/card/card.d.ts +7 -0
- package/dist/types/components/card-view/card-view.d.ts +11 -3
- package/dist/types/components/card-view/record-card.d.ts +7 -1
- package/dist/types/components/code-editor/code-editor.d.ts +160 -0
- package/dist/types/components/code-editor/field-adapter.d.ts +5 -0
- package/dist/types/components/context-menu/context-menu.d.ts +18 -2
- package/dist/types/components/date-picker/date-picker.d.ts +8 -0
- package/dist/types/components/date-picker/time-picker.d.ts +7 -0
- package/dist/types/components/dialog/dialog.d.ts +29 -0
- package/dist/types/components/entity-ref/entity-ref.d.ts +331 -0
- package/dist/types/components/file-item/file-item.d.ts +234 -0
- package/dist/types/components/file-list/file-list.d.ts +171 -0
- package/dist/types/components/filter/filter.d.ts +91 -36
- package/dist/types/components/filter-panel/filter-panel.d.ts +449 -0
- package/dist/types/components/kanban-view/kanban-card.d.ts +138 -0
- package/dist/types/components/kanban-view/kanban-view.d.ts +170 -4
- package/dist/types/components/launcher/launcher.d.ts +19 -12
- package/dist/types/components/list-toolbar/list-toolbar.d.ts +599 -0
- package/dist/types/components/menu-button/menu-button.d.ts +4 -37
- package/dist/types/components/message/message.d.ts +7 -0
- package/dist/types/components/modal/modal.d.ts +48 -0
- package/dist/types/components/navigation-bar/navigation-bar.d.ts +105 -21
- package/dist/types/components/panel/panel.d.ts +7 -0
- package/dist/types/components/search/search.d.ts +7 -0
- package/dist/types/components/select/select.d.ts +4 -0
- package/dist/types/components/sort-control/sort-control.d.ts +105 -0
- package/dist/types/components/stat-tile/stat-tile.d.ts +277 -0
- package/dist/types/components/tabbox/tabbox.d.ts +7 -0
- package/dist/types/components/table/table.d.ts +144 -0
- package/dist/types/components/table-view/table-view.d.ts +11 -5
- package/dist/types/components/timebox/timebox.d.ts +7 -0
- package/dist/types/components/value-list/value-list.d.ts +8 -0
- package/dist/types/components/view/record-view.d.ts +96 -5
- package/dist/types/core/icons.d.ts +17 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/internal/app-rail.d.ts +10 -0
- package/dist/types/internal/menu-items.d.ts +134 -0
- package/dist/zx-zeyos.esm.js +616 -77
- package/dist/zx-zeyos.esm.min.js +8 -1
- package/dist/zx.css +2085 -238
- package/dist/zx.esm.js +6704 -1542
- package/dist/zx.esm.min.js +10 -3
- package/dist/zx.global.js +6704 -1542
- package/dist/zx.global.min.js +10 -3
- package/dist/zx.min.css +1 -1
- package/docs/api.json +1479 -127
- package/docs/llms.md +315 -10
- package/docs/llms.txt +11 -5
- package/package.json +1 -1
- package/src/components/activity-item/activity-item.css +137 -0
- package/src/components/activity-item/activity-item.js +599 -0
- package/src/components/activity-list/activity-list.css +64 -0
- package/src/components/activity-list/activity-list.js +375 -0
- package/src/components/app-rail/app-rail.css +227 -19
- package/src/components/app-sidebar/app-sidebar.css +414 -24
- package/src/components/app-sidebar/app-sidebar.js +65 -5
- package/src/components/button/button.css +8 -0
- package/src/components/button/button.js +6 -1
- package/src/components/calendar/calendar.js +33 -3
- package/src/components/card/card.js +12 -1
- package/src/components/card-view/card-view.css +1 -0
- package/src/components/card-view/card-view.js +25 -9
- package/src/components/card-view/record-card.js +7 -3
- package/src/components/code-editor/code-editor.css +67 -0
- package/src/components/code-editor/code-editor.js +288 -0
- package/src/components/code-editor/field-adapter.js +34 -0
- package/src/components/context-menu/context-menu.css +80 -3
- package/src/components/context-menu/context-menu.js +22 -30
- package/src/components/date-picker/date-picker.js +22 -8
- package/src/components/date-picker/month-picker.js +3 -3
- package/src/components/date-picker/time-picker.js +20 -8
- package/src/components/dialog/dialog.js +88 -66
- package/src/components/dropdown/dropdown.js +2 -2
- package/src/components/entity-ref/entity-ref.css +182 -0
- package/src/components/entity-ref/entity-ref.js +496 -0
- package/src/components/file-item/file-item.css +88 -0
- package/src/components/file-item/file-item.js +371 -0
- package/src/components/file-list/file-list.css +51 -0
- package/src/components/file-list/file-list.js +320 -0
- package/src/components/filter/filter.css +27 -1
- package/src/components/filter/filter.js +199 -45
- package/src/components/filter-panel/filter-panel.css +104 -0
- package/src/components/filter-panel/filter-panel.js +964 -0
- package/src/components/kanban-view/kanban-card.js +239 -0
- package/src/components/kanban-view/kanban-view.css +194 -0
- package/src/components/kanban-view/kanban-view.js +251 -8
- package/src/components/launcher/launcher.js +59 -27
- package/src/components/list-toolbar/list-toolbar.css +189 -0
- package/src/components/list-toolbar/list-toolbar.js +851 -0
- package/src/components/menu-button/menu-button.css +80 -3
- package/src/components/menu-button/menu-button.js +21 -37
- package/src/components/message/message.css +5 -2
- package/src/components/message/message.js +13 -2
- package/src/components/modal/modal.css +15 -0
- package/src/components/modal/modal.js +141 -0
- package/src/components/navigation-bar/navigation-bar.css +77 -2
- package/src/components/navigation-bar/navigation-bar.js +171 -4
- package/src/components/panel/panel.js +13 -2
- package/src/components/search/search.js +17 -5
- package/src/components/select/field-adapter.js +4 -1
- package/src/components/select/select.js +3 -0
- package/src/components/sort-control/sort-control.css +17 -0
- package/src/components/sort-control/sort-control.js +140 -0
- package/src/components/stat-tile/stat-tile.css +213 -0
- package/src/components/stat-tile/stat-tile.js +590 -0
- package/src/components/tabbox/tabbox.js +12 -1
- package/src/components/table/table.css +51 -2
- package/src/components/table/table.js +298 -19
- package/src/components/table-view/table-view.css +8 -2
- package/src/components/table-view/table-view.js +21 -6
- package/src/components/tag-picker/tag-picker.css +3 -1
- package/src/components/timebox/timebox.js +18 -5
- package/src/components/value-list/value-list.js +22 -6
- package/src/components/view/record-view.css +5 -0
- package/src/components/view/record-view.js +100 -7
- package/src/core/icons.js +74 -5
- package/src/index.js +25 -0
- package/src/internal/app-rail.js +19 -1
- package/src/internal/menu-items.js +142 -0
- package/styles/print.css +192 -0
- package/styles/zx.css +11 -0
package/dist/zx.esm.min.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
function Yc(s,t){let e=null;return function(...n){let r=this;e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,s.apply(r,n)},t)}}function Wc(s,t,{leading:e=!0,trailing:i=!0}={}){let n=Math.max(0,Number(t)||0),r=null,o=0,a=null,c=null,h=()=>{r=null,o=e?Date.now():0;let d=a,u=c;a=null,c=null,d!==null&&s.apply(u,d)};return function(...u){let p=Date.now();o===0&&!e&&(o=p);let f=n-(p-o);if(f<=0||f>n){r!==null&&(clearTimeout(r),r=null),o=p,a=null,c=null,s.apply(this,u);return}i&&(a=u,c=this,r===null&&(r=setTimeout(h,f)))}}var Jr=0;function x(s="zx"){return Jr+=1,`${s}-${Date.now().toString(36)}-${Jr.toString(36)}`}function ze(s,t){let e=Ae(s)?eo(s):{};if(!Ae(t))return gi(t);for(let[i,n]of Object.entries(t))Ae(n)&&Ae(e[i])?e[i]=ze(e[i],n):e[i]=gi(n);return e}function F(s){return!!(s&&typeof s=="object"&&s.nodeType===1)}function Ft(s){if(typeof s!="string")return!1;let t=s.trim();if(!t||t.length>256||/[;{}\u0000-\u001f\u007f]/.test(t)||/(?:url|image|image-set|cross-fade|element|var)\s*\(/i.test(t))return!1;let e=globalThis.CSS?.supports;if(typeof e=="function")try{return e.call(globalThis.CSS,"color",t)}catch{return!1}return/^(?:#[\da-f]{3,8}|[a-z]+|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix)\([^;{}]+\))$/i.test(t)}function P(s,t,e){return Math.min(e,Math.max(t,s))}function bi(s){if(s==null)return[];if(Array.isArray(s))return s.slice();let t=s;return typeof s!="string"&&typeof t?.[Symbol.iterator]=="function"||typeof s!="string"&&typeof t?.length=="number"?Array.from(t):[s]}function Gc(s,t){let e=mi(t),i=new Map;for(let n of bi(s)){let r=String(e(n)),o=i.get(r);o===void 0?i.set(r,[n]):o.push(n)}return Object.fromEntries(i)}function Qc(s,...t){let e=bi(s),i=t.map(Jc);return i.length===0?e:e.sort((n,r)=>{for(let o of i){let a=o(n,r);if(a!==0)return a}return 0})}function Xc(s,t){let e=t==null?r=>r:mi(t),i=new Set,n=[];for(let r of bi(s)){let o=e(r);i.has(o)||(i.add(o),n.push(r))}return n}function Ce(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function mi(s){if(typeof s=="function")return s;let t=String(s);return e=>e?.[t]}function Jc(s){let t,e=1;if(typeof s=="function")t=s;else if(s!==null&&typeof s=="object")t=mi(s.key),String(s.dir).toLowerCase()==="desc"&&(e=-1);else{let i=String(s);i.startsWith("-")?(e=-1,i=i.slice(1)):i.startsWith("+")&&(i=i.slice(1)),t=mi(i)}return(i,n)=>{let r=t(i),o=t(n),a=Zr(r),c=Zr(o);return a||c?a&&c?0:a?1:-1:e*Zc(r,o)}}function Zr(s){return s==null||typeof s=="number"&&Number.isNaN(s)}function Zc(s,t){return s instanceof Date||t instanceof Date?Is(to(s)-to(t)):typeof s=="boolean"||typeof t=="boolean"?Is(Number(s)-Number(t)):typeof s=="number"&&typeof t=="number"?Is(s-t):String(s).localeCompare(String(t),void 0,{numeric:!0})}function to(s){if(s instanceof Date)return s.getTime();let t=Number(s);return Number.isFinite(t)?t:0}function Is(s){return Number.isNaN(s)?0:s<0?-1:s>0?1:0}function Ae(s){if(s===null||typeof s!="object")return!1;let t=Object.getPrototypeOf(s);return t===Object.prototype||t===null}function eo(s){let t={};for(let[e,i]of Object.entries(s))t[e]=gi(i);return t}function gi(s){return Ae(s)?eo(s):Array.isArray(s)?s.map(gi):s}var Te=null,th=new Set(["href","id","lang","name","rel","src","target","title","value"]),De=new WeakMap;function io(s){if(typeof s!="string")throw new TypeError("DOM builder tag must be a string");let t=s,e="",i="",n=t.indexOf(".");return n!==-1&&(e=t.slice(n+1),t=t.slice(0,n)),n=t.indexOf("#"),n!==-1&&(i=t.slice(n+1),t=t.slice(0,n)),{tag:t||"div",id:i,className:e}}function yi(s,t=null,e=null){let i=io(s),n=document.createElement(i.tag);if(i.id&&(n.id=i.id),i.className&&(n.className=i.className),i.tag==="a"){let r=n;r.rel="noopener",r.tabIndex=-1}else if(i.tag==="button")n.type="button";else if(i.tag==="input"||i.tag==="textarea"){let r=n;r.autocapitalize="none",r.autocomplete="off",r.autocorrect="off",r.spellcheck=!1}return t&&so(n,t),dh(n,e),n}var eh=yi;function it(s){if(typeof s!="string")return null;let t=s.trim();if(!t)return null;try{let e=new URL(t,globalThis.location?.href??"https://zx.invalid/").protocol;if(["javascript:","data:","vbscript:"].includes(e.toLowerCase()))return null}catch{return null}return t}function so(s,t){for(let e in t??{}){let i=t[e];if(i!=null)if(e[0]==="D")s.setAttribute(`data-${e.slice(1)}`,String(i));else if(e[0]==="S")s.style[e.slice(1)]=i;else if(e.startsWith("on")){if(typeof i!="function")throw new TypeError(`Compact DOM event ${e} must be a function`);oo(s,e.slice(2),i)}else typeof i=="boolean"||th.has(e)?s[e]=i:s.setAttribute(e,String(i))}return s}function ih(s,t){if(t==null)return s;let e=ro(t);return e==null||(typeof e=="object"?s.appendChild(e):s.appendChild(document.createTextNode(String(e)))),s}function sh(s,t,e=null,i=null){return s.appendChild(yi(t,e,i)),s}function nh(s,t,e=null,i=null){let n=yi(t,e,i);return s.appendChild(n),n}function rh(...s){let t=document.createDocumentFragment();return no(t,s),t}function l(s,t,...e){let i=document.createElement(s),n=t;lh(n)||(e.unshift(n),n={});for(let[r,o]of Object.entries(n))ch(i,r,o);return no(i,e),i}l.scope=function(t,e){let i=Te;Te=t;try{return e()}finally{Te=i}};l.raw=function(t){let e=document.createElement("template");return e.innerHTML=String(t),e.content};function A(s){return{children:Array.from(s.childNodes),attributes:Array.from(s.attributes,t=>[t.name,t.value])}}function k(s,t){if(t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}}function oh(s){return String(s).replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}function ah(s,t,e={}){let{className:i="zx-mark"}=e,n=s==null?"":String(s),r=t==null?"":String(t).trim(),o=document.createDocumentFragment();if(r===""||n==="")return o.append(document.createTextNode(n)),o;let a=new RegExp(Ce(r),"gi"),c=0;for(let h of n.matchAll(a)){h.index>c&&o.append(document.createTextNode(n.slice(c,h.index)));let d=document.createElement("mark");i&&(d.className=String(i)),d.append(document.createTextNode(h[0])),o.append(d),c=h.index+h[0].length}return c<n.length&&o.append(document.createTextNode(n.slice(c))),o}function U(s){if(s==null)return null;if(F(s))return s;if(typeof s=="string")return document.querySelector(s);if(typeof s.toElement=="function"){let t=s.toElement();return F(t)?t:null}return null}function lh(s){if(s===null||typeof s!="object"||Array.isArray(s))return!1;let t=s;return typeof t.nodeType=="number"?!1:typeof t.toElement!="function"}function ch(s,t,e){if(t==="ref"){Te&&typeof e=="string"&&(Te[e]=s);return}if(t==="class"){s.className=Array.isArray(e)?e.flat(1/0).filter(Boolean).join(" "):String(e??"");return}if(t==="style"){if(typeof e=="string")s.style.cssText=e;else if(e&&typeof e=="object")for(let[n,r]of Object.entries(e))n.startsWith("--")||n.includes("-")?s.style.setProperty(n,String(r)):s.style[n]=r;return}if(t==="dataset"&&e&&typeof e=="object"){for(let[n,r]of Object.entries(e))r==null?delete s.dataset[n]:s.dataset[n]=String(r);return}if(/^on[a-z]/.test(t)&&typeof e=="function"){s.addEventListener(t.slice(2),e);return}if(e==null)return;let i=hh(t);if(i!==null)s.setAttribute(i,String(e));else if(t in s)try{s[t]=e}catch{s.setAttribute(t,String(e))}else typeof e=="boolean"?e?s.setAttribute(t,""):s.removeAttribute(t):s.setAttribute(t,String(e))}function hh(s){return s.startsWith("aria-")?s:/^aria[A-Z]/.test(s)?"aria-"+s.slice(4).toLowerCase():null}function no(s,t){let e=s;for(let i of t.flat(1/0)){if(i==null)continue;if(typeof i=="string"||typeof i=="number"){e.append(document.createTextNode(String(i)));continue}if(typeof i!="object")continue;let n=i;if(typeof n.nodeType=="number")e.append(i);else if(typeof n.toElement=="function"){let r=n.toElement();r&&e.append(r)}}}function dh(s,t){if(t==null)return;let e=ro(t);e!=null&&(typeof e=="object"?s.appendChild(e):s.textContent=String(e))}function ro(s){if(s&&typeof s=="object"){if(typeof s.nodeType=="number")return s;if(typeof s.toElement=="function")return s.toElement()}return s}function oo(s,t,e,i=!1){if(typeof e!="function")throw new TypeError("Compact DOM event handler must be a function");let n=String(t),r=De.get(s);r||(r=new Map,De.set(s,r));let o=r.get(n);if(o)return o.handlers.push(e),s;let a=[e],c=h=>ao(s,a,h);r.set(n,{handlers:a,listener:c});try{s.addEventListener(n,c,{passive:i})}catch{s.addEventListener(n,c)}return s}function uh(s,t,e){let i=String(t),n=De.get(s),r=n?.get(i);if(!r)return s;let o=r.handlers.indexOf(e);return o===-1||(r.handlers.splice(o,1),r.handlers.length===0&&(s.removeEventListener(i,r.listener),n.delete(i),n.size===0&&De.delete(s))),s}function fh(s,t,e=null){let i=String(t),n=De.get(s);if(!n?.has(i))return s;let r=e??ph(s,i),o=n.get(String(r.type));return o&&ao(s,o.handlers,r),s}function ao(s,t,e){let i=e,n=String(i.type).startsWith("key")?i.which:i.target;for(let r=t.length-1;r>=0;r-=1)t[r].call(s,e,n)===!1&&i.preventDefault()}function ph(s,t){let e={target:s,type:t,which:-1,defaultPrevented:!1,preventDefault(){e.defaultPrevented=!0}};return e}var Es=null,lo="en";function _h(s){if(s!==null&&typeof s!="function")throw new TypeError("Translator must be a function or null");Es=s}function mh(s){lo=String(s||"en")}function ot(){return lo}function yt(s,t){let e=Es?Es(s):s;return V(e==null?s:String(e),t)}function V(s,t){if(t==null)return String(s);let e=Array.isArray(t)?t:typeof t=="object"?null:[t],i=String(s).replace(/%(\d+)/g,(r,o)=>{let a=Number(o)-1,c;return e?c=e[a]:Object.prototype.hasOwnProperty.call(t,o)&&(c=t[o]),c==null?r:String(c)}),n=0;return i=i.replace(/%([A-Za-z_][\w.-]*)%/g,(r,o)=>{if(!e&&Object.prototype.hasOwnProperty.call(t,o)){let a=t[o];return a==null?r:String(a)}if(e&&n<e.length){let a=e[n];return n+=1,a==null?r:String(a)}return r}),i}var wi=new WeakMap,b=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#t=new AbortController;#e=!1;#i=!1;#s=!1;constructor(t,e={}){super();let i=this.constructor;this.#e=t===null;let n=U(t);if(t!==null&&!n)throw new TypeError("Component target could not be resolved");this.el=n,this.refs={};let r=gh(i,e),o=[];for(let[h,d]of Object.entries(r))/^on[a-z]/.test(h)&&typeof d=="function"&&(o.push([h.slice(2),d]),delete r[h]);r.msg&&typeof r.msg=="object"&&Object.freeze(r.msg),this.options=Object.freeze(r);for(let[h,d]of o)this.on(h,d);let a;try{a=l.scope(this.refs,()=>this.render())}catch(h){throw this.#t.abort(),h}if(this.#e){let h=F(a)?a:this.el;if(!F(h))throw this.#t.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=h}if(!F(this.el))throw this.#t.abort(),new TypeError("Component requires a root Element");let c=i.cssName;if(typeof c=="string"&&c){let h=`zx-${c}`;this.#s=!this.el.classList.contains(h),this.el.classList.add(h)}wi.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={},i={}){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("Event detail must be an object");let n=co(t,e,{cancelable:!0});if(this.dispatchEvent(n),this.el){let r=co(`zx-${t}`,e,{bubbles:!0,composed:!0,cancelable:!0});this.el.dispatchEvent(r),i.honorDomCancellation&&r.defaultPrevented&&n.preventDefault()}return n}listen(t,e,i,n={}){let r=typeof n=="boolean"?{capture:n}:{...n};return t.addEventListener(e,i,{...r,signal:this.#t.signal}),this}toElement(){return this.el}msg(t,...e){let i=this.options.msg,n=this.options.lang??this.options.language??ot(),r=i?.[n]?.[t];if(r!=null)return V(String(r),e);let o=i?.[t];return o!=null?V(String(o),e):yt(t,e)}destroy(){if(this.#i)return;this.#i=!0,this.#t.abort(),wi.get(this.el)===this&&wi.delete(this.el);let t=this.constructor.cssName;this.#s&&typeof t=="string"&&this.el&&this.el.classList.remove(`zx-${t}`),this.#e&&this.el&&this.el.remove()}static from(t){return wi.get(t)??null}};function gh(s,t){let e=[],i=s;for(;i&&i!==Function.prototype;)Object.prototype.hasOwnProperty.call(i,"defaults")&&e.unshift(i.defaults),i=Object.getPrototypeOf(i);let n={},r={},o=!1;for(let a of e)!a||typeof a!="object"||(Object.assign(n,a),a.msg&&typeof a.msg=="object"&&(o=!0,r=ze(r,a.msg)));return Object.assign(n,t&&typeof t=="object"?t:{}),t?.msg&&typeof t.msg=="object"&&(o=!0,r=ze(r,t.msg)),o&&(n.msg=r),n}function co(s,t,e){if(typeof CustomEvent=="function")return new CustomEvent(s,{...e,detail:t});let i=new Event(s,e);return Object.defineProperty(i,"detail",{configurable:!0,enumerable:!0,value:t}),i}var C=class s extends b{static cssName="field";static defaults={id:null,type:"text",label:"",description:"",value:void 0,placeholder:"",required:!1,disabled:!1,options:null,layout:"stack",props:{},msg:{"field.int":"Enter a whole number.","field.float":"Enter a valid number.","field.unknown":"Unknown field type: %1"}};static#t=new Map;static register(t,e){let i=String(t).trim().toLowerCase();if(!i)throw new TypeError("Field adapter type must not be empty");if(typeof e!="function")throw new TypeError("Field adapter must be a function");return s.#t.set(i,e),this}static has(t){return s.#t.has(String(t).trim().toLowerCase())}render(){let t=this.el??l("div");this.el=t;let e=String(this.options.type||"text").toLowerCase(),i=this.options.layout==="inline"?"inline":"stack";this._ownedComponents=new Set,this._ownedNodes=[],this._rootAttributes=vh(t,["data-layout","data-field-type","data-disabled","data-state"]),t.dataset.layout=i,t.dataset.fieldType=e,this.controlId=this.options.id?String(this.options.id):x("zx-field");let n=`${this.controlId}-label`,r=`${this.controlId}-description`,o=`${this.controlId}-highlight`,a=l("label",{class:"zx-field__label",id:n,htmlFor:this.controlId},String(this.options.label??""),this.options.required?l("span",{class:"zx-field__required",ariaHidden:"true"}," *"):null),c=l("div",{class:"zx-field__control"}),h=l("div",{class:"zx-field__description",id:r},String(this.options.description??"")),d=l("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),u=l("div",{class:"zx-field__body"},c,h,d);this._ownedNodes.push(a,u),t.append(a,u);let p=s.#t.get(e);if(p)try{this.adapter=yh(p(this,this.options))}catch(_){let m=_ instanceof Error?_.message:String(_);console.warn(`[zx.Field] Adapter "${e}" failed: ${m}`),this.adapter=uo(m,this.controlId)}else{let _=this.msg("field.unknown",e);console.warn(`[zx.Field] ${_}`),this.adapter=uo(_,this.controlId)}let f=this.adapter.el;return f.id||(f.id=this.controlId),a.htmlFor=f.id,wh(f)||f.setAttribute("aria-labelledby",n),this._baseDescribedBy=f.getAttribute("aria-describedby")??"",c.append(f),this._descriptionId=String(this.options.description??"")?r:"",this._highlightId=o,this._highlight=d,this._syncDescription(),this.initialValue=bh(e,this.options.value),this.adapter.set(this.initialValue,{silent:!0}),this.setDisabled(!!this.options.disabled),this.listen(f,"change",()=>{this.emit("change",{value:this.getValue()})}),t}getValue(){return this.adapter.get()}setValue(t,{silent:e=!1}={}){return this.adapter.set(t,{silent:e}),e||this.emit("change",{value:this.getValue()}),this}focus(){return this.adapter.focus(),this}reset(){return this.setValue(this.initialValue,{silent:!0}),this.clearHighlight(),this}setDisabled(t){let e=!!t;return this.adapter.setDisabled(e),this.el.dataset.disabled=String(e),this}setHighlight(t,e="danger"){if(!t)return this.clearHighlight();let i=["danger","warning","success"].includes(e)?e:"danger";return this.el.dataset.state=i,this._highlight.textContent=String(t??""),this._highlight.hidden=!t,i==="danger"&&t?(this._highlight.setAttribute("role","alert"),this.adapter.el.setAttribute("aria-invalid","true"),this.emit("invalid",{message:String(t)})):(this._highlight.removeAttribute("role"),this.adapter.el.removeAttribute("aria-invalid")),this._syncDescription(!!t),this}clearHighlight(){return delete this.el.dataset.state,this._highlight.textContent="",this._highlight.hidden=!0,this._highlight.removeAttribute("role"),this.adapter.el.removeAttribute("aria-invalid"),this._syncDescription(!1),this}getInput(){return this.adapter.el}own(t){if(!(t instanceof b))throw new TypeError("Field.own() requires a Component");return this._ownedComponents.add(t),t}_syncDescription(t=!1){let e=[this._baseDescribedBy,this._descriptionId,t?this._highlightId:""].flatMap(i=>i.split(/\s+/)).filter(Boolean);e.length?this.adapter.el.setAttribute("aria-describedby",[...new Set(e)].join(" ")):this.adapter.el.removeAttribute("aria-describedby")}destroy(){this.adapter?.destroy?.();for(let t of this._ownedComponents??[])t.destroy();this._ownedComponents?.clear();for(let t of this._ownedNodes??[])t.remove();xh(this.el,this._rootAttributes??new Map),super.destroy()}};function Ms(s){if(typeof s=="number")return Number.isInteger(s)?{valid:!0,value:s}:{valid:!1,value:String(s)};let t=String(s??"").trim();if(t==="")return{valid:!0,value:""};let e=po(t);return e!==null&&Number.isInteger(e)?{valid:!0,value:e}:{valid:!1,value:t}}function Ns(s){if(typeof s=="number")return Number.isFinite(s)?{valid:!0,value:s}:{valid:!1,value:String(s)};let t=String(s??"").trim();if(t==="")return{valid:!0,value:""};let e=po(t);return e!==null?{valid:!0,value:e}:{valid:!1,value:t}}function po(s){let t=s.replace(/[\s\u00a0]/g,"");if(!/^[+-]?[\d.,]+$/.test(t))return null;let e=/^[+-]/.test(t)?t[0]:"",i=e?t.slice(1):t;if(!/\d/.test(i))return null;let n=[...i.matchAll(/\./g)].map(c=>c.index),r=[...i.matchAll(/,/g)].map(c=>c.index),o;if(n.length&&r.length){let c=n.at(-1)>r.at(-1)?".":",",h=c==="."?",":".",d=i.lastIndexOf(c),u=i.slice(0,d),p=i.slice(d+1);if(!/^\d+$/.test(p)||!ho(u,h))return null;o=u.split(h).join("")+"."+p}else if(r.length>1||n.length>1){let c=r.length?",":".";if(!ho(i,c))return null;o=i.split(c).join("")}else r.length===1?o=i.replace(",","."):o=i;if(!/^(?:\d+(?:\.\d+)?|\.\d+)$/.test(o))return null;let a=Number(e+o);return Number.isFinite(a)?a:null}function ho(s,t){let e=s.split(t);return e.length>0&&/^\d{1,3}$/.test(e[0])&&e.slice(1).every(i=>/^\d{3}$/.test(i))}function bh(s,t){return t!==void 0?t:s==="checkbox"?!1:""}function yh(s){if(!s||typeof s!="object")throw new TypeError("Adapter must return an object");if(!(s.el&&s.el.nodeType===1))throw new TypeError("Adapter must provide an Element");for(let t of["get","set","focus","setDisabled"])if(typeof s[t]!="function")throw new TypeError(`Adapter is missing ${t}()`);return s}function uo(s,t){let e=l("div",{class:"zx-field__error-control",id:t,role:"alert",tabIndex:-1},s);return{el:e,get:()=>null,set:()=>{},focus:()=>e.focus(),setDisabled:()=>{}}}function wh(s){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(s.tagName)}function vh(s,t){return new Map(t.map(e=>[e,s.getAttribute(e)]))}function xh(s,t){for(let[e,i]of t)i===null?s.removeAttribute(e):s.setAttribute(e,i)}function Ie(s,t){let e={...s.props??{}};for(let i of Object.keys(e))(/^on[a-z]/i.test(i)||i==="content")&&delete e[i];return{...e,...t}}function vi(s,t){return(e,i)=>{let n=l(s,Ie(i,{type:s==="input"?t:void 0,placeholder:i.placeholder,required:i.required,disabled:i.disabled}));return Os(n)}}function Os(s){return{el:s,get:()=>s.value,set:t=>{s.value=t==null?"":String(t)},focus:()=>s.focus(),setDisabled:t=>{s.disabled=t}}}function _o(s){return(t,e)=>{let i=s==="int"?Ms:Ns,n=l("input",Ie(e,{type:"text",inputMode:s==="int"?"numeric":"decimal",placeholder:e.placeholder,required:e.required,disabled:e.disabled}));return t.listen(n,"blur",()=>{let r=i(n.value);if(!r.valid){t.setHighlight(t.msg(`field.${s}`),"danger");return}r.value!==""&&(n.value=String(r.value)),t.clearHighlight()}),{...Os(n),get:()=>i(n.value).value}}}var Sh=(s,t)=>{let e=l("input",Ie(t,{type:"checkbox",required:t.required,disabled:t.disabled}));return{el:e,get:()=>e.checked,set:i=>{e.checked=!!i},focus:()=>e.focus(),setDisabled:i=>{e.disabled=i}}},kh=(s,t)=>{let e=l("select",Ie(t,{required:t.required,disabled:t.disabled}));for(let[i,n]of mo(t.options))e.append(l("option",{value:i},n));return Os(e)},Ah=(s,t)=>{let e=l("div",{class:"zx-field__option-list",role:"radiogroup"}),i=t.id?String(t.id):x("zx-option-list"),n=mo(t.options).map(([r,o],a)=>{let c=l("input",{type:"radio",name:i,value:r,required:!!t.required&&a===0,disabled:t.disabled});return e.append(l("label",{class:"zx-field__option"},c,l("span",{},o))),c});return{el:e,get:()=>n.find(r=>r.checked)?.value??"",set:r=>{for(let o of n)o.checked=String(r??"")===o.value},focus:()=>(n.find(r=>r.checked)??n[0])?.focus(),setDisabled:r=>{for(let o of n)o.disabled=r;e.setAttribute("aria-disabled",String(r))}}},zh=(s,t)=>{let e=l("div",Ie(t,{class:"zx-field__static"})),i=null;return{el:e,get:()=>e.textContent,set:r=>{fo(i),i=null,r&&typeof r=="object"&&typeof r.nodeType=="number"?(i={node:r,parent:r.parentNode,next:r.nextSibling},e.replaceChildren(r)):e.textContent=r==null?"":String(r)},focus:()=>{},setDisabled:r=>{e.setAttribute("aria-disabled",String(r))},destroy:()=>fo(i)}};function fo(s){s&&(s.parent?s.parent.insertBefore(s.node,s.next?.parentNode===s.parent?s.next:null):s.node.remove())}var Ch=(s,t)=>{if(typeof t.adapter!="function")throw new TypeError("Custom fields require options.adapter");return t.adapter(s,t)};function mo(s){return Array.isArray(s)?s.map(t=>[String(t),String(t)]):s&&typeof s=="object"?Object.entries(s).map(([t,e])=>[t,String(e)]):[]}C.register("text",vi("input","text"));C.register("password",vi("input","password"));C.register("textarea",vi("textarea","text"));C.register("checkbox",Sh);C.register("int",_o("int"));C.register("float",_o("float"));C.register("select",kh);C.register("optionlist",Ah);C.register("hidden",vi("input","hidden"));C.register("html",zh);C.register("custom",Ch);function Rt(s,t,e){let i=go(t).split(/\s+/).filter(Boolean);return i.length===0?s.slice():s.filter(n=>{let r=Th(n,e).map(go);return i.every(o=>r.some(a=>a.includes(o)))})}function Th(s,t){return s===null||typeof s!="object"?[s]:!Array.isArray(t)||t.length===0?[s]:t.map(e=>typeof e=="function"?e(s):s[e])}function go(s){return String(s??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var wt=class extends b{static cssName="checklist";static defaults={items:[],valueKey:"ID",labelKey:"name",checkedKey:"on",search:!0,height:280,defaultChecked:!1,load:null};render(){this._items=[],this._visibleItems=[],this._checked=new Set,this._query="",this._loadSequence=0,this._createdRoot=!1,this._active=!0,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._createdRoot||(this._originalChildren=Array.from(t.childNodes));for(let o of["role","aria-labelledby","data-state"])this._originalAttributes.set(o,t.getAttribute(o));let e=x("zx-checklist-label"),i=l("div",{class:"zx-checklist__label",id:e},this._message("checklist.label","Checklist")),n=l("input",{ref:"search",class:"zx-checklist__search",type:"search",autocomplete:"off",placeholder:this._message("checklist.search","Search"),ariaLabel:this._message("checklist.search","Search checklist"),hidden:!this.options.search}),r=l("div",{ref:"list",class:"zx-checklist__list"});return r.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,t.replaceChildren(i,n,r),t.setAttribute("role","group"),t.setAttribute("aria-labelledby",e),this.listen(n,"input",()=>this.search(n.value)),this.listen(r,"change",o=>{let a=o.target;if(!a?.matches?.('input[type="checkbox"][data-index]'))return;let c=this._visibleItems[Number(a.dataset.index)];if(c===void 0)return;let h=this._itemValue(c);a.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)),i=new Set(this._items.map(n=>this._itemValue(n)).filter(n=>e.has(n)));return this._replaceChecked(i),this}checkAll(){return this._replaceChecked(new Set(this._items.map(t=>this._itemValue(t)))),this}uncheckAll(){return this._replaceChecked(new Set),this}search(t){this._query=String(t??"");let e=this.refs.search;return e.value!==this._query&&(e.value=this._query),this._visibleItems=Rt(this._items,this._query,[this.options.labelKey]),this._renderItems(),this}async reload(){if(!this._active||typeof this.options.load!="function")return this;let t=++this._loadSequence;this.el.setAttribute("data-state","loading"),this.refs.list.setAttribute("aria-busy","true");try{let e=await this.options.load();if(t!==this._loadSequence)return this;this._replaceItems(e),this.emit("loaded",{items:this._items.slice()})}finally{t===this._loadSequence&&(this.el.removeAttribute("data-state"),this.refs.list.setAttribute("aria-busy","false"))}return this}destroy(){this._active=!1,this._loadSequence+=1;let t=this.el;if(!this._createdRoot&&t){t.replaceChildren(...this._originalChildren);for(let[e,i]of this._originalAttributes)i===null?t.removeAttribute(e):t.setAttribute(e,i)}super.destroy()}_replaceItems(t){this._items=Array.isArray(t)?t.slice():[],this._checked=new Set(this._items.filter(e=>!!this._initialChecked(e)).map(e=>this._itemValue(e))),this._visibleItems=Rt(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let t=this._visibleItems.map((e,i)=>{let n=x("zx-checklist-item"),r=l("input",{type:"checkbox",id:n,checked:this._checked.has(this._itemValue(e)),dataset:{index:i}});return l("label",{class:"zx-checklist__item",for:n},r,l("span",{},this._itemLabel(e)))});t.length===0&&t.push(l("div",{class:"zx-checklist__empty",role:"status"},this._message("checklist.empty","No matches"))),this.refs.list.replaceChildren(...t)}_replaceChecked(t){Dh(this._checked,t)||(this._checked=t,this._renderItems(),this.emit("change",{values:this.getValues()}))}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){return String(this._read(t,this.options.labelKey)??"")}_initialChecked(t){let e;return typeof this.options.checkedKey=="function"?e=this.options.checkedKey(t):t!==null&&typeof t=="object"&&(e=t[this.options.checkedKey]),e??this.options.defaultChecked}_read(t,e){return typeof e=="function"?e(t):t===null||typeof t!="object"?t:t[e]}_message(t,e){let i=this.msg(t);return i===t?e:i}};function Dh(s,t){return s.size===t.size&&Array.from(s).every(e=>t.has(e))}function bo(){C.register("checklist",(s,t)=>{let e=s.own(new wt(null,{...t.props??{}})),i=!1,n=!1,r=()=>{e.el.setAttribute("aria-disabled",String(i));for(let o of e.el.querySelectorAll("input, button, select, textarea"))o.disabled=i};return s.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>{n||s.emit("change",{value:o.detail.values})}),e.on("loaded",r),{el:e.el,get:()=>e.getValues(),set:o=>{n=!0;try{e.setValues(Array.isArray(o)?o:[])}finally{n=!1}r()},focus:()=>{(e.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])")??e.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus()},setDisabled:o=>{i=!!o,r()}}})}var yo=["January","February","March","April","May","June","July","August","September","October","November","December"],wo=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],So=/%[demYyHMSaAbBs]/g;function D(s,t){return!(s instanceof Date)||Number.isNaN(s.getTime())?"":String(t).replace(So,e=>{switch(e){case"%d":return ce(s.getDate());case"%e":return String(s.getDate());case"%m":return ce(s.getMonth()+1);case"%Y":return String(s.getFullYear()).padStart(4,"0");case"%y":return ce(s.getFullYear()%100);case"%H":return ce(s.getHours());case"%M":return ce(s.getMinutes());case"%S":return ce(s.getSeconds());case"%a":return vo("weekday",s.getDay(),wo[s.getDay()]);case"%A":return Fs("weekday",s.getDay(),wo[s.getDay()]);case"%b":return vo("month",s.getMonth(),yo[s.getMonth()]);case"%B":return Fs("month",s.getMonth(),yo[s.getMonth()]);case"%s":return String(Math.floor(s.getTime()/1e3));default:return e}})}function X(s,t){let e=[],i="^",n=0;for(let _ of String(t).matchAll(So)){i+=xo(String(t).slice(n,_.index));let m=_[0],w=Ih(m);if(w===null)return null;i+=`(${w})`,e.push(m),n=_.index+m.length}i+=xo(String(t).slice(n))+"$";let r=new RegExp(i).exec(String(s));if(!r)return null;let o=Object.create(null);if(e.forEach((_,m)=>{o[_]=Number(r[m+1])}),o["%s"]!==void 0){let _=o["%s"]*1e3,m=new Date(_);return Number.isNaN(m.getTime())?null:m}let a=o["%Y"]??Eh(o["%y"])??1970,c=(o["%m"]??1)-1,h=o["%d"]??o["%e"]??1,d=o["%H"]??0,u=o["%M"]??0,p=o["%S"]??0,f=new Date(0);return f.setHours(0,0,0,0),f.setFullYear(a,c,h),f.setHours(d,u,p,0),Number.isNaN(f.getTime())||o["%Y"]!==void 0&&f.getFullYear()!==o["%Y"]||o["%y"]!==void 0&&f.getFullYear()%100!==o["%y"]||o["%m"]!==void 0&&f.getMonth()!==c||o["%d"]!==void 0&&f.getDate()!==h||o["%e"]!==void 0&&f.getDate()!==h||o["%H"]!==void 0&&f.getHours()!==d||o["%M"]!==void 0&&f.getMinutes()!==u||o["%S"]!==void 0&&f.getSeconds()!==p?null:f}function Rs(s,t,e){let i=s.getTime(),n=t instanceof Date?t.getTime():-1/0,r=e instanceof Date?e.getTime():1/0;return new Date(Math.min(r,Math.max(n,i)))}function j(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}function N(s,t){let e=new Date(s.getTime());return e.setDate(e.getDate()+t),e}function Lt(s,t){let e=new Date(s.getTime()),i=e.getDate();e.setDate(1),e.setMonth(e.getMonth()+t);let n=new Date(e.getFullYear(),e.getMonth()+1,0).getDate();return e.setDate(Math.min(i,n)),e}function Ee(s=ot()){if(!s||s.toLowerCase()==="en")return 1;try{let t=new Intl.Locale(s),e=t.getWeekInfo?.()??t.weekInfo;if(e?.firstDay)return e.firstDay%7}catch{}return 1}function ce(s){return String(s).padStart(2,"0")}function Fs(s,t,e){let i=`date.${s}.${t}`,n=yt(i);return n===i?e:n}function vo(s,t,e){let i=`date.${s}.short.${t}`,n=yt(i);return n!==i?n:Fs(s,t,e).slice(0,3)}function Ih(s){return{"%d":"\\d{1,2}","%e":"\\d{1,2}","%m":"\\d{1,2}","%Y":"\\d{4}","%y":"\\d{2}","%H":"\\d{1,2}","%M":"\\d{1,2}","%S":"\\d{1,2}","%s":"-?\\d+"}[s]??null}function Eh(s){if(s!==void 0)return s>=69?1900+s:2e3+s}function xo(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ps=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),Ao=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),ko=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"}),zo=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"}),Ls=new Map;function Vs(s){let t=String(s).trim();if(/\s/.test(t)||t.startsWith("fa-"))return{provider:"fa",name:"",style:null,classes:t.split(/\s+/).filter(Boolean)};let e=t.indexOf(":");if(e>0){let i=t.slice(0,e).toLowerCase(),n=t.slice(e+1);if(i==="builtin"||i==="zx")return{provider:"builtin",name:n,style:null,classes:null};if(Object.hasOwn(ko,i))return{provider:"fa",name:n,style:ko[i],classes:null}}return{provider:null,name:t,style:null,classes:null}}function xi(s,t={}){let{style:e="solid",family:i="classic",fixedWidth:n=!1,translate:r=!0}=t,o=String(s).replace(/^fa-/,""),a=r?zo[o]??o:o,c=[],h=Ao[i];return h&&c.push(h),c.push(Ps[e]??Ps.solid,`fa-${a}`),n&&c.push("fa-fw"),c}function Si(s){let t=String(s).trim();if(/^(https?:)?\/\//.test(t)||t.startsWith("/")||t.endsWith(".js"))return t;if(!/^[a-z0-9]+$/.test(t))throw new RangeError(`Invalid Font Awesome kit token: ${s}`);return`https://kit.fontawesome.com/${t}.js`}function Bs(s){let t=Si(s),e=Ls.get(t);if(e)return e;let i=new Promise((n,r)=>{let o=new URL(t,document.baseURI).href,a=[...document.scripts].find(h=>h.src===o);if(a&&globalThis.FontAwesomeKitConfig){n();return}let c=a??document.createElement("script");c.addEventListener("load",()=>n(),{once:!0}),c.addEventListener("error",()=>{Ls.delete(t),r(new Error(`Font Awesome kit failed to load: ${t}`))},{once:!0}),!a&&(c.src=t,c.async=!0,c.crossOrigin="anonymous",document.head.append(c))});return Ls.set(t,i),i}var Co="http://www.w3.org/2000/svg",qs=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"]}),Mh=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list"}),js=Object.create(null),zt={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function $s(){return{...zt}}function ki(s={}){for(let t of["provider","style","family","fixedWidth","kit"])s[t]!==void 0&&(zt[t]=s[t]);return $s()}function Do(s={}){return ki({...s,provider:"fontawesome"})}function Nh(){return ki({provider:"builtin"})}async function Oh(s){let t=typeof s=="string"?{kit:s}:{...s},{kit:e,activate:i=!0,...n}=t;if(!e)throw new TypeError("loadFontAwesome() needs a kit token or URL");return ki({...n,kit:Si(e)}),await Bs(e),i?Do():$s()}function Fh(s){for(let[t,e]of Object.entries(s)){if(!Array.isArray(e)||e.length!==2)throw new TypeError(`Icon "${t}" must be a [viewBox, path] pair`);js[t]=[String(e[0]),String(e[1])]}}function Rh(){return[...new Set([...Object.keys(qs),...Object.keys(js)])].sort()}function g(s,t={}){let e=Vs(s);if(e.classes)return Hs(e.classes,t);let i=Mh[e.name]??e.name;return e.provider==="builtin"?To(i,t):e.provider==="fa"?Hs(xi(i,{style:e.style??t.style??zt.style,family:t.family??zt.family,fixedWidth:t.fixedWidth??zt.fixedWidth}),t):zt.provider==="fontawesome"?Hs(xi(i,{style:t.style??zt.style,family:t.family??zt.family,fixedWidth:t.fixedWidth??zt.fixedWidth}),t):To(i,t)}function To(s,t){let e=js[s]??qs[s];if(!e)throw new RangeError(`Unknown icon: ${s}`);let[i,n]=e,{size:r=16}=t,o=document.createElementNS(Co,"svg"),a=document.createElementNS(Co,"path");return o.setAttribute("class",Eo("zx-icon",t.class)),o.setAttribute("viewBox",i),o.setAttribute("width",String(r)),o.setAttribute("height",String(r)),o.setAttribute("fill","currentColor"),o.setAttribute("focusable","false"),Io(o,t.label??null),a.setAttribute("d",n),o.append(a),o}function Hs(s,t){let{size:e=16}=t,i=document.createElement("i");return i.className=Eo("zx-icon",...s,t.class),i.style.fontSize=typeof e=="number"?`${e}px`:String(e),Io(i,t.label??null),i}function Io(s,t){if(t===null){s.setAttribute("aria-hidden","true");return}s.setAttribute("role","img"),s.setAttribute("aria-label",t)}function Eo(...s){return s.flat().filter(Boolean).join(" ")}var Lh=5,Me=class extends b{static cssName="time-picker";static defaults={value:null,seconds:!1,step:5,clock:!0};render(){let t=this.el??l("div");this.el=t;let e=Mo(this.options.value);this._value=e,this._display=e??{h:0,m:0,s:0},this._inputs=[],this._clockOpen=!1,this._clockUnit="h",this._clock=null;let i=l("div",{class:"zx-time-picker__segments",role:"group",ariaLabel:"Time"});if(this._content=i,this._addSpin(i,"h","Hour",23),i.append(l("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(i,"m","Minute",59),this.options.seconds&&(i.append(l("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(i,"s","Second",59)),t.append(i),this.options.clock){let n=x("zx-time-picker-clock");i.append(l("button",{ref:"clockToggle",class:"zx-icon-btn zx-time-picker__clock-toggle",type:"button",ariaLabel:"Pick the time on a clock",ariaExpanded:"false",ariaControls:n},g("clock",{size:15}))),this._clock=this._buildClock(n),t.append(this._clock),this.listen(this.refs.clockToggle,"click",()=>this.toggleClock())}return this._writeInputs(),t}get(){return this._value?{...this._value}:null}set(t,{silent:e=!1}={}){let i=Mo(t);return this._value=i,this._display=i??{h:0,m:0,s:0},this._writeInputs(),!e&&i&&this.emit("change",{time:{...i}}),this}openClock(t="h"){return this._clock?(this._clockOpen=!0,this._clockUnit=t==="m"?"m":"h",this._syncClock(),this):this}closeClock(){return this._clock?(this._clockOpen=!1,this._syncClock(),this):this}toggleClock(){return this._clockOpen?this.closeClock():this.openClock("h")}destroy(){this._content?.remove(),this._clock?.remove(),this._clock=null,super.destroy()}_addSpin(t,e,i,n){let r=l("input",{class:"zx-time-picker__spin",type:"text",role:"spinbutton",inputMode:"numeric",maxLength:2,autocomplete:"off",ariaLabel:i,ariaValueMin:"0",ariaValueMax:String(n),dataset:{segment:e}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"keydown",o=>this._onKeydown(o,e,n)),this.listen(r,"input",()=>this._onInput(r,e,n)),this.listen(r,"blur",()=>this._commitFromInputs())}_onKeydown(t,e,i){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return;t.preventDefault();let n=t.key==="ArrowUp"?1:-1,r=e==="m"?Hh(this.options.step):1,o=he(t.currentTarget.value,0,i),a=i+1,c=(o+n*r+a*r)%a;t.currentTarget.value=Kt(c),this._commitFromInputs()}_onInput(t,e,i){if(t.value=t.value.replace(/\D/g,"").slice(0,2),t.value.length<2)return;t.value=Kt(he(t.value,0,i)),this._commitFromInputs();let n=this._inputs.indexOf(t);this._inputs[n+1]?.focus()}_commitFromInputs(){let t={h:0,m:0,s:0};for(let i of this._inputs){let n=i.dataset.segment,r=n==="h"?23:59;t[n]=he(i.value,0,r)}let e=!this._value||!qh(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=Kt(this._display[e]),t.setAttribute("aria-valuenow",String(this._display[e])),t.setAttribute("aria-valuetext",t.value)}this._syncClock()}_buildClock(t){let e=l("div",{class:"zx-time-picker__clock",id:t,hidden:!0},l("div",{class:"zx-time-picker__clock-head"},l("button",{ref:"headHour",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:"Select the hour",dataset:{unit:"h"}}),l("span",{class:"zx-time-picker__clock-colon",ariaHidden:"true"},":"),l("button",{ref:"headMinute",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:"Select the minutes",dataset:{unit:"m"}})),l("div",{ref:"dial",class:"zx-time-picker__dial",role:"radiogroup"},l("span",{ref:"hand",class:"zx-time-picker__hand",ariaHidden:"true"}),l("span",{class:"zx-time-picker__pivot",ariaHidden:"true"})));return this.listen(this.refs.headHour,"click",()=>this.openClock("h")),this.listen(this.refs.headMinute,"click",()=>this.openClock("m")),this.listen(this.refs.dial,"click",i=>{let n=i.target.closest?.(".zx-time-picker__mark");n&&this._pick(Number(n.dataset.value))}),this.listen(this.refs.dial,"keydown",i=>this._onDialKeydown(i)),e}_pick(t){let e={...this._display,[this._clockUnit]:t},i=this._clockUnit==="h";this.set(e),i&&this.openClock("m")}_onDialKeydown(t){let e=[...this.refs.dial.querySelectorAll(".zx-time-picker__mark")],i=t.target.closest?.(".zx-time-picker__mark"),n=e.indexOf(i);if(n<0)return;let r={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[t.key],o=null;r!==void 0?o=(n+r+e.length)%e.length:t.key==="Home"?o=0:t.key==="End"&&(o=e.length-1),o!==null&&(t.preventDefault(),this._pick(Number(e[o].dataset.value)),this.refs.dial.querySelector(`[data-value="${e[o].dataset.value}"]`)?.focus())}_syncClock(){if(!this._clock)return;let t=this._clockUnit==="h";if(this._clock.hidden=!this._clockOpen,this.refs.clockToggle.setAttribute("aria-expanded",String(this._clockOpen)),this.refs.headHour.textContent=Kt(this._display.h),this.refs.headMinute.textContent=Kt(this._display.m),this.refs.headHour.setAttribute("aria-pressed",String(t)),this.refs.headMinute.setAttribute("aria-pressed",String(!t)),this.refs.dial.setAttribute("aria-label",t?"Hour":"Minutes"),!this._clockOpen)return;let e=t?this._display.h:this._display.m,i=t?Ph():Vh(),n=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(n.length!==i.length||this.refs.dial.dataset.unit!==this._clockUnit){for(let a of n)a.remove();this.refs.dial.dataset.unit=this._clockUnit,this.refs.dial.append(...i.map(a=>this._buildMark(a,e)))}else i.forEach((a,c)=>this._syncMark(n[c],a,e));let r=t&&!Bh(e)?"inner":"outer",o=t?e%12*30:e*6;this.refs.hand.dataset.ring=r,this.refs.hand.style.setProperty("--zx-clock-angle",`${o}deg`)}_buildMark(t,e){let i=l("button",{class:"zx-time-picker__mark",type:"button",role:"radio",dataset:{value:String(t.value),ring:t.ring}},t.label);return i.style.setProperty("--zx-clock-angle",`${t.angle}deg`),this._syncMark(i,t,e),i}_syncMark(t,e,i){let n=e.value===i;t.setAttribute("aria-checked",String(n)),t.tabIndex=n?0:-1}};function Ph(){let s=[];for(let t=1;t<=12;t+=1)s.push({value:t,label:String(t),angle:t%12*30,ring:"outer"});for(let t=0;t<12;t+=1){let e=t===0?0:12+t;s.push({value:e,label:Kt(e),angle:t*30,ring:"inner"})}return s}function Vh(){let s=[];for(let t=0;t<60;t+=Lh)s.push({value:t,label:Kt(t),angle:t*6,ring:"outer"});return s}function Bh(s){return s>=1&&s<=12}function Mo(s){return s instanceof Date&&!Number.isNaN(s.getTime())?{h:s.getHours(),m:s.getMinutes(),s:s.getSeconds()}:!s||typeof s!="object"?null:{h:he(s.h,0,23),m:he(s.m,0,59),s:he(s.s,0,59)}}function he(s,t,e){let i=Number.parseInt(String(s??""),10);return Number.isFinite(i)?Math.max(t,Math.min(e,i)):t}function Hh(s){let t=Math.round(Number(s));return Number.isFinite(t)&&t>0&&t<=59?t:5}function Kt(s){return String(s).padStart(2,"0")}function qh(s,t){return s.h===t.h&&s.m===t.m&&s.s===t.s}var Ut=class extends b{static cssName="date-picker";static defaults={value:null,min:null,max:null,weekStart:1,showWeekNumbers:!1,time:!1};render(){let t=this.el??l("div");this._min=at(Ai(this.options.min)),this._max=at(Ai(this.options.max)),this._value=this._normalizeValue(Ai(this.options.value)),this._focused=at(this._value)??this._clampFocus(at(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=jh(this.options.weekStart),this._quickOpen=!1,this._timePicker=null;let e=l("div",{class:"zx-date-picker__surface"},l("div",{class:"zx-date-picker__header"},l("button",{ref:"previous",class:"zx-date-picker__nav",type:"button",ariaLabel:"Previous month"},g("chevron-left")),l("button",{ref:"heading",class:"zx-date-picker__heading",type:"button",ariaExpanded:"false","aria-haspopup":"grid"}),l("button",{ref:"next",class:"zx-date-picker__nav",type:"button",ariaLabel:"Next month"},g("chevron-right"))),l("div",{ref:"quickPanel",class:"zx-date-picker__quick",hidden:!0},l("div",{class:"zx-date-picker__quick-header"},l("button",{ref:"quickPrevious",class:"zx-date-picker__nav",type:"button",ariaLabel:"Previous year"},g("chevron-left")),l("span",{ref:"quickYear",class:"zx-date-picker__quick-year",ariaLive:"polite"}),l("button",{ref:"quickNext",class:"zx-date-picker__nav",type:"button",ariaLabel:"Next year"},g("chevron-right"))),l("div",{ref:"quickGrid",class:"zx-date-picker__quick-grid",role:"grid"})),l("table",{ref:"grid",class:"zx-date-picker__grid",role:"grid",ariaLabel:"Calendar"},l("thead",{ref:"weekdays"}),l("tbody",{ref:"days"})));return this._content=e,t.append(e),this.listen(this.refs.previous,"click",()=>this._pageMonth(-1)),this.listen(this.refs.next,"click",()=>this._pageMonth(1)),this.listen(this.refs.heading,"click",()=>this._toggleQuickPick()),this.listen(this.refs.quickPrevious,"click",()=>this._stepQuickYear(-1)),this.listen(this.refs.quickNext,"click",()=>this._stepQuickYear(1)),this.listen(this.refs.quickGrid,"click",i=>this._onQuickClick(i)),this.listen(this.refs.quickGrid,"keydown",i=>this._onQuickKeydown(i)),this.listen(this.refs.days,"click",i=>this._onDayClick(i)),this.listen(this.refs.days,"keydown",i=>this._onDayKeydown(i)),this._renderWeekdays(),this._renderCalendar(),this.options.time&&(this._timePicker=new Me(null,{value:this._value,seconds:!1}),this._timePicker.on("change",i=>{let n=i.detail.time,r=this._value??this._focused,o=new Date(r.getTime());o.setHours(n.h,n.m,n.s,0),this.set(o)}),e.append(this._timePicker.el)),t}get(){return Ks(this._value)}set(t,{silent:e=!1}={}){let i=this._normalizeValue(Ai(t));return this._value=i,i&&(this._focused=at(i),this._viewYear=i.getFullYear(),this._viewMonth=i.getMonth()),this._timePicker?.set(i,{silent:!0}),this._renderCalendar(),e||this.emit("change",{date:Ks(this._value)}),this}focus(){return this._closeQuickPick(),this._buttonForDate(this._focused)?.focus(),this}destroy(){this._timePicker?.destroy(),this._timePicker=null,this._content?.remove(),super.destroy()}_normalizeValue(t){if(!t)return null;let e=new Date(t.getTime()),i=at(e);return this._min&&i<this._min&&No(e,this._min),this._max&&i>this._max&&No(e,this._max),e}_clampFocus(t){return this._min&&t<this._min?new Date(this._min.getTime()):this._max&&t>this._max?new Date(this._max.getTime()):t}_renderWeekdays(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-picker__week-heading",scope:"col",ariaLabel:"Week number"},"#"));let e=new Date(2023,0,1);for(let i=0;i<7;i+=1){let n=N(e,(this._weekStart+i)%7);t.append(l("th",{scope:"col",ariaLabel:D(n,"%A")},D(n,"%a")))}this.refs.weekdays.replaceChildren(t)}_renderCalendar(){if(!this.refs?.days)return;let t=new Date(this._viewYear,this._viewMonth,1),e=(t.getDay()-this._weekStart+7)%7,i=N(t,-e);this.refs.heading.textContent=D(t,"%B %Y"),this.refs.heading.setAttribute("aria-label",`Choose month and year, ${D(t,"%B %Y")}`);let n=[];for(let r=0;r<6;r+=1){let o=N(i,r*7),a=l("tr");this.options.showWeekNumbers&&a.append(l("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:`Week ${Oo(o)}`},String(Oo(o))));for(let c=0;c<7;c+=1){let h=N(o,c),d=!!(this._value&&j(h,this._value)),u=!this._inRange(h),p=l("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:j(h,this._focused)?0:-1,ariaSelected:String(d),ariaDisabled:String(u),ariaCurrent:j(h,new Date)?"date":null,ariaLabel:`${D(h,"%e")} ${D(h,"%B %Y")}`,dataset:{date:D(h,"%Y-%m-%d"),otherMonth:h.getMonth()===this._viewMonth?null:"true"}},D(h,"%e"));a.append(l("td",{role:"presentation"},p))}n.push(a)}this.refs.days.replaceChildren(...n),this._quickOpen&&this._renderQuickPick()}_onDayClick(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let i=X(e.dataset.date,"%Y-%m-%d");i&&this._inRange(i)&&this._selectDate(i)}_onDayKeydown(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let i=X(e.dataset.date,"%Y-%m-%d");if(!i)return;let n=null;if(t.key==="ArrowLeft")n=N(i,-1);else if(t.key==="ArrowRight")n=N(i,1);else if(t.key==="ArrowUp")n=N(i,-7);else if(t.key==="ArrowDown")n=N(i,7);else if(t.key==="PageUp")n=Lt(i,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=Lt(i,t.shiftKey?12:1);else if(t.key==="Home")n=N(i,-((i.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=N(i,6-(i.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._inRange(i)&&this._selectDate(i);return}n&&(t.preventDefault(),this._moveFocus(n))}_moveFocus(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;this._focused=at(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._renderCalendar(),e&&this._emitMonthChange(),this._buttonForDate(t)?.focus()}_selectDate(t){let e=new Date(t.getTime()),i=this._timePicker?.get();i?e.setHours(i.h,i.m,i.s,0):this._value&&e.setHours(this._value.getHours(),this._value.getMinutes(),this._value.getSeconds(),this._value.getMilliseconds());let n=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;this._value=e,this._focused=at(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._timePicker?.set(e,{silent:!0}),this._renderCalendar(),n&&this._emitMonthChange(),this.emit("change",{date:Ks(e)})}_pageMonth(t){this._closeQuickPick();let e=Lt(this._focused,t);this._focused=at(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._renderCalendar(),this._emitMonthChange()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_toggleQuickPick(){if(this._quickOpen){this._closeQuickPick(),this.refs.heading.focus();return}this._quickOpen=!0,this.refs.quickPanel.hidden=!1,this.refs.heading.setAttribute("aria-expanded","true"),this._renderQuickPick(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_closeQuickPick(){this._quickOpen&&(this._quickOpen=!1,this.refs.quickPanel.hidden=!0,this.refs.heading.setAttribute("aria-expanded","false"))}_renderQuickPick(){this.refs.quickYear.textContent=String(this._viewYear);let t=[];for(let e=0;e<12;e+=1){let i=new Date(this._viewYear,e,1);t.push(l("button",{class:"zx-date-picker__quick-month",type:"button",role:"gridcell",tabindex:e===this._viewMonth?0:-1,ariaSelected:String(e===this._viewMonth),dataset:{month:e}},D(i,"%b")))}this.refs.quickGrid.replaceChildren(...t)}_stepQuickYear(t){this._viewYear+=t,this._renderQuickPick(),this._emitMonthChange(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_onQuickClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.quickGrid.contains(e)||this._chooseQuickMonth(Number(e.dataset.month))}_onQuickKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.quickGrid.contains(e))return;let i=Number(e.dataset.month),n=null;if(t.key==="ArrowLeft")n=i-1;else if(t.key==="ArrowRight")n=i+1;else if(t.key==="ArrowUp")n=i-3;else if(t.key==="ArrowDown")n=i+3;else if(t.key==="Home")n=0;else if(t.key==="End")n=11;else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._chooseQuickMonth(i);return}else if(t.key==="Escape"){t.preventDefault(),this._closeQuickPick(),this.refs.heading.focus();return}if(n===null)return;t.preventDefault(),n=Math.max(0,Math.min(11,n));let r=this.refs.quickGrid.querySelectorAll("[data-month]");for(let o of r)o.tabIndex=Number(o.dataset.month)===n?0:-1;r[n]?.focus()}_chooseQuickMonth(t){let e=new Date(this._viewYear,t,Math.min(this._focused.getDate(),new Date(this._viewYear,t+1,0).getDate()));this._focused=at(e),this._viewMonth=t,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(t){let e=at(t);return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_buttonForDate(t){return this.refs.days.querySelector(`[data-date="${D(t,"%Y-%m-%d")}"]`)}};function Ai(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function at(s){return s?new Date(s.getFullYear(),s.getMonth(),s.getDate()):null}function Ks(s){return s?new Date(s.getTime()):null}function No(s,t){s.setFullYear(t.getFullYear(),t.getMonth(),t.getDate())}function jh(s){let t=Number(s);return Number.isInteger(t)&&t>=0&&t<=6?t:Ee()}function Oo(s){let t=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-i.getTime())/864e5+1)/7)}var Ne=class extends Ut{static cssName="month-picker";static defaults={value:null,min:null,max:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??l("div");this._min=Ci(zi(this.options.min)),this._max=Ci(zi(this.options.max)),this._value=this._normalizeMonth(zi(this.options.value));let e=this._value??Ci(new Date);this._year=e.getFullYear(),this._focusedMonth=e.getMonth();let i=l("div",{class:"zx-month-picker__surface"},l("div",{class:"zx-month-picker__header"},l("button",{ref:"previousYear",class:"zx-month-picker__nav",type:"button",ariaLabel:"Previous year"},g("chevron-left")),l("span",{ref:"year",class:"zx-month-picker__year",ariaLive:"polite"}),l("button",{ref:"nextYear",class:"zx-month-picker__nav",type:"button",ariaLabel:"Next year"},g("chevron-right"))),l("div",{ref:"grid",class:"zx-month-picker__grid",role:"grid",ariaLabel:"Choose month"}));return this._content=i,t.append(i),this.listen(this.refs.previousYear,"click",()=>this._stepYear(-1)),this.listen(this.refs.nextYear,"click",()=>this._stepYear(1)),this.listen(this.refs.grid,"click",n=>this._onMonthClick(n)),this.listen(this.refs.grid,"keydown",n=>this._onMonthKeydown(n)),this._renderMonths(),t}get(){return this._value?new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeMonth(zi(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=Ci(t);return this._min&&e<this._min&&(e=new Date(this._min.getTime())),this._max&&e>this._max&&(e=new Date(this._max.getTime())),e}_renderMonths(){if(!this.refs?.grid)return;this.refs.year.textContent=String(this._year);let t=[];for(let e=0;e<12;e+=1){let i=new Date(this._year,e,1),n=!!(this._value&&$h(i,this._value));t.push(l("button",{class:"zx-month-picker__month",type:"button",role:"gridcell",tabindex:e===this._focusedMonth?0:-1,ariaSelected:String(n),ariaDisabled:String(!this._inRange(i)),ariaLabel:D(i,"%B %Y"),dataset:{month:e}},D(i,"%b")))}this.refs.grid.replaceChildren(...t)}_stepYear(t){this._year+=t,this._renderMonths()}_onMonthClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.grid.contains(e)||this._selectMonth(Number(e.dataset.month))}_onMonthKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.grid.contains(e))return;let i=Number(e.dataset.month),n=null;if(t.key==="ArrowLeft")n=-1;else if(t.key==="ArrowRight")n=1;else if(t.key==="ArrowUp")n=-3;else if(t.key==="ArrowDown")n=3;else if(t.key==="Home")n=-(i%3);else if(t.key==="End")n=2-i%3;else if(t.key==="PageUp"){t.preventDefault(),this._stepYear(-1),this.focus();return}else if(t.key==="PageDown"){t.preventDefault(),this._stepYear(1),this.focus();return}else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._selectMonth(i);return}if(n===null)return;t.preventDefault();let r=this._year*12+i+n;this._year=Math.floor(r/12),this._focusedMonth=(r%12+12)%12,this._renderMonths(),this.focus()}_selectMonth(t){let e=new Date(this._year,t,1);this._inRange(e)&&(this._focusedMonth=t,this._value=e,this._renderMonths(),this.emit("change",{date:this.get()}))}_inRange(t){return!(this._min&&t<this._min)&&!(this._max&&t>this._max)}_button(t){return this.refs.grid.querySelector(`[data-month="${t}"]`)}};function zi(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function Ci(s){return s?new Date(s.getFullYear(),s.getMonth(),1):null}function $h(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()}function Fo(){C.register("month",(s,t)=>{let e=s.own(new Ne(null,{...t.props??{},value:t.value})),i=!1,n=()=>{e.el.setAttribute("aria-disabled",String(i));for(let r of e.el.querySelectorAll("button"))r.disabled=i};return s.listen(e.el,"change",r=>r.stopImmediatePropagation()),e.on("change",r=>s.emit("change",{value:r.detail.date})),{el:e.el,get:()=>e.get(),set:r=>{e.set(r instanceof Date?r:null,{silent:!0}),n()},focus:()=>e.focus(),setDisabled:r=>{i=!!r,n()}}})}var Kh=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function st(s,t,e={}){if(!(s instanceof Element)||!(t instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let i=Kh.has(e.placement)?e.placement:"bottom-start",n=Number(e.offset??4),r=e.flip??!0,o=e.matchWidth??!1,a=s.getAttribute("style"),c=t.getAttribute("style"),h=t.getAttribute("popover"),d=!1,u=null,p=()=>{},f=()=>{};if(t.setAttribute("popover","manual"),typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a")){let m=`--${x("zx-a")}`;s.style.setProperty("anchor-name",m),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.setProperty("position-anchor",m);let w=Uh(i,getComputedStyle(s).direction==="rtl");t.style.setProperty("position-area",w),t.style.setProperty("inset-area",w),t.style.setProperty("position-try-fallbacks",r?"flip-block, flip-inline, flip-block flip-inline":"none");let y=i.startsWith("top")?"margin-bottom":i.startsWith("bottom")?"margin-top":i.startsWith("left")?"margin-right":"margin-left";t.style.setProperty(y,`${n}px`),p=()=>{o&&(t.style.minWidth=`${s.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(u=new ResizeObserver(p),u.observe(s))}else t.style.position="fixed",t.style.inset="auto",t.style.margin="0",p=()=>Yh(s,t,{placement:i,offset:n,flip:r,matchWidth:o}),window.addEventListener("scroll",p,{capture:!0,passive:!0}),window.addEventListener("resize",p,{passive:!0}),typeof ResizeObserver=="function"&&(u=new ResizeObserver(p),u.observe(s)),f=()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)};return Wh(t),p(),{update(){d||p()},destroy(){d||(d=!0,u?.disconnect(),f(),Gh(t),Us(s,"style",a),Us(t,"style",c),Us(t,"popover",h))}}}function Uh(s,t){return{"bottom-start":t?"bottom span-left":"bottom span-right","bottom-end":t?"bottom span-right":"bottom span-left","top-start":t?"top span-left":"top span-right","top-end":t?"top span-right":"top span-left","right-start":"right span-bottom","right-end":"right span-top","left-start":"left span-bottom","left-end":"left span-top",bottom:"bottom",top:"top",right:"right",left:"left"}[s]}function Yh(s,t,{placement:e,offset:i,flip:n,matchWidth:r}){let o=s.getBoundingClientRect();r&&(t.style.minWidth=`${o.width}px`);let a=t.getBoundingClientRect(),c=document.documentElement.clientWidth||window.innerWidth,h=document.documentElement.clientHeight||window.innerHeight,d=e,u=Ro(e),p=o.bottom+i,f=o.top-i-a.height,_=o.right+i,m=o.left-i-a.width;n&&(u==="bottom"&&p+a.height>h&&f>=0?d=Ti(e,"bottom","top"):u==="top"&&f<0&&p+a.height<=h?d=Ti(e,"top","bottom"):u==="right"&&_+a.width>c&&m>=0?d=Ti(e,"right","left"):u==="left"&&m<0&&_+a.width<=c&&(d=Ti(e,"left","right")));let w=Ro(d),y,v;if(w==="bottom"||w==="top"){let S=getComputedStyle(s).direction==="rtl";d.endsWith("-end")?y=S?o.left:o.right-a.width:d.endsWith("-start")?y=S?o.right-a.width:o.left:y=o.left+(o.width-a.width)/2,v=w==="bottom"?p:f}else y=w==="right"?_:m,d.endsWith("-end")?v=o.bottom-a.height:d.endsWith("-start")?v=o.top:v=o.top+(o.height-a.height)/2;t.style.left=`${Math.round(P(y,0,Math.max(0,c-a.width)))}px`,t.style.top=`${Math.round(P(v,0,Math.max(0,h-a.height)))}px`}function Ro(s){return s.split("-")[0]}function Ti(s,t,e){return s.replace(t,e)}function Wh(s){if(typeof s.showPopover=="function")try{s.showPopover()}catch{}}function Gh(s){if(typeof s.hidePopover=="function")try{s.hidePopover()}catch{}}function Us(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}var Qh=6,qo=864e5;function de(s,t){let e=J(Yt(s)),i=J(Yt(t));return e&&i&&e.getTime()>i.getTime()?{start:i,end:e}:{start:e,end:i}}function Oe(s,t){let e=de(s,t);return!e.start||!e.end?0:Math.round((Vo(e.end)-Vo(e.start))/qo)}function jo(s,t,e){let i=J(Yt(s));if(!i)return null;let n=de(t,e);return!n.start&&!n.end?null:n.end?n.start?i.getTime()<n.start.getTime()||i.getTime()>n.end.getTime()?null:j(i,n.start)?"start":j(i,n.end)?"end":"middle":j(i,n.end)?"end":null:j(i,n.start)?"start":null}function Fe(s,t={}){let e=J(Yt(t.min)),i=J(Yt(t.max)),n=Di(t.minNights)??0,r=Di(t.maxNights),{start:o,end:a}=de(s?.start,s?.end);return o&&(o=Ws(o,e,i)),a&&(a=Ws(a,e,i)),!o||!a?{start:o,end:a}:(r!==null&&Oe(o,a)>r&&(a=N(o,r)),n>0&&Oe(o,a)<n&&(a=N(o,n),i&&a.getTime()>i.getTime()&&(a=new Date(i.getTime()),o=N(a,-n),e&&o.getTime()<e.getTime()))?{start:null,end:null}:{start:o,end:a})}var Re=class extends b{static cssName="date-range-picker";static defaults={start:null,end:null,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._rootAttributes=id(t,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=J(Yt(this.options.min)),this._max=J(Yt(this.options.max)),this._minNights=Di(this.options.minNights)??0,this._maxNights=Di(this.options.maxNights),this._weekStart=Zh(this.options.weekStart),this._monthCount=td(this.options.months),this._presets=Jh(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let e=Fe({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=Pt(this._start)??this._clampFocus(J(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),t.setAttribute("role","group"),t.setAttribute("aria-label",B("daterange.label","Date range")),t.dataset.months=String(this._monthCount),this._presets.length&&(t.dataset.presets="true");let i=l("div",{class:"zx-date-range-picker__surface"},this._presets.length?l("div",{ref:"presets",class:"zx-date-range-picker__presets",role:"group",ariaLabel:B("daterange.presets","Date range presets")},this._presets.map(r=>l("button",{class:"zx-date-range-picker__preset",type:"button",dataset:{preset:r.name}},r.label))):null,l("div",{ref:"calendars",class:"zx-date-range-picker__calendars"})),n=l("div",{ref:"status",class:"zx-date-range-picker__status",role:"status",ariaLive:"polite"});return this._nodes=[i,n],t.append(i,n),this.refs.presets&&this.listen(this.refs.presets,"click",r=>this._onPresetClick(r)),this.listen(this.refs.calendars,"click",r=>this._onCalendarClick(r)),this.listen(this.refs.calendars,"keydown",r=>this._onDayKeydown(r)),this.listen(this.refs.calendars,"mouseover",r=>this._onDayHover(r)),this.listen(this.refs.calendars,"mouseleave",()=>this._setHover(null)),this._renderCalendars(),this._announce(),t}get(){return{start:Pt(this._start),end:Pt(this._end)}}set(t={},{silent:e=!1}={}){let i=Fe({start:t?.start??null,end:t?.end??null},this._bounds());return this._start=i.start,this._end=i.end,this._picking=!!(i.start&&!i.end),this._remember(),this._hover=null,i.start?(this._focused=Pt(i.start),this._setView(i.start)):this._paint(),this._announce(),e||this.emit("change",this.get()),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}focus(){return this._buttonForDate(this._focused)?.focus(),this}enable(){return this._disabled=!1,this._paint(),this._syncDisabled(),this}disable(){return this._disabled=!0,this._hover=null,this._paint(),this._syncDisabled(),this}destroy(){for(let t of this._nodes??[])t.remove();this._nodes=[],this._dayCells=[],sd(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=J(t);if(!e||this._min&&e.getTime()<this._min.getTime()||this._max&&e.getTime()>this._max.getTime())return!1;if(!this._picking||!this._start||e.getTime()<=this._start.getTime())return!0;let i=Oe(this._start,e);return!(i<this._minNights||this._maxNights!==null&&i>this._maxNights)}_choose(t){let e=J(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?Pt(this._start):null,this._committedEnd=t?Pt(this._end):null}_abandon(){return this._picking?(this._start=Pt(this._committedStart),this._end=Pt(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(t){return Ws(t,this._min,this._max)}_visibleMonthCount(){let t=this.refs.calendars?.children??[],e=0;for(let i of t)i.getClientRects().length>0&&(e+=1);return e||this._monthCount}_setView(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;if(this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),!e){this._paint();return}this._renderCalendars(),this._emitMonthChange()}_ensureVisible(t){let e=this._visibleMonthCount(),i=Bo(t)-(this._viewYear*12+this._viewMonth);if(i>=0&&i<e)return!1;let n=i<0?i:i-(e-1),r=new Date(this._viewYear,this._viewMonth+n,1);return this._viewYear=r.getFullYear(),this._viewMonth=r.getMonth(),!0}_pageView(t){if(this._disabled)return;let e=new Date(this._viewYear,this._viewMonth+t,1);this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._focused=this._focusInView(this._focused),this._renderCalendars(),this._emitMonthChange()}_focusInView(t){let e=this._visibleMonthCount(),i=Bo(t)-(this._viewYear*12+this._viewMonth);if(i>=0&&i<e)return t;let n=new Date(this._viewYear,this._viewMonth+1,0).getDate();return new Date(this._viewYear,this._viewMonth,Math.min(t.getDate(),n))}_moveFocus(t){let e=J(t);this._focused=e,this._ensureVisible(e)?(this._renderCalendars(),this._emitMonthChange()):this._paint(),this._buttonForDate(e)?.focus()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_onPresetClick(t){let e=t.target?.closest?.("[data-preset]");if(!e||this._disabled)return;let i=this._presets.find(r=>r.name===e.dataset.preset);if(!i)return;let n=i.range();this.set({start:n?.start??null,end:n?.end??null},{silent:!0}),this.emit("select",this.get()),this.emit("change",this.get())}_onCalendarClick(t){let e=t.target,i=e?.closest?.("[data-nav]");if(i){this._pageView(i.dataset.nav==="next"?1:-1);return}let n=this._cellFor(e);n&&this._choose(n.date)}_onDayHover(t){let e=this._cellFor(t.target);this._setHover(e?e.date:null)}_setHover(t){if(this._disabled||!this._picking)return;let e=t?J(t):null;!e&&!this._hover||e&&this._hover&&j(e,this._hover)||(this._hover=e,this._paint())}_onDayKeydown(t){let e=this._cellFor(t.target);if(!e)return;let i=e.date,n=null;if(t.key==="ArrowLeft")n=N(i,-1);else if(t.key==="ArrowRight")n=N(i,1);else if(t.key==="ArrowUp")n=N(i,-7);else if(t.key==="ArrowDown")n=N(i,7);else if(t.key==="PageUp")n=Lt(i,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=Lt(i,t.shiftKey?12:1);else if(t.key==="Home")n=N(i,-((i.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=N(i,6-(i.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._choose(i);return}else if(t.key==="Escape"){if(!this._abandon())return;t.preventDefault(),t.stopPropagation();return}!n||this._disabled||(t.preventDefault(),this._moveFocus(n))}_renderCalendars(){if(!this.refs?.calendars)return;this._dayCells=[];let t=[];for(let e=0;e<this._monthCount;e+=1)t.push(this._renderMonth(new Date(this._viewYear,this._viewMonth+e,1)));this.refs.calendars.replaceChildren(...t),this._paint(),this._syncDisabled()}_renderMonth(t){let e=D(t,"%B %Y"),i=(t.getDay()-this._weekStart+7)%7,n=N(t,-i),r=[];for(let o=0;o<Qh;o+=1){let a=N(n,o*7),c=l("tr"),h=ed(a,t);this.options.showWeekNumbers&&c.append(l("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:h?B("daterange.week","Week %1",[Ho(a)]):null},h?String(Ho(a)):""));for(let d=0;d<7;d+=1){let u=N(a,d),p=l("td",{role:"presentation"});if(u.getMonth()===t.getMonth()&&u.getFullYear()===t.getFullYear()){let f=l("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:D(u,"%Y-%m-%d")}},D(u,"%e"));p.append(f),this._dayCells.push({date:u,cell:p,button:f})}c.append(p)}r.push(c)}return l("div",{class:"zx-date-range-picker__month"},l("div",{class:"zx-date-range-picker__header"},l("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"previous"},ariaLabel:B("daterange.previousMonth","Previous month")},g("chevron-left")),l("div",{class:"zx-date-range-picker__caption",ariaHidden:"true"},e),l("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"next"},ariaLabel:B("daterange.nextMonth","Next month")},g("chevron-right"))),l("table",{class:"zx-date-range-picker__grid",role:"grid",ariaLabel:e},l("thead",{},this._weekdayRow()),l("tbody",{},...r)))}_weekdayRow(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-range-picker__week-heading",scope:"col",ariaLabel:B("daterange.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let i=0;i<7;i+=1){let n=N(e,(this._weekStart+i)%7);t.append(l("th",{scope:"col",ariaLabel:D(n,"%A")},D(n,"%a")))}return t}_paint(){let t=new Date,e=null;for(let i of this._dayCells)j(i.date,this._focused)&&(e=i);e||(e=this._dayCells[0]??null);for(let i of this._dayCells){let{date:n,cell:r,button:o}=i,a=this._dayState(n);Ys(r,"range",a.range),Ys(r,"rangeEdge",a.edge),Ys(o,"range",a.range),o.tabIndex=i===e?0:-1,o.setAttribute("aria-selected",String(a.range!==null&&a.range!=="preview")),o.setAttribute("aria-disabled",String(!this._selectable(n))),o.setAttribute("aria-label",this._dayLabel(n,a.range)),j(n,t)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(t){if(this._start&&this._end){let i=jo(t,this._start,this._end);if(!i)return{range:null,edge:null};let n=j(this._start,this._end);return i==="start"?{range:i,edge:n?"both":"start"}:i==="end"?{range:i,edge:n?"both":"end"}:{range:i,edge:null}}if(!this._start)return{range:null,edge:null};let e=this._previewEnd();return j(t,this._start)?{range:"start",edge:e?"start":"both"}:e?t.getTime()>this._start.getTime()&&t.getTime()<=e.getTime()?{range:"preview",edge:j(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=J(t);return e.getTime()<=this._start.getTime()?null:this._selectable(e)?e:null}_dayLabel(t,e){let i=D(t,"%A, %e %B %Y");return e==="start"?`${i}, ${B("daterange.day.start","range start")}`:e==="end"?`${i}, ${B("daterange.day.end","range end")}`:e==="middle"?`${i}, ${B("daterange.day.middle","in selected range")}`:i}_syncDisabled(){this.el.setAttribute("aria-disabled",String(this._disabled));for(let t of this.el.querySelectorAll("button"))t.disabled=this._disabled}_announce(){this.refs?.status&&(this.refs.status.textContent=this._selectionLabel())}_selectionLabel(){if(!this._start)return B("daterange.status.empty","No date range selected");if(!this._end)return B("daterange.status.start","%1 selected, choose an end date",[D(this._start,"%e %B %Y")]);let t=Oe(this._start,this._end),e=t===1?B("daterange.night","1 night"):B("daterange.nights","%1 nights",[t]);return`${Xh(this._start,this._end)}, ${e}`}_cellFor(t){let e=t?.closest?.("[data-date]");return e?this._dayCells.find(i=>i.button===e)??null:null}_buttonForDate(t){return this._dayCells.find(e=>j(e.date,t))?.button??null}};function $o(){return[{name:"today",label:B("daterange.preset.today","Today"),range:()=>Lo(vt())},{name:"yesterday",label:B("daterange.preset.yesterday","Yesterday"),range:()=>Lo(N(vt(),-1))},{name:"last7",label:B("daterange.preset.last7","Last 7 days"),range:()=>({start:N(vt(),-6),end:vt()})},{name:"last30",label:B("daterange.preset.last30","Last 30 days"),range:()=>({start:N(vt(),-29),end:vt()})},{name:"thisMonth",label:B("daterange.preset.thisMonth","This month"),range:()=>Po(vt(),0)},{name:"lastMonth",label:B("daterange.preset.lastMonth","Last month"),range:()=>Po(vt(),-1)},{name:"thisQuarter",label:B("daterange.preset.thisQuarter","This quarter"),range:()=>{let s=vt(),t=Math.floor(s.getMonth()/3)*3;return{start:new Date(s.getFullYear(),t,1),end:new Date(s.getFullYear(),t+3,0)}}},{name:"thisYear",label:B("daterange.preset.thisYear","This year"),range:()=>{let s=vt();return{start:new Date(s.getFullYear(),0,1),end:new Date(s.getFullYear(),11,31)}}}]}function B(s,t,e){let i=yt(s);return V(i===s?t:i,e)}function Xh(s,t){if(j(s,t))return D(s,"%e %B %Y");let e=D(t,"%e %B %Y");return s.getFullYear()!==t.getFullYear()?`${D(s,"%e %B %Y")} \u2013 ${e}`:s.getMonth()!==t.getMonth()?`${D(s,"%e %B")} \u2013 ${e}`:`${D(s,"%e")} \u2013 ${e}`}function Jh(s){return s===!0?$o():Array.isArray(s)?s.filter(t=>t&&typeof t.range=="function").map((t,e)=>({name:String(t.name??`preset-${e}`),label:String(t.label??t.name??""),range:t.range})):[]}function vt(){return J(new Date)}function Lo(s){return{start:s,end:new Date(s.getTime())}}function Po(s,t){return{start:new Date(s.getFullYear(),s.getMonth()+t,1),end:new Date(s.getFullYear(),s.getMonth()+t+1,0)}}function Yt(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function J(s){return!s||Number.isNaN(s.getTime())?null:new Date(s.getFullYear(),s.getMonth(),s.getDate())}function Pt(s){return s?new Date(s.getTime()):null}function Ws(s,t,e){return t&&s.getTime()<t.getTime()?new Date(t.getTime()):e&&s.getTime()>e.getTime()?new Date(e.getTime()):new Date(s.getTime())}function Vo(s){return Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())}function Bo(s){return s.getFullYear()*12+s.getMonth()}function Di(s){if(s==null||s==="")return null;let t=Number(s);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):null}function Zh(s){let t=Number(s);return Number.isInteger(t)&&t>=0&&t<=6?t:Ee()}function td(s){let t=Number(s);return Number.isInteger(t)&&t>=1&&t<=4?t:2}function ed(s,t){for(let e=0;e<7;e+=1){let i=N(s,e);if(i.getMonth()===t.getMonth()&&i.getFullYear()===t.getFullYear())return!0}return!1}function Ho(s){let t=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-i.getTime())/qo+1)/7)}function Ys(s,t,e){e==null?delete s.dataset[t]:s.dataset[t]=e}function id(s,t){return new Map(t.map(e=>[e,s.getAttribute(e)]))}function sd(s,t){for(let[e,i]of t)i===null?s.removeAttribute(e):s.setAttribute(e,i)}var nd={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function Qs(s,t,e){let i=String(s??"").trim();if(i==="")return{start:null,end:null};let n=String(e??" \u2013 "),r=n.trim(),o=r!==""&&String(t).includes(r)&&/^\s|\s$/.test(n),a=o?"\\s+":"\\s*",c=o?"(?:\\s+|$)":"\\s*",h=r===""?[i]:i.split(new RegExp(`${a}${Ce(r)}${c}`));if(h.length>2)return null;let d=X(h[0].trim(),t);if(!d)return null;if(h.length===1)return{start:d,end:new Date(d.getTime())};if(h[1].trim()==="")return{start:d,end:null};let u=X(h[1].trim(),t);return u?de(d,u):null}function Uo(s,t,e){let i=s?.start??null,n=s?.end??null;return!i&&!n?"":n?i?`${D(i,t)}${e}${D(n,t)}`:D(n,t):D(i,t)}var Le=class extends b{static cssName="date-range-box";static defaults={start:null,end:null,format:"%d.%m.%Y",separator:" \u2013 ",placeholder:null,clearable:!0,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._format=String(this.options.format||"%d.%m.%Y"),this._separator=String(this.options.separator??" \u2013 "),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._range=this._coerce({start:this.options.start,end:this.options.end});let e=x("zx-date-range-box-popover"),i=l("div",{class:"zx-date-range-box__content"},l("div",{ref:"control",class:"zx-date-range-box__control"},l("input",{ref:"input",class:"zx-date-range-box__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??this._placeholder(),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),l("button",{ref:"clear",class:"zx-icon-btn zx-date-range-box__clear",type:"button",ariaLabel:Ko("daterange.clear","Clear date range")},g("x",{size:13})),l("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:Ko("daterange.choose","Choose date range"),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},g("calendar"))),l("div",{ref:"popover",id:e,class:"zx-date-range-box__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=i,t.append(i),this._picker=new Re(null,{start:this._range.start,end:this._range.end,min:this.options.min,max:this.options.max,months:this.options.months,weekStart:this.options.weekStart,showWeekNumbers:this.options.showWeekNumbers,minNights:this.options.minNights,maxNights:this.options.maxNights,presets:this.options.presets}),this.refs.popover.append(this._picker.el),this._picker.on("select",n=>{this._range={start:n.detail.start,end:n.detail.end},this._setValid(),this._syncDisplay()}),this._picker.on("change",n=>{this._apply({start:n.detail.start,end:n.detail.end},{push:!1}),n.detail.start&&n.detail.end&&this._close(!0)}),this.listen(this.refs.input,"blur",()=>{this._open||this._commitText()}),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.clear(),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return t==="seconds"?{start:this._range.start?Math.floor(this._range.start.getTime()/1e3):null,end:this._range.end?Math.floor(this._range.end.getTime()/1e3):null}:{start:this._range.start?new Date(this._range.start.getTime()):null,end:this._range.end?new Date(this._range.end.getTime()):null}}set(t,{silent:e=!1}={}){return this._apply(this._coerce(t),{silent:e}),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}open(){return this._disabled||this._open?this:(this._picker.set(this._range,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=st(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(),Gs(this.el,"data-state",this._originalState),Gs(this.el,"aria-disabled",this._originalAriaDisabled),super.destroy()}_apply(t,{silent:e=!1,push:i=!0}={}){this._range=t,i&&this._picker?.set(this._range,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",this.get())}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set({start:null,end:null});return}let e=Qs(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(Qs(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()!==""?X(t.trim(),this._format):null}_clamp(t){return Fe(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=>nd[e]??e);return`${t}${this._separator}${t}`}_syncDisplay(){this.refs.input.value=Uo(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"&&Gs(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 Ko(s,t,e){let i=yt(s);return V(i===s?t:i,e)}function Gs(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}function Yo(){C.register("daterange",(s,t)=>{let e=s.own(new Le(null,{...t.props??{},disabled:!!t.disabled,start:t.value?.start??null,end:t.value?.end??null}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:{start:i.detail.start,end:i.detail.end}})),{el:e.el,get:()=>e.get(),set:i=>e.set(i,{silent:!0}),focus:()=>e.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var Z=class extends b{static cssName="datebox";static defaults={value:null,format:"%d.%m.%Y",time:!1,min:null,max:null,placeholder:null,clearable:!0,disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._format=rd(this.options.format,this.options.time),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._min=Wo(this.options.min),this._max=Wo(this.options.max),this._value=this._normalizeValue(this.options.value);let e=x("zx-datebox-popover"),i=l("div",{class:"zx-datebox__content"},l("div",{ref:"control",class:"zx-datebox__control"},l("input",{ref:"input",class:"zx-datebox__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??od(this._format),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),l("button",{ref:"clear",class:"zx-icon-btn zx-datebox__clear",type:"button",ariaLabel:"Clear date"},g("x",{size:13})),l("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:"Choose date","aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},g("calendar"))),l("div",{ref:"popover",id:e,class:"zx-datebox__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=i,t.append(i),this._picker=new Ut(null,{value:this._value,min:this._min,max:this._max,time:!!this.options.time}),this.refs.popover.append(this._picker.el),this._picker.on("change",n=>{this.set(n.detail.date),this.options.time||this._close(!0)}),this.listen(this.refs.input,"blur",()=>this._commitText()),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.set(null),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return this._value?t==="seconds"?Math.floor(this._value.getTime()/1e3):new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeValue(t),this._picker?.set(this._value,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",{date:this._copyValue()}),this}open(){return this._disabled||this._open?this:(this._picker.set(this._value,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=st(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=X(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=X(t,this._format)),!e||Number.isNaN(e.getTime())?null:Rs(e,this._min,this._max)}_syncDisplay(){this.refs.input.value=this._value?D(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}},Xs=function(t,e={}){return new Z(t,{...e,time:!0})};function Wo(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function rd(s,t){let e=String(s||"%d.%m.%Y");return t&&!/%[HM]/.test(e)?`${e} %H:%M`:e}function od(s){return s.replace(/%[demYyHMS]/g,t=>({"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY","%H":"HH","%M":"MM","%S":"SS"})[t]??t)}function Qo(){Go("date",s=>new Z(null,s)),Go("datetime",s=>Xs(null,s))}function Go(s,t){C.register(s,(e,i)=>{let n=e.own(t({...i.props??{},value:i.value}));return e.listen(n.el,"change",r=>r.stopImmediatePropagation()),n.on("change",r=>e.emit("change",{value:r.detail.date})),{el:n.el,get:()=>n.get(),set:r=>n.set(r,{silent:!0}),focus:()=>n.focus(),setDisabled:r=>r?n.disable():n.enable()}})}var Pe=class extends b{static cssName="field-upload";static defaults={url:"",paramName:"upload",params:{},headers:{},multiple:!1,accept:null,maxSize:null,autoUpload:!0,preview:!0,http:null};render(){let t=this.el??l("div");this.el=t,this._ownedNodes=[],this._files=[],this._disabled=!1,this._running=!1,this._runId=0,this._xhr=null,this._transportController=null,this._previewUrl=null,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled");let e=x("zx-upload");return this._input=l("input",{class:"zx-field-upload__input",id:e,type:"file",multiple:!!this.options.multiple,accept:this.options.accept??void 0,tabIndex:-1}),this._dropzone=l("button",{class:"zx-field-upload__dropzone",type:"button",ariaControls:e,ariaLabel:this.options.multiple?"Choose files or drop them here":"Choose a file or drop it here"},l("span",{class:"zx-field-upload__prompt"},this.options.multiple?"Drop files here or choose files":"Drop a file here or choose a file"),l("span",{class:"zx-field-upload__hint"},ad(this.options))),this._preview=l("div",{class:"zx-field-upload__preview"}),this._progress=l("progress",{class:"zx-field-upload__progress",max:100,value:0,ariaLabel:"Upload progress"}),this._progressText=l("span",{class:"zx-field-upload__progress-text"},"0%"),this._abort=l("button",{class:"zx-btn zx-field-upload__abort",type:"button"},"Abort"),this._progressWrap=l("div",{class:"zx-field-upload__progress-wrap",hidden:!0},this._progress,this._progressText,this._abort),this._status=l("div",{class:"zx-field-upload__status",role:"status",ariaLive:"polite"}),this._ownedNodes.push(this._input,this._dropzone,this._preview,this._progressWrap,this._status),t.append(...this._ownedNodes),this.listen(this._dropzone,"click",()=>{!this._disabled&&!this._running&&this._input.click()}),this.listen(this._input,"change",()=>this._selectFiles(this._input.files)),this.listen(this._dropzone,"dragenter",i=>this._handleDragOver(i)),this.listen(this._dropzone,"dragover",i=>this._handleDragOver(i)),this.listen(this._dropzone,"dragleave",i=>{(!(i.relatedTarget instanceof Node)||!this._dropzone.contains(i.relatedTarget))&&this._setState("idle")}),this.listen(this._dropzone,"drop",i=>{i.preventDefault(),!(this._disabled||this._running)&&(this._setState("idle"),this._selectFiles(i.dataTransfer?.files??[]))}),this.listen(this._abort,"click",()=>this.abort()),this.setDisabled(!1),t}async upload(t=null){if(t!==null&&!this._setFiles(t)||this._disabled||this._running||this._files.length===0)return null;this._running=!0,this._runId+=1;let e=this._runId;this._setState("uploading"),this._progressWrap.hidden=!1,this._abort.hidden=!1,this._setProgress(0),this._status.textContent="Uploading\u2026";try{let i=this.options.http?await this._uploadInjected():await this._uploadXhr();return e!==this._runId?null:(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setProgress(100),this._setState("success"),this._status.textContent="Upload complete.",this.emit("success",{response:i}),i)}catch(i){if(e!==this._runId)return null;let n=i instanceof Error?i:new Error(String(i));return n.name==="AbortError"?(this._finishAbort(),null):(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("error"),this._status.textContent=n.message,this.emit("error",{error:n}),null)}}abort(){return this._running?(this._xhr?.abort(),this._transportController?.abort(),this._finishAbort(),this):this}clear(){return this._running&&this.abort(),this._files=[],this._input.value="",this._revokePreview(),this._preview.replaceChildren(),this._progress.value=0,this._progressText.textContent="0%",this._progressWrap.hidden=!0,this._status.textContent="",this._setState("idle"),this}setDisabled(t){return this._disabled=!!t,this._input.disabled=this._disabled,this._dropzone.disabled=this._disabled,this.el.dataset.disabled=String(this._disabled),this}_selectFiles(t){this._setFiles(t)&&(this._input.value="",this.options.autoUpload&&this.upload())}_setFiles(t){if(this._disabled||this._running)return!1;let e=Array.from(t??[]),i=this.options.multiple?e:e.slice(0,1);if(i.length===0)return!1;let n=i.find(o=>!cd(o,this.options.accept));if(n)return this._selectionError(new Error(`${n.name} is not an accepted file type.`)),!1;let r=this.options.maxSize==null?null:i.find(o=>o.size>Number(this.options.maxSize));return r?(this._selectionError(new Error(`${r.name} exceeds the maximum file size.`)),!1):(this._files=i,this._renderPreview(),this._status.textContent=i.map(o=>o.name).join(", "),this._setState("selected"),this.emit("select",{files:this._files.slice()}),!0)}_handleDragOver(t){t.preventDefault(),!this._disabled&&!this._running&&this._setState("dragover")}_uploadInjected(){let t=this.options.http;this._transportController=new AbortController;let e={files:this._files.slice(),paramName:String(this.options.paramName),params:{...this.options.params},headers:{...this.options.headers},signal:this._transportController.signal,onProgress:i=>this._setProgress(i)};return typeof t.upload=="function"?t.upload(String(this.options.url),e):typeof t.request=="function"?t.request(String(this.options.url),{method:"POST",data:e.params,files:e.files,headers:e.headers,signal:e.signal,onProgress:e.onProgress,paramName:e.paramName}):Promise.reject(new TypeError("Injected upload transport requires upload() or request()"))}_uploadXhr(){return typeof XMLHttpRequest!="function"?Promise.reject(new Error("XMLHttpRequest is not available")):new Promise((t,e)=>{let i=new XMLHttpRequest;this._xhr=i,i.open("POST",String(this.options.url));for(let[n,r]of Object.entries(this.options.headers??{}))i.setRequestHeader(n,String(r));this.listen(i.upload,"progress",n=>{n.lengthComputable&&this._setProgress(n.loaded/n.total*100)}),this.listen(i,"load",()=>{if(i.status<200||i.status>=300){e(new Error(`Upload failed with HTTP ${i.status}`));return}t(dd(i.responseText))}),this.listen(i,"error",()=>e(new Error("Upload request failed"))),this.listen(i,"abort",()=>e(ud())),i.send(hd(this._files,String(this.options.paramName),this.options.params))})}_setProgress(t){let e=Math.max(0,Math.min(100,Number(t)||0));this._progress.value=e,this._progressText.textContent=`${Math.round(e)}%`,this.emit("progress",{percent:e})}_finishAbort(){this._running&&(this._runId+=1,this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("idle"),this._status.textContent="Upload aborted.",this.emit("abort",{}))}_selectionError(t){this._setState("error"),this._status.textContent=t.message,this.emit("error",{error:t})}_renderPreview(){this._revokePreview(),this._preview.replaceChildren();let t=this._files[0];!this.options.preview||!t?.type?.startsWith("image/")||typeof URL>"u"||typeof URL.createObjectURL!="function"||(this._previewUrl=URL.createObjectURL(t),this._preview.append(l("img",{class:"zx-field-upload__image",src:this._previewUrl,alt:`Preview of ${t.name}`})))}_revokePreview(){this._previewUrl&&typeof URL<"u"&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(this._previewUrl),this._previewUrl=null}_setState(t){t==="idle"?this.el.removeAttribute("data-state"):this.el.dataset.state=t}destroy(){this._running&&this.abort(),this._revokePreview();for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function ad(s){let t=[];return s.accept&&t.push(String(s.accept)),s.maxSize!=null&&t.push(`up to ${ld(Number(s.maxSize))}`),t.join(" \xB7 ")||"Choose from this device"}function ld(s){return s<1024?`${s} B`:s<1024*1024?`${Math.round(s/1024)} KB`:`${Math.round(s/(1024*1024))} MB`}function cd(s,t){if(!t)return!0;let e=String(s.type??"").toLowerCase();return String(t).split(",").map(i=>i.trim().toLowerCase()).filter(Boolean).some(i=>i.startsWith(".")?s.name.toLowerCase().endsWith(i):i.endsWith("/*")?e.startsWith(i.slice(0,-1)):e===i)}function hd(s,t,e){let i=new FormData;for(let n of s)i.append(t,n);for(let[n,r]of Object.entries(e??{}))Xo(i,n,r);return i}function Xo(s,t,e){if(e==null)return;if(Array.isArray(e)){for(let n of e)Xo(s,t,n);return}typeof Blob=="function"&&e instanceof Blob?s.append(t,e):s.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function dd(s){if(!s)return null;try{return JSON.parse(s)}catch{return s}}function ud(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let s=new Error("Upload aborted");return s.name="AbortError",s}function Jo(){C.register("upload",(s,t)=>{let e=s.own(new Pe(null,{...t.props??{}}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("select",()=>s.emit("change",{value:null})),{el:e.el,get:()=>null,set:()=>e.clear(),focus:()=>e.el.querySelector(".zx-field-upload__dropzone")?.focus(),setDisabled:i=>e.setDisabled(i)}})}var Zo=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),ta=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),Ve=class extends b{static cssName="multi-value-editor";static defaults={values:[],options:null,addLabel:"Add value",reorder:"both"};render(){let t=this.el??l("div");return this.el=t,this._values=Array.isArray(this.options.values)?this.options.values.map(String):[],this._ownedNodes=[],this._initialState=t.getAttribute("data-state"),this._dragIndex=-1,this._armed=null,this._rows=l("div",{class:"zx-multi-value-editor__rows"}),this._add=l("button",{class:"zx-btn zx-multi-value-editor__add",type:"button",dataset:{action:"add"}},String(this.options.addLabel??"Add value")),this._ownedNodes.push(this._rows,this._add),t.append(this._rows,this._add),this.listen(t,"click",e=>this._handleClick(e)),this.listen(this._rows,"change",e=>this._handleChange(e)),this.listen(this._rows,"keydown",e=>this._handleKeydown(e)),this._reorder().drag&&(this.listen(this._rows,"pointerdown",e=>this._handlePointerDown(e)),this.listen(this._rows,"dragstart",e=>this._handleDragStart(e)),this.listen(this._rows,"dragover",e=>this._handleDragOver(e)),this.listen(this._rows,"dragleave",e=>this._handleDragLeave(e)),this.listen(this._rows,"drop",e=>this._handleDrop(e)),this.listen(this._rows,"dragend",()=>this._finishDrag()),this.listen(document,"pointerup",()=>this._disarm()),this.listen(document,"pointercancel",()=>this._disarm())),this._renderRows(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=Array.isArray(t)?t.map(String):[],this._renderRows(),e||this.emit("change",{values:this.getValues()}),this}_reorder(){return Zo[this.options.reorder]??Zo.both}_renderRows(t=-1,e="value"){let i=ea(this.options.options),n=this.options.options!==null,{drag:r,buttons:o}=this._reorder(),a=this._values.length-1,c=this._values.map((h,d)=>{let u=!n||i.some(([f])=>f===h)?i:[[h,h],...i],p=n?l("select",{class:"zx-multi-value-editor__value",ariaLabel:`Value ${d+1}`,dataset:{index:d}},u.map(([f,_])=>l("option",{value:f,selected:f===h},_))):l("input",{class:"zx-multi-value-editor__value",type:"text",value:h,ariaLabel:`Value ${d+1}`,dataset:{index:d}});return l("div",{class:"zx-multi-value-editor__row",dataset:{row:d}},r?l("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:`Reorder value ${d+1}. Use the arrow keys to move it.`,dataset:{action:"grab",index:d}},g("drag",{size:12})):null,p,l("div",{class:"zx-multi-value-editor__controls"},o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(d===0),ariaLabel:`Move value ${d+1} up`,dataset:{action:"up",index:d}},g("chevron-up",{size:12})):null,o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(d===a),ariaLabel:`Move value ${d+1} down`,dataset:{action:"down",index:d}},g("chevron-down",{size:12})):null,l("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${d+1}`,dataset:{action:"remove",index:d}},g("x",{size:12}))))});this._rows.replaceChildren(...c),t>=0&&c[Math.min(t,c.length-1)]?.querySelector(ta[e]??ta.value)?.focus()}_handleClick(t){let e=t.target instanceof Element?t.target.closest("[data-action]"):null;if(!e||!this.el.contains(e)||e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.action,n=Number(e.dataset.index);if(i==="add"){let r=ea(this.options.options);this._values.push(this.options.options===null?"":r[0]?.[0]??""),this._renderRows(this._values.length-1),this._emitChange()}else i==="remove"&&Number.isInteger(n)?(this._values.splice(n,1),this._renderRows(Math.min(n,this._values.length-1)),this._emitChange()):(i==="up"||i==="down")&&Number.isInteger(n)&&this._move(n,n+(i==="up"?-1:1),i)}_handleChange(t){let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e||!("value"in e))return;let i=Number(e.dataset.index);!Number.isInteger(i)||i<0||i>=this._values.length||(this._values[i]=e.value,this._emitChange())}_handleKeydown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(!e)return;let i=Number(e.dataset.index),n=t.key==="ArrowUp"?i-1:t.key==="ArrowDown"?i+1:t.key==="Home"?0:t.key==="End"?this._values.length-1:-1;n<0||n>=this._values.length||(t.preventDefault(),this._move(i,n,"handle"))}_handlePointerDown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(this._disarm(),!e||e.disabled)return;let i=e.closest(".zx-multi-value-editor__row");i&&(i.draggable=!0,this._armed=i)}_disarm(){this._armed&&(this._armed.draggable=!1),this._armed=null}_handleDragStart(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__row"):null;if(!e||e!==this._armed){t.preventDefault();return}this._dragIndex=Number(e.dataset.row),e.dataset.dragging="true",this.el.setAttribute("data-state","dragging"),t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move")}_handleDragOver(t){this._dragIndex<0||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._showDrop(this._dropTarget(t.clientY)))}_handleDragLeave(t){let e=t.relatedTarget;e instanceof Node&&this._rows.contains(e)||this._clearDrop()}_handleDrop(t){if(this._dragIndex<0)return;t.preventDefault();let e=this._dragIndex,i=this._dropTarget(t.clientY);this._finishDrag(),this._move(e,i>e?i-1:i,"handle")}_finishDrag(){this._dragIndex=-1,this._disarm(),this._clearDrop();for(let t of this._rows.children)delete t.dataset.dragging;this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_dropTarget(t){let e=[...this._rows.children];for(let[i,n]of e.entries()){let r=n.getBoundingClientRect();if(t<r.top+r.height/2)return i}return e.length}_showDrop(t){let e=[...this._rows.children],i=t===this._dragIndex||t===this._dragIndex+1;for(let[n,r]of e.entries()){let o=r;!i&&n===t?o.dataset.drop="before":!i&&t===e.length&&n===e.length-1?o.dataset.drop="after":delete o.dataset.drop}}_clearDrop(){for(let t of this._rows.children)delete t.dataset.drop}_move(t,e,i){let n=this._values.length;if(t===e||t<0||e<0||t>=n||e>=n)return!1;let[r]=this._values.splice(t,1);return this._values.splice(e,0,r),this._renderRows(e,i),this._emitChange(),!0}_emitChange(){this.emit("change",{values:this.getValues()})}destroy(){this._initialState===null?this.el?.removeAttribute("data-state"):this.el?.setAttribute("data-state",this._initialState);for(let t of this._ownedNodes??[])t.remove();super.destroy()}};function ea(s){return Array.isArray(s)?s.map(t=>[String(t),String(t)]):s&&typeof s=="object"?Object.entries(s).map(([t,e])=>[t,String(e)]):[]}function ia(){C.register("multivalueeditor",(s,t)=>{let e=s.own(new Ve(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]})),i=new WeakMap,n=!1,r=()=>{e.el.setAttribute("aria-disabled",String(n));for(let o of e.el.querySelectorAll("input, button, select, textarea"))n?(i.has(o)||i.set(o,!!o.disabled),o.disabled=!0):i.has(o)&&(o.disabled=i.get(o),i.delete(o))};return s.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>s.emit("change",{value:o.detail.values})),{el:e.el,get:()=>e.getValues(),set:o=>{e.setValues(Array.isArray(o)?o:[],{silent:!0}),r()},focus:()=>e.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),setDisabled:o=>{n=!!o,r()}}})}var Wt=class extends b{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:A(this.el);let t=this.el??l("div");this.el=t;let e=fd(this.options.step);this._step=e,this._precision=this.options.precision===null?pd(e):Math.max(0,Math.trunc(Number(this.options.precision)||0));let i=this._stepButton("down","minus"),n=this._stepButton("up","plus"),r=l("input",{ref:"input",class:"zx-number-field__input",type:"text",role:"spinbutton",inputMode:this._precision>0?"decimal":"numeric",autocomplete:"off",spellcheck:!1,placeholder:String(this.options.placeholder??""),ariaLabel:this.options.label??void 0,name:this.options.name??void 0,required:!!this.options.required}),o=[i,r];return this.options.unit!==null&&o.push(l("span",{ref:"unit",class:"zx-number-field__unit",ariaHidden:"true"},String(this.options.unit))),o.push(n),t.replaceChildren(...o),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(r,"input",()=>this._onInput()),this.listen(r,"keydown",a=>this._onKeydown(a)),this.listen(r,"focus",()=>{this._editing=!0,this._syncInput()}),this.listen(r,"blur",()=>{this._commit(),this._editing=!1,this._syncInput()}),this.listen(i,"click",()=>this._stepBy(-1)),this.listen(n,"click",()=>this._stepBy(1)),this.listen(r,"wheel",a=>{document.activeElement!==r||this._disabled||this._readonly||(a.preventDefault(),this._stepBy(a.deltaY<0?1:-1))},{passive:!1}),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=this._coerce(t),n=i!==this._value;return this._value=i,this._syncInput(),n&&!e&&this.emit("change",{value:this._value}),this}stepUp(t=1){return this._stepBy(t)}stepDown(t=1){return this._stepBy(-t)}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}focus(){return this.refs.input.focus(),this}getInput(){return this.refs.input}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}setRange(t,e){return this._min=t==null?null:Number(t),this._max=e==null?null:Number(e),this.set(this._value,{silent:!0})}_stepButton(t,e){return l("button",{ref:t,class:"zx-number-field__step",type:"button",tabIndex:-1,ariaHidden:"true",dataset:{step:t}},g(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=Ii(t,this.options.group?this._separators():null);return e===null?null:Ei(e,{min:this._rangeMin,max:this._rangeMax,step:this._step,precision:this._precision})}_stepBy(t){if(this._disabled||this._readonly)return this;let e=this._rangeMin,i=this._rangeMax,r=Ii(this.refs.input.value)??this._value,o=r===null?e??0:r,a=r===null&&t>0&&e!==null?e-this._step*t:o,c=sa(a+this._step*t,this._precision);return this.options.wrap&&e!==null&&i!==null&&(c>i?c=e:c<e&&(c=i)),this.set(c),this}_separators(){if(this._localeSeparators)return this._localeSeparators;let t=new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:1}).formatToParts(1234.5);return this._localeSeparators={group:t.find(e=>e.type==="group")?.value??",",decimal:t.find(e=>e.type==="decimal")?.value??"."},this._localeSeparators}_onInput(){let t=Ii(this.refs.input.value,this.options.group?this._separators():null);this._syncAria(t),this.emit("input",{value:t})}_onKeydown(t){if(this._disabled||this._readonly)return;let e=Math.max(1,Math.trunc(Number(this.options.largeStep)||1)),n={ArrowUp:()=>this._stepBy(1),ArrowDown:()=>this._stepBy(-1),PageUp:()=>this._stepBy(e),PageDown:()=>this._stepBy(-e),Home:()=>this._rangeMin===null?null:this.set(this._rangeMin),End:()=>this._rangeMax===null?null:this.set(this._rangeMax),Enter:()=>this._commit()}[t.key];n&&(t.key==="Home"&&this._rangeMin===null||t.key==="End"&&this._rangeMax===null||(t.preventDefault(),n()))}_commit(){this.set(this.refs.input.value)}_syncInput(){let t=this.refs.input,e=this._value===null?"":this._format(this._value,this._editing);t.value!==e&&(t.value=e),this._syncAria(this._value)}_syncAria(t){let e=this.refs.input,i=this._rangeMin,n=this._rangeMax;if(i===null?e.removeAttribute("aria-valuemin"):e.setAttribute("aria-valuemin",String(i)),n===null?e.removeAttribute("aria-valuemax"):e.setAttribute("aria-valuemax",String(n)),t===null)e.removeAttribute("aria-valuenow"),e.setAttribute("aria-valuetext",this._message("numberField.empty","Empty"));else{e.setAttribute("aria-valuenow",String(t));let r=this.options.unit===null?"":` ${this.options.unit}`;e.setAttribute("aria-valuetext",`${this._format(t,!1)}${r}`)}this.el.toggleAttribute("data-empty",t===null)}_format(t,e){return this.options.group?new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:this._precision,maximumFractionDigits:this._precision,useGrouping:!e}).format(t):t.toFixed(this._precision)}_message(t,e){let i=this.msg(t);return i===t?e:i}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.up.disabled=this._disabled||this._readonly,this.refs.down.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&k(t,this._snapshot)}};function Ii(s,t=null){if(typeof s=="number")return Number.isFinite(s)?s:null;if(s==null)return null;let e=String(s).trim();if(e==="")return null;let i;if(t)i=e.split(t.group).join("").replace(t.decimal,".").replace(/[^\d.\-+eE]/g,"");else{let r=e.replace(/[^\d,.\-+eE]/g,""),o=r.lastIndexOf(","),a=r.lastIndexOf(".");i=r,o>=0&&o>a?i=r.replace(/\./g,"").replace(",","."):o>=0&&(i=r.replace(/,/g,""))}if(!/\d/.test(i))return null;let n=Number(i);return Number.isFinite(n)?n:null}function Ei(s,{min:t,max:e,step:i,precision:n}){let r=s;if(i>0){let o=t??0;r=o+Math.round((s-o)/i)*i}return r=sa(r,n),t!==null&&r<t?t:e!==null&&r>e?e:r}function fd(s){let t=Number(s);return Number.isFinite(t)&&t>0?t:1}function pd(s){let t=String(s),e=t.match(/e-(\d+)/i);if(e)return Number(e[1]);let i=t.split(".")[1];return i?i.length:0}function sa(s,t){return Number.isFinite(s)?Number(s.toFixed(Math.min(15,Math.max(0,t)))):s}function na(){C.register("number",(s,t)=>{let e=s.own(new Wt(null,{label:t.label?String(t.label):void 0,placeholder:t.placeholder,required:t.required,...t.props??{}})),i=!1;return s.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{i||s.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get(),set:n=>{i=!0;try{e.set(n===""||n===null||n===void 0?null:n,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var He=class extends b{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:A(this.el);let t=this.el??l("div");this.el=t,this._max=Math.max(1,Math.trunc(Number(this.options.max)||5)),this._step=this.options.allowHalf?.5:1,this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this._name=x("zx-rating");let e=l("div",{ref:"symbols",class:"zx-rating__symbols",role:"radiogroup",ariaLabel:String(this.options.label??"Rating")});for(let i=1;i<=this._max;i+=1){let n=l("span",{class:"zx-rating__symbol"},l("span",{class:"zx-rating__glyph",ariaHidden:"true"},g(this.options.icon,{size:Be[this.options.size]??Be.md})),l("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},g(this.options.icon,{size:Be[this.options.size]??Be.md})));this.options.allowHalf?n.append(this._radio(i-.5,"half"),this._radio(i,"full")):n.append(this._radio(i,"full")),e.append(n)}return t.replaceChildren(e,l("span",{ref:"readout",class:"zx-rating__readout"})),t.dataset.size=Be[this.options.size]?this.options.size:"md",this.listen(e,"keydown",i=>this._onKeydown(i)),this.listen(e,"pointerleave",()=>this._setPreview(null)),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=this._clamp(t),n=i!==this._value;return this._value=i,this._preview=null,this._sync(),n&&!e&&this.emit("change",{value:this._value}),this}clear({silent:t=!1}={}){return this.set(0,{silent:t})}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}setCount(t){return this._count=t,this._syncReadout(),this}focus(){return(this._radios.find(e=>e.tabIndex===0)??this._radios[0])?.focus(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}_radio(t,e){let i=l("button",{class:"zx-rating__radio",type:"button",role:"radio",tabIndex:-1,ariaChecked:"false",ariaLabel:this._stepLabel(t),dataset:{value:String(t),part:e}});return this.listen(i,"click",n=>{this._choose(t,n.detail>0)}),this.listen(i,"pointerenter",()=>this._setPreview(t)),this.listen(i,"focus",()=>this._setPreview(t)),this.listen(i,"blur",()=>this._setPreview(null)),this._radios.push(i),i}_stepLabel(t){let e=this.options.labels;if(Array.isArray(e)){let i=Math.round(t/this._step)-1;if(e[i]!=null)return String(e[i])}return this._message("rating.value","%1 of %2",[t,this._max])}_message(t,e,i){let n=this.msg(t,...i);return n===t?V(e,i):n}_choose(t,e){this._disabled||this._readonly||(e&&this.options.clearable&&t===this._value?this.set(0):this.set(t))}_onKeydown(t){if(this._disabled||this._readonly)return;let e=["ArrowRight","ArrowDown"],i=["ArrowLeft","ArrowUp"];if(e.includes(t.key))t.preventDefault(),this.set(this._value>=this._max?this._step:(this._value||0)+this._step);else if(i.includes(t.key))t.preventDefault(),this.set(this._value<=this._step?this._max:this._value-this._step);else if(t.key==="Home")t.preventDefault(),this.set(this._step);else if(t.key==="End")t.preventDefault(),this.set(this._max);else if((t.key==="Delete"||t.key==="Backspace")&&this.options.clearable)t.preventDefault(),this.set(0);else return;this.focus()}_setPreview(t){let e=this._disabled||this._readonly?null:t;e!==this._preview&&(this._preview=e,this._paint(),this.emit("hover",{value:this._preview}))}_clamp(t){let e=Number(t);if(!Number.isFinite(e)||e<=0)return 0;let i=Math.round(e/this._step)*this._step;return Math.min(this._max,Math.max(0,i))}_sync(){for(let e of this._radios){let i=Number(e.dataset.value);e.setAttribute("aria-checked",String(i===this._value))}let t=this._radios.find(e=>e.getAttribute("aria-checked")==="true");for(let e of this._radios)e.tabIndex=-1;(t??this._radios[0]).tabIndex=0,this._paint(),this._syncReadout()}_paint(){let t=this._preview??this._value;this.refs.symbols.querySelectorAll(".zx-rating__symbol").forEach((i,n)=>{let r=Math.min(1,Math.max(0,t-n));i.style.setProperty("--zx-rating-fill",`${r*100}%`),i.toggleAttribute("data-preview",this._preview!==null)}),this.el.dataset.value=String(t)}_syncReadout(){let t=this.refs.readout;if(!t)return;let e=this._count===void 0?this.options.count:this._count,i=[];this.options.showValue&&i.push(_d(this._value,this._step)),e!=null&&i.push(this._message("rating.count","%1 ratings",[e])),t.textContent=i.join(" \xB7 ")}_syncDisabled(){let t=this._disabled||this._readonly;for(let e of this._radios)e.disabled=this._disabled;this.refs.symbols.setAttribute("aria-readonly",String(this._readonly)),this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this.el.toggleAttribute("data-inert",t),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&k(t,this._snapshot)}},Be={sm:14,md:18,lg:24};function _d(s,t){return t<1?s.toFixed(1):String(s)}function ra(){C.register("rating",(s,t)=>{let e=s.own(new He(null,{label:t.label?String(t.label):void 0,...t.props??{}})),i=!1;return e.on("change",n=>{i||s.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get()||null,set:n=>{i=!0;try{e.set(Number(n)||0,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var md=["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 Js(s){let t=!1,e=null;function i(n){if(n.key!=="Tab")return;let r=oa(s);if(r.length===0){n.preventDefault();return}let o=r[0],a=r[r.length-1];n.shiftKey&&(document.activeElement===o||!s.contains(document.activeElement))?(n.preventDefault(),a.focus()):!n.shiftKey&&(document.activeElement===a||!s.contains(document.activeElement))&&(n.preventDefault(),o.focus())}return{activate(){t||(t=!0,e=document.activeElement,document.addEventListener("keydown",i),oa(s)[0]?.focus())},deactivate(){t&&(t=!1,document.removeEventListener("keydown",i),e?.isConnected&&typeof e.focus=="function"&&e.focus(),e=null)}}}function Ct(s,t,{orientation:e="vertical",wrap:i=!0}={}){let n=new AbortController,r=new Map,o=!1;function a(){return Array.from(s.querySelectorAll(t)).filter(f=>(c(f),aa(f)))}function c(f){r.has(f)||r.set(f,f.getAttribute("tabindex"))}function h(f=null){let _=a(),m=f&&_.includes(f)?f:_.find(w=>w.tabIndex===0)??_[0];for(let w of _){let y=w===m?0:-1;w.tabIndex!==y&&(w.tabIndex=y)}}function d(f){let _=a(),m=f.target?.closest?.(t)??null,w=_.indexOf(m);if(w<0)return;let y=e==="horizontal"?"ArrowLeft":"ArrowUp",v=e==="horizontal"?"ArrowRight":"ArrowDown",S=null;f.key==="Home"?S=0:f.key==="End"?S=_.length-1:f.key===y?S=w-1:f.key===v&&(S=w+1),!(S===null||_.length===0)&&(i?S=(S+_.length)%_.length:S=Math.max(0,Math.min(_.length-1,S)),f.preventDefault(),h(_[S]),_[S].focus())}function u(f){let _=f.target?.closest?.(t)??null;_&&s.contains(_)&&h(_)}s.addEventListener("keydown",d,{signal:n.signal}),s.addEventListener("focusin",u,{signal:n.signal});let p=typeof MutationObserver=="function"?new MutationObserver(()=>h()):null;return p?.observe(s,{childList:!0,subtree:!0,attributes:!0}),h(),{focusFirst(){let f=a()[0];f&&(h(f),f.focus())},focusLast(){let f=a(),_=f[f.length-1];_&&(h(_),_.focus())},destroy(){if(!o){o=!0,n.abort(),p?.disconnect();for(let[f,_]of r)_===null?f.removeAttribute("tabindex"):f.setAttribute("tabindex",_);r.clear()}}}}function lt(s,t){let e="",i=null;return function(r){let o=typeof r=="string"?r:r.key;if(typeof r!="string"&&(r.ctrlKey||r.metaKey||r.altKey)||!o||o.length!==1||/\s/.test(o))return;i!==null&&clearTimeout(i),e+=o.toLocaleLowerCase(),e.split("").every(h=>h===e[0])&&(e=e[0]),i=setTimeout(()=>{e="",i=null},500);let a=s(),c=a.findIndex(h=>gd(h).startsWith(e));c>=0&&t(a[c],c)}}function oa(s){return Array.from(s.querySelectorAll(md)).filter(t=>aa(t)&&t.getClientRects().length>0)}function aa(s){return!(!(s instanceof HTMLElement)||s.hidden||s.getAttribute("aria-hidden")==="true"||s.matches(":disabled"))}function gd(s){if(typeof s=="string"||typeof s=="number")return String(s).trim().toLocaleLowerCase();if(s&&typeof s=="object"&&"textContent"in s)return String(s.textContent??"").trim().toLocaleLowerCase();if(s&&typeof s=="object"){let t=s,e=t.label??t.text??t.value;if(e!=null)return String(e).trim().toLocaleLowerCase()}return String(s??"").trim().toLocaleLowerCase()}var bd=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],la=["Lowest","Low","Medium","High","Highest"],yd=Object.freeze([["backlog","status.backlog","Backlog","dotted","muted"],["todo","status.todo","Todo","ring","neutral"],["in-progress","status.inProgress","In Progress","progress","warning"],["in-review","status.inReview","In Review","review","info"],["ready","status.ready","Ready to Merge","ready","accent"],["waiting","status.waiting","Waiting for feedback","waiting","warning"],["done","status.done","Done","done","info"],["canceled","status.canceled","Canceled","canceled","muted"],["duplicate","status.duplicate","Duplicate","duplicate","muted"]]),G=class s extends b{static cssName="select";static defaults={items:[],fixedItems:[],fixedLabel:null,valueKey:"ID",labelKey:"name",renderItem:null,renderValue:null,renderValueAdornment:null,renderNone:null,noneLabel:null,actions:[],value:null,disabled:!1,placeholder:"",clearable:!1,filter:!1,searchKeys:null,minQuery:0,debounce:200,listHeight:280,groupKey:null};render(){this._items=[],this._visibleItems=[],this._fixedItems=[],this._visibleFixed=[],this._actions=[],this._selected=null,this._optionEntries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._createdRoot=!1,this._root=null,this._snapshot=null,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._root=t,this._snapshot=this._createdRoot?null:A(t);let e=x("zx-select-list"),i=l("input",{ref:"input",class:"zx-select__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:this.options.filter?"list":"none",placeholder:String(this.options.placeholder??""),readOnly:!this.options.filter}),n=l("span",{ref:"valueAdornment",class:"zx-select__value-adornment",ariaHidden:"true",hidden:!0}),r=l("button",{ref:"clear",class:"zx-icon-btn zx-select__clear",type:"button",tabIndex:-1,ariaLabel:this._message("select.clear","Clear selection"),hidden:!0},g("x",{size:13})),o=l("span",{ref:"loading",class:"zx-select__loading",role:"status",ariaLabel:this._message("select.loading","Loading"),hidden:!0}),a=l("button",{ref:"toggle",class:"zx-select__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("select.toggle","Toggle options")},g("chevron-down",{size:16})),c=l("div",{ref:"control",class:"zx-select__control"},n,i,r,o,a),h=l("div",{ref:"list",class:"zx-select__list",id:e,role:"listbox"});h.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let d=l("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},h);return t.replaceChildren(c,d),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visibleItems=this._items.slice(),this._fixedItems=Array.isArray(this.options.fixedItems)?this.options.fixedItems.slice():[],this._visibleFixed=this._fixedItems.slice(),this._actions=ca(this.options.actions),this._disabled=!!this.options.disabled,this._handleTypeahead=lt(()=>this._optionEntries.filter(u=>!u.clear&&!u.action).map(u=>u.element),(u,p)=>{this._open||this.open(),this._setActive(this._itemEntryIndex(p))}),this.listen(i,"click",()=>this.open()),this.listen(i,"input",()=>this._onInput()),this.listen(i,"keydown",u=>this._onKeydown(u)),this.listen(a,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(r,"click",()=>{this.set(null),this.focus()}),this.listen(d,"pointerdown",u=>u.preventDefault()),this.listen(d,"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 i=this.value,n=t==null?null:this._findItem(t);this._selected=n,this._syncInputValue(),this._renderOptions();let r=this.value;return!e&&!Object.is(i,r)&&this.emit("change",{value:r,item:n}),this}setItems(t){let e=this.value;return this._items=Array.isArray(t)?t.slice():[],this._visibleItems=this._items.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setFixedItems(t){let e=this.value;return this._fixedItems=Array.isArray(t)?t.slice():[],this._visibleFixed=this._fixedItems.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setActions(t){return this._actions=ca(t),this._renderOptions(),this._position?.update(),this}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t}),this}open(){return this._disabled||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=st(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._selectedEntryIndex()),this._activeIndex<0&&this._optionEntries.length>0&&this._setActive(0),this.options.filter&&this._selected!==null&&this.refs.input.select(),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(""),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._setLoading(!1),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._visibleItems=this._items.slice(),this._visibleFixed=this._fixedItems.slice(),this._syncInputValue(),this.emit("close",{}),this):this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}static priority(t,e={}){let i=e.value??null,n=new s(t,{...e,value:null,items:[],renderItem(r){return xd(r,!0)},renderValueAdornment(r){return da(r.level)}});return n.setItems(bd.map((r,o)=>{let a=o===2?n.msg("priority.medium"):r;return(a==="priority.medium"||o!==2)&&(a=n._message(r,la[o])),{ID:o,name:a,level:o}})),n.set(i,{silent:!0}),n}static status(t,e={}){let{items:i=null,value:n=null,...r}=e,o=new s(t,{...r,value:null,items:[],renderItem(c){return kd(c)},renderValueAdornment(c){return ua(c)}}),a=Array.isArray(i)?i.map(Sd).filter(Boolean):yd.map(([c,h,d,u,p],f)=>({ID:c,name:o._message(h,d),indicator:u,tone:p,shortcut:String(f+1)}));return o.setItems(a),o.set(n,{silent:!0}),o}static entity(t,e={}){let{recent:i=[],recentLabel:n="Recent",create:r=!1,iconKey:o="icon",colorKey:a="color",subtitleKey:c="description",renderIcon:h=null,fixedItems:d=[],actions:u=[],renderItem:p=null,renderValueAdornment:f=null,..._}=e,m=(v,S=!1)=>{if(typeof h=="function")return h(v,{selected:S});let z=Mi(v,o);if(z&&typeof z=="object"&&typeof z.nodeType=="number")return z.cloneNode(!0);if(typeof z!="string"||!z)return null;let T=Mi(v,a);return l("span",{class:"zx-select__entity-glyph",style:Ft(T)?{"--zx-select-entity-color":String(T)}:null,ariaHidden:"true"},g(z,{size:14}))},w=r?wd(r):null,y=new s(t,{..._,fixedItems:[...Array.isArray(i)?i:[],...Array.isArray(d)?d:[]],fixedLabel:Array.isArray(i)&&i.length?n:_.fixedLabel??null,actions:[...Array.isArray(u)?u:[],...w?[w]:[]],renderItem:p??(v=>{let S=m(v,!1),z=Mi(v,c),T=l("span",{class:"zx-select__entity-copy"},l("span",{class:"zx-select__entity-label"},String(Mi(v,_.labelKey??"name")??"")),z==null||z===""?null:l("span",{class:"zx-select__entity-subtitle"},String(z)));return l("span",{class:"zx-select__entity"},S?l("span",{class:"zx-select__entity-icon",ariaHidden:"true"},S):null,T)}),renderValueAdornment:f??(v=>m(v,!0))});return y.el.dataset.preset="entity",y}static permission(t,e={}){let{groups:i=[],value:n=!0,valueKey:r="ID",labelKey:o="name",filter:a="local",...c}=e,h=typeof i=="function"?i:null,d=h?[]:i,u=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],p=new s(t,{filter:h??a,...c,value:null,items:d,fixedItems:[],valueKey:f=>u.includes(f)?f.ID:tn(f,r),labelKey:f=>u.includes(f)?f.name:String(tn(f,o)??"")});return u[0].name=p._message("permission.private","Private"),u[1].name=p._message("permission.public","Public"),p.setFixedItems(u),p.set(n,{silent:!0}),p}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;!this._createdRoot&&t&&k(t,this._snapshot),super.destroy()}_onKeydown(t){if(!this._disabled){if(this._open&&ha(t)){let e=this._optionEntries.findIndex(i=>!i.clear&&!i.action&&String(i.item?.shortcut??"")===t.key);if(e>=0){t.preventDefault(),this._setActive(e),this._chooseEntry(this._optionEntries[e]);return}}if(t.key==="ArrowDown"){t.preventDefault(),this._open?this._moveActive(1):this.open();return}if(t.key==="ArrowUp"){t.preventDefault(),this._open?this._moveActive(-1):(this.open(),this._setActive(this._optionEntries.length-1));return}if(t.key==="Home"&&this._open){t.preventDefault(),this._setActive(0);return}if(t.key==="End"&&this._open){t.preventDefault(),this._setActive(this._optionEntries.length-1);return}if(t.key==="Enter"&&this._open){t.preventDefault(),this._chooseEntry(this._optionEntries[this._activeIndex]);return}if(t.key==="Escape"&&this._open){t.preventDefault(),this.close();return}if(t.key==="Tab"&&this._open){this.close();return}!this.options.filter&&ha(t)&&this._handleTypeahead(t)}}_onInput(){if(!this.options.filter)return;let t=this.refs.input.value;this._syncValueAdornment(),this._open||this.open(),this.options.filter==="local"?(this._visibleFixed=this._matchFixed(t),this._visibleItems=Rt(this._items,t,this._searchKeys()),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update()):typeof this.options.filter=="function"&&this._scheduleAsyncQuery(t)}_onOptionClick(t){let e=t.target?.closest?.('[role="option"]');!e||!this.refs.panel.contains(e)||this._chooseEntry(this._optionEntries[Number(e.getAttribute("data-index"))])}_chooseEntry(t){if(t){if(t.action){let e={id:t.action.id,action:t.action,query:this.refs.input.value,select:this};this.emit("action",e).defaultPrevented||t.action.invoke?.(e),this.close(),this.focus();return}this.set(t.clear?null:t.item),this.close(),this.focus()}}_moveActive(t){let e=this._optionEntries.length;e!==0&&this._setActive((this._activeIndex+t+e)%e)}_setActive(t){this._activeIndex=t>=0&&t<this._optionEntries.length?t:-1,this._optionEntries.forEach((i,n)=>{n===this._activeIndex?i.element.setAttribute("data-active","true"):i.element.removeAttribute("data-active")});let e=this._optionEntries[this._activeIndex]?.element;e?(this.refs.input.setAttribute("aria-activedescendant",e.id),e.scrollIntoView?.({block:"nearest"})):this.refs.input.removeAttribute("aria-activedescendant")}_renderOptions(){let t=this.refs.list;if(!t)return;t.replaceChildren(),this._optionEntries=[];let e=Symbol("initial-group"),i=this._uniqueItems(this._visibleFixed),n=this._uniqueItems(this._visibleItems,i);this.options.clearable&&this._appendOption(null,!0,this.options.noneLabel??this._message("select.none","No selection")),i.length>0&&this.options.fixedLabel&&t.append(l("div",{class:"zx-select__group",role:"presentation"},String(this.options.fixedLabel)));for(let r of i)this._appendOption(r,!1);i.length>0&&n.length>0&&!this.options.groupKey&&t.append(l("div",{class:"zx-select__separator",role:"presentation"}));for(let r of n){if(this.options.groupKey){let o=this._read(r,this.options.groupKey);Object.is(o,e)||(t.append(l("div",{class:"zx-select__group",role:"presentation"},String(o??""))),e=o)}this._appendOption(r,!1)}if(this._actions.length>0){(i.length>0||n.length>0||this.options.clearable)&&t.append(l("div",{class:"zx-select__separator",role:"presentation"}));let r=Symbol("initial-action-group");for(let o of this._actions)o.group&&o.group!==r&&(t.append(l("div",{class:"zx-select__group",role:"presentation"},o.group)),r=o.group),this._appendAction(o)}n.length===0&&i.length===0&&this._actions.length===0&&!this._loading&&t.append(l("div",{class:"zx-select__empty",role:"status"},this._message("select.empty","No matches"))),this._setActive(-1)}_appendOption(t,e,i){let n=e?this._selected===null:this._selected!==null&&Object.is(this._itemValue(t),this.value),r=this._optionEntries.length,o=e&&typeof this.options.renderNone=="function"?Zs(this.options.renderNone(String(i??""))):e?String(i??""):this._renderItem(t),a=l("div",{class:"zx-select__option",id:x("zx-select-option"),role:"option",ariaSelected:String(n),dataset:{index:r}},l("span",{class:"zx-select__option-content"},o));n&&a.append(g("check",{size:15})),this.refs.list.append(a),this._optionEntries.push({item:t,clear:e,action:null,element:a})}_appendAction(t){let e=this._optionEntries.length,i=vd(t.icon),n=l("div",{class:"zx-select__option zx-select__action",id:x("zx-select-option"),role:"option",ariaSelected:"false",dataset:{index:e,kind:"action"}},l("span",{class:"zx-select__option-content zx-select__action-content"},i?l("span",{class:"zx-select__action-icon",ariaHidden:"true"},i):null,l("span",{class:"zx-select__action-copy"},l("span",{class:"zx-select__action-label"},t.label),t.description?l("span",{class:"zx-select__action-description"},t.description):null)));this.refs.list.append(n),this._optionEntries.push({item:null,clear:!1,action:t,element:n})}_renderItem(t){if(typeof this.options.renderItem=="function"){let e=this.options.renderItem(t);return Zs(e)}return this._itemLabel(t)}_scheduleAsyncQuery(t){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._requestSequence+=1;let e=this._requestSequence;if(this._visibleFixed=this._matchFixed(t),t.length<Math.max(0,Number(this.options.minQuery)||0)){this._setLoading(!1),this._visibleItems=[],this._renderOptions();return}this._setLoading(!0),this._renderOptions(),this._position?.update();let i=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runAsyncQuery(t,e)},i)}async _runAsyncQuery(t,e){if(!(e!==this._requestSequence||typeof this.options.filter!="function")){this.emit("query",{query:t});try{let i=await this.options.filter(t);if(e!==this._requestSequence||!this._open)return;this._items=Array.isArray(i)?i.slice():[],this._visibleItems=this._items.slice(),this._setLoading(!1),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update(),this.emit("loaded",{items:this._items.slice()})}catch{if(e!==this._requestSequence||!this._open)return;this._items=[],this._visibleItems=[],this._setLoading(!1),this._renderOptions(),this._position?.update()}}}_cancelQuery(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._requestSequence+=1}_setLoading(t){this._loading=t,this.refs.loading.hidden=!t,this.refs.input.setAttribute("aria-busy",String(t)),this.refs.list.setAttribute("aria-busy",String(t)),t?this._root?.setAttribute("data-loading","true"):this._root?.removeAttribute("data-loading")}_syncInputValue(){if(!this.refs.input)return;let t=this.refs.input;t.value=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),this._syncValueAdornment(),this.refs.clear.hidden=!this.options.clearable||this._selected===null}_syncValueAdornment(){let t=this.refs.valueAdornment;if(!t)return;let e=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),i=String(this.refs.input?.value??"");if(this._selected===null||typeof this.options.renderValueAdornment!="function"||this.options.filter&&i!==e){t.replaceChildren(),t.hidden=!0;return}let n=this.options.renderValueAdornment(this._selected),r=Zs(n);t.replaceChildren(r instanceof Node?r:document.createTextNode(r)),t.hidden=n==null||typeof r=="string"&&r===""}_syncDisabled(){let t=this.refs.input,e=this.refs.clear,i=this.refs.toggle;t.disabled=this._disabled,e.disabled=this._disabled,i.disabled=this._disabled,this._root?.setAttribute("aria-disabled",String(this._disabled))}_findItem(t){let e=this._fixedItems.length===0?this._items:[...this._fixedItems,...this._items],i=e.find(r=>r===t);if(i!==void 0)return i;let n=t!==null&&typeof t=="object"?this._itemValue(t):t;return e.find(r=>Object.is(this._itemValue(r),n))??null}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){let e=this._read(t,this.options.labelKey);return String(e??"")}_read(t,e){return tn(t,e)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(t){return Rt(this._fixedItems,t,this._searchKeys())}_uniqueItems(t,e=[]){let i=e.map(n=>this._itemValue(n));return t.filter(n=>{let r=this._itemValue(n);return i.some(o=>Object.is(o,r))?!1:(i.push(r),!0)})}_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)}_message(t,e){let i=this.msg(t);return i===t?e:i}};function Mi(s,t){return typeof t=="function"?t(s):s!==null&&typeof s=="object"&&typeof t=="string"?s[t]:null}function wd(s){let t=s===!0?{}:s;return{id:t.id??"create",label:t.label??"Create new\u2026",description:t.description,group:t.group??"New",icon:t.icon??"plus",invoke:t.invoke}}function Zs(s){return s&&typeof s=="object"&&"nodeType"in s?s:String(s??"")}function ca(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>({...t,label:String(t.label),description:t.description==null?void 0:String(t.description),group:t.group==null?void 0:String(t.group)})):[]}function vd(s){return typeof s=="string"?g(s):s instanceof Node?s.cloneNode(!0):null}function xd(s,t){return l("span",{class:"zx-select__priority"},da(s.level),t?l("span",{},String(s.name)):null)}function da(s){let t=Math.max(0,Math.min(4,Math.trunc(Number(s)||0)));return l("span",{class:"zx-select__priority-icon",dataset:{level:t},ariaHidden:"true"},Array.from({length:5},(e,i)=>l("span",{dataset:{filled:String(i<=t)}})))}function Sd(s){if(!s||typeof s!="object"||s.ID==null||s.name==null)return null;let t=["dotted","ring","progress","review","ready","waiting","done","canceled","duplicate"],e=["muted","neutral","warning","info","accent","success","danger"];return{...s,name:String(s.name),indicator:t.includes(String(s.indicator))?String(s.indicator):"ring",tone:e.includes(String(s.tone))?String(s.tone):"muted",description:s.description==null?"":String(s.description),shortcut:s.shortcut==null?"":String(s.shortcut)}}function kd(s){return l("span",{class:"zx-select__status"},ua(s),l("span",{class:"zx-select__status-copy"},l("span",{class:"zx-select__status-label"},String(s.name)),s.description?l("span",{class:"zx-select__status-description"},s.description):null),s.shortcut?l("kbd",{class:"zx-select__status-shortcut"},s.shortcut):null)}function ua(s){let t=String(s.indicator??"ring"),e=l("span",{class:"zx-select__status-indicator",dataset:{indicator:t,tone:String(s.tone??"muted")},ariaHidden:"true"});return t==="done"&&e.append(g("check",{size:8})),t==="canceled"&&e.append(g("x",{size:7})),e}function tn(s,t){return typeof t=="function"?t(s):s===null||typeof s!="object"?s:s[t]}function ha(s){return s.key.length===1&&!s.ctrlKey&&!s.metaKey&&!s.altKey}function fa(){C.register("zxselect",(s,t)=>{let e=t.props??{},i=e.preset,n={...e,value:t.value};delete n.preset;let r=s.own(i==="priority"?G.priority(null,n):i==="status"?G.status(null,n):new G(null,n));return s.listen(r.el,"change",o=>o.stopImmediatePropagation()),r.on("change",o=>s.emit("change",{value:o.detail.value})),{el:r.el,get:()=>r.value,set:o=>r.set(o,{silent:!0}),focus:()=>r.focus(),setDisabled:o=>o?r.disable():r.enable()}})}var qe=class extends b{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:A(this.el);let t=this.el??l("div");this.el=t,this._min=Number(this.options.min)||0,this._max=Number(this.options.max),(!Number.isFinite(this._max)||this._max<=this._min)&&(this._max=this._min+100),this._step=Math.abs(Number(this.options.step))||1,this._id=x("zx-slider");let e=l("input",{ref:"input",class:"zx-slider__input",type:"range",id:this._id,min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled}),i=l("div",{class:"zx-slider__track"},e,this._marks()),n=l("div",{class:"zx-slider__control"});return this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._min))),n.append(i),this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._max))),this.options.showInput&&n.append(this._numberBox()),t.replaceChildren(l("div",{class:"zx-slider__head"},l("label",{ref:"label",class:"zx-slider__label",for:this._id},String(this.options.label??"")),l("span",{ref:"output",class:"zx-slider__value",ariaHidden:"true"})),n),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(e,"input",()=>this._onInput()),this.listen(e,"change",()=>this._onCommit()),this.listen(e,"keydown",r=>{this._readonly&&Ad.has(r.key)&&r.preventDefault()}),this.set(this.options.value,{silent:!0}),this._syncState(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=this._snap(t),n=i!==this._value;return this._value=i,this._paint(),n&&!e&&this.emit("change",{value:i}),this}setRange(t,e,i){let n=Number(t),r=Number(e);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)throw new RangeError("Slider range requires min < max");this._min=n,this._max=r,i!==void 0&&(this._step=Math.abs(Number(i))||1);let{input:o}=this.refs;o.min=String(this._min),o.max=String(this._max),o.step=String(this._step);for(let[a,c]of[...this.el.querySelectorAll(".zx-slider__bound")].entries())c.textContent=this._format(a===0?this._min:this._max);return this.set(this._value,{silent:!0})}focus(){return this.refs.input.focus(),this}enable(){return this.refs.input.disabled=!1,this.refs.number&&(this.refs.number.disabled=!1),this._syncState(),this}disable(){return this.refs.input.disabled=!0,this.refs.number&&(this.refs.number.disabled=!0),this._syncState(),this}setReadonly(t){return this._readonly=!!t,this.refs.number&&(this.refs.number.readOnly=this._readonly),this._syncState(),this}setLabel(t){return this.refs.label.textContent=String(t??""),this}_numberBox(){let t=l("input",{ref:"number",class:"zx-slider__number",type:"number",min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled,readOnly:this._readonly,ariaLabel:String(this.options.label??"Value")});return this.listen(t,"input",()=>{if(this._readonly)return;let e=Number(t.value);t.value===""||!Number.isFinite(e)||(this._value=this._snap(e),this.refs.input.value=String(this._value),this._paintTrack(),this.emit("input",{value:this._value}))}),this.listen(t,"change",()=>{if(this._readonly){t.value=String(this._value);return}this.set(t.value===""?this._min:Number(t.value))}),t}_marks(){let t=this.options.marks;if(!Array.isArray(t)||t.length===0)return null;let e=l("div",{class:"zx-slider__marks",ariaHidden:"true"});for(let i of t){let n=typeof i=="number"?i:Number(i?.value);if(!Number.isFinite(n))continue;let r=typeof i=="number"?this._format(n):String(i.label??this._format(n));e.append(l("span",{class:"zx-slider__mark",style:{"--zx-slider-mark":`${this._ratio(n)*100}%`}},r))}return e}_onInput(){if(this._readonly){this.refs.input.value=String(this._value);return}this._value=this._snap(this.refs.input.value),this._paintTrack(),this.refs.number&&(this.refs.number.value=String(this._value)),this.emit("input",{value:this._value})}_onCommit(){if(this._readonly){this.refs.input.value=String(this._value);return}this.emit("change",{value:this._value})}_paint(){this.refs.input.value=String(this._value),this.refs.number&&(this.refs.number.value=String(this._value)),this._paintTrack()}_paintTrack(){this.el.style.setProperty("--zx-slider-fill",`${this._ratio(this._value)*100}%`);let{output:t}=this.refs;t.textContent=this.options.showValue?this._format(this._value):""}_syncState(){let t=this.refs.input.disabled;this.el.toggleAttribute("data-disabled",t),this.el.toggleAttribute("data-readonly",this._readonly),this.refs.input.setAttribute("aria-readonly",String(this._readonly))}_snap(t){let e=Number(t);return Number.isFinite(e)?Ei(e,{min:this._min,max:this._max,step:this._step,precision:pa(this._step)}):this._min}_ratio(t){return P((t-this._min)/(this._max-this._min),0,1)}_format(t){let e=this.options.formatValue;return typeof e=="function"?String(e(t)):`${zd(t)}${this.options.unit??""}`}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&k(t,this._snapshot)}},Ad=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function pa(s){let t=String(s),e=/e-(\d+)$/i.exec(t);return e?Number(e[1]):(t.split(".")[1]??"").length}function zd(s){return String(Number(s.toFixed(6)))}function _a(){C.register("slider",(s,t)=>{let e=s.own(new qe(null,{label:t.label?String(t.label):void 0,hideLabel:!0,disabled:!!t.disabled,...t.props??{}})),i=!1;return e.on("change",n=>{i||s.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get(),set:n=>{i=!0;try{e.set(Number(n)||0,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var je=class extends b{static cssName="tag-picker";static defaults={items:[],values:[],valueKey:"ID",labelKey:"name",iconKey:"icon",colorKey:"color",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:A(this.el);let t=this.el??l("div");this.el=t;let e=x("zx-tag-picker-list"),i=l("span",{ref:"tags",class:"zx-tag-picker__tags"}),n=l("input",{ref:"input",class:"zx-tag-picker__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:"list",ariaLabel:this._message("tagPicker.input","Add a value"),placeholder:String(this.options.placeholder??"")}),r=l("button",{ref:"toggle",class:"zx-tag-picker__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("tagPicker.toggle","Toggle options")},g("chevron-down",{size:15})),o=l("div",{ref:"control",class:"zx-tag-picker__control"},i,n,r),a=l("div",{ref:"list",class:"zx-tag-picker__list",id:e,role:"listbox",ariaMultiSelectable:"true"});a.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let c=l("div",{ref:"panel",class:"zx-tag-picker__panel",popover:"manual"},a);return t.replaceChildren(o,c),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visible=this._items.slice(),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(o,"pointerdown",h=>{let d=h.target;d.closest(".zx-tag-picker__remove")||d.closest(".zx-tag-picker__toggle")||(h.target!==n&&(h.preventDefault(),this.focus()),this._open||this.open())}),this.listen(i,"click",h=>{let d=h.target.closest(".zx-tag-picker__remove");if(!d||this._disabled||this._readonly)return;h.stopPropagation();let u=[...i.children].indexOf(d.closest(".zx-tag-picker__tag")),p=this._selected[u];p!==void 0&&(this.removeValue(this._valueOf(p)),this.focus())}),this.listen(n,"input",()=>this._onInput()),this.listen(n,"keydown",h=>this._onKeydown(h)),this.listen(n,"blur",()=>this.el.removeAttribute("data-focus")),this.listen(n,"focus",()=>this.el.setAttribute("data-focus","")),this.listen(r,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(c,"pointerdown",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 i=Array.isArray(t)?t:[],n=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),r=[];for(let a of i){if(r.length>=n)break;let c=this._resolve(a);c!==null&&!r.some(h=>this._sameValue(h,c))&&r.push(c)}let o=!Cd(r,this._selected,a=>this._valueOf(a));return this._selected=r,this._renderTags(),this._renderOptions(),o&&!e&&this._emitChange(),this}addValue(t,{silent:e=!1}={}){if(this.isFull())return this;let i=this._resolve(t);return i===null?this:this._selected.some(n=>this._sameValue(n,i))?this:(this._selected.push(i),this._renderTags(),this._renderOptions(),e||(this.emit("add",{value:this._valueOf(i),item:i}),this._emitChange()),this)}removeValue(t,{silent:e=!1}={}){let i=this._valueOf(this._resolve(t)??t),n=this._selected.findIndex(o=>Object.is(this._valueOf(o),i));if(n<0)return this;let[r]=this._selected.splice(n,1);return this._renderTags(),this._renderOptions(),e||(this.emit("remove",{value:this._valueOf(r),item:r}),this._emitChange()),this}clear({silent:t=!1}={}){return this.setValues([],{silent:t})}reset({silent:t=!1}={}){return this.setValues(this.options.values,{silent:t})}setItems(t){return this._cancelQuery(),this._items=Array.isArray(t)?t.slice():[],typeof this.options.filter=="function"?this._visible=this._items.slice():this._applyLocalFilter(this.refs.input.value),this._renderOptions(),this._position?.update(),this}isFull(){let t=this.options.max;return t!=null&&this._selected.length>=Number(t)}open(){return this._disabled||this._readonly||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=st(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&&k(t,this._snapshot)}_renderTags(){let t=this._selected.map(e=>{let i=this._labelOf(e),n=this._colorOf(e),r=this.options.renderTag?this.options.renderTag(e):[this._iconOf(e),l("span",{class:"zx-tag-picker__tag-label"},i)],o=l("span",{class:"zx-tag-picker__tag",dataset:{colored:String(!!n)},style:n?{"--zx-tag-color":n}:null},r);return!this._readonly&&!this._disabled&&o.append(l("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[i])},g("x",{size:11}))),o});this.refs.tags.replaceChildren(...t),this.el.toggleAttribute("data-empty",this._selected.length===0),this._syncPlaceholder()}_renderOptions(){let t=this.refs.list;this._entries=[];let e=[];for(let r of this._visible){let o=this._valueOf(r),a=this._isSelected(o),c=l("div",{class:"zx-tag-picker__option",id:x("zx-tag-picker-option"),role:"option",ariaSelected:String(a)},l("span",{class:"zx-tag-picker__check",ariaHidden:"true"},a?g("check",{size:13}):null),l("span",{class:"zx-tag-picker__option-label"},this.options.renderItem?this.options.renderItem(r):[this._iconOf(r),l("span",{},this._labelOf(r))]));!a&&this.isFull()&&c.setAttribute("aria-disabled","true"),this._entries.push({item:r,element:c,create:!1}),e.push(c)}let i=this.refs.input.value.trim();if(this._canCreate(i)){let r=l("div",{class:"zx-tag-picker__option",id:x("zx-tag-picker-option"),role:"option",ariaSelected:"false",dataset:{create:"true"}},l("span",{class:"zx-tag-picker__check",ariaHidden:"true"},g("plus",{size:13})),l("span",{class:"zx-tag-picker__option-label"},this._message("tagPicker.create","Create \u201C%1\u201D",[i])));this._entries.push({item:null,element:r,create:!0}),e.push(r)}e.length===0&&e.push(l("div",{class:"zx-tag-picker__empty"},this._loading?this._message("tagPicker.loading","Loading\u2026"):this._message("tagPicker.empty","No matches"))),t.replaceChildren(...e);let n=this._entries.findIndex(r=>this._entryId(r)===this._activeId);this._setActive(n>=0?n:this._entries.length>0?0:-1)}_entryId(t){return t.create?"\0create":String(this._valueOf(t.item))}_syncPlaceholder(){let t=this.refs.input;t.placeholder=this._selected.length===0?String(this.options.placeholder??""):""}_onInput(){let t=this.refs.input.value;this._syncInputWidth(),this._open||this.open(),typeof this.options.filter=="function"?this._scheduleAsyncQuery(t):this._applyLocalFilter(t),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update()}_onKeydown(t){if(this._disabled||this._readonly)return;let e=this.refs.input;switch(t.key){case"ArrowDown":t.preventDefault(),this._open?this._move(1):this.open();return;case"ArrowUp":t.preventDefault(),this._open&&this._move(-1);return;case"Home":this._open&&e.value===""&&(t.preventDefault(),this._setActive(0));return;case"End":this._open&&e.value===""&&(t.preventDefault(),this._setActive(this._entries.length-1));return;case"Enter":{if(!this._open||this._activeIndex<0)return;t.preventDefault(),this._commitEntry(this._entries[this._activeIndex]);return}case"Escape":this._open&&(t.preventDefault(),this.close());return;case"Backspace":e.value===""&&this._selected.length>0&&(t.preventDefault(),this.removeValue(this._valueOf(this._selected[this._selected.length-1])));return;case"Tab":this._open&&this.close();return;default:}}_onOptionClick(t){let e=t.target.closest(".zx-tag-picker__option");if(!e)return;let i=this._entries.find(n=>n.element===e);i&&this._commitEntry(i)}_commitEntry(t){if(!t)return;let e=this.refs.input;if(t.create){let i=e.value.trim(),n=this._createItem(i);this._items=this._items.concat([n]),this.addValue(n),this.emit("create",{value:this._valueOf(n),item:n})}else{let i=this._valueOf(t.item);if(this._isSelected(i))this.removeValue(i);else if(!this.isFull())this.addValue(t.item);else return}e.value="",this._syncInputWidth(),this._applyLocalFilter(""),this._renderOptions(),this.options.closeOnSelect?this.close():(this._setActive(this._entries.length>0?0:-1),this._position?.update()),this.focus()}_move(t){if(this._entries.length===0)return;let e=this._activeIndex<0?t>0?0:this._entries.length-1:Math.min(this._entries.length-1,Math.max(0,this._activeIndex+t));this._setActive(e)}_setActive(t){this._activeIndex=t,this._activeId=this._entries[t]?this._entryId(this._entries[t]):null;for(let[e,i]of this._entries.entries()){let n=e===t;i.element.toggleAttribute("data-active",n),n&&(this.refs.input.setAttribute("aria-activedescendant",i.element.id),i.element.scrollIntoView({block:"nearest"}))}t<0&&this.refs.input.removeAttribute("aria-activedescendant")}_applyLocalFilter(t){if(typeof this.options.filter=="function")return;let e=this.options.searchKeys??[this.options.labelKey];this._visible=Rt(this._items,t,e)}_scheduleAsyncQuery(t){this._cancelQuery();let e=String(t??"");if(e.length<Number(this.options.minQuery??0)){this._visible=[],this._renderOptions();return}this._visible=[],this._setLoading(!0),this._renderOptions();let i=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runQuery(e)},i)}async _runQuery(t){let e=this._requestSequence+1;this._requestSequence=e,this._setLoading(!0),this.emit("query",{query:t});try{let i=await this.options.filter(t);if(e!==this._requestSequence)return;this._items=Array.isArray(i)?i.slice():[],this._visible=this._items.slice()}catch(i){if(e!==this._requestSequence)return;this._visible=[],this.emit("error",{error:i})}finally{e===this._requestSequence&&(this._setLoading(!1),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update())}}_cancelQuery(){this._queryTimer!==null&&(clearTimeout(this._queryTimer),this._queryTimer=null),this._requestSequence+=1,this._setLoading(!1)}_setLoading(t){this._loading=t,this.el.toggleAttribute("data-loading",t)}_isSelected(t){return this._selected.some(e=>Object.is(this._valueOf(e),t))}_canCreate(t){if(!this.options.allowCreate||t===""||this.isFull())return!1;let e=i=>i.some(n=>ma(this._labelOf(n))===ma(t));return!e(this._items)&&!e(this._selected)}_createItem(t,e=t){return typeof this.options.valueKey!="string"||typeof this.options.labelKey!="string"?t:{[this.options.valueKey]:e,[this.options.labelKey]:t,created:!0}}_resolve(t){if(t==null)return null;let e=this._valueOf(t),i=this._items.find(r=>Object.is(this._valueOf(r),e));if(i!==void 0)return i;let n=this._selected.find(r=>Object.is(this._valueOf(r),e));return n!==void 0?n:typeof t=="object"?t:this._createItem(String(t),t)}_sameValue(t,e){return Object.is(this._valueOf(t),this._valueOf(e))}_valueOf(t){let e=this.options.valueKey;return typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]:t}_labelOf(t){let e=this.options.labelKey;return String(typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]??"":t??"")}_iconOf(t){let e=this._readItem(t,this.options.iconKey),i=e&&typeof e=="object"&&typeof e.nodeType=="number"?e.cloneNode(!0):typeof e=="string"&&e.trim()?g(e,{size:12}):null;return i?l("span",{class:"zx-tag-picker__visual",style:this._colorOf(t)?{"--zx-tag-color":this._colorOf(t)}:null,ariaHidden:"true"},i):null}_colorOf(t){let e=this._readItem(t,this.options.colorKey);return Ft(e)?e:null}_readItem(t,e){return typeof e=="function"?e(t):t!==null&&typeof t=="object"&&typeof e=="string"?t[e]:null}_emitChange(){this.emit("change",{values:this.getValues(),items:this.getItems()})}_syncInputWidth(){let t=this.refs.input,e=t.value.length;t.style.inlineSize=e===0?"":`${Math.min(40,e+1)}ch`}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.toggle.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}_message(t,e,i=[]){let n=this.msg(t,...i);return n!==t?n:i.reduce((r,o,a)=>r.replaceAll(`%${a+1}`,String(o)),e)}};function ma(s){return String(s??"").trim().toLocaleLowerCase()}function Cd(s,t,e){return s.length!==t.length?!1:s.every((i,n)=>Object.is(e(i),e(t[n])))}function ga(){C.register("tagpicker",(s,t)=>{let e=s.own(new je(null,{placeholder:t.placeholder,...t.props??{}})),i=!1;return s.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{i||s.emit("change",{value:n.detail.values})}),{el:e.el,get:()=>e.getValues(),set:n=>{i=!0;try{e.setValues(Array.isArray(n)?n:[],{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}function ba(s,t="minutes"){let e=Math.round(Math.abs(wa(Gt(s),t)));return{hours:Math.floor(e/3600),minutes:Math.floor(e/60)%60,seconds:e%60,negative:Gt(s)<0}}function ya(s,t="minutes"){$e(t);let e=Math.abs(Math.trunc(Gt(s?.hours))),i=Math.abs(Math.trunc(Gt(s?.minutes))),n=Math.abs(Math.trunc(Gt(s?.seconds))),r=s?.negative?-1:1;return va(r*(e*3600+i*60+n),t)}var Tt=class extends b{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){$e(this.options.unit);let t=this.el??l("div");this.el=t,this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._disabled=!!this.options.disabled,this._parts={hours:0,minutes:0,seconds:0,negative:!1},this._inputs=[];let e=l("div",{class:"zx-timebox__content",role:"group",ariaLabel:this.options.seconds?"Duration in hours, minutes, and seconds":"Duration in hours and minutes"});return this._content=e,this.options.signed&&(e.append(l("button",{ref:"sign",class:"zx-timebox__sign",type:"button",ariaLabel:"Toggle duration sign",ariaPressed:"false"},"+")),this.listen(this.refs.sign,"click",()=>{this._disabled||(this._parts.negative=!this._parts.negative,this._writeParts(),this._emitChange())})),this._addSegment(e,"hours","Hours",!1),e.append(l("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"minutes","Minutes",!0),this.options.seconds&&(e.append(l("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"seconds","Seconds",!0)),t.append(e),this.set(this.options.value,this.options.unit,{silent:!0}),this._syncDisabled(),t}get(t=this.options.unit){return ya(this._readParts(),t)}set(t,e=this.options.unit,i={}){e&&typeof e=="object"&&(i=e,e=this.options.unit),$e(e);let n=Gt(t);return!this.options.signed&&n<0&&(n=0),this.options.seconds||(n=va(Math.round(wa(n,e)/60)*60,e)),this._parts=ba(n,e),this.options.signed||(this._parts.negative=!1),this._writeParts(),i.silent||this._emitChange(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}destroy(){this._content?.remove(),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_addSegment(t,e,i,n){let r=l("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:i,maxLength:n?2:null,dataset:{segment:e,bounded:String(n)}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"input",()=>{e==="hours"&&this.options.signed&&r.value.trim().startsWith("-")&&(this._parts.negative=!0);let o=r.value.replace(/\D/g,"");r.value=n?o.slice(0,2):o}),this.listen(r,"change",()=>this._commitSegments()),this.listen(r,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this._commitSegments(),r.select())})}_readParts(){let t={...this._parts};for(let e of this._inputs){let i=e.dataset.segment,n=e.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;t[i]=Math.max(0,Math.min(n,Math.trunc(Gt(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]):Td(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 Gt(s){let t=Number(s);return Number.isFinite(t)?t:0}function wa(s,t){return $e(t),t==="hours"?s*3600:t==="minutes"?s*60:s}function va(s,t){return $e(t),t==="hours"?s/3600:t==="minutes"?s/60:s}function $e(s){if(s!=="hours"&&s!=="minutes"&&s!=="seconds")throw new RangeError(`Unknown time unit: ${s}`)}function Td(s){return String(s).padStart(2,"0")}function xa(){C.register("time",(s,t)=>{let e=s.own(new Tt(null,{...t.props??{},value:t.value}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.value})),{el:e.el,get:()=>e.get(),set:i=>e.set(Number(i)||0,{silent:!0}),focus:()=>e.el.querySelector("input:not([disabled]), button:not([disabled])")?.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var nt=class extends b{static cssName="toggle";static defaults={checked:!1,value:!0,label:null,disabled:!1};render(){let t=!this.el,e=this.el??l("button");if(this.el=e,e.localName!=="button")throw new TypeError("Toggle target must be a button element");this._createdRoot=t,this._original=t?null:Dd(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,e.type="button",e.setAttribute("role","switch");let i=[l("span",{class:"zx-toggle__track",ariaHidden:"true"},l("span",{class:"zx-toggle__thumb"}))];return this.options.label!==null&&i.push(l("span",{class:"zx-toggle__label"},String(this.options.label))),e.replaceChildren(...i),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let i=!!t;return i===this._checked?this:(this._checked=i,this._sync(),e||this.emit("change",{checked:this._checked,value:this.getValue()}),this)}toggle(){return this.set(!this._checked)}getValue(){return this._checked?this.options.value:!1}enable(){return this._disabled=!1,this.el.removeAttribute("disabled"),this}disable(){return this._disabled=!0,this.el.setAttribute("disabled",""),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&Id(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function Dd(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Id(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function Sa(){C.register("toggle",(s,t)=>{let e=s.own(new nt(null,{...t.props??{},checked:!!t.value}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.value})),{el:e.el,get:()=>e.getValue(),set:i=>e.set(!!i,{silent:!0}),focus:()=>e.el.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var Ke=class extends b{static cssName="value-list";static defaults={values:[],placeholder:"",deletable:!0,sortable:!0,unique:!0,validate:null};render(){let t=this.el??l("div");this._ownedNodes=[],this._disabled=!1,this._dragIndex=-1,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled"),this._values=ka(this.options.values,!!this.options.unique);let e=x("zx-value-list-instructions");return this._list=l("ul",{class:"zx-value-list__list",role:"listbox",ariaLabel:"Values",ariaOrientation:"horizontal"}),this._input=l("input",{class:"zx-value-list__input",type:"text",placeholder:String(this.options.placeholder??""),ariaLabel:"Add value",ariaDescribedby:e}),this._status=l("div",{class:"zx-value-list__status",role:"status",ariaLive:"polite"}),this._instructions=l("span",{class:"zx-value-list__instructions",id:e},"Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder."),this._ownedNodes.push(this._list,this._input,this._status,this._instructions),t.append(this._list,this._input,this._status,this._instructions),this.listen(this._input,"keydown",i=>this._handleInputKeydown(i)),this.listen(this._list,"keydown",i=>this._handleChipKeydown(i)),this.listen(this._list,"click",i=>this._handleChipClick(i)),this.listen(this._list,"dragstart",i=>this._handleDragStart(i)),this.listen(this._list,"dragover",i=>{this._dragIndex>=0&&!this._disabled&&i.preventDefault()}),this.listen(this._list,"drop",i=>this._handleDrop(i)),this.listen(this._list,"dragend",()=>this._finishDrag()),this.listen(t,"click",i=>{i.target===t&&!this._disabled&&this.focus()}),this._renderChips(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=ka(t,!!this.options.unique),this._renderChips(),e||this.emit("change",{values:this.getValues()}),this}addValue(t){if(this._disabled)return!1;let e=String(t??"").trim();if(!e)return!1;if(this.options.unique&&this._values.includes(e))return this._showError("This value already exists."),!1;if(typeof this.options.validate=="function"){let i=this.options.validate(e);if(i!==!0)return this._showError(typeof i=="string"?i:"This value is not valid."),!1}return this._status.textContent="",this._input.removeAttribute("aria-invalid"),this._values.push(e),this._renderChips(),this.emit("add",{value:e}),this.emit("change",{values:this.getValues()}),!0}removeValue(t){if(this._disabled||!this.options.deletable)return!1;let e=this._values.indexOf(String(t));return e<0?!1:(this._removeAt(e),!0)}focus(){return this._input.focus(),this}enable(){return this._disabled=!1,this._input.disabled=!1,this.el.dataset.disabled="false",this._renderChips(),this}disable(){return this._disabled=!0,this._input.disabled=!0,this.el.dataset.disabled="true",this._renderChips(),this}_renderChips(t=-1){let e=this._values.map((i,n)=>l("li",{class:"zx-value-list__chip",role:"option",tabIndex:this._disabled?-1:0,draggable:!!this.options.sortable&&!this._disabled,ariaSelected:"false",ariaDisabled:String(this._disabled),ariaLabel:this.options.deletable?`${i}. Press Delete to remove.`:i,dataset:{index:n}},l("span",{class:"zx-value-list__value"},i),this.options.deletable?l("span",{class:"zx-value-list__remove",dataset:{remove:""},ariaHidden:"true"},"\xD7"):null));this._list.replaceChildren(...e),t>=0&&e[Math.min(t,e.length-1)]?.focus()}_handleInputKeydown(t){this._disabled||(t.key==="Enter"?(t.preventDefault(),this.addValue(this._input.value)&&(this._input.value="")):t.key==="Backspace"&&this._input.value===""&&this._values.length&&this.options.deletable&&(t.preventDefault(),this._removeAt(this._values.length-1)))}_handleChipKeydown(t){if(this._disabled)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e)return;let i=Number(e.dataset.index);if((t.key==="Delete"||t.key==="Backspace")&&this.options.deletable){t.preventDefault(),this._removeAt(i,Math.min(i,this._values.length-2));return}let n=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0,r=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0,o=n||r;if(!o)return;t.preventDefault();let a=Math.max(0,Math.min(this._values.length-1,i+o));t.ctrlKey&&n&&this.options.sortable?this._move(i,a,!0):this._list.querySelector(`[data-index="${a}"]`)?.focus()}_handleChipClick(t){let e=t.target instanceof Element?t.target:null,i=e?.closest("[data-index]");!i||this._disabled||(e.closest("[data-remove]")&&this.options.deletable?this._removeAt(Number(i.dataset.index)):i.focus())}_handleDragStart(t){if(this._disabled||!this.options.sortable)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;e&&(this._dragIndex=Number(e.dataset.index),this.el.dataset.state="dragging",t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"))}_handleDrop(t){if(this._dragIndex<0||this._disabled)return;t.preventDefault();let e=t.target instanceof Element?t.target.closest("[data-index]"):null,i=e?Number(e.dataset.index):this._values.length-1;this._move(this._dragIndex,i,!0),this._finishDrag()}_finishDrag(){this._dragIndex=-1,this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_move(t,e,i){if(t===e||t<0||e<0||t>=this._values.length||e>=this._values.length)return;let[n]=this._values.splice(t,1);this._values.splice(e,0,n),this._renderChips(i?e:-1),this.emit("change",{values:this.getValues()})}_removeAt(t,e=-1){let[i]=this._values.splice(t,1);i!==void 0&&(this._renderChips(e),e<0&&this._values.length===0&&this._input.focus(),this.emit("remove",{value:i}),this.emit("change",{values:this.getValues()}))}_showError(t){this._status.textContent=t,this._input.setAttribute("aria-invalid","true")}destroy(){for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function ka(s,t){if(!Array.isArray(s))return[];let e=s.map(i=>String(i));return t?[...new Set(e)]:e}function Aa(){C.register("valuelist",(s,t)=>{let e=s.own(new Ke(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.values})),{el:e.el,get:()=>e.getValues(),set:i=>e.setValues(Array.isArray(i)?i:[],{silent:!0}),focus:()=>e.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var ue=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),Ed=["xl","lg","md","sm"];function en(s){let t=Number(s);if(!Number.isFinite(t))return"xs";for(let e of Ed)if(t>=ue[e])return e;return"xs"}function sn(s,t){if(s==="xs")return!0;let e=ue[s];if(e===void 0)throw new RangeError(`Unknown breakpoint "${s}"`);return Number(t)>=e}function Ue(s,t={}){if(typeof s!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in t&&!F(t.target)&&t.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let e=t.target??globalThis,i=F(e)?e:null,n=null,r=!1,o=null,a=()=>i?i.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,c=()=>{if(r)return;let u=a();if(i&&u===0)return;let p=en(u);p!==n&&(n=p,s(n,u))};c();let h=0,d=()=>{h||r||(h=requestAnimationFrame(()=>{h=0,c()}))};return i&&typeof ResizeObserver=="function"?(o=new ResizeObserver(d),o.observe(i)):globalThis.addEventListener?.("resize",c,{passive:!0}),{current:()=>n??en(a()),destroy:()=>{r||(r=!0,h&&cancelAnimationFrame(h),o?.disconnect(),globalThis.removeEventListener?.("resize",c))}}}var Ni=class{base;headers;onError;timeout;constructor({base:t="",headers:e={},onError:i=null,timeout:n=3e4}={}){this.base=String(t),this.headers=Object.freeze({...e}),this.onError=i,this.timeout=Number(n)}async request(t,e={}){let{method:i="GET",data:n=null,files:r=null,query:o=null,headers:a={}}=e,c=new AbortController,h=this.timeout>0?setTimeout(()=>c.abort(),this.timeout):null,d=new Headers(this.headers);for(let[f,_]of Object.entries(a))d.set(f,_);d.set("Accept",d.get("Accept")??"application/json");let u;r!==null?(u=Od(n,r),d.delete("Content-Type")):n!==null&&i.toUpperCase()!=="GET"&&i.toUpperCase()!=="HEAD"&&(u=JSON.stringify(n),d.set("Content-Type",d.get("Content-Type")??"application/json"));let p=Nd(this.base+t,o);try{let f=await fetch(p,{method:i.toUpperCase(),headers:d,body:u,signal:c.signal}),_=await f.text(),m=null;if(_!=="")try{m=JSON.parse(_)}catch(w){let y=new Error("Invalid JSON response",{cause:w});throw y.response=f,y}if(!f.ok){try{nn(m)}catch(y){throw y.response=f,y}let w=new Error(`HTTP ${f.status} ${f.statusText}`.trim());throw w.response=f,w}return nn(m)}catch(f){let _=f instanceof Error?f:new Error(String(f));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 Md(s,t="",e={}){let{apiBase:i="../remotecall/",...n}=e,r=`${i}${s}${t?`:${t}`:""}/`;return new Ni({...n,base:r})}function nn(s){if(s&&typeof s=="object"){if(Object.prototype.hasOwnProperty.call(s,"error")&&s.error!=null){let t=typeof s.error=="string"?s.error:JSON.stringify(s.error);throw new Error(t||"Server error")}if(Object.prototype.hasOwnProperty.call(s,"result"))return s.result}return s}function Nd(s,t){if(t==null)return s;let e;if(typeof t=="string")e=t.replace(/^\?/,"");else if(t instanceof URLSearchParams)e=t.toString();else{let i=new URLSearchParams;for(let[n,r]of Object.entries(t))za(i,n,r);e=i.toString()}return e?s+(s.includes("?")?"&":"?")+e:s}function za(s,t,e){if(e!=null)if(Array.isArray(e))for(let i of e)za(s,t,i);else s.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function Od(s,t){let e=new FormData;if(s&&typeof s=="object"&&!Array.isArray(s))for(let[n,r]of Object.entries(s))Ca(e,n,r);else s!=null&&e.append("data",typeof s=="string"?s:JSON.stringify(s));let i=Fd(t)||Array.isArray(t)?Array.from(t):[t];for(let n of i)e.append("files",n);return e}function Ca(s,t,e){if(e!=null)if(Array.isArray(e))for(let i of e)Ca(s,t,i);else{let i=typeof Blob=="function"&&e instanceof Blob;s.append(t,typeof e=="object"&&!i?JSON.stringify(e):e)}}function Fd(s){return typeof FileList=="function"&&s instanceof FileList}var Rd=0,Ld=20,Pd=3,Vd=["B","KiB","MiB","GiB","TiB","PiB","EiB"],Bd=["B","kB","MB","GB","TB","PB","EB"],rn=[{unit:"second",ms:1e3,limit:45},{unit:"minute",ms:6e4,limit:45},{unit:"hour",ms:36e5,limit:22},{unit:"day",ms:864e5,limit:6},{unit:"week",ms:6048e5,limit:4},{unit:"month",ms:26298e5,limit:11},{unit:"year",ms:315576e5,limit:1/0}],Ta=new Map,Da=new Map;function Qt(s,t={}){let e=Oi(s);if(e===null)return"";let{locale:i=ot(),decimals:n,minDecimals:r,maxDecimals:o,group:a=!0}=t;return ln(i,cn({decimals:n,minDecimals:r,maxDecimals:o,group:a}),e)}function on(s,t,e={}){let i=Oi(s);if(i===null)return"";let{locale:n=ot(),decimals:r}=e,o=Kd(t);if(o===null)return Qt(i,{locale:n,decimals:r});let a=cn({decimals:r,group:!0});return ln(n,{...a,style:"currency",currency:o},i)}function an(s,t={}){let e=Oi(s);if(e===null)return"";let{locale:i=ot(),decimals:n=0}=t;return ln(i,{...cn({decimals:n,group:!0}),style:"percent"},e)}function Hd(s,t={}){let e=Oi(s);if(e===null)return"";let{locale:i=ot(),decimals:n=1,standard:r="iec"}=t;if(e===0)return`${Qt(0,{locale:i,decimals:0})} B`;let o=r==="si"?Bd:Vd,a=r==="si"?1e3:1024,c=Math.abs(e),h=Math.min(o.length-1,Math.max(0,Math.floor(Math.log(c)/Math.log(a)))),d=c/a**h;Ud(d,h===0?0:n)>=a&&h<o.length-1&&(h+=1,d=c/a**h);let u=e<0?-d:d;return`${Qt(u,{locale:i,minDecimals:0,maxDecimals:h===0?0:n})} ${o[h]}`}function qd(s,t={}){let e=Ea(s);if(e===null)return"";let{now:i=new Date,locale:n=ot(),numeric:r="auto"}=t,o=Ea(i);if(o===null)return"";let a=e.getTime()-o.getTime(),c=rn.find(({ms:d,limit:u})=>Math.abs(a)/d<u)??rn[rn.length-1],h=Math.round(a/c.ms);return $d(n,r).format(h,c.unit)}function ln(s,t,e){let i=`${s}\0${JSON.stringify(t)}`,n=Ta.get(i);return n===void 0&&(n=jd(s,t),Ta.set(i,n)),n.format(e)}function jd(s,t){try{return new Intl.NumberFormat(s,t)}catch{try{return new Intl.NumberFormat(void 0,t)}catch{return new Intl.NumberFormat}}}function $d(s,t){let e=`${s}\0${t}`,i=Da.get(e);if(i===void 0){try{i=new Intl.RelativeTimeFormat(s,{numeric:t})}catch{i=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"})}Da.set(e,i)}return i}function cn({decimals:s,minDecimals:t,maxDecimals:e,group:i=!0}){let n={useGrouping:i!==!1},r=Ia(t??s),o=Ia(e??s);return r!==null&&(n.minimumFractionDigits=r),o!==null?(n.maximumFractionDigits=o,r!==null&&r>o&&(n.minimumFractionDigits=o)):r!==null&&(n.maximumFractionDigits=Math.max(r,Pd)),n}function Ia(s){if(s==null)return null;let t=Number(s);return Number.isFinite(t)?Math.min(Ld,Math.max(Rd,Math.round(t))):null}function Oi(s){if(s==null||s==="")return null;let t=typeof s=="number"?s:Number(s);return Number.isFinite(t)?t:null}function Kd(s){if(typeof s!="string")return null;let t=s.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function Ea(s){if(s instanceof Date)return Number.isNaN(s.getTime())?null:s;if(typeof s=="number")return Number.isFinite(s)?new Date(s*1e3):null;if(typeof s=="string"){let t=s.trim();if(t==="")return null;let e=/^-?\d+$/.test(t)?new Date(Number(t)*1e3):new Date(t);return Number.isNaN(e.getTime())?null:e}return null}function Ud(s,t){let e=10**t;return Math.round(s*e)/e}var Ma="zx:__probe__";function Ye(s,t={}){let{area:e="local"}=t,i=`zx:${String(s??"")}:`,n=new Map,r=Yd(e),o=d=>{if(r!==null)try{return r.getItem(d)}catch{r=null}return n.has(d)?n.get(d):null},a=(d,u)=>{if(r!==null)try{r.setItem(d,u);return}catch{r=null}n.set(d,u)},c=d=>{if(r!==null)try{r.removeItem(d)}catch{r=null}n.delete(d)},h=()=>{if(r!==null)try{let d=[];for(let u=0;u<r.length;u+=1){let p=r.key(u);typeof p=="string"&&p.startsWith(i)&&d.push(p)}return d}catch{r=null}return[...n.keys()].filter(d=>d.startsWith(i))};return{get(d,u){let p=o(i+d);if(p==null)return u;try{return JSON.parse(p)}catch{return u}},set(d,u){let p;try{p=JSON.stringify(u)}catch{p=void 0}p===void 0?c(i+d):a(i+d,p)},remove(d){c(i+d)},keys(){return h().map(d=>d.slice(i.length))},clear(){for(let d of h())c(d)}}}function Yd(s){let t=s==="session"?"sessionStorage":"localStorage";try{let e=globalThis[t];return!e||typeof e.getItem!="function"?null:(e.setItem(Ma,"1"),e.removeItem(Ma),e)}catch{return null}}var Wd=["=","+","-","@"];function Gd(s,t,e={}){let{delimiter:i=",",header:n=!0,newline:r=`\r
|
|
2
|
-
|
|
3
|
-
`)||i.includes("\r")?`"${i.replaceAll('"','""')}"`:i}function eu(s,t){if(typeof Blob=="function"&&s instanceof Blob)return s;let e=typeof s=="string"&&/^text\/csv\b/i.test(t)?["\uFEFF",s]:[s];return new Blob(e,{type:t})}var Vt=class extends b{static cssName="check-button";static defaults={label:"",checked:!1,icon:!0,disabled:!1};render(){let t=!this.el,e=this.el??l("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:iu(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,this._labels=Fa(this.options.label),e.type="button";let i=[];return this.options.icon&&i.push(l("span",{class:"zx-check-button__icon",ariaHidden:"true"},l("span",{class:"zx-check-button__off"},g("square",{size:15})),l("span",{class:"zx-check-button__on"},g("check",{size:15})))),i.push(l("span",{class:"zx-check-button__label",ref:"label"})),e.replaceChildren(...i),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let i=!!t;return i===this._checked?this:(this._checked=i,this._sync(),e||this.emit("change",{checked:this._checked}),this)}toggle(){return this.set(!this._checked)}setLabel(t){return this._labels=Fa(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&&su(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 Fa(s){return Array.isArray(s)?{on:String(s[0]??""),off:String(s[1]??"")}:{on:String(s??""),off:String(s??"")}}function iu(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function su(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}var nu=".zx-scope, [data-zx-theme], [data-zx-density], [data-zx-preset]";function rt(s=null){let e=(s==null?document.activeElement instanceof Element?document.activeElement:null:U(s))?.closest?.(nu)??null;return!e||e===document.documentElement||e===document.body?document.body:e}var We=class extends b{static cssName="modal";static defaults={content:null,width:"auto",closable:!0,lightDismiss:!1,destroyOnClose:!1,scope:null};#t=new Map;#e=!1;#i=0;#s=[];constructor(t=null,e={}){super(null,e),this.#r(this.options.width),Ra(this.refs.content,this.options.content),this.listen(this.el,"cancel",i=>{let n=this.emit("cancel");(!this.options.closable||n.defaultPrevented)&&i.preventDefault()}),this.listen(this.el,"close",()=>{this._settleClose(this.#s.shift())}),this.listen(this.el,"click",i=>{!this.options.lightDismiss||i.target!==this.el||!ru(this.el,i)||this.close()})}mountTarget(){return rt(this.options.scope)}_show(){this.el.showModal()}_hide(t="",e=this.#i){this.#s.push(e);try{this.el.close(t)}catch(i){throw this.#s.pop(),i}}_present(){this._show(),this.#i+=1}_dismiss(t=""){this._hide(t,this.#i)}_isShown(){return this.el.open}_isRealClose(t){return t!==void 0&&t!==this.#i?!1:!this._isShown()}_settleClose(t){if(!this._isRealClose(t))return t!==void 0&&this.#t.delete(t),!1;this.el.dataset.state="closed",delete this.el.dataset.zxOverlayOrder;let e=t===void 0?void 0:this.#t.get(t);t!==void 0&&this.#t.delete(t);let i=e?e.result:this.el.returnValue||void 0;return this.emit("close",{result:i}),this.options.destroyOnClose&&!this.#e&&this.destroy(),!0}render(){let t=l("dialog",{class:"zx-modal"},l("div",{class:"zx-modal__content",ref:"content"}));return t.dataset.state="closed",this.mountTarget().append(t),t}open(){if(this.isOpen())return this;let t=this.mountTarget();this.el.parentElement!==t&&t.append(this.el),this.el.dataset.zxOverlayOrder=String(ou()),this.el.returnValue="";try{this._present()}catch(e){throw delete this.el.dataset.zxOverlayOrder,e}return this.el.dataset.state="open",this.emit("open"),this}close(t){if(!this.isOpen())return this;let e=this.#i;this.#t.set(e,{result:t});try{this._dismiss(typeof t=="string"?t:"")}catch(i){throw this.#t.delete(e),i}return this}setContent(t){return Ra(this.refs.content,t),this}isOpen(){return this._isShown()}destroy(){this.#e||(this.#e=!0,this.isOpen()&&this._dismiss(),super.destroy())}#r(t){typeof t=="number"&&Number.isFinite(t)?this.el.style.inlineSize=`${Math.max(0,t)}px`:this.el.style.inlineSize=String(t??"auto")}};function Ra(s,t){if(s.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t.nodeType=="number"&&s.append(t)}function ru(s,t){let e=s.getBoundingClientRect();return t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom}function ou(){let s=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...s)+1}var au=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(","),Bt=class s extends We{static cssName="dialog";static defaults={title:"",size:"md",buttons:[],closable:!0};#t=new Map;#e=null;#i=[];#s="";#r=null;constructor(t=null,e={}){super(null,e),this._applySize(this.options.size),this.#s=String(this.options.title??""),this.#o(this.#s),this.#i=Fi(this.options.buttons),this.#a(this.#i),this.refs.close.hidden=!this.options.closable,this.listen(this.refs.close,"click",()=>this.close()),this.listen(this.refs.footer,"click",i=>{let n=i.target.closest?.("[data-dialog-button]");if(!n||!this.refs.footer.contains(n))return;let r=this.#n[Number(n.dataset.dialogButton)];r&&this.#l(r)}),this.on("close",()=>this.#c())}#n=[];render(){let t=x("zx-dialog-title"),e=l("dialog",{class:"zx-modal zx-dialog",ariaLabelledby:t},l("header",{class:"zx-dialog__header"},l("h2",{class:"zx-dialog__title",id:t,ref:"title"}),l("button",{class:"zx-btn zx-dialog__close",ref:"close",type:"button","data-kind":"ghost",ariaLabel:"Close",title:"Close"},"\xD7")),l("div",{class:"zx-modal__content zx-dialog__body",ref:"content"}),l("footer",{class:"zx-dialog__footer",ref:"footer"}));return e.dataset.state="closed",this.mountTarget().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(au);e instanceof HTMLElement&&e.focus()}),this)}setTitle(t){return this.#s=String(t??""),this.#o(this.#s),this}setContent(t){return this.#t.clear(),this.#e=null,lu(this.refs.content,t),this}setButtons(t){return this.#i=Fi(t),this.#a(this.#i),this}addView(t,e){let i=String(t);this.#t.get(i)?.content.remove();let r=l("section",{class:"zx-dialog__view",hidden:!0,ariaHidden:"true"});La(r,e?.content??null);let o={key:i,content:r,buttons:e&&Object.hasOwn(e,"buttons")?Fi(e.buttons??[]):null,title:e&&Object.hasOwn(e,"title")?String(e.title??""):null};return this.#t.set(i,o),this.#t.size===1||this.#e?.key===i?this.showView(i):this.refs.content.append(r),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 i of this.#t.values()){i.content.isConnected||this.refs.content.append(i.content);let n=i===e;i.content.hidden=!n,i.content.setAttribute("aria-hidden",String(!n))}return this.#e=e,this.#o(e.title??this.#s),this.#a(e.buttons??this.#i),e}getView(t){return this.#t.get(String(t))??null}static alert({title:t="",message:e="",okLabel:i="OK"}={}){return new Promise(n=>{let r=!1,o=()=>{r||(r=!0,a.close(),n())},a=new s(null,{title:t,content:e,buttons:[{label:i,kind:"primary",action:o,autofocus:!0}]});a.once("close",()=>{r||(r=!0,n()),a.destroy()}),a.open()})}static confirm({title:t="",message:e="",okLabel:i="OK",cancelLabel:n="Cancel",danger:r=!1}={}){return new Promise(o=>{let a=!1,c=d=>{a||(a=!0,h.close(d),o(d))},h=new s(null,{title:t,content:e,buttons:[{label:n,action:()=>c(!1)},{label:i,kind:r?"danger":"primary",action:()=>c(!0),autofocus:!0}]});h.once("close",()=>{a||(a=!0,o(!1)),h.destroy()}),h.open()})}static prompt({title:t="",message:e="",value:i="",placeholder:n=""}={}){return new Promise(r=>{let o=!1,a=l("input",{class:"zx-dialog__prompt-input",value:String(i),placeholder:String(n),autofocus:!0,ariaLabel:String(t||"Prompt value")}),c=l("div",{class:"zx-dialog__prompt"},l("div",{class:"zx-dialog__prompt-message"},e),a),h=u=>{o||(o=!0,d.close(u),r(u))},d=new s(null,{title:t,content:c,buttons:[{label:"Cancel",action:()=>h(null)},{label:"OK",kind:"primary",action:()=>h(a.value)}]});d.listen(a,"keydown",u=>{u.key==="Enter"&&(u.preventDefault(),h(a.value))}),d.once("close",()=>{o||(o=!0,r(null)),d.destroy()}),d.open()})}_applySize(t){let e={sm:400,md:600,lg:840},i=typeof t=="number"&&Number.isFinite(t)?t:e[t]??e.md;this.el.style.inlineSize=`${Math.max(0,i)}px`}#o(t){this.refs.title.textContent=t}#a(t){this.#n=Fi(t),this.refs.footer.replaceChildren(),this.refs.footer.hidden=this.#n.length===0,this.#n.forEach((e,i)=>{this.refs.footer.append(l("button",{class:"zx-btn",type:"button","data-kind":e.kind??"default","data-size":"md","data-dialog-button":String(i),autofocus:!!e.autofocus},l("span",{class:"zx-btn__label"},e.label)))})}#l(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 Fi(s){return Array.isArray(s)?s.map(t=>({...t,label:String(t.label??"")})):[]}function lu(s,t){s.replaceChildren(),La(s,t)}function La(s,t){if(t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t.nodeType=="number"&&s.append(t)}var Xt=class extends b{static cssName="groupbox";static defaults={title:"",open:!0};constructor(t,e={}){let i=t,n=null;if(t!==null){let r=U(t);if(r&&r.localName!=="details"){let o=document.createElement("details"),a=Array.from(r.childNodes),c=r.parentNode,h=r.nextSibling;c&&c.insertBefore(o,r),o.append(...a),r.remove(),n={original:r,details:o,children:a,parent:c,next:h},i=o}}try{super(i,e)}catch(r){throw n&&Pa(n),r}this._adoption=n}render(){let t=!this.el,e=this.el??l("details");if(e.localName!=="details")throw new TypeError("Groupbox requires a details element");this._createdRoot=t,this._original=t?null:cu(e);let i=Array.from(e.childNodes).filter(o=>!(o.nodeType===1&&o.localName==="summary")),n=l("summary",{class:"zx-groupbox__summary",ref:"summary"},l("span",{class:"zx-groupbox__chevron",ariaHidden:"true"},g("chevron-right",{size:16})),l("span",{class:"zx-groupbox__title",ref:"title"},String(this.options.title))),r=l("div",{class:"zx-groupbox__content",ref:"content"},i);return e.replaceChildren(n,r),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 b?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?Pa(this._adoption):!this._createdRoot&&this._original&&hu(this.el,this._original))}};function cu(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function hu(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function Pa(s){if(s.original.replaceChildren(...s.children),s.details.parentNode)s.details.replaceWith(s.original);else if(s.parent){let t=s.next?.parentNode===s.parent?s.next:null;s.parent.insertBefore(s.original,t)}}var Ge=class extends b{static cssName="search";static defaults={placeholder:"",value:"",clearable:!0,debounce:250};render(){let t=!this.el,e=this.el??l("form");this._createdRoot=t,this._original=t?null:du(e),this._inputTimer=null,e.setAttribute("role","search");let i=l("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")}),n=this.options.clearable?l("button",{class:"zx-search__clear",ref:"clear",type:"button",ariaLabel:"Clear search",title:"Clear search"},g("x",{size:15})):null,r=l("button",{class:"zx-search__submit",ref:"submit",type:e.localName==="form"?"submit":"button",ariaLabel:"Submit search",title:"Search"},g("search",{size:16}));return e.replaceChildren(...[i,n,r].filter(Boolean)),this._syncClear(),this.listen(i,"input",()=>{this._syncClear(),this._scheduleInput()}),e.localName==="form"?this.listen(e,"submit",o=>{o.preventDefault(),this.emit("submit",{value:this.get()})}):(this.listen(i,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this.emit("submit",{value:this.get()}))}),this.listen(r,"click",()=>this.emit("submit",{value:this.get()}))),n&&this.listen(n,"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&&uu(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 du(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function uu(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}var fu=new Set(["divided","bracket","line","segmented"]),Qe=class extends b{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??l("section");if(this.el=e,this._createdRoot=t,this._original=t?null:_u(e),this._cleaned=!1,this._tabs=[],this._active=null,this._keepAlive=!!this.options.keepAlive,this._initializing=!0,!fu.has(this.options.variant))throw new RangeError(`Unknown tabbox variant: ${this.options.variant}`);e.dataset.variant=this.options.variant;let i=l("div",{class:"zx-tabbox__tablist",ref:"tablist",role:"tablist",ariaOrientation:"horizontal"}),n=l("div",{class:"zx-tabbox__panels",ref:"panels"});if(e.replaceChildren(i,n),!Array.isArray(this.options.tabs))throw new TypeError("Tabbox tabs must be an array");for(let a of this.options.tabs)this.addTab(a);this._initializing=!1;let r=this.options.active===null?null:this._find(this.options.active),o=r&&!r.definition.disabled?r:this._enabledTabs()[0];return o&&this._applyActive(o),this.listen(i,"click",a=>{let c=a.target.closest?.('[role="tab"]');if(!c||!i.contains(c))return;let h=this._recordForTab(c);if(!(!h||h.definition.disabled)){if(a.target.closest?.(".zx-tabbox__close")){this._closeTab(h);return}this._setFocused(h),this.openTab(h.definition.name)}}),this.listen(i,"keydown",a=>this._onKeydown(a)),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(!pu(t.content))throw new TypeError("Tab content must be a Node, Component, or function");let i={name:t.name,title:String(t.title??""),content:t.content,icon:t.icon?String(t.icon):null,closable:!!t.closable,disabled:!!t.disabled},n=x("zx-tab"),r=x("zx-tabpanel"),o=l("span",{class:"zx-tabbox__title"},i.title),a=l("span",{class:"zx-tabbox__badge",hidden:!0}),c=[];i.icon&&c.push(l("span",{class:"zx-tabbox__icon",ariaHidden:"true"},g(i.icon,{size:16}))),c.push(o,a),i.closable&&c.push(l("span",{class:"zx-tabbox__close zx-icon-btn",ariaHidden:"true",title:"Close"},g("x",{size:14})));let h=l("button",{class:"zx-tabbox__tab",type:"button",id:n,role:"tab",tabindex:"-1",ariaControls:r,ariaSelected:"false",ariaDisabled:i.disabled?"true":null,dataset:{closable:i.closable?"true":null}},c),d=l("div",{class:"zx-tabbox__panel",id:r,role:"tabpanel",tabindex:"0",ariaLabelledby:n,hidden:!0}),u={definition:i,tab:h,title:o,badge:a,panel:d,built:!1},p=Number.isFinite(e.index)?Math.trunc(e.index):this._tabs.length,f=Math.max(0,Math.min(this._tabs.length,p)),_=this._tabs[f]??null;return this._tabs.splice(f,0,u),this.refs.tablist.insertBefore(h,_?.tab??null),this._keepAlive&&this.refs.panels.insertBefore(d,_?.panel??null),!this._initializing&&!this._active&&!i.disabled&&this._applyActive(u),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 i=this._active?.definition.name??null;return this.emit("change",{name:e.definition.name,previous:i}).defaultPrevented?this:(this._applyActive(e),this)}show(t){return this.openTab(t)}getActive(){return this._active?.definition.name??null}setTitle(t,e){let i=this._require(t);return i.definition.title=String(e??""),i.title.textContent=i.definition.title,this}setBadge(t,e){let i=this._require(t);return i.badge.textContent=e===null?"":String(e),i.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 i=this._enabledTabs().find(n=>n!==e)??null;if(i){if(this.openTab(i.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&&mu(this.el,this._original))}_onKeydown(t){let e=t.target.closest?.('[role="tab"]');if(!e||!this.refs.tablist.contains(e))return;let i=this._recordForTab(e);if(!i)return;let n=this._enabledTabs();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let r=t.key==="ArrowRight"?1:-1,o=n.indexOf(i),a=n[(o+r+n.length)%n.length];a&&this._setFocused(a);return}if(t.key==="Home"||t.key==="End"){t.preventDefault();let r=t.key==="Home"?n[0]:n[n.length-1];r&&this._setFocused(r);return}if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.openTab(i.definition.name);return}t.key==="Delete"&&i.definition.closable&&(t.preventDefault(),this._closeTab(i))}_closeTab(t){let e=this._tabs.indexOf(t),i=t.tab.contains(document.activeElement);if(!this._removeTab(t.definition.name,!0))return;let n=this._tabs[Math.min(e,this._tabs.length-1)]??this._tabs[e-1],r=n&&!n.definition.disabled?n:this._active;r&&this._setFocused(r,i)}_removeTab(t,e){let i=this._find(t);if(!i)return!1;let n=this._tabs.indexOf(i),o=this._tabs.filter(c=>c!==i).filter(c=>!c.definition.disabled),a=o.find(c=>this._tabs.indexOf(c)>n)??o.at(-1)??null;return i===this._active&&a&&this.emit("change",{name:a.definition.name,previous:i.definition.name}).defaultPrevented?!1:(this._tabs.splice(n,1),i.tab.remove(),i.panel.remove(),i===this._active&&(this._active=null,a&&this._applyActive(a)),e&&this.emit("close",{name:i.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,i=e instanceof b?e.toElement():e;if(!i||typeof i.nodeType!="number")throw new TypeError(`Tab content factory for ${t.definition.name} must return a Node or Component`);t.panel.append(i),t.built=!0}_setFocused(t,e=!0){for(let i of this._tabs)i.tab.tabIndex=i===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 pu(s){return typeof s=="function"||s instanceof b?!0:!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function _u(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function mu(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function gu(s,t){return String(s).localeCompare(String(t))}function bu(s,t){return s-t}function yu(s,t){return s.getTime()-t.getTime()}function wu(s,t,e="asc"){let i=s==null,n=t==null;if(i||n)return i&&n?0:i?1:-1;let r;return s instanceof Date&&t instanceof Date?r=yu(s,t):typeof s=="number"&&typeof t=="number"?r=bu(s,t):r=gu(s,t),e==="desc"?-r:r}function vu(s,t="asc"){return(e,i)=>wu(s(e),s(i),t)}function Xe(s,t,e="asc"){let i=vu(t,e);return s.map((n,r)=>({row:n,index:r})).sort((n,r)=>i(n.row,r.row)||n.index-r.index).map(({row:n})=>n)}var xu=new Set(["text","number","select","date","checkbox","textarea"]),Su='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',Dt=class extends b{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,editTrigger:"double",hierarchy:!1,rowReorder:!1,columnVisibility:!1,columnReorder:!1,hiddenColumns:[]};constructor(t,e={}){super(t,e)}render(){let t=this.el===null,e=this.el??l("div");if(this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._columns=Ba(this.options.columns),this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._selected=new Set,this._selectionAnchorId=null,this._sort=qa(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=Mu(this.options.editMode),this._editTrigger=this.options.editTrigger==="single"?"single":"double",this._edit=null,this._editMessage=null,this._stacked=!1,this._width=null,this._growStep=Pu(this.options.growing),this._rendered=this._growStep??1/0,this._more=null,this._rovingKey=null,this._rovingCell=null,this._rovingMatched=!1,this._hierarchy=dn(this.options.hierarchy,this._columns),this._hiddenColumns=new Set((Array.isArray(this.options.hiddenColumns)?this.options.hiddenColumns:[]).map(String).filter(i=>this._columns.some(n=>n.id===i))),this._hiddenColumns.size>=this._columns.length&&this._columns[0]&&this._hiddenColumns.delete(this._columns[0].id),this._dragId=null,this._grabbedId=null,this._columnControlIds=new Map,this._columnStatus=null,this._expanded=Eu(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let i of Ri(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(i);return this._reconcileExpanded(),this._table=l("table",{class:"zx-table__table"}),this._hierarchy&&this._table.setAttribute("role","treegrid"),this._colgroup=l("colgroup",{class:"zx-table__columns"}),this._thead=l("thead",{class:"zx-table__head"}),this._tbody=l("tbody",{class:"zx-table__body"}),this._table.append(this._colgroup,this._thead,this._tbody),this._scroll=l("div",{class:"zx-table__scroll",dataset:{stickyHeader:String(!!this.options.stickyHeader),zebra:String(!!this.options.zebra)}},this._table),this._rowMoveMessage=this.options.rowReorder?l("div",{class:"zx-table__reorder-status",role:"status",ariaLive:"polite"}):null,this.options.height!=null&&(this._scroll.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._columnControls=this.options.columnVisibility||this.options.columnReorder?this._createColumnControls():null,this._editMode===!1?e.replaceChildren(...[this._columnControls,this._scroll,this._rowMoveMessage].filter(Boolean)):(e.dataset.editMode=this._editMode,this._editMessage=l("div",{class:"zx-table__message",id:x("zx-table-message"),role:"status",ariaLive:"polite"}),e.replaceChildren(...[this._columnControls,this._scroll,this._editMessage,this._rowMoveMessage].filter(Boolean))),this._renderColumns(),this._renderHeader(),this._renderBody(),this._watchWidth(),this.listen(this._tbody,"click",i=>this._handleBodyClick(i)),this.listen(this._tbody,"dblclick",i=>this._handleBodyDoubleClick(i)),this.options.rowReorder&&(this.listen(this._tbody,"dragstart",i=>this._handleRowDragStart(i)),this.listen(this._tbody,"dragover",i=>this._handleRowDragOver(i)),this.listen(this._tbody,"drop",i=>this._handleRowDrop(i)),this.listen(this._tbody,"dragend",()=>this._clearRowDrag()),this.listen(this._tbody,"keydown",i=>this._handleRowHandleKeydown(i))),this._columnControls&&(this.listen(this._columnControls,"change",i=>{let n=i.target;n?.classList.contains("zx-table__column-toggle")&&this.setColumnVisible(n.value,n.checked)}),this.listen(this._columnControls,"click",i=>this._handleColumnControlClick(i)),this.listen(this._columnControls,"keydown",i=>this._handleColumnControlKeydown(i))),this._editMode!==!1&&(this.listen(this._tbody,"keydown",i=>this._handleEditKeydown(i)),this.listen(this._tbody,"focusin",i=>this._handleEditFocusIn(i)),this.listen(document,"pointerdown",i=>this._handleDocumentPointerDown(i),{capture:!0})),e}setLoading(t=!0){return t?this.el.dataset.loading="true":delete this.el.dataset.loading,this.el.setAttribute("aria-busy",String(!!t)),this}setData(t){this._rendered=this._growStep??1/0,this.setLoading(!1),ja(t),this._data=[...t],this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded();let e=this._pruneSelection();return this._renderBody(),e&&this._emitSelectionChange(),this._emitDataChange(),this}addData(t){return ja(t),this._data.push(...t),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),this._emitDataChange(),this}updateRow(t,e){let i=this._data.findIndex(r=>Object.is(this._idFor(r),t));if(i<0)return this;let n=this._selected.delete(t);return this._data[i]=e,n&&this._selected.add(this._idFor(e)),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),n&&!Object.is(t,this._idFor(e))&&this._emitSelectionChange(),this._emitDataChange(),this}removeRow(t){let e=this._data.findIndex(n=>Object.is(this._idFor(n),t));if(e<0)return this;this._data.splice(e,1),this._reconcileExpanded();let i=this._selected.delete(t);return Object.is(this._selectionAnchorId,t)&&(this._selectionAnchorId=null),this._renderBody(),i&&this._emitSelectionChange(),this._emitDataChange(),this}getRow(t){return this._data.find(e=>Object.is(this._idFor(e),t))??null}getData(){return[...this._data]}getColumns(){return this._columns.map(t=>({...t}))}setColumns(t,e={}){let i=Ba(t),n=this.getColumnOrder(),r=this.getHiddenColumns(),o=this.getSort();return this._abortEdit({focus:!1}),this._columns=i,this._hiddenColumns=new Set(r.filter(a=>i.some(c=>c.id===a))),this._hiddenColumns.size>=i.length&&i[0]&&this._hiddenColumns.delete(i[0].id),this._sort=qa(o,i),this._hierarchy=dn(this.options.hierarchy,i),this._reconcileExpanded(),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(),e.silent||(Pi(n,this.getColumnOrder())||this.emit("columnorderchange",{order:this.getColumnOrder()}),Pi(r,this.getHiddenColumns())||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()})),this}getColumnOrder(){return this._columns.map(t=>t.id)}setColumnOrder(t,e={}){let i=Ou(this._columns,t);if(Pi(i,this.getColumnOrder()))return this;let n=this._activeColumnControl(),r=new Map(this._columns.map(o=>[o.id,o]));return this._abortEdit({focus:!1}),this._columns=i.map(o=>r.get(o)),this._hierarchy=dn(this.options.hierarchy,this._columns),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(n),e.silent||this.emit("columnorderchange",{order:this.getColumnOrder()}),this}moveColumn(t,e,i="before",n={}){if(i!=="before"&&i!=="after")throw new TypeError('Table column position must be "before" or "after"');let r=Fu(this.getColumnOrder(),String(t),String(e),i);if(Pi(r,this.getColumnOrder()))return this;if(this.setColumnOrder(r,n),this._columnStatus){let o=this._columns.find(c=>c.id===String(t)),a=this.getColumnOrder().indexOf(String(t));o&&a>=0&&(this._columnStatus.textContent=`Moved ${o.label} to position ${a+1} of ${this._columns.length}.`)}return this}getVisibleColumns(){return this._visibleColumns().map(t=>t.id)}getHiddenColumns(){return this._columns.filter(t=>this._hiddenColumns.has(t.id)).map(t=>t.id)}setColumnVisible(t,e=!0,i={}){let n=String(t);if(!this._columns.find(c=>c.id===n))throw new RangeError(`Unknown table column: ${n}`);let o=this._activeColumnControl();if(!e&&!this._hiddenColumns.has(n)&&this._visibleColumns().length<=1)return this._renderColumnControls(o),this;let a=e?this._hiddenColumns.delete(n):!this._hiddenColumns.has(n);return!e&&a&&this._hiddenColumns.add(n),a?(this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(o),i.silent||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()}),this):this}toggleColumn(t,e={}){return this.setColumnVisible(t,this._hiddenColumns.has(String(t)),e)}moveRow(t,e,i="before"){if(!this.options.rowReorder||this._sort&&this.options.sortMode==="local")return this;let n=this.getRow(t),r=this.getRow(e);if(!n||!r||Object.is(t,e))return this;let o=$a(this._data,this.options.rowId,t,e,i,this._hierarchy?.parentId);if(!o)return this;if(this.emit("rowmove",{row:n,id:t,target:r,targetId:e,position:i}).defaultPrevented)return this;if(this._data=o,this._renderBody(),this._rowMoveMessage){let c=this._siblingIds(t),h=c.findIndex(d=>Object.is(d,t));this._rowMoveMessage.textContent=`Moved row to position ${h+1} of ${c.length}.`}return this._emitDataChange(),queueMicrotask(()=>this._rowHandle(t)?.focus()),this}empty(){let t=this._selected.size>0;return this._data=[],this._expanded.clear(),this._selected.clear(),this._selectionAnchorId=null,this._renderBody(),t&&this._emitSelectionChange(),this._emitDataChange(),this}setSort(t,e,i={}){if(this._abortEdit({focus:!1}),!this._columns.find(o=>o.id===t))throw new RangeError(`Unknown table column: ${t}`);let r=e??(this._sort?.id===t&&this._sort.dir==="asc"?"desc":"asc");if(r!=="asc"&&r!=="desc")throw new TypeError('Table sort direction must be "asc" or "desc"');return this._sort={id:t,dir:r},this.options.sortMode==="local"&&(this._sortData(),this._renderBody()),this._syncSortHeader(),i.silent||this.emit("sort",{id:t,dir:r}),this}getSort(){return this._sort?{...this._sort}:null}clearSort(t={}){return this._sort?(this._abortEdit({focus:!1}),this._sort=null,this._syncSortHeader(),t.silent||this.emit("sort",{id:null,dir:null}),this):this}getSelection(){return this._data.filter(t=>this._selected.has(this._idFor(t)))}setSelection(t){if(!Array.isArray(t))throw new TypeError("Table selection must be an array of row ids");let e=new Set(this._data.map(n=>this._idFor(n))),i=new Set;if(this.options.selectable!==!1){for(let n of t)if(e.has(n)&&i.add(n),this.options.selectable==="single"&&i.size>0)break}return Lu(this._selected,i)?this:(this._selected=i,this._syncSelection(),this._emitSelectionChange(),this)}clearSelection(){return this._selected.size===0?this:(this._selected.clear(),this._selectionAnchorId=null,this._syncSelection(),this._emitSelectionChange(),this)}toggleRow(t,e={}){return this._expanded.has(t)?this.collapseRow(t,e):this.expandRow(t,e)}expandRow(t,e={}){return this._setRowExpanded(t,!0,e)}collapseRow(t,e={}){return this._setRowExpanded(t,!1,e)}expandAll(t={}){if(!this._hierarchy)return this;let i=Ri(this._data,this.options.rowId,this._hierarchy.parentId).filter(n=>!this._expanded.has(n));for(let n of i)this._expanded.add(n);if(i.length&&this._renderBody(),!t.silent)for(let n of i)this._emitRowToggle(n,!0);return this}collapseAll(t={}){if(!this._hierarchy||this._expanded.size===0)return this;let e=[...this._expanded];if(this._expanded.clear(),this._renderBody(),!t.silent)for(let i of e)this._emitRowToggle(i,!1);return this}getExpanded(){return this._data.map(t=>this._idFor(t)).filter(t=>this._expanded.has(t))}startEdit(t,e){if(this._editMode===!1)return this;let i=this._columns.find(p=>p.id===e);if(!i)return this;let n=this._data.find(p=>Object.is(this._idFor(p),t));if(n===void 0)return this;let r=this._editMode==="row"&&this._hiddenColumns.has(i.id)?this._visibleColumns().find(p=>fe(p,n)!==!1)??null:i;if(!r||fe(r,n)===!1)return this;let o=r.id;if(this._edit){if(Object.is(this._edit.id,t)&&this._edit.cells.has(o))return this._edit.columnId=o,this._focusEditor(o),this;if(this.commitEdit(),this._edit)return this}let a=this._data.findIndex(p=>Object.is(this._idFor(p),t));if(a<0)return this;let c=this._data[a],h=this._rowElements.get(t)?.[0];if(!h)return this;let d=this._editMode==="row"?this._visibleColumns().filter(p=>fe(p,c)!==!1):[r],u=new Map;for(let p of d){let f=Ha(h,p.id);if(!f)continue;let _=this._createEditor(f,p,c,a);_&&u.set(p.id,_)}return u.size===0?this:(this._edit={id:t,columnId:o,row:c,cells:u,tr:h},h.dataset.editing="true",this.emit("editstart",{row:c,id:t,column:r,columnId:o,value:c?.[o]}),this._focusEditor(o),this)}commitEdit(){let t=this._edit;if(!t)return this;let e=this.getRow(t.id)??t.row,i={};for(let[u,p]of t.cells)i[u]=p.read();let n=this._columns.filter(u=>t.cells.has(u.id)),r=Iu(i,n,e,this._msgOr("table.invalid","Invalid value"));if(r)return this._markInvalid(r.columnId,r.message),t.columnId=r.columnId,this.emit("editinvalid",{row:e,id:t.id,column:this._columns.find(u=>u.id===r.columnId)??null,columnId:r.columnId,value:i[r.columnId],message:r.message}),this._focusEditor(r.columnId),this;this._clearInvalid();let o=Du(e,i),a=t.columnId;if(this.emit("editcommit",{row:e,id:t.id,column:this._columns.find(u=>u.id===a)??null,columnId:a,value:i[a],previous:e?.[a],changes:o}).defaultPrevented)return this;let h=this._editHasFocus(),d={...e,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(t.id,d),h&&this._focusCell(this._idFor(d),a),this}cancelEdit(){return this._abortEdit({focus:!0}),this}isEditing(){return this._edit!==null}getEditing(){return this._edit?{id:this._edit.id,columnId:this._edit.columnId}:null}_visibleData(){return this._visibleEntries().map(t=>t.row)}_projectedData(){return this._hierarchy?ku(this._data,this.options.rowId,this._hierarchy.parentId,this._expanded):this._data.map((t,e)=>({row:t,id:this._idFor(t),index:e,depth:0,hasChildren:!1,parentId:null}))}_visibleEntries(){let t=this._projectedData();return this._rendered===1/0?t:t.slice(0,this._rendered)}growBy(t){if(!this._growStep)return this;let e=Number(t)>0?Math.trunc(Number(t)):this._growStep,i=this._rendered,n=this._projectedData().length;return this._rendered=Math.min(n,this._rendered+e),this._rendered===i?this:(this._renderBody(),this.emit("grow",{rendered:this._rendered,total:n}),this)}showAll(){return this.growBy(this._projectedData().length)}getRenderedCount(){return Math.min(this._rendered,this._projectedData().length)}_syncGrowing(){if(!this._growStep)return;let t=this._projectedData().length-this.getRenderedCount();if(t<=0){this._more?.remove(),this._more=null;return}let e=this._message("table.more","Show %1 more",[t]);this._more||(this._more=l("button",{class:"zx-table__more",type:"button",onclick:()=>this.growBy()}),this.el.append(this._more)),this._more.textContent=e,this._more.setAttribute("aria-label",e)}_message(t,e,i){let n=this.msg(t,...i);return n===t?V(e,i):n}_watchWidth(){this._width?.destroy(),this._width=null;let t=this.options.responsive;!t||!(t in ue)||(this._width=Ue((e,i)=>this._setStacked(i>0&&i<ue[t]),{target:this.el}))}_setStacked(t){this._stacked!==t&&(this._stacked=t,this.el.toggleAttribute("data-stacked",t),this._applyStackedRoles(t),this.emit("stackedchange",{stacked:t}))}_applyStackedRoles(t){let e=[[this._table,this._hierarchy?"treegrid":"table"],[this._thead,"rowgroup"],[this._tbody,"rowgroup"]];for(let[i,n]of e)i&&(t?i.setAttribute("role",n):i===this._table&&this._hierarchy?i.setAttribute("role","treegrid"):i.removeAttribute("role"));for(let[i,n]of[["tr","row"],["td","cell"],["th","columnheader"]])for(let r of this._table.querySelectorAll(i))t?r.setAttribute("role",n):r.removeAttribute("role")}isStacked(){return!!this._stacked}destroy(){this._teardownEdit(),this._width?.destroy(),this._width=null,!this._restored&&!this._createdRoot&&(k(this.el,this._original),this._restored=!0),super.destroy()}_visibleColumns(){return this._columns.filter(t=>!this._hiddenColumns.has(t.id))}_createColumnControls(){let t=l("div",{class:"zx-table__column-list"});this._columnList=t,this._columnStatus=l("div",{class:"zx-table__column-status",role:"status",ariaLive:"polite"});let e=l("details",{class:"zx-table__column-controls"},l("summary",{class:"zx-button zx-button--sm"},g("fields",{size:13}),"Columns"),t);return this._renderColumnControls(),e}_renderColumnControls(t=null){if(!this._columnList)return;let e=this._visibleColumns(),i=this._columns.map((n,r)=>{let o=!this._hiddenColumns.has(n.id),a=this._columnControlIds.get(n.id);a||(a=x("zx-table-column"),this._columnControlIds.set(n.id,a));let c=this.options.columnVisibility?l("input",{id:a,class:"zx-table__column-toggle",type:"checkbox",value:n.id,checked:o,disabled:o&&e.length===1,dataset:{columnId:n.id,columnAction:"toggle"}}):null,h=c?l("label",{for:a},c,l("span",{},n.label)):l("span",{class:"zx-table__column-label"},n.label),d=this.options.columnReorder?l("span",{class:"zx-table__column-order",role:"group",ariaLabel:`Move ${n.label}`},l("button",{class:"zx-table__column-move",type:"button",disabled:r===0,ariaLabel:`Move ${n.label} earlier`,dataset:{columnId:n.id,columnAction:"up"}},g("chevron-up",{size:11})),l("button",{class:"zx-table__column-move",type:"button",disabled:r===this._columns.length-1,ariaLabel:`Move ${n.label} later`,dataset:{columnId:n.id,columnAction:"down"}},g("chevron-down",{size:11}))):null;return l("div",{class:"zx-table__column-option",dataset:{columnId:n.id}},h,d)});if(this._columnList.replaceChildren(...i,this._columnStatus),t!==null){let n=[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===t.id&&o.dataset.columnAction===t.action});n?.disabled&&(n=[...this._columnList.querySelectorAll(".zx-table__column-move[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===t.id&&!o.disabled})??[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===t.id&&!o.disabled})),queueMicrotask(()=>{n?.isConnected&&n.focus()})}}_activeColumnControl(){let t=typeof document>"u"?null:document.activeElement;if(!t||!this._columnList?.contains(t))return null;let e=t.dataset.columnId,i=t.dataset.columnAction;return e&&i?{id:e,action:i}:null}_handleColumnControlClick(t){let e=t.target?.closest?.(".zx-table__column-move");if(!e||!this._columnList?.contains(e))return;let i=e.dataset.columnId,n=e.dataset.columnAction,r=this.getColumnOrder().indexOf(String(i));n==="up"&&r>0&&this.moveColumn(String(i),this._columns[r-1].id,"before"),n==="down"&&r>=0&&r<this._columns.length-1&&this.moveColumn(String(i),this._columns[r+1].id,"after")}_handleColumnControlKeydown(t){let e=t.target?.closest?.(".zx-table__column-move");if(!e||!this._columnList?.contains(e))return;let i=String(e.dataset.columnId),n=this.getColumnOrder(),r=n.indexOf(i);r<0||(t.key==="ArrowUp"||t.key==="ArrowLeft"?(t.preventDefault(),r>0&&this.moveColumn(i,n[r-1],"before")):t.key==="ArrowDown"||t.key==="ArrowRight"?(t.preventDefault(),r<n.length-1&&this.moveColumn(i,n[r+1],"after")):t.key==="Home"?(t.preventDefault(),r>0&&this.moveColumn(i,n[0],"before")):t.key==="End"&&(t.preventDefault(),r<n.length-1&&this.moveColumn(i,n.at(-1),"after")))}_handleRowDragStart(t){let e=t.target?.closest?.(".zx-table__row-handle"),i=e?.closest("tr[data-row]"),n=i?this._rowMeta.get(i):null;if(!e||!n||this._sort&&this.options.sortMode==="local"){t.preventDefault();return}this._dragId=n.id,i.dataset.dragging="true",t.dataTransfer?.setData("text/plain","zx-table-row"),t.dataTransfer&&(t.dataTransfer.effectAllowed="move")}_handleRowDragOver(t){if(this._dragId==null)return;let e=t.target?.closest?.("tr[data-row]"),i=e?this._rowMeta.get(e):null;if(!i||Object.is(i.id,this._dragId)||!this._canMoveTogether(this._dragId,i.id))return;t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._clearDropMarkers();let n=e.getBoundingClientRect();e.dataset.drop=t.clientY>=n.top+n.height/2?"after":"before"}_handleRowDrop(t){if(this._dragId==null)return;let e=t.target?.closest?.("tr[data-row]"),i=e?this._rowMeta.get(e):null,n=e?.dataset.drop==="after"?"after":"before";i&&this._canMoveTogether(this._dragId,i.id)&&(t.preventDefault(),this.moveRow(this._dragId,i.id,n)),this._clearRowDrag()}_handleRowHandleKeydown(t){let e=t.target?.closest?.(".zx-table__row-handle"),i=e?.closest("tr[data-row]"),n=i?this._rowMeta.get(i):null;if(!e||!n)return;if(t.key===" "||t.key==="Enter"){t.preventDefault(),this._grabbedId=Object.is(this._grabbedId,n.id)?null:n.id,e.setAttribute("aria-pressed",String(this._grabbedId!=null));let c=this._rowMoveMessage??this._editMessage;c&&(c.textContent=this._grabbedId==null?"Row dropped":"Row grabbed. Use the arrow keys to move it.");return}if(t.key==="Escape"&&this._grabbedId!=null){t.preventDefault(),this._grabbedId=null,e.setAttribute("aria-pressed","false");return}if(!Object.is(this._grabbedId,n.id)||!["ArrowUp","ArrowDown"].includes(t.key))return;t.preventDefault();let r=this._siblingIds(n.id),o=r.findIndex(c=>Object.is(c,n.id)),a=r[o+(t.key==="ArrowUp"?-1:1)];a!==void 0&&this.moveRow(n.id,a,t.key==="ArrowUp"?"before":"after")}_siblingIds(t){let e=this.getRow(t);if(!e)return[];let i=this._hierarchy?ct(this._hierarchy.parentId,e):null;return this._data.filter(n=>!this._hierarchy||fn(ct(this._hierarchy.parentId,n),i)).map(n=>this._idFor(n))}_canMoveTogether(t,e){if(!this._hierarchy)return!0;let i=this.getRow(t),n=this.getRow(e);return!!(i&&n&&fn(ct(this._hierarchy.parentId,i),ct(this._hierarchy.parentId,n)))}_rowHandle(t){return this._rowElements.get(t)?.[0]?.querySelector(".zx-table__row-handle")??null}_clearDropMarkers(){for(let t of this._tbody.querySelectorAll("tr[data-drop]"))delete t.dataset.drop}_clearRowDrag(){for(let t of this._tbody.querySelectorAll("tr[data-dragging]"))delete t.dataset.dragging;this._clearDropMarkers(),this._dragId=null}_hierarchyColumn(){return this._hierarchy?this._visibleColumns().some(t=>t.id===this._hierarchy.column)?this._hierarchy.column:this._visibleColumns()[0]?.id??null:null}_renderColumns(){let t=document.createDocumentFragment();this.options.rowReorder&&t.append(l("col",{class:"zx-table__reorder-column"})),this.options.selectable==="multi"&&t.append(l("col",{class:"zx-table__selection-column"}));let e=this._visibleColumns(),i=e.map(r=>Ru(r.width)),n=i.reduce((r,o)=>r+o,0);this._table.dataset.layout=n>0?"fixed":"auto",e.forEach((r,o)=>{let a=l("col");i[o]>0?a.style.width=`${i[o]/n*100}%`:r.width&&r.width!=="auto"&&(a.style.width=String(r.width)),t.append(a)}),this._colgroup.replaceChildren(t)}_renderHeader(){let t=l("tr",{class:"zx-table__header-row"});if(this._growStep&&t.setAttribute("aria-rowindex","1"),this.options.rowReorder&&t.append(l("th",{class:"zx-table__reorder-header",scope:"col",ariaLabel:"Row order"})),this.options.selectable==="multi"){this._selectAll=l("input",{class:"zx-table__checkbox zx-table__select-all",type:"checkbox",ariaLabel:"Select all rows"});let e=l("th",{class:"zx-table__selection-header",scope:"col"},this._selectAll);t.append(e),this.listen(this._selectAll,"click",()=>{if(this._selectAll.checked)for(let i of this._visibleData())this._selected.add(this._idFor(i));else for(let i of this._visibleData())this._selected.delete(this._idFor(i));this._selectionAnchorId=null,this._syncSelection(),this._emitSelectionChange()})}else this._selectAll=null;this._headers=new Map;for(let e of this._visibleColumns()){let i=l("th",{scope:"col"}),n=e.align??(un(e)?"end":null);if(n&&(i.dataset.align=n),e.headerTitle&&(i.title=e.headerTitle),e.sortable){let r=l("button",{class:"zx-table__sort-button",type:"button"},l("span",{class:"zx-table__header-label"},e.label));this.listen(r,"click",()=>{let o=this._sort?.id===e.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(e.id,o)}),i.append(r)}else i.append(l("span",{class:"zx-table__header-label"},e.label));this._headers.set(e.id,i),t.append(i)}this._thead.replaceChildren(t),this._syncSortHeader()}_renderBody(){this._abortEdit({focus:!1});let t=document.createDocumentFragment();this._rowMeta=new WeakMap,this._rowElements=new Map,this._rovingCell=null,this._rovingMatched=!1;let e=this._projectedData();this._hierarchyMeta=new Map(e.map(i=>[i.id,i])),this._data.length===0?t.append(l("tr",{class:"zx-table__empty-row"},l("td",{class:"zx-table__empty",colspan:this._visibleColumns().length+(this.options.selectable==="multi"?1:0)+(this.options.rowReorder?1:0)},this._emptyContent()))):this._visibleEntries().forEach((i,n)=>{t.append(this._createRow(i.row,i.index,{...i,visibleIndex:n}))}),this._tbody.replaceChildren(t),this._table.setAttribute("aria-colcount",String(this._visibleColumns().length+(this.options.selectable==="multi"?1:0)+(this.options.rowReorder?1:0))),this._growStep&&this._table.setAttribute("aria-rowcount",String(e.length+1)),this._syncSelectAll(),this._syncGrowing(),this._stacked&&this._applyStackedRoles(!0)}_emptyContent(){let t=this.options.emptyText;return t==null?this.msg("table.empty"):typeof t=="function"?t():t}_createRow(t,e,i){let n=this._idFor(t),r=l("tr",{dataset:{row:""}});this._growStep&&r.setAttribute("aria-rowindex",String(i.visibleIndex+2));let o=typeof this.options.rowClass=="function"?this.options.rowClass(t):"";o&&r.classList.add(...String(o).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&r.setAttribute("aria-selected",String(this._selected.has(n))),this._hierarchy&&(r.setAttribute("aria-level",String(i.depth+1)),i.hasChildren&&r.setAttribute("aria-expanded",String(this._expanded.has(n)))),this._rowMeta.set(r,{row:t,id:n,index:e,visibleIndex:i.visibleIndex});let a=this._rowElements.get(n)??[];if(a.push(r),this._rowElements.set(n,a),this.options.rowReorder){let c=l("button",{class:"zx-table__row-handle",type:"button",draggable:!0,dataset:{rowHandle:""},ariaLabel:`Move row ${e+1}`,ariaPressed:String(Object.is(this._grabbedId,n)),disabled:!!(this._sort&&this.options.sortMode==="local"),title:this._sort&&this.options.sortMode==="local"?"Clear sorting to reorder rows":null},g("drag",{size:14}));r.append(l("td",{class:"zx-table__reorder-cell"},c))}if(this.options.selectable==="multi"){let c=l("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",checked:this._selected.has(n),ariaLabel:`Select row ${e+1}`});r.append(l("td",{class:"zx-table__selection-cell"},c))}return this._visibleColumns().forEach(c=>{let h=l("td"),d=c.align??(un(c)?"end":null);d&&(h.dataset.align=d),h.dataset.label=c.label,c.popin===!1&&(h.dataset.popin="false"),this._editMode!==!1&&(h.dataset.column=c.id,fe(c,t)!==!1&&(h.dataset.editable="true",h.tabIndex=-1,this._offerRovingCell(h,n,c.id))),this._renderCellContent(h,c,t,e,i),r.append(h)}),r}_renderCellContent(t,e,i,n,r=this._hierarchyMeta?.get(this._idFor(i))){let o=pn(e,i,n),a=l("span",{class:"zx-table__cell-content"});if(o&&typeof o=="object"&&typeof o.nodeType=="number"?a.append(o):o!=null&&a.append(document.createTextNode(String(o))),!this._hierarchy||e.id!==this._hierarchyColumn()||!r){t.replaceChildren(...a.childNodes);return}let c=l("span",{class:"zx-table__tree-cell"});if(c.style.setProperty("--zx-table-depth",String(r.depth)),r.hasChildren){let h=this._expanded.has(r.id);c.append(l("button",{class:"zx-table__tree-toggle",type:"button",ariaExpanded:String(h),ariaLabel:`${h?"Collapse":"Expand"} row ${n+1}`},g(h?"chevron-down":"chevron-right",{size:14})))}else c.append(l("span",{class:"zx-table__tree-spacer",ariaHidden:"true"}));c.append(a),t.replaceChildren(c)}_handleBodyClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(this._edit&&Li(e))return;let i=e?.closest("tr[data-row]");if(!i||!this._tbody.contains(i))return;let n=this._rowMeta.get(i);if(!n||e.closest(".zx-table__row-handle")||this._edit&&(this.commitEdit(),this._edit))return;if(e.closest(".zx-table__tree-toggle")){this.toggleRow(n.id);return}let o=e.closest(".zx-table__row-checkbox");if(o&&this.options.selectable==="multi"){this._toggleMultiSelection(n,o.checked,t.shiftKey);return}if(!Va(e)){if(this._editMode!==!1&&this._editTrigger==="single"){let a=e?.closest('td[data-editable="true"]');if(a&&this._tbody.contains(a)){this.startEdit(n.id,String(a.dataset.column));return}}this.emit("rowclick",{...n,event:t}),this.options.selectable==="single"&&!this._selected.has(n.id)&&(this._selected=new Set([n.id]),this._selectionAnchorId=n.id,this._syncSelection(),this._emitSelectionChange())}}_handleBodyDoubleClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(e?.closest(".zx-table__row-checkbox")||this._edit&&Li(e))return;let i=e?.closest("tr[data-row]");if(!i||!this._tbody.contains(i))return;let n=this._rowMeta.get(i);if(n&&!Va(e)){if(this._editMode!==!1&&this._editTrigger==="double"){let r=e?.closest('td[data-editable="true"]');if(r&&this._tbody.contains(r)){this.startEdit(n.id,String(r.dataset.column));return}}this.emit("rowdblclick",{...n,event:t})}}_createEditor(t,e,i,n){let r=fe(e,i);if(r===!1)return null;let o=i?.[e.id],a=e.editorProps&&typeof e.editorProps=="object"?e.editorProps:{},c=l("span",{class:"zx-table__cell-shadow",ariaHidden:"true"});c.append(...t.childNodes);let h=l("div",{class:"zx-table__editor",dataset:{editor:r}});t.replaceChildren(c,h),t.dataset.editing="true";let d={column:e,type:r,td:t,host:h,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(r==="custom"){d.custom=o,d.read=()=>Jt(e,d.custom,i);let f={value:o,row:i,column:e,commit:m=>{d.custom=m,this.commitEdit()},cancel:()=>this.cancelEdit()},_=e.editor(i,f);return _&&typeof _.toElement=="function"?(typeof _.destroy=="function"&&(d.component=_),h.append(_.toElement())):_&&h.append(_),d.control=h.querySelector(Su)??h,d}if(r==="number"){let f=Zt(e.locale,i),_=Ka(e,i),m=e.type==="currency"?Zt(e.currency,i):e.type==="unit"?Zt(e.unit,i):null,w={...f!=null&&!Object.prototype.hasOwnProperty.call(a,"locale")?{locale:f}:{},..._!=null&&!Object.prototype.hasOwnProperty.call(a,"precision")?{precision:_}:{},...m!=null&&!Object.prototype.hasOwnProperty.call(a,"unit")?{unit:String(m)}:{}},y=new Wt(null,{...w,...a,value:o??null});return h.append(y.el),d.component=y,d.control=y.getInput(),d.read=()=>(y.set(y.getInput().value,{silent:!0}),Jt(e,y.get(),i)),d}if(r==="select"){let f=zu(e.options,i),_=f.find(w=>Object.is(w.value,o))??f.find(w=>String(w.value)===String(o??"")),m=new G(null,{...a,items:f,valueKey:"value",labelKey:"label",value:_?_.value:null});return h.append(m.el),d.component=m,d.control=m.refs.input,d.read=()=>Jt(e,m.value,i),d}if(r==="date"){let f=new Z(null,{...a,value:o??null});h.append(f.el),d.component=f;let _=f.refs.input;return d.control=_,d.read=()=>{let m=String(_.value??"").trim(),w=f.get();return m===""?Jt(e,null,i):(f.set(m,{silent:!0}),f.get()===null&&f.set(w,{silent:!0}),Jt(e,f.get(),i))},d}if(r==="checkbox"){let f=new nt(null,{...a,checked:!!o});return h.append(f.el),d.component=f,d.control=f.el,d.read=()=>Jt(e,f.get(),i),d}let u=r==="textarea",p=l(u?"textarea":"input",{...a,class:u?"zx-table__editor-input zx-table__editor-textarea":"zx-table__editor-input",...u?{}:{type:"text"},ariaLabel:a.ariaLabel??`${e.label} row ${n+1}`,value:Cu(e,o,i)});return h.append(p),d.control=p,d.read=()=>Jt(e,p.value,i),d}_focusEditor(t){let e=this._edit?.cells.get(t),i=e?.control;!i||typeof i.focus!="function"||(i.focus(),e.type==="text"&&typeof i.select=="function"&&i.select())}_focusCell(t,e){let i=this._rowElements.get(t)?.[0];(i?Ha(i,e):null)?.focus()}_teardownEdit(){let t=this._edit;if(!t)return;this._edit=null;let e=this._data.findIndex(n=>Object.is(this._idFor(n),t.id)),i=e<0?t.row:this._data[e];for(let n of t.cells.values())n.destroy(),delete n.td.dataset.editing,delete n.td.dataset.invalid,this._renderCellContent(n.td,n.column,i,e<0?0:e);t.cells.clear(),delete t.tr.dataset.editing,this._clearInvalid()}_abortEdit({focus:t=!0}={}){let e=this._edit;if(!e)return;let i=t&&this._editHasFocus(),n=this.getRow(e.id)??e.row,r=this._columns.find(o=>o.id===e.columnId)??null;this._teardownEdit(),i&&this._focusCell(e.id,e.columnId),this.emit("editcancel",{row:n,id:e.id,column:r,columnId:e.columnId})}_editHasFocus(){let t=document.activeElement;return!!(t&&this.el?.contains(t))}_markInvalid(t,e){this._clearInvalid();let i=this._edit?.cells.get(t);i&&(i.td.dataset.invalid="true",i.control?.setAttribute("aria-invalid","true"),this._editMessage&&(i.control?.setAttribute("aria-describedby",this._editMessage.id),this._editMessage.textContent=e))}_clearInvalid(){if(this._edit)for(let t of this._edit.cells.values())delete t.td.dataset.invalid,t.control?.removeAttribute("aria-invalid"),t.control?.removeAttribute("aria-describedby");this._editMessage&&(this._editMessage.textContent="")}_handleEditKeydown(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(!e)return;if(this._edit&&Li(e)){if(Nu(e))return;if(t.key==="Escape"){if(t.defaultPrevented)return;t.preventDefault(),this.cancelEdit();return}if(t.key==="Enter"){if(e.localName==="textarea"&&t.shiftKey)return;t.preventDefault(),this.commitEdit();return}t.key==="Tab"&&this._moveEdit(t);return}if(t.key!=="Enter"&&t.key!=="F2")return;let i=e.closest('td[data-editable="true"]');if(!i||!this._tbody.contains(i))return;let n=this._rowMeta.get(i.parentElement);n&&(t.preventDefault(),this.startEdit(n.id,String(i.dataset.column)))}_moveEdit(t){let e=this._edit;if(!e)return;let i=t.shiftKey?-1:1,n=this._data.findIndex(o=>Object.is(this._idFor(o),e.id)),r=this._nextEditableCell(n,e.columnId,i);if(r&&Object.is(r.id,e.id)&&e.cells.has(r.columnId)){t.preventDefault(),e.columnId=r.columnId,this._focusEditor(r.columnId);return}if(!r){this.commitEdit(),this._edit&&t.preventDefault();return}t.preventDefault(),this.commitEdit(),this._edit||this.startEdit(r.id,r.columnId)}_nextEditableCell(t,e,i){let n=this._visibleColumns(),r=n.length;if(t<0||r===0)return null;let o=this._visibleData(),a=this._idFor(this._data[t]),c=o.findIndex(u=>Object.is(this._idFor(u),a));if(c<0)return null;let h=n.findIndex(u=>u.id===e),d=o.length*r+r;for(let u=0;u<d;u+=1){if(h+=i,h>=r?(c+=1,h=0):h<0&&(c-=1,h=r-1),c<0||c>=o.length)return null;let p=o[c],f=n[h];if(fe(f,p)!==!1)return{id:this._idFor(p),columnId:f.id,index:this._data.indexOf(p)}}return null}_handleEditFocusIn(t){let i=(t.target?.nodeType===1?t.target:null)?.closest('td[data-editable="true"]');if(!i||!this._tbody.contains(i))return;let n=this._rowMeta.get(i.parentElement);n&&this._setRovingCell(i,n.id,String(i.dataset.column))}_handleDocumentPointerDown(t){if(!this._edit)return;let e=t.target?.nodeType===1?t.target:t.target?.parentElement;e&&Li(e)||e&&this._tbody.contains(e)||this.commitEdit()}_offerRovingCell(t,e,i){if(this._rovingMatched)return;let n=this._rovingKey!==null&&Object.is(this._rovingKey.id,e)&&this._rovingKey.columnId===i;!n&&this._rovingCell||(n&&this._rovingCell&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=n)}_setRovingCell(t,e,i){this._rovingCell&&this._rovingCell!==t&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=!0,this._rovingKey={id:e,columnId:i}}_msgOr(t,e){let i=this.msg(t);return i===t?e:i}_toggleMultiSelection(t,e,i){let n=this._visibleData(),r=n.findIndex(o=>Object.is(this._idFor(o),this._selectionAnchorId));if(i&&r>=0){let o=t.visibleIndex??n.findIndex(h=>Object.is(this._idFor(h),t.id)),a=Math.min(r,o),c=Math.max(r,o);for(let h=a;h<=c;h+=1){let d=this._idFor(n[h]);e?this._selected.add(d):this._selected.delete(d)}}else e?this._selected.add(t.id):this._selected.delete(t.id);this._selectionAnchorId=t.id,this._syncSelection(),this._emitSelectionChange()}_syncSelection(){for(let[t,e]of this._rowElements){let i=this._selected.has(t);for(let n of e){n.setAttribute("aria-selected",String(i));let r=n.querySelector(".zx-table__row-checkbox");r&&(r.checked=i)}}this._syncSelectAll()}_syncSelectAll(){if(!this._selectAll)return;let t=this._visibleData(),e=t.reduce((i,n)=>i+Number(this._selected.has(this._idFor(n))),0);this._selectAll.disabled=t.length===0,this._selectAll.checked=t.length>0&&e===t.length,this._selectAll.indeterminate=e>0&&e<t.length}_syncSortHeader(){if(this._headers)for(let[t,e]of this._headers)this._sort?.id===t?e.setAttribute("aria-sort",this._sort.dir==="asc"?"ascending":"descending"):e.removeAttribute("aria-sort")}_sortData(){if(!this._sort)return;let t=this._columns.find(i=>i.id===this._sort.id);if(!t)return;let e=typeof t.sortValue=="function"?t.sortValue:i=>i?.[t.id];this._data=this._hierarchy?Au(this._data,this.options.rowId,this._hierarchy.parentId,e,this._sort.dir):Xe(this._data,e,this._sort.dir)}_setRowExpanded(t,e,i){return this._hierarchy?Ri(this._data,this.options.rowId,this._hierarchy.parentId).some(r=>Object.is(r,t))?this._expanded.has(t)===e?this:(e?this._expanded.add(t):this._expanded.delete(t),this._renderBody(),i.silent||this._emitRowToggle(t,e),this):this:this}_emitRowToggle(t,e){let i=this.getRow(t);i&&this.emit("rowtoggle",{row:i,id:t,expanded:e})}_reconcileExpanded(){if(!this._hierarchy){this._expanded.clear();return}let t=Ri(this._data,this.options.rowId,this._hierarchy.parentId),e=new Set(t);for(let i of this._expanded)e.has(i)||this._expanded.delete(i)}_pruneSelection(){let t=new Set(this._data.map(i=>this._idFor(i))),e=this._selected.size;for(let i of this._selected)t.has(i)||this._selected.delete(i);return t.has(this._selectionAnchorId)||(this._selectionAnchorId=null),e!==this._selected.size}_idFor(t){return typeof this.options.rowId=="function"?this.options.rowId(t):t?.[this.options.rowId]}_emitSelectionChange(){let t=this.getSelection();this.emit("selectionchange",{rows:t,ids:t.map(e=>this._idFor(e))})}_emitDataChange(){this.emit("datachange",{rows:this.getData()})}};function pn(s,t,e=0){if(typeof s?.render=="function")return s.render(t,e);let i=t?.[s?.id],n=s?.type??"text";if(n==="text")return i;let r=Zt(s.locale,t),o=Ka(s,t),a={...r!=null?{locale:String(r)}:{},...o!=null?{decimals:o}:{}};if(n==="number")return Qt(i,a);if(n==="currency"){let c=Zt(s.currency,t);return on(i,c==null?null:String(c),a)}if(n==="percent")return an(i,a);if(n==="unit"){let c=Qt(i,a),h=Zt(s.unit,t);return c&&h!=null&&String(h)!==""?`${c}\xA0${h}`:c}return i}function ku(s,t,e,i=[]){let n=Vi(s,t,e),r=i instanceof Set?i:new Set(i),o=[],a=n.roots.slice().reverse().map(c=>({node:c,depth:0}));for(;a.length;){let{node:c,depth:h}=a.pop();if(o.push({row:c.row,id:c.id,index:c.index,depth:h,hasChildren:c.children.length>0,parentId:c.parent?.id??null}),!!r.has(c.id))for(let d=c.children.length-1;d>=0;d-=1)a.push({node:c.children[d],depth:h+1})}return o}function Au(s,t,e,i,n){let r=Vi(s,t,e),o=h=>Xe(h,d=>i(d.row),n),a=[],c=o(r.roots).reverse();for(;c.length;){let h=c.pop();a.push(h.row);let d=o(h.children);for(let u=d.length-1;u>=0;u-=1)c.push(d[u])}return a}function $a(s,t,e,i,n="before",r=null){if(!Array.isArray(s)||Object.is(e,i))return null;let o=s.findIndex(u=>Object.is(ct(t,u),e)),a=s.findIndex(u=>Object.is(ct(t,u),i));if(o<0||a<0||r&&!fn(ct(r,s[o]),ct(r,s[a])))return null;if(r){let u=Vi(s,t,r),p=u.nodes[o],f=u.nodes[a];if(!p||!f||p.parent!==f.parent)return null;let _=T=>{let I=[],et=[T];for(;et.length;){let E=et.pop();I.push(E);for(let Q=E.children.length-1;Q>=0;Q-=1)et.push(E.children[Q])}return I},m=new Set(_(p).map(T=>T.index)),w=new Set(_(f).map(T=>T.index)),y=s.filter((T,I)=>m.has(I)),v=s.filter((T,I)=>!m.has(I)),S=s.map((T,I)=>I).filter(T=>!m.has(T)),z=S.findIndex(T=>T===a);if(n==="after"){let T=S.map((I,et)=>w.has(I)?et:-1).filter(I=>I>=0);z=Math.max(...T)+1}return z<0?null:(v.splice(z,0,...y),v)}let c=[...s],[h]=c.splice(o,1),d=c.findIndex(u=>Object.is(ct(t,u),i));return c.splice(d+(n==="after"?1:0),0,h),c}function fe(s,t){if(!s||typeof s!="object")return!1;if(typeof s.editor=="function")return typeof s.editable=="function"&&s.editable(t)===!1?!1:"custom";let e=typeof s.editable=="function"?s.editable(t):s.editable;return e===!0?un(s)?"number":"text":typeof e=="string"&&xu.has(e)?e:!1}function zu(s,t){let e=typeof s=="function"?s(t):s;return Array.isArray(e)?e.map(i=>i!==null&&typeof i=="object"?{value:i.value,label:String(i.label??i.value??"")}:{value:i,label:String(i??"")}):e!==null&&typeof e=="object"?Object.entries(e).map(([i,n])=>({value:i,label:String(n??"")})):[]}function Cu(s,t,e){if(typeof s?.format=="function"){let i=s.format(t,e);return i==null?"":String(i)}return t==null?"":String(t)}function Jt(s,t,e){return typeof s?.parse=="function"?s.parse(t,e):t}function Tu(s,t){return Object.is(s,t)?!0:s instanceof Date&&t instanceof Date?s.getTime()===t.getTime():!1}function Du(s,t){let e={};for(let[i,n]of Object.entries(t??{}))Tu(s?.[i],n)||(e[i]=n);return e}function Iu(s,t,e,i="Invalid value"){for(let n of t??[]){if(typeof n?.validate!="function"||!Object.prototype.hasOwnProperty.call(s??{},n.id))continue;let r=n.validate(s[n.id],e);if(typeof r=="string")return{columnId:n.id,message:r};if(r===!1)return{columnId:n.id,message:i}}return null}function Zt(s,t){return typeof s=="function"?s(t):s}function Ka(s,t){let e=Zt(s?.decimals,t);if(e==null)return null;let i=Number(e);return Number.isFinite(i)?Math.max(0,Math.trunc(i)):null}function un(s){return["number","currency","percent","unit"].includes(s?.type)}function Vi(s,t,e){let i=(Array.isArray(s)?s:[]).map((a,c)=>({row:a,id:ct(t,a),index:c,parent:null,children:[]})),n=new Map;for(let a of i)n.has(a.id)||n.set(a.id,a);let r=new Map;for(let a of i){let c=ct(e,a.row),h=c==null?null:n.get(c)??null;r.set(a,h===a?null:h)}for(let a of i){let c=new Set([a]),h=r.get(a)??null;for(;h;){if(c.has(h)){r.set(h,null);break}c.add(h),h=r.get(h)??null}}let o=[];for(let a of i)a.parent=r.get(a)??null,a.parent?a.parent.children.push(a):o.push(a);return{roots:o,nodes:i}}function Ri(s,t,e){return Vi(s,t,e).nodes.filter(i=>i.children.length>0).map(i=>i.id)}function ct(s,t){return typeof s=="function"?s(t):t?.[s]}function fn(s,t){return s==null&&t==null||Object.is(s,t)}function dn(s,t){if(!s||typeof s!="object")return null;let e=s.parentId;if(typeof e!="string"&&typeof e!="function")return null;let i=typeof s.column=="string"?s.column:null,n=t.some(r=>r.id===i)?i:t[0]?.id;return n?{...s,parentId:e,column:n}:null}function Eu(s){return new Set(Array.isArray(s)?s:[])}function Mu(s){return s==="cell"||s==="row"?s:s===!0?"cell":!1}function Li(s){return!!s?.closest?.(".zx-table__editor")}function Va(s){let t=s?.closest?.("td[data-column]"),e=s?.closest?.(["a[href]","button","input","select","textarea","summary",'[contenteditable="true"]','[role="button"]','[role="link"]','[tabindex]:not([tabindex="-1"])',"[data-zx-table-no-edit]"].join(","));return!!(t&&e&&e!==t&&t.contains(e))}function Nu(s){return s.closest("[popover]")?!0:s.getAttribute?.("aria-expanded")==="true"}function Ba(s){if(!Array.isArray(s))throw new TypeError("Table columns must be an array");let t=new Set;return s.map((e,i)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError(`Table column at index ${i} must be an object`);let n=String(e.id??"").trim();if(!n)throw new TypeError(`Table column at index ${i} requires an id`);if(t.has(n))throw new TypeError(`Duplicate table column: ${n}`);return t.add(n),{...e,id:n,label:String(e.label??n)}})}function Ou(s,t){let e=s.map(a=>a.id),i=new Set(e),n=Array.isArray(t)?t.map(String):[],r=new Set,o=[];for(let a of n)i.has(a)&&!r.has(a)&&(r.add(a),o.push(a));for(let a of e)r.has(a)||o.push(a);return o}function Fu(s,t,e,i="before"){let n=[...s],r=n.indexOf(t),o=n.indexOf(e);if(r<0||o<0||r===o)return n;n.splice(r,1);let a=n.indexOf(e)+(i==="after"?1:0);return n.splice(a,0,t),n}function Ha(s,t){for(let e of s.cells)if(e.dataset.column===t)return e;return null}function qa(s,t){return!s||typeof s!="object"||!t.some(e=>e.id===s.id)?null:{id:s.id,dir:s.dir==="desc"?"desc":"asc"}}function Ru(s){if(typeof s!="string")return 0;let t=/^(\d*\.?\d+)fr$/.exec(s.trim());return t?Math.max(0,Number(t[1])):0}function ja(s){if(!Array.isArray(s))throw new TypeError("Table data must be an array")}function Lu(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}function Pi(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function Pu(s){let t=Math.trunc(Number(s));return Number.isFinite(t)&&t>0?t:null}var ht=Symbol("invalid attribute");function pe(s,t="string",e=console.warn){if(Ua(t),t==="boolean")return s!==null;if(s!==null){if(t==="string")return s;if(t==="number"){let i=Number(s);return Number.isFinite(i)?i:(e(`Ignoring invalid number attribute: ${JSON.stringify(s)}`),ht)}try{return JSON.parse(s)}catch{return e(`Ignoring invalid JSON attribute: ${JSON.stringify(s)}`),ht}}}function _n(s,t="string",e=console.warn){if(Ua(t),t==="boolean")return s?"":null;if(s==null)return null;if(t==="number"){let i=Number(s);return Number.isFinite(i)?String(i):(e(`Ignoring invalid number property: ${String(s)}`),ht)}if(t==="json"){try{let i=JSON.stringify(s);if(i!==void 0)return i}catch{}return e("Ignoring property that cannot be serialized as JSON"),ht}return String(s)}function Ua(s){if(!["string","number","boolean","json"].includes(String(s)))throw new TypeError(`Unknown reflected attribute type: ${String(s)}`)}var Vu=Object.freeze(["change","input","submit","clear","open","close","cancel","invalid","query","loaded","rowclick","rowdblclick","sort","selectionchange","datachange"]),Bu=dt({checked:L({always:!0,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),value:M({default:!0}),label:M({default:null,rebuild:!0}),disabled:L({always:!0,set:Je})}),Hu=dt({checked:L({always:!0,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),value:M({option:null,default:"on"}),label:M({default:"",set:(s,t)=>s.setLabel(t)}),icon:L({rebuild:!0}),disabled:L({always:!0,set:Je})}),qu=dt({items:It({default:[],set:(s,t)=>s.setItems(t)}),value:M({default:null,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.value}),"value-key":M({property:"valueKey",default:"ID",rebuild:!0}),"label-key":M({property:"labelKey",default:"name",rebuild:!0}),placeholder:M({default:"",set:(s,t)=>{s.refs.input.placeholder=t}}),clearable:L({default:!1,rebuild:!0}),filter:M({default:!1,normalize:sf,rebuild:!0}),"search-keys":It({property:"searchKeys",default:null,rebuild:!0}),"min-query":_e({property:"minQuery",default:0,rebuild:!0}),debounce:_e({default:200,rebuild:!0}),"list-height":_e({property:"listHeight",default:280,rebuild:!0}),disabled:L({always:!0,set:Je}),required:L({option:null,always:!0}),name:M({option:null,default:""})}),ju=dt({items:It({default:[],set:(s,t)=>s.setItems(t)}),value:It({option:null,default:[],set:(s,t)=>s.setValues(t),get:s=>s.getValues()}),"value-key":M({property:"valueKey",default:"ID",rebuild:!0}),"label-key":M({property:"labelKey",default:"name",rebuild:!0}),"checked-key":M({property:"checkedKey",default:"on",rebuild:!0}),search:L({rebuild:!0}),height:_e({default:280,rebuild:!0}),"default-checked":L({property:"defaultChecked",default:!1,rebuild:!0}),disabled:L({option:null,always:!0,set:ef}),name:M({option:null,default:""})}),$u=dt({format:M({default:"%d.%m.%Y",rebuild:!0}),time:L({always:!0,rebuild:!0}),value:M({option:null,default:null,normalize:af,set:(s,t)=>s.set(t,{silent:!0}),get:(s,t)=>gn(s.get(),!!t.time),serialize:lf}),placeholder:M({default:null,rebuild:!0}),clearable:L({rebuild:!0}),disabled:L({always:!0,set:Je}),required:L({option:null,always:!0}),name:M({option:null,default:""})}),Ku=dt({value:_e({default:0,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),unit:M({default:"minutes",rebuild:!0}),seconds:L({always:!0,rebuild:!0}),signed:L({always:!0,rebuild:!0}),disabled:L({always:!0,set:Je}),name:M({option:null,default:""})}),Uu=dt({value:M({default:"",set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),placeholder:M({default:"",set:(s,t)=>{s.refs.input.placeholder=t}}),clearable:L({rebuild:!0}),debounce:_e({default:250,rebuild:!0})}),Yu=dt({title:M({default:"",set:(s,t)=>s.setTitle(t)}),open:L({default:!1,always:!0,set:(s,t)=>t?s.open():s.close(),get:s=>s.isOpen()})}),Wu=dt({tabs:It({default:[],normalize:rf,rebuild:!0}),active:M({default:null,set:(s,t)=>{t!==null&&s.openTab(t)},get:s=>s.getActive()}),variant:M({default:"divided",rebuild:!0}),"keep-alive":L({property:"keepAlive",rebuild:!0})}),Gu=dt({columns:It({default:[],rebuild:!0}),data:It({default:[],set:(s,t)=>s.setData(t),get:s=>s.getData()}),"row-id":M({property:"rowId",default:"ID",rebuild:!0}),sort:It({default:null,rebuild:!0}),"sort-mode":M({property:"sortMode",default:"local",rebuild:!0}),selectable:M({default:!1,normalize:nf,rebuild:!0}),"sticky-header":L({property:"stickyHeader",rebuild:!0}),height:M({default:null,normalize:Ga,rebuild:!0}),"empty-text":M({property:"emptyText",default:null,rebuild:!0}),zebra:L({rebuild:!0})}),Qu=dt({title:M({default:"",set:(s,t)=>s.setTitle(t)}),size:M({default:"md",normalize:Ga,rebuild:!0}),buttons:It({default:[],set:(s,t)=>s.setButtons(t)}),closable:L({rebuild:!0}),open:L({option:null,default:!1,always:!0,set:(s,t)=>t?s.open():s.close(),get:s=>s.isOpen()})}),Xu=Object.freeze([["toggle",nt,{formAssociated:!0,attrs:Bu}],["check-button",Vt,{formAssociated:!0,attrs:Hu}],["select",G,{formAssociated:!0,attrs:qu}],["checklist",wt,{formAssociated:!0,attrs:ju}],["datebox",Z,{formAssociated:!0,attrs:$u}],["timebox",Tt,{formAssociated:!0,attrs:Ku}],["search",Ge,{formAssociated:!1,attrs:Uu}],["groupbox",Xt,{formAssociated:!1,attrs:Yu}],["tabbox",Qe,{formAssociated:!1,attrs:Wu}],["table",Dt,{formAssociated:!1,attrs:Gu}],["dialog",Bt,{formAssociated:!1,attrs:Qu}]]);function Ju(s,{formAssociated:t=!1,attrs:e={}}={}){let i=Wa(e),n=Object.freeze(Object.keys(i)),r=s===Xt||s===Bt;class o extends HTMLElement{static formAssociated=!!t;static get observedAttributes(){return n}constructor(){super(),this._component=null,this._bridgeAbort=null,this._reflecting=new Set,this._propertyValues=new Map,this._defaults=null,this._contentNodes=null,this._disabledByForm=!1,this._applying=!1,this._internals=t&&typeof this.attachInternals=="function"?this.attachInternals():null}connectedCallback(){this._component||(this._upgradeProperties(i),r&&this._contentNodes===null&&(this._contentNodes=Array.from(this.childNodes)),t&&this._defaults===null&&this._captureDefaults(i),this._createComponent(s,i,r))}disconnectedCallback(){this._destroyComponent()}attributeChangedCallback(c,h,d){if(this._reflecting.has(c))return;let u=i[c];if(!u)return;let p=pe(d,u.type);if(p===ht)return;this._propertyValues.delete(u.property);let f=p===void 0?Bi(u.default):p;this._applyValue(c,u,f)}formDisabledCallback(c){this._disabledByForm=!!c,this._syncEffectiveDisabled(i),this._syncFormState(s)}formResetCallback(){if(!this._defaults)return;let c=mn(s);!c||!this._defaults.has(c)||this._applyControlValue(i,c,Bi(this._defaults.get(c)))}formStateRestoreCallback(c,h){if(typeof c!="string")return;let d=hf(s,c);if(d===ht)return;let u=mn(s);u&&this._applyControlValue(i,u,d)}get component(){return this._component}get form(){return this._internals?.form??null}get labels(){return this._internals?.labels??null}get validity(){return this._internals?.validity??null}get validationMessage(){return this._internals?.validationMessage??""}get willValidate(){return this._internals?.willValidate??!1}checkValidity(){return this._internals?.checkValidity()??!0}reportValidity(){return this._internals?.reportValidity()??!0}_upgradeProperties(c){for(let h of Object.values(c)){let d=h.property;if(!Object.prototype.hasOwnProperty.call(this,d))continue;let u=this[d];delete this[d],this[d]=u}}_captureDefaults(c){this._defaults=new Map;let h=mn(s);if(h){let d=Object.values(c).find(u=>u.property===h);d&&this._defaults.set(h,Bi(this._readProperty(d)))}}_createComponent(c,h,d){let u={};for(let[_,m]of Object.entries(h)){if(!(this._propertyValues.has(m.property)||this.hasAttribute(_)||m.always)||m.option===null)continue;let y=this._currentValue(_,m);y===ht||y===void 0||(u[m.option]=Ya(m,y,this))}let p=null;d&&(p=document.createDocumentFragment(),p.append(...this._contentNodes),u.content=p);let f=new c(null,u);this._component=f,s===Xt&&p&&f.setContent(p),this.append(f.el),this._bridgeEvents(f,s);for(let[_,m]of Object.entries(h)){if(m.option!==null||!m.set||!(this._propertyValues.has(m.property)||this.hasAttribute(_)||m.always))continue;let y=this._currentValue(_,m);y!==ht&&y!==void 0&&this._applyValue(_,m,y,!0)}this._syncEffectiveDisabled(h),this._syncFormState(s)}_bridgeEvents(c,h){this._bridgeAbort?.abort(),this._bridgeAbort=new AbortController;for(let d of Vu)c.on(d,u=>{if(this._applying)return;this._syncFormState(h);let p=new CustomEvent(`zx-${d}`,{detail:u.detail??{},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(p),p.defaultPrevented&&u.preventDefault()}),c.el.addEventListener(`zx-${d}`,u=>u.stopPropagation(),{signal:this._bridgeAbort.signal})}_destroyComponent(){this._bridgeAbort?.abort(),this._bridgeAbort=null,this._component&&(this._component.destroy(),this._component=null)}_rebuildComponent(c,h=r){this._component&&(h&&this._contentNodes&&document.createDocumentFragment().append(...this._contentNodes),this._destroyComponent(),this._createComponent(s,c,h))}_applyValue(c,h,d,u=!1){if(this._component){if(h.rebuild&&!u){this._rebuildComponent(i);return}if(!h.set){this._syncFormState(s);return}this._applying=!0;try{h.set(this._component,Ya(h,d,this),this)}finally{this._applying=!1}c!=="disabled"&&this._syncEffectiveDisabled(i),this._syncFormState(s)}}_syncEffectiveDisabled(c){if(!(!this._component||!c.disabled?.set)){this._applying=!0;try{c.disabled.set(this._component,this.hasAttribute("disabled")||this._disabledByForm,this)}finally{this._applying=!1}}}_syncFormState(c){if(!this._internals||!this._component)return;let{formValue:h,state:d,empty:u}=cf(c,this._component,this);if(this._internals.setFormValue(h,d),(c===G||c===Z)&&this.hasAttribute("required")&&u){let p=c===Z?"Please enter a date.":"Please select a value.";this._internals.setValidity({valueMissing:!0},p,this._component.refs.input)}else this._internals.setValidity({})}_applyControlValue(c,h,d){let u=Object.entries(c).find(([,p])=>p.property===h);u&&this._applyValue(u[0],u[1],d)}_currentValue(c,h){if(this._propertyValues.has(h.property))return this._propertyValues.get(h.property);let d=pe(this.getAttribute(c),h.type);return d===void 0?h.default:d}_readProperty(c){if(this._component&&c.get)return c.get(this._component,this);if(this._propertyValues.has(c.property))return this._propertyValues.get(c.property);let h=pe(this.getAttribute(c.attribute),c.type);return h===ht||h===void 0?Bi(c.default):h}_writeProperty(c,h){this._propertyValues.set(c.property,h);let d=c.serialize?c.serialize(h,this):_n(h,c.type);if(d!==ht){this._reflecting.add(c.attribute);try{d===null?this.removeAttribute(c.attribute):this.setAttribute(c.attribute,d)}finally{this._reflecting.delete(c.attribute)}}this._applyValue(c.attribute,c,h)}}for(let a of Object.values(i))Object.prototype.hasOwnProperty.call(o.prototype,a.property)||Object.defineProperty(o.prototype,a.property,{configurable:!0,enumerable:!0,get(){return this._readProperty(a)},set(c){this._writeProperty(a,c)}});return o}function Zu(s="zx"){if(typeof customElements>"u")throw new Error("Custom elements are not available in this environment");let t=String(s).trim();for(let[e,i,n]of Xu){let r=`${t}-${e}`;customElements.get(r)||customElements.define(r,Ju(i,n))}}function Wa(s){let t={};for(let[e,i]of Object.entries(s)){let n=typeof i=="string"?{type:i}:{...i},r=n.property??tf(e);t[e]=Object.freeze({type:n.type??"string",option:Object.prototype.hasOwnProperty.call(n,"option")?n.option:r,property:r,default:n.default,always:!!n.always,rebuild:!!n.rebuild,normalize:n.normalize,serialize:n.serialize,set:n.set,get:n.get,attribute:e})}return Object.freeze(t)}function dt(s){return Wa(s)}function M(s={}){return{type:"string",...s}}function _e(s={}){return{type:"number",...s}}function L(s={}){return{type:"boolean",default:!1,always:!0,...s}}function It(s={}){return{type:"json",...s}}function tf(s){return s.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function Ya(s,t,e){return s.normalize?s.normalize(t,e):t}function Je(s,t){t?s.disable():s.enable()}function ef(s,t){s.el.setAttribute("aria-disabled",String(t)),s.refs.search&&(s.refs.search.disabled=t);for(let e of s.refs.list?.querySelectorAll("input")??[])e.disabled=t}function sf(s){return s===""||s==="true"?"local":s==="false"?!1:s}function nf(s){return s===""||s==="true"?"single":s==="false"?!1:s}function Ga(s){if(typeof s!="string"||s.trim()==="")return s;let t=Number(s);return Number.isFinite(t)?t:s}function rf(s){return Array.isArray(s)?s.map(t=>!t||typeof t!="object"||of(t.content)||typeof t.content=="function"?t:{...t,content:document.createTextNode(String(t.content??""))}):s}function of(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function af(s){return typeof s!="string"?s:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(s)?X(s,"%Y-%m-%dT%H:%M"):/^\d{4}-\d{2}-\d{2}$/.test(s)?X(s,"%Y-%m-%d"):s}function lf(s,t){return s instanceof Date?gn(s,!!t.time):_n(s,"string")}function gn(s,t){return!(s instanceof Date)||Number.isNaN(s.getTime())?"":D(s,t?"%Y-%m-%dT%H:%M":"%Y-%m-%d")}function mn(s){return s===nt||s===Vt?"checked":[G,wt,Z,Tt].includes(s)?"value":null}function cf(s,t,e){if(s===nt||s===Vt){let n=t.get(),r=s===nt?!0:"on";return e._propertyValues.has("value")?r=e._propertyValues.get("value"):e.hasAttribute("value")&&(r=e.getAttribute("value")),{formValue:n?String(r):null,state:String(n),empty:!n}}if(s===G){let n=t.value;return{formValue:n===null?null:String(n),state:JSON.stringify(n),empty:n===null||n===""}}if(s===wt){let n=JSON.stringify(t.getValues());return{formValue:n,state:n,empty:n==="[]"}}if(s===Z){let n=gn(t.get(),!!e.time);return{formValue:n||null,state:n,empty:n===""}}let i=String(t.get());return{formValue:i,state:i,empty:!1}}function hf(s,t){return s===nt||s===Vt?t==="true":s===G||s===wt?pe(t,"json"):s===Tt?pe(t,"number"):t}function Bi(s){return Array.isArray(s)?s.slice():s instanceof Date?new Date(s.getTime()):s}var df=Object.freeze({label:"",icon:null,kind:"default",size:"md",disabled:!1});function W(s={}){let t={...df,...s},e=l("button",{class:"zx-btn",type:"button",disabled:!!t.disabled,title:t.title,dataset:{kind:ff(t.kind),size:pf(t.size)}});return t.icon&&e.append(g(t.icon,{size:16})),t.label!==""&&e.append(l("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 uf(s){let t=l("div",{class:"zx-btn-group",role:"group"});return t.append(...s),t}function ff(s){return["primary","danger","ghost"].includes(String(s))?s:"default"}function pf(s){return s==="sm"?"sm":"md"}var _f=Object.freeze(["neutral","accent","success","warning","danger","info"]),mf=Object.freeze(["soft","solid","outline"]),gf=Object.freeze({label:"",icon:null,kind:"neutral",variant:"soft",size:"md",dot:!1});function bn(s={}){let t={...gf,...s},e=l("span",{class:"zx-badge",title:t.title,dataset:{kind:yf(t.kind),variant:wf(t.variant),size:vf(t.size)}});return t.dot?e.append(l("span",{class:"zx-badge__dot",ariaHidden:"true"})):t.icon&&e.append(g(t.icon,{size:12,class:"zx-badge__icon"})),t.label!==""&&t.label!=null?e.append(l("span",{class:"zx-badge__label"},String(t.label))):t.title&&(e.setAttribute("role","img"),e.setAttribute("aria-label",t.title)),e}function bf(s){let t=l("span",{class:"zx-badge-group"});return t.append(...s),t}function yf(s){return _f.includes(s)?s:"neutral"}function wf(s){return mf.includes(s)?s:"soft"}function vf(s){return s==="sm"?"sm":"md"}var xf=Object.freeze({md:40,sm:28}),Sf=Object.freeze({icon:"folder-open",title:"",description:"",actions:[],size:"md",align:"center"});function kf(s={}){let t={...Sf,...s},e=zf(t.size),i=l("div",{class:"zx-empty-state",dataset:{size:e,align:Cf(t.align)}});t.icon&&i.append(l("div",{class:"zx-empty-state__icon",ariaHidden:"true"},g(t.icon,{size:xf[e]}))),t.title&&i.append(l("p",{class:"zx-empty-state__title"},String(t.title))),t.description&&i.append(l("p",{class:"zx-empty-state__description"},String(t.description)));let n=Af(t.actions);return n.length>0&&i.append(l("div",{class:"zx-empty-state__actions"},n)),i}function Af(s){if(!Array.isArray(s))throw new TypeError("emptyState actions must be an array");return s.map(t=>{if(F(t))return t;if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("emptyState actions must be Elements or button descriptors");return W(t)})}function zf(s){return s==="sm"?"sm":"md"}function Cf(s){return s==="start"?"start":"center"}var Tf=Object.freeze({size:"md",label:"",showLabel:!1,kind:"accent"}),Df=Object.freeze({sm:!0,md:!0,lg:!0});function yn(s={}){let t={...Tf,...s},e=String(t.label??""),i=l("span",{class:"zx-spinner",dataset:{size:Df[t.size]?t.size:"md",kind:t.kind==="current"?"current":"accent"}},l("span",{class:"zx-spinner__ring",ariaHidden:"true"}));return e?(i.setAttribute("role","status"),i.append(l("span",{class:"zx-spinner__label",dataset:{visible:t.showLabel?"true":null}},e))):i.setAttribute("aria-hidden","true"),i}var Ze=class extends b{static cssName="progress-bar";static defaults={value:0,max:100,label:"",helperText:"",status:"active",indeterminate:!1,size:"md",hideLabel:!1,showValue:!0,formatValue:null};render(){this._value=0,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t,this._max=Math.max(1,Number(this.options.max)||100),this._status=Qa(this.options.status),this._indeterminate=!!this.options.indeterminate,this._labelId=x("zx-progress-label");let e=l("div",{ref:"head",class:"zx-progress-bar__head"},l("span",{ref:"label",class:"zx-progress-bar__label",id:this._labelId},String(this.options.label??"")),l("span",{ref:"value",class:"zx-progress-bar__value"})),i=l("div",{ref:"track",class:"zx-progress-bar__track",role:"progressbar",ariaValuemin:"0",ariaValuemax:String(this._max),ariaLabelledby:this._labelId},l("div",{ref:"fill",class:"zx-progress-bar__fill"}));return t.replaceChildren(e,i,l("p",{ref:"helper",class:"zx-progress-bar__helper"},String(this.options.helperText??""))),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.set(this.options.value,{silent:!0}),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=Number(t),n=P(Number.isFinite(i)?i:0,0,this._max),r=n!==this._value,o=r&&n>=this._max;return this._value=n,this._sync(),!e&&r&&this.emit("change",{value:n,percent:this.percent()}),!e&&o&&this.emit("complete",{value:n}),this}percent(){return this._value/this._max*100}setMax(t){return this._max=Math.max(1,Number(t)||1),this.refs.track.setAttribute("aria-valuemax",String(this._max)),this.set(this._value,{silent:!0})}setStatus(t,e){return this._status=Qa(t),e!==void 0&&this.setHelperText(e),this._sync(),this}setLabel(t){return this.refs.label.textContent=String(t??""),this}setHelperText(t){return this.refs.helper.textContent=String(t??""),this}setIndeterminate(t=!0){return this._indeterminate=!!t,this._sync(),this}_sync(){let{track:t,fill:e,value:i}=this.refs;if(this.el.dataset.status=this._status,this.el.toggleAttribute("data-indeterminate",this._indeterminate),this._indeterminate){t.removeAttribute("aria-valuenow"),t.removeAttribute("aria-valuetext"),e.style.removeProperty("--zx-progress-fill"),i.textContent="";return}let n=this._format();t.setAttribute("aria-valuenow",String(this._value)),t.setAttribute("aria-valuetext",n),e.style.setProperty("--zx-progress-fill",`${this.percent()}%`),i.replaceChildren(...this._readout(n))}_format(){let t=this.options.formatValue;return typeof t=="function"?String(t(this._value,this._max)):`${Math.round(this.percent())}%`}_readout(t){if(!this.options.showValue)return[];let e=[];return this._status!=="active"&&e.push(g(this._status==="success"?"success":"error",{size:14})),e.push(l("span",{class:"zx-progress-bar__percent"},t)),e}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&k(t,this._snapshot)}};function Qa(s){return s==="success"||s==="error"?s:"active"}var If=new Set(["inactive","active","success","error"]),wn=class extends b{static cssName="inline-loading";static defaults={status:"active",description:"",size:"sm",live:!0};render(){this._status="inactive",this._description="",this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("span");return this.el=t,t.replaceChildren(l("span",{ref:"indicator",class:"zx-inline-loading__indicator"}),l("span",{ref:"description",class:"zx-inline-loading__description"})),t.dataset.size=this.options.size==="md"?"md":"sm",this.options.live!==!1&&(t.setAttribute("role","status"),t.setAttribute("aria-live","polite")),this.set(this.options.status,this.options.description,{silent:!0}),t}get(){return this._status}getDescription(){return this._description}set(t,e,{silent:i=!1}={}){let n=If.has(t)?t:"inactive";e!==void 0&&(this._description=String(e??""));let r=n!==this._status;return this._status=n,this._sync(),r&&!i&&this.emit("statuschange",{status:this._status,description:this._description}),this}setDescription(t){return this._description=String(t??""),this.refs.description.textContent=this._description,this}_sync(){this.el.dataset.status=this._status,this.refs.description.textContent=this._description,this.refs.indicator.replaceChildren(...this._indicator())}_indicator(){let t=this.el.dataset.size==="md"?18:16;return this._status==="active"?[yn({size:"sm",kind:"current"})]:this._status==="success"?[g("success",{size:t})]:this._status==="error"?[g("error",{size:t})]:[]}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&k(t,this._snapshot)}};function xn(s={}){let t={width:"100%",height:"1rem",radius:"sm",...s};return l("span",{class:"zx-skeleton",ariaHidden:"true",dataset:{radius:Nf.has(t.radius)?t.radius:"sm"},style:{"inline-size":vn(t.width),"block-size":vn(t.height)}})}function Ef(s={}){let t={lines:3,width:"100%",heading:!1,lastLineWidth:"60%",...s},e=P(Math.trunc(Number(t.lines)||0),1,20),i=l("div",{class:"zx-skeleton-text",ariaHidden:"true",style:{"inline-size":vn(t.width)}});for(let n=0;n<e;n+=1){let r=t.heading&&n===0,o=n===e-1&&e>1;i.append(xn({width:o?t.lastLineWidth:"100%",height:r?"1.5rem":"0.75rem"}))}return i}function Mf(s={}){let t={rows:5,columns:4,header:!0,...s},e=P(Math.trunc(Number(t.rows)||0),1,50),i=P(Math.trunc(Number(t.columns)||0),1,20),n=l("div",{class:"zx-skeleton-table",ariaHidden:"true",style:{"--zx-skeleton-columns":String(i)}});t.header!==!1&&n.append(Xa(i,"header"));for(let r=0;r<e;r+=1)n.append(Xa(i,"body"));return n}var Nf=new Set(["sm","md","full"]);function Xa(s,t){let e=l("div",{class:"zx-skeleton-table__row",dataset:{kind:t}});for(let i=0;i<s;i+=1)e.append(l("span",{class:"zx-skeleton-table__cell"},xn({width:Of(i,s),height:"0.75rem"})));return e}function Of(s,t){return s===t-1?"55%":s%2===0?"80%":"65%"}function vn(s){return typeof s=="number"?`${s}px`:String(s??"")}function Ff(s={},...t){return l("div",{class:["zx-stack",s.class??""],dataset:{direction:s.direction==="row"?"row":null,align:Ja.has(s.align)?s.align:null,justify:Pf.has(s.justify)?s.justify:null,wrap:s.wrap?"true":null,inline:s.inline?"true":null},style:Za("--zx-stack-gap",s.gap)},t)}function Rf(s={},...t){let e=Number(s.columns),i={...Za("--zx-grid-gap",s.gap),"--zx-grid-min":Bf(s.min??"16rem")};return Number.isFinite(e)&&e>=1&&(i["--zx-grid-columns"]=String(Math.trunc(e))),l("div",{class:["zx-grid",s.class??""],dataset:{columns:Number.isFinite(e)&&e>=1?"true":null,align:Ja.has(s.align)?s.align:null},style:i},t)}function Lf(s={},...t){return l("div",{class:["zx-aspect",s.class??""],style:{"--zx-aspect-ratio":String(s.ratio??"16 / 9"),"--zx-aspect-fit":Vf.has(s.fit)?s.fit:"cover"}},t)}var Ja=new Set(["start","center","end","stretch","baseline"]),Pf=new Set(["start","center","end","between","around"]),Vf=new Set(["cover","contain","fill"]);function Za(s,t){if(t==null||t==="")return{};let e=Number(t);return Number.isInteger(e)&&e>=1&&e<=8?{[s]:`var(--zx-space-${e})`}:{[s]:String(t)}}function Bf(s){return typeof s=="number"?`${s}px`:String(s)}function Hf(s,t={}){let e=U(s);if(!e)throw new TypeError("truncate() target could not be resolved");let i=P(Math.trunc(Number(t.lines)||1),1,10),n=t.title!==!1,r=e.classList.contains("zx-truncate"),o=e.getAttribute("title"),a=!1,c=null;e.classList.add("zx-truncate"),i>1&&(e.dataset.lines=String(i),e.style.setProperty("--zx-truncate-lines",String(i)));let h=()=>(a=tl(e),n&&(a?e.setAttribute("title",e.textContent?.trim()??""):o===null?e.removeAttribute("title"):e.setAttribute("title",o)),a);return h(),typeof ResizeObserver=="function"&&(c=new ResizeObserver(h),c.observe(e)),{update:h,isTruncated:()=>a,destroy:()=>{c?.disconnect(),c=null,r||e.classList.remove("zx-truncate"),delete e.dataset.lines,e.style.removeProperty("--zx-truncate-lines"),n&&(o===null?e.removeAttribute("title"):e.setAttribute("title",o))}}}function tl(s){return s.scrollWidth-s.clientWidth>1||s.scrollHeight-s.clientHeight>1}var qf=Object.freeze({text:"",label:"",title:"Copy",feedback:"Copied",feedbackDuration:2e3,size:"md",kind:"ghost"});function Sn(s={}){let t={...qf,...s},e=!t.label,i=l("button",{class:["zx-copy-button",e?"zx-icon-btn":"zx-btn"],type:"button",dataset:{size:t.size==="sm"?"sm":"md",kind:e?null:t.kind},title:e?String(t.title):null,ariaLabel:e?String(t.title):null}),n=l("span",{class:"zx-copy-button__icon",ariaHidden:"true"},g("copy",{size:t.size==="sm"?12:14})),r=l("span",{class:"zx-copy-button__status",role:"status"});i.append(n),e||i.append(l("span",{class:"zx-copy-button__label"},String(t.label))),i.append(r);let o=0;return i.addEventListener("click",async()=>{let a=typeof t.text=="function"?String(t.text()):String(t.text??""),c=await hn(a);t.oncopy?.(a,c),c&&(clearTimeout(o),i.dataset.copied="true",n.replaceChildren(g("check",{size:t.size==="sm"?12:14})),r.textContent=String(t.feedback),o=setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,n.replaceChildren(g("copy",{size:t.size==="sm"?12:14})),r.textContent="")},Math.max(0,Number(t.feedbackDuration)||0)))}),i}var kn=class extends b{static cssName="copy-input";static defaults={value:"",label:"",hideLabel:!1,feedback:"Copied",buttonTitle:"Copy",size:"md"};render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t;let e=x("zx-copy-input"),i=l("input",{ref:"input",class:"zx-copy-input__field",type:"text",id:e,readOnly:!0,value:String(this.options.value??"")}),n=Sn({text:()=>this.get(),title:String(this.options.buttonTitle),feedback:String(this.options.feedback),size:this.options.size==="sm"?"sm":"md",oncopy:(r,o)=>this.emit("copy",{value:r,copied:o})});return t.replaceChildren(l("label",{ref:"label",class:"zx-copy-input__label",for:e},String(this.options.label??"")),l("div",{class:"zx-copy-input__box"},i,n)),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(i,"focus",()=>i.select()),t}get(){return this.refs.input.value}set(t){return this.refs.input.value=String(t??""),this}focus(){return this.refs.input.focus(),this.refs.input.select(),this}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&k(t,this._snapshot)}};var il=Symbol("zxDropdownPointerDismiss"),sl=Symbol("zxDropdownEscapeDismiss"),ut=class extends b{static cssName="dropdown";static defaults={content:null,placement:"bottom-start",offset:4,matchWidth:!1,openOn:"click",closeOnSelect:!1,scope:null};#t;#e=null;#i=new Map;#s=!1;constructor(t,e={}){let i=U(t);if(!i)throw new TypeError("Dropdown anchor could not be resolved");super(null,e),this.#t=i,rt(this.options.scope??i).append(this.el),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=l("div",{id:x("zx-dropdown"),popover:"manual"});return t.dataset.state="closed",t}open(){if(this.isOpen()||this.#s)return this;let t=rt(this.options.scope??this.#t);return this.el.parentElement!==t&&t.append(this.el),this.#e=st(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($f()),this.#t.setAttribute("aria-expanded","true"),Kf(),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"),Uf(),this):this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.#e!==null}setContent(t){return jf(this.el,t),this.#e?.update(),this}getPanel(){return this.el}destroy(){if(!this.#s){this.#s=!0,this.close();for(let[t,e]of this.#i)Yf(this.#t,t,e);super.destroy()}}[il](t){if(!this.isOpen())return;let e=t.composedPath();e.includes(this.el)||e.includes(this.#t)||this.close()}[sl](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.#i.set(t,this.#t.getAttribute(t))}},ti=class extends b{constructor(){super(null),this.listen(document,"pointerdown",t=>{let e=el();e instanceof ut&&e[il](t)}),this.listen(document,"keydown",t=>{if(t.key!=="Escape")return;let e=el();e instanceof ut&&e[sl](t)})}render(){let t=l("span",{hidden:!0,"data-zx-dropdown-dismiss-manager":""});return document.body.append(t),t}};function jf(s,t){if(s.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t.nodeType=="number"&&s.append(t)}function el(){let s=null,t=-1;for(let e of document.querySelectorAll("[data-zx-overlay-order]")){let i=Number(e.getAttribute("data-zx-overlay-order"))||0;i>t&&(t=i,s=e)}return s?b.from(s):null}function $f(){let s=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...s)+1}function Kf(){let s=document.querySelector("[data-zx-dropdown-dismiss-manager]"),t=s?b.from(s):null;return t instanceof ti?t:new ti}function Uf(){if(document.querySelector('.zx-dropdown[data-state="open"]'))return;let s=document.querySelector("[data-zx-dropdown-dismiss-manager]"),t=s?b.from(s):null;t instanceof ti&&t.destroy()}function Yf(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}var Hi='[role="menuitem"]',ft=class extends b{static cssName="menu-button";static defaults={label:"",icon:null,kind:"default",items:[],placement:"bottom-start"};#t;#e;#i;#s;#r=[];#n=null;#o=!1;#a=!1;constructor(t=null,e={}){let i=t===null?null:U(t);if(t!==null&&(!i||i.tagName!=="BUTTON"))throw new TypeError("MenuButton target must resolve to a button");let n=i?{attributes:Array.from(i.attributes,o=>[o.name,o.value]),children:Array.from(i.childNodes)}:null,r=Object.hasOwn(e,"label");super(t,e),this.#o=i===null,this.#n=n,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 ut(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"),i&&r&&this.setLabel(this.options.label),this.setItems(this.options.items),this.#i=Ct(this.#e,Hi),this.#s=lt(()=>this.#d(),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.#i.focusFirst())}),this.listen(this.el,"keydown",o=>this.#l(o)),this.listen(this.#e,"click",o=>{let a=o.target.closest?.(Hi);a&&this.#e.contains(a)&&this.#h(a)}),this.listen(this.#e,"keydown",o=>this.#c(o))}render(){return this.el?this.el:l("button",{class:"zx-btn",type:"button","data-kind":this.options.kind,"data-size":"md"},nl(this.options.label,this.options.icon))}setItems(t){return this.#r=Array.isArray(t)?t.slice():[],this.#e.replaceChildren(),this.#r.forEach((e,i)=>{if(e==="-"){this.#e.append(l("div",{class:"zx-menu-button__separator",role:"separator"}));return}let n=[];e.icon&&n.push(l("span",{class:"zx-menu-button__icon"},g(e.icon))),n.push(l("span",{class:"zx-menu-button__label"},e.label)),this.#e.append(l("button",{class:"zx-menu-button__item",type:"button",role:"menuitem",tabindex:"-1","data-menu-item":String(i),"data-danger":e.danger?"true":null,ariaDisabled:e.disabled?"true":null},n))}),this}open(){return this.#t.open(),this}close(){return this.#t.close(),this}isOpen(){return this.#t.isOpen()}getTrigger(){return this.el}getPanel(){return this.#e}focusFirst(){return this.open(),this.#i.focusFirst(),this}focusLast(){return this.open(),this.#i.focusLast(),this}setLabel(t){return this.el.replaceChildren(...nl(t,this.options.icon)),this}destroy(){if(!this.#a&&(this.#a=!0,this.#i.destroy(),this.#t.destroy(),super.destroy(),!this.#o&&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)}}#l(t){["ArrowDown","ArrowUp","Enter"," "].includes(t.key)&&(t.preventDefault(),this.open(),t.key==="ArrowUp"?this.#i.focusLast():this.#i.focusFirst())}#c(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?.(Hi);if(!e||!this.#e.contains(e))return;t.preventDefault(),this.#h(e);return}this.#s(t)}#h(t){let e=Number(t.getAttribute("data-menu-item")),i=this.#r[e];if(!(!i||i==="-"||i.disabled||this.emit("select",{value:i.value,item:i}).defaultPrevented))try{i.onselect?.(i.value,i,this)}finally{this.close()}}#d(){return Array.from(this.#e.querySelectorAll(Hi))}};function nl(s,t){let e=[];return t&&e.push(l("span",{class:"zx-btn__icon"},g(t))),e.push(l("span",{class:"zx-btn__label"},String(s??""))),e}var Wf=["button","a[href]","input","select","textarea","[tabindex]"],Gf=Wf.flatMap(s=>[`.zx-toolbar > ${s}`,`.zx-toolbar > [role="group"] > ${s}`]).join(","),An=class extends b{static cssName="toolbar";static defaults={items:[],align:"start",label:"Toolbar",overflow:!0,overflowLabel:"More",dense:!1};#t;#e=null;#i=null;#s=!1;#r=-1;#n=-1;#o=0;#a=!1;constructor(t=null,e={}){if(super(t,e),this.options.overflow){this.#e=new ft(null,{icon:"dots",label:"",kind:"ghost",placement:"bottom-end"});let i=this.#e.toElement();i.classList.add("zx-toolbar__overflow"),i.setAttribute("aria-label",String(this.options.overflowLabel)),i.setAttribute("title",String(this.options.overflowLabel)),this.options.dense&&i.setAttribute("data-size","sm"),i.hidden=!0}this.#t=Ct(this.el,Gf,{orientation:"horizontal"}),this.listen(this.el,"click",i=>this.#c(i)),this.setItems(this._initialItems),this.#e&&typeof ResizeObserver=="function"&&(this.#i=new ResizeObserver(()=>this.#d()),this.#i.observe(this.el))}render(){this._records=[],this._named=new Map,this._createdRoot=!this.el;let t=this.el??l("div");this.el=t,this._snapshot=this._createdRoot?null:A(t);let e=this.options.items;return this._initialItems=Array.isArray(e)&&e.length===0?Array.from(t.children):e,t.setAttribute("role","toolbar"),t.setAttribute("aria-label",String(this.options.label)),t.dataset.align=Xf(this.options.align),t.dataset.overflow=this.options.overflow?"true":"false",this.options.dense&&(t.dataset.dense="true"),t}setItems(t){for(let i of this._records)i.type==="element"&&(i.element.hidden=i.userHidden);this._records=Qf(t).map(i=>this.#l(i)),this._named=new Map;for(let i of this._records)i.name!==null&&!this._named.has(i.name)&&this._named.set(i.name,i);let e=this._records.map(i=>i.element);if(this.#e){this.#e.setItems([]);let i=this.#e.toElement();i.hidden=!0,e.push(i)}return this.el.replaceChildren(...e),this.#r=-1,this.#n=-1,this.#u(),this}getItem(t){return this._named.get(String(t))?.element??null}enable(t){return this.#h(t,!1)}disable(t){return this.#h(t,!0)}setActive(t,e=!0){let i=this._named.get(String(t));return i&&i.element.setAttribute("aria-pressed",e?"true":"false"),this}destroy(){if(!this.#a){this.#a=!0,this.#i?.disconnect(),this.#i=null,this.#o!==0&&cancelAnimationFrame(this.#o),this.#o=0,this.#t.destroy(),this.#e?.destroy(),this.#e=null;for(let t of this._records)t.type==="element"&&(t.element.hidden=t.userHidden);super.destroy(),this._createdRoot||k(this.el,this._snapshot)}}#l(t){if(t.type==="separator")return{type:"separator",element:l("span",{class:"zx-toolbar__separator",role:"separator",ariaOrientation:"vertical",dataset:{separator:"true"}}),name:null,label:"",icon:null,onclick:null,userHidden:!1};if(t.type==="element"){let a=t.element;return{type:"element",element:a,name:a.dataset?.name??null,label:ol(a),icon:null,onclick:null,userHidden:!!a.hidden}}let{name:e=null,active:i,onclick:n,...r}=t.descriptor,o=W({size:this.options.dense?"sm":"md",...r});return i!==void 0&&o.setAttribute("aria-pressed",i?"true":"false"),e!==null&&(o.dataset.name=String(e)),{type:"descriptor",element:o,name:e===null?null:String(e),label:String(r.label??r.title??""),icon:r.icon??null,onclick:typeof n=="function"?n:null,userHidden:!1}}#c(t){let e=t.target;if(!e)return;let i=this._records.find(n=>n.type==="descriptor"&&n.element.contains(e));i&&(this.emit("action",{name:i.name,item:i.element}),i.onclick?.(t))}#h(t,e){let i=this._named.get(String(t));if(!i)return this;let n=i.element;return"disabled"in n?n.disabled=e:e?n.setAttribute("aria-disabled","true"):n.removeAttribute("aria-disabled"),this.#f(),this}#d(){if(!(this.#o!==0||this.#a)){if(typeof requestAnimationFrame!="function"){this.#u();return}this.#o=requestAnimationFrame(()=>{this.#o=0,this.#u()})}}#u(){if(this.#s||this.#a||!this.#e)return;let t=this.el;if(typeof getComputedStyle!="function"||!t.isConnected)return;let e=getComputedStyle(t),i=parseFloat(e.columnGap)||0,n=(parseFloat(e.paddingInlineStart)||0)+(parseFloat(e.paddingInlineEnd)||0),r=t.clientWidth-n,o=t.clientHeight;if(!(!(r>0)||r===this.#r&&o===this.#n)){this.#s=!0;try{let a=this.#e.toElement(),c=this._records.filter(_=>!_.userHidden);for(let _ of c)_.element.hidden=!1;a.hidden=!1;let h=c.map(_=>_.element.getBoundingClientRect().width),d=h.reduce((_,m)=>_+m,0)+i*Math.max(0,h.length-1),u=a.getBoundingClientRect().width,p=[];if(d>r){let _=r-u-i,m=0,w=!1;for(c.forEach((y,v)=>{let S=m+h[v]+(m>0?i:0);if(!w&&S<=_){m=S;return}w=!0,y.element.hidden=!0,p.push(y)});c.length>p.length;){let y=c[c.length-p.length-1];if(y.type!=="separator")break;y.element.hidden=!0,p.unshift(y)}}let f=rl(p);this.#e.setItems(f),a.hidden=f.length===0,this.#r=r,this.#n=t.clientHeight}finally{this.#s=!1}}}#f(){if(!this.#e)return;let t=this._records.filter(e=>!e.userHidden&&e.element.hidden);this.#e.setItems(rl(t))}};function Qf(s){if(s!=null&&!Array.isArray(s))throw new TypeError("Toolbar items must be an array");let t=[];for(let e of s??[])if(e!=null){if(e==="-"){t.length>0&&t[t.length-1].type!=="separator"&&t.push({type:"separator"});continue}if(F(e)){t.push({type:"element",element:e});continue}if(typeof e!="object"||Array.isArray(e))throw new TypeError('Toolbar items must be Elements, item descriptors, or "-"');t.push({type:"descriptor",descriptor:{...e}})}for(;t.length>0&&t[t.length-1].type==="separator";)t.pop();return t}function rl(s){let t=[];for(let e of s){if(e.type==="separator"){t.length>0&&t[t.length-1]!=="-"&&t.push("-");continue}let i=e.element;t.push({label:e.label||ol(i)||"\u2026",icon:e.icon??void 0,value:e.name,disabled:!!i.disabled||i.getAttribute("aria-disabled")==="true",onselect:()=>i.click()})}for(;t.length>0&&t[t.length-1]==="-";)t.pop();return t}function ol(s){return(s.getAttribute("aria-label")??s.getAttribute("title")??s.textContent??"").trim()}function Xf(s){return["end","between"].includes(s)?s:"start"}var Cn=class extends b{static cssName="card";static defaults={title:"",media:null,content:null,actions:[],footer:null,link:null,variant:"outlined",orientation:"vertical",headingLevel:3};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("article");this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._cleaned=!1,this._title="",this._link=null,this._actionAbort=null,this._linkAbort=null;let i=t?[]:Array.from(e.childNodes);try{let n=ep(this.options.headingLevel),r=x("zx-card-heading"),o=l(`h${n}`,{ref:"heading",class:"zx-card__heading",id:r}),a=l("div",{ref:"media",class:"zx-card__media",hidden:!0}),c=l("div",{ref:"actions",class:"zx-card__actions",role:"group",ariaLabel:"Card actions",hidden:!0}),h=l("div",{ref:"content",class:"zx-card__content",hidden:!0}),d=l("footer",{ref:"footer",class:"zx-card__footer",hidden:!0}),u=l("header",{ref:"header",class:"zx-card__header"},o,c);return e.replaceChildren(l("div",{class:"zx-card__layout"},a,l("div",{class:"zx-card__inner"},u,h,d))),e.dataset.variant=Zf(this.options.variant),e.dataset.orientation=tp(this.options.orientation),this.setTitle(this.options.title),this.setMedia(this.options.media),this.options.content!==null?this.setContent(this.options.content):i.length&&(h.replaceChildren(...i),h.hidden=!1),this.setActions(this.options.actions),this.setFooter(this.options.footer),this.setLink(this.options.link),e}catch(n){throw this._actionAbort?.abort(),this._linkAbort?.abort(),t||k(e,this._original),n}}setTitle(t){let e=String(t??"");if(this._link&&!e.trim())throw new TypeError("A linked Card requires a non-empty title");return this._title=e,this._renderHeading(),this}setMedia(t){return zn(this.refs.media,t,"Card media"),this.refs.media.hidden=t===null,this}setContent(t){return zn(this.refs.content,t,"Card content"),this.refs.content.hidden=t===null,this}setActions(t){if(!Array.isArray(t))throw new TypeError("Card actions must be an array");let e=new AbortController,i;try{i=t.map(n=>{if(F(n))return n;if(!n||typeof n!="object"||Array.isArray(n))throw new TypeError("Card actions must be Elements or button descriptors");let r={...n},o=r.onclick;delete r.onclick;let a=W(r);if(o!==void 0&&typeof o!="function")throw new TypeError("Card action onclick must be a function");return o&&a.addEventListener("click",o,{signal:e.signal}),a})}catch(n){throw e.abort(),n}return this._actionAbort?.abort(),this._actionAbort=e,this.refs.actions.replaceChildren(...i),this.refs.actions.hidden=i.length===0,this._syncHeader(),this}setFooter(t){return zn(this.refs.footer,t,"Card footer"),this.refs.footer.hidden=t===null,this}setLink(t){let e=Jf(t);if(e&&!this._title.trim())throw new TypeError("A linked Card requires a non-empty title");return this._link=e,this.el.dataset.linked=e?"true":"false",this._renderHeading(),this}destroy(){this._cleaned||(this._cleaned=!0,this._actionAbort?.abort(),this._linkAbort?.abort(),super.destroy(),this._createdRoot||k(this.el,this._original))}_renderHeading(){let t=this._title,e=new AbortController,i=this._link?l("a",{class:"zx-card__primary",href:this._link.href,target:this._link.target,rel:this._link.rel},t):l("span",{class:"zx-card__title"},t);this._link?.onclick&&i.addEventListener("click",this._link.onclick,{signal:e.signal}),this._linkAbort?.abort(),this._linkAbort=e,this.refs.heading.replaceChildren(i),this.refs.heading.hidden=t==="",t?this.el.setAttribute("aria-labelledby",this.refs.heading.id):this.el.removeAttribute("aria-labelledby"),this._syncHeader()}_syncHeader(){this.refs.header&&(this.refs.header.hidden=this._title===""&&this.refs.actions.childElementCount===0)}};function zn(s,t,e){if(t===null){s.replaceChildren();return}if(typeof t=="string"){s.textContent=t;return}let i=t instanceof b?t.toElement():t;if(i instanceof Node){s.replaceChildren(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}function Jf(s){if(s===null)return null;let t=typeof s=="string"?{href:s}:s;if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Card link must be a URL string, descriptor, or null");let e=it(t.href);if(e===null)throw new TypeError("Card link requires a safe non-empty href");if(t.onclick!==void 0&&typeof t.onclick!="function")throw new TypeError("Card link onclick must be a function");let i=t.target==null?void 0:String(t.target),n=t.rel==null?"":String(t.rel).trim();return i==="_blank"&&!/(^|\s)noopener(\s|$)/i.test(n)&&(n=`${n} noopener`.trim()),{href:e,target:i,rel:n||void 0,onclick:t.onclick}}function Zf(s){return["raised","filled"].includes(String(s))?s:"outlined"}function tp(s){return s==="horizontal"?"horizontal":"vertical"}function ep(s){let t=Math.trunc(Number(s));return t>=1&&t<=6?t:3}var ip=Object.freeze(["source","confluence","horizon","diagonal","edge","curtain"]),sp=Object.freeze(["subtle","balanced","vivid"]),qi=Object.freeze(["--zx-aurora-color-1","--zx-aurora-color-2","--zx-aurora-color-3","--zx-aurora-color-4"]),Tn=class extends b{static cssName="aurora";static defaults={preset:"source",colors:[],intensity:"subtle"};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("div");return this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._cleaned=!1,this._initialColors=qi.map(i=>({property:i,value:e.style.getPropertyValue(i),priority:e.style.getPropertyPriority(i)})),this._colors=[],this.setPreset(this.options.preset),this.setIntensity(this.options.intensity),this.setColors(this.options.colors),e}setPreset(t){return this.el.dataset.preset=np(t),this}setColors(t){let e=op(t),i=ap(e);if(this._colors=[...e],this.el.dataset.colors=e.length===0?"semantic":String(e.length),i.length===0){for(let n of this._initialColors)n.value?this.el.style.setProperty(n.property,n.value,n.priority):this.el.style.removeProperty(n.property);return this}for(let n=0;n<qi.length;n+=1)this.el.style.setProperty(qi[n],i[n]);return this}setIntensity(t){return this.el.dataset.intensity=rp(t),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),this._createdRoot||k(this.el,this._original))}};function np(s){let t=String(s??"").trim().toLowerCase();if(!ip.includes(t))throw new TypeError(`Unknown Aurora preset: ${s}`);return t}function rp(s){let t=String(s??"").trim().toLowerCase();if(!sp.includes(t))throw new TypeError(`Unknown Aurora intensity: ${s}`);return t}function op(s){if(s==null)return[];if(!Array.isArray(s))throw new TypeError("Aurora colors must be an array");if(s.length>qi.length)throw new TypeError("Aurora accepts at most four colors");return s.map(t=>{if(!Ft(t))throw new TypeError(`Invalid Aurora color: ${t}`);return t.trim()})}function ap(s){return s.length===0?[]:s.length===1?[s[0],s[0],s[0],s[0]]:s.length===2?[s[0],s[1],s[0],s[1]]:s.length===3?[s[0],s[1],s[2],s[1]]:[...s]}var Dn=class extends b{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??l("section");this.el=e,this._createdRoot=t,this._original=t?null:lp(e),this._cleaned=!1,this._open=!!this.options.open,this._collapsible=!!this.options.collapsible,this._hasFooterContent=!1;let i=t?[]:Array.from(e.childNodes),n=x("zx-panel-body"),r=l("span",{class:"zx-panel__title",ref:"title"}),o=[];this._collapsible&&o.push(l("span",{class:"zx-panel__chevron",ariaHidden:"true"},g("chevron-right",{size:16}))),o.push(r);let a=this._collapsible?l("button",{class:"zx-panel__toggle",ref:"toggle",type:"button",ariaControls:n,ariaExpanded:String(this._open)},o):l("div",{class:"zx-panel__toggle",ref:"toggle"},o),c=l("div",{class:"zx-panel__header",ref:"header"},a,l("div",{class:"zx-panel__buttons",ref:"buttons",role:"group",ariaLabel:"Panel actions"})),h=l("div",{class:"zx-panel__content",ref:"content"}),d=l("div",{class:"zx-panel__body",ref:"body",id:n},h),u=l("div",{class:"zx-panel__footer",ref:"footer",hidden:!0},l("div",{class:"zx-panel__footer-content",ref:"footerContent"}),l("div",{class:"zx-panel__footer-buttons",ref:"footerButtons",role:"group",ariaLabel:"Panel footer actions"}));return e.replaceChildren(c,d,u),this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):h.append(...i),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),this.setFooterButtons(this.options.footerButtons),this._syncOpenState(),this._collapsible&&this.listen(a,"click",()=>this.toggle()),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return al(this.refs.content,t,"Panel content"),this}setButtons(t){return this.refs.buttons.replaceChildren(...this._buildButtons(t,"Panel buttons")),this}setFooter(t){return al(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&&cp(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(i=>{if(F(i))return i;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`${e} must be Elements or button descriptors`);let n={...i},r=n.onclick;delete n.onclick;let o=W(n);return typeof r=="function"&&this.listen(o,"click",r),o})}};function lp(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function cp(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function al(s,t,e){if(s.replaceChildren(),t===null)return;if(typeof t=="string"){s.append(document.createTextNode(t));return}let i=t instanceof b?t.toElement():t;if(i&&typeof i.nodeType=="number"){s.append(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}var hp=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"]),In=class extends b{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??l("section");this.el=e,this._createdRoot=t,this._original=t?null:dp(e),this._cleaned=!1;let i=t?[]:Array.from(e.childNodes),n=l("header",{class:"zx-master-panel__header"},l("h1",{class:"zx-master-panel__title",ref:"title"}),l("div",{class:"zx-master-panel__buttons",ref:"buttons",role:"group",ariaLabel:"Panel actions"})),r=l("div",{class:"zx-master-panel__content",ref:"content"}),o=l("footer",{class:"zx-master-panel__footer",ref:"footer",hidden:!0});e.replaceChildren(n,r,o);let a=fp(this.options.module);return e.dataset.module=a,e.style.setProperty("--zx-master-panel-accent",`var(--zx-module-${a})`),this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):r.append(...i),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return ll(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(i=>{if(F(i))return i;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("MasterPanel buttons must be Elements or button descriptors");let n={...i},r=n.onclick;delete n.onclick;let o=W(n);return typeof r=="function"&&this.listen(o,"click",r),o});return this.refs.buttons.replaceChildren(...e),this}setFooter(t){return ll(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&&up(this.el,this._original))}};function dp(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function up(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function ll(s,t,e){if(s.replaceChildren(),t===null)return;if(typeof t=="string"){s.append(document.createTextNode(t));return}let i=t instanceof b?t.toElement():t;if(i&&typeof i.nodeType=="number"){s.append(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}function fp(s){let t=String(s??"default").toLowerCase();return hp.includes(t)?t:"default"}function me(s,t){if(!s)throw new TypeError("dragAxis requires a handle element");if(typeof t?.onMove!="function")throw new TypeError("dragAxis requires an onMove callback");let e=t.orientation==="vertical",i=new AbortController,{signal:n}=i,r=!1,o=null,a=0,c=0,h=!1,d=0,u=y=>e?y.clientY:y.clientX,p=()=>!!t.disabled?.(),f=()=>{let y=o;if(o=null,y!==null)try{s.releasePointerCapture(y)}catch{}},_=()=>{d!==0&&(cancelAnimationFrame(d),d=0)},m=()=>{r=!1,h=!1,_(),f()};s.addEventListener("pointerdown",y=>{let v=y;if(!(p()||r||v.button!==0)&&t.onStart?.(v)!==!1){r=!0,o=v.pointerId,a=u(v),c=a,h=!1;try{s.setPointerCapture(v.pointerId)}catch{}}},{signal:n}),s.addEventListener("pointermove",y=>{let v=y;!r||v.pointerId!==o||(c=u(v),c!==a&&(h=!0),d===0&&(d=requestAnimationFrame(()=>{d=0,r&&t.onMove(c-a)})))},{signal:n});let w=y=>{let v=y;if(!r||v.pointerId!==o)return;_(),c=u(v);let S=h,z=c-a;m(),t.onEnd?.(z,S)};return s.addEventListener("pointerup",w,{signal:n}),s.addEventListener("pointercancel",w,{signal:n}),s.addEventListener("keydown",y=>{let v=y;if(p())return;if((v.key==="Enter"||v.key===" ")&&t.onActivate){v.preventDefault(),t.onActivate();return}if(v.key==="Home"||v.key==="End"){if(!t.onJump)return;v.preventDefault(),t.onJump(v.key==="Home"?"min":"max");return}let S=e?"ArrowUp":"ArrowLeft",z=e?"ArrowDown":"ArrowRight";v.key!==S&&v.key!==z||t.onStep&&(v.preventDefault(),t.onStep(v.key===z?1:-1,v.shiftKey))},{signal:n}),{isDragging:()=>r,cancel(){r&&m()},destroy(){m(),i.abort()}}}function pt(s,t){if(typeof s=="number")return Number.isFinite(s)?s:Number.NaN;if(typeof s!="string")return Number.NaN;let e=/^([+-]?(?:\d+\.?\d*|\.\d+))(px|%)?$/i.exec(s.trim());if(!e)return Number.NaN;let i=Number(e[1]);if(!Number.isFinite(i))return Number.NaN;if((e[2]??"").toLowerCase()!=="%")return i;let n=Number(t);return Number.isFinite(n)?i/100*n:Number.NaN}var pp="split-view",En=class extends b{static cssName="split-view";static defaults={orientation:"horizontal",start:null,end:null,size:"38%",min:160,max:null,collapsible:!1,collapsed:!1,snap:0,storageKey:null,disabled:!1,label:"Resize panes"};#t=null;#e=null;#i=null;constructor(t=null,e={}){super(t,e);let i=this.options.storageKey;if(i!=null&&i!==""){this.#e=Ye(pp);let o=this.#e.get(String(i));typeof o=="number"&&Number.isFinite(o)&&o>=0&&this.setSize(o)}let n=this.options.collapsed;n==="start"||n==="end"?this.#o(n,!1):n===!0&&this.options.collapsible&&this.#o(this.options.collapsible==="end"?"end":"start",!1);let r=this.refs.divider;this.#i=me(r,{orientation:this._orientation,disabled:()=>this._disabled,onStart:()=>{this._startSize=this.getSize(),this.el.dataset.dragging="true"},onMove:o=>this.#a(o,!1),onEnd:(o,a)=>{a&&this.#a(o,!0),delete this.el.dataset.dragging,a&&(this.#_(),this.#p())},onStep:(o,a)=>this.#l(o*(a?64:16)),onJump:o=>this.#c(o),onActivate:()=>{this.options.collapsible&&(this._collapsed===null?this.collapse(this.options.collapsible):this.expand())}}),this.listen(r,"dblclick",()=>this.#u()),typeof ResizeObserver=="function"&&(this.#t=new ResizeObserver(()=>this.#f()),this.#t.observe(this.el)),this.#n()}render(){let t=this.options;this._orientation=t.orientation==="vertical"?"vertical":"horizontal";let e=pt(t.size,Number.NaN);this._size=Number.isFinite(e)?Math.max(0,e):null,this._collapsed=null,this._disabled=!!t.disabled,this._destroyed=!1,this._startSize=0,this._lastTotal=-1,this._createdRoot=!this.el;let i=this.el??l("div");this.el=i,this._snapshot=this._createdRoot?null:A(i);let n=this._createdRoot||t.start!=null||t.end!=null?[]:Array.from(i.children),r=x("zx-split-start"),o=l("div",{class:"zx-split-view__pane",id:r,ref:"start",dataset:{pane:"start"}}),a=l("div",{class:"zx-split-view__divider",ref:"divider",role:"separator",tabindex:this._disabled?-1:0,ariaOrientation:this._orientation==="vertical"?"horizontal":"vertical",ariaLabel:String(t.label??"Resize panes"),ariaControls:r}),c=l("div",{class:"zx-split-view__pane",ref:"end",dataset:{pane:"end"}});return i.replaceChildren(o,a,c),i.dataset.orientation=this._orientation,this._disabled&&a.setAttribute("aria-disabled","true"),i.style.setProperty("--zx-split-size",ji(t.size)),t.start!=null?$i(o,t.start,"SplitView start"):n[0]&&o.append(n[0]),t.end!=null?$i(c,t.end,"SplitView end"):n[1]&&c.append(...n.slice(1)),i}setSize(t){let{total:e,divider:i,min:n,max:r}=this.#s(),o=pt(t,e>0?e:Number.NaN);return Number.isFinite(o)?(this.#r(Ht({size:o,min:n,max:r,total:e,divider:i})),this):(this._size=null,this.el.style.setProperty("--zx-split-size",ji(t)),this.#n(),this)}getSize(){if(this._collapsed==="start")return 0;let{total:t,divider:e}=this.#s();if(this._collapsed==="end")return Math.max(0,t-e);if(this._size!==null)return this._size;let i=cl(this.refs.start,this._orientation);if(i>0)return i;let n=pt(this.options.size,t);return Number.isFinite(n)?Math.max(0,n):0}getRatio(){let{total:t}=this.#s();return t>0?this.getSize()/t:0}setStart(t){return $i(this.refs.start,t,"SplitView start"),this}setEnd(t){return $i(this.refs.end,t,"SplitView end"),this}collapse(t){let e=this.options.collapsible==="end"?"end":"start";return this.#o(t==="end"?"end":t==="start"?"start":e,!0)}expand(){return this._collapsed===null?this:(this._collapsed=null,delete this.el.dataset.collapsed,this.#n(),this.emit("expand"),this)}isCollapsed(){return this._collapsed??!1}enable(){return this._disabled=!1,this.refs.divider.removeAttribute("aria-disabled"),this.refs.divider.setAttribute("tabindex","0"),this}disable(){return this._disabled=!0,this.#i?.cancel(),delete this.el.dataset.dragging,this.refs.divider.setAttribute("aria-disabled","true"),this.refs.divider.setAttribute("tabindex","-1"),this}isDisabled(){return this._disabled}destroy(){this._destroyed||(this._destroyed=!0,this.#i?.destroy(),this.#i=null,this.#t?.disconnect(),this.#t=null,super.destroy(),!this._createdRoot&&this._snapshot&&k(this.el,this._snapshot))}#s(){let t=this.el,e=this._orientation==="vertical"?t.clientHeight:t.clientWidth,i=this.options.max==null?null:Number(this.options.max);return{total:Number.isFinite(e)&&e>0?e:0,divider:cl(this.refs.divider,this._orientation),min:Math.max(0,Number(this.options.min)||0),max:Number.isFinite(i)?i:null}}#r(t){this._size=t,this.el.style.setProperty("--zx-split-size",`${t}px`),this.#n()}#n(){let{total:t,divider:e,min:i,max:n}=this.#s(),r=Ki({min:i,max:n,total:t,divider:e}),o=this.refs.divider;o.setAttribute("aria-valuemin",String(Math.round(r.min))),o.setAttribute("aria-valuemax",String(Math.round(r.max))),o.setAttribute("aria-valuenow",String(Math.round(this.getSize())))}#o(t,e){return this._collapsed===t?this:(this._collapsed=t,this.el.dataset.collapsed=t,this.#n(),e&&this.emit("collapse",{pane:t}),this)}#a(t,e){if(this._destroyed)return;let{total:i,divider:n,min:r,max:o}=this.#s();if(i<=0)return;this._collapsed!==null&&this.expand();let a=Ht({size:this._startSize+t,min:r,max:o,total:i,divider:n});e&&(a=Ht({size:hl(a,this.#d(i,n),Number(this.options.snap)),min:r,max:o,total:i,divider:n})),a!==this._size&&(this.#r(a),this.emit("resize",{size:a,ratio:a/i}))}#l(t){let{total:e,divider:i,min:n,max:r}=this.#s();e<=0||(this._collapsed!==null&&this.expand(),this.#h(Ht({size:this.getSize()+t,min:n,max:r,total:e,divider:i}),e))}#c(t){let{total:e,divider:i,min:n,max:r}=this.#s();if(e<=0)return;this._collapsed!==null&&this.expand();let o=Ki({min:n,max:r,total:e,divider:i});this.#h(Ht({size:o[t],min:n,max:r,total:e,divider:i}),e)}#h(t,e){t!==this._size&&(this.#r(t),this.emit("resize",{size:t,ratio:t/e}),this.#_(),this.#p())}#d(t,e){let{min:i,max:n}=this.#s(),r=Ki({min:i,max:n,total:t,divider:e}),o=[r.min,r.max],a=pt(this.options.size,t);return Number.isFinite(a)&&o.unshift(a),o}#u(){if(this._disabled)return;this._collapsed!==null&&this.expand();let t=pt(this.options.size,Number.NaN);Number.isFinite(t)?this.setSize(t):(this._size=null,this.el.style.setProperty("--zx-split-size",ji(this.options.size)),this._lastTotal=-1,this.#f());let{total:e}=this.#s(),i=this.getSize();this.emit("resize",{size:i,ratio:e>0?i/e:0}),this.#_(),this.#p()}#f(){if(this._destroyed||this.#i?.isDragging())return;let{total:t,divider:e,min:i,max:n}=this.#s();if(t<=0||t===this._lastTotal)return;if(this._lastTotal=t,this._size===null){let o=pt(this.options.size,t);if(Number.isFinite(o)){let a=Ht({size:o,min:i,max:n,total:t,divider:e});this.el.style.setProperty("--zx-split-size",Math.abs(a-o)>.5?`${a}px`:ji(this.options.size))}this.#n();return}let r=Ht({size:this._size,min:i,max:n,total:t,divider:e});if(r===this._size){this.#n();return}this.#r(r),this.emit("resize",{size:r,ratio:r/t})}#_(){let t=this.options.storageKey;!this.#e||t==null||t===""||(this._size===null?this.#e.remove(String(t)):this.#e.set(String(t),Math.round(this._size)))}#p(){let{total:t}=this.#s(),e=this.getSize();this.emit("resizeend",{size:e,ratio:t>0?e/t:0})}};function Ht({size:s,min:t=0,max:e=null,total:i=0,divider:n=0}){let r=Number(s),o=Ki({min:t,max:e,total:i,divider:n});return Math.max(0,(Number(i)||0)-Math.max(0,Number(n)||0))>0?Number.isFinite(r)?Math.min(o.max,Math.max(o.min,r)):o.min:Number.isFinite(r)?Math.max(0,r):o.min}function hl(s,t,e){let i=Number(s),n=Number(e);if(!Number.isFinite(i)||!Number.isFinite(n)||n<=0)return i;let r=Array.isArray(t)?t:t==null?[]:[t],o=i,a=Number.POSITIVE_INFINITY;for(let c of r){let h=Number(c);if(!Number.isFinite(h))continue;let d=Math.abs(h-i);d<=n&&d<a&&(a=d,o=h)}return o}function Ki({min:s=0,max:t=null,total:e=0,divider:i=0}){let n=Math.max(0,(Number(e)||0)-Math.max(0,Number(i)||0)),r=t==null||!Number.isFinite(Number(t))?n:Math.min(n,Math.max(0,Number(t)));return{min:Math.min(Math.max(0,Number(s)||0),r),max:r}}function cl(s,t){let e=s.getBoundingClientRect(),i=t==="vertical"?e.height:e.width;return Number.isFinite(i)&&i>0?i:0}function ji(s){return typeof s=="number"&&Number.isFinite(s)?`${s}px`:String(s)}function $i(s,t,e){if(s.replaceChildren(),t==null)return;if(typeof t=="string"||typeof t=="number"){s.append(document.createTextNode(String(t)));return}let i=t instanceof b?t.toElement():t;if(i&&typeof i.nodeType=="number"){s.append(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}var _p="dock",On=class extends b{static cssName="dock";static defaults={orientation:"vertical",content:null,panes:[],resizable:!0,collapsible:!0,lazy:!0,storageKey:null,label:"Resize panes"};constructor(t=null,e={}){super(t,e);let i=this.options.storageKey;if(i!=null&&i!==""){this._store=Ye(_p);let n=this._store.get(String(i));n&&typeof n=="object"&&this.setState(n)}this._syncGrow(),this._syncDividers()}render(){let t=this.options;this._orientation=t.orientation==="horizontal"?"horizontal":"vertical",this._resizable=t.resizable!==!1,this._lazy=t.lazy!==!1,this._destroyed=!1,this._panes=new Map,this._store=null,this._drag=null,this._dividerDrags=[],this._createdRoot=!this.el;let e=this.el??l("div");this.el=e,this._snapshot=this._createdRoot?null:A(e),e.dataset.orientation=this._orientation,e.replaceChildren(),this._content=t.content==null?null:l("div",{class:"zx-dock__content",ref:"content"}),this._content&&Nn(this._content,t.content,!1);for(let i of Array.isArray(t.panes)?t.panes:[])this._panes.set(String(i.name),this._buildPane(i));return this._layout(),e}pane(t){return this._panes.get(String(t))??null}names(){return[...this._panes.keys()]}add(t,e={}){let i=String(t?.name??"");if(!i)throw new TypeError("Dock pane requires a name");this._panes.has(i)&&this.remove(i);let n=this._buildPane(t),r=[...this._panes.entries()],o=Number.isInteger(e.index)?P(Number(e.index),0,r.length):r.length;return r.splice(o,0,[i,n]),this._panes=new Map(r),this._layout(),this._syncGrow(),this._syncDividers(),n}remove(t){let e=this._panes.get(String(t));return e?e.kind==="sheet"?this.release(e.sheet):(e.roving?.destroy(),e.element.remove(),this._panes.delete(String(t)),this._layout(),this._syncGrow(),this._syncDividers(),this):this}collapse(t){let e=this._panes.get(String(t));return!e||!e.collapsible||e.collapsed?this:(e.collapsed=!0,this._syncPaneState(e),this._syncGrow(),this._syncDividers(),this._persist(),this.emit("collapse",{name:e.name}),this)}expand(t){let e=this._panes.get(String(t));return!e||!e.collapsed?this:(e.collapsed=!1,this._syncPaneState(e),this._materialize(e),this._syncGrow(),this._syncDividers(),this._persist(),this.emit("expand",{name:e.name}),this)}toggle(t){let e=this._panes.get(String(t));return e?e.collapsed?this.expand(t):this.collapse(t):this}isCollapsed(t){return!!this._panes.get(String(t))?.collapsed}reveal(t){let e=String(t),i=this._panes.get(e);if(i)this.expand(e);else for(let n of this._panes.values())if(n.tabs?.has(e)){i=n,this.expand(n.name),this.activate(n.name,e);break}return i?(i.element.scrollIntoView({block:"nearest",inline:"nearest"}),this.emit("reveal",{name:i.name}),this):this}setSize(t,e){let i=this._panes.get(String(t));if(!i)return this;let n=Mn(e);return n===null?i.element.style.removeProperty("--zx-pane-size"):i.element.style.setProperty("--zx-pane-size",n),this._syncDividers(),this._persist(),this}getSize(t){let e=this._panes.get(String(t));return e?this._axisSize(e.element):0}activate(t,e){let i=this._panes.get(String(t)),n=i?.tabs?.get(String(e));if(!n||i.active===n.name)return this;let r=i.active;i.active=n.name;for(let o of i.tabs.values()){let a=o===n;o.tab.setAttribute("aria-selected",String(a)),o.tab.tabIndex=a?0:-1,o.panel.hidden=!a}return this._materialize(i),this._persist(),this.emit("tabchange",{pane:i.name,tab:n.name,previous:r}),this}getActive(t){return this._panes.get(String(t))?.active??null}state(){let t={sizes:{},collapsed:[],active:{}};for(let e of this._panes.values())if(e.kind!=="sheet"){if(e.collapsed)t.collapsed.push(e.name);else if(!e.grow){let i=this._axisSize(e.element);i>0&&(t.sizes[e.name]=i)}e.active&&(t.active[e.name]=e.active)}return t}setState(t){if(!t||typeof t!="object")return this;let e=new Set(Array.isArray(t.collapsed)?t.collapsed.map(String):[]);for(let i of this._panes.values()){if(i.kind==="sheet")continue;let n=t.sizes?.[i.name];typeof n=="number"&&Number.isFinite(n)&&n>0&&i.element.style.setProperty("--zx-pane-size",`${n}px`);let r=t.active?.[i.name];r&&i.tabs?.has(String(r))&&this.activate(i.name,String(r));let o=e.has(i.name);o!==i.collapsed&&i.collapsible&&(i.collapsed=o,this._syncPaneState(i))}return this._syncGrow(),this._syncDividers(),this}destroy(){if(!this._destroyed){this._destroyed=!0;for(let t of this._dividerDrags)t.destroy();this._dividerDrags=[];for(let t of this._panes.values())t.roving?.destroy(),t.breakpoint?.destroy(),t.kind==="sheet"&&t.sheet._setDock(null);super.destroy(),!this._createdRoot&&this._snapshot&&k(this.el,this._snapshot)}}_buildPane(t){let e=String(t.name),i=String(t.title??""),n=t.collapsible??this.options.collapsible!==!1,r=x("zx-dock-body"),o=Array.isArray(t.tabs)&&t.tabs.length>0,a=l("span",{class:"zx-dock__chevron",ariaHidden:"true"},g("chevron-right",{size:14})),c=l("button",{class:"zx-dock__toggle",type:"button",ariaControls:r,ariaExpanded:"true",ariaLabel:o?i||e:null},a,o?null:l("span",{class:"zx-dock__title"},i));n||(c.disabled=!0);let h=l("div",{class:"zx-dock__header"},c),d=l("div",{class:"zx-dock__body",id:r}),u=l("section",{class:"zx-dock__pane",dataset:{name:e,state:"open"}},h,d),p={name:e,title:i,element:u,header:h,body:d,toggle:c,collapsible:n,collapsed:!1,grow:!!t.grow,side:t.side==="end"?"end":"start",min:Number.isFinite(t.min)?Math.max(0,Number(t.min)):0,tabs:null,active:null,content:null,built:!1,roving:null};if(o){p.tabs=new Map;let _=l("div",{class:"zx-dock__tabs",role:"tablist",ariaOrientation:"horizontal",ariaLabel:i||e});for(let y of t.tabs){let v=String(y.name),S=x("zx-dock-tab"),z=x("zx-dock-panel"),T=l("button",{class:"zx-dock__tab",type:"button",role:"tab",id:S,ariaControls:z,ariaSelected:"false",tabindex:-1},String(y.title??v)),I=l("div",{class:"zx-dock__panel",role:"tabpanel",id:z,ariaLabelledby:S,tabindex:0,hidden:!0});_.append(T),d.append(I),p.tabs.set(v,{name:v,tab:T,panel:I,content:y.content,built:!1})}h.append(_),p.roving=Ct(_,".zx-dock__tab",{orientation:"horizontal"}),this.listen(_,"click",y=>{let v=y.target.closest?.(".zx-dock__tab");if(!v||!_.contains(v))return;let S=[...p.tabs.values()].find(z=>z.tab===v);S&&this.activate(p.name,S.name)});let m=String(t.active??""),w=p.tabs.has(m)?m:[...p.tabs.keys()][0];p.active=w;for(let y of p.tabs.values()){let v=y.name===w;y.tab.setAttribute("aria-selected",String(v)),y.tab.tabIndex=v?0:-1,y.panel.hidden=!v}}else p.content=l("div",{class:"zx-dock__pane-content"}),d.append(p.content),p.factory=t.content;let f=Mn(t.size);return f!==null&&u.style.setProperty("--zx-pane-size",f),n&&this.listen(c,"click",()=>this.toggle(p.name)),t.collapsed&&n&&(p.collapsed=!0,this._syncPaneState(p)),(!this._lazy||!p.collapsed)&&this._materialize(p),p}_materialize(t){if(!t.collapsed){if(t.tabs){let e=t.tabs.get(t.active);if(!e||e.built)return;e.built=!0,Nn(e.panel,e.content,!0);return}t.built||(t.built=!0,Nn(t.content,t.factory,!0))}}_layout(){let t=[...this._panes.values()].filter(n=>n.kind!=="sheet"||n.sheet.isDocked()),e=this._content?[...t.filter(n=>n.side==="start"),this._content,...t.filter(n=>n.side==="end")]:t;for(let n of this._dividerDrags)n.destroy();this._dividerDrags=[];let i=[];e.forEach((n,r)=>{r>0&&i.push(this._divider()),i.push(n instanceof Element?n:n.element)}),this.el.replaceChildren(...i)}_divider(){let t=l("div",{class:"zx-dock__divider",role:"separator",tabindex:this._resizable?0:-1,ariaOrientation:this._orientation==="vertical"?"horizontal":"vertical",ariaLabel:String(this.options.label??"Resize panes")});return this._dividerDrags.push(me(t,{orientation:this._orientation,disabled:()=>!this._resizable,onStart:()=>{let{before:e,after:i}=this._neighbours(t),n=this._resizeSubject(e,i);return n?(this._drag={subject:n,startSize:this._axisSize(n.element),oppositeStart:n.opposite?this._axisSize(n.opposite.element):0},this.el.dataset.dragging="true",!0):!1},onMove:e=>this._trackDelta(e),onEnd:(e,i)=>{i&&this._trackDelta(e),this._drag=null,delete this.el.dataset.dragging,i&&this._persist()},onStep:(e,i)=>this._stepDivider(t,e*(i?64:16)),onActivate:()=>{let{before:e}=this._neighbours(t);e?.collapsible&&this.toggle(e.name)}})),t}_isHidden(t){return t.kind==="sheet"?!t.sheet.isOpen():!!t.collapsed}adopt(t,e={}){if(!t||typeof t._setDock!="function"||!t.el)throw new TypeError("Dock.adopt expects a Sheet");let i=String(e.name??t.el.id??"")||x("zx-dock-sheet"),n={kind:"sheet",name:i,sheet:t,element:t.el,side:e.side==="end"?"end":"start",min:Number.isFinite(e.min)?Math.max(0,Number(e.min)):0,grow:!1,collapsed:!1,collapsible:!1,breakpoint:null,resync:null},r=[...this._panes.entries()],o=Number.isInteger(e.index)?P(Number(e.index),0,r.length):r.length;r.splice(o,0,[i,n]),this._panes=new Map(r);let a=Mn(e.size);a!==null&&t.el.style.setProperty("--zx-pane-size",a),n.resync=()=>{this._syncGrow(),this._syncDividers()},t.on("open",n.resync),t.on("close",n.resync);let c=e.dockAt??null;return c?n.breakpoint=Ue((h,d)=>{this._applyDockAt(n,sn(c,d))},{target:this.el}):this._applyDockAt(n,!0),n}release(t){let e=[...this._panes.values()].find(i=>i.sheet===t);return e?(e.breakpoint?.destroy(),e.breakpoint=null,this._panes.delete(e.name),t.off("open",e.resync),t.off("close",e.resync),t.el.style.removeProperty("--zx-pane-size"),t._setDock(null),this._layout(),this._syncGrow(),this._syncDividers(),this):this}_forget(t){let e=[...this._panes.values()].find(i=>i.sheet===t);e&&(e.breakpoint?.destroy(),this._panes.delete(e.name),!this._destroyed&&(this._layout(),this._syncGrow(),this._syncDividers()))}_applyDockAt(t,e){t.sheet.isDocked()!==e&&(t.sheet._setDock(e?this:null),this._layout(),this._syncGrow(),this._syncDividers())}_syncGrow(){let t=[...this._panes.values()];for(let n of t)n.element.removeAttribute("data-grow");if(this._content)return;let e=t.filter(n=>!this._isHidden(n));if(e.length===0)return;let i=e.find(n=>n.grow);(i??e[e.length-1]).element.dataset.grow="true"}_syncDividers(){for(let t of this._dividers()){let{before:e,after:i}=this._neighbours(t),n=this._resizeSubject(e,i),r=this._resizable&&n!==null;if(t.toggleAttribute("data-disabled",!r),t.tabIndex=r?0:-1,!r){t.removeAttribute("aria-valuenow");continue}let o=this._axisSize(this.el);t.setAttribute("aria-valuenow",String(Math.round(this._axisSize(n.element)))),t.setAttribute("aria-valuemin",String(Math.round(this._minSize(n)))),t.setAttribute("aria-valuemax",String(Math.round(o))),t.setAttribute("aria-controls",n.element.id||mp(n.element))}}_syncPaneState(t){t.element.dataset.state=t.collapsed?"collapsed":"open",t.toggle.setAttribute("aria-expanded",String(!t.collapsed))}_dividers(){return[...this.el.querySelectorAll(":scope > .zx-dock__divider")]}_neighbours(t){let e=i=>{if(!i)return null;for(let n of this._panes.values())if(n.element===i)return n;return null};return{before:e(t.previousElementSibling),after:e(t.nextElementSibling)}}_resizeSubject(t,e){let i=n=>!!n&&!this._isHidden(n)&&n.element.dataset.grow!=="true";return i(t)?{element:t.element,record:t,sign:1,opposite:i(e)?e:null}:i(e)?{element:e.element,record:e,sign:-1,opposite:null}:null}_minSize(t){let i=(t.record.header??t.record.element.querySelector(".zx-dialog__header")??t.record.element).getBoundingClientRect(),n=this._orientation==="vertical"?i.height:i.width;return Math.max(t.record.min,n)}_axisSize(t){let e=t.getBoundingClientRect();return this._orientation==="vertical"?e.height:e.width}_trackDelta(t){if(!this._drag||this._destroyed)return;let{subject:e,startSize:i,oppositeStart:n}=this._drag,r=this._minSize(e),o=Math.max(r,i+t*e.sign);if(e.opposite){let a=this._minSize({record:e.opposite,element:e.opposite.element});o=Math.max(r,Math.min(o,i+n-a)),e.opposite.element.style.setProperty("--zx-pane-size",`${i+n-o}px`)}e.element.style.setProperty("--zx-pane-size",`${o}px`),this._syncDividers(),this.emit("resize",{name:e.record.name,size:o})}_stepDivider(t,e){let{before:i,after:n}=this._neighbours(t),r=this._resizeSubject(i,n);if(!r)return;let o=Math.max(this._minSize(r),this._axisSize(r.element)+e*r.sign);r.element.style.setProperty("--zx-pane-size",`${o}px`),this._syncDividers(),this._persist(),this.emit("resize",{name:r.record.name,size:o})}_persist(){let t=this.options.storageKey;!this._store||t===null||t===void 0||t===""||this._store.set(String(t),this.state())}};function mp(s){let t=x("zx-dock-pane");return s.id=t,t}function Mn(s){return s==null||s===""?null:typeof s=="number"?Number.isFinite(s)?`${Math.max(0,s)}px`:null:String(s)}function Nn(s,t,e){let i=e&&typeof t=="function"?t():t;if(i==null)return;if(typeof i=="string"||typeof i=="number"){s.append(document.createTextNode(String(i)));return}let n=i instanceof b?i.toElement():i;n&&typeof n.nodeType=="number"&&s.append(n)}var Fn=class extends b{static cssName="navigation-bar";static defaults={title:"",items:[],active:null,actions:[]};constructor(t,e={}){super(t,e),this._overflow=new ft(this.refs.moreTrigger,{label:"More",icon:"dots",kind:"ghost",items:[],placement:"bottom-end"}),this._overflow.on("select",i=>{let n=this._find(String(i.detail.value));!n||n.definition.disabled||(this.setActive(n.definition.name),n.definition.onselect?.(n.definition.name,n.definition,this),n.definition.href&&globalThis.location?.assign(n.definition.href))}),this._syncOverflow()}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._createdRoot=t,this._original=t?null:bp(e),this._cleaned=!1,this._items=[],this._activeName=null,this._tabMode=!1,this._overflow=null;let i=l("header",{class:"zx-navigation-bar__bar"},l("div",{class:"zx-navigation-bar__brand",ref:"title"}),l("nav",{class:"zx-navigation-bar__navigation",ariaLabel:"Primary navigation"},l("div",{class:"zx-navigation-bar__items",ref:"items"}),l("div",{class:"zx-navigation-bar__more",ref:"more"},l("button",{class:"zx-navigation-bar__more-trigger",ref:"moreTrigger"}))),l("div",{class:"zx-navigation-bar__actions",ref:"actions",role:"group",ariaLabel:"Application actions"})),n=l("div",{class:"zx-navigation-bar__panels",ref:"panels",hidden:!0});return e.replaceChildren(i,n),this.setTitle(this.options.title),this.setItems(this.options.items),this.setActions(this.options.actions),this.listen(this.refs.items,"keydown",r=>this._onTabKeydown(r)),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,i=new Set,n=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(i.has(h.name))throw new RangeError(`Navigation item already exists: ${h.name}`);if(i.add(h.name),Object.hasOwn(h,"content")&&!gp(h.content))throw new TypeError(`Navigation panel content for ${h.name} is invalid`);let d={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")&&(d.content=h.content),d}),r=n.some(h=>Object.hasOwn(h,"content"));if(r&&n.some(h=>!Object.hasOwn(h,"content")))throw new TypeError("NavigationBar panel items must all define content");this._items=[],this._activeName=null,this._tabMode=r,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 n)this._appendItem(h);let o=e??this.options.active,a=o===null?null:this._find(o),c=a&&!a.definition.disabled?a: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 i=this._require(t);return i.definition.badge=e===null?null:String(e),i.badge.textContent=i.definition.badge??"",i.badge.hidden=i.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(i=>{if(F(i))return i;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("NavigationBar actions must be Elements or button descriptors");let n={...i},r=n.onclick;delete n.onclick;let o=W(n);return typeof r=="function"&&this.listen(o,"click",r),o});return this.refs.actions.replaceChildren(...e),this}destroy(){this._cleaned||(this._cleaned=!0,this._overflow?.destroy(),super.destroy(),!this._createdRoot&&this._original&&yp(this.el,this._original))}_appendItem(t){let e=x("zx-navigation-item"),i=x("zx-navigation-panel"),n=l("span",{class:"zx-navigation-bar__badge",hidden:t.badge===null},t.badge??""),r={class:"zx-navigation-bar__item",id:e,ariaDisabled:t.disabled?"true":null},o;this._tabMode?o=l("button",{...r,type:"button",role:"tab",tabindex:"-1",ariaControls:i,ariaSelected:"false"},l("span",{class:"zx-navigation-bar__label"},t.title),n):t.href?o=l("a",{...r,href:t.href},l("span",{class:"zx-navigation-bar__label"},t.title),n):o=l("button",{...r,type:"button"},l("span",{class:"zx-navigation-bar__label"},t.title),n);let a=null;this._tabMode&&(a=l("div",{class:"zx-navigation-bar__panel",id:i,role:"tabpanel",tabindex:"0",ariaLabelledby:e,hidden:!0}),this.refs.panels.append(a));let c={definition:t,item:o,badge:n,panel:a,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 i=e===t;this._tabMode?(e.item.setAttribute("aria-selected",String(i)),e.item.tabIndex=i?0:-1,e.panel&&(e.panel.hidden=!i)):i?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,i=typeof e=="function"?e():e,n=i instanceof b?i.toElement():i;if(!n||typeof n.nodeType!="number")throw new TypeError(`Navigation panel factory for ${t.definition.name} must return a Node or Component`);t.panel.append(n),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 i=this._items.find(r=>r.item===e);if(!i)return;let n=this._enabledItems();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let r=t.key==="ArrowRight"?1:-1,o=n.indexOf(i),a=n[(o+r+n.length)%n.length];a&&this._focusTab(a);return}if(t.key==="Home"||t.key==="End"){t.preventDefault();let r=t.key==="Home"?n[0]:n[n.length-1];r&&this._focusTab(r);return}(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.setActive(i.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 gp(s){return typeof s=="function"||s instanceof b?!0:!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function bp(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function yp(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function ul(s){if(!Array.isArray(s))throw new TypeError("Stepper steps must be an array");let t=new Set;return s.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Step definition must be an object");if(typeof e.name!="string"||e.name==="")throw new TypeError("Step name must be a non-empty string");if(t.has(e.name))throw new RangeError(`Step already exists: ${e.name}`);return t.add(e.name),{name:e.name,title:String(e.title??""),description:e.description==null?null:String(e.description),optional:!!e.optional,disabled:!!e.disabled}})}function Ui(s,t){return t===null?-1:s.findIndex(e=>e.name===t)}function Yi(s,t,e){let i=e<0?-1:1,n=t<0?i>0?0:s.length-1:t+i;for(;n>=0&&n<s.length;){if(!s[n].disabled)return n;n+=i}return-1}function fl(s,t,e){return t<0||e<=t?[]:s.slice(t,e).map(i=>i.name)}function pl(s,t,e={}){let{activeIndex:i=-1,completed:n,errored:r}=e;return dl(r,s.name)?"error":t===i?"active":dl(n,s.name)?"complete":"upcoming"}function dl(s,t){return s?s instanceof Set?s.has(t):s.includes(t):!1}var wp=new Set(["horizontal","vertical"]),vp=new Set(["completed","all",!1]),Rn=class extends b{static cssName="stepper";static defaults={steps:[],active:null,orientation:"horizontal",clickable:"completed",showNumbers:!0,counter:!1};constructor(t,e={}){super(t,e)}render(){if(this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._steps=[],this._records=[],this._activeIndex=-1,this._completed=new Set,this._errored=new Set,!wp.has(this.options.orientation))throw new RangeError(`Unknown stepper orientation: ${this.options.orientation}`);if(!vp.has(this.options.clickable))throw new RangeError(`Unknown stepper clickable mode: ${this.options.clickable}`);let t=this.el??l("div");this.el=t,t.dataset.orientation=this.options.orientation;let e=l("p",{class:"zx-stepper__counter",ref:"counter",ariaLive:"polite",hidden:!0}),i=l("ol",{class:"zx-stepper__list",ref:"list"});return t.replaceChildren(...this.options.counter?[e,i]:[i]),this.setSteps(this.options.steps),this.listen(i,"click",n=>{let r=n.target.closest?.(".zx-stepper__control");if(!r||!i.contains(r)||r.tagName!=="BUTTON")return;let o=r.dataset.step;typeof o=="string"&&this.goTo(o)}),t}setSteps(t){let e=this.getActive(),i=ul(t),n=new Set(i.map(a=>a.name));this._steps=i,this._completed=new Set([...this._completed].filter(a=>n.has(a))),this._errored=new Set([...this._errored].filter(a=>n.has(a)));let r=e??(this.options.active===null?null:String(this.options.active)),o=r===null?-1:Ui(i,r);return o>=0&&i[o].disabled&&(o=-1),o<0&&(o=Yi(i,-1,1)),this._activeIndex=o,this._records=i.map(a=>this._createRecord(a)),this.refs.list.replaceChildren(...this._records.map(a=>a.item)),this._sync(),this}goTo(t){let e=Ui(this._steps,t);if(e<0)throw new RangeError(`Unknown step: ${t}`);return this._activate(e)}next(){return this._activate(Yi(this._steps,this._activeIndex,1))}previous(){return this._activate(Yi(this._steps,this._activeIndex,-1))}getActive(){return this._activeIndex<0?null:this._steps[this._activeIndex].name}getIndex(){return this._activeIndex}complete(t){return this._require(t),this._completed.add(t),this._sync(),this}uncomplete(t){return this._require(t),this._completed.delete(t),this._sync(),this}setError(t,e=!0){return this._require(t),e?this._errored.add(t):this._errored.delete(t),this._sync(),this}setDisabled(t,e=!0){return this._require(t).disabled=!!e,this._sync(),this}getState(){return{active:this.getActive(),index:this._activeIndex,completed:this._steps.filter(t=>this._completed.has(t.name)).map(t=>t.name),errored:this._steps.filter(t=>this._errored.has(t.name)).map(t=>t.name)}}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&k(t,this._snapshot)}_activate(t){if(t<0||t>=this._steps.length||t===this._activeIndex)return this;let e=this._steps[t];if(e.disabled)return this;let i=this._activeIndex;if(this.emit("change",{name:e.name,previous:i<0?null:this._steps[i].name,index:t}).defaultPrevented)return this;for(let r of fl(this._steps,i,t))this._completed.add(r);return this._activeIndex=t,this._sync(),this}_createRecord(t){let e=l("span",{class:"zx-stepper__marker",ariaHidden:"true"}),i=l("span",{class:"zx-stepper__status"}),n=[l("span",{class:"zx-stepper__title"},t.title)];t.description&&n.push(l("span",{class:"zx-stepper__description"},t.description)),t.optional&&n.push(l("span",{class:"zx-stepper__optional"},this._message("stepper.optional","Optional")));let r=[e,l("span",{class:"zx-stepper__text"},n),i],o=this.options.clickable===!1?l("span",{class:"zx-stepper__control"},r):l("button",{class:"zx-stepper__control",type:"button",dataset:{step:t.name}},r);return{step:t,item:l("li",{class:"zx-stepper__step"},o),control:o,marker:e,status:i}}_sync(){this._records.forEach((t,e)=>{let i=this._stateFor(t.step,e);t.item.dataset.state=i,e===this._activeIndex?t.item.setAttribute("aria-current","step"):t.item.removeAttribute("aria-current"),t.item.toggleAttribute("data-disabled",t.step.disabled),t.marker.replaceChildren(...this._markerContent(i,e)),t.status.textContent=this._statusText(i),t.control.tagName==="BUTTON"&&(t.control.disabled=!this._isClickable(t.step))}),this._syncCounter()}_stateFor(t,e){return pl(t,e,{activeIndex:this._activeIndex,completed:this._completed,errored:this._errored})}_markerContent(t,e){return t==="complete"?[g("check",{size:12})]:t==="error"?[g("warning",{size:12})]:this.options.showNumbers?[String(e+1)]:[]}_statusText(t){return t==="complete"?this._message("stepper.completed","Completed"):t==="error"?this._message("stepper.error","Error"):t==="active"?this._message("stepper.current","Current step"):""}_isClickable(t){return t.disabled?!1:this.options.clickable==="all"?!0:this.options.clickable==="completed"?this._completed.has(t.name):!1}_syncCounter(){if(!this.options.counter)return;let t=this.refs.counter;t.hidden=this._activeIndex<0,t.textContent=this._activeIndex<0?"":this._message("stepper.counter","Step %1 of %2",this._activeIndex+1,this._steps.length)}_require(t){let e=Ui(this._steps,t);if(e<0)throw new RangeError(`Unknown step: ${t}`);return this._steps[e]}_message(t,e,...i){let n=this.msg(t,...i);return n===t?V(e,i):n}};var xp=new Set(["chevron","slash"]),Ln=class extends b{static cssName="breadcrumb";static defaults={items:[],maxVisible:0,separator:"chevron",rootIcon:null};constructor(t,e={}){super(t,e)}render(){if(this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._items=[],this._overflow=null,!xp.has(this.options.separator))throw new RangeError(`Unknown breadcrumb separator: ${this.options.separator}`);let t=this.el??l("nav");this.el=t,t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.setAttribute("aria-label",this._message("breadcrumb.label","Breadcrumb"));let e=l("ol",{class:"zx-breadcrumb__list",ref:"list"});return t.replaceChildren(e),this.setItems(this.options.items),this.listen(e,"click",i=>{let n=i.target.closest?.("[data-crumb]");!n||!e.contains(n)||this._select(n.dataset.crumb)}),t}setItems(t){if(!Array.isArray(t))throw new TypeError("Breadcrumb items must be an array");let e=new Set;return this._items=t.map(i=>{if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Breadcrumb item must be an object");if(typeof i.name!="string"||i.name==="")throw new TypeError("Breadcrumb item name must be a non-empty string");if(e.has(i.name))throw new RangeError(`Breadcrumb item already exists: ${i.name}`);return e.add(i.name),{name:i.name,label:String(i.label??""),icon:i.icon?String(i.icon):null,href:i.href==null?null:String(i.href)}}),this._build(),this}getItems(){return this._items.map(t=>({...t}))}push(t){return this.setItems([...this._items,t])}pop(){if(this._items.length===0)return null;let t=this._items[this._items.length-1];return this.setItems(this._items.slice(0,-1)),t}truncateTo(t){let e=this._items.findIndex(i=>i.name===t);if(e<0)throw new RangeError(`Unknown breadcrumb item: ${t}`);return this.setItems(this._items.slice(0,e+1))}destroy(){if(this._destroyed)return;this._destroyed=!0,this._overflow?.destroy(),this._overflow=null;let t=this.el;super.destroy(),!this._createdRoot&&t&&k(t,this._snapshot)}_build(){let{head:t,hidden:e,tail:i}=this._split(),n=this._items[this._items.length-1]??null,r=[];for(let o of t)r.push(this._renderItem(o,o===n));e.length>0&&r.push(this._renderOverflow(e));for(let o of i)r.push(this._renderItem(o,o===n));this.refs.list.replaceChildren(...r.map((o,a)=>l("li",{class:"zx-breadcrumb__item"},a===0?o:[this._renderSeparator(),o]))),e.length===0&&this._overflow?.toElement().remove()}_split(){let t=this._items,e=Math.trunc(Number(this.options.maxVisible)||0);if(e<=0||t.length<=e)return{head:t,hidden:[],tail:[]};let i=Math.max(2,e);if(t.length<=i)return{head:t,hidden:[],tail:[]};let n=i-1;return{head:t.slice(0,1),hidden:t.slice(1,t.length-n),tail:t.slice(t.length-n)}}_renderItem(t,e){let i=[],n=t.icon??(t===this._items[0]?this.options.rootIcon:null);return n&&i.push(l("span",{class:"zx-breadcrumb__icon",ariaHidden:"true"},g(String(n),{size:13}))),i.push(l("span",{class:"zx-breadcrumb__label"},t.label)),e?l("span",{class:"zx-breadcrumb__current",ariaCurrent:"page"},i):t.href!==null?l("a",{class:"zx-breadcrumb__link",href:t.href,dataset:{crumb:t.name}},i):l("button",{class:"zx-breadcrumb__link",type:"button",dataset:{crumb:t.name}},i)}_renderOverflow(t){if(!this._overflow){this._overflow=new ft(null,{label:"",icon:"dots",kind:"ghost",placement:"bottom-start"});let e=this._overflow.toElement();e.classList.add("zx-breadcrumb__more"),e.setAttribute("aria-label",this._message("breadcrumb.more","Show hidden levels")),this._overflow.on("select",i=>this._select(String(i.detail.value)))}return this._overflow.setItems(t.map(e=>({label:e.label,value:e.name,icon:e.icon??void 0}))),this._overflow.toElement()}_renderSeparator(){return l("span",{class:"zx-breadcrumb__separator",ariaHidden:"true"},this.options.separator==="slash"?"/":g("chevron-right",{size:11}))}_select(t){let e=this._items.findIndex(i=>i.name===t);e<0||this.emit("select",{name:this._items[e].name,item:{...this._items[e]},index:e})}_message(t,e,...i){let n=this.msg(t,...i);return n===t?V(e,i):n}};var Gi="\u2026",Sp=new Set(["pages","loadmore"]);function _l({page:s=1,pages:t=1,siblings:e=1,boundaries:i=1}={}){let n=te(t);if(n<=0)return[];let r=Bn(te(s)||1,1,n),o=Math.max(0,te(e)),a=Math.max(0,te(i)),c=a*2+o*2+3;if(n<=c)return Wi(1,n);let h=Wi(1,Math.min(a,n)),d=Wi(Math.max(n-a+1,a+1),n),u=Math.max(Math.min(r-o,n-a-o*2-1),a+2),p=Math.min(Math.max(r+o,a+o*2+2),d.length>0?d[0]-2:n-1);return[...h,...u>a+2?[Gi]:a+1<n-a?[a+1]:[],...Wi(u,p),...p<n-a-1?[Gi]:n-a>a?[n-a]:[],...d]}var Vn=class extends b{static cssName="pagination";static defaults={page:1,pageSize:25,total:0,pageSizes:[25,50,100],siblings:1,boundaries:1,showPageSize:!0,showSummary:!0,mode:"pages",disabled:!1};constructor(t,e={}){super(t,e)}render(){if(this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._pageSize=Pn(this.options.pageSize,25),this._total=Math.max(0,te(this.options.total)),this._page=Math.max(1,te(this.options.page)||1),this._disabled=!!this.options.disabled,this._sizeKey="",this._pageSizes=(Array.isArray(this.options.pageSizes)?this.options.pageSizes:[]).map(i=>Pn(i,0)).filter(i=>i>0),!Sp.has(this.options.mode))throw new RangeError(`Unknown pagination mode: ${this.options.mode}`);this._page=Bn(this._page,1,this._pageCount());let t=this.el??l("nav");this.el=t,t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.setAttribute("aria-label",this._message("pagination.label","Pagination")),t.dataset.mode=this.options.mode;let e=[];return this.options.showSummary&&e.push(l("span",{class:"zx-pagination__summary",ref:"summary",ariaLive:"polite"})),e.push(l("span",{class:"zx-pagination__spacer"})),this.options.showPageSize&&e.push(this._renderPageSize()),e.push(this.options.mode==="pages"?this._renderPages():this._renderLoadMore()),t.replaceChildren(...e),this._sync(),this._wire(),t}setPage(t){return this.setState({page:t})}setTotal(t){return this.setState({total:t},{silent:!0})}setPageSize(t){return this.setState({pageSize:t,page:1})}setState(t={},{silent:e=!1}={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Pagination state must be an object");let i=this._page,n=this._pageSize;if(Object.hasOwn(t,"total")&&(this._total=Math.max(0,te(t.total))),Object.hasOwn(t,"pageSize")&&(this._pageSize=Pn(t.pageSize,this._pageSize)),Object.hasOwn(t,"page")){let r=Math.trunc(Number(t.page));Number.isFinite(r)&&(this._page=r)}return this._page=Bn(this._page,1,this._pageCount()),this._sync(),!e&&(this._page!==i||this._pageSize!==n)&&this.emit("change",this.getState()),this}getState(){let t=this._pageCount();return{page:this._page,pageSize:this._pageSize,total:this._total,pages:t,offset:(this._page-1)*this._pageSize}}enable(){return this._disabled=!1,this._sync(),this}disable(){return this._disabled=!0,this._sync(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&k(t,this._snapshot)}_pageCount(){return this._total<=0?1:Math.ceil(this._total/this._pageSize)}_renderPageSize(){let t=this._message("pagination.pageSize","Rows per page");return l("label",{class:"zx-pagination__size"},l("span",{class:"zx-pagination__size-label"},t),l("select",{class:"zx-pagination__select",ref:"select",ariaLabel:t}))}_renderPages(){return l("div",{class:"zx-pagination__controls"},this._navButton("prev","chevron-left",this._message("pagination.previous","Previous page")),l("div",{class:"zx-pagination__pages",ref:"pages"}),this._navButton("next","chevron-right",this._message("pagination.next","Next page")))}_navButton(t,e,i){return l("button",{class:"zx-btn zx-pagination__nav",type:"button",ref:t,ariaLabel:i,dataset:{kind:"default",size:"sm"}},g(e,{size:14}))}_renderLoadMore(){return l("button",{class:"zx-btn zx-pagination__more",type:"button",ref:"more",dataset:{kind:"default",size:"md"}},l("span",{class:"zx-btn__label"},this._message("pagination.loadMore","Load more")))}_wire(){if(this.refs.select&&this.listen(this.refs.select,"change",()=>{this.setPageSize(Number(this.refs.select.value))}),this.options.mode==="pages"){this.listen(this.refs.prev,"click",()=>this.setPage(this._page-1)),this.listen(this.refs.next,"click",()=>this.setPage(this._page+1)),this.listen(this.refs.pages,"click",t=>{let e=t.target.closest?.("[data-page]");!e||!this.refs.pages.contains(e)||this.setPage(Number(e.dataset.page))});return}this.listen(this.refs.more,"click",()=>this.setPage(this._page+1))}_sync(){let t=this._pageCount();if(this.el.dataset.disabled=this._disabled?"true":"false",this.refs.summary&&(this.refs.summary.textContent=this._summary()),this.refs.select&&this._syncPageSize(),this.options.mode==="pages"){this.refs.prev.disabled=this._disabled||this._page<=1,this.refs.next.disabled=this._disabled||this._page>=t,this._syncPages(t);return}this.refs.more.disabled=this._disabled||this._page>=t}_summary(){if(this._total<=0)return this._message("pagination.empty","0 of 0");let t=(this._page-1)*this._pageSize,e=Math.min(t+this._pageSize,this._total);return this.options.mode==="loadmore"?this._message("pagination.loaded","%1 of %2",si(e),si(this._total)):this._message("pagination.summary","%1\u2013%2 of %3",si(t+1),si(e),si(this._total))}_syncPageSize(){let t=this.refs.select,e=[...new Set([...this._pageSizes,this._pageSize])].sort((n,r)=>n-r),i=e.join(",");i!==this._sizeKey&&(this._sizeKey=i,t.replaceChildren(...e.map(n=>l("option",{value:String(n)},String(n))))),t.value=String(this._pageSize),t.disabled=this._disabled}_syncPages(t){let e=this.refs.pages,i=this.el.ownerDocument?.activeElement??null,n=i&&e.contains(i)?i.dataset.page??null:null,r=_l({page:this._page,pages:t,siblings:this.options.siblings,boundaries:this.options.boundaries});if(e.replaceChildren(...r.map(a=>a===Gi?l("span",{class:"zx-pagination__ellipsis",ariaHidden:"true"},Gi):l("button",{class:"zx-btn zx-pagination__page",type:"button",disabled:this._disabled,ariaCurrent:a===this._page?"page":null,ariaLabel:this._message("pagination.page","Page %1",a),dataset:{kind:"default",size:"sm",page:String(a)}},String(a)))),n===null)return;let o=e.querySelector(`[data-page="${n}"]`);o&&!o.disabled&&o.focus()}_message(t,e,...i){let n=this.msg(t,...i);return n===t?V(e,i):n}};function te(s){let t=Math.trunc(Number(s));return Number.isFinite(t)&&t>0?t:0}function Pn(s,t){let e=Math.trunc(Number(s));return Number.isFinite(e)&&e>0?e:t}function Bn(s,t,e){return Math.min(Math.max(s,t),e)}function Wi(s,t){return t<s?[]:Array.from({length:t-s+1},(e,i)=>s+i)}function si(s){return s.toLocaleString()}var Qi=class extends b{static cssName="app-icon";static defaults={icon:null,color:null,size:36,iconSize:"52%",label:null,badge:null,selected:!1,shape:"tile",glass:"subtle",class:[]};render(){this._createdRoot=this.el===null;let t=this.el??l("span");return this.el=t,this._snapshot=this._createdRoot?null:A(t),this._interactiveRoot=t.matches('a[href], button, input, select, textarea, [role="button"], [role="link"]'),this._state={...this.options},this._appliedClasses=[],this._sync(),t}set(t={}){return!t||typeof t!="object"?this:(Object.assign(this._state,t),this._sync(),this)}destroy(){let t=this.el,e=this._snapshot;super.destroy(),!this._createdRoot&&t&&k(t,e)}_sync(){let t=this._state;this.el.classList.remove(...this._appliedClasses),this._appliedClasses=[t.class].flat().flatMap(h=>String(h??"").split(/\s+/)).filter(Boolean),this.el.classList.add(...this._appliedClasses);let e=ml(t.size,"36px"),i=ml(t.iconSize,"52%");this.el.style.setProperty("--zx-app-icon-size",e),this.el.style.setProperty("--zx-app-icon-glyph-size",i),Ft(t.color)?this.el.style.setProperty("--zx-app-icon-color",String(t.color)):this.el.style.removeProperty("--zx-app-icon-color"),this.el.dataset.glass=zp(t.glass),this.el.dataset.shape=Cp(t.shape),this.el.toggleAttribute("data-selected",!!t.selected);let n=t.label==null?"":String(t.label).trim();if(this._interactiveRoot){let h=gl(this._snapshot,"role"),d=gl(this._snapshot,"aria-label");h===null?this.el.removeAttribute("role"):this.el.setAttribute("role",h),n?this.el.setAttribute("aria-label",n):d===null?this.el.removeAttribute("aria-label"):this.el.setAttribute("aria-label",d),this.el.removeAttribute("aria-hidden")}else n?(this.el.setAttribute("role","img"),this.el.setAttribute("aria-label",n),this.el.removeAttribute("aria-hidden")):(this.el.removeAttribute("role"),this.el.removeAttribute("aria-label"),this.el.setAttribute("aria-hidden","true"));let r=Ap(t.icon),o=t.badge==null||t.badge===""?null:l("span",{class:"zx-app-icon__badge",ariaHidden:"true"},String(t.badge)),c=[l("span",{class:"zx-app-icon__surface",ariaHidden:"true"},l("span",{class:"zx-app-icon__shine",ariaHidden:"true"}),l("span",{class:"zx-app-icon__glyph",ariaHidden:"true"},r))];o&&c.push(o),this.el.replaceChildren(...c)}};function kp(s={}){return new Qi(null,s).toElement()}function Ap(s){let t=typeof s=="function"?s():s;return typeof t=="string"?g(t,{size:"1em"}):t&&typeof t=="object"&&typeof t.nodeType=="number"?t:null}function ml(s,t){if(typeof s=="number"&&Number.isFinite(s))return`${Math.max(1,s)}px`;let e=String(s??"").trim();return e&&!/[;{}]/.test(e)?e:t}function zp(s){return s===!1||s==="none"?"none":s==="strong"?"strong":"subtle"}function Cp(s){return s==="circle"?"circle":"tile"}function gl(s,t){return s?.attributes.find(([e])=>e===t)?.[1]??null}var qn=class extends b{static cssName="launcher";static defaults={items:[],sources:[],query:"",debounce:250,minQuery:0,maxResults:100,placeholder:"Search applications and records",label:"Launcher",closeLabel:"Close launcher",resultsLabel:"Launcher results",emptyText:"No results",loadingText:"Searching\u2026",shortcut:"mod+k",hints:{move:"Move",open:"Open",close:"Close"},scope:null};constructor(t=null,e={}){super(t,e)}render(){if(this.el!==null&&!(this.el instanceof HTMLDialogElement))throw new TypeError("Launcher target must be a <dialog> element");this._createdRoot=this.el===null;let t=this.el??l("dialog");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,h=>[h.name,h.value]),children:Array.from(t.childNodes)},this._items=Hn(this.options.items),this._sources=yl(this.options.sources),this._sourceItems=new Map,this._query=String(this.options.query??""),this._renderedQuery=null,this._results=[],this._active=-1,this._request=null,this._requestSequence=0,this._queryTimer=null,this._busy=!1,this._destroyed=!1;let e=x("zx-launcher-results"),i=l("input",{ref:"input",class:"zx-launcher__input",type:"search",role:"combobox",autocomplete:"off",spellcheck:!1,ariaAutocomplete:"list",ariaControls:e,ariaExpanded:"false",ariaLabel:this.options.label,placeholder:this.options.placeholder,value:this._query}),n=l("button",{ref:"close",class:"zx-icon-btn zx-launcher__close",type:"button",ariaLabel:this.options.closeLabel},g("x")),r=l("div",{ref:"status",class:"zx-launcher__status",role:"status",ariaLive:"polite"}),o=l("div",{ref:"results",class:"zx-launcher__results",id:e,role:"listbox",ariaLabel:this.options.resultsLabel}),a=this.options.shortcut==="mod+k"?l("kbd",{class:"zx-launcher__shortcut",ariaHidden:"true"},Tp()):null,c=Dp(this.options.hints);return t.setAttribute("aria-label",String(this.options.label)),t.replaceChildren(l("div",{class:"zx-launcher__surface"},l("div",{class:"zx-launcher__search",dataset:{shortcut:a?"true":"false"}},g("search"),i,a,n),r,o,c)),t.dataset.state="closed",this._createdRoot&&rt(this.options.scope).append(t),this.listen(i,"input",()=>{this._query=i.value,this.emit("query",{query:this._query.trim()}),this._refresh()}),this.listen(i,"keydown",h=>this._onKeydown(h)),this.listen(n,"click",()=>this.close()),this.listen(o,"click",h=>{let d=h.target?.closest?.("[data-launcher-index]");!d||!o.contains(d)||this._activate(Number(d.getAttribute("data-launcher-index")),h)}),this.listen(o,"pointermove",h=>{let d=h.target?.closest?.("[data-launcher-index]");if(!d||!o.contains(d))return;let u=Number(d.getAttribute("data-launcher-index"));!Number.isInteger(u)||this._results[u]?.disabled||u===this._active||(this._active=u,this._syncActive())}),this.listen(t,"cancel",h=>{h.preventDefault(),this.close()}),this.listen(t,"close",()=>{t.dataset.state="closed",i.setAttribute("aria-expanded","false"),this._abortRequest(),this.emit("close")}),this.listen(document,"keydown",h=>this._onDocumentKeydown(h)),this._renderResults(),t}open(){if(this.isOpen()||this._destroyed)return this;if(this._createdRoot){let t=rt(this.options.scope);this.el.parentElement!==t&&t.append(this.el)}return this.el.showModal(),this.el.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this._refresh(),queueMicrotask(()=>{this.isOpen()&&(this.refs.input.focus(),this.refs.input.select())}),this.emit("open"),this}close(){return this.isOpen()&&this.el.close(),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return!!this.el.open}focus(){return this.refs.input.focus(),this.refs.input.select(),this}setQuery(t){return this._query=String(t??""),this.refs.input.value=this._query,this.emit("query",{query:this._query.trim()}),this._refresh(),this}getQuery(){return this._query}setItems(t){return this._items=Hn(t),this._renderResults(),this}setCurrent(t){let e=t==null?null:String(t);return this._items=this._items.map(i=>({...i,current:e!==null&&String(i.id)===e})),this._renderResults(),this}setSources(t){return this._abortRequest(),this._sources=yl(t),this._sourceItems.clear(),this._refresh(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this._original;if(this._abortRequest(),this.isOpen()&&this.el.close(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_refresh(){if(this._sourceItems.clear(),this._renderResults(),this._abortRequest(),this._sources.length===0)return;let t=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>this._loadSources(),t)}async _loadSources(){this._queryTimer=null;let t=this._query.trim(),e=this._sources.filter(r=>Xi(r.when,t)&&t.length>=Math.max(Number(this.options.minQuery)||0,Number(r.minQuery)||0));if(e.length===0)return;let i=new AbortController,n=++this._requestSequence;this._request=i,this._setBusy(!0),await Promise.all(e.map(async r=>{try{let o=await r.load(t,{signal:i.signal});if(i.signal.aborted||n!==this._requestSequence)return;this._sourceItems.set(r.id,Hn(o).map((a,c)=>({...a,_source:r.id,_sourceOrder:r.order==="source",group:a.group??r.label??"",itemOrder:a.itemOrder??(r.order==="source"?c:void 0)}))),this._renderResults()}catch(o){if(i.signal.aborted||n!==this._requestSequence)return;this.emit("error",{source:r,error:o})}})),!(i.signal.aborted||n!==this._requestSequence)&&(this._request=null,this._setBusy(!1))}_setBusy(t){this._busy=t,this.el.setAttribute("aria-busy",String(t)),this._renderStatus()}_abortRequest(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._request?.abort(),this._request=null,this._requestSequence+=1,this._busy&&this._setBusy(!1)}_renderResults(){let t=this._query,e=this._renderedQuery===t&&this._active>=0&&this._results[this._active]?String(this._results[this._active].id):null,i=this._query.trim(),n=this._items.filter(f=>Xi(f.when,i)),r=jn(n,i,this.options.maxResults),o=this._sources.flatMap(f=>{let _=this._sourceItems.get(String(f.id))??[];return f.order==="source"?_.filter(m=>Xi(m.when,i)):jn(_.filter(m=>Xi(m.when,i)),i,this.options.maxResults)}),a=new Set,c=[...r.map(f=>({...f,_source:null})),...o].filter(f=>{let _=String(f.id);return a.has(_)?!1:(a.add(_),!0)}).slice(0,Math.max(0,Number(this.options.maxResults)||0)),h=new Map;for(let f of c){let _=String(f.group??"");h.has(_)||h.set(_,[]),h.get(_).push(f)}this._results=[...h.values()].flat(),this._renderedQuery=t;let d=e===null?-1:this._results.findIndex(f=>!f.disabled&&String(f.id)===e);this._active=d>=0?d:this._results.findIndex(f=>!f.disabled);let u=[],p=0;for(let[f,_]of h){let m=_.map(w=>this._option(w,p++));f?u.push(l("div",{class:"zx-launcher__group",role:"group",ariaLabel:f,dataset:{layout:_.every(w=>w.kind==="application")?"grid":"list"}},l("div",{class:"zx-launcher__group-label",ariaHidden:"true"},f),m)):u.push(...m)}this.refs.results.replaceChildren(...u),this._syncActive(),this._renderStatus()}_option(t,e){let i=it(t.href),n=i?"a":"button",r=[],o=Ip(t);return o&&r.push(l("span",{class:"zx-launcher__icon",ariaHidden:"true"},o)),r.push(l("span",{class:"zx-launcher__copy"},l("span",{class:"zx-launcher__label"},t.label),t.description?l("span",{class:"zx-launcher__description"},t.description):null)),t.badge!=null&&r.push(l("span",{class:"zx-launcher__badge"},String(t.badge))),l(n,{class:"zx-launcher__option",type:n==="button"?"button":null,href:i,target:t.target??null,rel:n==="a"?"noopener":null,role:"option",id:x("zx-launcher-option"),tabIndex:-1,ariaSelected:"false",ariaDisabled:t.disabled?"true":null,ariaCurrent:t.current?"page":null,dataset:{launcherIndex:e,pinned:t.pinned!==void 0&&t.pinned!==!1?"true":null,kind:Ep(t.kind)}},r)}_renderStatus(){this._busy?this.refs.status.textContent=String(this.options.loadingText):this._results.length===0?this.refs.status.textContent=String(this.options.emptyText):this.refs.status.textContent="",this.refs.status.hidden=!this.refs.status.textContent}_syncActive(){let t=[...this.refs.results.querySelectorAll("[data-launcher-index]")];for(let i of t){let n=Number(i.getAttribute("data-launcher-index"))===this._active;i.setAttribute("aria-selected",String(n))}let e=t.find(i=>Number(i.getAttribute("data-launcher-index"))===this._active);e?this.refs.input.setAttribute("aria-activedescendant",e.id):this.refs.input.removeAttribute("aria-activedescendant")}_onKeydown(t){if(t.key==="Escape"){this.close();return}if(t.key==="Enter"){if(this._active<0)return;t.preventDefault(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.click();return}let e=this._results.map((n,r)=>n.disabled?-1:r).filter(n=>n>=0);if(e.length===0)return;if(/^Arrow(?:Left|Right|Up|Down)$/.test(t.key)){let n=this._spatialIndex(t.key,e);if(n!==null){t.preventDefault(),this._active=n,this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"});return}if(t.key==="ArrowLeft"||t.key==="ArrowRight")return}let i=e.indexOf(this._active);if(t.key==="Home"||t.key==="PageUp")i=0;else if(t.key==="End"||t.key==="PageDown")i=e.length-1;else if(t.key==="ArrowDown")i=(i+1+e.length)%e.length;else if(t.key==="ArrowUp")i=(i-1+e.length)%e.length;else return;t.preventDefault(),this._active=e[i],this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest"})}_spatialIndex(t,e){let i=this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`);if(!(i instanceof HTMLElement)||(t==="ArrowLeft"||t==="ArrowRight")&&this._results[this._active]?.kind!=="application")return null;let n=[...this.refs.results.querySelectorAll("[data-launcher-index]")].filter(o=>e.includes(Number(o.getAttribute("data-launcher-index")))&&(t!=="ArrowLeft"&&t!=="ArrowRight"||o.getAttribute("data-kind")==="application")),r=Mp(n,i,t);return r?Number(r.getAttribute("data-launcher-index")):null}_activate(t,e){let i=this._results[t];if(!i||i.disabled){e.preventDefault();return}if(this.emit("select",{item:i,value:i.value??i.id,source:i._source??null,query:this._query.trim()}).defaultPrevented){e.preventDefault();return}i.href||(e.preventDefault(),i.invoke?.()),this.close()}_onDocumentKeydown(t){if(this.options.shortcut!=="mod+k"||t.isComposing||t.key.toLowerCase()!=="k"||Number(t.metaKey)+Number(t.ctrlKey)!==1||t.altKey||t.shiftKey)return;let e=document.activeElement;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)return;let i=document.querySelector("dialog:modal");i&&i!==this.el||(t.preventDefault(),this.open())}};function Tp(){let s=String(navigator.userAgentData?.platform??navigator.platform??"");return/mac|iphone|ipad/i.test(s)?"\u2318 K":"Ctrl K"}function Dp(s){if(s===!1)return null;let t=s&&typeof s=="object"?s:{};return l("footer",{class:"zx-launcher__hints",ariaHidden:"true"},l("span",{},l("kbd",{},"\u2191\u2193\u2190\u2192"),t.move??"Move"),l("span",{},l("kbd",{},"\u21B5"),t.open??"Open"),l("span",{},l("kbd",{},"Esc"),t.close??"Close"))}function Ip(s){let t=s.icon;if(typeof t=="function"&&(t=t(s)),typeof t=="string")return g(t);if(t instanceof Node)return t.cloneNode(!0);if(t&&typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();return e instanceof Node?e.cloneNode(!0):null}return null}function Ep(s){return s==="application"||s==="record"?s:"action"}function Xi(s,t){return s==="empty"?t==="":s==="query"?t!=="":!0}function Mp(s,t,e){let i=t.getBoundingClientRect();if(i.width===0&&i.height===0)return null;let n=i.left+i.width/2,r=i.top+i.height/2,o=null,a=1/0;for(let c of s){if(c===t)continue;let h=c.getBoundingClientRect(),d=h.left+h.width/2-n,u=h.top+h.height/2-r,p=!1,f=1/0;e==="ArrowLeft"?(p=d<-2&&Math.abs(u)<Math.max(i.height,h.height)/2,f=Math.abs(d)+Math.abs(u)*4):e==="ArrowRight"?(p=d>2&&Math.abs(u)<Math.max(i.height,h.height)/2,f=Math.abs(d)+Math.abs(u)*4):e==="ArrowUp"?(p=u<-2,f=Math.abs(u)*10+Math.abs(d)):e==="ArrowDown"&&(p=u>2,f=Math.abs(u)*10+Math.abs(d)),p&&f<a&&(o=c,a=f)}return o}function jn(s,t,e=100){let i=ge(t).trim(),n=s.map((o,a)=>({item:o,order:a,score:Np(o,i)})).filter(({score:o})=>o<1/0);n.sort((o,a)=>{let c=Ji(o.item.groupOrder),h=Ji(a.item.groupOrder);if(c!==h)return c-h;if(i===""){let d=bl(o.item.pinned,o.order),u=bl(a.item.pinned,a.order);if(d!==u)return d-u}return o.score-a.score||Ji(o.item.itemOrder)-Ji(a.item.itemOrder)||Op(o.item.label,a.item.label)||o.order-a.order});let r=Math.max(0,Number(e)||0);return n.slice(0,r||0).map(({item:o,score:a})=>({...o,_score:a}))}function Np(s,t){if(!t)return s.pinned?-1:0;let e=ge(s.label),i=ge(s.id),n=ge(Array.isArray(s.keywords)?s.keywords.join(" "):s.keywords??"");return e===t?0:e.startsWith(t)?10:e.split(/[^\p{L}\p{N}]+/u).some(o=>o.startsWith(t))?20:e.includes(t)||n.includes(t)?30:i.includes(t)?40:e.split(/[^\p{L}\p{N}]+/u).filter(Boolean).map(o=>o[0]).join("").startsWith(t)?50:1/0}function bl(s,t){return typeof s=="number"&&Number.isFinite(s)?s:s?t:Number.MAX_SAFE_INTEGER}function Ji(s){return typeof s=="number"&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER}function ge(s){return String(s??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function Op(s,t){let e=ge(s),i=ge(t);if(e<i)return-1;if(e>i)return 1;let n=String(s??"").normalize("NFC"),r=String(t??"").normalize("NFC");return n<r?-1:n>r?1:0}function Hn(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>Fp(t)):[]}function Fp(s){let t={...s,label:String(s.label)};if(s.href==null)return t;let e=it(s.href);return e!==null?t.href=e:(delete t.href,typeof t.invoke!="function"&&(t.disabled=!0)),t}function yl(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.id!=null&&typeof t.load=="function").map(t=>({...t,id:String(t.id)})):[]}var ni=class extends b{static cssName="avatar";static defaults={src:null,name:"",initials:null,label:null,size:"md",shape:"circle",status:null,statusLabel:null};render(){this._createdRoot=this.el===null;let t=this.el??l("span");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,r=>[r.name,r.value]),children:Array.from(t.childNodes)},this._state={src:this.options.src,name:String(this.options.name??""),initials:this.options.initials,label:this.options.label,size:this.options.size,shape:this.options.shape,status:this.options.status,statusLabel:this.options.statusLabel};let e=l("img",{ref:"image",class:"zx-avatar__image",alt:"",draggable:!1}),i=l("span",{ref:"fallback",class:"zx-avatar__fallback",ariaHidden:"true"}),n=l("span",{ref:"status",class:"zx-avatar__status",ariaHidden:"true",hidden:!0});return t.replaceChildren(e,i,n),this.listen(e,"load",()=>{this._isCurrentImageSource()&&this._showImage(!0)}),this.listen(e,"error",()=>{this._isCurrentImageSource()&&this._showImage(!1)}),this._sync(),t}set(t={}){if(!t||typeof t!="object")return this;for(let e of["src","name","initials","label","size","shape","status","statusLabel"])Object.hasOwn(t,e)&&(this._state[e]=t[e]);return this._sync(),this}setStatus(t,e=null){return this._state.status=t,this._state.statusLabel=e,this._syncLabel(),this._syncStatus(),this}hasImage(){return!this.refs.image.hidden}destroy(){let t=this._original;if(super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_sync(){let{size:t,shape:e,label:i}=this._state;this.el.dataset.size=typeof t=="string"?t:"custom",this.el.dataset.shape=["circle","rounded","square"].includes(e)?e:"circle",typeof t=="number"&&Number.isFinite(t)?this.el.style.setProperty("--zx-avatar-size",`${Math.max(1,t)}px`):this.el.style.removeProperty("--zx-avatar-size"),this._syncLabel(),this.refs.fallback.textContent=String(this._state.initials||xl(this._state.name));let n=this._state.src==null?"":String(this._state.src).trim();n?(this.refs.image.setAttribute("src",n),this._showImage(this.refs.image.complete&&this.refs.image.naturalWidth>0)):(this.refs.image.removeAttribute("src"),this._showImage(!1)),this._syncStatus()}_syncLabel(){let{label:t,status:e,statusLabel:i}=this._state;if(t){let n=["online","away","busy","offline"].includes(e)?i:null;this.el.setAttribute("role","img"),this.el.setAttribute("aria-label",[t,n].filter(Boolean).join(", ")),this.el.removeAttribute("aria-hidden")}else this.el.removeAttribute("role"),this.el.removeAttribute("aria-label"),this.el.setAttribute("aria-hidden","true")}_showImage(t){this.refs.image.hidden=!t,this.refs.fallback.hidden=t,this.el.dataset.fallback=String(!t)}_isCurrentImageSource(){let t=this.refs.image,e=t.getAttribute("src");if(!e)return!1;try{return t.currentSrc===new URL(e,document.baseURI).href}catch{return t.currentSrc===e}}_syncStatus(){let e=["online","away","busy","offline"].includes(this._state.status)?this._state.status:null;this.refs.status.hidden=e===null,e?this.refs.status.dataset.status=e:delete this.refs.status.dataset.status;let i=this._state.statusLabel;i?this.refs.status.setAttribute("title",String(i)):this.refs.status.removeAttribute("title")}};function xl(s){let t=String(s??"").trim().split(/\s+/u).filter(Boolean);if(t.length===0)return"?";let e=wl(t[0]),i=t.length>1?wl(t[t.length-1]):"";return`${e}${i}`}function wl(s){return vl(vl(s).toUpperCase())}function vl(s){return typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(s)[Symbol.iterator]().next().value?.segment??"":Array.from(s)[0]??""}var $n=class extends b{static cssName="account-menu";static defaults={account:{},items:[],compact:!1,label:null,placement:"top-start"};constructor(t=null,e={}){super(t,e);for(let i of["select","open","close"])this.listen(this.refs.trigger,`zx-${i}`,n=>n.stopPropagation());this._avatar=new ni(this.refs.avatar,kl(this._account)),this._menu=new ft(this.refs.trigger,{items:this.options.items,placement:this.options.placement}),this._menu.on("select",i=>{this.emit("select",i.detail).defaultPrevented&&i.preventDefault()}),this._menu.on("open",()=>this.emit("open")),this._menu.on("close",()=>this.emit("close")),this._renderIdentity()}render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,e=>[e.name,e.value]),children:Array.from(t.childNodes)},this._account=Sl(this.options.account),t.dataset.compact=String(!!this.options.compact),t.replaceChildren(l("button",{ref:"trigger",class:"zx-account-menu__trigger",type:"button"},l("span",{ref:"avatar",class:"zx-account-menu__avatar"}),l("span",{class:"zx-account-menu__identity"},l("span",{ref:"name",class:"zx-account-menu__name"}),l("span",{ref:"secondary",class:"zx-account-menu__secondary"})),l("span",{class:"zx-account-menu__chevron",ariaHidden:"true"},g("chevron-down")))),t}open(){return this._menu.open(),this}close(){return this._menu.close(),this}toggle(){return this._menu.toggle(),this}isOpen(){return this._menu.isOpen()}setAccount(t){return this._account=Sl(t),this._avatar.set(kl(this._account)),this._renderIdentity(),this}setItems(t){return this._menu.setItems(t),this._renderPanelHeader(),this}focus(){return this._menu.getTrigger().focus(),this}getPanel(){return this._menu.getPanel()}destroy(){let t=this._original;if(this._menu.destroy(),this._avatar.destroy(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_renderIdentity(){this.refs.name.textContent=this._account.name,this.refs.secondary.textContent=this._account.secondary,this.refs.secondary.hidden=!this._account.secondary;let e=["online","away","busy","offline"].includes(this._account.status)&&this._account.statusLabel?`, ${this._account.statusLabel}`:"",i=this.options.label||`Account menu${this._account.name?` for ${this._account.name}`:""}${e}`;this.refs.trigger.setAttribute("aria-label",i),this._renderPanelHeader()}_renderPanelHeader(){let t=this._menu.getPanel();t.querySelector(".zx-account-menu__panel-identity")?.remove(),t.prepend(l("div",{class:"zx-account-menu__panel-identity",role:"presentation"},l("strong",{},this._account.name||"Account"),this._account.secondary?l("span",{},this._account.secondary):null))}};function Sl(s){let t=s&&typeof s=="object"?s:{};return{...t,name:String(t.name??""),secondary:String(t.secondary??"")}}function kl(s){return{name:s.name,src:s.src??null,initials:s.initials??null,status:s.status??null,statusLabel:s.statusLabel??null,label:null,size:"md"}}var Rp=new Set(["top","bottom","top-start","top-end","bottom-start","bottom-end","left","right","left-start","left-end","right-start","right-end"]),Lp=new Set(["hover","focus","both","manual"]),ee=class extends b{static cssName="tooltip";static defaults={content:"",placement:"top",offset:6,delay:400,hideDelay:80,maxWidth:260,trigger:"both",disabled:!1};#t;#e;#i=null;#s=null;#r=0;#n=0;#o=!1;#a=!1;#l=!1;constructor(t,e={}){let i=U(t);if(!i)throw new TypeError("Tooltip anchor could not be resolved");super(null,e),this.#t=i,rt(i).append(this.el),this.#e=this.options.content,this.#a=!!this.options.disabled,this.#s=i.getAttribute("aria-describedby"),this.el.style.setProperty("--zx-tooltip-max-inline-size",qp(this.options.maxWidth));let n=Lp.has(this.options.trigger)?this.options.trigger:"both";n!=="manual"&&((n==="hover"||n==="both")&&(this.listen(this.#t,"pointerenter",r=>{r.pointerType!=="touch"&&this.#c(Number(this.options.delay))}),this.listen(this.#t,"pointerleave",()=>this.#h(Number(this.options.hideDelay)))),(n==="focus"||n==="both")&&(this.listen(this.#t,"focusin",()=>{this.#o||!jp(this.#t)||this.#c(0)}),this.listen(this.#t,"focusout",()=>this.#h(Number(this.options.hideDelay)))),this.listen(document,"keydown",r=>{r.key!=="Escape"||!this.isOpen()||(r.preventDefault(),this.hide())}),this.listen(document,"pointerdown",()=>{this.#o=!0,this.#d(),this.hide()},{capture:!0}),this.listen(document,"pointerup",()=>{this.#o=!1},{capture:!0}),this.listen(document,"pointercancel",()=>{this.#o=!1},{capture:!0}),this.listen(document,"focusin",r=>{!this.isOpen()||r.composedPath().includes(this.#t)||this.hide()}))}render(){let t=l("div",{id:x("zx-tooltip"),role:"tooltip",popover:"manual"});return t.dataset.state="closed",t}show(){if(this.#l||this.#a||this.isOpen())return this;this.#d();let t=rt(this.#t);this.el.parentElement!==t&&t.append(this.el);let e=Al(this.#e);return e===null?this:(this.el.replaceChildren(e),this.#i=st(this.#t,this.el,{placement:Rp.has(this.options.placement)?this.options.placement:"top",offset:Number(this.options.offset),flip:!0}),this.el.dataset.state="open",this.#t.setAttribute("aria-describedby",Hp(this.#s,this.el.id)),this.emit("open"),this)}hide(){return this.#d(),this.isOpen()?(this.#i?.destroy(),this.#i=null,this.el.dataset.state="closed",this.el.replaceChildren(),this.#u(),this.emit("close"),this):this}toggle(){return this.isOpen()?this.hide():this.show()}isOpen(){return this.#i!==null}setContent(t){if(this.#e=t,!this.isOpen())return this;let e=Al(t);return e===null?this.hide():(this.el.replaceChildren(e),this.#i?.update(),this)}enable(){return this.#a=!1,this}disable(){return this.#a=!0,this.hide()}isDisabled(){return this.#a}getAnchor(){return this.#t}destroy(){this.#l||(this.#l=!0,this.hide(),this.#u(),super.destroy())}#c(t){if(this.#d(),this.#l||this.#a||this.isOpen())return;let e=Number.isFinite(t)?Math.max(0,t):0;if(e===0){this.show();return}this.#r=setTimeout(()=>{this.#r=0,this.show()},e)}#h(t){if(this.#d(),!this.isOpen())return;let e=Number.isFinite(t)?Math.max(0,t):0;if(e===0){this.hide();return}this.#n=setTimeout(()=>{this.#n=0,this.hide()},e)}#d(){this.#r!==0&&clearTimeout(this.#r),this.#n!==0&&clearTimeout(this.#n),this.#r=0,this.#n=0}#u(){this.#s===null?this.#t.removeAttribute("aria-describedby"):this.#t.setAttribute("aria-describedby",this.#s)}};function Pp(s,t=""){return new ee(s,Bp(t)?t:{content:t})}function Vp(s,t){return new ee(s,{content:String(t??"")})}function Bp(s){return s===null||typeof s!="object"||Array.isArray(s)||typeof s.nodeType=="number"?!1:typeof s.toElement!="function"}function Al(s){let t=typeof s=="function"?s():s;if(t==null)return null;if(typeof t=="object"&&typeof t.nodeType=="number")return t;if(typeof t=="object"&&typeof t.toElement=="function")return t.toElement();let e=String(t);return e===""?null:document.createTextNode(e)}function Hp(s,t){let e=String(s??"").split(/\s+/).filter(Boolean);return e.includes(t)||e.push(t),e.join(" ")}function qp(s){return typeof s=="number"&&Number.isFinite(s)?`${s}px`:String(s)}function jp(s){try{return s.matches(":focus-visible")}catch{return!0}}var Zi=class extends b{static cssName="app-rail";static defaults={items:[],active:null,orientation:"vertical",side:"left",label:"Applications",header:null,footer:null,openDelay:80,closeDelay:160,renderIcon:null};constructor(t=null,e={}){super(t,e),this._rebuild()}render(){this._createdRoot=this.el===null;let t=this.el??l("nav");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,r=>[r.name,r.value]),children:Array.from(t.childNodes)},this._items=ie(this.options.items),this._active=this.options.active,this._flyouts=new Map,this._tooltips=[],this._tooltipById=new Map,this._interaction=null,this._openTimers=new Map,this._closeTimers=new Map,this._pointerFocus=new WeakSet,this._silenceFlyoutEvents=!1,t.setAttribute("aria-label",String(this.options.label)),t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.dataset.orientation=this.options.orientation==="horizontal"?"horizontal":"vertical";let e=t.dataset.orientation==="horizontal"?["top","bottom"]:["left","right"];t.dataset.side=e.includes(this.options.side)?this.options.side:e[0];let i=l("div",{class:"zx-app-rail__header"}),n=l("div",{class:"zx-app-rail__footer"});return Tl(i,this.options.header),Tl(n,this.options.footer),i.hidden=!i.hasChildNodes(),n.hidden=!n.hasChildNodes(),t.replaceChildren(i,l("ul",{ref:"list",class:"zx-app-rail__list"}),n),this.listen(t,"keydown",r=>this._onRailKeydown(r)),t}setItems(t){return this._items=ie(t),this._rebuild(),this}setActive(t){return this._active=t,this._syncActive(),this}getItems(){return this._items.map(t=>({...t,children:t.children?.map(e=>({...e}))}))}openFlyout(t,{focus:e=!1}={}){let i=this._resolveFlyout(t);if(!i)return this;let n=[i],r=i.parentKey===null?null:this._flyouts.get(i.parentKey)??null;for(;r;)n.unshift(r),r=r.parentKey===null?null:this._flyouts.get(r.parentKey)??null;if(n.some(o=>o.item.disabled))return this;this._cancelFlyoutTimers(i,!0);for(let[o,a]of this._flyouts)o!==i.key&&a.dropdown.isOpen()&&!this._isAncestor(a,i)&&this.closeFlyout(o);for(let o of n)this._tooltipById.get(String(o.item.id))?.hide(),o.dropdown.open();return e&&Cl(i.panel)?.focus(),this}closeFlyout(t){let e=this._resolveFlyout(t);if(!e)return this;for(let i of[...this._flyouts.values()].reverse())i!==e&&this._isAncestor(e,i)&&(this._cancelTimers(i.key),i.dropdown.close());return this._cancelTimers(e.key),e.dropdown.close(),this}closeAllFlyouts(){for(let t of this._flyouts.values())t.parentKey===null&&this.closeFlyout(t.key);for(let t of[...this._flyouts.values()].reverse())this._cancelTimers(t.key),t.dropdown.isOpen()&&t.dropdown.close();return this}isFlyoutOpen(t){return this._resolveFlyout(t)?.dropdown.isOpen()??!1}focus(){return Cl(this.refs.list)?.focus(),this}_containsNode(t){return!!(t&&(this.el.contains(t)||[...this._flyouts.values()].some(e=>e.panel.contains(t))))}destroy(){let t=this._original;if(this._clearArtifacts(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_rebuild(){this._clearArtifacts(),this.refs.list.replaceChildren(),this._interaction=new Kn(this.el),this._items.forEach(t=>{let e=Array.isArray(t.children)&&t.children.length>0,i=zl(t,{className:"zx-app-rail__item",index:String(t.id),iconOnly:!0,disclosure:e,disclosureIcon:$p(this.el.dataset.side),visual:ts(t,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:1,location:"root"})}),n=l("li",{class:"zx-app-rail__row"},i);this.refs.list.append(n);let r=new ee(i,{content:t.label,placement:Wp(this.el.dataset.side),delay:450});this._tooltips.push(r),this._tooltipById.set(String(t.id),r),e?this._buildFlyout(t,i,String(t.id),null):this._interaction.listen(i,"click",o=>{if(!this._select(t,o).defaultPrevented)for(let c of this._flyouts.values())c.parentKey===null&&c.dropdown.isOpen()&&this.closeFlyout(c.key)})}),this._interaction.listen(document,"pointerdown",t=>{let e=[...this._flyouts.values()].filter(n=>n.dropdown.isOpen());if(e.length===0)return;let i=t.composedPath();if(!e.some(n=>i.includes(n.panel)||i.includes(n.trigger)))for(let n of e)n.parentKey===null&&this.closeFlyout(n.key)}),this._syncActive()}_buildFlyout(t,e,i,n){let r=l("ul",{class:"zx-app-rail__flyout-list"});for(let d of t.children??[]){let u=`${i}/${d.id}`,p=!!d.children?.length,f=zl(d,{className:"zx-app-rail__flyout-item",index:u,iconOnly:!1,disclosure:p,disclosureIcon:Kp(this.el.dataset.side),visual:ts(d,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:u.split("/").length,location:"flyout"})});r.append(l("li",{},f)),p?this._buildFlyout(d,f,u,i):this._interaction.listen(f,"click",_=>{this._select(d,_).defaultPrevented||this._closeFlyoutChain(i)})}let o=l("div",{class:"zx-app-rail__flyout"},l("div",{class:"zx-app-rail__flyout-title"},t.label),r),a=new ut(e,{openOn:"manual",placement:n===null?Up(this.el.dataset.side):Yp(this.el.dataset.side),content:o,offset:6}),c=a.getPanel();c.classList.add("zx-app-rail__popover"),c.setAttribute("role","region"),c.setAttribute("aria-label",`${t.label} sub-navigation`);let h={key:i,parentKey:n,item:t,trigger:e,panel:c,dropdown:a};this._flyouts.set(i,h),a.on("open",()=>{this._silenceFlyoutEvents||this.emit("flyoutchange",{item:t,id:t.id,open:!0})}),a.on("close",()=>{this._silenceFlyoutEvents||this.emit("flyoutchange",{item:t,id:t.id,open:!1})}),this._interaction.listen(e,"pointerdown",()=>{this._pointerFocus.add(e),queueMicrotask(()=>this._pointerFocus.delete(e))}),this._interaction.listen(e,"pointerenter",d=>{d.pointerType!=="touch"&&this._scheduleOpen(i)}),this._interaction.listen(e,"pointerleave",()=>this._scheduleClose(i)),this._interaction.listen(e,"focus",()=>{this._pointerFocus.has(e)||this.openFlyout(i)}),this._interaction.listen(e,"focusout",d=>{c.contains(d.relatedTarget)||this._scheduleClose(i)}),this._interaction.listen(e,"click",d=>{d.preventDefault(),d instanceof MouseEvent&&d.detail===0?this.openFlyout(i,{focus:!0}):this.openFlyout(i)}),this._interaction.listen(c,"pointerenter",()=>this._cancelFlyoutTimers(h,!0)),this._interaction.listen(c,"pointerleave",()=>this._scheduleFlyoutClose(h,!0)),this._interaction.listen(c,"focusin",()=>this._cancelFlyoutTimers(h,!0)),this._interaction.listen(c,"focusout",d=>{d.relatedTarget!==e&&!c.contains(d.relatedTarget)&&this._scheduleFlyoutClose(h,!0)}),this._interaction.listen(c,"keydown",d=>this._onFlyoutKeydown(d,h))}_select(t,e){if(t.disabled){e.preventDefault();let n=new Event("select",{cancelable:!0});return n.preventDefault(),n}let i=this.emit("select",{item:t,id:t.id,value:t.value??t.id,href:t.href??null,event:e});return i.defaultPrevented?e.preventDefault():t.href||(e.preventDefault(),t.invoke?.()),i}_onRailKeydown(t){let e=Gp(this.refs.list),i=t.target?.closest?.("[data-app-nav-id]"),n=e.indexOf(i);if(n<0)return;let r=this.el.dataset.orientation==="horizontal",o=r?"ArrowLeft":"ArrowUp",a=r?"ArrowRight":"ArrowDown",c={left:"ArrowRight",right:"ArrowLeft",top:"ArrowDown",bottom:"ArrowUp"}[this.el.dataset.side],h=i.getAttribute("data-app-nav-id");if(t.key===c&&this._flyouts.has(String(h))){t.preventDefault(),this.openFlyout(String(h),{focus:!0});return}let d;if(t.key==="Home")d=0;else if(t.key==="End")d=e.length-1;else if(t.key===o)d=(n-1+e.length)%e.length;else if(t.key===a)d=(n+1)%e.length;else return;t.preventDefault(),e[d]?.focus()}_onFlyoutKeydown(t,e){let i=Dl(e.panel),n=t.target?.closest?.("a, button"),r=i.indexOf(n);if(t.key==="Escape"){t.preventDefault(),t.stopPropagation();let d=[...this._flyouts.values()].find(u=>u.trigger===n&&u.dropdown.isOpen());if(d){this.closeFlyout(d.key),this._restoreFocus(d.trigger);return}this.closeFlyout(e.key),this._restoreFocus(e.trigger);return}let o=[...this._flyouts.values()].find(d=>d.trigger===n),a=this.el.dataset.side==="right"?"ArrowLeft":"ArrowRight",c=a==="ArrowRight"?"ArrowLeft":"ArrowRight";if(o&&t.key===a){t.preventDefault(),t.stopPropagation(),this.openFlyout(o.key,{focus:!0});return}if(e.parentKey!==null&&t.key===c){t.preventDefault(),t.stopPropagation(),this.closeFlyout(e.key),this._restoreFocus(e.trigger);return}if(i.length===0)return;let h;if(t.key==="Home")h=0;else if(t.key==="End")h=i.length-1;else if(t.key==="ArrowDown")h=(r+1+i.length)%i.length;else if(t.key==="ArrowUp")h=(r-1+i.length)%i.length;else return;t.preventDefault(),i[h]?.focus()}_scheduleOpen(t){let e=String(t);this._cancelTimer(this._closeTimers,e),this._cancelTimer(this._openTimers,e);let i=Math.max(0,Number(this.options.openDelay)||0);this._openTimers.set(e,setTimeout(()=>{this._openTimers.delete(e),this.openFlyout(t)},i))}_scheduleClose(t){let e=String(t);this._cancelTimer(this._openTimers,e),this._cancelTimer(this._closeTimers,e);let i=Math.max(0,Number(this.options.closeDelay)||0);this._closeTimers.set(e,setTimeout(()=>{this._closeTimers.delete(e);let n=this._flyouts.get(e);n&&(this._branchInteracting(n)||this.closeFlyout(e))},i))}_scheduleFlyoutClose(t,e){let i=t;for(;i&&(this._scheduleClose(i.key),!(!e||i.parentKey===null));)i=this._flyouts.get(i.parentKey)??null}_resolveFlyout(t){let e=String(t);return this._flyouts.get(e)??[...this._flyouts.values()].find(i=>String(i.item.id)===e)??null}_closeFlyoutChain(t){let e=this._flyouts.get(t)??null;for(;e?.parentKey!==null;)e=this._flyouts.get(e.parentKey)??null;e&&this.closeFlyout(e.key)}_isAncestor(t,e){let i=e.parentKey;for(;i!==null;){if(i===t.key)return!0;i=this._flyouts.get(i)?.parentKey??null}return!1}_cancelFlyoutTimers(t,e){let i=t;for(;i&&(this._cancelTimers(i.key),!(!e||i.parentKey===null));)i=this._flyouts.get(i.parentKey)??null}_branchInteracting(t){return t.trigger.matches(":hover")||t.panel.matches(":hover")||t.trigger===document.activeElement||t.panel.contains(document.activeElement)?!0:[...this._flyouts.values()].some(e=>this._isAncestor(t,e)&&e.dropdown.isOpen()&&(e.trigger.matches(":hover")||e.panel.matches(":hover")||e.trigger===document.activeElement||e.panel.contains(document.activeElement)))}_restoreFocus(t){this._pointerFocus.add(t),t.focus(),queueMicrotask(()=>this._pointerFocus.delete(t))}_cancelTimers(t){this._cancelTimer(this._openTimers,t),this._cancelTimer(this._closeTimers,t)}_cancelTimer(t,e){let i=t.get(e);i!==void 0&&clearTimeout(i),t.delete(e)}_syncActive(){let t=this._active==null?null:String(this._active);for(let e of this.refs.list.querySelectorAll("[data-app-nav-id]")){let i=t!==null&&e.getAttribute("data-app-nav-value-id")===t,n=this._flyouts.get(String(e.getAttribute("data-app-nav-id"))),r=t!==null&&n?Un(n.item.children??[],t):!1;i?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current"),r?e.dataset.activeDescendant="true":delete e.dataset.activeDescendant}for(let e of this._flyouts.values()){t!==null&&Un(e.item.children??[],t)?e.trigger.dataset.activeDescendant="true":delete e.trigger.dataset.activeDescendant;for(let n of e.panel.querySelectorAll("[data-app-nav-value-id]"))t!==null&&n.getAttribute("data-app-nav-value-id")===t?n.setAttribute("aria-current","page"):n.removeAttribute("aria-current")}}_clearArtifacts(){for(let t of this._openTimers?this._openTimers.values():[])clearTimeout(t);for(let t of this._closeTimers?this._closeTimers.values():[])clearTimeout(t);this._openTimers?.clear?.(),this._closeTimers?.clear?.(),this._interaction?.destroy?.();for(let t of this._tooltips??[])t.destroy();this._silenceFlyoutEvents=!0;for(let t of this._flyouts?.values?.()??[])t.dropdown.destroy();this._silenceFlyoutEvents=!1,this._tooltips=[],this._tooltipById=new Map,this._interaction=null,this._flyouts=new Map}},Kn=class extends b{constructor(t){super(null),t.append(this.el)}render(){return l("span",{hidden:!0,"data-zx-app-rail-listener-scope":""})}};function ie(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>{let e={...t,label:String(t.label),children:Array.isArray(t.children)?ie(t.children):[]};if(t.href==null)return e;let i=it(t.href);return i!==null?e.href=i:(delete e.href,e.children.length===0&&typeof e.invoke!="function"&&(e.disabled=!0)),e}):[]}function ts(s,t,e){let i=typeof t=="function"?t(s,e):null;if(i==null&&(i=s.icon),typeof i=="function"&&(i=i(e,s)),typeof i=="string")return g(i);if(i instanceof Node)return i.cloneNode(!0);if(i&&typeof i=="object"&&typeof i.toElement=="function"){let n=i.toElement();return n instanceof Node?n.cloneNode(!0):null}return null}function zl(s,{className:t,index:e,iconOnly:i,disclosure:n,disclosureIcon:r,visual:o}){let a=it(s.href),c=a&&!n?"a":"button";return l(c,{class:t,type:c==="button"?"button":null,href:c==="a"?a:null,target:c==="a"?s.target??null:null,rel:c==="a"?"noopener":null,ariaLabel:i?s.label:null,ariaDisabled:s.disabled?"true":null,dataset:{appNavId:e,appNavValueId:String(s.id)}},o?l("span",{class:`${t}-icon`,ariaHidden:"true"},o):null,l("span",{class:`${t}-label`},s.label),s.badge!=null?l("span",{class:`${t}-badge`},String(s.badge)):null,n?l("span",{class:`${t}-disclosure`,ariaHidden:"true"},g(r)):null)}function $p(s){return{left:"chevron-right",right:"chevron-left",top:"chevron-down",bottom:"chevron-up"}[s]??"chevron-right"}function Kp(s){return s==="right"?"chevron-left":"chevron-right"}function Up(s){return{left:"right-start",right:"left-start",top:"bottom-start",bottom:"top-start"}[s]??"right-start"}function Yp(s){return s==="right"?"left-start":"right-start"}function Wp(s){return{left:"right",right:"left",top:"bottom",bottom:"top"}[s]??"right"}function Dl(s){return[...s.querySelectorAll('a:not([aria-disabled="true"]), button:not([aria-disabled="true"])')]}function Cl(s){return Dl(s)[0]??null}function Gp(s){return[...s.children].map(t=>t.querySelector("[data-app-nav-id]")).filter(Boolean)}function Un(s,t){return s.some(e=>String(e.id)===t||Un(e.children??[],t))}function Tl(s,t){if(t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t=="object"&&typeof t.nodeType=="number"&&s.append(t)}var Wn=class extends b{static cssName="app-sidebar";static defaults={items:[],active:null,expanded:[],collapsed:!1,collapsible:!0,orientation:"vertical",side:"left",label:"Applications",header:null,footer:null,railHeader:null,railFooter:null,openDelay:80,closeDelay:160,renderIcon:null};constructor(t=null,e={}){super(t,e),this._rail=null,this._railExpandButton=null,this._renderMode()}render(){this._createdRoot=this.el===null;let t=this.el??l("aside");return this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,e=>[e.name,e.value]),children:Array.from(t.childNodes)},this._items=ie(this.options.items),this._active=this.options.active,this._expanded=new Set(Array.isArray(this.options.expanded)?this.options.expanded.map(String):[]),this._collapsed=!!this.options.collapsed,this._orientation=this.options.orientation==="horizontal"?"horizontal":"vertical",this._side=Il(this._orientation,this.options.side),this._modeAbort=null,t.replaceChildren(),t}setItems(t){return this._items=ie(t),this._reconcileExpanded(),this._rail?this._rail.setItems(this._items):this._renderTree(),this}getItems(){return this._items.map(t=>({...t,children:t.children?.map(e=>({...e}))}))}setActive(t){return this._active=t,this._rail?this._rail.setActive(t):this._syncActive(),this}setExpanded(t,{silent:e=!1}={}){return this._expanded=new Set(Array.isArray(t)?t.map(String):[]),this._reconcileExpanded(),this._rail||this._renderTree(),e||this.emit("branchchange",{item:null,id:null,expanded:null,ids:this.getExpanded()}),this}getExpanded(){let t=[];return Gn(this._items,e=>{this._expanded.has(String(e.id))&&t.push(e.id)}),t}toggleBranch(t,{silent:e=!1}={}){let i=ri(this._items,t);if(!i?.children?.length)return this;let n=String(t),r=!this._expanded.has(n);return r?this._expanded.add(n):this._expanded.delete(n),this._rail||this._renderTree(),e||this.emit("branchchange",{item:i,id:i.id,expanded:r,ids:this.getExpanded()}),this}expand(t={}){return this.setCollapsed(!1,t)}collapse(t={}){return this.setCollapsed(!0,t)}setCollapsed(t,{silent:e=!1}={}){let i=this.isCollapsed(),n=document.activeElement,r=!!(n&&(this.el.contains(n)||this._rail?._containsNode(n)));this._collapsed=!!t;let o=this.isCollapsed();return i!==o&&(this._renderMode(),r&&(o?this._railExpandButton?.focus():this.refs.collapse?.focus()),e||this.emit("collapsechange",{collapsed:o})),this}isCollapsed(){return this._orientation==="horizontal"||this._collapsed}setLayout(t={},{silent:e=!1}={}){let i=t.orientation==="horizontal"?"horizontal":t.orientation==="vertical"?"vertical":this._orientation,n=Il(i,t.side??this._side);if(i===this._orientation&&n===this._side)return this;let r=this.isCollapsed(),o=document.activeElement,a=!!(o&&(this.el.contains(o)||this._rail?._containsNode(o))),c=a&&o instanceof Element?o.closest("[data-app-nav-id]")?.getAttribute("data-app-nav-id")??null:null;this._orientation=i,this._side=n,this._renderMode();let h=this.isCollapsed();if(a){let d=c===null?null:[...this.el.querySelectorAll("[data-app-nav-id]")].find(u=>u.getAttribute("data-app-nav-id")===c)??null;d instanceof HTMLElement?d.focus():h?this.focus():this.refs.collapse instanceof HTMLElement&&!this.refs.collapse.hidden?this.refs.collapse.focus():es(this.refs.list)[0]?.focus()}return r!==h&&!e&&this.emit("collapsechange",{collapsed:h}),this}openFlyout(t,e={}){return this._rail?.openFlyout(t,e),this}closeFlyout(t){return this._rail?.closeFlyout(t),this}closeAllFlyouts(){return this._rail?.closeAllFlyouts(),this}isFlyoutOpen(t){return this._rail?.isFlyoutOpen(t)??!1}focus(){return this._rail?this._rail.focus():es(this.refs.list)[0]?.focus(),this}destroy(){let t=this._original;if(this._modeAbort?.abort(),this._modeAbort=null,this._rail?.destroy(),this._rail=null,super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_renderMode(){this._modeAbort?.abort(),this._modeAbort=new AbortController,this._rail?.destroy(),this._rail=null,this._railExpandButton=null;for(let t of["expanded","list","collapse","rail"])delete this.refs[t];this.el.replaceChildren(),this.el.dataset.orientation=this._orientation,this.el.dataset.side=this._side,this.el.dataset.collapsed=String(this.isCollapsed()),this.isCollapsed()?this._renderRail():this._renderExpanded()}_renderExpanded(){let t=l("div",{class:"zx-app-sidebar__header-content"});Yn(t,this.options.header);let e=l("button",{class:"zx-app-sidebar__collapse zx-icon-btn",type:"button",ariaLabel:"Minimize application sidebar"},g(this._side==="right"?"chevron-right":"chevron-left"));e.hidden=!this.options.collapsible;let i=l("footer",{class:"zx-app-sidebar__footer"});Yn(i,this.options.footer),i.hidden=!i.hasChildNodes();let n=l("ul",{class:"zx-app-sidebar__list"}),r=l("div",{class:"zx-app-sidebar__expanded"},l("header",{class:"zx-app-sidebar__header"},t,e),l("nav",{class:"zx-app-sidebar__nav",ariaLabel:this.options.label},n),i);this.refs.expanded=r,this.refs.list=n,this.refs.collapse=e,this.el.append(r),this._listenMode(e,"click",()=>this.collapse()),this._listenMode(n,"click",o=>this._onTreeClick(o)),this._listenMode(n,"keydown",o=>this._onTreeKeydown(o)),this._renderTree()}_renderRail(){let t=l("nav",{class:"zx-app-sidebar__rail"});this.el.append(t),this.refs.rail=t;let e=this._orientation==="vertical"&&!!this.options.collapsible,i=l("div",{class:"zx-app-sidebar__rail-header"});if(e){let n=l("button",{class:"zx-app-sidebar__rail-toggle zx-icon-btn",type:"button",ariaLabel:"Expand application sidebar"},g(this._side==="right"?"chevron-left":"chevron-right"));i.append(n),this._railExpandButton=n,this._listenMode(n,"click",()=>this.expand())}Yn(i,this.options.railHeader),this._rail=new Zi(t,{items:this._items,active:this._active,orientation:this._orientation,side:this._side,label:this.options.label,header:i.hasChildNodes()?i:null,footer:this.options.railFooter,openDelay:this.options.openDelay,closeDelay:this.options.closeDelay,renderIcon:this.options.renderIcon,onselect:n=>{this.emit("select",n.detail).defaultPrevented&&n.preventDefault()},onflyoutchange:n=>this.emit("flyoutchange",n.detail)}),this._listenMode(t,"zx-select",n=>n.stopPropagation()),this._listenMode(t,"zx-flyoutchange",n=>n.stopPropagation())}_listenMode(t,e,i){t.addEventListener(e,i,{signal:this._modeAbort.signal})}_renderTree(){if(!this.refs.list)return;let t=this.refs.list.contains(document.activeElement)?document.activeElement.closest("[data-app-nav-id]")?.getAttribute("data-app-nav-id"):null;if(this.refs.list.replaceChildren(...this._items.map(e=>this._treeRow(e,1))),this._syncActive(),t!==null){let e=[...this.refs.list.querySelectorAll("[data-app-nav-id]")].find(i=>i.getAttribute("data-app-nav-id")===t)??null;Xp(e)?.focus()}}_treeRow(t,e){let i=t.children??[],n=i.length>0,r=String(t.id),o=n&&this._expanded.has(r),a=n?x("zx-app-sidebar-branch"):null,c=ts(t,this.options.renderIcon,{orientation:this._orientation,collapsed:!1,side:this._side,level:e,location:e===1?"root":"inline"}),h=Qp(t,n,o,a,c),d=l("li",{class:"zx-app-sidebar__row",dataset:{level:e}},h);return n&&d.append(l("ul",{class:"zx-app-sidebar__sublist",id:a,hidden:!o},i.map(u=>this._treeRow(u,e+1)))),d}_onTreeClick(t){let e=t.target?.closest?.("[data-app-nav-id]");if(!e||!this.refs.list.contains(e))return;let i=ri(this._items,e.getAttribute("data-app-nav-id"));if(!i||i.disabled){t.preventDefault();return}i.children?.length?this.toggleBranch(i.id):this._select(i,t)}_onTreeKeydown(t){let e=t.target?.closest?.("[data-app-nav-id]");if(!(e instanceof HTMLElement))return;let i=ri(this._items,e.getAttribute("data-app-nav-id")),n=es(this.refs.list),r=n.indexOf(e);if(t.key==="ArrowRight"&&i?.children?.length){t.preventDefault(),this._expanded.has(String(i.id))?es(e.parentElement?.querySelector(".zx-app-sidebar__sublist"))[0]?.focus():this.toggleBranch(i.id);return}if(t.key==="ArrowLeft"){if(i?.children?.length&&this._expanded.has(String(i.id))){t.preventDefault(),this.toggleBranch(i.id);return}let c=e.closest(".zx-app-sidebar__sublist")?.parentElement?.querySelector(":scope > [data-app-nav-id]");c instanceof HTMLElement&&(t.preventDefault(),c.focus());return}let o;if(t.key==="Home")o=0;else if(t.key==="End")o=n.length-1;else if(t.key==="ArrowDown")o=Math.min(n.length-1,r+1);else if(t.key==="ArrowUp")o=Math.max(0,r-1);else return;t.preventDefault(),n[o]?.focus()}_select(t,e){if(t.disabled){e.preventDefault();return}this.emit("select",{item:t,id:t.id,value:t.value??t.id,href:t.href??null,event:e}).defaultPrevented?e.preventDefault():t.href||(e.preventDefault(),t.invoke?.())}_syncActive(){if(!this.refs.list)return;let t=this._active==null?null:String(this._active);for(let e of this.refs.list.querySelectorAll("[data-app-nav-id]")){let i=ri(this._items,e.getAttribute("data-app-nav-id")),n=t!==null&&e.getAttribute("data-app-nav-id")===t,r=t!==null&&i?El(i.children??[],t):!1;n?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current"),r?e.dataset.activeDescendant="true":delete e.dataset.activeDescendant}}_reconcileExpanded(){let t=new Set;Gn(this._items,e=>{e.children?.length&&t.add(String(e.id))});for(let e of this._expanded)t.has(e)||this._expanded.delete(e)}};function Qp(s,t,e,i,n){let r=s.href&&!t?"a":"button";return l(r,{class:"zx-app-sidebar__item",type:r==="button"?"button":null,href:r==="a"?s.href:null,target:r==="a"?s.target??null:null,ariaDisabled:s.disabled?"true":null,ariaExpanded:t?String(e):null,ariaControls:i,dataset:{appNavId:String(s.id)}},n?l("span",{class:"zx-app-sidebar__item-icon",ariaHidden:"true"},n):null,l("span",{class:"zx-app-sidebar__item-label"},s.label),s.badge!=null?l("span",{class:"zx-app-sidebar__item-badge"},String(s.badge)):null,t?l("span",{class:"zx-app-sidebar__item-disclosure",ariaHidden:"true"},g(e?"chevron-down":"chevron-right")):null)}function es(s){return s?[...s.querySelectorAll("[data-app-nav-id]")].filter(t=>!t.closest(".zx-app-sidebar__sublist[hidden]")):[]}function Xp(s){let t=s;for(;t;){let e=t.closest(".zx-app-sidebar__sublist[hidden]");if(!e)return t;t=e.parentElement?.firstElementChild??null}return null}function ri(s,t){for(let e of s){if(String(e.id)===String(t))return e;let i=ri(e.children??[],t);if(i)return i}return null}function Gn(s,t){for(let e of s)t(e),Gn(e.children??[],t)}function El(s,t){return s.some(e=>String(e.id)===t||El(e.children??[],t))}function Yn(s,t){if(t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t=="object"&&typeof t.nodeType=="number"&&s.append(t)}function Il(s,t){return s==="horizontal"?t==="bottom"?"bottom":"top":t==="right"?"right":"left"}var Xn=class{#t;#e=[];#i=[];#s;constructor(t=5,e=()=>{}){if(!Number.isInteger(t)||t<1)throw new RangeError("Queue limit must be positive");if(typeof e!="function")throw new TypeError("Activation callback must be a function");this.#t=t,this.#s=e}enqueue(t){return this.#e.length<this.#t?(this.#e.push(t),this.#s(t),"active"):(this.#i.push(t),"pending")}remove(t){let e=this.#i.indexOf(t);if(e!==-1)return this.#i.splice(e,1),"pending";let i=this.#e.indexOf(t);if(i===-1)return null;if(this.#e.splice(i,1),this.#i.length>0){let n=this.#i.shift();this.#e.push(n),this.#s(n)}return"active"}isActive(t){return this.#e.includes(t)}clear(){let t={active:this.#e.slice(),pending:this.#i.slice()};return this.#e.length=0,this.#i.length=0,t}get activeCount(){return this.#e.length}get pendingCount(){return this.#i.length}},Jn=class s extends b{static cssName="message";static defaults={kind:"info",timeout:4e3,closable:!0,maxVisible:5};static#t=new WeakMap;render(){let t=!this.el,e=this.el??l("div");return this._createdRoot=t,this._original=t?null:n_(e),this._entries=new Set,this._queue=new Xn(t_(this.options.maxVisible),i=>{this._activate(i)}),e.replaceChildren(),e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e}show(t,e={}){let i={kind:Jp(e.kind??this.options.kind),timeout:Zp(e.timeout??this.options.timeout),closable:e.closable??!!this.options.closable},n=this._createEntry(t,i);return this._entries.add(n),this._queue.enqueue(n),{close:()=>this._close(n)}}static info(t,e={}){return this.show(t,{...e,kind:"info"})}static success(t,e={}){return this.show(t,{...e,kind:"success"})}static warning(t,e={}){return this.show(t,{...e,kind:"warning"})}static error(t,e={}){return this.show(t,{...e,kind:"error"})}static show(t,e={}){return this.#e(e.scope).show(t,e)}static progress(t,e={}){return this.#e(e.scope)._progress(t)}destroy(){if(!this._cleaned){this._cleaned=!0;for(let t of this._entries)Qn(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&r_(this.el,this._original)}}_progress(t){let e={pct:0,text:String(t)},i=this._createEntry(e.text,{kind:"info",timeout:0,closable:!1},e);this._entries.add(i),this._queue.enqueue(i);let n=!1;return{update:(r,o)=>{n||i.closed||(e.pct=i_(r),o!==void 0&&(e.text=String(o)),is(i,e))},done:()=>{n||i.closed||(n=!0,e.pct=100,is(i,e),i.remaining=600,this._queue.isActive(i)&&this._schedule(i))},fail:r=>{n||i.closed||(n=!0,r!==void 0&&(e.text=String(r)),i.kind="error",i.node.dataset.kind="error",i.node.setAttribute("role","alert"),i.iconHost.replaceChildren(g("error",{size:18})),is(i,e),i.remaining=4e3,this._queue.isActive(i)&&this._schedule(i))}}}_createEntry(t,e,i=null){let n=l("span",{class:"zx-message__icon",ariaHidden:"true"},g(e.kind,{size:18})),r=l("div",{class:"zx-message__content"});e_(t)?r.append(t):r.append(document.createTextNode(String(t)));let o=l("div",{class:"zx-message__toast",role:e.kind==="error"?"alert":"status",dataset:{kind:e.kind,state:"queued"}},n,r),a={node:o,content:r,iconHost:n,kind:e.kind,timeout:e.timeout,remaining:e.timeout,startedAt:0,timer:null,exitTimer:null,closed:!1,progressBar:null,progressFill:null};if(i){o.dataset.progress="";let c=l("span",{class:"zx-message__progress-fill"}),h=l("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:i.text},c);r.append(h),a.progressBar=h,a.progressFill=c,is(a,i)}if(e.closable){let c=l("button",{class:"zx-icon-btn zx-message__close",type:"button",ariaLabel:"Close message",title:"Close"},g("x",{size:14}));o.append(c),this.listen(c,"click",()=>this._close(a))}return this.listen(o,"mouseenter",()=>this._pause(a)),this.listen(o,"mouseleave",()=>this._resume(a)),a}_activate(t){t.closed||(t.node.dataset.state="open",this.el.append(t.node),this._schedule(t))}_schedule(t){t.closed||t.remaining<=0||(t.startedAt=Date.now(),t.timer=setTimeout(()=>this._close(t),t.remaining))}_pause(t){t.closed||t.timer===null||(clearTimeout(t.timer),t.timer=null,t.remaining=Math.max(0,t.remaining-(Date.now()-t.startedAt)))}_resume(t){if(!(t.closed||t.timer!==null)){if(t.remaining<=0){this._close(t);return}this._schedule(t)}}_close(t){if(t.closed)return;if(t.closed=!0,Qn(t),!this._queue.isActive(t)){this._queue.remove(t),t.node.remove(),this._entries.delete(t);return}if(t.node.dataset.state="closing",!s_()){this._finish(t);return}let e=i=>{i.target===t.node&&this._finish(t)};this.listen(t.node,"animationend",e,{once:!0}),t.exitTimer=setTimeout(()=>this._finish(t),260)}_finish(t){this._entries.has(t)&&(Qn(t),t.node.remove(),this._entries.delete(t),this._queue.remove(t))}static#e(t){let e=rt(t??null),i=this.#t.get(e);if(i)return i;let n=l("div",{class:"zx-message-region",popover:"manual",role:"status",ariaLive:"polite"});e.append(n);let r=new s(n);return this.#t.set(e,r),typeof n.showPopover=="function"&&n.showPopover(),r}};function Jp(s){return s==="danger"?"error":["success","warning","error"].includes(String(s))?s:"info"}function Zp(s){let t=Number(s);return Number.isFinite(t)?Math.max(0,t):4e3}function t_(s){let t=Number(s);return Number.isInteger(t)&&t>0?t:5}function e_(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function i_(s){let t=Number(s);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function is(s,t){s.content.firstChild.textContent=t.text,s.progressBar?.setAttribute("aria-valuenow",String(t.pct)),s.progressBar?.setAttribute("aria-label",t.text),s.progressFill&&(s.progressFill.style.inlineSize=`${t.pct}%`)}function Qn(s){s.timer!==null&&clearTimeout(s.timer),s.exitTimer!==null&&clearTimeout(s.exitTimer),s.timer=null,s.exitTimer=null}function s_(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function n_(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function r_(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}var o_=new Set(["start","end","top","bottom"]),a_=new Set(["dim","blur","none"]),l_=Object.freeze({start:1,end:-1,top:1,bottom:-1}),Zn=class extends Bt{static cssName="sheet";static defaults={side:"end",modal:!0,backdrop:"dim",size:null,closeButton:!0,resizable:!1,min:160,max:null,handle:"auto",snap:null,lightDismiss:!0};#t=null;#e=null;#i=0;constructor(t=null,e={}){super(null,e),this._dock=null,this.setSide(this.options.side),this.el.dataset.backdrop=a_.has(this.options.backdrop)?this.options.backdrop:"dim",this.el.dataset.modality=d_(this.options.modal),this.refs.close.hidden=!this.options.closeButton,this.options.modal!==!0&&(this.listen(this.el,"keydown",i=>{let n=i;n.key!=="Escape"||!this.options.closable||this._dock||(n.preventDefault(),this.emit("cancel").defaultPrevented||this.close())}),this.options.lightDismiss&&this.listen(document,"pointerdown",i=>{let n=i.target;!this.isOpen()||this._dock||this.el.contains(n)||this.close()})),this.on("close",()=>this.#t?.deactivate()),this.#s()&&this.#r()}#s(){let t=this.options.handle,e=this.getSide(),i=t===!0||t==="auto"&&(e==="top"||e==="bottom");return!!this.options.resizable||Array.isArray(this.options.snap)||i}#r(){let t=this.getSide()==="top"||this.getSide()==="bottom",e=l("div",{class:"zx-sheet__handle",ref:"handle",role:"separator",tabindex:0,ariaOrientation:t?"horizontal":"vertical",ariaLabel:this._message("sheet.resize","Resize sheet")});this.el.append(e),this.refs.handle=e,this.#c(),this.#e=me(e,{orientation:t?"vertical":"horizontal",disabled:()=>this.isDocked(),onStart:()=>{this.#i=this.getSize(),this.el.dataset.dragging="true"},onMove:i=>this.#n(i,!1),onEnd:(i,n)=>{delete this.el.dataset.dragging,n&&this.#n(i,!0)},onStep:(i,n)=>{this.#i=this.getSize(),this.#n(i*(n?64:16),!0)}})}#n(t,e){let i=this.#o(),{min:n,max:r}=this.#a(i),a=!!this.options.resizable||this.#l(i).length>0?r:Math.min(r,this.#i),c=P(this.#i+t*l_[this.getSide()],0,a);if(!e){this._applySize(c),this.#c();return}if(this.options.closable&&c<n/2){this._applySize(this.#i),this.close();return}let h=this.#l(i),d=h.length>0?h_(c,h):c;this._applySize(P(d,n,a)),this.#c(),this.emit("resize",{size:this.getSize(),ratio:i>0?this.getSize()/i:0})}snapTo(t){let e=this.#o(),i=this.#l(e);if(i.length===0)return this;let n=typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<i.length?i[t]:Ml(t,e);if(!Number.isFinite(n))return this;let{min:r,max:o}=this.#a(e);return this._applySize(P(n,r,o)),this.#c(),this.emit("resize",{size:this.getSize(),ratio:e>0?this.getSize()/e:0}),this}getSize(){let t=this.el.getBoundingClientRect();return this.getSide()==="top"||this.getSide()==="bottom"?t.height:t.width}_message(t,e){let i=this.msg(t);return i===t?e:i}#o(){return this.getSide()==="top"||this.getSide()==="bottom"?window.innerHeight:window.innerWidth}#a(t){let e=this.#l(t),i=Math.max(0,Number(this.options.min)||0),n=this.options.max==null?t:Math.min(t,Number(this.options.max)||t),r=e.length>0?Math.max(i,Math.min(...e)):i;return{min:Math.min(r,n),max:n}}#l(t){let e=this.options.snap;return Array.isArray(e)?e.map(i=>Ml(i,t)).filter(i=>Number.isFinite(i)&&i>0).sort((i,n)=>i-n):[]}#c(){let t=this.refs.handle;if(!t)return;let e=this.#o(),{min:i,max:n}=this.#a(e);t.setAttribute("aria-valuenow",String(Math.round(this.getSize()))),t.setAttribute("aria-valuemin",String(Math.round(i))),t.setAttribute("aria-valuemax",String(Math.round(n)))}mountTarget(){return this._dock?.el??super.mountTarget()}isDocked(){return!!this._dock}_setDock(t){this._dock!==t&&(this._dock=t??null,this.el.toggleAttribute("data-docked",!!this._dock),this._rehost(),this.emit("dockchange",{docked:!!this._dock,dock:this._dock}))}_rehost(){let t=this.isOpen();t&&this._dismiss(),this.mountTarget().append(this.el),t&&(this.el.returnValue="",this._present(),this.el.dataset.state="open",this._dock?delete this.el.dataset.zxOverlayOrder:this.el.dataset.zxOverlayOrder=String(c_()))}open(){return this.isOpen()?this:(this.options.modal==="trap-focus"&&(this.#t??=Js(this.el),this.#t.activate()),super.open(),this.#c(),this)}close(t){return this.#t?.deactivate(),super.close(t)}setSide(t){return this.el.dataset.side=o_.has(t)?t:"end",this}getSide(){return this.el.dataset.side}setSize(t){return this._applySize(t),this}isModal(){return this.options.modal===!0}_applySize(t){this.el.style.removeProperty("inline-size"),this.el.style.removeProperty("block-size");let e=u_(t);e===null?this.el.style.removeProperty("--zx-sheet-size"):this.el.style.setProperty("--zx-sheet-size",e)}_show(){if(this.options.modal===!0&&!this._dock){this.el.removeAttribute("popover"),this.el.removeAttribute("aria-modal"),super._show();return}if(this.el.setAttribute("aria-modal","false"),this._dock){this.el.removeAttribute("popover"),this.el.show();return}this.el.setAttribute("popover","manual"),this.el.showPopover()}_hide(t="",e){if(!this.el.matches(":popover-open")){super._hide(t,e);return}this.el.returnValue=t,this.el.hidePopover(),queueMicrotask(()=>this._settleClose(e))}_isShown(){return this.el.matches(":popover-open")||super._isShown()}destroy(){this.#t?.deactivate(),this.#t=null,this.#e?.destroy(),this.#e=null,this._dock?._forget(this),this._dock=null,super.destroy()}};function c_(){let s=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...s)+1}function Ml(s,t){return typeof s=="number"&&Number.isFinite(s)&&s>0&&s<=1?s*t:pt(s,t)}function h_(s,t){let e=s,i=Number.POSITIVE_INFINITY;for(let n of t){let r=Math.abs(n-s);r<i&&(i=r,e=n)}return e}function d_(s){return s===!0?"modal":s==="trap-focus"?"trap-focus":"none"}function u_(s){return s==null||s===""?null:typeof s=="number"?Number.isFinite(s)?`${Math.max(0,s)}px`:null:String(s)}var tr=class s extends EventTarget{static defaults=Object.freeze({layout:"stack",offset:24,scale:.04,max:3});#t=[];#e=new WeakMap;#i=!1;constructor(t={}){super();let e={...s.defaults,...t&&typeof t=="object"?t:{}};for(let[i,n]of Object.entries(e))!/^on[a-z]/.test(i)||typeof n!="function"||(this.on(i.slice(2),n),delete e[i]);this.options=Object.freeze(e)}push(t){if(!t||typeof t.open!="function")throw new TypeError("SheetStack.push expects a Sheet");let e=this.#t.indexOf(t);if(e!==-1&&this.#t.splice(e,1),this.#t.push(t),!this.#e.has(t)){let i=()=>this.#s(t);this.#e.set(t,i),t.on("close",i)}return t.isOpen()||t.open(),this.#n(),this.#o("push",{sheet:t,depth:0}),this}pop(){let t=this.top();return t?(this.#r(t),t.close(),t):null}popTo(t){let e=this.#t.indexOf(t);if(e===-1)return this;for(;this.#t.length>e+1;)this.pop();return this}clear(){for(;this.#t.length>0;)this.pop();return this}top(){return this.#t[this.#t.length-1]??null}size(){return this.#t.length}sheets(){return[...this.#t]}has(t){return this.#t.includes(t)}on(t,e){return this.addEventListener(t,e),this}off(t,e){return this.removeEventListener(t,e),this}once(t,e){return this.addEventListener(t,e,{once:!0}),this}destroy(){if(!this.#i){this.#i=!0;for(let t of this.#t){let e=this.#e.get(t);e&&t.off("close",e),Nl(t)}this.#t=[]}}#s(t){this.#t.includes(t)&&this.#r(t)}#r(t){let e=this.#t.indexOf(t);if(e===-1)return;this.#t.splice(e,1);let i=this.#e.get(t);i&&t.off("close",i),this.#e.delete(t),Nl(t),this.#n(),this.#o("pop",{sheet:t})}#n(){let{layout:t,offset:e,scale:i,max:n}=this.options,r=t==="cascade",o=0;for(let a=0;a<this.#t.length;a+=1){let c=this.#t[this.#t.length-1-a],h=c.el;h.dataset.stack=r?"cascade":"stack",h.dataset.depth=String(a),h.style.setProperty("--zx-sheet-depth",String(a)),h.style.setProperty("--zx-sheet-stack-offset",`${Number(e)||0}px`),h.style.setProperty("--zx-sheet-stack-scale",String(Number(i)||0)),h.toggleAttribute("data-stack-hidden",a>=Math.max(1,Number(n)||1)),h.inert=!r&&a>0,r?(h.style.setProperty("--zx-sheet-depth-offset",`${o}px`),o+=c.getSize()):h.style.removeProperty("--zx-sheet-depth-offset")}}#o(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))}};function Nl(s){let t=s.el;if(t){delete t.dataset.stack,delete t.dataset.depth,t.removeAttribute("data-stack-hidden"),t.inert=!1;for(let e of["--zx-sheet-depth","--zx-sheet-stack-offset","--zx-sheet-stack-scale","--zx-sheet-depth-offset"])t.style.removeProperty(e)}}var ss='[role="menuitem"]',oi=class extends b{static defaults={items:[],selector:null};#t;#e;#i;#s;#r;#n=[];#o=null;#a=null;#l=!1;constructor(t,e={}){let i=U(t);if(!i)throw new TypeError("ContextMenu target could not be resolved");super(null,e),this.#t=i,document.body.append(this.el),this.#e=new ut(this.el,{openOn:"manual",placement:"bottom-start",scope:i}),this.#i=this.#e.getPanel(),this.#i.classList.add("zx-context-menu"),this.#i.setAttribute("role","menu"),Array.isArray(this.options.items)&&this.setItems(this.options.items),this.#s=Ct(this.#i,ss),this.#r=lt(()=>this.#m(),n=>n.focus()),this.#e.on("close",()=>{this.#o=null;let n=this.#a;this.#a=null,n instanceof HTMLElement&&n.isConnected&&n.focus(),this.emit("close")}),this.listen(this.#t,"contextmenu",n=>this.#d(n)),this.listen(this.#t,"keydown",n=>this.#u(n)),this.listen(this.#i,"click",n=>{let r=n.target.closest?.(ss);r&&this.#i.contains(r)&&this.#p(r)}),this.listen(this.#i,"keydown",n=>this.#_(n))}render(){return l("span",{class:"zx-context-menu__anchor",ariaHidden:"true"})}setItems(t){return this.#n=Array.isArray(t)?t.slice():[],this.#i.replaceChildren(),this.#n.forEach((e,i)=>{if(e==="-"){this.#i.append(l("div",{class:"zx-context-menu__separator",role:"separator"}));return}let n=[];e.icon&&n.push(l("span",{class:"zx-context-menu__icon"},g(e.icon))),n.push(l("span",{class:"zx-context-menu__label"},String(e.label??""))),this.#i.append(l("button",{class:"zx-context-menu__item",type:"button",role:"menuitem",tabindex:"-1","data-menu-item":String(i),"data-danger":e.danger?"true":null,ariaDisabled:e.disabled?"true":null},n))}),this}openAt(t,e,i=null){return this.#c(i)?(this.#h(t,e,i),this):this}openAtElement(t){let e=t.getBoundingClientRect();return this.openAt(e.left,e.bottom,t)}close(){return this.#e.close(),this}isOpen(){return this.#e.isOpen()}getContext(){return this.#o}destroy(){this.#l||(this.#l=!0,this.#s.destroy(),this.#e.destroy(),super.destroy())}#c(t){let e=this.options.items;if(typeof e=="function"){let i=e(t);if(!Array.isArray(i)||i.length===0)return!1;this.setItems(i)}return this.#n.length>0}#h(t,e,i){let n=this.el;n.style.left=`${t}px`,n.style.top=`${e}px`,this.#o=i,this.#a=document.activeElement,this.#e.open(),this.#s.focusFirst(),this.emit("open",{context:i})}#d(t){let e=t,i=this.#f(e.target);!i||!this.#c(i)||(t.preventDefault(),this.#h(e.clientX,e.clientY,i))}#u(t){let e=t;if(e.key!=="ContextMenu"&&!(e.key==="F10"&&e.shiftKey))return;let i=this.#f(e.target);if(!i||!this.#c(i))return;t.preventDefault();let n=i.getBoundingClientRect();this.#h(n.left,n.bottom,i)}#f(t){if(!this.options.selector)return this.#t;let e=t?.closest?.(String(this.options.selector));return e&&this.#t.contains(e)?e:null}#_(t){let e=t;if(e.key==="Escape"||e.key==="Tab"){t.preventDefault(),this.close();return}if(e.key==="Enter"||e.key===" "){let i=e.target.closest?.(ss);if(!i||!this.#i.contains(i))return;t.preventDefault(),this.#p(i);return}this.#r(e)}#p(t){let e=Number(t.getAttribute("data-menu-item")),i=this.#n[e];if(!i||i==="-"||i.disabled)return;let n=this.#o;this.emit("select",{value:i.value,item:i,context:n});try{i.onselect?.(i.value,i,this)}finally{this.close()}}#m(){return Array.from(this.#i.querySelectorAll(ss))}};var rs=Object.freeze(["agenda","day","week","month","year"]),f_=864e5;function ir(s,t,e={}){let i=se(t,"Calendar date"),n=Bl(e.weekStart??1),r,o;if(s==="agenda")r=$(i),o=O(r,as(e.agendaDays??14,"agendaDays"));else if(s==="day")r=$(i),o=O(r,1);else if(s==="week")r=ns(i,n),o=O(r,7);else if(s==="month"){let a=new Date(i.getFullYear(),i.getMonth(),1),c=new Date(i.getFullYear(),i.getMonth()+1,0);r=ns(a,n),o=O(ns(c,n),7)}else if(s==="year")r=new Date(i.getFullYear(),0,1),o=new Date(i.getFullYear()+1,0,1);else throw new RangeError(`Unknown calendar view: ${s}`);return{start:r,end:o}}function sr(s,t,e,i={}){let n=se(t,"Calendar date"),r=Mt(e,"direction");if(s==="day")n.setDate(n.getDate()+r);else if(s==="agenda")n.setDate(n.getDate()+r*as(i.agendaDays??14,"agendaDays"));else if(s==="week")n.setDate(n.getDate()+r*7);else{if(s==="month")return er(n,r);if(s==="year")return er(n,r*12);throw new RangeError(`Unknown calendar view: ${s}`)}return n}function er(s,t){let e=se(s,"Calendar date"),i=e.getDate();return e.setDate(1),e.setMonth(e.getMonth()+Mt(t,"month amount")),e.setDate(Math.min(i,p_(e.getFullYear(),e.getMonth()))),e}function p_(s,t){return new Date(s,t+1,0).getDate()}function be(s,t={}){if(!Array.isArray(s))throw new TypeError("Calendar events must be an array");let e={id:t.eventId??"id",title:t.eventTitle??"title",start:t.eventStart??"start",end:t.eventEnd??"end",allDay:t.eventAllDay??"allDay",color:t.eventColor??"color",location:t.eventLocation??"location",editable:t.eventEditable??"editable",durationEditable:t.eventDurationEditable??"durationEditable"},i=t.dateUnit==="seconds"?"seconds":"milliseconds",n=new Set;return s.map((r,o)=>{if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError(`Calendar event at index ${o} must be an object`);let a=Et(r,e.id);if(a==null||a==="")throw new TypeError(`Calendar event at index ${o} requires an id`);let c=String(a);if(n.has(c))throw new RangeError(`Duplicate Calendar event id: ${c}`);n.add(c);let h=Fl(Et(r,e.start),i,`event ${c} start`),d=Et(r,e.end),u=d==null||d===""?new Date(h.getTime()):Fl(d,i,`event ${c} end`);if(u<h)throw new RangeError(`Calendar event ${c} ends before it starts`);let p=String(Et(r,e.title)??"").trim()||"Untitled event",f=String(Et(r,e.location)??"").trim(),_=Rl(Et(r,e.editable)),m=Rl(Et(r,e.durationEditable));return{id:a,title:p,start:h,end:u,allDay:!!Et(r,e.allDay),color:m_(Et(r,e.color)),location:f,editable:_,durationEditable:m,data:r}})}function K(s){return{...s,start:new Date(s.start.getTime()),end:new Date(s.end.getTime())}}function nr(s,t,e={}){let i=Vl(e.minMinutes??0,"minMinutes"),n=Vl(e.maxMinutes??1440,"maxMinutes",!0),r=as(e.minimumMinutes??30,"minimumMinutes");if(n<=i)throw new RangeError("Calendar maxMinutes must exceed minMinutes");let o=$(t),a=Ll(o,i),c=Ll(o,n),h=s.filter(f=>!St(f)&&rr(f,a,c)).map(f=>{let _=new Date(Math.max(f.start.getTime(),a.getTime())),m=new Date(Math.min(f.end.getTime(),c.getTime()));return m<=_&&(m=new Date(Math.min(c.getTime(),_.getTime()+r*6e4))),{event:f,start:_,end:m,startMinutes:Pl(o,_),endMinutes:Pl(o,m),column:0,columns:1}}).sort((f,_)=>f.start-_.start||_.end-f.end||String(f.event.id).localeCompare(String(_.event.id))),d=[],u=-1/0,p=()=>{if(!d.length)return;let f=[],_=1;for(let m of d){let w=f.findIndex(y=>y<=m.start.getTime());w===-1&&(w=f.length),f[w]=m.end.getTime(),m.column=w,_=Math.max(_,w+1)}for(let m of d)m.columns=_;d=[],u=-1/0};for(let f of h)d.length&&f.start.getTime()>=u&&p(),d.push(f),u=Math.max(u,f.end.getTime());return p(),h}function os(s,t,e){let i=$(t),n=O(i,as(e,"days")),r=s.filter(a=>St(a)&&rr(a,i,n)).map(a=>{let c=$(a.start),h=__(a);return{event:a,start:Math.max(0,xt(i,c)),end:Math.min(e,xt(i,h)),lane:0}}).filter(a=>a.end>a.start).sort((a,c)=>a.start-c.start||c.end-a.end||String(a.event.id).localeCompare(String(c.event.id))),o=[];for(let a of r){let c=o.findIndex(h=>h<=a.start);c===-1&&(c=o.length),a.lane=c,o[c]=a.end}return r}function ai(s,t={}){let e=Mt(t.days??0,"days"),i=Mt(t.minutes??0,"minutes"),n=Mt(t.endDays??e,"endDays"),r=Mt(t.endMinutes??i,"endMinutes"),o=K(s);if(o.start=Ol(o.start,e,i),o.end=Ol(o.end,n,r),o.end<o.start)throw new RangeError("Calendar event proposal ends before it starts");return o}function $(s){let t=se(s,"Calendar date");return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function O(s,t){let e=se(s,"Calendar date"),i=new Date(e.getTime());return i.setDate(i.getDate()+Mt(t,"day amount")),i}function ns(s,t=1){let e=$(s),i=Bl(t);return O(e,-((e.getDay()-i+7)%7))}function xt(s,t){let e=$(s),i=$(t),n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(i.getFullYear(),i.getMonth(),i.getDate());return Math.round((r-n)/f_)}function Y(s){let t=se(s,"Calendar date"),e=i=>String(i).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function St(s){if(s.allDay)return!0;if(s.end<=s.start)return!1;let t=new Date(s.end.getTime()-1);return Y(s.start)!==Y(t)}function li(s,t,e){return rr(s,t,e)}function Ol(s,t,e){let i=new Date(s.getTime());return i.setDate(i.getDate()+t),i.setMinutes(i.getMinutes()+e),i}function __(s){if(s.end<=s.start)return O($(s.start),1);let t=$(s.end);return s.end.getTime()===t.getTime()?t:O(t,1)}function rr(s,t,e){let i=s.end>s.start?s.end:new Date(s.start.getTime()+1);return s.start<e&&i>t}function Et(s,t){return typeof t=="function"?t(s):s[t]}function Fl(s,t,e){let i;if(s instanceof Date)i=new Date(s.getTime());else if(typeof s=="number"||typeof s=="string"&&/^-?\d+(?:\.\d+)?$/.test(s.trim())){let n=Number(s);i=new Date(n*(t==="seconds"?1e3:1))}else i=new Date(s);return se(i,e)}function Rl(s){return s==null?null:!!s}function m_(s){let t=String(s??"").trim();return!t||t.length>100||/[;{}]|url\s*\(|image\s*\(/i.test(t)?null:/^#[\da-f]{3,8}$/i.test(t)||/^(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color)\([^{};]+\)$/i.test(t)||/^var\(--[\w-]+\)$/i.test(t)||/^[a-z]+$/i.test(t)?t:null}function Ll(s,t){let e=$(s);return e.setMinutes(t),e}function Pl(s,t){return(t.getTime()-s.getTime())/6e4}function se(s,t){if(!(s instanceof Date)||Number.isNaN(s.getTime()))throw new TypeError(`${t} must be a valid Date`);return new Date(s.getTime())}function Bl(s){let t=Number(s);if(!Number.isInteger(t)||t<0||t>6)throw new RangeError("weekStart must be from 0 through 6");return t}function Mt(s,t){let e=Number(s);if(!Number.isInteger(e))throw new TypeError(`${t} must be an integer`);return e}function as(s,t){let e=Mt(s,t);if(e<=0)throw new RangeError(`${t} must be greater than zero`);return e}function Vl(s,t,e=!1){let i=Mt(s,t),n=e?1440:1439;if(i<0||i>n)throw new RangeError(`${t} must be from 0 through ${n}`);return i}var g_={today:"Today",new:"New",agenda:"Agenda",day:"Day",week:"Week",month:"Month",year:"Year",previous:"Previous period",next:"Next period",allDay:"All day",noEvents:"No events",more:"+%1 more",loading:"Loading calendar\u2026",move:"Move %1",resize:"Resize %1",moveStarted:"Moving %1. Use arrow keys, Space to drop, or Escape to cancel.",resizeStarted:"Resizing %1. Use arrow keys, Space to drop, or Escape to cancel.",editPreview:"%1, %2 to %3",editCancelled:"Calendar edit cancelled.",editCommitted:"%1 updated.",calendar:"Calendar",weekNumber:"Week %1"},ar=class extends b{static cssName="calendar";static defaults={events:[],date:null,view:"month",views:[...rs],weekStart:1,weekNumbers:!0,workweek:!1,agendaDays:14,slotDuration:30,slotMinTime:0,slotMaxTime:1440,scrollTime:480,eventLimit:3,selectable:!1,editable:!1,eventStartEditable:null,eventDurationEditable:null,optimistic:!0,nowIndicator:!0,now:null,disabled:!1,eventId:"id",eventTitle:"title",eventStart:"start",eventEnd:"end",eventAllDay:"allDay",eventColor:"color",eventLocation:"location",eventEditable:"editable",eventDurationEditable:"durationEditable",dateUnit:"milliseconds",msg:g_};render(){let t=!this.el,e=this.el??l("section");this.el||(this.el=e),this._createdRoot=t,this._original=this._createdRoot?null:{attributes:Array.from(e.attributes).map(({name:u,value:p})=>[u,p]),children:Array.from(e.childNodes)},this._views=b_(this.options.views),this._view=this._views.includes(this.options.view)?this.options.view:this._views[0],this._date=Hl(this.options.date,this.options.dateUnit,this._now()),this._events=be(this.options.events,this._normalizeOptions()),this._loading=!1,this._destroyed=!1,this._pointer=null,this._keyboardEdit=null,this._mutationVersions=new Map,this._mutationSerial=0,this._suppressClickId=null,this._suppressDateClick=!1,this._focusedSlot=null,this._selection=null,this._nowTimer=null;let i=l("div",{class:"zx-calendar__navigation"},this._toolbarButton("previous",this.msg("previous"),"chevron-left"),this._toolbarButton("today",this.msg("today")),this._toolbarButton("next",this.msg("next"),"chevron-right")),n=l("h2",{ref:"heading",class:"zx-calendar__heading",ariaLive:"polite"}),r=l("div",{ref:"views",class:"zx-calendar__views",role:"group",ariaLabel:"Calendar view"},this._views.map(u=>l("button",{type:"button",class:"zx-calendar__view-button",dataset:{calendarAction:"view",view:u},disabled:this.options.disabled},this.msg(u)))),o=l("div",{class:"zx-calendar__commands"},r,l("button",{type:"button",class:"zx-calendar__new",dataset:{calendarAction:"new"},disabled:this.options.disabled},g("plus"),l("span",{},this.msg("new")))),a=l("header",{class:"zx-calendar__toolbar"},i,n,o),c=l("div",{ref:"body",class:"zx-calendar__body"}),h=l("div",{ref:"loading",class:"zx-calendar__loading",role:"status",hidden:!0},this.msg("loading")),d=l("div",{ref:"status",class:"zx-calendar__status",role:"status",ariaLive:"polite",ariaAtomic:"true"});return e.replaceChildren(a,c,h,d),e.setAttribute("aria-label",this.msg("calendar")),e.dataset.view=this._view,e.dataset.state="ready",this.listen(e,"click",u=>this._onClick(u)),this.listen(e,"dblclick",u=>this._onDoubleClick(u)),this.listen(e,"keydown",u=>this._onKeydown(u)),this.listen(e,"pointerdown",u=>this._onPointerDown(u)),this.listen(e,"pointermove",u=>this._onPointerMove(u)),this.listen(e,"pointerup",u=>this._onPointerUp(u)),this.listen(e,"pointercancel",u=>this._cancelPointer(u)),this.listen(e,"dragstart",u=>u.preventDefault()),this._renderView({emitDates:!0,scroll:!0}),this.options.nowIndicator&&(this._nowTimer=setInterval(()=>this._refreshNowIndicator(),6e4)),e}getEvents(){return this._events.map(K)}setEvents(t,e={}){let i=be(t,this._normalizeOptions());return this._events=i,this._mutationVersions.clear(),this._renderView({preserveFocus:!0}),e.silent||this.emit("eventschange",{events:this.getEvents()}),this}addEvent(t,e={}){let[i]=be([t],this._normalizeOptions());if(this._eventById(i.id))throw new RangeError(`Duplicate Calendar event id: ${i.id}`);return this._events=[...this._events,i],this._renderView({preserveFocus:!0}),e.silent||this.emit("eventschange",{events:this.getEvents()}),this}updateEvent(t,e,i={}){let n=this._eventIndex(t);if(n<0)throw new RangeError(`Unknown Calendar event id: ${t}`);let r=this._events[n],o={id:r.id,title:e.title??r.title,start:e.start??r.start,end:e.end??r.end,allDay:e.allDay??r.allDay,color:Object.prototype.hasOwnProperty.call(e,"color")?e.color:r.color,location:e.location??r.location,editable:Object.prototype.hasOwnProperty.call(e,"editable")?e.editable:r.editable,durationEditable:Object.prototype.hasOwnProperty.call(e,"durationEditable")?e.durationEditable:r.durationEditable,data:e.data??r.data},[a]=be([o],{dateUnit:this.options.dateUnit});return a.data=o.data,this._events=this._events.map((c,h)=>h===n?a:c),this._mutationVersions.delete(String(t)),this._renderView({preserveFocus:!0}),i.silent||this.emit("eventschange",{events:this.getEvents()}),this}removeEvent(t,e={}){let i=String(t),n=this._events.filter(r=>String(r.id)!==i);return n.length===this._events.length?this:(this._events=n,this._mutationVersions.delete(i),this._renderView({preserveFocus:!0}),e.silent||this.emit("eventschange",{events:this.getEvents()}),this)}getDate(){return new Date(this._date.getTime())}setDate(t,e={}){return this._date=Hl(t,this.options.dateUnit,this._now()),this._renderView({emitDates:!e.silent,preserveFocus:!0,scroll:!0}),this}getView(){return this._view}setView(t,e={}){if(!this._views.includes(t))throw new RangeError(`Calendar view is not enabled: ${t}`);if(t===this._view)return this;let i=this._view;return this._view=t,this.el.dataset.view=t,this._renderView({emitDates:!0,preserveFocus:!0,scroll:!0}),e.silent||this.emit("viewchange",{view:t,oldView:i}),this}prev(){return this._page(-1)}next(){return this._page(1)}today(){return this.setDate(this._now())}setLoading(t=!0){return this._loading=!!t,this.el.dataset.state=this._loading?"loading":"ready",this.el.setAttribute("aria-busy",String(this._loading)),this.refs.loading.hidden=!this._loading,this}focusEvent(t){return this.el.querySelector(`[data-event-action][data-event-id="${ls(String(t))}"]`)?.focus(),this}destroy(){if(this._destroyed)return;this._destroyed=!0,this._nowTimer&&clearInterval(this._nowTimer),this._nowTimer=null;let t=this._original;if(super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_toolbarButton(t,e,i=null){return l("button",{type:"button",class:"zx-calendar__toolbar-button",dataset:{calendarAction:t},ariaLabel:i?e:null,disabled:this.options.disabled},i?g(i):e)}_normalizeOptions(){return{eventId:this.options.eventId,eventTitle:this.options.eventTitle,eventStart:this.options.eventStart,eventEnd:this.options.eventEnd,eventAllDay:this.options.eventAllDay,eventColor:this.options.eventColor,eventLocation:this.options.eventLocation,eventEditable:this.options.eventEditable,eventDurationEditable:this.options.eventDurationEditable,dateUnit:this.options.dateUnit}}_renderView(t={}){if(!this.refs?.body||this._destroyed)return;let e=t.preserveFocus?this._focusIdentity():null,i=ir(this._view,this._date,{weekStart:this.options.weekStart,agendaDays:this.options.agendaDays});this._range=i,this.refs.heading.textContent=this._rangeTitle(i);for(let r of this.refs.views.querySelectorAll("[data-view]"))r.setAttribute("aria-pressed",String(r.dataset.view===this._view));let n=this._view==="agenda"?this._renderAgenda(i):this._view==="day"||this._view==="week"?this._renderTimeGrid(i):this._view==="month"?this._renderMonth(i):this._renderYear(i);this.refs.body.replaceChildren(n),t.scroll&&this._scrollTimeGrid(),e&&this._restoreFocus(e),t.emitDates&&this.emit("dateschange",{view:this._view,start:new Date(i.start.getTime()),end:new Date(i.end.getTime())})}_renderAgenda(t){let e=l("div",{class:"zx-calendar__agenda",role:"grid",ariaLabel:this._rangeTitle(t)}),i=xt(t.start,t.end);for(let n=0;n<i;n+=1){let r=O(t.start,n),o=O(r,1),a=this._events.filter(d=>li(d,r,o)?d.start>=r||n===0:!1).sort(v_),c=l("section",{class:"zx-calendar__agenda-day",role:"row",dataset:{date:Y(r)}},l("button",{type:"button",class:"zx-calendar__agenda-heading",role:"rowheader",dataset:{calendarAction:"date",date:Y(r),dateCell:"true"},ariaCurrent:re(r,this._now())?"date":null,disabled:this.options.disabled},this._format(r,{weekday:"long",day:"numeric",month:"long"}))),h=l("div",{class:"zx-calendar__agenda-events",role:"gridcell"});if(!a.length)h.append(l("p",{class:"zx-calendar__agenda-empty"},this.msg("noEvents")));else for(let d of a)h.append(this._eventElement(d,{variant:"agenda",day:r}));c.append(h),e.append(c)}return e}_renderTimeGrid(t){let e=Array.from({length:xt(t.start,t.end)},(y,v)=>O(t.start,v)),i=this._view==="week"&&this.options.workweek?e.filter(y=>y.getDay()>0&&y.getDay()<6):e,n=Nt(this.options.slotMinTime,0),r=Nt(this.options.slotMaxTime,1440,!0),o=_t(this.options.slotDuration);if(r<=n)throw new RangeError("slotMaxTime must exceed slotMinTime");let a=Math.ceil((r-n)/o),c=l("div",{class:"zx-calendar__time-surface",style:{"--zx-calendar-day-count":String(i.length)}}),h=l("div",{class:"zx-calendar__time-header"},l("span",{class:"zx-calendar__time-corner",ariaHidden:"true"}),l("div",{class:"zx-calendar__day-headings",role:"row"},i.map(y=>l("button",{type:"button",class:"zx-calendar__day-heading",role:"columnheader",dataset:{calendarAction:"date",date:Y(y),dateCell:"true"},ariaCurrent:re(y,this._now())?"date":null,disabled:this.options.disabled},l("span",{class:"zx-calendar__day-weekday"},this._format(y,{weekday:"short"})),l("span",{class:"zx-calendar__day-number"},this._format(y,{day:"numeric",month:"short"})))))),d=this._renderAllDayRail(i),u=l("div",{ref:"timeScroller",class:"zx-calendar__time-scroller"}),p=l("div",{class:"zx-calendar__time-axis",ariaHidden:"true"}),f=l("div",{class:"zx-calendar__time-grid",role:"grid",ariaLabel:this._rangeTitle(t),ariaRowcount:String(a),ariaColcount:String(i.length),style:{"--zx-calendar-slot-count":String(a)}}),_=l("div",{ref:"slots",class:"zx-calendar__slots"}),m=!0;for(let y=0;y<a;y+=1){let v=n+y*o;p.append(l("span",{class:"zx-calendar__time-label"},v%60===0?or(v,this.options.locale):""));for(let S=0;S<i.length;S+=1){let z=w_(i[S],v),T=String(z.getTime()),I=this._focusedSlot?this._focusedSlot===T:m;I&&(m=!1),_.append(l("button",{type:"button",class:"zx-calendar__slot",role:"gridcell",tabindex:I?0:-1,dataset:{calendarAction:"date",slot:T,dateTime:T,dayIndex:String(S),rowIndex:String(y),major:v%60===0?"true":null},ariaLabel:this._dateTimeLabel(z),disabled:this.options.disabled}))}}let w=l("div",{class:"zx-calendar__timed-events",ariaHidden:"false"});return i.forEach((y,v)=>{let S=nr(this._events,y,{minMinutes:n,maxMinutes:r,minimumMinutes:o});for(let z of S){let T=(z.startMinutes-n)/(r-n)*100,I=Math.max(o/(r-n)*100,(z.endMinutes-z.startMinutes)/(r-n)*100),et=100/i.length,E=et/z.columns,Q=v*et+z.column*E,bt=this._eventElement(z.event,{variant:"timed",day:y,resizable:!0});bt.style.insetInlineStart=`${Q}%`,bt.style.inlineSize=`${E}%`,bt.style.insetBlockStart=`${T}%`,bt.style.blockSize=`${I}%`,w.append(bt)}}),f.append(_,w,this._nowLine(i,n,r)),u.append(p,f),c.append(h,d,u),c}_renderAllDayRail(t){let e=l("div",{class:"zx-calendar__all-day"},l("span",{class:"zx-calendar__all-day-label"},this.msg("allDay"))),i=l("div",{class:"zx-calendar__all-day-grid",role:"row",style:{"--zx-calendar-day-count":String(t.length)}});for(let r of t)i.append(l("span",{class:"zx-calendar__all-day-cell",dataset:{date:Y(r)},ariaHidden:"true"}));let n=os(this._events,t[0],t.length);for(let r of n){let o=this._eventElement(r.event,{variant:"span",day:t[r.start]});o.style.gridColumn=`${r.start+1} / ${r.end+1}`,o.style.gridRow=String(r.lane+1),i.append(o)}return e.append(i),e}_renderMonth(t){let e=l("div",{class:"zx-calendar__month"}),i=l("div",{class:"zx-calendar__month-weekdays",role:"row"});this.options.weekNumbers&&i.append(l("span",{class:"zx-calendar__month-week-gutter",ariaHidden:"true"}));for(let r=0;r<7;r+=1){let o=O(t.start,r);i.append(l("span",{class:"zx-calendar__month-weekday",role:"columnheader"},this._format(o,{weekday:"short"})))}e.append(i);let n=xt(t.start,t.end)/7;for(let r=0;r<n;r+=1){let o=O(t.start,r*7),a=os(this._events.map(m=>({...m,allDay:!0})),o,7),c=y_(this.options.eventLimit),h=a.filter(m=>m.lane<c),d=a.filter(m=>m.lane>=c),u=l("div",{class:"zx-calendar__month-week",role:"row",dataset:{weekStart:Y(o)}});this.options.weekNumbers&&u.append(l("button",{type:"button",class:"zx-calendar__month-week-number",dataset:{calendarAction:"week",date:Y(o)},ariaLabel:this.msg("weekNumber",jl(o)),disabled:this.options.disabled},String(jl(o))));let p=l("div",{class:"zx-calendar__month-days"});for(let m=0;m<7;m+=1){let w=O(o,m),y=this._events.filter(v=>li(v,w,O(w,1))).length;p.append(l("button",{type:"button",class:"zx-calendar__month-day",role:"gridcell",dataset:{calendarAction:"date",date:Y(w),dateCell:"true",otherMonth:w.getMonth()===this._date.getMonth()?null:"true",eventCount:String(y)},ariaCurrent:re(w,this._now())?"date":null,ariaLabel:`${this._format(w,{dateStyle:"full"})}, ${y} ${y===1?"event":"events"}`,disabled:this.options.disabled},this._format(w,{day:"numeric"})))}let f=l("div",{class:"zx-calendar__month-events"});for(let m of h){let w=this._eventElement(m.event,{variant:"month",day:O(o,m.start)});w.style.gridColumn=`${m.start+1} / ${m.end+1}`,w.style.gridRow=String(m.lane+1),f.append(w)}let _=Array.from({length:7},(m,w)=>d.filter(y=>y.start<=w&&y.end>w).length);for(let m=0;m<_.length;m+=1){let w=_[m];if(!w)continue;let y=O(o,m);f.append(l("button",{type:"button",class:"zx-calendar__more",dataset:{calendarAction:"more",date:Y(y),count:String(w)},style:{gridColumn:String(m+1),gridRow:String(c+1)},disabled:this.options.disabled},this.msg("more",w)))}u.append(p,f),e.append(u)}return e.setAttribute("role","grid"),e.setAttribute("aria-label",this._rangeTitle(t)),e}_renderYear(t){let e=t.start.getFullYear(),i=l("div",{class:"zx-calendar__year",ariaLabel:String(e)});for(let n=0;n<12;n+=1){let r=new Date(e,n,1),o=(r.getDay()-this.options.weekStart+7)%7,a=O(r,-o),c=l("div",{class:"zx-calendar__year-grid",role:"grid",ariaLabel:this._format(r,{month:"long"})},l("h3",{class:"zx-calendar__year-heading"},this._format(r,{month:"long"})));for(let h=0;h<7;h+=1){let d=O(a,h);c.append(l("span",{class:"zx-calendar__year-weekday",role:"columnheader"},this._format(d,{weekday:"narrow"})))}for(let h=0;h<42;h+=1){let d=O(a,h);if(d.getMonth()!==n){c.append(l("span",{class:"zx-calendar__year-blank",role:"gridcell",ariaHidden:"true"}));continue}let u=this._events.filter(p=>li(p,d,O(d,1))).length;c.append(l("button",{type:"button",class:"zx-calendar__year-day",role:"gridcell",dataset:{calendarAction:"date",date:Y(d),dateCell:"true",activity:String(Math.min(3,u))},ariaCurrent:re(d,this._now())?"date":null,ariaLabel:`${this._format(d,{dateStyle:"full"})}, ${u} ${u===1?"event":"events"}`,disabled:this.options.disabled},String(d.getDate())))}i.append(c)}return i}_eventElement(t,e){let i=String(t.id),n=l("div",{class:"zx-calendar__event",dataset:{eventId:i,variant:e.variant,allDay:t.allDay?"true":null,draggable:this._canMove(t)?"true":null},style:t.color?{"--zx-calendar-event-color":t.color}:null}),r=l("button",{type:"button",class:"zx-calendar__event-action",dataset:{eventAction:"activate",eventId:i},ariaLabel:this._eventLabel(t),disabled:this.options.disabled}),o=typeof this.options.renderEvent=="function"?this.options.renderEvent(K(t)):null;if(o instanceof Node)r.append(o);else if(typeof o=="string")r.append(document.createTextNode(o));else{let a=l("span",{class:"zx-calendar__event-time"},this._eventTime(t,e.day)),c=l("span",{class:"zx-calendar__event-title"},t.title);r.append(a,c),t.location&&r.append(l("span",{class:"zx-calendar__event-location"},t.location))}return n.append(r),e.resizable&&this._canResize(t)&&n.append(l("button",{type:"button",class:"zx-calendar__event-resize",dataset:{eventAction:"resize",eventId:i},ariaLabel:this.msg("resize",t.title),disabled:this.options.disabled},l("span",{ariaHidden:"true"}))),n}_nowLine(t,e,i){let n=this._now(),r=t.findIndex(c=>re(c,n)),o=n.getHours()*60+n.getMinutes(),a=this.options.nowIndicator&&r>=0&&o>=e&&o<=i;return l("div",{ref:"nowLine",class:"zx-calendar__now",hidden:!a,ariaHidden:"true",style:a?{insetBlockStart:`${(o-e)/(i-e)*100}%`,"--zx-calendar-now-day":String(r)}:null},l("span",{class:"zx-calendar__now-time"},or(o,this.options.locale)))}_onClick(t){let e=t.target?.closest?.("button");if(!e||!this.el.contains(e))return;let i=e.dataset.eventId;if(i!=null&&this._suppressClickId===i){this._suppressClickId=null,t.preventDefault();return}if(e.dataset.eventAction==="activate"){let r=this._eventById(i);r&&this.emit("eventclick",{event:K(r),jsEvent:t});return}if(e.dataset.eventAction==="resize")return;let n=e.dataset.calendarAction;if(n){if(n==="previous")this.prev();else if(n==="next")this.next();else if(n==="today")this.today();else if(n==="view")this.setView(e.dataset.view);else if(n==="new")this.emit("new",{date:this.getDate(),view:this._view,jsEvent:t});else if(n==="week"){let r=qt(e.dataset.date);r&&this.setDate(r).setView("week")}else if(n==="more"){let r=qt(e.dataset.date);if(!r)return;!this.emit("moreclick",{date:r,count:Number(e.dataset.count),jsEvent:t}).defaultPrevented&&this._views.includes("agenda")&&this.setDate(r).setView("agenda")}else if(n==="date"){if(this._suppressDateClick){this._suppressDateClick=!1,t.preventDefault();return}let r=this._dateFromTarget(e);if(!r)return;this._rememberFocusedDate(e),this.emit("dateclick",{date:r,allDay:!e.dataset.dateTime,view:this._view,jsEvent:t})}}}_onDoubleClick(t){let e=t.target?.closest?.('[data-event-action="activate"]');if(e){let a=this._eventById(e.dataset.eventId);a&&this.emit("eventdblclick",{event:K(a),jsEvent:t});return}let i=t.target?.closest?.('[data-calendar-action="date"]');if(!i)return;let n=this._dateFromTarget(i);if(!n)return;let r=!i.dataset.dateTime,o=r?O(n,1):ne(n,_t(this.options.slotDuration));this.emit("select",{start:n,end:o,allDay:r,view:this._view,jsEvent:t})}_onKeydown(t){let e=t.target?.closest?.("[data-event-action]");if(e){this._onEventKeydown(t,e);return}let i=t.target?.closest?.("[data-slot]");if(i){this._onSlotKeydown(t,i);return}let n=t.target?.closest?.("[data-date-cell]");n&&this._onDayKeydown(t,n)}_onEventKeydown(t,e){let i=this._eventById(e.dataset.eventId);if(!i)return;let n=e.dataset.eventAction==="resize";if(t.key==="Enter"&&!this._keyboardEdit&&!n){t.preventDefault(),this.emit("eventclick",{event:K(i),jsEvent:t});return}if(t.key===" "&&!this._keyboardEdit){if(n?!this._canResize(i):!this._canMove(i))return;t.preventDefault(),this._keyboardEdit={oldEvent:K(i),event:K(i),action:n?"resize":"move",control:e},e.setAttribute("aria-grabbed","true"),e.closest(".zx-calendar__event")?.setAttribute("data-state","grabbed"),this._announce(this.msg(n?"resizeStarted":"moveStarted",i.title));return}if(!this._keyboardEdit||String(this._keyboardEdit.event.id)!==String(i.id))return;if(t.key==="Escape"){t.preventDefault(),this._cancelKeyboardEdit();return}if(t.key===" "){t.preventDefault();let h=this._keyboardEdit;this._keyboardEdit=null,h.control.removeAttribute("aria-grabbed"),this._commitMutation(h.oldEvent,h.event,h.action,t);return}let r=0,o=0,a=!St(i)&&(this._view==="day"||this._view==="week");if(t.key==="ArrowLeft")r=-1;else if(t.key==="ArrowRight")r=1;else if(t.key==="ArrowUp")a?o=-_t(this.options.slotDuration):r=-7;else if(t.key==="ArrowDown")a?o=_t(this.options.slotDuration):r=7;else return;t.preventDefault();let c=this._keyboardEdit;if(c.action==="move")c.event=ai(c.event,{days:r,minutes:o});else{let h=ai(c.event,{days:0,minutes:0,endDays:r,endMinutes:o});h.end>h.start&&(c.event=h)}c.control.closest(".zx-calendar__event")?.setAttribute("data-preview",this._eventTime(c.event,c.event.start)),this._announce(this.msg("editPreview",c.event.title,this._dateTimeLabel(c.event.start),this._dateTimeLabel(c.event.end)))}_onSlotKeydown(t,e){let i=Number(e.dataset.rowIndex),n=Number(e.dataset.dayIndex),r=e.closest('[role="grid"]'),o=Number(r?.getAttribute("aria-colcount"))||1,a=Number(r?.getAttribute("aria-rowcount"))||1,c=i,h=n;if(t.key==="ArrowLeft")h-=1;else if(t.key==="ArrowRight")h+=1;else if(t.key==="ArrowUp")c-=1;else if(t.key==="ArrowDown")c+=1;else if(t.key==="Home")h=0;else if(t.key==="End")h=o-1;else if(t.key==="PageUp"){t.preventDefault(),this.prev();return}else if(t.key==="PageDown"){t.preventDefault(),this.next();return}else if(t.key==="Enter"||t.key===" "){t.preventDefault();let u=this._dateFromTarget(e);u&&this.emit("dateclick",{date:u,allDay:!1,view:this._view,jsEvent:t});return}else return;t.preventDefault(),c=Math.max(0,Math.min(a-1,c)),h=Math.max(0,Math.min(o-1,h));let d=r?.querySelector(`[data-row-index="${c}"][data-day-index="${h}"]`);d&&(e.tabIndex=-1,d.tabIndex=0,this._focusedSlot=d.dataset.slot,d.focus())}_onDayKeydown(t,e){let i=qt(e.dataset.date);if(!i)return;let n=0;if(t.key==="ArrowLeft")n=-1;else if(t.key==="ArrowRight")n=1;else if(t.key==="ArrowUp")n=-7;else if(t.key==="ArrowDown")n=7;else if(t.key==="Home")n=-((i.getDay()-this.options.weekStart+7)%7);else if(t.key==="End")n=6-(i.getDay()-this.options.weekStart+7)%7;else if(t.key==="PageUp"){t.preventDefault(),this.prev();return}else if(t.key==="PageDown"){t.preventDefault(),this.next();return}else return;t.preventDefault();let r=O(i,n),o=this.el.querySelector(`[data-date-cell][data-date="${Y(r)}"]`);o?o.focus():this.setDate(r)}_onPointerDown(t){if(this.options.disabled||t.button!==0)return;let e=t.target?.closest?.("[data-event-action]");if(e){let r=this._eventById(e.dataset.eventId),o=e.dataset.eventAction==="resize"?"resize":"move";if(!r||(o==="move"?!this._canMove(r):!this._canResize(r)))return;t.preventDefault(),this._capturePointer(t.pointerId);let a=o==="move"?this._dragOffsetForEvent(r,t.clientX,t.clientY):null;this._pointer={type:"event",pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,oldEvent:K(r),event:K(r),action:o,control:e,timeOffsetMinutes:a?.minutes??0,dayOffset:a?.days??0,moved:!1};return}let i=t.target?.closest?.("[data-slot]");if(!i||!this.options.selectable)return;let n=this._dateFromTarget(i);n&&(t.preventDefault(),this._capturePointer(t.pointerId),this._pointer={type:"selection",pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,start:n,end:ne(n,_t(this.options.slotDuration)),control:i,moved:!1})}_onPointerMove(t){let e=this._pointer;if(!e||e.pointerId!==t.pointerId||!e.moved&&Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<5)return;if(e.moved=!0,t.preventDefault(),e.type==="selection"){let r=this._timeAtPoint(t.clientX,t.clientY);if(!r)return;let o=_t(this.options.slotDuration);e.end=ne(r,o),this._previewSelection(e.start,e.end);return}let i=this._proposalAtPoint(e.oldEvent,e.action,t.clientX,t.clientY);if(!i)return;e.event=i;let n=e.control.closest(".zx-calendar__event");if(n){if(n.dataset.state="dragging",e.action==="resize"){n.style.transform="";let r=this._timedPreviewHeight(i);r&&(n.style.blockSize=r)}else n.style.transform=`translate(${t.clientX-e.startX}px, ${t.clientY-e.startY}px)`;n.dataset.preview=this._eventTime(i,i.start)}this._announce(this.msg("editPreview",i.title,this._dateTimeLabel(i.start),this._dateTimeLabel(i.end)))}_onPointerUp(t){let e=this._pointer;if(!(!e||e.pointerId!==t.pointerId)&&(this._pointer=null,this._releasePointerCapture(e.pointerId),this._clearSelectionPreview(),!!e.moved)){if(t.preventDefault(),e.type==="selection"){this._suppressDateClick=!0;let i=e.start<e.end?e.start:ne(e.end,-_t(this.options.slotDuration)),n=e.start<e.end?e.end:ne(e.start,_t(this.options.slotDuration));this.emit("select",{start:new Date(i),end:new Date(n),allDay:!1,view:this._view,jsEvent:t});return}this._suppressClickId=String(e.oldEvent.id),this._commitMutation(e.oldEvent,e.event,e.action,t)}}_cancelPointer(t){if(!this._pointer||this._pointer.pointerId!==t.pointerId)return;let e=this._pointer.control;this._releasePointerCapture(this._pointer.pointerId),this._pointer=null,this._clearSelectionPreview(),e.closest?.(".zx-calendar__event")?.removeAttribute("data-state"),this._renderView({preserveFocus:!0})}_proposalAtPoint(t,e,i,n){let r=e==="resize"&&!St(t),o=this._timeAtPoint(i,n,r?t.start:null);if(o&&!St(t)){if(e==="move"){let f=t.end.getTime()-t.start.getTime(),_=K(t);return _.start=ne(o,-Number(this._pointer?.timeOffsetMinutes??0)),_.end=new Date(_.start.getTime()+f),_}let p=K(t);return p.end=ne(o,_t(this.options.slotDuration)),p.end>p.start?p:null}let a=this._dayAtPoint(i,n);if(!a)return null;let c=O(a,-Number(this._pointer?.dayOffset??0)),h=xt($(t.start),c);if(e==="move")return ai(t,{days:h,minutes:0});let d=K(t),u=O(a,1);return d.end=new Date(u.getTime()),d.end>d.start?d:null}_timeAtPoint(t,e,i=null){let n=this.refs.body.querySelector(".zx-calendar__slots");if(!n)return null;let r=n.getBoundingClientRect(),a=n.closest(".zx-calendar__time-scroller")?.getBoundingClientRect(),c=a?Math.max(r.left,a.left):r.left,h=a?Math.min(r.right,a.right):r.right,d=a?Math.max(r.top,a.top):r.top,u=a?Math.min(r.bottom,a.bottom):r.bottom;if(t<c||t>h||e<d||e>u||r.width<=0||r.height<=0)return null;let p=Number(n.closest('[role="grid"]')?.getAttribute("aria-colcount"))||1,f=Number(n.closest('[role="grid"]')?.getAttribute("aria-rowcount"))||1,_=i?this._timeGridDayIndex(i):-1,m=_>=0?_:Math.max(0,Math.min(p-1,Math.floor((t-r.left)/r.width*p))),w=Math.max(0,Math.min(f-1,Math.floor((e-r.top)/r.height*f))),y=n.querySelector(`[data-row-index="${w}"][data-day-index="${m}"]`);return y?this._dateFromTarget(y):null}_dayAtPoint(t,e){let i=this.refs.body.querySelector(".zx-calendar__all-day-grid");if(i){let r=i.getBoundingClientRect();if(t>=r.left&&t<=r.right&&e>=r.top&&e<=r.bottom){let o=i.querySelectorAll("[data-date]"),a=Math.max(0,Math.min(o.length-1,Math.floor((t-r.left)/r.width*o.length)));return qt(o[a]?.dataset.date)}}for(let r of this.refs.body.querySelectorAll(".zx-calendar__month-events")){let o=r.getBoundingClientRect();if(t<o.left||t>o.right||e<o.top||e>o.bottom||o.width<=0)continue;let a=qt(r.closest(".zx-calendar__month-week")?.dataset.weekStart);if(!a)continue;let c=Math.max(0,Math.min(6,Math.floor((t-o.left)/o.width*7)));return O(a,c)}for(let r of this.refs.body.querySelectorAll(".zx-calendar__agenda-day")){let o=r.getBoundingClientRect();if(!(t<o.left||t>o.right||e<o.top||e>o.bottom))return qt(r.dataset.date)}let n=typeof document.elementsFromPoint=="function"?document.elementsFromPoint(t,e):[];for(let r of n){let o=r instanceof HTMLElement?r.closest("[data-date]"):null,a=o instanceof HTMLElement?o.dataset.date:null;if(a)return qt(a)}return null}_dragOffsetForEvent(t,e,i){if(!St(t)){let o=this._timeAtPoint(e,i);if(o){let a=_t(this.options.slotDuration),c=Math.max(0,Math.round((t.end.getTime()-t.start.getTime())/6e4)),h=Math.max(0,c-a),d=Math.round((o.getTime()-t.start.getTime())/6e4);return{minutes:Math.max(0,Math.min(h,d)),days:0}}}let n=this._dayAtPoint(e,i),r=n?xt($(t.start),n):0;return{minutes:0,days:Math.max(0,r)}}_timeGridDayIndex(t){let e=Y(t);return[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")].findIndex(n=>n.dataset.date===e)}_timedPreviewHeight(t){if(!this.refs.body.querySelector(".zx-calendar__time-grid")||St(t))return null;let i=Nt(this.options.slotMinTime,0),n=Nt(this.options.slotMaxTime,1440,!0),r=_t(this.options.slotDuration),o=t.start.getHours()*60+t.start.getMinutes(),a=t.end.getHours()*60+t.end.getMinutes();return`${Math.max(r,Math.min(n,a)-Math.max(i,o))/(n-i)*100}%`}_capturePointer(t){try{this.el.setPointerCapture?.(t)}catch{}}_releasePointerCapture(t){this.el.hasPointerCapture?.(t)&&this.el.releasePointerCapture?.(t)}_previewSelection(t,e){let i=Math.min(t.getTime(),e.getTime()),n=Math.max(t.getTime(),e.getTime());for(let r of this.refs.body.querySelectorAll("[data-slot]")){let o=Number(r.dataset.dateTime);r.setAttribute("aria-selected",String(o>=i&&o<n))}}_clearSelectionPreview(){for(let t of this.refs.body.querySelectorAll("[data-slot][aria-selected]"))t.removeAttribute("aria-selected")}_cancelKeyboardEdit(){let t=this._keyboardEdit;t&&(t.control.removeAttribute("aria-grabbed"),t.control.closest(".zx-calendar__event")?.removeAttribute("data-state"),this._keyboardEdit=null,this._announce(this.msg("editCancelled")),this._renderView({preserveFocus:!0}))}_commitMutation(t,e,i,n){if(!(t.start.getTime()!==e.start.getTime()||t.end.getTime()!==e.end.getTime())){this._renderView({preserveFocus:!0});return}let o=String(t.id),a=++this._mutationSerial,c=!1;this.options.optimistic?(this._replaceNormalizedEvent(e),this._mutationVersions.set(o,a),this._renderView({preserveFocus:!0})):this._renderView({preserveFocus:!0});let h=()=>{if(c||!this.options.optimistic||this._mutationVersions.get(o)!==a)return!1;let p=this._eventById(o);return!p||p.start.getTime()!==e.start.getTime()||p.end.getTime()!==e.end.getTime()?!1:(c=!0,this._replaceNormalizedEvent(t),this._mutationVersions.delete(o),this._renderView({preserveFocus:!0}),this._announce(this.msg("editCancelled")),!0)},d={event:K(e),oldEvent:K(t),action:i,delta:x_(t,e),jsEvent:n,revert:h};this.emit("eventchange",d).defaultPrevented?h():this._announce(this.msg("editCommitted",e.title))}_replaceNormalizedEvent(t){let e=String(t.id);this._events=this._events.map(i=>String(i.id)===e?K(t):i)}_canMove(t){return this.options.disabled?!1:t.editable!=null?t.editable:this.options.eventStartEditable!=null?!!this.options.eventStartEditable:!!this.options.editable}_canResize(t){return this.options.disabled?!1:t.durationEditable!=null?t.durationEditable:this.options.eventDurationEditable!=null?!!this.options.eventDurationEditable:!!this.options.editable}_eventById(t){let e=this._eventIndex(t);return e<0?null:this._events[e]}_eventIndex(t){let e=String(t);return this._events.findIndex(i=>String(i.id)===e)}_page(t){return this.setDate(sr(this._view,this._date,t,{agendaDays:this.options.agendaDays}))}_rangeTitle(t){if(this._view==="day")return this._format(t.start,{weekday:"long",day:"numeric",month:"long",year:"numeric"});if(this._view==="month")return this._format(this._date,{month:"long",year:"numeric"});if(this._view==="year")return this._format(this._date,{year:"numeric"});let e=O(t.end,-1),i=new Intl.DateTimeFormat(this.options.locale,{day:"numeric",month:"long",year:"numeric"});return typeof i.formatRange=="function"?i.formatRange(t.start,e):t.start.getFullYear()!==e.getFullYear()?`${this._format(t.start,{day:"numeric",month:"short",year:"numeric"})} \u2013 ${this._format(e,{day:"numeric",month:"short",year:"numeric"})}`:t.start.getMonth()!==e.getMonth()?`${this._format(t.start,{day:"numeric",month:"short"})} \u2013 ${this._format(e,{day:"numeric",month:"short",year:"numeric"})}`:`${this._format(t.start,{day:"numeric"})}\u2013${this._format(e,{day:"numeric",month:"long",year:"numeric"})}`}_eventTime(t,e){if(t.allDay)return this.msg("allDay");if(St(t))return re(t.start,e)?`${ci(t.start,this.options.locale)} \u2192`:re(t.end,e)?`\u2192 ${ci(t.end,this.options.locale)}`:this.msg("allDay");let i=lr(t.start,this.options.locale);return t.end<=t.start?i:`${i}\u2013${lr(t.end,this.options.locale)}`}_eventLabel(t){let e=t.location?`, ${t.location}`:"";return`${t.title}, ${ci(t.start,this.options.locale)} to ${ci(t.end,this.options.locale)}${e}`}_dateTimeLabel(t){return ci(t,this.options.locale)}_format(t,e){return new Intl.DateTimeFormat(this.options.locale,e).format(t)}_now(){let t=typeof this.options.now=="function"?this.options.now():this.options.now,e=t??new Date;if(!(e instanceof Date)||Number.isNaN(e.getTime()))throw new TypeError("Calendar now must return a valid Date");return new Date(e.getTime())}_dateFromTarget(t){if(t.dataset.dateTime){let e=new Date(Number(t.dataset.dateTime));return Number.isNaN(e.getTime())?null:e}return qt(t.dataset.date)}_rememberFocusedDate(t){t.dataset.slot&&(this._focusedSlot=t.dataset.slot)}_focusIdentity(){let t=document.activeElement;return!(t instanceof HTMLElement)||!this.el.contains(t)?null:{eventId:t.dataset.eventId,eventAction:t.dataset.eventAction,date:t.dataset.date,slot:t.dataset.slot}}_restoreFocus(t){let e=null;t.eventId&&(e=this.el.querySelector(`[data-event-id="${ls(t.eventId)}"][data-event-action="${t.eventAction??"activate"}"]`)),!e&&t.slot&&(e=this.el.querySelector(`[data-slot="${ls(t.slot)}"]`)),!e&&t.date&&(e=this.el.querySelector(`[data-date-cell][data-date="${ls(t.date)}"]`)),e?.focus?.()}_scrollTimeGrid(){let t=this.refs.body.querySelector(".zx-calendar__time-scroller");if(!t)return;let e=Nt(this.options.slotMinTime,0),i=Nt(this.options.slotMaxTime,1440,!0),n=Nt(this.options.scrollTime,480,!0),r=Math.max(0,Math.min(1,(n-e)/(i-e)));requestAnimationFrame(()=>{t.isConnected&&(t.scrollTop=Math.max(0,r*t.scrollHeight-t.clientHeight/4))})}_refreshNowIndicator(){if(this._destroyed||!this.options.nowIndicator||!["day","week"].includes(this._view))return;let t=this.refs.body.querySelector(".zx-calendar__now"),e=[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")];if(!t||!e.length)return;let i=this._now(),n=e.findIndex(h=>h.dataset.date===Y(i)),r=Nt(this.options.slotMinTime,0),o=Nt(this.options.slotMaxTime,1440,!0),a=i.getHours()*60+i.getMinutes(),c=n>=0&&a>=r&&a<=o;t.hidden=!c,c&&(t.style.insetBlockStart=`${(a-r)/(o-r)*100}%`,t.style.setProperty("--zx-calendar-now-day",String(n)),t.querySelector(".zx-calendar__now-time").textContent=or(a,this.options.locale))}_announce(t){this.refs.status.textContent="",requestAnimationFrame(()=>{this._destroyed||(this.refs.status.textContent=t)})}};function b_(s){if(!Array.isArray(s)||s.length===0)throw new TypeError("Calendar views must be a non-empty array");let t=[...new Set(s.map(String))];for(let e of t)if(!rs.includes(e))throw new RangeError(`Unknown Calendar view: ${e}`);return t}function Hl(s,t,e){if(s==null)return e;if(s instanceof Date){if(Number.isNaN(s.getTime()))throw new TypeError("Calendar date must be valid");return new Date(s.getTime())}let i=typeof s=="number"?s:typeof s=="string"&&/^-?\d+(?:\.\d+)?$/.test(s.trim())?Number(s):null,n=i==null?new Date(s):new Date(i*(t==="seconds"?1e3:1));if(Number.isNaN(n.getTime()))throw new TypeError("Calendar date must be valid");return n}function _t(s){let t=Number(s);if(!Number.isInteger(t)||t<=0||t>720||1440%t!==0)throw new RangeError("Calendar slotDuration must be a positive divisor of 1440");return t}function y_(s){let t=Number(s);if(!Number.isInteger(t)||t<1||t>20)throw new RangeError("Calendar eventLimit must be an integer from 1 through 20");return t}function Nt(s,t,e=!1){let i=Number(s??t),n=e?1440:1439;if(!Number.isInteger(i)||i<0||i>n)throw new RangeError(`Calendar minute must be from 0 through ${n}`);return i}function w_(s,t){let e=$(s);return e.setMinutes(t),e}function ne(s,t){let e=new Date(s.getTime());return e.setMinutes(e.getMinutes()+t),e}function ql(s){return`${s.getFullYear()}-${s.getMonth()}-${s.getDate()}`}function re(s,t){return ql(s)===ql(t)}function qt(s){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s??""));if(!t)return null;let e=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return Y(e)===s?e:null}function v_(s,t){return s.start-t.start||t.end-s.end||s.title.localeCompare(t.title)}function or(s,t){let e=new Date(2026,0,1);return e.setHours(Math.floor(s/60)%24,s%60,0,0),lr(e,t)}function lr(s,t){return new Intl.DateTimeFormat(t,{hour:"2-digit",minute:"2-digit"}).format(s)}function ci(s,t){return new Intl.DateTimeFormat(t,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(s)}function jl(s){let t=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t-i)/864e5+1)/7)}function x_(s,t){let e=t.start.getTime()-s.start.getTime();return{milliseconds:e,days:xt($(s.start),$(t.start)),minutes:Math.round(e/6e4),endMilliseconds:t.end.getTime()-s.end.getTime()}}function ls(s){return globalThis.CSS?.escape?CSS.escape(s):s.replace(/[^a-zA-Z0-9_-]/g,t=>`\\${t}`)}var mt=class extends b{static cssName="record-view";static defaults={fields:[],data:[],recordId:"ID",sort:null,sortMode:"local",selectable:!1,selection:[],fieldOrder:[],hiddenFields:[],fieldControls:!0,emptyText:null};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("div");return this._recordViewOriginal=t?null:A(e),this._recordViewDestroyed=!1,this._initRecordView(e),e}destroy(){if(this._recordViewDestroyed)return;this._recordViewDestroyed=!0;let t=this.el,e=this._recordViewOriginal;super.destroy(),e&&t&&k(t,e)}_initRecordView(t){this.el=t,t.classList.add("zx-record-view"),this._viewFields=hr(this.options.fields),this._viewFieldOrder=hi(this._viewFields,this.options.fieldOrder),this._viewHidden=dr(this._viewFields,this.options.hiddenFields,!0),this._viewData=cr(this.options.data),this._viewSort=cs(this.options.sort,this._viewFields),this._viewSelected=new Set,this._viewSelectionAnchor=null,this._viewFieldControls=null,this._viewFieldList=null,this._viewInitialized=!0,this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._setInitialSelection(this.options.selection)}setData(t){this._viewData=cr(t),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData();let e=this._pruneViewSelection();return this.setLoading(!1),this._refreshView("data"),e&&this._emitViewSelection(),this.emit("datachange",{records:this.getData()}),this}addData(t){return this._viewData.push(...cr(t)),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("data"),this.emit("datachange",{records:this.getData()}),this}updateRecord(t,e){Gl(e);let i=this._viewData.findIndex(o=>Object.is(this._viewRecordId(o),t));if(i<0)return this;let n=this._viewSelected.delete(t);this._viewData[i]=e;let r=this._viewRecordId(e);return n&&this._viewSelected.add(r),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("data"),n&&!Object.is(t,r)&&this._emitViewSelection(),this.emit("datachange",{records:this.getData()}),this}removeRecord(t){let e=this._viewData.findIndex(n=>Object.is(this._viewRecordId(n),t));if(e<0)return this;this._viewData.splice(e,1);let i=this._viewSelected.delete(t);return Object.is(this._viewSelectionAnchor,t)&&(this._viewSelectionAnchor=null),this._refreshView("data"),i&&this._emitViewSelection(),this.emit("datachange",{records:this.getData()}),this}getRecord(t){return this._viewData.find(e=>Object.is(this._viewRecordId(e),t))??null}getData(){return[...this._viewData]}setFields(t){let e=this.getFieldOrder(),i=this.getHiddenFields();return this._viewFields=hr(t),this._viewFieldOrder=hi(this._viewFields,e),this._viewHidden=dr(this._viewFields,i),this._viewSort=cs(this._viewSort,this._viewFields),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("fields"),this._renderViewFieldControls(),this._emitViewState("fields"),this}getFields(){let t=new Map(this._viewFields.map(e=>[e.id,e]));return this._viewFieldOrder.map(e=>({...t.get(e)}))}getVisibleFields(){return this.getFields().filter(t=>!this._viewHidden.has(t.id))}getHiddenFields(){return this._viewFieldOrder.filter(t=>this._viewHidden.has(t))}getFieldOrder(){return[...this._viewFieldOrder]}setFieldVisible(t,e=!0,i={}){let n=String(t);if(!this._viewFields.some(o=>o.id===n))throw new RangeError(`Unknown view field: ${n}`);if(!e&&!this._viewHidden.has(n)&&this.getVisibleFields().length<=1)return this._renderViewFieldControls(n),this;let r=e?this._viewHidden.delete(n):!this._viewHidden.has(n);return!e&&r&&this._viewHidden.add(n),r?(this._refreshView("fields"),this._renderViewFieldControls(n),i.silent||(this.emit("fieldvisibilitychange",{visible:this.getVisibleFields().map(o=>o.id),hidden:this.getHiddenFields()}),this._emitViewState("fieldvisibility")),this):this}toggleField(t,e={}){return this.setFieldVisible(t,this._viewHidden.has(String(t)),e)}moveField(t,e,i="before",n={}){let r=Ul(this._viewFieldOrder,String(t),String(e),i);return $l(r,this._viewFieldOrder)?this:this.setFieldOrder(r,n)}setFieldOrder(t,e={}){let i=hi(this._viewFields,t);return $l(i,this._viewFieldOrder)?this:(this._viewFieldOrder=i,this._refreshView("fields"),this._renderViewFieldControls(),e.silent||(this.emit("fieldorderchange",{order:this.getFieldOrder()}),this._emitViewState("fieldorder")),this)}setSort(t,e="asc",i={}){let n=t==null?null:cs({id:String(t),dir:e},this._viewFields);if(t!=null&&!n)throw new RangeError(`Unknown or unsortable view field: ${t}`);return k_(n,this._viewSort)?this:(this._viewSort=n,n&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("sort"),i.silent||(this.emit("sortchange",n?{...n}:{id:null,dir:null}),this._emitViewState("sort")),this)}getSort(){return this._viewSort?{...this._viewSort}:null}getSelection(){return this._viewData.filter(t=>this._viewSelected.has(this._viewRecordId(t)))}getSelectionIds(){return this.getSelection().map(t=>this._viewRecordId(t))}setSelection(t,e={}){let i=new Set(Array.isArray(t)?t:[]),r=this._viewData.map(o=>this._viewRecordId(o)).filter(o=>i.has(o));return this.options.selectable===!1&&(r=[]),this.options.selectable==="single"&&(r=r.slice(0,1)),Kl(this._viewSelected,new Set(r))?this:(this._viewSelected=new Set(r),this._viewSelectionAnchor=r.at(-1)??null,this._refreshView("selection"),e.silent||this._emitViewSelection(),this)}clearSelection(t={}){return this.setSelection([],t)}toggleSelection(t,e={}){if(this.options.selectable===!1||!this.getRecord(t))return this;let i=e.selected??!this._viewSelected.has(t);if(this.options.selectable==="single")this._viewSelected=i?new Set([t]):new Set;else if(e.range&&this._viewSelectionAnchor!=null){let n=this._viewData.map(a=>this._viewRecordId(a)),r=n.findIndex(a=>Object.is(a,this._viewSelectionAnchor)),o=n.findIndex(a=>Object.is(a,t));if(r>=0&&o>=0)for(let a of n.slice(Math.min(r,o),Math.max(r,o)+1))i?this._viewSelected.add(a):this._viewSelected.delete(a)}else i?this._viewSelected.add(t):this._viewSelected.delete(t);return this._viewSelectionAnchor=t,this._refreshView("selection"),this._emitViewSelection(),this}setLoading(t=!0){return t?this.el.setAttribute("data-loading","true"):this.el.removeAttribute("data-loading"),this.el.setAttribute("aria-busy",String(!!t)),this._refreshView("loading"),this}getViewState(){return{version:1,fieldOrder:this.getFieldOrder(),hiddenFields:this.getHiddenFields(),sort:this.getSort()}}setViewState(t,e={}){let i=Wl(t,this._viewFields);return this._viewFieldOrder=i.fieldOrder,this._viewHidden=new Set(i.hiddenFields),this._viewSort=i.sort,this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("state"),this._renderViewFieldControls(),e.silent||this._emitViewState("restore"),this}_createViewFieldControls(t="Fields"){let e=l("div",{class:"zx-record-view__field-list"}),i=l("details",{class:"zx-record-view__field-controls"},l("summary",{class:"zx-button zx-button--sm"},g("fields",{size:13}),t),e);return this._viewFieldControls=i,this._viewFieldList=e,this._renderViewFieldControls(),this.listen(e,"change",n=>{let r=n.target;r?.classList.contains("zx-record-view__field-toggle")&&this.setFieldVisible(r.value,r.checked)}),this.listen(e,"click",n=>{let r=n.target?.closest?.("[data-view-field-action]");if(!r)return;let o=r.dataset.fieldId,a=r.dataset.viewFieldAction,c=this._viewFieldOrder.indexOf(String(o));a==="up"&&c>0&&this.moveField(String(o),this._viewFieldOrder[c-1],"before"),a==="down"&&c>=0&&c<this._viewFieldOrder.length-1&&this.moveField(String(o),this._viewFieldOrder[c+1],"after")}),i}_refreshView(t){}_viewRecordId(t){return ye(t,this.options.recordId)}_isViewSelected(t){return this._viewSelected.has(t)}_sortViewData(){this._viewSort&&(this._viewData=Yl(this._viewData,this._viewFields,this._viewSort))}_setInitialSelection(t){let e=new Set(Array.isArray(t)?t:[]),n=this._viewData.map(r=>this._viewRecordId(r)).filter(r=>e.has(r));this.options.selectable===!1&&(n=[]),this.options.selectable==="single"&&(n=n.slice(0,1)),this._viewSelected=new Set(n),this._viewSelectionAnchor=n.at(-1)??null}_pruneViewSelection(){let t=new Set(this._viewData.map(n=>this._viewRecordId(n))),e=new Set([...this._viewSelected].filter(n=>t.has(n))),i=!Kl(e,this._viewSelected);return this._viewSelected=e,this._viewSelectionAnchor!=null&&!t.has(this._viewSelectionAnchor)&&(this._viewSelectionAnchor=null),i}_emitViewSelection(){this.emit("selectionchange",{records:this.getSelection(),ids:this.getSelectionIds()})}_emitViewState(t){this.emit("statechange",{state:this.getViewState(),reason:t})}_renderViewFieldControls(t=null){if(!this._viewFieldList)return;let e=this.getFields(),i=e.filter(r=>!this._viewHidden.has(r.id));this._viewFieldControls.hidden=e.length===0;let n=e.map((r,o)=>{let a=l("input",{class:"zx-record-view__field-toggle",type:"checkbox",value:r.id,checked:!this._viewHidden.has(r.id),disabled:!this._viewHidden.has(r.id)&&i.length===1}),c=l("button",{class:"zx-record-view__field-move",type:"button",ariaLabel:`Move ${r.label} up`,disabled:o===0,dataset:{viewFieldAction:"up",fieldId:r.id}},g("chevron-up",{size:11})),h=l("button",{class:"zx-record-view__field-move",type:"button",ariaLabel:`Move ${r.label} down`,disabled:o===e.length-1,dataset:{viewFieldAction:"down",fieldId:r.id}},g("chevron-down",{size:11}));return l("div",{class:"zx-record-view__field-option"},l("label",{},a,l("span",{},r.label)),l("span",{class:"zx-record-view__field-order"},c,h))});if(this._viewFieldList.replaceChildren(...n),t!=null){let r=[...this._viewFieldList.querySelectorAll(".zx-record-view__field-toggle")].find(o=>o.value===t);queueMicrotask(()=>{r?.isConnected&&r.focus()})}}};function hr(s){if(!Array.isArray(s))throw new TypeError("Record view fields must be an array");let t=new Set;return s.map((e,i)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError(`Record view field at index ${i} must be an object`);let n=String(e.id??"").trim();if(!n)throw new TypeError(`Record view field at index ${i} requires an id`);if(t.has(n))throw new TypeError(`Duplicate record view field: ${n}`);return t.add(n),{...e,id:n,label:String(e.label??S_(n)),sortable:!!e.sortable,type:String(e.type??"text")}})}function hi(s,t){let e=s.map(r=>r.id),i=new Set(e),n=Array.isArray(t)?t.map(String):[];return[...new Set(n.filter(r=>i.has(r))),...e.filter(r=>!n.includes(r))]}function Ul(s,t,e,i="before"){let n=[...s],r=n.indexOf(t),o=n.indexOf(e);if(r<0||o<0||r===o)return n;n.splice(r,1);let a=n.indexOf(e)+(i==="after"?1:0);return a=Math.max(0,Math.min(n.length,a)),n.splice(a,0,t),n}function tt(s,t,e=0){return typeof s.get=="function"?s.get(t,e):t?.[s.id]}function hs(s,t,e=0){let i=tt(s,t,e);return typeof s.render=="function"?s.render(t,e,i):i==null?"":String(i)}function Yl(s,t,e){if(!e)return[...s];let i=t.find(r=>r.id===e.id);if(!i)return[...s];let n=new WeakMap(s.map((r,o)=>[r,o]));return Xe(s,r=>typeof i.sortValue=="function"?i.sortValue(r,n.get(r)??0):tt(i,r,n.get(r)??0),e.dir)}function Wl(s,t){let e=s&&typeof s=="object"?s:{};return{version:1,fieldOrder:hi(t,e.fieldOrder),hiddenFields:[...dr(t,e.hiddenFields)],sort:cs(e.sort,t)}}function ye(s,t){return typeof t=="function"?t(s):s?.[String(t??"ID")]}function cs(s,t){if(!s||typeof s!="object")return null;let e=String(s.id??""),i=t.find(n=>n.id===e);return!i||!i.sortable?null:{id:e,dir:s.dir==="desc"?"desc":"asc"}}function dr(s,t,e=!1){let i=new Set(s.map(r=>r.id)),n=new Set(Array.isArray(t)?t.map(String).filter(r=>i.has(r)):[]);if(e)for(let r of s)r.visible===!1&&n.add(r.id);return n.size>=s.length&&s[0]&&n.delete(s[0].id),n}function cr(s){if(!Array.isArray(s))throw new TypeError("Record view data must be an array");return s.forEach(Gl),[...s]}function Gl(s){if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("Record view data entries must be objects")}function S_(s){let t=String(s).split(".").at(-1)??"";if(t==="ID")return"ID";let e=t.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):t}function k_(s,t){return s===null&&t===null||!!(s&&t&&s.id===t.id&&s.dir===t.dir)}function $l(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function Kl(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}var fr=class extends mt{static cssName="table-view";static defaults={table:{}};constructor(t=null,e={}){super(t,e)}render(){let t=this.el===null,e=this.el??l("div");this.el=e,this._createdTableViewRoot=t,this._tableViewOriginal=t?null:A(e),this._tableViewRestored=!1,this._tableSyncDepth=0,this._tableViewDestroyed=!1,this._tableHost=l("div",{class:"zx-table-view__table"}),this._initRecordView(e);try{e.replaceChildren(this._tableHost);let i=this.options,n=A_(i.table,{fields:this.getFields(),data:this.getData(),recordId:this.options.recordId,sort:this.getSort(),sortMode:this.options.sortMode,selectable:this.options.selectable,hiddenFields:this.getHiddenFields(),fieldControls:this.options.fieldControls,emptyText:this.options.emptyText});return this.table=new Dt(this._tableHost,n),this.table.setSelection(this.getSelectionIds()),this._bridgeTableEvents(),e}catch(i){throw this.table?.destroy(),t||k(e,this._tableViewOriginal),i}}getTable(){return this.table}_refreshView(t){!this.table||this._tableSyncDepth>0||this._withTableSync(()=>{if((t==="fields"||t==="state")&&(this.table.setColumns(Ql(this.getFields()),{silent:!0}),this._syncTableFieldState()),(t==="data"||t==="fields"||t==="sort"||t==="state")&&this.table.setData(this.getData()),t==="sort"||t==="fields"||t==="state"){let e=this.getSort();e?this.table.setSort(e.id,e.dir,{silent:!0}):this.table.clearSort({silent:!0})}(t==="selection"||t==="data"||t==="state")&&this.table.setSelection(this.getSelectionIds()),t==="loading"&&this.table.setLoading(this.el.dataset.loading==="true")})}destroy(){this._tableViewDestroyed||(this._tableViewDestroyed=!0,this.table?.destroy(),!this._tableViewRestored&&!this._createdTableViewRoot&&(k(this.el,this._tableViewOriginal),this._tableViewRestored=!0),super.destroy())}_withTableSync(t){this._tableSyncDepth+=1;try{t()}finally{this._tableSyncDepth-=1}}_syncTableFieldState(){let t=new Set(this.getHiddenFields());for(let e of this.getFieldOrder())t.has(e)||this.table.setColumnVisible(e,!0,{silent:!0});for(let e of this.getFieldOrder())t.has(e)&&this.table.setColumnVisible(e,!1,{silent:!0})}_bridgeTableEvents(){this.listen(this._tableHost,"zx-datachange",t=>t.stopPropagation()),this.listen(this._tableHost,"zx-selectionchange",t=>t.stopPropagation()),this.listen(this.table,"rowclick",t=>{let e=t.detail;this.emit("recordclick",{...e,record:e.row})}),this.listen(this.table,"rowdblclick",t=>{let e=t.detail;this.emit("recorddblclick",{...e,record:e.row})}),this.listen(this.table,"sort",t=>this._tableSortChanged(t.detail)),this.listen(this.table,"selectionchange",t=>this._tableSelectionChanged(t.detail)),this.listen(this.table,"datachange",()=>this._tableDataChanged()),this.listen(this.table,"columnvisibilitychange",t=>this._tableVisibilityChanged(t.detail)),this.listen(this.table,"columnorderchange",t=>this._tableOrderChanged(t.detail))}_tableSortChanged(t){if(this._tableSyncDepth>0)return;let e=t.id==null?null:{id:String(t.id),dir:t.dir==="desc"?"desc":"asc"};z_(e,this._viewSort)||(this._viewSort=e,this.options.sortMode==="local"&&(this._viewData=this.table.getData()),this.emit("sortchange",e?{...e}:{id:null,dir:null}),this._emitTableViewState("sort"))}_tableSelectionChanged(t){if(this._tableSyncDepth>0)return;let e=new Set(t.ids);ur(e,this._viewSelected)||(this._viewSelected=e,this._viewSelectionAnchor=t.ids.at(-1)??null,this._emitTableViewSelection())}_tableDataChanged(){if(this._tableSyncDepth>0)return;this._viewData=this.table.getData();let t=new Set(this._viewData.map(n=>this._viewRecordId(n))),e=new Set([...this._viewSelected].filter(n=>t.has(n))),i=!ur(e,this._viewSelected);this._viewSelected=e,this._viewSelectionAnchor!=null&&!t.has(this._viewSelectionAnchor)&&(this._viewSelectionAnchor=null),i&&this._emitTableViewSelection(),this.emit("datachange",{records:this.getData()})}_tableVisibilityChanged(t){if(this._tableSyncDepth>0)return;let e=new Set(this.getFieldOrder()),i=new Set(t.hidden.filter(n=>e.has(n)));ur(i,this._viewHidden)||(this._viewHidden=i,this.emit("fieldvisibilitychange",{visible:this.getVisibleFields().map(n=>n.id),hidden:this.getHiddenFields()}),this._emitTableViewState("fieldvisibility"))}_tableOrderChanged(t){if(this._tableSyncDepth>0)return;let e=new Set(this.getFieldOrder()),i=[...new Set(t.order.filter(n=>e.has(n))),...this.getFieldOrder().filter(n=>!t.order.includes(n))];C_(i,this._viewFieldOrder)||(this._viewFieldOrder=i,this.emit("fieldorderchange",{order:this.getFieldOrder()}),this._emitTableViewState("fieldorder"))}_emitTableViewSelection(){this.emit("selectionchange",{records:this.getSelection(),ids:this.getSelectionIds()})}_emitTableViewState(t){this.emit("statechange",{state:this.getViewState(),reason:t})}};function Ql(s){return s.map(t=>{let e=t.view&&typeof t.view=="object"&&t.view.table&&typeof t.view.table=="object"?t.view.table:{},i={...t,...e,id:t.id,label:t.label,sortable:!!t.sortable};if(delete i.get,delete i.visible,delete i.duplicate,delete i.view,typeof t.render=="function")i.render=(n,r)=>t.render(n,r,tt(t,n,r));else if(typeof e.render!="function"&&typeof t.get=="function"){let n={...i};delete n.render,i.render=(r,o)=>pn(n,{...r,[t.id]:tt(t,r,o)},o)}return typeof t.sortValue=="function"?i.sortValue=n=>t.sortValue(n,0):typeof e.sortValue!="function"&&typeof t.get=="function"&&(i.sortValue=n=>tt(t,n,0)),i})}function A_(s,t){return{...s&&typeof s=="object"?s:{},columns:Ql(t.fields),data:[...t.data],rowId:t.recordId,sort:t.sort?{...t.sort}:null,sortMode:t.sortMode,selectable:t.selectable,hiddenColumns:[...t.hiddenFields],columnVisibility:!!t.fieldControls,columnReorder:!!t.fieldControls,emptyText:t.emptyText}}function z_(s,t){return s===null&&t===null||!!(s&&t&&s.id===t.id&&s.dir===t.dir)}function ur(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}function C_(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function fs(s,t,e={}){let i=Array.isArray(e.fields)?e.fields:[],n=Array.isArray(e.visibleFields)?e.visibleFields:i,r=e.titleField??i[0]?.id??null,o=e.subtitleField??null,a=Xl(s,t,r,i),c=Xl(s,t,o,i),h=D_(s,t,e.preview,e.previewAlt,i),d=I_(s,t,e.link),u=di(s,t,e.actions),p=L_(e.controls),f=V_(e.selectable),_=!!e.selected,m=x("zx-record-card-title"),w=H_(e.headingLevel),y=d?l("a",{class:"zx-record-card__primary",href:d.href,target:d.target,rel:d.rel},ds(a)):l("span",{class:"zx-record-card__title"},ds(a)),v=l(`h${w}`,{class:"zx-record-card__heading",id:m},y),S=T_(n,r,o),z=M_(s,t,S.eyebrowStart,S.eyebrowEnd),T=us(s,t,S.titlePrefix,"zx-record-card__title-prefix","title-prefix"),I=T?l("div",{class:"zx-record-card__title-row"},T,v):v,et=f==="multi"?l("label",{class:"zx-record-card__selection"},l("input",{type:"checkbox",checked:_,dataset:{recordSelection:""},ariaLabel:`Select ${Jl(a)||"record"}`})):null,E=u.map(O_),Q=E.length||p.length?l("div",{class:"zx-record-card__actions",role:"group",ariaLabel:`Actions for ${Jl(a)||"record"}`},p,E):null,bt=l("header",{class:"zx-record-card__header"},et,l("div",{class:"zx-record-card__titles"},I,R_(c)?null:l("p",{class:"zx-record-card__subtitle"},ds(c))),Q),Kc=us(s,t,S.metadata,"zx-record-card__metadata"),Uc=l("div",{class:"zx-record-card__body"},z,bt,Kc);return l("li",{class:"zx-record-card",tabindex:0,ariaDescription:f?_?"Selected":"Not selected":void 0,ariaLabelledby:m,dataset:{recordIndex:String(t),variant:B_(e.variant),selected:String(_)}},h?E_(h):null,Uc)}function T_(s,t=null,e=null){let i={eyebrowStart:[],eyebrowEnd:[],titlePrefix:[],metadata:[]},n=typeof t=="string"?t:null,r=typeof e=="string"?e:null;for(let o of Array.isArray(s)?s:[]){if(!o.duplicate&&(o.id===n||o.id===r))continue;let a=N_(o);a==="eyebrow-start"?i.eyebrowStart.push(o):a==="eyebrow-end"?i.eyebrowEnd.push(o):a==="title-prefix"?i.titlePrefix.push(o):i.metadata.push(o)}return i}function D_(s,t,e,i,n=[]){if(e==null)return null;let r=typeof e=="function"?e(s,t):Zl(s,t,e,n,!1);if(r==null||r==="")return null;let o=F_(s,t,i,n);if(ps(r))return{node:r,src:null,alt:o,fit:"cover",rejected:!1};let a=typeof r=="object"&&!Array.isArray(r)?r:{src:String(r)},c=typeof a.src=="string"?a.src:"",h=P_(c);return{node:null,src:h,alt:a.alt==null?o:String(a.alt),fit:q_(a.fit),rejected:h===null}}function I_(s,t,e){let i=typeof e=="function"?e(s,t):e;if(i==null)return null;let n=typeof i=="string"?{href:i}:i;if(!n||typeof n!="object"||Array.isArray(n))return null;let r=it(n.href);if(r===null)return null;let o=n.target==null?void 0:String(n.target),a=tc(n.rel,o);return{href:r,...o?{target:o}:{},...a?{rel:a}:{}}}function di(s,t,e){let i=typeof e=="function"?e(s,t):e;return Array.isArray(i)?i.flatMap(n=>{if(!n||typeof n!="object"||Array.isArray(n))return[];let r=String(n.id??"").trim(),o=String(n.label??""),a=n.title==null?"":String(n.title);return!r||!o&&!a?[]:n.href!=null&&it(n.href)===null?[]:[{...n,id:r,label:o,...a?{title:a}:{}}]}):[]}function E_(s){let t=l("span",{class:"zx-record-card__preview-fallback",ariaHidden:"true"},g("file",{size:24}));if(s.node)return l("div",{class:"zx-record-card__preview"},s.node);let e=s.src?l("img",{class:"zx-record-card__preview-image",src:s.src,alt:s.alt,loading:"lazy",decoding:"async",dataset:{recordPreview:""},style:{objectFit:s.fit}}):null;return l("div",{class:"zx-record-card__preview",dataset:{failed:String(s.rejected)}},t,e)}function M_(s,t,e,i){let n=us(s,t,e,"zx-record-card__eyebrow-group","eyebrow-start"),r=us(s,t,i,"zx-record-card__eyebrow-group","eyebrow-end");return n||r?l("div",{class:"zx-record-card__eyebrow"},n,r):null}function us(s,t,e,i,n=null){return e.length===0?null:l("dl",{class:i,dataset:n?{cardSlot:n}:void 0},e.map(r=>l("div",{class:"zx-record-card__field",dataset:{fieldId:r.id,...n?{cardSlot:n}:{}}},l("dt",{class:"zx-record-card__label"},r.label),l("dd",{class:"zx-record-card__value"},ds(hs(r,s,t))))))}function N_(s){let t=s?.view;if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t.card;if(!e||typeof e!="object"||Array.isArray(e))return null;let i=e.slot;return i==="eyebrow-start"||i==="eyebrow-end"||i==="title-prefix"?i:null}function O_(s){let t=String(s.label??""),e=String(s.title??(t||s.id)),i=[s.icon?g(String(s.icon),{size:14}):null,t?l("span",{class:"zx-record-card__action-label"},t):null],n=s.href==null?null:it(s.href);if(n&&!s.disabled){let r=s.target==null?void 0:String(s.target);return l("a",{class:"zx-record-card__action",href:n,target:r,rel:tc(s.rel,r),title:e,ariaLabel:t||e,dataset:{recordAction:s.id}},i)}return l("button",{class:"zx-record-card__action",type:"button",disabled:!!s.disabled,title:e,ariaLabel:t||e,dataset:{recordAction:s.id}},i)}function Xl(s,t,e,i){if(e==null)return"";if(typeof e=="function")return e(s,t);let n=i.find(r=>r.id===e);return n?hs(n,s,t):s?.[e]??""}function Zl(s,t,e,i,n){let r=i.find(o=>o.id===e);return r?tt(r,s,t):Object.prototype.hasOwnProperty.call(s,e)?s[e]:n?e:null}function F_(s,t,e,i){if(e==null)return"";let n=typeof e=="function"?e(s,t):Zl(s,t,e,i,!0);return n==null?"":String(n)}function ds(s){return ps(s)?s:s==null?"":String(s)}function R_(s){return s==null||typeof s!="object"&&String(s)===""}function Jl(s){return ps(s)?s.textContent?.trim()??"":s==null?"":String(s).trim()}function ps(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function L_(s){return Array.isArray(s)?s.filter(ps):[]}function P_(s){let t=it(s);if(!t)return null;try{let e=globalThis.location?.href??"https://zx.invalid/",i=new URL(t,e).protocol.toLowerCase();return["http:","https:","blob:"].includes(i)?t:null}catch{return null}}function tc(s,t){let e=String(s??"").split(/\s+/).filter(i=>/^[a-z-]+$/i.test(i));return t==="_blank"&&!e.includes("noopener")&&e.push("noopener"),e.length?[...new Set(e)].join(" "):void 0}function V_(s){return s==="single"||s==="multi"?s:!1}function B_(s){return s==="raised"||s==="filled"?s:"outlined"}function H_(s){let t=Number(s??3);return Number.isInteger(t)&&t>=1&&t<=6?t:3}function q_(s){return["contain","fill","none","scale-down"].includes(String(s))?s:"cover"}var pr=class extends mt{static cssName="card-view";static defaults={...mt.defaults,titleField:null,subtitleField:null,preview:void 0,previewAlt:null,link:void 0,actions:[],groupBy:null,groupOrder:[],minCardWidth:"15rem",maxColumns:null,variant:"outlined",loadingCount:6,headingLevel:3,label:"Card view"};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._cardCreatedRoot=t,this._cardOriginal=t?null:A(e),this._cardCleaned=!1,this._cardNodesById=new Map;let i=this._cardOptions();this._cardGroupOrder=_r(i.groupOrder),this._cardMinWidth=ec(i.minCardWidth),this._cardMaxColumns=ic(i.maxColumns),this._cardVariant=sc(i.variant),this._cardLoadingCount=K_(i.loadingCount),this._cardHeadingLevel=U_(i.headingLevel);try{this._initRecordView(e),e.setAttribute("aria-label",String(i.label||"Card view"));let n=l("label",{ref:"sortWrap",class:"zx-card-view__sort"},l("span",{class:"zx-card-view__sort-label"},"Sort"),l("select",{ref:"sort",ariaLabel:"Sort cards"})),r=l("div",{class:"zx-record-view__toolbar zx-card-view__toolbar"},n);this.options.fieldControls&&r.append(this._createViewFieldControls("Fields"));let o=l("div",{ref:"content",class:"zx-card-view__content"});return e.replaceChildren(r,o),this.listen(this.refs.sort,"change",()=>this._changeCardSort()),this.listen(o,"click",a=>this._cardClick(a)),this.listen(o,"dblclick",a=>this._cardDoubleClick(a)),this.listen(o,"keydown",a=>this._cardKeydown(a)),this.listen(o,"error",a=>this._cardPreviewError(a),!0),this._applyCardLayout(),this._renderCardSort(),this._renderCards(),e}catch(n){throw t||k(e,this._cardOriginal),n}}getViewState(){return{...super.getViewState(),groupOrder:[...this._cardGroupOrder],minCardWidth:this._cardMinWidth,maxColumns:this._cardMaxColumns,variant:this._cardVariant}}setViewState(t,e={}){let i=t&&typeof t=="object"?t:{};return Object.prototype.hasOwnProperty.call(i,"groupOrder")&&(this._cardGroupOrder=_r(i.groupOrder)),Object.prototype.hasOwnProperty.call(i,"minCardWidth")&&(this._cardMinWidth=ec(i.minCardWidth)),Object.prototype.hasOwnProperty.call(i,"maxColumns")&&(this._cardMaxColumns=ic(i.maxColumns)),Object.prototype.hasOwnProperty.call(i,"variant")&&(this._cardVariant=sc(i.variant)),this._applyCardLayout(),super.setViewState(i,e)}destroy(){this._cardCleaned||(this._cardCleaned=!0,super.destroy(),this._cardCreatedRoot||k(this.el,this._cardOriginal))}_refreshView(t){this.refs?.content&&(t==="selection"?this._syncCardSelection():this._renderCards(),this._renderCardSort())}_applyCardLayout(){if(!this.el)return;let t=this.el;t.style.setProperty("--zx-card-view-min-card-width",this._cardMinWidth);let e=this._cardMaxColumns?`${100/this._cardMaxColumns}%`:"0%";t.style.setProperty("--zx-card-view-column-basis",e),this._cardMaxColumns?t.dataset.maxColumns=String(this._cardMaxColumns):delete t.dataset.maxColumns}_renderCardSort(){if(!this.refs?.sort||!this.refs?.sortWrap)return;let t=this.refs.sort,e=this.getSort(),i=[l("option",{value:"",selected:e===null},"Unsorted")];for(let n of this.getFields().filter(r=>r.sortable))i.push(l("option",{selected:e?.id===n.id&&e.dir==="asc",dataset:{sortId:n.id,sortDir:"asc"}},`${n.label} (ascending)`)),i.push(l("option",{selected:e?.id===n.id&&e.dir==="desc",dataset:{sortId:n.id,sortDir:"desc"}},`${n.label} (descending)`));t.replaceChildren(...i),this.refs.sortWrap.hidden=i.length===1}_changeCardSort(){let e=this.refs.sort.selectedOptions[0],i=e?.dataset.sortId;i?this.setSort(i,e.dataset.sortDir==="desc"?"desc":"asc"):this.setSort(null)}_renderCards(){let t=this.refs.content,e=t.querySelector(".zx-record-card:focus"),i=e?Number(e.dataset.recordIndex):-1,n=i>=0?this._viewData[i]:null,r=n?this._viewRecordId(n):null;if(this._cardNodesById=new Map,this.el.dataset.loading==="true"){t.replaceChildren(this._createCardSkeletons());return}let o=j_(this._viewData,this._cardOptions().groupBy,this._cardGroupOrder,this._viewFields);if(this._viewData.length===0&&o.length===0){t.replaceChildren(this._createCardEmpty());return}let a=this.getFields(),c=this.getVisibleFields(),h=o.map((d,u)=>this._createCardGroup(d,a,c,u));if(t.replaceChildren(...h),r!==null){let d=this._cardNodesById.get(r);d&&queueMicrotask(()=>d.isConnected&&d.focus())}}_createCardGroup(t,e,i,n){let r=this._cardOptions(),o=t.id===null?null:`zx-card-view-group-${W_(t.id)}-${n}`,a=l("ul",{class:"zx-card-view__list",ariaLabelledby:o??void 0});for(let c of t.records){let h=this._viewData.indexOf(c),d=this._viewRecordId(c),u=fs(c,h,{fields:e,visibleFields:i,titleField:r.titleField,subtitleField:r.subtitleField,preview:r.preview,previewAlt:r.previewAlt,link:r.link,actions:r.actions,selectable:this.options.selectable,selected:this._isViewSelected(d),variant:this._cardVariant,headingLevel:this._cardHeadingLevel});this._cardNodesById.set(d,u),a.append(u)}return t.records.length===0&&a.append(l("li",{class:"zx-card-view__group-empty"},"No records in this group.")),t.id===null?a:l("section",{class:"zx-card-view__group",ariaLabelledby:o},l("h2",{class:"zx-card-view__group-heading",id:o},t.label),a)}_createCardSkeletons(){let t=l("ul",{class:"zx-card-view__list zx-card-view__skeletons",ariaHidden:"true"});for(let e=0;e<this._cardLoadingCount;e+=1)t.append(l("li",{class:"zx-record-card zx-card-view__skeleton",tabindex:-1},l("span",{class:"zx-card-view__skeleton-preview zx-skeleton"}),l("span",{class:"zx-card-view__skeleton-line zx-skeleton"}),l("span",{class:"zx-card-view__skeleton-line zx-skeleton"}),l("span",{class:"zx-card-view__skeleton-line zx-skeleton"})));return t}_createCardEmpty(){let t=this.options.emptyText,e=typeof t=="function"?t():t??this.msg("table.empty");return l("div",{class:"zx-card-view__empty",role:"status"},Y_(e)?e:String(e))}_syncCardSelection(){for(let[t,e]of this._cardNodesById){let i=this._isViewSelected(t);e.dataset.selected=String(i),this.options.selectable&&e.setAttribute("aria-description",i?"Selected":"Not selected");let n=e.querySelector("[data-record-selection]");n&&(n.checked=i)}}_cardClick(t){let e=t.target,i=e?.closest?.(".zx-record-card");if(!i||!this.refs.content.contains(i))return;let n=Number(i.dataset.recordIndex),r=this._viewData[n];if(!r)return;let o=this._viewRecordId(r),a=e?.closest?.("[data-record-selection]");if(a){this.toggleSelection(o,{selected:a.checked,range:t.shiftKey});return}let c=e?.closest?.("[data-record-action]");if(c){this._activateCardAction(r,o,n,c.dataset.recordAction,t);return}nc(e,i)||rc(i)||(this._activateCard(r,o,n,t),this.options.selectable==="single"&&this.toggleSelection(o,{selected:!0}))}_cardDoubleClick(t){let e=t.target,i=e?.closest?.(".zx-record-card");if(!i||nc(e,i)||rc(i))return;let n=Number(i.dataset.recordIndex),r=this._viewData[n];r&&this.emit("recorddblclick",{record:r,id:this._viewRecordId(r),index:n,event:t})}_cardKeydown(t){let e=t.target instanceof Element?t.target.closest(".zx-record-card"):null;if(!e||t.target!==e)return;let i=Number(e.dataset.recordIndex),n=this._viewData[i];if(!n)return;let r=this._viewRecordId(n);t.key==="Enter"?(t.preventDefault(),this._activateCard(n,r,i,t)):t.key===" "&&this.options.selectable&&(t.preventDefault(),this.toggleSelection(r))}_activateCard(t,e,i,n){this.emit("recordclick",{record:t,id:e,index:i,event:n})}_activateCardAction(t,e,i,n,r){let o=di(t,i,this._cardOptions().actions).find(c=>c.id===n);if(!o||o.disabled){r.preventDefault();return}typeof o.onclick=="function"&&o.onclick(t,i,r),this.emit("recordaction",{record:t,id:e,index:i,action:{...o},event:r}).defaultPrevented&&r.preventDefault()}_cardPreviewError(t){let e=t.target;if(!e?.matches?.("[data-record-preview]"))return;let i=e.closest(".zx-record-card__preview");i&&(i.dataset.failed="true"),e.hidden=!0}_cardOptions(){return this.options}};function j_(s,t,e=[],i=[]){if(!Array.isArray(s))throw new TypeError("Card view records must be an array");if(t==null)return s.length?[{id:null,label:"",records:[...s]}]:[];let n=_r(e),r=new Map(n.map(o=>[o,[]]));for(let[o,a]of s.entries()){let c=typeof t=="function"?t(a,o):$_(a,o,t,i),h=oc(c);r.has(h)||r.set(h,[]),r.get(h).push(a)}return[...r].map(([o,a])=>({id:o,label:o||"Ungrouped",records:a}))}function $_(s,t,e,i){let n=i.find(r=>r.id===e);return n?tt(n,s,t):s?.[e]}function _r(s){return Array.isArray(s)?[...new Set(s.map(oc))]:[]}function oc(s){return s==null||s===""?"":String(s)}function ec(s){if(typeof s=="number")return Number.isFinite(s)&&s>0?`${s}px`:"15rem";let t=String(s??"").trim();return!t||t.length>128||/[;{}\u0000-\u001f\u007f]/.test(t)||/(?:url|image|image-set|cross-fade|element|expression)\s*\(/i.test(t)||typeof globalThis.CSS?.supports=="function"&&!globalThis.CSS.supports("width",t)?"15rem":t}function ic(s){if(s==null||s==="")return null;let t=Number(s);return Number.isFinite(t)?Math.max(1,Math.min(12,Math.floor(t))):null}function sc(s){return s==="raised"||s==="filled"?s:"outlined"}function K_(s){let t=Number(s??6);return Number.isFinite(t)?Math.max(1,Math.min(50,Math.floor(t))):6}function U_(s){let t=Number(s??3);return Number.isInteger(t)&&t>=1&&t<=6?t:3}function nc(s,t){let e=s?.closest?.('a,button,input,select,textarea,summary,[contenteditable="true"],[role="button"]');return!!(e&&e!==t&&t.contains(e))}function rc(s){let t=globalThis.getSelection?.();return!!(t&&!t.isCollapsed&&(t.anchorNode&&s.contains(t.anchorNode)||t.focusNode&&s.contains(t.focusNode)))}function Y_(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function W_(s){return s.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"empty"}var G_=Object.freeze(["neutral","accent","success","warning","danger","info"]);function mr(s){if(s==null)return[];if(!Array.isArray(s))throw new TypeError("Kanban rules must be an array or null");let t=new Set;return s.map((e,i)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError(`Kanban rule at index ${i} must be an object`);let n=e,r=String(n.id??"").trim();if(!r)throw new TypeError(`Kanban rule at index ${i} requires an id`);if(t.has(r))throw new TypeError(`Duplicate Kanban rule: ${r}`);if(typeof n.when!="function")throw new TypeError(`Kanban rule ${r} requires a when predicate`);return t.add(r),{id:r,when:n.when,tone:G_.includes(n.tone)?n.tone:"accent",label:n.label==null?"":String(n.label),icon:n.icon==null?null:String(n.icon),description:n.description==null?"":String(n.description)}})}function _s(s,t,e){return!Array.isArray(s)||!s.length?[]:s.filter(i=>{try{return i.when(t,e)===!0}catch{return!1}})}function gr(s){let{records:t,column:e,swimlane:i,context:n,from:r}=s,o=Math.max(1,t.length),a=e?.wipPolicy==="block"||e?.wipPolicy==="warn"?e.wipPolicy:s.policy==="block"?"block":"warn",c=(_,m={})=>({allowed:!1,reason:_,limit:null,count:0,limitExceeded:!1,limitReached:!1,policy:a,...m}),h=ms(e,i,r);if(h)return c(h);for(let _ of t){if(e.accept&&e.accept(_,n)===!1)return c("accept");if(i?.accept&&i.accept(_,n)===!1)return c("lane-accept")}let d=[];e.limit!=null&&d.push({reason:"wip",limit:e.limit,count:s.columnCount+o});let u=i?Q_(e.laneLimits,i.id):null;u!=null&&d.push({reason:"wip",limit:u,count:s.cellCount+o}),i?.limit!=null&&d.push({reason:"lane-wip",limit:i.limit,count:s.laneCount+o});let p=d.find(_=>_.count>_.limit),f=p??d.find(_=>_.count===_.limit)??d[0];return p&&a==="block"?c(p.reason,{limit:p.limit,count:p.count,limitExceeded:!0}):{allowed:!0,reason:null,limit:f?f.limit:null,count:f?f.count:0,limitExceeded:!!p,limitReached:!!(f&&!p&&f.count===f.limit),policy:a}}function ms(s,t,e){return s.id!==e.column&&!ac(s.from,e.column)?"transition":t&&t.id!==e.lane&&!ac(t.from,e.lane)?"lane-transition":null}function br(s){let t=s==null?"":String(s).trim().toLowerCase();return t?[...t.matchAll(/"([^"]*)"|(\S+)/g)].map(e=>(e[1]??e[2]??"").trim()).filter(Boolean):[]}function yr(s,t){if(!t.length)return!0;let e=s.toLowerCase();return t.every(i=>e.includes(i))}function wr(s=50){let t=Number.isFinite(Number(s))&&Number(s)>0?Math.floor(Number(s)):50,e=[],i=[];return{push(n){e.push(n),e.length>t&&(e=e.slice(-t)),i=[]},undo(n){let r=e.pop();return r?(i.push(n),i.length>t&&(i=i.slice(-t)),r):null},redo(n){let r=i.pop();return r?(e.push(n),e.length>t&&(e=e.slice(-t)),r):null},canUndo:()=>e.length>0,canRedo:()=>i.length>0,clear(){e=[],i=[]},depth:()=>({undo:e.length,redo:i.length})}}function vr(s,t,e){if(!Array.isArray(s)||!Array.isArray(t)||!t.length)return null;let i=t.map(d=>({...d,index:s.findIndex(u=>Object.is(ye(u,e.recordId),d.id))}));if(i.some(d=>d.index<0||!d.record||typeof d.record!="object"))return null;i.sort((d,u)=>d.index-u.index);let n=i.map(d=>({id:d.id,from:gs(s,d.index,e)})),r=new Set(i.map(d=>d.index)),o=s.filter((d,u)=>!r.has(u)),a=o.filter((d,u)=>H(jt(d,u,e.columnBy))===e.destination.column&&(e.swimlaneBy==null||H(jt(d,u,e.swimlaneBy))===e.destination.lane)),c=ui(e.destination.index,a.length),h=o.length;return a[c]?h=o.indexOf(a[c]):a.length&&(h=o.indexOf(a.at(-1))+1),o.splice(h,0,...i.map(d=>d.record)),{records:o,moves:n,to:{column:e.destination.column,lane:e.swimlaneBy==null?null:e.destination.lane,index:c}}}function gs(s,t,e){let i=s[t],n=H(jt(i,t,e.columnBy)),r=e.swimlaneBy==null?null:H(jt(i,t,e.swimlaneBy)),o=s.filter((c,h)=>H(jt(c,h,e.columnBy))===n&&(e.swimlaneBy==null||H(jt(c,h,e.swimlaneBy))===r)),a=ye(i,e.recordId);return{column:n,lane:r,index:o.findIndex(c=>Object.is(ye(c,e.recordId),a))}}function xr(s,t){let e=ui(t,s.filter(Boolean).length),i=0;for(let n=0;n<s.length;n+=1)if(s[n]){if(i===e)return n;i+=1}return s.length}function jt(s,t,e){return typeof e=="function"?e(s,t):e==null?null:s?.[e]}function H(s){return s==null?"":String(s)}function ui(s,t){return s==null||!Number.isFinite(Number(s))?t:Math.max(0,Math.min(t,Math.trunc(Number(s))))}function ac(s,t){return s==null||!Array.isArray(s)?!0:s.length?s.some(e=>String(e)==="*"||String(e)===H(t)):!1}function Q_(s,t){if(!s||typeof s!="object")return null;let e=s[t];if(e==null||e==="")return null;let i=Number(e);return Number.isFinite(i)&&i>=0?Math.floor(i):null}var Sr='a, button, input, select, textarea, summary, [contenteditable="true"]',X_=4,J_=350,Z_=120,bs=56,ys=18,tm=Object.freeze({fields:"Fields",search:"Search board",searchPlaceholder:"Search cards",clearSearch:"Clear search",searchSummary:"%count% of %total% cards match.",undo:"Undo",redo:"Redo",add:"Add card",addTo:"Add card to %target%",move:"Move %name%",moveMultiple:"Move %count% selected cards",collapseColumn:"Collapse column %label%",expandColumn:"Expand column %label%",collapseLane:"Collapse swim lane %label%",expandLane:"Expand swim lane %label%",count:"%count% records",countFiltered:"%count% of %total% records",countLimit:"%count% records, work-in-progress limit %limit%",countLimitInLane:"%count% records in this lane, %total% of work-in-progress limit %limit% in the column",empty:"No records",columnEmpty:"",selected:"Selected",notSelected:"Not selected",noMatches:"No cards match the current search.",record:"record",grabbed:"Grabbed %name%. Use left and right for columns, up and down for position, and Alt plus up or down for swim lanes.",grabbedMultiple:"Grabbed %count% cards. Use left and right for columns, up and down for position, and Alt plus up or down for swim lanes.",target:"Target %target%, position %position% of %total%.",moved:"Moved %name% to %target%.%wip%",movedMultiple:"Moved %count% cards to %target%.%wip%",moveRequested:"Move requested for %name% to %target%.%wip%",moveCanceled:"Move canceled for %name%.",moveCanceledPlain:"Move canceled.",limitReached:" Work-in-progress limit %limit% reached.",limitExceeded:" Work-in-progress limit %limit% exceeded.",rejectAccept:"Move rejected: %target% does not accept %name%.",rejectTransition:"Move rejected: %target% does not accept cards from %origin%.",rejectWip:"Move rejected: %target% is at its work-in-progress limit of %limit%.",rejectDestination:"Move rejected: the destination is not available.",rejectGrouping:"Move rejected: callback grouping requires external move mode.",undone:"Move undone.",redone:"Move redone.",nothingToUndo:"Nothing to undo.",nothingToRedo:"Nothing to redo.",menuMoveTo:"Move to %target%",menuMoveToLane:"Move to lane %target%",dragPreview:"%count% cards"}),kr=class extends mt{static cssName="kanban-view";static defaults={...mt.defaults,columnBy:"status",columns:null,swimlaneBy:null,swimlanes:null,titleField:null,subtitleField:null,preview:null,previewAlt:null,link:null,actions:[],moveMode:"local",dragFrom:"card",multiMove:!0,autoScroll:!0,wipPolicy:"warn",rules:[],search:"",searchFields:null,filter:null,searchControl:!1,history:!0,historyLimit:50,historyControls:!1,columnHeight:null,allowAdd:!1,contextMenu:!1,renderCard:null,renderColumnHeader:null,renderSwimlaneHeader:null,renderColumnEmpty:null,renderDragPreview:null,labels:{},columnOrder:[],swimlaneOrder:[],collapsedColumns:[],collapsedSwimlanes:[],showCounts:!0,showEmptyColumns:!0,variant:"outlined",label:"Kanban board"};constructor(t=null,e={}){super(t,e)}render(){let t=!!this.el,e=this.el??l("div"),i=this._kanbanOptions();this._kanbanSnapshot=t?A(e):null,this._kanbanDestroyed=!1;try{return this._initRecordView(e),this._kanbanColumns=i.columns===null?null:ws(i.columns,"column"),this._kanbanSwimlanes=i.swimlanes===null?null:ws(i.swimlanes,"swimlane"),this._kanbanColumnOrder=kt(i.columnOrder),this._kanbanSwimlaneOrder=kt(i.swimlaneOrder),this._collapsedColumns=new Set(kt(i.collapsedColumns)),this._collapsedSwimlanes=new Set(kt(i.collapsedSwimlanes)),this._kanbanRules=mr(i.rules),this._kanbanSearch=i.search==null?"":String(i.search),this._kanbanFilter=typeof i.filter=="function"?i.filter:null,this._kanbanHistory=wr(i.historyLimit),this._keyboardMove=null,this._dragIds=[],this._dragDestination=null,this._pointerStart=null,this._pointerHold=0,this._dragFrame=0,this._dragPreview=null,this._dragPointer=null,this._dragCaptured=!1,this._searchTimer=0,this._dragPoint={x:0,y:0},this._suppressClick=!1,this._announcementToken=0,this._cardMeta=new WeakMap,this._sectionMeta=new WeakMap,this._cardsById=new Map,this._visibleIds=new Set,this._kanbanMenu=null,this._searchInput=null,this._undoButton=null,this._redoButton=null,this._toolbar=l("div",{class:"zx-record-view__toolbar zx-kanban-view__toolbar"}),i.fieldControls&&this._toolbar.append(this._createViewFieldControls(this._text("fields"))),i.searchControl&&this._toolbar.append(this._createSearchControl()),i.historyControls&&this._toolbar.append(this._createHistoryControls()),this._board=l("div",{class:"zx-kanban-view__board",role:"region",ariaLabel:i.label}),this._live=l("div",{class:"zx-kanban-view__live",role:"status",ariaLive:"polite",ariaAtomic:"true"}),e.replaceChildren(this._toolbar,this._board,this._live),i.columnHeight&&(e.style.setProperty("--zx-kanban-column-height",String(i.columnHeight)),e.dataset.columnScroll="true"),this.listen(this._board,"click",n=>this._handleBoardClick(n)),this.listen(this._board,"dblclick",n=>this._handleBoardDoubleClick(n)),this.listen(this._board,"keydown",n=>this._handleBoardKeydown(n)),this.listen(this._board,"error",n=>this._handlePreviewError(n),{capture:!0}),this.listen(this._board,"pointerdown",n=>this._handlePointerDown(n)),this.listen(this._board,"pointermove",n=>this._handlePointerMove(n)),this.listen(this._board,"pointerup",n=>this._handlePointerUp(n)),this.listen(this._board,"pointercancel",()=>this._clearDrag()),this.listen(this._board,"dragstart",n=>n.preventDefault()),this._refreshView("init"),i.contextMenu&&this._createContextMenu(),e}catch(n){throw this._kanbanSnapshot&&k(e,this._kanbanSnapshot),n}}getColumns(){return this._resolvedColumns().map(t=>({...t}))}setColumns(t){this._kanbanColumns=t===null?null:ws(t,"column");let e=this._rawColumns();if(this._kanbanColumnOrder=we(e,this._kanbanColumnOrder,this._kanbanColumns===null),this._kanbanColumns!==null){let i=new Set(e.map(n=>n.id));this._collapsedColumns=new Set([...this._collapsedColumns].filter(n=>i.has(n)))}return this._refreshView("columns"),this._emitKanbanState("columns"),this}getSwimlanes(){return this._resolvedSwimlanes().map(t=>({...t}))}setSwimlanes(t){this._kanbanSwimlanes=t===null?null:ws(t,"swimlane");let e=this._rawSwimlanes(),i=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;if(this._kanbanSwimlaneOrder=we(e,this._kanbanSwimlaneOrder,i),!i){let n=new Set(e.map(r=>r.id));this._collapsedSwimlanes=new Set([...this._collapsedSwimlanes].filter(r=>n.has(r)))}return this._refreshView("swimlanes"),this._emitKanbanState("swimlanes"),this}getColumnOrder(){return this._resolvedColumns().map(t=>t.id)}setColumnOrder(t,e={}){let i=this._rawColumns(),n=this.getColumnOrder(),r=Ar(i,t);return pc(r,n)?this:(this._kanbanColumnOrder=fc(this._kanbanColumnOrder,i,r,this._kanbanColumns===null),this._refreshView("columnorder"),e.silent||this._emitKanbanState("columnorder"),this)}moveColumn(t,e,i="before"){return this.setColumnOrder(uc(this.getColumnOrder(),t,e,i))}getSwimlaneOrder(){return this._resolvedSwimlanes().map(t=>t.id)}setSwimlaneOrder(t,e={}){let i=this._rawSwimlanes(),n=this.getSwimlaneOrder(),r=Ar(i,t);if(pc(r,n))return this;let o=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;return this._kanbanSwimlaneOrder=fc(this._kanbanSwimlaneOrder,i,r,o),this._refreshView("swimlaneorder"),e.silent||this._emitKanbanState("swimlaneorder"),this}moveSwimlane(t,e,i="before"){return this.setSwimlaneOrder(uc(this.getSwimlaneOrder(),t,e,i))}getCollapsedColumns(){return this.getColumnOrder().filter(t=>this._collapsedColumns.has(t))}setColumnCollapsed(t,e=!0,i={}){let n=String(t);if(!this.getColumnOrder().includes(n))throw new RangeError(`Unknown Kanban column: ${n}`);return(e?!this._collapsedColumns.has(n):this._collapsedColumns.has(n))?(e?this._collapsedColumns.add(n):this._collapsedColumns.delete(n),this._refreshView("columncollapse"),i.silent||this._emitKanbanState("columncollapse"),this):this}toggleColumn(t){return this.setColumnCollapsed(t,!this._collapsedColumns.has(String(t)))}getCollapsedSwimlanes(){return this.getSwimlaneOrder().filter(t=>this._collapsedSwimlanes.has(t))}setSwimlaneCollapsed(t,e=!0,i={}){let n=String(t);if(!this.getSwimlaneOrder().includes(n))throw new RangeError(`Unknown Kanban lane: ${n}`);return(e?!this._collapsedSwimlanes.has(n):this._collapsedSwimlanes.has(n))?(e?this._collapsedSwimlanes.add(n):this._collapsedSwimlanes.delete(n),this._refreshView("swimlanecollapse"),i.silent||this._emitKanbanState("swimlanecollapse"),this):this}toggleSwimlane(t){return this.setSwimlaneCollapsed(t,!this._collapsedSwimlanes.has(String(t)))}moveRecord(t,e){return this.moveRecords([t],e)}moveRecords(t,e){let i=this._kanbanOptions();if(!Array.isArray(t)||!e||typeof e!="object")return this;let n=this._orderedIds(t);if(!n.length)return this;let r=n.map(E=>this.getRecord(E)),o=n.map(E=>this._recordLocation(E)),a=o[0],c=this._resolvedColumns(),h=this._resolvedSwimlanes(),d=e.column==null?a.column:String(e.column),u=i.swimlaneBy==null?null:e.lane===void 0?a.lane:H(e.lane),p=c.find(E=>E.id===d),f=i.swimlaneBy==null?null:h.find(E=>E.id===u)??null;if(!p||i.swimlaneBy!=null&&!f)return this._rejectMove("destination",{ids:n,records:r,from:a,to:null,column:null,swimlane:null}),this;let _=new Set(n),m=this._recordsIn(d,u).filter(E=>!_.has(this._viewRecordId(E.record))).length,w=ui(e.index,m),y={column:d,lane:u,index:w};if(n.length===1&&sm(a,y))return this;let v={id:n[0],from:{...a},to:{...y},column:{...p},swimlane:f?{...f}:null},S=this._evaluateMove(r,o,p,f,y,v,_);if(!S.allowed)return this._rejectMove(S.reason,{ids:n,records:r,from:a,to:y,column:p,swimlane:f,evaluation:S}),this;let z=[];for(let E=0;E<n.length;E+=1){let Q=r[E],bt=i.moveMode==="local"?this._localMovedRecord(Q,o[E],y,p,f):Q;if(!bt)return this._rejectMove("grouping",{ids:n,records:r,from:a,to:y,column:p,swimlane:f}),this;z.push({id:n[E],record:bt})}let T=vr(this._viewData,z,{recordId:i.recordId,columnBy:(E,Q)=>this._readAxis(i.columnBy,E,Q),swimlaneBy:i.swimlaneBy==null?null:(E,Q)=>this._readAxis(i.swimlaneBy,E,Q),destination:y});if(!T)return this._rejectMove("destination",{ids:n,records:r,from:a,to:y,column:p,swimlane:f}),this;let I=this._wipAnnouncement(S);return this.emit("recordmove",{record:r[0],id:n[0],records:[...r],ids:[...n],moves:T.moves.map(E=>({id:E.id,from:{...E.from}})),from:{...a},to:{...T.to},column:{...p},swimlane:f?{...f}:null,limitExceeded:S.limitExceeded},{honorDomCancellation:!0}).defaultPrevented?(this._announce(this._text("moveCanceled",{name:this._movingName(r)})),this):i.moveMode==="external"?(this._announce(this._text("moveRequested",{name:this._movingName(r),target:this._targetName(T.to),wip:I})),this):(this._commitLocalRecords(T.records),this._announce(n.length>1?this._text("movedMultiple",{count:n.length,target:this._targetName(T.to),wip:I}):this._text("moved",{name:this._recordName(z[0].record,T.to.index),target:this._targetName(T.to),wip:I})),queueMicrotask(()=>this._moveHandle(n[0])?.focus()),this)}canUndo(){return this._kanbanOptions().history!==!1&&this._kanbanHistory.canUndo()}canRedo(){return this._kanbanOptions().history!==!1&&this._kanbanHistory.canRedo()}undo(){return this._travelHistory("undo")}redo(){return this._travelHistory("redo")}clearHistory(){return this._kanbanHistory.clear(),this._syncHistoryControls(),this._emitHistory(),this}getSearch(){return this._kanbanSearch}setSearch(t,e={}){let i=t==null?"":String(t);return i===this._kanbanSearch?this:(this._kanbanSearch=i,this._searchInput&&this._searchInput.value!==i&&(this._searchInput.value=i),this._refreshView("search"),e.silent||this.emit("searchchange",{search:i}),this)}setFilter(t){if(t!=null&&typeof t!="function")throw new TypeError("Kanban filter must be a function or null");return this._kanbanFilter=t??null,this._refreshView("filter"),this}getVisibleRecords(){return this._viewData.filter(t=>this._visibleIds.has(this._viewRecordId(t)))}setData(t){return this._resetHistory(),super.setData(t)}addData(t){return this._resetHistory(),super.addData(t)}updateRecord(t,e){return this._resetHistory(),super.updateRecord(t,e)}removeRecord(t){return this._resetHistory(),super.removeRecord(t)}getViewState(){this.getColumnOrder(),this.getSwimlaneOrder();let t=this._kanbanColumns===null,e=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;return{...super.getViewState(),columnOrder:t?[...this._kanbanColumnOrder]:this.getColumnOrder(),swimlaneOrder:e?[...this._kanbanSwimlaneOrder]:this.getSwimlaneOrder(),collapsedColumns:t?[...this._collapsedColumns]:this.getCollapsedColumns(),collapsedSwimlanes:e?[...this._collapsedSwimlanes]:this.getCollapsedSwimlanes()}}setViewState(t,e={}){let i=t&&typeof t=="object"?t:{};super.setViewState(i,{silent:!0});let n=this._rawColumns(),r=this._rawSwimlanes(),o=this._kanbanColumns===null,a=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;this._kanbanColumnOrder=we(n,Array.isArray(i.columnOrder)?i.columnOrder:this._kanbanColumnOrder,o),this._kanbanSwimlaneOrder=we(r,Array.isArray(i.swimlaneOrder)?i.swimlaneOrder:this._kanbanSwimlaneOrder,a);let c=new Set(n.map(d=>d.id)),h=new Set(r.map(d=>d.id));if(Array.isArray(i.collapsedColumns)){let d=kt(i.collapsedColumns);this._collapsedColumns=new Set(o?d:d.filter(u=>c.has(u)))}if(Array.isArray(i.collapsedSwimlanes)){let d=kt(i.collapsedSwimlanes);this._collapsedSwimlanes=new Set(a?d:d.filter(u=>h.has(u)))}return this._refreshView("state"),e.silent||this._emitKanbanState("restore"),this}destroy(){if(this._kanbanDestroyed)return;this._kanbanDestroyed=!0,this._clearDrag(),clearTimeout(this._pointerHold),clearTimeout(this._searchTimer),this._kanbanMenu?.destroy(),this._kanbanMenu=null;let t=this.el,e=this._kanbanSnapshot;super.destroy(),e&&t&&k(t,e)}_refreshView(t){if(!this._board)return;if(t==="selection"){this._syncCardSelection();return}if(t==="loading")return;let e=this._kanbanOptions(),i=document.activeElement,n=this._metaForTarget(document.activeElement),r=!!document.activeElement?.classList?.contains("zx-kanban-view__move-handle"),o=i instanceof Element?i.closest("[data-kanban-collapse]"):null,a=o?.closest(".zx-kanban-view__column"),c=o&&this._board.contains(o)?{axis:o.dataset.kanbanCollapse,id:String(o.dataset.kanbanId),lane:a?this._sectionMeta.get(a)?.lane??null:null}:null,h=this._resolvedColumns(),d=this._resolvedSwimlanes();this._cardMeta=new WeakMap,this._sectionMeta=new WeakMap,this._cardsById=new Map,this._resolveVisibility();let u=[];e.swimlaneBy==null?u.push(this._renderColumns(h,null,!1)):d.forEach(p=>u.push(this._renderLane(p,h))),this._viewData.length?this._visibleIds.size||u.push(this._emptyContent(this._text("noMatches"))):u.push(this._emptyContent(this._text("empty"))),this._board.replaceChildren(...u),this._keyboardMove&&(this._keyboardMove.ids=this._keyboardMove.ids.filter(p=>this.getRecord(p)),this._keyboardMove.ids.length||(this._keyboardMove=null)),this._syncKeyboardTarget(),(c||n)&&queueMicrotask(()=>{if(c){this._collapseControl(c.axis,c.id,c.lane)?.focus();return}if(!n)return;if(n.lane!=null&&this._collapsedSwimlanes.has(n.lane)){this._collapseControl("swimlane",n.lane)?.focus();return}if(this._collapsedColumns.has(n.column)){this._collapseControl("column",n.column,n.lane)?.focus();return}let p=this._cardsById.get(n.id),f=r?p?.querySelector(".zx-kanban-view__move-handle"):p;f?.isConnected&&f.focus()})}_renderLane(t,e){let i=this._kanbanOptions(),n=this._collapsedSwimlanes.has(t.id),r=x("zx-kanban-lane"),o=x("zx-kanban-lane-body"),a=this._viewData.filter((w,y)=>H(this._readAxis(i.swimlaneBy,w,y))===t.id),c=a.length,h=a.filter(w=>this._visibleIds.has(this._viewRecordId(w))).length,d=l("button",{class:"zx-kanban-view__collapse",type:"button",ariaExpanded:String(!n),ariaControls:o,ariaLabel:this._text(n?"expandLane":"collapseLane",{label:t.label}),dataset:{kanbanCollapse:"swimlane",kanbanId:t.id}},g(n?"chevron-right":"chevron-down",{size:13})),u=t.limit??null,p=cc(c,u),f=this._renderHook("renderSwimlaneHeader",{swimlane:{...t},count:h,total:c,columnTotal:c,limit:u,wip:p,collapsed:n}),_=l("h2",{class:"zx-kanban-view__lane-heading",id:r},d,f??[l("span",{},t.label),i.showCounts||u!=null?this._countIndicator(h,c,u):null]),m=this._renderColumns(e,t,!0);return m.id=o,m.hidden=n,l("section",{class:"zx-kanban-view__lane",ariaLabelledby:r,dataset:{collapsed:String(n),wip:p}},_,m)}_renderColumns(t,e,i){let n=this._kanbanOptions(),r=l("div",{class:"zx-kanban-view__columns"});for(let o of t){let a=this._recordsIn(o.id,e?.id??null);!n.showEmptyColumns&&a.length===0||r.append(this._renderColumn(o,e,a,i))}return r}_renderColumn(t,e,i,n){let r=this._kanbanOptions(),o=this._collapsedColumns.has(t.id),a=x("zx-kanban-column"),c=x("zx-kanban-column-list"),d=this._viewData.filter((I,et)=>H(this._readAxis(r.columnBy,I,et))===t.id).length,u=i.filter(I=>this._visibleIds.has(this._viewRecordId(I.record))),p=e?im(t,e.id):null,f=p??t.limit??null,_=cc(p==null?d:i.length,f),m=l("button",{class:"zx-kanban-view__collapse",type:"button",ariaExpanded:String(!o),ariaControls:c,ariaLabel:this._text(o?"expandColumn":"collapseColumn",{label:t.label}),dataset:{kanbanCollapse:"column",kanbanId:t.id}},g(o?"chevron-right":"chevron-down",{size:13})),w=this._renderHook("renderColumnHeader",{column:{...t},swimlane:e?{...e}:null,count:u.length,total:i.length,columnTotal:d,limit:f,wip:_,collapsed:o}),y=r.showCounts||f!=null?this._columnIndicator(u.length,i.length,d,f,n&&p==null):null,v=l(n?"h3":"h2",{class:"zx-kanban-view__column-heading",id:a},m,w??[l("span",{class:"zx-kanban-view__column-label"},t.label),y]),S=l("ul",{class:"zx-kanban-view__cards",id:c,ariaLabel:`${t.label}${e?`, ${e.label}`:""}`});if(u.forEach(I=>S.append(this._renderCard(I.record,I.index,t.id,e?.id??null,n))),!u.length){let I=this._renderHook("renderColumnEmpty",{column:{...t},swimlane:e?{...e}:null,count:0,total:i.length,columnTotal:d,limit:f,wip:_,collapsed:o})??this._placeholderText();I&&S.append(l("li",{class:"zx-kanban-view__column-empty",role:"presentation"},I))}S.hidden=o;let z=this._allowsAdd(t,e)?l("button",{class:"zx-kanban-view__add",type:"button",ariaLabel:this._text("addTo",{target:`${t.label}${e?`, ${e.label}`:""}`}),dataset:{kanbanAdd:t.id,kanbanLane:e?.id??""}},g("plus",{size:13}),l("span",{},this._text("add"))):null;z&&(z.hidden=o);let T=l("section",{class:"zx-kanban-view__column",ariaLabelledby:a,dataset:{column:t.id,collapsed:String(o),wip:_}},v,S,z);return this._sectionMeta.set(T,{column:t.id,lane:e?.id??null,list:S}),T}_renderCard(t,e,i,n,r){let o=this._kanbanOptions(),a=this._viewRecordId(t),c=!!this._keyboardMove?.ids.some(_=>Object.is(_,a)),h=_s(this._kanbanRules,t,{index:e,column:i,lane:n}),d=c&&this._keyboardMove?this._keyboardMove.ids.length:1,u=l("button",{class:"zx-kanban-view__move-handle",type:"button",ariaPressed:String(c),ariaLabel:d>1?this._text("moveMultiple",{count:d}):this._text("move",{name:this._recordName(t,e)})},g("drag",{size:13})),p=fs(t,e,{fields:this.getFields(),visibleFields:this.getVisibleFields(),titleField:o.titleField,subtitleField:o.subtitleField,preview:o.preview??void 0,previewAlt:o.previewAlt,link:o.link??void 0,actions:o.actions,selectable:o.selectable,selected:this._isViewSelected(a),variant:o.variant,headingLevel:r?4:3,controls:[u]});p.tabIndex=0,c&&(p.dataset.grabbed="true"),this._applyCardContent(p,{record:t,id:a,index:e,column:i,lane:n,rules:h,selected:this._isViewSelected(a)}),this._applyCardRules(p,h),this._applyCardDescription(p,a);let f={record:t,id:a,index:e,column:i,lane:n};return this._cardMeta.set(p,f),this._cardsById.set(a,p),p}_applyCardContent(t,e){let i=this._renderHook("renderCard",e);if(!i)return;let n=t.querySelector(".zx-record-card__body"),r=t.querySelector(".zx-record-card__titles");!n||!r||(r.replaceChildren(i),n.querySelector(".zx-record-card__eyebrow")?.remove(),n.querySelector(".zx-record-card__metadata")?.remove(),t.removeAttribute("aria-labelledby"),t.setAttribute("aria-label",this._recordName(e.record,e.index)),t.dataset.customCard="true")}_applyCardRules(t,e){if(!e.length)return;t.dataset.rule=e.map(r=>r.id).join(" "),t.dataset.ruleTone=e[0].tone;let i=e.filter(r=>r.label);if(i.length){let r=l("p",{class:"zx-kanban-view__rules"},i.map(o=>bn({label:o.label,icon:o.icon??void 0,kind:o.tone,size:"sm",variant:"soft"})));t.querySelector(".zx-record-card__body")?.append(r)}let n=e.map(r=>r.description).filter(Boolean).join(". ");n&&(t.dataset.ruleDescription=n)}_applyCardDescription(t,e){let i=[];this.options.selectable&&i.push(this._text(this._isViewSelected(e)?"selected":"notSelected")),t.dataset.ruleDescription&&i.push(t.dataset.ruleDescription),i.length?t.setAttribute("aria-description",i.join(". ")):t.removeAttribute("aria-description")}_emptyContent(t){let i=(typeof this.options.emptyText=="function"?this.options.emptyText():this.options.emptyText)??t;return l("div",{class:"zx-kanban-view__empty",role:"status"},i&&typeof i=="object"&&"nodeType"in i?i:String(i))}_placeholderText(){return this._text("columnEmpty")}_countIndicator(t,e,i){let n=t!==e;return l("span",{class:"zx-kanban-view__count",ariaLabel:i!=null?this._text("countLimit",{count:e,limit:i}):n?this._text("countFiltered",{count:t,total:e}):this._text("count",{count:t})},i!=null?`${e} / ${i}`:n?`${t} / ${e}`:String(t))}_columnIndicator(t,e,i,n,r){let o=t!==e,a=n==null?o?this._text("countFiltered",{count:t,total:e}):this._text("count",{count:t}):r?this._text("countLimitInLane",{count:e,total:i,limit:n}):this._text("countLimit",{count:e,limit:n}),c=n==null?o?`${t} / ${e}`:String(t):r?`${e} \xB7 ${i} / ${n}`:`${e} / ${n}`;return l("span",{class:"zx-kanban-view__count",ariaLabel:a},c)}_rawColumns(){let t=this._kanbanOptions();return this._kanbanColumns===null?lc(this._viewData,(e,i)=>this._readAxis(t.columnBy,e,i)):this._kanbanColumns.map(e=>({...e}))}_resolvedColumns(){let t=this._rawColumns();return this._kanbanColumnOrder=we(t,this._kanbanColumnOrder,this._kanbanColumns===null),dc(t,this._kanbanColumnOrder)}_rawSwimlanes(){let t=this._kanbanOptions();return t.swimlaneBy==null?[]:this._kanbanSwimlanes===null?lc(this._viewData,(e,i)=>this._readAxis(t.swimlaneBy,e,i)):this._kanbanSwimlanes.map(e=>({...e}))}_resolvedSwimlanes(){let t=this._rawSwimlanes(),e=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;return this._kanbanSwimlaneOrder=we(t,this._kanbanSwimlaneOrder,e),dc(t,this._kanbanSwimlaneOrder)}_readAxis(t,e,i){if(typeof t=="function")return t(e,i);if(t==null)return null;let n=this.getFields().find(r=>r.id===t);return n?tt(n,e,i):e?.[t]}_recordsIn(t,e){let i=this._kanbanOptions(),n=[];return this._viewData.forEach((r,o)=>{H(this._readAxis(i.columnBy,r,o))===t&&(i.swimlaneBy!=null&&H(this._readAxis(i.swimlaneBy,r,o))!==e||n.push({record:r,index:o}))}),n}_recordLocation(t){let e=this._kanbanOptions(),i=this._viewData.findIndex(n=>Object.is(this._viewRecordId(n),t));return i<0?null:gs(this._viewData,i,{recordId:e.recordId,columnBy:(n,r)=>this._readAxis(e.columnBy,n,r),swimlaneBy:e.swimlaneBy==null?null:(n,r)=>this._readAxis(e.swimlaneBy,n,r)})}_resolveVisibility(){let t=br(this._kanbanSearch),e=this._kanbanFilter,i=t.length?this._searchSources():null;this._visibleIds=new Set,this._viewData.forEach((n,r)=>{e&&e(n,r)!==!0||i&&!yr(this._searchableText(n,r,i),t)||this._visibleIds.add(this._viewRecordId(n))})}_searchSources(){let t=this._kanbanOptions(),e=Array.isArray(t.searchFields)?t.searchFields.map(String):null,i=this.getFields();if(e)return{fields:i.filter(a=>e.includes(a.id)),readers:[]};let n=this.getVisibleFields(),r=new Set(n.map(a=>a.id)),o=[];for(let a of[t.titleField,t.subtitleField]){if(a==null)continue;if(typeof a=="function"){o.push(a);continue}if(r.has(a))continue;let c=i.find(h=>h.id===a);c?n.push(c):o.push(h=>h?.[a])}return{fields:n,readers:o}}_searchableText(t,e,i){let n=i.fields.map(r=>hc(tt(r,t,e)));for(let r of i.readers)n.push(hc(r(t,e)));return n.filter(Boolean).join(" ")}_absoluteIndex(t,e,i,n){let r=this._recordsIn(t,e).filter(o=>!n.has(this._viewRecordId(o.record)));return xr(r.map(o=>this._visibleIds.has(this._viewRecordId(o.record))),i)}_localMovedRecord(t,e,i,n,r){let o=this._kanbanOptions(),a={...t};if(e.column!==i.column){if(typeof o.columnBy!="string")return null;a[o.columnBy]=Object.prototype.hasOwnProperty.call(n,"value")?n.value:n.id}if(e.lane!==i.lane){if(typeof o.swimlaneBy!="string"||!r)return null;a[o.swimlaneBy]=Object.prototype.hasOwnProperty.call(r,"value")?r.value:r.id}let c=this._viewData.indexOf(t);return H(this._readAxis(o.columnBy,a,c))!==i.column||o.swimlaneBy!=null&&H(this._readAxis(o.swimlaneBy,a,c))!==i.lane?null:a}_evaluateMove(t,e,i,n,r,o,a){let c=this._kanbanOptions();for(let f of e){let _=ms(i,n,f);if(_)return{allowed:!1,reason:_,limit:null,count:0,limitExceeded:!1,limitReached:!1,policy:i.wipPolicy??(c.wipPolicy==="block"?"block":"warn")}}let h=f=>!a.has(this._viewRecordId(f)),d=this._viewData.filter((f,_)=>H(this._readAxis(c.columnBy,f,_))===r.column&&h(f)).length,u=c.swimlaneBy==null?0:this._viewData.filter((f,_)=>H(this._readAxis(c.swimlaneBy,f,_))===r.lane&&h(f)).length,p=this._recordsIn(r.column,r.lane).filter(f=>h(f.record)).length;return gr({records:t,column:i,swimlane:n,context:o,from:e[0],columnCount:d,laneCount:u,cellCount:p,policy:c.wipPolicy==="block"?"block":"warn"})}_rejectMove(t,e){let i=e.to?this._targetName(e.to):"",n=this._movingName(e.records),r=t==="destination"?this._text("rejectDestination"):t==="grouping"?this._text("rejectGrouping"):t==="transition"||t==="lane-transition"?this._text("rejectTransition",{target:i,origin:e.from?this._targetName(e.from):""}):t==="wip"||t==="lane-wip"?this._text("rejectWip",{target:i,limit:e.evaluation?.limit??""}):this._text("rejectAccept",{target:i,name:n});this._announce(r),this.emit("movereject",{reason:t,ids:[...e.ids],records:[...e.records],record:e.records[0]??null,id:e.ids[0],from:e.from?{...e.from}:null,to:e.to?{...e.to}:null,column:e.column?{...e.column}:null,swimlane:e.swimlane?{...e.swimlane}:null,limit:e.evaluation?.limit??null,count:e.evaluation?.count??0,message:r})}_commitLocalRecords(t){let e=this._kanbanOptions();e.history!==!1&&(this._kanbanHistory.push({records:[...this._viewData],selection:this.getSelectionIds()}),this._syncHistoryControls()),this._viewData=t,e.sortMode==="local"&&this.getSort()?this.setSort(null):this._refreshView("move"),this.emit("datachange",{records:this.getData()}),e.history!==!1&&this._emitHistory()}_travelHistory(t){if(this._kanbanOptions().history===!1)return this;let e={records:[...this._viewData],selection:this.getSelectionIds()},i=t==="undo"?this._kanbanHistory.undo(e):this._kanbanHistory.redo(e);return i?(this._viewData=[...i.records],this._refreshView(t),this.setSelection(i.selection),this._syncHistoryControls(),this.emit("datachange",{records:this.getData()}),this._emitHistory(),this._announce(this._text(t==="undo"?"undone":"redone")),this):(this._announce(this._text(t==="undo"?"nothingToUndo":"nothingToRedo")),this)}_resetHistory(){if(!this._kanbanHistory)return;let t=this._kanbanHistory.canUndo()||this._kanbanHistory.canRedo();this._kanbanHistory.clear(),this._syncHistoryControls(),t&&this._emitHistory()}_emitHistory(){this.emit("historychange",{canUndo:this.canUndo(),canRedo:this.canRedo(),depth:this._kanbanHistory.depth()})}_syncHistoryControls(){this._undoButton&&(this._undoButton.disabled=!this.canUndo()),this._redoButton&&(this._redoButton.disabled=!this.canRedo())}_createSearchControl(){let t=l("input",{class:"zx-kanban-view__search-input",type:"search",value:this._kanbanSearch,ariaLabel:this._text("search"),placeholder:this._text("searchPlaceholder")});return this._searchInput=t,this.listen(t,"input",()=>{clearTimeout(this._searchTimer),this._searchTimer=setTimeout(()=>{this._searchTimer=0,this._kanbanDestroyed||this.setSearch(t.value)},Z_)}),this.listen(t,"keydown",e=>{e.key!=="Escape"||!t.value||(e.stopPropagation(),clearTimeout(this._searchTimer),this._searchTimer=0,this.setSearch(""))}),l("div",{class:"zx-kanban-view__search"},g("search",{size:13}),t)}_createHistoryControls(){this._undoButton=l("button",{class:"zx-button zx-button--sm",type:"button",disabled:!0,dataset:{kanbanHistory:"undo"}},this._text("undo")),this._redoButton=l("button",{class:"zx-button zx-button--sm",type:"button",disabled:!0,dataset:{kanbanHistory:"redo"}},this._text("redo"));let t=l("div",{class:"zx-kanban-view__history",role:"group"},this._undoButton,this._redoButton);return this.listen(t,"click",e=>{let i=e.target?.closest?.("[data-kanban-history]");i&&(i.dataset.kanbanHistory==="undo"?this.undo():this.redo())}),t}_createContextMenu(){this._kanbanMenu=new oi(this._board,{selector:".zx-record-card",items:t=>this._menuItems(t),onselect:({detail:t})=>this._handleMenuSelect(t)})}_menuItems(t){let e=t?this._cardMeta.get(t):null;if(!e)return[];let i=this._kanbanOptions(),n=this._movingIds(e.id),r=[];for(let a of this._resolvedColumns())a.id!==e.column&&r.push({label:this._text("menuMoveTo",{target:a.label}),value:{kind:"column",id:a.id,ids:n},disabled:!this._canMove(n,{column:a.id})});if(i.swimlaneBy!=null)for(let a of this._resolvedSwimlanes())a.id!==e.lane&&r.push({label:this._text("menuMoveToLane",{target:a.label}),value:{kind:"lane",id:a.id,ids:n},disabled:!this._canMove(n,{lane:a.id})});let o=typeof i.contextMenu=="function"?i.contextMenu({record:e.record,id:e.id,index:e.index,column:e.column,lane:e.lane,rules:_s(this._kanbanRules,e.record,e),selected:this._isViewSelected(e.id)}):Array.isArray(i.contextMenu)?i.contextMenu:[];return Array.isArray(o)&&o.length&&r.push("-",...o),r}_handleMenuSelect(t){let e=t.value;!e||typeof e!="object"||!e.kind||!Array.isArray(e.ids)||this.moveRecords(e.ids,e.kind==="lane"?{lane:e.id}:{column:e.id})}_canMove(t,e){let i=this._kanbanOptions(),n=this._orderedIds(t);if(!n.length)return!1;let r=n.map(m=>this.getRecord(m)),o=n.map(m=>this._recordLocation(m)),a=o[0],c=e.column==null?a.column:String(e.column),h=i.swimlaneBy==null?null:e.lane===void 0?a.lane:H(e.lane),d=this._resolvedColumns().find(m=>m.id===c),u=i.swimlaneBy==null?null:this._resolvedSwimlanes().find(m=>m.id===h)??null;if(!d||i.swimlaneBy!=null&&!u)return!1;let p=new Set(n),f={column:c,lane:h,index:0},_={id:n[0],from:{...a},to:{...f},column:{...d},swimlane:u?{...u}:null};return this._evaluateMove(r,o,d,u,f,_,p).allowed}_movingIds(t){let e=this._kanbanOptions();if(e.multiMove===!1||e.selectable!=="multi"||!this._isViewSelected(t))return[t];let i=this.getSelectionIds();return i.length>1?i:[t]}_orderedIds(t){let e=new Set(t);return this._viewData.map(i=>this._viewRecordId(i)).filter(i=>e.has(i))}_handleBoardClick(t){if(this._suppressClick){this._suppressClick=!1;return}let e=ve(t),i=e?.closest("[data-kanban-collapse]");if(i){let c=i;c.dataset.kanbanCollapse==="column"?this.toggleColumn(String(c.dataset.kanbanId)):this.toggleSwimlane(String(c.dataset.kanbanId));return}let n=e?.closest("[data-kanban-add]");if(n){let c=n,h=String(c.dataset.kanbanAdd),d=c.dataset.kanbanLane||null;this.emit("recordadd",{column:this._resolvedColumns().find(u=>u.id===h)??null,swimlane:d==null?null:this._resolvedSwimlanes().find(u=>u.id===d)??null,columnId:h,laneId:d,event:t});return}let r=this._metaForTarget(e);if(!r)return;let o=e?.closest("input[data-record-selection]");if(o){this.toggleSelection(r.id,{selected:o.checked,range:t.shiftKey});return}let a=e?.closest("[data-record-action]");if(a){let c=a.dataset.recordAction,h=di(r.record,r.index,this._kanbanOptions().actions).find(u=>u.id===c);if(!h||h.disabled){t.preventDefault();return}typeof h.onclick=="function"&&h.onclick(r.record,r.index,t),this.emit("recordaction",{record:r.record,id:r.id,index:r.index,action:{...h},event:t}).defaultPrevented&&t.preventDefault();return}e?.closest(".zx-kanban-view__move-handle, .zx-record-card__selection, [data-record-select]")||e?.closest(Sr)||mc()||(this.emit("recordclick",{...r,event:t}),this.options.selectable==="single"&&!this._isViewSelected(r.id)&&this.setSelection([r.id]))}_handleBoardDoubleClick(t){let e=ve(t),i=this._metaForTarget(e);!i||e?.closest(Sr)||mc()||this.emit("recorddblclick",{...i,event:t})}_handleBoardKeydown(t){if(this._dragIds.length&&t.key==="Escape"){t.preventDefault(),this._clearDrag(),this._announce(this._text("moveCanceledPlain"));return}let e=ve(t);if(this._handleHistoryKeydown(t,e))return;let i=e?.closest(".zx-kanban-view__move-handle"),n=this._metaForTarget(i);if(i&&n){this._handleMoveKeydown(t,i,n);return}let r=e?.closest(".zx-record-card"),o=r?this._cardMeta.get(r):null;!o||e!==r||(t.key==="Enter"?(t.preventDefault(),this.emit("recordclick",{...o,event:t}),this.options.selectable==="single"&&this.setSelection([o.id])):t.key===" "&&this.options.selectable!==!1&&(t.preventDefault(),this.toggleSelection(o.id)))}_handleHistoryKeydown(t,e){if(this._kanbanOptions().history===!1||!(t.ctrlKey||t.metaKey)||e?.closest('input, textarea, [contenteditable="true"]'))return!1;let i=t.key.toLowerCase();return i==="z"&&!t.shiftKey&&this.canUndo()?(t.preventDefault(),this.undo(),!0):(i==="y"||i==="z"&&t.shiftKey)&&this.canRedo()?(t.preventDefault(),this.redo(),!0):!1}_handleMoveKeydown(t,e,i){if(t.key===" "||t.key==="Enter"){if(t.preventDefault(),this._keyboardMove?.ids.some(a=>Object.is(a,i.id))){let a=this._keyboardMove;this._keyboardMove=null,e.setAttribute("aria-pressed","false");let c=e.closest(".zx-record-card");c&&delete c.dataset.grabbed,this._syncKeyboardTarget(),this._commitInteractionMove(a.ids,a.to)}else{let a=this._recordLocation(i.id);if(!a)return;let c=this._movingIds(i.id),h={...a,index:this._visibleIndex(i.id)};this._keyboardMove={ids:c,from:{...a},to:h},e.setAttribute("aria-pressed","true");let d=e.closest(".zx-record-card");d&&(d.dataset.grabbed="true"),this._syncKeyboardTarget(),this._announce(c.length>1?this._text("grabbedMultiple",{count:c.length}):this._text("grabbed",{name:this._recordName(i.record,i.index)}))}return}if(t.key==="Escape"&&this._keyboardMove){t.preventDefault();let a=this._keyboardMove.ids.map(h=>this.getRecord(h)).filter(Boolean);this._keyboardMove=null,e.setAttribute("aria-pressed","false");let c=e.closest(".zx-record-card");c&&delete c.dataset.grabbed,this._syncKeyboardTarget(),this._announce(a.length?this._text("moveCanceled",{name:this._movingName(a)}):this._text("moveCanceledPlain"));return}if(!this._keyboardMove||!this._keyboardMove.ids.some(a=>Object.is(a,i.id))||!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key))return;t.preventDefault();let n=this._keyboardMove,r=t.altKey||t.ctrlKey||t.metaKey;if((t.key==="ArrowLeft"||t.key==="ArrowRight")&&!r){let a=this.getColumnOrder(),c=a.indexOf(n.to.column),h=a[c+(t.key==="ArrowLeft"?-1:1)];h!=null&&(n.to.column=h)}else if((t.key==="ArrowUp"||t.key==="ArrowDown")&&r&&this._kanbanOptions().swimlaneBy!=null){let a=this.getSwimlaneOrder(),c=a.indexOf(String(n.to.lane)),h=a[c+(t.key==="ArrowUp"?-1:1)];h!=null&&(n.to.lane=h)}else(t.key==="ArrowUp"||t.key==="ArrowDown")&&(n.to.index+=t.key==="ArrowUp"?-1:1);let o=this._visibleCount(n.to.column,n.to.lane,new Set(n.ids));n.to.index=ui(n.to.index,o),this._syncKeyboardTarget(),this._announce(this._text("target",{target:this._targetName(n.to),position:n.to.index+1,total:o+1}))}_handlePreviewError(t){let e=ve(t)?.closest("img[data-record-preview]");if(!e)return;let i=e.closest(".zx-record-card__preview");i&&(i.dataset.failed="true"),e.hidden=!0}_handlePointerDown(t){if(this._suppressClick=!1,t.button!=null&&t.button!==0)return;let e=ve(t),i=e?.closest(".zx-kanban-view__move-handle"),n=this._metaForTarget(i??e);if(!n||!i&&(this._kanbanOptions().dragFrom!=="card"||e?.closest(Sr)||e?.closest(".zx-record-card__selection")))return;let r=this._movingIds(n.id);this._pointerStart={x:t.clientX,y:t.clientY,id:t.pointerId,ids:r,touch:t.pointerType==="touch"},this._dragPoint={x:t.clientX,y:t.clientY},clearTimeout(this._pointerHold),!(t.pointerType!=="touch"||i)&&(this._pointerHold=setTimeout(()=>this._beginDrag(this._dragPoint.x,this._dragPoint.y),J_))}_handlePointerMove(t){let e=this._pointerStart;if(!this._dragIds.length){if(!e||t.pointerId!==e.id)return;let i=Math.hypot(t.clientX-e.x,t.clientY-e.y);if(this._dragPoint={x:t.clientX,y:t.clientY},i<=X_)return;if(e.touch&&this._pointerHold){clearTimeout(this._pointerHold),this._pointerHold=0,this._pointerStart=null;return}if(this._beginDrag(t.clientX,t.clientY),!this._dragIds.length)return}this._dragPointer!=null&&t.pointerId!==this._dragPointer||(t.preventDefault(),this._dragPoint={x:t.clientX,y:t.clientY},this._positionDragPreview(),this._updateDropTarget(t.clientX,t.clientY))}_handlePointerUp(t){if(this._dragIds.length&&this._dragPointer!=null&&t.pointerId!==this._dragPointer||(clearTimeout(this._pointerHold),this._pointerHold=0,this._pointerStart=null,!this._dragIds.length))return;t.preventDefault();let e=[...this._dragIds],i=this._dragDestination?{...this._dragDestination}:null;this._clearDrag(),this._suppressClick=!0,i&&this._commitInteractionMove(e,i)}_beginDrag(t,e){let i=this._pointerStart;if(!(!i||this._dragIds.length)&&(this._pointerHold=0,this._dragIds=i.ids.filter(n=>this.getRecord(n)),!!this._dragIds.length)){this._dragPoint={x:t,y:e},this._board.dataset.dragging="true";for(let n of this._dragIds){let r=this._cardsById.get(n);r&&(r.dataset.dragging="true")}this._dragPointer=i.id;try{this._board.setPointerCapture(i.id),this._dragCaptured=!0}catch{}globalThis.getSelection?.()?.removeAllRanges(),this._dragPreview=this._createDragPreview(),this.el.append(this._dragPreview),this._positionDragPreview(),this._updateDropTarget(t,e),this._kanbanOptions().autoScroll!==!1&&this._scheduleAutoScroll()}}_createDragPreview(){let t=this._dragIds.map(n=>this.getRecord(n)),i=this._renderHook("renderDragPreview",{records:t,ids:[...this._dragIds],count:this._dragIds.length})??(this._dragIds.length>1?this._text("dragPreview",{count:this._dragIds.length}):this._movingName(t));return l("div",{class:"zx-kanban-view__drag-preview",ariaHidden:"true",dataset:{count:String(this._dragIds.length)}},i)}_positionDragPreview(){this._dragPreview&&(this._dragPreview.style.transform=`translate3d(${Math.round(this._dragPoint.x)}px, ${Math.round(this._dragPoint.y)}px, 0)`)}_updateDropTarget(t,e){let n=document.elementFromPoint(t,e)?.closest(".zx-kanban-view__column"),r=n&&this._board.contains(n)?this._sectionMeta.get(n):null;if(this._clearDropMarkers(),!r||this._collapsedColumns.has(r.column)){this._dragDestination=null;return}let o=this._draggableCards(r.list),a=o.findIndex(h=>{let d=h.getBoundingClientRect();return e<d.top+d.height/2}),c=a<0?o.length:a;o[c]?o[c].dataset.drop="before":o.length?o[o.length-1].dataset.drop="after":r.list.dataset.drop="append",this._dragDestination={column:r.column,lane:r.lane,index:c}}_scheduleAutoScroll(){this._dragFrame||(this._dragFrame=requestAnimationFrame(()=>{this._dragFrame=0,this._dragIds.length&&(this._autoScroll(),this._scheduleAutoScroll())}))}_autoScroll(){let{x:t,y:e}=this._dragPoint,i=this._board.getBoundingClientRect();t<i.left+bs?this._board.scrollLeft-=ys:t>i.right-bs&&(this._board.scrollLeft+=ys);let n=document.elementFromPoint(t,e)?.closest(".zx-kanban-view__cards");if(!n||!this._board.contains(n)||n.scrollHeight<=n.clientHeight)return;let r=n.getBoundingClientRect();e<r.top+bs?n.scrollTop-=ys:e>r.bottom-bs&&(n.scrollTop+=ys)}_commitInteractionMove(t,e){let i=new Set(t);this.moveRecords(t,{column:e.column,lane:e.lane,index:this._absoluteIndex(e.column,e.lane,e.index,i)})}_clearDrag(){if(this._dragFrame&&cancelAnimationFrame(this._dragFrame),this._dragFrame=0,clearTimeout(this._pointerHold),this._pointerHold=0,this._pointerStart=null,this._dragPreview?.remove(),this._dragPreview=null,this._dragIds=[],this._dragDestination=null,this._board){if(this._dragCaptured&&this._dragPointer!=null)try{this._board.releasePointerCapture(this._dragPointer)}catch{}this._clearDropMarkers(),delete this._board.dataset.dragging;for(let t of this._board.querySelectorAll("[data-dragging]"))delete t.dataset.dragging}this._dragPointer=null,this._dragCaptured=!1}_clearDropMarkers(){for(let t of this._board.querySelectorAll("[data-drop]"))delete t.dataset.drop}_draggableCards(t){let e=new Set(this._dragIds.length?this._dragIds:this._keyboardMove?.ids??[]);return[...t.querySelectorAll(":scope > .zx-record-card")].filter(i=>!_c(e,this._cardMeta.get(i)?.id))}_visibleCount(t,e,i){return this._recordsIn(t,e).filter(n=>{let r=this._viewRecordId(n.record);return!_c(i,r)&&this._visibleIds.has(r)}).length}_visibleIndex(t){let e=this._recordLocation(t);if(!e)return 0;let i=this._recordsIn(e.column,e.lane).filter(r=>this._visibleIds.has(this._viewRecordId(r.record))),n=i.findIndex(r=>Object.is(this._viewRecordId(r.record),t));return n<0?i.length:n}_syncKeyboardTarget(){for(let o of this._board.querySelectorAll("[data-keyboard-target]"))delete o.dataset.keyboardTarget;let t=this._keyboardMove;if(!t)return;let e=[...this._board.querySelectorAll(".zx-kanban-view__column")].find(o=>{let a=this._sectionMeta.get(o);return a?.column===t.to.column&&a?.lane===t.to.lane}),i=e?this._sectionMeta.get(e):null;if(!i)return;let r=this._draggableCards(i.list)[t.to.index];r?r.dataset.keyboardTarget="before":i.list.dataset.keyboardTarget="append"}_syncCardSelection(){for(let[t,e]of this._cardsById){let i=this._isViewSelected(t);e.dataset.selected=String(i),this._applyCardDescription(e,t);let n=e.querySelector("[data-record-selection]");n&&(n.checked=i)}}_metaForTarget(t){let e=ve({target:t})?.closest(".zx-record-card");return e?this._cardMeta.get(e)??null:null}_moveHandle(t){return this._cardsById.get(t)?.querySelector(".zx-kanban-view__move-handle")??null}_collapseControl(t,e,i=null){return[...this._board.querySelectorAll("[data-kanban-collapse]")].find(n=>{let r=n;if(r.dataset.kanbanCollapse!==t||r.dataset.kanbanId!==e)return!1;if(t!=="column")return!0;let o=r.closest(".zx-kanban-view__column");return o?this._sectionMeta.get(o)?.lane===i:!1})??null}_renderHook(t,e){let i=this._kanbanOptions()[t];if(typeof i!="function")return null;let n=i(e);return n&&typeof n=="object"&&"nodeType"in n?n:null}_allowsAdd(t,e){let i=this._kanbanOptions().allowAdd;return typeof i=="function"?i(t,e)===!0:i===!0}_recordName(t,e){let i=this._kanbanOptions().titleField,n=typeof i=="function"?i(t,e):typeof i=="string"?this._readAxis(i,t,e):this._viewRecordId(t);return n&&typeof n=="object"&&"nodeType"in n?n.textContent?.trim()||this._text("record"):String(n??this._text("record"))}_movingName(t){return t.length?t.length===1?this._recordName(t[0],this._viewData.indexOf(t[0])):this._text("dragPreview",{count:t.length}):this._text("record")}_targetName(t){let e=this._resolvedColumns().find(n=>n.id===t.column),i=t.lane==null?null:this._resolvedSwimlanes().find(n=>n.id===t.lane);return`${e?.label??t.column}${i?`, ${i.label}`:""}`}_wipAnnouncement(t){return t.limit==null?"":t.limitExceeded?this._text("limitExceeded",{limit:t.limit}):t.limitReached?this._text("limitReached",{limit:t.limit}):""}_text(t,e){let i=this._kanbanOptions().labels,n=i&&typeof i=="object"&&t in i?i[t]:tm[t];return V(n==null?String(t):String(n),e)}_announce(t){let e=++this._announcementToken;this._live.textContent="",queueMicrotask(()=>{e===this._announcementToken&&this._live?.isConnected&&(this._live.textContent=t)})}_emitKanbanState(t){this.emit("statechange",{state:this.getViewState(),reason:t})}_kanbanOptions(){return this.options}};function ws(s,t="column"){if(!Array.isArray(s))throw new TypeError(`Kanban ${t}s must be an array or null`);let e=new Set;return s.map((i,n)=>{if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`Kanban ${t} at index ${n} must be an object`);let r=i,o=String(r.id??"").trim();if(!o&&r.id!=="")throw new TypeError(`Kanban ${t} at index ${n} requires an id`);if(e.has(o))throw new TypeError(`Duplicate Kanban ${t}: ${o}`);if(r.accept!=null&&typeof r.accept!="function")throw new TypeError(`Kanban ${t} ${o} accept must be a function`);if(r.from!=null&&!Array.isArray(r.from))throw new TypeError(`Kanban ${t} ${o} from must be an array or null`);e.add(o);let a={...r,id:o,label:String(r.label??gc(r.id)),limit:bc(r.limit),from:Array.isArray(r.from)?r.from.map(String):null,...Object.prototype.hasOwnProperty.call(r,"value")?{}:{value:r.id}};if(t==="column"){let c=em(r.laneLimits);c&&(a.laneLimits=c),(r.wipPolicy==="block"||r.wipPolicy==="warn")&&(a.wipPolicy=r.wipPolicy)}else delete a.laneLimits,delete a.wipPolicy;return a})}function lc(s,t){let e=[],i=new Set;return s.forEach((n,r)=>{let o=jt(n,r,t),a=H(o);i.has(a)||(i.add(a),e.push({id:a,label:gc(o),value:o,limit:null}))}),e}function Ar(s,t){let e=s.map(r=>r.id),i=new Set(e),n=kt(t).filter(r=>i.has(r));return[...new Set(n),...e.filter(r=>!n.includes(r))]}function we(s,t,e=!1){if(!e)return Ar(s,t);let i=kt(t),n=s.map(r=>r.id);return[...i,...n.filter(r=>!i.includes(r))]}function gc(s){return s==null||String(s).trim()===""?"Unassigned":String(s)}function bc(s){if(s==null||s==="")return null;let t=Number(s);if(!Number.isFinite(t)||t<0)throw new TypeError("Kanban column limit must be a non-negative number");return Math.floor(t)}function em(s){if(s==null)return;if(typeof s!="object"||Array.isArray(s))throw new TypeError("Kanban column laneLimits must be an object");let t={};for(let[e,i]of Object.entries(s)){let n=bc(i);n!=null&&(t[e]=n)}return t}function im(s,t){let e=s.laneLimits;if(!e||typeof e!="object")return null;let i=e[t];return typeof i=="number"&&Number.isFinite(i)?i:null}function cc(s,t){return t==null?"none":s>t?"exceeded":s===t?"limit":"within"}function kt(s){return Array.isArray(s)?[...new Set(s.map(String))]:[]}function hc(s){return s==null?"":typeof s=="object"?"nodeType"in s?String(s.textContent??""):"":String(s)}function dc(s,t){let e=new Map(s.map(i=>[i.id,i]));return t.map(i=>e.get(i)).filter(Boolean)}function uc(s,t,e,i){let n=[...s],r=n.indexOf(String(t));if(r<0||!n.includes(String(e))||String(t)===String(e))return n;n.splice(r,1);let o=n.indexOf(String(e));return n.splice(o+(i==="after"?1:0),0,String(t)),n}function fc(s,t,e,i){if(!i)return[...e];let n=new Set(t.map(c=>c.id)),r=[...e],o=0,a=kt(s).flatMap(c=>n.has(c)?o<r.length?[r[o++]]:[]:[c]);return a.push(...r.slice(o)),kt(a)}function sm(s,t){return s.column===t.column&&s.lane===t.lane&&s.index===t.index}function pc(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function _c(s,t){for(let e of s)if(Object.is(e,t))return!0;return!1}function ve(s){let t=s.target;return t?t instanceof Element?t:t.parentElement:null}function mc(){let s=globalThis.getSelection?.();return!!(s&&!s.isCollapsed&&String(s).trim())}var zr=class s extends Dt{static cssName="table";constructor(t=null,e={}){super(t,{editTrigger:"single",...e})}static BillingItems(t,e={}){let i=new s(t,nm(e));return i.el.dataset.preset="billing-items",i}};function nm(s={}){let{fields:t={},units:e=[],currencies:i=[],currency:n="EUR",locale:r,decimals:o=2,columnOverrides:a={},lineTotal:c=null,columns:h,oneditcommit:d,rowClass:u,...p}=s,f={...vc,...t},_=typeof c=="function"?c:w=>{let y=wc(w?.[f.quantity]),v=wc(w?.[f.unitPrice]);return y!==null&&v!==null?y*v:null},m=Array.isArray(h)?h.map(w=>({...w})):xc(f,{units:e,currencies:i,currency:n,locale:r,decimals:o,columnOverrides:a});return{rowId:f.id,editMode:"cell",editTrigger:"single",rowReorder:!0,columnVisibility:!0,hierarchy:{parentId:f.parent,column:f.item,expanded:!0},responsive:"sm",...p,columns:m,rowClass(w){let y=vs(w,f)?"":"zx-grid-billing__summary",v=typeof u=="function"?u(w):"";return[y,v].filter(Boolean).join(" ")},oneditcommit(w){let{row:y,changes:v}=w.detail;if(vs(y,f)){let S={...y,...v},z=_(S,v);z!=null&&Number.isFinite(Number(z))&&(v[f.total]=Number(z))}d?.(w)}}}var vc=Object.freeze({id:"id",parent:"parent",item:"item",kind:"kind",quantity:"quantity",unit:"unit",unitPrice:"unitPrice",currency:"currency",total:"total"});function vs(s,t=vc){let e=String(s?.[t.kind]??"line").toLowerCase();return!["group","subtotal","header","section"].includes(e)}function xc(s,{units:t,currencies:e,currency:i,locale:n,decimals:r,columnOverrides:o}){let a=u=>p=>vs(p,s)?u:!1,c=u=>String(u?.[s.currency]||i),h=u=>String(u?.[s.unit]??""),d={item:{id:s.item,label:"Item",width:"2fr",sortable:!0,editable:a("text")},quantity:{id:s.quantity,label:"Quantity",width:"1fr",type:"unit",locale:n,unit:h,editable:a("number"),editorProps:{min:0,step:.01}},unit:{id:s.unit,label:"Unit",width:".8fr",editable:a(yc(t)?"select":"text"),options:t},unitPrice:{id:s.unitPrice,label:"Unit price",width:"1fr",type:"currency",locale:n,decimals:r,currency:c,editable:a("number"),editorProps:{min:0,step:.01}},currency:{id:s.currency,label:"Currency",width:".8fr",editable:a(yc(e)?"select":"text"),options:e},total:{id:s.total,label:"Line total",width:"1fr",type:"currency",locale:n,decimals:r,currency:c}};return Object.entries(d).map(([u,p])=>({...p,...o?.[u]??{}}))}function yc(s){return Array.isArray(s)?s.length>0:!!(s&&typeof s=="object"&&Object.keys(s).length)}function wc(s){if(s==null||typeof s=="string"&&s.trim()==="")return null;let t=Number(s);return Number.isFinite(t)?t:null}var Cr=class extends b{static cssName="chart";static defaults={adapter:null,type:"bar",data:{labels:[],datasets:[]},chartOptions:{},label:"Chart",description:"",summary:"hidden",loading:!1,emptyText:"No chart data",loadingText:"Loading chart\u2026",errorText:"Unable to render chart",aspectRatio:"16 / 9"};constructor(t=null,e={}){super(t,e),this._mountOrUpdate(!1)}render(){this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,c=>[c.name,c.value]),children:Array.from(t.childNodes)},this._adapter=this.options.adapter,this._type=String(this.options.type||"bar"),this._data=kc(this.options.data),this._label=rm(this.options.label),this._chartOptions=At(this.options.chartOptions),this._loading=!!this.options.loading,this._error=null,this._hasError=!1,this._handle=null,this._destroyed=!1;let e=x("zx-chart-description"),i=l("canvas",{ref:"canvas",class:"zx-chart__canvas",role:"img",ariaLabel:this._label,ariaDescribedby:e}),n=l("div",{ref:"viewport",class:"zx-chart__viewport"},i);n.style.setProperty("--zx-chart-aspect-ratio",String(this.options.aspectRatio));let r=l("p",{ref:"description",class:"zx-chart__description",id:e},this.options.description),o=l("div",{ref:"status",class:"zx-chart__status",role:"status",ariaLive:"polite"}),a=l("div",{ref:"summary",class:"zx-chart__summary",dataset:{summary:this.options.summary==="visible"?"visible":"hidden"}});return t.replaceChildren(n,r,o,a),this._renderSummary(),this._syncState(),this._observer=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.resize()):null,this._observer?.observe(n),t}setData(t){return this._data=kc(t),this._error=null,this._hasError=!1,this._loading=!1,this._renderSummary(),this._mountOrUpdate(!0),this}setType(t){return this._type=String(t||"bar"),this._mountOrUpdate(!0),this}update(t){return this._chartOptions=At(t&&typeof t=="object"?t:{}),this._mountOrUpdate(!0),this}setAdapter(t){return this._destroyHandle(),this._adapter=t,this._mountOrUpdate(!1),this}setLoading(t=!0){return this._loading=!!t,this._loading?this._destroyHandle():this._mountOrUpdate(!1),this._syncState(),this}setError(t){return this._error=t??new Error(String(this.options.errorText)),this._hasError=!0,this._loading=!1,this._destroyHandle(),this._syncState(),this.emit("error",{error:this._error}),this}clearError(){return this._error=null,this._hasError=!1,this._mountOrUpdate(!1),this}resize(){try{this._handle?.resize?.()}catch(t){this.setError(t)}return this}refreshTheme(){return this._mountOrUpdate(!0),this}getInstance(){return this._handle?.instance??null}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this._original;if(this._observer?.disconnect(),this._destroyHandle(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_mountOrUpdate(t){if(this._syncState(),this._loading||this._hasError||Ir(this._data)){this._destroyHandle();return}if(!this._adapter||typeof this._adapter.create!="function"){this._destroyHandle();return}let e=this._spec();try{if(this._handle)this._handle.update(e);else{if(this._handle=this._adapter.create(this.refs.canvas,e),!this._handle||typeof this._handle.destroy!="function")throw new TypeError("Chart adapter create() must return a lifecycle handle");this.emit("ready",{instance:this.getInstance()})}t&&this.emit("update",{data:this._data,type:this._type})}catch(i){this.setError(i)}}_spec(){return{type:this._type,data:At(this._data),options:{...lm(this.el),...At(this._chartOptions)},onSelect:t=>this.emit("select",t)}}_destroyHandle(){if(!this._handle)return;let t=this._handle;this._handle=null;try{t.destroy()}catch{}}_syncState(){let t=Ir(this._data),e=this._loading?"loading":this._hasError?"error":t?"empty":"ready";this.el.dataset.state=e,this.refs.viewport.hidden=e!=="ready";let i="";e==="loading"?i=String(this.options.loadingText):e==="error"?i=cm(this._error,this.options.errorText):e==="empty"&&(i=String(this.options.emptyText)),this.refs.status.textContent=i,this.refs.status.hidden=!i}_renderSummary(){this.refs.summary.replaceChildren(Ac(this._data,this._label))}};function rm(s){return String(s??"").trim()||"Chart"}var Tr=class{constructor(t,e={}){let i=typeof t=="function"?t:t?.Chart;if(typeof i!="function")throw new TypeError("ChartJsAdapter requires an injected Chart.js constructor");this.engine=i,this.defaults=At(e)}create(t,e){let i=this.engine,n=null,r="",o=!1,a=c=>{let h=null,d=Sc(c,this.defaults,()=>h);h=new i(t,d),n=h,r=c.type};return a(e),{get instance(){return n},update:c=>{if(o)return;if(c.type!==r){let d=n;n=null,d?.destroy?.(),a(c);return}let h=Sc(c,this.defaults,()=>n);n.data=h.data,n.options=h.options,n.update()},resize:()=>{o||n?.resize?.()},destroy:()=>{o||(o=!0,n?.destroy?.(),n=null)}}}};function Sc(s,t,e){let i=At(s.options),n={responsive:!0,maintainAspectRatio:!1,...At(t),...i},r=n.onClick;return n.onClick=(o,a,c)=>{typeof r=="function"&&r(o,a,c);let h=e()??c,u=(Array.isArray(a)&&a.length?a:h?.getElementsAtEventForMode?.(o,"nearest",{intersect:!0},!0)??[])[0];if(!u)return;let p=s.data.datasets?.[u.datasetIndex]??null;s.onSelect({datasetIndex:u.datasetIndex,index:u.index,dataset:p,label:s.data.labels?.[u.index],value:p?.data?.[u.index],nativeEvent:o?.native??o??null})},{type:s.type,data:At(s.data),options:n}}function At(s){return Dr(s,new WeakMap)}function Dr(s,t){if(Array.isArray(s)){if(t.has(s))return t.get(s);let e=[];return t.set(s,e),e.push(...s.map(i=>Dr(i,t))),e}if(s&&typeof s=="object"&&Object.getPrototypeOf(s)===Object.prototype){if(t.has(s))return t.get(s);let e={};t.set(s,e);for(let[i,n]of Object.entries(s))e[i]=Dr(n,t);return e}return s}function kc(s){return!s||typeof s!="object"?{labels:[],datasets:[]}:At({...s,labels:Array.isArray(s.labels)?s.labels:[],datasets:Array.isArray(s.datasets)?s.datasets:[]})}function Ir(s){return!Array.isArray(s?.datasets)||!s.datasets.some(t=>Array.isArray(t?.data)&&t.data.length>0)}function Ac(s,t="Chart data"){let e=om(s);return l("table",{class:"zx-chart__table"},l("caption",{},t),l("thead",{},l("tr",{},l("th",{scope:"col"},"Label"),e.headers.map(n=>l("th",{scope:"col"},n)))),l("tbody",{},e.rows.map(n=>l("tr",{},l("th",{scope:"row"},n.label),n.values.map(r=>l("td",{},r))))))}function om(s){let t=Array.isArray(s?.datasets)?s.datasets:[],e=Array.isArray(s?.labels)?s.labels:[],i=Math.max(e.length,...t.map(n=>Array.isArray(n.data)?n.data.length:0),0);return{headers:t.map((n,r)=>String(n.label??`Series ${r+1}`)),rows:Array.from({length:i},(n,r)=>({label:String(e[r]??r+1),values:t.map(o=>am(o.data?.[r]))}))}}function am(s){if(s==null)return"";if(typeof s=="object"){if("y"in s)return String(s.y??"");if("r"in s)return String(s.r??"");try{return JSON.stringify(s)}catch{return String(s)}}return String(s)}function lm(s){if(typeof getComputedStyle!="function")return{};let t=getComputedStyle(s),e=t.getPropertyValue("--zx-color-text").trim(),i=t.getPropertyValue("--zx-color-border").trim();return{color:e||void 0,borderColor:i||void 0}}function cm(s,t){let e=s&&typeof s=="object"&&"message"in s?String(s.message):"";return e.trim()?e:String(t)}function xs({valueKey:s="ID",labelKey:t="name",childrenKey:e="children"}={}){return{value:i=>typeof s=="function"?s(i):i?.[s],label:i=>String((typeof t=="function"?t(i):i?.[t])??""),children:i=>{let n=i?.[e];return Array.isArray(n)?n:null}}}function q(s,t){if(s?.hasChildren===!0)return!0;let e=t.children(s);return Array.isArray(e)&&e.length>0}function xe(s,t,e,{level:i=1,parent:n=null}={}){s.forEach((r,o)=>{e(r,{level:i,parent:n,index:o,siblings:s});let a=t.children(r);a&&xe(a,t,e,{level:i+1,parent:r})})}function zc(s,t,e){let i=null;return xe(s,e,n=>{i===null&&Object.is(e.value(n),t)&&(i=n)}),i}function fi(s,t,e){for(let i of s){if(Object.is(e.value(i),t))return[i];let n=e.children(i);if(!n)continue;let r=fi(n,t,e);if(r.length>0)return[i,...r]}return[]}function Cc(s,t){let e=[],i=t.children(s);return i&&xe(i,t,n=>e.push(n)),e}function Tc(s,t,e){let i=[],n=(r,o,a)=>{r.forEach((c,h)=>{let d=t.value(c);if(i.push({node:c,id:d,level:o,parent:a,posinset:h+1,setsize:r.length}),!e.has(d))return;let u=t.children(c);u&&u.length>0&&n(u,o+1,c)})};return n(s,1,null),i}function Er(s,t,e,i){let n=[];for(let r of s){let o=t.children(r)??[],a=Er(o,t,e,i);(e(r)||a.length>0)&&n.push(a.length>0||o.length>0?{...r,[i]:a}:r)}return n}var Mr=class extends b{static cssName="tree";static defaults={items:[],valueKey:"ID",labelKey:"name",childrenKey:"children",expanded:[],selection:"single",selected:[],checkboxes:!1,checked:[],icons:!0,renderLabel:null,load:null,filter:"",label:"Tree",emptyText:"Nothing to show",height:null};render(){this._items=[],this._rows=[],this._expanded=new Set,this._selected=new Set,this._checked=new Set,this._loading=new Map,this._focusId=null,this._filter="",this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t,this._readers=xs(this.options),this._childrenKey=this.options.childrenKey??"children",t.setAttribute("role","tree"),t.setAttribute("aria-label",String(this.options.label??"Tree")),t.tabIndex=0,this.options.selection==="multi"&&t.setAttribute("aria-multiselectable","true"),this.options.height!==null&&(t.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height),t.style.overflowY="auto"),this._items=Nr(this.options.items);for(let i of pi(this.options.expanded))this._expanded.add(i);for(let i of pi(this.options.selected))this._selected.add(i);let[e]=this._selected;if(e!==void 0){this._focusId=e;for(let i of this.getPath(e).slice(0,-1))this._expanded.add(this._readers.value(i))}for(let i of pi(this.options.checked))this._applyCheck(i,!0,{silent:!0});return this._handleTypeahead=lt(()=>this._rotatedRows().map(i=>this._readers.label(i.node)),(i,n)=>this._focusNodeId(this._rotatedRows()[n]?.id)),this.listen(t,"keydown",i=>this._onKeydown(i)),this.listen(t,"click",i=>this._onClick(i)),this.listen(t,"dblclick",i=>this._onDoubleClick(i)),this.listen(t,"focus",()=>{this._rows.length>0&&!this._rowElement(this._focusId)&&this._focusRow(0)}),String(this.options.filter??"")!==""?this.setFilter(this.options.filter):this._renderRows(),t}setItems(t){return this._items=Nr(t),this._renderRows(),this}getItems(){return this._items}getNode(t){return zc(this._items,t,this._readers)}getPath(t){return fi(this._items,t,this._readers)}setFilter(t){if(this._filter=String(t??""),this._filter!=="")for(let e of this._visibleItems())xe([e],this._readers,i=>this._expanded.add(this._readers.value(i)));return this._renderRows(),this}async expand(t){let e=this.getNode(t);if(!e||!q(e,this._readers))return this;let i=this._readers.children(e),n=!!this.options.load&&(!i||i.length===0);return this._expanded.has(t)&&!n?this:await this._ensureChildren(e,t)?(this._expanded.add(t),this._renderRows(),this.emit("expand",{node:e,id:t}),this):this}collapse(t){if(!this._expanded.delete(t))return this;let e=this.getNode(t);return this._renderRows(),e&&this.emit("collapse",{node:e,id:t}),this}async toggle(t){return this._expanded.has(t)?this.collapse(t):this.expand(t)}expandAll(){return xe(this._items,this._readers,t=>{q(t,this._readers)&&this._expanded.add(this._readers.value(t))}),this._renderRows(),this}collapseAll(){return this._expanded.clear(),this._renderRows(),this}reveal(t){let e=this.getPath(t);for(let i of e.slice(0,-1))this._expanded.add(this._readers.value(i));return this._renderRows(),this}select(t,{silent:e=!1,additive:i=!1}={}){if(this.options.selection===!1)return this;let n=this.getNode(t);return n?(this.options.selection==="multi"&&i?this._selected.has(t)?this._selected.delete(t):this._selected.add(t):(this._selected.clear(),this._selected.add(t)),this._syncRows(),e||this.emit("select",{node:n,id:t,ids:this.getSelection()}),this):this}getSelection(){return[...this._selected]}setSelection(t,{silent:e=!0}={}){let i=pi(t);if(this._selected=new Set(this.options.selection==="multi"?i:i.slice(0,1)),this._syncRows(),!e){let[n]=this._selected;this.emit("select",{node:this.getNode(n)??null,id:n,ids:this.getSelection()})}return this}clearSelection(){return this._selected.clear(),this._syncRows(),this}getChecked({leavesOnly:t=!1}={}){return t?[...this._checked].filter(e=>{let i=this.getNode(e);return i!==null&&!q(i,this._readers)}):[...this._checked]}setChecked(t,{silent:e=!0}={}){this._checked.clear();for(let i of pi(t))this._applyCheck(i,!0,{silent:!0});return this._syncRows(),e||this.emit("check",{ids:this.getChecked(),node:null}),this}check(t,e,{silent:i=!1}={}){let n=this._applyCheck(t,e,{silent:!0});return this._syncRows(),!i&&n&&this.emit("check",{ids:this.getChecked(),node:n}),this}focusNode(t){this.reveal(t);let e=this._rows.findIndex(i=>Object.is(i.id,t));return e>=0&&this._focusRow(e),this}_visibleItems(){if(this._filter==="")return this._items;let t=this._filter.trim().toLocaleLowerCase();return t===""?this._items:Er(this._items,this._readers,e=>this._readers.label(e).toLocaleLowerCase().includes(t),this._childrenKey)}_renderRows(){let t=this._visibleItems();if(this._rows=Tc(t,this._readers,this._expanded),this._rows.length===0){this.el.replaceChildren(l("div",{class:"zx-tree__empty"},this._message("tree.empty",this.options.emptyText)));return}this.el.replaceChildren(...this._rows.map(e=>this._renderRow(e))),this._syncRows()}_renderRow(t){let e=q(t.node,this._readers),i=e&&this._expanded.has(t.id),n=l("div",{class:"zx-tree__row",role:"treeitem",id:x("zx-tree-item"),tabIndex:-1,ariaLevel:String(t.level),ariaSetSize:String(t.setsize),ariaPosInSet:String(t.posinset),dataset:{level:String(t.level)}});n.style.setProperty("--zx-tree-level",String(t.level-1));let r=l("span",{class:"zx-tree__twisty",ariaHidden:"true"},e?g("chevron-right",{size:12}):null);if(r.dataset.action="twisty",n.append(r),this.options.checkboxes){let a=l("input",{class:"zx-tree__checkbox",type:"checkbox",tabIndex:-1,ariaHidden:"true"});a.dataset.action="checkbox",n.append(a)}this.options.icons&&n.append(l("span",{class:"zx-tree__icon",ariaHidden:"true"},g(e?i?"folder-open":"folder":"file",{size:14})));let o=this.options.renderLabel?this.options.renderLabel(t.node):this._readers.label(t.node);return n.append(l("span",{class:"zx-tree__label"},o)),t.node.badge!=null&&n.append(l("span",{class:"zx-tree__badge"},String(t.node.badge))),n}_syncRows(){let t=this.el.querySelectorAll(".zx-tree__row"),e=this._rows.findIndex(i=>Object.is(i.id,this._focusId));e<0&&(e=0),t.forEach((i,n)=>{let r=this._rows[n];if(!r)return;let o=q(r.node,this._readers),a=o&&this._expanded.has(r.id);o?i.setAttribute("aria-expanded",String(a)):i.removeAttribute("aria-expanded"),this.options.selection!==!1&&i.setAttribute("aria-selected",String(this._selected.has(r.id))),i.toggleAttribute("data-branch",o),i.toggleAttribute("data-loading",this._loading.has(r.id)),i.tabIndex=n===e?0:-1;let c=i.querySelector(".zx-tree__checkbox");if(c){let d=this._checkState(this.getNode(r.id)??r.node);c.checked=d==="checked",c.indeterminate=d==="partial",i.setAttribute("aria-checked",d==="partial"?"mixed":String(c.checked))}let h=i.querySelector(".zx-tree__icon");h&&this.options.icons&&h.replaceChildren(g(o?a?"folder-open":"folder":"file",{size:14}))}),this._focusId=this._rows[e]?.id??null,this.el.tabIndex=this._rows.length===0?0:-1}_onClick(t){let e=t.target.closest(".zx-tree__row");if(!e)return;let i=this._rowIndex(e);if(i<0)return;let n=this._rows[i];this._focusRow(i);let r=t.target.closest("[data-action]");if(r?.dataset.action==="twisty"){q(n.node,this._readers)&&this.toggle(n.id).then(()=>this._focusNodeId(n.id));return}let o=this.getNode(n.id)??n.node;if(r?.dataset.action==="checkbox"){this.check(n.id,this._checkState(o)!=="checked");return}if(this.options.checkboxes&&this.options.selection===!1){this.check(n.id,this._checkState(o)!=="checked");return}this.select(n.id,{additive:t.ctrlKey||t.metaKey})}_onDoubleClick(t){let e=t.target.closest(".zx-tree__row");if(!e)return;let i=this._rows[this._rowIndex(e)];i&&(q(i.node,this._readers)?this.toggle(i.id).then(()=>this._focusNodeId(i.id)):this.emit("activate",{node:i.node,id:i.id}))}_onKeydown(t){let e=this._rows.findIndex(o=>Object.is(o.id,this._focusId));if(e<0||this._rows.length===0)return;let i=this._rows[e],n=q(i.node,this._readers),r=n&&this._expanded.has(i.id);switch(t.key){case"ArrowDown":t.preventDefault(),this._focusRow(Math.min(this._rows.length-1,e+1));return;case"ArrowUp":t.preventDefault(),this._focusRow(Math.max(0,e-1));return;case"ArrowRight":t.preventDefault(),n&&!r?this.expand(i.id).then(()=>this._focusNodeId(i.id)):r&&this._focusRow(Math.min(this._rows.length-1,e+1));return;case"ArrowLeft":{t.preventDefault(),r?(this.collapse(i.id),this._focusNodeId(i.id)):i.parent&&this._focusNodeId(this._readers.value(i.parent));return}case"Home":t.preventDefault(),this._focusRow(0);return;case"End":t.preventDefault(),this._focusRow(this._rows.length-1);return;case"Enter":t.preventDefault(),this.options.selection!==!1&&this.select(i.id),this.emit("activate",{node:i.node,id:i.id});return;case" ":t.preventDefault(),this.options.checkboxes?this.check(i.id,this._checkState(this.getNode(i.id)??i.node)!=="checked"):this.options.selection!==!1&&this.select(i.id,{additive:this.options.selection==="multi"});return;case"*":t.preventDefault(),this._expandSiblings(i);return;default:this._handleTypeahead(t)}}_expandSiblings(t){let e=t.parent?this._readers.children(t.parent)??[]:this._visibleItems(),i=this._focusId;for(let n of e)q(n,this._readers)&&this._expanded.add(this._readers.value(n));this._renderRows(),this._focusNodeId(i)}async _ensureChildren(t,e){let i=this._readers.children(t);if(!this.options.load||i&&i.length>0)return!0;if(this._loading.has(e))return await this._loading.get(e),Array.isArray(this._readers.children(t));let n=(async()=>{try{let o=await this.options.load(t);return t[this._childrenKey]=Array.isArray(o)?o:[],t[this._childrenKey].length===0&&(t.hasChildren=!1),!0}catch(o){return this.emit("error",{error:o,node:t,id:e}),!1}finally{this._loading.delete(e)}})();this._loading.set(e,n),this._syncRows();let r=await n;return this._syncRows(),r}_applyCheck(t,e,{silent:i}){let n=this.getNode(t);if(!n)return null;let r=[t,...Cc(n,this._readers).map(o=>this._readers.value(o))];for(let o of r)e?this._checked.add(o):this._checked.delete(o);return i||this._syncRows(),n}_checkState(t){let e=this._readers.children(t);if(!e||e.length===0)return this._checked.has(this._readers.value(t))?"checked":"unchecked";let i=e.map(n=>this._checkState(n));return i.every(n=>n==="checked")?"checked":i.every(n=>n==="unchecked")?"unchecked":"partial"}_rotatedRows(){let t=this._rows.findIndex(e=>Object.is(e.id,this._focusId));return t<0?this._rows:[...this._rows.slice(t+1),...this._rows.slice(0,t+1)]}_rowIndex(t){return[...this.el.querySelectorAll(".zx-tree__row")].indexOf(t)}_rowElement(t){let e=this._rows.findIndex(i=>Object.is(i.id,t));return e<0?null:this.el.querySelectorAll(".zx-tree__row")[e]??null}_focusRow(t){let e=this._rows[t];if(!e)return;this._focusId=e.id,this._syncRows();let i=this._rowElement(e.id);i?.focus(),i?.scrollIntoView({block:"nearest"})}_focusNodeId(t){if(t===void 0)return;let e=this._rows.findIndex(i=>Object.is(i.id,t));e>=0&&this._focusRow(e)}_message(t,e){let i=this.msg(t);return i===t?e:i}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&k(t,this._snapshot)}};function Nr(s){return Array.isArray(s)?s.map(t=>{if(t===null||typeof t!="object")return t;let e={...t};for(let[i,n]of Object.entries(e))Array.isArray(n)&&(e[i]=Nr(n));return e}):[]}function pi(s){return Array.isArray(s)?s:[]}var Or=class extends b{static cssName="finder";static defaults={items:[],valueKey:"ID",labelKey:"name",childrenKey:"children",path:[],load:null,preview:null,rootLabel:"",columnWidth:220,height:320,icons:!0,renderItem:null,emptyText:"Empty"};render(){this._items=[],this._path=[],this._columns=[],this._activeColumn=0,this._loading=new Map,this._pathSequence=0,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");return this.el=t,this._readers=xs(this.options),this._childrenKey=this.options.childrenKey??"children",t.style.setProperty("--zx-finder-column",`${Number(this.options.columnWidth)||220}px`),this.options.height!==null&&(t.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._handleTypeahead=lt(()=>this._columnNodes(this._activeColumn).map(e=>this._readers.label(e)),(e,i)=>this._selectAt(this._activeColumn,i,{focus:!0})),this.listen(t,"click",e=>this._onClick(e)),this.listen(t,"dblclick",e=>this._onDoubleClick(e)),this.listen(t,"keydown",e=>this._onKeydown(e)),this._render({}),this.setPath(this.options.path,{silent:!0}),t}getPath(){return this._path.slice()}getNodes(){let t=this._items,e=[];for(let i of this._path){let n=t.find(r=>Object.is(this._readers.value(r),i));if(!n)break;e.push(n),t=this._readers.children(n)??[]}return e}getSelection(){let t=this.getNodes();return t.length>0?t[t.length-1]:null}async setPath(t,{silent:e=!1,focus:i=!1}={}){let n=this._pathSequence+1;this._pathSequence=n;let r=Array.isArray(t)?t.slice():[],o=[],a=this._items;for(let c of r){let h=a.find(d=>Object.is(this._readers.value(d),c));if(!h||(o.push(c),!q(h,this._readers)))break;if(await this._ensureChildren(h),n!==this._pathSequence)return this;a=this._readers.children(h)??[]}return this._path=o,this._activeColumn=Math.max(0,o.length-1),this._render({focus:i}),e||this._emitChange(),this}async reveal(t,{silent:e=!1}={}){let i=fi(this._items,t,this._readers);return i.length===0?this:this.setPath(i.map(n=>this._readers.value(n)),{silent:e})}setItems(t){return this._items=Array.isArray(t)?t.slice():[],this._path=[],this._render({}),this}focus(){return(this._activeRow(this._activeColumn)??this._rowAt(this._activeColumn,0))?.focus(),this}_render({focus:t=!1}){let e=this.getNodes(),i=[{nodes:this._items,selectedId:this._path[0],owner:null}];e.forEach((a,c)=>{if(!q(a,this._readers))return;let h=this._readers.children(a)??[];i.push({nodes:h,selectedId:this._path[c+1],owner:a})}),this._columns=i,this._activeColumn=Math.min(this._activeColumn,i.length-1);let n=i.map((a,c)=>this._renderColumn(a,c)),r=e[e.length-1]??null;if(this.options.preview&&r&&!q(r,this._readers)){let a=this.options.preview(r);a&&n.push(l("div",{class:"zx-finder__preview"},a))}this.el.replaceChildren(...n),this._syncTabStop(),this.el.lastElementChild?.scrollIntoView({block:"nearest",inline:"nearest"}),t&&this.focus()}_renderColumn(t,e){let i=t.owner?this._readers.label(t.owner):String(this.options.rootLabel||this._message("finder.root","Root")),n=l("div",{class:"zx-finder__list",role:"listbox",ariaLabel:i,dataset:{column:String(e)}});if(t.nodes.length===0){let r=t.owner!==null&&this._loading.has(this._readers.value(t.owner));n.append(l("div",{class:"zx-finder__empty"},r?this._message("finder.loading","Loading\u2026"):this._message("finder.empty",this.options.emptyText)))}for(let r of t.nodes){let o=this._readers.value(r),a=q(r,this._readers),c=t.selectedId!==void 0&&Object.is(o,t.selectedId),h=l("div",{class:"zx-finder__row",id:x("zx-finder-row"),role:"option",tabIndex:-1,ariaSelected:String(c)});this.options.icons&&h.append(l("span",{class:"zx-finder__icon",ariaHidden:"true"},g(a?"folder":"file",{size:14}))),h.append(l("span",{class:"zx-finder__label"},this.options.renderItem?this.options.renderItem(r):this._readers.label(r))),a&&h.append(l("span",{class:"zx-finder__chevron",ariaHidden:"true"},g("chevron-right",{size:11}))),h.toggleAttribute("data-branch",a),n.append(h)}return l("div",{class:"zx-finder__column"},n)}_syncTabStop(){let t=this.el.querySelectorAll(".zx-finder__row");t.forEach(i=>{i.tabIndex=-1});let e=this._activeRow(this._activeColumn)??this._rowAt(this._activeColumn,0)??t[0];e&&(e.tabIndex=0)}_onClick(t){let e=t.target.closest(".zx-finder__row");if(!e)return;let{column:i,index:n}=this._locate(e);i<0||this._selectAt(i,n,{focus:!0})}_onDoubleClick(t){let e=t.target.closest(".zx-finder__row");if(!e)return;let{column:i,index:n}=this._locate(e),r=this._columnNodes(i)[n];r&&(q(r,this._readers)?this._enter(i,n):this.emit("activate",{node:r,id:this._readers.value(r)}))}_onKeydown(t){if(t.target.closest(".zx-finder__preview"))return;let e=this._activeColumn,i=this._columnNodes(e);if(i.length===0&&!["ArrowLeft"].includes(t.key))return;let n=Math.max(0,i.findIndex(r=>Object.is(this._readers.value(r),this._columns[e]?.selectedId)));switch(t.key){case"ArrowDown":t.preventDefault(),this._selectAt(e,Math.min(i.length-1,n+1),{focus:!0});return;case"ArrowUp":t.preventDefault(),this._selectAt(e,Math.max(0,n-1),{focus:!0});return;case"Home":t.preventDefault(),this._selectAt(e,0,{focus:!0});return;case"End":t.preventDefault(),this._selectAt(e,i.length-1,{focus:!0});return;case"ArrowRight":{t.preventDefault();let r=i[n];if(!r||!q(r,this._readers))return;this._enter(e,n);return}case"ArrowLeft":if(t.preventDefault(),e===0)return;this._path=this._path.slice(0,e),this._activeColumn=e-1,this._render({focus:!0}),this._emitChange();return;case"Enter":{t.preventDefault();let r=i[n];if(!r)return;q(r,this._readers)?this._enter(e,n):this.emit("activate",{node:r,id:this._readers.value(r)});return}default:this._handleTypeahead(t)}}async _selectAt(t,e,{focus:i=!1}={}){let n=this._columnNodes(t)[e];if(!n)return;let r=this._readers.value(n);if(this._path.length===t+1&&Object.is(this._path[t],r)){this._activeColumn=t,this._syncTabStop(),i&&this.focus();return}this._path=[...this._path.slice(0,t),r],this._activeColumn=t,q(n,this._readers)&&await this._ensureChildren(n),this._render({focus:i}),this._emitChange()}async _enter(t,e){if(await this._selectAt(t,e),this._columnNodes(t+1).length===0){this._activeColumn=t,this._syncTabStop(),this.focus();return}this._activeColumn=t+1,this._path.length<=t+1?await this._selectAt(t+1,0,{focus:!0}):(this._syncTabStop(),this.focus())}async _ensureChildren(t){let e=this._readers.children(t);if(!this.options.load||e&&e.length>0)return;let i=this._readers.value(t),n=this._loading.get(i);if(n)return n;let r=(async()=>{try{let o=await this.options.load(t);t[this._childrenKey]=Array.isArray(o)?o:[],t[this._childrenKey].length===0&&(t.hasChildren=!1)}catch(o){t[this._childrenKey]=[],this.emit("error",{error:o,node:t,id:i})}finally{this._loading.delete(i)}})();return this._loading.set(i,r),r}_columnNodes(t){return this._columns[t]?.nodes??[]}_locate(t){let e=t.closest(".zx-finder__list");return e?{column:Number(e.dataset.column),index:[...e.querySelectorAll(".zx-finder__row")].indexOf(t)}:{column:-1,index:-1}}_rowAt(t,e){return this.el.querySelector(`.zx-finder__list[data-column="${t}"]`)?.querySelectorAll(".zx-finder__row")[e]??null}_activeRow(t){return this.el.querySelector(`.zx-finder__list[data-column="${t}"]`)?.querySelector('[aria-selected="true"]')??null}_emitChange(){let t=this.getNodes();this.emit("change",{path:this.getPath(),nodes:t,node:t.length>0?t[t.length-1]:null})}_message(t,e){let i=this.msg(t);return i===t?e:i}destroy(){this._pathSequence+=1;let t=this.el;super.destroy(),!this._createdRoot&&t&&k(t,this._snapshot)}};function Dc(s){return String(s??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLocaleLowerCase()}function hm(s,t){let e=Dc(t).trim().split(/\s+/).filter(Boolean);if(e.length===0)return!0;let i=Dc(s.flat(1/0).join(" "));return e.every(n=>i.includes(n))}function Rr(s){return s!=null&&!(typeof s=="string"&&s.trim()==="")}function Ic(s,t){if(typeof t.get=="function")return Fr(t.get(s));let e=t.fields??t.field??t.id;return(Array.isArray(e)?e:[e]).flatMap(n=>Fr(typeof n=="function"?n(s):n==null?void 0:s?.[n]))}function Ec(s,t){let e=[],i=new Map;for(let n of s)for(let r of Ic(n,t)){let o=Mc(r);o.value==null||o.value===""||i.has(o.value)||(i.set(o.value,!0),e.push(o))}return e}function oe(s,t,e){return s.filter(i=>t.every(n=>{let r=e?.[n.id];if(!Rr(r))return!0;if(n.type==="custom")return typeof n.predicate!="function"||!!n.predicate(i,r);let o=Ic(i,n);return n.type==="text"?hm(o,r):n.type==="select"?o.some(a=>dm(Mc(a).value,r)):!0}))}function Fr(s){return Array.isArray(s)?s.flat(1/0):[s]}function Mc(s){if(s&&typeof s=="object"&&!(s instanceof Date)){if(Object.prototype.hasOwnProperty.call(s,"value"))return{value:s.value,label:String(s.label??s.value??"")};if(Object.prototype.hasOwnProperty.call(s,"field"))return{value:s.field,label:String(s.label??s.field??"")}}return{value:s,label:String(s??"")}}function dm(s,t){return Object.is(s,t)?!0:s==null||t==null?!1:String(s)===String(t)}var Vr=class extends b{static cssName="data-filter";static defaults={filters:[],data:[],autoApply:!0,clearLabel:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??l("div");this._originalChildren=this.el?Array.from(this.el.childNodes):null,this._filters=Array.isArray(this.options.filters)?this.options.filters.map(i=>({...i})):[],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 i of this._filters){if(Lr(i),e.has(i.id))throw new RangeError(`Duplicate filter id: ${i.id}`);e.add(i.id),i.type==="custom"&&!this._customOrigins.has(i.element)&&this._customOrigins.set(i.element,{parent:i.element.parentNode,nextSibling:i.element.nextSibling}),this._state[i.id]=i.type==="custom"?Pr(i.element):""}this._filtered=oe(this._data,this._filters,this._state),this._controls=l("div",{class:"zx-data-filter__controls"}),this._badge=l("span",{class:"zx-data-filter__badge",ariaLive:"polite",hidden:!0},"0"),this._clearButton=l("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 i of this._filters)this._appendFilter(i);return this._syncActiveState(),t}setData(t){pm(t),this._data=[...t];for(let e of this._filters){if(e.type!=="select")continue;let i=this._entries.get(e.id);i&&this._populateSelect(e,i)}return this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=oe(this._data,this._filters,this._state),this}apply(){this._filtered=oe(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=oe(this._data,this._filters,this._state),this}addFilter(t){Lr(t);let e={...t};return this._filters.push(e),this._state[e.id]=e.type==="custom"?Pr(e.element):"",this._appendFilter(e),this._filtered=oe(this._data,this._filters,this._state),this._syncActiveState(),this}destroy(){this._restored||(this._originalChildren&&this.el.replaceChildren(...this._originalChildren),_m(this._customOrigins),this._restored=!0),super.destroy()}_appendFilter(t){if(Lr(t),this._entries.has(t.id))throw new RangeError(`Duplicate filter id: ${t.id}`);let e,i={element:null,options:[]};if(t.type==="select")e=l("select",{ariaLabel:t.label}),i.element=e,this._populateSelect(t,i),this.listen(e,"change",()=>{let r=Number(e.value)-1;this._state[t.id]=r>=0?i.options[r]?.value??"":"",this._controlChanged()});else if(t.type==="text")e=l("input",{type:"search",placeholder:t.placeholder??"",ariaLabel:t.label,autocomplete:"off"}),i.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}),i.element=e;let r=e.matches?.('input:not([type="checkbox"]):not([type="radio"]), textarea')?"input":"change";this.listen(e,r,()=>{this._state[t.id]=Pr(e),this._controlChanged()})}this._entries.set(t.id,i);let n=l("label",{class:"zx-data-filter__field"},l("span",{class:"zx-data-filter__label"},t.label),e);this._controls.append(n)}_populateSelect(t,e){let i=this._state[t.id];e.options=Array.isArray(t.options)?t.options.map(um):Ec(this._data,t);let n=l("option",{value:""},t.emptyLabel??this.msg("dataFilter.all")),r=document.createDocumentFragment();r.append(n),e.options.forEach((a,c)=>{r.append(l("option",{value:String(c+1)},a.label))}),e.element.replaceChildren(r);let o=e.options.findIndex(a=>Nc(a.value,i));e.element.value=o>=0?String(o+1):"",o<0&&(this._state[t.id]="")}_controlChanged(){this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=oe(this._data,this._filters,this._state)}_syncControls(){for(let t of this._filters){let e=this._entries.get(t.id);if(!e)continue;let i=this._state[t.id];if(t.type==="select"){let n=e.options.findIndex(r=>Nc(r.value,i));e.element.value=n>=0?String(n+1):"",n<0&&(this._state[t.id]="")}else fm(e.element,i)}}_syncActiveState(){let t=this._filters.reduce((e,i)=>e+Number(Rr(this._state[i.id])),0);this._badge.textContent=String(t),this._badge.hidden=t===0,this._clearButton.hidden=t===0}};function Lr(s){if(!s||typeof s!="object")throw new TypeError("Filter definition must be an object");if(!["select","text","custom"].includes(s.type))throw new TypeError(`Unknown filter type: ${s.type}`);if(typeof s.id!="string"||!s.id)throw new TypeError("Filter definition requires an id");if(s.type==="custom"){if(!s.element||s.element.nodeType!==1)throw new TypeError("Custom filter requires an Element");if(typeof s.predicate!="function")throw new TypeError("Custom filter requires a predicate")}}function um(s){return s&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"value")?{value:s.value,label:String(s.label??s.value??"")}:{value:s,label:String(s??"")}}function Pr(s){return"checked"in s&&["checkbox","radio"].includes(s.type)?s.checked:"value"in s?s.value:s.getAttribute("data-value")??""}function fm(s,t){"checked"in s&&["checkbox","radio"].includes(s.type)?s.checked=!!t:"value"in s?s.value=t==null?"":String(t):t==null||t===""?s.removeAttribute("data-value"):s.setAttribute("data-value",String(t))}function Nc(s,t){return Object.is(s,t)?!0:s==null||t==null?!1:String(s)===String(t)}function pm(s){if(!Array.isArray(s))throw new TypeError("DataFilter data must be an array")}function _m(s){let t=[...s];for(let e=t.length;t.length>0&&e>=0;e-=1){let i=0;for(let n=t.length-1;n>=0;n-=1){let[r,o]=t[n];if(!o.parent)r.remove();else{if(o.nextSibling&&o.nextSibling.parentNode!==o.parent)continue;o.parent.insertBefore(r,o.nextSibling)}t.splice(n,1),i+=1}if(i===0)break}for(let[e,i]of t)i.parent?i.parent.append(e):e.remove()}var As=Object.freeze([R("contains","contains","single",["text"]),R("notContains","does not contain","single",["text"]),R("eq","is","single",["text","number","money","boolean","enum","status","priority","country","currency","unit","entity","date","datetime"]),R("neq","is not","single",["text","number","money","boolean","enum","status","priority","country","currency","unit","entity","date","datetime"]),R("startsWith","starts with","single",["text"]),R("endsWith","ends with","single",["text"]),R("lt","is less than","single",["number","money"]),R("lte","is at most","single",["number","money"]),R("gt","is greater than","single",["number","money"]),R("gte","is at least","single",["number","money"]),R("on","is on","single",["date","datetime"]),R("notOn","is not on","single",["date","datetime"]),R("before","is before","single",["date","datetime"]),R("onOrBefore","is on or before","single",["date","datetime"]),R("after","is after","single",["date","datetime"]),R("onOrAfter","is on or after","single",["date","datetime"]),R("between","is between","pair",["number","money","date","datetime"]),R("notBetween","is not between","pair",["number","money","date","datetime"]),R("withinLast","is within the last","pair",["date","datetime"]),R("withinNext","is within the next","pair",["date","datetime"]),R("anyOf","is any of","many",["enum","status","priority","country","currency","unit","entity"]),R("noneOf","is none of","many",["enum","status","priority","country","currency","unit","entity"]),R("containsAny","contains any","many",["tags"]),R("containsAll","contains all","many",["tags"]),R("containsNone","contains none","many",["tags"]),R("isEmpty","is empty","none",["text","number","money","date","datetime","boolean","enum","status","priority","country","currency","unit","entity","tags"]),R("isNotEmpty","is not empty","none",["text","number","money","date","datetime","boolean","enum","status","priority","country","currency","unit","entity","tags"])]);function Hr(){return{version:1,root:{kind:"group",id:x("filter-root"),logic:"and",children:[]}}}function qr(s={}){return{kind:"condition",id:String(s.id||x("filter-condition")),field:String(s.field??""),operator:String(s.operator??""),value:jr(s.value??null)}}function jr(s){return ks(s)}function $r(s="and",t=[]){return{kind:"group",id:x("filter-group"),logic:s,children:t}}function Se(s,t={}){let e=Oc(t.maxDepth,3),i=Oc(t.maxConditions,50);if(!Ss(s)||s.version!==1||!Ss(s.root))throw new TypeError("Filter AST must have version 1 and a root group");let n=new Set,r=0,o=(c,h,d=!1)=>{if(!Ss(c))throw new TypeError("Filter nodes must be plain objects");let u=String(c.id??"").trim();if(!u||n.has(u))throw new TypeError("Filter node IDs must be non-empty and unique");if(n.add(u),c.kind==="group"){if(h>e)throw new RangeError("Filter group depth exceeds maxDepth");if(c.logic!=="and"&&c.logic!=="or")throw new TypeError("Filter group logic must be and or or");if(!Array.isArray(c.children))throw new TypeError("Filter group children must be an array");return{kind:"group",id:u,logic:c.logic,children:c.children.map(p=>o(p,h+1,!1))}}if(d||c.kind!=="condition")throw new TypeError("Filter root must be a group");if(r+=1,r>i)throw new RangeError("Filter condition count exceeds maxConditions");return{kind:"condition",id:u,field:String(c.field??""),operator:String(c.operator??""),value:ks(c.value)}},a=o(s.root,0,!0);if(a.kind!=="group")throw new TypeError("Filter root must be a group");return{version:1,root:a}}function zs(s){return Se(s,{maxDepth:1/0,maxConditions:1/0})}function mm(s){return JSON.stringify(zs(s))}function Kr(s,t,e=As){let i=[],n=new Map((Array.isArray(t)?t:[]).map(a=>[String(a.id),a])),r=new Map((Array.isArray(e)?e:[]).map(a=>[String(a.id),a])),o=(a,c=!1)=>{if(a.kind==="group"){!c&&a.children.length===0&&i.push(_i(a.id,"empty-group","Nested groups need at least one condition")),a.children.forEach(u=>o(u));return}let h=n.get(a.field);h||i.push(_i(a.id,"unknown-field",a.field?`Unavailable field: ${a.field}`:"Choose a field"));let d=r.get(a.operator);if(!d){i.push(_i(a.id,"unknown-operator",a.operator?`Unavailable operator: ${a.operator}`:"Choose an operator"));return}h&&(!(Array.isArray(h.operators)&&h.operators.length?h.operators:e.filter(p=>p.types.includes(h.type)).map(p=>p.id)).includes(d.id)||!d.types.includes(h.type))&&i.push(_i(a.id,"operator-type",`${d.label} is not available for ${h.label}`)),gm(d.arity,a.value)||i.push(_i(a.id,"value",d.arity==="pair"?"Enter both values":d.arity==="many"?"Choose at least one value":d.arity==="none"?"This operator does not accept a value":"Enter a value"))};return o(s.root,!0),{valid:i.length===0,errors:i}}function R(s,t,e,i){return Object.freeze({id:s,label:t,arity:e,types:Object.freeze(i)})}function _i(s,t,e){return{nodeId:s,code:t,message:e}}function gm(s,t){return s==="none"?t===null:s==="pair"?Array.isArray(t)&&t.length===2&&t.every(Br):s==="many"?Array.isArray(t)&&t.length>0&&t.every(Br):Br(t)}function Br(s){return s!=null&&!(typeof s=="string"&&s.trim()==="")}function ks(s,t=new WeakSet){if(s===null||typeof s=="string"||typeof s=="boolean")return s;if(typeof s=="number"){if(!Number.isFinite(s))throw new TypeError("Filter values cannot contain non-finite numbers");return s}if(typeof s!="object"||s instanceof Date||typeof s.nodeType=="number")throw new TypeError("Filter values must be JSON-safe");if(t.has(s))throw new TypeError("Filter values cannot contain cycles");if(t.add(s),Array.isArray(s)){let i=s.map(n=>ks(n,t));return t.delete(s),i}if(!Ss(s))throw new TypeError("Filter values must be plain JSON objects");let e={};for(let[i,n]of Object.entries(s))Object.defineProperty(e,i,{value:ks(n,t),enumerable:!0,configurable:!0,writable:!0});return t.delete(s),e}function Ss(s){if(!s||typeof s!="object"||Array.isArray(s))return!1;let t=Object.getPrototypeOf(s);return t===Object.prototype||t===null}function Oc(s,t){if(s===1/0)return 1/0;let e=Number(s);return Number.isFinite(e)&&e>=0?Math.floor(e):t}var Yr=class extends b{static cssName="filter";static defaults={fields:[],value:null,operators:[],allowGroups:!0,maxDepth:3,maxConditions:50,autoApply:!1,readonly:!1,disabled:!1,applyLabel:"Apply filters",clearLabel:"Clear"};render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._snapshot=this._createdRoot?null:A(t),this._fields=(Array.isArray(this.options.fields)?this.options.fields:[]).map(e=>({...e})),this._operators=ym(As,this.options.operators),this._readonly=!!this.options.readonly,this._disabled=!!this.options.disabled,this._async=new Map,this._customEditors=[],this._value=this.options.value==null?Hr():Se(this.options.value,this._limits()),this.listen(t,"change",e=>this._handleChange(e)),this.listen(t,"input",e=>this._handleInput(e)),this.listen(t,"click",e=>this._handleClick(e)),this._render(),t}getValue(){return zs(this._value)}setValue(t,{silent:e=!1}={}){let i=Se(t,this._limits());return this._abortAll(),this._value=i,this._render(),e||this._changed("set",this._value.root.id),this}addCondition(t=null,e={}){if(!this._canMutate()||Vc(this._value.root)>=Number(this.options.maxConditions))return null;let i=Ur(this._value.root,t??this._value.root.id);if(!i)return null;let n=this._fields[0],r=String(e.field??n?.id??""),o=this._field(r),a=qr({...e,field:r,operator:String(e.operator??this._defaultOperator(o)??"")});return i.children.push(a),this._render(),this._changed("add",a.id),this.focus(a.id),a.id}addGroup(t=null,e="and"){if(!this._canMutate()||!this.options.allowGroups)return null;let i=Ur(this._value.root,t??this._value.root.id);if(!i||Bc(this._value.root,i.id)>=Number(this.options.maxDepth))return null;let n=$r(e==="or"?"or":"and");return i.children.push(n),this._render(),this._changed("add",n.id),this.focus(n.id),n.id}update(t,e={}){if(!this._canMutate())return this;let i=gt(this._value.root,t);return i?(i.kind==="group"?(e.logic==="and"||e.logic==="or")&&(i.logic=e.logic):(Object.hasOwn(e,"field")&&(i.field=String(e.field??"")),Object.hasOwn(e,"operator")&&(i.operator=String(e.operator??"")),Object.hasOwn(e,"value")&&(i.value=Lc(e.value))),this._abort(t),this._render(),this._changed("update",t),this):this}remove(t){if(!this._canMutate()||t===this._value.root.id)return this;let e=Wr(this._value.root,t);if(!e)return this;let i=e.children.findIndex(a=>a.id===t),n=e.children[i+1]?.id??e.children[i-1]?.id??e.id,r=Pc(this._value.root,t);if(!r)return this;this._abortTree(r),this._render();let o=r.kind==="condition"?this._field(r.field)?.label??"Filter":"Filter group";return this._announce(`${o} removed`),this._changed("remove",t),this.focus(n),this}move(t,e,i){let n=gt(this._value.root,t),r=Ur(this._value.root,e),o=Wr(this._value.root,t);if(!this._canMutate()||t===this._value.root.id||!n||!r||!o||bm(n,e))return this;let a=o.children.findIndex(h=>h.id===t),c=o.children.splice(a,1)[0];r.children.splice(Math.max(0,Math.min(r.children.length,Number(i)||0)),0,c);try{Se(this._value,this._limits())}catch{return r.children.splice(r.children.indexOf(c),1),o.children.splice(a,0,c),this}return this._render(),this._changed("move",t),this}validate(){return Kr(this._value,this._fields,this._operators)}apply(){if(this._disabled)return null;let t=this.validate();if(!t.valid)return this.emit("invalid",{errors:t.errors}),this.focus(t.errors[0]?.nodeId),null;let e=this.getValue();return this.emit("apply",{value:e}),e}clear({silent:t=!1}={}){return this._canMutate()?(this._abortAll(),this._value.root.children=[],this._render(),t||this._changed("clear",this._value.root.id),this.refs.add?.focus(),this):this}focus(t=null){let e=t?`[data-node-id="${ae(t)}"] :is([data-filter-field], [data-filter-logic], [data-filter-action="add"])`:'[data-filter-action="add"]';return queueMicrotask(()=>this.el.querySelector(e)?.focus()),this}setReadonly(t){return this._readonly=!!t,this._render(),this}enable(){return this._disabled=!1,this._render(),this}disable(){return this._disabled=!0,this._abortAll(),this._render(),this}destroy(){this._abortAll(),this._destroyEditors();let t=this.el,e=this._snapshot;super.destroy(),!this._createdRoot&&t&&k(t,e)}_render(){this._destroyEditors(),this._renderVersion=(this._renderVersion??0)+1;let t=l("div",{ref:"status",class:"zx-filter__status",role:"status",ariaLive:"polite"}),e=this._renderGroup(this._value.root,0,!0),i=l("div",{class:"zx-filter__actions"},$t("add",this._value.root.id,"plus","Add filter",{ref:"add",disabled:this._blocked()}),this.options.allowGroups?$t("add-group",this._value.root.id,"folder","Add group",{disabled:this._blocked()}):null,$t("clear","","x",String(this.options.clearLabel),{disabled:this._blocked()}),$t("apply","","check",String(this.options.applyLabel),{class:"zx-button--primary",disabled:this._disabled}));this.el.replaceChildren(t,e,i),this.refs.status=t,this.refs.add=this.el.querySelector('[data-filter-action="add"]'),this.el.toggleAttribute("data-readonly",this._readonly),this.el.toggleAttribute("data-disabled",this._disabled);let n=this.validate();this.el.dataset.valid=String(n.valid);for(let r of n.errors)this.el.querySelector(`[data-node-id="${ae(r.nodeId)}"]`)?.setAttribute("data-invalid","")}_renderGroup(t,e,i){let n=l("ol",{class:"zx-filter__children"},t.children.map(c=>c.kind==="group"?this._renderGroup(c,e+1,!1):this._renderCondition(c))),r=l("select",{class:"zx-filter__logic",dataset:{filterLogic:"",nodeId:t.id},ariaLabel:i?"Root filter logic":"Group filter logic",disabled:this._blocked()},l("option",{value:"and",selected:t.logic==="and"},"Match all"),l("option",{value:"or",selected:t.logic==="or"},"Match any")),o=l("legend",{class:"zx-filter__legend"},r,l("span",{},i?"conditions":"in this group")),a=l("div",{class:"zx-filter__group-actions"},$t("add",t.id,"plus","Add filter",{disabled:this._blocked()}),this.options.allowGroups&&e<Number(this.options.maxDepth)?$t("add-group",t.id,"folder","Add subgroup",{disabled:this._blocked()}):null,i?null:$t("remove",t.id,"trash","Remove group",{disabled:this._blocked()}));return l(i?"fieldset":"li",{class:"zx-filter__group",dataset:{nodeId:t.id,depth:String(e)}},i?o:l("fieldset",{},o,n,a),i?n:null,i?a:null)}_renderCondition(t){let e=this._field(t.field),i=this._operatorsFor(e),n=this._operator(t.operator),r=l("select",{class:"zx-filter__field",dataset:{filterField:"",nodeId:t.id},ariaLabel:"Filter field",disabled:this._blocked()},l("option",{value:"",selected:!t.field},"Choose a field\u2026"),this._fields.map(a=>l("option",{value:a.id,selected:a.id===t.field},a.label)),t.field&&!e?l("option",{value:t.field,selected:!0},`Unavailable: ${t.field}`):null),o=l("select",{class:"zx-filter__operator",dataset:{filterOperator:"",nodeId:t.id},ariaLabel:"Filter operator",disabled:this._blocked()},l("option",{value:"",selected:!t.operator},"Choose an operator\u2026"),i.map(a=>l("option",{value:a.id,selected:a.id===t.operator},a.label)),t.operator&&!i.some(a=>a.id===t.operator)?l("option",{value:t.operator,selected:!0},`Unavailable: ${t.operator}`):null);return l("li",{class:"zx-filter__condition",dataset:{nodeId:t.id}},r,o,this._renderValue(t,e,n),$t("remove",t.id,"trash",`Remove ${e?.label??"filter"}`,{disabled:this._blocked()}))}_renderValue(t,e,i){let n=l("div",{class:"zx-filter__value"});if(!e||!i)return n;if(i.arity==="none")return l("div",{class:"zx-filter__value zx-filter__value--empty"},"No value");if(e.type==="custom"&&typeof e.editor=="function"){let a=this._renderVersion;return queueMicrotask(()=>{if(a!==this._renderVersion||!this.el.contains(n))return;let c=e.editor(n,{value:t.value,field:e,conditionId:t.id,setValue:h=>this._setNodeValue(t.id,Lc(h))});c&&typeof c.destroy=="function"&&this._customEditors.push(c)}),n}let r=i.arity==="pair"?Array.isArray(t.value)?t.value:[null,null]:[t.value];if(i.arity==="many"){let a=Fc(e,t,r[0],!0,this._blocked());return a?l("div",{class:"zx-filter__value"},a):l("div",{class:"zx-filter__value"},Rc(e,t.id,Array.isArray(t.value)?t.value.join(", "):"",0,this._blocked(),!0))}let o=r.map((a,c)=>Fc(e,t,a,!1,this._blocked(),c)??Rc(e,t.id,a,c,this._blocked()));return l("div",{class:"zx-filter__value",dataset:{arity:i.arity}},o)}_handleChange(t){if(!this._canMutate())return;let e=t.target,i=e?.dataset.nodeId;if(!(!e||!i))if(e.dataset.filterField!==void 0){let n=gt(this._value.root,i);if(n?.kind!=="condition")return;n.field=e.value;let r=this._field(n.field);n.operator=this._defaultOperator(r)??"",n.value=null,this._abort(i),this._render(),this._changed("update",i),this.focus(i)}else if(e.dataset.filterOperator!==void 0){let n=gt(this._value.root,i);if(n?.kind!=="condition")return;n.operator=e.value,n.value=null,this._abort(i),this._render(),this._changed("update",i),queueMicrotask(()=>this.el.querySelector(`[data-node-id="${ae(i)}"] [data-filter-value]`)?.focus())}else if(e.dataset.filterLogic!==void 0){let n=gt(this._value.root,i);n?.kind==="group"&&(n.logic=e.value==="or"?"or":"and"),this._changed("update",i)}else e.dataset.filterValue!==void 0&&this._valueInput(e)}_handleInput(t){if(!this._canMutate())return;let e=t.target;if(!e||e.dataset.filterValue===void 0)return;this._valueInput(e);let i=e.dataset.nodeId,n=gt(this._value.root,i),r=n?.kind==="condition"?this._field(n.field):null;r?.loadChoices&&this._scheduleChoices(n.id,r,e.value)}_valueInput(t){let e=gt(this._value.root,t.dataset.nodeId);if(e?.kind!=="condition")return;let i=this._operator(e.operator),n=this._field(e.field);if(!i||!n)return;let r;if(t instanceof HTMLSelectElement&&t.multiple)r=Array.from(t.selectedOptions,o=>Cs(o.value,n.type));else if(i.arity==="many")r=t.value.split(",").map(o=>o.trim()).filter(Boolean).map(o=>Cs(o,n.type));else if(i.arity==="pair"){let o=Array.isArray(e.value)?[...e.value]:[null,null];o[Number(t.dataset.valueIndex)||0]=Cs(t.value,n.type),r=o}else r=Cs(t.value,n.type);this._setNodeValue(e.id,r)}_handleClick(t){let e=t.target?.closest?.("[data-filter-action]");if(!e||!this.el.contains(e))return;let i=e.dataset.filterAction,n=e.dataset.nodeId||null;i==="add"?this.addCondition(n):i==="add-group"?this.addGroup(n):i==="remove"&&n?this.remove(n):i==="clear"?this.clear():i==="apply"&&this.apply()}_setNodeValue(t,e){let i=gt(this._value.root,t);if(i?.kind!=="condition")return;i.value=e;let n=this.validate();this.el.dataset.valid=String(n.valid),this.el.querySelector(`[data-node-id="${ae(t)}"]`)?.toggleAttribute("data-invalid",n.errors.some(o=>o.nodeId===t)),this._changed("update",t)}_changed(t,e){let i=this.validate(),n=this.getValue();this.emit("change",{value:n,valid:i.valid,errors:i.errors,reason:t,nodeId:e}),this.options.autoApply&&i.valid&&this.emit("apply",{value:n})}_scheduleChoices(t,e,i){if(this._abort(t),i.length<Number(e.minQuery??0))return;let n=new AbortController;this._setAsyncBusy(t,!0);let r={controller:n,timer:setTimeout(async()=>{this.emit("query",{conditionId:t,fieldId:e.id,query:i});try{let o=await e.loadChoices({query:i,signal:n.signal,conditionId:t,field:e});if(n.signal.aborted||this._async.get(t)?.controller!==n)return;let c=this.el.querySelector(`[data-node-id="${ae(t)}"] [data-filter-value]`)?.getAttribute("list"),h=c?this.el.querySelector(`#${ae(c)}`):null;h&&h.replaceChildren(...(Array.isArray(o)?o:[]).map(d=>l("option",{value:d.value},d.label))),this.emit("loaded",{conditionId:t,fieldId:e.id,query:i,choices:o})}catch(o){n.signal.aborted||this.emit("error",{conditionId:t,fieldId:e.id,query:i,error:o instanceof Error?o:new Error(String(o))})}finally{this._async.get(t)?.controller===n&&(this._async.delete(t),this._setAsyncBusy(t,!1))}},Math.max(0,Number(e.debounce??200)))};this._async.set(t,r)}_abort(t){let e=this._async.get(t);e&&(clearTimeout(e.timer),e.controller.abort(),this._async.delete(t),this._setAsyncBusy(t,!1))}_setAsyncBusy(t,e){let i=this.el.querySelector(`[data-node-id="${ae(t)}"] [data-filter-value]`);e?i?.setAttribute("aria-busy","true"):i?.removeAttribute("aria-busy")}_abortTree(t){t.kind==="condition"?this._abort(t.id):t.children.forEach(e=>this._abortTree(e))}_abortAll(){for(let t of[...this._async.keys()])this._abort(t)}_destroyEditors(){for(let t of this._customEditors??[])t.destroy?.();this._customEditors=[]}_blocked(){return this._readonly||this._disabled}_canMutate(){return!this._blocked()}_limits(){return{maxDepth:Number(this.options.maxDepth),maxConditions:Number(this.options.maxConditions)}}_field(t){return this._fields.find(e=>e.id===t)??null}_operator(t){return this._operators.find(e=>e.id===t)??null}_operatorsFor(t){if(!t)return[];let e=t.operators?.length?t.operators:null;return this._operators.filter(i=>e?e.includes(i.id):i.types.includes(t.type))}_defaultOperator(t){return t?.defaultOperator&&this._operatorsFor(t).some(e=>e.id===t.defaultOperator)?t.defaultOperator:this._operatorsFor(t)[0]?.id??null}_announce(t){this.refs.status&&(this.refs.status.textContent=t)}};function $t(s,t,e,i,n={}){return l("button",{type:"button",class:["zx-button","zx-button--sm",n.class].filter(Boolean),...n,dataset:{filterAction:s,nodeId:t}},g(e,{size:13}),l("span",{},i))}function Fc(s,t,e,i,n,r=0){let o=Array.isArray(s.choices)&&s.choices.length?s.choices:s.type==="boolean"?[{value:!0,label:"True"},{value:!1,label:"False"}]:null;if(!o)return null;let a=new Set(Array.isArray(e)?e.map(String):[String(e??"")]);return l("select",{dataset:{filterValue:"",nodeId:t.id,valueIndex:String(r)},ariaLabel:`${s.label} value`,multiple:i,disabled:n},i?null:l("option",{value:"",selected:!a.has(String(e))||e==null},"Choose\u2026"),o.map(c=>l("option",{value:c.value,selected:a.has(String(c.value))},c.label)))}function Rc(s,t,e,i,n,r=!1){let o=r?"text":["number","money"].includes(s.type)?"number":s.type==="date"?"date":s.type==="datetime"?"datetime-local":"text",a=s.loadChoices?`zx-filter-choices-${t}-${i}`:null,c=l("input",{type:o,value:e??"",dataset:{filterValue:"",nodeId:t,valueIndex:String(i)},ariaLabel:`${s.label} value${i?` ${i+1}`:""}`,disabled:n,placeholder:r?"Comma-separated values":"",list:a});return l("span",{class:"zx-filter__value-control"},c,a?l("datalist",{id:a}):null)}function Cs(s,t){if(s==="")return null;if(["number","money"].includes(t)){let e=Number(s);return Number.isFinite(e)?e:null}return t==="boolean"?s==="true":s}function Lc(s){return jr(s===void 0?null:s)}function gt(s,t){if(!s||s.id===t)return s??null;if(s.kind==="group")for(let e of s.children){let i=gt(e,t);if(i)return i}return null}function Ur(s,t){let e=gt(s,t);return e?.kind==="group"?e:null}function Wr(s,t){if(s?.kind!=="group")return null;if(s.children.some(e=>e.id===t))return s;for(let e of s.children){let i=Wr(e,t);if(i)return i}return null}function Pc(s,t){if(s.kind!=="group")return null;let e=s.children.findIndex(i=>i.id===t);if(e>=0)return s.children.splice(e,1)[0];for(let i of s.children){let n=Pc(i,t);if(n)return n}return null}function bm(s,t){return!!(s&>(s,t))}function Vc(s){return s.kind==="condition"?1:s.children.reduce((t,e)=>t+Vc(e),0)}function Bc(s,t,e=0){if(s.id===t)return e;if(s.kind==="group"){for(let i of s.children)if(i.kind==="group"){let n=Bc(i,t,e+1);if(n>=0)return n}}return-1}function ym(s,t){let e=new Map(s.map(i=>[i.id,{...i,types:[...i.types]}]));for(let i of Array.isArray(t)?t:[])i?.id&&e.set(String(i.id),{...i,id:String(i.id),types:Array.isArray(i.types)?[...i.types]:[]});return[...e.values()]}function ae(s){return globalThis.CSS?.escape?CSS.escape(s):String(s).replaceAll(/[^a-zA-Z0-9_-]/g,"\\$&")}var ke=class extends b{static cssName="fieldset";static defaults={title:"",columns:1,fields:{}};render(){let t=this.el??l("fieldset");this._fields=new Map,this._ownedFields=new Set,this._origins=new Map,this._fieldIdAttributes=new Map,this._ownedNodes=[],this._columnAttribute=t.getAttribute("data-columns");let e=[1,2,3].includes(Number(this.options.columns))?Number(this.options.columns):1;if(t.dataset.columns=String(e),this.options.title){let n=l("legend",{class:"zx-fieldset__legend"},String(this.options.title));this._ownedNodes.push(n),t.append(n)}this._grid=l("div",{class:"zx-fieldset__grid"}),this._ownedNodes.push(this._grid),t.append(this._grid);let i=this.options.fields&&typeof this.options.fields=="object"?this.options.fields:{};for(let[n,r]of Object.entries(i))this.addField(n,r);return t}addField(t,e){let i=String(t);if(this._fields.has(i))throw new Error(`Field "${i}" already exists`);let n,r=!1;if(e instanceof C)n=e;else if(F(e)||e instanceof b){let o=e;n=new C(null,{id:i,type:"custom",label:i,value:vm(o),disabled:xm(o),adapter:()=>wm(o)}),r=!0}else{let o=e&&typeof e=="object"?e:{};n=new C(null,{...o,id:o.id??i}),r=!0}return r?this._ownedFields.add(n):this._origins.set(n,{parent:n.el.parentNode,next:n.el.nextSibling}),this._fields.set(i,n),this._fieldIdAttributes.set(n,n.el.getAttribute("data-field-id")),n.el.dataset.fieldId=i,this._grid.append(n.el),n}getField(t){return this._fields.get(String(t))??null}hasField(t){return this._fields.has(String(t))}getFields(){return Object.fromEntries(this._fields)}getValues(){let t={};for(let[e,i]of this._fields)t[e]=i.getValue();return t}setValues(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[i,n]of Object.entries(t))this._fields.get(i)?.setValue(n,{silent:e});return this}getValue(t){return this._fields.get(String(t))?.getValue()??null}setValue(t,e){return this._fields.get(String(t))?.setValue(e),this}reset(){for(let t of this._fields.values())t.reset();return this}clear(){for(let t of[...this._fields.values()])this._releaseField(t);return this._fields.clear(),this}focus(t){return this._fields.get(String(t))?.focus(),this}setHighlights(t={},e="danger"){let i=0;for(let[n,r]of this._fields){let o=t?.[n];o?(r.setHighlight(String(o),e),i+=1):r.clearHighlight()}return i}clearHighlights(){for(let t of this._fields.values())t.clearHighlight();return this}_releaseField(t){let e=this._fieldIdAttributes.get(t);if(e==null?t.el.removeAttribute("data-field-id"):t.el.setAttribute("data-field-id",e),this._fieldIdAttributes.delete(t),this._ownedFields.has(t)){t.destroy(),this._ownedFields.delete(t);return}let i=this._origins.get(t);i?.parent?i.parent.insertBefore(t.el,i.next?.parentNode===i.parent?i.next:null):t.el.remove(),this._origins.delete(t)}destroy(){this.clear();for(let t of this._ownedNodes??[])t.remove();this._columnAttribute===null?this.el.removeAttribute("data-columns"):this.el.setAttribute("data-columns",this._columnAttribute),super.destroy()}};function wm(s){let t=F(s)?s:s.toElement(),e=t.parentNode,i=t.nextSibling,n=new Map(["id","aria-labelledby","aria-describedby","aria-disabled","aria-invalid"].map(a=>[a,t.getAttribute(a)])),r="disabled"in t?t.disabled:void 0,o="value"in t?t.value:void 0;return{el:t,get:()=>typeof s.getValue=="function"?s.getValue():typeof s.getValues=="function"?s.getValues():"value"in t?t.value:null,set:(a,c)=>{typeof s.setValue=="function"?s.setValue(a,c):typeof s.setValues=="function"&&a&&typeof a=="object"?s.setValues(a,c):"value"in t&&(t.value=a??"")},focus:()=>{typeof s.focus=="function"?s.focus():typeof t.focus=="function"&&t.focus()},setDisabled:a=>{typeof s.setDisabled=="function"?s.setDisabled(a):"disabled"in t?t.disabled=a:t.setAttribute("aria-disabled",String(a))},destroy:()=>{for(let[a,c]of n)c===null?t.removeAttribute(a):t.setAttribute(a,c);r!==void 0&&(t.disabled=r),o!==void 0&&(t.value=o),e?e.insertBefore(t,i?.parentNode===e?i:null):t.remove()}}}function vm(s){let t=F(s)?s:s.toElement();return typeof s.getValue=="function"?s.getValue():typeof s.getValues=="function"?s.getValues():"value"in t?t.value:null}function xm(s){let t=F(s)?s:s.toElement();return"disabled"in t?!!t.disabled:t.getAttribute("aria-disabled")==="true"}var Qr=class extends b{static cssName="form";static defaults={fieldsets:[],actions:[],novalidate:!0,msg:{"form.required":"This field is required.","form.int":"Enter a whole number.","form.float":"Enter a valid number."}};render(){let t=this.el??l("form");this._fieldsets=[],this._ownedFieldsets=new Set,this._origins=new Map,this._ownedNodes=[],this._novalidateAttribute=t.getAttribute("novalidate"),t.toggleAttribute("novalidate",!!this.options.novalidate),this._body=l("div",{class:"zx-form__body"}),this._actions=l("div",{class:"zx-form__actions"}),this._ownedNodes.push(this._body,this._actions),t.append(this._body,this._actions),this.listen(t,"submit",i=>{i.preventDefault(),this.submit()}),this.listen(t,"reset",i=>{i.preventDefault(),this.reset()}),this.listen(this._actions,"click",i=>this._handleAction(i));let e=Array.isArray(this.options.fieldsets)?this.options.fieldsets:[];for(let i of e)this.addFieldset(i);return this.setActions(Array.isArray(this.options.actions)?this.options.actions:[]),t}addFieldset(t){let e=!(t instanceof ke),i=e?new ke(null,t??{}):t;return this._fieldsets.includes(i)||(e?this._ownedFieldsets.add(i):this._origins.set(i,{parent:i.el.parentNode,next:i.el.nextSibling}),this._fieldsets.push(i),this._body.append(i.el),this.listen(i.el,"zx-change",n=>{let r=n.target,o=r instanceof Element?r.dataset.fieldId:null;o&&this.emit("change",{id:o,value:i.getValue(o)})})),i}setActions(t){return this._actionDescriptors=Array.isArray(t)?t.map(e=>({...e})):[],this._actions.replaceChildren(...this._actionDescriptors.map((e,i)=>{let n=String(e.label??e.id??"Action");return l("button",{class:"zx-btn",type:["submit","reset"].includes(e.type)?e.type:"button",disabled:!!e.disabled,title:e.title,ariaLabel:!n&&e.title?e.title:void 0,dataset:{actionIndex:i,kind:["primary","danger","ghost"].includes(e.kind)?e.kind:"default",size:e.size==="sm"?"sm":"md"}},e.icon?g(e.icon,{size:16}):null,n?l("span",{class:"zx-btn__label"},n):null)})),this._actions.hidden=this._actionDescriptors.length===0,this}getValues(){return Object.assign({},...this._fieldsets.map(t=>t.getValues()))}setValues(t,{silent:e=!1}={}){for(let i of this._fieldsets)i.setValues(t,{silent:e});return this}getField(t){for(let e of this._fieldsets){let i=e.getField(t);if(i)return i}return null}setValue(t,e){return this.getField(t)?.setValue(e),this}getValue(t){return this.getField(t)?.getValue()??null}reset(){for(let t of this._fieldsets)t.reset().clearHighlights();return this}setHighlights(t,e="danger"){return this._fieldsets.reduce((i,n)=>i+n.setHighlights(t,e),0)}clearHighlights(){for(let t of this._fieldsets)t.clearHighlights();return this}submit(){let t={},e=null;for(let n of this._fieldsets)for(let[r,o]of Object.entries(n.getFields())){let a=o.getValue(),c="";if(o.options.required&&Gr(a))c=this.msg("form.required");else if(!Gr(a)&&o.options.type==="int"){let h=Ms(a);h.valid?o.setValue(h.value,{silent:!0}):c=this.msg("form.int")}else if(!Gr(a)&&o.options.type==="float"){let h=Ns(a);h.valid?o.setValue(h.value,{silent:!0}):c=this.msg("form.float")}c?(t[r]=c,o.setHighlight(c,"danger"),e??=o):o.clearHighlight()}return Object.keys(t).length?(this.emit("invalid",{errors:t}),e?.focus(),!1):!this.emit("submit",{values:this.getValues()}).defaultPrevented}_handleAction(t){let e=t.target instanceof Element?t.target.closest("[data-action-index]"):null;if(!e||!this._actions.contains(e))return;let i=this._actionDescriptors[Number(e.dataset.actionIndex)],n=i?.onClick??i?.onclick??i?.handler;typeof n=="function"&&n(t,this)}destroy(){for(let t of this._fieldsets??[])if(this._ownedFieldsets.has(t))t.destroy();else{let e=this._origins.get(t);e?.parent?e.parent.insertBefore(t.el,e.next?.parentNode===e.parent?e.next:null):t.el.remove()}this._fieldsets=[];for(let t of this._ownedNodes??[])t.remove();this._novalidateAttribute===null?this.el.removeAttribute("novalidate"):this.el.setAttribute("novalidate",this._novalidateAttribute),super.destroy()}};function Gr(s){return s==null||s===""||s===!1||Array.isArray(s)&&s.length===0}var Ts="123456789abcdefghijklmnopqrstuvwxyz";function Hc(s){if(!Array.isArray(s))throw new TypeError("Questionnaire items must be an array");let t=new Set;return s.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Each questionnaire item must be an object");if(typeof e.name!="string"||e.name.trim()==="")throw new TypeError("Each questionnaire item needs a non-empty string name");let i=e.name;if(t.has(i))throw new TypeError(`Item already exists: ${i}`);t.add(i);let n=Sm(e.choices??[],i),r=e.field&&typeof e.field=="object"?{...e.field}:null,o=Am(e.input);if(n.length===0&&!r&&!o)throw new TypeError(`Item "${i}" needs choices, an input, or a field`);return{name:i,prompt:String(e.prompt??i),description:e.description==null||e.description===""?null:String(e.description),section:e.section==null?"":String(e.section),required:!!e.required,multiple:!!e.multiple,skippable:!!e.skippable,choices:n,input:o,field:r,when:typeof e.when=="function"?e.when:null,next:typeof e.next=="function"||typeof e.next=="string"&&e.next?e.next:null,validate:typeof e.validate=="function"?e.validate:null}})}function Sm(s,t=""){if(!Array.isArray(s))throw new TypeError("Questionnaire choices must be an array");let e=new Set,i=s.map(o=>{if(!o||typeof o!="object"||Array.isArray(o))throw new TypeError("Each questionnaire choice must be an object");if(o.value==null||o.value==="")throw new TypeError(`Each choice of "${t}" needs a value`);let a=typeof o.value=="number"?o.value:String(o.value),c=String(a);if(e.has(c))throw new TypeError(`Choice already exists in "${t}": ${c}`);return e.add(c),{value:a,label:String(o.label??a),description:o.description==null||o.description===""?null:String(o.description),icon:o.icon==null||o.icon===""?null:String(o.icon),key:typeof o.key=="string"&&o.key?o.key.slice(0,1).toLowerCase():"",disabled:!!o.disabled,exclusive:!!o.exclusive}}),n=new Set(i.map(o=>o.key).filter(Boolean)),r=0;for(let o of i)if(!o.key){for(;r<Ts.length&&n.has(Ts[r]);)r+=1;if(r>=Ts.length)break;o.key=Ts[r],n.add(o.key),r+=1}return i}function km(s,t){if(typeof s.when!="function")return!0;try{return s.when(t)!==!1}catch{return!0}}function Ot(s,t){let e={},i=[];for(let n of s)km(n,e)&&(i.push(n),Object.prototype.hasOwnProperty.call(t,n.name)&&(e[n.name]=t[n.name]));return{answers:e,visible:i}}function Ds(s,t,e){let{answers:i,visible:n}=Ot(s,e),r=new Set(n.map(c=>c.name)),o=null;if(typeof t.next=="string")o=t.next;else if(typeof t.next=="function"){let c=t.next(i[t.name],i);o=c==null||c===""?null:String(c)}let a=s.indexOf(t);if(o!==null){let c=s.findIndex(h=>h.name===o);if(c<0)throw new RangeError(`Unknown questionnaire item: ${o}`);if(r.has(o))return o;a=c}for(let c=a+1;c<s.length;c+=1)if(r.has(s[c].name))return s[c].name;return null}function le(s){return s==null?!0:typeof s=="string"?s.trim()==="":Array.isArray(s)?s.every(t=>le(t)):!1}function qc(s,t,e){return!s.required||!le(t)?null:e(s.choices.length>0?"questionnaire.required":"questionnaire.requiredInput")}function jc(s,t,e=null){let i=new Set(t.map(r=>String(r))),n=new Set(s.filter(r=>r.exclusive).map(r=>String(r.value)));return n.size>0&&e!==null&&i.has(String(e))&&(n.has(String(e))?i.forEach(r=>r!==String(e)&&i.delete(r)):n.forEach(r=>i.delete(r))),s.filter(r=>i.has(String(r.value))).map(r=>r.value)}function $c(s,t,e){let{answers:i,visible:n}=Ot(s,t),r=new Map(n.map(f=>[f.name,f])),o=e.filter(f=>r.has(f)),a=o.length>0?r.get(o[o.length-1]):null,c=o.filter(f=>!le(i[f])).length,h=new Set(o),d=a?n.indexOf(a):-1,u=n.slice(d+1).filter(f=>!h.has(f.name)).length,p=o.length+u;return{index:Math.max(0,o.length-1),answered:c,total:p,percent:p===0?0:Math.round(c/p*100),section:a?.section??""}}function Am(s){if(!s)return null;let t=typeof s=="object"&&!Array.isArray(s)?s:{};return{label:String(t.label??"Other"),placeholder:String(t.placeholder??""),multiline:!!t.multiline,maxLength:Math.max(0,Number(t.maxLength)||0)}}var zm=260,Xr=class extends b{static cssName="questionnaire";static defaults={items:[],answers:{},active:null,progress:!0,review:!1,advance:"manual",shortcuts:!0,allowBack:!0,msg:{"questionnaire.next":"Continue","questionnaire.previous":"Back","questionnaire.skip":"Skip","questionnaire.submit":"Submit","questionnaire.review":"Review answers","questionnaire.reviewTitle":"Check your answers","questionnaire.edit":"Edit","questionnaire.counter":"Question %1 of %2","questionnaire.required":"Choose an answer to continue.","questionnaire.requiredInput":"Enter an answer to continue.","questionnaire.noAnswer":"Skipped","questionnaire.empty":"There is nothing to answer."}};render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._items=[],this._selected=new Map,this._freeform=new Map,this._fields=new Map,this._path=[],this._status="asking",this._returnToReview=!1,this._busy=!1,this._error="",this._advanceTimer=0,this._uid=x("zx-questionnaire");let t=this.el??l("form");if(this.el=t,this._form=t.localName==="form"?t:l("form",{class:"zx-questionnaire__form"}),this._form.setAttribute("novalidate",""),this._progressHost=l("div",{class:"zx-questionnaire__progress",hidden:!this.options.progress}),this._itemHost=l("fieldset",{class:"zx-questionnaire__item",tabIndex:-1}),this._reviewHost=l("div",{class:"zx-questionnaire__review",tabIndex:-1,hidden:!0}),this._actionsHost=l("div",{class:"zx-questionnaire__actions"}),this.refs.item=this._itemHost,this.refs.review=this._reviewHost,this.refs.actions=this._actionsHost,this._bar=new Ze(null,{max:100,value:0,size:"sm",showValue:!1}),this._progressHost.append(this._bar.el),this._back=this._action("previous",this.msg("questionnaire.previous"),"chevron-left","default"),this._skip=this._action("skip",this.msg("questionnaire.skip"),null,"ghost"),this._forward=this._action("next",this.msg("questionnaire.next"),"chevron-right","primary"),this._actionsHost.append(this._back,l("span",{class:"zx-questionnaire__spacer"}),this._skip,this._forward),this._form.replaceChildren(this._progressHost,this._itemHost,this._reviewHost,this._actionsHost),this._form!==t&&t.replaceChildren(this._form),this.listen(this._form,"submit",e=>{e.preventDefault(),this.next()}),this.listen(this._itemHost,"change",e=>this._onControlChange(e)),this.listen(this._itemHost,"input",e=>this._onFreeformInput(e)),this.listen(this._actionsHost,"click",e=>this._onActionClick(e)),this.listen(this._reviewHost,"click",e=>this._onReviewClick(e)),this.listen(t,"keydown",e=>this._onKeydown(e)),this.setItems(this.options.items),this.options.answers&&typeof this.options.answers=="object"&&this.setAnswers(this.options.answers,{silent:!0}),this.options.active!=null){let e=String(this.options.active);Ot(this._items,this._rawAnswers()).visible.some(n=>n.name===e)&&(this._path=[e])}return this._paint(),t}setItems(t){let e=this.getActive(),i=Hc(t),n=new Set(i.map(a=>a.name));this._items=i;for(let a of[this._selected,this._freeform])for(let c of[...a.keys()])n.has(c)||a.delete(c);for(let[a,c]of[...this._fields])n.has(a)||(c.destroy(),this._fields.delete(a));let r=Ot(i,this._rawAnswers()).visible,o=this._path.filter(a=>r.some(c=>c.name===a));return e&&o[o.length-1]===e?this._path=o:this._path=r.length>0?[r[0].name]:[],this._status="asking",this._returnToReview=!1,this._error="",this._paint(),this}getItems(){return this._items.map(t=>({...t,choices:t.choices.map(e=>({...e})),input:t.input?{...t.input}:null}))}goTo(t){let e=this._items.find(r=>r.name===t);if(!e)throw new RangeError(`Unknown questionnaire item: ${t}`);if(!Ot(this._items,this._rawAnswers()).visible.includes(e))return!1;let n=this._returnToReview;return this._returnToReview=n||this._status==="review",this._navigate(t,"goto")?!0:(this._returnToReview=n,!1)}async next(){if(this._busy||this._status==="complete")return!1;if(this._status==="review")return this.submit();if(!await this._validateActive()||this._destroyed)return!1;if(this._returnToReview)return this._returnToReview=!1,this._enterReview();let t=this._activeItem(),e=t?Ds(this._items,t,this._rawAnswers()):null;return e?this._navigate(e,"next"):this.options.review?this._enterReview():this.submit()}previous(){if(this._busy)return!1;if(this._status==="review"||this._status==="complete"){let n=this._path[this._path.length-1];return!n||this.emit("navigate",{from:null,to:n,reason:"previous"}).defaultPrevented?!1:(this._status="asking",this._returnToReview=!1,this._error="",this._paint(),this._focusItem(),!0)}if(!this.options.allowBack||this._path.length<=1)return!1;let t=this.getActive(),e=this._path[this._path.length-2];return this.emit("navigate",{from:t,to:e,reason:"previous"}).defaultPrevented?!1:(this._path.pop(),this._returnToReview=!1,this._error="",this._paint(),this._focusItem(),!0)}async skip(){let t=this._activeItem();if(!t||!t.skippable||this._busy)return!1;if(this.setAnswer(t.name,null,{silent:!0}),this.emit("skip",{name:t.name}),this._returnToReview)return this._returnToReview=!1,this._enterReview();let e=Ds(this._items,t,this._rawAnswers());return e?this._navigate(e,"skip"):this.options.review?this._enterReview():this.submit()}async submit(){if(this._busy||this._status==="complete"||this._status!=="review"&&!await this._validateActive()||this._destroyed)return!1;let t={answers:this.getAnswers(),path:this.getPath()};return this.emit("submit",t).defaultPrevented?!1:(this._status="complete",this._paint(),this.emit("complete",{answers:t.answers,path:t.path}),!0)}getAnswers(){return Ot(this._items,this._rawAnswers()).answers}getAnswer(t){let e=this._items.find(i=>i.name===t);return e?this._answerOf(e):null}setAnswers(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[i,n]of Object.entries(t))this._items.some(r=>r.name===i)&&this.setAnswer(i,n,{silent:!0});if(this._paint(),!e){let i=this.getAnswers();for(let n of Object.keys(t))n in i&&this.emit("change",{name:n,value:i[n],answers:i})}return this}setAnswer(t,e,{silent:i=!1}={}){let n=this._items.find(r=>r.name===t);if(!n)throw new RangeError(`Unknown questionnaire item: ${t}`);if(n.field)this._field(n).setValue(e===void 0?null:e,{silent:!0});else{let r=Array.isArray(e)?e:e==null||e===""?[]:[e],o=new Set(r.map(c=>String(c))),a=n.choices.filter(c=>o.has(String(c.value)));for(let c of a)o.delete(String(c.value));this._selected.set(t,a.map(c=>c.value)),this._freeform.set(t,n.input?[...o][0]??"":"")}return this._paint(),i||this._emitChange(n),this}getActive(){return this._status!=="asking"?null:this._path[this._path.length-1]??null}getPath(){return[...this._path]}getProgress(){return $c(this._items,this._rawAnswers(),this._path)}getState(){return{active:this.getActive(),status:this._status,answers:this.getAnswers(),path:this.getPath(),progress:this.getProgress()}}toFormData(){let t=new FormData;for(let[e,i]of Object.entries(this.getAnswers()))if(Array.isArray(i))for(let n of i)t.append(e,String(n));else i instanceof File||i instanceof Blob?t.append(e,i):t.append(e,i==null?"":String(i));return t}reset(){this._selected.clear(),this._freeform.clear();for(let[e,i]of this._fields){let n=this._items.find(r=>r.name===e);i.setValue(n?.field?.value??null,{silent:!0})}let t=Ot(this._items,this._rawAnswers()).visible;return this._path=t.length>0?[t[0].name]:[],this._status="asking",this._returnToReview=!1,this._error="",this._paint(),this}focus(){return this._focusItem(),this}destroy(){if(!this._destroyed){this._destroyed=!0,clearTimeout(this._advanceTimer);for(let t of this._fields.values())t.destroy();this._fields.clear(),this._bar?.destroy(),super.destroy(),this._createdRoot||k(this.el,this._snapshot)}}_activeItem(){let t=this._path[this._path.length-1];return this._items.find(e=>e.name===t)??null}_rawAnswers(){let t={};for(let e of this._items){let i=this._answerOf(e);le(i)||(t[e.name]=i)}return t}_answerOf(t){if(t.field)return this._fields.get(t.name)?.getValue()??null;let e=this._selected.get(t.name)??[],i=(this._freeform.get(t.name)??"").trim();return t.multiple?i?[...e,i]:[...e]:i||(e.length>0?e[0]:null)}_field(t){let e=this._fields.get(t.name);if(e)return e;let i=t.field??{};return e=new C(null,{...i,label:i.label??t.prompt,required:t.required}),e.el.classList.add("zx-questionnaire__field"),i.label==null&&e.el.setAttribute("data-hide-label",""),e.on("change",()=>{this._error="",this._paintError(t),this._emitChange(t)}),this._fields.set(t.name,e),e}_navigate(t,e){let i=this.getActive();if(i===t&&this._status==="asking"||this.emit("navigate",{from:i,to:t,reason:e}).defaultPrevented)return!1;let n=this._path.indexOf(t);return n>=0?this._path=this._path.slice(0,n+1):this._path.push(t),this._status="asking",this._error="",this._paint(),this._focusItem(),!0}_enterReview(){return this.emit("navigate",{from:this.getActive(),to:null,reason:"review"}).defaultPrevented?!1:(this._status="review",this._error="",this._paint(),this._reviewHost.focus?.(),!0)}async _validateActive(){let t=this._activeItem();if(!t)return!0;let e=this._answerOf(t),i=qc(t,e,n=>this.msg(n));if(!i&&typeof t.validate=="function"){this._setBusy(!0);try{i=await t.validate(e,this.getAnswers())}catch(n){i=n instanceof Error?n.message:String(n)}finally{this._destroyed||this._setBusy(!1)}}return this._destroyed?!1:(this._error=i?String(i):"",this._paintError(t),this._error?(this.emit("invalid",{name:t.name,message:this._error}),this._focusControl(),!1):!0)}_setBusy(t){this._busy=t,t?this.el.setAttribute("aria-busy","true"):this.el.removeAttribute("aria-busy"),this._syncState(),this._paintActions()}_paint(){this._destroyed||(this._syncState(),this._paintProgress(),this._status==="review"?this._paintReview():this._paintItem(),this._itemHost.hidden=this._status==="review",this._reviewHost.hidden=this._status!=="review",this._paintActions())}_syncState(){this.el.dataset.state=this._busy?"checking":this._status}_paintProgress(){if(this._progressHost.hidden=!this.options.progress||this._items.length===0,this._progressHost.hidden)return;let t=this.getProgress(),e=this.msg("questionnaire.counter",t.index+1,Math.max(t.total,1));this._bar.setLabel(t.section?`${e} \xB7 ${t.section}`:e),this._bar.set(this._status==="asking"?t.percent:100,{silent:!0}),this._bar.setStatus(this._status==="complete"?"success":"active")}_paintItem(){let t=this._activeItem();if(this._itemHost.toggleAttribute("data-empty",!t),!t){this._itemHost.replaceChildren(l("p",{class:"zx-questionnaire__prompt"},this.msg("questionnaire.empty")));return}let e=`${this._uid}-prompt`,i=`${this._uid}-description`,n=`${this._uid}-error`,r=[l("legend",{class:"zx-questionnaire__prompt",id:e},t.prompt)];t.description&&r.push(l("p",{class:"zx-questionnaire__description",id:i},t.description)),r.push(t.field?this._field(t).el:this._choices(t)),r.push(l("p",{class:"zx-questionnaire__error",id:n,role:"alert",hidden:!0})),this._itemHost.replaceChildren(...r),this._itemHost.dataset.item=t.name,this._itemHost.setAttribute("aria-describedby",[t.description?i:"",n].filter(Boolean).join(" ")),this._paintError(t)}_choices(t){let e=new Set((this._selected.get(t.name)??[]).map(n=>String(n))),i=l("div",{class:"zx-questionnaire__choices"});if(i.append(...t.choices.map((n,r)=>l("label",{class:"zx-questionnaire__choice",dataset:{disabled:n.disabled?"true":null}},l("input",{type:t.multiple?"checkbox":"radio",class:"zx-questionnaire__control",name:t.name,value:String(n.value),checked:e.has(String(n.value)),disabled:n.disabled,dataset:{index:r}}),l("span",{class:"zx-questionnaire__marker",ariaHidden:"true"}),n.icon?g(n.icon,{size:16}):null,l("span",{class:"zx-questionnaire__text"},l("span",{class:"zx-questionnaire__label"},n.label),n.description?l("span",{class:"zx-questionnaire__hint"},n.description):null),n.key?l("kbd",{class:"zx-questionnaire__key",ariaHidden:"true"},n.key):null))),t.input){let n=`${this._uid}-freeform`,r=this._freeform.get(t.name)??"",o=l(t.input.multiline?"textarea":"input",{type:t.input.multiline?void 0:"text",class:"zx-questionnaire__freeform-input",id:n,name:t.choices.length>0?`${t.name}__other`:t.name,placeholder:t.input.placeholder||void 0,maxLength:t.input.maxLength>0?t.input.maxLength:void 0,rows:t.input.multiline?3:void 0,autocomplete:"off",value:r});i.append(l("div",{class:"zx-questionnaire__freeform"},l("label",{class:"zx-questionnaire__freeform-label",htmlFor:n},t.input.label),o))}return i}_paintError(t){let e=this._itemHost.querySelector(".zx-questionnaire__error");e instanceof HTMLElement&&(e.textContent=this._error,e.hidden=!this._error),this._error?this._itemHost.setAttribute("aria-invalid","true"):this._itemHost.removeAttribute("aria-invalid");let i=t?.field?this._fields.get(t.name):null;i&&(this._error?i.setHighlight(this._error,"danger"):i.clearHighlight(),e instanceof HTMLElement&&(e.hidden=!0))}_paintReview(){let{answers:t,visible:e}=Ot(this._items,this._rawAnswers()),i=this._path.map(n=>e.find(r=>r.name===n)).filter(n=>!!n).map(n=>l("div",{class:"zx-questionnaire__answer"},l("dt",{class:"zx-questionnaire__answer-prompt"},n.prompt),l("dd",{class:"zx-questionnaire__answer-value",dataset:{empty:le(t[n.name])?"true":null}},this._formatAnswer(n,t[n.name])),W({label:this.msg("questionnaire.edit"),kind:"ghost",size:"sm"})));for(let[n,r]of i.entries()){let o=r.querySelector("button");o instanceof HTMLElement&&(o.dataset.edit=this._path[n])}this._reviewHost.replaceChildren(l("p",{class:"zx-questionnaire__review-title"},this.msg("questionnaire.reviewTitle")),l("dl",{class:"zx-questionnaire__answers"},...i))}_formatAnswer(t,e){if(le(e))return this.msg("questionnaire.noAnswer");let i=new Map(t.choices.map(r=>[String(r.value),r.label]));return(Array.isArray(e)?e:[e]).map(r=>i.get(String(r))??String(r)).join(", ")}_paintActions(){let t=this._activeItem(),e=this._status==="review",i=this._status==="complete",n=!1;try{n=!!t&&Ds(this._items,t,this._rawAnswers())!==null}catch{n=!1}this._back.hidden=i||!e&&(!this.options.allowBack||this._path.length<=1),this._back.disabled=this._busy,this._skip.hidden=e||i||!t?.skippable,this._skip.disabled=this._busy,this._forward.hidden=i,this._forward.disabled=this._busy||!t&&!e;let r=e?"submit":this._returnToReview||!n&&this.options.review?"review":n?"next":"submit";if(this._forward.dataset.role!==r){this._forward.dataset.role=r;let o=r==="next"?"chevron-right":r==="review"?"list":"check";this._forward.replaceChildren(g(o,{size:16}),l("span",{class:"zx-btn__label"},this.msg(`questionnaire.${r}`)))}}_action(t,e,i,n){let r=W({label:e,icon:i,kind:n});return r.dataset.action=t,r}_onControlChange(t){let e=t.target;if(!(e instanceof HTMLInputElement)||!e.classList.contains("zx-questionnaire__control"))return;let i=this._activeItem();if(!i)return;let n=i.choices[Number(e.dataset.index)];if(n){if(i.multiple){let r=[...this._itemHost.querySelectorAll(".zx-questionnaire__control")].filter(c=>c.checked).map(c=>i.choices[Number(c.dataset.index)].value),o=jc(i.choices,r,e.checked?n.value:null);this._selected.set(i.name,o);let a=new Set(o.map(c=>String(c)));for(let c of this._itemHost.querySelectorAll(".zx-questionnaire__control"))c.checked=a.has(c.value)}else{this._selected.set(i.name,[n.value]),this._freeform.set(i.name,"");let r=this._itemHost.querySelector(".zx-questionnaire__freeform-input");(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value="")}this._error="",this._paintError(i),this._paintProgress(),this._paintActions(),this._emitChange(i),this._maybeAutoAdvance(i)}}_onFreeformInput(t){let e=t.target;if(!((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.classList.contains("zx-questionnaire__freeform-input")))return;let n=this._activeItem();if(n){if(this._freeform.set(n.name,e.value),!n.multiple&&e.value.trim()!==""){this._selected.set(n.name,[]);for(let r of this._itemHost.querySelectorAll(".zx-questionnaire__control"))r.checked=!1}this._error="",this._paintError(n),this._paintProgress(),this._paintActions(),this._emitChange(n)}}_onActionClick(t){let e=t.target instanceof Element?t.target.closest("[data-action]"):null;!(e instanceof HTMLElement)||!this._actionsHost.contains(e)||(e.dataset.action==="previous"?this.previous():e.dataset.action==="skip"?this.skip():this.next())}_onReviewClick(t){let e=t.target instanceof Element?t.target.closest("[data-edit]"):null;e instanceof HTMLElement&&this.goTo(String(e.dataset.edit))}_onKeydown(t){if(t.defaultPrevented||t.ctrlKey||t.metaKey||t.altKey)return;let e=t.target,i=e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!["radio","checkbox"].includes(e.type)||e instanceof HTMLElement&&e.isContentEditable;if(t.key==="Enter"){if(e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement)return;t.preventDefault(),this.next();return}if(!this.options.shortcuts||i||t.key.length!==1)return;let n=this._activeItem();if(!n||this._status!=="asking")return;let r=t.key.toLowerCase(),o=n.choices.findIndex(c=>c.key===r&&!c.disabled);if(o<0)return;let a=this._itemHost.querySelector(`.zx-questionnaire__control[data-index="${o}"]`);a instanceof HTMLInputElement&&(t.preventDefault(),a.checked=n.multiple?!a.checked:!0,a.focus(),a.dispatchEvent(new Event("change",{bubbles:!0})))}_maybeAutoAdvance(t){this.options.advance!=="auto"||t.multiple||t.input||(clearTimeout(this._advanceTimer),this._advanceTimer=setTimeout(()=>{!this._destroyed&&this._activeItem()===t&&this.next()},zm))}_emitChange(t){let e=this.getAnswers();this.emit("change",{name:t.name,value:this._answerOf(t),answers:e})}_focusItem(){this._status==="asking"&&this._itemHost.focus?.()}_focusControl(){let t=this._activeItem(),e=t?.field?this._fields.get(t.name):null;if(e){e.focus();return}let i=this._itemHost.querySelector(".zx-questionnaire__control:not(:disabled), .zx-questionnaire__freeform-input");i instanceof HTMLElement?i.focus():this._focusItem()}};function Cm(){fa(),bo(),Qo(),Fo(),Yo(),xa(),Aa(),ia(),Jo(),Sa(),na(),ra(),ga(),_a()}Cm();export{$n as AccountMenu,Qi as AppIcon,Wn as AppSidebar,Tn as Aurora,ni as Avatar,Ln as Breadcrumb,rs as CALENDAR_VIEWS,ar as Calendar,Cn as Card,pr as CardView,Cr as Chart,Tr as ChartJsAdapter,Vt as CheckButton,wt as Checklist,b as Component,oi as ContextMenu,kn as CopyInput,Vr as DataFilter,Ut as DatePicker,Le as DateRangeBox,Re as DateRangePicker,Xs as DateTimeBox,Z as Datebox,Bt as Dialog,On as Dock,ut as Dropdown,C as Field,Pe as FieldUpload,ke as Fieldset,Yr as Filter,Or as Finder,Qr as Form,zr as Grid,Xt as Groupbox,Ni as Http,wn as InlineLoading,kr as KanbanView,qn as Launcher,In as MasterPanel,ft as MenuButton,Jn as Message,We as Modal,Ne as MonthPicker,Ve as MultiValueEditor,Fn as NavigationBar,Wt as NumberField,Vn as Pagination,Dn as Panel,Ze as ProgressBar,Xr as Questionnaire,He as Rating,mt as RecordView,Ge as Search,G as Select,Zn as Sheet,tr as SheetStack,qe as Slider,En as SplitView,Rn as Stepper,Qe as Tabbox,Dt as Table,fr as TableView,je as TagPicker,Me as TimePicker,Tt as Timebox,nt as Toggle,An as Toolbar,ee as Tooltip,Mr as TreeView,Ke as ValueList,eh as __,xr as absoluteKanbanIndex,O as addCalendarDays,er as addCalendarMonths,N as addDays,Lt as addMonths,ms as allowsKanbanTransition,kp as appIcon,sh as appendCompact,nh as appendCompactChild,ih as appendContent,so as applyCompactProperties,Lf as aspect,xl as avatarInitials,bn as badge,bf as badgeGroup,xc as billingColumns,en as breakpointOf,ue as breakpoints,W as button,uf as buttonGroup,xt as calendarDayDifference,Y as calendarDayKey,li as calendarEventIntersects,St as calendarEventSpansDays,sr as calendarPageDate,ir as calendarRange,Ac as chartSummaryTable,P as clamp,Rs as clampDate,Fe as clampRange,Ht as clampSize,K as cloneCalendarEvent,At as cloneChartValue,zs as cloneFilterAst,yi as compactElement,ki as configureIcons,Sn as copyButton,hn as copyToClipboard,wr as createKanbanHistory,Yc as debounce,ze as deepMerge,$o as defaultDateRangePresets,Zu as defineElements,Vp as describe,Qd as downloadBlob,Hr as emptyFilterAst,kf as emptyState,Ce as escapeRegExp,gr as evaluateKanbanMove,Ao as faFamilies,xi as faIconClasses,zo as faNames,Ps as faStyles,qr as filterCondition,$r as filterGroup,As as filterOperators,fh as fireCompactEvent,Js as focusTrap,on as formatCurrency,D as formatDate,Hd as formatFileSize,Qt as formatNumber,an as formatPercent,Uo as formatRangeText,qd as formatRelativeTime,rh as fragment,$s as getIconConfig,ot as getLanguage,Ee as getWeekStart,Rf as grid,Gc as groupBy,l as h,ah as highlightMatch,oh as htmlEscape,g as icon,Rh as iconNames,qs as icons,vs as isBillingLine,F as isElement,Ir as isEmptyChartData,j as isSameDay,tl as isTruncated,ya as joinTime,br as kanbanSearchTerms,Si as kitUrl,os as layoutCalendarSpans,nr as layoutTimedCalendarEvents,Oh as loadFontAwesome,Bs as loadFontAwesomeKit,gs as locateKanbanRecord,sn as matchBreakpoint,yr as matchesKanbanSearch,Ul as moveViewField,ie as normalizeAppItems,be as normalizeCalendarEvents,mr as normalizeKanbanRules,de as normalizeRange,hr as normalizeViewFields,Wl as normalizeViewState,uh as offCompactEvent,Ue as onBreakpoint,oo as onCompactEvent,_l as paginationRange,io as parseCompactTag,X as parseDate,Se as parseFilterAst,Vs as parseIconSpec,Ii as parseNumber,Qs as parseRangeText,nn as parseResult,st as position,V as printf,Oe as rangeNights,jo as rangeStateOf,jn as rankLauncherItems,tt as readViewField,hi as reconcileFieldOrder,Cm as registerFieldAdapters,Fh as registerIcons,hs as renderViewField,vr as reorderKanbanRecords,$a as reorderTableRows,U as resolveElement,_s as resolveKanbanRules,pt as resolveSize,Ct as rovingTabindex,mh as setLanguage,_h as setTranslator,ai as shiftCalendarEvent,xn as skeleton,Mf as skeletonTable,Ef as skeletonText,Ei as snapNumber,hl as snapSize,Qc as sortBy,Yl as sortViewRecords,yn as spinner,ba as splitTime,Ff as stack,$ as startOfCalendarDay,ns as startOfCalendarWeek,pa as stepPrecision,Ye as storage,mm as stringifyFilterAst,Wc as throttle,bi as toArray,Gd as toCsv,Pp as tooltip,yt as translate,Hf as truncate,lt as typeahead,x as uid,Xc as uniqueBy,Nh as useBuiltinIcons,Do as useFontAwesome,Kr as validateFilterAst,ye as viewRecordId,Md as zeyosService};
|
|
1
|
+
function Ru(s,t){let e=null;return function(...n){let r=this;e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,s.apply(r,n)},t)}}function Vu(s,t,{leading:e=!0,trailing:i=!0}={}){let n=Math.max(0,Number(t)||0),r=null,o=0,a=null,c=null,h=()=>{r=null,o=e?Date.now():0;let u=a,d=c;a=null,c=null,u!==null&&s.apply(d,u)};return function(...d){let p=Date.now();o===0&&!e&&(o=p);let f=n-(p-o);if(f<=0||f>n){r!==null&&(clearTimeout(r),r=null),o=p,a=null,c=null,s.apply(this,d);return}i&&(a=d,c=this,r===null&&(r=setTimeout(h,f)))}}var Wo=0;function x(s="zx"){return Wo+=1,`${s}-${Date.now().toString(36)}-${Wo.toString(36)}`}function Ve(s,t){let e=Re(s)?Xo(s):{};if(!Re(t))return Bi(t);for(let[i,n]of Object.entries(t))Re(n)&&Re(e[i])?e[i]=Ve(e[i],n):e[i]=Bi(n);return e}function T(s){return!!(s&&typeof s=="object"&&s.nodeType===1)}function Ht(s){if(typeof s!="string")return!1;let t=s.trim();if(!t||t.length>256||/[;{}\u0000-\u001f\u007f]/.test(t)||/(?:url|image|image-set|cross-fade|element|var)\s*\(/i.test(t))return!1;let e=globalThis.CSS?.supports;if(typeof e=="function")try{return e.call(globalThis.CSS,"color",t)}catch{return!1}return/^(?:#[\da-f]{3,8}|[a-z]+|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix)\([^;{}]+\))$/i.test(t)}function B(s,t,e){return Math.min(e,Math.max(t,s))}function ji(s){if(s==null)return[];if(Array.isArray(s))return s.slice();let t=s;return typeof s!="string"&&typeof t?.[Symbol.iterator]=="function"||typeof s!="string"&&typeof t?.length=="number"?Array.from(t):[s]}function Pu(s,t){let e=Pi(t),i=new Map;for(let n of ji(s)){let r=String(e(n)),o=i.get(r);o===void 0?i.set(r,[n]):o.push(n)}return Object.fromEntries(i)}function Bu(s,...t){let e=ji(s),i=t.map(Hu);return i.length===0?e:e.sort((n,r)=>{for(let o of i){let a=o(n,r);if(a!==0)return a}return 0})}function ju(s,t){let e=t==null?r=>r:Pi(t),i=new Set,n=[];for(let r of ji(s)){let o=e(r);i.has(o)||(i.add(o),n.push(r))}return n}function Pe(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pi(s){if(typeof s=="function")return s;let t=String(s);return e=>e?.[t]}function Hu(s){let t,e=1;if(typeof s=="function")t=s;else if(s!==null&&typeof s=="object")t=Pi(s.key),String(s.dir).toLowerCase()==="desc"&&(e=-1);else{let i=String(s);i.startsWith("-")?(e=-1,i=i.slice(1)):i.startsWith("+")&&(i=i.slice(1)),t=Pi(i)}return(i,n)=>{let r=t(i),o=t(n),a=Go(r),c=Go(o);return a||c?a&&c?0:a?1:-1:e*qu(r,o)}}function Go(s){return s==null||typeof s=="number"&&Number.isNaN(s)}function qu(s,t){return s instanceof Date||t instanceof Date?an(Qo(s)-Qo(t)):typeof s=="boolean"||typeof t=="boolean"?an(Number(s)-Number(t)):typeof s=="number"&&typeof t=="number"?an(s-t):String(s).localeCompare(String(t),void 0,{numeric:!0})}function Qo(s){if(s instanceof Date)return s.getTime();let t=Number(s);return Number.isFinite(t)?t:0}function an(s){return Number.isNaN(s)?0:s<0?-1:s>0?1:0}function Re(s){if(s===null||typeof s!="object")return!1;let t=Object.getPrototypeOf(s);return t===Object.prototype||t===null}function Xo(s){let t={};for(let[e,i]of Object.entries(s))t[e]=Bi(i);return t}function Bi(s){return Re(s)?Xo(s):Array.isArray(s)?s.map(Bi):s}var Be=null,$u=new Set(["href","id","lang","name","rel","src","target","title","value"]),je=new WeakMap;function Jo(s){if(typeof s!="string")throw new TypeError("DOM builder tag must be a string");let t=s,e="",i="",n=t.indexOf(".");return n!==-1&&(e=t.slice(n+1),t=t.slice(0,n)),n=t.indexOf("#"),n!==-1&&(i=t.slice(n+1),t=t.slice(0,n)),{tag:t||"div",id:i,className:e}}function Hi(s,t=null,e=null){let i=Jo(s),n=document.createElement(i.tag);if(i.id&&(n.id=i.id),i.className&&(n.className=i.className),i.tag==="a"){let r=n;r.rel="noopener",r.tabIndex=-1}else if(i.tag==="button")n.type="button";else if(i.tag==="input"||i.tag==="textarea"){let r=n;r.autocapitalize="none",r.autocomplete="off",r.autocorrect="off",r.spellcheck=!1}return t&&Zo(n,t),ed(n,e),n}var Ku=Hi;function V(s){if(typeof s!="string")return null;let t=s.trim();if(!t)return null;try{let e=new URL(t,globalThis.location?.href??"https://zx.invalid/").protocol;if(["javascript:","data:","vbscript:"].includes(e.toLowerCase()))return null}catch{return null}return t}function Zo(s,t){for(let e in t??{}){let i=t[e];if(i!=null)if(e[0]==="D")s.setAttribute(`data-${e.slice(1)}`,String(i));else if(e[0]==="S")s.style[e.slice(1)]=i;else if(e.startsWith("on")){if(typeof i!="function")throw new TypeError(`Compact DOM event ${e} must be a function`);ia(s,e.slice(2),i)}else typeof i=="boolean"||$u.has(e)?s[e]=i:s.setAttribute(e,String(i))}return s}function Uu(s,t){if(t==null)return s;let e=ea(t);return e==null||(typeof e=="object"?s.appendChild(e):s.appendChild(document.createTextNode(String(e)))),s}function Yu(s,t,e=null,i=null){return s.appendChild(Hi(t,e,i)),s}function Wu(s,t,e=null,i=null){let n=Hi(t,e,i);return s.appendChild(n),n}function Gu(...s){let t=document.createDocumentFragment();return ta(t,s),t}function l(s,t,...e){let i=document.createElement(s),n=t;Ju(n)||(e.unshift(n),n={});for(let[r,o]of Object.entries(n))Zu(i,r,o);return ta(i,e),i}l.scope=function(t,e){let i=Be;Be=t;try{return e()}finally{Be=i}};l.raw=function(t){let e=document.createElement("template");return e.innerHTML=String(t),e.content};function A(s){return{children:Array.from(s.childNodes),attributes:Array.from(s.attributes,t=>[t.name,t.value])}}function S(s,t){if(t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}}function Qu(s){return String(s).replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}function Xu(s,t,e={}){let{className:i="zx-mark"}=e,n=s==null?"":String(s),r=t==null?"":String(t).trim(),o=document.createDocumentFragment();if(r===""||n==="")return o.append(document.createTextNode(n)),o;let a=new RegExp(Pe(r),"gi"),c=0;for(let h of n.matchAll(a)){h.index>c&&o.append(document.createTextNode(n.slice(c,h.index)));let u=document.createElement("mark");i&&(u.className=String(i)),u.append(document.createTextNode(h[0])),o.append(u),c=h.index+h[0].length}return c<n.length&&o.append(document.createTextNode(n.slice(c))),o}function q(s){if(s==null)return null;if(T(s))return s;if(typeof s=="string")return document.querySelector(s);if(typeof s.toElement=="function"){let t=s.toElement();return T(t)?t:null}return null}function Ju(s){if(s===null||typeof s!="object"||Array.isArray(s))return!1;let t=s;return typeof t.nodeType=="number"?!1:typeof t.toElement!="function"}function Zu(s,t,e){if(t==="ref"){Be&&typeof e=="string"&&(Be[e]=s);return}if(t==="class"){s.className=Array.isArray(e)?e.flat(1/0).filter(Boolean).join(" "):String(e??"");return}if(t==="style"){if(typeof e=="string")s.style.cssText=e;else if(e&&typeof e=="object")for(let[n,r]of Object.entries(e))n.startsWith("--")||n.includes("-")?s.style.setProperty(n,String(r)):s.style[n]=r;return}if(t==="dataset"&&e&&typeof e=="object"){for(let[n,r]of Object.entries(e))r==null?delete s.dataset[n]:s.dataset[n]=String(r);return}if(/^on[a-z]/.test(t)&&typeof e=="function"){s.addEventListener(t.slice(2),e);return}if(e==null)return;let i=td(t);if(i!==null)s.setAttribute(i,String(e));else if(t in s)try{s[t]=e}catch{s.setAttribute(t,String(e))}else typeof e=="boolean"?e?s.setAttribute(t,""):s.removeAttribute(t):s.setAttribute(t,String(e))}function td(s){return s.startsWith("aria-")?s:/^aria[A-Z]/.test(s)?"aria-"+s.slice(4).toLowerCase():null}function ta(s,t){let e=s;for(let i of t.flat(1/0)){if(i==null)continue;if(typeof i=="string"||typeof i=="number"){e.append(document.createTextNode(String(i)));continue}if(typeof i!="object")continue;let n=i;if(typeof n.nodeType=="number")e.append(i);else if(typeof n.toElement=="function"){let r=n.toElement();r&&e.append(r)}}}function ed(s,t){if(t==null)return;let e=ea(t);e!=null&&(typeof e=="object"?s.appendChild(e):s.textContent=String(e))}function ea(s){if(s&&typeof s=="object"){if(typeof s.nodeType=="number")return s;if(typeof s.toElement=="function")return s.toElement()}return s}function ia(s,t,e,i=!1){if(typeof e!="function")throw new TypeError("Compact DOM event handler must be a function");let n=String(t),r=je.get(s);r||(r=new Map,je.set(s,r));let o=r.get(n);if(o)return o.handlers.push(e),s;let a=[e],c=h=>sa(s,a,h);r.set(n,{handlers:a,listener:c});try{s.addEventListener(n,c,{passive:i})}catch{s.addEventListener(n,c)}return s}function id(s,t,e){let i=String(t),n=je.get(s),r=n?.get(i);if(!r)return s;let o=r.handlers.indexOf(e);return o===-1||(r.handlers.splice(o,1),r.handlers.length===0&&(s.removeEventListener(i,r.listener),n.delete(i),n.size===0&&je.delete(s))),s}function sd(s,t,e=null){let i=String(t),n=je.get(s);if(!n?.has(i))return s;let r=e??nd(s,i),o=n.get(String(r.type));return o&&sa(s,o.handlers,r),s}function sa(s,t,e){let i=e,n=String(i.type).startsWith("key")?i.which:i.target;for(let r=t.length-1;r>=0;r-=1)t[r].call(s,e,n)===!1&&i.preventDefault()}function nd(s,t){let e={target:s,type:t,which:-1,defaultPrevented:!1,preventDefault(){e.defaultPrevented=!0}};return e}var ln=null,na="en";function rd(s){if(s!==null&&typeof s!="function")throw new TypeError("Translator must be a function or null");ln=s}function od(s){na=String(s||"en")}function lt(){return na}function vt(s,t){let e=ln?ln(s):s;return I(e==null?s:String(e),t)}function I(s,t){if(t==null)return String(s);let e=Array.isArray(t)?t:typeof t=="object"?null:[t],i=String(s).replace(/%(\d+)/g,(r,o)=>{let a=Number(o)-1,c;return e?c=e[a]:Object.prototype.hasOwnProperty.call(t,o)&&(c=t[o]),c==null?r:String(c)}),n=0;return i=i.replace(/%([A-Za-z_][\w.-]*)%/g,(r,o)=>{if(!e&&Object.prototype.hasOwnProperty.call(t,o)){let a=t[o];return a==null?r:String(a)}if(e&&n<e.length){let a=e[n];return n+=1,a==null?r:String(a)}return r}),i}var qi=new WeakMap,m=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#t=new AbortController;#e=!1;#i=!1;#s=!1;constructor(t,e={}){super();let i=this.constructor;this.#e=t===null;let n=q(t);if(t!==null&&!n)throw new TypeError("Component target could not be resolved");this.el=n,this.refs={};let r=ad(i,e),o=[];for(let[h,u]of Object.entries(r))/^on[a-z]/.test(h)&&typeof u=="function"&&(o.push([h.slice(2),u]),delete r[h]);r.msg&&typeof r.msg=="object"&&Object.freeze(r.msg),this.options=Object.freeze(r);for(let[h,u]of o)this.on(h,u);let a;try{a=l.scope(this.refs,()=>this.render())}catch(h){throw this.#t.abort(),h}if(this.#e){let h=T(a)?a:this.el;if(!T(h))throw this.#t.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=h}if(!T(this.el))throw this.#t.abort(),new TypeError("Component requires a root Element");let c=i.cssName;if(typeof c=="string"&&c){let h=`zx-${c}`;this.#s=!this.el.classList.contains(h),this.el.classList.add(h)}qi.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={},i={}){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("Event detail must be an object");let n=ra(t,e,{cancelable:!0});if(this.dispatchEvent(n),this.el){let r=ra(`zx-${t}`,e,{bubbles:!0,composed:!0,cancelable:!0});this.el.dispatchEvent(r),i.honorDomCancellation&&r.defaultPrevented&&n.preventDefault()}return n}listen(t,e,i,n={}){let r=typeof n=="boolean"?{capture:n}:{...n};return t.addEventListener(e,i,{...r,signal:this.#t.signal}),this}toElement(){return this.el}msg(t,...e){let i=this.options.msg,n=this.options.lang??this.options.language??lt(),r=i?.[n]?.[t];if(r!=null)return I(String(r),e);let o=i?.[t];return o!=null?I(String(o),e):vt(t,e)}destroy(){if(this.#i)return;this.#i=!0,this.#t.abort(),qi.get(this.el)===this&&qi.delete(this.el);let t=this.constructor.cssName;this.#s&&typeof t=="string"&&this.el&&this.el.classList.remove(`zx-${t}`),this.#e&&this.el&&this.el.remove()}static from(t){return qi.get(t)??null}};function ad(s,t){let e=[],i=s;for(;i&&i!==Function.prototype;)Object.prototype.hasOwnProperty.call(i,"defaults")&&e.unshift(i.defaults),i=Object.getPrototypeOf(i);let n={},r={},o=!1;for(let a of e)!a||typeof a!="object"||(Object.assign(n,a),a.msg&&typeof a.msg=="object"&&(o=!0,r=Ve(r,a.msg)));return Object.assign(n,t&&typeof t=="object"?t:{}),t?.msg&&typeof t.msg=="object"&&(o=!0,r=Ve(r,t.msg)),o&&(n.msg=r),n}function ra(s,t,e){if(typeof CustomEvent=="function")return new CustomEvent(s,{...e,detail:t});let i=new Event(s,e);return Object.defineProperty(i,"detail",{configurable:!0,enumerable:!0,value:t}),i}var C=class s extends m{static cssName="field";static defaults={id:null,type:"text",label:"",description:"",value:void 0,placeholder:"",required:!1,disabled:!1,options:null,layout:"stack",props:{},msg:{"field.int":"Enter a whole number.","field.float":"Enter a valid number.","field.unknown":"Unknown field type: %1"}};static#t=new Map;static register(t,e){let i=String(t).trim().toLowerCase();if(!i)throw new TypeError("Field adapter type must not be empty");if(typeof e!="function")throw new TypeError("Field adapter must be a function");return s.#t.set(i,e),this}static has(t){return s.#t.has(String(t).trim().toLowerCase())}render(){let t=this.el??l("div");this.el=t;let e=String(this.options.type||"text").toLowerCase(),i=this.options.layout==="inline"?"inline":"stack";this._ownedComponents=new Set,this._ownedNodes=[],this._rootAttributes=ud(t,["data-layout","data-field-type","data-disabled","data-state"]),t.dataset.layout=i,t.dataset.fieldType=e,this.controlId=this.options.id?String(this.options.id):x("zx-field");let n=`${this.controlId}-label`,r=`${this.controlId}-description`,o=`${this.controlId}-highlight`,a=l("label",{class:"zx-field__label",id:n,htmlFor:this.controlId},String(this.options.label??""),this.options.required?l("span",{class:"zx-field__required",ariaHidden:"true"}," *"):null),c=l("div",{class:"zx-field__control"}),h=l("div",{class:"zx-field__description",id:r},String(this.options.description??"")),u=l("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),d=l("div",{class:"zx-field__body"},c,h,u);this._ownedNodes.push(a,d),t.append(a,d);let p=s.#t.get(e);if(p)try{this.adapter=cd(p(this,this.options))}catch(_){let b=_ instanceof Error?_.message:String(_);console.warn(`[zx.Field] Adapter "${e}" failed: ${b}`),this.adapter=aa(b,this.controlId)}else{let _=this.msg("field.unknown",e);console.warn(`[zx.Field] ${_}`),this.adapter=aa(_,this.controlId)}let f=this.adapter.el;return f.id||(f.id=this.controlId),a.htmlFor=f.id,hd(f)||f.setAttribute("aria-labelledby",n),this._baseDescribedBy=f.getAttribute("aria-describedby")??"",c.append(f),this._descriptionId=String(this.options.description??"")?r:"",this._highlightId=o,this._highlight=u,this._syncDescription(),this.initialValue=ld(e,this.options.value),this.adapter.set(this.initialValue,{silent:!0}),this.setDisabled(!!this.options.disabled),this.listen(f,"change",()=>{this.emit("change",{value:this.getValue()})}),t}getValue(){return this.adapter.get()}setValue(t,{silent:e=!1}={}){return this.adapter.set(t,{silent:e}),e||this.emit("change",{value:this.getValue()}),this}focus(){return this.adapter.focus(),this}reset(){return this.setValue(this.initialValue,{silent:!0}),this.clearHighlight(),this}setDisabled(t){let e=!!t;return this.adapter.setDisabled(e),this.el.dataset.disabled=String(e),this}setHighlight(t,e="danger"){if(!t)return this.clearHighlight();let i=["danger","warning","success"].includes(e)?e:"danger";return this.el.dataset.state=i,this._highlight.textContent=String(t??""),this._highlight.hidden=!t,i==="danger"&&t?(this._highlight.setAttribute("role","alert"),this.adapter.el.setAttribute("aria-invalid","true"),this.emit("invalid",{message:String(t)})):(this._highlight.removeAttribute("role"),this.adapter.el.removeAttribute("aria-invalid")),this._syncDescription(!!t),this}clearHighlight(){return delete this.el.dataset.state,this._highlight.textContent="",this._highlight.hidden=!0,this._highlight.removeAttribute("role"),this.adapter.el.removeAttribute("aria-invalid"),this._syncDescription(!1),this}getInput(){return this.adapter.el}own(t){if(!(t instanceof m))throw new TypeError("Field.own() requires a Component");return this._ownedComponents.add(t),t}_syncDescription(t=!1){let e=[this._baseDescribedBy,this._descriptionId,t?this._highlightId:""].flatMap(i=>i.split(/\s+/)).filter(Boolean);e.length?this.adapter.el.setAttribute("aria-describedby",[...new Set(e)].join(" ")):this.adapter.el.removeAttribute("aria-describedby")}destroy(){this.adapter?.destroy?.();for(let t of this._ownedComponents??[])t.destroy();this._ownedComponents?.clear();for(let t of this._ownedNodes??[])t.remove();dd(this.el,this._rootAttributes??new Map),super.destroy()}};function cn(s){if(typeof s=="number")return Number.isInteger(s)?{valid:!0,value:s}:{valid:!1,value:String(s)};let t=String(s??"").trim();if(t==="")return{valid:!0,value:""};let e=ca(t);return e!==null&&Number.isInteger(e)?{valid:!0,value:e}:{valid:!1,value:t}}function hn(s){if(typeof s=="number")return Number.isFinite(s)?{valid:!0,value:s}:{valid:!1,value:String(s)};let t=String(s??"").trim();if(t==="")return{valid:!0,value:""};let e=ca(t);return e!==null?{valid:!0,value:e}:{valid:!1,value:t}}function ca(s){let t=s.replace(/[\s\u00a0]/g,"");if(!/^[+-]?[\d.,]+$/.test(t))return null;let e=/^[+-]/.test(t)?t[0]:"",i=e?t.slice(1):t;if(!/\d/.test(i))return null;let n=[...i.matchAll(/\./g)].map(c=>c.index),r=[...i.matchAll(/,/g)].map(c=>c.index),o;if(n.length&&r.length){let c=n.at(-1)>r.at(-1)?".":",",h=c==="."?",":".",u=i.lastIndexOf(c),d=i.slice(0,u),p=i.slice(u+1);if(!/^\d+$/.test(p)||!oa(d,h))return null;o=d.split(h).join("")+"."+p}else if(r.length>1||n.length>1){let c=r.length?",":".";if(!oa(i,c))return null;o=i.split(c).join("")}else r.length===1?o=i.replace(",","."):o=i;if(!/^(?:\d+(?:\.\d+)?|\.\d+)$/.test(o))return null;let a=Number(e+o);return Number.isFinite(a)?a:null}function oa(s,t){let e=s.split(t);return e.length>0&&/^\d{1,3}$/.test(e[0])&&e.slice(1).every(i=>/^\d{3}$/.test(i))}function ld(s,t){return t!==void 0?t:s==="checkbox"?!1:""}function cd(s){if(!s||typeof s!="object")throw new TypeError("Adapter must return an object");if(!(s.el&&s.el.nodeType===1))throw new TypeError("Adapter must provide an Element");for(let t of["get","set","focus","setDisabled"])if(typeof s[t]!="function")throw new TypeError(`Adapter is missing ${t}()`);return s}function aa(s,t){let e=l("div",{class:"zx-field__error-control",id:t,role:"alert",tabIndex:-1},s);return{el:e,get:()=>null,set:()=>{},focus:()=>e.focus(),setDisabled:()=>{}}}function hd(s){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(s.tagName)}function ud(s,t){return new Map(t.map(e=>[e,s.getAttribute(e)]))}function dd(s,t){for(let[e,i]of t)i===null?s.removeAttribute(e):s.setAttribute(e,i)}function He(s,t){let e={...s.props??{}};for(let i of Object.keys(e))(/^on[a-z]/i.test(i)||i==="content")&&delete e[i];return{...e,...t}}function $i(s,t){return(e,i)=>{let n=l(s,He(i,{type:s==="input"?t:void 0,placeholder:i.placeholder,required:i.required,disabled:i.disabled}));return un(n)}}function un(s){return{el:s,get:()=>s.value,set:t=>{s.value=t==null?"":String(t)},focus:()=>s.focus(),setDisabled:t=>{s.disabled=t}}}function ha(s){return(t,e)=>{let i=s==="int"?cn:hn,n=l("input",He(e,{type:"text",inputMode:s==="int"?"numeric":"decimal",placeholder:e.placeholder,required:e.required,disabled:e.disabled}));return t.listen(n,"blur",()=>{let r=i(n.value);if(!r.valid){t.setHighlight(t.msg(`field.${s}`),"danger");return}r.value!==""&&(n.value=String(r.value)),t.clearHighlight()}),{...un(n),get:()=>i(n.value).value}}}var fd=(s,t)=>{let e=l("input",He(t,{type:"checkbox",required:t.required,disabled:t.disabled}));return{el:e,get:()=>e.checked,set:i=>{e.checked=!!i},focus:()=>e.focus(),setDisabled:i=>{e.disabled=i}}},pd=(s,t)=>{let e=l("select",He(t,{required:t.required,disabled:t.disabled}));for(let[i,n]of ua(t.options))e.append(l("option",{value:i},n));return un(e)},_d=(s,t)=>{let e=l("div",{class:"zx-field__option-list",role:"radiogroup"}),i=t.id?String(t.id):x("zx-option-list"),n=ua(t.options).map(([r,o],a)=>{let c=l("input",{type:"radio",name:i,value:r,required:!!t.required&&a===0,disabled:t.disabled});return e.append(l("label",{class:"zx-field__option"},c,l("span",{},o))),c});return{el:e,get:()=>n.find(r=>r.checked)?.value??"",set:r=>{for(let o of n)o.checked=String(r??"")===o.value},focus:()=>(n.find(r=>r.checked)??n[0])?.focus(),setDisabled:r=>{for(let o of n)o.disabled=r;e.setAttribute("aria-disabled",String(r))}}},md=(s,t)=>{let e=l("div",He(t,{class:"zx-field__static"})),i=null;return{el:e,get:()=>e.textContent,set:r=>{la(i),i=null,r&&typeof r=="object"&&typeof r.nodeType=="number"?(i={node:r,parent:r.parentNode,next:r.nextSibling},e.replaceChildren(r)):e.textContent=r==null?"":String(r)},focus:()=>{},setDisabled:r=>{e.setAttribute("aria-disabled",String(r))},destroy:()=>la(i)}};function la(s){s&&(s.parent?s.parent.insertBefore(s.node,s.next?.parentNode===s.parent?s.next:null):s.node.remove())}var gd=(s,t)=>{if(typeof t.adapter!="function")throw new TypeError("Custom fields require options.adapter");return t.adapter(s,t)};function ua(s){return Array.isArray(s)?s.map(t=>[String(t),String(t)]):s&&typeof s=="object"?Object.entries(s).map(([t,e])=>[t,String(e)]):[]}C.register("text",$i("input","text"));C.register("password",$i("input","password"));C.register("textarea",$i("textarea","text"));C.register("checkbox",fd);C.register("int",ha("int"));C.register("float",ha("float"));C.register("select",pd);C.register("optionlist",_d);C.register("hidden",$i("input","hidden"));C.register("html",md);C.register("custom",gd);function qt(s,t,e){let i=da(t).split(/\s+/).filter(Boolean);return i.length===0?s.slice():s.filter(n=>{let r=bd(n,e).map(da);return i.every(o=>r.some(a=>a.includes(o)))})}function bd(s,t){return s===null||typeof s!="object"?[s]:!Array.isArray(t)||t.length===0?[s]:t.map(e=>typeof e=="function"?e(s):s[e])}function da(s){return String(s??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var ot=class extends m{static cssName="checklist";static defaults={items:[],valueKey:"ID",labelKey:"name",checkedKey:"on",search:!0,height:280,defaultChecked:!1,load:null};render(){this._items=[],this._visibleItems=[],this._checked=new Set,this._query="",this._loadSequence=0,this._createdRoot=!1,this._active=!0,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._createdRoot||(this._originalChildren=Array.from(t.childNodes));for(let o of["role","aria-labelledby","data-state"])this._originalAttributes.set(o,t.getAttribute(o));let e=x("zx-checklist-label"),i=l("div",{class:"zx-checklist__label",id:e},this._message("checklist.label","Checklist")),n=l("input",{ref:"search",class:"zx-checklist__search",type:"search",autocomplete:"off",placeholder:this._message("checklist.search","Search"),ariaLabel:this._message("checklist.search","Search checklist"),hidden:!this.options.search}),r=l("div",{ref:"list",class:"zx-checklist__list"});return r.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,t.replaceChildren(i,n,r),t.setAttribute("role","group"),t.setAttribute("aria-labelledby",e),this.listen(n,"input",()=>this.search(n.value)),this.listen(r,"change",o=>{let a=o.target;if(!a?.matches?.('input[type="checkbox"][data-index]'))return;let c=this._visibleItems[Number(a.dataset.index)];if(c===void 0)return;let h=this._itemValue(c);a.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)),i=new Set(this._items.map(n=>this._itemValue(n)).filter(n=>e.has(n)));return this._replaceChecked(i),this}checkAll(){return this._replaceChecked(new Set(this._items.map(t=>this._itemValue(t)))),this}uncheckAll(){return this._replaceChecked(new Set),this}search(t){this._query=String(t??"");let e=this.refs.search;return e.value!==this._query&&(e.value=this._query),this._visibleItems=qt(this._items,this._query,[this.options.labelKey]),this._renderItems(),this}async reload(){if(!this._active||typeof this.options.load!="function")return this;let t=++this._loadSequence;this.el.setAttribute("data-state","loading"),this.refs.list.setAttribute("aria-busy","true");try{let e=await this.options.load();if(t!==this._loadSequence)return this;this._replaceItems(e),this.emit("loaded",{items:this._items.slice()})}finally{t===this._loadSequence&&(this.el.removeAttribute("data-state"),this.refs.list.setAttribute("aria-busy","false"))}return this}destroy(){this._active=!1,this._loadSequence+=1;let t=this.el;if(!this._createdRoot&&t){t.replaceChildren(...this._originalChildren);for(let[e,i]of this._originalAttributes)i===null?t.removeAttribute(e):t.setAttribute(e,i)}super.destroy()}_replaceItems(t){this._items=Array.isArray(t)?t.slice():[],this._checked=new Set(this._items.filter(e=>!!this._initialChecked(e)).map(e=>this._itemValue(e))),this._visibleItems=qt(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let t=this._visibleItems.map((e,i)=>{let n=x("zx-checklist-item"),r=l("input",{type:"checkbox",id:n,checked:this._checked.has(this._itemValue(e)),dataset:{index:i}});return l("label",{class:"zx-checklist__item",for:n},r,l("span",{},this._itemLabel(e)))});t.length===0&&t.push(l("div",{class:"zx-checklist__empty",role:"status"},this._message("checklist.empty","No matches"))),this.refs.list.replaceChildren(...t)}_replaceChecked(t){yd(this._checked,t)||(this._checked=t,this._renderItems(),this.emit("change",{values:this.getValues()}))}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){return String(this._read(t,this.options.labelKey)??"")}_initialChecked(t){let e;return typeof this.options.checkedKey=="function"?e=this.options.checkedKey(t):t!==null&&typeof t=="object"&&(e=t[this.options.checkedKey]),e??this.options.defaultChecked}_read(t,e){return typeof e=="function"?e(t):t===null||typeof t!="object"?t:t[e]}_message(t,e){let i=this.msg(t);return i===t?e:i}};function yd(s,t){return s.size===t.size&&Array.from(s).every(e=>t.has(e))}function fa(){C.register("checklist",(s,t)=>{let e=s.own(new ot(null,{...t.props??{}})),i=!1,n=!1,r=()=>{e.el.setAttribute("aria-disabled",String(i));for(let o of e.el.querySelectorAll("input, button, select, textarea"))o.disabled=i};return s.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>{n||s.emit("change",{value:o.detail.values})}),e.on("loaded",r),{el:e.el,get:()=>e.getValues(),set:o=>{n=!0;try{e.setValues(Array.isArray(o)?o:[])}finally{n=!1}r()},focus:()=>{(e.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])")??e.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus()},setDisabled:o=>{i=!!o,r()}}})}var qe=class extends m{static cssName="code-editor";static defaults={value:"",name:"",language:"text",label:"Code editor",placeholder:"",rows:12,indent:" ",wrap:"off",spellcheck:!1,readOnly:!1,disabled:!1,status:!0};render(){this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._initialChildren=this._createdRoot?[]:[...t.childNodes],this._initialAttributes=new Map(["data-language","data-readonly","data-disabled"].map(e=>[e,t.getAttribute(e)])),this._language=pa(this.options.language),this._languageLabel=l("span",{class:"zx-code-editor__language"},this._language),this._position=l("span",{class:"zx-code-editor__position",role:"status",ariaLive:"polite"}),this._header=l("div",{class:"zx-code-editor__header"},this._languageLabel,this.options.status?this._position:null),this._input=l("textarea",{class:"zx-code-editor__input",name:this.options.name?String(this.options.name):void 0,ariaLabel:String(this.options.label??"Code editor"),placeholder:String(this.options.placeholder??""),rows:xd(this.options.rows),wrap:vd(this.options.wrap),spellcheck:!!this.options.spellcheck,readOnly:!!this.options.readOnly,disabled:!!this.options.disabled,autocomplete:"off",autocapitalize:"off"}),this._input.value=String(this.options.value??""),t.dataset.language=this._language,t.dataset.readonly=String(!!this.options.readOnly),t.dataset.disabled=String(!!this.options.disabled),t.replaceChildren(this._header,this._input),this.listen(this._input,"keydown",e=>this._handleKeydown(e)),this.listen(this._input,"input",()=>{this._updatePosition(),this.emit("input",{value:this.getValue()})}),this.listen(this._input,"change",()=>this.emit("change",{value:this.getValue()}));for(let e of["click","keyup","select","focus"])this.listen(this._input,e,()=>this._updatePosition());return this._updatePosition(),t}getValue(){return this._input.value}setValue(t,{silent:e=!1}={}){let i=String(t??"");return this._input.value===i?this:(this._input.value=i,this._updatePosition(),e||this.emit("change",{value:i}),this)}setLanguage(t){return this._language=pa(t),this.el.dataset.language=this._language,this._languageLabel.textContent=this._language,this}focus(){return this._input.focus(),this}enable(){return this._input.disabled=!1,this.el.dataset.disabled="false",this}disable(){return this._input.disabled=!0,this.el.dataset.disabled="true",this}setReadOnly(t){return this._input.readOnly=!!t,this.el.dataset.readonly=String(!!t),this}_handleKeydown(t){if(t.key!=="Tab"||t.altKey||t.ctrlKey||t.metaKey||this._input.readOnly||this._input.disabled)return;let e=String(this.options.indent??" ");if(!e)return;t.preventDefault();let i=_a(this._input.value,this._input.selectionStart??0,this._input.selectionEnd??0,e,t.shiftKey);i.value!==this._input.value&&(this._input.value=i.value,this._input.setSelectionRange(i.start,i.end),this._updatePosition(),this.emit("input",{value:this.getValue()}))}_updatePosition(){if(!this.options.status)return;let t=ma(this._input.value,this._input.selectionStart??0,this._input.selectionEnd??0);this._position.textContent=t.lines>1?`Ln ${t.line}, Col ${t.column} \xB7 ${t.lines} lines selected`:`Ln ${t.line}, Col ${t.column}`}destroy(){if(!this._createdRoot){this.el.replaceChildren(...this._initialChildren);for(let[t,e]of this._initialAttributes)e===null?this.el.removeAttribute(t):this.el.setAttribute(t,e)}super.destroy()}};function _a(s,t,e,i=" ",n=!1){let r=String(s??""),o=String(i??""),a=Ki(t,r.length),c=Ki(e,r.length);if(!o)return{value:r,start:a,end:c};if(a===c&&!n)return{value:r.slice(0,a)+o+r.slice(c),start:a+o.length,end:a+o.length};let h=r.lastIndexOf(`
|
|
2
|
+
`,Math.max(0,a-1))+1,u=r.indexOf(`
|
|
3
|
+
`,c);u<0&&(u=r.length);let p=r.slice(h,u).split(`
|
|
4
|
+
`),f=0,_=0,b=p.map((y,v)=>{if(!n)return _+=o.length,o+y;let k=wd(y,o);return v===0&&(f=k),_-=k,y.slice(k)}).join(`
|
|
5
|
+
`),w=n?Math.max(h,a-Math.min(f,a-h)):a+o.length;return{value:r.slice(0,h)+b+r.slice(u),start:w,end:Math.max(w,c+_)}}function ma(s,t,e=t){let i=String(s??""),n=Ki(t,i.length),r=Ki(e,i.length),o=i.slice(0,n);return{line:o.split(`
|
|
6
|
+
`).length,column:n-o.lastIndexOf(`
|
|
7
|
+
`),lines:i.slice(n,r).split(`
|
|
8
|
+
`).length}}function wd(s,t){return s.startsWith(t)?t.length:t===" "?s.startsWith(" ")?1:Math.min(/^ +/.exec(s)?.[0].length??0,2):Math.min(/^\s+/.exec(s)?.[0].length??0,t.length)}function pa(s){let t=String(s??"text").trim().toLowerCase();return/^[a-z0-9][a-z0-9+_.-]*$/.test(t)?t:"text"}function xd(s){let t=Number(s);return Number.isFinite(t)?Math.max(2,Math.min(100,Math.round(t))):12}function vd(s){return["off","soft","hard"].includes(String(s))?s:"off"}function Ki(s,t){let e=Number(s);return Math.max(0,Math.min(t,Number.isFinite(e)?Math.round(e):0))}function ga(){C.register("code",(s,t)=>{let e=s.own(new qe(null,{label:t.label?String(t.label):"Code editor",placeholder:t.placeholder,readOnly:!!t.props?.readOnly,disabled:!!t.disabled,...t.props??{},value:t.value})),i=!1;return e.on("input",n=>{i||s.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.getValue(),set:n=>{i=!0;try{e.setValue(n,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var ba=["January","February","March","April","May","June","July","August","September","October","November","December"],ya=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],va=/%[demYyHMSaAbBs]/g;function D(s,t){return!(s instanceof Date)||Number.isNaN(s.getTime())?"":String(t).replace(va,e=>{switch(e){case"%d":return be(s.getDate());case"%e":return String(s.getDate());case"%m":return be(s.getMonth()+1);case"%Y":return String(s.getFullYear()).padStart(4,"0");case"%y":return be(s.getFullYear()%100);case"%H":return be(s.getHours());case"%M":return be(s.getMinutes());case"%S":return be(s.getSeconds());case"%a":return wa("weekday",s.getDay(),ya[s.getDay()]);case"%A":return dn("weekday",s.getDay(),ya[s.getDay()]);case"%b":return wa("month",s.getMonth(),ba[s.getMonth()]);case"%B":return dn("month",s.getMonth(),ba[s.getMonth()]);case"%s":return String(Math.floor(s.getTime()/1e3));default:return e}})}function Z(s,t){let e=[],i="^",n=0;for(let _ of String(t).matchAll(va)){i+=xa(String(t).slice(n,_.index));let b=_[0],w=Sd(b);if(w===null)return null;i+=`(${w})`,e.push(b),n=_.index+b.length}i+=xa(String(t).slice(n))+"$";let r=new RegExp(i).exec(String(s));if(!r)return null;let o=Object.create(null);if(e.forEach((_,b)=>{o[_]=Number(r[b+1])}),o["%s"]!==void 0){let _=o["%s"]*1e3,b=new Date(_);return Number.isNaN(b.getTime())?null:b}let a=o["%Y"]??Ad(o["%y"])??1970,c=(o["%m"]??1)-1,h=o["%d"]??o["%e"]??1,u=o["%H"]??0,d=o["%M"]??0,p=o["%S"]??0,f=new Date(0);return f.setHours(0,0,0,0),f.setFullYear(a,c,h),f.setHours(u,d,p,0),Number.isNaN(f.getTime())||o["%Y"]!==void 0&&f.getFullYear()!==o["%Y"]||o["%y"]!==void 0&&f.getFullYear()%100!==o["%y"]||o["%m"]!==void 0&&f.getMonth()!==c||o["%d"]!==void 0&&f.getDate()!==h||o["%e"]!==void 0&&f.getDate()!==h||o["%H"]!==void 0&&f.getHours()!==u||o["%M"]!==void 0&&f.getMinutes()!==d||o["%S"]!==void 0&&f.getSeconds()!==p?null:f}function fn(s,t,e){let i=s.getTime(),n=t instanceof Date?t.getTime():-1/0,r=e instanceof Date?e.getTime():1/0;return new Date(Math.min(r,Math.max(n,i)))}function Y(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}function F(s,t){let e=new Date(s.getTime());return e.setDate(e.getDate()+t),e}function $t(s,t){let e=new Date(s.getTime()),i=e.getDate();e.setDate(1),e.setMonth(e.getMonth()+t);let n=new Date(e.getFullYear(),e.getMonth()+1,0).getDate();return e.setDate(Math.min(i,n)),e}function $e(s=lt()){if(!s||s.toLowerCase()==="en")return 1;try{let t=new Intl.Locale(s),e=t.getWeekInfo?.()??t.weekInfo;if(e?.firstDay)return e.firstDay%7}catch{}return 1}function be(s){return String(s).padStart(2,"0")}function dn(s,t,e){let i=`date.${s}.${t}`,n=vt(i);return n===i?e:n}function wa(s,t,e){let i=`date.${s}.short.${t}`,n=vt(i);return n!==i?n:dn(s,t,e).slice(0,3)}function Sd(s){return{"%d":"\\d{1,2}","%e":"\\d{1,2}","%m":"\\d{1,2}","%Y":"\\d{4}","%y":"\\d{2}","%H":"\\d{1,2}","%M":"\\d{1,2}","%S":"\\d{1,2}","%s":"-?\\d+"}[s]??null}function Ad(s){if(s!==void 0)return s>=69?1900+s:2e3+s}function xa(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var _n=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),Aa=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),Sa=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"}),ka=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"}),pn=new Map;function mn(s){let t=String(s).trim();if(/\s/.test(t)||t.startsWith("fa-"))return{provider:"fa",name:"",style:null,classes:t.split(/\s+/).filter(Boolean)};let e=t.indexOf(":");if(e>0){let i=t.slice(0,e).toLowerCase(),n=t.slice(e+1);if(i==="builtin"||i==="zx")return{provider:"builtin",name:n,style:null,classes:null};if(Object.hasOwn(Sa,i))return{provider:"fa",name:n,style:Sa[i],classes:null}}return{provider:null,name:t,style:null,classes:null}}function Ui(s,t={}){let{style:e="solid",family:i="classic",fixedWidth:n=!1,translate:r=!0}=t,o=String(s).replace(/^fa-/,""),a=r?ka[o]??o:o,c=[],h=Aa[i];return h&&c.push(h),c.push(_n[e]??_n.solid,`fa-${a}`),n&&c.push("fa-fw"),c}function Yi(s){let t=String(s).trim();if(/^(https?:)?\/\//.test(t)||t.startsWith("/")||t.endsWith(".js"))return t;if(!/^[a-z0-9]+$/.test(t))throw new RangeError(`Invalid Font Awesome kit token: ${s}`);return`https://kit.fontawesome.com/${t}.js`}function gn(s){let t=Yi(s),e=pn.get(t);if(e)return e;let i=new Promise((n,r)=>{let o=new URL(t,document.baseURI).href,a=[...document.scripts].find(h=>h.src===o);if(a&&globalThis.FontAwesomeKitConfig){n();return}let c=a??document.createElement("script");c.addEventListener("load",()=>n(),{once:!0}),c.addEventListener("error",()=>{pn.delete(t),r(new Error(`Font Awesome kit failed to load: ${t}`))},{once:!0}),!a&&(c.src=t,c.async=!0,c.crossOrigin="anonymous",document.head.append(c))});return pn.set(t,i),i}var Ta="http://www.w3.org/2000/svg",yn=Object.freeze({"arrow-up-wide-short":["0 0 576 512","M151.6 42.4C145.5 35.8 137 32 128 32s-17.5 3.8-23.6 10.4l-88 96c-11.9 13-11.1 33.3 2 45.2s33.3 11.1 45.2-2L96 146.3 96 448c0 17.7 14.3 32 32 32s32-14.3 32-32l0-301.7 32.4 35.4c11.9 13 32.2 13.9 45.2 2s13.9-32.2 2-45.2l-88-96zM320 480l32 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-32 0c-17.7 0-32 14.3-32 32s14.3 32 32 32zm0-128l96 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-96 0c-17.7 0-32 14.3-32 32s14.3 32 32 32zm0-128l160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-160 0c-17.7 0-32 14.3-32 32s14.3 32 32 32zm0-128l224 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L320 32c-17.7 0-32 14.3-32 32s14.3 32 32 32z"],"arrow-down-wide-short":["0 0 576 512","M151.6 469.6C145.5 476.2 137 480 128 480s-17.5-3.8-23.6-10.4l-88-96c-11.9-13-11.1-33.3 2-45.2s33.3-11.1 45.2 2L96 365.7 96 64c0-17.7 14.3-32 32-32s32 14.3 32 32l0 301.7 32.4-35.4c11.9-13 32.2-13.9 45.2-2s13.9 32.2 2 45.2l-88 96zM320 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l32 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-32 0zm0-128c-17.7 0-32-14.3-32-32s14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-96 0zm0-128c-17.7 0-32-14.3-32-32s14.3-32 32-32l160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-160 0zm0-128c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L320 96z"],"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"]}),kd=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list"}),wn=Object.create(null),It={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function xn(){return{...It}}function Wi(s={}){for(let t of["provider","style","family","fixedWidth","kit"])s[t]!==void 0&&(It[t]=s[t]);return xn()}function Ia(s={}){return Wi({...s,provider:"fontawesome"})}function zd(){return Wi({provider:"builtin"})}async function Cd(s){let t=typeof s=="string"?{kit:s}:{...s},{kit:e,activate:i=!0,...n}=t;if(!e)throw new TypeError("loadFontAwesome() needs a kit token or URL");return Wi({...n,kit:Yi(e)}),await gn(e),i?Ia():xn()}function Td(s){for(let[t,e]of Object.entries(s)){if(!Array.isArray(e)||e.length!==2)throw new TypeError(`Icon "${t}" must be a [viewBox, path] pair`);wn[t]=[String(e[0]),String(e[1])]}}function Id(){return[...new Set([...Object.keys(yn),...Object.keys(wn)])].sort()}function g(s,t={}){let e=mn(s);if(e.classes)return bn(e.classes,t);let i=kd[e.name]??e.name;return e.provider==="builtin"?za(i,t):e.provider==="fa"?bn(Ui(i,{style:e.style??t.style??It.style,family:t.family??It.family,fixedWidth:t.fixedWidth??It.fixedWidth}),t):It.provider==="fontawesome"?bn(Ui(i,{style:t.style??It.style,family:t.family??It.family,fixedWidth:t.fixedWidth??It.fixedWidth}),t):za(i,t)}function za(s,t){let e=wn[s]??yn[s];if(!e){if(t.strict)throw new RangeError(`Unknown icon: ${s}`);return Md(s),Dd(s,t)}let[i,n]=e,r=Ea(i,t),o=document.createElementNS(Ta,"path");return o.setAttribute("d",n),r.append(o),r}function Ea(s,t){let{size:e=16}=t,i=document.createElementNS(Ta,"svg");return i.setAttribute("class",Ma("zx-icon",t.class)),i.setAttribute("viewBox",s),i.setAttribute("width",String(e)),i.setAttribute("height",String(e)),i.setAttribute("fill","currentColor"),i.setAttribute("focusable","false"),Da(i,t.label??null),i}var Ed="0 0 512 512";function Dd(s,t){let e=Ea(Ed,t);return e.setAttribute("data-zx-icon-missing",s),e}var Ca=new Set;function Md(s){Ca.has(s)||(Ca.add(s),console.warn(`[zx.icon] Unknown icon "${s}" \u2014 rendered an empty placeholder. Add it with registerIcons(), or render Font Awesome with useFontAwesome().`))}function bn(s,t){let{size:e=16}=t,i=document.createElement("i");return i.className=Ma("zx-icon",...s,t.class),i.style.fontSize=typeof e=="number"?`${e}px`:String(e),Da(i,t.label??null),i}function Da(s,t){if(t===null){s.setAttribute("aria-hidden","true");return}s.setAttribute("role","img"),s.setAttribute("aria-label",t)}function Ma(...s){return s.flat().filter(Boolean).join(" ")}var Nd=5,Ke=class extends m{static cssName="time-picker";static defaults={value:null,seconds:!1,step:5,clock:!0};render(){let t=this.el??l("div");this.el=t;let e=Na(this.options.value);this._value=e,this._display=e??{h:0,m:0,s:0},this._inputs=[],this._clockOpen=!1,this._clockUnit="h",this._clock=null;let i=l("div",{class:"zx-time-picker__segments",role:"group",ariaLabel:this._message("timePicker.label","Time")});if(this._content=i,this._addSpin(i,"h",this._message("timePicker.hour","Hour"),23),i.append(l("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(i,"m",this._message("timePicker.minute","Minute"),59),this.options.seconds&&(i.append(l("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(i,"s",this._message("timePicker.second","Second"),59)),t.append(i),this.options.clock){let n=x("zx-time-picker-clock");i.append(l("button",{ref:"clockToggle",class:"zx-icon-btn zx-time-picker__clock-toggle",type:"button",ariaLabel:this._message("timePicker.clock","Pick the time on a clock"),ariaExpanded:"false",ariaControls:n},g("clock",{size:15}))),this._clock=this._buildClock(n),t.append(this._clock),this.listen(this.refs.clockToggle,"click",()=>this.toggleClock())}return this._writeInputs(),t}get(){return this._value?{...this._value}:null}set(t,{silent:e=!1}={}){let i=Na(t);return this._value=i,this._display=i??{h:0,m:0,s:0},this._writeInputs(),!e&&i&&this.emit("change",{time:{...i}}),this}openClock(t="h"){return this._clock?(this._clockOpen=!0,this._clockUnit=t==="m"?"m":"h",this._syncClock(),this):this}closeClock(){return this._clock?(this._clockOpen=!1,this._syncClock(),this):this}toggleClock(){return this._clockOpen?this.closeClock():this.openClock("h")}destroy(){this._content?.remove(),this._clock?.remove(),this._clock=null,super.destroy()}_addSpin(t,e,i,n){let r=l("input",{class:"zx-time-picker__spin",type:"text",role:"spinbutton",inputMode:"numeric",maxLength:2,autocomplete:"off",ariaLabel:i,ariaValueMin:"0",ariaValueMax:String(n),dataset:{segment:e}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"keydown",o=>this._onKeydown(o,e,n)),this.listen(r,"input",()=>this._onInput(r,e,n)),this.listen(r,"blur",()=>this._commitFromInputs())}_onKeydown(t,e,i){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return;t.preventDefault();let n=t.key==="ArrowUp"?1:-1,r=e==="m"?Rd(this.options.step):1,o=ye(t.currentTarget.value,0,i),a=i+1,c=(o+n*r+a*r)%a;t.currentTarget.value=Zt(c),this._commitFromInputs()}_onInput(t,e,i){if(t.value=t.value.replace(/\D/g,"").slice(0,2),t.value.length<2)return;t.value=Zt(ye(t.value,0,i)),this._commitFromInputs();let n=this._inputs.indexOf(t);this._inputs[n+1]?.focus()}_commitFromInputs(){let t={h:0,m:0,s:0};for(let i of this._inputs){let n=i.dataset.segment,r=n==="h"?23:59;t[n]=ye(i.value,0,r)}let e=!this._value||!Vd(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=Zt(this._display[e]),t.setAttribute("aria-valuenow",String(this._display[e])),t.setAttribute("aria-valuetext",t.value)}this._syncClock()}_buildClock(t){let e=l("div",{class:"zx-time-picker__clock",id:t,hidden:!0},l("div",{class:"zx-time-picker__clock-head"},l("button",{ref:"headHour",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:this._message("timePicker.selectHour","Select the hour"),dataset:{unit:"h"}}),l("span",{class:"zx-time-picker__clock-colon",ariaHidden:"true"},":"),l("button",{ref:"headMinute",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:this._message("timePicker.selectMinutes","Select the minutes"),dataset:{unit:"m"}})),l("div",{ref:"dial",class:"zx-time-picker__dial",role:"radiogroup"},l("span",{ref:"hand",class:"zx-time-picker__hand",ariaHidden:"true"}),l("span",{class:"zx-time-picker__pivot",ariaHidden:"true"})));return this.listen(this.refs.headHour,"click",()=>this.openClock("h")),this.listen(this.refs.headMinute,"click",()=>this.openClock("m")),this.listen(this.refs.dial,"click",i=>{let n=i.target.closest?.(".zx-time-picker__mark");n&&this._pick(Number(n.dataset.value))}),this.listen(this.refs.dial,"keydown",i=>this._onDialKeydown(i)),e}_pick(t){let e={...this._display,[this._clockUnit]:t},i=this._clockUnit==="h";this.set(e),i&&this.openClock("m")}_onDialKeydown(t){let e=[...this.refs.dial.querySelectorAll(".zx-time-picker__mark")],i=t.target.closest?.(".zx-time-picker__mark"),n=e.indexOf(i);if(n<0)return;let r={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[t.key],o=null;r!==void 0?o=(n+r+e.length)%e.length:t.key==="Home"?o=0:t.key==="End"&&(o=e.length-1),o!==null&&(t.preventDefault(),this._pick(Number(e[o].dataset.value)),this.refs.dial.querySelector(`[data-value="${e[o].dataset.value}"]`)?.focus())}_syncClock(){if(!this._clock)return;let t=this._clockUnit==="h";if(this._clock.hidden=!this._clockOpen,this.refs.clockToggle.setAttribute("aria-expanded",String(this._clockOpen)),this.refs.headHour.textContent=Zt(this._display.h),this.refs.headMinute.textContent=Zt(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?this._message("timePicker.hour","Hour"):this._message("timePicker.minutes","Minutes")),!this._clockOpen)return;let e=t?this._display.h:this._display.m,i=t?Od():Fd(),n=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(n.length!==i.length||this.refs.dial.dataset.unit!==this._clockUnit){for(let a of n)a.remove();this.refs.dial.dataset.unit=this._clockUnit,this.refs.dial.append(...i.map(a=>this._buildMark(a,e)))}else i.forEach((a,c)=>this._syncMark(n[c],a,e));let r=t&&!Ld(e)?"inner":"outer",o=t?e%12*30:e*6;this.refs.hand.dataset.ring=r,this.refs.hand.style.setProperty("--zx-clock-angle",`${o}deg`)}_buildMark(t,e){let i=l("button",{class:"zx-time-picker__mark",type:"button",role:"radio",dataset:{value:String(t.value),ring:t.ring}},t.label);return i.style.setProperty("--zx-clock-angle",`${t.angle}deg`),this._syncMark(i,t,e),i}_syncMark(t,e,i){let n=e.value===i;t.setAttribute("aria-checked",String(n)),t.tabIndex=n?0:-1}_message(t,e){let i=this.msg(t);return i===t?e:i}};function Od(){let s=[];for(let t=1;t<=12;t+=1)s.push({value:t,label:String(t),angle:t%12*30,ring:"outer"});for(let t=0;t<12;t+=1){let e=t===0?0:12+t;s.push({value:e,label:Zt(e),angle:t*30,ring:"inner"})}return s}function Fd(){let s=[];for(let t=0;t<60;t+=Nd)s.push({value:t,label:Zt(t),angle:t*6,ring:"outer"});return s}function Ld(s){return s>=1&&s<=12}function Na(s){return s instanceof Date&&!Number.isNaN(s.getTime())?{h:s.getHours(),m:s.getMinutes(),s:s.getSeconds()}:!s||typeof s!="object"?null:{h:ye(s.h,0,23),m:ye(s.m,0,59),s:ye(s.s,0,59)}}function ye(s,t,e){let i=Number.parseInt(String(s??""),10);return Number.isFinite(i)?Math.max(t,Math.min(e,i)):t}function Rd(s){let t=Math.round(Number(s));return Number.isFinite(t)&&t>0&&t<=59?t:5}function Zt(s){return String(s).padStart(2,"0")}function Vd(s,t){return s.h===t.h&&s.m===t.m&&s.s===t.s}var te=class extends m{static cssName="date-picker";static defaults={value:null,min:null,max:null,weekStart:1,showWeekNumbers:!1,time:!1};render(){let t=this.el??l("div");this._min=ct(Gi(this.options.min)),this._max=ct(Gi(this.options.max)),this._value=this._normalizeValue(Gi(this.options.value)),this._focused=ct(this._value)??this._clampFocus(ct(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=Pd(this.options.weekStart),this._quickOpen=!1,this._timePicker=null;let e=l("div",{class:"zx-date-picker__surface"},l("div",{class:"zx-date-picker__header"},l("button",{ref:"previous",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.previousMonth","Previous month")},g("chevron-left")),l("button",{ref:"heading",class:"zx-date-picker__heading",type:"button",ariaExpanded:"false","aria-haspopup":"grid"}),l("button",{ref:"next",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.nextMonth","Next month")},g("chevron-right"))),l("div",{ref:"quickPanel",class:"zx-date-picker__quick",hidden:!0},l("div",{class:"zx-date-picker__quick-header"},l("button",{ref:"quickPrevious",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.previousYear","Previous year")},g("chevron-left")),l("span",{ref:"quickYear",class:"zx-date-picker__quick-year",ariaLive:"polite"}),l("button",{ref:"quickNext",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.nextYear","Next year")},g("chevron-right"))),l("div",{ref:"quickGrid",class:"zx-date-picker__quick-grid",role:"grid"})),l("table",{ref:"grid",class:"zx-date-picker__grid",role:"grid",ariaLabel:this._message("datePicker.calendar","Calendar")},l("thead",{ref:"weekdays"}),l("tbody",{ref:"days"})));return this._content=e,t.append(e),this.listen(this.refs.previous,"click",()=>this._pageMonth(-1)),this.listen(this.refs.next,"click",()=>this._pageMonth(1)),this.listen(this.refs.heading,"click",()=>this._toggleQuickPick()),this.listen(this.refs.quickPrevious,"click",()=>this._stepQuickYear(-1)),this.listen(this.refs.quickNext,"click",()=>this._stepQuickYear(1)),this.listen(this.refs.quickGrid,"click",i=>this._onQuickClick(i)),this.listen(this.refs.quickGrid,"keydown",i=>this._onQuickKeydown(i)),this.listen(this.refs.days,"click",i=>this._onDayClick(i)),this.listen(this.refs.days,"keydown",i=>this._onDayKeydown(i)),this._renderWeekdays(),this._renderCalendar(),this.options.time&&(this._timePicker=new Ke(null,{value:this._value,seconds:!1}),this._timePicker.on("change",i=>{let n=i.detail.time,r=this._value??this._focused,o=new Date(r.getTime());o.setHours(n.h,n.m,n.s,0),this.set(o)}),e.append(this._timePicker.el)),t}get(){return vn(this._value)}set(t,{silent:e=!1}={}){let i=this._normalizeValue(Gi(t));return this._value=i,i&&(this._focused=ct(i),this._viewYear=i.getFullYear(),this._viewMonth=i.getMonth()),this._timePicker?.set(i,{silent:!0}),this._renderCalendar(),e||this.emit("change",{date:vn(this._value)}),this}focus(){return this._closeQuickPick(),this._buttonForDate(this._focused)?.focus(),this}destroy(){this._timePicker?.destroy(),this._timePicker=null,this._content?.remove(),super.destroy()}_normalizeValue(t){if(!t)return null;let e=new Date(t.getTime()),i=ct(e);return this._min&&i<this._min&&Oa(e,this._min),this._max&&i>this._max&&Oa(e,this._max),e}_clampFocus(t){return this._min&&t<this._min?new Date(this._min.getTime()):this._max&&t>this._max?new Date(this._max.getTime()):t}_renderWeekdays(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-picker__week-heading",scope:"col",ariaLabel:this._message("datePicker.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let i=0;i<7;i+=1){let n=F(e,(this._weekStart+i)%7);t.append(l("th",{scope:"col",ariaLabel:D(n,"%A")},D(n,"%a")))}this.refs.weekdays.replaceChildren(t)}_renderCalendar(){if(!this.refs?.days)return;let t=new Date(this._viewYear,this._viewMonth,1),e=(t.getDay()-this._weekStart+7)%7,i=F(t,-e);this.refs.heading.textContent=D(t,"%B %Y"),this.refs.heading.setAttribute("aria-label",this._message("datePicker.chooseMonthYear","Choose month and year, %1",D(t,"%B %Y")));let n=[];for(let r=0;r<6;r+=1){let o=F(i,r*7),a=l("tr");this.options.showWeekNumbers&&a.append(l("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:this._message("datePicker.week","Week %1",Fa(o))},String(Fa(o))));for(let c=0;c<7;c+=1){let h=F(o,c),u=!!(this._value&&Y(h,this._value)),d=!this._inRange(h),p=l("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:Y(h,this._focused)?0:-1,ariaSelected:String(u),ariaDisabled:String(d),ariaCurrent:Y(h,new Date)?"date":null,ariaLabel:`${D(h,"%e")} ${D(h,"%B %Y")}`,dataset:{date:D(h,"%Y-%m-%d"),otherMonth:h.getMonth()===this._viewMonth?null:"true"}},D(h,"%e"));a.append(l("td",{role:"presentation"},p))}n.push(a)}this.refs.days.replaceChildren(...n),this._quickOpen&&this._renderQuickPick()}_onDayClick(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let i=Z(e.dataset.date,"%Y-%m-%d");i&&this._inRange(i)&&this._selectDate(i)}_onDayKeydown(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let i=Z(e.dataset.date,"%Y-%m-%d");if(!i)return;let n=null;if(t.key==="ArrowLeft")n=F(i,-1);else if(t.key==="ArrowRight")n=F(i,1);else if(t.key==="ArrowUp")n=F(i,-7);else if(t.key==="ArrowDown")n=F(i,7);else if(t.key==="PageUp")n=$t(i,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=$t(i,t.shiftKey?12:1);else if(t.key==="Home")n=F(i,-((i.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=F(i,6-(i.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._inRange(i)&&this._selectDate(i);return}n&&(t.preventDefault(),this._moveFocus(n))}_moveFocus(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;this._focused=ct(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._renderCalendar(),e&&this._emitMonthChange(),this._buttonForDate(t)?.focus()}_selectDate(t){let e=new Date(t.getTime()),i=this._timePicker?.get();i?e.setHours(i.h,i.m,i.s,0):this._value&&e.setHours(this._value.getHours(),this._value.getMinutes(),this._value.getSeconds(),this._value.getMilliseconds());let n=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;this._value=e,this._focused=ct(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._timePicker?.set(e,{silent:!0}),this._renderCalendar(),n&&this._emitMonthChange(),this.emit("change",{date:vn(e)})}_pageMonth(t){this._closeQuickPick();let e=$t(this._focused,t);this._focused=ct(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._renderCalendar(),this._emitMonthChange()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_toggleQuickPick(){if(this._quickOpen){this._closeQuickPick(),this.refs.heading.focus();return}this._quickOpen=!0,this.refs.quickPanel.hidden=!1,this.refs.heading.setAttribute("aria-expanded","true"),this._renderQuickPick(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_closeQuickPick(){this._quickOpen&&(this._quickOpen=!1,this.refs.quickPanel.hidden=!0,this.refs.heading.setAttribute("aria-expanded","false"))}_renderQuickPick(){this.refs.quickYear.textContent=String(this._viewYear);let t=[];for(let e=0;e<12;e+=1){let i=new Date(this._viewYear,e,1);t.push(l("button",{class:"zx-date-picker__quick-month",type:"button",role:"gridcell",tabindex:e===this._viewMonth?0:-1,ariaSelected:String(e===this._viewMonth),dataset:{month:e}},D(i,"%b")))}this.refs.quickGrid.replaceChildren(...t)}_stepQuickYear(t){this._viewYear+=t,this._renderQuickPick(),this._emitMonthChange(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_onQuickClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.quickGrid.contains(e)||this._chooseQuickMonth(Number(e.dataset.month))}_onQuickKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.quickGrid.contains(e))return;let i=Number(e.dataset.month),n=null;if(t.key==="ArrowLeft")n=i-1;else if(t.key==="ArrowRight")n=i+1;else if(t.key==="ArrowUp")n=i-3;else if(t.key==="ArrowDown")n=i+3;else if(t.key==="Home")n=0;else if(t.key==="End")n=11;else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._chooseQuickMonth(i);return}else if(t.key==="Escape"){t.preventDefault(),this._closeQuickPick(),this.refs.heading.focus();return}if(n===null)return;t.preventDefault(),n=Math.max(0,Math.min(11,n));let r=this.refs.quickGrid.querySelectorAll("[data-month]");for(let o of r)o.tabIndex=Number(o.dataset.month)===n?0:-1;r[n]?.focus()}_chooseQuickMonth(t){let e=new Date(this._viewYear,t,Math.min(this._focused.getDate(),new Date(this._viewYear,t+1,0).getDate()));this._focused=ct(e),this._viewMonth=t,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(t){let e=ct(t);return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_buttonForDate(t){return this.refs.days.querySelector(`[data-date="${D(t,"%Y-%m-%d")}"]`)}_message(t,e,...i){let n=this.msg(t,...i);return n===t?I(e,i):n}};function Gi(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function ct(s){return s?new Date(s.getFullYear(),s.getMonth(),s.getDate()):null}function vn(s){return s?new Date(s.getTime()):null}function Oa(s,t){s.setFullYear(t.getFullYear(),t.getMonth(),t.getDate())}function Pd(s){let t=Number(s);return Number.isInteger(t)&&t>=0&&t<=6?t:$e()}function Fa(s){let t=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-i.getTime())/864e5+1)/7)}var Ue=class extends te{static cssName="month-picker";static defaults={value:null,min:null,max:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??l("div");this._min=Xi(Qi(this.options.min)),this._max=Xi(Qi(this.options.max)),this._value=this._normalizeMonth(Qi(this.options.value));let e=this._value??Xi(new Date);this._year=e.getFullYear(),this._focusedMonth=e.getMonth();let i=l("div",{class:"zx-month-picker__surface"},l("div",{class:"zx-month-picker__header"},l("button",{ref:"previousYear",class:"zx-month-picker__nav",type:"button",ariaLabel:this._message("monthPicker.previousYear","Previous year")},g("chevron-left")),l("span",{ref:"year",class:"zx-month-picker__year",ariaLive:"polite"}),l("button",{ref:"nextYear",class:"zx-month-picker__nav",type:"button",ariaLabel:this._message("monthPicker.nextYear","Next year")},g("chevron-right"))),l("div",{ref:"grid",class:"zx-month-picker__grid",role:"grid",ariaLabel:this._message("monthPicker.chooseMonth","Choose month")}));return this._content=i,t.append(i),this.listen(this.refs.previousYear,"click",()=>this._stepYear(-1)),this.listen(this.refs.nextYear,"click",()=>this._stepYear(1)),this.listen(this.refs.grid,"click",n=>this._onMonthClick(n)),this.listen(this.refs.grid,"keydown",n=>this._onMonthKeydown(n)),this._renderMonths(),t}get(){return this._value?new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeMonth(Qi(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=Xi(t);return this._min&&e<this._min&&(e=new Date(this._min.getTime())),this._max&&e>this._max&&(e=new Date(this._max.getTime())),e}_renderMonths(){if(!this.refs?.grid)return;this.refs.year.textContent=String(this._year);let t=[];for(let e=0;e<12;e+=1){let i=new Date(this._year,e,1),n=!!(this._value&&Bd(i,this._value));t.push(l("button",{class:"zx-month-picker__month",type:"button",role:"gridcell",tabindex:e===this._focusedMonth?0:-1,ariaSelected:String(n),ariaDisabled:String(!this._inRange(i)),ariaLabel:D(i,"%B %Y"),dataset:{month:e}},D(i,"%b")))}this.refs.grid.replaceChildren(...t)}_stepYear(t){this._year+=t,this._renderMonths()}_onMonthClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.grid.contains(e)||this._selectMonth(Number(e.dataset.month))}_onMonthKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.grid.contains(e))return;let i=Number(e.dataset.month),n=null;if(t.key==="ArrowLeft")n=-1;else if(t.key==="ArrowRight")n=1;else if(t.key==="ArrowUp")n=-3;else if(t.key==="ArrowDown")n=3;else if(t.key==="Home")n=-(i%3);else if(t.key==="End")n=2-i%3;else if(t.key==="PageUp"){t.preventDefault(),this._stepYear(-1),this.focus();return}else if(t.key==="PageDown"){t.preventDefault(),this._stepYear(1),this.focus();return}else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._selectMonth(i);return}if(n===null)return;t.preventDefault();let r=this._year*12+i+n;this._year=Math.floor(r/12),this._focusedMonth=(r%12+12)%12,this._renderMonths(),this.focus()}_selectMonth(t){let e=new Date(this._year,t,1);this._inRange(e)&&(this._focusedMonth=t,this._value=e,this._renderMonths(),this.emit("change",{date:this.get()}))}_inRange(t){return!(this._min&&t<this._min)&&!(this._max&&t>this._max)}_button(t){return this.refs.grid.querySelector(`[data-month="${t}"]`)}};function Qi(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function Xi(s){return s?new Date(s.getFullYear(),s.getMonth(),1):null}function Bd(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()}function La(){C.register("month",(s,t)=>{let e=s.own(new Ue(null,{...t.props??{},value:t.value})),i=!1,n=()=>{e.el.setAttribute("aria-disabled",String(i));for(let r of e.el.querySelectorAll("button"))r.disabled=i};return s.listen(e.el,"change",r=>r.stopImmediatePropagation()),e.on("change",r=>s.emit("change",{value:r.detail.date})),{el:e.el,get:()=>e.get(),set:r=>{e.set(r instanceof Date?r:null,{silent:!0}),n()},focus:()=>e.focus(),setDisabled:r=>{i=!!r,n()}}})}var jd=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function st(s,t,e={}){if(!(s instanceof Element)||!(t instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let i=jd.has(e.placement)?e.placement:"bottom-start",n=Number(e.offset??4),r=e.flip??!0,o=e.matchWidth??!1,a=s.getAttribute("style"),c=t.getAttribute("style"),h=t.getAttribute("popover"),u=!1,d=null,p=()=>{},f=()=>{};if(t.setAttribute("popover","manual"),typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a")){let b=`--${x("zx-a")}`;s.style.setProperty("anchor-name",b),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.setProperty("position-anchor",b);let w=Hd(i,getComputedStyle(s).direction==="rtl");t.style.setProperty("position-area",w),t.style.setProperty("inset-area",w),t.style.setProperty("position-try-fallbacks",r?"flip-block, flip-inline, flip-block flip-inline":"none");let y=i.startsWith("top")?"margin-bottom":i.startsWith("bottom")?"margin-top":i.startsWith("left")?"margin-right":"margin-left";t.style.setProperty(y,`${n}px`),p=()=>{o&&(t.style.minWidth=`${s.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(d=new ResizeObserver(p),d.observe(s))}else t.style.position="fixed",t.style.inset="auto",t.style.margin="0",p=()=>qd(s,t,{placement:i,offset:n,flip:r,matchWidth:o}),window.addEventListener("scroll",p,{capture:!0,passive:!0}),window.addEventListener("resize",p,{passive:!0}),typeof ResizeObserver=="function"&&(d=new ResizeObserver(p),d.observe(s)),f=()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)};return $d(t),p(),{update(){u||p()},destroy(){u||(u=!0,d?.disconnect(),f(),Kd(t),Sn(s,"style",a),Sn(t,"style",c),Sn(t,"popover",h))}}}function Hd(s,t){return{"bottom-start":t?"bottom span-left":"bottom span-right","bottom-end":t?"bottom span-right":"bottom span-left","top-start":t?"top span-left":"top span-right","top-end":t?"top span-right":"top span-left","right-start":"right span-bottom","right-end":"right span-top","left-start":"left span-bottom","left-end":"left span-top",bottom:"bottom",top:"top",right:"right",left:"left"}[s]}function qd(s,t,{placement:e,offset:i,flip:n,matchWidth:r}){let o=s.getBoundingClientRect();r&&(t.style.minWidth=`${o.width}px`);let a=t.getBoundingClientRect(),c=document.documentElement.clientWidth||window.innerWidth,h=document.documentElement.clientHeight||window.innerHeight,u=e,d=Ra(e),p=o.bottom+i,f=o.top-i-a.height,_=o.right+i,b=o.left-i-a.width;n&&(d==="bottom"&&p+a.height>h&&f>=0?u=Ji(e,"bottom","top"):d==="top"&&f<0&&p+a.height<=h?u=Ji(e,"top","bottom"):d==="right"&&_+a.width>c&&b>=0?u=Ji(e,"right","left"):d==="left"&&b<0&&_+a.width<=c&&(u=Ji(e,"left","right")));let w=Ra(u),y,v;if(w==="bottom"||w==="top"){let k=getComputedStyle(s).direction==="rtl";u.endsWith("-end")?y=k?o.left:o.right-a.width:u.endsWith("-start")?y=k?o.right-a.width:o.left:y=o.left+(o.width-a.width)/2,v=w==="bottom"?p:f}else y=w==="right"?_:b,u.endsWith("-end")?v=o.bottom-a.height:u.endsWith("-start")?v=o.top:v=o.top+(o.height-a.height)/2;t.style.left=`${Math.round(B(y,0,Math.max(0,c-a.width)))}px`,t.style.top=`${Math.round(B(v,0,Math.max(0,h-a.height)))}px`}function Ra(s){return s.split("-")[0]}function Ji(s,t,e){return s.replace(t,e)}function $d(s){if(typeof s.showPopover=="function")try{s.showPopover()}catch{}}function Kd(s){if(typeof s.hidePopover=="function")try{s.hidePopover()}catch{}}function Sn(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}var Ud=6,qa=864e5;function we(s,t){let e=tt(ee(s)),i=tt(ee(t));return e&&i&&e.getTime()>i.getTime()?{start:i,end:e}:{start:e,end:i}}function Ye(s,t){let e=we(s,t);return!e.start||!e.end?0:Math.round((Ba(e.end)-Ba(e.start))/qa)}function $a(s,t,e){let i=tt(ee(s));if(!i)return null;let n=we(t,e);return!n.start&&!n.end?null:n.end?n.start?i.getTime()<n.start.getTime()||i.getTime()>n.end.getTime()?null:Y(i,n.start)?"start":Y(i,n.end)?"end":"middle":Y(i,n.end)?"end":null:Y(i,n.start)?"start":null}function We(s,t={}){let e=tt(ee(t.min)),i=tt(ee(t.max)),n=Zi(t.minNights)??0,r=Zi(t.maxNights),{start:o,end:a}=we(s?.start,s?.end);return o&&(o=kn(o,e,i)),a&&(a=kn(a,e,i)),!o||!a?{start:o,end:a}:(r!==null&&Ye(o,a)>r&&(a=F(o,r)),n>0&&Ye(o,a)<n&&(a=F(o,n),i&&a.getTime()>i.getTime()&&(a=new Date(i.getTime()),o=F(a,-n),e&&o.getTime()<e.getTime()))?{start:null,end:null}:{start:o,end:a})}var Ge=class extends m{static cssName="date-range-picker";static defaults={start:null,end:null,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._rootAttributes=Jd(t,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=tt(ee(this.options.min)),this._max=tt(ee(this.options.max)),this._minNights=Zi(this.options.minNights)??0,this._maxNights=Zi(this.options.maxNights),this._weekStart=Gd(this.options.weekStart),this._monthCount=Qd(this.options.months),this._presets=Wd(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let e=We({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=Kt(this._start)??this._clampFocus(tt(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),t.setAttribute("role","group"),t.setAttribute("aria-label",H("daterange.label","Date range")),t.dataset.months=String(this._monthCount),this._presets.length&&(t.dataset.presets="true");let i=l("div",{class:"zx-date-range-picker__surface"},this._presets.length?l("div",{ref:"presets",class:"zx-date-range-picker__presets",role:"group",ariaLabel:H("daterange.presets","Date range presets")},this._presets.map(r=>l("button",{class:"zx-date-range-picker__preset",type:"button",dataset:{preset:r.name}},r.label))):null,l("div",{ref:"calendars",class:"zx-date-range-picker__calendars"})),n=l("div",{ref:"status",class:"zx-date-range-picker__status",role:"status",ariaLive:"polite"});return this._nodes=[i,n],t.append(i,n),this.refs.presets&&this.listen(this.refs.presets,"click",r=>this._onPresetClick(r)),this.listen(this.refs.calendars,"click",r=>this._onCalendarClick(r)),this.listen(this.refs.calendars,"keydown",r=>this._onDayKeydown(r)),this.listen(this.refs.calendars,"mouseover",r=>this._onDayHover(r)),this.listen(this.refs.calendars,"mouseleave",()=>this._setHover(null)),this._renderCalendars(),this._announce(),t}get(){return{start:Kt(this._start),end:Kt(this._end)}}set(t={},{silent:e=!1}={}){let i=We({start:t?.start??null,end:t?.end??null},this._bounds());return this._start=i.start,this._end=i.end,this._picking=!!(i.start&&!i.end),this._remember(),this._hover=null,i.start?(this._focused=Kt(i.start),this._setView(i.start)):this._paint(),this._announce(),e||this.emit("change",this.get()),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}focus(){return this._buttonForDate(this._focused)?.focus(),this}enable(){return this._disabled=!1,this._paint(),this._syncDisabled(),this}disable(){return this._disabled=!0,this._hover=null,this._paint(),this._syncDisabled(),this}destroy(){for(let t of this._nodes??[])t.remove();this._nodes=[],this._dayCells=[],Zd(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=tt(t);if(!e||this._min&&e.getTime()<this._min.getTime()||this._max&&e.getTime()>this._max.getTime())return!1;if(!this._picking||!this._start||e.getTime()<=this._start.getTime())return!0;let i=Ye(this._start,e);return!(i<this._minNights||this._maxNights!==null&&i>this._maxNights)}_choose(t){let e=tt(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?Kt(this._start):null,this._committedEnd=t?Kt(this._end):null}_abandon(){return this._picking?(this._start=Kt(this._committedStart),this._end=Kt(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(t){return kn(t,this._min,this._max)}_visibleMonthCount(){let t=this.refs.calendars?.children??[],e=0;for(let i of t)i.getClientRects().length>0&&(e+=1);return e||this._monthCount}_setView(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;if(this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),!e){this._paint();return}this._renderCalendars(),this._emitMonthChange()}_ensureVisible(t){let e=this._visibleMonthCount(),i=ja(t)-(this._viewYear*12+this._viewMonth);if(i>=0&&i<e)return!1;let n=i<0?i:i-(e-1),r=new Date(this._viewYear,this._viewMonth+n,1);return this._viewYear=r.getFullYear(),this._viewMonth=r.getMonth(),!0}_pageView(t){if(this._disabled)return;let e=new Date(this._viewYear,this._viewMonth+t,1);this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._focused=this._focusInView(this._focused),this._renderCalendars(),this._emitMonthChange()}_focusInView(t){let e=this._visibleMonthCount(),i=ja(t)-(this._viewYear*12+this._viewMonth);if(i>=0&&i<e)return t;let n=new Date(this._viewYear,this._viewMonth+1,0).getDate();return new Date(this._viewYear,this._viewMonth,Math.min(t.getDate(),n))}_moveFocus(t){let e=tt(t);this._focused=e,this._ensureVisible(e)?(this._renderCalendars(),this._emitMonthChange()):this._paint(),this._buttonForDate(e)?.focus()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_onPresetClick(t){let e=t.target?.closest?.("[data-preset]");if(!e||this._disabled)return;let i=this._presets.find(r=>r.name===e.dataset.preset);if(!i)return;let n=i.range();this.set({start:n?.start??null,end:n?.end??null},{silent:!0}),this.emit("select",this.get()),this.emit("change",this.get())}_onCalendarClick(t){let e=t.target,i=e?.closest?.("[data-nav]");if(i){this._pageView(i.dataset.nav==="next"?1:-1);return}let n=this._cellFor(e);n&&this._choose(n.date)}_onDayHover(t){let e=this._cellFor(t.target);this._setHover(e?e.date:null)}_setHover(t){if(this._disabled||!this._picking)return;let e=t?tt(t):null;!e&&!this._hover||e&&this._hover&&Y(e,this._hover)||(this._hover=e,this._paint())}_onDayKeydown(t){let e=this._cellFor(t.target);if(!e)return;let i=e.date,n=null;if(t.key==="ArrowLeft")n=F(i,-1);else if(t.key==="ArrowRight")n=F(i,1);else if(t.key==="ArrowUp")n=F(i,-7);else if(t.key==="ArrowDown")n=F(i,7);else if(t.key==="PageUp")n=$t(i,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=$t(i,t.shiftKey?12:1);else if(t.key==="Home")n=F(i,-((i.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=F(i,6-(i.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._choose(i);return}else if(t.key==="Escape"){if(!this._abandon())return;t.preventDefault(),t.stopPropagation();return}!n||this._disabled||(t.preventDefault(),this._moveFocus(n))}_renderCalendars(){if(!this.refs?.calendars)return;this._dayCells=[];let t=[];for(let e=0;e<this._monthCount;e+=1)t.push(this._renderMonth(new Date(this._viewYear,this._viewMonth+e,1)));this.refs.calendars.replaceChildren(...t),this._paint(),this._syncDisabled()}_renderMonth(t){let e=D(t,"%B %Y"),i=(t.getDay()-this._weekStart+7)%7,n=F(t,-i),r=[];for(let o=0;o<Ud;o+=1){let a=F(n,o*7),c=l("tr"),h=Xd(a,t);this.options.showWeekNumbers&&c.append(l("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:h?H("daterange.week","Week %1",[Ha(a)]):null},h?String(Ha(a)):""));for(let u=0;u<7;u+=1){let d=F(a,u),p=l("td",{role:"presentation"});if(d.getMonth()===t.getMonth()&&d.getFullYear()===t.getFullYear()){let f=l("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:D(d,"%Y-%m-%d")}},D(d,"%e"));p.append(f),this._dayCells.push({date:d,cell:p,button:f})}c.append(p)}r.push(c)}return l("div",{class:"zx-date-range-picker__month"},l("div",{class:"zx-date-range-picker__header"},l("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"previous"},ariaLabel:H("daterange.previousMonth","Previous month")},g("chevron-left")),l("div",{class:"zx-date-range-picker__caption",ariaHidden:"true"},e),l("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"next"},ariaLabel:H("daterange.nextMonth","Next month")},g("chevron-right"))),l("table",{class:"zx-date-range-picker__grid",role:"grid",ariaLabel:e},l("thead",{},this._weekdayRow()),l("tbody",{},...r)))}_weekdayRow(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-range-picker__week-heading",scope:"col",ariaLabel:H("daterange.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let i=0;i<7;i+=1){let n=F(e,(this._weekStart+i)%7);t.append(l("th",{scope:"col",ariaLabel:D(n,"%A")},D(n,"%a")))}return t}_paint(){let t=new Date,e=null;for(let i of this._dayCells)Y(i.date,this._focused)&&(e=i);e||(e=this._dayCells[0]??null);for(let i of this._dayCells){let{date:n,cell:r,button:o}=i,a=this._dayState(n);An(r,"range",a.range),An(r,"rangeEdge",a.edge),An(o,"range",a.range),o.tabIndex=i===e?0:-1,o.setAttribute("aria-selected",String(a.range!==null&&a.range!=="preview")),o.setAttribute("aria-disabled",String(!this._selectable(n))),o.setAttribute("aria-label",this._dayLabel(n,a.range)),Y(n,t)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(t){if(this._start&&this._end){let i=$a(t,this._start,this._end);if(!i)return{range:null,edge:null};let n=Y(this._start,this._end);return i==="start"?{range:i,edge:n?"both":"start"}:i==="end"?{range:i,edge:n?"both":"end"}:{range:i,edge:null}}if(!this._start)return{range:null,edge:null};let e=this._previewEnd();return Y(t,this._start)?{range:"start",edge:e?"start":"both"}:e?t.getTime()>this._start.getTime()&&t.getTime()<=e.getTime()?{range:"preview",edge:Y(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=tt(t);return e.getTime()<=this._start.getTime()?null:this._selectable(e)?e:null}_dayLabel(t,e){let i=D(t,"%A, %e %B %Y");return e==="start"?`${i}, ${H("daterange.day.start","range start")}`:e==="end"?`${i}, ${H("daterange.day.end","range end")}`:e==="middle"?`${i}, ${H("daterange.day.middle","in selected range")}`:i}_syncDisabled(){this.el.setAttribute("aria-disabled",String(this._disabled));for(let t of this.el.querySelectorAll("button"))t.disabled=this._disabled}_announce(){this.refs?.status&&(this.refs.status.textContent=this._selectionLabel())}_selectionLabel(){if(!this._start)return H("daterange.status.empty","No date range selected");if(!this._end)return H("daterange.status.start","%1 selected, choose an end date",[D(this._start,"%e %B %Y")]);let t=Ye(this._start,this._end),e=t===1?H("daterange.night","1 night"):H("daterange.nights","%1 nights",[t]);return`${Yd(this._start,this._end)}, ${e}`}_cellFor(t){let e=t?.closest?.("[data-date]");return e?this._dayCells.find(i=>i.button===e)??null:null}_buttonForDate(t){return this._dayCells.find(e=>Y(e.date,t))?.button??null}};function Ka(){return[{name:"today",label:H("daterange.preset.today","Today"),range:()=>Va(St())},{name:"yesterday",label:H("daterange.preset.yesterday","Yesterday"),range:()=>Va(F(St(),-1))},{name:"last7",label:H("daterange.preset.last7","Last 7 days"),range:()=>({start:F(St(),-6),end:St()})},{name:"last30",label:H("daterange.preset.last30","Last 30 days"),range:()=>({start:F(St(),-29),end:St()})},{name:"thisMonth",label:H("daterange.preset.thisMonth","This month"),range:()=>Pa(St(),0)},{name:"lastMonth",label:H("daterange.preset.lastMonth","Last month"),range:()=>Pa(St(),-1)},{name:"thisQuarter",label:H("daterange.preset.thisQuarter","This quarter"),range:()=>{let s=St(),t=Math.floor(s.getMonth()/3)*3;return{start:new Date(s.getFullYear(),t,1),end:new Date(s.getFullYear(),t+3,0)}}},{name:"thisYear",label:H("daterange.preset.thisYear","This year"),range:()=>{let s=St();return{start:new Date(s.getFullYear(),0,1),end:new Date(s.getFullYear(),11,31)}}}]}function H(s,t,e){let i=vt(s);return I(i===s?t:i,e)}function Yd(s,t){if(Y(s,t))return D(s,"%e %B %Y");let e=D(t,"%e %B %Y");return s.getFullYear()!==t.getFullYear()?`${D(s,"%e %B %Y")} \u2013 ${e}`:s.getMonth()!==t.getMonth()?`${D(s,"%e %B")} \u2013 ${e}`:`${D(s,"%e")} \u2013 ${e}`}function Wd(s){return s===!0?Ka():Array.isArray(s)?s.filter(t=>t&&typeof t.range=="function").map((t,e)=>({name:String(t.name??`preset-${e}`),label:String(t.label??t.name??""),range:t.range})):[]}function St(){return tt(new Date)}function Va(s){return{start:s,end:new Date(s.getTime())}}function Pa(s,t){return{start:new Date(s.getFullYear(),s.getMonth()+t,1),end:new Date(s.getFullYear(),s.getMonth()+t+1,0)}}function ee(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function tt(s){return!s||Number.isNaN(s.getTime())?null:new Date(s.getFullYear(),s.getMonth(),s.getDate())}function Kt(s){return s?new Date(s.getTime()):null}function kn(s,t,e){return t&&s.getTime()<t.getTime()?new Date(t.getTime()):e&&s.getTime()>e.getTime()?new Date(e.getTime()):new Date(s.getTime())}function Ba(s){return Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())}function ja(s){return s.getFullYear()*12+s.getMonth()}function Zi(s){if(s==null||s==="")return null;let t=Number(s);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):null}function Gd(s){let t=Number(s);return Number.isInteger(t)&&t>=0&&t<=6?t:$e()}function Qd(s){let t=Number(s);return Number.isInteger(t)&&t>=1&&t<=4?t:2}function Xd(s,t){for(let e=0;e<7;e+=1){let i=F(s,e);if(i.getMonth()===t.getMonth()&&i.getFullYear()===t.getFullYear())return!0}return!1}function Ha(s){let t=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-i.getTime())/qa+1)/7)}function An(s,t,e){e==null?delete s.dataset[t]:s.dataset[t]=e}function Jd(s,t){return new Map(t.map(e=>[e,s.getAttribute(e)]))}function Zd(s,t){for(let[e,i]of t)i===null?s.removeAttribute(e):s.setAttribute(e,i)}var tf={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function Cn(s,t,e){let i=String(s??"").trim();if(i==="")return{start:null,end:null};let n=String(e??" \u2013 "),r=n.trim(),o=r!==""&&String(t).includes(r)&&/^\s|\s$/.test(n),a=o?"\\s+":"\\s*",c=o?"(?:\\s+|$)":"\\s*",h=r===""?[i]:i.split(new RegExp(`${a}${Pe(r)}${c}`));if(h.length>2)return null;let u=Z(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 d=Z(h[1].trim(),t);return d?we(u,d):null}function Ya(s,t,e){let i=s?.start??null,n=s?.end??null;return!i&&!n?"":n?i?`${D(i,t)}${e}${D(n,t)}`:D(n,t):D(i,t)}var Qe=class extends m{static cssName="date-range-box";static defaults={start:null,end:null,format:"%d.%m.%Y",separator:" \u2013 ",placeholder:null,clearable:!0,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._format=String(this.options.format||"%d.%m.%Y"),this._separator=String(this.options.separator??" \u2013 "),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._range=this._coerce({start:this.options.start,end:this.options.end});let e=x("zx-date-range-box-popover"),i=l("div",{class:"zx-date-range-box__content"},l("div",{ref:"control",class:"zx-date-range-box__control"},l("input",{ref:"input",class:"zx-date-range-box__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??this._placeholder(),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),l("button",{ref:"clear",class:"zx-icon-btn zx-date-range-box__clear",type:"button",ariaLabel:Ua("daterange.clear","Clear date range")},g("x",{size:13})),l("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:Ua("daterange.choose","Choose date range"),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},g("calendar"))),l("div",{ref:"popover",id:e,class:"zx-date-range-box__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=i,t.append(i),this._picker=new Ge(null,{start:this._range.start,end:this._range.end,min:this.options.min,max:this.options.max,months:this.options.months,weekStart:this.options.weekStart,showWeekNumbers:this.options.showWeekNumbers,minNights:this.options.minNights,maxNights:this.options.maxNights,presets:this.options.presets}),this.refs.popover.append(this._picker.el),this._picker.on("select",n=>{this._range={start:n.detail.start,end:n.detail.end},this._setValid(),this._syncDisplay()}),this._picker.on("change",n=>{this._apply({start:n.detail.start,end:n.detail.end},{push:!1}),n.detail.start&&n.detail.end&&this._close(!0)}),this.listen(this.refs.input,"blur",()=>{this._open||this._commitText()}),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.clear(),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return t==="seconds"?{start:this._range.start?Math.floor(this._range.start.getTime()/1e3):null,end:this._range.end?Math.floor(this._range.end.getTime()/1e3):null}:{start:this._range.start?new Date(this._range.start.getTime()):null,end:this._range.end?new Date(this._range.end.getTime()):null}}set(t,{silent:e=!1}={}){return this._apply(this._coerce(t),{silent:e}),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}open(){return this._disabled||this._open?this:(this._picker.set(this._range,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=st(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(),zn(this.el,"data-state",this._originalState),zn(this.el,"aria-disabled",this._originalAriaDisabled),super.destroy()}_apply(t,{silent:e=!1,push:i=!0}={}){this._range=t,i&&this._picker?.set(this._range,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",this.get())}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set({start:null,end:null});return}let e=Cn(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(Cn(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()!==""?Z(t.trim(),this._format):null}_clamp(t){return We(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=>tf[e]??e);return`${t}${this._separator}${t}`}_syncDisplay(){this.refs.input.value=Ya(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"&&zn(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 Ua(s,t,e){let i=vt(s);return I(i===s?t:i,e)}function zn(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}function Wa(){C.register("daterange",(s,t)=>{let e=s.own(new Qe(null,{...t.props??{},disabled:!!t.disabled,start:t.value?.start??null,end:t.value?.end??null}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:{start:i.detail.start,end:i.detail.end}})),{el:e.el,get:()=>e.get(),set:i=>e.set(i,{silent:!0}),focus:()=>e.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var et=class extends m{static cssName="datebox";static defaults={value:null,format:"%d.%m.%Y",time:!1,min:null,max:null,placeholder:null,clearable:!0,disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._format=ef(this.options.format,this.options.time),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._min=Ga(this.options.min),this._max=Ga(this.options.max),this._value=this._normalizeValue(this.options.value);let e=x("zx-datebox-popover"),i=l("div",{class:"zx-datebox__content"},l("div",{ref:"control",class:"zx-datebox__control"},l("input",{ref:"input",class:"zx-datebox__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??sf(this._format),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),l("button",{ref:"clear",class:"zx-icon-btn zx-datebox__clear",type:"button",ariaLabel:"Clear date"},g("x",{size:13})),l("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:"Choose date","aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},g("calendar"))),l("div",{ref:"popover",id:e,class:"zx-datebox__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=i,t.append(i),this._picker=new te(null,{value:this._value,min:this._min,max:this._max,time:!!this.options.time}),this.refs.popover.append(this._picker.el),this._picker.on("change",n=>{this.set(n.detail.date),this.options.time||this._close(!0)}),this.listen(this.refs.input,"blur",()=>this._commitText()),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.set(null),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return this._value?t==="seconds"?Math.floor(this._value.getTime()/1e3):new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeValue(t),this._picker?.set(this._value,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",{date:this._copyValue()}),this}open(){return this._disabled||this._open?this:(this._picker.set(this._value,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=st(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=Z(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=Z(t,this._format)),!e||Number.isNaN(e.getTime())?null:fn(e,this._min,this._max)}_syncDisplay(){this.refs.input.value=this._value?D(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}},Tn=function(t,e={}){return new et(t,{...e,time:!0})};function Ga(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function ef(s,t){let e=String(s||"%d.%m.%Y");return t&&!/%[HM]/.test(e)?`${e} %H:%M`:e}function sf(s){return s.replace(/%[demYyHMS]/g,t=>({"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY","%H":"HH","%M":"MM","%S":"SS"})[t]??t)}function Xa(){Qa("date",s=>new et(null,s)),Qa("datetime",s=>Tn(null,s))}function Qa(s,t){C.register(s,(e,i)=>{let n=e.own(t({...i.props??{},value:i.value}));return e.listen(n.el,"change",r=>r.stopImmediatePropagation()),n.on("change",r=>e.emit("change",{value:r.detail.date})),{el:n.el,get:()=>n.get(),set:r=>n.set(r,{silent:!0}),focus:()=>n.focus(),setDisabled:r=>r?n.disable():n.enable()}})}var Xe=class extends m{static cssName="field-upload";static defaults={url:"",paramName:"upload",params:{},headers:{},multiple:!1,accept:null,maxSize:null,autoUpload:!0,preview:!0,http:null};render(){let t=this.el??l("div");this.el=t,this._ownedNodes=[],this._files=[],this._disabled=!1,this._running=!1,this._runId=0,this._xhr=null,this._transportController=null,this._previewUrl=null,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled");let e=x("zx-upload");return this._input=l("input",{class:"zx-field-upload__input",id:e,type:"file",multiple:!!this.options.multiple,accept:this.options.accept??void 0,tabIndex:-1}),this._dropzone=l("button",{class:"zx-field-upload__dropzone",type:"button",ariaControls:e,ariaLabel:this.options.multiple?"Choose files or drop them here":"Choose a file or drop it here"},l("span",{class:"zx-field-upload__prompt"},this.options.multiple?"Drop files here or choose files":"Drop a file here or choose a file"),l("span",{class:"zx-field-upload__hint"},nf(this.options))),this._preview=l("div",{class:"zx-field-upload__preview"}),this._progress=l("progress",{class:"zx-field-upload__progress",max:100,value:0,ariaLabel:"Upload progress"}),this._progressText=l("span",{class:"zx-field-upload__progress-text"},"0%"),this._abort=l("button",{class:"zx-btn zx-field-upload__abort",type:"button"},"Abort"),this._progressWrap=l("div",{class:"zx-field-upload__progress-wrap",hidden:!0},this._progress,this._progressText,this._abort),this._status=l("div",{class:"zx-field-upload__status",role:"status",ariaLive:"polite"}),this._ownedNodes.push(this._input,this._dropzone,this._preview,this._progressWrap,this._status),t.append(...this._ownedNodes),this.listen(this._dropzone,"click",()=>{!this._disabled&&!this._running&&this._input.click()}),this.listen(this._input,"change",()=>this._selectFiles(this._input.files)),this.listen(this._dropzone,"dragenter",i=>this._handleDragOver(i)),this.listen(this._dropzone,"dragover",i=>this._handleDragOver(i)),this.listen(this._dropzone,"dragleave",i=>{(!(i.relatedTarget instanceof Node)||!this._dropzone.contains(i.relatedTarget))&&this._setState("idle")}),this.listen(this._dropzone,"drop",i=>{i.preventDefault(),!(this._disabled||this._running)&&(this._setState("idle"),this._selectFiles(i.dataTransfer?.files??[]))}),this.listen(this._abort,"click",()=>this.abort()),this.setDisabled(!1),t}async upload(t=null){if(t!==null&&!this._setFiles(t)||this._disabled||this._running||this._files.length===0)return null;this._running=!0,this._runId+=1;let e=this._runId;this._setState("uploading"),this._progressWrap.hidden=!1,this._abort.hidden=!1,this._setProgress(0),this._status.textContent="Uploading\u2026";try{let i=this.options.http?await this._uploadInjected():await this._uploadXhr();return e!==this._runId?null:(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setProgress(100),this._setState("success"),this._status.textContent="Upload complete.",this.emit("success",{response:i}),i)}catch(i){if(e!==this._runId)return null;let n=i instanceof Error?i:new Error(String(i));return n.name==="AbortError"?(this._finishAbort(),null):(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("error"),this._status.textContent=n.message,this.emit("error",{error:n}),null)}}abort(){return this._running?(this._xhr?.abort(),this._transportController?.abort(),this._finishAbort(),this):this}clear(){return this._running&&this.abort(),this._files=[],this._input.value="",this._revokePreview(),this._preview.replaceChildren(),this._progress.value=0,this._progressText.textContent="0%",this._progressWrap.hidden=!0,this._status.textContent="",this._setState("idle"),this}setDisabled(t){return this._disabled=!!t,this._input.disabled=this._disabled,this._dropzone.disabled=this._disabled,this.el.dataset.disabled=String(this._disabled),this}_selectFiles(t){this._setFiles(t)&&(this._input.value="",this.options.autoUpload&&this.upload())}_setFiles(t){if(this._disabled||this._running)return!1;let e=Array.from(t??[]),i=this.options.multiple?e:e.slice(0,1);if(i.length===0)return!1;let n=i.find(o=>!of(o,this.options.accept));if(n)return this._selectionError(new Error(`${n.name} is not an accepted file type.`)),!1;let r=this.options.maxSize==null?null:i.find(o=>o.size>Number(this.options.maxSize));return r?(this._selectionError(new Error(`${r.name} exceeds the maximum file size.`)),!1):(this._files=i,this._renderPreview(),this._status.textContent=i.map(o=>o.name).join(", "),this._setState("selected"),this.emit("select",{files:this._files.slice()}),!0)}_handleDragOver(t){t.preventDefault(),!this._disabled&&!this._running&&this._setState("dragover")}_uploadInjected(){let t=this.options.http;this._transportController=new AbortController;let e={files:this._files.slice(),paramName:String(this.options.paramName),params:{...this.options.params},headers:{...this.options.headers},signal:this._transportController.signal,onProgress:i=>this._setProgress(i)};return typeof t.upload=="function"?t.upload(String(this.options.url),e):typeof t.request=="function"?t.request(String(this.options.url),{method:"POST",data:e.params,files:e.files,headers:e.headers,signal:e.signal,onProgress:e.onProgress,paramName:e.paramName}):Promise.reject(new TypeError("Injected upload transport requires upload() or request()"))}_uploadXhr(){return typeof XMLHttpRequest!="function"?Promise.reject(new Error("XMLHttpRequest is not available")):new Promise((t,e)=>{let i=new XMLHttpRequest;this._xhr=i,i.open("POST",String(this.options.url));for(let[n,r]of Object.entries(this.options.headers??{}))i.setRequestHeader(n,String(r));this.listen(i.upload,"progress",n=>{n.lengthComputable&&this._setProgress(n.loaded/n.total*100)}),this.listen(i,"load",()=>{if(i.status<200||i.status>=300){e(new Error(`Upload failed with HTTP ${i.status}`));return}t(lf(i.responseText))}),this.listen(i,"error",()=>e(new Error("Upload request failed"))),this.listen(i,"abort",()=>e(cf())),i.send(af(this._files,String(this.options.paramName),this.options.params))})}_setProgress(t){let e=Math.max(0,Math.min(100,Number(t)||0));this._progress.value=e,this._progressText.textContent=`${Math.round(e)}%`,this.emit("progress",{percent:e})}_finishAbort(){this._running&&(this._runId+=1,this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("idle"),this._status.textContent="Upload aborted.",this.emit("abort",{}))}_selectionError(t){this._setState("error"),this._status.textContent=t.message,this.emit("error",{error:t})}_renderPreview(){this._revokePreview(),this._preview.replaceChildren();let t=this._files[0];!this.options.preview||!t?.type?.startsWith("image/")||typeof URL>"u"||typeof URL.createObjectURL!="function"||(this._previewUrl=URL.createObjectURL(t),this._preview.append(l("img",{class:"zx-field-upload__image",src:this._previewUrl,alt:`Preview of ${t.name}`})))}_revokePreview(){this._previewUrl&&typeof URL<"u"&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(this._previewUrl),this._previewUrl=null}_setState(t){t==="idle"?this.el.removeAttribute("data-state"):this.el.dataset.state=t}destroy(){this._running&&this.abort(),this._revokePreview();for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function nf(s){let t=[];return s.accept&&t.push(String(s.accept)),s.maxSize!=null&&t.push(`up to ${rf(Number(s.maxSize))}`),t.join(" \xB7 ")||"Choose from this device"}function rf(s){return s<1024?`${s} B`:s<1024*1024?`${Math.round(s/1024)} KB`:`${Math.round(s/(1024*1024))} MB`}function of(s,t){if(!t)return!0;let e=String(s.type??"").toLowerCase();return String(t).split(",").map(i=>i.trim().toLowerCase()).filter(Boolean).some(i=>i.startsWith(".")?s.name.toLowerCase().endsWith(i):i.endsWith("/*")?e.startsWith(i.slice(0,-1)):e===i)}function af(s,t,e){let i=new FormData;for(let n of s)i.append(t,n);for(let[n,r]of Object.entries(e??{}))Ja(i,n,r);return i}function Ja(s,t,e){if(e==null)return;if(Array.isArray(e)){for(let n of e)Ja(s,t,n);return}typeof Blob=="function"&&e instanceof Blob?s.append(t,e):s.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function lf(s){if(!s)return null;try{return JSON.parse(s)}catch{return s}}function cf(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let s=new Error("Upload aborted");return s.name="AbortError",s}function Za(){C.register("upload",(s,t)=>{let e=s.own(new Xe(null,{...t.props??{}}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("select",()=>s.emit("change",{value:null})),{el:e.el,get:()=>null,set:()=>e.clear(),focus:()=>e.el.querySelector(".zx-field-upload__dropzone")?.focus(),setDisabled:i=>e.setDisabled(i)}})}var tl=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),el=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),Je=class extends m{static cssName="multi-value-editor";static defaults={values:[],options:null,addLabel:"Add value",reorder:"both"};render(){let t=this.el??l("div");return this.el=t,this._values=Array.isArray(this.options.values)?this.options.values.map(String):[],this._ownedNodes=[],this._initialState=t.getAttribute("data-state"),this._dragIndex=-1,this._armed=null,this._rows=l("div",{class:"zx-multi-value-editor__rows"}),this._add=l("button",{class:"zx-btn zx-multi-value-editor__add",type:"button",dataset:{action:"add"}},String(this.options.addLabel??"Add value")),this._ownedNodes.push(this._rows,this._add),t.append(this._rows,this._add),this.listen(t,"click",e=>this._handleClick(e)),this.listen(this._rows,"change",e=>this._handleChange(e)),this.listen(this._rows,"keydown",e=>this._handleKeydown(e)),this._reorder().drag&&(this.listen(this._rows,"pointerdown",e=>this._handlePointerDown(e)),this.listen(this._rows,"dragstart",e=>this._handleDragStart(e)),this.listen(this._rows,"dragover",e=>this._handleDragOver(e)),this.listen(this._rows,"dragleave",e=>this._handleDragLeave(e)),this.listen(this._rows,"drop",e=>this._handleDrop(e)),this.listen(this._rows,"dragend",()=>this._finishDrag()),this.listen(document,"pointerup",()=>this._disarm()),this.listen(document,"pointercancel",()=>this._disarm())),this._renderRows(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=Array.isArray(t)?t.map(String):[],this._renderRows(),e||this.emit("change",{values:this.getValues()}),this}_reorder(){return tl[this.options.reorder]??tl.both}_renderRows(t=-1,e="value"){let i=il(this.options.options),n=this.options.options!==null,{drag:r,buttons:o}=this._reorder(),a=this._values.length-1,c=this._values.map((h,u)=>{let d=!n||i.some(([f])=>f===h)?i:[[h,h],...i],p=n?l("select",{class:"zx-multi-value-editor__value",ariaLabel:`Value ${u+1}`,dataset:{index:u}},d.map(([f,_])=>l("option",{value:f,selected:f===h},_))):l("input",{class:"zx-multi-value-editor__value",type:"text",value:h,ariaLabel:`Value ${u+1}`,dataset:{index:u}});return l("div",{class:"zx-multi-value-editor__row",dataset:{row:u}},r?l("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}},g("drag",{size:12})):null,p,l("div",{class:"zx-multi-value-editor__controls"},o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(u===0),ariaLabel:`Move value ${u+1} up`,dataset:{action:"up",index:u}},g("chevron-up",{size:12})):null,o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(u===a),ariaLabel:`Move value ${u+1} down`,dataset:{action:"down",index:u}},g("chevron-down",{size:12})):null,l("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${u+1}`,dataset:{action:"remove",index:u}},g("x",{size:12}))))});this._rows.replaceChildren(...c),t>=0&&c[Math.min(t,c.length-1)]?.querySelector(el[e]??el.value)?.focus()}_handleClick(t){let e=t.target instanceof Element?t.target.closest("[data-action]"):null;if(!e||!this.el.contains(e)||e.getAttribute("aria-disabled")==="true")return;let i=e.dataset.action,n=Number(e.dataset.index);if(i==="add"){let r=il(this.options.options);this._values.push(this.options.options===null?"":r[0]?.[0]??""),this._renderRows(this._values.length-1),this._emitChange()}else i==="remove"&&Number.isInteger(n)?(this._values.splice(n,1),this._renderRows(Math.min(n,this._values.length-1)),this._emitChange()):(i==="up"||i==="down")&&Number.isInteger(n)&&this._move(n,n+(i==="up"?-1:1),i)}_handleChange(t){let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e||!("value"in e))return;let i=Number(e.dataset.index);!Number.isInteger(i)||i<0||i>=this._values.length||(this._values[i]=e.value,this._emitChange())}_handleKeydown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(!e)return;let i=Number(e.dataset.index),n=t.key==="ArrowUp"?i-1:t.key==="ArrowDown"?i+1:t.key==="Home"?0:t.key==="End"?this._values.length-1:-1;n<0||n>=this._values.length||(t.preventDefault(),this._move(i,n,"handle"))}_handlePointerDown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(this._disarm(),!e||e.disabled)return;let i=e.closest(".zx-multi-value-editor__row");i&&(i.draggable=!0,this._armed=i)}_disarm(){this._armed&&(this._armed.draggable=!1),this._armed=null}_handleDragStart(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__row"):null;if(!e||e!==this._armed){t.preventDefault();return}this._dragIndex=Number(e.dataset.row),e.dataset.dragging="true",this.el.setAttribute("data-state","dragging"),t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move")}_handleDragOver(t){this._dragIndex<0||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._showDrop(this._dropTarget(t.clientY)))}_handleDragLeave(t){let e=t.relatedTarget;e instanceof Node&&this._rows.contains(e)||this._clearDrop()}_handleDrop(t){if(this._dragIndex<0)return;t.preventDefault();let e=this._dragIndex,i=this._dropTarget(t.clientY);this._finishDrag(),this._move(e,i>e?i-1:i,"handle")}_finishDrag(){this._dragIndex=-1,this._disarm(),this._clearDrop();for(let t of this._rows.children)delete t.dataset.dragging;this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_dropTarget(t){let e=[...this._rows.children];for(let[i,n]of e.entries()){let r=n.getBoundingClientRect();if(t<r.top+r.height/2)return i}return e.length}_showDrop(t){let e=[...this._rows.children],i=t===this._dragIndex||t===this._dragIndex+1;for(let[n,r]of e.entries()){let o=r;!i&&n===t?o.dataset.drop="before":!i&&t===e.length&&n===e.length-1?o.dataset.drop="after":delete o.dataset.drop}}_clearDrop(){for(let t of this._rows.children)delete t.dataset.drop}_move(t,e,i){let n=this._values.length;if(t===e||t<0||e<0||t>=n||e>=n)return!1;let[r]=this._values.splice(t,1);return this._values.splice(e,0,r),this._renderRows(e,i),this._emitChange(),!0}_emitChange(){this.emit("change",{values:this.getValues()})}destroy(){this._initialState===null?this.el?.removeAttribute("data-state"):this.el?.setAttribute("data-state",this._initialState);for(let t of this._ownedNodes??[])t.remove();super.destroy()}};function il(s){return Array.isArray(s)?s.map(t=>[String(t),String(t)]):s&&typeof s=="object"?Object.entries(s).map(([t,e])=>[t,String(e)]):[]}function sl(){C.register("multivalueeditor",(s,t)=>{let e=s.own(new Je(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]})),i=new WeakMap,n=!1,r=()=>{e.el.setAttribute("aria-disabled",String(n));for(let o of e.el.querySelectorAll("input, button, select, textarea"))n?(i.has(o)||i.set(o,!!o.disabled),o.disabled=!0):i.has(o)&&(o.disabled=i.get(o),i.delete(o))};return s.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>s.emit("change",{value:o.detail.values})),{el:e.el,get:()=>e.getValues(),set:o=>{e.setValues(Array.isArray(o)?o:[],{silent:!0}),r()},focus:()=>e.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),setDisabled:o=>{n=!!o,r()}}})}var Et=class extends m{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:A(this.el);let t=this.el??l("div");this.el=t;let e=hf(this.options.step);this._step=e,this._precision=this.options.precision===null?uf(e):Math.max(0,Math.trunc(Number(this.options.precision)||0));let i=this._stepButton("down","minus"),n=this._stepButton("up","plus"),r=l("input",{ref:"input",class:"zx-number-field__input",type:"text",role:"spinbutton",inputMode:this._precision>0?"decimal":"numeric",autocomplete:"off",spellcheck:!1,placeholder:String(this.options.placeholder??""),ariaLabel:this.options.label??void 0,name:this.options.name??void 0,required:!!this.options.required}),o=[i,r];return this.options.unit!==null&&o.push(l("span",{ref:"unit",class:"zx-number-field__unit",ariaHidden:"true"},String(this.options.unit))),o.push(n),t.replaceChildren(...o),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(r,"input",()=>this._onInput()),this.listen(r,"keydown",a=>this._onKeydown(a)),this.listen(r,"focus",()=>{this._editing=!0,this._syncInput()}),this.listen(r,"blur",()=>{this._commit(),this._editing=!1,this._syncInput()}),this.listen(i,"click",()=>this._stepBy(-1)),this.listen(n,"click",()=>this._stepBy(1)),this.listen(r,"wheel",a=>{document.activeElement!==r||this._disabled||this._readonly||(a.preventDefault(),this._stepBy(a.deltaY<0?1:-1))},{passive:!1}),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=this._coerce(t),n=i!==this._value;return this._value=i,this._syncInput(),n&&!e&&this.emit("change",{value:this._value}),this}stepUp(t=1){return this._stepBy(t)}stepDown(t=1){return this._stepBy(-t)}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}focus(){return this.refs.input.focus(),this}getInput(){return this.refs.input}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}setRange(t,e){return this._min=t==null?null:Number(t),this._max=e==null?null:Number(e),this.set(this._value,{silent:!0})}_stepButton(t,e){return l("button",{ref:t,class:"zx-number-field__step",type:"button",tabIndex:-1,ariaHidden:"true",dataset:{step:t}},g(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=xe(t,this.options.group?this._separators():null);return e===null?null:ts(e,{min:this._rangeMin,max:this._rangeMax,step:this._step,precision:this._precision})}_stepBy(t){if(this._disabled||this._readonly)return this;let e=this._rangeMin,i=this._rangeMax,r=xe(this.refs.input.value)??this._value,o=r===null?e??0:r,a=r===null&&t>0&&e!==null?e-this._step*t:o,c=nl(a+this._step*t,this._precision);return this.options.wrap&&e!==null&&i!==null&&(c>i?c=e:c<e&&(c=i)),this.set(c),this}_separators(){if(this._localeSeparators)return this._localeSeparators;let t=new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:1}).formatToParts(1234.5);return this._localeSeparators={group:t.find(e=>e.type==="group")?.value??",",decimal:t.find(e=>e.type==="decimal")?.value??"."},this._localeSeparators}_onInput(){let t=xe(this.refs.input.value,this.options.group?this._separators():null);this._syncAria(t),this.emit("input",{value:t})}_onKeydown(t){if(this._disabled||this._readonly)return;let e=Math.max(1,Math.trunc(Number(this.options.largeStep)||1)),n={ArrowUp:()=>this._stepBy(1),ArrowDown:()=>this._stepBy(-1),PageUp:()=>this._stepBy(e),PageDown:()=>this._stepBy(-e),Home:()=>this._rangeMin===null?null:this.set(this._rangeMin),End:()=>this._rangeMax===null?null:this.set(this._rangeMax),Enter:()=>this._commit()}[t.key];n&&(t.key==="Home"&&this._rangeMin===null||t.key==="End"&&this._rangeMax===null||(t.preventDefault(),n()))}_commit(){this.set(this.refs.input.value)}_syncInput(){let t=this.refs.input,e=this._value===null?"":this._format(this._value,this._editing);t.value!==e&&(t.value=e),this._syncAria(this._value)}_syncAria(t){let e=this.refs.input,i=this._rangeMin,n=this._rangeMax;if(i===null?e.removeAttribute("aria-valuemin"):e.setAttribute("aria-valuemin",String(i)),n===null?e.removeAttribute("aria-valuemax"):e.setAttribute("aria-valuemax",String(n)),t===null)e.removeAttribute("aria-valuenow"),e.setAttribute("aria-valuetext",this._message("numberField.empty","Empty"));else{e.setAttribute("aria-valuenow",String(t));let r=this.options.unit===null?"":` ${this.options.unit}`;e.setAttribute("aria-valuetext",`${this._format(t,!1)}${r}`)}this.el.toggleAttribute("data-empty",t===null)}_format(t,e){return this.options.group?new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:this._precision,maximumFractionDigits:this._precision,useGrouping:!e}).format(t):t.toFixed(this._precision)}_message(t,e){let i=this.msg(t);return i===t?e:i}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.up.disabled=this._disabled||this._readonly,this.refs.down.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function xe(s,t=null){if(typeof s=="number")return Number.isFinite(s)?s:null;if(s==null)return null;let e=String(s).trim();if(e==="")return null;let i;if(t)i=e.split(t.group).join("").replace(t.decimal,".").replace(/[^\d.\-+eE]/g,"");else{let r=e.replace(/[^\d,.\-+eE]/g,""),o=r.lastIndexOf(","),a=r.lastIndexOf(".");i=r,o>=0&&o>a?i=r.replace(/\./g,"").replace(",","."):o>=0&&(i=r.replace(/,/g,""))}if(!/\d/.test(i))return null;let n=Number(i);return Number.isFinite(n)?n:null}function ts(s,{min:t,max:e,step:i,precision:n}){let r=s;if(i>0){let o=t??0;r=o+Math.round((s-o)/i)*i}return r=nl(r,n),t!==null&&r<t?t:e!==null&&r>e?e:r}function hf(s){let t=Number(s);return Number.isFinite(t)&&t>0?t:1}function uf(s){let t=String(s),e=t.match(/e-(\d+)/i);if(e)return Number(e[1]);let i=t.split(".")[1];return i?i.length:0}function nl(s,t){return Number.isFinite(s)?Number(s.toFixed(Math.min(15,Math.max(0,t)))):s}function rl(){C.register("number",(s,t)=>{let e=s.own(new Et(null,{label:t.label?String(t.label):void 0,placeholder:t.placeholder,required:t.required,...t.props??{}})),i=!1;return s.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{i||s.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get(),set:n=>{i=!0;try{e.set(n===""||n===null||n===void 0?null:n,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var ti=class extends m{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:A(this.el);let t=this.el??l("div");this.el=t,this._max=Math.max(1,Math.trunc(Number(this.options.max)||5)),this._step=this.options.allowHalf?.5:1,this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this._name=x("zx-rating");let e=l("div",{ref:"symbols",class:"zx-rating__symbols",role:"radiogroup",ariaLabel:String(this.options.label??"Rating")});for(let i=1;i<=this._max;i+=1){let n=l("span",{class:"zx-rating__symbol"},l("span",{class:"zx-rating__glyph",ariaHidden:"true"},g(this.options.icon,{size:Ze[this.options.size]??Ze.md})),l("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},g(this.options.icon,{size:Ze[this.options.size]??Ze.md})));this.options.allowHalf?n.append(this._radio(i-.5,"half"),this._radio(i,"full")):n.append(this._radio(i,"full")),e.append(n)}return t.replaceChildren(e,l("span",{ref:"readout",class:"zx-rating__readout"})),t.dataset.size=Ze[this.options.size]?this.options.size:"md",this.listen(e,"keydown",i=>this._onKeydown(i)),this.listen(e,"pointerleave",()=>this._setPreview(null)),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=this._clamp(t),n=i!==this._value;return this._value=i,this._preview=null,this._sync(),n&&!e&&this.emit("change",{value:this._value}),this}clear({silent:t=!1}={}){return this.set(0,{silent:t})}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}setCount(t){return this._count=t,this._syncReadout(),this}focus(){return(this._radios.find(e=>e.tabIndex===0)??this._radios[0])?.focus(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}_radio(t,e){let i=l("button",{class:"zx-rating__radio",type:"button",role:"radio",tabIndex:-1,ariaChecked:"false",ariaLabel:this._stepLabel(t),dataset:{value:String(t),part:e}});return this.listen(i,"click",n=>{this._choose(t,n.detail>0)}),this.listen(i,"pointerenter",()=>this._setPreview(t)),this.listen(i,"focus",()=>this._setPreview(t)),this.listen(i,"blur",()=>this._setPreview(null)),this._radios.push(i),i}_stepLabel(t){let e=this.options.labels;if(Array.isArray(e)){let i=Math.round(t/this._step)-1;if(e[i]!=null)return String(e[i])}return this._message("rating.value","%1 of %2",[t,this._max])}_message(t,e,i){let n=this.msg(t,...i);return n===t?I(e,i):n}_choose(t,e){this._disabled||this._readonly||(e&&this.options.clearable&&t===this._value?this.set(0):this.set(t))}_onKeydown(t){if(this._disabled||this._readonly)return;let e=["ArrowRight","ArrowDown"],i=["ArrowLeft","ArrowUp"];if(e.includes(t.key))t.preventDefault(),this.set(this._value>=this._max?this._step:(this._value||0)+this._step);else if(i.includes(t.key))t.preventDefault(),this.set(this._value<=this._step?this._max:this._value-this._step);else if(t.key==="Home")t.preventDefault(),this.set(this._step);else if(t.key==="End")t.preventDefault(),this.set(this._max);else if((t.key==="Delete"||t.key==="Backspace")&&this.options.clearable)t.preventDefault(),this.set(0);else return;this.focus()}_setPreview(t){let e=this._disabled||this._readonly?null:t;e!==this._preview&&(this._preview=e,this._paint(),this.emit("hover",{value:this._preview}))}_clamp(t){let e=Number(t);if(!Number.isFinite(e)||e<=0)return 0;let i=Math.round(e/this._step)*this._step;return Math.min(this._max,Math.max(0,i))}_sync(){for(let e of this._radios){let i=Number(e.dataset.value);e.setAttribute("aria-checked",String(i===this._value))}let t=this._radios.find(e=>e.getAttribute("aria-checked")==="true");for(let e of this._radios)e.tabIndex=-1;(t??this._radios[0]).tabIndex=0,this._paint(),this._syncReadout()}_paint(){let t=this._preview??this._value;this.refs.symbols.querySelectorAll(".zx-rating__symbol").forEach((i,n)=>{let r=Math.min(1,Math.max(0,t-n));i.style.setProperty("--zx-rating-fill",`${r*100}%`),i.toggleAttribute("data-preview",this._preview!==null)}),this.el.dataset.value=String(t)}_syncReadout(){let t=this.refs.readout;if(!t)return;let e=this._count===void 0?this.options.count:this._count,i=[];this.options.showValue&&i.push(df(this._value,this._step)),e!=null&&i.push(this._message("rating.count","%1 ratings",[e])),t.textContent=i.join(" \xB7 ")}_syncDisabled(){let t=this._disabled||this._readonly;for(let e of this._radios)e.disabled=this._disabled;this.refs.symbols.setAttribute("aria-readonly",String(this._readonly)),this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this.el.toggleAttribute("data-inert",t),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}},Ze={sm:14,md:18,lg:24};function df(s,t){return t<1?s.toFixed(1):String(s)}function ol(){C.register("rating",(s,t)=>{let e=s.own(new ti(null,{label:t.label?String(t.label):void 0,...t.props??{}})),i=!1;return e.on("change",n=>{i||s.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get()||null,set:n=>{i=!0;try{e.set(Number(n)||0,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var ff=["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 In(s){let t=!1,e=null;function i(n){if(n.key!=="Tab")return;let r=al(s);if(r.length===0){n.preventDefault();return}let o=r[0],a=r[r.length-1];n.shiftKey&&(document.activeElement===o||!s.contains(document.activeElement))?(n.preventDefault(),a.focus()):!n.shiftKey&&(document.activeElement===a||!s.contains(document.activeElement))&&(n.preventDefault(),o.focus())}return{activate(){t||(t=!0,e=document.activeElement,document.addEventListener("keydown",i),al(s)[0]?.focus())},deactivate(){t&&(t=!1,document.removeEventListener("keydown",i),e?.isConnected&&typeof e.focus=="function"&&e.focus(),e=null)}}}function Dt(s,t,{orientation:e="vertical",wrap:i=!0}={}){let n=new AbortController,r=new Map,o=!1;function a(){return Array.from(s.querySelectorAll(t)).filter(f=>(c(f),ll(f)))}function c(f){r.has(f)||r.set(f,f.getAttribute("tabindex"))}function h(f=null){let _=a(),b=f&&_.includes(f)?f:_.find(w=>w.tabIndex===0)??_[0];for(let w of _){let y=w===b?0:-1;w.tabIndex!==y&&(w.tabIndex=y)}}function u(f){let _=a(),b=f.target?.closest?.(t)??null,w=_.indexOf(b);if(w<0)return;let y=e==="horizontal"?"ArrowLeft":"ArrowUp",v=e==="horizontal"?"ArrowRight":"ArrowDown",k=null;f.key==="Home"?k=0:f.key==="End"?k=_.length-1:f.key===y?k=w-1:f.key===v&&(k=w+1),!(k===null||_.length===0)&&(i?k=(k+_.length)%_.length:k=Math.max(0,Math.min(_.length-1,k)),f.preventDefault(),h(_[k]),_[k].focus())}function d(f){let _=f.target?.closest?.(t)??null;_&&s.contains(_)&&h(_)}s.addEventListener("keydown",u,{signal:n.signal}),s.addEventListener("focusin",d,{signal:n.signal});let p=typeof MutationObserver=="function"?new MutationObserver(()=>h()):null;return p?.observe(s,{childList:!0,subtree:!0,attributes:!0}),h(),{focusFirst(){let f=a()[0];f&&(h(f),f.focus())},focusLast(){let f=a(),_=f[f.length-1];_&&(h(_),_.focus())},destroy(){if(!o){o=!0,n.abort(),p?.disconnect();for(let[f,_]of r)_===null?f.removeAttribute("tabindex"):f.setAttribute("tabindex",_);r.clear()}}}}function ht(s,t){let e="",i=null;return function(r){let o=typeof r=="string"?r:r.key;if(typeof r!="string"&&(r.ctrlKey||r.metaKey||r.altKey)||!o||o.length!==1||/\s/.test(o))return;i!==null&&clearTimeout(i),e+=o.toLocaleLowerCase(),e.split("").every(h=>h===e[0])&&(e=e[0]),i=setTimeout(()=>{e="",i=null},500);let a=s(),c=a.findIndex(h=>pf(h).startsWith(e));c>=0&&t(a[c],c)}}function al(s){return Array.from(s.querySelectorAll(ff)).filter(t=>ll(t)&&t.getClientRects().length>0)}function ll(s){return!(!(s instanceof HTMLElement)||s.hidden||s.getAttribute("aria-hidden")==="true"||s.matches(":disabled"))}function pf(s){if(typeof s=="string"||typeof s=="number")return String(s).trim().toLocaleLowerCase();if(s&&typeof s=="object"&&"textContent"in s)return String(s.textContent??"").trim().toLocaleLowerCase();if(s&&typeof s=="object"){let t=s,e=t.label??t.text??t.value;if(e!=null)return String(e).trim().toLocaleLowerCase()}return String(s??"").trim().toLocaleLowerCase()}var _f=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],cl=["Lowest","Low","Medium","High","Highest"],mf=Object.freeze([["backlog","status.backlog","Backlog","dotted","muted"],["todo","status.todo","Todo","ring","neutral"],["in-progress","status.inProgress","In Progress","progress","warning"],["in-review","status.inReview","In Review","review","info"],["ready","status.ready","Ready to Merge","ready","accent"],["waiting","status.waiting","Waiting for feedback","waiting","warning"],["done","status.done","Done","done","info"],["canceled","status.canceled","Canceled","canceled","muted"],["duplicate","status.duplicate","Duplicate","duplicate","muted"]]),$=class s extends m{static cssName="select";static defaults={items:[],fixedItems:[],fixedLabel:null,valueKey:"ID",labelKey:"name",renderItem:null,renderValue:null,renderValueAdornment:null,renderNone:null,noneLabel:null,actions:[],value:null,disabled:!1,placeholder:"",label:"",clearable:!1,filter:!1,searchKeys:null,minQuery:0,debounce:200,listHeight:280,groupKey:null};render(){this._items=[],this._visibleItems=[],this._fixedItems=[],this._visibleFixed=[],this._actions=[],this._selected=null,this._optionEntries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._createdRoot=!1,this._root=null,this._snapshot=null,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._root=t,this._snapshot=this._createdRoot?null:A(t);let e=x("zx-select-list"),i=l("input",{ref:"input",class:"zx-select__input",type:"text",role:"combobox",ariaLabel:String(this.options.label||this.options.placeholder||"Select"),autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:this.options.filter?"list":"none",placeholder:String(this.options.placeholder??""),readOnly:!this.options.filter}),n=l("span",{ref:"valueAdornment",class:"zx-select__value-adornment",ariaHidden:"true",hidden:!0}),r=l("button",{ref:"clear",class:"zx-icon-btn zx-select__clear",type:"button",tabIndex:-1,ariaLabel:this._message("select.clear","Clear selection"),hidden:!0},g("x",{size:13})),o=l("span",{ref:"loading",class:"zx-select__loading",role:"status",ariaLabel:this._message("select.loading","Loading"),hidden:!0}),a=l("button",{ref:"toggle",class:"zx-select__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("select.toggle","Toggle options")},g("chevron-down",{size:16})),c=l("div",{ref:"control",class:"zx-select__control"},n,i,r,o,a),h=l("div",{ref:"list",class:"zx-select__list",id:e,role:"listbox"});h.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let u=l("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},h);return t.replaceChildren(c,u),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visibleItems=this._items.slice(),this._fixedItems=Array.isArray(this.options.fixedItems)?this.options.fixedItems.slice():[],this._visibleFixed=this._fixedItems.slice(),this._actions=hl(this.options.actions),this._disabled=!!this.options.disabled,this._handleTypeahead=ht(()=>this._optionEntries.filter(d=>!d.clear&&!d.action).map(d=>d.element),(d,p)=>{this._open||this.open(),this._setActive(this._itemEntryIndex(p))}),this.listen(i,"click",()=>this.open()),this.listen(i,"input",()=>this._onInput()),this.listen(i,"keydown",d=>this._onKeydown(d)),this.listen(a,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(r,"click",()=>{this.set(null),this.focus()}),this.listen(u,"pointerdown",d=>d.preventDefault()),this.listen(u,"click",d=>this._onOptionClick(d)),this.listen(document,"pointerdown",d=>{this._open&&!t.contains(d.target)&&this.close()},{capture:!0}),this._renderOptions(),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._selected===null?null:this._itemValue(this._selected)}set value(t){this.set(t)}get selected(){return this._selected}set(t,{silent:e=!1}={}){let i=this.value,n=t==null?null:this._findItem(t);this._selected=n,this._syncInputValue(),this._renderOptions();let r=this.value;return!e&&!Object.is(i,r)&&this.emit("change",{value:r,item:n}),this}setItems(t){let e=this.value;return this._items=Array.isArray(t)?t.slice():[],this._visibleItems=this._items.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setFixedItems(t){let e=this.value;return this._fixedItems=Array.isArray(t)?t.slice():[],this._visibleFixed=this._fixedItems.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setActions(t){return this._actions=hl(t),this._renderOptions(),this._position?.update(),this}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t}),this}open(){return this._disabled||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=st(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._selectedEntryIndex()),this._activeIndex<0&&this._optionEntries.length>0&&this._setActive(0),this.options.filter&&this._selected!==null&&this.refs.input.select(),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(""),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._setLoading(!1),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._visibleItems=this._items.slice(),this._visibleFixed=this._fixedItems.slice(),this._syncInputValue(),this.emit("close",{}),this):this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}static priority(t,e={}){let i=e.value??null,n=new s(t,{...e,value:null,items:[],renderItem(r){return yf(r,!0)},renderValueAdornment(r){return dl(r.level)}});return n.setItems(_f.map((r,o)=>{let a=o===2?n.msg("priority.medium"):r;return(a==="priority.medium"||o!==2)&&(a=n._message(r,cl[o])),{ID:o,name:a,level:o}})),n.set(i,{silent:!0}),n}static status(t,e={}){let{items:i=null,value:n=null,...r}=e,o=new s(t,{...r,value:null,items:[],renderItem(c){return xf(c)},renderValueAdornment(c){return fl(c)}}),a=Array.isArray(i)?i.map(wf).filter(Boolean):mf.map(([c,h,u,d,p],f)=>({ID:c,name:o._message(h,u),indicator:d,tone:p,shortcut:String(f+1)}));return o.setItems(a),o.set(n,{silent:!0}),o}static entity(t,e={}){let{recent:i=[],recentLabel:n="Recent",create:r=!1,iconKey:o="icon",colorKey:a="color",subtitleKey:c="description",renderIcon:h=null,fixedItems:u=[],actions:d=[],renderItem:p=null,renderValueAdornment:f=null,..._}=e,b=(v,k=!1)=>{if(typeof h=="function")return h(v,{selected:k});let z=es(v,o);if(z&&typeof z=="object"&&typeof z.nodeType=="number")return z.cloneNode(!0);if(typeof z!="string"||!z)return null;let E=es(v,a);return l("span",{class:"zx-select__entity-glyph",style:Ht(E)?{"--zx-select-entity-color":String(E)}:null,ariaHidden:"true"},g(z,{size:14}))},w=r?gf(r):null,y=new s(t,{..._,fixedItems:[...Array.isArray(i)?i:[],...Array.isArray(u)?u:[]],fixedLabel:Array.isArray(i)&&i.length?n:_.fixedLabel??null,actions:[...Array.isArray(d)?d:[],...w?[w]:[]],renderItem:p??(v=>{let k=b(v,!1),z=es(v,c),E=l("span",{class:"zx-select__entity-copy"},l("span",{class:"zx-select__entity-label"},String(es(v,_.labelKey??"name")??"")),z==null||z===""?null:l("span",{class:"zx-select__entity-subtitle"},String(z)));return l("span",{class:"zx-select__entity"},k?l("span",{class:"zx-select__entity-icon",ariaHidden:"true"},k):null,E)}),renderValueAdornment:f??(v=>b(v,!0))});return y.el.dataset.preset="entity",y}static permission(t,e={}){let{groups:i=[],value:n=!0,valueKey:r="ID",labelKey:o="name",filter:a="local",...c}=e,h=typeof i=="function"?i:null,u=h?[]:i,d=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],p=new s(t,{filter:h??a,...c,value:null,items:u,fixedItems:[],valueKey:f=>d.includes(f)?f.ID:Dn(f,r),labelKey:f=>d.includes(f)?f.name:String(Dn(f,o)??"")});return d[0].name=p._message("permission.private","Private"),d[1].name=p._message("permission.public","Public"),p.setFixedItems(d),p.set(n,{silent:!0}),p}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;!this._createdRoot&&t&&S(t,this._snapshot),super.destroy()}_onKeydown(t){if(!this._disabled){if(this._open&&ul(t)){let e=this._optionEntries.findIndex(i=>!i.clear&&!i.action&&String(i.item?.shortcut??"")===t.key);if(e>=0){t.preventDefault(),this._setActive(e),this._chooseEntry(this._optionEntries[e]);return}}if(t.key==="ArrowDown"){t.preventDefault(),this._open?this._moveActive(1):this.open();return}if(t.key==="ArrowUp"){t.preventDefault(),this._open?this._moveActive(-1):(this.open(),this._setActive(this._optionEntries.length-1));return}if(t.key==="Home"&&this._open){t.preventDefault(),this._setActive(0);return}if(t.key==="End"&&this._open){t.preventDefault(),this._setActive(this._optionEntries.length-1);return}if(t.key==="Enter"&&this._open){t.preventDefault(),this._chooseEntry(this._optionEntries[this._activeIndex]);return}if(t.key==="Escape"&&this._open){t.preventDefault(),this.close();return}if(t.key==="Tab"&&this._open){this.close();return}!this.options.filter&&ul(t)&&this._handleTypeahead(t)}}_onInput(){if(!this.options.filter)return;let t=this.refs.input.value;this._syncValueAdornment(),this._open||this.open(),this.options.filter==="local"?(this._visibleFixed=this._matchFixed(t),this._visibleItems=qt(this._items,t,this._searchKeys()),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update()):typeof this.options.filter=="function"&&this._scheduleAsyncQuery(t)}_onOptionClick(t){let e=t.target?.closest?.('[role="option"]');!e||!this.refs.panel.contains(e)||this._chooseEntry(this._optionEntries[Number(e.getAttribute("data-index"))])}_chooseEntry(t){if(t){if(t.action){let e={id:t.action.id,action:t.action,query:this.refs.input.value,select:this};this.emit("action",e).defaultPrevented||t.action.invoke?.(e),this.close(),this.focus();return}this.set(t.clear?null:t.item),this.close(),this.focus()}}_moveActive(t){let e=this._optionEntries.length;e!==0&&this._setActive((this._activeIndex+t+e)%e)}_setActive(t){this._activeIndex=t>=0&&t<this._optionEntries.length?t:-1,this._optionEntries.forEach((i,n)=>{n===this._activeIndex?i.element.setAttribute("data-active","true"):i.element.removeAttribute("data-active")});let e=this._optionEntries[this._activeIndex]?.element;e?(this.refs.input.setAttribute("aria-activedescendant",e.id),e.scrollIntoView?.({block:"nearest"})):this.refs.input.removeAttribute("aria-activedescendant")}_renderOptions(){let t=this.refs.list;if(!t)return;t.replaceChildren(),this._optionEntries=[];let e=Symbol("initial-group"),i=this._uniqueItems(this._visibleFixed),n=this._uniqueItems(this._visibleItems,i);this.options.clearable&&this._appendOption(null,!0,this.options.noneLabel??this._message("select.none","No selection")),i.length>0&&this.options.fixedLabel&&t.append(l("div",{class:"zx-select__group",role:"presentation"},String(this.options.fixedLabel)));for(let r of i)this._appendOption(r,!1);i.length>0&&n.length>0&&!this.options.groupKey&&t.append(l("div",{class:"zx-select__separator",role:"presentation"}));for(let r of n){if(this.options.groupKey){let o=this._read(r,this.options.groupKey);Object.is(o,e)||(t.append(l("div",{class:"zx-select__group",role:"presentation"},String(o??""))),e=o)}this._appendOption(r,!1)}if(this._actions.length>0){(i.length>0||n.length>0||this.options.clearable)&&t.append(l("div",{class:"zx-select__separator",role:"presentation"}));let r=Symbol("initial-action-group");for(let o of this._actions)o.group&&o.group!==r&&(t.append(l("div",{class:"zx-select__group",role:"presentation"},o.group)),r=o.group),this._appendAction(o)}n.length===0&&i.length===0&&this._actions.length===0&&!this._loading&&t.append(l("div",{class:"zx-select__empty",role:"status"},this._message("select.empty","No matches"))),this._setActive(-1)}_appendOption(t,e,i){let n=e?this._selected===null:this._selected!==null&&Object.is(this._itemValue(t),this.value),r=this._optionEntries.length,o=e&&typeof this.options.renderNone=="function"?En(this.options.renderNone(String(i??""))):e?String(i??""):this._renderItem(t),a=l("div",{class:"zx-select__option",id:x("zx-select-option"),role:"option",ariaSelected:String(n),dataset:{index:r}},l("span",{class:"zx-select__option-content"},o));n&&a.append(g("check",{size:15})),this.refs.list.append(a),this._optionEntries.push({item:t,clear:e,action:null,element:a})}_appendAction(t){let e=this._optionEntries.length,i=bf(t.icon),n=l("div",{class:"zx-select__option zx-select__action",id:x("zx-select-option"),role:"option",ariaSelected:"false",dataset:{index:e,kind:"action"}},l("span",{class:"zx-select__option-content zx-select__action-content"},i?l("span",{class:"zx-select__action-icon",ariaHidden:"true"},i):null,l("span",{class:"zx-select__action-copy"},l("span",{class:"zx-select__action-label"},t.label),t.description?l("span",{class:"zx-select__action-description"},t.description):null)));this.refs.list.append(n),this._optionEntries.push({item:null,clear:!1,action:t,element:n})}_renderItem(t){if(typeof this.options.renderItem=="function"){let e=this.options.renderItem(t);return En(e)}return this._itemLabel(t)}_scheduleAsyncQuery(t){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._requestSequence+=1;let e=this._requestSequence;if(this._visibleFixed=this._matchFixed(t),t.length<Math.max(0,Number(this.options.minQuery)||0)){this._setLoading(!1),this._visibleItems=[],this._renderOptions();return}this._setLoading(!0),this._renderOptions(),this._position?.update();let i=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runAsyncQuery(t,e)},i)}async _runAsyncQuery(t,e){if(!(e!==this._requestSequence||typeof this.options.filter!="function")){this.emit("query",{query:t});try{let i=await this.options.filter(t);if(e!==this._requestSequence||!this._open)return;this._items=Array.isArray(i)?i.slice():[],this._visibleItems=this._items.slice(),this._setLoading(!1),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update(),this.emit("loaded",{items:this._items.slice()})}catch{if(e!==this._requestSequence||!this._open)return;this._items=[],this._visibleItems=[],this._setLoading(!1),this._renderOptions(),this._position?.update()}}}_cancelQuery(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._requestSequence+=1}_setLoading(t){this._loading=t,this.refs.loading.hidden=!t,this.refs.input.setAttribute("aria-busy",String(t)),this.refs.list.setAttribute("aria-busy",String(t)),t?this._root?.setAttribute("data-loading","true"):this._root?.removeAttribute("data-loading")}_syncInputValue(){if(!this.refs.input)return;let t=this.refs.input;t.value=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),this._syncValueAdornment(),this.refs.clear.hidden=!this.options.clearable||this._selected===null}_syncValueAdornment(){let t=this.refs.valueAdornment;if(!t)return;let e=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),i=String(this.refs.input?.value??"");if(this._selected===null||typeof this.options.renderValueAdornment!="function"||this.options.filter&&i!==e){t.replaceChildren(),t.hidden=!0;return}let n=this.options.renderValueAdornment(this._selected),r=En(n);t.replaceChildren(r instanceof Node?r:document.createTextNode(r)),t.hidden=n==null||typeof r=="string"&&r===""}_syncDisabled(){let t=this.refs.input,e=this.refs.clear,i=this.refs.toggle;t.disabled=this._disabled,e.disabled=this._disabled,i.disabled=this._disabled,this._root?.setAttribute("aria-disabled",String(this._disabled))}_findItem(t){let e=this._fixedItems.length===0?this._items:[...this._fixedItems,...this._items],i=e.find(r=>r===t);if(i!==void 0)return i;let n=t!==null&&typeof t=="object"?this._itemValue(t):t;return e.find(r=>Object.is(this._itemValue(r),n))??null}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){let e=this._read(t,this.options.labelKey);return String(e??"")}_read(t,e){return Dn(t,e)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(t){return qt(this._fixedItems,t,this._searchKeys())}_uniqueItems(t,e=[]){let i=e.map(n=>this._itemValue(n));return t.filter(n=>{let r=this._itemValue(n);return i.some(o=>Object.is(o,r))?!1:(i.push(r),!0)})}_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)}_message(t,e){let i=this.msg(t);return i===t?e:i}};function es(s,t){return typeof t=="function"?t(s):s!==null&&typeof s=="object"&&typeof t=="string"?s[t]:null}function gf(s){let t=s===!0?{}:s;return{id:t.id??"create",label:t.label??"Create new\u2026",description:t.description,group:t.group??"New",icon:t.icon??"plus",invoke:t.invoke}}function En(s){return s&&typeof s=="object"&&"nodeType"in s?s:String(s??"")}function hl(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>({...t,label:String(t.label),description:t.description==null?void 0:String(t.description),group:t.group==null?void 0:String(t.group)})):[]}function bf(s){return typeof s=="string"?g(s):s instanceof Node?s.cloneNode(!0):null}function yf(s,t){return l("span",{class:"zx-select__priority"},dl(s.level),t?l("span",{},String(s.name)):null)}function dl(s){let t=Math.max(0,Math.min(4,Math.trunc(Number(s)||0)));return l("span",{class:"zx-select__priority-icon",dataset:{level:t},ariaHidden:"true"},Array.from({length:5},(e,i)=>l("span",{dataset:{filled:String(i<=t)}})))}function wf(s){if(!s||typeof s!="object"||s.ID==null||s.name==null)return null;let t=["dotted","ring","progress","review","ready","waiting","done","canceled","duplicate"],e=["muted","neutral","warning","info","accent","success","danger"];return{...s,name:String(s.name),indicator:t.includes(String(s.indicator))?String(s.indicator):"ring",tone:e.includes(String(s.tone))?String(s.tone):"muted",description:s.description==null?"":String(s.description),shortcut:s.shortcut==null?"":String(s.shortcut)}}function xf(s){return l("span",{class:"zx-select__status"},fl(s),l("span",{class:"zx-select__status-copy"},l("span",{class:"zx-select__status-label"},String(s.name)),s.description?l("span",{class:"zx-select__status-description"},s.description):null),s.shortcut?l("kbd",{class:"zx-select__status-shortcut"},s.shortcut):null)}function fl(s){let t=String(s.indicator??"ring"),e=l("span",{class:"zx-select__status-indicator",dataset:{indicator:t,tone:String(s.tone??"muted")},ariaHidden:"true"});return t==="done"&&e.append(g("check",{size:8})),t==="canceled"&&e.append(g("x",{size:7})),e}function Dn(s,t){return typeof t=="function"?t(s):s===null||typeof s!="object"?s:s[t]}function ul(s){return s.key.length===1&&!s.ctrlKey&&!s.metaKey&&!s.altKey}function pl(){C.register("zxselect",(s,t)=>{let e=t.props??{},i=e.preset,n={...e,value:t.value,label:t.label||e.label,placeholder:e.placeholder??t.placeholder};s.listen(s.el,"click",o=>{o.target.closest?.(".zx-field__label")&&s.adapter.focus()}),delete n.preset;let r=s.own(i==="priority"?$.priority(null,n):i==="status"?$.status(null,n):new $(null,n));return s.listen(r.el,"change",o=>o.stopImmediatePropagation()),r.on("change",o=>s.emit("change",{value:o.detail.value})),{el:r.el,get:()=>r.value,set:o=>r.set(o,{silent:!0}),focus:()=>r.focus(),setDisabled:o=>o?r.disable():r.enable()}})}var ei=class extends m{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:A(this.el);let t=this.el??l("div");this.el=t,this._min=Number(this.options.min)||0,this._max=Number(this.options.max),(!Number.isFinite(this._max)||this._max<=this._min)&&(this._max=this._min+100),this._step=Math.abs(Number(this.options.step))||1,this._id=x("zx-slider");let e=l("input",{ref:"input",class:"zx-slider__input",type:"range",id:this._id,min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled}),i=l("div",{class:"zx-slider__track"},e,this._marks()),n=l("div",{class:"zx-slider__control"});return this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._min))),n.append(i),this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._max))),this.options.showInput&&n.append(this._numberBox()),t.replaceChildren(l("div",{class:"zx-slider__head"},l("label",{ref:"label",class:"zx-slider__label",for:this._id},String(this.options.label??"")),l("span",{ref:"output",class:"zx-slider__value",ariaHidden:"true"})),n),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(e,"input",()=>this._onInput()),this.listen(e,"change",()=>this._onCommit()),this.listen(e,"keydown",r=>{this._readonly&&vf.has(r.key)&&r.preventDefault()}),this.set(this.options.value,{silent:!0}),this._syncState(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=this._snap(t),n=i!==this._value;return this._value=i,this._paint(),n&&!e&&this.emit("change",{value:i}),this}setRange(t,e,i){let n=Number(t),r=Number(e);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)throw new RangeError("Slider range requires min < max");this._min=n,this._max=r,i!==void 0&&(this._step=Math.abs(Number(i))||1);let{input:o}=this.refs;o.min=String(this._min),o.max=String(this._max),o.step=String(this._step);for(let[a,c]of[...this.el.querySelectorAll(".zx-slider__bound")].entries())c.textContent=this._format(a===0?this._min:this._max);return this.set(this._value,{silent:!0})}focus(){return this.refs.input.focus(),this}enable(){return this.refs.input.disabled=!1,this.refs.number&&(this.refs.number.disabled=!1),this._syncState(),this}disable(){return this.refs.input.disabled=!0,this.refs.number&&(this.refs.number.disabled=!0),this._syncState(),this}setReadonly(t){return this._readonly=!!t,this.refs.number&&(this.refs.number.readOnly=this._readonly),this._syncState(),this}setLabel(t){return this.refs.label.textContent=String(t??""),this}_numberBox(){let t=l("input",{ref:"number",class:"zx-slider__number",type:"number",min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled,readOnly:this._readonly,ariaLabel:String(this.options.label??"Value")});return this.listen(t,"input",()=>{if(this._readonly)return;let e=Number(t.value);t.value===""||!Number.isFinite(e)||(this._value=this._snap(e),this.refs.input.value=String(this._value),this._paintTrack(),this.emit("input",{value:this._value}))}),this.listen(t,"change",()=>{if(this._readonly){t.value=String(this._value);return}this.set(t.value===""?this._min:Number(t.value))}),t}_marks(){let t=this.options.marks;if(!Array.isArray(t)||t.length===0)return null;let e=l("div",{class:"zx-slider__marks",ariaHidden:"true"});for(let i of t){let n=typeof i=="number"?i:Number(i?.value);if(!Number.isFinite(n))continue;let r=typeof i=="number"?this._format(n):String(i.label??this._format(n));e.append(l("span",{class:"zx-slider__mark",style:{"--zx-slider-mark":`${this._ratio(n)*100}%`}},r))}return e}_onInput(){if(this._readonly){this.refs.input.value=String(this._value);return}this._value=this._snap(this.refs.input.value),this._paintTrack(),this.refs.number&&(this.refs.number.value=String(this._value)),this.emit("input",{value:this._value})}_onCommit(){if(this._readonly){this.refs.input.value=String(this._value);return}this.emit("change",{value:this._value})}_paint(){this.refs.input.value=String(this._value),this.refs.number&&(this.refs.number.value=String(this._value)),this._paintTrack()}_paintTrack(){this.el.style.setProperty("--zx-slider-fill",`${this._ratio(this._value)*100}%`);let{output:t}=this.refs;t.textContent=this.options.showValue?this._format(this._value):""}_syncState(){let t=this.refs.input.disabled;this.el.toggleAttribute("data-disabled",t),this.el.toggleAttribute("data-readonly",this._readonly),this.refs.input.setAttribute("aria-readonly",String(this._readonly))}_snap(t){let e=Number(t);return Number.isFinite(e)?ts(e,{min:this._min,max:this._max,step:this._step,precision:_l(this._step)}):this._min}_ratio(t){return B((t-this._min)/(this._max-this._min),0,1)}_format(t){let e=this.options.formatValue;return typeof e=="function"?String(e(t)):`${Sf(t)}${this.options.unit??""}`}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}},vf=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function _l(s){let t=String(s),e=/e-(\d+)$/i.exec(t);return e?Number(e[1]):(t.split(".")[1]??"").length}function Sf(s){return String(Number(s.toFixed(6)))}function ml(){C.register("slider",(s,t)=>{let e=s.own(new ei(null,{label:t.label?String(t.label):void 0,hideLabel:!0,disabled:!!t.disabled,...t.props??{}})),i=!1;return e.on("change",n=>{i||s.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get(),set:n=>{i=!0;try{e.set(Number(n)||0,{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var ii=class extends m{static cssName="tag-picker";static defaults={items:[],values:[],valueKey:"ID",labelKey:"name",iconKey:"icon",colorKey:"color",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:A(this.el);let t=this.el??l("div");this.el=t;let e=x("zx-tag-picker-list"),i=l("span",{ref:"tags",class:"zx-tag-picker__tags"}),n=l("input",{ref:"input",class:"zx-tag-picker__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:"list",ariaLabel:this._message("tagPicker.input","Add a value"),placeholder:String(this.options.placeholder??"")}),r=l("button",{ref:"toggle",class:"zx-tag-picker__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("tagPicker.toggle","Toggle options")},g("chevron-down",{size:15})),o=l("div",{ref:"control",class:"zx-tag-picker__control"},i,n,r),a=l("div",{ref:"list",class:"zx-tag-picker__list",id:e,role:"listbox",ariaMultiSelectable:"true"});a.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let c=l("div",{ref:"panel",class:"zx-tag-picker__panel",popover:"manual"},a);return t.replaceChildren(o,c),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visible=this._items.slice(),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(o,"pointerdown",h=>{let u=h.target;u.closest(".zx-tag-picker__remove")||u.closest(".zx-tag-picker__toggle")||(h.target!==n&&(h.preventDefault(),this.focus()),this._open||this.open())}),this.listen(i,"click",h=>{let u=h.target.closest(".zx-tag-picker__remove");if(!u||this._disabled||this._readonly)return;h.stopPropagation();let d=[...i.children].indexOf(u.closest(".zx-tag-picker__tag")),p=this._selected[d];p!==void 0&&(this.removeValue(this._valueOf(p)),this.focus())}),this.listen(n,"input",()=>this._onInput()),this.listen(n,"keydown",h=>this._onKeydown(h)),this.listen(n,"blur",()=>this.el.removeAttribute("data-focus")),this.listen(n,"focus",()=>this.el.setAttribute("data-focus","")),this.listen(r,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(c,"pointerdown",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 i=Array.isArray(t)?t:[],n=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),r=[];for(let a of i){if(r.length>=n)break;let c=this._resolve(a);c!==null&&!r.some(h=>this._sameValue(h,c))&&r.push(c)}let o=!Af(r,this._selected,a=>this._valueOf(a));return this._selected=r,this._renderTags(),this._renderOptions(),o&&!e&&this._emitChange(),this}addValue(t,{silent:e=!1}={}){if(this.isFull())return this;let i=this._resolve(t);return i===null?this:this._selected.some(n=>this._sameValue(n,i))?this:(this._selected.push(i),this._renderTags(),this._renderOptions(),e||(this.emit("add",{value:this._valueOf(i),item:i}),this._emitChange()),this)}removeValue(t,{silent:e=!1}={}){let i=this._valueOf(this._resolve(t)??t),n=this._selected.findIndex(o=>Object.is(this._valueOf(o),i));if(n<0)return this;let[r]=this._selected.splice(n,1);return this._renderTags(),this._renderOptions(),e||(this.emit("remove",{value:this._valueOf(r),item:r}),this._emitChange()),this}clear({silent:t=!1}={}){return this.setValues([],{silent:t})}reset({silent:t=!1}={}){return this.setValues(this.options.values,{silent:t})}setItems(t){return this._cancelQuery(),this._items=Array.isArray(t)?t.slice():[],typeof this.options.filter=="function"?this._visible=this._items.slice():this._applyLocalFilter(this.refs.input.value),this._renderOptions(),this._position?.update(),this}isFull(){let t=this.options.max;return t!=null&&this._selected.length>=Number(t)}open(){return this._disabled||this._readonly||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=st(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&&S(t,this._snapshot)}_renderTags(){let t=this._selected.map(e=>{let i=this._labelOf(e),n=this._colorOf(e),r=this.options.renderTag?this.options.renderTag(e):[this._iconOf(e),l("span",{class:"zx-tag-picker__tag-label"},i)],o=l("span",{class:"zx-tag-picker__tag",dataset:{colored:String(!!n)},style:n?{"--zx-tag-color":n}:null},r);return!this._readonly&&!this._disabled&&o.append(l("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[i])},g("x",{size:11}))),o});this.refs.tags.replaceChildren(...t),this.el.toggleAttribute("data-empty",this._selected.length===0),this._syncPlaceholder()}_renderOptions(){let t=this.refs.list;this._entries=[];let e=[];for(let r of this._visible){let o=this._valueOf(r),a=this._isSelected(o),c=l("div",{class:"zx-tag-picker__option",id:x("zx-tag-picker-option"),role:"option",ariaSelected:String(a)},l("span",{class:"zx-tag-picker__check",ariaHidden:"true"},a?g("check",{size:13}):null),l("span",{class:"zx-tag-picker__option-label"},this.options.renderItem?this.options.renderItem(r):[this._iconOf(r),l("span",{},this._labelOf(r))]));!a&&this.isFull()&&c.setAttribute("aria-disabled","true"),this._entries.push({item:r,element:c,create:!1}),e.push(c)}let i=this.refs.input.value.trim();if(this._canCreate(i)){let r=l("div",{class:"zx-tag-picker__option",id:x("zx-tag-picker-option"),role:"option",ariaSelected:"false",dataset:{create:"true"}},l("span",{class:"zx-tag-picker__check",ariaHidden:"true"},g("plus",{size:13})),l("span",{class:"zx-tag-picker__option-label"},this._message("tagPicker.create","Create \u201C%1\u201D",[i])));this._entries.push({item:null,element:r,create:!0}),e.push(r)}e.length===0&&e.push(l("div",{class:"zx-tag-picker__empty"},this._loading?this._message("tagPicker.loading","Loading\u2026"):this._message("tagPicker.empty","No matches"))),t.replaceChildren(...e);let n=this._entries.findIndex(r=>this._entryId(r)===this._activeId);this._setActive(n>=0?n:this._entries.length>0?0:-1)}_entryId(t){return t.create?"\0create":String(this._valueOf(t.item))}_syncPlaceholder(){let t=this.refs.input;t.placeholder=this._selected.length===0?String(this.options.placeholder??""):""}_onInput(){let t=this.refs.input.value;this._syncInputWidth(),this._open||this.open(),typeof this.options.filter=="function"?this._scheduleAsyncQuery(t):this._applyLocalFilter(t),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update()}_onKeydown(t){if(this._disabled||this._readonly)return;let e=this.refs.input;switch(t.key){case"ArrowDown":t.preventDefault(),this._open?this._move(1):this.open();return;case"ArrowUp":t.preventDefault(),this._open&&this._move(-1);return;case"Home":this._open&&e.value===""&&(t.preventDefault(),this._setActive(0));return;case"End":this._open&&e.value===""&&(t.preventDefault(),this._setActive(this._entries.length-1));return;case"Enter":{if(!this._open||this._activeIndex<0)return;t.preventDefault(),this._commitEntry(this._entries[this._activeIndex]);return}case"Escape":this._open&&(t.preventDefault(),this.close());return;case"Backspace":e.value===""&&this._selected.length>0&&(t.preventDefault(),this.removeValue(this._valueOf(this._selected[this._selected.length-1])));return;case"Tab":this._open&&this.close();return;default:}}_onOptionClick(t){let e=t.target.closest(".zx-tag-picker__option");if(!e)return;let i=this._entries.find(n=>n.element===e);i&&this._commitEntry(i)}_commitEntry(t){if(!t)return;let e=this.refs.input;if(t.create){let i=e.value.trim(),n=this._createItem(i);this._items=this._items.concat([n]),this.addValue(n),this.emit("create",{value:this._valueOf(n),item:n})}else{let i=this._valueOf(t.item);if(this._isSelected(i))this.removeValue(i);else if(!this.isFull())this.addValue(t.item);else return}e.value="",this._syncInputWidth(),this._applyLocalFilter(""),this._renderOptions(),this.options.closeOnSelect?this.close():(this._setActive(this._entries.length>0?0:-1),this._position?.update()),this.focus()}_move(t){if(this._entries.length===0)return;let e=this._activeIndex<0?t>0?0:this._entries.length-1:Math.min(this._entries.length-1,Math.max(0,this._activeIndex+t));this._setActive(e)}_setActive(t){this._activeIndex=t,this._activeId=this._entries[t]?this._entryId(this._entries[t]):null;for(let[e,i]of this._entries.entries()){let n=e===t;i.element.toggleAttribute("data-active",n),n&&(this.refs.input.setAttribute("aria-activedescendant",i.element.id),i.element.scrollIntoView({block:"nearest"}))}t<0&&this.refs.input.removeAttribute("aria-activedescendant")}_applyLocalFilter(t){if(typeof this.options.filter=="function")return;let e=this.options.searchKeys??[this.options.labelKey];this._visible=qt(this._items,t,e)}_scheduleAsyncQuery(t){this._cancelQuery();let e=String(t??"");if(e.length<Number(this.options.minQuery??0)){this._visible=[],this._renderOptions();return}this._visible=[],this._setLoading(!0),this._renderOptions();let i=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runQuery(e)},i)}async _runQuery(t){let e=this._requestSequence+1;this._requestSequence=e,this._setLoading(!0),this.emit("query",{query:t});try{let i=await this.options.filter(t);if(e!==this._requestSequence)return;this._items=Array.isArray(i)?i.slice():[],this._visible=this._items.slice()}catch(i){if(e!==this._requestSequence)return;this._visible=[],this.emit("error",{error:i})}finally{e===this._requestSequence&&(this._setLoading(!1),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update())}}_cancelQuery(){this._queryTimer!==null&&(clearTimeout(this._queryTimer),this._queryTimer=null),this._requestSequence+=1,this._setLoading(!1)}_setLoading(t){this._loading=t,this.el.toggleAttribute("data-loading",t)}_isSelected(t){return this._selected.some(e=>Object.is(this._valueOf(e),t))}_canCreate(t){if(!this.options.allowCreate||t===""||this.isFull())return!1;let e=i=>i.some(n=>gl(this._labelOf(n))===gl(t));return!e(this._items)&&!e(this._selected)}_createItem(t,e=t){return typeof this.options.valueKey!="string"||typeof this.options.labelKey!="string"?t:{[this.options.valueKey]:e,[this.options.labelKey]:t,created:!0}}_resolve(t){if(t==null)return null;let e=this._valueOf(t),i=this._items.find(r=>Object.is(this._valueOf(r),e));if(i!==void 0)return i;let n=this._selected.find(r=>Object.is(this._valueOf(r),e));return n!==void 0?n:typeof t=="object"?t:this._createItem(String(t),t)}_sameValue(t,e){return Object.is(this._valueOf(t),this._valueOf(e))}_valueOf(t){let e=this.options.valueKey;return typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]:t}_labelOf(t){let e=this.options.labelKey;return String(typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]??"":t??"")}_iconOf(t){let e=this._readItem(t,this.options.iconKey),i=e&&typeof e=="object"&&typeof e.nodeType=="number"?e.cloneNode(!0):typeof e=="string"&&e.trim()?g(e,{size:12}):null;return i?l("span",{class:"zx-tag-picker__visual",style:this._colorOf(t)?{"--zx-tag-color":this._colorOf(t)}:null,ariaHidden:"true"},i):null}_colorOf(t){let e=this._readItem(t,this.options.colorKey);return Ht(e)?e:null}_readItem(t,e){return typeof e=="function"?e(t):t!==null&&typeof t=="object"&&typeof e=="string"?t[e]:null}_emitChange(){this.emit("change",{values:this.getValues(),items:this.getItems()})}_syncInputWidth(){let t=this.refs.input,e=t.value.length;t.style.inlineSize=e===0?"":`${Math.min(40,e+1)}ch`}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.toggle.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}_message(t,e,i=[]){let n=this.msg(t,...i);return n!==t?n:i.reduce((r,o,a)=>r.replaceAll(`%${a+1}`,String(o)),e)}};function gl(s){return String(s??"").trim().toLocaleLowerCase()}function Af(s,t,e){return s.length!==t.length?!1:s.every((i,n)=>Object.is(e(i),e(t[n])))}function bl(){C.register("tagpicker",(s,t)=>{let e=s.own(new ii(null,{placeholder:t.placeholder,...t.props??{}})),i=!1;return s.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{i||s.emit("change",{value:n.detail.values})}),{el:e.el,get:()=>e.getValues(),set:n=>{i=!0;try{e.setValues(Array.isArray(n)?n:[],{silent:!0})}finally{i=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}function yl(s,t="minutes"){let e=Math.round(Math.abs(xl(ie(s),t)));return{hours:Math.floor(e/3600),minutes:Math.floor(e/60)%60,seconds:e%60,negative:ie(s)<0}}function wl(s,t="minutes"){si(t);let e=Math.abs(Math.trunc(ie(s?.hours))),i=Math.abs(Math.trunc(ie(s?.minutes))),n=Math.abs(Math.trunc(ie(s?.seconds))),r=s?.negative?-1:1;return vl(r*(e*3600+i*60+n),t)}var Mt=class extends m{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){si(this.options.unit);let t=this.el??l("div");this.el=t,this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._disabled=!!this.options.disabled,this._parts={hours:0,minutes:0,seconds:0,negative:!1},this._inputs=[];let e=l("div",{class:"zx-timebox__content",role:"group",ariaLabel:this.options.seconds?this._message("timebox.durationWithSeconds","Duration in hours, minutes, and seconds"):this._message("timebox.duration","Duration in hours and minutes")});return this._content=e,this.options.signed&&(e.append(l("button",{ref:"sign",class:"zx-timebox__sign",type:"button",ariaLabel:this._message("timebox.toggleSign","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",this._message("timebox.hours","Hours"),!1),e.append(l("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"minutes",this._message("timebox.minutes","Minutes"),!0),this.options.seconds&&(e.append(l("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"seconds",this._message("timebox.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 wl(this._readParts(),t)}set(t,e=this.options.unit,i={}){e&&typeof e=="object"&&(i=e,e=this.options.unit),si(e);let n=ie(t);return!this.options.signed&&n<0&&(n=0),this.options.seconds||(n=vl(Math.round(xl(n,e)/60)*60,e)),this._parts=yl(n,e),this.options.signed||(this._parts.negative=!1),this._writeParts(),i.silent||this._emitChange(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}destroy(){this._content?.remove(),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_addSegment(t,e,i,n){let r=l("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:i,maxLength:n?2:null,dataset:{segment:e,bounded:String(n)}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"input",()=>{e==="hours"&&this.options.signed&&r.value.trim().startsWith("-")&&(this._parts.negative=!0);let o=r.value.replace(/\D/g,"");r.value=n?o.slice(0,2):o}),this.listen(r,"change",()=>this._commitSegments()),this.listen(r,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this._commitSegments(),r.select())})}_readParts(){let t={...this._parts};for(let e of this._inputs){let i=e.dataset.segment,n=e.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;t[i]=Math.max(0,Math.min(n,Math.trunc(ie(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]):kf(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)})}_message(t,e){let i=this.msg(t);return i===t?e:i}};function ie(s){let t=Number(s);return Number.isFinite(t)?t:0}function xl(s,t){return si(t),t==="hours"?s*3600:t==="minutes"?s*60:s}function vl(s,t){return si(t),t==="hours"?s/3600:t==="minutes"?s/60:s}function si(s){if(s!=="hours"&&s!=="minutes"&&s!=="seconds")throw new RangeError(`Unknown time unit: ${s}`)}function kf(s){return String(s).padStart(2,"0")}function Sl(){C.register("time",(s,t)=>{let e=s.own(new Mt(null,{...t.props??{},value:t.value}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.value})),{el:e.el,get:()=>e.get(),set:i=>e.set(Number(i)||0,{silent:!0}),focus:()=>e.el.querySelector("input:not([disabled]), button:not([disabled])")?.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var nt=class extends m{static cssName="toggle";static defaults={checked:!1,value:!0,label:null,disabled:!1};render(){let t=!this.el,e=this.el??l("button");if(this.el=e,e.localName!=="button")throw new TypeError("Toggle target must be a button element");this._createdRoot=t,this._original=t?null:zf(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,e.type="button",e.setAttribute("role","switch");let i=[l("span",{class:"zx-toggle__track",ariaHidden:"true"},l("span",{class:"zx-toggle__thumb"}))];return this.options.label!==null&&i.push(l("span",{class:"zx-toggle__label"},String(this.options.label))),e.replaceChildren(...i),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let i=!!t;return i===this._checked?this:(this._checked=i,this._sync(),e||this.emit("change",{checked:this._checked,value:this.getValue()}),this)}toggle(){return this.set(!this._checked)}getValue(){return this._checked?this.options.value:!1}enable(){return this._disabled=!1,this.el.removeAttribute("disabled"),this}disable(){return this._disabled=!0,this.el.setAttribute("disabled",""),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&Cf(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function zf(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Cf(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function Al(){C.register("toggle",(s,t)=>{let e=s.own(new nt(null,{...t.props??{},checked:!!t.value}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.value})),{el:e.el,get:()=>e.getValue(),set:i=>e.set(!!i,{silent:!0}),focus:()=>e.el.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var ni=class extends m{static cssName="value-list";static defaults={values:[],placeholder:"",deletable:!0,sortable:!0,unique:!0,validate:null};render(){let t=this.el??l("div");this._ownedNodes=[],this._disabled=!1,this._dragIndex=-1,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled"),this._values=kl(this.options.values,!!this.options.unique);let e=x("zx-value-list-instructions");return this._list=l("ul",{class:"zx-value-list__list",role:"listbox",ariaLabel:this._message("valueList.values","Values"),ariaOrientation:"horizontal"}),this._input=l("input",{class:"zx-value-list__input",type:"text",placeholder:String(this.options.placeholder??""),ariaLabel:this._message("valueList.add","Add value"),ariaDescribedby:e}),this._status=l("div",{class:"zx-value-list__status",role:"status",ariaLive:"polite"}),this._instructions=l("span",{class:"zx-value-list__instructions",id:e},this._message("valueList.instructions","Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder.")),this._ownedNodes.push(this._list,this._input,this._status,this._instructions),t.append(this._list,this._input,this._status,this._instructions),this.listen(this._input,"keydown",i=>this._handleInputKeydown(i)),this.listen(this._list,"keydown",i=>this._handleChipKeydown(i)),this.listen(this._list,"click",i=>this._handleChipClick(i)),this.listen(this._list,"dragstart",i=>this._handleDragStart(i)),this.listen(this._list,"dragover",i=>{this._dragIndex>=0&&!this._disabled&&i.preventDefault()}),this.listen(this._list,"drop",i=>this._handleDrop(i)),this.listen(this._list,"dragend",()=>this._finishDrag()),this.listen(t,"click",i=>{i.target===t&&!this._disabled&&this.focus()}),this._renderChips(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=kl(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._message("valueList.duplicate","This value already exists.")),!1;if(typeof this.options.validate=="function"){let i=this.options.validate(e);if(i!==!0)return this._showError(typeof i=="string"?i:this._message("valueList.invalid","This value is not valid.")),!1}return this._status.textContent="",this._input.removeAttribute("aria-invalid"),this._values.push(e),this._renderChips(),this.emit("add",{value:e}),this.emit("change",{values:this.getValues()}),!0}removeValue(t){if(this._disabled||!this.options.deletable)return!1;let e=this._values.indexOf(String(t));return e<0?!1:(this._removeAt(e),!0)}focus(){return this._input.focus(),this}enable(){return this._disabled=!1,this._input.disabled=!1,this.el.dataset.disabled="false",this._renderChips(),this}disable(){return this._disabled=!0,this._input.disabled=!0,this.el.dataset.disabled="true",this._renderChips(),this}_renderChips(t=-1){let e=this._values.map((i,n)=>l("li",{class:"zx-value-list__chip",role:"option",tabIndex:this._disabled?-1:0,draggable:!!this.options.sortable&&!this._disabled,ariaSelected:"false",ariaDisabled:String(this._disabled),ariaLabel:this.options.deletable?this._message("valueList.removable","%1. Press Delete to remove.",i):i,dataset:{index:n}},l("span",{class:"zx-value-list__value"},i),this.options.deletable?l("span",{class:"zx-value-list__remove",dataset:{remove:""},ariaHidden:"true"},"\xD7"):null));this._list.replaceChildren(...e),t>=0&&e[Math.min(t,e.length-1)]?.focus()}_handleInputKeydown(t){this._disabled||(t.key==="Enter"?(t.preventDefault(),this.addValue(this._input.value)&&(this._input.value="")):t.key==="Backspace"&&this._input.value===""&&this._values.length&&this.options.deletable&&(t.preventDefault(),this._removeAt(this._values.length-1)))}_handleChipKeydown(t){if(this._disabled)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e)return;let i=Number(e.dataset.index);if((t.key==="Delete"||t.key==="Backspace")&&this.options.deletable){t.preventDefault(),this._removeAt(i,Math.min(i,this._values.length-2));return}let n=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0,r=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0,o=n||r;if(!o)return;t.preventDefault();let a=Math.max(0,Math.min(this._values.length-1,i+o));t.ctrlKey&&n&&this.options.sortable?this._move(i,a,!0):this._list.querySelector(`[data-index="${a}"]`)?.focus()}_handleChipClick(t){let e=t.target instanceof Element?t.target:null,i=e?.closest("[data-index]");!i||this._disabled||(e.closest("[data-remove]")&&this.options.deletable?this._removeAt(Number(i.dataset.index)):i.focus())}_handleDragStart(t){if(this._disabled||!this.options.sortable)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;e&&(this._dragIndex=Number(e.dataset.index),this.el.dataset.state="dragging",t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"))}_handleDrop(t){if(this._dragIndex<0||this._disabled)return;t.preventDefault();let e=t.target instanceof Element?t.target.closest("[data-index]"):null,i=e?Number(e.dataset.index):this._values.length-1;this._move(this._dragIndex,i,!0),this._finishDrag()}_finishDrag(){this._dragIndex=-1,this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_move(t,e,i){if(t===e||t<0||e<0||t>=this._values.length||e>=this._values.length)return;let[n]=this._values.splice(t,1);this._values.splice(e,0,n),this._renderChips(i?e:-1),this.emit("change",{values:this.getValues()})}_removeAt(t,e=-1){let[i]=this._values.splice(t,1);i!==void 0&&(this._renderChips(e),e<0&&this._values.length===0&&this._input.focus(),this.emit("remove",{value:i}),this.emit("change",{values:this.getValues()}))}_showError(t){this._status.textContent=t,this._input.setAttribute("aria-invalid","true")}_message(t,e,...i){let n=this.msg(t,...i);return n===t?I(e,i):n}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 kl(s,t){if(!Array.isArray(s))return[];let e=s.map(i=>String(i));return t?[...new Set(e)]:e}function zl(){C.register("valuelist",(s,t)=>{let e=s.own(new ni(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]}));return s.listen(e.el,"change",i=>i.stopImmediatePropagation()),e.on("change",i=>s.emit("change",{value:i.detail.values})),{el:e.el,get:()=>e.getValues(),set:i=>e.setValues(Array.isArray(i)?i:[],{silent:!0}),focus:()=>e.focus(),setDisabled:i=>i?e.disable():e.enable()}})}var ve=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),Tf=["xl","lg","md","sm"];function Mn(s){let t=Number(s);if(!Number.isFinite(t))return"xs";for(let e of Tf)if(t>=ve[e])return e;return"xs"}function Nn(s,t){if(s==="xs")return!0;let e=ve[s];if(e===void 0)throw new RangeError(`Unknown breakpoint "${s}"`);return Number(t)>=e}function ri(s,t={}){if(typeof s!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in t&&!T(t.target)&&t.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let e=t.target??globalThis,i=T(e)?e:null,n=null,r=!1,o=null,a=()=>i?i.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,c=()=>{if(r)return;let d=a();if(i&&d===0)return;let p=Mn(d);p!==n&&(n=p,s(n,d))};c();let h=0,u=()=>{h||r||(h=requestAnimationFrame(()=>{h=0,c()}))};return i&&typeof ResizeObserver=="function"?(o=new ResizeObserver(u),o.observe(i)):globalThis.addEventListener?.("resize",c,{passive:!0}),{current:()=>n??Mn(a()),destroy:()=>{r||(r=!0,h&&cancelAnimationFrame(h),o?.disconnect(),globalThis.removeEventListener?.("resize",c))}}}var is=class{base;headers;onError;timeout;constructor({base:t="",headers:e={},onError:i=null,timeout:n=3e4}={}){this.base=String(t),this.headers=Object.freeze({...e}),this.onError=i,this.timeout=Number(n)}async request(t,e={}){let{method:i="GET",data:n=null,files:r=null,query:o=null,headers:a={}}=e,c=new AbortController,h=this.timeout>0?setTimeout(()=>c.abort(),this.timeout):null,u=new Headers(this.headers);for(let[f,_]of Object.entries(a))u.set(f,_);u.set("Accept",u.get("Accept")??"application/json");let d;r!==null?(d=Df(n,r),u.delete("Content-Type")):n!==null&&i.toUpperCase()!=="GET"&&i.toUpperCase()!=="HEAD"&&(d=JSON.stringify(n),u.set("Content-Type",u.get("Content-Type")??"application/json"));let p=Ef(this.base+t,o);try{let f=await fetch(p,{method:i.toUpperCase(),headers:u,body:d,signal:c.signal}),_=await f.text(),b=null;if(_!=="")try{b=JSON.parse(_)}catch(w){let y=new Error("Invalid JSON response",{cause:w});throw y.response=f,y}if(!f.ok){try{On(b)}catch(y){throw y.response=f,y}let w=new Error(`HTTP ${f.status} ${f.statusText}`.trim());throw w.response=f,w}return On(b)}catch(f){let _=f instanceof Error?f:new Error(String(f));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 If(s,t="",e={}){let{apiBase:i="../remotecall/",...n}=e,r=`${i}${s}${t?`:${t}`:""}/`;return new is({...n,base:r})}function On(s){if(s&&typeof s=="object"){if(Object.prototype.hasOwnProperty.call(s,"error")&&s.error!=null){let t=typeof s.error=="string"?s.error:JSON.stringify(s.error);throw new Error(t||"Server error")}if(Object.prototype.hasOwnProperty.call(s,"result"))return s.result}return s}function Ef(s,t){if(t==null)return s;let e;if(typeof t=="string")e=t.replace(/^\?/,"");else if(t instanceof URLSearchParams)e=t.toString();else{let i=new URLSearchParams;for(let[n,r]of Object.entries(t))Cl(i,n,r);e=i.toString()}return e?s+(s.includes("?")?"&":"?")+e:s}function Cl(s,t,e){if(e!=null)if(Array.isArray(e))for(let i of e)Cl(s,t,i);else s.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function Df(s,t){let e=new FormData;if(s&&typeof s=="object"&&!Array.isArray(s))for(let[n,r]of Object.entries(s))Tl(e,n,r);else s!=null&&e.append("data",typeof s=="string"?s:JSON.stringify(s));let i=Mf(t)||Array.isArray(t)?Array.from(t):[t];for(let n of i)e.append("files",n);return e}function Tl(s,t,e){if(e!=null)if(Array.isArray(e))for(let i of e)Tl(s,t,i);else{let i=typeof Blob=="function"&&e instanceof Blob;s.append(t,typeof e=="object"&&!i?JSON.stringify(e):e)}}function Mf(s){return typeof FileList=="function"&&s instanceof FileList}var Nf=0,Of=20,Ff=3,Lf=["B","KiB","MiB","GiB","TiB","PiB","EiB"],Rf=["B","kB","MB","GB","TB","PB","EB"],Fn=[{unit:"second",ms:1e3,limit:45},{unit:"minute",ms:6e4,limit:45},{unit:"hour",ms:36e5,limit:22},{unit:"day",ms:864e5,limit:6},{unit:"week",ms:6048e5,limit:4},{unit:"month",ms:26298e5,limit:11},{unit:"year",ms:315576e5,limit:1/0}],Il=new Map,El=new Map;function Nt(s,t={}){let e=ss(s);if(e===null)return"";let{locale:i=lt(),decimals:n,minDecimals:r,maxDecimals:o,group:a=!0}=t;return Ln(i,Rn({decimals:n,minDecimals:r,maxDecimals:o,group:a}),e)}function oi(s,t,e={}){let i=ss(s);if(i===null)return"";let{locale:n=lt(),decimals:r}=e,o=jf(t);if(o===null)return Nt(i,{locale:n,decimals:r});let a=Rn({decimals:r,group:!0});return Ln(n,{...a,style:"currency",currency:o},i)}function ai(s,t={}){let e=ss(s);if(e===null)return"";let{locale:i=lt(),decimals:n=0}=t;return Ln(i,{...Rn({decimals:n,group:!0}),style:"percent"},e)}function li(s,t={}){let e=ss(s);if(e===null)return"";let{locale:i=lt(),decimals:n=1,standard:r="iec"}=t;if(e===0)return`${Nt(0,{locale:i,decimals:0})} B`;let o=r==="si"?Rf:Lf,a=r==="si"?1e3:1024,c=Math.abs(e),h=Math.min(o.length-1,Math.max(0,Math.floor(Math.log(c)/Math.log(a)))),u=c/a**h;Hf(u,h===0?0:n)>=a&&h<o.length-1&&(h+=1,u=c/a**h);let d=e<0?-u:u;return`${Nt(d,{locale:i,minDecimals:0,maxDecimals:h===0?0:n})} ${o[h]}`}function Vf(s,t={}){let e=Ml(s);if(e===null)return"";let{now:i=new Date,locale:n=lt(),numeric:r="auto"}=t,o=Ml(i);if(o===null)return"";let a=e.getTime()-o.getTime(),c=Fn.find(({ms:u,limit:d})=>Math.abs(a)/u<d)??Fn[Fn.length-1],h=Math.round(a/c.ms);return Bf(n,r).format(h,c.unit)}function Ln(s,t,e){let i=`${s}\0${JSON.stringify(t)}`,n=Il.get(i);return n===void 0&&(n=Pf(s,t),Il.set(i,n)),n.format(e)}function Pf(s,t){try{return new Intl.NumberFormat(s,t)}catch{try{return new Intl.NumberFormat(void 0,t)}catch{return new Intl.NumberFormat}}}function Bf(s,t){let e=`${s}\0${t}`,i=El.get(e);if(i===void 0){try{i=new Intl.RelativeTimeFormat(s,{numeric:t})}catch{i=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"})}El.set(e,i)}return i}function Rn({decimals:s,minDecimals:t,maxDecimals:e,group:i=!0}){let n={useGrouping:i!==!1},r=Dl(t??s),o=Dl(e??s);return r!==null&&(n.minimumFractionDigits=r),o!==null?(n.maximumFractionDigits=o,r!==null&&r>o&&(n.minimumFractionDigits=o)):r!==null&&(n.maximumFractionDigits=Math.max(r,Ff)),n}function Dl(s){if(s==null)return null;let t=Number(s);return Number.isFinite(t)?Math.min(Of,Math.max(Nf,Math.round(t))):null}function ss(s){if(s==null||s==="")return null;let t=typeof s=="number"?s:Number(s);return Number.isFinite(t)?t:null}function jf(s){if(typeof s!="string")return null;let t=s.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function Ml(s){if(s instanceof Date)return Number.isNaN(s.getTime())?null:s;if(typeof s=="number")return Number.isFinite(s)?new Date(s*1e3):null;if(typeof s=="string"){let t=s.trim();if(t==="")return null;let e=/^-?\d+$/.test(t)?new Date(Number(t)*1e3):new Date(t);return Number.isNaN(e.getTime())?null:e}return null}function Hf(s,t){let e=10**t;return Math.round(s*e)/e}var Nl="zx:__probe__";function ci(s,t={}){let{area:e="local"}=t,i=`zx:${String(s??"")}:`,n=new Map,r=qf(e),o=u=>{if(r!==null)try{return r.getItem(u)}catch{r=null}return n.has(u)?n.get(u):null},a=(u,d)=>{if(r!==null)try{r.setItem(u,d);return}catch{r=null}n.set(u,d)},c=u=>{if(r!==null)try{r.removeItem(u)}catch{r=null}n.delete(u)},h=()=>{if(r!==null)try{let u=[];for(let d=0;d<r.length;d+=1){let p=r.key(d);typeof p=="string"&&p.startsWith(i)&&u.push(p)}return u}catch{r=null}return[...n.keys()].filter(u=>u.startsWith(i))};return{get(u,d){let p=o(i+u);if(p==null)return d;try{return JSON.parse(p)}catch{return d}},set(u,d){let p;try{p=JSON.stringify(d)}catch{p=void 0}p===void 0?c(i+u):a(i+u,p)},remove(u){c(i+u)},keys(){return h().map(u=>u.slice(i.length))},clear(){for(let u of h())c(u)}}}function qf(s){let t=s==="session"?"sessionStorage":"localStorage";try{let e=globalThis[t];return!e||typeof e.getItem!="function"?null:(e.setItem(Nl,"1"),e.removeItem(Nl),e)}catch{return null}}var $f=["=","+","-","@"];function Kf(s,t,e={}){let{delimiter:i=",",header:n=!0,newline:r=`\r
|
|
9
|
+
`}=e,o=Wf(t),a=[];n&&a.push(o.map(c=>Fl(c.label,i,Ol(c.label))).join(i));for(let c of s??[]){let h=o.map(u=>{let d=typeof u.value=="function"?u.value(c):Gf(c,u.id);return Fl(Qf(d),i,Ol(d))});a.push(h.join(i))}return a.join(r)}function Uf(s,t,e={}){let{type:i="text/plain;charset=utf-8"}=e,n=Xf(t,i),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=String(s??"download"),o.rel="noopener",o.style.display="none",document.body.append(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}async function Vn(s){let t=String(s??"");if(globalThis.navigator?.clipboard?.writeText)try{return await navigator.clipboard.writeText(t),!0}catch{}return Yf(t)}function Yf(s){if(typeof document>"u"||!document.body)return!1;let t=document.activeElement,e=document.createElement("textarea");e.value=s,e.setAttribute("readonly",""),e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;inset-block-start:-1000px;opacity:0;pointer-events:none",document.body.append(e);let i=!1;try{e.select(),e.setSelectionRange(0,s.length),i=document.execCommand?.("copy")===!0}catch{i=!1}finally{e.remove(),t instanceof HTMLElement&&t.focus({preventScroll:!0})}return i}function Wf(s){return(s??[]).map(t=>{if(typeof t=="string")return{id:t,label:t};let e=String(t?.id??"");return{id:e,label:String(t?.label??e),value:t?.value}})}function Gf(s,t){return s?.[t]}function Qf(s){if(s==null)return"";if(s instanceof Date)return Number.isNaN(s.getTime())?"":s.toISOString();if(typeof s=="number")return Number.isFinite(s)?String(s):"";if(typeof s=="boolean")return s?"true":"false";if(typeof s=="object")try{return JSON.stringify(s)}catch{return String(s)}return String(s)}function Ol(s){return typeof s!="string"?!1:$f.includes(s.charAt(0))}function Fl(s,t,e=!1){let i=e?` ${s}`:s;return i.includes(t)||i.includes('"')||i.includes(`
|
|
10
|
+
`)||i.includes("\r")?`"${i.replaceAll('"','""')}"`:i}function Xf(s,t){if(typeof Blob=="function"&&s instanceof Blob)return s;let e=typeof s=="string"&&/^text\/csv\b/i.test(t)?["\uFEFF",s]:[s];return new Blob(e,{type:t})}var Ut=class extends m{static cssName="check-button";static defaults={label:"",checked:!1,icon:!0,disabled:!1};render(){let t=!this.el,e=this.el??l("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:Jf(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,this._labels=Ll(this.options.label),e.type="button";let i=[];return this.options.icon&&i.push(l("span",{class:"zx-check-button__icon",ariaHidden:"true"},l("span",{class:"zx-check-button__off"},g("square",{size:15})),l("span",{class:"zx-check-button__on"},g("check",{size:15})))),i.push(l("span",{class:"zx-check-button__label",ref:"label"})),e.replaceChildren(...i),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let i=!!t;return i===this._checked?this:(this._checked=i,this._sync(),e||this.emit("change",{checked:this._checked}),this)}toggle(){return this.set(!this._checked)}setLabel(t){return this._labels=Ll(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&&Zf(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 Ll(s){return Array.isArray(s)?{on:String(s[0]??""),off:String(s[1]??"")}:{on:String(s??""),off:String(s??"")}}function Jf(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Zf(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}var tp=".zx-scope, [data-zx-theme], [data-zx-density], [data-zx-preset]";function rt(s=null){let e=(s==null?document.activeElement instanceof Element?document.activeElement:null:q(s))?.closest?.(tp)??null;return!e||e===document.documentElement||e===document.body?document.body:e}var ep=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(","),hi=class extends m{static cssName="modal";static defaults={content:null,width:"auto",closable:!0,lightDismiss:!1,destroyOnClose:!1,scope:null};#t=new Map;#e=!1;#i=0;#s=[];#r=null;constructor(t=null,e={}){super(null,e),this.#a(this.options.width),Vl(this.refs.content,this.options.content),this.listen(this.el,"cancel",i=>{let n=this.emit("cancel");(!this.options.closable||n.defaultPrevented)&&i.preventDefault()}),this.listen(this.el,"close",()=>{this._settleClose(this.#s.shift())}),this.listen(this.el,"click",i=>{!this.options.lightDismiss||i.target!==this.el||!sp(this.el,i)||this.close()}),this.on("close",()=>this.#o())}mountTarget(){return rt(this.options.scope)}_show(){this.el.showModal()}_hide(t="",e=this.#i){this.#s.push(e);try{this.el.close(t)}catch(i){throw this.#s.pop(),i}}_present(){this._show(),this.#i+=1,this.#n()}#n(){this.el.matches(":modal")?this.el.setAttribute("aria-modal","true"):this.el.getAttribute("aria-modal")==="true"&&this.el.removeAttribute("aria-modal")}_dismiss(t=""){this._hide(t,this.#i)}_isShown(){return this.el.open}_isRealClose(t){return t!==void 0&&t!==this.#i?!1:!this._isShown()}_settleClose(t){if(!this._isRealClose(t))return t!==void 0&&this.#t.delete(t),!1;this.el.dataset.state="closed",delete this.el.dataset.zxOverlayOrder,this.el.getAttribute("aria-modal")==="true"&&this.el.removeAttribute("aria-modal");let e=t===void 0?void 0:this.#t.get(t);t!==void 0&&this.#t.delete(t);let i=e?e.result:this.el.returnValue||void 0;return this.emit("close",{result:i}),this.options.destroyOnClose&&!this.#e&&this.destroy(),!0}#o(){let t=this.#r;this.#r=null,t?.isConnected&&typeof t.focus=="function"&&t.focus()}_focusInitial(){if(!this.isOpen())return;let t=ip(this.el);if(t){t.focus();return}let e=this.el;e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus()}render(){let t=l("dialog",{class:"zx-modal"},l("div",{class:"zx-modal__content",ref:"content"}));return t.dataset.state="closed",this.mountTarget().append(t),t}open(){if(this.isOpen())return this;this.#r=document.activeElement instanceof Element?document.activeElement:null;let t=this.mountTarget();this.el.parentElement!==t&&t.append(this.el),this.el.dataset.zxOverlayOrder=String(np()),this.el.returnValue="";try{this._present()}catch(e){throw delete this.el.dataset.zxOverlayOrder,this.#r=null,e}return this.el.dataset.state="open",this.emit("open"),queueMicrotask(()=>this._focusInitial()),this}close(t){if(!this.isOpen())return this;let e=this.#i;this.#t.set(e,{result:t});try{this._dismiss(typeof t=="string"?t:"")}catch(i){throw this.#t.delete(e),i}return this}setContent(t){return Vl(this.refs.content,t),this}isOpen(){return this._isShown()}destroy(){this.#e||(this.#e=!0,this.isOpen()&&this._dismiss(),super.destroy())}#a(t){typeof t=="number"&&Number.isFinite(t)?this.el.style.inlineSize=`${Math.max(0,t)}px`:this.el.style.inlineSize=String(t??"auto")}};function ip(s){let t=s.querySelector("[autofocus]:not([disabled])");if(t&&Rl(t,s))return t;for(let e of s.querySelectorAll(ep))if(Rl(e,s))return e;return null}function Rl(s,t){if(typeof s.focus!="function")return!1;for(let e=s;e;e=e.parentElement){if(e.hidden||e.getAttribute("aria-hidden")==="true"||e.hasAttribute("inert"))return!1;if(e===t)break}return!0}function Vl(s,t){if(s.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t.nodeType=="number"&&s.append(t)}function sp(s,t){let e=s.getBoundingClientRect();return t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom}function np(){let s=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...s)+1}var rp=Object.freeze({label:"",icon:null,kind:"default",size:"md",disabled:!1});function j(s={}){let t={...rp,...s},e=l("button",{class:"zx-btn",type:"button",disabled:!!t.disabled,title:t.title??(t.shortcut?`${t.label} (${t.shortcut.label})`:void 0),ariaKeyshortcuts:t.shortcut?.keys,dataset:{kind:ap(t.kind),size:lp(t.size)}});return t.icon&&e.append(g(t.icon,{size:16})),t.label!==""&&e.append(l("span",{class:"zx-btn__label"},String(t.label))),t.shortcut&&e.append(l("kbd",{class:"zx-btn__shortcut",ariaHidden:"true"},t.shortcut.label)),!t.label&&t.title&&e.setAttribute("aria-label",t.title),typeof t.onclick=="function"&&(e.onclick=t.onclick),e}function op(s){let t=l("div",{class:"zx-btn-group",role:"group"});return t.append(...s),t}function ap(s){return["primary","danger","ghost"].includes(String(s))?s:"default"}function lp(s){return s==="sm"?"sm":"md"}var Yt=class s extends hi{static cssName="dialog";static defaults={title:"",size:"md",buttons:[],closable:!0};#t=new Map;#e=null;#i=[];#s="";constructor(t=null,e={}){super(null,e),this._applySize(this.options.size),this.#s=String(this.options.title??""),this.#n(this.#s),this.#i=ns(this.options.buttons),this.#o(this.#i),this.refs.close.hidden=!this.options.closable,this.listen(this.refs.close,"click",()=>this.close()),this.listen(this.refs.footer,"click",i=>{let n=i.target.closest?.("[data-dialog-button]");if(!n||!this.refs.footer.contains(n))return;let r=this.#r[Number(n.dataset.dialogButton)];r&&this.#a(r)})}#r=[];render(){let t=x("zx-dialog-title"),e=this._message("dialog.close","Close"),i=l("dialog",{class:"zx-modal zx-dialog",ariaLabelledby:t},l("header",{class:"zx-dialog__header"},l("h2",{class:"zx-dialog__title",id:t,ref:"title"}),l("button",{class:"zx-btn zx-dialog__close",ref:"close",type:"button","data-kind":"ghost",ariaLabel:e,title:e},"\xD7")),l("div",{class:"zx-modal__content zx-dialog__body",ref:"content"}),l("footer",{class:"zx-dialog__footer",ref:"footer"}));return i.dataset.state="closed",this.mountTarget().append(i),i}open(){return super.open()}setTitle(t){return this.#s=String(t??""),this.#n(this.#s),this}setContent(t){return this.#t.clear(),this.#e=null,cp(this.refs.content,t),this}setButtons(t){return this.#i=ns(t),this.#o(this.#i),this}addView(t,e){let i=String(t);this.#t.get(i)?.content.remove();let r=l("section",{class:"zx-dialog__view",hidden:!0,ariaHidden:"true"});Pl(r,e?.content??null);let o={key:i,content:r,buttons:e&&Object.hasOwn(e,"buttons")?ns(e.buttons??[]):null,title:e&&Object.hasOwn(e,"title")?String(e.title??""):null};return this.#t.set(i,o),this.#t.size===1||this.#e?.key===i?this.showView(i):this.refs.content.append(r),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 i of this.#t.values()){i.content.isConnected||this.refs.content.append(i.content);let n=i===e;i.content.hidden=!n,i.content.setAttribute("aria-hidden",String(!n))}return this.#e=e,this.#n(e.title??this.#s),this.#o(e.buttons??this.#i),e}getView(t){return this.#t.get(String(t))??null}static alert({title:t="",message:e="",okLabel:i}={}){return new Promise(n=>{let r=!1,o=()=>{r||(r=!0,a.close(),n())},a=new s(null,{title:t,content:e});a.setButtons([{label:i??a._message("dialog.ok","OK"),kind:"primary",action:o,autofocus:!0}]),a.once("close",()=>{r||(r=!0,n()),a.destroy()}),a.open()})}static confirm({title:t="",message:e="",okLabel:i,cancelLabel:n,danger:r=!1}={}){return new Promise(o=>{let a=!1,c=u=>{a||(a=!0,h.close(u),o(u))},h=new s(null,{title:t,content:e});h.setButtons([{label:n??h._message("dialog.cancel","Cancel"),action:()=>c(!1)},{label:i??h._message("dialog.ok","OK"),kind:r?"danger":"primary",action:()=>c(!0),autofocus:!0}]),h.once("close",()=>{a||(a=!0,o(!1)),h.destroy()}),h.open()})}static prompt({title:t="",message:e="",value:i="",placeholder:n=""}={}){return new Promise(r=>{let o=!1,a=l("input",{class:"zx-dialog__prompt-input",value:String(i),placeholder:String(n),autofocus:!0}),c=l("div",{class:"zx-dialog__prompt"},l("div",{class:"zx-dialog__prompt-message"},e),a),h=d=>{o||(o=!0,u.close(d),r(d))},u=new s(null,{title:t,content:c});a.setAttribute("aria-label",String(t||u._message("dialog.promptValue","Prompt value"))),u.setButtons([{label:u._message("dialog.cancel","Cancel"),action:()=>h(null)},{label:u._message("dialog.ok","OK"),kind:"primary",action:()=>h(a.value)}]),u.listen(a,"keydown",d=>{d.key==="Enter"&&(d.preventDefault(),h(a.value))}),u.once("close",()=>{o||(o=!0,r(null)),u.destroy()}),u.open()})}_applySize(t){let e={sm:400,md:600,lg:840},i=typeof t=="number"&&Number.isFinite(t)?t:e[t]??e.md;this.el.style.inlineSize=`${Math.max(0,i)}px`}_message(t,e){let i=this.msg(t);return i===t?e:i}#n(t){this.refs.title.textContent=t}#o(t){this.#r=ns(t),this.refs.footer.replaceChildren(),this.refs.footer.hidden=this.#r.length===0,this.#r.forEach((e,i)=>{let n=j({label:e.label,kind:e.kind,shortcut:e.shortcut,disabled:e.disabled});n.dataset.dialogButton=String(i),n.autofocus=e.autofocus,this.refs.footer.append(n)})}#a(t){if(t.disabled)return;let e=t.action??"close";e==="close"?this.close():e==="cancel"?this.emit("cancel").defaultPrevented||this.close():typeof e=="function"&&e(this)}};function ns(s){return Array.isArray(s)?s.map(t=>{let e=!!t?.disabled;return{...t,label:String(t?.label??""),disabled:e,autofocus:!!t?.autofocus&&!e}}):[]}function cp(s,t){s.replaceChildren(),Pl(s,t)}function Pl(s,t){if(t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t.nodeType=="number"&&s.append(t)}var se=class extends m{static cssName="groupbox";static defaults={title:"",open:!0};constructor(t,e={}){let i=t,n=null;if(t!==null){let r=q(t);if(r&&r.localName!=="details"){let o=document.createElement("details"),a=Array.from(r.childNodes),c=r.parentNode,h=r.nextSibling;c&&c.insertBefore(o,r),o.append(...a),r.remove(),n={original:r,details:o,children:a,parent:c,next:h},i=o}}try{super(i,e)}catch(r){throw n&&Bl(n),r}this._adoption=n}render(){let t=!this.el,e=this.el??l("details");if(e.localName!=="details")throw new TypeError("Groupbox requires a details element");this._createdRoot=t,this._original=t?null:hp(e);let i=Array.from(e.childNodes).filter(o=>!(o.nodeType===1&&o.localName==="summary")),n=l("summary",{class:"zx-groupbox__summary",ref:"summary"},l("span",{class:"zx-groupbox__chevron",ariaHidden:"true"},g("chevron-right",{size:16})),l("span",{class:"zx-groupbox__title",ref:"title"},String(this.options.title))),r=l("div",{class:"zx-groupbox__content",ref:"content"},i);return e.replaceChildren(n,r),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 m?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?Bl(this._adoption):!this._createdRoot&&this._original&&up(this.el,this._original))}};function hp(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function up(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function Bl(s){if(s.original.replaceChildren(...s.children),s.details.parentNode)s.details.replaceWith(s.original);else if(s.parent){let t=s.next?.parentNode===s.parent?s.next:null;s.parent.insertBefore(s.original,t)}}var ne=class extends m{static cssName="search";static defaults={placeholder:"",value:"",clearable:!0,debounce:250};render(){let t=!this.el,e=this.el??l("form");this._createdRoot=t,this._original=t?null:dp(e),this._inputTimer=null,e.setAttribute("role","search");let i=this._message("search.clear","Clear search"),n=l("input",{class:"zx-search__input",ref:"input",type:"search",placeholder:String(this.options.placeholder),value:String(this.options.value),ariaLabel:String(this.options.placeholder||this._message("search.label","Search"))}),r=this.options.clearable?l("button",{class:"zx-search__clear",ref:"clear",type:"button",ariaLabel:i,title:i},g("x",{size:15})):null,o=l("button",{class:"zx-search__submit",ref:"submit",type:e.localName==="form"?"submit":"button",ariaLabel:this._message("search.submit","Submit search"),title:this._message("search.submitTitle","Search")},g("search",{size:16}));return e.replaceChildren(...[n,r,o].filter(Boolean)),this._syncClear(),this.listen(n,"input",()=>{this._syncClear(),this._scheduleInput()}),e.localName==="form"?this.listen(e,"submit",a=>{a.preventDefault(),this.emit("submit",{value:this.get()})}):(this.listen(n,"keydown",a=>{a.key==="Enter"&&(a.preventDefault(),this.emit("submit",{value:this.get()}))}),this.listen(o,"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&&fp(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()==="")}_message(t,e){let i=this.msg(t);return i===t?e:i}};function dp(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function fp(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}var pp=new Set(["divided","bracket","line","segmented"]),ui=class extends m{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??l("section");if(this.el=e,this._createdRoot=t,this._original=t?null:mp(e),this._cleaned=!1,this._tabs=[],this._active=null,this._keepAlive=!!this.options.keepAlive,this._initializing=!0,!pp.has(this.options.variant))throw new RangeError(`Unknown tabbox variant: ${this.options.variant}`);e.dataset.variant=this.options.variant;let i=l("div",{class:"zx-tabbox__tablist",ref:"tablist",role:"tablist",ariaOrientation:"horizontal"}),n=l("div",{class:"zx-tabbox__panels",ref:"panels"});if(e.replaceChildren(i,n),!Array.isArray(this.options.tabs))throw new TypeError("Tabbox tabs must be an array");for(let a of this.options.tabs)this.addTab(a);this._initializing=!1;let r=this.options.active===null?null:this._find(this.options.active),o=r&&!r.definition.disabled?r:this._enabledTabs()[0];return o&&this._applyActive(o),this.listen(i,"click",a=>{let c=a.target.closest?.('[role="tab"]');if(!c||!i.contains(c))return;let h=this._recordForTab(c);if(!(!h||h.definition.disabled)){if(a.target.closest?.(".zx-tabbox__close")){this._closeTab(h);return}this._setFocused(h),this.openTab(h.definition.name)}}),this.listen(i,"keydown",a=>this._onKeydown(a)),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(!_p(t.content))throw new TypeError("Tab content must be a Node, Component, or function");let i={name:t.name,title:String(t.title??""),content:t.content,icon:t.icon?String(t.icon):null,closable:!!t.closable,disabled:!!t.disabled},n=x("zx-tab"),r=x("zx-tabpanel"),o=l("span",{class:"zx-tabbox__title"},i.title),a=l("span",{class:"zx-tabbox__badge",hidden:!0}),c=[];i.icon&&c.push(l("span",{class:"zx-tabbox__icon",ariaHidden:"true"},g(i.icon,{size:16}))),c.push(o,a),i.closable&&c.push(l("span",{class:"zx-tabbox__close zx-icon-btn",ariaHidden:"true",title:this._message("tabbox.close","Close")},g("x",{size:14})));let h=l("button",{class:"zx-tabbox__tab",type:"button",id:n,role:"tab",tabindex:"-1",ariaControls:r,ariaSelected:"false",ariaDisabled:i.disabled?"true":null,dataset:{closable:i.closable?"true":null}},c),u=l("div",{class:"zx-tabbox__panel",id:r,role:"tabpanel",tabindex:"0",ariaLabelledby:n,hidden:!0}),d={definition:i,tab:h,title:o,badge:a,panel:u,built:!1},p=Number.isFinite(e.index)?Math.trunc(e.index):this._tabs.length,f=Math.max(0,Math.min(this._tabs.length,p)),_=this._tabs[f]??null;return this._tabs.splice(f,0,d),this.refs.tablist.insertBefore(h,_?.tab??null),this._keepAlive&&this.refs.panels.insertBefore(u,_?.panel??null),!this._initializing&&!this._active&&!i.disabled&&this._applyActive(d),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 i=this._active?.definition.name??null;return this.emit("change",{name:e.definition.name,previous:i}).defaultPrevented?this:(this._applyActive(e),this)}show(t){return this.openTab(t)}getActive(){return this._active?.definition.name??null}setTitle(t,e){let i=this._require(t);return i.definition.title=String(e??""),i.title.textContent=i.definition.title,this}setBadge(t,e){let i=this._require(t);return i.badge.textContent=e===null?"":String(e),i.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 i=this._enabledTabs().find(n=>n!==e)??null;if(i){if(this.openTab(i.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&&gp(this.el,this._original))}_onKeydown(t){let e=t.target.closest?.('[role="tab"]');if(!e||!this.refs.tablist.contains(e))return;let i=this._recordForTab(e);if(!i)return;let n=this._enabledTabs();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let r=t.key==="ArrowRight"?1:-1,o=n.indexOf(i),a=n[(o+r+n.length)%n.length];a&&this._setFocused(a);return}if(t.key==="Home"||t.key==="End"){t.preventDefault();let r=t.key==="Home"?n[0]:n[n.length-1];r&&this._setFocused(r);return}if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.openTab(i.definition.name);return}t.key==="Delete"&&i.definition.closable&&(t.preventDefault(),this._closeTab(i))}_closeTab(t){let e=this._tabs.indexOf(t),i=t.tab.contains(document.activeElement);if(!this._removeTab(t.definition.name,!0))return;let n=this._tabs[Math.min(e,this._tabs.length-1)]??this._tabs[e-1],r=n&&!n.definition.disabled?n:this._active;r&&this._setFocused(r,i)}_removeTab(t,e){let i=this._find(t);if(!i)return!1;let n=this._tabs.indexOf(i),o=this._tabs.filter(c=>c!==i).filter(c=>!c.definition.disabled),a=o.find(c=>this._tabs.indexOf(c)>n)??o.at(-1)??null;return i===this._active&&a&&this.emit("change",{name:a.definition.name,previous:i.definition.name}).defaultPrevented?!1:(this._tabs.splice(n,1),i.tab.remove(),i.panel.remove(),i===this._active&&(this._active=null,a&&this._applyActive(a)),e&&this.emit("close",{name:i.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,i=e instanceof m?e.toElement():e;if(!i||typeof i.nodeType!="number")throw new TypeError(`Tab content factory for ${t.definition.name} must return a Node or Component`);t.panel.append(i),t.built=!0}_setFocused(t,e=!0){for(let i of this._tabs)i.tab.tabIndex=i===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}_message(t,e){let i=this.msg(t);return i===t?e:i}};function _p(s){return typeof s=="function"||s instanceof m?!0:!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function mp(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function gp(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function bp(s,t){return String(s).localeCompare(String(t))}function yp(s,t){return s-t}function wp(s,t){return s.getTime()-t.getTime()}function xp(s,t,e="asc"){let i=s==null,n=t==null;if(i||n)return i&&n?0:i?1:-1;let r;return s instanceof Date&&t instanceof Date?r=wp(s,t):typeof s=="number"&&typeof t=="number"?r=yp(s,t):r=bp(s,t),e==="desc"?-r:r}function vp(s,t="asc"){return(e,i)=>xp(s(e),s(i),t)}function di(s,t,e="asc"){let i=vp(t,e);return s.map((n,r)=>({row:n,index:r})).sort((n,r)=>i(n.row,r.row)||n.index-r.index).map(({row:n})=>n)}var Sp=new Set(["text","number","select","date","checkbox","textarea"]),Ap='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',Ot=class extends m{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,rowKind:null,rowKinds:null,zebra:!0,editMode:!1,editTrigger:"double",hierarchy:!1,rowReorder:!1,columnVisibility:!1,columnReorder:!1,hiddenColumns:[]};constructor(t,e={}){super(t,e)}render(){let t=this.el===null,e=this.el??l("div");if(this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._columns=Hl(this.options.columns),this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._rowKind=Fp(this.options.rowKind),this._rowKinds=Lp(this.options.rowKinds),this._spanning=this._hasSpanningRow(),this._sortWarned=!1,this._selected=new Set,this._selectionAnchorId=null,this._sort=$l(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=Vp(this.options.editMode),this._editTrigger=this.options.editTrigger==="single"?"single":"double",this._edit=null,this._editMessage=null,this._stacked=!1,this._width=null,this._growStep=$p(this.options.growing),this._rendered=this._growStep??1/0,this._more=null,this._rovingKey=null,this._rovingCell=null,this._rovingMatched=!1,this._hierarchy=Pn(this.options.hierarchy,this._columns),this._hiddenColumns=new Set((Array.isArray(this.options.hiddenColumns)?this.options.hiddenColumns:[]).map(String).filter(i=>this._columns.some(n=>n.id===i))),this._hiddenColumns.size>=this._columns.length&&this._columns[0]&&this._hiddenColumns.delete(this._columns[0].id),this._dragId=null,this._grabbedId=null,this._columnControlIds=new Map,this._columnStatus=null,this._expanded=Rp(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let i of rs(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(i);return this._reconcileExpanded(),this._table=l("table",{class:"zx-table__table"}),this._hierarchy&&this._table.setAttribute("role","treegrid"),this._colgroup=l("colgroup",{class:"zx-table__columns"}),this._thead=l("thead",{class:"zx-table__head"}),this._tbody=l("tbody",{class:"zx-table__body"}),this._table.append(this._colgroup,this._thead,this._tbody),this._scroll=l("div",{class:"zx-table__scroll",dataset:{stickyHeader:String(!!this.options.stickyHeader),zebra:String(!!this.options.zebra)}},this._table),this._rowMoveMessage=this.options.rowReorder?l("div",{class:"zx-table__reorder-status",role:"status",ariaLive:"polite"}):null,this.options.height!=null&&(this._scroll.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._columnControls=this.options.columnVisibility||this.options.columnReorder?this._createColumnControls():null,this._editMode===!1?e.replaceChildren(...[this._columnControls,this._scroll,this._rowMoveMessage].filter(Boolean)):(e.dataset.editMode=this._editMode,this._editMessage=l("div",{class:"zx-table__message",id:x("zx-table-message"),role:"status",ariaLive:"polite"}),e.replaceChildren(...[this._columnControls,this._scroll,this._editMessage,this._rowMoveMessage].filter(Boolean))),this._renderColumns(),this._renderHeader(),this._renderBody(),this._watchWidth(),this.listen(this._tbody,"click",i=>this._handleBodyClick(i)),this.listen(this._tbody,"dblclick",i=>this._handleBodyDoubleClick(i)),this.options.rowReorder&&(this.listen(this._tbody,"dragstart",i=>this._handleRowDragStart(i)),this.listen(this._tbody,"dragover",i=>this._handleRowDragOver(i)),this.listen(this._tbody,"drop",i=>this._handleRowDrop(i)),this.listen(this._tbody,"dragend",()=>this._clearRowDrag()),this.listen(this._tbody,"keydown",i=>this._handleRowHandleKeydown(i))),this._columnControls&&(this.listen(this._columnControls,"change",i=>{let n=i.target;n?.classList.contains("zx-table__column-toggle")&&this.setColumnVisible(n.value,n.checked)}),this.listen(this._columnControls,"click",i=>this._handleColumnControlClick(i)),this.listen(this._columnControls,"keydown",i=>this._handleColumnControlKeydown(i))),this._editMode!==!1&&(this.listen(this._tbody,"keydown",i=>this._handleEditKeydown(i)),this.listen(this._tbody,"focusin",i=>this._handleEditFocusIn(i)),this.listen(document,"pointerdown",i=>this._handleDocumentPointerDown(i),{capture:!0})),e}setLoading(t=!0){return t?this.el.dataset.loading="true":delete this.el.dataset.loading,this.el.setAttribute("aria-busy",String(!!t)),this}setData(t){this._rendered=this._growStep??1/0,this.setLoading(!1),Kl(t),this._data=[...t],this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded();let e=this._pruneSelection();return this._renderBody(),e&&this._emitSelectionChange(),this._emitDataChange(),this}addData(t){return Kl(t),this._data.push(...t),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),this._emitDataChange(),this}updateRow(t,e){let i=this._data.findIndex(r=>Object.is(this._idFor(r),t));if(i<0)return this;let n=this._selected.delete(t);return this._data[i]=e,n&&this._selected.add(this._idFor(e)),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),n&&!Object.is(t,this._idFor(e))&&this._emitSelectionChange(),this._emitDataChange(),this}removeRow(t){let e=this._data.findIndex(n=>Object.is(this._idFor(n),t));if(e<0)return this;this._data.splice(e,1),this._reconcileExpanded();let i=this._selected.delete(t);return Object.is(this._selectionAnchorId,t)&&(this._selectionAnchorId=null),this._renderBody(),i&&this._emitSelectionChange(),this._emitDataChange(),this}getRow(t){return this._data.find(e=>Object.is(this._idFor(e),t))??null}getData(){return[...this._data]}getColumns(){return this._columns.map(t=>({...t}))}setColumns(t,e={}){let i=Hl(t),n=this.getColumnOrder(),r=this.getHiddenColumns(),o=this.getSort();return this._abortEdit({focus:!1}),this._columns=i,this._hiddenColumns=new Set(r.filter(a=>i.some(c=>c.id===a))),this._hiddenColumns.size>=i.length&&i[0]&&this._hiddenColumns.delete(i[0].id),this._sort=$l(o,i),this._hierarchy=Pn(this.options.hierarchy,i),this._reconcileExpanded(),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(),e.silent||(as(n,this.getColumnOrder())||this.emit("columnorderchange",{order:this.getColumnOrder()}),as(r,this.getHiddenColumns())||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()})),this}getColumnOrder(){return this._columns.map(t=>t.id)}setColumnOrder(t,e={}){let i=Bp(this._columns,t);if(as(i,this.getColumnOrder()))return this;let n=this._activeColumnControl(),r=new Map(this._columns.map(o=>[o.id,o]));return this._abortEdit({focus:!1}),this._columns=i.map(o=>r.get(o)),this._hierarchy=Pn(this.options.hierarchy,this._columns),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(n),e.silent||this.emit("columnorderchange",{order:this.getColumnOrder()}),this}moveColumn(t,e,i="before",n={}){if(i!=="before"&&i!=="after")throw new TypeError('Table column position must be "before" or "after"');let r=jp(this.getColumnOrder(),String(t),String(e),i);if(as(r,this.getColumnOrder()))return this;if(this.setColumnOrder(r,n),this._columnStatus){let o=this._columns.find(c=>c.id===String(t)),a=this.getColumnOrder().indexOf(String(t));o&&a>=0&&(this._columnStatus.textContent=`Moved ${o.label} to position ${a+1} of ${this._columns.length}.`)}return this}getVisibleColumns(){return this._visibleColumns().map(t=>t.id)}getHiddenColumns(){return this._columns.filter(t=>this._hiddenColumns.has(t.id)).map(t=>t.id)}setColumnVisible(t,e=!0,i={}){let n=String(t);if(!this._columns.find(c=>c.id===n))throw new RangeError(`Unknown table column: ${n}`);let o=this._activeColumnControl();if(!e&&!this._hiddenColumns.has(n)&&this._visibleColumns().length<=1)return this._renderColumnControls(o),this;let a=e?this._hiddenColumns.delete(n):!this._hiddenColumns.has(n);return!e&&a&&this._hiddenColumns.add(n),a?(this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(o),i.silent||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()}),this):this}toggleColumn(t,e={}){return this.setColumnVisible(t,this._hiddenColumns.has(String(t)),e)}moveRow(t,e,i="before"){if(!this.options.rowReorder||this._sort&&this.options.sortMode==="local")return this;let n=this.getRow(t),r=this.getRow(e);if(!n||!r||Object.is(t,e))return this;if(this._isSpanningRow(n))return this;let o=Gl(this._data,this.options.rowId,t,e,i,this._hierarchy?.parentId);if(!o)return this;if(this.emit("rowmove",{row:n,id:t,target:r,targetId:e,position:i}).defaultPrevented)return this;if(this._data=o,this._renderBody(),this._rowMoveMessage){let c=this._siblingIds(t),h=c.findIndex(u=>Object.is(u,t));this._rowMoveMessage.textContent=`Moved row to position ${h+1} of ${c.length}.`}return this._emitDataChange(),queueMicrotask(()=>this._rowHandle(t)?.focus()),this}empty(){let t=this._selected.size>0;return this._data=[],this._expanded.clear(),this._selected.clear(),this._selectionAnchorId=null,this._renderBody(),t&&this._emitSelectionChange(),this._emitDataChange(),this}setSort(t,e,i={}){if(this._spanning)return this._sortWarned||(this._sortWarned=!0,console.warn("[zx.Table] setSort() is inert while the data contains spanning rowKinds rows: sorting would scatter the rows out of the sections that group them.")),this;if(this._abortEdit({focus:!1}),!this._columns.find(o=>o.id===t))throw new RangeError(`Unknown table column: ${t}`);let r=e??(this._sort?.id===t&&this._sort.dir==="asc"?"desc":"asc");if(r!=="asc"&&r!=="desc")throw new TypeError('Table sort direction must be "asc" or "desc"');return this._sort={id:t,dir:r},this.options.sortMode==="local"&&(this._sortData(),this._renderBody()),this._syncSortHeader(),i.silent||this.emit("sort",{id:t,dir:r}),this}getSort(){return this._sort?{...this._sort}:null}clearSort(t={}){return this._sort?(this._abortEdit({focus:!1}),this._sort=null,this._syncSortHeader(),t.silent||this.emit("sort",{id:null,dir:null}),this):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=this._selectableIds(),i=new Set;if(this.options.selectable!==!1){for(let n of t)if(e.has(n)&&i.add(n),this.options.selectable==="single"&&i.size>0)break}return qp(this._selected,i)?this:(this._selected=i,this._syncSelection(),this._emitSelectionChange(),this)}clearSelection(){return this._selected.size===0?this:(this._selected.clear(),this._selectionAnchorId=null,this._syncSelection(),this._emitSelectionChange(),this)}toggleRow(t,e={}){return this._expanded.has(t)?this.collapseRow(t,e):this.expandRow(t,e)}expandRow(t,e={}){return this._setRowExpanded(t,!0,e)}collapseRow(t,e={}){return this._setRowExpanded(t,!1,e)}expandAll(t={}){if(!this._hierarchy)return this;let i=rs(this._data,this.options.rowId,this._hierarchy.parentId).filter(n=>!this._expanded.has(n));for(let n of i)this._expanded.add(n);if(i.length&&this._renderBody(),!t.silent)for(let n of i)this._emitRowToggle(n,!0);return this}collapseAll(t={}){if(!this._hierarchy||this._expanded.size===0)return this;let e=[...this._expanded];if(this._expanded.clear(),this._renderBody(),!t.silent)for(let i of e)this._emitRowToggle(i,!1);return this}getExpanded(){return this._data.map(t=>this._idFor(t)).filter(t=>this._expanded.has(t))}startEdit(t,e){if(this._editMode===!1)return this;let i=this._columns.find(p=>p.id===e);if(!i)return this;let n=this._data.find(p=>Object.is(this._idFor(p),t));if(n===void 0)return this;if(this._isSpanningRow(n))return this;let r=this._editMode==="row"&&this._hiddenColumns.has(i.id)?this._visibleColumns().find(p=>Se(p,n)!==!1)??null:i;if(!r||Se(r,n)===!1)return this;let o=r.id;if(this._edit){if(Object.is(this._edit.id,t)&&this._edit.cells.has(o))return this._edit.columnId=o,this._focusEditor(o),this;if(this.commitEdit(),this._edit)return this}let a=this._data.findIndex(p=>Object.is(this._idFor(p),t));if(a<0)return this;let c=this._data[a],h=this._rowElements.get(t)?.[0];if(!h)return this;let u=this._editMode==="row"?this._visibleColumns().filter(p=>Se(p,c)!==!1):[r],d=new Map;for(let p of u){let f=ql(h,p.id);if(!f)continue;let _=this._createEditor(f,p,c,a);_&&d.set(p.id,_)}return d.size===0?this:(this._edit={id:t,columnId:o,row:c,cells:d,tr:h},h.dataset.editing="true",this.emit("editstart",{row:c,id:t,column:r,columnId:o,value:c?.[o]}),this._focusEditor(o),this)}commitEdit(){let t=this._edit;if(!t)return this;let e=this.getRow(t.id)??t.row,i={};for(let[d,p]of t.cells)i[d]=p.read();let n=this._columns.filter(d=>t.cells.has(d.id)),r=Op(i,n,e,this._msgOr("table.invalid","Invalid value"));if(r)return this._markInvalid(r.columnId,r.message),t.columnId=r.columnId,this.emit("editinvalid",{row:e,id:t.id,column:this._columns.find(d=>d.id===r.columnId)??null,columnId:r.columnId,value:i[r.columnId],message:r.message}),this._focusEditor(r.columnId),this;this._clearInvalid();let o=Np(e,i),a=t.columnId;if(this.emit("editcommit",{row:e,id:t.id,column:this._columns.find(d=>d.id===a)??null,columnId:a,value:i[a],previous:e?.[a],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),a),this}cancelEdit(){return this._abortEdit({focus:!0}),this}isEditing(){return this._edit!==null}getEditing(){return this._edit?{id:this._edit.id,columnId:this._edit.columnId}:null}_visibleData(){return this._visibleEntries().map(t=>t.row)}_projectedData(){return this._hierarchy?Tp(this._data,this.options.rowId,this._hierarchy.parentId,this._expanded):this._data.map((t,e)=>({row:t,id:this._idFor(t),index:e,depth:0,hasChildren:!1,parentId:null}))}_visibleEntries(){let t=this._projectedData();return this._rendered===1/0?t:t.slice(0,this._rendered)}growBy(t){if(!this._growStep)return this;let e=Number(t)>0?Math.trunc(Number(t)):this._growStep,i=this._rendered,n=this._projectedData().length;return this._rendered=Math.min(n,this._rendered+e),this._rendered===i?this:(this._renderBody(),this.emit("grow",{rendered:this._rendered,total:n}),this)}showAll(){return this.growBy(this._projectedData().length)}getRenderedCount(){return Math.min(this._rendered,this._projectedData().length)}_syncGrowing(){if(!this._growStep)return;let t=this._projectedData().length-this.getRenderedCount();if(t<=0){this._more?.remove(),this._more=null;return}let e=this._message("table.more","Show %1 more",[t]);this._more||(this._more=l("button",{class:"zx-table__more",type:"button",onclick:()=>this.growBy()}),this.el.append(this._more)),this._more.textContent=e,this._more.setAttribute("aria-label",e)}_message(t,e,i){let n=this.msg(t,...i);return n===t?I(e,i):n}_watchWidth(){this._width?.destroy(),this._width=null;let t=this.options.responsive;!t||!(t in ve)||(this._width=ri((e,i)=>this._setStacked(i>0&&i<ve[t]),{target:this.el}))}_setStacked(t){this._stacked!==t&&(this._stacked=t,this.el.toggleAttribute("data-stacked",t),this._applyStackedRoles(t),this.emit("stackedchange",{stacked:t}))}_applyStackedRoles(t){let e=[[this._table,this._hierarchy?"treegrid":"table"],[this._thead,"rowgroup"],[this._tbody,"rowgroup"]];for(let[i,n]of e)i&&(t?i.setAttribute("role",n):i===this._table&&this._hierarchy?i.setAttribute("role","treegrid"):i.removeAttribute("role"));for(let[i,n]of[["tr","row"],["td","cell"],["th","columnheader"]])for(let r of this._table.querySelectorAll(i))t?r.setAttribute("role",n):r.removeAttribute("role")}isStacked(){return!!this._stacked}destroy(){this._teardownEdit(),this._width?.destroy(),this._width=null,!this._restored&&!this._createdRoot&&(S(this.el,this._original),this._restored=!0),super.destroy()}_visibleColumns(){return this._columns.filter(t=>!this._hiddenColumns.has(t.id))}_isSpanningRow(t){return this._rowKind===null||this._rowKinds===null?!1:Wl(t,this._rowKind,this._rowKinds)}_hasSpanningRow(){return kp(this._data,this._rowKind,this._rowKinds)}_spanColspan(){return zp(this._visibleColumns().length,{selectable:this.options.selectable,rowReorder:this.options.rowReorder})}_selectableData(){let t=this._visibleData();return this._rowKind===null?t:t.filter(e=>!this._isSpanningRow(e))}_createColumnControls(){let t=l("div",{class:"zx-table__column-list"});this._columnList=t,this._columnStatus=l("div",{class:"zx-table__column-status",role:"status",ariaLive:"polite"});let e=l("details",{class:"zx-table__column-controls"},l("summary",{class:"zx-button zx-button--sm"},g("fields",{size:13}),this._message("table.columns","Columns",[])),t);return this._renderColumnControls(),e}_renderColumnControls(t=null){if(!this._columnList)return;let e=this._visibleColumns(),i=this._columns.map((n,r)=>{let o=!this._hiddenColumns.has(n.id),a=this._columnControlIds.get(n.id);a||(a=x("zx-table-column"),this._columnControlIds.set(n.id,a));let c=this.options.columnVisibility?l("input",{id:a,class:"zx-table__column-toggle",type:"checkbox",value:n.id,checked:o,disabled:o&&e.length===1,dataset:{columnId:n.id,columnAction:"toggle"}}):null,h=c?l("label",{for:a},c,l("span",{},n.label)):l("span",{class:"zx-table__column-label"},n.label),u=this.options.columnReorder?l("span",{class:"zx-table__column-order",role:"group",ariaLabel:this._message("table.moveColumn","Move %1",[n.label])},l("button",{class:"zx-table__column-move",type:"button",disabled:r===0,ariaLabel:`Move ${n.label} earlier`,dataset:{columnId:n.id,columnAction:"up"}},g("chevron-up",{size:11})),l("button",{class:"zx-table__column-move",type:"button",disabled:r===this._columns.length-1,ariaLabel:`Move ${n.label} later`,dataset:{columnId:n.id,columnAction:"down"}},g("chevron-down",{size:11}))):null;return l("div",{class:"zx-table__column-option",dataset:{columnId:n.id}},h,u)});if(this._columnList.replaceChildren(...i,this._columnStatus),t!==null){let n=[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===t.id&&o.dataset.columnAction===t.action});n?.disabled&&(n=[...this._columnList.querySelectorAll(".zx-table__column-move[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===t.id&&!o.disabled})??[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===t.id&&!o.disabled})),queueMicrotask(()=>{n?.isConnected&&n.focus()})}}_activeColumnControl(){let t=typeof document>"u"?null:document.activeElement;if(!t||!this._columnList?.contains(t))return null;let e=t.dataset.columnId,i=t.dataset.columnAction;return e&&i?{id:e,action:i}:null}_handleColumnControlClick(t){let e=t.target?.closest?.(".zx-table__column-move");if(!e||!this._columnList?.contains(e))return;let i=e.dataset.columnId,n=e.dataset.columnAction,r=this.getColumnOrder().indexOf(String(i));n==="up"&&r>0&&this.moveColumn(String(i),this._columns[r-1].id,"before"),n==="down"&&r>=0&&r<this._columns.length-1&&this.moveColumn(String(i),this._columns[r+1].id,"after")}_handleColumnControlKeydown(t){let e=t.target?.closest?.(".zx-table__column-move");if(!e||!this._columnList?.contains(e))return;let i=String(e.dataset.columnId),n=this.getColumnOrder(),r=n.indexOf(i);r<0||(t.key==="ArrowUp"||t.key==="ArrowLeft"?(t.preventDefault(),r>0&&this.moveColumn(i,n[r-1],"before")):t.key==="ArrowDown"||t.key==="ArrowRight"?(t.preventDefault(),r<n.length-1&&this.moveColumn(i,n[r+1],"after")):t.key==="Home"?(t.preventDefault(),r>0&&this.moveColumn(i,n[0],"before")):t.key==="End"&&(t.preventDefault(),r<n.length-1&&this.moveColumn(i,n.at(-1),"after")))}_handleRowDragStart(t){let e=t.target?.closest?.(".zx-table__row-handle"),i=e?.closest("tr[data-row]"),n=i?this._rowMeta.get(i):null;if(!e||!n||this._sort&&this.options.sortMode==="local"){t.preventDefault();return}this._dragId=n.id,i.dataset.dragging="true",t.dataTransfer?.setData("text/plain","zx-table-row"),t.dataTransfer&&(t.dataTransfer.effectAllowed="move")}_handleRowDragOver(t){if(this._dragId==null)return;let e=t.target?.closest?.("tr[data-row]"),i=e?this._rowMeta.get(e):null;if(!i||Object.is(i.id,this._dragId)||!this._canMoveTogether(this._dragId,i.id))return;t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._clearDropMarkers();let n=e.getBoundingClientRect();e.dataset.drop=t.clientY>=n.top+n.height/2?"after":"before"}_handleRowDrop(t){if(this._dragId==null)return;let e=t.target?.closest?.("tr[data-row]"),i=e?this._rowMeta.get(e):null,n=e?.dataset.drop==="after"?"after":"before";i&&this._canMoveTogether(this._dragId,i.id)&&(t.preventDefault(),this.moveRow(this._dragId,i.id,n)),this._clearRowDrag()}_handleRowHandleKeydown(t){let e=t.target?.closest?.(".zx-table__row-handle"),i=e?.closest("tr[data-row]"),n=i?this._rowMeta.get(i):null;if(!e||!n)return;if(t.key===" "||t.key==="Enter"){t.preventDefault(),this._grabbedId=Object.is(this._grabbedId,n.id)?null:n.id,e.setAttribute("aria-pressed",String(this._grabbedId!=null));let c=this._rowMoveMessage??this._editMessage;c&&(c.textContent=this._grabbedId==null?"Row dropped":"Row grabbed. Use the arrow keys to move it.");return}if(t.key==="Escape"&&this._grabbedId!=null){t.preventDefault(),this._grabbedId=null,e.setAttribute("aria-pressed","false");return}if(!Object.is(this._grabbedId,n.id)||!["ArrowUp","ArrowDown"].includes(t.key))return;t.preventDefault();let r=this._siblingIds(n.id),o=r.findIndex(c=>Object.is(c,n.id)),a=r[o+(t.key==="ArrowUp"?-1:1)];a!==void 0&&this.moveRow(n.id,a,t.key==="ArrowUp"?"before":"after")}_siblingIds(t){let e=this.getRow(t);if(!e)return[];let i=this._hierarchy?ut(this._hierarchy.parentId,e):null;return this._data.filter(n=>!this._hierarchy||jn(ut(this._hierarchy.parentId,n),i)).map(n=>this._idFor(n))}_canMoveTogether(t,e){if(!this._hierarchy)return!0;let i=this.getRow(t),n=this.getRow(e);return!!(i&&n&&jn(ut(this._hierarchy.parentId,i),ut(this._hierarchy.parentId,n)))}_rowHandle(t){return this._rowElements.get(t)?.[0]?.querySelector(".zx-table__row-handle")??null}_clearDropMarkers(){for(let t of this._tbody.querySelectorAll("tr[data-drop]"))delete t.dataset.drop}_clearRowDrag(){for(let t of this._tbody.querySelectorAll("tr[data-dragging]"))delete t.dataset.dragging;this._clearDropMarkers(),this._dragId=null}_hierarchyColumn(){return this._hierarchy?this._visibleColumns().some(t=>t.id===this._hierarchy.column)?this._hierarchy.column:this._visibleColumns()[0]?.id??null:null}_renderColumns(){let t=document.createDocumentFragment();this.options.rowReorder&&t.append(l("col",{class:"zx-table__reorder-column"})),this.options.selectable==="multi"&&t.append(l("col",{class:"zx-table__selection-column"}));let e=this._visibleColumns(),i=e.map(r=>Hp(r.width)),n=i.reduce((r,o)=>r+o,0);this._table.dataset.layout=n>0?"fixed":"auto",e.forEach((r,o)=>{let a=l("col");i[o]>0?a.style.width=`${i[o]/n*100}%`:r.width&&r.width!=="auto"&&(a.style.width=String(r.width)),t.append(a)}),this._colgroup.replaceChildren(t)}_renderHeader(){let t=l("tr",{class:"zx-table__header-row"});if(this._growStep&&t.setAttribute("aria-rowindex","1"),this.options.rowReorder&&t.append(l("th",{class:"zx-table__reorder-header",scope:"col",ariaLabel:"Row order"})),this.options.selectable==="multi"){this._selectAll=l("input",{class:"zx-table__checkbox zx-table__select-all",type:"checkbox",ariaLabel:"Select all rows"});let e=l("th",{class:"zx-table__selection-header",scope:"col"},this._selectAll);t.append(e),this.listen(this._selectAll,"click",()=>{if(this._selectAll.checked)for(let i of this._selectableData())this._selected.add(this._idFor(i));else for(let i of this._selectableData())this._selected.delete(this._idFor(i));this._selectionAnchorId=null,this._syncSelection(),this._emitSelectionChange()})}else this._selectAll=null;this._headers=new Map,this._headerSpanning=this._spanning;for(let e of this._visibleColumns()){let i=l("th",{scope:"col"}),n=e.align??(Bn(e)?"end":null);if(n&&(i.dataset.align=n),e.headerTitle&&(i.title=e.headerTitle),e.sortable&&!this._spanning){let r=l("button",{class:"zx-table__sort-button",type:"button"},l("span",{class:"zx-table__header-label"},e.label));this.listen(r,"click",()=>{let o=this._sort?.id===e.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(e.id,o)}),i.append(r)}else i.append(l("span",{class:"zx-table__header-label"},e.label));this._headers.set(e.id,i),t.append(i)}this._thead.replaceChildren(t),this._syncSortHeader()}_renderBody(){this._abortEdit({focus:!1}),this._spanning=this._hasSpanningRow(),this._headers&&this._spanning!==this._headerSpanning&&this._renderHeader();let t=document.createDocumentFragment();this._rowMeta=new WeakMap,this._rowElements=new Map,this._rovingCell=null,this._rovingMatched=!1;let e=this._projectedData();this._hierarchyMeta=new Map(e.map(i=>[i.id,i])),this._data.length===0?t.append(l("tr",{class:"zx-table__empty-row"},l("td",{class:"zx-table__empty",colspan:this._spanColspan()},this._emptyContent()))):this._visibleEntries().forEach((i,n)=>{t.append(this._createRow(i.row,i.index,{...i,visibleIndex:n}))}),this._tbody.replaceChildren(t),this._table.setAttribute("aria-colcount",String(this._visibleColumns().length+(this.options.selectable==="multi"?1:0)+(this.options.rowReorder?1:0))),this._growStep&&this._table.setAttribute("aria-rowcount",String(e.length+1)),this._syncSelectAll(),this._syncGrowing(),this._stacked&&this._applyStackedRoles(!0)}_emptyContent(){let t=this.options.emptyText;return t==null?this.msg("table.empty"):typeof t=="function"?t():t}_createRow(t,e,i){let n=this._idFor(t),r=l("tr",{dataset:{row:""}});this._growStep&&r.setAttribute("aria-rowindex",String(i.visibleIndex+2));let o=typeof this.options.rowClass=="function"?this.options.rowClass(t):"";o&&r.classList.add(...String(o).split(/\s+/).filter(Boolean));let a=this._rowKind===null?null:Ul(t,this._rowKind),c=a===null?null:Yl(this._rowKinds,a),h=!!c?.span;a!==null&&(r.dataset.rowKind=a),c?.class&&r.classList.add(...String(c.class).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&!h&&r.setAttribute("aria-selected",String(this._selected.has(n))),this._hierarchy&&(r.setAttribute("aria-level",String(i.depth+1)),i.hasChildren&&r.setAttribute("aria-expanded",String(this._expanded.has(n)))),this._rowMeta.set(r,{row:t,id:n,index:e,visibleIndex:i.visibleIndex});let u=this._rowElements.get(n)??[];if(u.push(r),this._rowElements.set(n,u),h){r.dataset.span="true";let d=l("th",{class:"zx-table__section-cell",scope:"colgroup",colspan:this._spanColspan()}),p=Cp(t,c,this._visibleColumns(),e);return p&&typeof p=="object"&&typeof p.nodeType=="number"?d.append(p):p!=null&&d.append(document.createTextNode(String(p))),r.append(d),r}if(this.options.rowReorder){let d=l("button",{class:"zx-table__row-handle",type:"button",draggable:!0,dataset:{rowHandle:""},ariaLabel:`Move row ${e+1}`,ariaPressed:String(Object.is(this._grabbedId,n)),disabled:!!(this._sort&&this.options.sortMode==="local"),title:this._sort&&this.options.sortMode==="local"?"Clear sorting to reorder rows":null},g("drag",{size:14}));r.append(l("td",{class:"zx-table__reorder-cell"},d))}if(this.options.selectable==="multi"){let d=l("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",checked:this._selected.has(n),ariaLabel:`Select row ${e+1}`});r.append(l("td",{class:"zx-table__selection-cell"},d))}return this._visibleColumns().forEach(d=>{let p=l("td"),f=d.align??(Bn(d)?"end":null);f&&(p.dataset.align=f),p.dataset.label=d.label,d.popin===!1&&(p.dataset.popin="false"),this._editMode!==!1&&(p.dataset.column=d.id,Se(d,t)!==!1&&(p.dataset.editable="true",p.tabIndex=-1,this._offerRovingCell(p,n,d.id))),this._renderCellContent(p,d,t,e,i),r.append(p)}),r}_renderCellContent(t,e,i,n,r=this._hierarchyMeta?.get(this._idFor(i))){let o=Hn(e,i,n),a=l("span",{class:"zx-table__cell-content"});if(o&&typeof o=="object"&&typeof o.nodeType=="number"?a.append(o):o!=null&&a.append(document.createTextNode(String(o))),!this._hierarchy||e.id!==this._hierarchyColumn()||!r){t.replaceChildren(...a.childNodes);return}let c=l("span",{class:"zx-table__tree-cell"});if(c.style.setProperty("--zx-table-depth",String(r.depth)),r.hasChildren){let h=this._expanded.has(r.id);c.append(l("button",{class:"zx-table__tree-toggle",type:"button",ariaExpanded:String(h),ariaLabel:`${h?"Collapse":"Expand"} row ${n+1}`},g(h?"chevron-down":"chevron-right",{size:14})))}else c.append(l("span",{class:"zx-table__tree-spacer",ariaHidden:"true"}));c.append(a),t.replaceChildren(c)}_handleBodyClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(this._edit&&os(e))return;let i=e?.closest("tr[data-row]");if(!i||!this._tbody.contains(i))return;let n=this._rowMeta.get(i);if(!n||e.closest(".zx-table__row-handle")||this._edit&&(this.commitEdit(),this._edit))return;if(e.closest(".zx-table__tree-toggle")){this.toggleRow(n.id);return}let o=e.closest(".zx-table__row-checkbox");if(o&&this.options.selectable==="multi"){this._toggleMultiSelection(n,o.checked,t.shiftKey);return}if(!jl(e)){if(this._editMode!==!1&&this._editTrigger==="single"){let a=e?.closest('td[data-editable="true"]');if(a&&this._tbody.contains(a)){this.startEdit(n.id,String(a.dataset.column));return}}this.emit("rowclick",{...n,event:t}),this.options.selectable==="single"&&!this._selected.has(n.id)&&!this._isSpanningRow(n.row)&&(this._selected=new Set([n.id]),this._selectionAnchorId=n.id,this._syncSelection(),this._emitSelectionChange())}}_handleBodyDoubleClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(e?.closest(".zx-table__row-checkbox")||this._edit&&os(e))return;let i=e?.closest("tr[data-row]");if(!i||!this._tbody.contains(i))return;let n=this._rowMeta.get(i);if(n&&!jl(e)){if(this._editMode!==!1&&this._editTrigger==="double"){let r=e?.closest('td[data-editable="true"]');if(r&&this._tbody.contains(r)){this.startEdit(n.id,String(r.dataset.column));return}}this.emit("rowdblclick",{...n,event:t})}}_createEditor(t,e,i,n){let r=Se(e,i);if(r===!1)return null;let o=i?.[e.id],a=e.editorProps&&typeof e.editorProps=="object"?e.editorProps:{},c=l("span",{class:"zx-table__cell-shadow",ariaHidden:"true"});c.append(...t.childNodes);let h=l("div",{class:"zx-table__editor",dataset:{editor:r}});t.replaceChildren(c,h),t.dataset.editing="true";let u={column:e,type:r,td:t,host:h,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(r==="custom"){u.custom=o,u.read=()=>re(e,u.custom,i);let f={value:o,row:i,column:e,commit:b=>{u.custom=b,this.commitEdit()},cancel:()=>this.cancelEdit()},_=e.editor(i,f);return _&&typeof _.toElement=="function"?(typeof _.destroy=="function"&&(u.component=_),h.append(_.toElement())):_&&h.append(_),u.control=h.querySelector(Ap)??h,u}if(r==="number"){let f=oe(e.locale,i),_=Ql(e,i),b=e.type==="currency"?oe(e.currency,i):e.type==="unit"?oe(e.unit,i):null,w={...f!=null&&!Object.prototype.hasOwnProperty.call(a,"locale")?{locale:f}:{},..._!=null&&!Object.prototype.hasOwnProperty.call(a,"precision")?{precision:_}:{},...b!=null&&!Object.prototype.hasOwnProperty.call(a,"unit")?{unit:String(b)}:{}},y=new Et(null,{...w,...a,value:o??null});return h.append(y.el),u.component=y,u.control=y.getInput(),u.read=()=>(y.set(y.getInput().value,{silent:!0}),re(e,y.get(),i)),u}if(r==="select"){let f=Ep(e.options,i),_=f.find(w=>Object.is(w.value,o))??f.find(w=>String(w.value)===String(o??"")),b=new $(null,{...a,items:f,valueKey:"value",labelKey:"label",value:_?_.value:null});return h.append(b.el),u.component=b,u.control=b.refs.input,u.read=()=>re(e,b.value,i),u}if(r==="date"){let f=new et(null,{...a,value:o??null});h.append(f.el),u.component=f;let _=f.refs.input;return u.control=_,u.read=()=>{let b=String(_.value??"").trim(),w=f.get();return b===""?re(e,null,i):(f.set(b,{silent:!0}),f.get()===null&&f.set(w,{silent:!0}),re(e,f.get(),i))},u}if(r==="checkbox"){let f=new nt(null,{...a,checked:!!o});return h.append(f.el),u.component=f,u.control=f.el,u.read=()=>re(e,f.get(),i),u}let d=r==="textarea",p=l(d?"textarea":"input",{...a,class:d?"zx-table__editor-input zx-table__editor-textarea":"zx-table__editor-input",...d?{}:{type:"text"},ariaLabel:a.ariaLabel??`${e.label} row ${n+1}`,value:Dp(e,o,i)});return h.append(p),u.control=p,u.read=()=>re(e,p.value,i),u}_focusEditor(t){let e=this._edit?.cells.get(t),i=e?.control;!i||typeof i.focus!="function"||(i.focus(),e.type==="text"&&typeof i.select=="function"&&i.select())}_focusCell(t,e){let i=this._rowElements.get(t)?.[0];(i?ql(i,e):null)?.focus()}_teardownEdit(){let t=this._edit;if(!t)return;this._edit=null;let e=this._data.findIndex(n=>Object.is(this._idFor(n),t.id)),i=e<0?t.row:this._data[e];for(let n of t.cells.values())n.destroy(),delete n.td.dataset.editing,delete n.td.dataset.invalid,this._renderCellContent(n.td,n.column,i,e<0?0:e);t.cells.clear(),delete t.tr.dataset.editing,this._clearInvalid()}_abortEdit({focus:t=!0}={}){let e=this._edit;if(!e)return;let i=t&&this._editHasFocus(),n=this.getRow(e.id)??e.row,r=this._columns.find(o=>o.id===e.columnId)??null;this._teardownEdit(),i&&this._focusCell(e.id,e.columnId),this.emit("editcancel",{row:n,id:e.id,column:r,columnId:e.columnId})}_editHasFocus(){let t=document.activeElement;return!!(t&&this.el?.contains(t))}_markInvalid(t,e){this._clearInvalid();let i=this._edit?.cells.get(t);i&&(i.td.dataset.invalid="true",i.control?.setAttribute("aria-invalid","true"),this._editMessage&&(i.control?.setAttribute("aria-describedby",this._editMessage.id),this._editMessage.textContent=e))}_clearInvalid(){if(this._edit)for(let t of this._edit.cells.values())delete t.td.dataset.invalid,t.control?.removeAttribute("aria-invalid"),t.control?.removeAttribute("aria-describedby");this._editMessage&&(this._editMessage.textContent="")}_handleEditKeydown(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(!e)return;if(this._edit&&os(e)){if(Pp(e))return;if(t.key==="Escape"){if(t.defaultPrevented)return;t.preventDefault(),this.cancelEdit();return}if(t.key==="Enter"){if(e.localName==="textarea"&&t.shiftKey)return;t.preventDefault(),this.commitEdit();return}t.key==="Tab"&&this._moveEdit(t);return}if(t.key!=="Enter"&&t.key!=="F2")return;let i=e.closest('td[data-editable="true"]');if(!i||!this._tbody.contains(i))return;let n=this._rowMeta.get(i.parentElement);n&&(t.preventDefault(),this.startEdit(n.id,String(i.dataset.column)))}_moveEdit(t){let e=this._edit;if(!e)return;let i=t.shiftKey?-1:1,n=this._data.findIndex(o=>Object.is(this._idFor(o),e.id)),r=this._nextEditableCell(n,e.columnId,i);if(r&&Object.is(r.id,e.id)&&e.cells.has(r.columnId)){t.preventDefault(),e.columnId=r.columnId,this._focusEditor(r.columnId);return}if(!r){this.commitEdit(),this._edit&&t.preventDefault();return}t.preventDefault(),this.commitEdit(),this._edit||this.startEdit(r.id,r.columnId)}_nextEditableCell(t,e,i){let n=this._visibleColumns(),r=n.length;if(t<0||r===0)return null;let o=this._visibleData(),a=this._idFor(this._data[t]),c=o.findIndex(d=>Object.is(this._idFor(d),a));if(c<0)return null;let h=n.findIndex(d=>d.id===e),u=o.length*r+r;for(let d=0;d<u;d+=1){if(h+=i,h>=r?(c+=1,h=0):h<0&&(c-=1,h=r-1),c<0||c>=o.length)return null;let p=o[c],f=n[h];if(!this._isSpanningRow(p)&&Se(f,p)!==!1)return{id:this._idFor(p),columnId:f.id,index:this._data.indexOf(p)}}return null}_handleEditFocusIn(t){let i=(t.target?.nodeType===1?t.target:null)?.closest('td[data-editable="true"]');if(!i||!this._tbody.contains(i))return;let n=this._rowMeta.get(i.parentElement);n&&this._setRovingCell(i,n.id,String(i.dataset.column))}_handleDocumentPointerDown(t){if(!this._edit)return;let e=t.target?.nodeType===1?t.target:t.target?.parentElement;e&&os(e)||e&&this._tbody.contains(e)||this.commitEdit()}_offerRovingCell(t,e,i){if(this._rovingMatched)return;let n=this._rovingKey!==null&&Object.is(this._rovingKey.id,e)&&this._rovingKey.columnId===i;!n&&this._rovingCell||(n&&this._rovingCell&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=n)}_setRovingCell(t,e,i){this._rovingCell&&this._rovingCell!==t&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=!0,this._rovingKey={id:e,columnId:i}}_msgOr(t,e){let i=this.msg(t);return i===t?e:i}_toggleMultiSelection(t,e,i){let n=this._visibleData(),r=n.findIndex(o=>Object.is(this._idFor(o),this._selectionAnchorId));if(i&&r>=0){let o=t.visibleIndex??n.findIndex(h=>Object.is(this._idFor(h),t.id)),a=Math.min(r,o),c=Math.max(r,o);for(let h=a;h<=c;h+=1){if(this._isSpanningRow(n[h]))continue;let u=this._idFor(n[h]);e?this._selected.add(u):this._selected.delete(u)}}else e?this._selected.add(t.id):this._selected.delete(t.id);this._selectionAnchorId=t.id,this._syncSelection(),this._emitSelectionChange()}_syncSelection(){for(let[t,e]of this._rowElements){let i=this._selected.has(t);for(let n of e){if(n.hasAttribute("data-span"))continue;n.setAttribute("aria-selected",String(i));let r=n.querySelector(".zx-table__row-checkbox");r&&(r.checked=i)}}this._syncSelectAll()}_syncSelectAll(){if(!this._selectAll)return;let t=this._selectableData(),e=t.reduce((i,n)=>i+Number(this._selected.has(this._idFor(n))),0);this._selectAll.disabled=t.length===0,this._selectAll.checked=t.length>0&&e===t.length,this._selectAll.indeterminate=e>0&&e<t.length}_syncSortHeader(){if(this._headers)for(let[t,e]of this._headers)!this._spanning&&this._sort?.id===t?e.setAttribute("aria-sort",this._sort.dir==="asc"?"ascending":"descending"):e.removeAttribute("aria-sort")}_sortData(){if(this._spanning=this._hasSpanningRow(),!this._sort||this._spanning)return;let t=this._columns.find(i=>i.id===this._sort.id);if(!t)return;let e=typeof t.sortValue=="function"?t.sortValue:i=>i?.[t.id];this._data=this._hierarchy?Ip(this._data,this.options.rowId,this._hierarchy.parentId,e,this._sort.dir):di(this._data,e,this._sort.dir)}_setRowExpanded(t,e,i){return this._hierarchy?rs(this._data,this.options.rowId,this._hierarchy.parentId).some(r=>Object.is(r,t))?this._expanded.has(t)===e?this:(e?this._expanded.add(t):this._expanded.delete(t),this._renderBody(),i.silent||this._emitRowToggle(t,e),this):this:this}_emitRowToggle(t,e){let i=this.getRow(t);i&&this.emit("rowtoggle",{row:i,id:t,expanded:e})}_reconcileExpanded(){if(!this._hierarchy){this._expanded.clear();return}let t=rs(this._data,this.options.rowId,this._hierarchy.parentId),e=new Set(t);for(let i of this._expanded)e.has(i)||this._expanded.delete(i)}_selectableIds(){let t=new Set;for(let e of this._data)this._isSpanningRow(e)||t.add(this._idFor(e));return t}_pruneSelection(){let t=this._selectableIds(),e=this._selected.size;for(let i of this._selected)t.has(i)||this._selected.delete(i);return t.has(this._selectionAnchorId)||(this._selectionAnchorId=null),e!==this._selected.size}_idFor(t){return typeof this.options.rowId=="function"?this.options.rowId(t):t?.[this.options.rowId]}_emitSelectionChange(){let t=this.getSelection();this.emit("selectionchange",{rows:t,ids:t.map(e=>this._idFor(e))})}_emitDataChange(){this.emit("datachange",{rows:this.getData()})}};function Ul(s,t){if(t==null||t==="")return null;let e=typeof t=="function"?t(s):s?.[t];return e==null?null:String(e)}function Yl(s,t){if(t===null||s==null||typeof s!="object"||!Object.prototype.hasOwnProperty.call(s,t))return null;let e=s[t];return e&&typeof e=="object"?e:null}function Wl(s,t,e){return!!Yl(e,Ul(s,t))?.span}function kp(s,t,e){return!Array.isArray(s)||t==null||e==null?!1:s.some(i=>Wl(i,t,e))}function zp(s,t={}){let e=Number.isFinite(Number(s))?Math.max(0,Math.trunc(Number(s))):0,i=(t.selectable==="multi"?1:0)+(t.rowReorder?1:0);return Math.max(1,e+i)}function Cp(s,t,e,i=0){if(typeof t?.render=="function")return t.render(s,i);let n=e?.[0];return n?s?.[n.id]:null}function Hn(s,t,e=0){if(typeof s?.render=="function")return s.render(t,e);let i=t?.[s?.id],n=s?.type??"text";if(n==="text")return i;let r=oe(s.locale,t),o=Ql(s,t),a={...r!=null?{locale:String(r)}:{},...o!=null?{decimals:o}:{}};if(n==="number")return Nt(i,a);if(n==="currency"){let c=oe(s.currency,t);return oi(i,c==null?null:String(c),a)}if(n==="percent")return ai(i,a);if(n==="unit"){let c=Nt(i,a),h=oe(s.unit,t);return c&&h!=null&&String(h)!==""?`${c}\xA0${h}`:c}return i}function Tp(s,t,e,i=[]){let n=ls(s,t,e),r=i instanceof Set?i:new Set(i),o=[],a=n.roots.slice().reverse().map(c=>({node:c,depth:0}));for(;a.length;){let{node:c,depth:h}=a.pop();if(o.push({row:c.row,id:c.id,index:c.index,depth:h,hasChildren:c.children.length>0,parentId:c.parent?.id??null}),!!r.has(c.id))for(let u=c.children.length-1;u>=0;u-=1)a.push({node:c.children[u],depth:h+1})}return o}function Ip(s,t,e,i,n){let r=ls(s,t,e),o=h=>di(h,u=>i(u.row),n),a=[],c=o(r.roots).reverse();for(;c.length;){let h=c.pop();a.push(h.row);let u=o(h.children);for(let d=u.length-1;d>=0;d-=1)c.push(u[d])}return a}function Gl(s,t,e,i,n="before",r=null){if(!Array.isArray(s)||Object.is(e,i))return null;let o=s.findIndex(d=>Object.is(ut(t,d),e)),a=s.findIndex(d=>Object.is(ut(t,d),i));if(o<0||a<0||r&&!jn(ut(r,s[o]),ut(r,s[a])))return null;if(r){let d=ls(s,t,r),p=d.nodes[o],f=d.nodes[a];if(!p||!f||p.parent!==f.parent)return null;let _=E=>{let M=[],it=[E];for(;it.length;){let N=it.pop();M.push(N);for(let J=N.children.length-1;J>=0;J-=1)it.push(N.children[J])}return M},b=new Set(_(p).map(E=>E.index)),w=new Set(_(f).map(E=>E.index)),y=s.filter((E,M)=>b.has(M)),v=s.filter((E,M)=>!b.has(M)),k=s.map((E,M)=>M).filter(E=>!b.has(E)),z=k.findIndex(E=>E===a);if(n==="after"){let E=k.map((M,it)=>w.has(M)?it:-1).filter(M=>M>=0);z=Math.max(...E)+1}return z<0?null:(v.splice(z,0,...y),v)}let c=[...s],[h]=c.splice(o,1),u=c.findIndex(d=>Object.is(ut(t,d),i));return c.splice(u+(n==="after"?1:0),0,h),c}function Se(s,t){if(!s||typeof s!="object")return!1;if(typeof s.editor=="function")return typeof s.editable=="function"&&s.editable(t)===!1?!1:"custom";let e=typeof s.editable=="function"?s.editable(t):s.editable;return e===!0?Bn(s)?"number":"text":typeof e=="string"&&Sp.has(e)?e:!1}function Ep(s,t){let e=typeof s=="function"?s(t):s;return Array.isArray(e)?e.map(i=>i!==null&&typeof i=="object"?{value:i.value,label:String(i.label??i.value??"")}:{value:i,label:String(i??"")}):e!==null&&typeof e=="object"?Object.entries(e).map(([i,n])=>({value:i,label:String(n??"")})):[]}function Dp(s,t,e){if(typeof s?.format=="function"){let i=s.format(t,e);return i==null?"":String(i)}return t==null?"":String(t)}function re(s,t,e){return typeof s?.parse=="function"?s.parse(t,e):t}function Mp(s,t){return Object.is(s,t)?!0:s instanceof Date&&t instanceof Date?s.getTime()===t.getTime():!1}function Np(s,t){let e={};for(let[i,n]of Object.entries(t??{}))Mp(s?.[i],n)||(e[i]=n);return e}function Op(s,t,e,i="Invalid value"){for(let n of t??[]){if(typeof n?.validate!="function"||!Object.prototype.hasOwnProperty.call(s??{},n.id))continue;let r=n.validate(s[n.id],e);if(typeof r=="string")return{columnId:n.id,message:r};if(r===!1)return{columnId:n.id,message:i}}return null}function oe(s,t){return typeof s=="function"?s(t):s}function Ql(s,t){let e=oe(s?.decimals,t);if(e==null)return null;let i=Number(e);return Number.isFinite(i)?Math.max(0,Math.trunc(i)):null}function Bn(s){return["number","currency","percent","unit"].includes(s?.type)}function ls(s,t,e){let i=(Array.isArray(s)?s:[]).map((a,c)=>({row:a,id:ut(t,a),index:c,parent:null,children:[]})),n=new Map;for(let a of i)n.has(a.id)||n.set(a.id,a);let r=new Map;for(let a of i){let c=ut(e,a.row),h=c==null?null:n.get(c)??null;r.set(a,h===a?null:h)}for(let a of i){let c=new Set([a]),h=r.get(a)??null;for(;h;){if(c.has(h)){r.set(h,null);break}c.add(h),h=r.get(h)??null}}let o=[];for(let a of i)a.parent=r.get(a)??null,a.parent?a.parent.children.push(a):o.push(a);return{roots:o,nodes:i}}function rs(s,t,e){return ls(s,t,e).nodes.filter(i=>i.children.length>0).map(i=>i.id)}function ut(s,t){return typeof s=="function"?s(t):t?.[s]}function jn(s,t){return s==null&&t==null||Object.is(s,t)}function Pn(s,t){if(!s||typeof s!="object")return null;let e=s.parentId;if(typeof e!="string"&&typeof e!="function")return null;let i=typeof s.column=="string"?s.column:null,n=t.some(r=>r.id===i)?i:t[0]?.id;return n?{...s,parentId:e,column:n}:null}function Fp(s){return typeof s=="function"||typeof s=="string"&&s!==""?s:null}function Lp(s){return!s||typeof s!="object"||Array.isArray(s)?null:s}function Rp(s){return new Set(Array.isArray(s)?s:[])}function Vp(s){return s==="cell"||s==="row"?s:s===!0?"cell":!1}function os(s){return!!s?.closest?.(".zx-table__editor")}function jl(s){let t=s?.closest?.("td[data-column]"),e=s?.closest?.(["a[href]","button","input","select","textarea","summary",'[contenteditable="true"]','[role="button"]','[role="link"]','[tabindex]:not([tabindex="-1"])',"[data-zx-table-no-edit]"].join(","));return!!(t&&e&&e!==t&&t.contains(e))}function Pp(s){return s.closest("[popover]")?!0:s.getAttribute?.("aria-expanded")==="true"}function Hl(s){if(!Array.isArray(s))throw new TypeError("Table columns must be an array");let t=new Set;return s.map((e,i)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError(`Table column at index ${i} must be an object`);let n=String(e.id??"").trim();if(!n)throw new TypeError(`Table column at index ${i} requires an id`);if(t.has(n))throw new TypeError(`Duplicate table column: ${n}`);return t.add(n),{...e,id:n,label:String(e.label??n)}})}function Bp(s,t){let e=s.map(a=>a.id),i=new Set(e),n=Array.isArray(t)?t.map(String):[],r=new Set,o=[];for(let a of n)i.has(a)&&!r.has(a)&&(r.add(a),o.push(a));for(let a of e)r.has(a)||o.push(a);return o}function jp(s,t,e,i="before"){let n=[...s],r=n.indexOf(t),o=n.indexOf(e);if(r<0||o<0||r===o)return n;n.splice(r,1);let a=n.indexOf(e)+(i==="after"?1:0);return n.splice(a,0,t),n}function ql(s,t){for(let e of s.cells)if(e.dataset.column===t)return e;return null}function $l(s,t){return!s||typeof s!="object"||!t.some(e=>e.id===s.id)?null:{id:s.id,dir:s.dir==="desc"?"desc":"asc"}}function Hp(s){if(typeof s!="string")return 0;let t=/^(\d*\.?\d+)fr$/.exec(s.trim());return t?Math.max(0,Number(t[1])):0}function Kl(s){if(!Array.isArray(s))throw new TypeError("Table data must be an array")}function qp(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}function as(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function $p(s){let t=Math.trunc(Number(s));return Number.isFinite(t)&&t>0?t:null}var dt=Symbol("invalid attribute");function Ae(s,t="string",e=console.warn){if(Xl(t),t==="boolean")return s!==null;if(s!==null){if(t==="string")return s;if(t==="number"){let i=Number(s);return Number.isFinite(i)?i:(e(`Ignoring invalid number attribute: ${JSON.stringify(s)}`),dt)}try{return JSON.parse(s)}catch{return e(`Ignoring invalid JSON attribute: ${JSON.stringify(s)}`),dt}}}function qn(s,t="string",e=console.warn){if(Xl(t),t==="boolean")return s?"":null;if(s==null)return null;if(t==="number"){let i=Number(s);return Number.isFinite(i)?String(i):(e(`Ignoring invalid number property: ${String(s)}`),dt)}if(t==="json"){try{let i=JSON.stringify(s);if(i!==void 0)return i}catch{}return e("Ignoring property that cannot be serialized as JSON"),dt}return String(s)}function Xl(s){if(!["string","number","boolean","json"].includes(String(s)))throw new TypeError(`Unknown reflected attribute type: ${String(s)}`)}var Kp=Object.freeze(["change","input","submit","clear","open","close","cancel","invalid","query","loaded","rowclick","rowdblclick","sort","selectionchange","datachange"]),Up=ft({checked:P({always:!0,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),value:O({default:!0}),label:O({default:null,rebuild:!0}),disabled:P({always:!0,set:fi})}),Yp=ft({checked:P({always:!0,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),value:O({option:null,default:"on"}),label:O({default:"",set:(s,t)=>s.setLabel(t)}),icon:P({rebuild:!0}),disabled:P({always:!0,set:fi})}),Wp=ft({items:Ft({default:[],set:(s,t)=>s.setItems(t)}),value:O({default:null,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.value}),"value-key":O({property:"valueKey",default:"ID",rebuild:!0}),"label-key":O({property:"labelKey",default:"name",rebuild:!0}),placeholder:O({default:"",set:(s,t)=>{s.refs.input.placeholder=t}}),clearable:P({default:!1,rebuild:!0}),filter:O({default:!1,normalize:l_,rebuild:!0}),"search-keys":Ft({property:"searchKeys",default:null,rebuild:!0}),"min-query":ke({property:"minQuery",default:0,rebuild:!0}),debounce:ke({default:200,rebuild:!0}),"list-height":ke({property:"listHeight",default:280,rebuild:!0}),disabled:P({always:!0,set:fi}),required:P({option:null,always:!0}),name:O({option:null,default:""})}),Gp=ft({items:Ft({default:[],set:(s,t)=>s.setItems(t)}),value:Ft({option:null,default:[],set:(s,t)=>s.setValues(t),get:s=>s.getValues()}),"value-key":O({property:"valueKey",default:"ID",rebuild:!0}),"label-key":O({property:"labelKey",default:"name",rebuild:!0}),"checked-key":O({property:"checkedKey",default:"on",rebuild:!0}),search:P({rebuild:!0}),height:ke({default:280,rebuild:!0}),"default-checked":P({property:"defaultChecked",default:!1,rebuild:!0}),disabled:P({option:null,always:!0,set:a_}),name:O({option:null,default:""})}),Qp=ft({format:O({default:"%d.%m.%Y",rebuild:!0}),time:P({always:!0,rebuild:!0}),value:O({option:null,default:null,normalize:d_,set:(s,t)=>s.set(t,{silent:!0}),get:(s,t)=>Kn(s.get(),!!t.time),serialize:f_}),placeholder:O({default:null,rebuild:!0}),clearable:P({rebuild:!0}),disabled:P({always:!0,set:fi}),required:P({option:null,always:!0}),name:O({option:null,default:""})}),Xp=ft({value:ke({default:0,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),unit:O({default:"minutes",rebuild:!0}),seconds:P({always:!0,rebuild:!0}),signed:P({always:!0,rebuild:!0}),disabled:P({always:!0,set:fi}),name:O({option:null,default:""})}),Jp=ft({value:O({default:"",set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),placeholder:O({default:"",set:(s,t)=>{s.refs.input.placeholder=t}}),clearable:P({rebuild:!0}),debounce:ke({default:250,rebuild:!0})}),Zp=ft({title:O({default:"",set:(s,t)=>s.setTitle(t)}),open:P({default:!1,always:!0,set:(s,t)=>t?s.open():s.close(),get:s=>s.isOpen()})}),t_=ft({tabs:Ft({default:[],normalize:h_,rebuild:!0}),active:O({default:null,set:(s,t)=>{t!==null&&s.openTab(t)},get:s=>s.getActive()}),variant:O({default:"divided",rebuild:!0}),"keep-alive":P({property:"keepAlive",rebuild:!0})}),e_=ft({columns:Ft({default:[],rebuild:!0}),data:Ft({default:[],set:(s,t)=>s.setData(t),get:s=>s.getData()}),"row-id":O({property:"rowId",default:"ID",rebuild:!0}),sort:Ft({default:null,rebuild:!0}),"sort-mode":O({property:"sortMode",default:"local",rebuild:!0}),selectable:O({default:!1,normalize:c_,rebuild:!0}),"sticky-header":P({property:"stickyHeader",rebuild:!0}),height:O({default:null,normalize:tc,rebuild:!0}),"empty-text":O({property:"emptyText",default:null,rebuild:!0}),zebra:P({rebuild:!0})}),i_=ft({title:O({default:"",set:(s,t)=>s.setTitle(t)}),size:O({default:"md",normalize:tc,rebuild:!0}),buttons:Ft({default:[],set:(s,t)=>s.setButtons(t)}),closable:P({rebuild:!0}),open:P({option:null,default:!1,always:!0,set:(s,t)=>t?s.open():s.close(),get:s=>s.isOpen()})}),s_=Object.freeze([["toggle",nt,{formAssociated:!0,attrs:Up}],["check-button",Ut,{formAssociated:!0,attrs:Yp}],["select",$,{formAssociated:!0,attrs:Wp}],["checklist",ot,{formAssociated:!0,attrs:Gp}],["datebox",et,{formAssociated:!0,attrs:Qp}],["timebox",Mt,{formAssociated:!0,attrs:Xp}],["search",ne,{formAssociated:!1,attrs:Jp}],["groupbox",se,{formAssociated:!1,attrs:Zp}],["tabbox",ui,{formAssociated:!1,attrs:t_}],["table",Ot,{formAssociated:!1,attrs:e_}],["dialog",Yt,{formAssociated:!1,attrs:i_}]]);function n_(s,{formAssociated:t=!1,attrs:e={}}={}){let i=Zl(e),n=Object.freeze(Object.keys(i)),r=s===se||s===Yt;class o extends HTMLElement{static formAssociated=!!t;static get observedAttributes(){return n}constructor(){super(),this._component=null,this._bridgeAbort=null,this._reflecting=new Set,this._propertyValues=new Map,this._defaults=null,this._contentNodes=null,this._disabledByForm=!1,this._applying=!1,this._internals=t&&typeof this.attachInternals=="function"?this.attachInternals():null}connectedCallback(){this._component||(this._upgradeProperties(i),r&&this._contentNodes===null&&(this._contentNodes=Array.from(this.childNodes)),t&&this._defaults===null&&this._captureDefaults(i),this._createComponent(s,i,r))}disconnectedCallback(){this._destroyComponent()}attributeChangedCallback(c,h,u){if(this._reflecting.has(c))return;let d=i[c];if(!d)return;let p=Ae(u,d.type);if(p===dt)return;this._propertyValues.delete(d.property);let f=p===void 0?cs(d.default):p;this._applyValue(c,d,f)}formDisabledCallback(c){this._disabledByForm=!!c,this._syncEffectiveDisabled(i),this._syncFormState(s)}formResetCallback(){if(!this._defaults)return;let c=$n(s);!c||!this._defaults.has(c)||this._applyControlValue(i,c,cs(this._defaults.get(c)))}formStateRestoreCallback(c,h){if(typeof c!="string")return;let u=__(s,c);if(u===dt)return;let d=$n(s);d&&this._applyControlValue(i,d,u)}get component(){return this._component}get form(){return this._internals?.form??null}get labels(){return this._internals?.labels??null}get validity(){return this._internals?.validity??null}get validationMessage(){return this._internals?.validationMessage??""}get willValidate(){return this._internals?.willValidate??!1}checkValidity(){return this._internals?.checkValidity()??!0}reportValidity(){return this._internals?.reportValidity()??!0}_upgradeProperties(c){for(let h of Object.values(c)){let u=h.property;if(!Object.prototype.hasOwnProperty.call(this,u))continue;let d=this[u];delete this[u],this[u]=d}}_captureDefaults(c){this._defaults=new Map;let h=$n(s);if(h){let u=Object.values(c).find(d=>d.property===h);u&&this._defaults.set(h,cs(this._readProperty(u)))}}_createComponent(c,h,u){let d={};for(let[_,b]of Object.entries(h)){if(!(this._propertyValues.has(b.property)||this.hasAttribute(_)||b.always)||b.option===null)continue;let y=this._currentValue(_,b);y===dt||y===void 0||(d[b.option]=Jl(b,y,this))}let p=null;u&&(p=document.createDocumentFragment(),p.append(...this._contentNodes),d.content=p);let f=new c(null,d);this._component=f,s===se&&p&&f.setContent(p),this.append(f.el),this._bridgeEvents(f,s);for(let[_,b]of Object.entries(h)){if(b.option!==null||!b.set||!(this._propertyValues.has(b.property)||this.hasAttribute(_)||b.always))continue;let y=this._currentValue(_,b);y!==dt&&y!==void 0&&this._applyValue(_,b,y,!0)}this._syncEffectiveDisabled(h),this._syncFormState(s)}_bridgeEvents(c,h){this._bridgeAbort?.abort(),this._bridgeAbort=new AbortController;for(let u of Kp)c.on(u,d=>{if(this._applying)return;this._syncFormState(h);let p=new CustomEvent(`zx-${u}`,{detail:d.detail??{},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(p),p.defaultPrevented&&d.preventDefault()}),c.el.addEventListener(`zx-${u}`,d=>d.stopPropagation(),{signal:this._bridgeAbort.signal})}_destroyComponent(){this._bridgeAbort?.abort(),this._bridgeAbort=null,this._component&&(this._component.destroy(),this._component=null)}_rebuildComponent(c,h=r){this._component&&(h&&this._contentNodes&&document.createDocumentFragment().append(...this._contentNodes),this._destroyComponent(),this._createComponent(s,c,h))}_applyValue(c,h,u,d=!1){if(this._component){if(h.rebuild&&!d){this._rebuildComponent(i);return}if(!h.set){this._syncFormState(s);return}this._applying=!0;try{h.set(this._component,Jl(h,u,this),this)}finally{this._applying=!1}c!=="disabled"&&this._syncEffectiveDisabled(i),this._syncFormState(s)}}_syncEffectiveDisabled(c){if(!(!this._component||!c.disabled?.set)){this._applying=!0;try{c.disabled.set(this._component,this.hasAttribute("disabled")||this._disabledByForm,this)}finally{this._applying=!1}}}_syncFormState(c){if(!this._internals||!this._component)return;let{formValue:h,state:u,empty:d}=p_(c,this._component,this);if(this._internals.setFormValue(h,u),(c===$||c===et)&&this.hasAttribute("required")&&d){let p=c===et?"Please enter a date.":"Please select a value.";this._internals.setValidity({valueMissing:!0},p,this._component.refs.input)}else this._internals.setValidity({})}_applyControlValue(c,h,u){let d=Object.entries(c).find(([,p])=>p.property===h);d&&this._applyValue(d[0],d[1],u)}_currentValue(c,h){if(this._propertyValues.has(h.property))return this._propertyValues.get(h.property);let u=Ae(this.getAttribute(c),h.type);return u===void 0?h.default:u}_readProperty(c){if(this._component&&c.get)return c.get(this._component,this);if(this._propertyValues.has(c.property))return this._propertyValues.get(c.property);let h=Ae(this.getAttribute(c.attribute),c.type);return h===dt||h===void 0?cs(c.default):h}_writeProperty(c,h){this._propertyValues.set(c.property,h);let u=c.serialize?c.serialize(h,this):qn(h,c.type);if(u!==dt){this._reflecting.add(c.attribute);try{u===null?this.removeAttribute(c.attribute):this.setAttribute(c.attribute,u)}finally{this._reflecting.delete(c.attribute)}}this._applyValue(c.attribute,c,h)}}for(let a of Object.values(i))Object.prototype.hasOwnProperty.call(o.prototype,a.property)||Object.defineProperty(o.prototype,a.property,{configurable:!0,enumerable:!0,get(){return this._readProperty(a)},set(c){this._writeProperty(a,c)}});return o}function r_(s="zx"){if(typeof customElements>"u")throw new Error("Custom elements are not available in this environment");let t=String(s).trim();for(let[e,i,n]of s_){let r=`${t}-${e}`;customElements.get(r)||customElements.define(r,n_(i,n))}}function Zl(s){let t={};for(let[e,i]of Object.entries(s)){let n=typeof i=="string"?{type:i}:{...i},r=n.property??o_(e);t[e]=Object.freeze({type:n.type??"string",option:Object.prototype.hasOwnProperty.call(n,"option")?n.option:r,property:r,default:n.default,always:!!n.always,rebuild:!!n.rebuild,normalize:n.normalize,serialize:n.serialize,set:n.set,get:n.get,attribute:e})}return Object.freeze(t)}function ft(s){return Zl(s)}function O(s={}){return{type:"string",...s}}function ke(s={}){return{type:"number",...s}}function P(s={}){return{type:"boolean",default:!1,always:!0,...s}}function Ft(s={}){return{type:"json",...s}}function o_(s){return s.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function Jl(s,t,e){return s.normalize?s.normalize(t,e):t}function fi(s,t){t?s.disable():s.enable()}function a_(s,t){s.el.setAttribute("aria-disabled",String(t)),s.refs.search&&(s.refs.search.disabled=t);for(let e of s.refs.list?.querySelectorAll("input")??[])e.disabled=t}function l_(s){return s===""||s==="true"?"local":s==="false"?!1:s}function c_(s){return s===""||s==="true"?"single":s==="false"?!1:s}function tc(s){if(typeof s!="string"||s.trim()==="")return s;let t=Number(s);return Number.isFinite(t)?t:s}function h_(s){return Array.isArray(s)?s.map(t=>!t||typeof t!="object"||u_(t.content)||typeof t.content=="function"?t:{...t,content:document.createTextNode(String(t.content??""))}):s}function u_(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function d_(s){return typeof s!="string"?s:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(s)?Z(s,"%Y-%m-%dT%H:%M"):/^\d{4}-\d{2}-\d{2}$/.test(s)?Z(s,"%Y-%m-%d"):s}function f_(s,t){return s instanceof Date?Kn(s,!!t.time):qn(s,"string")}function Kn(s,t){return!(s instanceof Date)||Number.isNaN(s.getTime())?"":D(s,t?"%Y-%m-%dT%H:%M":"%Y-%m-%d")}function $n(s){return s===nt||s===Ut?"checked":[$,ot,et,Mt].includes(s)?"value":null}function p_(s,t,e){if(s===nt||s===Ut){let n=t.get(),r=s===nt?!0:"on";return e._propertyValues.has("value")?r=e._propertyValues.get("value"):e.hasAttribute("value")&&(r=e.getAttribute("value")),{formValue:n?String(r):null,state:String(n),empty:!n}}if(s===$){let n=t.value;return{formValue:n===null?null:String(n),state:JSON.stringify(n),empty:n===null||n===""}}if(s===ot){let n=JSON.stringify(t.getValues());return{formValue:n,state:n,empty:n==="[]"}}if(s===et){let n=Kn(t.get(),!!e.time);return{formValue:n||null,state:n,empty:n===""}}let i=String(t.get());return{formValue:i,state:i,empty:!1}}function __(s,t){return s===nt||s===Ut?t==="true":s===$||s===ot?Ae(t,"json"):s===Mt?Ae(t,"number"):t}function cs(s){return Array.isArray(s)?s.slice():s instanceof Date?new Date(s.getTime()):s}var m_=Object.freeze(["neutral","accent","success","warning","danger","info"]),g_=Object.freeze(["soft","solid","outline"]),b_=Object.freeze({label:"",icon:null,kind:"neutral",variant:"soft",size:"md",dot:!1});function pt(s={}){let t={...b_,...s},e=l("span",{class:"zx-badge",title:t.title,dataset:{kind:w_(t.kind),variant:x_(t.variant),size:v_(t.size)}});return t.dot?e.append(l("span",{class:"zx-badge__dot",ariaHidden:"true"})):t.icon&&e.append(g(t.icon,{size:12,class:"zx-badge__icon"})),t.label!==""&&t.label!=null?e.append(l("span",{class:"zx-badge__label"},String(t.label))):t.title&&(e.setAttribute("role","img"),e.setAttribute("aria-label",t.title)),e}function y_(s){let t=l("span",{class:"zx-badge-group"});return t.append(...s),t}function w_(s){return m_.includes(s)?s:"neutral"}function x_(s){return g_.includes(s)?s:"soft"}function v_(s){return s==="sm"?"sm":"md"}var S_=Object.freeze({md:40,sm:28}),A_=Object.freeze({icon:"folder-open",title:"",description:"",actions:[],size:"md",align:"center"});function k_(s={}){let t={...A_,...s},e=C_(t.size),i=l("div",{class:"zx-empty-state",dataset:{size:e,align:T_(t.align)}});t.icon&&i.append(l("div",{class:"zx-empty-state__icon",ariaHidden:"true"},g(t.icon,{size:S_[e]}))),t.title&&i.append(l("p",{class:"zx-empty-state__title"},String(t.title))),t.description&&i.append(l("p",{class:"zx-empty-state__description"},String(t.description)));let n=z_(t.actions);return n.length>0&&i.append(l("div",{class:"zx-empty-state__actions"},n)),i}function z_(s){if(!Array.isArray(s))throw new TypeError("emptyState actions must be an array");return s.map(t=>{if(T(t))return t;if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("emptyState actions must be Elements or button descriptors");return j(t)})}function C_(s){return s==="sm"?"sm":"md"}function T_(s){return s==="start"?"start":"center"}var I_=Object.freeze({size:"md",label:"",showLabel:!1,kind:"accent"}),E_=Object.freeze({sm:!0,md:!0,lg:!0});function Un(s={}){let t={...I_,...s},e=String(t.label??""),i=l("span",{class:"zx-spinner",dataset:{size:E_[t.size]?t.size:"md",kind:t.kind==="current"?"current":"accent"}},l("span",{class:"zx-spinner__ring",ariaHidden:"true"}));return e?(i.setAttribute("role","status"),i.append(l("span",{class:"zx-spinner__label",dataset:{visible:t.showLabel?"true":null}},e))):i.setAttribute("aria-hidden","true"),i}var pi=class extends m{static cssName="progress-bar";static defaults={value:0,max:100,label:"",helperText:"",status:"active",indeterminate:!1,size:"md",hideLabel:!1,showValue:!0,formatValue:null};render(){this._value=0,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t,this._max=Math.max(1,Number(this.options.max)||100),this._status=ec(this.options.status),this._indeterminate=!!this.options.indeterminate,this._labelId=x("zx-progress-label");let e=l("div",{ref:"head",class:"zx-progress-bar__head"},l("span",{ref:"label",class:"zx-progress-bar__label",id:this._labelId},String(this.options.label??"")),l("span",{ref:"value",class:"zx-progress-bar__value"})),i=l("div",{ref:"track",class:"zx-progress-bar__track",role:"progressbar",ariaValuemin:"0",ariaValuemax:String(this._max),ariaLabelledby:this._labelId},l("div",{ref:"fill",class:"zx-progress-bar__fill"}));return t.replaceChildren(e,i,l("p",{ref:"helper",class:"zx-progress-bar__helper"},String(this.options.helperText??""))),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.set(this.options.value,{silent:!0}),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let i=Number(t),n=B(Number.isFinite(i)?i:0,0,this._max),r=n!==this._value,o=r&&n>=this._max;return this._value=n,this._sync(),!e&&r&&this.emit("change",{value:n,percent:this.percent()}),!e&&o&&this.emit("complete",{value:n}),this}percent(){return this._value/this._max*100}setMax(t){return this._max=Math.max(1,Number(t)||1),this.refs.track.setAttribute("aria-valuemax",String(this._max)),this.set(this._value,{silent:!0})}setStatus(t,e){return this._status=ec(t),e!==void 0&&this.setHelperText(e),this._sync(),this}setLabel(t){return this.refs.label.textContent=String(t??""),this}setHelperText(t){return this.refs.helper.textContent=String(t??""),this}setIndeterminate(t=!0){return this._indeterminate=!!t,this._sync(),this}_sync(){let{track:t,fill:e,value:i}=this.refs;if(this.el.dataset.status=this._status,this.el.toggleAttribute("data-indeterminate",this._indeterminate),this._indeterminate){t.removeAttribute("aria-valuenow"),t.removeAttribute("aria-valuetext"),e.style.removeProperty("--zx-progress-fill"),i.textContent="";return}let n=this._format();t.setAttribute("aria-valuenow",String(this._value)),t.setAttribute("aria-valuetext",n),e.style.setProperty("--zx-progress-fill",`${this.percent()}%`),i.replaceChildren(...this._readout(n))}_format(){let t=this.options.formatValue;return typeof t=="function"?String(t(this._value,this._max)):`${Math.round(this.percent())}%`}_readout(t){if(!this.options.showValue)return[];let e=[];return this._status!=="active"&&e.push(g(this._status==="success"?"success":"error",{size:14})),e.push(l("span",{class:"zx-progress-bar__percent"},t)),e}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function ec(s){return s==="success"||s==="error"?s:"active"}var D_=new Set(["inactive","active","success","error"]),Yn=class extends m{static cssName="inline-loading";static defaults={status:"active",description:"",size:"sm",live:!0};render(){this._status="inactive",this._description="",this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("span");return this.el=t,t.replaceChildren(l("span",{ref:"indicator",class:"zx-inline-loading__indicator"}),l("span",{ref:"description",class:"zx-inline-loading__description"})),t.dataset.size=this.options.size==="md"?"md":"sm",this.options.live!==!1&&(t.setAttribute("role","status"),t.setAttribute("aria-live","polite")),this.set(this.options.status,this.options.description,{silent:!0}),t}get(){return this._status}getDescription(){return this._description}set(t,e,{silent:i=!1}={}){let n=D_.has(t)?t:"inactive";e!==void 0&&(this._description=String(e??""));let r=n!==this._status;return this._status=n,this._sync(),r&&!i&&this.emit("statuschange",{status:this._status,description:this._description}),this}setDescription(t){return this._description=String(t??""),this.refs.description.textContent=this._description,this}_sync(){this.el.dataset.status=this._status,this.refs.description.textContent=this._description,this.refs.indicator.replaceChildren(...this._indicator())}_indicator(){let t=this.el.dataset.size==="md"?18:16;return this._status==="active"?[Un({size:"sm",kind:"current"})]:this._status==="success"?[g("success",{size:t})]:this._status==="error"?[g("error",{size:t})]:[]}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function at(s={}){let t={width:"100%",height:"1rem",radius:"sm",...s};return l("span",{class:"zx-skeleton",ariaHidden:"true",dataset:{radius:N_.has(t.radius)?t.radius:"sm"},style:{"inline-size":Wn(t.width),"block-size":Wn(t.height)}})}function _i(s={}){let t={lines:3,width:"100%",heading:!1,lastLineWidth:"60%",...s},e=B(Math.trunc(Number(t.lines)||0),1,20),i=l("div",{class:"zx-skeleton-text",ariaHidden:"true",style:{"inline-size":Wn(t.width)}});for(let n=0;n<e;n+=1){let r=t.heading&&n===0,o=n===e-1&&e>1;i.append(at({width:o?t.lastLineWidth:"100%",height:r?"1.5rem":"0.75rem"}))}return i}function M_(s={}){let t={rows:5,columns:4,header:!0,...s},e=B(Math.trunc(Number(t.rows)||0),1,50),i=B(Math.trunc(Number(t.columns)||0),1,20),n=l("div",{class:"zx-skeleton-table",ariaHidden:"true",style:{"--zx-skeleton-columns":String(i)}});t.header!==!1&&n.append(ic(i,"header"));for(let r=0;r<e;r+=1)n.append(ic(i,"body"));return n}var N_=new Set(["sm","md","full"]);function ic(s,t){let e=l("div",{class:"zx-skeleton-table__row",dataset:{kind:t}});for(let i=0;i<s;i+=1)e.append(l("span",{class:"zx-skeleton-table__cell"},at({width:O_(i,s),height:"0.75rem"})));return e}function O_(s,t){return s===t-1?"55%":s%2===0?"80%":"65%"}function Wn(s){return typeof s=="number"?`${s}px`:String(s??"")}function F_(s={},...t){return l("div",{class:["zx-stack",s.class??""],dataset:{direction:s.direction==="row"?"row":null,align:sc.has(s.align)?s.align:null,justify:V_.has(s.justify)?s.justify:null,wrap:s.wrap?"true":null,inline:s.inline?"true":null},style:nc("--zx-stack-gap",s.gap)},t)}function L_(s={},...t){let e=Number(s.columns),i={...nc("--zx-grid-gap",s.gap),"--zx-grid-min":B_(s.min??"16rem")};return Number.isFinite(e)&&e>=1&&(i["--zx-grid-columns"]=String(Math.trunc(e))),l("div",{class:["zx-grid",s.class??""],dataset:{columns:Number.isFinite(e)&&e>=1?"true":null,align:sc.has(s.align)?s.align:null},style:i},t)}function R_(s={},...t){return l("div",{class:["zx-aspect",s.class??""],style:{"--zx-aspect-ratio":String(s.ratio??"16 / 9"),"--zx-aspect-fit":P_.has(s.fit)?s.fit:"cover"}},t)}var sc=new Set(["start","center","end","stretch","baseline"]),V_=new Set(["start","center","end","between","around"]),P_=new Set(["cover","contain","fill"]);function nc(s,t){if(t==null||t==="")return{};let e=Number(t);return Number.isInteger(e)&&e>=1&&e<=8?{[s]:`var(--zx-space-${e})`}:{[s]:String(t)}}function B_(s){return typeof s=="number"?`${s}px`:String(s)}function j_(s,t={}){let e=q(s);if(!e)throw new TypeError("truncate() target could not be resolved");let i=B(Math.trunc(Number(t.lines)||1),1,10),n=t.title!==!1,r=e.classList.contains("zx-truncate"),o=e.getAttribute("title"),a=!1,c=null;e.classList.add("zx-truncate"),i>1&&(e.dataset.lines=String(i),e.style.setProperty("--zx-truncate-lines",String(i)));let h=()=>(a=rc(e),n&&(a?e.setAttribute("title",e.textContent?.trim()??""):o===null?e.removeAttribute("title"):e.setAttribute("title",o)),a);return h(),typeof ResizeObserver=="function"&&(c=new ResizeObserver(h),c.observe(e)),{update:h,isTruncated:()=>a,destroy:()=>{c?.disconnect(),c=null,r||e.classList.remove("zx-truncate"),delete e.dataset.lines,e.style.removeProperty("--zx-truncate-lines"),n&&(o===null?e.removeAttribute("title"):e.setAttribute("title",o))}}}function rc(s){return s.scrollWidth-s.clientWidth>1||s.scrollHeight-s.clientHeight>1}var H_=Object.freeze({text:"",label:"",title:"Copy",feedback:"Copied",feedbackDuration:2e3,size:"md",kind:"ghost"});function Gn(s={}){let t={...H_,...s},e=!t.label,i=l("button",{class:["zx-copy-button",e?"zx-icon-btn":"zx-btn"],type:"button",dataset:{size:t.size==="sm"?"sm":"md",kind:e?null:t.kind},title:e?String(t.title):null,ariaLabel:e?String(t.title):null}),n=l("span",{class:"zx-copy-button__icon",ariaHidden:"true"},g("copy",{size:t.size==="sm"?12:14})),r=l("span",{class:"zx-copy-button__status",role:"status"});i.append(n),e||i.append(l("span",{class:"zx-copy-button__label"},String(t.label))),i.append(r);let o=0;return i.addEventListener("click",async()=>{let a=typeof t.text=="function"?String(t.text()):String(t.text??""),c=await Vn(a);t.oncopy?.(a,c),c&&(clearTimeout(o),i.dataset.copied="true",n.replaceChildren(g("check",{size:t.size==="sm"?12:14})),r.textContent=String(t.feedback),o=setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,n.replaceChildren(g("copy",{size:t.size==="sm"?12:14})),r.textContent="")},Math.max(0,Number(t.feedbackDuration)||0)))}),i}var Qn=class extends m{static cssName="copy-input";static defaults={value:"",label:"",hideLabel:!1,feedback:"Copied",buttonTitle:"Copy",size:"md"};render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t;let e=x("zx-copy-input"),i=l("input",{ref:"input",class:"zx-copy-input__field",type:"text",id:e,readOnly:!0,value:String(this.options.value??"")}),n=Gn({text:()=>this.get(),title:String(this.options.buttonTitle),feedback:String(this.options.feedback),size:this.options.size==="sm"?"sm":"md",oncopy:(r,o)=>this.emit("copy",{value:r,copied:o})});return t.replaceChildren(l("label",{ref:"label",class:"zx-copy-input__label",for:e},String(this.options.label??"")),l("div",{class:"zx-copy-input__box"},i,n)),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(i,"focus",()=>i.select()),t}get(){return this.refs.input.value}set(t){return this.refs.input.value=String(t??""),this}focus(){return this.refs.input.focus(),this.refs.input.select(),this}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};var At=['[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]'].join(",");function mi(s){return!!(s&&s!=="-"&&typeof s=="object"&&!["heading","separator"].includes(String(s.type??"")))}function q_(s){return["menuitemcheckbox","menuitemradio"].includes(String(s.role))?s.role:"menuitem"}function hs(s,t){let e=[];return s.forEach((i,n)=>{if(i==="-"||i&&typeof i=="object"&&i.type==="separator"){e.push(l("div",{class:`zx-${t}__separator`,role:"separator"}));return}if(i&&typeof i=="object"&&i.type==="heading"){e.push(l("div",{class:`zx-${t}__heading`,role:"presentation"},String(i.label??"")));return}if(!mi(i))return;let r=q_(i),o=V(i.href),a=i.target==null?null:String(i.target),c=i.rel==null?a==="_blank"?"noopener noreferrer":null:String(i.rel),h=[],u=[];r!=="menuitem"&&u.push(l("span",{class:`zx-${t}__check`,"data-check-kind":r==="menuitemradio"?"radio":"checkbox"})),i.icon&&u.push(g(i.icon)),h.push(l("span",{class:`zx-${t}__leading`,ariaHidden:"true"},u)),h.push(l("span",{class:`zx-${t}__body`},l("span",{class:`zx-${t}__label`},String(i.label??"")),i.description==null||i.description===""?null:l("span",{class:`zx-${t}__description`},String(i.description))));let d=[];if(i.badge!=null&&d.push(l("span",{class:`zx-${t}__badge`},String(i.badge))),i.shortcut&&d.push(l("kbd",{class:`zx-${t}__shortcut`},String(i.shortcut))),i.adornment!=null){let f=i.adornment&&typeof i.adornment=="object"&&"nodeType"in i.adornment?i.adornment:String(i.adornment);d.push(l("span",{class:`zx-${t}__adornment`},f))}d.length&&h.push(l("span",{class:`zx-${t}__meta`},d));let p={class:`zx-${t}__item`,role:r,tabindex:"-1","data-menu-item":String(n),"data-danger":i.danger?"true":null,ariaDisabled:i.disabled?"true":null,ariaChecked:r==="menuitem"?null:String(!!i.checked)};o?e.push(l("a",{...p,href:o,target:a,rel:c},h)):e.push(l("button",{...p,type:"button"},h))}),e}var ac=Symbol("zxDropdownPointerDismiss"),lc=Symbol("zxDropdownEscapeDismiss"),_t=class extends m{static cssName="dropdown";static defaults={content:null,placement:"bottom-start",offset:4,matchWidth:!1,openOn:"click",closeOnSelect:!1,scope:null};#t;#e=null;#i=new Map;#s=!1;constructor(t,e={}){let i=q(t);if(!i)throw new TypeError("Dropdown anchor could not be resolved");super(null,e),this.#t=i,rt(this.options.scope??i).append(this.el),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=l("div",{id:x("zx-dropdown"),popover:"manual"});return t.dataset.state="closed",t}open(){if(this.isOpen()||this.#s)return this;let t=rt(this.options.scope??this.#t);return this.el.parentElement!==t&&t.append(this.el),this.#e=st(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(K_()),this.#t.setAttribute("aria-expanded","true"),U_(),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"),Y_(),this):this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.#e!==null}setContent(t){return $_(this.el,t),this.#e?.update(),this}getPanel(){return this.el}destroy(){if(!this.#s){this.#s=!0,this.close();for(let[t,e]of this.#i)W_(this.#t,t,e);super.destroy()}}[ac](t){if(!this.isOpen())return;let e=t.composedPath();e.includes(this.el)||e.includes(this.#t)||this.close()}[lc](t){if(t.defaultPrevented||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.#i.set(t,this.#t.getAttribute(t))}},gi=class extends m{constructor(){super(null),this.listen(document,"pointerdown",t=>{let e=oc();e instanceof _t&&e[ac](t)}),this.listen(document,"keydown",t=>{if(t.defaultPrevented||t.key!=="Escape")return;let e=oc();e instanceof _t&&e[lc](t)})}render(){let t=l("span",{hidden:!0,"data-zx-dropdown-dismiss-manager":""});return document.body.append(t),t}};function $_(s,t){if(s.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t.nodeType=="number"&&s.append(t)}function oc(){let s=null,t=-1;for(let e of document.querySelectorAll("[data-zx-overlay-order]")){let i=Number(e.getAttribute("data-zx-overlay-order"))||0;i>t&&(t=i,s=e)}return s?m.from(s):null}function K_(){let s=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...s)+1}function U_(){let s=document.querySelector("[data-zx-dropdown-dismiss-manager]"),t=s?m.from(s):null;return t instanceof gi?t:new gi}function Y_(){if(document.querySelector('.zx-dropdown[data-state="open"]'))return;let s=document.querySelector("[data-zx-dropdown-dismiss-manager]"),t=s?m.from(s):null;t instanceof gi&&t.destroy()}function W_(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}var mt=class extends m{static cssName="menu-button";static defaults={label:"",icon:null,kind:"default",items:[],placement:"bottom-start"};#t;#e;#i;#s;#r=[];#n=null;#o=!1;#a=!1;constructor(t=null,e={}){let i=t===null?null:q(t);if(t!==null&&(!i||i.tagName!=="BUTTON"))throw new TypeError("MenuButton target must resolve to a button");let n=i?{attributes:Array.from(i.attributes,o=>[o.name,o.value]),children:Array.from(i.childNodes)}:null,r=Object.hasOwn(e,"label");super(t,e),this.#o=i===null,this.#n=n,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 _t(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"),i&&r&&this.setLabel(this.options.label),this.setItems(this.options.items),this.#i=Dt(this.#e,At),this.#s=ht(()=>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.#i.focusFirst())}),this.listen(this.el,"keydown",o=>this.#l(o)),this.listen(this.#e,"click",o=>{let a=o.target.closest?.(At);a&&this.#e.contains(a)&&this.#h(a,o)}),this.listen(this.#e,"keydown",o=>this.#c(o))}render(){return this.el?this.el:l("button",{class:"zx-btn",type:"button","data-kind":this.options.kind,"data-size":"md"},cc(this.options.label,this.options.icon))}setItems(t){return this.#r=Array.isArray(t)?t.slice():[],this.#e.replaceChildren(...hs(this.#r,"menu-button")),this}open(){return this.#t.open(),this}close(){return this.#t.close(),this}isOpen(){return this.#t.isOpen()}getTrigger(){return this.el}getPanel(){return this.#e}focusFirst(){return this.open(),this.#i.focusFirst(),this}focusLast(){return this.open(),this.#i.focusLast(),this}setLabel(t){return this.el.replaceChildren(...cc(t,this.options.icon)),this}destroy(){if(!this.#a&&(this.#a=!0,this.#i.destroy(),this.#t.destroy(),super.destroy(),!this.#o&&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)}}#l(t){["ArrowDown","ArrowUp","Enter"," "].includes(t.key)&&(t.preventDefault(),this.open(),t.key==="ArrowUp"?this.#i.focusLast():this.#i.focusFirst())}#c(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?.(At);if(!e||!this.#e.contains(e)||t.key==="Enter"&&e.tagName==="A")return;t.preventDefault(),e.click();return}this.#s(t)}#h(t,e=null){let i=Number(t.getAttribute("data-menu-item")),n=this.#r[i];if(!mi(n)||n.disabled){e?.preventDefault();return}if(this.emit("select",{value:n.value,item:n}).defaultPrevented){e?.preventDefault();return}try{n.onselect?.(n.value,n,this)}finally{this.close()}}#u(){return Array.from(this.#e.querySelectorAll(At))}};function cc(s,t){let e=[];return t&&e.push(l("span",{class:"zx-btn__icon"},g(t))),e.push(l("span",{class:"zx-btn__label"},String(s??""))),e}var G_=["button","a[href]","input","select","textarea","[tabindex]"],Q_=G_.flatMap(s=>[`.zx-toolbar > ${s}`,`.zx-toolbar > [role="group"] > ${s}`]).join(","),Xn=class extends m{static cssName="toolbar";static defaults={items:[],align:"start",label:"Toolbar",overflow:!0,overflowLabel:"More",dense:!1};#t;#e=null;#i=null;#s=!1;#r=-1;#n=-1;#o=0;#a=!1;constructor(t=null,e={}){if(super(t,e),this.options.overflow){this.#e=new mt(null,{icon:"dots",label:"",kind:"ghost",placement:"bottom-end"});let i=this.#e.toElement();i.classList.add("zx-toolbar__overflow"),i.setAttribute("aria-label",String(this.options.overflowLabel)),i.setAttribute("title",String(this.options.overflowLabel)),this.options.dense&&i.setAttribute("data-size","sm"),i.hidden=!0}this.#t=Dt(this.el,Q_,{orientation:"horizontal"}),this.listen(this.el,"click",i=>this.#c(i)),this.setItems(this._initialItems),this.#e&&typeof ResizeObserver=="function"&&(this.#i=new ResizeObserver(()=>this.#u()),this.#i.observe(this.el))}render(){this._records=[],this._named=new Map,this._createdRoot=!this.el;let t=this.el??l("div");this.el=t,this._snapshot=this._createdRoot?null:A(t);let e=this.options.items;return this._initialItems=Array.isArray(e)&&e.length===0?Array.from(t.children):e,t.setAttribute("role","toolbar"),t.setAttribute("aria-label",String(this.options.label)),t.dataset.align=J_(this.options.align),t.dataset.overflow=this.options.overflow?"true":"false",this.options.dense&&(t.dataset.dense="true"),t}setItems(t){for(let i of this._records)i.type==="element"&&(i.element.hidden=i.userHidden);this._records=X_(t).map(i=>this.#l(i)),this._named=new Map;for(let i of this._records)i.name!==null&&!this._named.has(i.name)&&this._named.set(i.name,i);let e=this._records.map(i=>i.element);if(this.#e){this.#e.setItems([]);let i=this.#e.toElement();i.hidden=!0,e.push(i)}return this.el.replaceChildren(...e),this.#r=-1,this.#n=-1,this.#d(),this}getItem(t){return this._named.get(String(t))?.element??null}enable(t){return this.#h(t,!1)}disable(t){return this.#h(t,!0)}setActive(t,e=!0){let i=this._named.get(String(t));return i&&i.element.setAttribute("aria-pressed",e?"true":"false"),this}destroy(){if(!this.#a){this.#a=!0,this.#i?.disconnect(),this.#i=null,this.#o!==0&&cancelAnimationFrame(this.#o),this.#o=0,this.#t.destroy(),this.#e?.destroy(),this.#e=null;for(let t of this._records)t.type==="element"&&(t.element.hidden=t.userHidden);super.destroy(),this._createdRoot||S(this.el,this._snapshot)}}#l(t){if(t.type==="separator")return{type:"separator",element:l("span",{class:"zx-toolbar__separator",role:"separator",ariaOrientation:"vertical",dataset:{separator:"true"}}),name:null,label:"",icon:null,onclick:null,userHidden:!1};if(t.type==="element"){let a=t.element;return{type:"element",element:a,name:a.dataset?.name??null,label:uc(a),icon:null,onclick:null,userHidden:!!a.hidden}}let{name:e=null,active:i,onclick:n,...r}=t.descriptor,o=j({size:this.options.dense?"sm":"md",...r});return i!==void 0&&o.setAttribute("aria-pressed",i?"true":"false"),e!==null&&(o.dataset.name=String(e)),{type:"descriptor",element:o,name:e===null?null:String(e),label:String(r.label??r.title??""),icon:r.icon??null,onclick:typeof n=="function"?n:null,userHidden:!1}}#c(t){let e=t.target;if(!e)return;let i=this._records.find(n=>n.type==="descriptor"&&n.element.contains(e));i&&(this.emit("action",{name:i.name,item:i.element}),i.onclick?.(t))}#h(t,e){let i=this._named.get(String(t));if(!i)return this;let n=i.element;return"disabled"in n?n.disabled=e:e?n.setAttribute("aria-disabled","true"):n.removeAttribute("aria-disabled"),this.#f(),this}#u(){if(!(this.#o!==0||this.#a)){if(typeof requestAnimationFrame!="function"){this.#d();return}this.#o=requestAnimationFrame(()=>{this.#o=0,this.#d()})}}#d(){if(this.#s||this.#a||!this.#e)return;let t=this.el;if(typeof getComputedStyle!="function"||!t.isConnected)return;let e=getComputedStyle(t),i=parseFloat(e.columnGap)||0,n=(parseFloat(e.paddingInlineStart)||0)+(parseFloat(e.paddingInlineEnd)||0),r=t.clientWidth-n,o=t.clientHeight;if(!(!(r>0)||r===this.#r&&o===this.#n)){this.#s=!0;try{let a=this.#e.toElement(),c=this._records.filter(_=>!_.userHidden);for(let _ of c)_.element.hidden=!1;a.hidden=!1;let h=c.map(_=>_.element.getBoundingClientRect().width),u=h.reduce((_,b)=>_+b,0)+i*Math.max(0,h.length-1),d=a.getBoundingClientRect().width,p=[];if(u>r){let _=r-d-i,b=0,w=!1;for(c.forEach((y,v)=>{let k=b+h[v]+(b>0?i:0);if(!w&&k<=_){b=k;return}w=!0,y.element.hidden=!0,p.push(y)});c.length>p.length;){let y=c[c.length-p.length-1];if(y.type!=="separator")break;y.element.hidden=!0,p.unshift(y)}}let f=hc(p);this.#e.setItems(f),a.hidden=f.length===0,this.#r=r,this.#n=t.clientHeight}finally{this.#s=!1}}}#f(){if(!this.#e)return;let t=this._records.filter(e=>!e.userHidden&&e.element.hidden);this.#e.setItems(hc(t))}};function X_(s){if(s!=null&&!Array.isArray(s))throw new TypeError("Toolbar items must be an array");let t=[];for(let e of s??[])if(e!=null){if(e==="-"){t.length>0&&t[t.length-1].type!=="separator"&&t.push({type:"separator"});continue}if(T(e)){t.push({type:"element",element:e});continue}if(typeof e!="object"||Array.isArray(e))throw new TypeError('Toolbar items must be Elements, item descriptors, or "-"');t.push({type:"descriptor",descriptor:{...e}})}for(;t.length>0&&t[t.length-1].type==="separator";)t.pop();return t}function hc(s){let t=[];for(let e of s){if(e.type==="separator"){t.length>0&&t[t.length-1]!=="-"&&t.push("-");continue}let i=e.element;t.push({label:e.label||uc(i)||"\u2026",icon:e.icon??void 0,value:e.name,disabled:!!i.disabled||i.getAttribute("aria-disabled")==="true",onselect:()=>i.click()})}for(;t.length>0&&t[t.length-1]==="-";)t.pop();return t}function uc(s){return(s.getAttribute("aria-label")??s.getAttribute("title")??s.textContent??"").trim()}function J_(s){return["end","between"].includes(s)?s:"start"}var Zn=class extends m{static cssName="card";static defaults={title:"",media:null,content:null,actions:[],footer:null,link:null,variant:"outlined",orientation:"vertical",headingLevel:3};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("article");this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._cleaned=!1,this._title="",this._link=null,this._actionAbort=null,this._linkAbort=null;let i=t?[]:Array.from(e.childNodes);try{let n=im(this.options.headingLevel),r=x("zx-card-heading"),o=l(`h${n}`,{ref:"heading",class:"zx-card__heading",id:r}),a=l("div",{ref:"media",class:"zx-card__media",hidden:!0}),c=l("div",{ref:"actions",class:"zx-card__actions",role:"group",ariaLabel:this._message("card.actions","Card actions"),hidden:!0}),h=l("div",{ref:"content",class:"zx-card__content",hidden:!0}),u=l("footer",{ref:"footer",class:"zx-card__footer",hidden:!0}),d=l("header",{ref:"header",class:"zx-card__header"},o,c);return e.replaceChildren(l("div",{class:"zx-card__layout"},a,l("div",{class:"zx-card__inner"},d,h,u))),e.dataset.variant=tm(this.options.variant),e.dataset.orientation=em(this.options.orientation),this.setTitle(this.options.title),this.setMedia(this.options.media),this.options.content!==null?this.setContent(this.options.content):i.length&&(h.replaceChildren(...i),h.hidden=!1),this.setActions(this.options.actions),this.setFooter(this.options.footer),this.setLink(this.options.link),e}catch(n){throw this._actionAbort?.abort(),this._linkAbort?.abort(),t||S(e,this._original),n}}setTitle(t){let e=String(t??"");if(this._link&&!e.trim())throw new TypeError("A linked Card requires a non-empty title");return this._title=e,this._renderHeading(),this}setMedia(t){return Jn(this.refs.media,t,"Card media"),this.refs.media.hidden=t===null,this}setContent(t){return Jn(this.refs.content,t,"Card content"),this.refs.content.hidden=t===null,this}setActions(t){if(!Array.isArray(t))throw new TypeError("Card actions must be an array");let e=new AbortController,i;try{i=t.map(n=>{if(T(n))return n;if(!n||typeof n!="object"||Array.isArray(n))throw new TypeError("Card actions must be Elements or button descriptors");let r={...n},o=r.onclick;delete r.onclick;let a=j(r);if(o!==void 0&&typeof o!="function")throw new TypeError("Card action onclick must be a function");return o&&a.addEventListener("click",o,{signal:e.signal}),a})}catch(n){throw e.abort(),n}return this._actionAbort?.abort(),this._actionAbort=e,this.refs.actions.replaceChildren(...i),this.refs.actions.hidden=i.length===0,this._syncHeader(),this}setFooter(t){return Jn(this.refs.footer,t,"Card footer"),this.refs.footer.hidden=t===null,this}setLink(t){let e=Z_(t);if(e&&!this._title.trim())throw new TypeError("A linked Card requires a non-empty title");return this._link=e,this.el.dataset.linked=e?"true":"false",this._renderHeading(),this}destroy(){this._cleaned||(this._cleaned=!0,this._actionAbort?.abort(),this._linkAbort?.abort(),super.destroy(),this._createdRoot||S(this.el,this._original))}_renderHeading(){let t=this._title,e=new AbortController,i=this._link?l("a",{class:"zx-card__primary",href:this._link.href,target:this._link.target,rel:this._link.rel},t):l("span",{class:"zx-card__title"},t);this._link?.onclick&&i.addEventListener("click",this._link.onclick,{signal:e.signal}),this._linkAbort?.abort(),this._linkAbort=e,this.refs.heading.replaceChildren(i),this.refs.heading.hidden=t==="",t?this.el.setAttribute("aria-labelledby",this.refs.heading.id):this.el.removeAttribute("aria-labelledby"),this._syncHeader()}_syncHeader(){this.refs.header&&(this.refs.header.hidden=this._title===""&&this.refs.actions.childElementCount===0)}_message(t,e){let i=this.msg(t);return i===t?e:i}};function Jn(s,t,e){if(t===null){s.replaceChildren();return}if(typeof t=="string"){s.textContent=t;return}let i=t instanceof m?t.toElement():t;if(i instanceof Node){s.replaceChildren(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}function Z_(s){if(s===null)return null;let t=typeof s=="string"?{href:s}:s;if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Card link must be a URL string, descriptor, or null");let e=V(t.href);if(e===null)throw new TypeError("Card link requires a safe non-empty href");if(t.onclick!==void 0&&typeof t.onclick!="function")throw new TypeError("Card link onclick must be a function");let i=t.target==null?void 0:String(t.target),n=t.rel==null?"":String(t.rel).trim();return i==="_blank"&&!/(^|\s)noopener(\s|$)/i.test(n)&&(n=`${n} noopener`.trim()),{href:e,target:i,rel:n||void 0,onclick:t.onclick}}function tm(s){return["raised","filled"].includes(String(s))?s:"outlined"}function em(s){return s==="horizontal"?"horizontal":"vertical"}function im(s){let t=Math.trunc(Number(s));return t>=1&&t<=6?t:3}var sm=Object.freeze(["neutral","accent","success","warning","danger","info"]),nm=Object.freeze(["positive","negative","neutral"]),rm=Object.freeze({"statTile.up":"up %1","statTile.down":"down %1","statTile.unchanged":"no change","statTile.loading":"Loading"}),om=Object.freeze({up:"chevron-up",down:"chevron-down",flat:"minus"}),gc=100,ir=30,am=2,lm=Object.freeze({label:"",value:null,format:"number",currency:null,delta:null,deltaKind:"neutral",deltaLabel:"",trend:[],icon:null,kind:"neutral",href:null,clickable:!1,loading:!1}),dc="http://www.w3.org/2000/svg",us=class extends m{static cssName="stat-tile";static defaults=lm;constructor(t=null,e={}){super(t,{...e,clickable:e?.clickable===!0||typeof e?.onclick=="function"})}render(){let t=tr(this.options);if(this._createdRoot=this.el===null,!this._createdRoot&&this.el.tagName.toLowerCase()!==t)throw new TypeError(`StatTile needs a <${t}> for these options, but the target is a <${this.el.tagName.toLowerCase()}>. Pass null as the target to let it build its own.`);let e=this.el??l(t);return this.el=e,this._snapshot=this._createdRoot?null:A(e),this._closed=!1,this._state={...this.options},t==="button"&&(e.type="button"),pc(e,this._state,(i,...n)=>this._message(i,...n)),t!=="div"&&this.listen(e,"click",i=>{this.emit("click",{event:i})}),e}update(t={}){let e={...this._state,...t},i=this.el.tagName.toLowerCase();if(tr(e)!==i)throw new TypeError(`StatTile cannot change from <${i}> to <${tr(e)}> in place: href and clickable decide the element, and an element's tag is fixed once it exists.`);return this._state=e,pc(this.el,e,(n,...r)=>this._message(n,...r)),this}getAccessibleName(){return this.el.getAttribute("aria-label")??""}destroy(){if(this._closed)return;this._closed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_message(t,...e){let i=this.msg(t,...e);return i===t?I(rm[t]??t,e):i}};function cm(s={}){return new us(null,s)}function bc(s,t={}){let{format:e="number",locale:i,currency:n=null}=t;if(typeof e=="function")return bi(e(s));if(typeof s=="string")return s;if(s==null)return"";switch(e){case"currency":return oi(s,n,{locale:i});case"percent":return ai(s,{locale:i});case"fileSize":return li(s,{locale:i});case"number":return Nt(s,{locale:i});default:return bi(s)}}function hm(s,t={}){let e=xc(s);if(e===null)return null;let i=e>0?"up":e<0?"down":"flat",n=i==="up"?"+":i==="down"?"\u2212":"",r=bc(Math.abs(e),t);return{direction:i,sign:n,magnitude:r,text:`${n}${r}`}}function tr(s={}){return V(s.href)?"a":s.clickable===!0||typeof s.onclick=="function"?"button":"div"}function fc(s={}){let t=[s.delta,s.deltaLabel].map(er).filter(Boolean).join(" ");return[er(s.label),er(s.value),t].filter(Boolean).join(", ")}function yc(s,t={}){let{width:e=gc,height:i=ir,inset:n=am}=t,r=(Array.isArray(s)?s:[]).map(xc).filter(p=>p!==null);if(r.length<2)return null;let o=Math.min(...r),a=Math.max(...r),c=n,h=Math.max(n,i-n),u=a-o,d=e/(r.length-1);return r.map((p,f)=>{let _=f===r.length-1?e:f*d,b=u===0?(c+h)/2:h-(p-o)/u*(h-c);return`${mc(_)},${mc(b)}`}).join(" ")}function pc(s,t,e){let i=wc(t.kind,sm,"neutral"),n=bi(t.label),r=t.loading===!0;if(s.classList.add("zx-stat-tile"),s.dataset.kind=i,s.dataset.loading=String(r),s.tagName.toLowerCase()==="a"){let f=V(t.href);f?s.setAttribute("href",f):s.removeAttribute("href")}if(r){s.setAttribute("aria-busy","true"),_c(s,fc({label:n,value:e("statTile.loading")})),s.replaceChildren(fm(t));return}s.removeAttribute("aria-busy");let o=bc(t.value,t),a=hm(t.delta,{format:t.deltaFormat??t.format,locale:t.locale,currency:t.currency}),c=bi(t.deltaLabel);_c(s,fc({label:n,value:o,delta:a===null?"":_m(a,e),deltaLabel:c}));let h=l("div",{class:"zx-stat-tile__header"},l("span",{class:"zx-stat-tile__label"},n)),u=pm(t.icon);u&&h.append(l("span",{class:"zx-stat-tile__icon"},u));let d=[h,l("div",{class:"zx-stat-tile__value"},o)];a!==null&&d.push(um(a,c,t.deltaKind));let p=dm(t.trend);p&&d.push(p),s.replaceChildren(...d)}function um(s,t,e){let i=l("div",{class:"zx-stat-tile__delta",ariaHidden:"true",dataset:{kind:wc(e,nm,"neutral"),direction:s.direction}},g(om[s.direction],{size:12}),l("span",{class:"zx-stat-tile__delta-value"},s.text));return t&&i.append(l("span",{class:"zx-stat-tile__delta-label"},t)),i}function dm(s){let t=yc(s);if(t===null)return null;let e=document.createElementNS(dc,"svg");e.setAttribute("class","zx-stat-tile__trend"),e.setAttribute("viewBox",`0 0 ${gc} ${ir}`),e.setAttribute("preserveAspectRatio","none"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");let i=document.createElementNS(dc,"polyline");return i.setAttribute("points",t),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","1.5"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.setAttribute("vector-effect","non-scaling-stroke"),e.append(i),e}function fm(s){let t=[l("div",{class:"zx-stat-tile__header"},at({width:"55%",height:"0.75rem"})),at({width:"70%",height:"1.75rem",radius:"md"})];return s.delta!==null&&s.delta!==void 0&&t.push(at({width:"40%",height:"0.75rem"})),yc(s.trend)!==null&&t.push(at({width:"100%",height:`${ir}px`,radius:"md"})),l("div",{class:"zx-stat-tile__loading"},...t)}function pm(s){return s?g(String(s),{size:16}):null}function _m(s,t){return s.direction==="flat"?t("statTile.unchanged"):t(s.direction==="up"?"statTile.up":"statTile.down",s.magnitude)}function _c(s,t){let e=s.tagName.toLowerCase()==="div";if(t){s.setAttribute("aria-label",t),e&&s.setAttribute("role","group");return}s.removeAttribute("aria-label"),e&&s.removeAttribute("role")}function wc(s,t,e){return t.includes(s)?s:e}function xc(s){if(typeof s=="number")return Number.isFinite(s)?s:null;if(typeof s!="string")return null;let t=s.trim();if(t==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}function bi(s){return s==null?"":String(s)}function er(s){return bi(s).trim()}function mc(s){return Math.round(B(s,-1e6,1e6)*100)/100}var mm=Object.freeze(["source","confluence","horizon","diagonal","edge","curtain"]),gm=Object.freeze(["subtle","balanced","vivid"]),ds=Object.freeze(["--zx-aurora-color-1","--zx-aurora-color-2","--zx-aurora-color-3","--zx-aurora-color-4"]),sr=class extends m{static cssName="aurora";static defaults={preset:"source",colors:[],intensity:"subtle"};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("div");return this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._cleaned=!1,this._initialColors=ds.map(i=>({property:i,value:e.style.getPropertyValue(i),priority:e.style.getPropertyPriority(i)})),this._colors=[],this.setPreset(this.options.preset),this.setIntensity(this.options.intensity),this.setColors(this.options.colors),e}setPreset(t){return this.el.dataset.preset=bm(t),this}setColors(t){let e=wm(t),i=xm(e);if(this._colors=[...e],this.el.dataset.colors=e.length===0?"semantic":String(e.length),i.length===0){for(let n of this._initialColors)n.value?this.el.style.setProperty(n.property,n.value,n.priority):this.el.style.removeProperty(n.property);return this}for(let n=0;n<ds.length;n+=1)this.el.style.setProperty(ds[n],i[n]);return this}setIntensity(t){return this.el.dataset.intensity=ym(t),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),this._createdRoot||S(this.el,this._original))}};function bm(s){let t=String(s??"").trim().toLowerCase();if(!mm.includes(t))throw new TypeError(`Unknown Aurora preset: ${s}`);return t}function ym(s){let t=String(s??"").trim().toLowerCase();if(!gm.includes(t))throw new TypeError(`Unknown Aurora intensity: ${s}`);return t}function wm(s){if(s==null)return[];if(!Array.isArray(s))throw new TypeError("Aurora colors must be an array");if(s.length>ds.length)throw new TypeError("Aurora accepts at most four colors");return s.map(t=>{if(!Ht(t))throw new TypeError(`Invalid Aurora color: ${t}`);return t.trim()})}function xm(s){return s.length===0?[]:s.length===1?[s[0],s[0],s[0],s[0]]:s.length===2?[s[0],s[1],s[0],s[1]]:s.length===3?[s[0],s[1],s[2],s[1]]:[...s]}var nr=class extends m{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??l("section");this.el=e,this._createdRoot=t,this._original=t?null:vm(e),this._cleaned=!1,this._open=!!this.options.open,this._collapsible=!!this.options.collapsible,this._hasFooterContent=!1;let i=t?[]:Array.from(e.childNodes),n=x("zx-panel-body"),r=l("span",{class:"zx-panel__title",ref:"title"}),o=[];this._collapsible&&o.push(l("span",{class:"zx-panel__chevron",ariaHidden:"true"},g("chevron-right",{size:16}))),o.push(r);let a=this._collapsible?l("button",{class:"zx-panel__toggle",ref:"toggle",type:"button",ariaControls:n,ariaExpanded:String(this._open)},o):l("div",{class:"zx-panel__toggle",ref:"toggle"},o),c=l("div",{class:"zx-panel__header",ref:"header"},a,l("div",{class:"zx-panel__buttons",ref:"buttons",role:"group",ariaLabel:this._message("panel.actions","Panel actions")})),h=l("div",{class:"zx-panel__content",ref:"content"}),u=l("div",{class:"zx-panel__body",ref:"body",id:n},h),d=l("div",{class:"zx-panel__footer",ref:"footer",hidden:!0},l("div",{class:"zx-panel__footer-content",ref:"footerContent"}),l("div",{class:"zx-panel__footer-buttons",ref:"footerButtons",role:"group",ariaLabel:this._message("panel.footerActions","Panel footer actions")}));return e.replaceChildren(c,u,d),this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):h.append(...i),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),this.setFooterButtons(this.options.footerButtons),this._syncOpenState(),this._collapsible&&this.listen(a,"click",()=>this.toggle()),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return vc(this.refs.content,t,"Panel content"),this}setButtons(t){return this.refs.buttons.replaceChildren(...this._buildButtons(t,"Panel buttons")),this}setFooter(t){return vc(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&&Sm(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(i=>{if(T(i))return i;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`${e} must be Elements or button descriptors`);let n={...i},r=n.onclick;delete n.onclick;let o=j(n);return typeof r=="function"&&this.listen(o,"click",r),o})}_message(t,e){let i=this.msg(t);return i===t?e:i}};function vm(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Sm(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function vc(s,t,e){if(s.replaceChildren(),t===null)return;if(typeof t=="string"){s.append(document.createTextNode(t));return}let i=t instanceof m?t.toElement():t;if(i&&typeof i.nodeType=="number"){s.append(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}var Am=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"]),rr=class extends m{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??l("section");this.el=e,this._createdRoot=t,this._original=t?null:km(e),this._cleaned=!1;let i=t?[]:Array.from(e.childNodes),n=l("header",{class:"zx-master-panel__header"},l("h1",{class:"zx-master-panel__title",ref:"title"}),l("div",{class:"zx-master-panel__buttons",ref:"buttons",role:"group",ariaLabel:"Panel actions"})),r=l("div",{class:"zx-master-panel__content",ref:"content"}),o=l("footer",{class:"zx-master-panel__footer",ref:"footer",hidden:!0});e.replaceChildren(n,r,o);let a=Cm(this.options.module);return e.dataset.module=a,e.style.setProperty("--zx-master-panel-accent",`var(--zx-module-${a})`),this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):r.append(...i),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return Sc(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(i=>{if(T(i))return i;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("MasterPanel buttons must be Elements or button descriptors");let n={...i},r=n.onclick;delete n.onclick;let o=j(n);return typeof r=="function"&&this.listen(o,"click",r),o});return this.refs.buttons.replaceChildren(...e),this}setFooter(t){return Sc(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&&zm(this.el,this._original))}};function km(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function zm(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function Sc(s,t,e){if(s.replaceChildren(),t===null)return;if(typeof t=="string"){s.append(document.createTextNode(t));return}let i=t instanceof m?t.toElement():t;if(i&&typeof i.nodeType=="number"){s.append(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}function Cm(s){let t=String(s??"default").toLowerCase();return Am.includes(t)?t:"default"}function ze(s,t){if(!s)throw new TypeError("dragAxis requires a handle element");if(typeof t?.onMove!="function")throw new TypeError("dragAxis requires an onMove callback");let e=t.orientation==="vertical",i=new AbortController,{signal:n}=i,r=!1,o=null,a=0,c=0,h=!1,u=0,d=y=>e?y.clientY:y.clientX,p=()=>!!t.disabled?.(),f=()=>{let y=o;if(o=null,y!==null)try{s.releasePointerCapture(y)}catch{}},_=()=>{u!==0&&(cancelAnimationFrame(u),u=0)},b=()=>{r=!1,h=!1,_(),f()};s.addEventListener("pointerdown",y=>{let v=y;if(!(p()||r||v.button!==0)&&t.onStart?.(v)!==!1){r=!0,o=v.pointerId,a=d(v),c=a,h=!1;try{s.setPointerCapture(v.pointerId)}catch{}}},{signal:n}),s.addEventListener("pointermove",y=>{let v=y;!r||v.pointerId!==o||(c=d(v),c!==a&&(h=!0),u===0&&(u=requestAnimationFrame(()=>{u=0,r&&t.onMove(c-a)})))},{signal:n});let w=y=>{let v=y;if(!r||v.pointerId!==o)return;_(),c=d(v);let k=h,z=c-a;b(),t.onEnd?.(z,k)};return s.addEventListener("pointerup",w,{signal:n}),s.addEventListener("pointercancel",w,{signal:n}),s.addEventListener("keydown",y=>{let v=y;if(p())return;if((v.key==="Enter"||v.key===" ")&&t.onActivate){v.preventDefault(),t.onActivate();return}if(v.key==="Home"||v.key==="End"){if(!t.onJump)return;v.preventDefault(),t.onJump(v.key==="Home"?"min":"max");return}let k=e?"ArrowUp":"ArrowLeft",z=e?"ArrowDown":"ArrowRight";v.key!==k&&v.key!==z||t.onStep&&(v.preventDefault(),t.onStep(v.key===z?1:-1,v.shiftKey))},{signal:n}),{isDragging:()=>r,cancel(){r&&b()},destroy(){b(),i.abort()}}}function gt(s,t){if(typeof s=="number")return Number.isFinite(s)?s:Number.NaN;if(typeof s!="string")return Number.NaN;let e=/^([+-]?(?:\d+\.?\d*|\.\d+))(px|%)?$/i.exec(s.trim());if(!e)return Number.NaN;let i=Number(e[1]);if(!Number.isFinite(i))return Number.NaN;if((e[2]??"").toLowerCase()!=="%")return i;let n=Number(t);return Number.isFinite(n)?i/100*n:Number.NaN}var Tm="split-view",or=class extends m{static cssName="split-view";static defaults={orientation:"horizontal",start:null,end:null,size:"38%",min:160,max:null,collapsible:!1,collapsed:!1,snap:0,storageKey:null,disabled:!1,label:"Resize panes"};#t=null;#e=null;#i=null;constructor(t=null,e={}){super(t,e);let i=this.options.storageKey;if(i!=null&&i!==""){this.#e=ci(Tm);let o=this.#e.get(String(i));typeof o=="number"&&Number.isFinite(o)&&o>=0&&this.setSize(o)}let n=this.options.collapsed;n==="start"||n==="end"?this.#o(n,!1):n===!0&&this.options.collapsible&&this.#o(this.options.collapsible==="end"?"end":"start",!1);let r=this.refs.divider;this.#i=ze(r,{orientation:this._orientation,disabled:()=>this._disabled,onStart:()=>{this._startSize=this.getSize(),this.el.dataset.dragging="true"},onMove:o=>this.#a(o,!1),onEnd:(o,a)=>{a&&this.#a(o,!0),delete this.el.dataset.dragging,a&&(this.#p(),this.#_())},onStep:(o,a)=>this.#l(o*(a?64:16)),onJump:o=>this.#c(o),onActivate:()=>{this.options.collapsible&&(this._collapsed===null?this.collapse(this.options.collapsible):this.expand())}}),this.listen(r,"dblclick",()=>this.#d()),typeof ResizeObserver=="function"&&(this.#t=new ResizeObserver(()=>this.#f()),this.#t.observe(this.el)),this.#n()}render(){let t=this.options;this._orientation=t.orientation==="vertical"?"vertical":"horizontal";let e=gt(t.size,Number.NaN);this._size=Number.isFinite(e)?Math.max(0,e):null,this._collapsed=null,this._disabled=!!t.disabled,this._destroyed=!1,this._startSize=0,this._lastTotal=-1,this._createdRoot=!this.el;let i=this.el??l("div");this.el=i,this._snapshot=this._createdRoot?null:A(i);let n=this._createdRoot||t.start!=null||t.end!=null?[]:Array.from(i.children),r=x("zx-split-start"),o=l("div",{class:"zx-split-view__pane",id:r,ref:"start",dataset:{pane:"start"}}),a=l("div",{class:"zx-split-view__divider",ref:"divider",role:"separator",tabindex:this._disabled?-1:0,ariaOrientation:this._orientation==="vertical"?"horizontal":"vertical",ariaLabel:String(t.label??"Resize panes"),ariaControls:r}),c=l("div",{class:"zx-split-view__pane",ref:"end",dataset:{pane:"end"}});return i.replaceChildren(o,a,c),i.dataset.orientation=this._orientation,this._disabled&&a.setAttribute("aria-disabled","true"),i.style.setProperty("--zx-split-size",fs(t.size)),t.start!=null?ps(o,t.start,"SplitView start"):n[0]&&o.append(n[0]),t.end!=null?ps(c,t.end,"SplitView end"):n[1]&&c.append(...n.slice(1)),i}setSize(t){let{total:e,divider:i,min:n,max:r}=this.#s(),o=gt(t,e>0?e:Number.NaN);return Number.isFinite(o)?(this.#r(Wt({size:o,min:n,max:r,total:e,divider:i})),this):(this._size=null,this.el.style.setProperty("--zx-split-size",fs(t)),this.#n(),this)}getSize(){if(this._collapsed==="start")return 0;let{total:t,divider:e}=this.#s();if(this._collapsed==="end")return Math.max(0,t-e);if(this._size!==null)return this._size;let i=Ac(this.refs.start,this._orientation);if(i>0)return i;let n=gt(this.options.size,t);return Number.isFinite(n)?Math.max(0,n):0}getRatio(){let{total:t}=this.#s();return t>0?this.getSize()/t:0}setStart(t){return ps(this.refs.start,t,"SplitView start"),this}setEnd(t){return ps(this.refs.end,t,"SplitView end"),this}collapse(t){let e=this.options.collapsible==="end"?"end":"start";return this.#o(t==="end"?"end":t==="start"?"start":e,!0)}expand(){return this._collapsed===null?this:(this._collapsed=null,delete this.el.dataset.collapsed,this.#n(),this.emit("expand"),this)}isCollapsed(){return this._collapsed??!1}enable(){return this._disabled=!1,this.refs.divider.removeAttribute("aria-disabled"),this.refs.divider.setAttribute("tabindex","0"),this}disable(){return this._disabled=!0,this.#i?.cancel(),delete this.el.dataset.dragging,this.refs.divider.setAttribute("aria-disabled","true"),this.refs.divider.setAttribute("tabindex","-1"),this}isDisabled(){return this._disabled}destroy(){this._destroyed||(this._destroyed=!0,this.#i?.destroy(),this.#i=null,this.#t?.disconnect(),this.#t=null,super.destroy(),!this._createdRoot&&this._snapshot&&S(this.el,this._snapshot))}#s(){let t=this.el,e=this._orientation==="vertical"?t.clientHeight:t.clientWidth,i=this.options.max==null?null:Number(this.options.max);return{total:Number.isFinite(e)&&e>0?e:0,divider:Ac(this.refs.divider,this._orientation),min:Math.max(0,Number(this.options.min)||0),max:Number.isFinite(i)?i:null}}#r(t){this._size=t,this.el.style.setProperty("--zx-split-size",`${t}px`),this.#n()}#n(){let{total:t,divider:e,min:i,max:n}=this.#s(),r=_s({min:i,max:n,total:t,divider:e}),o=this.refs.divider;o.setAttribute("aria-valuemin",String(Math.round(r.min))),o.setAttribute("aria-valuemax",String(Math.round(r.max))),o.setAttribute("aria-valuenow",String(Math.round(this.getSize())))}#o(t,e){return this._collapsed===t?this:(this._collapsed=t,this.el.dataset.collapsed=t,this.#n(),e&&this.emit("collapse",{pane:t}),this)}#a(t,e){if(this._destroyed)return;let{total:i,divider:n,min:r,max:o}=this.#s();if(i<=0)return;this._collapsed!==null&&this.expand();let a=Wt({size:this._startSize+t,min:r,max:o,total:i,divider:n});e&&(a=Wt({size:kc(a,this.#u(i,n),Number(this.options.snap)),min:r,max:o,total:i,divider:n})),a!==this._size&&(this.#r(a),this.emit("resize",{size:a,ratio:a/i}))}#l(t){let{total:e,divider:i,min:n,max:r}=this.#s();e<=0||(this._collapsed!==null&&this.expand(),this.#h(Wt({size:this.getSize()+t,min:n,max:r,total:e,divider:i}),e))}#c(t){let{total:e,divider:i,min:n,max:r}=this.#s();if(e<=0)return;this._collapsed!==null&&this.expand();let o=_s({min:n,max:r,total:e,divider:i});this.#h(Wt({size:o[t],min:n,max:r,total:e,divider:i}),e)}#h(t,e){t!==this._size&&(this.#r(t),this.emit("resize",{size:t,ratio:t/e}),this.#p(),this.#_())}#u(t,e){let{min:i,max:n}=this.#s(),r=_s({min:i,max:n,total:t,divider:e}),o=[r.min,r.max],a=gt(this.options.size,t);return Number.isFinite(a)&&o.unshift(a),o}#d(){if(this._disabled)return;this._collapsed!==null&&this.expand();let t=gt(this.options.size,Number.NaN);Number.isFinite(t)?this.setSize(t):(this._size=null,this.el.style.setProperty("--zx-split-size",fs(this.options.size)),this._lastTotal=-1,this.#f());let{total:e}=this.#s(),i=this.getSize();this.emit("resize",{size:i,ratio:e>0?i/e:0}),this.#p(),this.#_()}#f(){if(this._destroyed||this.#i?.isDragging())return;let{total:t,divider:e,min:i,max:n}=this.#s();if(t<=0||t===this._lastTotal)return;if(this._lastTotal=t,this._size===null){let o=gt(this.options.size,t);if(Number.isFinite(o)){let a=Wt({size:o,min:i,max:n,total:t,divider:e});this.el.style.setProperty("--zx-split-size",Math.abs(a-o)>.5?`${a}px`:fs(this.options.size))}this.#n();return}let r=Wt({size:this._size,min:i,max:n,total:t,divider:e});if(r===this._size){this.#n();return}this.#r(r),this.emit("resize",{size:r,ratio:r/t})}#p(){let t=this.options.storageKey;!this.#e||t==null||t===""||(this._size===null?this.#e.remove(String(t)):this.#e.set(String(t),Math.round(this._size)))}#_(){let{total:t}=this.#s(),e=this.getSize();this.emit("resizeend",{size:e,ratio:t>0?e/t:0})}};function Wt({size:s,min:t=0,max:e=null,total:i=0,divider:n=0}){let r=Number(s),o=_s({min:t,max:e,total:i,divider:n});return Math.max(0,(Number(i)||0)-Math.max(0,Number(n)||0))>0?Number.isFinite(r)?Math.min(o.max,Math.max(o.min,r)):o.min:Number.isFinite(r)?Math.max(0,r):o.min}function kc(s,t,e){let i=Number(s),n=Number(e);if(!Number.isFinite(i)||!Number.isFinite(n)||n<=0)return i;let r=Array.isArray(t)?t:t==null?[]:[t],o=i,a=Number.POSITIVE_INFINITY;for(let c of r){let h=Number(c);if(!Number.isFinite(h))continue;let u=Math.abs(h-i);u<=n&&u<a&&(a=u,o=h)}return o}function _s({min:s=0,max:t=null,total:e=0,divider:i=0}){let n=Math.max(0,(Number(e)||0)-Math.max(0,Number(i)||0)),r=t==null||!Number.isFinite(Number(t))?n:Math.min(n,Math.max(0,Number(t)));return{min:Math.min(Math.max(0,Number(s)||0),r),max:r}}function Ac(s,t){let e=s.getBoundingClientRect(),i=t==="vertical"?e.height:e.width;return Number.isFinite(i)&&i>0?i:0}function fs(s){return typeof s=="number"&&Number.isFinite(s)?`${s}px`:String(s)}function ps(s,t,e){if(s.replaceChildren(),t==null)return;if(typeof t=="string"||typeof t=="number"){s.append(document.createTextNode(String(t)));return}let i=t instanceof m?t.toElement():t;if(i&&typeof i.nodeType=="number"){s.append(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}var Im="dock",cr=class extends m{static cssName="dock";static defaults={orientation:"vertical",content:null,panes:[],resizable:!0,collapsible:!0,lazy:!0,storageKey:null,label:"Resize panes"};constructor(t=null,e={}){super(t,e);let i=this.options.storageKey;if(i!=null&&i!==""){this._store=ci(Im);let n=this._store.get(String(i));n&&typeof n=="object"&&this.setState(n)}this._syncGrow(),this._syncDividers()}render(){let t=this.options;this._orientation=t.orientation==="horizontal"?"horizontal":"vertical",this._resizable=t.resizable!==!1,this._lazy=t.lazy!==!1,this._destroyed=!1,this._panes=new Map,this._store=null,this._drag=null,this._dividerDrags=[],this._createdRoot=!this.el;let e=this.el??l("div");this.el=e,this._snapshot=this._createdRoot?null:A(e),e.dataset.orientation=this._orientation,e.replaceChildren(),this._content=t.content==null?null:l("div",{class:"zx-dock__content",ref:"content"}),this._content&&lr(this._content,t.content,!1);for(let i of Array.isArray(t.panes)?t.panes:[])this._panes.set(String(i.name),this._buildPane(i));return this._layout(),e}pane(t){return this._panes.get(String(t))??null}names(){return[...this._panes.keys()]}add(t,e={}){let i=String(t?.name??"");if(!i)throw new TypeError("Dock pane requires a name");this._panes.has(i)&&this.remove(i);let n=this._buildPane(t),r=[...this._panes.entries()],o=Number.isInteger(e.index)?B(Number(e.index),0,r.length):r.length;return r.splice(o,0,[i,n]),this._panes=new Map(r),this._layout(),this._syncGrow(),this._syncDividers(),n}remove(t){let e=this._panes.get(String(t));return e?e.kind==="sheet"?this.release(e.sheet):(e.roving?.destroy(),e.element.remove(),this._panes.delete(String(t)),this._layout(),this._syncGrow(),this._syncDividers(),this):this}collapse(t){let e=this._panes.get(String(t));return!e||!e.collapsible||e.collapsed?this:(e.collapsed=!0,this._syncPaneState(e),this._syncGrow(),this._syncDividers(),this._persist(),this.emit("collapse",{name:e.name}),this)}expand(t){let e=this._panes.get(String(t));return!e||!e.collapsed?this:(e.collapsed=!1,this._syncPaneState(e),this._materialize(e),this._syncGrow(),this._syncDividers(),this._persist(),this.emit("expand",{name:e.name}),this)}toggle(t){let e=this._panes.get(String(t));return e?e.collapsed?this.expand(t):this.collapse(t):this}isCollapsed(t){return!!this._panes.get(String(t))?.collapsed}reveal(t){let e=String(t),i=this._panes.get(e);if(i)this.expand(e);else for(let n of this._panes.values())if(n.tabs?.has(e)){i=n,this.expand(n.name),this.activate(n.name,e);break}return i?(i.element.scrollIntoView({block:"nearest",inline:"nearest"}),this.emit("reveal",{name:i.name}),this):this}setSize(t,e){let i=this._panes.get(String(t));if(!i)return this;let n=ar(e);return n===null?i.element.style.removeProperty("--zx-pane-size"):i.element.style.setProperty("--zx-pane-size",n),this._syncDividers(),this._persist(),this}getSize(t){let e=this._panes.get(String(t));return e?this._axisSize(e.element):0}activate(t,e){let i=this._panes.get(String(t)),n=i?.tabs?.get(String(e));if(!n||i.active===n.name)return this;let r=i.active;i.active=n.name;for(let o of i.tabs.values()){let a=o===n;o.tab.setAttribute("aria-selected",String(a)),o.tab.tabIndex=a?0:-1,o.panel.hidden=!a}return this._materialize(i),this._persist(),this.emit("tabchange",{pane:i.name,tab:n.name,previous:r}),this}getActive(t){return this._panes.get(String(t))?.active??null}state(){let t={sizes:{},collapsed:[],active:{}};for(let e of this._panes.values())if(e.kind!=="sheet"){if(e.collapsed)t.collapsed.push(e.name);else if(!e.grow){let i=this._axisSize(e.element);i>0&&(t.sizes[e.name]=i)}e.active&&(t.active[e.name]=e.active)}return t}setState(t){if(!t||typeof t!="object")return this;let e=new Set(Array.isArray(t.collapsed)?t.collapsed.map(String):[]);for(let i of this._panes.values()){if(i.kind==="sheet")continue;let n=t.sizes?.[i.name];typeof n=="number"&&Number.isFinite(n)&&n>0&&i.element.style.setProperty("--zx-pane-size",`${n}px`);let r=t.active?.[i.name];r&&i.tabs?.has(String(r))&&this.activate(i.name,String(r));let o=e.has(i.name);o!==i.collapsed&&i.collapsible&&(i.collapsed=o,this._syncPaneState(i))}return this._syncGrow(),this._syncDividers(),this}destroy(){if(!this._destroyed){this._destroyed=!0;for(let t of this._dividerDrags)t.destroy();this._dividerDrags=[];for(let t of this._panes.values())t.roving?.destroy(),t.breakpoint?.destroy(),t.kind==="sheet"&&t.sheet._setDock(null);super.destroy(),!this._createdRoot&&this._snapshot&&S(this.el,this._snapshot)}}_buildPane(t){let e=String(t.name),i=String(t.title??""),n=t.collapsible??this.options.collapsible!==!1,r=x("zx-dock-body"),o=Array.isArray(t.tabs)&&t.tabs.length>0,a=l("span",{class:"zx-dock__chevron",ariaHidden:"true"},g("chevron-right",{size:14})),c=l("button",{class:"zx-dock__toggle",type:"button",ariaControls:r,ariaExpanded:"true",ariaLabel:o?i||e:null},a,o?null:l("span",{class:"zx-dock__title"},i));n||(c.disabled=!0);let h=l("div",{class:"zx-dock__header"},c),u=l("div",{class:"zx-dock__body",id:r}),d=l("section",{class:"zx-dock__pane",dataset:{name:e,state:"open"}},h,u),p={name:e,title:i,element:d,header:h,body:u,toggle:c,collapsible:n,collapsed:!1,grow:!!t.grow,side:t.side==="end"?"end":"start",min:Number.isFinite(t.min)?Math.max(0,Number(t.min)):0,tabs:null,active:null,content:null,built:!1,roving:null};if(o){p.tabs=new Map;let _=l("div",{class:"zx-dock__tabs",role:"tablist",ariaOrientation:"horizontal",ariaLabel:i||e});for(let y of t.tabs){let v=String(y.name),k=x("zx-dock-tab"),z=x("zx-dock-panel"),E=l("button",{class:"zx-dock__tab",type:"button",role:"tab",id:k,ariaControls:z,ariaSelected:"false",tabindex:-1},String(y.title??v)),M=l("div",{class:"zx-dock__panel",role:"tabpanel",id:z,ariaLabelledby:k,tabindex:0,hidden:!0});_.append(E),u.append(M),p.tabs.set(v,{name:v,tab:E,panel:M,content:y.content,built:!1})}h.append(_),p.roving=Dt(_,".zx-dock__tab",{orientation:"horizontal"}),this.listen(_,"click",y=>{let v=y.target.closest?.(".zx-dock__tab");if(!v||!_.contains(v))return;let k=[...p.tabs.values()].find(z=>z.tab===v);k&&this.activate(p.name,k.name)});let b=String(t.active??""),w=p.tabs.has(b)?b:[...p.tabs.keys()][0];p.active=w;for(let y of p.tabs.values()){let v=y.name===w;y.tab.setAttribute("aria-selected",String(v)),y.tab.tabIndex=v?0:-1,y.panel.hidden=!v}}else p.content=l("div",{class:"zx-dock__pane-content"}),u.append(p.content),p.factory=t.content;let f=ar(t.size);return f!==null&&d.style.setProperty("--zx-pane-size",f),n&&this.listen(c,"click",()=>this.toggle(p.name)),t.collapsed&&n&&(p.collapsed=!0,this._syncPaneState(p)),(!this._lazy||!p.collapsed)&&this._materialize(p),p}_materialize(t){if(!t.collapsed){if(t.tabs){let e=t.tabs.get(t.active);if(!e||e.built)return;e.built=!0,lr(e.panel,e.content,!0);return}t.built||(t.built=!0,lr(t.content,t.factory,!0))}}_layout(){let t=[...this._panes.values()].filter(n=>n.kind!=="sheet"||n.sheet.isDocked()),e=this._content?[...t.filter(n=>n.side==="start"),this._content,...t.filter(n=>n.side==="end")]:t;for(let n of this._dividerDrags)n.destroy();this._dividerDrags=[];let i=[];e.forEach((n,r)=>{r>0&&i.push(this._divider()),i.push(n instanceof Element?n:n.element)}),this.el.replaceChildren(...i)}_divider(){let t=l("div",{class:"zx-dock__divider",role:"separator",tabindex:this._resizable?0:-1,ariaOrientation:this._orientation==="vertical"?"horizontal":"vertical",ariaLabel:String(this.options.label??"Resize panes")});return this._dividerDrags.push(ze(t,{orientation:this._orientation,disabled:()=>!this._resizable,onStart:()=>{let{before:e,after:i}=this._neighbours(t),n=this._resizeSubject(e,i);return n?(this._drag={subject:n,startSize:this._axisSize(n.element),oppositeStart:n.opposite?this._axisSize(n.opposite.element):0},this.el.dataset.dragging="true",!0):!1},onMove:e=>this._trackDelta(e),onEnd:(e,i)=>{i&&this._trackDelta(e),this._drag=null,delete this.el.dataset.dragging,i&&this._persist()},onStep:(e,i)=>this._stepDivider(t,e*(i?64:16)),onActivate:()=>{let{before:e}=this._neighbours(t);e?.collapsible&&this.toggle(e.name)}})),t}_isHidden(t){return t.kind==="sheet"?!t.sheet.isOpen():!!t.collapsed}adopt(t,e={}){if(!t||typeof t._setDock!="function"||!t.el)throw new TypeError("Dock.adopt expects a Sheet");let i=String(e.name??t.el.id??"")||x("zx-dock-sheet"),n={kind:"sheet",name:i,sheet:t,element:t.el,side:e.side==="end"?"end":"start",min:Number.isFinite(e.min)?Math.max(0,Number(e.min)):0,grow:!1,collapsed:!1,collapsible:!1,breakpoint:null,resync:null},r=[...this._panes.entries()],o=Number.isInteger(e.index)?B(Number(e.index),0,r.length):r.length;r.splice(o,0,[i,n]),this._panes=new Map(r);let a=ar(e.size);a!==null&&t.el.style.setProperty("--zx-pane-size",a),n.resync=()=>{this._syncGrow(),this._syncDividers()},t.on("open",n.resync),t.on("close",n.resync);let c=e.dockAt??null;return c?n.breakpoint=ri((h,u)=>{this._applyDockAt(n,Nn(c,u))},{target:this.el}):this._applyDockAt(n,!0),n}release(t){let e=[...this._panes.values()].find(i=>i.sheet===t);return e?(e.breakpoint?.destroy(),e.breakpoint=null,this._panes.delete(e.name),t.off("open",e.resync),t.off("close",e.resync),t.el.style.removeProperty("--zx-pane-size"),t._setDock(null),this._layout(),this._syncGrow(),this._syncDividers(),this):this}_forget(t){let e=[...this._panes.values()].find(i=>i.sheet===t);e&&(e.breakpoint?.destroy(),this._panes.delete(e.name),!this._destroyed&&(this._layout(),this._syncGrow(),this._syncDividers()))}_applyDockAt(t,e){t.sheet.isDocked()!==e&&(t.sheet._setDock(e?this:null),this._layout(),this._syncGrow(),this._syncDividers())}_syncGrow(){let t=[...this._panes.values()];for(let n of t)n.element.removeAttribute("data-grow");if(this._content)return;let e=t.filter(n=>!this._isHidden(n));if(e.length===0)return;let i=e.find(n=>n.grow);(i??e[e.length-1]).element.dataset.grow="true"}_syncDividers(){for(let t of this._dividers()){let{before:e,after:i}=this._neighbours(t),n=this._resizeSubject(e,i),r=this._resizable&&n!==null;if(t.toggleAttribute("data-disabled",!r),t.tabIndex=r?0:-1,!r){t.removeAttribute("aria-valuenow");continue}let o=this._axisSize(this.el);t.setAttribute("aria-valuenow",String(Math.round(this._axisSize(n.element)))),t.setAttribute("aria-valuemin",String(Math.round(this._minSize(n)))),t.setAttribute("aria-valuemax",String(Math.round(o))),t.setAttribute("aria-controls",n.element.id||Em(n.element))}}_syncPaneState(t){t.element.dataset.state=t.collapsed?"collapsed":"open",t.toggle.setAttribute("aria-expanded",String(!t.collapsed))}_dividers(){return[...this.el.querySelectorAll(":scope > .zx-dock__divider")]}_neighbours(t){let e=i=>{if(!i)return null;for(let n of this._panes.values())if(n.element===i)return n;return null};return{before:e(t.previousElementSibling),after:e(t.nextElementSibling)}}_resizeSubject(t,e){let i=n=>!!n&&!this._isHidden(n)&&n.element.dataset.grow!=="true";return i(t)?{element:t.element,record:t,sign:1,opposite:i(e)?e:null}:i(e)?{element:e.element,record:e,sign:-1,opposite:null}:null}_minSize(t){let i=(t.record.header??t.record.element.querySelector(".zx-dialog__header")??t.record.element).getBoundingClientRect(),n=this._orientation==="vertical"?i.height:i.width;return Math.max(t.record.min,n)}_axisSize(t){let e=t.getBoundingClientRect();return this._orientation==="vertical"?e.height:e.width}_trackDelta(t){if(!this._drag||this._destroyed)return;let{subject:e,startSize:i,oppositeStart:n}=this._drag,r=this._minSize(e),o=Math.max(r,i+t*e.sign);if(e.opposite){let a=this._minSize({record:e.opposite,element:e.opposite.element});o=Math.max(r,Math.min(o,i+n-a)),e.opposite.element.style.setProperty("--zx-pane-size",`${i+n-o}px`)}e.element.style.setProperty("--zx-pane-size",`${o}px`),this._syncDividers(),this.emit("resize",{name:e.record.name,size:o})}_stepDivider(t,e){let{before:i,after:n}=this._neighbours(t),r=this._resizeSubject(i,n);if(!r)return;let o=Math.max(this._minSize(r),this._axisSize(r.element)+e*r.sign);r.element.style.setProperty("--zx-pane-size",`${o}px`),this._syncDividers(),this._persist(),this.emit("resize",{name:r.record.name,size:o})}_persist(){let t=this.options.storageKey;!this._store||t===null||t===void 0||t===""||this._store.set(String(t),this.state())}};function Em(s){let t=x("zx-dock-pane");return s.id=t,t}function ar(s){return s==null||s===""?null:typeof s=="number"?Number.isFinite(s)?`${Math.max(0,s)}px`:null:String(s)}function lr(s,t,e){let i=e&&typeof t=="function"?t():t;if(i==null)return;if(typeof i=="string"||typeof i=="number"){s.append(document.createTextNode(String(i)));return}let n=i instanceof m?i.toElement():i;n&&typeof n.nodeType=="number"&&s.append(n)}var ms="44rem",Cc=/^\d+(?:\.\d+)?(?:px|rem)$/,hr=class extends m{static cssName="navigation-bar";static defaults={title:"",items:[],active:null,actions:[],overflow:!0,overflowBelow:ms,minVisible:0};constructor(t,e={}){super(t,e),this._overflow=new mt(this.refs.moreTrigger,{label:"More",icon:"dots",kind:"ghost",items:[],placement:"bottom-end"}),this._overflow.on("select",i=>{let n=this._find(String(i.detail.value));!n||n.definition.disabled||(this.setActive(n.definition.name),n.definition.onselect?.(n.definition.name,n.definition,this),n.definition.href&&globalThis.location?.assign(n.definition.href))}),this._syncOverflow(),this._observeWidth()}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._createdRoot=t,this._original=t?null:Om(e),this._cleaned=!1,this._items=[],this._activeName=null,this._tabMode=!1,this._overflow=null,this._observer=null,this._frame=0;let i=l("header",{class:"zx-navigation-bar__bar"},l("div",{class:"zx-navigation-bar__brand",ref:"title"}),l("nav",{class:"zx-navigation-bar__navigation",ariaLabel:"Primary navigation"},l("div",{class:"zx-navigation-bar__items",ref:"items"}),l("div",{class:"zx-navigation-bar__more",ref:"more"},l("button",{class:"zx-navigation-bar__more-trigger",ref:"moreTrigger"}))),l("div",{class:"zx-navigation-bar__actions",ref:"actions",role:"group",ariaLabel:"Application actions"})),n=l("div",{class:"zx-navigation-bar__panels",ref:"panels",hidden:!0});return e.replaceChildren(i,n),this.setTitle(this.options.title),this.setItems(this.options.items),this.setActions(this.options.actions),this.listen(this.refs.items,"keydown",r=>this._onTabKeydown(r)),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,i=new Set,n=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(i.has(h.name))throw new RangeError(`Navigation item already exists: ${h.name}`);if(i.add(h.name),Object.hasOwn(h,"content")&&!Nm(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}),r=n.some(h=>Object.hasOwn(h,"content"));if(r&&n.some(h=>!Object.hasOwn(h,"content")))throw new TypeError("NavigationBar panel items must all define content");this._items=[],this._activeName=null,this._tabMode=r,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 n)this._appendItem(h);let o=e??this.options.active,a=o===null?null:this._find(o),c=a&&!a.definition.disabled?a: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 i=this._require(t);return i.definition.badge=e===null?null:String(e),i.badge.textContent=i.definition.badge??"",i.badge.hidden=i.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(i=>{if(T(i))return i;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("NavigationBar actions must be Elements or button descriptors");let n={...i},r=n.onclick;delete n.onclick;let o=j(n);return typeof r=="function"&&this.listen(o,"click",r),o});return this.refs.actions.replaceChildren(...e),this}destroy(){this._cleaned||(this._cleaned=!0,this._frame&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this._frame),this._frame=0,this._observer?.disconnect(),this._observer=null,this._overflow?.destroy(),super.destroy(),!this._createdRoot&&this._original&&Fm(this.el,this._original))}_appendItem(t){let e=x("zx-navigation-item"),i=x("zx-navigation-panel"),n=l("span",{class:"zx-navigation-bar__badge",hidden:t.badge===null},t.badge??""),r={class:"zx-navigation-bar__item",id:e,ariaDisabled:t.disabled?"true":null},o;this._tabMode?o=l("button",{...r,type:"button",role:"tab",tabindex:"-1",ariaControls:i,ariaSelected:"false"},l("span",{class:"zx-navigation-bar__label"},t.title),n):t.href?o=l("a",{...r,href:t.href},l("span",{class:"zx-navigation-bar__label"},t.title),n):o=l("button",{...r,type:"button"},l("span",{class:"zx-navigation-bar__label"},t.title),n);let a=null;this._tabMode&&(a=l("div",{class:"zx-navigation-bar__panel",id:i,role:"tabpanel",tabindex:"0",ariaLabelledby:e,hidden:!0}),this.refs.panels.append(a));let c={definition:t,item:o,badge:n,panel:a,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 i=e===t;this._tabMode?(e.item.setAttribute("aria-selected",String(i)),e.item.tabIndex=i?0:-1,e.panel&&(e.panel.hidden=!i)):i?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,i=typeof e=="function"?e():e,n=i instanceof m?i.toElement():i;if(!n||typeof n.nodeType!="number")throw new TypeError(`Navigation panel factory for ${t.definition.name} must return a Node or Component`);t.panel.append(n),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 i=this._items.find(r=>r.item===e);if(!i)return;let n=this._enabledItems();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let r=t.key==="ArrowRight"?1:-1,o=n.indexOf(i),a=n[(o+r+n.length)%n.length];a&&this._focusTab(a);return}if(t.key==="Home"||t.key==="End"){t.preventDefault();let r=t.key==="Home"?n[0]:n[n.length-1];r&&this._focusTab(r);return}(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.setActive(i.definition.name))}_syncOverflow(){let t=zc(this.options),e=t===null?this._items.length:Dm(this.options,this._items.length),i=this._items.slice(e),n=this.el;for(let[r,o]of this._items.entries())o.item.dataset.collapsed=String(r>=e);n.dataset.overflow=t===null?"off":e===0?"all":"partial",t===null||t===ms?delete n.dataset.overflowBelow:n.dataset.overflowBelow=t,this._overflow&&(this.refs.more.dataset.empty=i.length===0?"true":"false",this._overflow.setItems(i.map(r=>({label:r.definition.badge===null?r.definition.title:`${r.definition.title} (${r.definition.badge})`,value:r.definition.name,disabled:r.definition.disabled}))))}_observeWidth(){let t=zc(this.options);if(t===null||t===ms||typeof ResizeObserver!="function")return;let e=this.el,i=()=>{let n=e.getBoundingClientRect().width;if(!n)return;let r=globalThis.document?.documentElement,o=r?Number.parseFloat(globalThis.getComputedStyle(r).fontSize):Number.NaN;e.dataset.narrow=String(n<=Mm(t,o))};this._observer=new ResizeObserver(()=>{if(this._frame||typeof requestAnimationFrame!="function"){typeof requestAnimationFrame!="function"&&i();return}this._frame=requestAnimationFrame(()=>{this._frame=0,i()})}),this._observer.observe(e),i()}_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 zc(s={}){let t=s.overflow??!0;if(typeof t!="boolean")throw new TypeError("NavigationBar overflow must be a boolean");let e=s.overflowBelow??ms;if(!t||e===!1)return null;if(typeof e=="number"){if(!Number.isFinite(e)||e<0)throw new RangeError(`NavigationBar overflowBelow must not be negative: ${e}`);return`${e}px`}if(typeof e!="string"||!Cc.test(e.trim()))throw new TypeError(`NavigationBar overflowBelow must be a px or rem length, a number of pixels, or false: ${String(e)}`);return e.trim()}function Dm(s={},t=0){let e=s.minVisible??0;if(!Number.isInteger(e)||e<0)throw new TypeError(`NavigationBar minVisible must be a non-negative integer: ${String(e)}`);let i=Number.isInteger(t)&&t>0?t:0;return Math.min(e,i)}function Mm(s,t=16){let e=typeof s=="number"?`${s}px`:String(s).trim();if(!Cc.test(e))throw new TypeError(`NavigationBar cannot measure the length "${String(s)}"`);let i=Number.parseFloat(e);if(!e.endsWith("rem"))return i;let n=Number(t);return i*(Number.isFinite(n)&&n>0?n:16)}function Nm(s){return typeof s=="function"||s instanceof m?!0:!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Om(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Fm(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}function Ic(s){if(!Array.isArray(s))throw new TypeError("Stepper steps must be an array");let t=new Set;return s.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Step definition must be an object");if(typeof e.name!="string"||e.name==="")throw new TypeError("Step name must be a non-empty string");if(t.has(e.name))throw new RangeError(`Step already exists: ${e.name}`);return t.add(e.name),{name:e.name,title:String(e.title??""),description:e.description==null?null:String(e.description),optional:!!e.optional,disabled:!!e.disabled}})}function gs(s,t){return t===null?-1:s.findIndex(e=>e.name===t)}function bs(s,t,e){let i=e<0?-1:1,n=t<0?i>0?0:s.length-1:t+i;for(;n>=0&&n<s.length;){if(!s[n].disabled)return n;n+=i}return-1}function Ec(s,t,e){return t<0||e<=t?[]:s.slice(t,e).map(i=>i.name)}function Dc(s,t,e={}){let{activeIndex:i=-1,completed:n,errored:r}=e;return Tc(r,s.name)?"error":t===i?"active":Tc(n,s.name)?"complete":"upcoming"}function Tc(s,t){return s?s instanceof Set?s.has(t):s.includes(t):!1}var Lm=new Set(["horizontal","vertical"]),Rm=new Set(["completed","all",!1]),ur=class extends m{static cssName="stepper";static defaults={steps:[],active:null,orientation:"horizontal",clickable:"completed",showNumbers:!0,counter:!1};constructor(t,e={}){super(t,e)}render(){if(this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._steps=[],this._records=[],this._activeIndex=-1,this._completed=new Set,this._errored=new Set,!Lm.has(this.options.orientation))throw new RangeError(`Unknown stepper orientation: ${this.options.orientation}`);if(!Rm.has(this.options.clickable))throw new RangeError(`Unknown stepper clickable mode: ${this.options.clickable}`);let t=this.el??l("div");this.el=t,t.dataset.orientation=this.options.orientation;let e=l("p",{class:"zx-stepper__counter",ref:"counter",ariaLive:"polite",hidden:!0}),i=l("ol",{class:"zx-stepper__list",ref:"list"});return t.replaceChildren(...this.options.counter?[e,i]:[i]),this.setSteps(this.options.steps),this.listen(i,"click",n=>{let r=n.target.closest?.(".zx-stepper__control");if(!r||!i.contains(r)||r.tagName!=="BUTTON")return;let o=r.dataset.step;typeof o=="string"&&this.goTo(o)}),t}setSteps(t){let e=this.getActive(),i=Ic(t),n=new Set(i.map(a=>a.name));this._steps=i,this._completed=new Set([...this._completed].filter(a=>n.has(a))),this._errored=new Set([...this._errored].filter(a=>n.has(a)));let r=e??(this.options.active===null?null:String(this.options.active)),o=r===null?-1:gs(i,r);return o>=0&&i[o].disabled&&(o=-1),o<0&&(o=bs(i,-1,1)),this._activeIndex=o,this._records=i.map(a=>this._createRecord(a)),this.refs.list.replaceChildren(...this._records.map(a=>a.item)),this._sync(),this}goTo(t){let e=gs(this._steps,t);if(e<0)throw new RangeError(`Unknown step: ${t}`);return this._activate(e)}next(){return this._activate(bs(this._steps,this._activeIndex,1))}previous(){return this._activate(bs(this._steps,this._activeIndex,-1))}getActive(){return this._activeIndex<0?null:this._steps[this._activeIndex].name}getIndex(){return this._activeIndex}complete(t){return this._require(t),this._completed.add(t),this._sync(),this}uncomplete(t){return this._require(t),this._completed.delete(t),this._sync(),this}setError(t,e=!0){return this._require(t),e?this._errored.add(t):this._errored.delete(t),this._sync(),this}setDisabled(t,e=!0){return this._require(t).disabled=!!e,this._sync(),this}getState(){return{active:this.getActive(),index:this._activeIndex,completed:this._steps.filter(t=>this._completed.has(t.name)).map(t=>t.name),errored:this._steps.filter(t=>this._errored.has(t.name)).map(t=>t.name)}}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_activate(t){if(t<0||t>=this._steps.length||t===this._activeIndex)return this;let e=this._steps[t];if(e.disabled)return this;let i=this._activeIndex;if(this.emit("change",{name:e.name,previous:i<0?null:this._steps[i].name,index:t}).defaultPrevented)return this;for(let r of Ec(this._steps,i,t))this._completed.add(r);return this._activeIndex=t,this._sync(),this}_createRecord(t){let e=l("span",{class:"zx-stepper__marker",ariaHidden:"true"}),i=l("span",{class:"zx-stepper__status"}),n=[l("span",{class:"zx-stepper__title"},t.title)];t.description&&n.push(l("span",{class:"zx-stepper__description"},t.description)),t.optional&&n.push(l("span",{class:"zx-stepper__optional"},this._message("stepper.optional","Optional")));let r=[e,l("span",{class:"zx-stepper__text"},n),i],o=this.options.clickable===!1?l("span",{class:"zx-stepper__control"},r):l("button",{class:"zx-stepper__control",type:"button",dataset:{step:t.name}},r);return{step:t,item:l("li",{class:"zx-stepper__step"},o),control:o,marker:e,status:i}}_sync(){this._records.forEach((t,e)=>{let i=this._stateFor(t.step,e);t.item.dataset.state=i,e===this._activeIndex?t.item.setAttribute("aria-current","step"):t.item.removeAttribute("aria-current"),t.item.toggleAttribute("data-disabled",t.step.disabled),t.marker.replaceChildren(...this._markerContent(i,e)),t.status.textContent=this._statusText(i),t.control.tagName==="BUTTON"&&(t.control.disabled=!this._isClickable(t.step))}),this._syncCounter()}_stateFor(t,e){return Dc(t,e,{activeIndex:this._activeIndex,completed:this._completed,errored:this._errored})}_markerContent(t,e){return t==="complete"?[g("check",{size:12})]:t==="error"?[g("warning",{size:12})]:this.options.showNumbers?[String(e+1)]:[]}_statusText(t){return t==="complete"?this._message("stepper.completed","Completed"):t==="error"?this._message("stepper.error","Error"):t==="active"?this._message("stepper.current","Current step"):""}_isClickable(t){return t.disabled?!1:this.options.clickable==="all"?!0:this.options.clickable==="completed"?this._completed.has(t.name):!1}_syncCounter(){if(!this.options.counter)return;let t=this.refs.counter;t.hidden=this._activeIndex<0,t.textContent=this._activeIndex<0?"":this._message("stepper.counter","Step %1 of %2",this._activeIndex+1,this._steps.length)}_require(t){let e=gs(this._steps,t);if(e<0)throw new RangeError(`Unknown step: ${t}`);return this._steps[e]}_message(t,e,...i){let n=this.msg(t,...i);return n===t?I(e,i):n}};var Vm=new Set(["chevron","slash"]),dr=class extends m{static cssName="breadcrumb";static defaults={items:[],maxVisible:0,separator:"chevron",rootIcon:null};constructor(t,e={}){super(t,e)}render(){if(this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._items=[],this._overflow=null,!Vm.has(this.options.separator))throw new RangeError(`Unknown breadcrumb separator: ${this.options.separator}`);let t=this.el??l("nav");this.el=t,t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.setAttribute("aria-label",this._message("breadcrumb.label","Breadcrumb"));let e=l("ol",{class:"zx-breadcrumb__list",ref:"list"});return t.replaceChildren(e),this.setItems(this.options.items),this.listen(e,"click",i=>{let n=i.target.closest?.("[data-crumb]");!n||!e.contains(n)||this._select(n.dataset.crumb)}),t}setItems(t){if(!Array.isArray(t))throw new TypeError("Breadcrumb items must be an array");let e=new Set;return this._items=t.map(i=>{if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Breadcrumb item must be an object");if(typeof i.name!="string"||i.name==="")throw new TypeError("Breadcrumb item name must be a non-empty string");if(e.has(i.name))throw new RangeError(`Breadcrumb item already exists: ${i.name}`);return e.add(i.name),{name:i.name,label:String(i.label??""),icon:i.icon?String(i.icon):null,href:i.href==null?null:String(i.href)}}),this._build(),this}getItems(){return this._items.map(t=>({...t}))}push(t){return this.setItems([...this._items,t])}pop(){if(this._items.length===0)return null;let t=this._items[this._items.length-1];return this.setItems(this._items.slice(0,-1)),t}truncateTo(t){let e=this._items.findIndex(i=>i.name===t);if(e<0)throw new RangeError(`Unknown breadcrumb item: ${t}`);return this.setItems(this._items.slice(0,e+1))}destroy(){if(this._destroyed)return;this._destroyed=!0,this._overflow?.destroy(),this._overflow=null;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_build(){let{head:t,hidden:e,tail:i}=this._split(),n=this._items[this._items.length-1]??null,r=[];for(let o of t)r.push(this._renderItem(o,o===n));e.length>0&&r.push(this._renderOverflow(e));for(let o of i)r.push(this._renderItem(o,o===n));this.refs.list.replaceChildren(...r.map((o,a)=>l("li",{class:"zx-breadcrumb__item"},a===0?o:[this._renderSeparator(),o]))),e.length===0&&this._overflow?.toElement().remove()}_split(){let t=this._items,e=Math.trunc(Number(this.options.maxVisible)||0);if(e<=0||t.length<=e)return{head:t,hidden:[],tail:[]};let i=Math.max(2,e);if(t.length<=i)return{head:t,hidden:[],tail:[]};let n=i-1;return{head:t.slice(0,1),hidden:t.slice(1,t.length-n),tail:t.slice(t.length-n)}}_renderItem(t,e){let i=[],n=t.icon??(t===this._items[0]?this.options.rootIcon:null);return n&&i.push(l("span",{class:"zx-breadcrumb__icon",ariaHidden:"true"},g(String(n),{size:13}))),i.push(l("span",{class:"zx-breadcrumb__label"},t.label)),e?l("span",{class:"zx-breadcrumb__current",ariaCurrent:"page"},i):t.href!==null?l("a",{class:"zx-breadcrumb__link",href:t.href,dataset:{crumb:t.name}},i):l("button",{class:"zx-breadcrumb__link",type:"button",dataset:{crumb:t.name}},i)}_renderOverflow(t){if(!this._overflow){this._overflow=new mt(null,{label:"",icon:"dots",kind:"ghost",placement:"bottom-start"});let e=this._overflow.toElement();e.classList.add("zx-breadcrumb__more"),e.setAttribute("aria-label",this._message("breadcrumb.more","Show hidden levels")),this._overflow.on("select",i=>this._select(String(i.detail.value)))}return this._overflow.setItems(t.map(e=>({label:e.label,value:e.name,icon:e.icon??void 0}))),this._overflow.toElement()}_renderSeparator(){return l("span",{class:"zx-breadcrumb__separator",ariaHidden:"true"},this.options.separator==="slash"?"/":g("chevron-right",{size:11}))}_select(t){let e=this._items.findIndex(i=>i.name===t);e<0||this.emit("select",{name:this._items[e].name,item:{...this._items[e]},index:e})}_message(t,e,...i){let n=this.msg(t,...i);return n===t?I(e,i):n}};var ws="\u2026",Pm=new Set(["pages","loadmore"]);function Mc({page:s=1,pages:t=1,siblings:e=1,boundaries:i=1}={}){let n=ae(t);if(n<=0)return[];let r=_r(ae(s)||1,1,n),o=Math.max(0,ae(e)),a=Math.max(0,ae(i)),c=a*2+o*2+3;if(n<=c)return ys(1,n);let h=ys(1,Math.min(a,n)),u=ys(Math.max(n-a+1,a+1),n),d=Math.max(Math.min(r-o,n-a-o*2-1),a+2),p=Math.min(Math.max(r+o,a+o*2+2),u.length>0?u[0]-2:n-1);return[...h,...d>a+2?[ws]:a+1<n-a?[a+1]:[],...ys(d,p),...p<n-a-1?[ws]:n-a>a?[n-a]:[],...u]}var pr=class extends m{static cssName="pagination";static defaults={page:1,pageSize:25,total:0,pageSizes:[25,50,100],siblings:1,boundaries:1,showPageSize:!0,showSummary:!0,mode:"pages",disabled:!1};constructor(t,e={}){super(t,e)}render(){if(this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._pageSize=fr(this.options.pageSize,25),this._total=Math.max(0,ae(this.options.total)),this._page=Math.max(1,ae(this.options.page)||1),this._disabled=!!this.options.disabled,this._sizeKey="",this._pageSizes=(Array.isArray(this.options.pageSizes)?this.options.pageSizes:[]).map(i=>fr(i,0)).filter(i=>i>0),!Pm.has(this.options.mode))throw new RangeError(`Unknown pagination mode: ${this.options.mode}`);this._page=_r(this._page,1,this._pageCount());let t=this.el??l("nav");this.el=t,t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.setAttribute("aria-label",this._message("pagination.label","Pagination")),t.dataset.mode=this.options.mode;let e=[];return this.options.showSummary&&e.push(l("span",{class:"zx-pagination__summary",ref:"summary",ariaLive:"polite"})),e.push(l("span",{class:"zx-pagination__spacer"})),this.options.showPageSize&&e.push(this._renderPageSize()),e.push(this.options.mode==="pages"?this._renderPages():this._renderLoadMore()),t.replaceChildren(...e),this._sync(),this._wire(),t}setPage(t){return this.setState({page:t})}setTotal(t){return this.setState({total:t},{silent:!0})}setPageSize(t){return this.setState({pageSize:t,page:1})}setState(t={},{silent:e=!1}={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Pagination state must be an object");let i=this._page,n=this._pageSize;if(Object.hasOwn(t,"total")&&(this._total=Math.max(0,ae(t.total))),Object.hasOwn(t,"pageSize")&&(this._pageSize=fr(t.pageSize,this._pageSize)),Object.hasOwn(t,"page")){let r=Math.trunc(Number(t.page));Number.isFinite(r)&&(this._page=r)}return this._page=_r(this._page,1,this._pageCount()),this._sync(),!e&&(this._page!==i||this._pageSize!==n)&&this.emit("change",this.getState()),this}getState(){let t=this._pageCount();return{page:this._page,pageSize:this._pageSize,total:this._total,pages:t,offset:(this._page-1)*this._pageSize}}enable(){return this._disabled=!1,this._sync(),this}disable(){return this._disabled=!0,this._sync(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_pageCount(){return this._total<=0?1:Math.ceil(this._total/this._pageSize)}_renderPageSize(){let t=this._message("pagination.pageSize","Rows per page");return l("label",{class:"zx-pagination__size"},l("span",{class:"zx-pagination__size-label"},t),l("select",{class:"zx-pagination__select",ref:"select",ariaLabel:t}))}_renderPages(){return l("div",{class:"zx-pagination__controls"},this._navButton("prev","chevron-left",this._message("pagination.previous","Previous page")),l("div",{class:"zx-pagination__pages",ref:"pages"}),this._navButton("next","chevron-right",this._message("pagination.next","Next page")))}_navButton(t,e,i){return l("button",{class:"zx-btn zx-pagination__nav",type:"button",ref:t,ariaLabel:i,dataset:{kind:"default",size:"sm"}},g(e,{size:14}))}_renderLoadMore(){return l("button",{class:"zx-btn zx-pagination__more",type:"button",ref:"more",dataset:{kind:"default",size:"md"}},l("span",{class:"zx-btn__label"},this._message("pagination.loadMore","Load more")))}_wire(){if(this.refs.select&&this.listen(this.refs.select,"change",()=>{this.setPageSize(Number(this.refs.select.value))}),this.options.mode==="pages"){this.listen(this.refs.prev,"click",()=>this.setPage(this._page-1)),this.listen(this.refs.next,"click",()=>this.setPage(this._page+1)),this.listen(this.refs.pages,"click",t=>{let e=t.target.closest?.("[data-page]");!e||!this.refs.pages.contains(e)||this.setPage(Number(e.dataset.page))});return}this.listen(this.refs.more,"click",()=>this.setPage(this._page+1))}_sync(){let t=this._pageCount();if(this.el.dataset.disabled=this._disabled?"true":"false",this.refs.summary&&(this.refs.summary.textContent=this._summary()),this.refs.select&&this._syncPageSize(),this.options.mode==="pages"){this.refs.prev.disabled=this._disabled||this._page<=1,this.refs.next.disabled=this._disabled||this._page>=t,this._syncPages(t);return}this.refs.more.disabled=this._disabled||this._page>=t}_summary(){if(this._total<=0)return this._message("pagination.empty","0 of 0");let t=(this._page-1)*this._pageSize,e=Math.min(t+this._pageSize,this._total);return this.options.mode==="loadmore"?this._message("pagination.loaded","%1 of %2",xi(e),xi(this._total)):this._message("pagination.summary","%1\u2013%2 of %3",xi(t+1),xi(e),xi(this._total))}_syncPageSize(){let t=this.refs.select,e=[...new Set([...this._pageSizes,this._pageSize])].sort((n,r)=>n-r),i=e.join(",");i!==this._sizeKey&&(this._sizeKey=i,t.replaceChildren(...e.map(n=>l("option",{value:String(n)},String(n))))),t.value=String(this._pageSize),t.disabled=this._disabled}_syncPages(t){let e=this.refs.pages,i=this.el.ownerDocument?.activeElement??null,n=i&&e.contains(i)?i.dataset.page??null:null,r=Mc({page:this._page,pages:t,siblings:this.options.siblings,boundaries:this.options.boundaries});if(e.replaceChildren(...r.map(a=>a===ws?l("span",{class:"zx-pagination__ellipsis",ariaHidden:"true"},ws):l("button",{class:"zx-btn zx-pagination__page",type:"button",disabled:this._disabled,ariaCurrent:a===this._page?"page":null,ariaLabel:this._message("pagination.page","Page %1",a),dataset:{kind:"default",size:"sm",page:String(a)}},String(a)))),n===null)return;let o=e.querySelector(`[data-page="${n}"]`);o&&!o.disabled&&o.focus()}_message(t,e,...i){let n=this.msg(t,...i);return n===t?I(e,i):n}};function ae(s){let t=Math.trunc(Number(s));return Number.isFinite(t)&&t>0?t:0}function fr(s,t){let e=Math.trunc(Number(s));return Number.isFinite(e)&&e>0?e:t}function _r(s,t,e){return Math.min(Math.max(s,t),e)}function ys(s,t){return t<s?[]:Array.from({length:t-s+1},(e,i)=>s+i)}function xi(s){return s.toLocaleString()}var xs=class extends m{static cssName="app-icon";static defaults={icon:null,color:null,size:36,iconSize:"52%",label:null,badge:null,selected:!1,shape:"tile",glass:"subtle",class:[]};render(){this._createdRoot=this.el===null;let t=this.el??l("span");return this.el=t,this._snapshot=this._createdRoot?null:A(t),this._interactiveRoot=t.matches('a[href], button, input, select, textarea, [role="button"], [role="link"]'),this._state={...this.options},this._appliedClasses=[],this._sync(),t}set(t={}){return!t||typeof t!="object"?this:(Object.assign(this._state,t),this._sync(),this)}destroy(){let t=this.el,e=this._snapshot;super.destroy(),!this._createdRoot&&t&&S(t,e)}_sync(){let t=this._state;this.el.classList.remove(...this._appliedClasses),this._appliedClasses=[t.class].flat().flatMap(h=>String(h??"").split(/\s+/)).filter(Boolean),this.el.classList.add(...this._appliedClasses);let e=Nc(t.size,"36px"),i=Nc(t.iconSize,"52%");this.el.style.setProperty("--zx-app-icon-size",e),this.el.style.setProperty("--zx-app-icon-glyph-size",i),Ht(t.color)?this.el.style.setProperty("--zx-app-icon-color",String(t.color)):this.el.style.removeProperty("--zx-app-icon-color"),this.el.dataset.glass=Hm(t.glass),this.el.dataset.shape=qm(t.shape),this.el.toggleAttribute("data-selected",!!t.selected);let n=t.label==null?"":String(t.label).trim();if(this._interactiveRoot){let h=Oc(this._snapshot,"role"),u=Oc(this._snapshot,"aria-label");h===null?this.el.removeAttribute("role"):this.el.setAttribute("role",h),n?this.el.setAttribute("aria-label",n):u===null?this.el.removeAttribute("aria-label"):this.el.setAttribute("aria-label",u),this.el.removeAttribute("aria-hidden")}else n?(this.el.setAttribute("role","img"),this.el.setAttribute("aria-label",n),this.el.removeAttribute("aria-hidden")):(this.el.removeAttribute("role"),this.el.removeAttribute("aria-label"),this.el.setAttribute("aria-hidden","true"));let r=jm(t.icon),o=t.badge==null||t.badge===""?null:l("span",{class:"zx-app-icon__badge",ariaHidden:"true"},String(t.badge)),c=[l("span",{class:"zx-app-icon__surface",ariaHidden:"true"},l("span",{class:"zx-app-icon__shine",ariaHidden:"true"}),l("span",{class:"zx-app-icon__glyph",ariaHidden:"true"},r))];o&&c.push(o),this.el.replaceChildren(...c)}};function Bm(s={}){return new xs(null,s).toElement()}function jm(s){let t=typeof s=="function"?s():s;return typeof t=="string"?g(t,{size:"1em"}):t&&typeof t=="object"&&typeof t.nodeType=="number"?t:null}function Nc(s,t){if(typeof s=="number"&&Number.isFinite(s))return`${Math.max(1,s)}px`;let e=String(s??"").trim();return e&&!/[;{}]/.test(e)?e:t}function Hm(s){return s===!1||s==="none"?"none":s==="strong"?"strong":"subtle"}function qm(s){return s==="circle"?"circle":"tile"}function Oc(s,t){return s?.attributes.find(([e])=>e===t)?.[1]??null}var gr=class extends m{static cssName="launcher";static defaults={items:[],sources:[],query:"",debounce:250,minQuery:0,maxResults:100,placeholder:null,label:null,closeLabel:null,resultsLabel:null,emptyText:null,loadingText:null,shortcut:"mod+k",hints:null,scope:null};constructor(t=null,e={}){super(t,e)}render(){if(this.el!==null&&!(this.el instanceof HTMLDialogElement))throw new TypeError("Launcher target must be a <dialog> element");this._createdRoot=this.el===null;let t=this.el??l("dialog");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,u=>[u.name,u.value]),children:Array.from(t.childNodes)},this._items=mr(this.options.items),this._sources=Lc(this.options.sources),this._sourceItems=new Map,this._query=String(this.options.query??""),this._renderedQuery=null,this._results=[],this._active=-1,this._request=null,this._requestSequence=0,this._queryTimer=null,this._busy=!1,this._destroyed=!1;let e=x("zx-launcher-results"),i=String(this.options.label??this._message("launcher.label","Launcher")),n=l("input",{ref:"input",class:"zx-launcher__input",type:"search",role:"combobox",autocomplete:"off",spellcheck:!1,ariaAutocomplete:"list",ariaControls:e,ariaExpanded:"false",ariaLabel:i,placeholder:this.options.placeholder??this._message("launcher.placeholder","Search applications and records"),value:this._query}),r=l("button",{ref:"close",class:"zx-icon-btn zx-launcher__close",type:"button",ariaLabel:this.options.closeLabel??this._message("launcher.close","Close launcher")},g("x")),o=l("div",{ref:"status",class:"zx-launcher__status",role:"status",ariaLive:"polite"}),a=l("div",{ref:"results",class:"zx-launcher__results",id:e,role:"listbox",ariaLabel:this.options.resultsLabel??this._message("launcher.results","Launcher results")}),c=this.options.shortcut==="mod+k"?l("kbd",{class:"zx-launcher__shortcut",ariaHidden:"true"},$m()):null,h=Km(this.options.hints,{move:this._message("launcher.hintMove","Move"),open:this._message("launcher.hintOpen","Open"),close:this._message("launcher.hintClose","Close")});return t.setAttribute("aria-label",i),t.replaceChildren(l("div",{class:"zx-launcher__surface"},l("div",{class:"zx-launcher__search",dataset:{shortcut:c?"true":"false"}},g("search"),n,c,r),o,a,h)),t.dataset.state="closed",this._createdRoot&&rt(this.options.scope).append(t),this.listen(n,"input",()=>{this._query=n.value,this.emit("query",{query:this._query.trim()}),this._refresh()}),this.listen(n,"keydown",u=>this._onKeydown(u)),this.listen(r,"click",()=>this.close()),this.listen(a,"click",u=>{let d=u.target?.closest?.("[data-launcher-index]");!d||!a.contains(d)||this._activate(Number(d.getAttribute("data-launcher-index")),u)}),this.listen(a,"pointermove",u=>{let d=u.target?.closest?.("[data-launcher-index]");if(!d||!a.contains(d))return;let p=Number(d.getAttribute("data-launcher-index"));!Number.isInteger(p)||this._results[p]?.disabled||p===this._active||(this._active=p,this._syncActive())}),this.listen(t,"cancel",u=>{u.preventDefault(),this.close()}),this.listen(t,"close",()=>{t.dataset.state="closed",n.setAttribute("aria-expanded","false"),this._abortRequest(),this.emit("close")}),this.listen(document,"keydown",u=>this._onDocumentKeydown(u)),this._renderResults(),t}open(){if(this.isOpen()||this._destroyed)return this;if(this._createdRoot){let t=rt(this.options.scope);this.el.parentElement!==t&&t.append(this.el)}return this.el.showModal(),this.el.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this._refresh(),queueMicrotask(()=>{this.isOpen()&&(this.refs.input.focus(),this.refs.input.select())}),this.emit("open"),this}close(){return this.isOpen()&&this.el.close(),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return!!this.el.open}focus(){return this.refs.input.focus(),this.refs.input.select(),this}setQuery(t){return this._query=String(t??""),this.refs.input.value=this._query,this.emit("query",{query:this._query.trim()}),this._refresh(),this}getQuery(){return this._query}setItems(t){return this._items=mr(t),this._renderResults(),this}setCurrent(t){let e=t==null?null:String(t);return this._items=this._items.map(i=>({...i,current:e!==null&&String(i.id)===e})),this._renderResults(),this}setSources(t){return this._abortRequest(),this._sources=Lc(t),this._sourceItems.clear(),this._refresh(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this._original;if(this._abortRequest(),this.isOpen()&&this.el.close(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_refresh(){if(this._sourceItems.clear(),this._renderResults(),this._abortRequest(),this._sources.length===0)return;let t=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>this._loadSources(),t)}async _loadSources(){this._queryTimer=null;let t=this._query.trim(),e=this._sources.filter(r=>vs(r.when,t)&&t.length>=Math.max(Number(this.options.minQuery)||0,Number(r.minQuery)||0));if(e.length===0)return;let i=new AbortController,n=++this._requestSequence;this._request=i,this._setBusy(!0),await Promise.all(e.map(async r=>{try{let o=await r.load(t,{signal:i.signal});if(i.signal.aborted||n!==this._requestSequence)return;this._sourceItems.set(r.id,mr(o).map((a,c)=>({...a,_source:r.id,_sourceOrder:r.order==="source",group:a.group??r.label??"",itemOrder:a.itemOrder??(r.order==="source"?c:void 0)}))),this._renderResults()}catch(o){if(i.signal.aborted||n!==this._requestSequence)return;this.emit("error",{source:r,error:o})}})),!(i.signal.aborted||n!==this._requestSequence)&&(this._request=null,this._setBusy(!1))}_setBusy(t){this._busy=t,this.el.setAttribute("aria-busy",String(t)),this._renderStatus()}_abortRequest(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._request?.abort(),this._request=null,this._requestSequence+=1,this._busy&&this._setBusy(!1)}_renderResults(){let t=this._query,e=this._renderedQuery===t&&this._active>=0&&this._results[this._active]?String(this._results[this._active].id):null,i=this._query.trim(),n=this._items.filter(f=>vs(f.when,i)),r=br(n,i,this.options.maxResults),o=this._sources.flatMap(f=>{let _=this._sourceItems.get(String(f.id))??[];return f.order==="source"?_.filter(b=>vs(b.when,i)):br(_.filter(b=>vs(b.when,i)),i,this.options.maxResults)}),a=new Set,c=[...r.map(f=>({...f,_source:null})),...o].filter(f=>{let _=String(f.id);return a.has(_)?!1:(a.add(_),!0)}).slice(0,Math.max(0,Number(this.options.maxResults)||0)),h=new Map;for(let f of c){let _=String(f.group??"");h.has(_)||h.set(_,[]),h.get(_).push(f)}this._results=[...h.values()].flat(),this._renderedQuery=t;let u=e===null?-1:this._results.findIndex(f=>!f.disabled&&String(f.id)===e);this._active=u>=0?u:this._results.findIndex(f=>!f.disabled);let d=[],p=0;for(let[f,_]of h){let b=_.map(w=>this._option(w,p++));f?d.push(l("div",{class:"zx-launcher__group",role:"group",ariaLabel:f,dataset:{layout:_.every(w=>w.kind==="application")?"grid":"list"}},l("div",{class:"zx-launcher__group-label",ariaHidden:"true"},f),b)):d.push(...b)}this.refs.results.replaceChildren(...d),this._syncActive(),this._renderStatus()}_option(t,e){let i=V(t.href),n=i?"a":"button",r=[],o=Um(t);return o&&r.push(l("span",{class:"zx-launcher__icon",ariaHidden:"true"},o)),r.push(l("span",{class:"zx-launcher__copy"},l("span",{class:"zx-launcher__label"},t.label),t.description?l("span",{class:"zx-launcher__description"},t.description):null)),t.badge!=null&&r.push(l("span",{class:"zx-launcher__badge"},String(t.badge))),l(n,{class:"zx-launcher__option",type:n==="button"?"button":null,href:i,target:t.target??null,rel:n==="a"?"noopener":null,role:"option",id:x("zx-launcher-option"),tabIndex:-1,ariaSelected:"false",ariaDisabled:t.disabled?"true":null,ariaCurrent:t.current?"page":null,dataset:{launcherIndex:e,pinned:t.pinned!==void 0&&t.pinned!==!1?"true":null,kind:Ym(t.kind)}},r)}_renderStatus(){this._busy?this.refs.status.textContent=String(this.options.loadingText??this._message("launcher.loading","Searching\u2026")):this._results.length===0?this.refs.status.textContent=String(this.options.emptyText??this._message("launcher.empty","No results")):this.refs.status.textContent="",this.refs.status.hidden=!this.refs.status.textContent}_syncActive(){let t=[...this.refs.results.querySelectorAll("[data-launcher-index]")];for(let i of t){let n=Number(i.getAttribute("data-launcher-index"))===this._active;i.setAttribute("aria-selected",String(n))}let e=t.find(i=>Number(i.getAttribute("data-launcher-index"))===this._active);e?this.refs.input.setAttribute("aria-activedescendant",e.id):this.refs.input.removeAttribute("aria-activedescendant")}_onKeydown(t){if(t.key==="Escape"){this.close();return}if(t.key==="Enter"){if(this._active<0)return;t.preventDefault(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.click();return}let e=this._results.map((n,r)=>n.disabled?-1:r).filter(n=>n>=0);if(e.length===0)return;if(/^Arrow(?:Left|Right|Up|Down)$/.test(t.key)){let n=this._spatialIndex(t.key,e);if(n!==null){t.preventDefault(),this._active=n,this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"});return}if(t.key==="ArrowLeft"||t.key==="ArrowRight")return}let i=e.indexOf(this._active);if(t.key==="Home"||t.key==="PageUp")i=0;else if(t.key==="End"||t.key==="PageDown")i=e.length-1;else if(t.key==="ArrowDown")i=(i+1+e.length)%e.length;else if(t.key==="ArrowUp")i=(i-1+e.length)%e.length;else return;t.preventDefault(),this._active=e[i],this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest"})}_spatialIndex(t,e){let i=this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`);if(!(i instanceof HTMLElement)||(t==="ArrowLeft"||t==="ArrowRight")&&this._results[this._active]?.kind!=="application")return null;let n=[...this.refs.results.querySelectorAll("[data-launcher-index]")].filter(o=>e.includes(Number(o.getAttribute("data-launcher-index")))&&(t!=="ArrowLeft"&&t!=="ArrowRight"||o.getAttribute("data-kind")==="application")),r=Wm(n,i,t);return r?Number(r.getAttribute("data-launcher-index")):null}_activate(t,e){let i=this._results[t];if(!i||i.disabled){e.preventDefault();return}if(this.emit("select",{item:i,value:i.value??i.id,source:i._source??null,query:this._query.trim()}).defaultPrevented){e.preventDefault();return}i.href||(e.preventDefault(),i.invoke?.()),this.close()}_onDocumentKeydown(t){if(this.options.shortcut!=="mod+k"||t.isComposing||t.key.toLowerCase()!=="k"||Number(t.metaKey)+Number(t.ctrlKey)!==1||t.altKey||t.shiftKey)return;let e=document.activeElement;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)return;let i=document.querySelector("dialog:modal");i&&i!==this.el||(t.preventDefault(),this.open())}_message(t,e){let i=this.msg(t);return i===t?e:i}};function $m(){let s=String(navigator.userAgentData?.platform??navigator.platform??"");return/mac|iphone|ipad/i.test(s)?"\u2318 K":"Ctrl K"}function Km(s,t){if(s===!1)return null;let e=s&&typeof s=="object"?s:{};return l("footer",{class:"zx-launcher__hints",ariaHidden:"true"},l("span",{},l("kbd",{},"\u2191\u2193\u2190\u2192"),e.move??t.move),l("span",{},l("kbd",{},"\u21B5"),e.open??t.open),l("span",{},l("kbd",{},"Esc"),e.close??t.close))}function Um(s){let t=s.icon;if(typeof t=="function"&&(t=t(s)),typeof t=="string")return g(t);if(t instanceof Node)return t.cloneNode(!0);if(t&&typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();return e instanceof Node?e.cloneNode(!0):null}return null}function Ym(s){return s==="application"||s==="record"?s:"action"}function vs(s,t){return s==="empty"?t==="":s==="query"?t!=="":!0}function Wm(s,t,e){let i=t.getBoundingClientRect();if(i.width===0&&i.height===0)return null;let n=i.left+i.width/2,r=i.top+i.height/2,o=null,a=1/0;for(let c of s){if(c===t)continue;let h=c.getBoundingClientRect(),u=h.left+h.width/2-n,d=h.top+h.height/2-r,p=!1,f=1/0;e==="ArrowLeft"?(p=u<-2&&Math.abs(d)<Math.max(i.height,h.height)/2,f=Math.abs(u)+Math.abs(d)*4):e==="ArrowRight"?(p=u>2&&Math.abs(d)<Math.max(i.height,h.height)/2,f=Math.abs(u)+Math.abs(d)*4):e==="ArrowUp"?(p=d<-2,f=Math.abs(d)*10+Math.abs(u)):e==="ArrowDown"&&(p=d>2,f=Math.abs(d)*10+Math.abs(u)),p&&f<a&&(o=c,a=f)}return o}function br(s,t,e=100){let i=Ce(t).trim(),n=s.map((o,a)=>({item:o,order:a,score:Gm(o,i)})).filter(({score:o})=>o<1/0);n.sort((o,a)=>{let c=Ss(o.item.groupOrder),h=Ss(a.item.groupOrder);if(c!==h)return c-h;if(i===""){let u=Fc(o.item.pinned,o.order),d=Fc(a.item.pinned,a.order);if(u!==d)return u-d}return o.score-a.score||Ss(o.item.itemOrder)-Ss(a.item.itemOrder)||Qm(o.item.label,a.item.label)||o.order-a.order});let r=Math.max(0,Number(e)||0);return n.slice(0,r||0).map(({item:o,score:a})=>({...o,_score:a}))}function Gm(s,t){if(!t)return s.pinned?-1:0;let e=Ce(s.label),i=Ce(s.id),n=Ce(Array.isArray(s.keywords)?s.keywords.join(" "):s.keywords??"");return e===t?0:e.startsWith(t)?10:e.split(/[^\p{L}\p{N}]+/u).some(o=>o.startsWith(t))?20:e.includes(t)||n.includes(t)?30:i.includes(t)?40:e.split(/[^\p{L}\p{N}]+/u).filter(Boolean).map(o=>o[0]).join("").startsWith(t)?50:1/0}function Fc(s,t){return typeof s=="number"&&Number.isFinite(s)?s:s?t:Number.MAX_SAFE_INTEGER}function Ss(s){return typeof s=="number"&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER}function Ce(s){return String(s??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function Qm(s,t){let e=Ce(s),i=Ce(t);if(e<i)return-1;if(e>i)return 1;let n=String(s??"").normalize("NFC"),r=String(t??"").normalize("NFC");return n<r?-1:n>r?1:0}function mr(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>Xm(t)):[]}function Xm(s){let t={...s,label:String(s.label)};if(s.href==null)return t;let e=V(s.href);return e!==null?t.href=e:(delete t.href,typeof t.invoke!="function"&&(t.disabled=!0)),t}function Lc(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.id!=null&&typeof t.load=="function").map(t=>({...t,id:String(t.id)})):[]}var le=class extends m{static cssName="avatar";static defaults={src:null,name:"",initials:null,label:null,size:"md",shape:"circle",status:null,statusLabel:null};render(){this._createdRoot=this.el===null;let t=this.el??l("span");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,r=>[r.name,r.value]),children:Array.from(t.childNodes)},this._state={src:this.options.src,name:String(this.options.name??""),initials:this.options.initials,label:this.options.label,size:this.options.size,shape:this.options.shape,status:this.options.status,statusLabel:this.options.statusLabel};let e=l("img",{ref:"image",class:"zx-avatar__image",alt:"",draggable:!1}),i=l("span",{ref:"fallback",class:"zx-avatar__fallback",ariaHidden:"true"}),n=l("span",{ref:"status",class:"zx-avatar__status",ariaHidden:"true",hidden:!0});return t.replaceChildren(e,i,n),this.listen(e,"load",()=>{this._isCurrentImageSource()&&this._showImage(!0)}),this.listen(e,"error",()=>{this._isCurrentImageSource()&&this._showImage(!1)}),this._sync(),t}set(t={}){if(!t||typeof t!="object")return this;for(let e of["src","name","initials","label","size","shape","status","statusLabel"])Object.hasOwn(t,e)&&(this._state[e]=t[e]);return this._sync(),this}setStatus(t,e=null){return this._state.status=t,this._state.statusLabel=e,this._syncLabel(),this._syncStatus(),this}hasImage(){return!this.refs.image.hidden}destroy(){let t=this._original;if(super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_sync(){let{size:t,shape:e,label:i}=this._state;this.el.dataset.size=typeof t=="string"?t:"custom",this.el.dataset.shape=["circle","rounded","square"].includes(e)?e:"circle",typeof t=="number"&&Number.isFinite(t)?this.el.style.setProperty("--zx-avatar-size",`${Math.max(1,t)}px`):this.el.style.removeProperty("--zx-avatar-size"),this._syncLabel(),this.refs.fallback.textContent=String(this._state.initials||As(this._state.name));let n=this._state.src==null?"":String(this._state.src).trim();n?(this.refs.image.setAttribute("src",n),this._showImage(this.refs.image.complete&&this.refs.image.naturalWidth>0)):(this.refs.image.removeAttribute("src"),this._showImage(!1)),this._syncStatus()}_syncLabel(){let{label:t,status:e,statusLabel:i}=this._state;if(t){let n=["online","away","busy","offline"].includes(e)?i:null;this.el.setAttribute("role","img"),this.el.setAttribute("aria-label",[t,n].filter(Boolean).join(", ")),this.el.removeAttribute("aria-hidden")}else this.el.removeAttribute("role"),this.el.removeAttribute("aria-label"),this.el.setAttribute("aria-hidden","true")}_showImage(t){this.refs.image.hidden=!t,this.refs.fallback.hidden=t,this.el.dataset.fallback=String(!t)}_isCurrentImageSource(){let t=this.refs.image,e=t.getAttribute("src");if(!e)return!1;try{return t.currentSrc===new URL(e,document.baseURI).href}catch{return t.currentSrc===e}}_syncStatus(){let e=["online","away","busy","offline"].includes(this._state.status)?this._state.status:null;this.refs.status.hidden=e===null,e?this.refs.status.dataset.status=e:delete this.refs.status.dataset.status;let i=this._state.statusLabel;i?this.refs.status.setAttribute("title",String(i)):this.refs.status.removeAttribute("title")}};function As(s){let t=String(s??"").trim().split(/\s+/u).filter(Boolean);if(t.length===0)return"?";let e=Rc(t[0]),i=t.length>1?Rc(t[t.length-1]):"";return`${e}${i}`}function Rc(s){return Vc(Vc(s).toUpperCase())}function Vc(s){return typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(s)[Symbol.iterator]().next().value?.segment??"":Array.from(s)[0]??""}var vi=class extends m{static cssName="entity-ref";static defaults={id:null,title:"",subtitle:null,icon:null,metadata:[],link:null,actions:[],size:"md",wrap:!1,actionsLabel:"Entity actions"};constructor(t=null,e={}){super(t,e)}render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._snapshot=this._createdRoot?null:A(t),this._destroyed=!1,this._state=yr(this.options),this._renderedActions=[],t.replaceChildren(l("span",{ref:"icon",class:"zx-entity-ref__icon",ariaHidden:"true"}),l("div",{class:"zx-entity-ref__body"},l("span",{ref:"title",class:"zx-entity-ref__title"}),l("span",{ref:"subtitle",class:"zx-entity-ref__subtitle"}),l("dl",{ref:"metadata",class:"zx-entity-ref__metadata"})),l("div",{ref:"actions",class:"zx-entity-ref__actions",role:"group"})),this.listen(t,"click",e=>this._handleClick(e)),this._sync(),t}set(t={}){return!t||typeof t!="object"||Array.isArray(t)?this:(this._state=yr({...this._state,...t}),this._sync(),this)}setMetadata(t){return this.set({metadata:t})}setActions(t){return this.set({actions:t})}setLink(t){return this.set({link:t})}getEntity(){return ng(this._state)}focus(){let t=this.refs.title.querySelector("a[href]")??this.refs.actions.querySelector("a[href], button:not(:disabled)");return t&&typeof t.focus=="function"&&t.focus(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_sync(){let t=this._state,e=this.el,i=this.refs.icon,n=this.refs.title,r=this.refs.subtitle,o=this.refs.metadata,a=this.refs.actions;e.dataset.size=t.size,e.dataset.wrap=String(t.wrap);let c=tg(t.icon);i.replaceChildren(...c===null?[]:[c]),i.hidden=c===null;let h=t.link?l("a",{class:"zx-entity-ref__primary",href:t.link.href,target:t.link.target,rel:t.link.rel,download:t.link.download===!0?"":t.link.download,dataset:{entityPrimary:""}},t.title):l("span",{class:"zx-entity-ref__name"},t.title);n.replaceChildren(h),n.hidden=t.title==="",eg(r,t.subtitle),r.hidden=jc(t.subtitle),o.replaceChildren(...t.metadata.map(u=>l("div",{class:"zx-entity-ref__field",dataset:{labelVisible:String(u.showLabel!==!1)}},l("dt",{class:"zx-entity-ref__label"},u.label),l("dd",{class:"zx-entity-ref__value"},u.icon?g(u.icon,{size:12}):null,Bc(u.value))))),o.hidden=t.metadata.length===0,this._renderedActions=t.actions,a.setAttribute("aria-label",t.actionsLabel),a.replaceChildren(...t.actions.map((u,d)=>T(u)?u:Jm(u,d))),a.hidden=t.actions.length===0}_handleClick(t){let e=t.target instanceof Element?t.target:null;if(!e)return;let i=e.closest("[data-entity-primary]");if(i&&this.el.contains(i)&&this._state.link){let a={id:this._state.id,entity:this.getEntity(),href:this._state.link.href,event:t};if(this.emit("activate",a,{honorDomCancellation:!0}).defaultPrevented){t.preventDefault();return}this._state.link.onclick?.(t,this.getEntity(),this);return}let n=e.closest("[data-entity-action]");if(!n||!this.refs.actions.contains(n))return;let r=this._renderedActions[Number(n.dataset.entityAction)];if(!r||T(r)||r.disabled)return;if(this.emit("action",{id:r.id,action:{...r},entity:this.getEntity(),event:t},{honorDomCancellation:!0}).defaultPrevented){t.preventDefault();return}r.onselect?.(r.id,{...r},this.getEntity(),this)}};function yr(s={}){let t=s&&typeof s=="object"&&!Array.isArray(s)?s:{},e=String(t.title??""),i=ks(t.link);if(i&&!e.trim())throw new TypeError("A linked EntityRef requires a non-empty title");return{id:t.id??null,title:e,subtitle:Pc(t.subtitle),icon:Zm(t.icon),metadata:zs(t.metadata),link:i,actions:Cs(t.actions),size:ig(t.size),wrap:!!t.wrap,actionsLabel:String(t.actionsLabel||"Entity actions")}}function ks(s){if(s==null)return null;let t=typeof s=="string"?{href:s}:s;if(!t||typeof t!="object"||Array.isArray(t))return null;let e=V(t.href);if(e===null)return null;let i=t.target==null?void 0:String(t.target),n=Hc(t.rel,i),r=t.onclick;if(r!==void 0&&typeof r!="function")throw new TypeError("EntityRef link onclick must be a function");let o=t.download,a=o===!0?!0:typeof o=="string"?o:void 0;return{href:e,...i?{target:i}:{},...n?{rel:n}:{},...a!==void 0?{download:a}:{},...r?{onclick:r}:{}}}function zs(s){return Array.isArray(s)?s.flatMap(t=>{if(!t||typeof t!="object"||Array.isArray(t))return[];let e=t,i=String(e.label??"").trim(),n=Pc(e.value);return!i||jc(n)?[]:[{label:i,value:n,icon:e.icon==null?null:String(e.icon),showLabel:e.showLabel!==!1}]}):[]}function Cs(s){if(!Array.isArray(s))return[];let t=new Set,e=[];for(let i of s){if(T(i)){e.push(i);continue}if(!i||typeof i!="object"||Array.isArray(i))continue;let n=i,r=String(n.id??"").trim(),o=String(n.label??""),a=String(n.title??o).trim();if(!r||!a||t.has(r)||n.href!=null&&V(n.href)===null)continue;if(n.onselect!==void 0&&typeof n.onselect!="function")throw new TypeError(`EntityRef action ${r} onselect must be a function`);t.add(r);let c=n.href==null?void 0:V(n.href),h=n.target==null?void 0:String(n.target),u=Hc(n.rel,h);e.push({...n,id:r,label:o,title:a,icon:n.icon==null?null:String(n.icon),kind:sg(n.kind),disabled:!!n.disabled,...c?{href:c}:{},...h?{target:h}:{},...u?{rel:u}:{}})}return e}function Jm(s,t){let e=[s.icon?g(s.icon,{size:14}):null,s.label?l("span",{class:"zx-entity-ref__action-label"},s.label):null],i={class:"zx-entity-ref__action",title:s.title,ariaLabel:s.label||s.title,dataset:{entityAction:String(t),kind:s.kind}};return s.href&&!s.disabled?l("a",{...i,href:s.href,target:s.target,rel:s.rel},e):l("button",{...i,type:"button",disabled:!!s.disabled},e)}function Zm(s){return s==null||typeof s=="string"||typeof s=="function"?s??null:Si(s)||s instanceof m?s:null}function tg(s){let t=typeof s=="function"?s():s;return typeof t=="string"?g(t,{size:18}):t instanceof m?t.toElement():Si(t)?t:null}function Pc(s){return s==null?null:typeof s=="string"||typeof s=="number"||Si(s)||s instanceof m?s:String(s)}function eg(s,t){s.replaceChildren(Bc(t))}function Bc(s){return s instanceof m?s.toElement():Si(s)?s:s==null?"":String(s)}function jc(s){return s==null||!Si(s)&&!(s instanceof m)&&String(s)===""}function Si(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function ig(s){return s==="sm"||s==="lg"?s:"md"}function sg(s){return s==="default"||s==="primary"||s==="danger"?s:"ghost"}function Hc(s,t){let e=String(s??"").split(/\s+/).filter(i=>/^[a-z-]+$/i.test(i));return t==="_blank"&&!e.includes("noopener")&&e.push("noopener"),e.length?[...new Set(e)].join(" "):void 0}function ng(s){return Object.freeze({...s,metadata:s.metadata.map(t=>({...t})),link:s.link?{...s.link}:null,actions:s.actions.map(t=>T(t)?t:{...t})})}var rg=new Set(["ready","temporary","waiting","uploading","processing","success","error"]),og=Object.freeze({ready:"",temporary:"Temporary",waiting:"Waiting",uploading:"Uploading",processing:"Processing",success:"Complete",error:"Failed"}),Ai=class extends m{static cssName="file-item";static defaults={id:null,name:"",size:null,mime:"",subtitle:null,icon:"file",metadata:[],link:null,actions:[],status:"ready",statusLabel:null,progress:null,indeterminate:!1,density:"md",wrap:!1,actionsLabel:"File actions"};constructor(t=null,e={}){super(t,e)}render(){this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._snapshot=this._createdRoot?null:A(t),this._destroyed=!1,this._state=ce(this.options);let e=l("div",{ref:"entity",class:"zx-file-item__entity"});return t.replaceChildren(e,l("div",{ref:"status",class:"zx-file-item__status",role:"status"}),l("div",{ref:"progress",class:"zx-file-item__progress"},l("div",{ref:"progressHead",class:"zx-file-item__progress-head"}),l("div",{ref:"progressTrack",class:"zx-file-item__progress-track",role:"progressbar",ariaValuemin:"0",ariaValuemax:"100"},l("div",{ref:"progressFill",class:"zx-file-item__progress-fill"})))),this._entity=new vi(e,qc(this._state)),this.listen(this._entity.el,"zx-activate",i=>this._forwardActivate(i)),this.listen(this._entity.el,"zx-action",i=>this._forwardAction(i)),this._sync(),t}set(t={}){return!t||typeof t!="object"||Array.isArray(t)?this:(this._state=ce({...this._state,...t}),this._sync(),this)}setStatus(t,e){return this.set({status:t,...e===void 0?{}:{statusLabel:e}})}setProgress(t,{indeterminate:e=!1}={}){return this.set({progress:t,indeterminate:e})}getFile(){return ug(this._state)}focus(){return this._entity.focus(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;this._entity?.destroy(),super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_sync(){let t=this._state,e=this.el,i=this.refs.status,n=this.refs.progress,r=this.refs.progressTrack,o=this.refs.progressFill;e.dataset.status=t.status,e.dataset.density=t.density,this._entity.set(qc(t));let a=ag(t);i.replaceChildren(...a?[pt({label:a,kind:lg(t.status),size:"sm",dot:t.status!=="ready"})]:[]),i.hidden=a==="";let c=t.indeterminate||t.progress!==null;if(n.hidden=!c,n.toggleAttribute("data-indeterminate",t.indeterminate),!c)return;let h=`${a||"Progress"}${t.indeterminate||t.progress===null?"":` \u2014 ${Math.round(t.progress)}%`}`;if(this.refs.progressHead.textContent=h,r.setAttribute("aria-label",`${t.name||"File"}: ${a||"Progress"}`),t.indeterminate)r.removeAttribute("aria-valuenow"),r.removeAttribute("aria-valuetext"),o.style.removeProperty("--zx-file-progress");else{let u=t.progress??0;r.setAttribute("aria-valuenow",String(u)),r.setAttribute("aria-valuetext",`${Math.round(u)}%`),o.style.setProperty("--zx-file-progress",`${u}%`)}}_forwardActivate(t){let e=t.detail??{};this.emit("activate",{id:this._state.id,file:this.getFile(),href:String(e.href??""),event:e.event},{honorDomCancellation:!0}).defaultPrevented&&t.preventDefault()}_forwardAction(t){let e=t.detail??{};this.emit("action",{id:String(e.id??""),fileId:this._state.id,action:e.action??{},file:this.getFile(),event:e.event},{honorDomCancellation:!0}).defaultPrevented&&t.preventDefault()}};function ce(s={}){let t=s&&typeof s=="object"&&!Array.isArray(s)?s:{},e=t.size==null||t.size===""?null:Number(t.size),i=t.progress==null?null:Number(t.progress),n=rg.has(String(t.status))?String(t.status):"ready";return{id:t.id??null,name:String(t.name??""),size:e!==null&&Number.isFinite(e)&&e>=0?e:null,mime:String(t.mime??""),subtitle:cg(t.subtitle),icon:t.icon===void 0?"file":t.icon,metadata:zs(t.metadata),link:ks(t.link),actions:Cs(t.actions),status:n,statusLabel:t.statusLabel==null?null:String(t.statusLabel),progress:i===null||!Number.isFinite(i)?null:Math.min(100,Math.max(0,i)),indeterminate:!!t.indeterminate,density:t.density==="sm"||t.density==="lg"?t.density:"md",wrap:!!t.wrap,actionsLabel:String(t.actionsLabel||"File actions"),locale:hg(t.locale)}}function qc(s){let t=[];return s.mime&&t.push({label:"Type",value:s.mime,showLabel:!1}),s.size!==null&&t.push({label:"Size",value:li(s.size,{locale:s.locale}),showLabel:!1}),t.push(...s.metadata),{id:s.id,title:s.name,subtitle:s.subtitle,icon:s.icon,metadata:t,link:s.link,actions:s.actions,size:s.density,wrap:s.wrap,actionsLabel:s.actionsLabel}}function ag(s){return s.statusLabel===null?og[s.status]:s.statusLabel}function lg(s){return s==="error"?"danger":s==="success"?"success":s==="temporary"||s==="waiting"?"warning":s==="uploading"?"info":s==="processing"?"accent":"neutral"}function cg(s){return s==null?null:typeof s=="string"||typeof s=="number"||s instanceof m||typeof s=="object"&&typeof s.nodeType=="number"?s:String(s)}function hg(s){if(typeof s=="string"&&s.trim())return s}function ug(s){return Object.freeze({...s,metadata:s.metadata.map(t=>({...t})),link:s.link?{...s.link}:null,actions:s.actions.map(t=>T(t)?t:{...t})})}var wr=class extends m{static cssName="file-list";static defaults={items:[],label:"Files",loading:!1,loadingCount:3,loadingText:"Loading files",emptyText:"No files"};constructor(t=null,e={}){super(t,e)}render(){this._createdRoot=this.el===null;let t=this.el??l("section");this.el=t,this._snapshot=this._createdRoot?null:A(t),this._destroyed=!1,this._items=xr(this.options.items),this._loading=!!this.options.loading,this._itemComponents=[],t.setAttribute("aria-label",String(this.options.label||"Files")),this.listen(t,"zx-activate",e=>this._forwardActivate(e)),this.listen(t,"zx-action",e=>this._forwardAction(e));try{return this._renderList(),t}catch(e){throw this._destroyItems(),this._createdRoot||S(t,this._snapshot),e}}setItems(t,e={}){return this._items=xr(t),this._renderList(),e.silent||this._emitDataChange(),this}getItems(){return this._itemComponents.map(t=>t.getFile())}getItem(t){return this._itemComponents.find(i=>Object.is(i.getFile().id,t))?.getFile()??null}addItem(t,e=this._items.length,i={}){let n=Math.max(0,Math.min(this._items.length,Math.trunc(Number(e))||0)),r=this._items.slice();return r.splice(n,0,ce(t)),this.setItems(r,i)}updateItem(t,e,i={}){if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("FileList update values must be an object");let n=this._items.findIndex(o=>Object.is(o.id,t));if(n<0)return this;let r=this._items.slice();return r[n]=ce({...r[n],...e}),this.setItems(r,i)}removeItem(t,e={}){let i=this._items.findIndex(r=>Object.is(r.id,t));if(i<0)return this;let n=this._items.slice();return n.splice(i,1),this.setItems(n,e)}setLoading(t){let e=!!t;return e===this._loading?this:(this._loading=e,this._renderList(),this)}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this.el;this._destroyItems(),super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_renderList(){this._destroyItems();let t=this.el;t.setAttribute("aria-busy",String(this._loading));let e=[];try{if(this._items.length){let i=l("ol",{class:"zx-file-list__items"});for(let n of this._items){let r=new Ai(null,n);this._itemComponents.push(r),i.append(l("li",{class:"zx-file-list__item"},r))}e.push(i)}else this._loading||e.push(l("div",{class:"zx-file-list__empty",role:"status"},fg(this.options.emptyText,"FileList emptyText")));this._loading&&e.push(this._createLoading(this._items.length===0)),t.replaceChildren(...e)}catch(i){throw this._destroyItems(),i}}_createLoading(t){let e=l("div",{class:"zx-file-list__loading",role:"status",ariaLive:"polite"},l("span",{class:"zx-file-list__loading-label"},String(this.options.loadingText)));if(!t)return e;let i=l("div",{class:"zx-file-list__skeletons",ariaHidden:"true"});for(let n=0;n<pg(this.options.loadingCount);n+=1)i.append(l("div",{class:"zx-file-list__skeleton"},at({width:"2rem",height:"2rem",radius:"md"}),_i({lines:2,lastLineWidth:n%2?"48%":"64%"})));return e.append(i),e}_destroyItems(){for(let t of this._itemComponents)t.destroy();this._itemComponents.length=0}_forwardActivate(t){let e=this._componentForEvent(t);if(!e)return;let i=this._itemComponents.indexOf(e),n=t.detail??{},r=e.getFile();this.emit("activate",{id:r.id,index:i,file:r,href:String(n.href??""),event:n.event},{honorDomCancellation:!0}).defaultPrevented&&t.preventDefault()}_forwardAction(t){let e=this._componentForEvent(t);if(!e)return;let i=this._itemComponents.indexOf(e),n=t.detail??{},r=e.getFile();this.emit("action",{id:String(n.id??""),fileId:r.id,index:i,action:n.action??{},file:r,event:n.event},{honorDomCancellation:!0}).defaultPrevented&&t.preventDefault()}_componentForEvent(t){return t.target===this.el?null:this._itemComponents.find(e=>t.target===e.el)??null}_emitDataChange(){this.emit("datachange",{items:this.getItems()})}};function xr(s){if(!Array.isArray(s))throw new TypeError("FileList items must be an array");let t=new Set;return s.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("FileList items must be descriptor objects");let i=ce(e);if(i.id!==null){if(t.has(i.id))throw new RangeError(`Duplicate FileList id: ${String(i.id)}`);t.add(i.id)}return dg(i)})}function dg(s){return{...s,metadata:s.metadata.map(t=>({...t})),link:s.link?{...s.link}:null,actions:[...s.actions],locale:s.locale}}function fg(s,t){if(s==null)return"";if(typeof s=="string"||typeof s=="number")return String(s);if(s instanceof m)return s.toElement();if(typeof s=="object"&&typeof s.nodeType=="number")return s;throw new TypeError(`${t} must be text, a Node, a Component, or null`)}function pg(s){let t=Math.trunc(Number(s));return Number.isFinite(t)?Math.max(1,Math.min(12,t)):3}var zi=class extends m{static cssName="activity-item";static defaults={id:null,actor:"",avatar:null,title:"",content:null,timestamp:null,timeLabel:null,metadata:[],attachments:[],actions:[],kind:"default",state:"default",stateLabel:null,headingLevel:3};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("li");this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._cleaned=!1,this._headingId=x("zx-activity-item-heading"),this._avatarComponent=null,this._actionsByKey=new Map,this._activity=Kc(this.options);try{return this.listen(e,"click",i=>this._onClick(i)),this._renderActivity(),e}catch(i){throw this._avatarComponent?.destroy(),this._avatarComponent=null,t||S(e,this._original),i}}setActivity(t={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("ActivityItem values must be an object");return this._activity=Kc({...this._activity,...t}),this._renderActivity(),this}getActivity(){return Gc(this._activity)}destroy(){this._cleaned||(this._cleaned=!0,this._avatarComponent?.destroy(),this._avatarComponent=null,super.destroy(),this._createdRoot||S(this.el,this._original))}_renderActivity(){this._avatarComponent?.destroy(),this._avatarComponent=null,this._actionsByKey.clear();let t=this._activity,e=this.el,i=xg(t.id);i===null?delete e.dataset.activityId:e.dataset.activityId=i,e.dataset.kind=vg(t.kind);let n=_g(t.state,t.stateLabel);e.dataset.state=n.state,n.busy?e.setAttribute("aria-busy","true"):e.removeAttribute("aria-busy");let r=ki(t.actor,"Activity actor"),o=ki(t.title,"Activity title"),a=[];r!==null&&a.push(l("span",{class:"zx-activity-item__actor"},r)),o!==null&&a.push(l("span",{class:"zx-activity-item__title"},o));let c=a.length?l(`h${kg(t.headingLevel)}`,{class:"zx-activity-item__heading",id:this._headingId},a):null,h=gg(t.timestamp,t.timeLabel),u=this._createStateBadge(n),d=c||h||u?l("header",{class:"zx-activity-item__header"},c,u,h):null,p=ki(t.content,"Activity content"),f=p===null?null:l("div",{class:"zx-activity-item__body"},p),_=bg(t.metadata,"zx-activity-item__metadata","Activity metadata",this._message("activityItem.metadata","Activity metadata")),b=yg(t.attachments,"zx-activity-item__attachments","Attachments",this._message("activityItem.attachments","Attachments")),w=this._createActions(t.actions),y=l("div",{class:"zx-activity-item__main"},d,f,_,b,w),v=this._createAvatar(t.avatar,t.actor),k=l("article",{class:"zx-activity-item__article",ariaLabelledby:c?this._headingId:void 0,ariaLabel:c?void 0:this._message("activityItem.label","Activity")},v?l("div",{class:"zx-activity-item__avatar"},v):null,y);e.replaceChildren(k)}_createStateBadge(t){if(t.key===null||t.fallback===null)return null;let e=pt({label:t.label??this._message(t.key,t.fallback),kind:t.kind,size:"sm"});return e.classList.add("zx-activity-item__state"),e}_createAvatar(t,e){if(t===null)return null;if(T(t))return t;if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("ActivityItem avatar must be an Element, descriptor, or null");let i={...t,name:t.name||vr(e),label:t.label??null,size:t.size??"md"};return this._avatarComponent=new le(null,i),this._avatarComponent.toElement()}_createActions(t){let e=Uc(t);if(e.length===0)return null;let i=e.map((r,o)=>{if(T(r))return r;let a=String(o);return this._actionsByKey.set(a,r),mg(r,a)}),n=wg(this._activity,this._message("activityItem.untitled","activity"));return l("div",{class:"zx-activity-item__actions",role:"group",ariaLabel:this._message("activityItem.actions","Actions for %1",n)},i)}_message(t,e,...i){let n=this.msg(t,...i);return n===t?I(e,i):n}_onClick(t){let i=(t.target&&typeof t.target=="object"?t.target:null)?.closest?.("[data-activity-action]")??null;if(!i||!this.el.contains(i))return;let n=this._actionsByKey.get(i.dataset.activityAction??"");if(!n||n.disabled){t.preventDefault();return}if(this.emit("action",{id:n.id,action:n,event:t},{honorDomCancellation:!0}).defaultPrevented){t.preventDefault();return}n.onselect?.(t)}};function Uc(s){if(!Array.isArray(s))return[];let t=[],e=new Set;for(let i of s){if(T(i)){t.push(i);continue}let n=Yc(i);!n||e.has(n.id)||(e.add(n.id),t.push(n))}return t}function Yc(s){if(!s||typeof s!="object"||Array.isArray(s))return null;let t=s;if(t.id===null||t.id===void 0)return null;let e=String(t.id).trim();if(!e)return null;let i=t.label==null?"":String(t.label),n=t.icon==null?null:String(t.icon).trim()||null,r=t.title==null?void 0:String(t.title);if(!i&&!r)return null;let o=t.href!==null&&t.href!==void 0,a=o?V(t.href):null;if(o&&a===null||t.onselect!==void 0&&typeof t.onselect!="function")return null;let c=t.target==null?void 0:String(t.target);return{id:e,label:i,icon:n,href:a,target:c,rel:Ag(t.rel,c),title:r,disabled:!!t.disabled,kind:Sg(t.kind),onselect:t.onselect}}var $c=Object.freeze({pending:Object.freeze({busy:!0,key:"activityItem.pending",fallback:"Sending\u2026",kind:"neutral"}),failed:Object.freeze({busy:!1,key:"activityItem.failed",fallback:"Failed",kind:"danger"})});function _g(s,t){let e=String(s??"default"),i=Object.prototype.hasOwnProperty.call($c,e)?$c[e]:null;return i?{state:e,busy:i.busy,key:i.key,fallback:i.fallback,kind:i.kind,label:t==null||t===""?null:String(t)}:{state:"default",busy:!1,key:null,fallback:null,kind:"neutral",label:null}}function Wc(s,t){let e=t==null?"":String(t).trim();if(s==null||s==="")return e?{dateTime:null,label:e}:null;let i=s instanceof Date?new Date(s.getTime()):new Date(s);if(Number.isNaN(i.getTime())){let n=e||(typeof s=="string"?s.trim():"");return n?{dateTime:null,label:n}:null}return{dateTime:i.toISOString(),label:e||zg(i)}}function Kc(s){if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("ActivityItem options must be an object");for(let t of["metadata","attachments","actions"])if(!Array.isArray(s[t]))throw new TypeError(`ActivityItem ${t} must be an array`);return Gc(s)}function Gc(s){let t=s.avatar&&!T(s.avatar)?{...s.avatar}:s.avatar??null;return{...s,avatar:t,metadata:[...s.metadata??[]],attachments:[...s.attachments??[]],actions:[...s.actions??[]]}}function mg(s,t){if(s.href&&!s.disabled){let i=l("a",{class:"zx-btn zx-activity-item__action",href:s.href,target:s.target,rel:s.rel,title:s.title,dataset:{activityAction:t,kind:s.kind,size:"sm"}});return s.icon&&i.append(g(s.icon,{size:16})),s.label&&i.append(l("span",{class:"zx-btn__label"},s.label)),!s.label&&s.title&&i.setAttribute("aria-label",s.title),i}let e=j({label:s.label,icon:s.icon,kind:s.kind,size:"sm",disabled:s.disabled,title:s.title});return e.classList.add("zx-activity-item__action"),e.dataset.activityAction=t,e}function gg(s,t){let e=Wc(s,t);return e?e.dateTime===null?l("span",{class:"zx-activity-item__time"},e.label):l("time",{class:"zx-activity-item__time",dateTime:e.dateTime,title:e.label},e.label):null}function bg(s,t,e,i){return s.length===0?null:l("ul",{class:t,ariaLabel:i},s.map(n=>l("li",{class:`${t}-item`},ki(n,e))))}function yg(s,t,e,i){return s.length===0?null:l("div",{class:t,role:"group",ariaLabel:i},s.map(n=>l("div",{class:`${t}-item`},ki(n,e))))}function ki(s,t){if(s===null||s==="")return null;if(typeof s=="string"||typeof s=="number")return String(s);if(s&&typeof s=="object"&&typeof s.nodeType=="number")return s;if(s instanceof m)return s.toElement();throw new TypeError(`${t} must be text, a Node, a Component, or null`)}function vr(s){return s===null?"":typeof s=="string"||typeof s=="number"?String(s).trim():s&&typeof s=="object"&&typeof s.nodeType=="number"?s.textContent?.trim()??"":s instanceof m?s.toElement().textContent?.trim()??"":""}function wg(s,t){return vr(s.title)||vr(s.actor)||t}function xg(s){return typeof s=="string"||typeof s=="number"?String(s):null}function vg(s){return String(s??"default").trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-")||"default"}function Sg(s){return["default","primary","danger"].includes(String(s))?s:"ghost"}function Ag(s,t){let e=String(s??"").split(/\s+/).filter(i=>/^[a-z-]+$/i.test(i));return t==="_blank"&&!e.includes("noopener")&&e.push("noopener"),e.length?[...new Set(e)].join(" "):void 0}function kg(s){let t=Math.trunc(Number(s));return t>=1&&t<=6?t:3}function zg(s){try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(s)}catch{return s.toLocaleString()}}var Sr=class extends m{static cssName="activity-list";static defaults={items:[],groupBy:null,groupLabel:null,label:"Activity",loading:!1,loadingCount:3,loadingText:"Loading activity",emptyText:"No activity yet",groupHeadingLevel:2,itemHeadingLevel:3};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._createdRoot=t,this._original=t?null:A(e),this._cleaned=!1,this._items=Lt(this.options.items),this._loading=!!this.options.loading,this._itemComponents=[],this._groupSequence=0,e.setAttribute("aria-label",String(this.options.label||"Activity"));try{return this._renderList(),e}catch(i){throw this._destroyItems(),t||S(e,this._original),i}}setItems(t,e={}){return this._items=Lt(t),this._renderList(),e.silent||this._emitDataChange(),this}getItems(){return this._items.map(Ts)}getItem(t){let e=this._items.find(i=>Object.is(i.id,t));return e?Ts(e):null}appendItems(t,e={}){let i=Lt(Array.isArray(t)?t:[t]);return i.length===0?this:(this._items=Lt([...this._items,...i]),this._renderList(),e.silent||this._emitDataChange(),this)}prependItems(t,e={}){let i=Lt(Array.isArray(t)?t:[t]);return i.length===0?this:(this._items=Lt([...i,...this._items]),this._renderList(),e.silent||this._emitDataChange(),this)}updateItem(t,e,i={}){if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("ActivityList update values must be an object");let n=this._items.findIndex(o=>Object.is(o.id,t));if(n<0)return this;let r=this._items.slice();return r[n]={...r[n],...e},this._items=Lt(r),this._renderList(),i.silent||this._emitDataChange(),this}removeItem(t,e={}){let i=this._items.findIndex(n=>Object.is(n.id,t));return i<0?this:(this._items.splice(i,1),this._renderList(),e.silent||this._emitDataChange(),this)}setLoading(t){let e=!!t;return e===this._loading?this:(this._loading=e,this._renderList(),this)}destroy(){this._cleaned||(this._cleaned=!0,this._destroyItems(),super.destroy(),this._createdRoot||S(this.el,this._original))}_renderList(){this._destroyItems(),this._groupSequence=0;let t=this.el;t.setAttribute("aria-busy",String(this._loading));let e=[];try{if(this._items.length>0){let i=this.options.groupBy??null,n=Xc(this._items,i),r=i!==null;for(let o of n)e.push(this._createGroup(o,r))}else this._loading||e.push(l("div",{class:"zx-activity-list__empty",role:"status"},Qc(this.options.emptyText,"ActivityList emptyText")));this._loading&&e.push(this._createLoading(this._items.length===0)),t.replaceChildren(...e)}catch(i){throw this._destroyItems(),i}}_createGroup(t,e){let i=l("ol",{class:"zx-activity-list__items"});for(let o of t.items){let a=new zi(null,{...o,headingLevel:o.headingLevel??this.options.itemHeadingLevel});this._itemComponents.push(a),i.append(a.toElement())}if(!e)return i;this._groupSequence+=1;let n=x(`zx-activity-list-group-${this._groupSequence}`),r=this.options.groupLabel?this.options.groupLabel(t.id,t.items.map(Ts)):String(t.id??"Other");return i.setAttribute("aria-labelledby",n),l("section",{class:"zx-activity-list__group",ariaLabelledby:n},l(`h${Tg(this.options.groupHeadingLevel,2)}`,{class:"zx-activity-list__group-heading",id:n},Qc(r,"ActivityList groupLabel")),i)}_createLoading(t){let e=l("div",{class:"zx-activity-list__loading",role:"status",ariaLive:"polite"},l("span",{class:"zx-activity-list__loading-label"},String(this.options.loadingText)));if(!t)return e;let i=l("div",{class:"zx-activity-list__skeletons",ariaHidden:"true"}),n=Ig(this.options.loadingCount);for(let r=0;r<n;r+=1)i.append(l("div",{class:"zx-activity-list__skeleton"},at({width:"2.25rem",height:"2.25rem",radius:"full"}),_i({lines:2,heading:!0,lastLineWidth:r%2?"58%":"72%"})));return e.append(i),e}_destroyItems(){for(let t of this._itemComponents)t.destroy();this._itemComponents.length=0}_emitDataChange(){this.emit("datachange",{items:this.getItems()})}};function Xc(s,t=null){let e=Lt(s);if(t===null)return e.length?[{id:null,items:e}]:[];if(typeof t!="string"&&typeof t!="function")throw new TypeError("ActivityList groupBy must be a property, function, or null");let i=new Map;return e.forEach((n,r)=>{let o=typeof t=="function"?t(n,r):n[t];i.has(o)||i.set(o,[]),i.get(o).push(n)}),Array.from(i,([n,r])=>({id:n,items:r}))}function Lt(s){if(!Array.isArray(s))throw new TypeError("ActivityList items must be an array");let t=new Set;return s.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("ActivityList items must be descriptor objects");for(let n of["metadata","attachments","actions"])if(e[n]!==void 0&&!Array.isArray(e[n]))throw new TypeError(`ActivityList item ${n} must be an array`);let i=e;if(i.id!==null&&i.id!==void 0){if(t.has(i.id))throw new RangeError(`Duplicate ActivityList id: ${String(i.id)}`);t.add(i.id)}return Ts(i)})}function Ts(s){let t=s.avatar&&Cg(s.avatar)?{...s.avatar}:s.avatar;return{...s,avatar:t,metadata:[...s.metadata??[]],attachments:[...s.attachments??[]],actions:[...s.actions??[]]}}function Qc(s,t){if(s===null)return"";if(typeof s=="string"||typeof s=="number")return String(s);if(s&&typeof s=="object"&&typeof s.nodeType=="number")return s;if(s instanceof m)return s.toElement();throw new TypeError(`${t} must be text, a Node, a Component, or null`)}function Cg(s){return!s||typeof s!="object"||Array.isArray(s)?!1:typeof s.nodeType!="number"&&!(s instanceof m)}function Tg(s,t){let e=Math.trunc(Number(s));return e>=1&&e<=6?e:t}function Ig(s){let t=Math.trunc(Number(s));return Number.isFinite(t)?Math.max(1,Math.min(12,t)):3}var Ar=class extends m{static cssName="account-menu";static defaults={account:{},items:[],compact:!1,label:null,placement:"top-start"};constructor(t=null,e={}){super(t,e);for(let i of["select","open","close"])this.listen(this.refs.trigger,`zx-${i}`,n=>n.stopPropagation());this._avatar=new le(this.refs.avatar,Zc(this._account)),this._menu=new mt(this.refs.trigger,{items:this.options.items,placement:this.options.placement}),this._menu.on("select",i=>{this.emit("select",i.detail).defaultPrevented&&i.preventDefault()}),this._menu.on("open",()=>this.emit("open")),this._menu.on("close",()=>this.emit("close")),this._renderIdentity()}render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,e=>[e.name,e.value]),children:Array.from(t.childNodes)},this._account=Jc(this.options.account),t.dataset.compact=String(!!this.options.compact),t.replaceChildren(l("button",{ref:"trigger",class:"zx-account-menu__trigger",type:"button"},l("span",{ref:"avatar",class:"zx-account-menu__avatar"}),l("span",{class:"zx-account-menu__identity"},l("span",{ref:"name",class:"zx-account-menu__name"}),l("span",{ref:"secondary",class:"zx-account-menu__secondary"})),l("span",{class:"zx-account-menu__chevron",ariaHidden:"true"},g("chevron-down")))),t}open(){return this._menu.open(),this}close(){return this._menu.close(),this}toggle(){return this._menu.toggle(),this}isOpen(){return this._menu.isOpen()}setAccount(t){return this._account=Jc(t),this._avatar.set(Zc(this._account)),this._renderIdentity(),this}setItems(t){return this._menu.setItems(t),this._renderPanelHeader(),this}focus(){return this._menu.getTrigger().focus(),this}getPanel(){return this._menu.getPanel()}destroy(){let t=this._original;if(this._menu.destroy(),this._avatar.destroy(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_renderIdentity(){this.refs.name.textContent=this._account.name,this.refs.secondary.textContent=this._account.secondary,this.refs.secondary.hidden=!this._account.secondary;let e=["online","away","busy","offline"].includes(this._account.status)&&this._account.statusLabel?`, ${this._account.statusLabel}`:"",i=this.options.label||`Account menu${this._account.name?` for ${this._account.name}`:""}${e}`;this.refs.trigger.setAttribute("aria-label",i),this._renderPanelHeader()}_renderPanelHeader(){let t=this._menu.getPanel();t.querySelector(".zx-account-menu__panel-identity")?.remove(),t.prepend(l("div",{class:"zx-account-menu__panel-identity",role:"presentation"},l("strong",{},this._account.name||"Account"),this._account.secondary?l("span",{},this._account.secondary):null))}};function Jc(s){let t=s&&typeof s=="object"?s:{};return{...t,name:String(t.name??""),secondary:String(t.secondary??"")}}function Zc(s){return{name:s.name,src:s.src??null,initials:s.initials??null,status:s.status??null,statusLabel:s.statusLabel??null,label:null,size:"md"}}var Eg=new Set(["top","bottom","top-start","top-end","bottom-start","bottom-end","left","right","left-start","left-end","right-start","right-end"]),Dg=new Set(["hover","focus","both","manual"]),he=class extends m{static cssName="tooltip";static defaults={content:"",placement:"top",offset:6,delay:400,hideDelay:80,maxWidth:260,trigger:"both",disabled:!1};#t;#e;#i=null;#s=null;#r=0;#n=0;#o=!1;#a=!1;#l=!1;constructor(t,e={}){let i=q(t);if(!i)throw new TypeError("Tooltip anchor could not be resolved");super(null,e),this.#t=i,rt(i).append(this.el),this.#e=this.options.content,this.#a=!!this.options.disabled,this.#s=i.getAttribute("aria-describedby"),this.el.style.setProperty("--zx-tooltip-max-inline-size",Lg(this.options.maxWidth));let n=Dg.has(this.options.trigger)?this.options.trigger:"both";n!=="manual"&&((n==="hover"||n==="both")&&(this.listen(this.#t,"pointerenter",r=>{r.pointerType!=="touch"&&this.#c(Number(this.options.delay))}),this.listen(this.#t,"pointerleave",()=>this.#h(Number(this.options.hideDelay)))),(n==="focus"||n==="both")&&(this.listen(this.#t,"focusin",()=>{this.#o||!Rg(this.#t)||this.#c(0)}),this.listen(this.#t,"focusout",()=>this.#h(Number(this.options.hideDelay)))),this.listen(document,"keydown",r=>{r.key!=="Escape"||!this.isOpen()||(r.preventDefault(),this.hide())}),this.listen(document,"pointerdown",()=>{this.#o=!0,this.#u(),this.hide()},{capture:!0}),this.listen(document,"pointerup",()=>{this.#o=!1},{capture:!0}),this.listen(document,"pointercancel",()=>{this.#o=!1},{capture:!0}),this.listen(document,"focusin",r=>{!this.isOpen()||r.composedPath().includes(this.#t)||this.hide()}))}render(){let t=l("div",{id:x("zx-tooltip"),role:"tooltip",popover:"manual"});return t.dataset.state="closed",t}show(){if(this.#l||this.#a||this.isOpen())return this;this.#u();let t=rt(this.#t);this.el.parentElement!==t&&t.append(this.el);let e=th(this.#e);return e===null?this:(this.el.replaceChildren(e),this.#i=st(this.#t,this.el,{placement:Eg.has(this.options.placement)?this.options.placement:"top",offset:Number(this.options.offset),flip:!0}),this.el.dataset.state="open",this.#t.setAttribute("aria-describedby",Fg(this.#s,this.el.id)),this.emit("open"),this)}hide(){return this.#u(),this.isOpen()?(this.#i?.destroy(),this.#i=null,this.el.dataset.state="closed",this.el.replaceChildren(),this.#d(),this.emit("close"),this):this}toggle(){return this.isOpen()?this.hide():this.show()}isOpen(){return this.#i!==null}setContent(t){if(this.#e=t,!this.isOpen())return this;let e=th(t);return e===null?this.hide():(this.el.replaceChildren(e),this.#i?.update(),this)}enable(){return this.#a=!1,this}disable(){return this.#a=!0,this.hide()}isDisabled(){return this.#a}getAnchor(){return this.#t}destroy(){this.#l||(this.#l=!0,this.hide(),this.#d(),super.destroy())}#c(t){if(this.#u(),this.#l||this.#a||this.isOpen())return;let e=Number.isFinite(t)?Math.max(0,t):0;if(e===0){this.show();return}this.#r=setTimeout(()=>{this.#r=0,this.show()},e)}#h(t){if(this.#u(),!this.isOpen())return;let e=Number.isFinite(t)?Math.max(0,t):0;if(e===0){this.hide();return}this.#n=setTimeout(()=>{this.#n=0,this.hide()},e)}#u(){this.#r!==0&&clearTimeout(this.#r),this.#n!==0&&clearTimeout(this.#n),this.#r=0,this.#n=0}#d(){this.#s===null?this.#t.removeAttribute("aria-describedby"):this.#t.setAttribute("aria-describedby",this.#s)}};function Mg(s,t=""){return new he(s,Og(t)?t:{content:t})}function Ng(s,t){return new he(s,{content:String(t??"")})}function Og(s){return s===null||typeof s!="object"||Array.isArray(s)||typeof s.nodeType=="number"?!1:typeof s.toElement!="function"}function th(s){let t=typeof s=="function"?s():s;if(t==null)return null;if(typeof t=="object"&&typeof t.nodeType=="number")return t;if(typeof t=="object"&&typeof t.toElement=="function")return t.toElement();let e=String(t);return e===""?null:document.createTextNode(e)}function Fg(s,t){let e=String(s??"").split(/\s+/).filter(Boolean);return e.includes(t)||e.push(t),e.join(" ")}function Lg(s){return typeof s=="number"&&Number.isFinite(s)?`${s}px`:String(s)}function Rg(s){try{return s.matches(":focus-visible")}catch{return!0}}var Is=class extends m{static cssName="app-rail";static defaults={items:[],active:null,orientation:"vertical",side:"left",label:"Applications",header:null,footer:null,openDelay:80,closeDelay:160,renderIcon:null};constructor(t=null,e={}){super(t,e),this._rebuild()}render(){this._createdRoot=this.el===null;let t=this.el??l("nav");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,r=>[r.name,r.value]),children:Array.from(t.childNodes)},this._items=ue(this.options.items),this._active=this.options.active,this._flyouts=new Map,this._tooltips=[],this._tooltipById=new Map,this._interaction=null,this._openTimers=new Map,this._closeTimers=new Map,this._pointerFocus=new WeakSet,this._silenceFlyoutEvents=!1,t.setAttribute("aria-label",String(this.options.label)),t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.dataset.orientation=this.options.orientation==="horizontal"?"horizontal":"vertical";let e=t.dataset.orientation==="horizontal"?["top","bottom"]:["left","right"];t.dataset.side=e.includes(this.options.side)?this.options.side:e[0];let i=l("div",{class:"zx-app-rail__header"}),n=l("div",{class:"zx-app-rail__footer"});return sh(i,this.options.header),sh(n,this.options.footer),i.hidden=!i.hasChildNodes(),n.hidden=!n.hasChildNodes(),t.replaceChildren(i,l("ul",{ref:"list",class:"zx-app-rail__list"}),n),this.listen(t,"keydown",r=>this._onRailKeydown(r)),t}setItems(t){return this._items=ue(t),this._rebuild(),this}setActive(t){return this._active=t,this._syncActive(),this}getItems(){return this._items.map(t=>({...t,children:t.children?.map(e=>({...e}))}))}openFlyout(t,{focus:e=!1}={}){let i=this._resolveFlyout(t);if(!i)return this;let n=[i],r=i.parentKey===null?null:this._flyouts.get(i.parentKey)??null;for(;r;)n.unshift(r),r=r.parentKey===null?null:this._flyouts.get(r.parentKey)??null;if(n.some(o=>o.item.disabled))return this;this._cancelFlyoutTimers(i,!0);for(let[o,a]of this._flyouts)o!==i.key&&a.dropdown.isOpen()&&!this._isAncestor(a,i)&&this.closeFlyout(o);for(let o of n)this._tooltipById.get(String(o.item.id))?.hide(),o.dropdown.open();return e&&ih(i.panel)?.focus(),this}closeFlyout(t){let e=this._resolveFlyout(t);if(!e)return this;for(let i of[...this._flyouts.values()].reverse())i!==e&&this._isAncestor(e,i)&&(this._cancelTimers(i.key),i.dropdown.close());return this._cancelTimers(e.key),e.dropdown.close(),this}closeAllFlyouts(){for(let t of this._flyouts.values())t.parentKey===null&&this.closeFlyout(t.key);for(let t of[...this._flyouts.values()].reverse())this._cancelTimers(t.key),t.dropdown.isOpen()&&t.dropdown.close();return this}isFlyoutOpen(t){return this._resolveFlyout(t)?.dropdown.isOpen()??!1}focus(){return ih(this.refs.list)?.focus(),this}_containsNode(t){return!!(t&&(this.el.contains(t)||[...this._flyouts.values()].some(e=>e.panel.contains(t))))}destroy(){let t=this._original;if(this._clearArtifacts(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_rebuild(){this._clearArtifacts(),this.refs.list.replaceChildren(),this._interaction=new kr(this.el),this._items.forEach(t=>{let e=Array.isArray(t.children)&&t.children.length>0,i=eh(t,{className:"zx-app-rail__item",index:String(t.id),iconOnly:!0,disclosure:e,disclosureIcon:Vg(this.el.dataset.side),visual:Es(t,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:1,location:"root"})}),n=l("li",{class:"zx-app-rail__row"},i);this.refs.list.append(n);let r=new he(i,{content:t.label,placement:Hg(this.el.dataset.side),delay:450});this._tooltips.push(r),this._tooltipById.set(String(t.id),r),e?this._buildFlyout(t,i,String(t.id),null):this._interaction.listen(i,"click",o=>{if(!this._select(t,o).defaultPrevented)for(let c of this._flyouts.values())c.parentKey===null&&c.dropdown.isOpen()&&this.closeFlyout(c.key)})}),this._interaction.listen(document,"pointerdown",t=>{let e=[...this._flyouts.values()].filter(n=>n.dropdown.isOpen());if(e.length===0)return;let i=t.composedPath();if(!e.some(n=>i.includes(n.panel)||i.includes(n.trigger)))for(let n of e)n.parentKey===null&&this.closeFlyout(n.key)}),this._syncActive()}_buildFlyout(t,e,i,n){let r=l("ul",{class:"zx-app-rail__flyout-list"});for(let u of t.children??[]){let d=`${i}/${u.id}`,p=!!u.children?.length,f=eh(u,{className:"zx-app-rail__flyout-item",index:d,iconOnly:!1,disclosure:p,disclosureIcon:Pg(this.el.dataset.side),visual:Es(u,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:d.split("/").length,location:"flyout"})});r.append(l("li",{},f)),p?this._buildFlyout(u,f,d,i):this._interaction.listen(f,"click",_=>{this._select(u,_).defaultPrevented||this._closeFlyoutChain(i)})}let o=l("div",{class:"zx-app-rail__flyout"},l("div",{class:"zx-app-rail__flyout-title"},t.label),r),a=new _t(e,{openOn:"manual",placement:n===null?Bg(this.el.dataset.side):jg(this.el.dataset.side),content:o,offset:6}),c=a.getPanel();c.classList.add("zx-app-rail__popover"),c.dataset.side=this.el.dataset.side,c.setAttribute("role","region"),c.setAttribute("aria-label",this._message("appRail.subNavigation","%1 sub-navigation",t.label));let h={key:i,parentKey:n,item:t,trigger:e,panel:c,dropdown:a};this._flyouts.set(i,h),a.on("open",()=>{this._silenceFlyoutEvents||this.emit("flyoutchange",{item:t,id:t.id,open:!0})}),a.on("close",()=>{this._silenceFlyoutEvents||this.emit("flyoutchange",{item:t,id:t.id,open:!1})}),this._interaction.listen(e,"pointerdown",()=>{this._pointerFocus.add(e),queueMicrotask(()=>this._pointerFocus.delete(e))}),this._interaction.listen(e,"pointerenter",u=>{u.pointerType!=="touch"&&this._scheduleOpen(i)}),this._interaction.listen(e,"pointerleave",()=>this._scheduleClose(i)),this._interaction.listen(e,"focus",()=>{this._pointerFocus.has(e)||this.openFlyout(i)}),this._interaction.listen(e,"focusout",u=>{c.contains(u.relatedTarget)||this._scheduleClose(i)}),this._interaction.listen(e,"click",u=>{u.preventDefault(),u instanceof MouseEvent&&u.detail===0?this.openFlyout(i,{focus:!0}):this.openFlyout(i)}),this._interaction.listen(c,"pointerenter",()=>this._cancelFlyoutTimers(h,!0)),this._interaction.listen(c,"pointerleave",()=>this._scheduleFlyoutClose(h,!0)),this._interaction.listen(c,"focusin",()=>this._cancelFlyoutTimers(h,!0)),this._interaction.listen(c,"focusout",u=>{u.relatedTarget!==e&&!c.contains(u.relatedTarget)&&this._scheduleFlyoutClose(h,!0)}),this._interaction.listen(c,"keydown",u=>this._onFlyoutKeydown(u,h))}_select(t,e){if(t.disabled){e.preventDefault();let n=new Event("select",{cancelable:!0});return n.preventDefault(),n}let i=this.emit("select",{item:t,id:t.id,value:t.value??t.id,href:t.href??null,event:e});return i.defaultPrevented?e.preventDefault():t.href||(e.preventDefault(),t.invoke?.()),i}_onRailKeydown(t){let e=qg(this.refs.list),i=t.target?.closest?.("[data-app-nav-id]"),n=e.indexOf(i);if(n<0)return;let r=this.el.dataset.orientation==="horizontal",o=r?"ArrowLeft":"ArrowUp",a=r?"ArrowRight":"ArrowDown",c={left:"ArrowRight",right:"ArrowLeft",top:"ArrowDown",bottom:"ArrowUp"}[this.el.dataset.side],h=i.getAttribute("data-app-nav-id");if(t.key===c&&this._flyouts.has(String(h))){t.preventDefault(),this.openFlyout(String(h),{focus:!0});return}let u;if(t.key==="Home")u=0;else if(t.key==="End")u=e.length-1;else if(t.key===o)u=(n-1+e.length)%e.length;else if(t.key===a)u=(n+1)%e.length;else return;t.preventDefault(),e[u]?.focus()}_onFlyoutKeydown(t,e){let i=nh(e.panel),n=t.target?.closest?.("a, button"),r=i.indexOf(n);if(t.key==="Escape"){t.preventDefault(),t.stopPropagation();let u=[...this._flyouts.values()].find(d=>d.trigger===n&&d.dropdown.isOpen());if(u){this.closeFlyout(u.key),this._restoreFocus(u.trigger);return}this.closeFlyout(e.key),this._restoreFocus(e.trigger);return}let o=[...this._flyouts.values()].find(u=>u.trigger===n),a=this.el.dataset.side==="right"?"ArrowLeft":"ArrowRight",c=a==="ArrowRight"?"ArrowLeft":"ArrowRight";if(o&&t.key===a){t.preventDefault(),t.stopPropagation(),this.openFlyout(o.key,{focus:!0});return}if(e.parentKey!==null&&t.key===c){t.preventDefault(),t.stopPropagation(),this.closeFlyout(e.key),this._restoreFocus(e.trigger);return}if(i.length===0)return;let h;if(t.key==="Home")h=0;else if(t.key==="End")h=i.length-1;else if(t.key==="ArrowDown")h=(r+1+i.length)%i.length;else if(t.key==="ArrowUp")h=(r-1+i.length)%i.length;else return;t.preventDefault(),i[h]?.focus()}_scheduleOpen(t){let e=String(t);this._cancelTimer(this._closeTimers,e),this._cancelTimer(this._openTimers,e);let i=Math.max(0,Number(this.options.openDelay)||0);this._openTimers.set(e,setTimeout(()=>{this._openTimers.delete(e),this.openFlyout(t)},i))}_scheduleClose(t){let e=String(t);this._cancelTimer(this._openTimers,e),this._cancelTimer(this._closeTimers,e);let i=Math.max(0,Number(this.options.closeDelay)||0);this._closeTimers.set(e,setTimeout(()=>{this._closeTimers.delete(e);let n=this._flyouts.get(e);n&&(this._branchInteracting(n)||this.closeFlyout(e))},i))}_scheduleFlyoutClose(t,e){let i=t;for(;i&&(this._scheduleClose(i.key),!(!e||i.parentKey===null));)i=this._flyouts.get(i.parentKey)??null}_resolveFlyout(t){let e=String(t);return this._flyouts.get(e)??[...this._flyouts.values()].find(i=>String(i.item.id)===e)??null}_closeFlyoutChain(t){let e=this._flyouts.get(t)??null;for(;e?.parentKey!==null;)e=this._flyouts.get(e.parentKey)??null;e&&this.closeFlyout(e.key)}_isAncestor(t,e){let i=e.parentKey;for(;i!==null;){if(i===t.key)return!0;i=this._flyouts.get(i)?.parentKey??null}return!1}_cancelFlyoutTimers(t,e){let i=t;for(;i&&(this._cancelTimers(i.key),!(!e||i.parentKey===null));)i=this._flyouts.get(i.parentKey)??null}_branchInteracting(t){return t.trigger.matches(":hover")||t.panel.matches(":hover")||t.trigger===document.activeElement||t.panel.contains(document.activeElement)?!0:[...this._flyouts.values()].some(e=>this._isAncestor(t,e)&&e.dropdown.isOpen()&&(e.trigger.matches(":hover")||e.panel.matches(":hover")||e.trigger===document.activeElement||e.panel.contains(document.activeElement)))}_restoreFocus(t){this._pointerFocus.add(t),t.focus(),queueMicrotask(()=>this._pointerFocus.delete(t))}_cancelTimers(t){this._cancelTimer(this._openTimers,t),this._cancelTimer(this._closeTimers,t)}_cancelTimer(t,e){let i=t.get(e);i!==void 0&&clearTimeout(i),t.delete(e)}_syncActive(){let t=this._active==null?null:String(this._active);for(let e of this.refs.list.querySelectorAll("[data-app-nav-id]")){let i=t!==null&&e.getAttribute("data-app-nav-value-id")===t,n=this._flyouts.get(String(e.getAttribute("data-app-nav-id"))),r=t!==null&&n?zr(n.item.children??[],t):!1;i?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current"),r?e.dataset.activeDescendant="true":delete e.dataset.activeDescendant}for(let e of this._flyouts.values()){t!==null&&zr(e.item.children??[],t)?e.trigger.dataset.activeDescendant="true":delete e.trigger.dataset.activeDescendant;for(let n of e.panel.querySelectorAll("[data-app-nav-value-id]"))t!==null&&n.getAttribute("data-app-nav-value-id")===t?n.setAttribute("aria-current","page"):n.removeAttribute("aria-current")}}_clearArtifacts(){for(let t of this._openTimers?this._openTimers.values():[])clearTimeout(t);for(let t of this._closeTimers?this._closeTimers.values():[])clearTimeout(t);this._openTimers?.clear?.(),this._closeTimers?.clear?.(),this._interaction?.destroy?.();for(let t of this._tooltips??[])t.destroy();this._silenceFlyoutEvents=!0;for(let t of this._flyouts?.values?.()??[])t.dropdown.destroy();this._silenceFlyoutEvents=!1,this._tooltips=[],this._tooltipById=new Map,this._interaction=null,this._flyouts=new Map}_message(t,e,...i){let n=this.msg(t,...i);return n===t?I(e,i):n}},kr=class extends m{constructor(t){super(null),t.append(this.el)}render(){return l("span",{hidden:!0,"data-zx-app-rail-listener-scope":""})}};function ue(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>{let e={...t,label:String(t.label),children:Array.isArray(t.children)?ue(t.children):[]};if(t.href==null)return e;let i=V(t.href);return i!==null?e.href=i:(delete e.href,e.children.length===0&&typeof e.invoke!="function"&&(e.disabled=!0)),e}):[]}function Es(s,t,e){let i=typeof t=="function"?t(s,e):null;if(i==null&&(i=s.icon),typeof i=="function"&&(i=i(e,s)),typeof i=="string")return g(i);if(i instanceof Node)return i.cloneNode(!0);if(i&&typeof i=="object"&&typeof i.toElement=="function"){let n=i.toElement();return n instanceof Node?n.cloneNode(!0):null}return null}function eh(s,{className:t,index:e,iconOnly:i,disclosure:n,disclosureIcon:r,visual:o}){let a=V(s.href),c=a&&!n?"a":"button";return l(c,{class:t,type:c==="button"?"button":null,href:c==="a"?a:null,target:c==="a"?s.target??null:null,rel:c==="a"?"noopener":null,ariaLabel:i?s.label:null,ariaDisabled:s.disabled?"true":null,dataset:{appNavId:e,appNavValueId:String(s.id)}},o?l("span",{class:`${t}-icon`,ariaHidden:"true"},o):null,l("span",{class:`${t}-label`},s.label),s.badge!=null?l("span",{class:`${t}-badge`},String(s.badge)):null,n?l("span",{class:`${t}-disclosure`,ariaHidden:"true"},g(r)):null)}function Vg(s){return{left:"chevron-right",right:"chevron-left",top:"chevron-down",bottom:"chevron-up"}[s]??"chevron-right"}function Pg(s){return s==="right"?"chevron-left":"chevron-right"}function Bg(s){return{left:"right-start",right:"left-start",top:"bottom-start",bottom:"top-start"}[s]??"right-start"}function jg(s){return s==="right"?"left-start":"right-start"}function Hg(s){return{left:"right",right:"left",top:"bottom",bottom:"top"}[s]??"right"}function nh(s){return[...s.querySelectorAll('a:not([aria-disabled="true"]), button:not([aria-disabled="true"])')]}function ih(s){return nh(s)[0]??null}function qg(s){return[...s.children].map(t=>t.querySelector("[data-app-nav-id]")).filter(Boolean)}function zr(s,t){return s.some(e=>String(e.id)===t||zr(e.children??[],t))}function sh(s,t){if(t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t=="object"&&typeof t.nodeType=="number"&&s.append(t)}var Tr=class extends m{static cssName="app-sidebar";static defaults={items:[],active:null,expanded:[],collapsed:!1,collapsible:!0,orientation:"vertical",side:"left",label:"Applications",header:null,footer:null,railHeader:null,railFooter:null,openDelay:80,closeDelay:160,renderIcon:null};constructor(t=null,e={}){super(t,e),this._rail=null,this._railExpandButton=null,this._renderMode()}render(){this._createdRoot=this.el===null;let t=this.el??l("aside");return this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,e=>[e.name,e.value]),children:Array.from(t.childNodes)},this._items=ue(this.options.items),this._active=this.options.active,this._expanded=new Set(Array.isArray(this.options.expanded)?this.options.expanded.map(String):[]),this._collapsed=!!this.options.collapsed,this._orientation=this.options.orientation==="horizontal"?"horizontal":"vertical",this._side=rh(this._orientation,this.options.side),this._modeAbort=null,t.replaceChildren(),t}setItems(t){return this._items=ue(t),this._reconcileExpanded(),this._rail?(this._rail.setItems(this._items),this._decorateRail()):this._renderTree(),this}getItems(){return this._items.map(t=>({...t,children:t.children?.map(e=>({...e}))}))}setActive(t){return this._active=t,this._rail?this._rail.setActive(t):this._syncActive(),this}setExpanded(t,{silent:e=!1}={}){return this._expanded=new Set(Array.isArray(t)?t.map(String):[]),this._reconcileExpanded(),this._rail||this._renderTree(),e||this.emit("branchchange",{item:null,id:null,expanded:null,ids:this.getExpanded()}),this}getExpanded(){let t=[];return Ir(this._items,e=>{this._expanded.has(String(e.id))&&t.push(e.id)}),t}toggleBranch(t,{silent:e=!1}={}){let i=Te(this._items,t);if(!i?.children?.length)return this;let n=String(t),r=!this._expanded.has(n);return r?this._expanded.add(n):this._expanded.delete(n),this._rail||(this._renderTree(),r&&this._markBranchMotion(n)),e||this.emit("branchchange",{item:i,id:i.id,expanded:r,ids:this.getExpanded()}),this}expand(t={}){return this.setCollapsed(!1,t)}collapse(t={}){return this.setCollapsed(!0,t)}setCollapsed(t,{silent:e=!1}={}){let i=this.isCollapsed(),n=document.activeElement,r=!!(n&&(this.el.contains(n)||this._rail?._containsNode(n)));this._collapsed=!!t;let o=this.isCollapsed();return i!==o&&(this._renderMode(),r&&(o?this._railExpandButton?.focus():this.refs.collapse?.focus()),e||this.emit("collapsechange",{collapsed:o})),this}isCollapsed(){return this._orientation==="horizontal"||this._collapsed}setLayout(t={},{silent:e=!1}={}){let i=t.orientation==="horizontal"?"horizontal":t.orientation==="vertical"?"vertical":this._orientation,n=rh(i,t.side??this._side);if(i===this._orientation&&n===this._side)return this;let r=this.isCollapsed(),o=document.activeElement,a=!!(o&&(this.el.contains(o)||this._rail?._containsNode(o))),c=a&&o instanceof Element?o.closest("[data-app-nav-id]")?.getAttribute("data-app-nav-id")??null:null;this._orientation=i,this._side=n,this._renderMode();let h=this.isCollapsed();if(a){let u=c===null?null:[...this.el.querySelectorAll("[data-app-nav-id]")].find(d=>d.getAttribute("data-app-nav-id")===c)??null;u instanceof HTMLElement?u.focus():h?this.focus():this.refs.collapse instanceof HTMLElement&&!this.refs.collapse.hidden?this.refs.collapse.focus():Ds(this.refs.list)[0]?.focus()}return r!==h&&!e&&this.emit("collapsechange",{collapsed:h}),this}openFlyout(t,e={}){return this._rail?.openFlyout(t,e),this}closeFlyout(t){return this._rail?.closeFlyout(t),this}closeAllFlyouts(){return this._rail?.closeAllFlyouts(),this}isFlyoutOpen(t){return this._rail?.isFlyoutOpen(t)??!1}focus(){return this._rail?this._rail.focus():Ds(this.refs.list)[0]?.focus(),this}destroy(){let t=this._original;if(this._modeAbort?.abort(),this._modeAbort=null,this._rail?.destroy(),this._rail=null,super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_renderMode(){this._modeAbort?.abort(),this._modeAbort=new AbortController,this._rail?.destroy(),this._rail=null,this._railExpandButton=null;for(let t of["expanded","list","collapse","rail"])delete this.refs[t];this.el.replaceChildren(),this.el.dataset.orientation=this._orientation,this.el.dataset.side=this._side,this.el.dataset.collapsed=String(this.isCollapsed()),this.isCollapsed()?this._renderRail():this._renderExpanded()}_renderExpanded(){let t=l("div",{class:"zx-app-sidebar__header-content"});Cr(t,this.options.header);let e=l("button",{class:"zx-app-sidebar__collapse zx-icon-btn",type:"button",ariaLabel:this._message("appSidebar.minimize","Minimize application sidebar")},g(this._side==="right"?"chevron-right":"chevron-left"));e.hidden=!this.options.collapsible;let i=l("footer",{class:"zx-app-sidebar__footer"});Cr(i,this.options.footer),i.hidden=!i.hasChildNodes();let n=l("ul",{class:"zx-app-sidebar__list"}),r=l("div",{class:"zx-app-sidebar__expanded"},l("header",{class:"zx-app-sidebar__header"},t,e),l("nav",{class:"zx-app-sidebar__nav",ariaLabel:this.options.label},n),i);this.refs.expanded=r,this.refs.list=n,this.refs.collapse=e,this.el.append(r),this._listenMode(e,"click",()=>this.collapse()),this._listenMode(n,"click",o=>this._onTreeClick(o)),this._listenMode(n,"keydown",o=>this._onTreeKeydown(o)),this._renderTree()}_renderRail(){let t=l("nav",{class:"zx-app-sidebar__rail"});this.el.append(t),this.refs.rail=t;let e=this._orientation==="vertical"&&!!this.options.collapsible,i=l("div",{class:"zx-app-sidebar__rail-header"});if(e){let n=l("button",{class:"zx-app-sidebar__rail-toggle zx-icon-btn",type:"button",ariaLabel:this._message("appSidebar.expand","Expand application sidebar")},g(this._side==="right"?"chevron-left":"chevron-right"));i.append(n),this._railExpandButton=n,this._listenMode(n,"click",()=>this.expand())}Cr(i,this.options.railHeader),this._rail=new Is(t,{items:this._items,active:this._active,orientation:this._orientation,side:this._side,label:this.options.label,header:i.hasChildNodes()?i:null,footer:this.options.railFooter,openDelay:this.options.openDelay,closeDelay:this.options.closeDelay,renderIcon:this.options.renderIcon,onselect:n=>{this.emit("select",n.detail).defaultPrevented&&n.preventDefault()},onflyoutchange:n=>this.emit("flyoutchange",n.detail)}),this._listenMode(t,"zx-select",n=>n.stopPropagation()),this._listenMode(t,"zx-flyoutchange",n=>n.stopPropagation()),this._decorateRail()}_decorateRail(){let t=this.refs.rail;if(t)for(let e of t.querySelectorAll(".zx-app-rail__item[data-app-nav-value-id]")){let i=e.querySelector(":scope > .zx-app-rail__item-badge");if(!i)continue;let n=Te(this._items,e.getAttribute("data-app-nav-value-id"));if(!n||n.badge==null)continue;let r=String(n.badge);i.dataset.zxBadge=r.length>2?"dot":"count",e.setAttribute("aria-label",this._message("appSidebar.itemBadge","%1 (%2)",n.label,r))}}_listenMode(t,e,i){t.addEventListener(e,i,{signal:this._modeAbort.signal})}_renderTree(){if(!this.refs.list)return;let t=this.refs.list.contains(document.activeElement)?document.activeElement.closest("[data-app-nav-id]")?.getAttribute("data-app-nav-id"):null;if(this.refs.list.replaceChildren(...this._items.map(e=>this._treeRow(e,1))),this._syncActive(),t!==null){let e=[...this.refs.list.querySelectorAll("[data-app-nav-id]")].find(i=>i.getAttribute("data-app-nav-id")===t)??null;Kg(e)?.focus()}}_treeRow(t,e){let i=t.children??[],n=i.length>0,r=String(t.id),o=n&&this._expanded.has(r),a=n?x("zx-app-sidebar-branch"):null,c=Es(t,this.options.renderIcon,{orientation:this._orientation,collapsed:!1,side:this._side,level:e,location:e===1?"root":"inline"}),h=$g(t,n,o,a,c),u=l("li",{class:"zx-app-sidebar__row",dataset:{level:e}},h);return n&&u.append(l("ul",{class:"zx-app-sidebar__sublist",id:a,hidden:!o},i.map(d=>this._treeRow(d,e+1)))),u}_onTreeClick(t){let e=t.target?.closest?.("[data-app-nav-id]");if(!e||!this.refs.list.contains(e))return;let i=Te(this._items,e.getAttribute("data-app-nav-id"));if(!i||i.disabled){t.preventDefault();return}i.children?.length?this.toggleBranch(i.id):this._select(i,t)}_onTreeKeydown(t){let e=t.target?.closest?.("[data-app-nav-id]");if(!(e instanceof HTMLElement))return;let i=Te(this._items,e.getAttribute("data-app-nav-id")),n=Ds(this.refs.list),r=n.indexOf(e);if(t.key==="ArrowRight"&&i?.children?.length){t.preventDefault(),this._expanded.has(String(i.id))?Ds(e.parentElement?.querySelector(".zx-app-sidebar__sublist"))[0]?.focus():this.toggleBranch(i.id);return}if(t.key==="ArrowLeft"){if(i?.children?.length&&this._expanded.has(String(i.id))){t.preventDefault(),this.toggleBranch(i.id);return}let c=e.closest(".zx-app-sidebar__sublist")?.parentElement?.querySelector(":scope > [data-app-nav-id]");c instanceof HTMLElement&&(t.preventDefault(),c.focus());return}let o;if(t.key==="Home")o=0;else if(t.key==="End")o=n.length-1;else if(t.key==="ArrowDown")o=Math.min(n.length-1,r+1);else if(t.key==="ArrowUp")o=Math.max(0,r-1);else return;t.preventDefault(),n[o]?.focus()}_select(t,e){if(t.disabled){e.preventDefault();return}this.emit("select",{item:t,id:t.id,value:t.value??t.id,href:t.href??null,event:e}).defaultPrevented?e.preventDefault():t.href||(e.preventDefault(),t.invoke?.())}_syncActive(){if(!this.refs.list)return;let t=this._active==null?null:String(this._active);for(let e of this.refs.list.querySelectorAll("[data-app-nav-id]")){let i=Te(this._items,e.getAttribute("data-app-nav-id")),n=t!==null&&e.getAttribute("data-app-nav-id")===t,r=t!==null&&i?oh(i.children??[],t):!1;n?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current"),r?e.dataset.activeDescendant="true":delete e.dataset.activeDescendant}}_markBranchMotion(t){if(!this.refs.list)return;let i=([...this.refs.list.querySelectorAll("[data-app-nav-id]")].find(n=>n.getAttribute("data-app-nav-id")===t)??null)?.parentElement?.querySelector(":scope > .zx-app-sidebar__sublist");i instanceof HTMLElement&&(i.dataset.branchMotion="expand")}_message(t,e,...i){let n=this.msg(t,...i);return n===t?I(e,i):n}_reconcileExpanded(){let t=new Set;Ir(this._items,e=>{e.children?.length&&t.add(String(e.id))});for(let e of this._expanded)t.has(e)||this._expanded.delete(e)}};function $g(s,t,e,i,n){let r=s.href&&!t?"a":"button";return l(r,{class:"zx-app-sidebar__item",type:r==="button"?"button":null,href:r==="a"?s.href:null,target:r==="a"?s.target??null:null,ariaDisabled:s.disabled?"true":null,ariaExpanded:t?String(e):null,ariaControls:i,dataset:{appNavId:String(s.id)}},n?l("span",{class:"zx-app-sidebar__item-icon",ariaHidden:"true"},n):null,l("span",{class:"zx-app-sidebar__item-label"},s.label),s.badge!=null?l("span",{class:"zx-app-sidebar__item-badge"},String(s.badge)):null,t?l("span",{class:"zx-app-sidebar__item-disclosure",ariaHidden:"true"},g(e?"chevron-down":"chevron-right")):null)}function Ds(s){return s?[...s.querySelectorAll("[data-app-nav-id]")].filter(t=>!t.closest(".zx-app-sidebar__sublist[hidden]")):[]}function Kg(s){let t=s;for(;t;){let e=t.closest(".zx-app-sidebar__sublist[hidden]");if(!e)return t;t=e.parentElement?.firstElementChild??null}return null}function Te(s,t){for(let e of s){if(String(e.id)===String(t))return e;let i=Te(e.children??[],t);if(i)return i}return null}function Ir(s,t){for(let e of s)t(e),Ir(e.children??[],t)}function oh(s,t){return s.some(e=>String(e.id)===t||oh(e.children??[],t))}function Cr(s,t){if(t!=null)if(typeof t=="string"||typeof t=="number")s.append(document.createTextNode(String(t)));else if(typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();e&&s.append(e)}else typeof t=="object"&&typeof t.nodeType=="number"&&s.append(t)}function rh(s,t){return s==="horizontal"?t==="bottom"?"bottom":"top":t==="right"?"right":"left"}var Dr=class{#t;#e=[];#i=[];#s;constructor(t=5,e=()=>{}){if(!Number.isInteger(t)||t<1)throw new RangeError("Queue limit must be positive");if(typeof e!="function")throw new TypeError("Activation callback must be a function");this.#t=t,this.#s=e}enqueue(t){return this.#e.length<this.#t?(this.#e.push(t),this.#s(t),"active"):(this.#i.push(t),"pending")}remove(t){let e=this.#i.indexOf(t);if(e!==-1)return this.#i.splice(e,1),"pending";let i=this.#e.indexOf(t);if(i===-1)return null;if(this.#e.splice(i,1),this.#i.length>0){let n=this.#i.shift();this.#e.push(n),this.#s(n)}return"active"}isActive(t){return this.#e.includes(t)}clear(){let t={active:this.#e.slice(),pending:this.#i.slice()};return this.#e.length=0,this.#i.length=0,t}get activeCount(){return this.#e.length}get pendingCount(){return this.#i.length}},Mr=class s extends m{static cssName="message";static defaults={kind:"info",timeout:4e3,closable:!0,maxVisible:5};static#t=new WeakMap;render(){let t=!this.el,e=this.el??l("div");return this._createdRoot=t,this._original=t?null:Jg(e),this._entries=new Set,this._queue=new Dr(Wg(this.options.maxVisible),i=>{this._activate(i)}),e.replaceChildren(),e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e}show(t,e={}){let i={kind:Ug(e.kind??this.options.kind),timeout:Yg(e.timeout??this.options.timeout),closable:e.closable??!!this.options.closable},n=this._createEntry(t,i);return this._entries.add(n),this._queue.enqueue(n),{close:()=>this._close(n)}}static info(t,e={}){return this.show(t,{...e,kind:"info"})}static success(t,e={}){return this.show(t,{...e,kind:"success"})}static warning(t,e={}){return this.show(t,{...e,kind:"warning"})}static error(t,e={}){return this.show(t,{...e,kind:"error"})}static show(t,e={}){return this.#e(e.scope).show(t,e)}static progress(t,e={}){return this.#e(e.scope)._progress(t)}destroy(){if(!this._cleaned){this._cleaned=!0;for(let t of this._entries)Er(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&Zg(this.el,this._original)}}_progress(t){let e={pct:0,text:String(t)},i=this._createEntry(e.text,{kind:"info",timeout:0,closable:!1},e);this._entries.add(i),this._queue.enqueue(i);let n=!1;return{update:(r,o)=>{n||i.closed||(e.pct=Qg(r),o!==void 0&&(e.text=String(o)),Ms(i,e))},done:()=>{n||i.closed||(n=!0,e.pct=100,Ms(i,e),i.remaining=600,this._queue.isActive(i)&&this._schedule(i))},fail:r=>{n||i.closed||(n=!0,r!==void 0&&(e.text=String(r)),i.kind="error",i.node.dataset.kind="error",i.node.setAttribute("role","alert"),i.iconHost.replaceChildren(g("error",{size:18})),Ms(i,e),i.remaining=4e3,this._queue.isActive(i)&&this._schedule(i))}}}_createEntry(t,e,i=null){let n=l("span",{class:"zx-message__icon",ariaHidden:"true"},g(e.kind,{size:18})),r=l("div",{class:"zx-message__content"});Gg(t)?r.append(t):r.append(document.createTextNode(String(t)));let o=l("div",{class:"zx-message__toast",role:e.kind==="error"?"alert":"status",dataset:{kind:e.kind,state:"queued"}},n,r),a={node:o,content:r,iconHost:n,kind:e.kind,timeout:e.timeout,remaining:e.timeout,startedAt:0,timer:null,exitTimer:null,closed:!1,progressBar:null,progressFill:null};if(i){o.dataset.progress="";let c=l("span",{class:"zx-message__progress-fill"}),h=l("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:i.text},c);r.append(h),a.progressBar=h,a.progressFill=c,Ms(a,i)}if(e.closable){let c=l("button",{class:"zx-icon-btn zx-message__close",type:"button",ariaLabel:this._message("message.close","Close message"),title:this._message("message.closeTitle","Close")},g("x",{size:14}));o.append(c),this.listen(c,"click",()=>this._close(a))}return this.listen(o,"mouseenter",()=>this._pause(a)),this.listen(o,"mouseleave",()=>this._resume(a)),a}_activate(t){t.closed||(t.node.dataset.state="open",this.el.append(t.node),this._schedule(t))}_schedule(t){t.closed||t.remaining<=0||(t.startedAt=Date.now(),t.timer=setTimeout(()=>this._close(t),t.remaining))}_pause(t){t.closed||t.timer===null||(clearTimeout(t.timer),t.timer=null,t.remaining=Math.max(0,t.remaining-(Date.now()-t.startedAt)))}_resume(t){if(!(t.closed||t.timer!==null)){if(t.remaining<=0){this._close(t);return}this._schedule(t)}}_close(t){if(t.closed)return;if(t.closed=!0,Er(t),!this._queue.isActive(t)){this._queue.remove(t),t.node.remove(),this._entries.delete(t);return}if(t.node.dataset.state="closing",!Xg()){this._finish(t);return}let e=i=>{i.target===t.node&&this._finish(t)};this.listen(t.node,"animationend",e,{once:!0}),t.exitTimer=setTimeout(()=>this._finish(t),260)}_finish(t){this._entries.has(t)&&(Er(t),t.node.remove(),this._entries.delete(t),this._queue.remove(t))}_message(t,e){let i=this.msg(t);return i===t?e:i}static#e(t){let e=rt(t??null),i=this.#t.get(e);if(i)return i;let n=l("div",{class:"zx-message-region",popover:"manual",role:"status",ariaLive:"polite"});e.append(n);let r=new s(n);return this.#t.set(e,r),typeof n.showPopover=="function"&&n.showPopover(),r}};function Ug(s){return s==="danger"?"error":["success","warning","error"].includes(String(s))?s:"info"}function Yg(s){let t=Number(s);return Number.isFinite(t)?Math.max(0,t):4e3}function Wg(s){let t=Number(s);return Number.isInteger(t)&&t>0?t:5}function Gg(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Qg(s){let t=Number(s);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function Ms(s,t){s.content.firstChild.textContent=t.text,s.progressBar?.setAttribute("aria-valuenow",String(t.pct)),s.progressBar?.setAttribute("aria-label",t.text),s.progressFill&&(s.progressFill.style.inlineSize=`${t.pct}%`)}function Er(s){s.timer!==null&&clearTimeout(s.timer),s.exitTimer!==null&&clearTimeout(s.exitTimer),s.timer=null,s.exitTimer=null}function Xg(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function Jg(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Zg(s,t){for(let e of Array.from(s.attributes))s.removeAttribute(e.name);for(let[e,i]of t.attributes)s.setAttribute(e,i);s.replaceChildren(...t.children)}var tb=new Set(["start","end","top","bottom"]),eb=new Set(["dim","blur","none"]),ib=Object.freeze({start:1,end:-1,top:1,bottom:-1}),Nr=class extends Yt{static cssName="sheet";static defaults={side:"end",modal:!0,backdrop:"dim",size:null,closeButton:!0,resizable:!1,min:160,max:null,handle:"auto",snap:null,lightDismiss:!0};#t=null;#e=null;#i=0;constructor(t=null,e={}){super(null,e),this._dock=null,this.setSide(this.options.side),this.el.dataset.backdrop=eb.has(this.options.backdrop)?this.options.backdrop:"dim",this.el.dataset.modality=rb(this.options.modal),this.refs.close.hidden=!this.options.closeButton,this.options.modal!==!0&&(this.listen(this.el,"keydown",i=>{let n=i;n.key!=="Escape"||!this.options.closable||this._dock||(n.preventDefault(),this.emit("cancel").defaultPrevented||this.close())}),this.options.lightDismiss&&this.listen(document,"pointerdown",i=>{let n=i.target;!this.isOpen()||this._dock||this.el.contains(n)||this.close()})),this.on("close",()=>this.#t?.deactivate()),this.#s()&&this.#r()}#s(){let t=this.options.handle,e=this.getSide(),i=t===!0||t==="auto"&&(e==="top"||e==="bottom");return!!this.options.resizable||Array.isArray(this.options.snap)||i}#r(){let t=this.getSide()==="top"||this.getSide()==="bottom",e=l("div",{class:"zx-sheet__handle",ref:"handle",role:"separator",tabindex:0,ariaOrientation:t?"horizontal":"vertical",ariaLabel:this._message("sheet.resize","Resize sheet")});this.el.append(e),this.refs.handle=e,this.#c(),this.#e=ze(e,{orientation:t?"vertical":"horizontal",disabled:()=>this.isDocked(),onStart:()=>{this.#i=this.getSize(),this.el.dataset.dragging="true"},onMove:i=>this.#n(i,!1),onEnd:(i,n)=>{delete this.el.dataset.dragging,n&&this.#n(i,!0)},onStep:(i,n)=>{this.#i=this.getSize(),this.#n(i*(n?64:16),!0)}})}#n(t,e){let i=this.#o(),{min:n,max:r}=this.#a(i),a=!!this.options.resizable||this.#l(i).length>0?r:Math.min(r,this.#i),c=B(this.#i+t*ib[this.getSide()],0,a);if(!e){this._applySize(c),this.#c();return}if(this.options.closable&&c<n/2){this._applySize(this.#i),this.close();return}let h=this.#l(i),u=h.length>0?nb(c,h):c;this._applySize(B(u,n,a)),this.#c(),this.emit("resize",{size:this.getSize(),ratio:i>0?this.getSize()/i:0})}snapTo(t){let e=this.#o(),i=this.#l(e);if(i.length===0)return this;let n=typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<i.length?i[t]:ah(t,e);if(!Number.isFinite(n))return this;let{min:r,max:o}=this.#a(e);return this._applySize(B(n,r,o)),this.#c(),this.emit("resize",{size:this.getSize(),ratio:e>0?this.getSize()/e:0}),this}getSize(){let t=this.el.getBoundingClientRect();return this.getSide()==="top"||this.getSide()==="bottom"?t.height:t.width}_message(t,e){let i=this.msg(t);return i===t?e:i}#o(){return this.getSide()==="top"||this.getSide()==="bottom"?window.innerHeight:window.innerWidth}#a(t){let e=this.#l(t),i=Math.max(0,Number(this.options.min)||0),n=this.options.max==null?t:Math.min(t,Number(this.options.max)||t),r=e.length>0?Math.max(i,Math.min(...e)):i;return{min:Math.min(r,n),max:n}}#l(t){let e=this.options.snap;return Array.isArray(e)?e.map(i=>ah(i,t)).filter(i=>Number.isFinite(i)&&i>0).sort((i,n)=>i-n):[]}#c(){let t=this.refs.handle;if(!t)return;let e=this.#o(),{min:i,max:n}=this.#a(e);t.setAttribute("aria-valuenow",String(Math.round(this.getSize()))),t.setAttribute("aria-valuemin",String(Math.round(i))),t.setAttribute("aria-valuemax",String(Math.round(n)))}mountTarget(){return this._dock?.el??super.mountTarget()}isDocked(){return!!this._dock}_setDock(t){this._dock!==t&&(this._dock=t??null,this.el.toggleAttribute("data-docked",!!this._dock),this._rehost(),this.emit("dockchange",{docked:!!this._dock,dock:this._dock}))}_rehost(){let t=this.isOpen();t&&this._dismiss(),this.mountTarget().append(this.el),t&&(this.el.returnValue="",this._present(),this.el.dataset.state="open",this._dock?delete this.el.dataset.zxOverlayOrder:this.el.dataset.zxOverlayOrder=String(sb()))}open(){return this.isOpen()?this:(this.options.modal==="trap-focus"&&(this.#t??=In(this.el),this.#t.activate()),super.open(),this.#c(),this)}close(t){return this.#t?.deactivate(),super.close(t)}setSide(t){return this.el.dataset.side=tb.has(t)?t:"end",this}getSide(){return this.el.dataset.side}setSize(t){return this._applySize(t),this}isModal(){return this.options.modal===!0}_applySize(t){this.el.style.removeProperty("inline-size"),this.el.style.removeProperty("block-size");let e=ob(t);e===null?this.el.style.removeProperty("--zx-sheet-size"):this.el.style.setProperty("--zx-sheet-size",e)}_show(){if(this.options.modal===!0&&!this._dock){this.el.removeAttribute("popover"),this.el.removeAttribute("aria-modal"),super._show();return}if(this.el.setAttribute("aria-modal","false"),this._dock){this.el.removeAttribute("popover"),this.el.show();return}this.el.setAttribute("popover","manual"),this.el.showPopover()}_hide(t="",e){if(!this.el.matches(":popover-open")){super._hide(t,e);return}this.el.returnValue=t,this.el.hidePopover(),queueMicrotask(()=>this._settleClose(e))}_isShown(){return this.el.matches(":popover-open")||super._isShown()}destroy(){this.#t?.deactivate(),this.#t=null,this.#e?.destroy(),this.#e=null,this._dock?._forget(this),this._dock=null,super.destroy()}};function sb(){let s=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...s)+1}function ah(s,t){return typeof s=="number"&&Number.isFinite(s)&&s>0&&s<=1?s*t:gt(s,t)}function nb(s,t){let e=s,i=Number.POSITIVE_INFINITY;for(let n of t){let r=Math.abs(n-s);r<i&&(i=r,e=n)}return e}function rb(s){return s===!0?"modal":s==="trap-focus"?"trap-focus":"none"}function ob(s){return s==null||s===""?null:typeof s=="number"?Number.isFinite(s)?`${Math.max(0,s)}px`:null:String(s)}var Or=class s extends EventTarget{static defaults=Object.freeze({layout:"stack",offset:24,scale:.04,max:3});#t=[];#e=new WeakMap;#i=!1;constructor(t={}){super();let e={...s.defaults,...t&&typeof t=="object"?t:{}};for(let[i,n]of Object.entries(e))!/^on[a-z]/.test(i)||typeof n!="function"||(this.on(i.slice(2),n),delete e[i]);this.options=Object.freeze(e)}push(t){if(!t||typeof t.open!="function")throw new TypeError("SheetStack.push expects a Sheet");let e=this.#t.indexOf(t);if(e!==-1&&this.#t.splice(e,1),this.#t.push(t),!this.#e.has(t)){let i=()=>this.#s(t);this.#e.set(t,i),t.on("close",i)}return t.isOpen()||t.open(),this.#n(),this.#o("push",{sheet:t,depth:0}),this}pop(){let t=this.top();return t?(this.#r(t),t.close(),t):null}popTo(t){let e=this.#t.indexOf(t);if(e===-1)return this;for(;this.#t.length>e+1;)this.pop();return this}clear(){for(;this.#t.length>0;)this.pop();return this}top(){return this.#t[this.#t.length-1]??null}size(){return this.#t.length}sheets(){return[...this.#t]}has(t){return this.#t.includes(t)}on(t,e){return this.addEventListener(t,e),this}off(t,e){return this.removeEventListener(t,e),this}once(t,e){return this.addEventListener(t,e,{once:!0}),this}destroy(){if(!this.#i){this.#i=!0;for(let t of this.#t){let e=this.#e.get(t);e&&t.off("close",e),lh(t)}this.#t=[]}}#s(t){this.#t.includes(t)&&this.#r(t)}#r(t){let e=this.#t.indexOf(t);if(e===-1)return;this.#t.splice(e,1);let i=this.#e.get(t);i&&t.off("close",i),this.#e.delete(t),lh(t),this.#n(),this.#o("pop",{sheet:t})}#n(){let{layout:t,offset:e,scale:i,max:n}=this.options,r=t==="cascade",o=0;for(let a=0;a<this.#t.length;a+=1){let c=this.#t[this.#t.length-1-a],h=c.el;h.dataset.stack=r?"cascade":"stack",h.dataset.depth=String(a),h.style.setProperty("--zx-sheet-depth",String(a)),h.style.setProperty("--zx-sheet-stack-offset",`${Number(e)||0}px`),h.style.setProperty("--zx-sheet-stack-scale",String(Number(i)||0)),h.toggleAttribute("data-stack-hidden",a>=Math.max(1,Number(n)||1)),h.inert=!r&&a>0,r?(h.style.setProperty("--zx-sheet-depth-offset",`${o}px`),o+=c.getSize()):h.style.removeProperty("--zx-sheet-depth-offset")}}#o(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))}};function lh(s){let t=s.el;if(t){delete t.dataset.stack,delete t.dataset.depth,t.removeAttribute("data-stack-hidden"),t.inert=!1;for(let e of["--zx-sheet-depth","--zx-sheet-stack-offset","--zx-sheet-stack-scale","--zx-sheet-depth-offset"])t.style.removeProperty(e)}}var Ci=class extends m{static defaults={items:[],selector:null};#t;#e;#i;#s;#r;#n=[];#o=null;#a=null;#l=!1;constructor(t,e={}){let i=q(t);if(!i)throw new TypeError("ContextMenu target could not be resolved");super(null,e),this.#t=i,document.body.append(this.el),this.#e=new _t(this.el,{openOn:"manual",placement:"bottom-start",scope:i}),this.#i=this.#e.getPanel(),this.#i.classList.add("zx-context-menu"),this.#i.setAttribute("role","menu"),Array.isArray(this.options.items)&&this.setItems(this.options.items),this.#s=Dt(this.#i,At),this.#r=ht(()=>this.#m(),n=>n.focus()),this.#e.on("close",()=>{this.#o=null;let n=this.#a;this.#a=null,n instanceof HTMLElement&&n.isConnected&&n.focus(),this.emit("close")}),this.listen(this.#t,"contextmenu",n=>this.#u(n)),this.listen(this.#t,"keydown",n=>this.#d(n)),this.listen(this.#i,"click",n=>{let r=n.target.closest?.(At);r&&this.#i.contains(r)&&this.#_(r,n)}),this.listen(this.#i,"keydown",n=>this.#p(n))}render(){return l("span",{class:"zx-context-menu__anchor",ariaHidden:"true"})}setItems(t){return this.#n=Array.isArray(t)?t.slice():[],this.#i.replaceChildren(...hs(this.#n,"context-menu")),this}openAt(t,e,i=null){return this.#c(i)?(this.#h(t,e,i),this):this}openAtElement(t){let e=t.getBoundingClientRect();return this.openAt(e.left,e.bottom,t)}close(){return this.#e.close(),this}isOpen(){return this.#e.isOpen()}getContext(){return this.#o}destroy(){this.#l||(this.#l=!0,this.#s.destroy(),this.#e.destroy(),super.destroy())}#c(t){let e=this.options.items;if(typeof e=="function"){let i=e(t);if(!Array.isArray(i)||i.length===0)return!1;this.setItems(i)}return this.#n.length>0}#h(t,e,i){let n=this.el;n.style.left=`${t}px`,n.style.top=`${e}px`,this.#o=i,this.#a=document.activeElement,this.#e.open(),this.#s.focusFirst(),this.emit("open",{context:i})}#u(t){let e=t,i=this.#f(e.target);!i||!this.#c(i)||(t.preventDefault(),this.#h(e.clientX,e.clientY,i))}#d(t){let e=t;if(e.key!=="ContextMenu"&&!(e.key==="F10"&&e.shiftKey))return;let i=this.#f(e.target);if(!i||!this.#c(i))return;t.preventDefault();let n=i.getBoundingClientRect();this.#h(n.left,n.bottom,i)}#f(t){if(!this.options.selector)return this.#t;let e=t?.closest?.(String(this.options.selector));return e&&this.#t.contains(e)?e:null}#p(t){let e=t;if(e.key==="Escape"||e.key==="Tab"){t.preventDefault(),this.close();return}if(e.key==="Enter"||e.key===" "){let i=e.target.closest?.(At);if(!i||!this.#i.contains(i)||e.key==="Enter"&&i.tagName==="A")return;t.preventDefault(),i.click();return}this.#r(e)}#_(t,e=null){let i=Number(t.getAttribute("data-menu-item")),n=this.#n[i];if(!mi(n)||n.disabled){e?.preventDefault();return}let r=this.#o;if(this.emit("select",{value:n.value,item:n,context:r}).defaultPrevented){e?.preventDefault();return}try{n.onselect?.(n.value,n,this)}finally{this.close()}}#m(){return Array.from(this.#i.querySelectorAll(At))}};var Os=Object.freeze(["agenda","day","week","month","year"]),ab=864e5;function Lr(s,t,e={}){let i=de(t,"Calendar date"),n=_h(e.weekStart??1),r,o;if(s==="agenda")r=W(i),o=L(r,Ls(e.agendaDays??14,"agendaDays"));else if(s==="day")r=W(i),o=L(r,1);else if(s==="week")r=Ns(i,n),o=L(r,7);else if(s==="month"){let a=new Date(i.getFullYear(),i.getMonth(),1),c=new Date(i.getFullYear(),i.getMonth()+1,0);r=Ns(a,n),o=L(Ns(c,n),7)}else if(s==="year")r=new Date(i.getFullYear(),0,1),o=new Date(i.getFullYear()+1,0,1);else throw new RangeError(`Unknown calendar view: ${s}`);return{start:r,end:o}}function Rr(s,t,e,i={}){let n=de(t,"Calendar date"),r=Vt(e,"direction");if(s==="day")n.setDate(n.getDate()+r);else if(s==="agenda")n.setDate(n.getDate()+r*Ls(i.agendaDays??14,"agendaDays"));else if(s==="week")n.setDate(n.getDate()+r*7);else{if(s==="month")return Fr(n,r);if(s==="year")return Fr(n,r*12);throw new RangeError(`Unknown calendar view: ${s}`)}return n}function Fr(s,t){let e=de(s,"Calendar date"),i=e.getDate();return e.setDate(1),e.setMonth(e.getMonth()+Vt(t,"month amount")),e.setDate(Math.min(i,lb(e.getFullYear(),e.getMonth()))),e}function lb(s,t){return new Date(s,t+1,0).getDate()}function Ie(s,t={}){if(!Array.isArray(s))throw new TypeError("Calendar events must be an array");let e={id:t.eventId??"id",title:t.eventTitle??"title",start:t.eventStart??"start",end:t.eventEnd??"end",allDay:t.eventAllDay??"allDay",color:t.eventColor??"color",location:t.eventLocation??"location",editable:t.eventEditable??"editable",durationEditable:t.eventDurationEditable??"durationEditable"},i=t.dateUnit==="seconds"?"seconds":"milliseconds",n=new Set;return s.map((r,o)=>{if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError(`Calendar event at index ${o} must be an object`);let a=Rt(r,e.id);if(a==null||a==="")throw new TypeError(`Calendar event at index ${o} requires an id`);let c=String(a);if(n.has(c))throw new RangeError(`Duplicate Calendar event id: ${c}`);n.add(c);let h=hh(Rt(r,e.start),i,`event ${c} start`),u=Rt(r,e.end),d=u==null||u===""?new Date(h.getTime()):hh(u,i,`event ${c} end`);if(d<h)throw new RangeError(`Calendar event ${c} ends before it starts`);let p=String(Rt(r,e.title)??"").trim()||"Untitled event",f=String(Rt(r,e.location)??"").trim(),_=uh(Rt(r,e.editable)),b=uh(Rt(r,e.durationEditable));return{id:a,title:p,start:h,end:d,allDay:!!Rt(r,e.allDay),color:hb(Rt(r,e.color)),location:f,editable:_,durationEditable:b,data:r}})}function G(s){return{...s,start:new Date(s.start.getTime()),end:new Date(s.end.getTime())}}function Vr(s,t,e={}){let i=ph(e.minMinutes??0,"minMinutes"),n=ph(e.maxMinutes??1440,"maxMinutes",!0),r=Ls(e.minimumMinutes??30,"minimumMinutes");if(n<=i)throw new RangeError("Calendar maxMinutes must exceed minMinutes");let o=W(t),a=dh(o,i),c=dh(o,n),h=s.filter(f=>!zt(f)&&Pr(f,a,c)).map(f=>{let _=new Date(Math.max(f.start.getTime(),a.getTime())),b=new Date(Math.min(f.end.getTime(),c.getTime()));return b<=_&&(b=new Date(Math.min(c.getTime(),_.getTime()+r*6e4))),{event:f,start:_,end:b,startMinutes:fh(o,_),endMinutes:fh(o,b),column:0,columns:1}}).sort((f,_)=>f.start-_.start||_.end-f.end||String(f.event.id).localeCompare(String(_.event.id))),u=[],d=-1/0,p=()=>{if(!u.length)return;let f=[],_=1;for(let b of u){let w=f.findIndex(y=>y<=b.start.getTime());w===-1&&(w=f.length),f[w]=b.end.getTime(),b.column=w,_=Math.max(_,w+1)}for(let b of u)b.columns=_;u=[],d=-1/0};for(let f of h)u.length&&f.start.getTime()>=d&&p(),u.push(f),d=Math.max(d,f.end.getTime());return p(),h}function Fs(s,t,e){let i=W(t),n=L(i,Ls(e,"days")),r=s.filter(a=>zt(a)&&Pr(a,i,n)).map(a=>{let c=W(a.start),h=cb(a);return{event:a,start:Math.max(0,kt(i,c)),end:Math.min(e,kt(i,h)),lane:0}}).filter(a=>a.end>a.start).sort((a,c)=>a.start-c.start||c.end-a.end||String(a.event.id).localeCompare(String(c.event.id))),o=[];for(let a of r){let c=o.findIndex(h=>h<=a.start);c===-1&&(c=o.length),a.lane=c,o[c]=a.end}return r}function Ti(s,t={}){let e=Vt(t.days??0,"days"),i=Vt(t.minutes??0,"minutes"),n=Vt(t.endDays??e,"endDays"),r=Vt(t.endMinutes??i,"endMinutes"),o=G(s);if(o.start=ch(o.start,e,i),o.end=ch(o.end,n,r),o.end<o.start)throw new RangeError("Calendar event proposal ends before it starts");return o}function W(s){let t=de(s,"Calendar date");return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function L(s,t){let e=de(s,"Calendar date"),i=new Date(e.getTime());return i.setDate(i.getDate()+Vt(t,"day amount")),i}function Ns(s,t=1){let e=W(s),i=_h(t);return L(e,-((e.getDay()-i+7)%7))}function kt(s,t){let e=W(s),i=W(t),n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(i.getFullYear(),i.getMonth(),i.getDate());return Math.round((r-n)/ab)}function Q(s){let t=de(s,"Calendar date"),e=i=>String(i).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function zt(s){if(s.allDay)return!0;if(s.end<=s.start)return!1;let t=new Date(s.end.getTime()-1);return Q(s.start)!==Q(t)}function Ii(s,t,e){return Pr(s,t,e)}function ch(s,t,e){let i=new Date(s.getTime());return i.setDate(i.getDate()+t),i.setMinutes(i.getMinutes()+e),i}function cb(s){if(s.end<=s.start)return L(W(s.start),1);let t=W(s.end);return s.end.getTime()===t.getTime()?t:L(t,1)}function Pr(s,t,e){let i=s.end>s.start?s.end:new Date(s.start.getTime()+1);return s.start<e&&i>t}function Rt(s,t){return typeof t=="function"?t(s):s[t]}function hh(s,t,e){let i;if(s instanceof Date)i=new Date(s.getTime());else if(typeof s=="number"||typeof s=="string"&&/^-?\d+(?:\.\d+)?$/.test(s.trim())){let n=Number(s);i=new Date(n*(t==="seconds"?1e3:1))}else i=new Date(s);return de(i,e)}function uh(s){return s==null?null:!!s}function hb(s){let t=String(s??"").trim();return!t||t.length>100||/[;{}]|url\s*\(|image\s*\(/i.test(t)?null:/^#[\da-f]{3,8}$/i.test(t)||/^(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color)\([^{};]+\)$/i.test(t)||/^var\(--[\w-]+\)$/i.test(t)||/^[a-z]+$/i.test(t)?t:null}function dh(s,t){let e=W(s);return e.setMinutes(t),e}function fh(s,t){return(t.getTime()-s.getTime())/6e4}function de(s,t){if(!(s instanceof Date)||Number.isNaN(s.getTime()))throw new TypeError(`${t} must be a valid Date`);return new Date(s.getTime())}function _h(s){let t=Number(s);if(!Number.isInteger(t)||t<0||t>6)throw new RangeError("weekStart must be from 0 through 6");return t}function Vt(s,t){let e=Number(s);if(!Number.isInteger(e))throw new TypeError(`${t} must be an integer`);return e}function Ls(s,t){let e=Vt(s,t);if(e<=0)throw new RangeError(`${t} must be greater than zero`);return e}function ph(s,t,e=!1){let i=Vt(s,t),n=e?1440:1439;if(i<0||i>n)throw new RangeError(`${t} must be from 0 through ${n}`);return i}var ub={today:"Today",new:"New",agenda:"Agenda",day:"Day",week:"Week",month:"Month",year:"Year",previous:"Previous period",next:"Next period",allDay:"All day",noEvents:"No events",more:"+%1 more",loading:"Loading calendar\u2026",move:"Move %1",resize:"Resize %1",moveStarted:"Moving %1. Use arrow keys, Space to drop, or Escape to cancel.",resizeStarted:"Resizing %1. Use arrow keys, Space to drop, or Escape to cancel.",editPreview:"%1, %2 to %3",editCancelled:"Calendar edit cancelled.",editCommitted:"%1 updated.",calendar:"Calendar",weekNumber:"Week %1"},jr=class extends m{static cssName="calendar";static defaults={events:[],date:null,view:"month",views:[...Os],weekStart:1,weekNumbers:!0,workweek:!1,agendaDays:14,slotDuration:30,slotMinTime:0,slotMaxTime:1440,scrollTime:480,eventLimit:3,selectable:!1,editable:!1,eventStartEditable:null,eventDurationEditable:null,optimistic:!0,nowIndicator:!0,now:null,disabled:!1,eventId:"id",eventTitle:"title",eventStart:"start",eventEnd:"end",eventAllDay:"allDay",eventColor:"color",eventLocation:"location",eventEditable:"editable",eventDurationEditable:"durationEditable",dateUnit:"milliseconds",msg:ub};render(){let t=!this.el,e=this.el??l("section");this.el||(this.el=e),this._createdRoot=t,this._original=this._createdRoot?null:{attributes:Array.from(e.attributes).map(({name:d,value:p})=>[d,p]),children:Array.from(e.childNodes)},this._views=db(this.options.views),this._view=this._views.includes(this.options.view)?this.options.view:this._views[0],this._date=mh(this.options.date,this.options.dateUnit,this._now()),this._events=Ie(this.options.events,this._normalizeOptions()),this._loading=!1,this._destroyed=!1,this._pointer=null,this._keyboardEdit=null,this._mutationVersions=new Map,this._mutationSerial=0,this._suppressClickId=null,this._suppressDateClick=!1,this._focusedSlot=null,this._selection=null,this._nowTimer=null;let i=l("div",{class:"zx-calendar__navigation"},this._toolbarButton("previous",this.msg("previous"),"chevron-left"),this._toolbarButton("today",this.msg("today")),this._toolbarButton("next",this.msg("next"),"chevron-right")),n=l("h2",{ref:"heading",class:"zx-calendar__heading",ariaLive:"polite"}),r=l("div",{ref:"views",class:"zx-calendar__views",role:"group",ariaLabel:this._message("calendar.viewSwitch","Calendar view")},this._views.map(d=>l("button",{type:"button",class:"zx-calendar__view-button",dataset:{calendarAction:"view",view:d},disabled:this.options.disabled},this.msg(d)))),o=l("div",{class:"zx-calendar__commands"},r,l("button",{type:"button",class:"zx-calendar__new",dataset:{calendarAction:"new"},disabled:this.options.disabled},g("plus"),l("span",{},this.msg("new")))),a=l("header",{class:"zx-calendar__toolbar"},i,n,o),c=l("div",{ref:"body",class:"zx-calendar__body"}),h=l("div",{ref:"loading",class:"zx-calendar__loading",role:"status",hidden:!0},this.msg("loading")),u=l("div",{ref:"status",class:"zx-calendar__status",role:"status",ariaLive:"polite",ariaAtomic:"true"});return e.replaceChildren(a,c,h,u),e.setAttribute("aria-label",this.msg("calendar")),e.dataset.view=this._view,e.dataset.state="ready",this.listen(e,"click",d=>this._onClick(d)),this.listen(e,"dblclick",d=>this._onDoubleClick(d)),this.listen(e,"keydown",d=>this._onKeydown(d)),this.listen(e,"pointerdown",d=>this._onPointerDown(d)),this.listen(e,"pointermove",d=>this._onPointerMove(d)),this.listen(e,"pointerup",d=>this._onPointerUp(d)),this.listen(e,"pointercancel",d=>this._cancelPointer(d)),this.listen(e,"dragstart",d=>d.preventDefault()),this._renderView({emitDates:!0,scroll:!0}),this.options.nowIndicator&&(this._nowTimer=setInterval(()=>this._refreshNowIndicator(),6e4)),e}getEvents(){return this._events.map(G)}setEvents(t,e={}){let i=Ie(t,this._normalizeOptions());return this._events=i,this._mutationVersions.clear(),this._renderView({preserveFocus:!0}),e.silent||this.emit("eventschange",{events:this.getEvents()}),this}addEvent(t,e={}){let[i]=Ie([t],this._normalizeOptions());if(this._eventById(i.id))throw new RangeError(`Duplicate Calendar event id: ${i.id}`);return this._events=[...this._events,i],this._renderView({preserveFocus:!0}),e.silent||this.emit("eventschange",{events:this.getEvents()}),this}updateEvent(t,e,i={}){let n=this._eventIndex(t);if(n<0)throw new RangeError(`Unknown Calendar event id: ${t}`);let r=this._events[n],o={id:r.id,title:e.title??r.title,start:e.start??r.start,end:e.end??r.end,allDay:e.allDay??r.allDay,color:Object.prototype.hasOwnProperty.call(e,"color")?e.color:r.color,location:e.location??r.location,editable:Object.prototype.hasOwnProperty.call(e,"editable")?e.editable:r.editable,durationEditable:Object.prototype.hasOwnProperty.call(e,"durationEditable")?e.durationEditable:r.durationEditable,data:e.data??r.data},[a]=Ie([o],{dateUnit:this.options.dateUnit});return a.data=o.data,this._events=this._events.map((c,h)=>h===n?a:c),this._mutationVersions.delete(String(t)),this._renderView({preserveFocus:!0}),i.silent||this.emit("eventschange",{events:this.getEvents()}),this}removeEvent(t,e={}){let i=String(t),n=this._events.filter(r=>String(r.id)!==i);return n.length===this._events.length?this:(this._events=n,this._mutationVersions.delete(i),this._renderView({preserveFocus:!0}),e.silent||this.emit("eventschange",{events:this.getEvents()}),this)}getDate(){return new Date(this._date.getTime())}setDate(t,e={}){return this._date=mh(t,this.options.dateUnit,this._now()),this._renderView({emitDates:!e.silent,preserveFocus:!0,scroll:!0}),this}getView(){return this._view}setView(t,e={}){if(!this._views.includes(t))throw new RangeError(`Calendar view is not enabled: ${t}`);if(t===this._view)return this;let i=this._view;return this._view=t,this.el.dataset.view=t,this._renderView({emitDates:!0,preserveFocus:!0,scroll:!0}),e.silent||this.emit("viewchange",{view:t,oldView:i}),this}prev(){return this._page(-1)}next(){return this._page(1)}today(){return this.setDate(this._now())}setLoading(t=!0){return this._loading=!!t,this.el.dataset.state=this._loading?"loading":"ready",this.el.setAttribute("aria-busy",String(this._loading)),this.refs.loading.hidden=!this._loading,this}focusEvent(t){return this.el.querySelector(`[data-event-action][data-event-id="${Rs(String(t))}"]`)?.focus(),this}destroy(){if(this._destroyed)return;this._destroyed=!0,this._nowTimer&&clearInterval(this._nowTimer),this._nowTimer=null;let t=this._original;if(super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_toolbarButton(t,e,i=null){return l("button",{type:"button",class:"zx-calendar__toolbar-button",dataset:{calendarAction:t},ariaLabel:i?e:null,disabled:this.options.disabled},i?g(i):e)}_normalizeOptions(){return{eventId:this.options.eventId,eventTitle:this.options.eventTitle,eventStart:this.options.eventStart,eventEnd:this.options.eventEnd,eventAllDay:this.options.eventAllDay,eventColor:this.options.eventColor,eventLocation:this.options.eventLocation,eventEditable:this.options.eventEditable,eventDurationEditable:this.options.eventDurationEditable,dateUnit:this.options.dateUnit}}_renderView(t={}){if(!this.refs?.body||this._destroyed)return;let e=t.preserveFocus?this._focusIdentity():null,i=Lr(this._view,this._date,{weekStart:this.options.weekStart,agendaDays:this.options.agendaDays});this._range=i,this.refs.heading.textContent=this._rangeTitle(i);for(let r of this.refs.views.querySelectorAll("[data-view]"))r.setAttribute("aria-pressed",String(r.dataset.view===this._view));let n=this._view==="agenda"?this._renderAgenda(i):this._view==="day"||this._view==="week"?this._renderTimeGrid(i):this._view==="month"?this._renderMonth(i):this._renderYear(i);this.refs.body.replaceChildren(n),t.scroll&&this._scrollTimeGrid(),e&&this._restoreFocus(e),t.emitDates&&this.emit("dateschange",{view:this._view,start:new Date(i.start.getTime()),end:new Date(i.end.getTime())})}_renderAgenda(t){let e=l("div",{class:"zx-calendar__agenda",role:"grid",ariaLabel:this._rangeTitle(t)}),i=kt(t.start,t.end);for(let n=0;n<i;n+=1){let r=L(t.start,n),o=L(r,1),a=this._events.filter(u=>Ii(u,r,o)?u.start>=r||n===0:!1).sort(_b),c=l("section",{class:"zx-calendar__agenda-day",role:"row",dataset:{date:Q(r)}},l("button",{type:"button",class:"zx-calendar__agenda-heading",role:"rowheader",dataset:{calendarAction:"date",date:Q(r),dateCell:"true"},ariaCurrent:pe(r,this._now())?"date":null,disabled:this.options.disabled},this._format(r,{weekday:"long",day:"numeric",month:"long"}))),h=l("div",{class:"zx-calendar__agenda-events",role:"gridcell"});if(!a.length)h.append(l("p",{class:"zx-calendar__agenda-empty"},this.msg("noEvents")));else for(let u of a)h.append(this._eventElement(u,{variant:"agenda",day:r}));c.append(h),e.append(c)}return e}_renderTimeGrid(t){let e=Array.from({length:kt(t.start,t.end)},(y,v)=>L(t.start,v)),i=this._view==="week"&&this.options.workweek?e.filter(y=>y.getDay()>0&&y.getDay()<6):e,n=Pt(this.options.slotMinTime,0),r=Pt(this.options.slotMaxTime,1440,!0),o=bt(this.options.slotDuration);if(r<=n)throw new RangeError("slotMaxTime must exceed slotMinTime");let a=Math.ceil((r-n)/o),c=l("div",{class:"zx-calendar__time-surface",style:{"--zx-calendar-day-count":String(i.length)}}),h=l("div",{class:"zx-calendar__time-header"},l("span",{class:"zx-calendar__time-corner",ariaHidden:"true"}),l("div",{class:"zx-calendar__day-headings",role:"row"},i.map(y=>l("button",{type:"button",class:"zx-calendar__day-heading",role:"columnheader",dataset:{calendarAction:"date",date:Q(y),dateCell:"true"},ariaCurrent:pe(y,this._now())?"date":null,disabled:this.options.disabled},l("span",{class:"zx-calendar__day-weekday"},this._format(y,{weekday:"short"})),l("span",{class:"zx-calendar__day-number"},this._format(y,{day:"numeric",month:"short"})))))),u=this._renderAllDayRail(i),d=l("div",{ref:"timeScroller",class:"zx-calendar__time-scroller"}),p=l("div",{class:"zx-calendar__time-axis",ariaHidden:"true"}),f=l("div",{class:"zx-calendar__time-grid",role:"grid",ariaLabel:this._rangeTitle(t),ariaRowcount:String(a),ariaColcount:String(i.length),style:{"--zx-calendar-slot-count":String(a)}}),_=l("div",{ref:"slots",class:"zx-calendar__slots"}),b=!0;for(let y=0;y<a;y+=1){let v=n+y*o;p.append(l("span",{class:"zx-calendar__time-label"},v%60===0?Br(v,this.options.locale):""));for(let k=0;k<i.length;k+=1){let z=pb(i[k],v),E=String(z.getTime()),M=this._focusedSlot?this._focusedSlot===E:b;M&&(b=!1),_.append(l("button",{type:"button",class:"zx-calendar__slot",role:"gridcell",tabindex:M?0:-1,dataset:{calendarAction:"date",slot:E,dateTime:E,dayIndex:String(k),rowIndex:String(y),major:v%60===0?"true":null},ariaLabel:this._dateTimeLabel(z),disabled:this.options.disabled}))}}let w=l("div",{class:"zx-calendar__timed-events",ariaHidden:"false"});return i.forEach((y,v)=>{let k=Vr(this._events,y,{minMinutes:n,maxMinutes:r,minimumMinutes:o});for(let z of k){let E=(z.startMinutes-n)/(r-n)*100,M=Math.max(o/(r-n)*100,(z.endMinutes-z.startMinutes)/(r-n)*100),it=100/i.length,N=it/z.columns,J=v*it+z.column*N,xt=this._eventElement(z.event,{variant:"timed",day:y,resizable:!0});xt.style.insetInlineStart=`${J}%`,xt.style.inlineSize=`${N}%`,xt.style.insetBlockStart=`${E}%`,xt.style.blockSize=`${M}%`,w.append(xt)}}),f.append(_,w,this._nowLine(i,n,r)),d.append(p,f),c.append(h,u,d),c}_renderAllDayRail(t){let e=l("div",{class:"zx-calendar__all-day"},l("span",{class:"zx-calendar__all-day-label"},this.msg("allDay"))),i=l("div",{class:"zx-calendar__all-day-grid",role:"row",style:{"--zx-calendar-day-count":String(t.length)}});for(let r of t)i.append(l("span",{class:"zx-calendar__all-day-cell",dataset:{date:Q(r)},ariaHidden:"true"}));let n=Fs(this._events,t[0],t.length);for(let r of n){let o=this._eventElement(r.event,{variant:"span",day:t[r.start]});o.style.gridColumn=`${r.start+1} / ${r.end+1}`,o.style.gridRow=String(r.lane+1),i.append(o)}return e.append(i),e}_renderMonth(t){let e=l("div",{class:"zx-calendar__month"}),i=l("div",{class:"zx-calendar__month-weekdays",role:"row"});this.options.weekNumbers&&i.append(l("span",{class:"zx-calendar__month-week-gutter",ariaHidden:"true"}));for(let r=0;r<7;r+=1){let o=L(t.start,r);i.append(l("span",{class:"zx-calendar__month-weekday",role:"columnheader"},this._format(o,{weekday:"short"})))}e.append(i);let n=kt(t.start,t.end)/7;for(let r=0;r<n;r+=1){let o=L(t.start,r*7),a=Fs(this._events.map(b=>({...b,allDay:!0})),o,7),c=fb(this.options.eventLimit),h=a.filter(b=>b.lane<c),u=a.filter(b=>b.lane>=c),d=l("div",{class:"zx-calendar__month-week",role:"row",dataset:{weekStart:Q(o)}});this.options.weekNumbers&&d.append(l("button",{type:"button",class:"zx-calendar__month-week-number",dataset:{calendarAction:"week",date:Q(o)},ariaLabel:this.msg("weekNumber",bh(o)),disabled:this.options.disabled},String(bh(o))));let p=l("div",{class:"zx-calendar__month-days"});for(let b=0;b<7;b+=1){let w=L(o,b),y=this._events.filter(v=>Ii(v,w,L(w,1))).length;p.append(l("button",{type:"button",class:"zx-calendar__month-day",role:"gridcell",dataset:{calendarAction:"date",date:Q(w),dateCell:"true",otherMonth:w.getMonth()===this._date.getMonth()?null:"true",eventCount:String(y)},ariaCurrent:pe(w,this._now())?"date":null,ariaLabel:this._dayCountLabel(w,y),disabled:this.options.disabled},this._format(w,{day:"numeric"})))}let f=l("div",{class:"zx-calendar__month-events"});for(let b of h){let w=this._eventElement(b.event,{variant:"month",day:L(o,b.start)});w.style.gridColumn=`${b.start+1} / ${b.end+1}`,w.style.gridRow=String(b.lane+1),f.append(w)}let _=Array.from({length:7},(b,w)=>u.filter(y=>y.start<=w&&y.end>w).length);for(let b=0;b<_.length;b+=1){let w=_[b];if(!w)continue;let y=L(o,b);f.append(l("button",{type:"button",class:"zx-calendar__more",dataset:{calendarAction:"more",date:Q(y),count:String(w)},style:{gridColumn:String(b+1),gridRow:String(c+1)},disabled:this.options.disabled},this.msg("more",w)))}d.append(p,f),e.append(d)}return e.setAttribute("role","grid"),e.setAttribute("aria-label",this._rangeTitle(t)),e}_renderYear(t){let e=t.start.getFullYear(),i=l("div",{class:"zx-calendar__year",ariaLabel:String(e)});for(let n=0;n<12;n+=1){let r=new Date(e,n,1),o=(r.getDay()-this.options.weekStart+7)%7,a=L(r,-o),c=l("div",{class:"zx-calendar__year-grid",role:"grid",ariaLabel:this._format(r,{month:"long"})},l("h3",{class:"zx-calendar__year-heading"},this._format(r,{month:"long"})));for(let h=0;h<7;h+=1){let u=L(a,h);c.append(l("span",{class:"zx-calendar__year-weekday",role:"columnheader"},this._format(u,{weekday:"narrow"})))}for(let h=0;h<42;h+=1){let u=L(a,h);if(u.getMonth()!==n){c.append(l("span",{class:"zx-calendar__year-blank",role:"gridcell",ariaHidden:"true"}));continue}let d=this._events.filter(p=>Ii(p,u,L(u,1))).length;c.append(l("button",{type:"button",class:"zx-calendar__year-day",role:"gridcell",dataset:{calendarAction:"date",date:Q(u),dateCell:"true",activity:String(Math.min(3,d))},ariaCurrent:pe(u,this._now())?"date":null,ariaLabel:this._dayCountLabel(u,d),disabled:this.options.disabled},String(u.getDate())))}i.append(c)}return i}_eventElement(t,e){let i=String(t.id),n=l("div",{class:"zx-calendar__event",dataset:{eventId:i,variant:e.variant,allDay:t.allDay?"true":null,draggable:this._canMove(t)?"true":null},style:t.color?{"--zx-calendar-event-color":t.color}:null}),r=l("button",{type:"button",class:"zx-calendar__event-action",dataset:{eventAction:"activate",eventId:i},ariaLabel:this._eventLabel(t),disabled:this.options.disabled}),o=typeof this.options.renderEvent=="function"?this.options.renderEvent(G(t)):null;if(o instanceof Node)r.append(o);else if(typeof o=="string")r.append(document.createTextNode(o));else{let a=l("span",{class:"zx-calendar__event-time"},this._eventTime(t,e.day)),c=l("span",{class:"zx-calendar__event-title"},t.title);r.append(a,c),t.location&&r.append(l("span",{class:"zx-calendar__event-location"},t.location))}return n.append(r),e.resizable&&this._canResize(t)&&n.append(l("button",{type:"button",class:"zx-calendar__event-resize",dataset:{eventAction:"resize",eventId:i},ariaLabel:this.msg("resize",t.title),disabled:this.options.disabled},l("span",{ariaHidden:"true"}))),n}_nowLine(t,e,i){let n=this._now(),r=t.findIndex(c=>pe(c,n)),o=n.getHours()*60+n.getMinutes(),a=this.options.nowIndicator&&r>=0&&o>=e&&o<=i;return l("div",{ref:"nowLine",class:"zx-calendar__now",hidden:!a,ariaHidden:"true",style:a?{insetBlockStart:`${(o-e)/(i-e)*100}%`,"--zx-calendar-now-day":String(r)}:null},l("span",{class:"zx-calendar__now-time"},Br(o,this.options.locale)))}_onClick(t){let e=t.target?.closest?.("button");if(!e||!this.el.contains(e))return;let i=e.dataset.eventId;if(i!=null&&this._suppressClickId===i){this._suppressClickId=null,t.preventDefault();return}if(e.dataset.eventAction==="activate"){let r=this._eventById(i);r&&this.emit("eventclick",{event:G(r),jsEvent:t});return}if(e.dataset.eventAction==="resize")return;let n=e.dataset.calendarAction;if(n){if(n==="previous")this.prev();else if(n==="next")this.next();else if(n==="today")this.today();else if(n==="view")this.setView(e.dataset.view);else if(n==="new")this.emit("new",{date:this.getDate(),view:this._view,jsEvent:t});else if(n==="week"){let r=Gt(e.dataset.date);r&&this.setDate(r).setView("week")}else if(n==="more"){let r=Gt(e.dataset.date);if(!r)return;!this.emit("moreclick",{date:r,count:Number(e.dataset.count),jsEvent:t}).defaultPrevented&&this._views.includes("agenda")&&this.setDate(r).setView("agenda")}else if(n==="date"){if(this._suppressDateClick){this._suppressDateClick=!1,t.preventDefault();return}let r=this._dateFromTarget(e);if(!r)return;this._rememberFocusedDate(e),this.emit("dateclick",{date:r,allDay:!e.dataset.dateTime,view:this._view,jsEvent:t})}}}_onDoubleClick(t){let e=t.target?.closest?.('[data-event-action="activate"]');if(e){let a=this._eventById(e.dataset.eventId);a&&this.emit("eventdblclick",{event:G(a),jsEvent:t});return}let i=t.target?.closest?.('[data-calendar-action="date"]');if(!i)return;let n=this._dateFromTarget(i);if(!n)return;let r=!i.dataset.dateTime,o=r?L(n,1):fe(n,bt(this.options.slotDuration));this.emit("select",{start:n,end:o,allDay:r,view:this._view,jsEvent:t})}_onKeydown(t){let e=t.target?.closest?.("[data-event-action]");if(e){this._onEventKeydown(t,e);return}let i=t.target?.closest?.("[data-slot]");if(i){this._onSlotKeydown(t,i);return}let n=t.target?.closest?.("[data-date-cell]");n&&this._onDayKeydown(t,n)}_onEventKeydown(t,e){let i=this._eventById(e.dataset.eventId);if(!i)return;let n=e.dataset.eventAction==="resize";if(t.key==="Enter"&&!this._keyboardEdit&&!n){t.preventDefault(),this.emit("eventclick",{event:G(i),jsEvent:t});return}if(t.key===" "&&!this._keyboardEdit){if(n?!this._canResize(i):!this._canMove(i))return;t.preventDefault(),this._keyboardEdit={oldEvent:G(i),event:G(i),action:n?"resize":"move",control:e},e.setAttribute("aria-grabbed","true"),e.closest(".zx-calendar__event")?.setAttribute("data-state","grabbed"),this._announce(this.msg(n?"resizeStarted":"moveStarted",i.title));return}if(!this._keyboardEdit||String(this._keyboardEdit.event.id)!==String(i.id))return;if(t.key==="Escape"){t.preventDefault(),this._cancelKeyboardEdit();return}if(t.key===" "){t.preventDefault();let h=this._keyboardEdit;this._keyboardEdit=null,h.control.removeAttribute("aria-grabbed"),this._commitMutation(h.oldEvent,h.event,h.action,t);return}let r=0,o=0,a=!zt(i)&&(this._view==="day"||this._view==="week");if(t.key==="ArrowLeft")r=-1;else if(t.key==="ArrowRight")r=1;else if(t.key==="ArrowUp")a?o=-bt(this.options.slotDuration):r=-7;else if(t.key==="ArrowDown")a?o=bt(this.options.slotDuration):r=7;else return;t.preventDefault();let c=this._keyboardEdit;if(c.action==="move")c.event=Ti(c.event,{days:r,minutes:o});else{let h=Ti(c.event,{days:0,minutes:0,endDays:r,endMinutes:o});h.end>h.start&&(c.event=h)}c.control.closest(".zx-calendar__event")?.setAttribute("data-preview",this._eventTime(c.event,c.event.start)),this._announce(this.msg("editPreview",c.event.title,this._dateTimeLabel(c.event.start),this._dateTimeLabel(c.event.end)))}_onSlotKeydown(t,e){let i=Number(e.dataset.rowIndex),n=Number(e.dataset.dayIndex),r=e.closest('[role="grid"]'),o=Number(r?.getAttribute("aria-colcount"))||1,a=Number(r?.getAttribute("aria-rowcount"))||1,c=i,h=n;if(t.key==="ArrowLeft")h-=1;else if(t.key==="ArrowRight")h+=1;else if(t.key==="ArrowUp")c-=1;else if(t.key==="ArrowDown")c+=1;else if(t.key==="Home")h=0;else if(t.key==="End")h=o-1;else if(t.key==="PageUp"){t.preventDefault(),this.prev();return}else if(t.key==="PageDown"){t.preventDefault(),this.next();return}else if(t.key==="Enter"||t.key===" "){t.preventDefault();let d=this._dateFromTarget(e);d&&this.emit("dateclick",{date:d,allDay:!1,view:this._view,jsEvent:t});return}else return;t.preventDefault(),c=Math.max(0,Math.min(a-1,c)),h=Math.max(0,Math.min(o-1,h));let u=r?.querySelector(`[data-row-index="${c}"][data-day-index="${h}"]`);u&&(e.tabIndex=-1,u.tabIndex=0,this._focusedSlot=u.dataset.slot,u.focus())}_onDayKeydown(t,e){let i=Gt(e.dataset.date);if(!i)return;let n=0;if(t.key==="ArrowLeft")n=-1;else if(t.key==="ArrowRight")n=1;else if(t.key==="ArrowUp")n=-7;else if(t.key==="ArrowDown")n=7;else if(t.key==="Home")n=-((i.getDay()-this.options.weekStart+7)%7);else if(t.key==="End")n=6-(i.getDay()-this.options.weekStart+7)%7;else if(t.key==="PageUp"){t.preventDefault(),this.prev();return}else if(t.key==="PageDown"){t.preventDefault(),this.next();return}else return;t.preventDefault();let r=L(i,n),o=this.el.querySelector(`[data-date-cell][data-date="${Q(r)}"]`);o?o.focus():this.setDate(r)}_onPointerDown(t){if(this.options.disabled||t.button!==0)return;let e=t.target?.closest?.("[data-event-action]");if(e){let r=this._eventById(e.dataset.eventId),o=e.dataset.eventAction==="resize"?"resize":"move";if(!r||(o==="move"?!this._canMove(r):!this._canResize(r)))return;t.preventDefault(),this._capturePointer(t.pointerId);let a=o==="move"?this._dragOffsetForEvent(r,t.clientX,t.clientY):null;this._pointer={type:"event",pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,oldEvent:G(r),event:G(r),action:o,control:e,timeOffsetMinutes:a?.minutes??0,dayOffset:a?.days??0,moved:!1};return}let i=t.target?.closest?.("[data-slot]");if(!i||!this.options.selectable)return;let n=this._dateFromTarget(i);n&&(t.preventDefault(),this._capturePointer(t.pointerId),this._pointer={type:"selection",pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,start:n,end:fe(n,bt(this.options.slotDuration)),control:i,moved:!1})}_onPointerMove(t){let e=this._pointer;if(!e||e.pointerId!==t.pointerId||!e.moved&&Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<5)return;if(e.moved=!0,t.preventDefault(),e.type==="selection"){let r=this._timeAtPoint(t.clientX,t.clientY);if(!r)return;let o=bt(this.options.slotDuration);e.end=fe(r,o),this._previewSelection(e.start,e.end);return}let i=this._proposalAtPoint(e.oldEvent,e.action,t.clientX,t.clientY);if(!i)return;e.event=i;let n=e.control.closest(".zx-calendar__event");if(n){if(n.dataset.state="dragging",e.action==="resize"){n.style.transform="";let r=this._timedPreviewHeight(i);r&&(n.style.blockSize=r)}else n.style.transform=`translate(${t.clientX-e.startX}px, ${t.clientY-e.startY}px)`;n.dataset.preview=this._eventTime(i,i.start)}this._announce(this.msg("editPreview",i.title,this._dateTimeLabel(i.start),this._dateTimeLabel(i.end)))}_onPointerUp(t){let e=this._pointer;if(!(!e||e.pointerId!==t.pointerId)&&(this._pointer=null,this._releasePointerCapture(e.pointerId),this._clearSelectionPreview(),!!e.moved)){if(t.preventDefault(),e.type==="selection"){this._suppressDateClick=!0;let i=e.start<e.end?e.start:fe(e.end,-bt(this.options.slotDuration)),n=e.start<e.end?e.end:fe(e.start,bt(this.options.slotDuration));this.emit("select",{start:new Date(i),end:new Date(n),allDay:!1,view:this._view,jsEvent:t});return}this._suppressClickId=String(e.oldEvent.id),this._commitMutation(e.oldEvent,e.event,e.action,t)}}_cancelPointer(t){if(!this._pointer||this._pointer.pointerId!==t.pointerId)return;let e=this._pointer.control;this._releasePointerCapture(this._pointer.pointerId),this._pointer=null,this._clearSelectionPreview(),e.closest?.(".zx-calendar__event")?.removeAttribute("data-state"),this._renderView({preserveFocus:!0})}_proposalAtPoint(t,e,i,n){let r=e==="resize"&&!zt(t),o=this._timeAtPoint(i,n,r?t.start:null);if(o&&!zt(t)){if(e==="move"){let f=t.end.getTime()-t.start.getTime(),_=G(t);return _.start=fe(o,-Number(this._pointer?.timeOffsetMinutes??0)),_.end=new Date(_.start.getTime()+f),_}let p=G(t);return p.end=fe(o,bt(this.options.slotDuration)),p.end>p.start?p:null}let a=this._dayAtPoint(i,n);if(!a)return null;let c=L(a,-Number(this._pointer?.dayOffset??0)),h=kt(W(t.start),c);if(e==="move")return Ti(t,{days:h,minutes:0});let u=G(t),d=L(a,1);return u.end=new Date(d.getTime()),u.end>u.start?u:null}_timeAtPoint(t,e,i=null){let n=this.refs.body.querySelector(".zx-calendar__slots");if(!n)return null;let r=n.getBoundingClientRect(),a=n.closest(".zx-calendar__time-scroller")?.getBoundingClientRect(),c=a?Math.max(r.left,a.left):r.left,h=a?Math.min(r.right,a.right):r.right,u=a?Math.max(r.top,a.top):r.top,d=a?Math.min(r.bottom,a.bottom):r.bottom;if(t<c||t>h||e<u||e>d||r.width<=0||r.height<=0)return null;let p=Number(n.closest('[role="grid"]')?.getAttribute("aria-colcount"))||1,f=Number(n.closest('[role="grid"]')?.getAttribute("aria-rowcount"))||1,_=i?this._timeGridDayIndex(i):-1,b=_>=0?_:Math.max(0,Math.min(p-1,Math.floor((t-r.left)/r.width*p))),w=Math.max(0,Math.min(f-1,Math.floor((e-r.top)/r.height*f))),y=n.querySelector(`[data-row-index="${w}"][data-day-index="${b}"]`);return y?this._dateFromTarget(y):null}_dayAtPoint(t,e){let i=this.refs.body.querySelector(".zx-calendar__all-day-grid");if(i){let r=i.getBoundingClientRect();if(t>=r.left&&t<=r.right&&e>=r.top&&e<=r.bottom){let o=i.querySelectorAll("[data-date]"),a=Math.max(0,Math.min(o.length-1,Math.floor((t-r.left)/r.width*o.length)));return Gt(o[a]?.dataset.date)}}for(let r of this.refs.body.querySelectorAll(".zx-calendar__month-events")){let o=r.getBoundingClientRect();if(t<o.left||t>o.right||e<o.top||e>o.bottom||o.width<=0)continue;let a=Gt(r.closest(".zx-calendar__month-week")?.dataset.weekStart);if(!a)continue;let c=Math.max(0,Math.min(6,Math.floor((t-o.left)/o.width*7)));return L(a,c)}for(let r of this.refs.body.querySelectorAll(".zx-calendar__agenda-day")){let o=r.getBoundingClientRect();if(!(t<o.left||t>o.right||e<o.top||e>o.bottom))return Gt(r.dataset.date)}let n=typeof document.elementsFromPoint=="function"?document.elementsFromPoint(t,e):[];for(let r of n){let o=r instanceof HTMLElement?r.closest("[data-date]"):null,a=o instanceof HTMLElement?o.dataset.date:null;if(a)return Gt(a)}return null}_dragOffsetForEvent(t,e,i){if(!zt(t)){let o=this._timeAtPoint(e,i);if(o){let a=bt(this.options.slotDuration),c=Math.max(0,Math.round((t.end.getTime()-t.start.getTime())/6e4)),h=Math.max(0,c-a),u=Math.round((o.getTime()-t.start.getTime())/6e4);return{minutes:Math.max(0,Math.min(h,u)),days:0}}}let n=this._dayAtPoint(e,i),r=n?kt(W(t.start),n):0;return{minutes:0,days:Math.max(0,r)}}_timeGridDayIndex(t){let e=Q(t);return[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")].findIndex(n=>n.dataset.date===e)}_timedPreviewHeight(t){if(!this.refs.body.querySelector(".zx-calendar__time-grid")||zt(t))return null;let i=Pt(this.options.slotMinTime,0),n=Pt(this.options.slotMaxTime,1440,!0),r=bt(this.options.slotDuration),o=t.start.getHours()*60+t.start.getMinutes(),a=t.end.getHours()*60+t.end.getMinutes();return`${Math.max(r,Math.min(n,a)-Math.max(i,o))/(n-i)*100}%`}_capturePointer(t){try{this.el.setPointerCapture?.(t)}catch{}}_releasePointerCapture(t){this.el.hasPointerCapture?.(t)&&this.el.releasePointerCapture?.(t)}_previewSelection(t,e){let i=Math.min(t.getTime(),e.getTime()),n=Math.max(t.getTime(),e.getTime());for(let r of this.refs.body.querySelectorAll("[data-slot]")){let o=Number(r.dataset.dateTime);r.setAttribute("aria-selected",String(o>=i&&o<n))}}_clearSelectionPreview(){for(let t of this.refs.body.querySelectorAll("[data-slot][aria-selected]"))t.removeAttribute("aria-selected")}_cancelKeyboardEdit(){let t=this._keyboardEdit;t&&(t.control.removeAttribute("aria-grabbed"),t.control.closest(".zx-calendar__event")?.removeAttribute("data-state"),this._keyboardEdit=null,this._announce(this.msg("editCancelled")),this._renderView({preserveFocus:!0}))}_commitMutation(t,e,i,n){if(!(t.start.getTime()!==e.start.getTime()||t.end.getTime()!==e.end.getTime())){this._renderView({preserveFocus:!0});return}let o=String(t.id),a=++this._mutationSerial,c=!1;this.options.optimistic?(this._replaceNormalizedEvent(e),this._mutationVersions.set(o,a),this._renderView({preserveFocus:!0})):this._renderView({preserveFocus:!0});let h=()=>{if(c||!this.options.optimistic||this._mutationVersions.get(o)!==a)return!1;let p=this._eventById(o);return!p||p.start.getTime()!==e.start.getTime()||p.end.getTime()!==e.end.getTime()?!1:(c=!0,this._replaceNormalizedEvent(t),this._mutationVersions.delete(o),this._renderView({preserveFocus:!0}),this._announce(this.msg("editCancelled")),!0)},u={event:G(e),oldEvent:G(t),action:i,delta:mb(t,e),jsEvent:n,revert:h};this.emit("eventchange",u).defaultPrevented?h():this._announce(this.msg("editCommitted",e.title))}_replaceNormalizedEvent(t){let e=String(t.id);this._events=this._events.map(i=>String(i.id)===e?G(t):i)}_canMove(t){return this.options.disabled?!1:t.editable!=null?t.editable:this.options.eventStartEditable!=null?!!this.options.eventStartEditable:!!this.options.editable}_canResize(t){return this.options.disabled?!1:t.durationEditable!=null?t.durationEditable:this.options.eventDurationEditable!=null?!!this.options.eventDurationEditable:!!this.options.editable}_eventById(t){let e=this._eventIndex(t);return e<0?null:this._events[e]}_eventIndex(t){let e=String(t);return this._events.findIndex(i=>String(i.id)===e)}_page(t){return this.setDate(Rr(this._view,this._date,t,{agendaDays:this.options.agendaDays}))}_rangeTitle(t){if(this._view==="day")return this._format(t.start,{weekday:"long",day:"numeric",month:"long",year:"numeric"});if(this._view==="month")return this._format(this._date,{month:"long",year:"numeric"});if(this._view==="year")return this._format(this._date,{year:"numeric"});let e=L(t.end,-1),i=new Intl.DateTimeFormat(this.options.locale,{day:"numeric",month:"long",year:"numeric"});return typeof i.formatRange=="function"?i.formatRange(t.start,e):t.start.getFullYear()!==e.getFullYear()?`${this._format(t.start,{day:"numeric",month:"short",year:"numeric"})} \u2013 ${this._format(e,{day:"numeric",month:"short",year:"numeric"})}`:t.start.getMonth()!==e.getMonth()?`${this._format(t.start,{day:"numeric",month:"short"})} \u2013 ${this._format(e,{day:"numeric",month:"short",year:"numeric"})}`:`${this._format(t.start,{day:"numeric"})}\u2013${this._format(e,{day:"numeric",month:"long",year:"numeric"})}`}_eventTime(t,e){if(t.allDay)return this.msg("allDay");if(zt(t))return pe(t.start,e)?`${Ei(t.start,this.options.locale)} \u2192`:pe(t.end,e)?`\u2192 ${Ei(t.end,this.options.locale)}`:this.msg("allDay");let i=Hr(t.start,this.options.locale);return t.end<=t.start?i:`${i}\u2013${Hr(t.end,this.options.locale)}`}_eventLabel(t){let e=t.location?`, ${t.location}`:"";return`${t.title}, ${Ei(t.start,this.options.locale)} to ${Ei(t.end,this.options.locale)}${e}`}_dateTimeLabel(t){return Ei(t,this.options.locale)}_format(t,e){return new Intl.DateTimeFormat(this.options.locale,e).format(t)}_now(){let t=typeof this.options.now=="function"?this.options.now():this.options.now,e=t??new Date;if(!(e instanceof Date)||Number.isNaN(e.getTime()))throw new TypeError("Calendar now must return a valid Date");return new Date(e.getTime())}_dateFromTarget(t){if(t.dataset.dateTime){let e=new Date(Number(t.dataset.dateTime));return Number.isNaN(e.getTime())?null:e}return Gt(t.dataset.date)}_rememberFocusedDate(t){t.dataset.slot&&(this._focusedSlot=t.dataset.slot)}_focusIdentity(){let t=document.activeElement;return!(t instanceof HTMLElement)||!this.el.contains(t)?null:{eventId:t.dataset.eventId,eventAction:t.dataset.eventAction,date:t.dataset.date,slot:t.dataset.slot}}_restoreFocus(t){let e=null;t.eventId&&(e=this.el.querySelector(`[data-event-id="${Rs(t.eventId)}"][data-event-action="${t.eventAction??"activate"}"]`)),!e&&t.slot&&(e=this.el.querySelector(`[data-slot="${Rs(t.slot)}"]`)),!e&&t.date&&(e=this.el.querySelector(`[data-date-cell][data-date="${Rs(t.date)}"]`)),e?.focus?.()}_scrollTimeGrid(){let t=this.refs.body.querySelector(".zx-calendar__time-scroller");if(!t)return;let e=Pt(this.options.slotMinTime,0),i=Pt(this.options.slotMaxTime,1440,!0),n=Pt(this.options.scrollTime,480,!0),r=Math.max(0,Math.min(1,(n-e)/(i-e)));requestAnimationFrame(()=>{t.isConnected&&(t.scrollTop=Math.max(0,r*t.scrollHeight-t.clientHeight/4))})}_refreshNowIndicator(){if(this._destroyed||!this.options.nowIndicator||!["day","week"].includes(this._view))return;let t=this.refs.body.querySelector(".zx-calendar__now"),e=[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")];if(!t||!e.length)return;let i=this._now(),n=e.findIndex(h=>h.dataset.date===Q(i)),r=Pt(this.options.slotMinTime,0),o=Pt(this.options.slotMaxTime,1440,!0),a=i.getHours()*60+i.getMinutes(),c=n>=0&&a>=r&&a<=o;t.hidden=!c,c&&(t.style.insetBlockStart=`${(a-r)/(o-r)*100}%`,t.style.setProperty("--zx-calendar-now-day",String(n)),t.querySelector(".zx-calendar__now-time").textContent=Br(a,this.options.locale))}_announce(t){this.refs.status.textContent="",requestAnimationFrame(()=>{this._destroyed||(this.refs.status.textContent=t)})}_dayCountLabel(t,e){let i=this._format(t,{dateStyle:"full"});return e===1?this._message("calendar.dayEvent","%1, %2 event",i,e):this._message("calendar.dayEvents","%1, %2 events",i,e)}_message(t,e,...i){let n=this.msg(t,...i);return n===t?I(e,i):n}};function db(s){if(!Array.isArray(s)||s.length===0)throw new TypeError("Calendar views must be a non-empty array");let t=[...new Set(s.map(String))];for(let e of t)if(!Os.includes(e))throw new RangeError(`Unknown Calendar view: ${e}`);return t}function mh(s,t,e){if(s==null)return e;if(s instanceof Date){if(Number.isNaN(s.getTime()))throw new TypeError("Calendar date must be valid");return new Date(s.getTime())}let i=typeof s=="number"?s:typeof s=="string"&&/^-?\d+(?:\.\d+)?$/.test(s.trim())?Number(s):null,n=i==null?new Date(s):new Date(i*(t==="seconds"?1e3:1));if(Number.isNaN(n.getTime()))throw new TypeError("Calendar date must be valid");return n}function bt(s){let t=Number(s);if(!Number.isInteger(t)||t<=0||t>720||1440%t!==0)throw new RangeError("Calendar slotDuration must be a positive divisor of 1440");return t}function fb(s){let t=Number(s);if(!Number.isInteger(t)||t<1||t>20)throw new RangeError("Calendar eventLimit must be an integer from 1 through 20");return t}function Pt(s,t,e=!1){let i=Number(s??t),n=e?1440:1439;if(!Number.isInteger(i)||i<0||i>n)throw new RangeError(`Calendar minute must be from 0 through ${n}`);return i}function pb(s,t){let e=W(s);return e.setMinutes(t),e}function fe(s,t){let e=new Date(s.getTime());return e.setMinutes(e.getMinutes()+t),e}function gh(s){return`${s.getFullYear()}-${s.getMonth()}-${s.getDate()}`}function pe(s,t){return gh(s)===gh(t)}function Gt(s){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s??""));if(!t)return null;let e=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return Q(e)===s?e:null}function _b(s,t){return s.start-t.start||t.end-s.end||s.title.localeCompare(t.title)}function Br(s,t){let e=new Date(2026,0,1);return e.setHours(Math.floor(s/60)%24,s%60,0,0),Hr(e,t)}function Hr(s,t){return new Intl.DateTimeFormat(t,{hour:"2-digit",minute:"2-digit"}).format(s)}function Ei(s,t){return new Intl.DateTimeFormat(t,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(s)}function bh(s){let t=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t-i)/864e5+1)/7)}function mb(s,t){let e=t.start.getTime()-s.start.getTime();return{milliseconds:e,days:kt(W(s.start),W(t.start)),minutes:Math.round(e/6e4),endMilliseconds:t.end.getTime()-s.end.getTime()}}function Rs(s){return globalThis.CSS?.escape?CSS.escape(s):s.replace(/[^a-zA-Z0-9_-]/g,t=>`\\${t}`)}var yt=class extends m{static cssName="record-view";static defaults={fields:[],data:[],recordId:"ID",sort:null,sortMode:"local",selectable:!1,selection:[],fieldOrder:[],hiddenFields:[],fieldControls:!0,emptyText:null};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("div");return this._recordViewOriginal=t?null:A(e),this._recordViewDestroyed=!1,this._initRecordView(e),e}destroy(){if(this._recordViewDestroyed)return;this._recordViewDestroyed=!0;let t=this.el,e=this._recordViewOriginal;this._removeViewFieldControls(),super.destroy(),e&&t&&S(t,e)}_initRecordView(t){this.el=t,t.classList.add("zx-record-view"),this._viewFields=$r(this.options.fields),this._viewFieldOrder=Di(this._viewFields,this.options.fieldOrder),this._viewHidden=Kr(this._viewFields,this.options.hiddenFields,!0),this._viewData=qr(this.options.data),this._viewSort=Vs(this.options.sort,this._viewFields),this._viewSelected=new Set,this._viewSelectionAnchor=null,this._viewFieldControls=null,this._viewFieldList=null,this._viewFieldSettings=Bt(this.options.fieldControls),this._viewFieldControlsTarget=q(this._viewFieldSettings.target),this._viewInitialized=!0,this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._setInitialSelection(this.options.selection)}setData(t){this._viewData=qr(t),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData();let e=this._pruneViewSelection();return this.setLoading(!1),this._refreshView("data"),e&&this._emitViewSelection(),this.emit("datachange",{records:this.getData()}),this}addData(t){return this._viewData.push(...qr(t)),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("data"),this.emit("datachange",{records:this.getData()}),this}updateRecord(t,e){Ah(e);let i=this._viewData.findIndex(o=>Object.is(this._viewRecordId(o),t));if(i<0)return this;let n=this._viewSelected.delete(t);this._viewData[i]=e;let r=this._viewRecordId(e);return n&&this._viewSelected.add(r),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("data"),n&&!Object.is(t,r)&&this._emitViewSelection(),this.emit("datachange",{records:this.getData()}),this}removeRecord(t){let e=this._viewData.findIndex(n=>Object.is(this._viewRecordId(n),t));if(e<0)return this;this._viewData.splice(e,1);let i=this._viewSelected.delete(t);return Object.is(this._viewSelectionAnchor,t)&&(this._viewSelectionAnchor=null),this._refreshView("data"),i&&this._emitViewSelection(),this.emit("datachange",{records:this.getData()}),this}getRecord(t){return this._viewData.find(e=>Object.is(this._viewRecordId(e),t))??null}getData(){return[...this._viewData]}setFields(t){let e=this.getFieldOrder(),i=this.getHiddenFields();return this._viewFields=$r(t),this._viewFieldOrder=Di(this._viewFields,e),this._viewHidden=Kr(this._viewFields,i),this._viewSort=Vs(this._viewSort,this._viewFields),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("fields"),this._renderViewFieldControls(),this._emitViewState("fields"),this}getFields(){let t=new Map(this._viewFields.map(e=>[e.id,e]));return this._viewFieldOrder.map(e=>({...t.get(e)}))}getVisibleFields(){return this.getFields().filter(t=>!this._viewHidden.has(t.id))}getHiddenFields(){return this._viewFieldOrder.filter(t=>this._viewHidden.has(t))}getFieldOrder(){return[...this._viewFieldOrder]}setFieldVisible(t,e=!0,i={}){let n=String(t);if(!this._viewFields.some(o=>o.id===n))throw new RangeError(`Unknown view field: ${n}`);if(!e&&!this._viewHidden.has(n)&&this.getVisibleFields().length<=1)return this._renderViewFieldControls(n),this;let r=e?this._viewHidden.delete(n):!this._viewHidden.has(n);return!e&&r&&this._viewHidden.add(n),r?(this._refreshView("fields"),this._renderViewFieldControls(n),i.silent||(this.emit("fieldvisibilitychange",{visible:this.getVisibleFields().map(o=>o.id),hidden:this.getHiddenFields()}),this._emitViewState("fieldvisibility")),this):this}toggleField(t,e={}){return this.setFieldVisible(t,this._viewHidden.has(String(t)),e)}moveField(t,e,i="before",n={}){let r=xh(this._viewFieldOrder,String(t),String(e),i);return yh(r,this._viewFieldOrder)?this:this.setFieldOrder(r,n)}setFieldOrder(t,e={}){let i=Di(this._viewFields,t);return yh(i,this._viewFieldOrder)?this:(this._viewFieldOrder=i,this._refreshView("fields"),this._renderViewFieldControls(),e.silent||(this.emit("fieldorderchange",{order:this.getFieldOrder()}),this._emitViewState("fieldorder")),this)}setSort(t,e="asc",i={}){let n=t==null?null:Vs({id:String(t),dir:e},this._viewFields);if(t!=null&&!n)throw new RangeError(`Unknown or unsortable view field: ${t}`);return bb(n,this._viewSort)?this:(this._viewSort=n,n&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("sort"),i.silent||(this.emit("sortchange",n?{...n}:{id:null,dir:null}),this._emitViewState("sort")),this)}getSort(){return this._viewSort?{...this._viewSort}:null}getSelection(){return this._viewData.filter(t=>this._viewSelected.has(this._viewRecordId(t)))}getSelectionIds(){return this.getSelection().map(t=>this._viewRecordId(t))}setSelection(t,e={}){let i=new Set(Array.isArray(t)?t:[]),r=this._viewData.map(o=>this._viewRecordId(o)).filter(o=>i.has(o));return this.options.selectable===!1&&(r=[]),this.options.selectable==="single"&&(r=r.slice(0,1)),wh(this._viewSelected,new Set(r))?this:(this._viewSelected=new Set(r),this._viewSelectionAnchor=r.at(-1)??null,this._refreshView("selection"),e.silent||this._emitViewSelection(),this)}clearSelection(t={}){return this.setSelection([],t)}toggleSelection(t,e={}){if(this.options.selectable===!1||!this.getRecord(t))return this;let i=e.selected??!this._viewSelected.has(t);if(this.options.selectable==="single")this._viewSelected=i?new Set([t]):new Set;else if(e.range&&this._viewSelectionAnchor!=null){let n=this._viewData.map(a=>this._viewRecordId(a)),r=n.findIndex(a=>Object.is(a,this._viewSelectionAnchor)),o=n.findIndex(a=>Object.is(a,t));if(r>=0&&o>=0)for(let a of n.slice(Math.min(r,o),Math.max(r,o)+1))i?this._viewSelected.add(a):this._viewSelected.delete(a)}else i?this._viewSelected.add(t):this._viewSelected.delete(t);return this._viewSelectionAnchor=t,this._refreshView("selection"),this._emitViewSelection(),this}setLoading(t=!0){return t?this.el.setAttribute("data-loading","true"):this.el.removeAttribute("data-loading"),this.el.setAttribute("aria-busy",String(!!t)),this._refreshView("loading"),this}getViewState(){return{version:1,fieldOrder:this.getFieldOrder(),hiddenFields:this.getHiddenFields(),sort:this.getSort()}}setViewState(t,e={}){let i=Sh(t,this._viewFields);return this._viewFieldOrder=i.fieldOrder,this._viewHidden=new Set(i.hiddenFields),this._viewSort=i.sort,this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("state"),this._renderViewFieldControls(),e.silent||this._emitViewState("restore"),this}_createViewFieldControls(t=null){let e=t??this._viewFieldControlsLabel(),i=l("div",{class:"zx-record-view__field-list"}),n=l("details",{class:"zx-record-view__field-controls"},l("summary",{class:"zx-button zx-button--sm"},g("fields",{size:13}),e),i);return this._viewFieldControls=n,this._viewFieldList=i,this._renderViewFieldControls(),this.listen(i,"change",r=>{let o=r.target;o?.classList.contains("zx-record-view__field-toggle")&&this.setFieldVisible(o.value,o.checked)}),this.listen(i,"click",r=>{let o=r.target?.closest?.("[data-view-field-action]");if(!o)return;let a=o.dataset.fieldId,c=o.dataset.viewFieldAction,h=this._viewFieldOrder.indexOf(String(a));c==="up"&&h>0&&this.moveField(String(a),this._viewFieldOrder[h-1],"before"),c==="down"&&h>=0&&h<this._viewFieldOrder.length-1&&this.moveField(String(a),this._viewFieldOrder[h+1],"after")}),n}_mountViewFieldControls(t,e=null){let i=this._createViewFieldControls(e),n=this._viewFieldControlsTarget;return n&&(i.dataset.mounted="external"),(n??t).append(i),i}_removeViewFieldControls(){this._viewFieldControls?.remove?.(),this._viewFieldControls=null,this._viewFieldList=null,this._viewFieldControlsTarget=null}_viewFieldControlsLabel(){return(this._viewFieldSettings??Bt(this.options.fieldControls)).label??this._message("recordView.fields","Fields")}_message(t,e,...i){let n=this.msg(t,...i);return n===t?I(e,i):n}_refreshView(t){}_viewRecordId(t){return Ee(t,this.options.recordId)}_isViewSelected(t){return this._viewSelected.has(t)}_sortViewData(){this._viewSort&&(this._viewData=vh(this._viewData,this._viewFields,this._viewSort))}_setInitialSelection(t){let e=new Set(Array.isArray(t)?t:[]),n=this._viewData.map(r=>this._viewRecordId(r)).filter(r=>e.has(r));this.options.selectable===!1&&(n=[]),this.options.selectable==="single"&&(n=n.slice(0,1)),this._viewSelected=new Set(n),this._viewSelectionAnchor=n.at(-1)??null}_pruneViewSelection(){let t=new Set(this._viewData.map(n=>this._viewRecordId(n))),e=new Set([...this._viewSelected].filter(n=>t.has(n))),i=!wh(e,this._viewSelected);return this._viewSelected=e,this._viewSelectionAnchor!=null&&!t.has(this._viewSelectionAnchor)&&(this._viewSelectionAnchor=null),i}_emitViewSelection(){this.emit("selectionchange",{records:this.getSelection(),ids:this.getSelectionIds()})}_emitViewState(t){this.emit("statechange",{state:this.getViewState(),reason:t})}_renderViewFieldControls(t=null){if(!this._viewFieldList)return;let e=this.getFields(),i=e.filter(r=>!this._viewHidden.has(r.id));this._viewFieldControls.hidden=e.length===0;let n=e.map((r,o)=>{let a=l("input",{class:"zx-record-view__field-toggle",type:"checkbox",value:r.id,checked:!this._viewHidden.has(r.id),disabled:!this._viewHidden.has(r.id)&&i.length===1}),c=l("button",{class:"zx-record-view__field-move",type:"button",ariaLabel:this._message("recordView.moveFieldUp","Move %1 up",r.label),disabled:o===0,dataset:{viewFieldAction:"up",fieldId:r.id}},g("chevron-up",{size:11})),h=l("button",{class:"zx-record-view__field-move",type:"button",ariaLabel:this._message("recordView.moveFieldDown","Move %1 down",r.label),disabled:o===e.length-1,dataset:{viewFieldAction:"down",fieldId:r.id}},g("chevron-down",{size:11}));return l("div",{class:"zx-record-view__field-option"},l("label",{},a,l("span",{},r.label)),l("span",{class:"zx-record-view__field-order"},c,h))});if(this._viewFieldList.replaceChildren(...n),t!=null){let r=[...this._viewFieldList.querySelectorAll(".zx-record-view__field-toggle")].find(o=>o.value===t);queueMicrotask(()=>{r?.isConnected&&r.focus()})}}};function Bt(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)?{enabled:!0,custom:!0,label:s.label==null?null:String(s.label),target:s.target??null}:{enabled:!!s,custom:!1,label:null,target:null}}function $r(s){if(!Array.isArray(s))throw new TypeError("Record view fields must be an array");let t=new Set;return s.map((e,i)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError(`Record view field at index ${i} must be an object`);let n=String(e.id??"").trim();if(!n)throw new TypeError(`Record view field at index ${i} requires an id`);if(t.has(n))throw new TypeError(`Duplicate record view field: ${n}`);return t.add(n),{...e,id:n,label:String(e.label??gb(n)),sortable:!!e.sortable,type:String(e.type??"text")}})}function Di(s,t){let e=s.map(r=>r.id),i=new Set(e),n=Array.isArray(t)?t.map(String):[];return[...new Set(n.filter(r=>i.has(r))),...e.filter(r=>!n.includes(r))]}function xh(s,t,e,i="before"){let n=[...s],r=n.indexOf(t),o=n.indexOf(e);if(r<0||o<0||r===o)return n;n.splice(r,1);let a=n.indexOf(e)+(i==="after"?1:0);return a=Math.max(0,Math.min(n.length,a)),n.splice(a,0,t),n}function X(s,t,e=0){return typeof s.get=="function"?s.get(t,e):t?.[s.id]}function Ps(s,t,e=0){let i=X(s,t,e);return typeof s.render=="function"?s.render(t,e,i):i==null?"":String(i)}function vh(s,t,e){if(!e)return[...s];let i=t.find(r=>r.id===e.id);if(!i)return[...s];let n=new WeakMap(s.map((r,o)=>[r,o]));return di(s,r=>typeof i.sortValue=="function"?i.sortValue(r,n.get(r)??0):X(i,r,n.get(r)??0),e.dir)}function Sh(s,t){let e=s&&typeof s=="object"?s:{};return{version:1,fieldOrder:Di(t,e.fieldOrder),hiddenFields:[...Kr(t,e.hiddenFields)],sort:Vs(e.sort,t)}}function Ee(s,t){return typeof t=="function"?t(s):s?.[String(t??"ID")]}function Vs(s,t){if(!s||typeof s!="object")return null;let e=String(s.id??""),i=t.find(n=>n.id===e);return!i||!i.sortable?null:{id:e,dir:s.dir==="desc"?"desc":"asc"}}function Kr(s,t,e=!1){let i=new Set(s.map(r=>r.id)),n=new Set(Array.isArray(t)?t.map(String).filter(r=>i.has(r)):[]);if(e)for(let r of s)r.visible===!1&&n.add(r.id);return n.size>=s.length&&s[0]&&n.delete(s[0].id),n}function qr(s){if(!Array.isArray(s))throw new TypeError("Record view data must be an array");return s.forEach(Ah),[...s]}function Ah(s){if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("Record view data entries must be objects")}function gb(s){let t=String(s).split(".").at(-1)??"";if(t==="ID")return"ID";let e=t.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):t}function bb(s,t){return s===null&&t===null||!!(s&&t&&s.id===t.id&&s.dir===t.dir)}function yh(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function wh(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}var Yr=class extends yt{static cssName="table-view";static defaults={table:{}};constructor(t=null,e={}){super(t,e)}render(){let t=this.el===null,e=this.el??l("div");this.el=e,this._createdTableViewRoot=t,this._tableViewOriginal=t?null:A(e),this._tableViewRestored=!1,this._tableSyncDepth=0,this._tableViewDestroyed=!1,this._tableHost=l("div",{class:"zx-table-view__table"}),this._initRecordView(e);let i=Bt(this.options.fieldControls);this._tableViewToolbar=i.custom&&!this._viewFieldControlsTarget?l("div",{class:"zx-record-view__toolbar zx-table-view__toolbar"}):null;try{e.replaceChildren(...[this._tableViewToolbar,this._tableHost].filter(Boolean));let n=this.options,r=yb(n.table,{fields:this.getFields(),data:this.getData(),recordId:this.options.recordId,sort:this.getSort(),sortMode:this.options.sortMode,selectable:this.options.selectable,hiddenFields:this.getHiddenFields(),fieldControls:this.options.fieldControls,emptyText:this.options.emptyText});return this.table=new Ot(this._tableHost,r),this.table.setSelection(this.getSelectionIds()),this._bridgeTableEvents(),i.custom&&this._mountViewFieldControls(this._tableViewToolbar??e),e}catch(n){throw this.table?.destroy(),this._removeViewFieldControls(),t||S(e,this._tableViewOriginal),n}}getTable(){return this.table}_refreshView(t){!this.table||this._tableSyncDepth>0||this._withTableSync(()=>{if((t==="fields"||t==="state")&&(this.table.setColumns(kh(this.getFields()),{silent:!0}),this._syncTableFieldState()),(t==="data"||t==="fields"||t==="sort"||t==="state")&&this.table.setData(this.getData()),t==="sort"||t==="fields"||t==="state"){let e=this.getSort();e?this.table.setSort(e.id,e.dir,{silent:!0}):this.table.clearSort({silent:!0})}(t==="selection"||t==="data"||t==="state")&&this.table.setSelection(this.getSelectionIds()),t==="loading"&&this.table.setLoading(this.el.dataset.loading==="true")})}destroy(){this._tableViewDestroyed||(this._tableViewDestroyed=!0,this.table?.destroy(),!this._tableViewRestored&&!this._createdTableViewRoot&&(S(this.el,this._tableViewOriginal),this._tableViewRestored=!0),super.destroy())}_withTableSync(t){this._tableSyncDepth+=1;try{t()}finally{this._tableSyncDepth-=1}}_syncTableFieldState(){let t=new Set(this.getHiddenFields());for(let e of this.getFieldOrder())t.has(e)||this.table.setColumnVisible(e,!0,{silent:!0});for(let e of this.getFieldOrder())t.has(e)&&this.table.setColumnVisible(e,!1,{silent:!0})}_bridgeTableEvents(){this.listen(this._tableHost,"zx-datachange",t=>t.stopPropagation()),this.listen(this._tableHost,"zx-selectionchange",t=>t.stopPropagation()),this.listen(this.table,"rowclick",t=>{let e=t.detail;this.emit("recordclick",{...e,record:e.row})}),this.listen(this.table,"rowdblclick",t=>{let e=t.detail;this.emit("recorddblclick",{...e,record:e.row})}),this.listen(this.table,"sort",t=>this._tableSortChanged(t.detail)),this.listen(this.table,"selectionchange",t=>this._tableSelectionChanged(t.detail)),this.listen(this.table,"datachange",()=>this._tableDataChanged()),this.listen(this.table,"columnvisibilitychange",t=>this._tableVisibilityChanged(t.detail)),this.listen(this.table,"columnorderchange",t=>this._tableOrderChanged(t.detail))}_tableSortChanged(t){if(this._tableSyncDepth>0)return;let e=t.id==null?null:{id:String(t.id),dir:t.dir==="desc"?"desc":"asc"};wb(e,this._viewSort)||(this._viewSort=e,this.options.sortMode==="local"&&(this._viewData=this.table.getData()),this.emit("sortchange",e?{...e}:{id:null,dir:null}),this._emitTableViewState("sort"))}_tableSelectionChanged(t){if(this._tableSyncDepth>0)return;let e=new Set(t.ids);Ur(e,this._viewSelected)||(this._viewSelected=e,this._viewSelectionAnchor=t.ids.at(-1)??null,this._emitTableViewSelection())}_tableDataChanged(){if(this._tableSyncDepth>0)return;this._viewData=this.table.getData();let t=new Set(this._viewData.map(n=>this._viewRecordId(n))),e=new Set([...this._viewSelected].filter(n=>t.has(n))),i=!Ur(e,this._viewSelected);this._viewSelected=e,this._viewSelectionAnchor!=null&&!t.has(this._viewSelectionAnchor)&&(this._viewSelectionAnchor=null),i&&this._emitTableViewSelection(),this.emit("datachange",{records:this.getData()})}_tableVisibilityChanged(t){if(this._tableSyncDepth>0)return;let e=new Set(this.getFieldOrder()),i=new Set(t.hidden.filter(n=>e.has(n)));Ur(i,this._viewHidden)||(this._viewHidden=i,this.emit("fieldvisibilitychange",{visible:this.getVisibleFields().map(n=>n.id),hidden:this.getHiddenFields()}),this._emitTableViewState("fieldvisibility"))}_tableOrderChanged(t){if(this._tableSyncDepth>0)return;let e=new Set(this.getFieldOrder()),i=[...new Set(t.order.filter(n=>e.has(n))),...this.getFieldOrder().filter(n=>!t.order.includes(n))];xb(i,this._viewFieldOrder)||(this._viewFieldOrder=i,this.emit("fieldorderchange",{order:this.getFieldOrder()}),this._emitTableViewState("fieldorder"))}_emitTableViewSelection(){this.emit("selectionchange",{records:this.getSelection(),ids:this.getSelectionIds()})}_emitTableViewState(t){this.emit("statechange",{state:this.getViewState(),reason:t})}};function kh(s){return s.map(t=>{let e=t.view&&typeof t.view=="object"&&t.view.table&&typeof t.view.table=="object"?t.view.table:{},i={...t,...e,id:t.id,label:t.label,sortable:!!t.sortable};if(delete i.get,delete i.visible,delete i.duplicate,delete i.view,typeof t.render=="function")i.render=(n,r)=>t.render(n,r,X(t,n,r));else if(typeof e.render!="function"&&typeof t.get=="function"){let n={...i};delete n.render,i.render=(r,o)=>Hn(n,{...r,[t.id]:X(t,r,o)},o)}return typeof t.sortValue=="function"?i.sortValue=n=>t.sortValue(n,0):typeof e.sortValue!="function"&&typeof t.get=="function"&&(i.sortValue=n=>X(t,n,0)),i})}function yb(s,t){let e=Bt(t.fieldControls),i=e.enabled&&!e.custom;return{...s&&typeof s=="object"?s:{},columns:kh(t.fields),data:[...t.data],rowId:t.recordId,sort:t.sort?{...t.sort}:null,sortMode:t.sortMode,selectable:t.selectable,hiddenColumns:[...t.hiddenFields],columnVisibility:i,columnReorder:i,emptyText:t.emptyText}}function wb(s,t){return s===null&&t===null||!!(s&&t&&s.id===t.id&&s.dir===t.dir)}function Ur(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}function xb(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function Hs(s,t,e={}){let i=Array.isArray(e.fields)?e.fields:[],n=Array.isArray(e.visibleFields)?e.visibleFields:i,r=e.titleField??i[0]?.id??null,o=e.subtitleField??null,a=zh(s,t,r,i),c=zh(s,t,o,i),h=Sb(s,t,e.preview,e.previewAlt,i),u=Ab(s,t,e.link),d=Mi(s,t,e.actions),p=Db(e.controls),f=Nb(e.selectable),_=!!e.selected,b=x("zx-record-card-title"),w=Fb(e.headingLevel),y=u?l("a",{class:"zx-record-card__primary",href:u.href,target:u.target,rel:u.rel},Bs(a)):l("span",{class:"zx-record-card__title"},Bs(a)),v=l(`h${w}`,{class:"zx-record-card__heading",id:b},y),k=vb(n,r,o),z=zb(s,t,k.eyebrowStart,k.eyebrowEnd),E=js(s,t,k.titlePrefix,"zx-record-card__title-prefix","title-prefix"),M=E?l("div",{class:"zx-record-card__title-row"},E,v):v,it=f==="multi"&&e.selectionTrigger!=="card"?l("label",{class:"zx-record-card__selection"},l("input",{type:"checkbox",checked:_,dataset:{recordSelection:""},ariaLabel:`Select ${Ch(a)||"record"}`})):null,N=d.map(Tb),J=N.length||p.length?l("div",{class:"zx-record-card__actions",role:"group",ariaLabel:`Actions for ${Ch(a)||"record"}`},p,N):null,xt=l("header",{class:"zx-record-card__header"},it,l("div",{class:"zx-record-card__titles"},M,Eb(c)?null:l("p",{class:"zx-record-card__subtitle"},Bs(c))),J),Fu=js(s,t,k.metadata,"zx-record-card__metadata"),Lu=l("div",{class:"zx-record-card__body"},z,xt,Fu);return l("li",{class:"zx-record-card",tabindex:0,ariaDescription:f?_?"Selected":"Not selected":void 0,ariaLabelledby:b,ariaKeyshortcuts:f&&e.selectionTrigger==="card"?"Space Enter":void 0,dataset:{recordIndex:String(t),variant:Ob(e.variant),selected:String(_),selectionTrigger:f&&e.selectionTrigger==="card"?"card":"checkbox"}},h?kb(h):null,Lu)}function vb(s,t=null,e=null){let i={eyebrowStart:[],eyebrowEnd:[],titlePrefix:[],metadata:[]},n=typeof t=="string"?t:null,r=typeof e=="string"?e:null;for(let o of Array.isArray(s)?s:[]){if(!o.duplicate&&(o.id===n||o.id===r))continue;let a=Cb(o);a==="eyebrow-start"?i.eyebrowStart.push(o):a==="eyebrow-end"?i.eyebrowEnd.push(o):a==="title-prefix"?i.titlePrefix.push(o):i.metadata.push(o)}return i}function Sb(s,t,e,i,n=[]){if(e==null)return null;let r=typeof e=="function"?e(s,t):Th(s,t,e,n,!1);if(r==null||r==="")return null;let o=Ib(s,t,i,n);if(qs(r))return{node:r,src:null,alt:o,fit:"cover",rejected:!1};let a=typeof r=="object"&&!Array.isArray(r)?r:{src:String(r)},c=typeof a.src=="string"?a.src:"",h=Mb(c);return{node:null,src:h,alt:a.alt==null?o:String(a.alt),fit:Lb(a.fit),rejected:h===null}}function Ab(s,t,e){let i=typeof e=="function"?e(s,t):e;if(i==null)return null;let n=typeof i=="string"?{href:i}:i;if(!n||typeof n!="object"||Array.isArray(n))return null;let r=V(n.href);if(r===null)return null;let o=n.target==null?void 0:String(n.target),a=Ih(n.rel,o);return{href:r,...o?{target:o}:{},...a?{rel:a}:{}}}function Mi(s,t,e){let i=typeof e=="function"?e(s,t):e;return Array.isArray(i)?i.flatMap(n=>{if(!n||typeof n!="object"||Array.isArray(n))return[];let r=String(n.id??"").trim(),o=String(n.label??""),a=n.title==null?"":String(n.title);return!r||!o&&!a?[]:n.href!=null&&V(n.href)===null?[]:[{...n,id:r,label:o,...a?{title:a}:{}}]}):[]}function kb(s){let t=l("span",{class:"zx-record-card__preview-fallback",ariaHidden:"true"},g("file",{size:24}));if(s.node)return l("div",{class:"zx-record-card__preview"},s.node);let e=s.src?l("img",{class:"zx-record-card__preview-image",src:s.src,alt:s.alt,loading:"lazy",decoding:"async",dataset:{recordPreview:""},style:{objectFit:s.fit}}):null;return l("div",{class:"zx-record-card__preview",dataset:{failed:String(s.rejected)}},t,e)}function zb(s,t,e,i){let n=js(s,t,e,"zx-record-card__eyebrow-group","eyebrow-start"),r=js(s,t,i,"zx-record-card__eyebrow-group","eyebrow-end");return n||r?l("div",{class:"zx-record-card__eyebrow"},n,r):null}function js(s,t,e,i,n=null){return e.length===0?null:l("dl",{class:i,dataset:n?{cardSlot:n}:void 0},e.map(r=>l("div",{class:"zx-record-card__field",dataset:{fieldId:r.id,...n?{cardSlot:n}:{}}},l("dt",{class:"zx-record-card__label"},r.label),l("dd",{class:"zx-record-card__value"},Bs(Ps(r,s,t))))))}function Cb(s){let t=s?.view;if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t.card;if(!e||typeof e!="object"||Array.isArray(e))return null;let i=e.slot;return i==="eyebrow-start"||i==="eyebrow-end"||i==="title-prefix"?i:null}function Tb(s){let t=String(s.label??""),e=String(s.title??(t||s.id)),i=[s.icon?g(String(s.icon),{size:14}):null,t?l("span",{class:"zx-record-card__action-label"},t):null],n=s.href==null?null:V(s.href);if(n&&!s.disabled){let r=s.target==null?void 0:String(s.target);return l("a",{class:"zx-record-card__action",href:n,target:r,rel:Ih(s.rel,r),title:e,ariaLabel:t||e,dataset:{recordAction:s.id}},i)}return l("button",{class:"zx-record-card__action",type:"button",disabled:!!s.disabled,title:e,ariaLabel:t||e,dataset:{recordAction:s.id}},i)}function zh(s,t,e,i){if(e==null)return"";if(typeof e=="function")return e(s,t);let n=i.find(r=>r.id===e);return n?Ps(n,s,t):s?.[e]??""}function Th(s,t,e,i,n){let r=i.find(o=>o.id===e);return r?X(r,s,t):Object.prototype.hasOwnProperty.call(s,e)?s[e]:n?e:null}function Ib(s,t,e,i){if(e==null)return"";let n=typeof e=="function"?e(s,t):Th(s,t,e,i,!0);return n==null?"":String(n)}function Bs(s){return qs(s)?s:s==null?"":String(s)}function Eb(s){return s==null||typeof s!="object"&&String(s)===""}function Ch(s){return qs(s)?s.textContent?.trim()??"":s==null?"":String(s).trim()}function qs(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Db(s){return Array.isArray(s)?s.filter(qs):[]}function Mb(s){let t=V(s);if(!t)return null;try{let e=globalThis.location?.href??"https://zx.invalid/",i=new URL(t,e).protocol.toLowerCase();return["http:","https:","blob:"].includes(i)?t:null}catch{return null}}function Ih(s,t){let e=String(s??"").split(/\s+/).filter(i=>/^[a-z-]+$/i.test(i));return t==="_blank"&&!e.includes("noopener")&&e.push("noopener"),e.length?[...new Set(e)].join(" "):void 0}function Nb(s){return s==="single"||s==="multi"?s:!1}function Ob(s){return s==="raised"||s==="filled"?s:"outlined"}function Fb(s){let t=Number(s??3);return Number.isInteger(t)&&t>=1&&t<=6?t:3}function Lb(s){return["contain","fill","none","scale-down"].includes(String(s))?s:"cover"}var Wr=class extends yt{static cssName="card-view";static defaults={...yt.defaults,selectionTrigger:"checkbox",titleField:null,subtitleField:null,preview:void 0,previewAlt:null,link:void 0,actions:[],groupBy:null,groupOrder:[],minCardWidth:"15rem",maxColumns:null,variant:"outlined",loadingCount:6,headingLevel:3,label:"Card view"};constructor(t=null,e={}){super(t,e)}render(){let t=!this.el,e=this.el??l("section");this.el=e,this._cardCreatedRoot=t,this._cardOriginal=t?null:A(e),this._cardCleaned=!1,this._cardNodesById=new Map;let i=this._cardOptions();this._cardGroupOrder=Gr(i.groupOrder),this._cardMinWidth=Eh(i.minCardWidth),this._cardMaxColumns=Dh(i.maxColumns),this._cardVariant=Mh(i.variant),this._cardLoadingCount=Pb(i.loadingCount),this._cardHeadingLevel=Bb(i.headingLevel);try{this._initRecordView(e),e.setAttribute("aria-label",String(i.label||"Card view"));let n=l("label",{ref:"sortWrap",class:"zx-card-view__sort"},l("span",{class:"zx-card-view__sort-label"},this._message("cardView.sort","Sort")),l("select",{ref:"sort",ariaLabel:this._message("cardView.sortCards","Sort cards")})),r=l("div",{class:"zx-record-view__toolbar zx-card-view__toolbar"},n);Bt(this.options.fieldControls).enabled&&this._mountViewFieldControls(r);let o=l("div",{ref:"content",class:"zx-card-view__content"});return e.replaceChildren(r,o),this.listen(this.refs.sort,"change",()=>this._changeCardSort()),this.listen(o,"click",a=>this._cardClick(a)),this.listen(o,"dblclick",a=>this._cardDoubleClick(a)),this.listen(o,"keydown",a=>this._cardKeydown(a)),this.listen(o,"error",a=>this._cardPreviewError(a),!0),this._applyCardLayout(),this._renderCardSort(),this._renderCards(),e}catch(n){throw this._removeViewFieldControls(),t||S(e,this._cardOriginal),n}}getViewState(){return{...super.getViewState(),groupOrder:[...this._cardGroupOrder],minCardWidth:this._cardMinWidth,maxColumns:this._cardMaxColumns,variant:this._cardVariant}}setViewState(t,e={}){let i=t&&typeof t=="object"?t:{};return Object.prototype.hasOwnProperty.call(i,"groupOrder")&&(this._cardGroupOrder=Gr(i.groupOrder)),Object.prototype.hasOwnProperty.call(i,"minCardWidth")&&(this._cardMinWidth=Eh(i.minCardWidth)),Object.prototype.hasOwnProperty.call(i,"maxColumns")&&(this._cardMaxColumns=Dh(i.maxColumns)),Object.prototype.hasOwnProperty.call(i,"variant")&&(this._cardVariant=Mh(i.variant)),this._applyCardLayout(),super.setViewState(i,e)}destroy(){this._cardCleaned||(this._cardCleaned=!0,super.destroy(),this._cardCreatedRoot||S(this.el,this._cardOriginal))}_refreshView(t){this.refs?.content&&(t==="selection"?this._syncCardSelection():this._renderCards(),this._renderCardSort())}_applyCardLayout(){if(!this.el)return;let t=this.el;t.style.setProperty("--zx-card-view-min-card-width",this._cardMinWidth);let e=this._cardMaxColumns?`${100/this._cardMaxColumns}%`:"0%";t.style.setProperty("--zx-card-view-column-basis",e),this._cardMaxColumns?t.dataset.maxColumns=String(this._cardMaxColumns):delete t.dataset.maxColumns}_renderCardSort(){if(!this.refs?.sort||!this.refs?.sortWrap)return;let t=this.refs.sort,e=this.getSort(),i=[l("option",{value:"",selected:e===null},this._message("cardView.unsorted","Unsorted"))];for(let n of this.getFields().filter(r=>r.sortable))i.push(l("option",{selected:e?.id===n.id&&e.dir==="asc",dataset:{sortId:n.id,sortDir:"asc"}},this._message("cardView.sortAscending","%1 (ascending)",n.label))),i.push(l("option",{selected:e?.id===n.id&&e.dir==="desc",dataset:{sortId:n.id,sortDir:"desc"}},this._message("cardView.sortDescending","%1 (descending)",n.label)));t.replaceChildren(...i),this.refs.sortWrap.hidden=i.length===1}_changeCardSort(){let e=this.refs.sort.selectedOptions[0],i=e?.dataset.sortId;i?this.setSort(i,e.dataset.sortDir==="desc"?"desc":"asc"):this.setSort(null)}_renderCards(){let t=this.refs.content,e=t.querySelector(".zx-record-card:focus"),i=e?Number(e.dataset.recordIndex):-1,n=i>=0?this._viewData[i]:null,r=n?this._viewRecordId(n):null;if(this._cardNodesById=new Map,this.el.dataset.loading==="true"){t.replaceChildren(this._createCardSkeletons());return}let o=Rb(this._viewData,this._cardOptions().groupBy,this._cardGroupOrder,this._viewFields);if(this._viewData.length===0&&o.length===0){t.replaceChildren(this._createCardEmpty());return}let a=this.getFields(),c=this.getVisibleFields(),h=o.map((u,d)=>this._createCardGroup(u,a,c,d));if(t.replaceChildren(...h),r!==null){let u=this._cardNodesById.get(r);u&&queueMicrotask(()=>u.isConnected&&u.focus())}}_createCardGroup(t,e,i,n){let r=this._cardOptions(),o=t.id===null?null:`zx-card-view-group-${Hb(t.id)}-${n}`,a=l("ul",{class:"zx-card-view__list",ariaLabelledby:o??void 0});for(let c of t.records){let h=this._viewData.indexOf(c),u=this._viewRecordId(c),d=Hs(c,h,{fields:e,visibleFields:i,titleField:r.titleField,subtitleField:r.subtitleField,preview:r.preview,previewAlt:r.previewAlt,link:r.link,actions:r.actions,selectable:this.options.selectable,selectionTrigger:r.selectionTrigger,selected:this._isViewSelected(u),variant:this._cardVariant,headingLevel:this._cardHeadingLevel});this._cardNodesById.set(u,d),a.append(d)}return t.records.length===0&&a.append(l("li",{class:"zx-card-view__group-empty"},"No records in this group.")),t.id===null?a:l("section",{class:"zx-card-view__group",ariaLabelledby:o},l("h2",{class:"zx-card-view__group-heading",id:o},t.label),a)}_createCardSkeletons(){let t=l("ul",{class:"zx-card-view__list zx-card-view__skeletons",ariaHidden:"true"});for(let e=0;e<this._cardLoadingCount;e+=1)t.append(l("li",{class:"zx-record-card zx-card-view__skeleton",tabindex:-1},l("span",{class:"zx-card-view__skeleton-preview zx-skeleton"}),l("span",{class:"zx-card-view__skeleton-line zx-skeleton"}),l("span",{class:"zx-card-view__skeleton-line zx-skeleton"}),l("span",{class:"zx-card-view__skeleton-line zx-skeleton"})));return t}_createCardEmpty(){let t=this.options.emptyText,e=typeof t=="function"?t():t??this.msg("table.empty");return l("div",{class:"zx-card-view__empty",role:"status"},jb(e)?e:String(e))}_syncCardSelection(){for(let[t,e]of this._cardNodesById){let i=this._isViewSelected(t);e.dataset.selected=String(i),this.options.selectable&&e.setAttribute("aria-description",i?"Selected":"Not selected");let n=e.querySelector("[data-record-selection]");n&&(n.checked=i)}}_cardClick(t){let e=t.target,i=e?.closest?.(".zx-record-card");if(!i||!this.refs.content.contains(i))return;let n=Number(i.dataset.recordIndex),r=this._viewData[n];if(!r)return;let o=this._viewRecordId(r),a=e?.closest?.("[data-record-selection]");if(a){this.toggleSelection(o,{selected:a.checked,range:t.shiftKey});return}let c=e?.closest?.("[data-record-action]");if(c){this._activateCardAction(r,o,n,c.dataset.recordAction,t);return}if(!(Nh(e,i)||Oh(i))){if(this.options.selectable&&this._cardOptions().selectionTrigger==="card"){this.toggleSelection(o,{range:t.shiftKey}),i.focus({preventScroll:!0});return}this._activateCard(r,o,n,t),this.options.selectable==="single"&&this.toggleSelection(o,{selected:!0})}}_cardDoubleClick(t){let e=t.target,i=e?.closest?.(".zx-record-card");if(!i||Nh(e,i)||Oh(i))return;let n=Number(i.dataset.recordIndex),r=this._viewData[n];r&&this.emit("recorddblclick",{record:r,id:this._viewRecordId(r),index:n,event:t})}_cardKeydown(t){let e=t.target instanceof Element?t.target.closest(".zx-record-card"):null;if(!e||t.target!==e)return;let i=Number(e.dataset.recordIndex),n=this._viewData[i];if(!n)return;let r=this._viewRecordId(n);t.key==="Enter"?(t.preventDefault(),this.options.selectable&&this._cardOptions().selectionTrigger==="card"?this.toggleSelection(r):this._activateCard(n,r,i,t)):t.key===" "&&this.options.selectable&&(t.preventDefault(),this.toggleSelection(r))}_activateCard(t,e,i,n){this.emit("recordclick",{record:t,id:e,index:i,event:n})}_activateCardAction(t,e,i,n,r){let o=Mi(t,i,this._cardOptions().actions).find(c=>c.id===n);if(!o||o.disabled){r.preventDefault();return}typeof o.onclick=="function"&&o.onclick(t,i,r),this.emit("recordaction",{record:t,id:e,index:i,action:{...o},event:r}).defaultPrevented&&r.preventDefault()}_cardPreviewError(t){let e=t.target;if(!e?.matches?.("[data-record-preview]"))return;let i=e.closest(".zx-record-card__preview");i&&(i.dataset.failed="true"),e.hidden=!0}_cardOptions(){return this.options}};function Rb(s,t,e=[],i=[]){if(!Array.isArray(s))throw new TypeError("Card view records must be an array");if(t==null)return s.length?[{id:null,label:"",records:[...s]}]:[];let n=Gr(e),r=new Map(n.map(o=>[o,[]]));for(let[o,a]of s.entries()){let c=typeof t=="function"?t(a,o):Vb(a,o,t,i),h=Fh(c);r.has(h)||r.set(h,[]),r.get(h).push(a)}return[...r].map(([o,a])=>({id:o,label:o||"Ungrouped",records:a}))}function Vb(s,t,e,i){let n=i.find(r=>r.id===e);return n?X(n,s,t):s?.[e]}function Gr(s){return Array.isArray(s)?[...new Set(s.map(Fh))]:[]}function Fh(s){return s==null||s===""?"":String(s)}function Eh(s){if(typeof s=="number")return Number.isFinite(s)&&s>0?`${s}px`:"15rem";let t=String(s??"").trim();return!t||t.length>128||/[;{}\u0000-\u001f\u007f]/.test(t)||/(?:url|image|image-set|cross-fade|element|expression)\s*\(/i.test(t)||typeof globalThis.CSS?.supports=="function"&&!globalThis.CSS.supports("width",t)?"15rem":t}function Dh(s){if(s==null||s==="")return null;let t=Number(s);return Number.isFinite(t)?Math.max(1,Math.min(12,Math.floor(t))):null}function Mh(s){return s==="raised"||s==="filled"?s:"outlined"}function Pb(s){let t=Number(s??6);return Number.isFinite(t)?Math.max(1,Math.min(50,Math.floor(t))):6}function Bb(s){let t=Number(s??3);return Number.isInteger(t)&&t>=1&&t<=6?t:3}function Nh(s,t){let e=s?.closest?.('a,button,input,select,textarea,summary,[contenteditable="true"],[role="button"]');return!!(e&&e!==t&&t.contains(e))}function Oh(s){let t=globalThis.getSelection?.();return!!(t&&!t.isCollapsed&&(t.anchorNode&&s.contains(t.anchorNode)||t.focusNode&&s.contains(t.focusNode)))}function jb(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Hb(s){return s.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"empty"}var Lh=Object.freeze(["neutral","accent","success","warning","danger","info"]);function Qr(s,t={}){if(s==null||s==="")return null;let e=t&&typeof t=="object"?t:{},i=typeof s=="object"&&!("nodeType"in s)?s:{label:s},n=i.label==null?"":String(i.label);if(!n)return null;let r=e[n],o=Lh.includes(i.tone)?i.tone:Lh.includes(r)?r:"neutral";return{label:n,tone:o,icon:i.icon==null?null:String(i.icon),dot:i.dot!==!1&&i.icon==null,...i.title==null?{}:{title:String(i.title)}}}function Rh(s){return pt({label:s.label,kind:s.tone,icon:s.icon??void 0,dot:s.dot,size:"sm",variant:"soft",...s.title==null?{}:{title:s.title}})}function Xr(s,t=100){if(s==null||s==="")return null;let e=typeof s=="object"&&!("nodeType"in s)?s:{value:s},i=Number(e.max??t),n=Number(e.value);if(!Number.isFinite(n)||!Number.isFinite(i)||i<=0)return null;let r=Math.max(0,Math.min(i,n)),o=e.label==null?"":String(e.label).trim();return{value:r,max:i,percent:Math.round(r/i*100),label:o||null}}function Jr(s,t,e){let i=l("div",{class:"zx-kanban-view__progress-track",role:"progressbar",ariaValuemin:"0",ariaValuemax:String(s.max),ariaValuenow:String(s.value),ariaValuetext:e,ariaLabel:t},l("div",{class:"zx-kanban-view__progress-fill"}));return i.firstElementChild.style.inlineSize=`${s.percent}%`,l("div",{class:"zx-kanban-view__progress"},l("div",{class:"zx-kanban-view__progress-head"},l("span",{class:"zx-kanban-view__progress-label"},t),l("span",{class:"zx-kanban-view__progress-value"},e)),i)}function Zr(s){return s==null||s===""?[]:(Array.isArray(s)?s:[s]).map(e=>{if(e==null||e==="")return null;let i=typeof e=="object"&&!("nodeType"in e)?e:{name:e},n=String(i.name??i.label??"").trim();if(!n)return null;let r=V(i.src??i.image??null),o=i.initials==null?As(n):String(i.initials);return{name:n,src:r,initials:o}}).filter(Boolean)}function Vh(s,t){let e=Number.isFinite(t)?Math.max(0,Math.floor(t)):0,i=Number.isFinite(s)?Math.max(1,Math.floor(s)):e,n=Math.min(e,i);return{shown:n,hidden:Math.max(0,e-n)}}function to(s,t,e,i){if(!s.length)return null;let n=Vh(t,s.length),r=s.slice(0,n.shown),o=n.hidden,a=r.map(c=>l("span",{class:"zx-kanban-view__avatar",ariaHidden:"true",title:c.name||void 0},c.src?l("img",{class:"zx-kanban-view__avatar-image",src:c.src,alt:"",draggable:!1}):l("span",{class:"zx-kanban-view__avatar-initials"},c.initials)));return o>0&&a.push(l("span",{class:"zx-kanban-view__avatar",ariaHidden:"true",dataset:{overflow:"true"}},l("span",{class:"zx-kanban-view__avatar-initials"},i(o)))),l("span",{class:"zx-kanban-view__avatars",role:"img",ariaLabel:e},a)}function eo(s){let t=[];s.entityIcon&&t.push(l("span",{class:"zx-kanban-view__entity",ariaHidden:"true"},g(s.entityIcon,{size:12}))),s.identifier&&t.push(l("span",{class:"zx-kanban-view__identifier"},s.identifierPrefix?l("span",{class:"zx-kanban-view__hint"},`${s.identifierPrefix} `):null,s.identifier));let e=(s.flags??[]).map(i=>{if(i.indicator==null)return null;let n=typeof i.indicator=="object"&&"nodeType"in i.indicator?i.indicator:Rh(i.indicator);return i.prefix?l("span",{class:"zx-kanban-view__flag"},l("span",{class:"zx-kanban-view__hint"},`${i.prefix} `),n):n}).filter(Boolean);return!t.length&&!e.length?null:l("div",{class:"zx-kanban-view__card-head"},t.length?l("span",{class:"zx-kanban-view__card-lead"},t):null,e.length?l("span",{class:"zx-kanban-view__card-flags"},e):null)}var qb=Object.freeze(["neutral","accent","success","warning","danger","info"]);function io(s){if(s==null)return[];if(!Array.isArray(s))throw new TypeError("Kanban rules must be an array or null");let t=new Set;return s.map((e,i)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError(`Kanban rule at index ${i} must be an object`);let n=e,r=String(n.id??"").trim();if(!r)throw new TypeError(`Kanban rule at index ${i} requires an id`);if(t.has(r))throw new TypeError(`Duplicate Kanban rule: ${r}`);if(typeof n.when!="function")throw new TypeError(`Kanban rule ${r} requires a when predicate`);return t.add(r),{id:r,when:n.when,tone:qb.includes(n.tone)?n.tone:"accent",label:n.label==null?"":String(n.label),icon:n.icon==null?null:String(n.icon),description:n.description==null?"":String(n.description)}})}function $s(s,t,e){return!Array.isArray(s)||!s.length?[]:s.filter(i=>{try{return i.when(t,e)===!0}catch{return!1}})}function so(s){let{records:t,column:e,swimlane:i,context:n,from:r}=s,o=Math.max(1,t.length),a=e?.wipPolicy==="block"||e?.wipPolicy==="warn"?e.wipPolicy:s.policy==="block"?"block":"warn",c=(_,b={})=>({allowed:!1,reason:_,limit:null,count:0,limitExceeded:!1,limitReached:!1,policy:a,...b}),h=Ks(e,i,r);if(h)return c(h);for(let _ of t){if(e.accept&&e.accept(_,n)===!1)return c("accept");if(i?.accept&&i.accept(_,n)===!1)return c("lane-accept")}let u=[];e.limit!=null&&u.push({reason:"wip",limit:e.limit,count:s.columnCount+o});let d=i?$b(e.laneLimits,i.id):null;d!=null&&u.push({reason:"wip",limit:d,count:s.cellCount+o}),i?.limit!=null&&u.push({reason:"lane-wip",limit:i.limit,count:s.laneCount+o});let p=u.find(_=>_.count>_.limit),f=p??u.find(_=>_.count===_.limit)??u[0];return p&&a==="block"?c(p.reason,{limit:p.limit,count:p.count,limitExceeded:!0}):{allowed:!0,reason:null,limit:f?f.limit:null,count:f?f.count:0,limitExceeded:!!p,limitReached:!!(f&&!p&&f.count===f.limit),policy:a}}function Ks(s,t,e){return s.id!==e.column&&!Ph(s.from,e.column)?"transition":t&&t.id!==e.lane&&!Ph(t.from,e.lane)?"lane-transition":null}function no(s){let t=s==null?"":String(s).trim().toLowerCase();return t?[...t.matchAll(/"([^"]*)"|(\S+)/g)].map(e=>(e[1]??e[2]??"").trim()).filter(Boolean):[]}function ro(s,t){if(!t.length)return!0;let e=s.toLowerCase();return t.every(i=>e.includes(i))}function oo(s=50){let t=Number.isFinite(Number(s))&&Number(s)>0?Math.floor(Number(s)):50,e=[],i=[];return{push(n){e.push(n),e.length>t&&(e=e.slice(-t)),i=[]},undo(n){let r=e.pop();return r?(i.push(n),i.length>t&&(i=i.slice(-t)),r):null},redo(n){let r=i.pop();return r?(e.push(n),e.length>t&&(e=e.slice(-t)),r):null},canUndo:()=>e.length>0,canRedo:()=>i.length>0,clear(){e=[],i=[]},depth:()=>({undo:e.length,redo:i.length})}}function ao(s,t,e){if(!Array.isArray(s)||!Array.isArray(t)||!t.length)return null;let i=t.map(u=>({...u,index:s.findIndex(d=>Object.is(Ee(d,e.recordId),u.id))}));if(i.some(u=>u.index<0||!u.record||typeof u.record!="object"))return null;i.sort((u,d)=>u.index-d.index);let n=i.map(u=>({id:u.id,from:Us(s,u.index,e)})),r=new Set(i.map(u=>u.index)),o=s.filter((u,d)=>!r.has(d)),a=o.filter((u,d)=>K(Qt(u,d,e.columnBy))===e.destination.column&&(e.swimlaneBy==null||K(Qt(u,d,e.swimlaneBy))===e.destination.lane)),c=Ni(e.destination.index,a.length),h=o.length;return a[c]?h=o.indexOf(a[c]):a.length&&(h=o.indexOf(a.at(-1))+1),o.splice(h,0,...i.map(u=>u.record)),{records:o,moves:n,to:{column:e.destination.column,lane:e.swimlaneBy==null?null:e.destination.lane,index:c}}}function Us(s,t,e){let i=s[t],n=K(Qt(i,t,e.columnBy)),r=e.swimlaneBy==null?null:K(Qt(i,t,e.swimlaneBy)),o=s.filter((c,h)=>K(Qt(c,h,e.columnBy))===n&&(e.swimlaneBy==null||K(Qt(c,h,e.swimlaneBy))===r)),a=Ee(i,e.recordId);return{column:n,lane:r,index:o.findIndex(c=>Object.is(Ee(c,e.recordId),a))}}function lo(s,t){let e=Ni(t,s.filter(Boolean).length),i=0;for(let n=0;n<s.length;n+=1)if(s[n]){if(i===e)return n;i+=1}return s.length}function Qt(s,t,e){return typeof e=="function"?e(s,t):e==null?null:s?.[e]}function K(s){return s==null?"":String(s)}function Ni(s,t){return s==null||!Number.isFinite(Number(s))?t:Math.max(0,Math.min(t,Math.trunc(Number(s))))}function Ph(s,t){return s==null||!Array.isArray(s)?!0:s.length?s.some(e=>String(e)==="*"||String(e)===K(t)):!1}function $b(s,t){if(!s||typeof s!="object")return null;let e=s[t];if(e==null||e==="")return null;let i=Number(e);return Number.isFinite(i)&&i>=0?Math.floor(i):null}var co='a, button, input, select, textarea, summary, [contenteditable="true"]',Kb=4,Ub=350,Yb=120,Ys=56,Ws=18,Wb=Object.freeze({fields:"Fields",search:"Search board",searchPlaceholder:"Search cards",clearSearch:"Clear search",searchSummary:"%count% of %total% cards match.",undo:"Undo",redo:"Redo",add:"Add card",addTo:"Add card to %target%",move:"Move %name%",moveMultiple:"Move %count% selected cards",collapseColumn:"Collapse column %label%",expandColumn:"Expand column %label%",collapseLane:"Collapse swim lane %label%",expandLane:"Expand swim lane %label%",count:"%count% records",countFiltered:"%count% of %total% records",countLimit:"%count% records, work-in-progress limit %limit%",countLimitInLane:"%count% records in this lane, %total% of work-in-progress limit %limit% in the column",empty:"No records",columnEmpty:"Drop a card here",identifier:"Record",priorityLabel:"Priority",statusLabel:"Status",progress:"Progress",progressValue:"%percent%%",assignees:"Assigned to %names%",assigneeOverflow:"+%count%",selected:"Selected",notSelected:"Not selected",noMatches:"No cards match the current search.",record:"record",grabbed:"Grabbed %name%. Use left and right for columns, up and down for position, and Alt plus up or down for swim lanes.",grabbedMultiple:"Grabbed %count% cards. Use left and right for columns, up and down for position, and Alt plus up or down for swim lanes.",target:"Target %target%, position %position% of %total%.",moved:"Moved %name% to %target%.%wip%",movedMultiple:"Moved %count% cards to %target%.%wip%",moveRequested:"Move requested for %name% to %target%.%wip%",moveCanceled:"Move canceled for %name%.",moveCanceledPlain:"Move canceled.",limitReached:" Work-in-progress limit %limit% reached.",limitExceeded:" Work-in-progress limit %limit% exceeded.",rejectAccept:"Move rejected: %target% does not accept %name%.",rejectTransition:"Move rejected: %target% does not accept cards from %origin%.",rejectWip:"Move rejected: %target% is at its work-in-progress limit of %limit%.",rejectDestination:"Move rejected: the destination is not available.",rejectGrouping:"Move rejected: callback grouping requires external move mode.",undone:"Move undone.",redone:"Move redone.",nothingToUndo:"Nothing to undo.",nothingToRedo:"Nothing to redo.",menuMoveTo:"Move to %target%",menuMoveToLane:"Move to lane %target%",dragPreview:"%count% cards"}),ho=class extends yt{static cssName="kanban-view";static defaults={...yt.defaults,selectionTrigger:"checkbox",columnBy:"status",columns:null,swimlaneBy:null,swimlanes:null,titleField:null,subtitleField:null,preview:null,previewAlt:null,link:null,actions:[],moveMode:"local",dragFrom:"card",moveHandle:"keyboard",entityIcon:null,identifier:null,status:null,statusTones:{},priority:null,priorityTones:{},progress:null,progressMax:100,assignees:null,maxAvatars:3,multiMove:!0,autoScroll:!0,wipPolicy:"warn",rules:[],search:"",searchFields:null,filter:null,searchControl:!1,history:!0,historyLimit:50,historyControls:!1,columnHeight:null,allowAdd:!1,contextMenu:!1,renderCard:null,renderColumnHeader:null,renderSwimlaneHeader:null,renderColumnEmpty:null,renderDragPreview:null,labels:{},columnOrder:[],swimlaneOrder:[],collapsedColumns:[],collapsedSwimlanes:[],showCounts:!0,showEmptyColumns:!0,variant:"outlined",label:"Kanban board"};constructor(t=null,e={}){super(t,e)}render(){let t=!!this.el,e=this.el??l("div"),i=this._kanbanOptions();this._kanbanSnapshot=t?A(e):null,this._kanbanDestroyed=!1;try{if(this._initRecordView(e),this._kanbanColumns=i.columns===null?null:Gs(i.columns,"column"),this._kanbanSwimlanes=i.swimlanes===null?null:Gs(i.swimlanes,"swimlane"),this._kanbanColumnOrder=Ct(i.columnOrder),this._kanbanSwimlaneOrder=Ct(i.swimlaneOrder),this._collapsedColumns=new Set(Ct(i.collapsedColumns)),this._collapsedSwimlanes=new Set(Ct(i.collapsedSwimlanes)),this._kanbanRules=io(i.rules),this._kanbanSearch=i.search==null?"":String(i.search),this._kanbanFilter=typeof i.filter=="function"?i.filter:null,this._kanbanHistory=oo(i.historyLimit),this._keyboardMove=null,this._dragIds=[],this._dragDestination=null,this._pointerStart=null,this._pointerHold=0,this._dragFrame=0,this._dragPreview=null,this._dragPointer=null,this._dragCaptured=!1,this._searchTimer=0,this._dragPoint={x:0,y:0},this._suppressClick=!1,this._announcementToken=0,this._cardMeta=new WeakMap,this._sectionMeta=new WeakMap,this._cardsById=new Map,this._visibleIds=new Set,this._cardSources={identifier:null,status:null,priority:null,progress:null,assignees:null,entityIcon:null,fieldIds:new Set,any:!1},this._fieldIndex=null,this._cardFields=null,this._kanbanMenu=null,this._searchInput=null,this._undoButton=null,this._redoButton=null,this._toolbar=l("div",{class:"zx-record-view__toolbar zx-kanban-view__toolbar"}),i.fieldControls){let n=Bt(i.fieldControls).label;this._toolbar.append(this._createViewFieldControls(n??this._text("fields")))}return i.searchControl&&this._toolbar.append(this._createSearchControl()),i.historyControls&&this._toolbar.append(this._createHistoryControls()),this._board=l("div",{class:"zx-kanban-view__board",role:"region",ariaLabel:i.label}),this._live=l("div",{class:"zx-kanban-view__live",role:"status",ariaLive:"polite",ariaAtomic:"true"}),e.replaceChildren(this._toolbar,this._board,this._live),i.columnHeight&&(e.style.setProperty("--zx-kanban-column-height",String(i.columnHeight)),e.dataset.columnScroll="true"),this.listen(this._board,"click",n=>this._handleBoardClick(n)),this.listen(this._board,"dblclick",n=>this._handleBoardDoubleClick(n)),this.listen(this._board,"keydown",n=>this._handleBoardKeydown(n)),this.listen(this._board,"error",n=>this._handlePreviewError(n),{capture:!0}),this.listen(this._board,"pointerdown",n=>this._handlePointerDown(n)),this.listen(this._board,"pointermove",n=>this._handlePointerMove(n)),this.listen(this._board,"pointerup",n=>this._handlePointerUp(n)),this.listen(this._board,"pointercancel",()=>this._clearDrag()),this.listen(this._board,"dragstart",n=>n.preventDefault()),this._refreshView("init"),i.contextMenu&&this._createContextMenu(),e}catch(n){throw this._kanbanSnapshot&&S(e,this._kanbanSnapshot),n}}getColumns(){return this._resolvedColumns().map(t=>({...t}))}setColumns(t){this._kanbanColumns=t===null?null:Gs(t,"column");let e=this._rawColumns();if(this._kanbanColumnOrder=De(e,this._kanbanColumnOrder,this._kanbanColumns===null),this._kanbanColumns!==null){let i=new Set(e.map(n=>n.id));this._collapsedColumns=new Set([...this._collapsedColumns].filter(n=>i.has(n)))}return this._refreshView("columns"),this._emitKanbanState("columns"),this}getSwimlanes(){return this._resolvedSwimlanes().map(t=>({...t}))}setSwimlanes(t){this._kanbanSwimlanes=t===null?null:Gs(t,"swimlane");let e=this._rawSwimlanes(),i=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;if(this._kanbanSwimlaneOrder=De(e,this._kanbanSwimlaneOrder,i),!i){let n=new Set(e.map(r=>r.id));this._collapsedSwimlanes=new Set([...this._collapsedSwimlanes].filter(r=>n.has(r)))}return this._refreshView("swimlanes"),this._emitKanbanState("swimlanes"),this}getColumnOrder(){return this._resolvedColumns().map(t=>t.id)}setColumnOrder(t,e={}){let i=this._rawColumns(),n=this.getColumnOrder(),r=uo(i,t);return Uh(r,n)?this:(this._kanbanColumnOrder=Kh(this._kanbanColumnOrder,i,r,this._kanbanColumns===null),this._refreshView("columnorder"),e.silent||this._emitKanbanState("columnorder"),this)}moveColumn(t,e,i="before"){return this.setColumnOrder($h(this.getColumnOrder(),t,e,i))}getSwimlaneOrder(){return this._resolvedSwimlanes().map(t=>t.id)}setSwimlaneOrder(t,e={}){let i=this._rawSwimlanes(),n=this.getSwimlaneOrder(),r=uo(i,t);if(Uh(r,n))return this;let o=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;return this._kanbanSwimlaneOrder=Kh(this._kanbanSwimlaneOrder,i,r,o),this._refreshView("swimlaneorder"),e.silent||this._emitKanbanState("swimlaneorder"),this}moveSwimlane(t,e,i="before"){return this.setSwimlaneOrder($h(this.getSwimlaneOrder(),t,e,i))}getCollapsedColumns(){return this.getColumnOrder().filter(t=>this._collapsedColumns.has(t))}setColumnCollapsed(t,e=!0,i={}){let n=String(t);if(!this.getColumnOrder().includes(n))throw new RangeError(`Unknown Kanban column: ${n}`);return(e?!this._collapsedColumns.has(n):this._collapsedColumns.has(n))?(e?this._collapsedColumns.add(n):this._collapsedColumns.delete(n),this._refreshView("columncollapse"),i.silent||this._emitKanbanState("columncollapse"),this):this}toggleColumn(t){return this.setColumnCollapsed(t,!this._collapsedColumns.has(String(t)))}getCollapsedSwimlanes(){return this.getSwimlaneOrder().filter(t=>this._collapsedSwimlanes.has(t))}setSwimlaneCollapsed(t,e=!0,i={}){let n=String(t);if(!this.getSwimlaneOrder().includes(n))throw new RangeError(`Unknown Kanban lane: ${n}`);return(e?!this._collapsedSwimlanes.has(n):this._collapsedSwimlanes.has(n))?(e?this._collapsedSwimlanes.add(n):this._collapsedSwimlanes.delete(n),this._refreshView("swimlanecollapse"),i.silent||this._emitKanbanState("swimlanecollapse"),this):this}toggleSwimlane(t){return this.setSwimlaneCollapsed(t,!this._collapsedSwimlanes.has(String(t)))}moveRecord(t,e){return this.moveRecords([t],e)}moveRecords(t,e){let i=this._kanbanOptions();if(!Array.isArray(t)||!e||typeof e!="object")return this;let n=this._orderedIds(t);if(!n.length)return this;let r=n.map(N=>this.getRecord(N)),o=n.map(N=>this._recordLocation(N)),a=o[0],c=this._resolvedColumns(),h=this._resolvedSwimlanes(),u=e.column==null?a.column:String(e.column),d=i.swimlaneBy==null?null:e.lane===void 0?a.lane:K(e.lane),p=c.find(N=>N.id===u),f=i.swimlaneBy==null?null:h.find(N=>N.id===d)??null;if(!p||i.swimlaneBy!=null&&!f)return this._rejectMove("destination",{ids:n,records:r,from:a,to:null,column:null,swimlane:null}),this;let _=new Set(n),b=this._recordsIn(u,d).filter(N=>!_.has(this._viewRecordId(N.record))).length,w=Ni(e.index,b),y={column:u,lane:d,index:w};if(n.length===1&&Xb(a,y))return this;let v={id:n[0],from:{...a},to:{...y},column:{...p},swimlane:f?{...f}:null},k=this._evaluateMove(r,o,p,f,y,v,_);if(!k.allowed)return this._rejectMove(k.reason,{ids:n,records:r,from:a,to:y,column:p,swimlane:f,evaluation:k}),this;let z=[];for(let N=0;N<n.length;N+=1){let J=r[N],xt=i.moveMode==="local"?this._localMovedRecord(J,o[N],y,p,f):J;if(!xt)return this._rejectMove("grouping",{ids:n,records:r,from:a,to:y,column:p,swimlane:f}),this;z.push({id:n[N],record:xt})}let E=ao(this._viewData,z,{recordId:i.recordId,columnBy:(N,J)=>this._readAxis(i.columnBy,N,J),swimlaneBy:i.swimlaneBy==null?null:(N,J)=>this._readAxis(i.swimlaneBy,N,J),destination:y});if(!E)return this._rejectMove("destination",{ids:n,records:r,from:a,to:y,column:p,swimlane:f}),this;let M=this._wipAnnouncement(k);return this.emit("recordmove",{record:r[0],id:n[0],records:[...r],ids:[...n],moves:E.moves.map(N=>({id:N.id,from:{...N.from}})),from:{...a},to:{...E.to},column:{...p},swimlane:f?{...f}:null,limitExceeded:k.limitExceeded},{honorDomCancellation:!0}).defaultPrevented?(this._announce(this._text("moveCanceled",{name:this._movingName(r)})),this):i.moveMode==="external"?(this._announce(this._text("moveRequested",{name:this._movingName(r),target:this._targetName(E.to),wip:M})),this):(this._commitLocalRecords(E.records),this._announce(n.length>1?this._text("movedMultiple",{count:n.length,target:this._targetName(E.to),wip:M}):this._text("moved",{name:this._recordName(z[0].record,E.to.index),target:this._targetName(E.to),wip:M})),queueMicrotask(()=>this._moveHandle(n[0])?.focus()),this)}canUndo(){return this._kanbanOptions().history!==!1&&this._kanbanHistory.canUndo()}canRedo(){return this._kanbanOptions().history!==!1&&this._kanbanHistory.canRedo()}undo(){return this._travelHistory("undo")}redo(){return this._travelHistory("redo")}clearHistory(){return this._kanbanHistory.clear(),this._syncHistoryControls(),this._emitHistory(),this}getSearch(){return this._kanbanSearch}setSearch(t,e={}){let i=t==null?"":String(t);return i===this._kanbanSearch?this:(this._kanbanSearch=i,this._searchInput&&this._searchInput.value!==i&&(this._searchInput.value=i),this._refreshView("search"),e.silent||this.emit("searchchange",{search:i}),this)}setFilter(t){if(t!=null&&typeof t!="function")throw new TypeError("Kanban filter must be a function or null");return this._kanbanFilter=t??null,this._refreshView("filter"),this}getVisibleRecords(){return this._viewData.filter(t=>this._visibleIds.has(this._viewRecordId(t)))}setData(t){return this._resetHistory(),super.setData(t)}addData(t){return this._resetHistory(),super.addData(t)}updateRecord(t,e){return this._resetHistory(),super.updateRecord(t,e)}removeRecord(t){return this._resetHistory(),super.removeRecord(t)}getViewState(){this.getColumnOrder(),this.getSwimlaneOrder();let t=this._kanbanColumns===null,e=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;return{...super.getViewState(),columnOrder:t?[...this._kanbanColumnOrder]:this.getColumnOrder(),swimlaneOrder:e?[...this._kanbanSwimlaneOrder]:this.getSwimlaneOrder(),collapsedColumns:t?[...this._collapsedColumns]:this.getCollapsedColumns(),collapsedSwimlanes:e?[...this._collapsedSwimlanes]:this.getCollapsedSwimlanes()}}setViewState(t,e={}){let i=t&&typeof t=="object"?t:{};super.setViewState(i,{silent:!0});let n=this._rawColumns(),r=this._rawSwimlanes(),o=this._kanbanColumns===null,a=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;this._kanbanColumnOrder=De(n,Array.isArray(i.columnOrder)?i.columnOrder:this._kanbanColumnOrder,o),this._kanbanSwimlaneOrder=De(r,Array.isArray(i.swimlaneOrder)?i.swimlaneOrder:this._kanbanSwimlaneOrder,a);let c=new Set(n.map(u=>u.id)),h=new Set(r.map(u=>u.id));if(Array.isArray(i.collapsedColumns)){let u=Ct(i.collapsedColumns);this._collapsedColumns=new Set(o?u:u.filter(d=>c.has(d)))}if(Array.isArray(i.collapsedSwimlanes)){let u=Ct(i.collapsedSwimlanes);this._collapsedSwimlanes=new Set(a?u:u.filter(d=>h.has(d)))}return this._refreshView("state"),e.silent||this._emitKanbanState("restore"),this}destroy(){if(this._kanbanDestroyed)return;this._kanbanDestroyed=!0,this._clearDrag(),clearTimeout(this._pointerHold),clearTimeout(this._searchTimer),this._kanbanMenu?.destroy(),this._kanbanMenu=null;let t=this.el,e=this._kanbanSnapshot;super.destroy(),e&&t&&S(t,e)}_refreshView(t){if(!this._board)return;if(t==="selection"){this._syncCardSelection();return}if(t==="loading")return;let e=this._kanbanOptions(),i=document.activeElement,n=this._metaForTarget(document.activeElement),r=!!document.activeElement?.classList?.contains("zx-kanban-view__move-handle"),o=i instanceof Element?i.closest("[data-kanban-collapse]"):null,a=o?.closest(".zx-kanban-view__column"),c=o&&this._board.contains(o)?{axis:o.dataset.kanbanCollapse,id:String(o.dataset.kanbanId),lane:a?this._sectionMeta.get(a)?.lane??null:null}:null;this._fieldIndex=null,this._cardFields=null;let h=this._resolvedColumns(),u=this._resolvedSwimlanes();this._resolveCardSources(),this._cardMeta=new WeakMap,this._sectionMeta=new WeakMap,this._cardsById=new Map,this._resolveVisibility();let d=[];e.swimlaneBy==null?d.push(this._renderColumns(h,null,!1)):u.forEach(p=>d.push(this._renderLane(p,h))),this._viewData.length?this._visibleIds.size||d.push(this._emptyContent(this._text("noMatches"))):d.push(this._emptyContent(this._text("empty"))),this._board.replaceChildren(...d),this._keyboardMove&&(this._keyboardMove.ids=this._keyboardMove.ids.filter(p=>this.getRecord(p)),this._keyboardMove.ids.length||(this._keyboardMove=null)),this._syncKeyboardTarget(),(c||n)&&queueMicrotask(()=>{if(c){this._collapseControl(c.axis,c.id,c.lane)?.focus();return}if(!n)return;if(n.lane!=null&&this._collapsedSwimlanes.has(n.lane)){this._collapseControl("swimlane",n.lane)?.focus();return}if(this._collapsedColumns.has(n.column)){this._collapseControl("column",n.column,n.lane)?.focus();return}let p=this._cardsById.get(n.id),f=r?p?.querySelector(".zx-kanban-view__move-handle"):p;f?.isConnected&&f.focus()})}_renderLane(t,e){let i=this._kanbanOptions(),n=this._collapsedSwimlanes.has(t.id),r=x("zx-kanban-lane"),o=x("zx-kanban-lane-body"),a=this._viewData.filter((w,y)=>K(this._readAxis(i.swimlaneBy,w,y))===t.id),c=a.length,h=a.filter(w=>this._visibleIds.has(this._viewRecordId(w))).length,u=l("button",{class:"zx-kanban-view__collapse",type:"button",ariaExpanded:String(!n),ariaControls:o,ariaLabel:this._text(n?"expandLane":"collapseLane",{label:t.label}),dataset:{kanbanCollapse:"swimlane",kanbanId:t.id}},g(n?"chevron-right":"chevron-down",{size:13})),d=t.limit??null,p=jh(c,d),f=this._renderHook("renderSwimlaneHeader",{swimlane:{...t},count:h,total:c,columnTotal:c,limit:d,wip:p,collapsed:n}),_=l("h2",{class:"zx-kanban-view__lane-heading",id:r},u,f??[l("span",{},t.label),i.showCounts||d!=null?this._countIndicator(h,c,d):null]),b=this._renderColumns(e,t,!0);return b.id=o,b.hidden=n,l("section",{class:"zx-kanban-view__lane",ariaLabelledby:r,dataset:{collapsed:String(n),wip:p}},_,b)}_renderColumns(t,e,i){let n=this._kanbanOptions(),r=l("div",{class:"zx-kanban-view__columns"});for(let o of t){let a=this._recordsIn(o.id,e?.id??null);!n.showEmptyColumns&&a.length===0||r.append(this._renderColumn(o,e,a,i))}return r}_renderColumn(t,e,i,n){let r=this._kanbanOptions(),o=this._collapsedColumns.has(t.id),a=x("zx-kanban-column"),c=x("zx-kanban-column-list"),u=this._viewData.filter((M,it)=>K(this._readAxis(r.columnBy,M,it))===t.id).length,d=i.filter(M=>this._visibleIds.has(this._viewRecordId(M.record))),p=e?Qb(t,e.id):null,f=p??t.limit??null,_=jh(p==null?u:i.length,f),b=l("button",{class:"zx-kanban-view__collapse",type:"button",ariaExpanded:String(!o),ariaControls:c,ariaLabel:this._text(o?"expandColumn":"collapseColumn",{label:t.label}),dataset:{kanbanCollapse:"column",kanbanId:t.id}},g(o?"chevron-right":"chevron-down",{size:13})),w=this._renderHook("renderColumnHeader",{column:{...t},swimlane:e?{...e}:null,count:d.length,total:i.length,columnTotal:u,limit:f,wip:_,collapsed:o}),y=r.showCounts||f!=null?this._columnIndicator(d.length,i.length,u,f,n&&p==null):null,v=l(n?"h3":"h2",{class:"zx-kanban-view__column-heading",id:a},b,w??[l("span",{class:"zx-kanban-view__column-label"},t.label),y]),k=l("ul",{class:"zx-kanban-view__cards",id:c,ariaLabel:`${t.label}${e?`, ${e.label}`:""}`});if(d.forEach(M=>k.append(this._renderCard(M.record,M.index,t.id,e?.id??null,n))),!d.length){let M=this._renderHook("renderColumnEmpty",{column:{...t},swimlane:e?{...e}:null,count:0,total:i.length,columnTotal:u,limit:f,wip:_,collapsed:o})??this._placeholderText();M&&k.append(l("li",{class:"zx-kanban-view__column-empty",role:"presentation"},M))}k.hidden=o;let z=this._allowsAdd(t,e)?l("button",{class:"zx-kanban-view__add",type:"button",ariaLabel:this._text("addTo",{target:`${t.label}${e?`, ${e.label}`:""}`}),dataset:{kanbanAdd:t.id,kanbanLane:e?.id??""}},g("plus",{size:13}),l("span",{},this._text("add"))):null;z&&(z.hidden=o);let E=l("section",{class:"zx-kanban-view__column",ariaLabelledby:a,dataset:{column:t.id,collapsed:String(o),wip:_}},v,k,z);return this._sectionMeta.set(E,{column:t.id,lane:e?.id??null,list:k}),E}_renderCard(t,e,i,n,r){let o=this._kanbanOptions(),a=this._viewRecordId(t),c=!!this._keyboardMove?.ids.some(w=>Object.is(w,a)),h=$s(this._kanbanRules,t,{index:e,column:i,lane:n}),u=c&&this._keyboardMove?this._keyboardMove.ids.length:1,d=o.moveHandle==="always"||o.dragFrom==="handle"?"always":"keyboard",p=l("button",{class:"zx-kanban-view__move-handle",type:"button",ariaPressed:String(c),dataset:{reveal:d},ariaLabel:u>1?this._text("moveMultiple",{count:u}):this._text("move",{name:this._recordName(t,e)})},g("drag",{size:13})),f=this._resolvedCardFields(),_=Hs(t,e,{fields:f.all,visibleFields:f.metadata,titleField:o.titleField,subtitleField:o.subtitleField,preview:o.preview??void 0,previewAlt:o.previewAlt,link:o.link??void 0,actions:o.actions,selectable:o.selectable,selectionTrigger:o.selectionTrigger,selected:this._isViewSelected(a),variant:o.variant,headingLevel:r?4:3,controls:[p]});_.tabIndex=0,c&&(_.dataset.grabbed="true"),this._applyCardContent(_,{record:t,id:a,index:e,column:i,lane:n,rules:h,selected:this._isViewSelected(a)}),this._applyCardRules(_,h),this._applyCardAnatomy(_,t,e),this._applyCardDescription(_,a);let b={record:t,id:a,index:e,column:i,lane:n};return this._cardMeta.set(_,b),this._cardsById.set(a,_),_}_resolvedCardFields(){return this._cardFields||(this._cardFields={all:this.getFields(),metadata:this._cardMetadataFields()}),this._cardFields}_cardMetadataFields(){let t=this._cardSources?.fieldIds,e=this.getVisibleFields();return t?.size?e.filter(i=>!t.has(i.id)||i.duplicate===!0):e}_resolveCardSources(){let t=this._kanbanOptions(),e=this.getFields(),i=new Set,n=o=>{if(o==null)return null;if(typeof o=="function")return o;if(typeof o=="object")return()=>o;let a=String(o),c=e.find(h=>h.id===a);return i.add(a),c?(h,u)=>X(c,h,u):h=>h?.[a]},r={identifier:n(t.identifier),status:n(t.status),priority:n(t.priority),progress:n(t.progress),assignees:n(t.assignees),entityIcon:typeof t.entityIcon=="function"?t.entityIcon:t.entityIcon==null?null:()=>t.entityIcon};this._cardSources={...r,fieldIds:i,any:Object.values(r).some(Boolean)}}_applyCardAnatomy(t,e,i){let n=this._kanbanOptions(),r=this._cardSources;if(!r?.any)return;let o=t.querySelector(".zx-record-card__body");if(!o)return;let a=r.entityIcon?.(e,i),c=r.identifier?.(e,i),h=eo({entityIcon:a==null||a===""?null:String(a),identifier:c==null?"":String(c),identifierPrefix:this._text("identifier"),flags:[{indicator:this._cardIndicator(r.status,n.statusTones,e,i),prefix:this._text("statusLabel")},{indicator:this._cardIndicator(r.priority,n.priorityTones,e,i),prefix:this._text("priorityLabel")}]});h&&o.prepend(h);let u=[],d=Xr(r.progress?.(e,i),Number(n.progressMax));d&&u.push(Jr(d,d.label??this._text("progress"),this._text("progressValue",{percent:d.percent})));let p=Zr(r.assignees?.(e,i)),f=to(p,Number(n.maxAvatars),this._text("assignees",{names:p.map(_=>_.name).filter(Boolean).join(", ")}),_=>this._text("assigneeOverflow",{count:_}));f&&u.push(f),u.length&&o.append(l("div",{class:"zx-kanban-view__card-footer"},u))}_cardIndicator(t,e,i,n){if(!t)return null;let r=t(i,n);return r&&typeof r=="object"&&"nodeType"in r?r:Qr(r,e??{})}_applyCardContent(t,e){let i=this._renderHook("renderCard",e);if(!i)return;let n=t.querySelector(".zx-record-card__body"),r=t.querySelector(".zx-record-card__titles");!n||!r||(r.replaceChildren(i),n.querySelector(".zx-record-card__eyebrow")?.remove(),n.querySelector(".zx-record-card__metadata")?.remove(),t.removeAttribute("aria-labelledby"),t.setAttribute("aria-label",this._recordName(e.record,e.index)),t.dataset.customCard="true")}_applyCardRules(t,e){if(!e.length)return;t.dataset.rule=e.map(r=>r.id).join(" "),t.dataset.ruleTone=e[0].tone;let i=e.filter(r=>r.label);if(i.length){let r=l("p",{class:"zx-kanban-view__rules"},i.map(o=>pt({label:o.label,icon:o.icon??void 0,kind:o.tone,size:"sm",variant:"soft"})));t.querySelector(".zx-record-card__body")?.append(r)}let n=e.map(r=>r.description).filter(Boolean).join(". ");n&&(t.dataset.ruleDescription=n)}_applyCardDescription(t,e){let i=[];this.options.selectable&&i.push(this._text(this._isViewSelected(e)?"selected":"notSelected")),t.dataset.ruleDescription&&i.push(t.dataset.ruleDescription),i.length?t.setAttribute("aria-description",i.join(". ")):t.removeAttribute("aria-description")}_emptyContent(t){let i=(typeof this.options.emptyText=="function"?this.options.emptyText():this.options.emptyText)??t;return l("div",{class:"zx-kanban-view__empty",role:"status"},i&&typeof i=="object"&&"nodeType"in i?i:String(i))}_placeholderText(){return this._text("columnEmpty")}_countIndicator(t,e,i){let n=t!==e;return l("span",{class:"zx-kanban-view__count",ariaLabel:i!=null?this._text("countLimit",{count:e,limit:i}):n?this._text("countFiltered",{count:t,total:e}):this._text("count",{count:t})},i!=null?`${e} / ${i}`:n?`${t} / ${e}`:String(t))}_columnIndicator(t,e,i,n,r){let o=t!==e,a=n==null?o?this._text("countFiltered",{count:t,total:e}):this._text("count",{count:t}):r?this._text("countLimitInLane",{count:e,total:i,limit:n}):this._text("countLimit",{count:e,limit:n}),c=n==null?o?`${t} / ${e}`:String(t):r?`${e} \xB7 ${i} / ${n}`:`${e} / ${n}`;return l("span",{class:"zx-kanban-view__count",ariaLabel:a},c)}_rawColumns(){let t=this._kanbanOptions();return this._kanbanColumns===null?Bh(this._viewData,(e,i)=>this._readAxis(t.columnBy,e,i)):this._kanbanColumns.map(e=>({...e}))}_resolvedColumns(){let t=this._rawColumns();return this._kanbanColumnOrder=De(t,this._kanbanColumnOrder,this._kanbanColumns===null),qh(t,this._kanbanColumnOrder)}_rawSwimlanes(){let t=this._kanbanOptions();return t.swimlaneBy==null?[]:this._kanbanSwimlanes===null?Bh(this._viewData,(e,i)=>this._readAxis(t.swimlaneBy,e,i)):this._kanbanSwimlanes.map(e=>({...e}))}_resolvedSwimlanes(){let t=this._rawSwimlanes(),e=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;return this._kanbanSwimlaneOrder=De(t,this._kanbanSwimlaneOrder,e),qh(t,this._kanbanSwimlaneOrder)}_readAxis(t,e,i){if(typeof t=="function")return t(e,i);if(t==null)return null;let n=this._axisField(String(t));return n?X(n,e,i):e?.[t]}_axisField(t){return this._fieldIndex||(this._fieldIndex=new Map(this.getFields().map(e=>[e.id,e]))),this._fieldIndex.get(t)}_recordsIn(t,e){let i=this._kanbanOptions(),n=[];return this._viewData.forEach((r,o)=>{K(this._readAxis(i.columnBy,r,o))===t&&(i.swimlaneBy!=null&&K(this._readAxis(i.swimlaneBy,r,o))!==e||n.push({record:r,index:o}))}),n}_recordLocation(t){let e=this._kanbanOptions(),i=this._viewData.findIndex(n=>Object.is(this._viewRecordId(n),t));return i<0?null:Us(this._viewData,i,{recordId:e.recordId,columnBy:(n,r)=>this._readAxis(e.columnBy,n,r),swimlaneBy:e.swimlaneBy==null?null:(n,r)=>this._readAxis(e.swimlaneBy,n,r)})}_resolveVisibility(){let t=no(this._kanbanSearch),e=this._kanbanFilter,i=t.length?this._searchSources():null;this._visibleIds=new Set,this._viewData.forEach((n,r)=>{e&&e(n,r)!==!0||i&&!ro(this._searchableText(n,r,i),t)||this._visibleIds.add(this._viewRecordId(n))})}_searchSources(){let t=this._kanbanOptions(),e=Array.isArray(t.searchFields)?t.searchFields.map(String):null,i=this.getFields();if(e)return{fields:i.filter(a=>e.includes(a.id)),readers:[]};let n=this.getVisibleFields(),r=new Set(n.map(a=>a.id)),o=[];for(let a of[t.titleField,t.subtitleField]){if(a==null)continue;if(typeof a=="function"){o.push(a);continue}if(r.has(a))continue;let c=i.find(h=>h.id===a);c?n.push(c):o.push(h=>h?.[a])}return{fields:n,readers:o}}_searchableText(t,e,i){let n=i.fields.map(r=>Hh(X(r,t,e)));for(let r of i.readers)n.push(Hh(r(t,e)));return n.filter(Boolean).join(" ")}_absoluteIndex(t,e,i,n){let r=this._recordsIn(t,e).filter(o=>!n.has(this._viewRecordId(o.record)));return lo(r.map(o=>this._visibleIds.has(this._viewRecordId(o.record))),i)}_localMovedRecord(t,e,i,n,r){let o=this._kanbanOptions(),a={...t};if(e.column!==i.column){if(typeof o.columnBy!="string")return null;a[o.columnBy]=Object.prototype.hasOwnProperty.call(n,"value")?n.value:n.id}if(e.lane!==i.lane){if(typeof o.swimlaneBy!="string"||!r)return null;a[o.swimlaneBy]=Object.prototype.hasOwnProperty.call(r,"value")?r.value:r.id}let c=this._viewData.indexOf(t);return K(this._readAxis(o.columnBy,a,c))!==i.column||o.swimlaneBy!=null&&K(this._readAxis(o.swimlaneBy,a,c))!==i.lane?null:a}_evaluateMove(t,e,i,n,r,o,a){let c=this._kanbanOptions();for(let f of e){let _=Ks(i,n,f);if(_)return{allowed:!1,reason:_,limit:null,count:0,limitExceeded:!1,limitReached:!1,policy:i.wipPolicy??(c.wipPolicy==="block"?"block":"warn")}}let h=f=>!a.has(this._viewRecordId(f)),u=this._viewData.filter((f,_)=>K(this._readAxis(c.columnBy,f,_))===r.column&&h(f)).length,d=c.swimlaneBy==null?0:this._viewData.filter((f,_)=>K(this._readAxis(c.swimlaneBy,f,_))===r.lane&&h(f)).length,p=this._recordsIn(r.column,r.lane).filter(f=>h(f.record)).length;return so({records:t,column:i,swimlane:n,context:o,from:e[0],columnCount:u,laneCount:d,cellCount:p,policy:c.wipPolicy==="block"?"block":"warn"})}_rejectMove(t,e){let i=e.to?this._targetName(e.to):"",n=this._movingName(e.records),r=t==="destination"?this._text("rejectDestination"):t==="grouping"?this._text("rejectGrouping"):t==="transition"||t==="lane-transition"?this._text("rejectTransition",{target:i,origin:e.from?this._targetName(e.from):""}):t==="wip"||t==="lane-wip"?this._text("rejectWip",{target:i,limit:e.evaluation?.limit??""}):this._text("rejectAccept",{target:i,name:n});this._announce(r),this.emit("movereject",{reason:t,ids:[...e.ids],records:[...e.records],record:e.records[0]??null,id:e.ids[0],from:e.from?{...e.from}:null,to:e.to?{...e.to}:null,column:e.column?{...e.column}:null,swimlane:e.swimlane?{...e.swimlane}:null,limit:e.evaluation?.limit??null,count:e.evaluation?.count??0,message:r})}_commitLocalRecords(t){let e=this._kanbanOptions();e.history!==!1&&(this._kanbanHistory.push({records:[...this._viewData],selection:this.getSelectionIds()}),this._syncHistoryControls()),this._viewData=t,e.sortMode==="local"&&this.getSort()?this.setSort(null):this._refreshView("move"),this.emit("datachange",{records:this.getData()}),e.history!==!1&&this._emitHistory()}_travelHistory(t){if(this._kanbanOptions().history===!1)return this;let e={records:[...this._viewData],selection:this.getSelectionIds()},i=t==="undo"?this._kanbanHistory.undo(e):this._kanbanHistory.redo(e);return i?(this._viewData=[...i.records],this._refreshView(t),this.setSelection(i.selection),this._syncHistoryControls(),this.emit("datachange",{records:this.getData()}),this._emitHistory(),this._announce(this._text(t==="undo"?"undone":"redone")),this):(this._announce(this._text(t==="undo"?"nothingToUndo":"nothingToRedo")),this)}_resetHistory(){if(!this._kanbanHistory)return;let t=this._kanbanHistory.canUndo()||this._kanbanHistory.canRedo();this._kanbanHistory.clear(),this._syncHistoryControls(),t&&this._emitHistory()}_emitHistory(){this.emit("historychange",{canUndo:this.canUndo(),canRedo:this.canRedo(),depth:this._kanbanHistory.depth()})}_syncHistoryControls(){this._undoButton&&(this._undoButton.disabled=!this.canUndo()),this._redoButton&&(this._redoButton.disabled=!this.canRedo())}_createSearchControl(){let t=l("input",{class:"zx-kanban-view__search-input",type:"search",value:this._kanbanSearch,ariaLabel:this._text("search"),placeholder:this._text("searchPlaceholder")});return this._searchInput=t,this.listen(t,"input",()=>{clearTimeout(this._searchTimer),this._searchTimer=setTimeout(()=>{this._searchTimer=0,this._kanbanDestroyed||this.setSearch(t.value)},Yb)}),this.listen(t,"keydown",e=>{e.key!=="Escape"||!t.value||(e.stopPropagation(),clearTimeout(this._searchTimer),this._searchTimer=0,this.setSearch(""))}),l("div",{class:"zx-kanban-view__search"},g("search",{size:13}),t)}_createHistoryControls(){this._undoButton=l("button",{class:"zx-button zx-button--sm",type:"button",disabled:!0,dataset:{kanbanHistory:"undo"}},this._text("undo")),this._redoButton=l("button",{class:"zx-button zx-button--sm",type:"button",disabled:!0,dataset:{kanbanHistory:"redo"}},this._text("redo"));let t=l("div",{class:"zx-kanban-view__history",role:"group"},this._undoButton,this._redoButton);return this.listen(t,"click",e=>{let i=e.target?.closest?.("[data-kanban-history]");i&&(i.dataset.kanbanHistory==="undo"?this.undo():this.redo())}),t}_createContextMenu(){this._kanbanMenu=new Ci(this._board,{selector:".zx-record-card",items:t=>this._menuItems(t),onselect:({detail:t})=>this._handleMenuSelect(t)})}_menuItems(t){let e=t?this._cardMeta.get(t):null;if(!e)return[];let i=this._kanbanOptions(),n=this._movingIds(e.id),r=[];for(let a of this._resolvedColumns())a.id!==e.column&&r.push({label:this._text("menuMoveTo",{target:a.label}),value:{kind:"column",id:a.id,ids:n},disabled:!this._canMove(n,{column:a.id})});if(i.swimlaneBy!=null)for(let a of this._resolvedSwimlanes())a.id!==e.lane&&r.push({label:this._text("menuMoveToLane",{target:a.label}),value:{kind:"lane",id:a.id,ids:n},disabled:!this._canMove(n,{lane:a.id})});let o=typeof i.contextMenu=="function"?i.contextMenu({record:e.record,id:e.id,index:e.index,column:e.column,lane:e.lane,rules:$s(this._kanbanRules,e.record,e),selected:this._isViewSelected(e.id)}):Array.isArray(i.contextMenu)?i.contextMenu:[];return Array.isArray(o)&&o.length&&r.push("-",...o),r}_handleMenuSelect(t){let e=t.value;!e||typeof e!="object"||!e.kind||!Array.isArray(e.ids)||this.moveRecords(e.ids,e.kind==="lane"?{lane:e.id}:{column:e.id})}_canMove(t,e){let i=this._kanbanOptions(),n=this._orderedIds(t);if(!n.length)return!1;let r=n.map(b=>this.getRecord(b)),o=n.map(b=>this._recordLocation(b)),a=o[0],c=e.column==null?a.column:String(e.column),h=i.swimlaneBy==null?null:e.lane===void 0?a.lane:K(e.lane),u=this._resolvedColumns().find(b=>b.id===c),d=i.swimlaneBy==null?null:this._resolvedSwimlanes().find(b=>b.id===h)??null;if(!u||i.swimlaneBy!=null&&!d)return!1;let p=new Set(n),f={column:c,lane:h,index:0},_={id:n[0],from:{...a},to:{...f},column:{...u},swimlane:d?{...d}:null};return this._evaluateMove(r,o,u,d,f,_,p).allowed}_movingIds(t){let e=this._kanbanOptions();if(e.multiMove===!1||e.selectable!=="multi"||!this._isViewSelected(t))return[t];let i=this.getSelectionIds();return i.length>1?i:[t]}_orderedIds(t){let e=new Set(t);return this._viewData.map(i=>this._viewRecordId(i)).filter(i=>e.has(i))}_handleBoardClick(t){if(this._suppressClick){this._suppressClick=!1;return}let e=Me(t),i=e?.closest("[data-kanban-collapse]");if(i){let c=i;c.dataset.kanbanCollapse==="column"?this.toggleColumn(String(c.dataset.kanbanId)):this.toggleSwimlane(String(c.dataset.kanbanId));return}let n=e?.closest("[data-kanban-add]");if(n){let c=n,h=String(c.dataset.kanbanAdd),u=c.dataset.kanbanLane||null;this.emit("recordadd",{column:this._resolvedColumns().find(d=>d.id===h)??null,swimlane:u==null?null:this._resolvedSwimlanes().find(d=>d.id===u)??null,columnId:h,laneId:u,event:t});return}let r=this._metaForTarget(e);if(!r)return;let o=e?.closest("input[data-record-selection]");if(o){this.toggleSelection(r.id,{selected:o.checked,range:t.shiftKey});return}let a=e?.closest("[data-record-action]");if(a){let c=a.dataset.recordAction,h=Mi(r.record,r.index,this._kanbanOptions().actions).find(d=>d.id===c);if(!h||h.disabled){t.preventDefault();return}typeof h.onclick=="function"&&h.onclick(r.record,r.index,t),this.emit("recordaction",{record:r.record,id:r.id,index:r.index,action:{...h},event:t}).defaultPrevented&&t.preventDefault();return}if(!e?.closest(".zx-kanban-view__move-handle, .zx-record-card__selection, [data-record-select]")&&!(e?.closest(co)||Wh())){if(this.options.selectable&&this._kanbanOptions().selectionTrigger==="card"){this.toggleSelection(r.id,{range:t.shiftKey}),e?.closest(".zx-record-card")?.focus({preventScroll:!0});return}this.emit("recordclick",{...r,event:t}),this.options.selectable==="single"&&!this._isViewSelected(r.id)&&this.setSelection([r.id])}}_handleBoardDoubleClick(t){let e=Me(t),i=this._metaForTarget(e);!i||e?.closest(co)||Wh()||this.emit("recorddblclick",{...i,event:t})}_handleBoardKeydown(t){if(this._dragIds.length&&t.key==="Escape"){t.preventDefault(),this._clearDrag(),this._announce(this._text("moveCanceledPlain"));return}let e=Me(t);if(this._handleHistoryKeydown(t,e))return;let i=e?.closest(".zx-kanban-view__move-handle"),n=this._metaForTarget(i);if(i&&n){this._handleMoveKeydown(t,i,n);return}let r=e?.closest(".zx-record-card"),o=r?this._cardMeta.get(r):null;if(!(!o||e!==r))if(t.key==="Enter"){if(t.preventDefault(),this.options.selectable&&this._kanbanOptions().selectionTrigger==="card"){this.toggleSelection(o.id);return}this.emit("recordclick",{...o,event:t}),this.options.selectable==="single"&&this.setSelection([o.id])}else t.key===" "&&this.options.selectable!==!1&&(t.preventDefault(),this.toggleSelection(o.id))}_handleHistoryKeydown(t,e){if(this._kanbanOptions().history===!1||!(t.ctrlKey||t.metaKey)||e?.closest('input, textarea, [contenteditable="true"]'))return!1;let i=t.key.toLowerCase();return i==="z"&&!t.shiftKey&&this.canUndo()?(t.preventDefault(),this.undo(),!0):(i==="y"||i==="z"&&t.shiftKey)&&this.canRedo()?(t.preventDefault(),this.redo(),!0):!1}_handleMoveKeydown(t,e,i){if(t.key===" "||t.key==="Enter"){if(t.preventDefault(),this._keyboardMove?.ids.some(a=>Object.is(a,i.id))){let a=this._keyboardMove;this._keyboardMove=null,e.setAttribute("aria-pressed","false");let c=e.closest(".zx-record-card");c&&delete c.dataset.grabbed,this._syncKeyboardTarget(),this._commitInteractionMove(a.ids,a.to)}else{let a=this._recordLocation(i.id);if(!a)return;let c=this._movingIds(i.id),h={...a,index:this._visibleIndex(i.id)};this._keyboardMove={ids:c,from:{...a},to:h},e.setAttribute("aria-pressed","true");let u=e.closest(".zx-record-card");u&&(u.dataset.grabbed="true"),this._syncKeyboardTarget(),this._announce(c.length>1?this._text("grabbedMultiple",{count:c.length}):this._text("grabbed",{name:this._recordName(i.record,i.index)}))}return}if(t.key==="Escape"&&this._keyboardMove){t.preventDefault();let a=this._keyboardMove.ids.map(h=>this.getRecord(h)).filter(Boolean);this._keyboardMove=null,e.setAttribute("aria-pressed","false");let c=e.closest(".zx-record-card");c&&delete c.dataset.grabbed,this._syncKeyboardTarget(),this._announce(a.length?this._text("moveCanceled",{name:this._movingName(a)}):this._text("moveCanceledPlain"));return}if(!this._keyboardMove||!this._keyboardMove.ids.some(a=>Object.is(a,i.id))||!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key))return;t.preventDefault();let n=this._keyboardMove,r=t.altKey||t.ctrlKey||t.metaKey;if((t.key==="ArrowLeft"||t.key==="ArrowRight")&&!r){let a=this.getColumnOrder(),c=a.indexOf(n.to.column),h=a[c+(t.key==="ArrowLeft"?-1:1)];h!=null&&(n.to.column=h)}else if((t.key==="ArrowUp"||t.key==="ArrowDown")&&r&&this._kanbanOptions().swimlaneBy!=null){let a=this.getSwimlaneOrder(),c=a.indexOf(String(n.to.lane)),h=a[c+(t.key==="ArrowUp"?-1:1)];h!=null&&(n.to.lane=h)}else(t.key==="ArrowUp"||t.key==="ArrowDown")&&(n.to.index+=t.key==="ArrowUp"?-1:1);let o=this._visibleCount(n.to.column,n.to.lane,new Set(n.ids));n.to.index=Ni(n.to.index,o),this._syncKeyboardTarget(),this._announce(this._text("target",{target:this._targetName(n.to),position:n.to.index+1,total:o+1}))}_handlePreviewError(t){let e=Me(t)?.closest("img[data-record-preview]");if(!e)return;let i=e.closest(".zx-record-card__preview");i&&(i.dataset.failed="true"),e.hidden=!0}_handlePointerDown(t){if(this._suppressClick=!1,t.button!=null&&t.button!==0)return;let e=Me(t),i=e?.closest(".zx-kanban-view__move-handle"),n=this._metaForTarget(i??e);if(!n||!i&&(this._kanbanOptions().dragFrom!=="card"||e?.closest(co)||e?.closest(".zx-record-card__selection")))return;let r=this._movingIds(n.id);this._pointerStart={x:t.clientX,y:t.clientY,id:t.pointerId,ids:r,touch:t.pointerType==="touch"},this._dragPoint={x:t.clientX,y:t.clientY},clearTimeout(this._pointerHold),!(t.pointerType!=="touch"||i)&&(this._pointerHold=setTimeout(()=>this._beginDrag(this._dragPoint.x,this._dragPoint.y),Ub))}_handlePointerMove(t){let e=this._pointerStart;if(!this._dragIds.length){if(!e||t.pointerId!==e.id)return;let i=Math.hypot(t.clientX-e.x,t.clientY-e.y);if(this._dragPoint={x:t.clientX,y:t.clientY},i<=Kb)return;if(e.touch&&this._pointerHold){clearTimeout(this._pointerHold),this._pointerHold=0,this._pointerStart=null;return}if(this._beginDrag(t.clientX,t.clientY),!this._dragIds.length)return}this._dragPointer!=null&&t.pointerId!==this._dragPointer||(t.preventDefault(),this._dragPoint={x:t.clientX,y:t.clientY},this._positionDragPreview(),this._updateDropTarget(t.clientX,t.clientY))}_handlePointerUp(t){if(this._dragIds.length&&this._dragPointer!=null&&t.pointerId!==this._dragPointer||(clearTimeout(this._pointerHold),this._pointerHold=0,this._pointerStart=null,!this._dragIds.length))return;t.preventDefault();let e=[...this._dragIds],i=this._dragDestination?{...this._dragDestination}:null;this._clearDrag(),this._suppressClick=!0,i&&this._commitInteractionMove(e,i)}_beginDrag(t,e){let i=this._pointerStart;if(!(!i||this._dragIds.length)&&(this._pointerHold=0,this._dragIds=i.ids.filter(n=>this.getRecord(n)),!!this._dragIds.length)){this._dragPoint={x:t,y:e},this._board.dataset.dragging="true";for(let n of this._dragIds){let r=this._cardsById.get(n);r&&(r.dataset.dragging="true")}this._dragPointer=i.id;try{this._board.setPointerCapture(i.id),this._dragCaptured=!0}catch{}globalThis.getSelection?.()?.removeAllRanges(),this._dragPreview=this._createDragPreview(),this.el.append(this._dragPreview),this._positionDragPreview(),this._updateDropTarget(t,e),this._kanbanOptions().autoScroll!==!1&&this._scheduleAutoScroll()}}_createDragPreview(){let t=this._dragIds.map(n=>this.getRecord(n)),i=this._renderHook("renderDragPreview",{records:t,ids:[...this._dragIds],count:this._dragIds.length})??(this._dragIds.length>1?this._text("dragPreview",{count:this._dragIds.length}):this._movingName(t));return l("div",{class:"zx-kanban-view__drag-preview",ariaHidden:"true",dataset:{count:String(this._dragIds.length)}},i)}_positionDragPreview(){this._dragPreview&&(this._dragPreview.style.transform=`translate3d(${Math.round(this._dragPoint.x)}px, ${Math.round(this._dragPoint.y)}px, 0)`)}_updateDropTarget(t,e){let n=document.elementFromPoint(t,e)?.closest(".zx-kanban-view__column"),r=n&&this._board.contains(n)?this._sectionMeta.get(n):null;if(this._clearDropMarkers(),!r||this._collapsedColumns.has(r.column)){this._dragDestination=null;return}let o=this._draggableCards(r.list),a=o.findIndex(h=>{let u=h.getBoundingClientRect();return e<u.top+u.height/2}),c=a<0?o.length:a;o[c]?o[c].dataset.drop="before":o.length?o[o.length-1].dataset.drop="after":r.list.dataset.drop="append",this._dragDestination={column:r.column,lane:r.lane,index:c}}_scheduleAutoScroll(){this._dragFrame||(this._dragFrame=requestAnimationFrame(()=>{this._dragFrame=0,this._dragIds.length&&(this._autoScroll(),this._scheduleAutoScroll())}))}_autoScroll(){let{x:t,y:e}=this._dragPoint,i=this._board.getBoundingClientRect();t<i.left+Ys?this._board.scrollLeft-=Ws:t>i.right-Ys&&(this._board.scrollLeft+=Ws);let n=document.elementFromPoint(t,e)?.closest(".zx-kanban-view__cards");if(!n||!this._board.contains(n)||n.scrollHeight<=n.clientHeight)return;let r=n.getBoundingClientRect();e<r.top+Ys?n.scrollTop-=Ws:e>r.bottom-Ys&&(n.scrollTop+=Ws)}_commitInteractionMove(t,e){let i=new Set(t);this.moveRecords(t,{column:e.column,lane:e.lane,index:this._absoluteIndex(e.column,e.lane,e.index,i)})}_clearDrag(){if(this._dragFrame&&cancelAnimationFrame(this._dragFrame),this._dragFrame=0,clearTimeout(this._pointerHold),this._pointerHold=0,this._pointerStart=null,this._dragPreview?.remove(),this._dragPreview=null,this._dragIds=[],this._dragDestination=null,this._board){if(this._dragCaptured&&this._dragPointer!=null)try{this._board.releasePointerCapture(this._dragPointer)}catch{}this._clearDropMarkers(),delete this._board.dataset.dragging;for(let t of this._board.querySelectorAll("[data-dragging]"))delete t.dataset.dragging}this._dragPointer=null,this._dragCaptured=!1}_clearDropMarkers(){for(let t of this._board.querySelectorAll("[data-drop]"))delete t.dataset.drop}_draggableCards(t){let e=new Set(this._dragIds.length?this._dragIds:this._keyboardMove?.ids??[]);return[...t.querySelectorAll(":scope > .zx-record-card")].filter(i=>!Yh(e,this._cardMeta.get(i)?.id))}_visibleCount(t,e,i){return this._recordsIn(t,e).filter(n=>{let r=this._viewRecordId(n.record);return!Yh(i,r)&&this._visibleIds.has(r)}).length}_visibleIndex(t){let e=this._recordLocation(t);if(!e)return 0;let i=this._recordsIn(e.column,e.lane).filter(r=>this._visibleIds.has(this._viewRecordId(r.record))),n=i.findIndex(r=>Object.is(this._viewRecordId(r.record),t));return n<0?i.length:n}_syncKeyboardTarget(){for(let o of this._board.querySelectorAll("[data-keyboard-target]"))delete o.dataset.keyboardTarget;let t=this._keyboardMove;if(!t)return;let e=[...this._board.querySelectorAll(".zx-kanban-view__column")].find(o=>{let a=this._sectionMeta.get(o);return a?.column===t.to.column&&a?.lane===t.to.lane}),i=e?this._sectionMeta.get(e):null;if(!i)return;let r=this._draggableCards(i.list)[t.to.index];r?r.dataset.keyboardTarget="before":i.list.dataset.keyboardTarget="append"}_syncCardSelection(){for(let[t,e]of this._cardsById){let i=this._isViewSelected(t);e.dataset.selected=String(i),this._applyCardDescription(e,t);let n=e.querySelector("[data-record-selection]");n&&(n.checked=i)}}_metaForTarget(t){let e=Me({target:t})?.closest(".zx-record-card");return e?this._cardMeta.get(e)??null:null}_moveHandle(t){return this._cardsById.get(t)?.querySelector(".zx-kanban-view__move-handle")??null}_collapseControl(t,e,i=null){return[...this._board.querySelectorAll("[data-kanban-collapse]")].find(n=>{let r=n;if(r.dataset.kanbanCollapse!==t||r.dataset.kanbanId!==e)return!1;if(t!=="column")return!0;let o=r.closest(".zx-kanban-view__column");return o?this._sectionMeta.get(o)?.lane===i:!1})??null}_renderHook(t,e){let i=this._kanbanOptions()[t];if(typeof i!="function")return null;let n=i(e);return n&&typeof n=="object"&&"nodeType"in n?n:null}_allowsAdd(t,e){let i=this._kanbanOptions().allowAdd;return typeof i=="function"?i(t,e)===!0:i===!0}_recordName(t,e){let i=this._kanbanOptions().titleField,n=typeof i=="function"?i(t,e):typeof i=="string"?this._readAxis(i,t,e):this._viewRecordId(t);return n&&typeof n=="object"&&"nodeType"in n?n.textContent?.trim()||this._text("record"):String(n??this._text("record"))}_movingName(t){return t.length?t.length===1?this._recordName(t[0],this._viewData.indexOf(t[0])):this._text("dragPreview",{count:t.length}):this._text("record")}_targetName(t){let e=this._resolvedColumns().find(n=>n.id===t.column),i=t.lane==null?null:this._resolvedSwimlanes().find(n=>n.id===t.lane);return`${e?.label??t.column}${i?`, ${i.label}`:""}`}_wipAnnouncement(t){return t.limit==null?"":t.limitExceeded?this._text("limitExceeded",{limit:t.limit}):t.limitReached?this._text("limitReached",{limit:t.limit}):""}_text(t,e){let i=this._kanbanOptions().labels,n=i&&typeof i=="object"&&t in i?i[t]:Wb[t];return I(n==null?String(t):String(n),e)}_announce(t){let e=++this._announcementToken;this._live.textContent="",queueMicrotask(()=>{e===this._announcementToken&&this._live?.isConnected&&(this._live.textContent=t)})}_emitKanbanState(t){this.emit("statechange",{state:this.getViewState(),reason:t})}_kanbanOptions(){return this.options}};function Gs(s,t="column"){if(!Array.isArray(s))throw new TypeError(`Kanban ${t}s must be an array or null`);let e=new Set;return s.map((i,n)=>{if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`Kanban ${t} at index ${n} must be an object`);let r=i,o=String(r.id??"").trim();if(!o&&r.id!=="")throw new TypeError(`Kanban ${t} at index ${n} requires an id`);if(e.has(o))throw new TypeError(`Duplicate Kanban ${t}: ${o}`);if(r.accept!=null&&typeof r.accept!="function")throw new TypeError(`Kanban ${t} ${o} accept must be a function`);if(r.from!=null&&!Array.isArray(r.from))throw new TypeError(`Kanban ${t} ${o} from must be an array or null`);e.add(o);let a={...r,id:o,label:String(r.label??Gh(r.id)),limit:Qh(r.limit),from:Array.isArray(r.from)?r.from.map(String):null,...Object.prototype.hasOwnProperty.call(r,"value")?{}:{value:r.id}};if(t==="column"){let c=Gb(r.laneLimits);c&&(a.laneLimits=c),(r.wipPolicy==="block"||r.wipPolicy==="warn")&&(a.wipPolicy=r.wipPolicy)}else delete a.laneLimits,delete a.wipPolicy;return a})}function Bh(s,t){let e=[],i=new Set;return s.forEach((n,r)=>{let o=Qt(n,r,t),a=K(o);i.has(a)||(i.add(a),e.push({id:a,label:Gh(o),value:o,limit:null}))}),e}function uo(s,t){let e=s.map(r=>r.id),i=new Set(e),n=Ct(t).filter(r=>i.has(r));return[...new Set(n),...e.filter(r=>!n.includes(r))]}function De(s,t,e=!1){if(!e)return uo(s,t);let i=Ct(t),n=s.map(r=>r.id);return[...i,...n.filter(r=>!i.includes(r))]}function Gh(s){return s==null||String(s).trim()===""?"Unassigned":String(s)}function Qh(s){if(s==null||s==="")return null;let t=Number(s);if(!Number.isFinite(t)||t<0)throw new TypeError("Kanban column limit must be a non-negative number");return Math.floor(t)}function Gb(s){if(s==null)return;if(typeof s!="object"||Array.isArray(s))throw new TypeError("Kanban column laneLimits must be an object");let t={};for(let[e,i]of Object.entries(s)){let n=Qh(i);n!=null&&(t[e]=n)}return t}function Qb(s,t){let e=s.laneLimits;if(!e||typeof e!="object")return null;let i=e[t];return typeof i=="number"&&Number.isFinite(i)?i:null}function jh(s,t){return t==null?"none":s>t?"exceeded":s===t?"limit":"within"}function Ct(s){return Array.isArray(s)?[...new Set(s.map(String))]:[]}function Hh(s){return s==null?"":typeof s=="object"?"nodeType"in s?String(s.textContent??""):"":String(s)}function qh(s,t){let e=new Map(s.map(i=>[i.id,i]));return t.map(i=>e.get(i)).filter(Boolean)}function $h(s,t,e,i){let n=[...s],r=n.indexOf(String(t));if(r<0||!n.includes(String(e))||String(t)===String(e))return n;n.splice(r,1);let o=n.indexOf(String(e));return n.splice(o+(i==="after"?1:0),0,String(t)),n}function Kh(s,t,e,i){if(!i)return[...e];let n=new Set(t.map(c=>c.id)),r=[...e],o=0,a=Ct(s).flatMap(c=>n.has(c)?o<r.length?[r[o++]]:[]:[c]);return a.push(...r.slice(o)),Ct(a)}function Xb(s,t){return s.column===t.column&&s.lane===t.lane&&s.index===t.index}function Uh(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function Yh(s,t){for(let e of s)if(Object.is(e,t))return!0;return!1}function Me(s){let t=s.target;return t?t instanceof Element?t:t.parentElement:null}function Wh(){let s=globalThis.getSelection?.();return!!(s&&!s.isCollapsed&&String(s).trim())}var fo=class s extends Ot{static cssName="table";constructor(t=null,e={}){super(t,{editTrigger:"single",...e})}static BillingItems(t,e={}){let i=new s(t,Jb(e));return i.el.dataset.preset="billing-items",i}};function Jb(s={}){let{fields:t={},units:e=[],currencies:i=[],currency:n="EUR",locale:r,decimals:o=2,columnOverrides:a={},lineTotal:c=null,columns:h,oneditcommit:u,rowClass:d,...p}=s,f={...Zh,...t},_=typeof c=="function"?c:w=>{let y=Jh(w?.[f.quantity]),v=Jh(w?.[f.unitPrice]);return y!==null&&v!==null?y*v:null},b=Array.isArray(h)?h.map(w=>({...w})):tu(f,{units:e,currencies:i,currency:n,locale:r,decimals:o,columnOverrides:a});return{rowId:f.id,editMode:"cell",editTrigger:"single",rowReorder:!0,columnVisibility:!0,hierarchy:{parentId:f.parent,column:f.item,expanded:!0},responsive:"sm",...p,columns:b,rowClass(w){let y=Qs(w,f)?"":"zx-grid-billing__summary",v=typeof d=="function"?d(w):"";return[y,v].filter(Boolean).join(" ")},oneditcommit(w){let{row:y,changes:v}=w.detail;if(Qs(y,f)){let k={...y,...v},z=_(k,v);z!=null&&Number.isFinite(Number(z))&&(v[f.total]=Number(z))}u?.(w)}}}var Zh=Object.freeze({id:"id",parent:"parent",item:"item",kind:"kind",quantity:"quantity",unit:"unit",unitPrice:"unitPrice",currency:"currency",total:"total"});function Qs(s,t=Zh){let e=String(s?.[t.kind]??"line").toLowerCase();return!["group","subtotal","header","section"].includes(e)}function tu(s,{units:t,currencies:e,currency:i,locale:n,decimals:r,columnOverrides:o}){let a=d=>p=>Qs(p,s)?d:!1,c=d=>String(d?.[s.currency]||i),h=d=>String(d?.[s.unit]??""),u={item:{id:s.item,label:"Item",width:"2fr",sortable:!0,editable:a("text")},quantity:{id:s.quantity,label:"Quantity",width:"1fr",type:"unit",locale:n,unit:h,editable:a("number"),editorProps:{min:0,step:.01}},unit:{id:s.unit,label:"Unit",width:".8fr",editable:a(Xh(t)?"select":"text"),options:t},unitPrice:{id:s.unitPrice,label:"Unit price",width:"1fr",type:"currency",locale:n,decimals:r,currency:c,editable:a("number"),editorProps:{min:0,step:.01}},currency:{id:s.currency,label:"Currency",width:".8fr",editable:a(Xh(e)?"select":"text"),options:e},total:{id:s.total,label:"Line total",width:"1fr",type:"currency",locale:n,decimals:r,currency:c}};return Object.entries(u).map(([d,p])=>({...p,...o?.[d]??{}}))}function Xh(s){return Array.isArray(s)?s.length>0:!!(s&&typeof s=="object"&&Object.keys(s).length)}function Jh(s){if(s==null||typeof s=="string"&&s.trim()==="")return null;let t=Number(s);return Number.isFinite(t)?t:null}var po=class extends m{static cssName="chart";static defaults={adapter:null,type:"bar",data:{labels:[],datasets:[]},chartOptions:{},label:"Chart",description:"",summary:"hidden",loading:!1,emptyText:"No chart data",loadingText:"Loading chart\u2026",errorText:"Unable to render chart",aspectRatio:"16 / 9"};constructor(t=null,e={}){super(t,e),this._mountOrUpdate(!1)}render(){this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,c=>[c.name,c.value]),children:Array.from(t.childNodes)},this._adapter=this.options.adapter,this._type=String(this.options.type||"bar"),this._data=iu(this.options.data),this._label=Zb(this.options.label),this._chartOptions=Tt(this.options.chartOptions),this._loading=!!this.options.loading,this._error=null,this._hasError=!1,this._handle=null,this._destroyed=!1;let e=x("zx-chart-description"),i=l("canvas",{ref:"canvas",class:"zx-chart__canvas",role:"img",ariaLabel:this._label,ariaDescribedby:e}),n=l("div",{ref:"viewport",class:"zx-chart__viewport"},i);n.style.setProperty("--zx-chart-aspect-ratio",String(this.options.aspectRatio));let r=l("p",{ref:"description",class:"zx-chart__description",id:e},this.options.description),o=l("div",{ref:"status",class:"zx-chart__status",role:"status",ariaLive:"polite"}),a=l("div",{ref:"summary",class:"zx-chart__summary",dataset:{summary:this.options.summary==="visible"?"visible":"hidden"}});return t.replaceChildren(n,r,o,a),this._renderSummary(),this._syncState(),this._observer=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.resize()):null,this._observer?.observe(n),t}setData(t){return this._data=iu(t),this._error=null,this._hasError=!1,this._loading=!1,this._renderSummary(),this._mountOrUpdate(!0),this}setType(t){return this._type=String(t||"bar"),this._mountOrUpdate(!0),this}update(t){return this._chartOptions=Tt(t&&typeof t=="object"?t:{}),this._mountOrUpdate(!0),this}setAdapter(t){return this._destroyHandle(),this._adapter=t,this._mountOrUpdate(!1),this}setLoading(t=!0){return this._loading=!!t,this._loading?this._destroyHandle():this._mountOrUpdate(!1),this._syncState(),this}setError(t){return this._error=t??new Error(String(this.options.errorText)),this._hasError=!0,this._loading=!1,this._destroyHandle(),this._syncState(),this.emit("error",{error:this._error}),this}clearError(){return this._error=null,this._hasError=!1,this._mountOrUpdate(!1),this}resize(){try{this._handle?.resize?.()}catch(t){this.setError(t)}return this}refreshTheme(){return this._mountOrUpdate(!0),this}getInstance(){return this._handle?.instance??null}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this._original;if(this._observer?.disconnect(),this._destroyHandle(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,i]of t.attributes)this.el.setAttribute(e,i);this.el.replaceChildren(...t.children)}}_mountOrUpdate(t){if(this._syncState(),this._loading||this._hasError||go(this._data)){this._destroyHandle();return}if(!this._adapter||typeof this._adapter.create!="function"){this._destroyHandle();return}let e=this._spec();try{if(this._handle)this._handle.update(e);else{if(this._handle=this._adapter.create(this.refs.canvas,e),!this._handle||typeof this._handle.destroy!="function")throw new TypeError("Chart adapter create() must return a lifecycle handle");this.emit("ready",{instance:this.getInstance()})}t&&this.emit("update",{data:this._data,type:this._type})}catch(i){this.setError(i)}}_spec(){return{type:this._type,data:Tt(this._data),options:{...iy(this.el),...Tt(this._chartOptions)},onSelect:t=>this.emit("select",t)}}_destroyHandle(){if(!this._handle)return;let t=this._handle;this._handle=null;try{t.destroy()}catch{}}_syncState(){let t=go(this._data),e=this._loading?"loading":this._hasError?"error":t?"empty":"ready";this.el.dataset.state=e,this.refs.viewport.hidden=e!=="ready";let i="";e==="loading"?i=String(this.options.loadingText):e==="error"?i=sy(this._error,this.options.errorText):e==="empty"&&(i=String(this.options.emptyText)),this.refs.status.textContent=i,this.refs.status.hidden=!i}_renderSummary(){this.refs.summary.replaceChildren(su(this._data,this._label))}};function Zb(s){return String(s??"").trim()||"Chart"}var _o=class{constructor(t,e={}){let i=typeof t=="function"?t:t?.Chart;if(typeof i!="function")throw new TypeError("ChartJsAdapter requires an injected Chart.js constructor");this.engine=i,this.defaults=Tt(e)}create(t,e){let i=this.engine,n=null,r="",o=!1,a=c=>{let h=null,u=eu(c,this.defaults,()=>h);h=new i(t,u),n=h,r=c.type};return a(e),{get instance(){return n},update:c=>{if(o)return;if(c.type!==r){let u=n;n=null,u?.destroy?.(),a(c);return}let h=eu(c,this.defaults,()=>n);n.data=h.data,n.options=h.options,n.update()},resize:()=>{o||n?.resize?.()},destroy:()=>{o||(o=!0,n?.destroy?.(),n=null)}}}};function eu(s,t,e){let i=Tt(s.options),n={responsive:!0,maintainAspectRatio:!1,...Tt(t),...i},r=n.onClick;return n.onClick=(o,a,c)=>{typeof r=="function"&&r(o,a,c);let h=e()??c,d=(Array.isArray(a)&&a.length?a:h?.getElementsAtEventForMode?.(o,"nearest",{intersect:!0},!0)??[])[0];if(!d)return;let p=s.data.datasets?.[d.datasetIndex]??null;s.onSelect({datasetIndex:d.datasetIndex,index:d.index,dataset:p,label:s.data.labels?.[d.index],value:p?.data?.[d.index],nativeEvent:o?.native??o??null})},{type:s.type,data:Tt(s.data),options:n}}function Tt(s){return mo(s,new WeakMap)}function mo(s,t){if(Array.isArray(s)){if(t.has(s))return t.get(s);let e=[];return t.set(s,e),e.push(...s.map(i=>mo(i,t))),e}if(s&&typeof s=="object"&&Object.getPrototypeOf(s)===Object.prototype){if(t.has(s))return t.get(s);let e={};t.set(s,e);for(let[i,n]of Object.entries(s))e[i]=mo(n,t);return e}return s}function iu(s){return!s||typeof s!="object"?{labels:[],datasets:[]}:Tt({...s,labels:Array.isArray(s.labels)?s.labels:[],datasets:Array.isArray(s.datasets)?s.datasets:[]})}function go(s){return!Array.isArray(s?.datasets)||!s.datasets.some(t=>Array.isArray(t?.data)&&t.data.length>0)}function su(s,t="Chart data"){let e=ty(s);return l("table",{class:"zx-chart__table"},l("caption",{},t),l("thead",{},l("tr",{},l("th",{scope:"col"},"Label"),e.headers.map(n=>l("th",{scope:"col"},n)))),l("tbody",{},e.rows.map(n=>l("tr",{},l("th",{scope:"row"},n.label),n.values.map(r=>l("td",{},r))))))}function ty(s){let t=Array.isArray(s?.datasets)?s.datasets:[],e=Array.isArray(s?.labels)?s.labels:[],i=Math.max(e.length,...t.map(n=>Array.isArray(n.data)?n.data.length:0),0);return{headers:t.map((n,r)=>String(n.label??`Series ${r+1}`)),rows:Array.from({length:i},(n,r)=>({label:String(e[r]??r+1),values:t.map(o=>ey(o.data?.[r]))}))}}function ey(s){if(s==null)return"";if(typeof s=="object"){if("y"in s)return String(s.y??"");if("r"in s)return String(s.r??"");try{return JSON.stringify(s)}catch{return String(s)}}return String(s)}function iy(s){if(typeof getComputedStyle!="function")return{};let t=getComputedStyle(s),e=t.getPropertyValue("--zx-color-text").trim(),i=t.getPropertyValue("--zx-color-border").trim();return{color:e||void 0,borderColor:i||void 0}}function sy(s,t){let e=s&&typeof s=="object"&&"message"in s?String(s.message):"";return e.trim()?e:String(t)}function Xs({valueKey:s="ID",labelKey:t="name",childrenKey:e="children"}={}){return{value:i=>typeof s=="function"?s(i):i?.[s],label:i=>String((typeof t=="function"?t(i):i?.[t])??""),children:i=>{let n=i?.[e];return Array.isArray(n)?n:null}}}function U(s,t){if(s?.hasChildren===!0)return!0;let e=t.children(s);return Array.isArray(e)&&e.length>0}function Ne(s,t,e,{level:i=1,parent:n=null}={}){s.forEach((r,o)=>{e(r,{level:i,parent:n,index:o,siblings:s});let a=t.children(r);a&&Ne(a,t,e,{level:i+1,parent:r})})}function nu(s,t,e){let i=null;return Ne(s,e,n=>{i===null&&Object.is(e.value(n),t)&&(i=n)}),i}function Oi(s,t,e){for(let i of s){if(Object.is(e.value(i),t))return[i];let n=e.children(i);if(!n)continue;let r=Oi(n,t,e);if(r.length>0)return[i,...r]}return[]}function ru(s,t){let e=[],i=t.children(s);return i&&Ne(i,t,n=>e.push(n)),e}function ou(s,t,e){let i=[],n=(r,o,a)=>{r.forEach((c,h)=>{let u=t.value(c);if(i.push({node:c,id:u,level:o,parent:a,posinset:h+1,setsize:r.length}),!e.has(u))return;let d=t.children(c);d&&d.length>0&&n(d,o+1,c)})};return n(s,1,null),i}function bo(s,t,e,i){let n=[];for(let r of s){let o=t.children(r)??[],a=bo(o,t,e,i);(e(r)||a.length>0)&&n.push(a.length>0||o.length>0?{...r,[i]:a}:r)}return n}var yo=class extends m{static cssName="tree";static defaults={items:[],valueKey:"ID",labelKey:"name",childrenKey:"children",expanded:[],selection:"single",selected:[],checkboxes:!1,checked:[],icons:!0,renderLabel:null,load:null,filter:"",label:"Tree",emptyText:"Nothing to show",height:null};render(){this._items=[],this._rows=[],this._expanded=new Set,this._selected=new Set,this._checked=new Set,this._loading=new Map,this._focusId=null,this._filter="",this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");this.el=t,this._readers=Xs(this.options),this._childrenKey=this.options.childrenKey??"children",t.setAttribute("role","tree"),t.setAttribute("aria-label",String(this.options.label??"Tree")),t.tabIndex=0,this.options.selection==="multi"&&t.setAttribute("aria-multiselectable","true"),this.options.height!==null&&(t.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height),t.style.overflowY="auto"),this._items=wo(this.options.items);for(let i of Fi(this.options.expanded))this._expanded.add(i);for(let i of Fi(this.options.selected))this._selected.add(i);let[e]=this._selected;if(e!==void 0){this._focusId=e;for(let i of this.getPath(e).slice(0,-1))this._expanded.add(this._readers.value(i))}for(let i of Fi(this.options.checked))this._applyCheck(i,!0,{silent:!0});return this._handleTypeahead=ht(()=>this._rotatedRows().map(i=>this._readers.label(i.node)),(i,n)=>this._focusNodeId(this._rotatedRows()[n]?.id)),this.listen(t,"keydown",i=>this._onKeydown(i)),this.listen(t,"click",i=>this._onClick(i)),this.listen(t,"dblclick",i=>this._onDoubleClick(i)),this.listen(t,"focus",()=>{this._rows.length>0&&!this._rowElement(this._focusId)&&this._focusRow(0)}),String(this.options.filter??"")!==""?this.setFilter(this.options.filter):this._renderRows(),t}setItems(t){return this._items=wo(t),this._renderRows(),this}getItems(){return this._items}getNode(t){return nu(this._items,t,this._readers)}getPath(t){return Oi(this._items,t,this._readers)}setFilter(t){if(this._filter=String(t??""),this._filter!=="")for(let e of this._visibleItems())Ne([e],this._readers,i=>this._expanded.add(this._readers.value(i)));return this._renderRows(),this}async expand(t){let e=this.getNode(t);if(!e||!U(e,this._readers))return this;let i=this._readers.children(e),n=!!this.options.load&&(!i||i.length===0);return this._expanded.has(t)&&!n?this:await this._ensureChildren(e,t)?(this._expanded.add(t),this._renderRows(),this.emit("expand",{node:e,id:t}),this):this}collapse(t){if(!this._expanded.delete(t))return this;let e=this.getNode(t);return this._renderRows(),e&&this.emit("collapse",{node:e,id:t}),this}async toggle(t){return this._expanded.has(t)?this.collapse(t):this.expand(t)}expandAll(){return Ne(this._items,this._readers,t=>{U(t,this._readers)&&this._expanded.add(this._readers.value(t))}),this._renderRows(),this}collapseAll(){return this._expanded.clear(),this._renderRows(),this}reveal(t){let e=this.getPath(t);for(let i of e.slice(0,-1))this._expanded.add(this._readers.value(i));return this._renderRows(),this}select(t,{silent:e=!1,additive:i=!1}={}){if(this.options.selection===!1)return this;let n=this.getNode(t);return n?(this.options.selection==="multi"&&i?this._selected.has(t)?this._selected.delete(t):this._selected.add(t):(this._selected.clear(),this._selected.add(t)),this._syncRows(),e||this.emit("select",{node:n,id:t,ids:this.getSelection()}),this):this}getSelection(){return[...this._selected]}setSelection(t,{silent:e=!0}={}){let i=Fi(t);if(this._selected=new Set(this.options.selection==="multi"?i:i.slice(0,1)),this._syncRows(),!e){let[n]=this._selected;this.emit("select",{node:this.getNode(n)??null,id:n,ids:this.getSelection()})}return this}clearSelection(){return this._selected.clear(),this._syncRows(),this}getChecked({leavesOnly:t=!1}={}){return t?[...this._checked].filter(e=>{let i=this.getNode(e);return i!==null&&!U(i,this._readers)}):[...this._checked]}setChecked(t,{silent:e=!0}={}){this._checked.clear();for(let i of Fi(t))this._applyCheck(i,!0,{silent:!0});return this._syncRows(),e||this.emit("check",{ids:this.getChecked(),node:null}),this}check(t,e,{silent:i=!1}={}){let n=this._applyCheck(t,e,{silent:!0});return this._syncRows(),!i&&n&&this.emit("check",{ids:this.getChecked(),node:n}),this}focusNode(t){this.reveal(t);let e=this._rows.findIndex(i=>Object.is(i.id,t));return e>=0&&this._focusRow(e),this}_visibleItems(){if(this._filter==="")return this._items;let t=this._filter.trim().toLocaleLowerCase();return t===""?this._items:bo(this._items,this._readers,e=>this._readers.label(e).toLocaleLowerCase().includes(t),this._childrenKey)}_renderRows(){let t=this._visibleItems();if(this._rows=ou(t,this._readers,this._expanded),this._rows.length===0){this.el.replaceChildren(l("div",{class:"zx-tree__empty"},this._message("tree.empty",this.options.emptyText)));return}this.el.replaceChildren(...this._rows.map(e=>this._renderRow(e))),this._syncRows()}_renderRow(t){let e=U(t.node,this._readers),i=e&&this._expanded.has(t.id),n=l("div",{class:"zx-tree__row",role:"treeitem",id:x("zx-tree-item"),tabIndex:-1,ariaLevel:String(t.level),ariaSetSize:String(t.setsize),ariaPosInSet:String(t.posinset),dataset:{level:String(t.level)}});n.style.setProperty("--zx-tree-level",String(t.level-1));let r=l("span",{class:"zx-tree__twisty",ariaHidden:"true"},e?g("chevron-right",{size:12}):null);if(r.dataset.action="twisty",n.append(r),this.options.checkboxes){let a=l("input",{class:"zx-tree__checkbox",type:"checkbox",tabIndex:-1,ariaHidden:"true"});a.dataset.action="checkbox",n.append(a)}this.options.icons&&n.append(l("span",{class:"zx-tree__icon",ariaHidden:"true"},g(e?i?"folder-open":"folder":"file",{size:14})));let o=this.options.renderLabel?this.options.renderLabel(t.node):this._readers.label(t.node);return n.append(l("span",{class:"zx-tree__label"},o)),t.node.badge!=null&&n.append(l("span",{class:"zx-tree__badge"},String(t.node.badge))),n}_syncRows(){let t=this.el.querySelectorAll(".zx-tree__row"),e=this._rows.findIndex(i=>Object.is(i.id,this._focusId));e<0&&(e=0),t.forEach((i,n)=>{let r=this._rows[n];if(!r)return;let o=U(r.node,this._readers),a=o&&this._expanded.has(r.id);o?i.setAttribute("aria-expanded",String(a)):i.removeAttribute("aria-expanded"),this.options.selection!==!1&&i.setAttribute("aria-selected",String(this._selected.has(r.id))),i.toggleAttribute("data-branch",o),i.toggleAttribute("data-loading",this._loading.has(r.id)),i.tabIndex=n===e?0:-1;let c=i.querySelector(".zx-tree__checkbox");if(c){let u=this._checkState(this.getNode(r.id)??r.node);c.checked=u==="checked",c.indeterminate=u==="partial",i.setAttribute("aria-checked",u==="partial"?"mixed":String(c.checked))}let h=i.querySelector(".zx-tree__icon");h&&this.options.icons&&h.replaceChildren(g(o?a?"folder-open":"folder":"file",{size:14}))}),this._focusId=this._rows[e]?.id??null,this.el.tabIndex=this._rows.length===0?0:-1}_onClick(t){let e=t.target.closest(".zx-tree__row");if(!e)return;let i=this._rowIndex(e);if(i<0)return;let n=this._rows[i];this._focusRow(i);let r=t.target.closest("[data-action]");if(r?.dataset.action==="twisty"){U(n.node,this._readers)&&this.toggle(n.id).then(()=>this._focusNodeId(n.id));return}let o=this.getNode(n.id)??n.node;if(r?.dataset.action==="checkbox"){this.check(n.id,this._checkState(o)!=="checked");return}if(this.options.checkboxes&&this.options.selection===!1){this.check(n.id,this._checkState(o)!=="checked");return}this.select(n.id,{additive:t.ctrlKey||t.metaKey})}_onDoubleClick(t){let e=t.target.closest(".zx-tree__row");if(!e)return;let i=this._rows[this._rowIndex(e)];i&&(U(i.node,this._readers)?this.toggle(i.id).then(()=>this._focusNodeId(i.id)):this.emit("activate",{node:i.node,id:i.id}))}_onKeydown(t){let e=this._rows.findIndex(o=>Object.is(o.id,this._focusId));if(e<0||this._rows.length===0)return;let i=this._rows[e],n=U(i.node,this._readers),r=n&&this._expanded.has(i.id);switch(t.key){case"ArrowDown":t.preventDefault(),this._focusRow(Math.min(this._rows.length-1,e+1));return;case"ArrowUp":t.preventDefault(),this._focusRow(Math.max(0,e-1));return;case"ArrowRight":t.preventDefault(),n&&!r?this.expand(i.id).then(()=>this._focusNodeId(i.id)):r&&this._focusRow(Math.min(this._rows.length-1,e+1));return;case"ArrowLeft":{t.preventDefault(),r?(this.collapse(i.id),this._focusNodeId(i.id)):i.parent&&this._focusNodeId(this._readers.value(i.parent));return}case"Home":t.preventDefault(),this._focusRow(0);return;case"End":t.preventDefault(),this._focusRow(this._rows.length-1);return;case"Enter":t.preventDefault(),this.options.selection!==!1&&this.select(i.id),this.emit("activate",{node:i.node,id:i.id});return;case" ":t.preventDefault(),this.options.checkboxes?this.check(i.id,this._checkState(this.getNode(i.id)??i.node)!=="checked"):this.options.selection!==!1&&this.select(i.id,{additive:this.options.selection==="multi"});return;case"*":t.preventDefault(),this._expandSiblings(i);return;default:this._handleTypeahead(t)}}_expandSiblings(t){let e=t.parent?this._readers.children(t.parent)??[]:this._visibleItems(),i=this._focusId;for(let n of e)U(n,this._readers)&&this._expanded.add(this._readers.value(n));this._renderRows(),this._focusNodeId(i)}async _ensureChildren(t,e){let i=this._readers.children(t);if(!this.options.load||i&&i.length>0)return!0;if(this._loading.has(e))return await this._loading.get(e),Array.isArray(this._readers.children(t));let n=(async()=>{try{let o=await this.options.load(t);return t[this._childrenKey]=Array.isArray(o)?o:[],t[this._childrenKey].length===0&&(t.hasChildren=!1),!0}catch(o){return this.emit("error",{error:o,node:t,id:e}),!1}finally{this._loading.delete(e)}})();this._loading.set(e,n),this._syncRows();let r=await n;return this._syncRows(),r}_applyCheck(t,e,{silent:i}){let n=this.getNode(t);if(!n)return null;let r=[t,...ru(n,this._readers).map(o=>this._readers.value(o))];for(let o of r)e?this._checked.add(o):this._checked.delete(o);return i||this._syncRows(),n}_checkState(t){let e=this._readers.children(t);if(!e||e.length===0)return this._checked.has(this._readers.value(t))?"checked":"unchecked";let i=e.map(n=>this._checkState(n));return i.every(n=>n==="checked")?"checked":i.every(n=>n==="unchecked")?"unchecked":"partial"}_rotatedRows(){let t=this._rows.findIndex(e=>Object.is(e.id,this._focusId));return t<0?this._rows:[...this._rows.slice(t+1),...this._rows.slice(0,t+1)]}_rowIndex(t){return[...this.el.querySelectorAll(".zx-tree__row")].indexOf(t)}_rowElement(t){let e=this._rows.findIndex(i=>Object.is(i.id,t));return e<0?null:this.el.querySelectorAll(".zx-tree__row")[e]??null}_focusRow(t){let e=this._rows[t];if(!e)return;this._focusId=e.id,this._syncRows();let i=this._rowElement(e.id);i?.focus(),i?.scrollIntoView({block:"nearest"})}_focusNodeId(t){if(t===void 0)return;let e=this._rows.findIndex(i=>Object.is(i.id,t));e>=0&&this._focusRow(e)}_message(t,e){let i=this.msg(t);return i===t?e:i}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function wo(s){return Array.isArray(s)?s.map(t=>{if(t===null||typeof t!="object")return t;let e={...t};for(let[i,n]of Object.entries(e))Array.isArray(n)&&(e[i]=wo(n));return e}):[]}function Fi(s){return Array.isArray(s)?s:[]}var xo=class extends m{static cssName="finder";static defaults={items:[],valueKey:"ID",labelKey:"name",childrenKey:"children",path:[],load:null,preview:null,rootLabel:"",columnWidth:220,height:320,icons:!0,renderItem:null,emptyText:"Empty"};render(){this._items=[],this._path=[],this._columns=[],this._activeColumn=0,this._loading=new Map,this._pathSequence=0,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el);let t=this.el??l("div");return this.el=t,this._readers=Xs(this.options),this._childrenKey=this.options.childrenKey??"children",t.style.setProperty("--zx-finder-column",`${Number(this.options.columnWidth)||220}px`),this.options.height!==null&&(t.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._handleTypeahead=ht(()=>this._columnNodes(this._activeColumn).map(e=>this._readers.label(e)),(e,i)=>this._selectAt(this._activeColumn,i,{focus:!0})),this.listen(t,"click",e=>this._onClick(e)),this.listen(t,"dblclick",e=>this._onDoubleClick(e)),this.listen(t,"keydown",e=>this._onKeydown(e)),this._render({}),this.setPath(this.options.path,{silent:!0}),t}getPath(){return this._path.slice()}getNodes(){let t=this._items,e=[];for(let i of this._path){let n=t.find(r=>Object.is(this._readers.value(r),i));if(!n)break;e.push(n),t=this._readers.children(n)??[]}return e}getSelection(){let t=this.getNodes();return t.length>0?t[t.length-1]:null}async setPath(t,{silent:e=!1,focus:i=!1}={}){let n=this._pathSequence+1;this._pathSequence=n;let r=Array.isArray(t)?t.slice():[],o=[],a=this._items;for(let c of r){let h=a.find(u=>Object.is(this._readers.value(u),c));if(!h||(o.push(c),!U(h,this._readers)))break;if(await this._ensureChildren(h),n!==this._pathSequence)return this;a=this._readers.children(h)??[]}return this._path=o,this._activeColumn=Math.max(0,o.length-1),this._render({focus:i}),e||this._emitChange(),this}async reveal(t,{silent:e=!1}={}){let i=Oi(this._items,t,this._readers);return i.length===0?this:this.setPath(i.map(n=>this._readers.value(n)),{silent:e})}setItems(t){return this._items=Array.isArray(t)?t.slice():[],this._path=[],this._render({}),this}focus(){return(this._activeRow(this._activeColumn)??this._rowAt(this._activeColumn,0))?.focus(),this}_render({focus:t=!1}){let e=this.getNodes(),i=[{nodes:this._items,selectedId:this._path[0],owner:null}];e.forEach((a,c)=>{if(!U(a,this._readers))return;let h=this._readers.children(a)??[];i.push({nodes:h,selectedId:this._path[c+1],owner:a})}),this._columns=i,this._activeColumn=Math.min(this._activeColumn,i.length-1);let n=i.map((a,c)=>this._renderColumn(a,c)),r=e[e.length-1]??null;if(this.options.preview&&r&&!U(r,this._readers)){let a=this.options.preview(r);a&&n.push(l("div",{class:"zx-finder__preview"},a))}this.el.replaceChildren(...n),this._syncTabStop(),this.el.lastElementChild?.scrollIntoView({block:"nearest",inline:"nearest"}),t&&this.focus()}_renderColumn(t,e){let i=t.owner?this._readers.label(t.owner):String(this.options.rootLabel||this._message("finder.root","Root")),n=l("div",{class:"zx-finder__list",role:"listbox",ariaLabel:i,dataset:{column:String(e)}});if(t.nodes.length===0){let r=t.owner!==null&&this._loading.has(this._readers.value(t.owner));n.append(l("div",{class:"zx-finder__empty"},r?this._message("finder.loading","Loading\u2026"):this._message("finder.empty",this.options.emptyText)))}for(let r of t.nodes){let o=this._readers.value(r),a=U(r,this._readers),c=t.selectedId!==void 0&&Object.is(o,t.selectedId),h=l("div",{class:"zx-finder__row",id:x("zx-finder-row"),role:"option",tabIndex:-1,ariaSelected:String(c)});this.options.icons&&h.append(l("span",{class:"zx-finder__icon",ariaHidden:"true"},g(a?"folder":"file",{size:14}))),h.append(l("span",{class:"zx-finder__label"},this.options.renderItem?this.options.renderItem(r):this._readers.label(r))),a&&h.append(l("span",{class:"zx-finder__chevron",ariaHidden:"true"},g("chevron-right",{size:11}))),h.toggleAttribute("data-branch",a),n.append(h)}return l("div",{class:"zx-finder__column"},n)}_syncTabStop(){let t=this.el.querySelectorAll(".zx-finder__row");t.forEach(i=>{i.tabIndex=-1});let e=this._activeRow(this._activeColumn)??this._rowAt(this._activeColumn,0)??t[0];e&&(e.tabIndex=0)}_onClick(t){let e=t.target.closest(".zx-finder__row");if(!e)return;let{column:i,index:n}=this._locate(e);i<0||this._selectAt(i,n,{focus:!0})}_onDoubleClick(t){let e=t.target.closest(".zx-finder__row");if(!e)return;let{column:i,index:n}=this._locate(e),r=this._columnNodes(i)[n];r&&(U(r,this._readers)?this._enter(i,n):this.emit("activate",{node:r,id:this._readers.value(r)}))}_onKeydown(t){if(t.target.closest(".zx-finder__preview"))return;let e=this._activeColumn,i=this._columnNodes(e);if(i.length===0&&!["ArrowLeft"].includes(t.key))return;let n=Math.max(0,i.findIndex(r=>Object.is(this._readers.value(r),this._columns[e]?.selectedId)));switch(t.key){case"ArrowDown":t.preventDefault(),this._selectAt(e,Math.min(i.length-1,n+1),{focus:!0});return;case"ArrowUp":t.preventDefault(),this._selectAt(e,Math.max(0,n-1),{focus:!0});return;case"Home":t.preventDefault(),this._selectAt(e,0,{focus:!0});return;case"End":t.preventDefault(),this._selectAt(e,i.length-1,{focus:!0});return;case"ArrowRight":{t.preventDefault();let r=i[n];if(!r||!U(r,this._readers))return;this._enter(e,n);return}case"ArrowLeft":if(t.preventDefault(),e===0)return;this._path=this._path.slice(0,e),this._activeColumn=e-1,this._render({focus:!0}),this._emitChange();return;case"Enter":{t.preventDefault();let r=i[n];if(!r)return;U(r,this._readers)?this._enter(e,n):this.emit("activate",{node:r,id:this._readers.value(r)});return}default:this._handleTypeahead(t)}}async _selectAt(t,e,{focus:i=!1}={}){let n=this._columnNodes(t)[e];if(!n)return;let r=this._readers.value(n);if(this._path.length===t+1&&Object.is(this._path[t],r)){this._activeColumn=t,this._syncTabStop(),i&&this.focus();return}this._path=[...this._path.slice(0,t),r],this._activeColumn=t,U(n,this._readers)&&await this._ensureChildren(n),this._render({focus:i}),this._emitChange()}async _enter(t,e){if(await this._selectAt(t,e),this._columnNodes(t+1).length===0){this._activeColumn=t,this._syncTabStop(),this.focus();return}this._activeColumn=t+1,this._path.length<=t+1?await this._selectAt(t+1,0,{focus:!0}):(this._syncTabStop(),this.focus())}async _ensureChildren(t){let e=this._readers.children(t);if(!this.options.load||e&&e.length>0)return;let i=this._readers.value(t),n=this._loading.get(i);if(n)return n;let r=(async()=>{try{let o=await this.options.load(t);t[this._childrenKey]=Array.isArray(o)?o:[],t[this._childrenKey].length===0&&(t.hasChildren=!1)}catch(o){t[this._childrenKey]=[],this.emit("error",{error:o,node:t,id:i})}finally{this._loading.delete(i)}})();return this._loading.set(i,r),r}_columnNodes(t){return this._columns[t]?.nodes??[]}_locate(t){let e=t.closest(".zx-finder__list");return e?{column:Number(e.dataset.column),index:[...e.querySelectorAll(".zx-finder__row")].indexOf(t)}:{column:-1,index:-1}}_rowAt(t,e){return this.el.querySelector(`.zx-finder__list[data-column="${t}"]`)?.querySelectorAll(".zx-finder__row")[e]??null}_activeRow(t){return this.el.querySelector(`.zx-finder__list[data-column="${t}"]`)?.querySelector('[aria-selected="true"]')??null}_emitChange(){let t=this.getNodes();this.emit("change",{path:this.getPath(),nodes:t,node:t.length>0?t[t.length-1]:null})}_message(t,e){let i=this.msg(t);return i===t?e:i}destroy(){this._pathSequence+=1;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function au(s){return String(s??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLocaleLowerCase()}function ny(s,t){let e=au(t).trim().split(/\s+/).filter(Boolean);if(e.length===0)return!0;let i=au(s.flat(1/0).join(" "));return e.every(n=>i.includes(n))}function So(s){return s!=null&&!(typeof s=="string"&&s.trim()==="")}function lu(s,t){if(typeof t.get=="function")return vo(t.get(s));let e=t.fields??t.field??t.id;return(Array.isArray(e)?e:[e]).flatMap(n=>vo(typeof n=="function"?n(s):n==null?void 0:s?.[n]))}function cu(s,t){let e=[],i=new Map;for(let n of s)for(let r of lu(n,t)){let o=hu(r);o.value==null||o.value===""||i.has(o.value)||(i.set(o.value,!0),e.push(o))}return e}function _e(s,t,e){return s.filter(i=>t.every(n=>{let r=e?.[n.id];if(!So(r))return!0;if(n.type==="custom")return typeof n.predicate!="function"||!!n.predicate(i,r);let o=lu(i,n);return n.type==="text"?ny(o,r):n.type==="select"?o.some(a=>ry(hu(a).value,r)):!0}))}function vo(s){return Array.isArray(s)?s.flat(1/0):[s]}function hu(s){if(s&&typeof s=="object"&&!(s instanceof Date)){if(Object.prototype.hasOwnProperty.call(s,"value"))return{value:s.value,label:String(s.label??s.value??"")};if(Object.prototype.hasOwnProperty.call(s,"field"))return{value:s.field,label:String(s.label??s.field??"")}}return{value:s,label:String(s??"")}}function ry(s,t){return Object.is(s,t)?!0:s==null||t==null?!1:String(s)===String(t)}var zo=class extends m{static cssName="data-filter";static defaults={filters:[],data:[],autoApply:!0,clearLabel:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??l("div");this._originalChildren=this.el?Array.from(this.el.childNodes):null,this._filters=Array.isArray(this.options.filters)?this.options.filters.map(i=>({...i})):[],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 i of this._filters){if(Ao(i),e.has(i.id))throw new RangeError(`Duplicate filter id: ${i.id}`);e.add(i.id),i.type==="custom"&&!this._customOrigins.has(i.element)&&this._customOrigins.set(i.element,{parent:i.element.parentNode,nextSibling:i.element.nextSibling}),this._state[i.id]=i.type==="custom"?ko(i.element):""}this._filtered=_e(this._data,this._filters,this._state),this._controls=l("div",{class:"zx-data-filter__controls"}),this._badge=l("span",{class:"zx-data-filter__badge",ariaLive:"polite",hidden:!0},"0"),this._clearButton=l("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 i of this._filters)this._appendFilter(i);return this._syncActiveState(),t}setData(t){ly(t),this._data=[...t];for(let e of this._filters){if(e.type!=="select")continue;let i=this._entries.get(e.id);i&&this._populateSelect(e,i)}return this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=_e(this._data,this._filters,this._state),this}apply(){this._filtered=_e(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=_e(this._data,this._filters,this._state),this}addFilter(t){Ao(t);let e={...t};return this._filters.push(e),this._state[e.id]=e.type==="custom"?ko(e.element):"",this._appendFilter(e),this._filtered=_e(this._data,this._filters,this._state),this._syncActiveState(),this}destroy(){this._restored||(this._originalChildren&&this.el.replaceChildren(...this._originalChildren),cy(this._customOrigins),this._restored=!0),super.destroy()}_appendFilter(t){if(Ao(t),this._entries.has(t.id))throw new RangeError(`Duplicate filter id: ${t.id}`);let e,i={element:null,options:[]};if(t.type==="select")e=l("select",{ariaLabel:t.label}),i.element=e,this._populateSelect(t,i),this.listen(e,"change",()=>{let r=Number(e.value)-1;this._state[t.id]=r>=0?i.options[r]?.value??"":"",this._controlChanged()});else if(t.type==="text")e=l("input",{type:"search",placeholder:t.placeholder??"",ariaLabel:t.label,autocomplete:"off"}),i.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}),i.element=e;let r=e.matches?.('input:not([type="checkbox"]):not([type="radio"]), textarea')?"input":"change";this.listen(e,r,()=>{this._state[t.id]=ko(e),this._controlChanged()})}this._entries.set(t.id,i);let n=l("label",{class:"zx-data-filter__field"},l("span",{class:"zx-data-filter__label"},t.label),e);this._controls.append(n)}_populateSelect(t,e){let i=this._state[t.id];e.options=Array.isArray(t.options)?t.options.map(oy):cu(this._data,t);let n=l("option",{value:""},t.emptyLabel??this.msg("dataFilter.all")),r=document.createDocumentFragment();r.append(n),e.options.forEach((a,c)=>{r.append(l("option",{value:String(c+1)},a.label))}),e.element.replaceChildren(r);let o=e.options.findIndex(a=>uu(a.value,i));e.element.value=o>=0?String(o+1):"",o<0&&(this._state[t.id]="")}_controlChanged(){this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=_e(this._data,this._filters,this._state)}_syncControls(){for(let t of this._filters){let e=this._entries.get(t.id);if(!e)continue;let i=this._state[t.id];if(t.type==="select"){let n=e.options.findIndex(r=>uu(r.value,i));e.element.value=n>=0?String(n+1):"",n<0&&(this._state[t.id]="")}else ay(e.element,i)}}_syncActiveState(){let t=this._filters.reduce((e,i)=>e+Number(So(this._state[i.id])),0);this._badge.textContent=String(t),this._badge.hidden=t===0,this._clearButton.hidden=t===0}};function Ao(s){if(!s||typeof s!="object")throw new TypeError("Filter definition must be an object");if(!["select","text","custom"].includes(s.type))throw new TypeError(`Unknown filter type: ${s.type}`);if(typeof s.id!="string"||!s.id)throw new TypeError("Filter definition requires an id");if(s.type==="custom"){if(!s.element||s.element.nodeType!==1)throw new TypeError("Custom filter requires an Element");if(typeof s.predicate!="function")throw new TypeError("Custom filter requires a predicate")}}function oy(s){return s&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"value")?{value:s.value,label:String(s.label??s.value??"")}:{value:s,label:String(s??"")}}function ko(s){return"checked"in s&&["checkbox","radio"].includes(s.type)?s.checked:"value"in s?s.value:s.getAttribute("data-value")??""}function ay(s,t){"checked"in s&&["checkbox","radio"].includes(s.type)?s.checked=!!t:"value"in s?s.value=t==null?"":String(t):t==null||t===""?s.removeAttribute("data-value"):s.setAttribute("data-value",String(t))}function uu(s,t){return Object.is(s,t)?!0:s==null||t==null?!1:String(s)===String(t)}function ly(s){if(!Array.isArray(s))throw new TypeError("DataFilter data must be an array")}function cy(s){let t=[...s];for(let e=t.length;t.length>0&&e>=0;e-=1){let i=0;for(let n=t.length-1;n>=0;n-=1){let[r,o]=t[n];if(!o.parent)r.remove();else{if(o.nextSibling&&o.nextSibling.parentNode!==o.parent)continue;o.parent.insertBefore(r,o.nextSibling)}t.splice(n,1),i+=1}if(i===0)break}for(let[e,i]of t)i.parent?i.parent.append(e):e.remove()}var hy=8,uy=1e11,dy=.01,Do=class extends m{static cssName="filter-panel";static defaults={fields:{},order:null,value:{},mode:"draft",serialize:"seconds",emptyText:null};render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._restored=!1,this._entries=[],this._children=[],this._writing=!1,this._draft={},this._applied={},this._appliedDraft="";let t=this.el??l("div");this.el=t,this._fields=py(this.options.fields,this.options.order),this._draft=Li(this.options.value,this.options.fields),this._applied=Mo(this._draft,this.options.fields,this.options.serialize),this._appliedDraft=Eo(this._draft);let e=[];if(this._fields.length===0)e.push(l("p",{ref:"empty",class:"zx-filter-panel__empty",role:"status"},this.options.emptyText==null?this._message("filterPanel.empty","No filters are available here."):String(this.options.emptyText)));else{let i=l("div",{ref:"fields",class:"zx-filter-panel__fields"});for(let{key:n,field:r,spec:o}of this._fields)i.append(this._buildField(n,r,o));e.push(i,this._buildActions())}return t.replaceChildren(...e),t.setAttribute("role","group"),t.setAttribute("aria-label",this._message("filterPanel.label","Filters")),t.setAttribute("data-mode",this.options.mode==="live"?"live":"draft"),this.listen(t,"keydown",i=>{i.key!=="Enter"||this.options.mode==="live"||!i.target?.matches?.('input:not([type="checkbox"]):not([type="radio"])')||(i.preventDefault(),this.apply())}),this._syncActions(),t}getValue(){return my(this._applied)}setValue(t){return this._draft=Li(t,this.options.fields),this._commit(this._draftValue()),this._writeControls(),this._syncActions(),this.emit("change",{value:this.getValue(),field:null}),this}apply(){let t=this._draftValue();return this._commit(t),this._syncActions(t),this.emit("apply",{value:this.getValue()}),this}reset(){return this._replaceDraft(Li(this.options.value,this.options.fields))}clear(){return this._replaceDraft(Li({},this.options.fields),{commit:!0})}destroy(){for(let t of this._children)t.destroy();this._children=[],!this._restored&&!this._createdRoot&&(S(this.el,this._snapshot),this._restored=!0),super.destroy()}_buildActions(){let t=l("div",{ref:"actions",class:"zx-filter-panel__actions"});if(this.options.mode!=="live"){let i=l("button",{ref:"apply",class:"zx-btn zx-filter-panel__apply",type:"button",dataset:{kind:"primary",size:"md"}},l("span",{class:"zx-btn__label"},this._message("filterPanel.apply","Apply")));this.listen(i,"click",()=>this.apply()),t.append(i)}let e=l("button",{ref:"clear",class:"zx-btn zx-filter-panel__clear",type:"button",dataset:{kind:"ghost",size:"md"}},l("span",{class:"zx-btn__label"},this._message("filterPanel.clear","Clear all")));return this.listen(e,"click",()=>this.clear()),t.append(e),t}_buildField(t,e,i){let n=String(e.label??t),r=l("div",{class:"zx-filter-panel__field",dataset:{field:t,type:String(e.type??"")}});return i?(i.kind==="select"?r.append(this._buildSelect(t,e,n)):i.kind==="text"?r.append(...this._buildText(t,e,n)):i.kind==="date"?r.append(...this._buildDate(t,e,n,i)):r.append(...this._buildNumber(t,e,n,i)),r):(r.setAttribute("data-state","unsupported"),r.append(l("span",{class:"zx-filter-panel__label"},n),l("p",{class:"zx-filter-panel__unsupported",role:"note"},this._message("filterPanel.unsupported","Unsupported filter type: %1",String(e.type??"")))),r)}_buildSelect(t,e,i){let n=du(e.options),r=this._draft[t]??[],o=new ot(null,{items:n.map(a=>({...a,on:r.some(c=>fu(c,a.value))})),valueKey:"value",labelKey:"label",search:typeof e.search=="boolean"?e.search:n.length>hy,height:220,msg:{"checklist.label":i}});return o.on("change",()=>this._edited(t,o.getValues())),this._isolate(o),this._children.push(o),this._entries.push({key:t,write:a=>o.setValues(a??[])}),o.toElement()}_buildText(t,e,i){let n=x("zx-filter-panel-text"),r=l("input",{id:n,class:"zx-filter-panel__input",type:"search",autocomplete:"off",placeholder:String(e.placeholder??""),value:String(this._draft[t]??"")});return this.listen(r,"input",()=>this._edited(t,r.value)),this._entries.push({key:t,write:o=>{r.value=o==null?"":String(o)}}),[l("label",{class:"zx-filter-panel__label",for:n},i),r]}_buildDate(t,e,i,n){if(!n.range){let h=x("zx-filter-panel-date"),u=this._dateInput(String(this._draft[t]??""),{id:h});return this.listen(u,"change",()=>this._edited(t,u.value)),this._entries.push({key:t,write:d=>{u.value=d==null?"":String(d)}}),[l("label",{class:"zx-filter-panel__label",for:h},i),u]}let r=x("zx-filter-panel-label"),o=this._draft[t]??{},a={},c=["from","to"].map(h=>{let u=x("zx-filter-panel-date"),d=this._dateInput(String(o[h]??""),{id:u,ariaLabel:this._edgeName(i,h)});return a[h]=d,this.listen(d,"change",()=>this._editedEdge(t,h,d.value)),l("div",{class:"zx-filter-panel__edge"},l("label",{class:"zx-filter-panel__edge-label",for:u},this._edgeLabel(h)),d)});return this._entries.push({key:t,write:h=>{let u=h??{};for(let d of["from","to"])a[d].value=u[d]==null?"":String(u[d])}}),[l("span",{class:"zx-filter-panel__label",id:r},i),l("div",{class:"zx-filter-panel__range",role:"group",ariaLabelledby:r},c)]}_dateInput(t,e){return l("input",{class:"zx-filter-panel__input",type:"date",autocomplete:"off",value:t,...e})}_buildNumber(t,e,i,n){let r=x("zx-filter-panel-label");if(!n.range){let h=this._numberField(e,n,i,this._draft[t]??null);return h.on("change",()=>this._edited(t,h.get())),this._entries.push({key:t,write:u=>h.set(u??null,{silent:!0})}),[l("span",{class:"zx-filter-panel__label",id:r},i),h.toElement()]}let o=this._draft[t]??{},a={},c=["from","to"].map(h=>{let u=this._numberField(e,n,this._edgeName(i,h),o[h]??null);return a[h]=u,u.on("change",()=>this._editedEdge(t,h,u.get())),l("div",{class:"zx-filter-panel__edge"},l("span",{class:"zx-filter-panel__edge-label"},this._edgeLabel(h)),u.toElement())});return this._entries.push({key:t,write:h=>{let u=h??{};for(let d of["from","to"])a[d].set(u[d]??null,{silent:!0})}}),[l("span",{class:"zx-filter-panel__label",id:r},i),l("div",{class:"zx-filter-panel__range",role:"group",ariaLabelledby:r},c)]}_numberField(t,e,i,n){let r=Number.isFinite(Number(t.step))&&Number(t.step)>0?Number(t.step):e.integer?1:dy,o=new Et(null,{value:n,min:t.min==null?null:Number(t.min),max:t.max==null?null:Number(t.max),step:r,precision:e.integer?0:null,placeholder:String(t.placeholder??""),label:i});return this._isolate(o),this._children.push(o),o}_edgeLabel(t){return t==="from"?this._message("filterPanel.from","From"):this._message("filterPanel.to","To")}_edgeName(t,e){return e==="from"?this._message("filterPanel.rangeFrom","%1 from",t):this._message("filterPanel.rangeTo","%1 to",t)}_edited(t,e){this._writing||(this._draft[t]=e,this._afterEdit(t))}_editedEdge(t,e,i){if(this._writing)return;let n=this._draft[t],r=n!==null&&typeof n=="object"&&!Array.isArray(n)?{...n}:{};r[e]=i,this._draft[t]=r,this._afterEdit(t)}_afterEdit(t){let e=this._draftValue();this._syncActions(e),this.emit("change",{value:e,field:t}),this.options.mode==="live"&&this.apply()}_isolate(t){for(let e of["zx-change","zx-input"])this.listen(t.el,e,i=>i.stopPropagation())}_replaceDraft(t,{commit:e=!1}={}){this._draft=t,this._writeControls();let i=this._draftValue(),n=e||this.options.mode==="live";return n&&this._commit(i),this._syncActions(i),this.emit("change",{value:i,field:null}),n&&this.emit("apply",{value:this.getValue()}),this}_commit(t){this._applied=t,this._appliedDraft=Eo(this._draft)}_draftValue(){return Mo(this._draft,this.options.fields,this.options.serialize)}_writeControls(){this._writing=!0;try{for(let t of this._entries)t.write(this._draft[t.key])}finally{this._writing=!1}}_syncActions(t=this._draftValue()){let e=Object.keys(t).length>0,i=this.refs.clear;if(i&&(i.disabled=!e),this.options.mode==="live"||this._fields.length===0)return;Eo(this._draft)!==this._appliedDraft?this.el.setAttribute("data-state","dirty"):this.el.removeAttribute("data-state")}_message(t,e,...i){let n=this.msg(t,...i);return n===t?I(e,i):n}};function No(s){switch(String(s??"").trim().toLowerCase()){case"text":return{kind:"text",range:!1,integer:!1};case"select":return{kind:"select",range:!1,integer:!1};case"date":return{kind:"date",range:!1,integer:!1};case"date:range":return{kind:"date",range:!0,integer:!1};case"int":return{kind:"number",range:!1,integer:!0};case"float":case"number":return{kind:"number",range:!1,integer:!1};case"int:range":return{kind:"number",range:!0,integer:!0};case"float:range":case"number:range":return{kind:"number",range:!0,integer:!1};default:return null}}function me(s){return s==null?!1:s instanceof Date?!Number.isNaN(s.getTime()):Array.isArray(s)?s.some(t=>me(t)):typeof s=="string"?s.trim()!=="":typeof s=="number"?Number.isFinite(s):typeof s=="boolean"?s:typeof s=="object"?Object.values(s).some(t=>me(t)):!0}function fy(s){let t={};if(!Oe(s))return t;for(let[e,i]of Object.entries(s)){if(Oe(i)){let n={};for(let[r,o]of Object.entries(i))me(o)&&(n[r]=o);Object.keys(n).length>0&&(t[e]=n);continue}me(i)&&(t[e]=i)}return t}function Ri(s){if(s==null||s==="")return"";if(s instanceof Date)return Number.isNaN(s.getTime())?"":Io(s);if(typeof s=="number")return Number.isFinite(s)?Io(new Date(Math.abs(s)<uy?s*1e3:s)):"";let t=String(s).trim();if(/^\d{4}-\d{2}-\d{2}$/.test(t))return t;if(/^-?\d+(\.\d+)?$/.test(t))return Ri(Number(t));let e=new Date(t);return Number.isNaN(e.getTime())?"":Io(e)}function Co(s,t,e="seconds"){let i=Ri(s);if(!i)return null;let[n,r,o]=i.split("-").map(Number),a=t==="to"?new Date(n,r-1,o,23,59,59,999):new Date(n,r-1,o,0,0,0,0);return typeof e=="function"?e(a,t):e==="ms"?a.getTime():e==="iso"?a.toISOString():Math.floor(a.getTime()/1e3)}function du(s){if(!Array.isArray(s))return[];let t=[];for(let e of s){if(e!==null&&typeof e=="object"){let i=e,n="value"in i?i.value:i.ID;if(n===void 0)continue;let r=i.label??i.name??i.title;t.push({value:n,label:r==null?String(n):String(r)});continue}e!==void 0&&t.push({value:e,label:String(e)})}return t}function Li(s,t){let e=Oe(s)?s:{},i={};for(let[n,r]of Object.entries(t??{})){let o=r??{},a=No(o.type);if(!a)continue;let c=e[n];a.kind==="text"?i[n]=c==null?"":String(c).trim():a.kind==="select"?i[n]=_y(c,du(o.options)):a.kind==="date"?i[n]=a.range?{from:Ri(Js(c,"from")),to:Ri(Js(c,"to"))}:Ri(c):i[n]=a.range?{from:To(Js(c,"from"),a),to:To(Js(c,"to"),a)}:To(c,a)}return i}function Mo(s,t,e="seconds"){let i=Li(s,t),n={};for(let[r,o]of Object.entries(t??{})){let a=No((o??{}).type);if(!a)continue;let c=i[r];if(a.kind==="text"){c!==""&&(n[r]=c);continue}if(a.kind==="select"){let d=c;d.length>0&&(n[r]=d.slice());continue}if(a.kind==="date"){if(!a.range){c&&(n[r]=Co(c,"from",e));continue}let d=c,p={};d.from&&(p.from=Co(d.from,"from",e)),d.to&&(p.to=Co(d.to,"to",e)),Object.keys(p).length>0&&(n[r]=p);continue}if(!a.range){c!==null&&(n[r]=c);continue}let h=c,u={};h.from!==null&&(u.from=h.from),h.to!==null&&(u.to=h.to),Object.keys(u).length>0&&(n[r]=u)}return n}function py(s,t){let e=Oe(s)?s:{},i=Object.keys(e),n=Array.isArray(t)?t.filter(o=>i.includes(o)):[],r=new Set(n);return[...n,...i.filter(o=>!r.has(o))].map(o=>({key:o,field:e[o]??{},spec:No(e[o]?.type)}))}function _y(s,t){let e=Array.isArray(s)?s:me(s)?[s]:[];return t.length===0?e.filter(i=>me(i)):t.filter(i=>e.some(n=>fu(n,i.value))).map(i=>i.value)}function Js(s,t){return s==null?null:Array.isArray(s)?(t==="from"?s[0]:s[1])??null:Oe(s)?t in s?s[t]:null:t==="from"?s:null}function To(s,t){let e=xe(s);return e===null?null:t.integer?Math.trunc(e):e}function Io(s){let t=String(s.getMonth()+1).padStart(2,"0"),e=String(s.getDate()).padStart(2,"0");return`${s.getFullYear()}-${t}-${e}`}function Oe(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)}function fu(s,t){return Object.is(s,t)?!0:s==null||t===null||t===void 0?!1:String(s)===String(t)}function my(s){let t={};for(let[e,i]of Object.entries(s))Array.isArray(i)?t[e]=i.slice():Oe(i)?t[e]={...i}:t[e]=i;return t}function Eo(s){return JSON.stringify(Object.keys(s).sort().map(t=>[t,s[t]]))}var Oo=class extends m{static cssName="sort-control";static defaults={fields:[],value:null,label:"Sort by",labels:{},disabled:!1};render(){let t=this.el??l("div");return this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(t),this.el=t,this._value=pu(this.options.value,this.options.fields),this._disabled=!!(this.options.disabled||!this.options.fields.length),this._direction=j({kind:"ghost",disabled:this._disabled}),this._direction.classList.add("zx-sort-control__direction"),this.listen(this._direction,"click",()=>{this._disabled||!this._value||this.setValue({id:this._value.id,dir:this._value.dir==="asc"?"desc":"asc"})}),this._select=new $(null,{items:gy(this.options.fields),valueKey:"id",labelKey:"label",value:this._value?.id??null,label:this.options.label,filter:"local",disabled:this._disabled,onchange:({detail:e})=>{e.item&&this.setValue({id:e.item.id,dir:this._value?.dir??"asc"})}}),this.listen(this._select.el,"zx-change",e=>e.stopPropagation()),t.replaceChildren(this._direction,this._select.el),this._syncDirection(),t}getValue(){return this._value?{...this._value}:null}setValue(t,{silent:e=!1}={}){let i=pu(t,this.options.fields),n=_u(i)!==_u(this._value);return this._value=i,this._select.set(i?.id??null,{silent:!0}),this._syncDirection(),n&&!e&&this.emit("change",{value:this.getValue()}),this}enable(){return this._disabled=!this.options.fields.length,this._disabled||this._select.enable(),this._direction.disabled=this._disabled,this}disable(){return this._disabled=!0,this._select.disable(),this._direction.disabled=!0,this}_syncDirection(){let t=this._value?.dir??"asc",e=t==="asc"?"desc":"asc",i={asc:"Ascending",desc:"Descending",...this.options.labels};this._direction.replaceChildren(g(t==="asc"?"arrow-up-wide-short":"arrow-down-wide-short")),this._direction.dataset.direction=t,this._direction.setAttribute("aria-label",`${this.options.label}: ${i[t]}`),this._direction.title=`${i[t]} \u2192 ${i[e]}`}focus(){return this._select.focus(),this}destroy(){this._select?.destroy(),super.destroy(),this._createdRoot||S(this.el,this._snapshot)}};function pu(s,t){if(!t.length)return null;if(s==null)return{id:String(t[0].id),dir:"asc"};if(!t.some(e=>String(e.id)===String(s.id)))throw new RangeError("Unknown sort field");if(s.dir!=="asc"&&s.dir!=="desc")throw new RangeError("Unknown sort direction");return{id:String(s.id),dir:s.dir}}function gy(s){return s.map(t=>({id:String(t.id),label:t.label}))}function _u(s){return s?JSON.stringify([s.id,s.dir]):""}var mu=Object.freeze({auto:{icon:null,key:"listToolbar.viewAuto",fallback:"Auto"},cards:{icon:"copy",key:"listToolbar.viewCards",fallback:"Cards"},table:{icon:"list",key:"listToolbar.viewTable",fallback:"Table"},list:{icon:"list",key:"listToolbar.viewList",fallback:"List"}}),Fo=class extends m{static cssName="list-toolbar";static defaults={search:{},count:null,countText:null,views:[],view:null,tools:[],label:null};constructor(t=null,e={}){super(t,e),this.refs.tools&&this.listen(this.refs.tools,"click",i=>this._toolClick(i)),this.refs.views&&this.listen(this.refs.views,"click",i=>this._viewClick(i)),this.on("viewchange",i=>{let n=this._bound,r=n?.capabilities.setShape;r&&n.view[r](i.detail.view)})}render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._tools=new Map,this._views=xy(this.options.views),this._view=gu(this._views,this.options.view,null),this._count=null,this._search=null,this._bound=null,this._adopted=[],this._chooser=null;let t=this.el??l("div");this.el=t,t.setAttribute("role","group"),t.setAttribute("aria-label",this.options.label??this._message("listToolbar.label","List controls"));let e=[],i=this._searchOptions();if(i){this._search=new ne(null,i);let n=this._search.toElement();n.classList.add("zx-list-toolbar__search"),this._search.on("input",r=>this.emit("search",{value:wu(r)})),this._search.on("submit",r=>this.emit("search",{value:wu(r)})),e.push(n)}return e.push(l("span",{class:"zx-list-toolbar__count",ref:"count",role:"status",ariaLive:"polite",ariaAtomic:"true"})),e.push(l("span",{class:"zx-list-toolbar__spacer"})),e.push(l("div",{class:"zx-list-toolbar__tools",ref:"tools"})),this._views.length>0&&e.push(l("div",{class:"zx-list-toolbar__views",ref:"views",role:"group",ariaLabel:this._message("listToolbar.views","View")})),t.replaceChildren(...e),this.setTools(this.options.tools),this._syncViews(),this.setCount(this.options.count),t}setCount(t){return this._count=vu(t),this.refs.count.textContent=vy(t,this._countFormat()),this}getCount(){return this._count}setBadge(t,e){let i=this._tools.get(String(t));return i?(i.badge=xu(e),this._syncTool(i),this):this}setPressed(t,e=!0){let i=this._tools.get(String(t));return i?.toggle?(i.pressed=!!e,i.element.setAttribute("aria-pressed",i.pressed?"true":"false"),this):this}setToolDisabled(t,e=!0){let i=this._tools.get(String(t));return i&&(i.element.disabled=!!e),this}setTools(t){for(let i of this._tools.values())i.element.remove();this._tools=new Map;let e=[];for(let i of wy(t)){let n=this._createTool(i);this._tools.set(n.id,n),e.push(n.element)}return this.refs.tools.prepend(...e),this}getTool(t){return this._tools.get(String(t))?.element??null}getToolsElement(){return this.refs.tools}addTool(t){if(!T(t))throw new TypeError("ListToolbar.addTool() needs an Element");return this.refs.tools.contains(t)?this:(this._adopted.push(bu(t)),this.refs.tools.append(t),this)}setView(t,{silent:e=!1}={}){let i=gu(this._views,t,this._view);if(i===null||i===this._view)return this;let n=this._view;return this._view=i,this._syncViews(),e||this.emit("viewchange",{view:i,previous:n}),this}getView(){return this._view}getSearch(){return this._search?this._search.get():""}setSearch(t,e={}){return this._search?.set(t,e),this}focusSearch(){return this._search?.focus(),this}bind(t){if(t===null||typeof t!="object")throw new TypeError("ListToolbar.bind() needs a record view");this.unbind();let e=by(t);if(this._bound={view:t,capabilities:e},e.getShape){let i=t[e.getShape]();i!=null&&this.setView(String(i),{silent:!0})}return this._mountFieldControls(t),this}unbind(){return this._bound=null,this._chooser&&(yu(this._chooser,this.el),this._chooser=null),this}destroy(){if(this._destroyed)return;this._destroyed=!0,this.unbind();for(let e of this._adopted.reverse())yu(e,this.el);this._adopted=[],this._search?.destroy(),this._search=null;let t=this.el;super.destroy(),this._createdRoot||S(t,this._snapshot)}_searchOptions(){let t=this.options.search;if(t===!1||t===null)return null;let e=t===!0||t===void 0?{}:t;if(typeof e!="object"||Array.isArray(e))throw new TypeError("ListToolbar search must be an options object or false");return{...e,placeholder:String(e.placeholder??this._message("listToolbar.search","Search"))}}_countFormat(){let t=this.options.countText;return typeof t=="function"?e=>String(t(e)):e=>this._message("listToolbar.results","%1 results",e.toLocaleString())}_createTool(t){let e=l("button",{class:"zx-list-toolbar__tool",type:"button",disabled:t.disabled,dataset:{toolId:t.id},ariaPressed:t.pressed===null?null:String(t.pressed)});t.icon&&e.append(g(t.icon,{size:16})),t.label!==""&&e.append(l("span",{class:"zx-list-toolbar__tool-label"},t.label));let i={id:t.id,element:e,label:t.label||t.title||t.id,title:t.title,badge:t.badge,badgeKind:t.badgeKind,badgeEl:null,toggle:t.pressed!==null,pressed:!!t.pressed,onclick:t.onclick};return this._syncTool(i),i}_syncTool(t){if(t.badgeEl?.remove(),t.badgeEl=null,t.badge!==null){let i=pt({label:t.badge,kind:t.badgeKind,size:"sm"});i.classList.add("zx-list-toolbar__badge"),i.setAttribute("aria-hidden","true"),t.badgeEl=i,t.element.append(i)}let e=yy(t.label,t.badge,this._message("listToolbar.toolBadge","%1 (%2)"));t.element.setAttribute("aria-label",e),t.element.setAttribute("title",t.title??e)}_toolClick(t){let i=t.target?.closest?.("[data-tool-id]");if(!i||!this.refs.tools.contains(i))return;let n=this._tools.get(String(i.dataset.toolId));n&&(n.toggle&&this.setPressed(n.id,!n.pressed),this.emit("action",{id:n.id,pressed:n.toggle?n.pressed:null,tool:n.element}),n.onclick?.(t))}_viewClick(t){let i=t.target?.closest?.("[data-view]");!i||!this.refs.views.contains(i)||this.setView(String(i.dataset.view))}_syncViews(){if(!this.refs.views)return;let t=this.refs.views;t.childElementCount!==this._views.length&&t.replaceChildren(...this._views.map(e=>{let i=e.label??this._viewLabel(e.id),n=l("button",{class:"zx-list-toolbar__view",type:"button",title:i,dataset:{view:e.id}}),r=e.icon===void 0?mu[e.id]?.icon??null:e.icon;return r&&n.append(g(r,{size:16})),n.append(l("span",{class:"zx-list-toolbar__view-label"},i)),n}));for(let e of t.children){let i=e.dataset.view===this._view;e.setAttribute("aria-pressed",i?"true":"false")}}_viewLabel(t){let e=mu[t];return e?this._message(e.key,e.fallback):t}_mountFieldControls(t){if(t.options?.fieldControls===!1)return;let e=this._findFieldControls(t);!e||this.el.contains(e)||(this._chooser=bu(e),this.refs.tools.append(e))}_findFieldControls(t){if(typeof t.getFieldControls=="function"){let i=t.getFieldControls();if(T(i))return i}if(T(t._viewFieldControls))return t._viewFieldControls;let e=typeof t.toElement=="function"?t.toElement():null;return T(e)?e.querySelector(".zx-record-view__field-controls"):null}_message(t,e,...i){let n=this.msg(t,...i);return n===t?I(e,i):n}};function by(s){let t=s,e=n=>!!t&&typeof t[n]=="function",i=(...n)=>n.find(e)??null;return{isRecordView:e("setViewState")&&e("getViewState")&&e("on")&&e("toElement"),setShape:i("setView","setViewShape"),getShape:i("getView","getViewShape"),events:e("on")&&e("emit"),fieldControls:e("getFieldControls")}}function xu(s){return s==null||s===!1||s===""?null:String(s)}function yy(s,t,e="%1 (%2)"){let i=String(s??"");return t==null||t===""?i:I(e,[i,String(t)])}function wy(s){if(s!=null&&!Array.isArray(s))throw new TypeError("ListToolbar tools must be an array");let t=new Set,e=[];for(let i of s??[]){if(i==null)continue;if(typeof i!="object"||Array.isArray(i))throw new TypeError("ListToolbar tools must be tool descriptors");let n=String(i.id??"").trim();if(!n)throw new TypeError("Every ListToolbar tool needs an id");if(t.has(n))throw new TypeError(`Duplicate ListToolbar tool: ${n}`);t.add(n),e.push({id:n,label:String(i.label??""),icon:i.icon??null,badge:xu(i.badge),badgeKind:String(i.badgeKind??"accent"),pressed:i.pressed===void 0?null:!!i.pressed,disabled:!!i.disabled,title:i.title===void 0?null:String(i.title),onclick:typeof i.onclick=="function"?i.onclick:null})}return e}function xy(s){if(s!=null&&!Array.isArray(s))throw new TypeError("ListToolbar views must be an array");let t=new Set,e=[];for(let i of s??[]){if(i==null)continue;let n=typeof i=="object"?i:{id:i},r=String(n.id??"").trim();if(!r||t.has(r))continue;t.add(r);let o={id:r};n.label!==void 0&&(o.label=String(n.label)),n.icon!==void 0&&(o.icon=n.icon),e.push(o)}return e}function gu(s,t,e){let i=s.map(n=>n.id);return i.length===0?null:t!=null&&i.includes(String(t))?String(t):e===null?i[0]:i.includes(e)?e:i[0]}function vy(s,t){let e=vu(s);return e===null?"":String(t(e))}function vu(s){if(s==null||s===""||typeof s=="boolean")return null;let t=Number(s);return Number.isFinite(t)?t:null}function bu(s){return{element:s,parent:s.parentNode,next:s.nextSibling}}function yu(s,t){let{element:e,parent:i,next:n}=s;if(t?.contains(e)){if(!i){e.remove();return}n&&n.parentNode===i?i.insertBefore(e,n):i.appendChild(e)}}function wu(s){return String(s.detail?.value??"")}var en=Object.freeze([R("contains","contains","single",["text"]),R("notContains","does not contain","single",["text"]),R("eq","is","single",["text","number","money","boolean","enum","status","priority","country","currency","unit","entity","date","datetime"]),R("neq","is not","single",["text","number","money","boolean","enum","status","priority","country","currency","unit","entity","date","datetime"]),R("startsWith","starts with","single",["text"]),R("endsWith","ends with","single",["text"]),R("lt","is less than","single",["number","money"]),R("lte","is at most","single",["number","money"]),R("gt","is greater than","single",["number","money"]),R("gte","is at least","single",["number","money"]),R("on","is on","single",["date","datetime"]),R("notOn","is not on","single",["date","datetime"]),R("before","is before","single",["date","datetime"]),R("onOrBefore","is on or before","single",["date","datetime"]),R("after","is after","single",["date","datetime"]),R("onOrAfter","is on or after","single",["date","datetime"]),R("between","is between","pair",["number","money","date","datetime"]),R("notBetween","is not between","pair",["number","money","date","datetime"]),R("withinLast","is within the last","pair",["date","datetime"]),R("withinNext","is within the next","pair",["date","datetime"]),R("anyOf","is any of","many",["enum","status","priority","country","currency","unit","entity"]),R("noneOf","is none of","many",["enum","status","priority","country","currency","unit","entity"]),R("containsAny","contains any","many",["tags"]),R("containsAll","contains all","many",["tags"]),R("containsNone","contains none","many",["tags"]),R("isEmpty","is empty","none",["text","number","money","date","datetime","boolean","enum","status","priority","country","currency","unit","entity","tags"]),R("isNotEmpty","is not empty","none",["text","number","money","date","datetime","boolean","enum","status","priority","country","currency","unit","entity","tags"])]);function Ro(){return{version:1,root:{kind:"group",id:x("filter-root"),logic:"and",children:[]}}}function Vo(s={}){return{kind:"condition",id:String(s.id||x("filter-condition")),field:String(s.field??""),operator:String(s.operator??""),value:Po(s.value??null)}}function Po(s){return tn(s)}function Bo(s="and",t=[]){return{kind:"group",id:x("filter-group"),logic:s,children:t}}function Fe(s,t={}){let e=Su(t.maxDepth,3),i=Su(t.maxConditions,50);if(!Zs(s)||s.version!==1||!Zs(s.root))throw new TypeError("Filter AST must have version 1 and a root group");let n=new Set,r=0,o=(c,h,u=!1)=>{if(!Zs(c))throw new TypeError("Filter nodes must be plain objects");let d=String(c.id??"").trim();if(!d||n.has(d))throw new TypeError("Filter node IDs must be non-empty and unique");if(n.add(d),c.kind==="group"){if(h>e)throw new RangeError("Filter group depth exceeds maxDepth");if(c.logic!=="and"&&c.logic!=="or")throw new TypeError("Filter group logic must be and or or");if(!Array.isArray(c.children))throw new TypeError("Filter group children must be an array");return{kind:"group",id:d,logic:c.logic,children:c.children.map(p=>o(p,h+1,!1))}}if(u||c.kind!=="condition")throw new TypeError("Filter root must be a group");if(r+=1,r>i)throw new RangeError("Filter condition count exceeds maxConditions");return{kind:"condition",id:d,field:String(c.field??""),operator:String(c.operator??""),value:tn(c.value)}},a=o(s.root,0,!0);if(a.kind!=="group")throw new TypeError("Filter root must be a group");return{version:1,root:a}}function sn(s){return Fe(s,{maxDepth:1/0,maxConditions:1/0})}function Sy(s){return JSON.stringify(sn(s))}function jo(s,t,e=en){let i=[],n=new Map((Array.isArray(t)?t:[]).map(a=>[String(a.id),a])),r=new Map((Array.isArray(e)?e:[]).map(a=>[String(a.id),a])),o=(a,c=!1)=>{if(a.kind==="group"){!c&&a.children.length===0&&i.push(Vi(a.id,"empty-group","Nested groups need at least one condition")),a.children.forEach(d=>o(d));return}let h=n.get(a.field);h||i.push(Vi(a.id,"unknown-field",a.field?`Unavailable field: ${a.field}`:"Choose a field"));let u=r.get(a.operator);if(!u){i.push(Vi(a.id,"unknown-operator",a.operator?`Unavailable operator: ${a.operator}`:"Choose an operator"));return}h&&(!(Array.isArray(h.operators)&&h.operators.length?h.operators:e.filter(p=>p.types.includes(h.type)).map(p=>p.id)).includes(u.id)||!u.types.includes(h.type))&&i.push(Vi(a.id,"operator-type",`${u.label} is not available for ${h.label}`)),Ay(u.arity,a.value)||i.push(Vi(a.id,"value",u.arity==="pair"?"Enter both values":u.arity==="many"?"Choose at least one value":u.arity==="none"?"This operator does not accept a value":"Enter a value"))};return o(s.root,!0),{valid:i.length===0,errors:i}}function R(s,t,e,i){return Object.freeze({id:s,label:t,arity:e,types:Object.freeze(i)})}function Vi(s,t,e){return{nodeId:s,code:t,message:e}}function Ay(s,t){return s==="none"?t===null:s==="pair"?Array.isArray(t)&&t.length===2&&t.every(Lo):s==="many"?Array.isArray(t)&&t.length>0&&t.every(Lo):Lo(t)}function Lo(s){return s!=null&&!(typeof s=="string"&&s.trim()==="")}function tn(s,t=new WeakSet){if(s===null||typeof s=="string"||typeof s=="boolean")return s;if(typeof s=="number"){if(!Number.isFinite(s))throw new TypeError("Filter values cannot contain non-finite numbers");return s}if(typeof s!="object"||s instanceof Date||typeof s.nodeType=="number")throw new TypeError("Filter values must be JSON-safe");if(t.has(s))throw new TypeError("Filter values cannot contain cycles");if(t.add(s),Array.isArray(s)){let i=s.map(n=>tn(n,t));return t.delete(s),i}if(!Zs(s))throw new TypeError("Filter values must be plain JSON objects");let e={};for(let[i,n]of Object.entries(s))Object.defineProperty(e,i,{value:tn(n,t),enumerable:!0,configurable:!0,writable:!0});return t.delete(s),e}function Zs(s){if(!s||typeof s!="object"||Array.isArray(s))return!1;let t=Object.getPrototypeOf(s);return t===Object.prototype||t===null}function Su(s,t){if(s===1/0)return 1/0;let e=Number(s);return Number.isFinite(e)&&e>=0?Math.floor(e):t}var Cu=Object.freeze({choose:"Choose\u2026",yes:"True",no:"False",commaSeparated:"Comma-separated values",value:s=>`${s} value`,valueAt:(s,t)=>`${s} value ${t}`}),qo=class extends m{static cssName="filter";static defaults={fields:[],value:null,operators:[],allowGroups:!0,maxDepth:3,maxConditions:50,autoApply:!1,readonly:!1,disabled:!1,searchable:!1,layout:"standard",rootLogic:null,showApply:!0,showRootActions:!0,applyLabel:null,clearLabel:null};render(){this._createdRoot=this.el===null;let t=this.el??l("div");return this.el=t,this._snapshot=this._createdRoot?null:A(t),this._fields=(Array.isArray(this.options.fields)?this.options.fields:[]).map(e=>({...e})),this._operators=zy(en,this.options.operators),this._readonly=!!this.options.readonly,this._disabled=!!this.options.disabled,this._async=new Map,this._customEditors=[],this._selectEditors=[],this._disposed=!1,t.dataset.layout=this.options.layout==="compact"?"compact":"standard",this._value=this.options.value==null?Ro():Fe(this.options.value,this._limits()),this.listen(t,"change",e=>this._handleChange(e)),this.listen(t,"input",e=>this._handleInput(e)),this.listen(t,"click",e=>this._handleClick(e)),this._render(),t}getValue(){return sn(this._value)}setValue(t,{silent:e=!1}={}){let i=Fe(t,this._limits());return this._abortAll(),this._value=i,this._render(),e||this._changed("set",this._value.root.id),this}addCondition(t=null,e={}){if(!this._canMutate()||Iu(this._value.root)>=Number(this.options.maxConditions))return null;let i=Ho(this._value.root,t??this._value.root.id);if(!i)return null;let n=this._fields[0],r=String(e.field??n?.id??""),o=this._field(r),a=Vo({...e,field:r,operator:String(e.operator??this._defaultOperator(o)??"")});return i.children.push(a),this._render(),this._changed("add",a.id),this.focus(a.id),a.id}addGroup(t=null,e="and"){if(!this._canMutate()||!this.options.allowGroups)return null;let i=Ho(this._value.root,t??this._value.root.id);if(!i||Eu(this._value.root,i.id)>=Number(this.options.maxDepth))return null;let n=Bo(e==="or"?"or":"and");return i.children.push(n),this._render(),this._changed("add",n.id),this.focus(n.id),n.id}update(t,e={}){if(!this._canMutate())return this;let i=wt(this._value.root,t);return i?(i.kind==="group"?(e.logic==="and"||e.logic==="or")&&(i.logic=e.logic):(Object.hasOwn(e,"field")&&(i.field=String(e.field??"")),Object.hasOwn(e,"operator")&&(i.operator=String(e.operator??"")),Object.hasOwn(e,"value")&&(i.value=zu(e.value))),this._abort(t),this._render(),this._changed("update",t),this):this}remove(t){if(!this._canMutate()||t===this._value.root.id)return this;let e=$o(this._value.root,t);if(!e)return this;let i=e.children.findIndex(a=>a.id===t),n=e.children[i+1]?.id??e.children[i-1]?.id??e.id,r=Tu(this._value.root,t);if(!r)return this;this._abortTree(r),this._render();let o=r.kind==="condition"?this._field(r.field)?.label??this._message("filter.conditionNoun","Filter"):this._message("filter.groupNoun","Filter group");return this._announce(this._message("filter.removed","%1 removed",o)),this._changed("remove",t),this.focus(n),this}move(t,e,i){let n=wt(this._value.root,t),r=Ho(this._value.root,e),o=$o(this._value.root,t);if(!this._canMutate()||t===this._value.root.id||!n||!r||!o||ky(n,e))return this;let a=o.children.findIndex(h=>h.id===t),c=o.children.splice(a,1)[0];r.children.splice(Math.max(0,Math.min(r.children.length,Number(i)||0)),0,c);try{Fe(this._value,this._limits())}catch{return r.children.splice(r.children.indexOf(c),1),o.children.splice(a,0,c),this}return this._render(),this._changed("move",t),this}validate(){let t=jo(this._value,this._fields,this._operators),e=Cy(this._value,this.options.rootLogic);return e&&(t.valid=!1,t.errors.push(e)),t}apply(){if(this._disabled)return null;let t=this.validate();if(!t.valid)return this.emit("invalid",{errors:t.errors}),this.focus(t.errors[0]?.nodeId),null;let e=this.getValue();return this.emit("apply",{value:e}),e}clear({silent:t=!1}={}){return this._canMutate()?(this._abortAll(),this._value.root.children=[],this._render(),t||this._changed("clear",this._value.root.id),this.refs.add?.focus(),this):this}focus(t=null){let e=t?`[data-node-id="${Jt(t)}"] :is([data-filter-field], [data-filter-focus="field"], [data-filter-logic], [data-filter-action="add"])`:'[data-filter-action="add"]';return queueMicrotask(()=>{if(this._disposed)return;(this.el.querySelector(e)??this.refs.add)?.focus()}),this}setReadonly(t){return this._readonly=!!t,this._render(),this}enable(){return this._disabled=!1,this._render(),this}disable(){return this._disabled=!0,this._abortAll(),this._render(),this}destroy(){this._disposed=!0,this._renderVersion+=1,this._abortAll(),this._destroyEditors();let t=this.el,e=this._snapshot;super.destroy(),!this._createdRoot&&t&&S(t,e)}_render(){this._destroyEditors(),this._renderVersion=(this._renderVersion??0)+1;let t=l("div",{ref:"status",class:"zx-filter__status",role:"status",ariaLive:"polite"}),e=this._renderGroup(this._value.root,0,!0),i=l("div",{class:"zx-filter__actions"},Xt("add",this._value.root.id,"plus",this._message("filter.addFilter","Add filter"),{ref:"add",disabled:this._blocked()}),this.options.allowGroups?Xt("add-group",this._value.root.id,"folder",this._message("filter.addGroup","Add group"),{disabled:this._blocked()}):null,Xt("clear","","x",String(this.options.clearLabel??this._message("filter.clear","Clear")),{disabled:this._blocked()}),this.options.showApply?Xt("apply","","check",String(this.options.applyLabel??this._message("filter.apply","Apply filters")),{class:"zx-button--primary",disabled:this._disabled}):null);this.el.replaceChildren(t,e,i),this.refs.status=t,this.refs.add=this.el.querySelector('[data-filter-action="add"]'),this.el.toggleAttribute("data-readonly",this._readonly),this.el.toggleAttribute("data-disabled",this._disabled);let n=this.validate();this.el.dataset.valid=String(n.valid);for(let r of n.errors)this.el.querySelector(`[data-node-id="${Jt(r.nodeId)}"]`)?.setAttribute("data-invalid","")}_renderGroup(t,e,i){let n=l("ol",{class:"zx-filter__children"},t.children.map(c=>c.kind==="group"?this._renderGroup(c,e+1,!1):this._renderCondition(c))),r=l("select",{class:"zx-filter__logic",dataset:{filterLogic:"",nodeId:t.id},ariaLabel:i?this._message("filter.rootLogic","Root filter logic"):this._message("filter.groupLogic","Group filter logic"),disabled:this._blocked()},l("option",{value:"and",selected:t.logic==="and"},this._message("filter.matchAll","Match all")),l("option",{value:"or",selected:t.logic==="or"},this._message("filter.matchAny","Match any"))),o=l("legend",{class:"zx-filter__legend"},i&&this.options.rootLogic?t.logic==="or"?this._message("filter.matchAnyConditions","Match any conditions"):this._message("filter.matchAllConditions","Match all conditions"):[r,l("span",{},i?this._message("filter.conditions","conditions"):this._message("filter.inThisGroup","in this group"))]),a=l("div",{class:"zx-filter__group-actions"},Xt("add",t.id,"plus",this._message("filter.addFilter","Add filter"),{disabled:this._blocked()}),this.options.allowGroups&&e<Number(this.options.maxDepth)?Xt("add-group",t.id,"folder",this._message("filter.addSubgroup","Add subgroup"),{disabled:this._blocked()}):null,i?null:Xt("remove",t.id,"trash",this._message("filter.removeGroup","Remove group"),{disabled:this._blocked()}));return l(i?"fieldset":"li",{class:"zx-filter__group",dataset:{nodeId:t.id,depth:String(e)}},i?o:l("fieldset",{},o,n,a),i?n:null,i&&this.options.showRootActions?a:null)}_renderCondition(t){let e=this._field(t.field),i=this._operatorsFor(e),n=this._operator(t.operator),r=this._fields.map(h=>({value:h.id,label:h.label}));t.field&&!e&&r.push({value:t.field,label:this._unavailable(t.field)});let o=i.map(h=>({value:h.id,label:h.label}));t.operator&&!i.some(h=>h.id===t.operator)&&o.push({value:t.operator,label:this._unavailable(t.operator)});let a=this.options.searchable?this._searchSelect(r,t.field,this._message("filter.field","Filter field"),t.id,"field",h=>{let u=this._field(String(h));this.update(t.id,{field:String(h),operator:this._defaultOperator(u)??"",value:null}),this.focus(t.id)}):l("select",{class:"zx-filter__field",dataset:{filterField:"",nodeId:t.id},ariaLabel:this._message("filter.field","Filter field"),disabled:this._blocked()},l("option",{value:"",selected:!t.field},this._message("filter.chooseField","Choose a field\u2026")),this._fields.map(h=>l("option",{value:h.id,selected:h.id===t.field},h.label)),t.field&&!e?l("option",{value:t.field,selected:!0},this._unavailable(t.field)):null),c=this.options.searchable?this._searchSelect(o,t.operator,this._message("filter.operator","Filter operator"),t.id,"operator",h=>{this.update(t.id,{operator:String(h),value:null}),queueMicrotask(()=>this.el.querySelector(`[data-node-id="${Jt(t.id)}"] :is([data-filter-value], [data-filter-focus="value"])`)?.focus())}):l("select",{class:"zx-filter__operator",dataset:{filterOperator:"",nodeId:t.id},ariaLabel:this._message("filter.operator","Filter operator"),disabled:this._blocked()},l("option",{value:"",selected:!t.operator},this._message("filter.chooseOperator","Choose an operator\u2026")),i.map(h=>l("option",{value:h.id,selected:h.id===t.operator},h.label)),t.operator&&!i.some(h=>h.id===t.operator)?l("option",{value:t.operator,selected:!0},this._unavailable(t.operator)):null);return l("li",{class:"zx-filter__condition",dataset:{nodeId:t.id}},a,c,this._renderValue(t,e,n),this._removeConditionButton(t,e))}_renderValue(t,e,i){let n=l("div",{class:"zx-filter__value"});if(!e||!i)return n;if(i.arity==="none")return l("div",{class:"zx-filter__value zx-filter__value--empty"},this._message("filter.noValue","No value"));if(e.type==="custom"&&typeof e.editor=="function"){let h=this._renderVersion;return queueMicrotask(()=>{if(h!==this._renderVersion||!this.el.contains(n))return;let u=e.editor(n,{value:t.value,field:e,conditionId:t.id,setValue:d=>this._setNodeValue(t.id,zu(d))});u&&typeof u.destroy=="function"&&this._customEditors.push(u)}),n}let r=this._valueMessages(),o=i.arity==="pair"?Array.isArray(t.value)?t.value:[null,null]:[t.value];if(i.arity==="many"){let h=Au(e,t,o[0],!0,this._blocked(),0,r);return h?l("div",{class:"zx-filter__value"},h):l("div",{class:"zx-filter__value"},ku(e,t.id,Array.isArray(t.value)?t.value.join(", "):"",0,this._blocked(),!0,r))}let a=e.choices?.length?e.choices:e.type==="boolean"?[{value:!0,label:r.yes},{value:!1,label:r.no}]:null,c=o.map((h,u)=>this.options.searchable&&a?this._searchSelect(a,h,i.arity==="pair"?r.valueAt(e.label,u+1):r.value(e.label),t.id,"value",d=>{let p=i.arity==="pair"?Array.isArray(t.value)?[...t.value]:[null,null]:null;p&&(p[u]=d),this._setNodeValue(t.id,p??d)}):Au(e,t,h,!1,this._blocked(),u,r)??ku(e,t.id,h,u,this._blocked(),!1,r));return l("div",{class:"zx-filter__value",dataset:{arity:i.arity}},c)}_searchSelect(t,e,i,n,r,o){let a=this._renderVersion,c=new $(null,{items:t,valueKey:"value",labelKey:"label",value:e,label:i,filter:"local",disabled:this._blocked(),placeholder:this._message("filter.choosePart","Choose %1\u2026",r),onchange:({detail:h})=>queueMicrotask(()=>{!this._disposed&&a===this._renderVersion&&this._canMutate()&&o(h.value)})});return this._selectEditors.push(c),c.el.classList.add("zx-filter__picker"),c.refs.input.dataset.filterFocus=r,c.refs.input.dataset.nodeId=n,c.el}_handleChange(t){if(!this._canMutate())return;let e=t.target,i=e?.dataset.nodeId;if(!(!e||!i))if(e.dataset.filterField!==void 0){let n=wt(this._value.root,i);if(n?.kind!=="condition")return;n.field=e.value;let r=this._field(n.field);n.operator=this._defaultOperator(r)??"",n.value=null,this._abort(i),this._render(),this._changed("update",i),this.focus(i)}else if(e.dataset.filterOperator!==void 0){let n=wt(this._value.root,i);if(n?.kind!=="condition")return;n.operator=e.value,n.value=null,this._abort(i),this._render(),this._changed("update",i),queueMicrotask(()=>this.el.querySelector(`[data-node-id="${Jt(i)}"] [data-filter-value]`)?.focus())}else if(e.dataset.filterLogic!==void 0){let n=wt(this._value.root,i);n?.kind==="group"&&!(n===this._value.root&&this.options.rootLogic)&&(n.logic=e.value==="or"?"or":"and"),this._changed("update",i)}else e.dataset.filterValue!==void 0&&this._valueInput(e)}_handleInput(t){if(!this._canMutate())return;let e=t.target;if(!e||e.dataset.filterValue===void 0)return;this._valueInput(e);let i=e.dataset.nodeId,n=wt(this._value.root,i),r=n?.kind==="condition"?this._field(n.field):null;r?.loadChoices&&this._scheduleChoices(n.id,r,e.value)}_valueInput(t){let e=wt(this._value.root,t.dataset.nodeId);if(e?.kind!=="condition")return;let i=this._operator(e.operator),n=this._field(e.field);if(!i||!n)return;let r;if(t instanceof HTMLSelectElement&&t.multiple)r=Array.from(t.selectedOptions,o=>nn(o.value,n.type));else if(i.arity==="many")r=t.value.split(",").map(o=>o.trim()).filter(Boolean).map(o=>nn(o,n.type));else if(i.arity==="pair"){let o=Array.isArray(e.value)?[...e.value]:[null,null];o[Number(t.dataset.valueIndex)||0]=nn(t.value,n.type),r=o}else r=nn(t.value,n.type);this._setNodeValue(e.id,r)}_handleClick(t){let e=t.target?.closest?.("[data-filter-action]");if(!e||!this.el.contains(e))return;let i=e.dataset.filterAction,n=e.dataset.nodeId||null;i==="add"?this.addCondition(n):i==="add-group"?this.addGroup(n):i==="remove"&&n?this.remove(n):i==="clear"?this.clear():i==="apply"&&this.apply()}_setNodeValue(t,e){let i=wt(this._value.root,t);if(i?.kind!=="condition")return;i.value=e;let n=this.validate();this.el.dataset.valid=String(n.valid),this.el.querySelector(`[data-node-id="${Jt(t)}"]`)?.toggleAttribute("data-invalid",n.errors.some(o=>o.nodeId===t)),this._changed("update",t)}_changed(t,e){let i=this.validate(),n=this.getValue();this.emit("change",{value:n,valid:i.valid,errors:i.errors,reason:t,nodeId:e}),this.options.autoApply&&i.valid&&this.emit("apply",{value:n})}_scheduleChoices(t,e,i){if(this._abort(t),i.length<Number(e.minQuery??0))return;let n=new AbortController;this._setAsyncBusy(t,!0);let r={controller:n,timer:setTimeout(async()=>{this.emit("query",{conditionId:t,fieldId:e.id,query:i});try{let o=await e.loadChoices({query:i,signal:n.signal,conditionId:t,field:e});if(n.signal.aborted||this._async.get(t)?.controller!==n)return;let c=this.el.querySelector(`[data-node-id="${Jt(t)}"] [data-filter-value]`)?.getAttribute("list"),h=c?this.el.querySelector(`#${Jt(c)}`):null;h&&h.replaceChildren(...(Array.isArray(o)?o:[]).map(u=>l("option",{value:u.value},u.label))),this.emit("loaded",{conditionId:t,fieldId:e.id,query:i,choices:o})}catch(o){n.signal.aborted||this.emit("error",{conditionId:t,fieldId:e.id,query:i,error:o instanceof Error?o:new Error(String(o))})}finally{this._async.get(t)?.controller===n&&(this._async.delete(t),this._setAsyncBusy(t,!1))}},Math.max(0,Number(e.debounce??200)))};this._async.set(t,r)}_abort(t){let e=this._async.get(t);e&&(clearTimeout(e.timer),e.controller.abort(),this._async.delete(t),this._setAsyncBusy(t,!1))}_setAsyncBusy(t,e){let i=this.el.querySelector(`[data-node-id="${Jt(t)}"] [data-filter-value]`);e?i?.setAttribute("aria-busy","true"):i?.removeAttribute("aria-busy")}_abortTree(t){t.kind==="condition"?this._abort(t.id):t.children.forEach(e=>this._abortTree(e))}_abortAll(){for(let t of[...this._async.keys()])this._abort(t)}_destroyEditors(){for(let t of[...this._customEditors??[],...this._selectEditors??[]])t.destroy?.();this._customEditors=[],this._selectEditors=[]}_blocked(){return this._readonly||this._disabled}_canMutate(){return!this._blocked()}_limits(){return{maxDepth:Number(this.options.maxDepth),maxConditions:Number(this.options.maxConditions)}}_field(t){return this._fields.find(e=>e.id===t)??null}_operator(t){return this._operators.find(e=>e.id===t)??null}_operatorsFor(t){if(!t)return[];let e=t.operators?.length?t.operators:null;return this._operators.filter(i=>e?e.includes(i.id):i.types.includes(t.type))}_defaultOperator(t){return t?.defaultOperator&&this._operatorsFor(t).some(e=>e.id===t.defaultOperator)?t.defaultOperator:this._operatorsFor(t)[0]?.id??null}_announce(t){this.refs.status&&(this.refs.status.textContent=t)}_unavailable(t){return this._message("filter.unavailable","Unavailable: %1",t)}_removeConditionButton(t,e){let i=this._message("filter.remove","Remove %1",e?.label??this._message("filter.filterNoun","filter"));return Xt("remove",t.id,"trash",i,{disabled:this._blocked(),ariaLabel:i})}_valueMessages(){return{choose:this._message("filter.choose","Choose\u2026"),yes:this._message("filter.booleanTrue","True"),no:this._message("filter.booleanFalse","False"),commaSeparated:this._message("filter.commaSeparated","Comma-separated values"),value:t=>this._message("filter.fieldValue","%1 value",t),valueAt:(t,e)=>this._message("filter.fieldValueAt","%1 value %2",t,e)}}_message(t,e,...i){let n=this.msg(t,...i);return n===t?I(e,i):n}};function Xt(s,t,e,i,n={}){return l("button",{type:"button",class:["zx-button","zx-button--sm",n.class].filter(Boolean),...n,dataset:{filterAction:s,nodeId:t}},g(e,{size:13}),l("span",{},i))}function Au(s,t,e,i,n,r=0,o=Cu){let a=Array.isArray(s.choices)&&s.choices.length?s.choices:s.type==="boolean"?[{value:!0,label:o.yes},{value:!1,label:o.no}]:null;if(!a)return null;let c=new Set(Array.isArray(e)?e.map(String):[String(e??"")]);return l("select",{dataset:{filterValue:"",nodeId:t.id,valueIndex:String(r)},ariaLabel:o.value(s.label),multiple:i,disabled:n},i?null:l("option",{value:"",selected:!c.has(String(e))||e==null},o.choose),a.map(h=>l("option",{value:h.value,selected:c.has(String(h.value))},h.label)))}function ku(s,t,e,i,n,r=!1,o=Cu){let a=r?"text":["number","money"].includes(s.type)?"number":s.type==="date"?"date":s.type==="datetime"?"datetime-local":"text",c=s.loadChoices?`zx-filter-choices-${t}-${i}`:null,h=l("input",{type:a,value:e??"",dataset:{filterValue:"",nodeId:t,valueIndex:String(i)},ariaLabel:i?o.valueAt(s.label,i+1):o.value(s.label),disabled:n,placeholder:r?o.commaSeparated:"",list:c});return l("span",{class:"zx-filter__value-control"},h,c?l("datalist",{id:c}):null)}function nn(s,t){if(s==="")return null;if(["number","money"].includes(t)){let e=Number(s);return Number.isFinite(e)?e:null}return t==="boolean"?s==="true":s}function zu(s){return Po(s===void 0?null:s)}function wt(s,t){if(!s||s.id===t)return s??null;if(s.kind==="group")for(let e of s.children){let i=wt(e,t);if(i)return i}return null}function Ho(s,t){let e=wt(s,t);return e?.kind==="group"?e:null}function $o(s,t){if(s?.kind!=="group")return null;if(s.children.some(e=>e.id===t))return s;for(let e of s.children){let i=$o(e,t);if(i)return i}return null}function Tu(s,t){if(s.kind!=="group")return null;let e=s.children.findIndex(i=>i.id===t);if(e>=0)return s.children.splice(e,1)[0];for(let i of s.children){let n=Tu(i,t);if(n)return n}return null}function ky(s,t){return!!(s&&wt(s,t))}function Iu(s){return s.kind==="condition"?1:s.children.reduce((t,e)=>t+Iu(e),0)}function Eu(s,t,e=0){if(s.id===t)return e;if(s.kind==="group"){for(let i of s.children)if(i.kind==="group"){let n=Eu(i,t,e+1);if(n>=0)return n}}return-1}function zy(s,t){let e=new Map(s.map(i=>[i.id,{...i,types:[...i.types]}]));for(let i of Array.isArray(t)?t:[])i?.id&&e.set(String(i.id),{...i,id:String(i.id),types:Array.isArray(i.types)?[...i.types]:[]});return[...e.values()]}function Jt(s){return globalThis.CSS?.escape?CSS.escape(s):String(s).replaceAll(/[^a-zA-Z0-9_-]/g,"\\$&")}function Cy(s,t){return!t||s.root.logic===t?null:{nodeId:s.root.id,code:"root-logic",message:`This filter requires match ${t==="or"?"any":"all"} conditions.`}}var Le=class extends m{static cssName="fieldset";static defaults={title:"",columns:1,fields:{}};render(){let t=this.el??l("fieldset");this._fields=new Map,this._ownedFields=new Set,this._origins=new Map,this._fieldIdAttributes=new Map,this._ownedNodes=[],this._columnAttribute=t.getAttribute("data-columns");let e=[1,2,3].includes(Number(this.options.columns))?Number(this.options.columns):1;if(t.dataset.columns=String(e),this.options.title){let n=l("legend",{class:"zx-fieldset__legend"},String(this.options.title));this._ownedNodes.push(n),t.append(n)}this._grid=l("div",{class:"zx-fieldset__grid"}),this._ownedNodes.push(this._grid),t.append(this._grid);let i=this.options.fields&&typeof this.options.fields=="object"?this.options.fields:{};for(let[n,r]of Object.entries(i))this.addField(n,r);return t}addField(t,e){let i=String(t);if(this._fields.has(i))throw new Error(`Field "${i}" already exists`);let n,r=!1;if(e instanceof C)n=e;else if(T(e)||e instanceof m){let o=e;n=new C(null,{id:i,type:"custom",label:i,value:Iy(o),disabled:Ey(o),adapter:()=>Ty(o)}),r=!0}else{let o=e&&typeof e=="object"?e:{};n=new C(null,{...o,id:o.id??i}),r=!0}return r?this._ownedFields.add(n):this._origins.set(n,{parent:n.el.parentNode,next:n.el.nextSibling}),this._fields.set(i,n),this._fieldIdAttributes.set(n,n.el.getAttribute("data-field-id")),n.el.dataset.fieldId=i,this._grid.append(n.el),n}getField(t){return this._fields.get(String(t))??null}hasField(t){return this._fields.has(String(t))}getFields(){return Object.fromEntries(this._fields)}getValues(){let t={};for(let[e,i]of this._fields)t[e]=i.getValue();return t}setValues(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[i,n]of Object.entries(t))this._fields.get(i)?.setValue(n,{silent:e});return this}getValue(t){return this._fields.get(String(t))?.getValue()??null}setValue(t,e){return this._fields.get(String(t))?.setValue(e),this}reset(){for(let t of this._fields.values())t.reset();return this}clear(){for(let t of[...this._fields.values()])this._releaseField(t);return this._fields.clear(),this}focus(t){return this._fields.get(String(t))?.focus(),this}setHighlights(t={},e="danger"){let i=0;for(let[n,r]of this._fields){let o=t?.[n];o?(r.setHighlight(String(o),e),i+=1):r.clearHighlight()}return i}clearHighlights(){for(let t of this._fields.values())t.clearHighlight();return this}_releaseField(t){let e=this._fieldIdAttributes.get(t);if(e==null?t.el.removeAttribute("data-field-id"):t.el.setAttribute("data-field-id",e),this._fieldIdAttributes.delete(t),this._ownedFields.has(t)){t.destroy(),this._ownedFields.delete(t);return}let i=this._origins.get(t);i?.parent?i.parent.insertBefore(t.el,i.next?.parentNode===i.parent?i.next:null):t.el.remove(),this._origins.delete(t)}destroy(){this.clear();for(let t of this._ownedNodes??[])t.remove();this._columnAttribute===null?this.el.removeAttribute("data-columns"):this.el.setAttribute("data-columns",this._columnAttribute),super.destroy()}};function Ty(s){let t=T(s)?s:s.toElement(),e=t.parentNode,i=t.nextSibling,n=new Map(["id","aria-labelledby","aria-describedby","aria-disabled","aria-invalid"].map(a=>[a,t.getAttribute(a)])),r="disabled"in t?t.disabled:void 0,o="value"in t?t.value:void 0;return{el:t,get:()=>typeof s.getValue=="function"?s.getValue():typeof s.getValues=="function"?s.getValues():"value"in t?t.value:null,set:(a,c)=>{typeof s.setValue=="function"?s.setValue(a,c):typeof s.setValues=="function"&&a&&typeof a=="object"?s.setValues(a,c):"value"in t&&(t.value=a??"")},focus:()=>{typeof s.focus=="function"?s.focus():typeof t.focus=="function"&&t.focus()},setDisabled:a=>{typeof s.setDisabled=="function"?s.setDisabled(a):"disabled"in t?t.disabled=a:t.setAttribute("aria-disabled",String(a))},destroy:()=>{for(let[a,c]of n)c===null?t.removeAttribute(a):t.setAttribute(a,c);r!==void 0&&(t.disabled=r),o!==void 0&&(t.value=o),e?e.insertBefore(t,i?.parentNode===e?i:null):t.remove()}}}function Iy(s){let t=T(s)?s:s.toElement();return typeof s.getValue=="function"?s.getValue():typeof s.getValues=="function"?s.getValues():"value"in t?t.value:null}function Ey(s){let t=T(s)?s:s.toElement();return"disabled"in t?!!t.disabled:t.getAttribute("aria-disabled")==="true"}var Uo=class extends m{static cssName="form";static defaults={fieldsets:[],actions:[],novalidate:!0,msg:{"form.required":"This field is required.","form.int":"Enter a whole number.","form.float":"Enter a valid number."}};render(){let t=this.el??l("form");this._fieldsets=[],this._ownedFieldsets=new Set,this._origins=new Map,this._ownedNodes=[],this._novalidateAttribute=t.getAttribute("novalidate"),t.toggleAttribute("novalidate",!!this.options.novalidate),this._body=l("div",{class:"zx-form__body"}),this._actions=l("div",{class:"zx-form__actions"}),this._ownedNodes.push(this._body,this._actions),t.append(this._body,this._actions),this.listen(t,"submit",i=>{i.preventDefault(),this.submit()}),this.listen(t,"reset",i=>{i.preventDefault(),this.reset()}),this.listen(this._actions,"click",i=>this._handleAction(i));let e=Array.isArray(this.options.fieldsets)?this.options.fieldsets:[];for(let i of e)this.addFieldset(i);return this.setActions(Array.isArray(this.options.actions)?this.options.actions:[]),t}addFieldset(t){let e=!(t instanceof Le),i=e?new Le(null,t??{}):t;return this._fieldsets.includes(i)||(e?this._ownedFieldsets.add(i):this._origins.set(i,{parent:i.el.parentNode,next:i.el.nextSibling}),this._fieldsets.push(i),this._body.append(i.el),this.listen(i.el,"zx-change",n=>{let r=n.target,o=r instanceof Element?r.dataset.fieldId:null;o&&this.emit("change",{id:o,value:i.getValue(o)})})),i}setActions(t){return this._actionDescriptors=Array.isArray(t)?t.map(e=>({...e})):[],this._actions.replaceChildren(...this._actionDescriptors.map((e,i)=>{let n=String(e.label??e.id??"Action");return l("button",{class:"zx-btn",type:["submit","reset"].includes(e.type)?e.type:"button",disabled:!!e.disabled,title:e.title,ariaLabel:!n&&e.title?e.title:void 0,dataset:{actionIndex:i,kind:["primary","danger","ghost"].includes(e.kind)?e.kind:"default",size:e.size==="sm"?"sm":"md"}},e.icon?g(e.icon,{size:16}):null,n?l("span",{class:"zx-btn__label"},n):null)})),this._actions.hidden=this._actionDescriptors.length===0,this}getValues(){return Object.assign({},...this._fieldsets.map(t=>t.getValues()))}setValues(t,{silent:e=!1}={}){for(let i of this._fieldsets)i.setValues(t,{silent:e});return this}getField(t){for(let e of this._fieldsets){let i=e.getField(t);if(i)return i}return null}setValue(t,e){return this.getField(t)?.setValue(e),this}getValue(t){return this.getField(t)?.getValue()??null}reset(){for(let t of this._fieldsets)t.reset().clearHighlights();return this}setHighlights(t,e="danger"){return this._fieldsets.reduce((i,n)=>i+n.setHighlights(t,e),0)}clearHighlights(){for(let t of this._fieldsets)t.clearHighlights();return this}submit(){let t={},e=null;for(let n of this._fieldsets)for(let[r,o]of Object.entries(n.getFields())){let a=o.getValue(),c="";if(o.options.required&&Ko(a))c=this.msg("form.required");else if(!Ko(a)&&o.options.type==="int"){let h=cn(a);h.valid?o.setValue(h.value,{silent:!0}):c=this.msg("form.int")}else if(!Ko(a)&&o.options.type==="float"){let h=hn(a);h.valid?o.setValue(h.value,{silent:!0}):c=this.msg("form.float")}c?(t[r]=c,o.setHighlight(c,"danger"),e??=o):o.clearHighlight()}return Object.keys(t).length?(this.emit("invalid",{errors:t}),e?.focus(),!1):!this.emit("submit",{values:this.getValues()}).defaultPrevented}_handleAction(t){let e=t.target instanceof Element?t.target.closest("[data-action-index]"):null;if(!e||!this._actions.contains(e))return;let i=this._actionDescriptors[Number(e.dataset.actionIndex)],n=i?.onClick??i?.onclick??i?.handler;typeof n=="function"&&n(t,this)}destroy(){for(let t of this._fieldsets??[])if(this._ownedFieldsets.has(t))t.destroy();else{let e=this._origins.get(t);e?.parent?e.parent.insertBefore(t.el,e.next?.parentNode===e.parent?e.next:null):t.el.remove()}this._fieldsets=[];for(let t of this._ownedNodes??[])t.remove();this._novalidateAttribute===null?this.el.removeAttribute("novalidate"):this.el.setAttribute("novalidate",this._novalidateAttribute),super.destroy()}};function Ko(s){return s==null||s===""||s===!1||Array.isArray(s)&&s.length===0}var rn="123456789abcdefghijklmnopqrstuvwxyz";function Du(s){if(!Array.isArray(s))throw new TypeError("Questionnaire items must be an array");let t=new Set;return s.map(e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Each questionnaire item must be an object");if(typeof e.name!="string"||e.name.trim()==="")throw new TypeError("Each questionnaire item needs a non-empty string name");let i=e.name;if(t.has(i))throw new TypeError(`Item already exists: ${i}`);t.add(i);let n=Dy(e.choices??[],i),r=e.field&&typeof e.field=="object"?{...e.field}:null,o=Ny(e.input);if(n.length===0&&!r&&!o)throw new TypeError(`Item "${i}" needs choices, an input, or a field`);return{name:i,prompt:String(e.prompt??i),description:e.description==null||e.description===""?null:String(e.description),section:e.section==null?"":String(e.section),required:!!e.required,multiple:!!e.multiple,skippable:!!e.skippable,choices:n,input:o,field:r,when:typeof e.when=="function"?e.when:null,next:typeof e.next=="function"||typeof e.next=="string"&&e.next?e.next:null,validate:typeof e.validate=="function"?e.validate:null}})}function Dy(s,t=""){if(!Array.isArray(s))throw new TypeError("Questionnaire choices must be an array");let e=new Set,i=s.map(o=>{if(!o||typeof o!="object"||Array.isArray(o))throw new TypeError("Each questionnaire choice must be an object");if(o.value==null||o.value==="")throw new TypeError(`Each choice of "${t}" needs a value`);let a=typeof o.value=="number"?o.value:String(o.value),c=String(a);if(e.has(c))throw new TypeError(`Choice already exists in "${t}": ${c}`);return e.add(c),{value:a,label:String(o.label??a),description:o.description==null||o.description===""?null:String(o.description),icon:o.icon==null||o.icon===""?null:String(o.icon),key:typeof o.key=="string"&&o.key?o.key.slice(0,1).toLowerCase():"",disabled:!!o.disabled,exclusive:!!o.exclusive}}),n=new Set(i.map(o=>o.key).filter(Boolean)),r=0;for(let o of i)if(!o.key){for(;r<rn.length&&n.has(rn[r]);)r+=1;if(r>=rn.length)break;o.key=rn[r],n.add(o.key),r+=1}return i}function My(s,t){if(typeof s.when!="function")return!0;try{return s.when(t)!==!1}catch{return!0}}function jt(s,t){let e={},i=[];for(let n of s)My(n,e)&&(i.push(n),Object.prototype.hasOwnProperty.call(t,n.name)&&(e[n.name]=t[n.name]));return{answers:e,visible:i}}function on(s,t,e){let{answers:i,visible:n}=jt(s,e),r=new Set(n.map(c=>c.name)),o=null;if(typeof t.next=="string")o=t.next;else if(typeof t.next=="function"){let c=t.next(i[t.name],i);o=c==null||c===""?null:String(c)}let a=s.indexOf(t);if(o!==null){let c=s.findIndex(h=>h.name===o);if(c<0)throw new RangeError(`Unknown questionnaire item: ${o}`);if(r.has(o))return o;a=c}for(let c=a+1;c<s.length;c+=1)if(r.has(s[c].name))return s[c].name;return null}function ge(s){return s==null?!0:typeof s=="string"?s.trim()==="":Array.isArray(s)?s.every(t=>ge(t)):!1}function Mu(s,t,e){return!s.required||!ge(t)?null:e(s.choices.length>0?"questionnaire.required":"questionnaire.requiredInput")}function Nu(s,t,e=null){let i=new Set(t.map(r=>String(r))),n=new Set(s.filter(r=>r.exclusive).map(r=>String(r.value)));return n.size>0&&e!==null&&i.has(String(e))&&(n.has(String(e))?i.forEach(r=>r!==String(e)&&i.delete(r)):n.forEach(r=>i.delete(r))),s.filter(r=>i.has(String(r.value))).map(r=>r.value)}function Ou(s,t,e){let{answers:i,visible:n}=jt(s,t),r=new Map(n.map(f=>[f.name,f])),o=e.filter(f=>r.has(f)),a=o.length>0?r.get(o[o.length-1]):null,c=o.filter(f=>!ge(i[f])).length,h=new Set(o),u=a?n.indexOf(a):-1,d=n.slice(u+1).filter(f=>!h.has(f.name)).length,p=o.length+d;return{index:Math.max(0,o.length-1),answered:c,total:p,percent:p===0?0:Math.round(c/p*100),section:a?.section??""}}function Ny(s){if(!s)return null;let t=typeof s=="object"&&!Array.isArray(s)?s:{};return{label:String(t.label??"Other"),placeholder:String(t.placeholder??""),multiline:!!t.multiline,maxLength:Math.max(0,Number(t.maxLength)||0)}}var Oy=260,Yo=class extends m{static cssName="questionnaire";static defaults={items:[],answers:{},active:null,progress:!0,review:!1,advance:"manual",shortcuts:!0,allowBack:!0,msg:{"questionnaire.next":"Continue","questionnaire.previous":"Back","questionnaire.skip":"Skip","questionnaire.submit":"Submit","questionnaire.review":"Review answers","questionnaire.reviewTitle":"Check your answers","questionnaire.edit":"Edit","questionnaire.counter":"Question %1 of %2","questionnaire.required":"Choose an answer to continue.","questionnaire.requiredInput":"Enter an answer to continue.","questionnaire.noAnswer":"Skipped","questionnaire.empty":"There is nothing to answer."}};render(){this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:A(this.el),this._destroyed=!1,this._items=[],this._selected=new Map,this._freeform=new Map,this._fields=new Map,this._path=[],this._status="asking",this._returnToReview=!1,this._busy=!1,this._error="",this._advanceTimer=0,this._uid=x("zx-questionnaire");let t=this.el??l("form");if(this.el=t,this._form=t.localName==="form"?t:l("form",{class:"zx-questionnaire__form"}),this._form.setAttribute("novalidate",""),this._progressHost=l("div",{class:"zx-questionnaire__progress",hidden:!this.options.progress}),this._itemHost=l("fieldset",{class:"zx-questionnaire__item",tabIndex:-1}),this._reviewHost=l("div",{class:"zx-questionnaire__review",tabIndex:-1,hidden:!0}),this._actionsHost=l("div",{class:"zx-questionnaire__actions"}),this.refs.item=this._itemHost,this.refs.review=this._reviewHost,this.refs.actions=this._actionsHost,this._bar=new pi(null,{max:100,value:0,size:"sm",showValue:!1}),this._progressHost.append(this._bar.el),this._back=this._action("previous",this.msg("questionnaire.previous"),"chevron-left","default"),this._skip=this._action("skip",this.msg("questionnaire.skip"),null,"ghost"),this._forward=this._action("next",this.msg("questionnaire.next"),"chevron-right","primary"),this._actionsHost.append(this._back,l("span",{class:"zx-questionnaire__spacer"}),this._skip,this._forward),this._form.replaceChildren(this._progressHost,this._itemHost,this._reviewHost,this._actionsHost),this._form!==t&&t.replaceChildren(this._form),this.listen(this._form,"submit",e=>{e.preventDefault(),this.next()}),this.listen(this._itemHost,"change",e=>this._onControlChange(e)),this.listen(this._itemHost,"input",e=>this._onFreeformInput(e)),this.listen(this._actionsHost,"click",e=>this._onActionClick(e)),this.listen(this._reviewHost,"click",e=>this._onReviewClick(e)),this.listen(t,"keydown",e=>this._onKeydown(e)),this.setItems(this.options.items),this.options.answers&&typeof this.options.answers=="object"&&this.setAnswers(this.options.answers,{silent:!0}),this.options.active!=null){let e=String(this.options.active);jt(this._items,this._rawAnswers()).visible.some(n=>n.name===e)&&(this._path=[e])}return this._paint(),t}setItems(t){let e=this.getActive(),i=Du(t),n=new Set(i.map(a=>a.name));this._items=i;for(let a of[this._selected,this._freeform])for(let c of[...a.keys()])n.has(c)||a.delete(c);for(let[a,c]of[...this._fields])n.has(a)||(c.destroy(),this._fields.delete(a));let r=jt(i,this._rawAnswers()).visible,o=this._path.filter(a=>r.some(c=>c.name===a));return e&&o[o.length-1]===e?this._path=o:this._path=r.length>0?[r[0].name]:[],this._status="asking",this._returnToReview=!1,this._error="",this._paint(),this}getItems(){return this._items.map(t=>({...t,choices:t.choices.map(e=>({...e})),input:t.input?{...t.input}:null}))}goTo(t){let e=this._items.find(r=>r.name===t);if(!e)throw new RangeError(`Unknown questionnaire item: ${t}`);if(!jt(this._items,this._rawAnswers()).visible.includes(e))return!1;let n=this._returnToReview;return this._returnToReview=n||this._status==="review",this._navigate(t,"goto")?!0:(this._returnToReview=n,!1)}async next(){if(this._busy||this._status==="complete")return!1;if(this._status==="review")return this.submit();if(!await this._validateActive()||this._destroyed)return!1;if(this._returnToReview)return this._returnToReview=!1,this._enterReview();let t=this._activeItem(),e=t?on(this._items,t,this._rawAnswers()):null;return e?this._navigate(e,"next"):this.options.review?this._enterReview():this.submit()}previous(){if(this._busy)return!1;if(this._status==="review"||this._status==="complete"){let n=this._path[this._path.length-1];return!n||this.emit("navigate",{from:null,to:n,reason:"previous"}).defaultPrevented?!1:(this._status="asking",this._returnToReview=!1,this._error="",this._paint(),this._focusItem(),!0)}if(!this.options.allowBack||this._path.length<=1)return!1;let t=this.getActive(),e=this._path[this._path.length-2];return this.emit("navigate",{from:t,to:e,reason:"previous"}).defaultPrevented?!1:(this._path.pop(),this._returnToReview=!1,this._error="",this._paint(),this._focusItem(),!0)}async skip(){let t=this._activeItem();if(!t||!t.skippable||this._busy)return!1;if(this.setAnswer(t.name,null,{silent:!0}),this.emit("skip",{name:t.name}),this._returnToReview)return this._returnToReview=!1,this._enterReview();let e=on(this._items,t,this._rawAnswers());return e?this._navigate(e,"skip"):this.options.review?this._enterReview():this.submit()}async submit(){if(this._busy||this._status==="complete"||this._status!=="review"&&!await this._validateActive()||this._destroyed)return!1;let t={answers:this.getAnswers(),path:this.getPath()};return this.emit("submit",t).defaultPrevented?!1:(this._status="complete",this._paint(),this.emit("complete",{answers:t.answers,path:t.path}),!0)}getAnswers(){return jt(this._items,this._rawAnswers()).answers}getAnswer(t){let e=this._items.find(i=>i.name===t);return e?this._answerOf(e):null}setAnswers(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[i,n]of Object.entries(t))this._items.some(r=>r.name===i)&&this.setAnswer(i,n,{silent:!0});if(this._paint(),!e){let i=this.getAnswers();for(let n of Object.keys(t))n in i&&this.emit("change",{name:n,value:i[n],answers:i})}return this}setAnswer(t,e,{silent:i=!1}={}){let n=this._items.find(r=>r.name===t);if(!n)throw new RangeError(`Unknown questionnaire item: ${t}`);if(n.field)this._field(n).setValue(e===void 0?null:e,{silent:!0});else{let r=Array.isArray(e)?e:e==null||e===""?[]:[e],o=new Set(r.map(c=>String(c))),a=n.choices.filter(c=>o.has(String(c.value)));for(let c of a)o.delete(String(c.value));this._selected.set(t,a.map(c=>c.value)),this._freeform.set(t,n.input?[...o][0]??"":"")}return this._paint(),i||this._emitChange(n),this}getActive(){return this._status!=="asking"?null:this._path[this._path.length-1]??null}getPath(){return[...this._path]}getProgress(){return Ou(this._items,this._rawAnswers(),this._path)}getState(){return{active:this.getActive(),status:this._status,answers:this.getAnswers(),path:this.getPath(),progress:this.getProgress()}}toFormData(){let t=new FormData;for(let[e,i]of Object.entries(this.getAnswers()))if(Array.isArray(i))for(let n of i)t.append(e,String(n));else i instanceof File||i instanceof Blob?t.append(e,i):t.append(e,i==null?"":String(i));return t}reset(){this._selected.clear(),this._freeform.clear();for(let[e,i]of this._fields){let n=this._items.find(r=>r.name===e);i.setValue(n?.field?.value??null,{silent:!0})}let t=jt(this._items,this._rawAnswers()).visible;return this._path=t.length>0?[t[0].name]:[],this._status="asking",this._returnToReview=!1,this._error="",this._paint(),this}focus(){return this._focusItem(),this}destroy(){if(!this._destroyed){this._destroyed=!0,clearTimeout(this._advanceTimer);for(let t of this._fields.values())t.destroy();this._fields.clear(),this._bar?.destroy(),super.destroy(),this._createdRoot||S(this.el,this._snapshot)}}_activeItem(){let t=this._path[this._path.length-1];return this._items.find(e=>e.name===t)??null}_rawAnswers(){let t={};for(let e of this._items){let i=this._answerOf(e);ge(i)||(t[e.name]=i)}return t}_answerOf(t){if(t.field)return this._fields.get(t.name)?.getValue()??null;let e=this._selected.get(t.name)??[],i=(this._freeform.get(t.name)??"").trim();return t.multiple?i?[...e,i]:[...e]:i||(e.length>0?e[0]:null)}_field(t){let e=this._fields.get(t.name);if(e)return e;let i=t.field??{};return e=new C(null,{...i,label:i.label??t.prompt,required:t.required}),e.el.classList.add("zx-questionnaire__field"),i.label==null&&e.el.setAttribute("data-hide-label",""),e.on("change",()=>{this._error="",this._paintError(t),this._emitChange(t)}),this._fields.set(t.name,e),e}_navigate(t,e){let i=this.getActive();if(i===t&&this._status==="asking"||this.emit("navigate",{from:i,to:t,reason:e}).defaultPrevented)return!1;let n=this._path.indexOf(t);return n>=0?this._path=this._path.slice(0,n+1):this._path.push(t),this._status="asking",this._error="",this._paint(),this._focusItem(),!0}_enterReview(){return this.emit("navigate",{from:this.getActive(),to:null,reason:"review"}).defaultPrevented?!1:(this._status="review",this._error="",this._paint(),this._reviewHost.focus?.(),!0)}async _validateActive(){let t=this._activeItem();if(!t)return!0;let e=this._answerOf(t),i=Mu(t,e,n=>this.msg(n));if(!i&&typeof t.validate=="function"){this._setBusy(!0);try{i=await t.validate(e,this.getAnswers())}catch(n){i=n instanceof Error?n.message:String(n)}finally{this._destroyed||this._setBusy(!1)}}return this._destroyed?!1:(this._error=i?String(i):"",this._paintError(t),this._error?(this.emit("invalid",{name:t.name,message:this._error}),this._focusControl(),!1):!0)}_setBusy(t){this._busy=t,t?this.el.setAttribute("aria-busy","true"):this.el.removeAttribute("aria-busy"),this._syncState(),this._paintActions()}_paint(){this._destroyed||(this._syncState(),this._paintProgress(),this._status==="review"?this._paintReview():this._paintItem(),this._itemHost.hidden=this._status==="review",this._reviewHost.hidden=this._status!=="review",this._paintActions())}_syncState(){this.el.dataset.state=this._busy?"checking":this._status}_paintProgress(){if(this._progressHost.hidden=!this.options.progress||this._items.length===0,this._progressHost.hidden)return;let t=this.getProgress(),e=this.msg("questionnaire.counter",t.index+1,Math.max(t.total,1));this._bar.setLabel(t.section?`${e} \xB7 ${t.section}`:e),this._bar.set(this._status==="asking"?t.percent:100,{silent:!0}),this._bar.setStatus(this._status==="complete"?"success":"active")}_paintItem(){let t=this._activeItem();if(this._itemHost.toggleAttribute("data-empty",!t),!t){this._itemHost.replaceChildren(l("p",{class:"zx-questionnaire__prompt"},this.msg("questionnaire.empty")));return}let e=`${this._uid}-prompt`,i=`${this._uid}-description`,n=`${this._uid}-error`,r=[l("legend",{class:"zx-questionnaire__prompt",id:e},t.prompt)];t.description&&r.push(l("p",{class:"zx-questionnaire__description",id:i},t.description)),r.push(t.field?this._field(t).el:this._choices(t)),r.push(l("p",{class:"zx-questionnaire__error",id:n,role:"alert",hidden:!0})),this._itemHost.replaceChildren(...r),this._itemHost.dataset.item=t.name,this._itemHost.setAttribute("aria-describedby",[t.description?i:"",n].filter(Boolean).join(" ")),this._paintError(t)}_choices(t){let e=new Set((this._selected.get(t.name)??[]).map(n=>String(n))),i=l("div",{class:"zx-questionnaire__choices"});if(i.append(...t.choices.map((n,r)=>l("label",{class:"zx-questionnaire__choice",dataset:{disabled:n.disabled?"true":null}},l("input",{type:t.multiple?"checkbox":"radio",class:"zx-questionnaire__control",name:t.name,value:String(n.value),checked:e.has(String(n.value)),disabled:n.disabled,dataset:{index:r}}),l("span",{class:"zx-questionnaire__marker",ariaHidden:"true"}),n.icon?g(n.icon,{size:16}):null,l("span",{class:"zx-questionnaire__text"},l("span",{class:"zx-questionnaire__label"},n.label),n.description?l("span",{class:"zx-questionnaire__hint"},n.description):null),n.key?l("kbd",{class:"zx-questionnaire__key",ariaHidden:"true"},n.key):null))),t.input){let n=`${this._uid}-freeform`,r=this._freeform.get(t.name)??"",o=l(t.input.multiline?"textarea":"input",{type:t.input.multiline?void 0:"text",class:"zx-questionnaire__freeform-input",id:n,name:t.choices.length>0?`${t.name}__other`:t.name,placeholder:t.input.placeholder||void 0,maxLength:t.input.maxLength>0?t.input.maxLength:void 0,rows:t.input.multiline?3:void 0,autocomplete:"off",value:r});i.append(l("div",{class:"zx-questionnaire__freeform"},l("label",{class:"zx-questionnaire__freeform-label",htmlFor:n},t.input.label),o))}return i}_paintError(t){let e=this._itemHost.querySelector(".zx-questionnaire__error");e instanceof HTMLElement&&(e.textContent=this._error,e.hidden=!this._error),this._error?this._itemHost.setAttribute("aria-invalid","true"):this._itemHost.removeAttribute("aria-invalid");let i=t?.field?this._fields.get(t.name):null;i&&(this._error?i.setHighlight(this._error,"danger"):i.clearHighlight(),e instanceof HTMLElement&&(e.hidden=!0))}_paintReview(){let{answers:t,visible:e}=jt(this._items,this._rawAnswers()),i=this._path.map(n=>e.find(r=>r.name===n)).filter(n=>!!n).map(n=>l("div",{class:"zx-questionnaire__answer"},l("dt",{class:"zx-questionnaire__answer-prompt"},n.prompt),l("dd",{class:"zx-questionnaire__answer-value",dataset:{empty:ge(t[n.name])?"true":null}},this._formatAnswer(n,t[n.name])),j({label:this.msg("questionnaire.edit"),kind:"ghost",size:"sm"})));for(let[n,r]of i.entries()){let o=r.querySelector("button");o instanceof HTMLElement&&(o.dataset.edit=this._path[n])}this._reviewHost.replaceChildren(l("p",{class:"zx-questionnaire__review-title"},this.msg("questionnaire.reviewTitle")),l("dl",{class:"zx-questionnaire__answers"},...i))}_formatAnswer(t,e){if(ge(e))return this.msg("questionnaire.noAnswer");let i=new Map(t.choices.map(r=>[String(r.value),r.label]));return(Array.isArray(e)?e:[e]).map(r=>i.get(String(r))??String(r)).join(", ")}_paintActions(){let t=this._activeItem(),e=this._status==="review",i=this._status==="complete",n=!1;try{n=!!t&&on(this._items,t,this._rawAnswers())!==null}catch{n=!1}this._back.hidden=i||!e&&(!this.options.allowBack||this._path.length<=1),this._back.disabled=this._busy,this._skip.hidden=e||i||!t?.skippable,this._skip.disabled=this._busy,this._forward.hidden=i,this._forward.disabled=this._busy||!t&&!e;let r=e?"submit":this._returnToReview||!n&&this.options.review?"review":n?"next":"submit";if(this._forward.dataset.role!==r){this._forward.dataset.role=r;let o=r==="next"?"chevron-right":r==="review"?"list":"check";this._forward.replaceChildren(g(o,{size:16}),l("span",{class:"zx-btn__label"},this.msg(`questionnaire.${r}`)))}}_action(t,e,i,n){let r=j({label:e,icon:i,kind:n});return r.dataset.action=t,r}_onControlChange(t){let e=t.target;if(!(e instanceof HTMLInputElement)||!e.classList.contains("zx-questionnaire__control"))return;let i=this._activeItem();if(!i)return;let n=i.choices[Number(e.dataset.index)];if(n){if(i.multiple){let r=[...this._itemHost.querySelectorAll(".zx-questionnaire__control")].filter(c=>c.checked).map(c=>i.choices[Number(c.dataset.index)].value),o=Nu(i.choices,r,e.checked?n.value:null);this._selected.set(i.name,o);let a=new Set(o.map(c=>String(c)));for(let c of this._itemHost.querySelectorAll(".zx-questionnaire__control"))c.checked=a.has(c.value)}else{this._selected.set(i.name,[n.value]),this._freeform.set(i.name,"");let r=this._itemHost.querySelector(".zx-questionnaire__freeform-input");(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value="")}this._error="",this._paintError(i),this._paintProgress(),this._paintActions(),this._emitChange(i),this._maybeAutoAdvance(i)}}_onFreeformInput(t){let e=t.target;if(!((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.classList.contains("zx-questionnaire__freeform-input")))return;let n=this._activeItem();if(n){if(this._freeform.set(n.name,e.value),!n.multiple&&e.value.trim()!==""){this._selected.set(n.name,[]);for(let r of this._itemHost.querySelectorAll(".zx-questionnaire__control"))r.checked=!1}this._error="",this._paintError(n),this._paintProgress(),this._paintActions(),this._emitChange(n)}}_onActionClick(t){let e=t.target instanceof Element?t.target.closest("[data-action]"):null;!(e instanceof HTMLElement)||!this._actionsHost.contains(e)||(e.dataset.action==="previous"?this.previous():e.dataset.action==="skip"?this.skip():this.next())}_onReviewClick(t){let e=t.target instanceof Element?t.target.closest("[data-edit]"):null;e instanceof HTMLElement&&this.goTo(String(e.dataset.edit))}_onKeydown(t){if(t.defaultPrevented||t.ctrlKey||t.metaKey||t.altKey)return;let e=t.target,i=e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!["radio","checkbox"].includes(e.type)||e instanceof HTMLElement&&e.isContentEditable;if(t.key==="Enter"){if(e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement)return;t.preventDefault(),this.next();return}if(!this.options.shortcuts||i||t.key.length!==1)return;let n=this._activeItem();if(!n||this._status!=="asking")return;let r=t.key.toLowerCase(),o=n.choices.findIndex(c=>c.key===r&&!c.disabled);if(o<0)return;let a=this._itemHost.querySelector(`.zx-questionnaire__control[data-index="${o}"]`);a instanceof HTMLInputElement&&(t.preventDefault(),a.checked=n.multiple?!a.checked:!0,a.focus(),a.dispatchEvent(new Event("change",{bubbles:!0})))}_maybeAutoAdvance(t){this.options.advance!=="auto"||t.multiple||t.input||(clearTimeout(this._advanceTimer),this._advanceTimer=setTimeout(()=>{!this._destroyed&&this._activeItem()===t&&this.next()},Oy))}_emitChange(t){let e=this.getAnswers();this.emit("change",{name:t.name,value:this._answerOf(t),answers:e})}_focusItem(){this._status==="asking"&&this._itemHost.focus?.()}_focusControl(){let t=this._activeItem(),e=t?.field?this._fields.get(t.name):null;if(e){e.focus();return}let i=this._itemHost.querySelector(".zx-questionnaire__control:not(:disabled), .zx-questionnaire__freeform-input");i instanceof HTMLElement?i.focus():this._focusItem()}};function Fy(){pl(),fa(),ga(),Xa(),La(),Wa(),Sl(),zl(),sl(),Za(),Al(),rl(),ol(),bl(),ml()}Fy();export{Ar as AccountMenu,zi as ActivityItem,Sr as ActivityList,xs as AppIcon,Tr as AppSidebar,sr as Aurora,le as Avatar,dr as Breadcrumb,Os as CALENDAR_VIEWS,jr as Calendar,Zn as Card,Wr as CardView,po as Chart,_o as ChartJsAdapter,Ut as CheckButton,ot as Checklist,qe as CodeEditor,m as Component,Ci as ContextMenu,Qn as CopyInput,zo as DataFilter,te as DatePicker,Qe as DateRangeBox,Ge as DateRangePicker,Tn as DateTimeBox,et as Datebox,Yt as Dialog,cr as Dock,_t as Dropdown,vi as EntityRef,C as Field,Xe as FieldUpload,Le as Fieldset,Ai as FileItem,wr as FileList,qo as Filter,Do as FilterPanel,xo as Finder,Uo as Form,fo as Grid,se as Groupbox,is as Http,Yn as InlineLoading,ho as KanbanView,gr as Launcher,Fo as ListToolbar,rr as MasterPanel,mt as MenuButton,Mr as Message,hi as Modal,Ue as MonthPicker,Je as MultiValueEditor,hr as NavigationBar,Et as NumberField,pr as Pagination,nr as Panel,pi as ProgressBar,Yo as Questionnaire,ti as Rating,yt as RecordView,ne as Search,$ as Select,Nr as Sheet,Or as SheetStack,ei as Slider,Oo as SortControl,or as SplitView,us as StatTile,ur as Stepper,ui as Tabbox,Ot as Table,Yr as TableView,ii as TagPicker,Ke as TimePicker,Mt as Timebox,nt as Toggle,Xn as Toolbar,he as Tooltip,yo as TreeView,ni as ValueList,Ku as __,lo as absoluteKanbanIndex,L as addCalendarDays,Fr as addCalendarMonths,F as addDays,$t as addMonths,Ks as allowsKanbanTransition,Bm as appIcon,Yu as appendCompact,Wu as appendCompactChild,Uu as appendContent,Zo as applyCompactProperties,R_ as aspect,As as avatarInitials,pt as badge,y_ as badgeGroup,tu as billingColumns,Mn as breakpointOf,ve as breakpoints,j as button,op as buttonGroup,kt as calendarDayDifference,Q as calendarDayKey,Ii as calendarEventIntersects,zt as calendarEventSpansDays,Rr as calendarPageDate,Lr as calendarRange,su as chartSummaryTable,B as clamp,fn as clampDate,We as clampRange,Wt as clampSize,G as cloneCalendarEvent,Tt as cloneChartValue,sn as cloneFilterAst,Hi as compactElement,Wi as configureIcons,Gn as copyButton,Vn as copyToClipboard,to as createKanbanAvatars,eo as createKanbanCardHead,oo as createKanbanHistory,Rh as createKanbanIndicator,Jr as createKanbanProgress,Ru as debounce,Ve as deepMerge,Ka as defaultDateRangePresets,r_ as defineElements,Ng as describe,Uf as downloadBlob,ma as editorPosition,Ro as emptyFilterAst,k_ as emptyState,Pe as escapeRegExp,so as evaluateKanbanMove,Aa as faFamilies,Ui as faIconClasses,ka as faNames,_n as faStyles,Vo as filterCondition,Bo as filterGroup,en as filterOperators,sd as fireCompactEvent,In as focusTrap,oi as formatCurrency,D as formatDate,li as formatFileSize,Nt as formatNumber,ai as formatPercent,Ya as formatRangeText,Vf as formatRelativeTime,Gu as fragment,xn as getIconConfig,lt as getLanguage,$e as getWeekStart,L_ as grid,Xc as groupActivityItems,Pu as groupBy,l as h,Xu as highlightMatch,Qu as htmlEscape,g as icon,Id as iconNames,yn as icons,_a as indentSelection,me as isActiveValue,Qs as isBillingLine,T as isElement,go as isEmptyChartData,Y as isSameDay,rc as isTruncated,wl as joinTime,Vh as kanbanAvatarLimit,no as kanbanSearchTerms,Yi as kitUrl,Fs as layoutCalendarSpans,Vr as layoutTimedCalendarEvents,Cd as loadFontAwesome,gn as loadFontAwesomeKit,Us as locateKanbanRecord,Nn as matchBreakpoint,ro as matchesKanbanSearch,xh as moveViewField,Yc as normalizeActivityAction,Lt as normalizeActivityItems,Wc as normalizeActivityTimestamp,ue as normalizeAppItems,Ie as normalizeCalendarEvents,yr as normalizeEntityRef,Cs as normalizeEntityRefActions,ks as normalizeEntityRefLink,zs as normalizeEntityRefMetadata,ce as normalizeFileItem,xr as normalizeFileListItems,io as normalizeKanbanRules,we as normalizeRange,$r as normalizeViewFields,Sh as normalizeViewState,id as offCompactEvent,ri as onBreakpoint,ia as onCompactEvent,Mc as paginationRange,Jo as parseCompactTag,Z as parseDate,Fe as parseFilterAst,mn as parseIconSpec,xe as parseNumber,Cn as parseRangeText,On as parseResult,st as position,I as printf,fy as pruneValue,Ye as rangeNights,$a as rangeStateOf,br as rankLauncherItems,X as readViewField,Di as reconcileFieldOrder,Fy as registerFieldAdapters,Td as registerIcons,Ps as renderViewField,ao as reorderKanbanRecords,Gl as reorderTableRows,Uc as resolveActivityActions,q as resolveElement,Zr as resolveKanbanAssignees,Qr as resolveKanbanIndicator,Xr as resolveKanbanProgress,$s as resolveKanbanRules,gt as resolveSize,Dt as rovingTabindex,Mo as serializeFilterValue,od as setLanguage,rd as setTranslator,Ti as shiftCalendarEvent,at as skeleton,M_ as skeletonTable,_i as skeletonText,ts as snapNumber,kc as snapSize,Bu as sortBy,vh as sortViewRecords,Un as spinner,yl as splitTime,F_ as stack,W as startOfCalendarDay,Ns as startOfCalendarWeek,cm as statTile,_l as stepPrecision,ci as storage,Sy as stringifyFilterAst,Vu as throttle,ji as toArray,Kf as toCsv,Mg as tooltip,vt as translate,j_ as truncate,ht as typeahead,x as uid,ju as uniqueBy,zd as useBuiltinIcons,Ia as useFontAwesome,jo as validateFilterAst,Ee as viewRecordId,If as zeyosService};
|