@zeyos/zx 4.3.4 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +438 -0
- package/README.md +49 -10
- package/dist/types/components/activity-item/activity-item.d.ts +351 -0
- package/dist/types/components/activity-list/activity-list.d.ts +217 -0
- package/dist/types/components/app-sidebar/app-sidebar.d.ts +33 -3
- package/dist/types/components/avatar/avatar.d.ts +46 -7
- package/dist/types/components/badge/badge.d.ts +21 -1
- package/dist/types/components/button/button.d.ts +23 -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/chart/chart.d.ts +10 -0
- package/dist/types/components/checklist/checklist.d.ts +9 -0
- package/dist/types/components/code-editor/code-editor.d.ts +149 -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/datebox/date-range-box.d.ts +5 -1
- package/dist/types/components/datebox/datebox.d.ts +7 -2
- package/dist/types/components/dialog/dialog.d.ts +75 -6
- package/dist/types/components/dropdown/dropdown.d.ts +2 -2
- package/dist/types/components/entity-ref/entity-ref.d.ts +331 -0
- package/dist/types/components/field/field.d.ts +24 -2
- package/dist/types/components/fieldset/fieldset.d.ts +19 -1
- package/dist/types/components/file-item/file-item.d.ts +262 -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/form/form.d.ts +12 -1
- package/dist/types/components/kanban-view/kanban-card.d.ts +146 -0
- package/dist/types/components/kanban-view/kanban-view.d.ts +170 -4
- package/dist/types/components/launcher/launcher.d.ts +278 -26
- package/dist/types/components/list-toolbar/list-toolbar.d.ts +599 -0
- package/dist/types/components/menu-button/menu-button.d.ts +37 -42
- package/dist/types/components/message/message.d.ts +126 -17
- package/dist/types/components/modal/modal.d.ts +61 -2
- 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/color.d.ts +12 -0
- package/dist/types/components/select/glyphs.d.ts +124 -0
- package/dist/types/components/select/select.d.ts +15 -3
- package/dist/types/components/sort-control/sort-control.d.ts +105 -0
- package/dist/types/components/stat-tile/stat-tile.d.ts +288 -0
- package/dist/types/components/tabbox/tabbox.d.ts +16 -0
- package/dist/types/components/table/table.d.ts +190 -1
- package/dist/types/components/table-view/table-view.d.ts +11 -5
- package/dist/types/components/tag-picker/tag-picker.d.ts +21 -4
- package/dist/types/components/timebox/timebox.d.ts +7 -0
- package/dist/types/components/tree/tree.d.ts +13 -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/breakpoint.d.ts +1 -1
- package/dist/types/core/icons.d.ts +37 -22
- package/dist/types/core/motion.d.ts +59 -0
- package/dist/types/core/overlay-host.d.ts +15 -1
- package/dist/types/index.d.ts +16 -3
- package/dist/types/internal/app-rail.d.ts +10 -0
- package/dist/types/internal/menu-items.d.ts +134 -0
- package/dist/types/zeyos/connect.d.ts +6 -0
- package/dist/types/zeyos/form.d.ts +50 -9
- package/dist/types/zeyos/index.d.ts +1 -1
- package/dist/types/zeyos/query.d.ts +79 -0
- package/dist/types/zeyos/schema.d.ts +24 -1
- package/dist/types/zeyos/table.d.ts +100 -14
- package/dist/types/zeyos/view.d.ts +10 -0
- package/dist/zx-zeyos.esm.js +2206 -489
- package/dist/zx-zeyos.esm.min.js +56 -1
- package/dist/zx.css +3322 -724
- package/dist/zx.esm.js +12244 -5809
- package/dist/zx.esm.min.js +58 -3
- package/dist/zx.global.js +12246 -5811
- package/dist/zx.global.min.js +58 -3
- package/dist/zx.min.css +1 -1
- package/docs/api.json +1683 -146
- package/docs/llms.md +777 -110
- package/docs/llms.txt +14 -8
- package/package.json +1 -1
- package/src/components/account-menu/account-menu.css +35 -10
- package/src/components/activity-item/activity-item.css +137 -0
- package/src/components/activity-item/activity-item.js +602 -0
- package/src/components/activity-list/activity-list.css +99 -0
- package/src/components/activity-list/activity-list.js +409 -0
- package/src/components/app-icon/app-icon.css +1 -1
- package/src/components/app-rail/app-rail.css +191 -22
- package/src/components/app-sidebar/app-sidebar.css +349 -24
- package/src/components/app-sidebar/app-sidebar.js +86 -11
- package/src/components/aurora/aurora.css +5 -3
- package/src/components/avatar/avatar.css +32 -7
- package/src/components/avatar/avatar.js +72 -8
- package/src/components/badge/badge.css +54 -2
- package/src/components/badge/badge.js +29 -2
- package/src/components/button/button.css +74 -8
- package/src/components/button/button.js +44 -1
- package/src/components/calendar/calendar.css +46 -46
- package/src/components/calendar/calendar.js +33 -3
- package/src/components/card/card.css +2 -2
- package/src/components/card/card.js +12 -1
- package/src/components/card-view/card-view.css +10 -7
- package/src/components/card-view/card-view.js +25 -9
- package/src/components/card-view/record-card.js +7 -3
- package/src/components/chart/chart.css +4 -1
- package/src/components/chart/chart.js +12 -0
- package/src/components/check-button/check-button.css +10 -2
- package/src/components/checklist/checklist.css +9 -2
- package/src/components/checklist/checklist.js +11 -5
- package/src/components/checklist/field-adapter.js +3 -1
- package/src/components/code-editor/code-editor.css +68 -0
- package/src/components/code-editor/code-editor.js +306 -0
- package/src/components/code-editor/field-adapter.js +34 -0
- package/src/components/context-menu/context-menu.css +87 -5
- package/src/components/context-menu/context-menu.js +22 -30
- package/src/components/copy/copy-button.css +6 -0
- package/src/components/copy/copy-input.css +8 -3
- package/src/components/data-filter/data-filter.css +5 -4
- package/src/components/date-picker/date-picker.css +6 -6
- package/src/components/date-picker/date-picker.js +22 -8
- package/src/components/date-picker/date-range-picker.css +3 -3
- package/src/components/date-picker/month-picker.js +3 -3
- package/src/components/date-picker/time-picker.css +1 -1
- package/src/components/date-picker/time-picker.js +20 -8
- package/src/components/datebox/date-range-box.css +79 -2
- package/src/components/datebox/date-range-box.js +13 -2
- package/src/components/datebox/datebox.css +79 -2
- package/src/components/datebox/datebox.js +13 -2
- package/src/components/dialog/dialog.css +26 -0
- package/src/components/dialog/dialog.js +174 -70
- package/src/components/dropdown/dropdown.css +1 -1
- package/src/components/dropdown/dropdown.js +7 -5
- package/src/components/empty-state/empty-state.css +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/field/field.css +28 -9
- package/src/components/field/field.js +68 -26
- package/src/components/field-upload/field-upload.css +1 -1
- package/src/components/fieldset/fieldset.css +5 -3
- package/src/components/fieldset/fieldset.js +28 -5
- package/src/components/file-item/file-item.css +88 -0
- package/src/components/file-item/file-item.js +505 -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 +205 -47
- package/src/components/filter-panel/filter-panel.css +104 -0
- package/src/components/filter-panel/filter-panel.js +964 -0
- package/src/components/finder/finder.css +15 -13
- package/src/components/form/form.css +5 -4
- package/src/components/form/form.js +11 -2
- package/src/components/grid/grid.css +1 -1
- package/src/components/groupbox/groupbox.css +1 -1
- package/src/components/kanban-view/kanban-card.js +247 -0
- package/src/components/kanban-view/kanban-view.css +226 -8
- package/src/components/kanban-view/kanban-view.js +255 -12
- package/src/components/launcher/launcher.css +107 -25
- package/src/components/launcher/launcher.js +557 -63
- package/src/components/list-toolbar/list-toolbar.css +194 -0
- package/src/components/list-toolbar/list-toolbar.js +851 -0
- package/src/components/master-panel/master-panel.css +2 -0
- package/src/components/menu-button/menu-button.css +87 -5
- package/src/components/menu-button/menu-button.js +86 -46
- package/src/components/message/message.css +38 -5
- package/src/components/message/message.js +230 -17
- package/src/components/modal/modal.css +15 -0
- package/src/components/modal/modal.js +159 -3
- package/src/components/navigation-bar/navigation-bar.css +95 -11
- package/src/components/navigation-bar/navigation-bar.js +171 -4
- package/src/components/number-field/field-adapter.js +1 -0
- package/src/components/number-field/number-field.css +70 -0
- package/src/components/number-field/number-field.js +2 -0
- package/src/components/pagination/pagination.css +8 -6
- package/src/components/panel/panel.css +1 -1
- package/src/components/panel/panel.js +13 -2
- package/src/components/rating/rating.css +7 -0
- package/src/components/search/search.js +17 -5
- package/src/components/select/color.js +22 -0
- package/src/components/select/field-adapter.js +6 -1
- package/src/components/select/glyphs.js +165 -0
- package/src/components/select/select.css +138 -45
- package/src/components/select/select.js +86 -47
- package/src/components/sheet/sheet.css +11 -8
- package/src/components/slider/slider.css +16 -2
- package/src/components/slider/slider.js +1 -1
- package/src/components/sort-control/sort-control.css +20 -0
- package/src/components/sort-control/sort-control.js +140 -0
- package/src/components/stat-tile/stat-tile.css +208 -0
- package/src/components/stat-tile/stat-tile.js +601 -0
- package/src/components/tabbox/tabbox.css +32 -27
- package/src/components/tabbox/tabbox.js +17 -2
- package/src/components/table/table.css +155 -31
- package/src/components/table/table.js +386 -33
- 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 +86 -6
- package/src/components/tag-picker/tag-picker.js +25 -8
- package/src/components/timebox/timebox.css +22 -2
- package/src/components/timebox/timebox.js +18 -5
- package/src/components/toggle/toggle.css +12 -1
- package/src/components/toolbar/toolbar.js +2 -2
- package/src/components/tooltip/tooltip.css +4 -0
- package/src/components/tooltip/tooltip.js +10 -3
- package/src/components/tree/tree.css +25 -16
- package/src/components/tree/tree.js +31 -0
- package/src/components/value-list/value-list.css +3 -3
- 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/breakpoint.js +1 -1
- package/src/core/icons.js +259 -57
- package/src/core/motion.js +147 -0
- package/src/core/overlay-host.js +21 -2
- package/src/index.js +30 -3
- package/src/internal/app-rail.js +18 -1
- package/src/internal/menu-items.js +142 -0
- package/src/zeyos/connect.js +6 -2
- package/src/zeyos/form.js +67 -27
- package/src/zeyos/index.js +1 -1
- package/src/zeyos/query.js +153 -0
- package/src/zeyos/schema.js +144 -27
- package/src/zeyos/table.js +68 -5
- package/src/zeyos/view.js +6 -0
- package/styles/base.css +56 -0
- package/styles/icons.css +11 -1
- package/styles/print.css +192 -0
- package/styles/tokens/dark.css +113 -37
- package/styles/tokens/global.css +121 -27
- package/styles/tokens/semantic.css +100 -31
- package/styles/tokens/themes.css +7 -6
- package/styles/zx.css +11 -1
- package/styles/tokens/density.css +0 -9
package/dist/zx.esm.min.js
CHANGED
|
@@ -1,3 +1,58 @@
|
|
|
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 yd(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 wd(s,t,{leading:e=!0,trailing:i=!0}={}){let n=Math.max(0,Number(t)||0),r=null,o=0,a=null,c=null,u=()=>{r=null,o=e?Date.now():0;let h=a,d=c;a=null,c=null,h!==null&&s.apply(d,h)};return function(...d){let f=Date.now();o===0&&!e&&(o=f);let p=n-(f-o);if(p<=0||p>n){r!==null&&(clearTimeout(r),r=null),o=f,a=null,c=null,s.apply(this,d);return}i&&(a=d,c=this,r===null&&(r=setTimeout(u,p)))}}var _a=0;function x(s="zx"){return _a+=1,`${s}-${Date.now().toString(36)}-${_a.toString(36)}`}function He(s,t){let e=je(s)?ba(s):{};if(!je(t))return Qi(t);for(let[i,n]of Object.entries(t))je(n)&&je(e[i])?e[i]=He(e[i],n):e[i]=Qi(n);return e}function E(s){return!!(s&&typeof s=="object"&&s.nodeType===1)}function we(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 H(s,t,e){return Math.min(e,Math.max(t,s))}function Xi(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 xd(s,t){let e=Gi(t),i=new Map;for(let n of Xi(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 vd(s,...t){let e=Xi(s),i=t.map(Ad);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 Sd(s,t){let e=t==null?r=>r:Gi(t),i=new Set,n=[];for(let r of Xi(s)){let o=e(r);i.has(o)||(i.add(o),n.push(r))}return n}function qe(s){return String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Gi(s){if(typeof s=="function")return s;let t=String(s);return e=>e?.[t]}function Ad(s){let t,e=1;if(typeof s=="function")t=s;else if(s!==null&&typeof s=="object")t=Gi(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=Gi(i)}return(i,n)=>{let r=t(i),o=t(n),a=ma(r),c=ma(o);return a||c?a&&c?0:a?1:-1:e*kd(r,o)}}function ma(s){return s==null||typeof s=="number"&&Number.isNaN(s)}function kd(s,t){return s instanceof Date||t instanceof Date?xn(ga(s)-ga(t)):typeof s=="boolean"||typeof t=="boolean"?xn(Number(s)-Number(t)):typeof s=="number"&&typeof t=="number"?xn(s-t):String(s).localeCompare(String(t),void 0,{numeric:!0})}function ga(s){if(s instanceof Date)return s.getTime();let t=Number(s);return Number.isFinite(t)?t:0}function xn(s){return Number.isNaN(s)?0:s<0?-1:s>0?1:0}function je(s){if(s===null||typeof s!="object")return!1;let t=Object.getPrototypeOf(s);return t===Object.prototype||t===null}function ba(s){let t={};for(let[e,i]of Object.entries(s))t[e]=Qi(i);return t}function Qi(s){return je(s)?ba(s):Array.isArray(s)?s.map(Qi):s}var $e=null,zd=new Set(["href","id","lang","name","rel","src","target","title","value"]),Ke=new WeakMap;function ya(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 Ji(s,t=null,e=null){let i=ya(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&&wa(n,t),Rd(n,e),n}var Cd=Ji;function B(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 wa(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`);Sa(s,e.slice(2),i)}else typeof i=="boolean"||zd.has(e)?s[e]=i:s.setAttribute(e,String(i))}return s}function Td(s,t){if(t==null)return s;let e=va(t);return e==null||(typeof e=="object"?s.appendChild(e):s.appendChild(document.createTextNode(String(e)))),s}function Id(s,t,e=null,i=null){return s.appendChild(Ji(t,e,i)),s}function Ed(s,t,e=null,i=null){let n=Ji(t,e,i);return s.appendChild(n),n}function Dd(...s){let t=document.createDocumentFragment();return xa(t,s),t}function l(s,t,...e){let i=document.createElement(s),n=t;Od(n)||(e.unshift(n),n={});for(let[r,o]of Object.entries(n))Fd(i,r,o);return xa(i,e),i}l.scope=function(t,e){let i=$e;$e=t;try{return e()}finally{$e=i}};l.raw=function(t){let e=document.createElement("template");return e.innerHTML=String(t),e.content};function k(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 Md(s){return String(s).replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}function Nd(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(qe(r),"gi"),c=0;for(let u of n.matchAll(a)){u.index>c&&o.append(document.createTextNode(n.slice(c,u.index)));let h=document.createElement("mark");i&&(h.className=String(i)),h.append(document.createTextNode(u[0])),o.append(h),c=u.index+u[0].length}return c<n.length&&o.append(document.createTextNode(n.slice(c))),o}function q(s){if(s==null)return null;if(E(s))return s;if(typeof s=="string")return document.querySelector(s);if(typeof s.toElement=="function"){let t=s.toElement();return E(t)?t:null}return null}function Od(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 Fd(s,t,e){if(t==="ref"){$e&&typeof e=="string"&&($e[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=Ld(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 Ld(s){return s.startsWith("aria-")?s:/^aria[A-Z]/.test(s)?"aria-"+s.slice(4).toLowerCase():null}function xa(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 Rd(s,t){if(t==null)return;let e=va(t);e!=null&&(typeof e=="object"?s.appendChild(e):s.textContent=String(e))}function va(s){if(s&&typeof s=="object"){if(typeof s.nodeType=="number")return s;if(typeof s.toElement=="function")return s.toElement()}return s}function Sa(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=Ke.get(s);r||(r=new Map,Ke.set(s,r));let o=r.get(n);if(o)return o.handlers.push(e),s;let a=[e],c=u=>Aa(s,a,u);r.set(n,{handlers:a,listener:c});try{s.addEventListener(n,c,{passive:i})}catch{s.addEventListener(n,c)}return s}function Pd(s,t,e){let i=String(t),n=Ke.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&&Ke.delete(s))),s}function Bd(s,t,e=null){let i=String(t),n=Ke.get(s);if(!n?.has(i))return s;let r=e??Vd(s,i),o=n.get(String(r.type));return o&&Aa(s,o.handlers,r),s}function Aa(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 Vd(s,t){let e={target:s,type:t,which:-1,defaultPrevented:!1,preventDefault(){e.defaultPrevented=!0}};return e}var vn=null,ka="en";function jd(s){if(s!==null&&typeof s!="function")throw new TypeError("Translator must be a function or null");vn=s}function Hd(s){ka=String(s||"en")}function ct(){return ka}function St(s,t){let e=vn?vn(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 Zi=new WeakMap,g=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#t=new AbortController;#e=!1;#i=!1;#s=!1;constructor(t,e={}){super();let i=this.constructor;this.#e=t===null;let n=q(t);if(t!==null&&!n)throw new TypeError("Component target could not be resolved");this.el=n,this.refs={};let r=qd(i,e),o=[];for(let[u,h]of Object.entries(r))/^on[a-z]/.test(u)&&typeof h=="function"&&(o.push([u.slice(2),h]),delete r[u]);r.msg&&typeof r.msg=="object"&&Object.freeze(r.msg),this.options=Object.freeze(r);for(let[u,h]of o)this.on(u,h);let a;try{a=l.scope(this.refs,()=>this.render())}catch(u){throw this.#t.abort(),u}if(this.#e){let u=E(a)?a:this.el;if(!E(u))throw this.#t.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=u}if(!E(this.el))throw this.#t.abort(),new TypeError("Component requires a root Element");let c=i.cssName;if(typeof c=="string"&&c){let u=`zx-${c}`;this.#s=!this.el.classList.contains(u),this.el.classList.add(u)}Zi.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=za(t,e,{cancelable:!0});if(this.dispatchEvent(n),this.el){let r=za(`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??ct(),r=i?.[n]?.[t];if(r!=null)return I(String(r),e);let o=i?.[t];return o!=null?I(String(o),e):St(t,e)}destroy(){if(this.#i)return;this.#i=!0,this.#t.abort(),Zi.get(this.el)===this&&Zi.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 Zi.get(t)??null}};function qd(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=He(r,a.msg)));return Object.assign(n,t&&typeof t=="object"?t:{}),t?.msg&&typeof t.msg=="object"&&(o=!0,r=He(r,t.msg)),o&&(n.msg=r),n}function za(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 g{static cssName="field";static defaults={id:null,name: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=Yd(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"),this.name=String(this.options.name??this.options.id??"");let n=`${this.controlId}-label`,r=`${this.controlId}-description`,o=`${this.controlId}-highlight`,a=l("label",{class:"zx-field__label",id:n,htmlFor:this.controlId},String(this.options.label??""),this.options.required?l("span",{class:"zx-field__required",ariaHidden:"true"}," *"):null),c=l("div",{class:"zx-field__control"}),u=l("div",{class:"zx-field__description",id:r},String(this.options.description??"")),h=l("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),d=l("div",{class:"zx-field__body"},c,u,h);this._ownedNodes.push(a,d),t.append(a,d);let f=s.#t.get(e);if(f)try{this.adapter=Kd(f(this,this.options))}catch(m){let w=m instanceof Error?m.message:String(m);console.warn(`[zx.Field] Adapter "${e}" failed: ${w}`),this.adapter=Ta(w,this.controlId)}else{let m=this.msg("field.unknown",e);console.warn(`[zx.Field] ${m}`),this.adapter=Ta(m,this.controlId)}let p=this.adapter.el;p.id||(p.id=this.controlId);let _=this.adapter.labelTarget??(ts(p)?p:Ud(p))??p;return this._labelled=_,_!==p&&ts(_)&&!_.id&&(_.id=`${this.controlId}-input`),a.htmlFor=ts(_)?_.id:p.id,ts(_)||_.setAttribute("aria-labelledby",n),this._baseDescribedBy=_.getAttribute("aria-describedby")??"",c.append(p),this._descriptionId=String(this.options.description??"")?r:"",this._highlightId=o,this._highlight=h,this._syncDescription(),this.initialValue=$d(e,this.options.value),this.adapter.set(this.initialValue,{silent:!0}),this.setDisabled(!!this.options.disabled),this.listen(p,"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._labelled.setAttribute("aria-invalid","true"),this.emit("invalid",{message:String(t)})):(this._highlight.removeAttribute("role"),this._labelled.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._labelled.removeAttribute("aria-invalid"),this._syncDescription(!1),this}getInput(){return this.adapter.el}own(t){if(!(t instanceof g))throw new TypeError("Field.own() requires a Component");return this._ownedComponents.add(t),t}_syncDescription(t=!1){let e=[this._baseDescribedBy,this._descriptionId,t?this._highlightId:""].flatMap(i=>i.split(/\s+/)).filter(Boolean);e.length?this._labelled.setAttribute("aria-describedby",[...new Set(e)].join(" ")):this._labelled.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();Wd(this.el,this._rootAttributes??new Map),super.destroy()}};function Sn(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=Ea(t);return e!==null&&Number.isInteger(e)?{valid:!0,value:e}:{valid:!1,value:t}}function An(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=Ea(t);return e!==null?{valid:!0,value:e}:{valid:!1,value:t}}function Ea(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)?".":",",u=c==="."?",":".",h=i.lastIndexOf(c),d=i.slice(0,h),f=i.slice(h+1);if(!/^\d+$/.test(f)||!Ca(d,u))return null;o=d.split(u).join("")+"."+f}else if(r.length>1||n.length>1){let c=r.length?",":".";if(!Ca(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 Ca(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 $d(s,t){return t!==void 0?t:s==="checkbox"?!1:""}function Kd(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 Ta(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 ts(s){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(s.tagName)}function Ud(s){for(let t of s.querySelectorAll('input:not([type="hidden"]), select, textarea'))if(!(t.hasAttribute("aria-label")||t.hasAttribute("aria-labelledby")||[...t.labels??[]].some(i=>i.textContent?.trim())))return t;return null}function Yd(s,t){return new Map(t.map(e=>[e,s.getAttribute(e)]))}function Wd(s,t){for(let[e,i]of t)i===null?s.removeAttribute(e):s.setAttribute(e,i)}function Ue(s,t,e){let i={...t.props??{}};for(let n of Object.keys(i))(/^on[a-z]/i.test(n)||n==="content")&&delete i[n];return{name:s.name||void 0,...i,...e}}function es(s,t){return(e,i)=>{let n=l(s,Ue(e,i,{type:s==="input"?t:void 0,placeholder:i.placeholder,required:i.required,disabled:i.disabled}));return kn(n)}}function kn(s){return{el:s,get:()=>s.value,set:t=>{s.value=t==null?"":String(t)},focus:()=>s.focus(),setDisabled:t=>{s.disabled=t}}}function Da(s){return(t,e)=>{let i=s==="int"?Sn:An,n=l("input",Ue(t,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()}),{...kn(n),get:()=>i(n.value).value}}}var Gd=(s,t)=>{let e=l("input",Ue(s,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}}},Qd=(s,t)=>{let e=l("select",Ue(s,t,{required:t.required,disabled:t.disabled}));for(let[i,n]of Ma(t.options))e.append(l("option",{value:i},n));return kn(e)},Xd=(s,t)=>{let e=l("div",{class:"zx-field__option-list",role:"radiogroup"}),i=s.controlId,n=Ma(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))}}},Jd=(s,t)=>{let e=l("div",Ue(s,t,{class:"zx-field__static",name:void 0})),i=null;return{el:e,get:()=>e.textContent,set:r=>{Ia(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:()=>Ia(i)}};function Ia(s){s&&(s.parent?s.parent.insertBefore(s.node,s.next?.parentNode===s.parent?s.next:null):s.node.remove())}var Zd=(s,t)=>{if(typeof t.adapter!="function")throw new TypeError("Custom fields require options.adapter");return t.adapter(s,t)};function Ma(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",es("input","text"));C.register("password",es("input","password"));C.register("textarea",es("textarea","text"));C.register("checkbox",Gd);C.register("int",Da("int"));C.register("float",Da("float"));C.register("select",Qd);C.register("optionlist",Xd);C.register("hidden",es("input","hidden"));C.register("html",Jd);C.register("custom",Zd);function qt(s,t,e){let i=Na(t).split(/\s+/).filter(Boolean);return i.length===0?s.slice():s.filter(n=>{let r=tf(n,e).map(Na);return i.every(o=>r.some(a=>a.includes(o)))})}function tf(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 Na(s){return String(s??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var lt=class extends g{static cssName="checklist";static defaults={items:[],valueKey:"ID",labelKey:"name",checkedKey:"on",search:!0,height:280,defaultChecked:!1,hideLabel:!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 a of["role","aria-label","aria-labelledby","data-state"])this._originalAttributes.set(a,t.getAttribute(a));let e=this._message("checklist.label","Checklist"),i=x("zx-checklist-label"),n=this.options.hideLabel?null:l("div",{class:"zx-checklist__label",id:i},e),r=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}),o=l("div",{ref:"list",class:"zx-checklist__list"});return o.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,t.replaceChildren(...[n,r,o].filter(Boolean)),t.setAttribute("role","group"),n?t.setAttribute("aria-labelledby",i):t.setAttribute("aria-label",e),this.listen(r,"input",()=>this.search(r.value)),this.listen(o,"change",a=>{let c=a.target;if(!c?.matches?.('input[type="checkbox"][data-index]'))return;let u=this._visibleItems[Number(c.dataset.index)];if(u===void 0)return;let h=this._itemValue(u);c.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){ef(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 ef(s,t){return s.size===t.size&&Array.from(s).every(e=>t.has(e))}function Oa(){C.register("checklist",(s,t)=>{let e=s.own(new lt(null,{hideLabel:!0,...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 sf=new Set(["Shift","Control","Alt","Meta","AltGraph","CapsLock","Fn","OS"]),Ye=class extends g{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=Fa(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:rf(this.options.rows),wrap:of(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._tabReleased=!1,this.listen(this._input,"keydown",e=>this._handleKeydown(e)),this.listen(this._input,"blur",()=>{this._tabReleased=!1}),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=Fa(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.isComposing||sf.has(t.key))return;if(t.key==="Escape"){this._tabReleased=!0;return}let e=this._tabReleased;if(this._tabReleased=!1,e||t.key!=="Tab"||t.altKey||t.ctrlKey||t.metaKey||this._input.readOnly||this._input.disabled)return;let i=String(this.options.indent??" ");if(!i)return;t.preventDefault();let n=La(this._input.value,this._input.selectionStart??0,this._input.selectionEnd??0,i,t.shiftKey);n.value!==this._input.value&&(this._input.value=n.value,this._input.setSelectionRange(n.start,n.end),this._updatePosition(),this.emit("input",{value:this.getValue()}))}_updatePosition(){if(!this.options.status)return;let t=Ra(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 La(s,t,e,i=" ",n=!1){let r=String(s??""),o=String(i??""),a=is(t,r.length),c=is(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 u=r.lastIndexOf(`
|
|
2
|
+
`,Math.max(0,a-1))+1,h=r.indexOf(`
|
|
3
|
+
`,c);h<0&&(h=r.length);let f=r.slice(u,h).split(`
|
|
4
|
+
`),p=0,_=0,m=f.map((y,v)=>{if(!n)return _+=o.length,o+y;let A=nf(y,o);return v===0&&(p=A),_-=A,y.slice(A)}).join(`
|
|
5
|
+
`),w=n?Math.max(u,a-Math.min(p,a-u)):a+o.length;return{value:r.slice(0,u)+m+r.slice(h),start:w,end:Math.max(w,c+_)}}function Ra(s,t,e=t){let i=String(s??""),n=is(t,i.length),r=is(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 nf(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 Fa(s){let t=String(s??"text").trim().toLowerCase();return/^[a-z0-9][a-z0-9+_.-]*$/.test(t)?t:"text"}function rf(s){let t=Number(s);return Number.isFinite(t)?Math.max(2,Math.min(100,Math.round(t))):12}function of(s){return["off","soft","hard"].includes(String(s))?s:"off"}function is(s,t){let e=Number(s);return Math.max(0,Math.min(t,Number.isFinite(e)?Math.round(e):0))}function Pa(){C.register("code",(s,t)=>{let e=s.own(new Ye(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"],Va=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],qa=/%[demYyHMSaAbBs]/g;function D(s,t){return!(s instanceof Date)||Number.isNaN(s.getTime())?"":String(t).replace(qa,e=>{switch(e){case"%d":return xe(s.getDate());case"%e":return String(s.getDate());case"%m":return xe(s.getMonth()+1);case"%Y":return String(s.getFullYear()).padStart(4,"0");case"%y":return xe(s.getFullYear()%100);case"%H":return xe(s.getHours());case"%M":return xe(s.getMinutes());case"%S":return xe(s.getSeconds());case"%a":return ja("weekday",s.getDay(),Va[s.getDay()]);case"%A":return zn("weekday",s.getDay(),Va[s.getDay()]);case"%b":return ja("month",s.getMonth(),Ba[s.getMonth()]);case"%B":return zn("month",s.getMonth(),Ba[s.getMonth()]);case"%s":return String(Math.floor(s.getTime()/1e3));default:return e}})}function tt(s,t){let e=[],i="^",n=0;for(let _ of String(t).matchAll(qa)){i+=Ha(String(t).slice(n,_.index));let m=_[0],w=af(m);if(w===null)return null;i+=`(${w})`,e.push(m),n=_.index+m.length}i+=Ha(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"]??lf(o["%y"])??1970,c=(o["%m"]??1)-1,u=o["%d"]??o["%e"]??1,h=o["%H"]??0,d=o["%M"]??0,f=o["%S"]??0,p=new Date(0);return p.setHours(0,0,0,0),p.setFullYear(a,c,u),p.setHours(h,d,f,0),Number.isNaN(p.getTime())||o["%Y"]!==void 0&&p.getFullYear()!==o["%Y"]||o["%y"]!==void 0&&p.getFullYear()%100!==o["%y"]||o["%m"]!==void 0&&p.getMonth()!==c||o["%d"]!==void 0&&p.getDate()!==u||o["%e"]!==void 0&&p.getDate()!==u||o["%H"]!==void 0&&p.getHours()!==h||o["%M"]!==void 0&&p.getMinutes()!==d||o["%S"]!==void 0&&p.getSeconds()!==f?null:p}function Cn(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 W(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}function L(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 We(s=ct()){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 xe(s){return String(s).padStart(2,"0")}function zn(s,t,e){let i=`date.${s}.${t}`,n=St(i);return n===i?e:n}function ja(s,t,e){let i=`date.${s}.short.${t}`,n=St(i);return n!==i?n:zn(s,t,e).slice(0,3)}function af(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 lf(s){if(s!==void 0)return s>=69?1900+s:2e3+s}function Ha(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var In=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),Ka=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),$a=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"}),Ua=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"}),Tn=new Map;function En(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($a,i))return{provider:"fa",name:n,style:$a[i],classes:null}}return{provider:null,name:t,style:null,classes:null}}function ss(s,t={}){let{style:e="solid",family:i="classic",fixedWidth:n=!1,translate:r=!0}=t,o=String(s).replace(/^fa-/,""),a=r?Ua[o]??o:o,c=[],u=Ka[i];return u&&c.push(u),c.push(In[e]??In.solid,`fa-${a}`),n&&c.push("fa-fw"),c}function ns(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 Dn(s){let t=ns(s),e=Tn.get(t);if(e)return e;let i=new Promise((n,r)=>{let o=new URL(t,document.baseURI).href,a=[...document.scripts].find(u=>u.src===o);if(a&&globalThis.FontAwesomeKitConfig){n();return}let c=a??document.createElement("script");c.addEventListener("load",()=>n(),{once:!0}),c.addEventListener("error",()=>{Tn.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 Tn.set(t,i),i}var Ga="http://www.w3.org/2000/svg",Qa="0 0 24 24",cf=1.75,uf=1,M=s=>[Qa,s,"stroke"];var Nn=Object.freeze({"arrow-up-wide-short":M("M3 8l4-4 4 4M7 4v16M11 12h10M11 16h7M11 20h4"),"arrow-down-wide-short":M("M3 16l4 4 4-4M7 20V4M11 4h10M11 8h7M11 12h4"),"chevron-down":M("M6 9l6 6 6-6"),"chevron-up":M("M18 15l-6-6-6 6"),"chevron-left":M("M15 18l-6-6 6-6"),"chevron-right":M("M9 18l6-6-6-6"),check:M("M20 6 9 17l-5-5"),x:M("M18 6 6 18M6 6l12 12"),plus:M("M5 12h14M12 5v14"),minus:M("M5 12h14"),search:M("M21 21l-4.34-4.34M3 11a8 8 0 1 0 16 0a8 8 0 1 0-16 0z"),calendar:M("M8 2v3M16 2v3M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM3 9h18"),clock:M("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 6v6l4 2"),trash:M("M10 11v6M14 11v6M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"),gear:M("M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915M9 12a3 3 0 1 0 6 0a3 3 0 1 0-6 0z"),eye:M("M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0M9 12a3 3 0 1 0 6 0a3 3 0 1 0-6 0z"),lock:M("M5 11h14a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2zM7 11V7a5 5 0 0 1 10 0v4"),reload:M("M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8M21 3v5h-5"),list:M("M3 5h.01M3 12h.01M3 19h.01M8 5h13M8 12h13M8 19h13"),filter:M("M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"),dots:M("M11 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM18 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM4 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0z"),info:M("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 16v-4M12 8h.01"),warning:M("M21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3M12 9v4M12 17h.01"),error:M("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 8V12M12 16H12.01"),success:M("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 9l-5.5 5.5L8 12"),upload:M("M12 3v12M17 8l-5-5-5 5M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"),drag:M("M8 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0z"),star:M("M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"),heart:M("M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"),tag:M("M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42zM7 7.5a.5 .5 0 1 0 1 0a.5 .5 0 1 0-1 0z"),folder:M("M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"),"folder-open":M("M6 14l1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"),file:M("M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2zM14 2v5a1 1 0 0 0 1 1h5"),copy:M("M10 8h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-10a2 2 0 0 1-2-2v-10a2 2 0 0 1 2-2zM4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"),square:M("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2z"),code:M("M18 16l4-4-4-4M6 8l-4 4 4 4M14.5 4l-5 16"),book:M("M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20")}),hf=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list"}),On=Object.create(null),Et={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function Ge(){return{...Et}}function rs(s={}){for(let t of["provider","style","family","fixedWidth","kit"])s[t]!==void 0&&(Et[t]=s[t]);return Ge()}function Xa(s={}){return rs({...s,provider:"fontawesome"})}function df(){return rs({provider:"builtin"})}async function ff(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 rs({...n,kit:ns(e)}),await Dn(e),i?Xa():Ge()}function pf(s){for(let[t,e]of Object.entries(s)){if(!Array.isArray(e)||e.length!==2&&e.length!==3||e.length===3&&e[2]!=="fill"&&e[2]!=="stroke")throw new TypeError(`Icon "${t}" must be a [viewBox, path] pair or a [viewBox, path, 'stroke'] triple`);On[t]=e[2]==="stroke"?[String(e[0]),String(e[1]),"stroke"]:[String(e[0]),String(e[1])]}}function Fn(){return[...new Set([...Object.keys(Nn),...Object.keys(On)])].sort()}function b(s,t={}){let e=En(s);if(e.classes)return Mn(e.classes,t);let i=hf[e.name]??e.name;return e.provider==="builtin"?Ya(i,t):e.provider==="fa"?Mn(ss(i,{style:e.style??t.style??Et.style,family:t.family??Et.family,fixedWidth:t.fixedWidth??Et.fixedWidth}),t):Et.provider==="fontawesome"?Mn(ss(i,{style:t.style??Et.style,family:t.family??Et.family,fixedWidth:t.fixedWidth??Et.fixedWidth}),t):Ya(i,t)}function Ya(s,t){let e=On[s]??Nn[s];if(!e){if(t.strict)throw new RangeError(`Unknown icon: ${s}`);return bf(s),gf(s,t)}let[i,n,r="fill"]=e,o=Ja(i,r,t),a=document.createElementNS(Ga,"path");return a.setAttribute("d",n),o.append(a),o}function Ja(s,t,e){let{size:i=16}=e,n=document.createElementNS(Ga,"svg");return n.setAttribute("class",tl("zx-icon",e.class)),n.setAttribute("viewBox",s),n.setAttribute("width",String(i)),n.setAttribute("height",String(i)),t==="stroke"?(n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width",_f(s,i)),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round")):n.setAttribute("fill","currentColor"),n.setAttribute("focusable","false"),Za(n,e.label??null),n}function _f(s,t){let[,,e,i]=s.trim().split(/[\s,]+/).map(Number),n=Math.max(e,i)||24,r=cf*n/24,o=typeof t=="number"?t:/^\d*\.?\d+(px)?$/.test(String(t).trim())?parseFloat(String(t)):NaN;return o>0&&(r=Math.max(r,uf*n/o)),String(Math.round(r*1e3)/1e3)}var mf=Qa;function gf(s,t){let e=Ja(mf,"stroke",t);return e.setAttribute("data-zx-icon-missing",s),e}var Wa=new Set;function bf(s){Wa.has(s)||(Wa.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 Mn(s,t){let{size:e=16}=t,i=document.createElement("i");return i.className=tl("zx-icon",...s,t.class),i.style.fontSize=typeof e=="number"?`${e}px`:String(e),Za(i,t.label??null),i}function Za(s,t){if(t===null){s.setAttribute("aria-hidden","true");return}s.setAttribute("role","img"),s.setAttribute("aria-label",t)}function tl(...s){return s.flat().filter(Boolean).join(" ")}var yf=5,Qe=class extends g{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=el(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},b("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=el(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"?Sf(this.options.step):1,o=ve(t.currentTarget.value,0,i),a=i+1,c=(o+n*r+a*r)%a;t.currentTarget.value=te(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=te(ve(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]=ve(i.value,0,r)}let e=!this._value||!Af(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=te(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=te(this._display.h),this.refs.headMinute.textContent=te(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?wf():xf(),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&&!vf(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 wf(){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:te(e),angle:t*30,ring:"inner"})}return s}function xf(){let s=[];for(let t=0;t<60;t+=yf)s.push({value:t,label:te(t),angle:t*6,ring:"outer"});return s}function vf(s){return s>=1&&s<=12}function el(s){return s instanceof Date&&!Number.isNaN(s.getTime())?{h:s.getHours(),m:s.getMinutes(),s:s.getSeconds()}:!s||typeof s!="object"?null:{h:ve(s.h,0,23),m:ve(s.m,0,59),s:ve(s.s,0,59)}}function ve(s,t,e){let i=Number.parseInt(String(s??""),10);return Number.isFinite(i)?Math.max(t,Math.min(e,i)):t}function Sf(s){let t=Math.round(Number(s));return Number.isFinite(t)&&t>0&&t<=59?t:5}function te(s){return String(s).padStart(2,"0")}function Af(s,t){return s.h===t.h&&s.m===t.m&&s.s===t.s}var ee=class extends g{static cssName="date-picker";static defaults={value:null,min:null,max:null,weekStart:1,showWeekNumbers:!1,time:!1};render(){let t=this.el??l("div");this._min=ut(os(this.options.min)),this._max=ut(os(this.options.max)),this._value=this._normalizeValue(os(this.options.value)),this._focused=ut(this._value)??this._clampFocus(ut(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=kf(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")},b("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")},b("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")},b("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")},b("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 Qe(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 Ln(this._value)}set(t,{silent:e=!1}={}){let i=this._normalizeValue(os(t));return this._value=i,i&&(this._focused=ut(i),this._viewYear=i.getFullYear(),this._viewMonth=i.getMonth()),this._timePicker?.set(i,{silent:!0}),this._renderCalendar(),e||this.emit("change",{date:Ln(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=ut(e);return this._min&&i<this._min&&il(e,this._min),this._max&&i>this._max&&il(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=L(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=L(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=L(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",sl(o))},String(sl(o))));for(let c=0;c<7;c+=1){let u=L(o,c),h=!!(this._value&&W(u,this._value)),d=!this._inRange(u),f=l("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:W(u,this._focused)?0:-1,ariaSelected:String(h),ariaDisabled:String(d),ariaCurrent:W(u,new Date)?"date":null,ariaLabel:`${D(u,"%e")} ${D(u,"%B %Y")}`,dataset:{date:D(u,"%Y-%m-%d"),otherMonth:u.getMonth()===this._viewMonth?null:"true"}},D(u,"%e"));a.append(l("td",{role:"presentation"},f))}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=tt(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=tt(e.dataset.date,"%Y-%m-%d");if(!i)return;let n=null;if(t.key==="ArrowLeft")n=L(i,-1);else if(t.key==="ArrowRight")n=L(i,1);else if(t.key==="ArrowUp")n=L(i,-7);else if(t.key==="ArrowDown")n=L(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=L(i,-((i.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=L(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=ut(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=ut(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._timePicker?.set(e,{silent:!0}),this._renderCalendar(),n&&this._emitMonthChange(),this.emit("change",{date:Ln(e)})}_pageMonth(t){this._closeQuickPick();let e=$t(this._focused,t);this._focused=ut(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=ut(e),this._viewMonth=t,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(t){let e=ut(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 os(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function ut(s){return s?new Date(s.getFullYear(),s.getMonth(),s.getDate()):null}function Ln(s){return s?new Date(s.getTime()):null}function il(s,t){s.setFullYear(t.getFullYear(),t.getMonth(),t.getDate())}function kf(s){let t=Number(s);return Number.isInteger(t)&&t>=0&&t<=6?t:We()}function sl(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 Xe=class extends ee{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=ls(as(this.options.min)),this._max=ls(as(this.options.max)),this._value=this._normalizeMonth(as(this.options.value));let e=this._value??ls(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")},b("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")},b("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(as(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=ls(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&&zf(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 as(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function ls(s){return s?new Date(s.getFullYear(),s.getMonth(),1):null}function zf(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()}function nl(){C.register("month",(s,t)=>{let e=s.own(new Xe(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 Cf=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function rt(s,t,e={}){if(!(s instanceof Element)||!(t instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let i=Cf.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"),u=t.getAttribute("popover"),h=!1,d=null,f=()=>{},p=()=>{};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=Tf(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`),f=()=>{o&&(t.style.minWidth=`${s.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(d=new ResizeObserver(f),d.observe(s))}else t.style.position="fixed",t.style.inset="auto",t.style.margin="0",f=()=>If(s,t,{placement:i,offset:n,flip:r,matchWidth:o}),window.addEventListener("scroll",f,{capture:!0,passive:!0}),window.addEventListener("resize",f,{passive:!0}),typeof ResizeObserver=="function"&&(d=new ResizeObserver(f),d.observe(s)),p=()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)};return Ef(t),f(),{update(){h||f()},destroy(){h||(h=!0,d?.disconnect(),p(),Df(t),Rn(s,"style",a),Rn(t,"style",c),Rn(t,"popover",u))}}}function Tf(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 If(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,u=document.documentElement.clientHeight||window.innerHeight,h=e,d=rl(e),f=o.bottom+i,p=o.top-i-a.height,_=o.right+i,m=o.left-i-a.width;n&&(d==="bottom"&&f+a.height>u&&p>=0?h=cs(e,"bottom","top"):d==="top"&&p<0&&f+a.height<=u?h=cs(e,"top","bottom"):d==="right"&&_+a.width>c&&m>=0?h=cs(e,"right","left"):d==="left"&&m<0&&_+a.width<=c&&(h=cs(e,"left","right")));let w=rl(h),y,v;if(w==="bottom"||w==="top"){let A=getComputedStyle(s).direction==="rtl";h.endsWith("-end")?y=A?o.left:o.right-a.width:h.endsWith("-start")?y=A?o.right-a.width:o.left:y=o.left+(o.width-a.width)/2,v=w==="bottom"?f:p}else y=w==="right"?_:m,h.endsWith("-end")?v=o.bottom-a.height:h.endsWith("-start")?v=o.top:v=o.top+(o.height-a.height)/2;t.style.left=`${Math.round(H(y,0,Math.max(0,c-a.width)))}px`,t.style.top=`${Math.round(H(v,0,Math.max(0,u-a.height)))}px`}function rl(s){return s.split("-")[0]}function cs(s,t,e){return s.replace(t,e)}function Ef(s){if(typeof s.showPopover=="function")try{s.showPopover()}catch{}}function Df(s){if(typeof s.hidePopover=="function")try{s.hidePopover()}catch{}}function Rn(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}var Mf=6,hl=864e5;function Se(s,t){let e=et(ie(s)),i=et(ie(t));return e&&i&&e.getTime()>i.getTime()?{start:i,end:e}:{start:e,end:i}}function Je(s,t){let e=Se(s,t);return!e.start||!e.end?0:Math.round((ll(e.end)-ll(e.start))/hl)}function dl(s,t,e){let i=et(ie(s));if(!i)return null;let n=Se(t,e);return!n.start&&!n.end?null:n.end?n.start?i.getTime()<n.start.getTime()||i.getTime()>n.end.getTime()?null:W(i,n.start)?"start":W(i,n.end)?"end":"middle":W(i,n.end)?"end":null:W(i,n.start)?"start":null}function Ze(s,t={}){let e=et(ie(t.min)),i=et(ie(t.max)),n=us(t.minNights)??0,r=us(t.maxNights),{start:o,end:a}=Se(s?.start,s?.end);return o&&(o=Bn(o,e,i)),a&&(a=Bn(a,e,i)),!o||!a?{start:o,end:a}:(r!==null&&Je(o,a)>r&&(a=L(o,r)),n>0&&Je(o,a)<n&&(a=L(o,n),i&&a.getTime()>i.getTime()&&(a=new Date(i.getTime()),o=L(a,-n),e&&o.getTime()<e.getTime()))?{start:null,end:null}:{start:o,end:a})}var ti=class extends g{static cssName="date-range-picker";static defaults={start:null,end:null,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._rootAttributes=Pf(t,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=et(ie(this.options.min)),this._max=et(ie(this.options.max)),this._minNights=us(this.options.minNights)??0,this._maxNights=us(this.options.maxNights),this._weekStart=Ff(this.options.weekStart),this._monthCount=Lf(this.options.months),this._presets=Of(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let e=Ze({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(et(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),t.setAttribute("role","group"),t.setAttribute("aria-label",$("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:$("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=Ze({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=[],Bf(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=et(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=Je(this._start,e);return!(i<this._minNights||this._maxNights!==null&&i>this._maxNights)}_choose(t){let e=et(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 Bn(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=cl(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=cl(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=et(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?et(t):null;!e&&!this._hover||e&&this._hover&&W(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=L(i,-1);else if(t.key==="ArrowRight")n=L(i,1);else if(t.key==="ArrowUp")n=L(i,-7);else if(t.key==="ArrowDown")n=L(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=L(i,-((i.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=L(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=L(t,-i),r=[];for(let o=0;o<Mf;o+=1){let a=L(n,o*7),c=l("tr"),u=Rf(a,t);this.options.showWeekNumbers&&c.append(l("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:u?$("daterange.week","Week %1",[ul(a)]):null},u?String(ul(a)):""));for(let h=0;h<7;h+=1){let d=L(a,h),f=l("td",{role:"presentation"});if(d.getMonth()===t.getMonth()&&d.getFullYear()===t.getFullYear()){let p=l("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:D(d,"%Y-%m-%d")}},D(d,"%e"));f.append(p),this._dayCells.push({date:d,cell:f,button:p})}c.append(f)}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:$("daterange.previousMonth","Previous month")},b("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:$("daterange.nextMonth","Next month")},b("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:$("daterange.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let i=0;i<7;i+=1){let n=L(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)W(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);Pn(r,"range",a.range),Pn(r,"rangeEdge",a.edge),Pn(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)),W(n,t)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(t){if(this._start&&this._end){let i=dl(t,this._start,this._end);if(!i)return{range:null,edge:null};let n=W(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 W(t,this._start)?{range:"start",edge:e?"start":"both"}:e?t.getTime()>this._start.getTime()&&t.getTime()<=e.getTime()?{range:"preview",edge:W(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=et(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}, ${$("daterange.day.start","range start")}`:e==="end"?`${i}, ${$("daterange.day.end","range end")}`:e==="middle"?`${i}, ${$("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 $("daterange.status.empty","No date range selected");if(!this._end)return $("daterange.status.start","%1 selected, choose an end date",[D(this._start,"%e %B %Y")]);let t=Je(this._start,this._end),e=t===1?$("daterange.night","1 night"):$("daterange.nights","%1 nights",[t]);return`${Nf(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=>W(e.date,t))?.button??null}};function fl(){return[{name:"today",label:$("daterange.preset.today","Today"),range:()=>ol(At())},{name:"yesterday",label:$("daterange.preset.yesterday","Yesterday"),range:()=>ol(L(At(),-1))},{name:"last7",label:$("daterange.preset.last7","Last 7 days"),range:()=>({start:L(At(),-6),end:At()})},{name:"last30",label:$("daterange.preset.last30","Last 30 days"),range:()=>({start:L(At(),-29),end:At()})},{name:"thisMonth",label:$("daterange.preset.thisMonth","This month"),range:()=>al(At(),0)},{name:"lastMonth",label:$("daterange.preset.lastMonth","Last month"),range:()=>al(At(),-1)},{name:"thisQuarter",label:$("daterange.preset.thisQuarter","This quarter"),range:()=>{let s=At(),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:$("daterange.preset.thisYear","This year"),range:()=>{let s=At();return{start:new Date(s.getFullYear(),0,1),end:new Date(s.getFullYear(),11,31)}}}]}function $(s,t,e){let i=St(s);return I(i===s?t:i,e)}function Nf(s,t){if(W(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 Of(s){return s===!0?fl():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 At(){return et(new Date)}function ol(s){return{start:s,end:new Date(s.getTime())}}function al(s,t){return{start:new Date(s.getFullYear(),s.getMonth()+t,1),end:new Date(s.getFullYear(),s.getMonth()+t+1,0)}}function ie(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function et(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 Bn(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 ll(s){return Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())}function cl(s){return s.getFullYear()*12+s.getMonth()}function us(s){if(s==null||s==="")return null;let t=Number(s);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):null}function Ff(s){let t=Number(s);return Number.isInteger(t)&&t>=0&&t<=6?t:We()}function Lf(s){let t=Number(s);return Number.isInteger(t)&&t>=1&&t<=4?t:2}function Rf(s,t){for(let e=0;e<7;e+=1){let i=L(s,e);if(i.getMonth()===t.getMonth()&&i.getFullYear()===t.getFullYear())return!0}return!1}function ul(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())/hl+1)/7)}function Pn(s,t,e){e==null?delete s.dataset[t]:s.dataset[t]=e}function Pf(s,t){return new Map(t.map(e=>[e,s.getAttribute(e)]))}function Bf(s,t){for(let[e,i]of t)i===null?s.removeAttribute(e):s.setAttribute(e,i)}var Vf={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function Vn(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*",u=r===""?[i]:i.split(new RegExp(`${a}${qe(r)}${c}`));if(u.length>2)return null;let h=tt(u[0].trim(),t);if(!h)return null;if(u.length===1)return{start:h,end:new Date(h.getTime())};if(u[1].trim()==="")return{start:h,end:null};let d=tt(u[1].trim(),t);return d?Se(h,d):null}function _l(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 ei=class extends g{static cssName="date-range-box";static defaults={start:null,end:null,format:"%d.%m.%Y",separator:" \u2013 ",placeholder:null,clearable:!0,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._originalClearable=t.getAttribute("data-clearable"),t.toggleAttribute("data-clearable",!!this.options.clearable),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:pl("daterange.clear","Clear date range")},b("x",{size:13})),l("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:pl("daterange.choose","Choose date range"),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},b("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 ti(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=rt(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(),hs(this.el,"data-state",this._originalState),hs(this.el,"aria-disabled",this._originalAriaDisabled),hs(this.el,"data-clearable",this._originalClearable),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=Vn(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(Vn(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()!==""?tt(t.trim(),this._format):null}_clamp(t){return Ze(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=>Vf[e]??e);return`${t}${this._separator}${t}`}_syncDisplay(){this.refs.input.value=_l(this._range,this._format,this._separator),this._syncClear()}_syncClear(){this.refs.clear.hidden=!this.options.clearable||!(this._range.start||this._range.end)||this._disabled}_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._syncClear(),this._disabled?this._picker?.disable():this._picker?.enable()}_setValid(){this.el.dataset.state==="invalid"&&hs(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 pl(s,t,e){let i=St(s);return I(i===s?t:i,e)}function hs(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}function ml(){C.register("daterange",(s,t)=>{let e=s.own(new ei(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 it=class extends g{static cssName="datebox";static defaults={value:null,format:"%d.%m.%Y",time:!1,min:null,max:null,placeholder:null,clearable:!0,disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._originalClearable=t.getAttribute("data-clearable"),t.toggleAttribute("data-clearable",!!this.options.clearable),this._format=jf(this.options.format,this.options.time),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._min=gl(this.options.min),this._max=gl(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??Hf(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"},b("x",{size:13})),l("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:"Choose date","aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},b("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 ee(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=rt(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),this._originalClearable===null?this.el.removeAttribute("data-clearable"):this.el.setAttribute("data-clearable",this._originalClearable),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=tt(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=tt(t,this._format)),!e||Number.isNaN(e.getTime())?null:Cn(e,this._min,this._max)}_syncDisplay(){this.refs.input.value=this._value?D(this._value,this._format):"",this._syncClear()}_syncClear(){this.refs.clear.hidden=!this.options.clearable||!this._value||this._disabled}_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._syncClear()}_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}},jn=function(t,e={}){return new it(t,{...e,time:!0})};function gl(s){return s instanceof Date&&!Number.isNaN(s.getTime())?new Date(s.getTime()):null}function jf(s,t){let e=String(s||"%d.%m.%Y");return t&&!/%[HM]/.test(e)?`${e} %H:%M`:e}function Hf(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 yl(){bl("date",s=>new it(null,s)),bl("datetime",s=>jn(null,s))}function bl(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 ii=class extends g{static cssName="field-upload";static defaults={url:"",paramName:"upload",params:{},headers:{},multiple:!1,accept:null,maxSize:null,autoUpload:!0,preview:!0,http:null};render(){let t=this.el??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"},qf(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=>!Kf(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(Yf(i.responseText))}),this.listen(i,"error",()=>e(new Error("Upload request failed"))),this.listen(i,"abort",()=>e(Wf())),i.send(Uf(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 qf(s){let t=[];return s.accept&&t.push(String(s.accept)),s.maxSize!=null&&t.push(`up to ${$f(Number(s.maxSize))}`),t.join(" \xB7 ")||"Choose from this device"}function $f(s){return s<1024?`${s} B`:s<1024*1024?`${Math.round(s/1024)} KB`:`${Math.round(s/(1024*1024))} MB`}function Kf(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 Uf(s,t,e){let i=new FormData;for(let n of s)i.append(t,n);for(let[n,r]of Object.entries(e??{}))wl(i,n,r);return i}function wl(s,t,e){if(e==null)return;if(Array.isArray(e)){for(let n of e)wl(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 Yf(s){if(!s)return null;try{return JSON.parse(s)}catch{return s}}function Wf(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let s=new Error("Upload aborted");return s.name="AbortError",s}function xl(){C.register("upload",(s,t)=>{let e=s.own(new ii(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 vl=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),Sl=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),si=class extends g{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 vl[this.options.reorder]??vl.both}_renderRows(t=-1,e="value"){let i=Al(this.options.options),n=this.options.options!==null,{drag:r,buttons:o}=this._reorder(),a=this._values.length-1,c=this._values.map((u,h)=>{let d=!n||i.some(([p])=>p===u)?i:[[u,u],...i],f=n?l("select",{class:"zx-multi-value-editor__value",ariaLabel:`Value ${h+1}`,dataset:{index:h}},d.map(([p,_])=>l("option",{value:p,selected:p===u},_))):l("input",{class:"zx-multi-value-editor__value",type:"text",value:u,ariaLabel:`Value ${h+1}`,dataset:{index:h}});return l("div",{class:"zx-multi-value-editor__row",dataset:{row:h}},r?l("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:`Reorder value ${h+1}. Use the arrow keys to move it.`,dataset:{action:"grab",index:h}},b("drag",{size:12})):null,f,l("div",{class:"zx-multi-value-editor__controls"},o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(h===0),ariaLabel:`Move value ${h+1} up`,dataset:{action:"up",index:h}},b("chevron-up",{size:12})):null,o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(h===a),ariaLabel:`Move value ${h+1} down`,dataset:{action:"down",index:h}},b("chevron-down",{size:12})):null,l("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${h+1}`,dataset:{action:"remove",index:h}},b("x",{size:12}))))});this._rows.replaceChildren(...c),t>=0&&c[Math.min(t,c.length-1)]?.querySelector(Sl[e]??Sl.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=Al(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 Al(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 kl(){C.register("multivalueeditor",(s,t)=>{let e=s.own(new si(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 Dt=class extends g{static cssName="number-field";static defaults={value:null,min:null,max:null,step:1,largeStep:10,precision:null,wrap:!1,placeholder:"",label:null,unit:null,disabled:!1,readonly:!1,required:!1,name:null,group:!1,locale:null};render(){this._value=null,this._disabled=!1,this._readonly=!1,this._editing=!1,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(this.el);let t=this.el??l("div");this.el=t;let e=Gf(this.options.step);this._step=e,this._precision=this.options.precision===null?Qf(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}},b(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=Ae(t,this.options.group?this._separators():null);return e===null?null:ds(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=Ae(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=zl(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=Ae(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||t.altKey||t.ctrlKey||t.metaKey)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 Ae(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 ds(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=zl(r,n),t!==null&&r<t?t:e!==null&&r>e?e:r}function Gf(s){let t=Number(s);return Number.isFinite(t)&&t>0?t:1}function Qf(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 zl(s,t){return Number.isFinite(s)?Number(s.toFixed(Math.min(15,Math.max(0,t)))):s}function Cl(){C.register("number",(s,t)=>{let e=s.own(new Dt(null,{label:t.label?String(t.label):void 0,placeholder:t.placeholder,required:t.required,name:s.name||null,...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 ri=class extends g{static cssName="rating";static defaults={value:0,max:5,allowHalf:!1,clearable:!0,readonly:!1,disabled:!1,label:"Rating",icon:"star",labels:null,showValue:!1,count:null,size:"md"};render(){this._value=0,this._preview=null,this._disabled=!1,this._readonly=!1,this._radios=[],this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(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"},b(this.options.icon,{size:ni[this.options.size]??ni.md})),l("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},b(this.options.icon,{size:ni[this.options.size]??ni.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=ni[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(Xf(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)}},ni={sm:14,md:18,lg:24};function Xf(s,t){return t<1?s.toFixed(1):String(s)}function Tl(){C.register("rating",(s,t)=>{let e=s.own(new ri(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 Jf=["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 Hn(s){let t=!1,e=null;function i(n){if(n.key!=="Tab")return;let r=Il(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),Il(s)[0]?.focus())},deactivate(){t&&(t=!1,document.removeEventListener("keydown",i),e?.isConnected&&typeof e.focus=="function"&&e.focus(),e=null)}}}function Mt(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(p=>(c(p),El(p)))}function c(p){r.has(p)||r.set(p,p.getAttribute("tabindex"))}function u(p=null){let _=a(),m=p&&_.includes(p)?p:_.find(w=>w.tabIndex===0)??_[0];for(let w of _){let y=w===m?0:-1;w.tabIndex!==y&&(w.tabIndex=y)}}function h(p){let _=a(),m=p.target?.closest?.(t)??null,w=_.indexOf(m);if(w<0)return;let y=e==="horizontal"?"ArrowLeft":"ArrowUp",v=e==="horizontal"?"ArrowRight":"ArrowDown",A=null;p.key==="Home"?A=0:p.key==="End"?A=_.length-1:p.key===y?A=w-1:p.key===v&&(A=w+1),!(A===null||_.length===0)&&(i?A=(A+_.length)%_.length:A=Math.max(0,Math.min(_.length-1,A)),p.preventDefault(),u(_[A]),_[A].focus())}function d(p){let _=p.target?.closest?.(t)??null;_&&s.contains(_)&&u(_)}s.addEventListener("keydown",h,{signal:n.signal}),s.addEventListener("focusin",d,{signal:n.signal});let f=typeof MutationObserver=="function"?new MutationObserver(()=>u()):null;return f?.observe(s,{childList:!0,subtree:!0,attributes:!0}),u(),{focusFirst(){let p=a()[0];p&&(u(p),p.focus())},focusLast(){let p=a(),_=p[p.length-1];_&&(u(_),_.focus())},destroy(){if(!o){o=!0,n.abort(),f?.disconnect();for(let[p,_]of r)_===null?p.removeAttribute("tabindex"):p.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(u=>u===e[0])&&(e=e[0]),i=setTimeout(()=>{e="",i=null},500);let a=s(),c=a.findIndex(u=>Zf(u).startsWith(e));c>=0&&t(a[c],c)}}function Il(s){return Array.from(s.querySelectorAll(Jf)).filter(t=>El(t)&&t.getClientRects().length>0)}function El(s){return!(!(s instanceof HTMLElement)||s.hidden||s.getAttribute("aria-hidden")==="true"||s.matches(":disabled"))}function Zf(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 tp=/^var\(\s*--[\w-]+\s*\)$/;function fs(s){if(typeof s!="string")return null;let t=s.trim();return tp.test(t)||we(t)?t:null}var $n=Object.freeze(["dotted","ring","progress","review","ready","waiting","done","canceled","duplicate"]),Kn=Object.freeze(["muted","neutral","warning","info","accent","success","danger"]),Un=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"]]),ep=Object.freeze({review:"in-review",cancelled:"canceled"}),qn=4;function ip(s,t={}){let e=s&&typeof s=="object"?s:null,i=sp(e?e.ID??e.id:s),n=Un.find(([a])=>a===i),r=String(t.indicator??e?.indicator??n?.[3]??"ring"),o=String(t.tone??e?.tone??n?.[4]??"muted");return{indicator:$n.includes(r)?r:"ring",tone:Kn.includes(o)?o:"muted"}}function sp(s){let t=String(s??"").trim().toLowerCase();return ep[t]??t}function Yn(s){return s==null||s===""?null:Math.max(0,Math.min(qn,Math.trunc(Number(s)||0)))}function Wn(s,t={}){let{indicator:e,tone:i}=ip(s,t??{}),n=l("span",{class:"zx-status-icon",dataset:{indicator:e,tone:i}});return e==="done"&&n.append(b("check",{size:8})),e==="canceled"&&n.append(b("x",{size:7})),Dl(n,t?.label)}function Gn(s,t={}){let e=Yn(s),i=l("span",{class:"zx-priority-icon",dataset:{level:e===null?"none":e}},e===qn?null:Array.from({length:qn},(n,r)=>l("span",{dataset:{filled:String(e!==null&&r<=e)}})));return Dl(i,t?.label)}function Dl(s,t){let e=t==null?"":String(t).trim();return e?(s.setAttribute("role","img"),s.setAttribute("aria-label",e)):s.setAttribute("aria-hidden","true"),s}var np=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],Ml=["Lowest","Low","Medium","High","Highest"],K=class s extends g{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._pointerModality=!1,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._root=t,this._snapshot=this._createdRoot?null:k(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},b("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")},b("chevron-down",{size:16})),c=l("div",{ref:"control",class:"zx-select__control"},n,i,r,o,a),u=l("div",{ref:"list",class:"zx-select__list",id:e,role:"listbox"});u.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let h=l("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},u);return t.replaceChildren(c,h),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visibleItems=this._items.slice(),this._fixedItems=Array.isArray(this.options.fixedItems)?this.options.fixedItems.slice():[],this._visibleFixed=this._fixedItems.slice(),this._actions=Nl(this.options.actions),this._disabled=!!this.options.disabled,this._handleTypeahead=ht(()=>this._optionEntries.filter(d=>!d.clear&&!d.action).map(d=>d.element),(d,f)=>{this._open||this.open(),this._setActive(this._itemEntryIndex(f))}),this.listen(i,"click",()=>this.open()),this.listen(i,"input",()=>this._onInput()),this.listen(i,"keydown",d=>{Fl(d)||t.removeAttribute("data-focus-origin"),this._onKeydown(d)}),this.listen(i,"focus",()=>{this._pointerModality&&i.readOnly?t.setAttribute("data-focus-origin","pointer"):t.removeAttribute("data-focus-origin")}),this.listen(i,"blur",()=>t.removeAttribute("data-focus-origin")),this.listen(document,"keydown",d=>{Fl(d)||(this._pointerModality=!1)},{capture:!0}),this.listen(a,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(r,"click",()=>{this.set(null),this.focus()}),this.listen(h,"pointerdown",d=>d.preventDefault()),this.listen(h,"click",d=>this._onOptionClick(d)),this.listen(document,"pointerdown",d=>{this._pointerModality=!0,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=Nl(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=rt(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=e.clearable??!0,r=null,o=()=>e.noneLabel??(r?r._message("priority.none","No priority"):"No priority");r=new s(t,{...e,clearable:n,value:null,items:[],renderItem(c){return Ol(c,!0)},renderNone:e.renderNone??(()=>Ol({level:null,name:o()},!0)),renderValueAdornment(c){return Rl(c.level)}}),n&&!e.placeholder&&(r.refs.input.placeholder=o());let a=r;return r.setItems(np.map((c,u)=>{let h=u===2?a.msg("priority.medium"):c;return(h==="priority.medium"||u!==2)&&(h=a._message(c,Ml[u])),{ID:u,name:h,level:u}})),r.set(i,{silent:!0}),r}static status(t,e={}){let{items:i=null,value:n=null,...r}=e,o=new s(t,{...r,value:null,items:[],renderItem(c){return lp(c)},renderValueAdornment(c){return Pl(c)}}),a=Array.isArray(i)?i.map(ap).filter(Boolean):Un.map(([c,u,h,d,f],p)=>({ID:c,name:o._message(u,h),indicator:d,tone:f,shortcut:String(p+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:u=null,fixedItems:h=[],actions:d=[],renderItem:f=null,renderValueAdornment:p=null,..._}=e,m=(v,A=!1)=>{if(typeof u=="function")return u(v,{selected:A});let z=ps(v,o);if(z&&typeof z=="object"&&typeof z.nodeType=="number")return z.cloneNode(!0);if(typeof z!="string"||!z)return null;let T=fs(ps(v,a));return l("span",{class:"zx-select__entity-glyph",style:T?{"--zx-select-entity-color":T}:null,ariaHidden:"true"},b(z,{size:14}))},w=r?rp(r):null,y=new s(t,{..._,fixedItems:[...Array.isArray(i)?i:[],...Array.isArray(h)?h:[]],fixedLabel:Array.isArray(i)&&i.length?n:_.fixedLabel??null,actions:[...Array.isArray(d)?d:[],...w?[w]:[]],renderItem:f??(v=>{let A=m(v,!1),z=ps(v,c),T=l("span",{class:"zx-select__entity-copy"},l("span",{class:"zx-select__entity-label"},String(ps(v,_.labelKey??"name")??"")),z==null||z===""?null:l("span",{class:"zx-select__entity-subtitle"},String(z)));return l("span",{class:"zx-select__entity"},A?l("span",{class:"zx-select__entity-icon",ariaHidden:"true"},A):null,T)}),renderValueAdornment:p??(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,u=typeof i=="function"?i:null,h=u?[]:i,d=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],f=new s(t,{filter:u??a,...c,value:null,items:h,fixedItems:[],valueKey:p=>d.includes(p)?p.ID:Xn(p,r),labelKey:p=>d.includes(p)?p.name:String(Xn(p,o)??"")});return d[0].name=f._message("permission.private","Private"),d[1].name=f._message("permission.public","Public"),f.setFixedItems(d),f.set(n,{silent:!0}),f}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&&Ll(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&&Ll(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"?Qn(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(b("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=op(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 Qn(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=Qn(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 Xn(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 ps(s,t){return typeof t=="function"?t(s):s!==null&&typeof s=="object"&&typeof t=="string"?s[t]:null}function rp(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 Qn(s){return s&&typeof s=="object"&&"nodeType"in s?s:String(s??"")}function Nl(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 op(s){return typeof s=="string"?b(s):s instanceof Node?s.cloneNode(!0):null}function Ol(s,t){return l("span",{class:"zx-select__priority"},Rl(s.level),t?l("span",{},String(s.name)):null)}function Rl(s){let t=Gn(Yn(s));return t.classList.add("zx-select__priority-icon"),t}function ap(s){return!s||typeof s!="object"||s.ID==null||s.name==null?null:{...s,name:String(s.name),indicator:$n.includes(String(s.indicator))?String(s.indicator):"ring",tone:Kn.includes(String(s.tone))?String(s.tone):"muted",description:s.description==null?"":String(s.description),shortcut:s.shortcut==null?"":String(s.shortcut)}}function lp(s){return l("span",{class:"zx-select__status"},Pl(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 Pl(s){let t=Wn({indicator:s.indicator??"ring",tone:s.tone??"muted"});return t.classList.add("zx-select__status-indicator"),t}function Xn(s,t){return typeof t=="function"?t(s):s===null||typeof s!="object"?s:s[t]}function Fl(s){return["Shift","Control","Alt","Meta","CapsLock"].includes(s.key)||s.ctrlKey||s.metaKey}function Ll(s){return s.key.length===1&&!s.ctrlKey&&!s.metaKey&&!s.altKey}function Bl(){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,i==="priority"&&e.clearable===void 0&&(n.clearable=!t.required);let r=s.own(i==="priority"?K.priority(null,n):i==="status"?K.status(null,n):new K(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 oi=class extends g{static cssName="slider";static defaults={value:0,min:0,max:100,step:1,label:"",hideLabel:!1,showValue:!0,showBounds:!1,showInput:!1,unit:"",marks:null,disabled:!1,readonly:!1,size:"md",formatValue:null};render(){this._value=0,this._readonly=!!this.options.readonly,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(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&&cp.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":String(this._ratio(n))}},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)?ds(e,{min:this._min,max:this._max,step:this._step,precision:Vl(this._step)}):this._min}_ratio(t){return H((t-this._min)/(this._max-this._min),0,1)}_format(t){let e=this.options.formatValue;return typeof e=="function"?String(e(t)):`${up(t)}${this.options.unit??""}`}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}},cp=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function Vl(s){let t=String(s),e=/e-(\d+)$/i.exec(t);return e?Number(e[1]):(t.split(".")[1]??"").length}function up(s){return String(Number(s.toFixed(6)))}function jl(){C.register("slider",(s,t)=>{let e=s.own(new oi(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 hp=Object.freeze(["neutral","accent","success","warning","danger","info"]),dp=Object.freeze(["soft","solid","outline"]),Hl=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),fp=Object.freeze({label:"",icon:null,kind:"neutral",tone:null,variant:"soft",size:"md",dot:!1});function dt(s={}){let t={...fp,...s},e=l("span",{class:"zx-badge",title:t.title,dataset:{kind:_p(t.kind),variant:mp(t.variant),size:gp(t.size),tone:Jn(t.tone)??void 0}});return t.dot?e.append(l("span",{class:"zx-badge__dot",ariaHidden:"true"})):t.icon&&e.append(b(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 pp(s){let t=l("span",{class:"zx-badge-group"});return t.append(...s),t}function _p(s){return hp.includes(s)?s:"neutral"}function mp(s){return dp.includes(s)?s:"soft"}function Jn(s){return Hl.includes(s)?s:null}function gp(s){return s==="sm"?"sm":"md"}var ai=class extends g{static cssName="tag-picker";static defaults={items:[],values:[],valueKey:"ID",labelKey:"name",iconKey:"icon",colorKey:"color",toneKey:"tone",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:k(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")},b("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",u=>{let h=u.target;h.closest(".zx-tag-picker__remove")||h.closest(".zx-tag-picker__toggle")||(u.target!==n&&(u.preventDefault(),this.focus()),this._open||this.open())}),this.listen(i,"click",u=>{let h=u.target.closest(".zx-tag-picker__remove");if(!h||this._disabled||this._readonly)return;u.stopPropagation();let d=[...i.children].indexOf(h.closest(".zx-tag-picker__tag")),f=this._selected[d];f!==void 0&&(this.removeValue(this._valueOf(f)),this.focus())}),this.listen(n,"input",()=>this._onInput()),this.listen(n,"keydown",u=>this._onKeydown(u)),this.listen(n,"blur",()=>this.el.removeAttribute("data-focus")),this.listen(n,"focus",()=>this.el.setAttribute("data-focus","")),this.listen(r,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(c,"pointerdown",u=>u.preventDefault()),this.listen(c,"click",u=>this._onOptionClick(u)),this.listen(document,"pointerdown",u=>{this._open&&!t.contains(u.target)&&this.close()},{capture:!0}),this.setValues(this.options.values,{silent:!0}),this._syncDisabled(),t}get values(){return this.getValues()}set values(t){this.setValues(t)}getValues(){return this._selected.map(t=>this._valueOf(t))}getItems(){return this._selected.slice()}setValues(t,{silent:e=!1}={}){let 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(u=>this._sameValue(u,c))&&r.push(c)}let o=!bp(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=rt(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._toneOf(e),r=n?null:this._colorOf(e),o=this.options.renderTag?this.options.renderTag(e):[this._iconOf(e),l("span",{class:"zx-tag-picker__tag-label"},i)],a=l("span",{class:"zx-tag-picker__tag",dataset:{colored:String(!!r),tone:n??void 0},style:r?{"--zx-tag-color":r}:null},o);return!this._readonly&&!this._disabled&&a.append(l("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[i])},b("x",{size:11}))),a});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?b("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"},b("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=>ql(this._labelOf(n))===ql(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()?b(e,{size:12}):null;if(!i)return null;let n=this._toneOf(t),r=n?null:this._colorOf(t);return l("span",{class:"zx-tag-picker__visual",dataset:{tone:n??void 0},style:r?{"--zx-tag-color":r}:null,ariaHidden:"true"},i)}_colorOf(t){return fs(this._readItem(t,this.options.colorKey))}_toneOf(t){return Jn(this._readItem(t,this.options.toneKey))}_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 ql(s){return String(s??"").trim().toLocaleLowerCase()}function bp(s,t,e){return s.length!==t.length?!1:s.every((i,n)=>Object.is(e(i),e(t[n])))}function $l(){C.register("tagpicker",(s,t)=>{let e=s.own(new ai(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 Kl(s,t="minutes"){let e=Math.round(Math.abs(Yl(se(s),t)));return{hours:Math.floor(e/3600),minutes:Math.floor(e/60)%60,seconds:e%60,negative:se(s)<0}}function Ul(s,t="minutes"){li(t);let e=Math.abs(Math.trunc(se(s?.hours))),i=Math.abs(Math.trunc(se(s?.minutes))),n=Math.abs(Math.trunc(se(s?.seconds))),r=s?.negative?-1:1;return Wl(r*(e*3600+i*60+n),t)}var Nt=class extends g{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){li(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 Ul(this._readParts(),t)}set(t,e=this.options.unit,i={}){e&&typeof e=="object"&&(i=e,e=this.options.unit),li(e);let n=se(t);return!this.options.signed&&n<0&&(n=0),this.options.seconds||(n=Wl(Math.round(Yl(n,e)/60)*60,e)),this._parts=Kl(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(se(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]):yp(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 se(s){let t=Number(s);return Number.isFinite(t)?t:0}function Yl(s,t){return li(t),t==="hours"?s*3600:t==="minutes"?s*60:s}function Wl(s,t){return li(t),t==="hours"?s/3600:t==="minutes"?s/60:s}function li(s){if(s!=="hours"&&s!=="minutes"&&s!=="seconds")throw new RangeError(`Unknown time unit: ${s}`)}function yp(s){return String(s).padStart(2,"0")}function Gl(){C.register("time",(s,t)=>{let e=s.own(new Nt(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 ot=class extends g{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:wp(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&&xp(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function wp(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function xp(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 Ql(){C.register("toggle",(s,t)=>{let e=s.own(new ot(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 ci=class extends g{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=Xl(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=Xl(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 Xl(s,t){if(!Array.isArray(s))return[];let e=s.map(i=>String(i));return t?[...new Set(e)]:e}function Jl(){C.register("valuelist",(s,t)=>{let e=s.own(new ci(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 ke=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),vp=["xl","lg","md","sm"];function Zn(s){let t=Number(s);if(!Number.isFinite(t))return"xs";for(let e of vp)if(t>=ke[e])return e;return"xs"}function tr(s,t){if(s==="xs")return!0;let e=ke[s];if(e===void 0)throw new RangeError(`Unknown breakpoint "${s}"`);return Number(t)>=e}function ui(s,t={}){if(typeof s!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in t&&!E(t.target)&&t.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let e=t.target??globalThis,i=E(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 f=Zn(d);f!==n&&(n=f,s(n,d))};c();let u=0,h=()=>{u||r||(u=requestAnimationFrame(()=>{u=0,c()}))};return i&&typeof ResizeObserver=="function"?(o=new ResizeObserver(h),o.observe(i)):globalThis.addEventListener?.("resize",c,{passive:!0}),{current:()=>n??Zn(a()),destroy:()=>{r||(r=!0,u&&cancelAnimationFrame(u),o?.disconnect(),globalThis.removeEventListener?.("resize",c))}}}var Zl="data-zx-motion",Sp='[data-zx-motion="reduced"]',tc="(prefers-reduced-motion: reduce)";function hi(s){if(Ap())return!0;let t=s??globalThis.document?.documentElement??null;return kp(t)}function er(s,t,e={}){if(typeof t!="function")throw new TypeError("watchMotion requires a callback");let{signal:i,immediate:n=!1}=e;if(i?.aborted)return()=>{};let r=hi(s),o=!1,a=()=>{if(o)return;let d=hi(s);d!==r&&(r=d,t(d))},c=typeof globalThis.matchMedia=="function"?globalThis.matchMedia(tc):null;c?.addEventListener?.("change",a);let u=typeof MutationObserver=="function"?new MutationObserver(a):null;if(u)for(let d of zp(s))u.observe(d,{attributes:!0,attributeFilter:[Zl],subtree:!0});let h=()=>{o||(o=!0,c?.removeEventListener?.("change",a),u?.disconnect(),i?.removeEventListener("abort",h))};return i?.addEventListener("abort",h,{once:!0}),n&&t(r),h}function Ap(){return typeof globalThis.matchMedia=="function"&&globalThis.matchMedia(tc).matches}function kp(s){let t=s;for(;t&&typeof t.closest=="function";){if(t.closest(Sp))return!0;let e=t.getRootNode?.();t=ec(e)?e.host:null}return!1}function zp(s){let t=[],e=s;for(;e&&typeof e.getRootNode=="function";){let n=e.getRootNode();if(!ec(n))break;t.push(n),e=n.host}let i=(s?.ownerDocument??globalThis.document)?.documentElement;return i&&t.push(i),t}function ec(s){return!!s&&s.nodeType===11&&"host"in s}var _s=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,u=this.timeout>0?setTimeout(()=>c.abort(),this.timeout):null,h=new Headers(this.headers);for(let[p,_]of Object.entries(a))h.set(p,_);h.set("Accept",h.get("Accept")??"application/json");let d;r!==null?(d=Ip(n,r),h.delete("Content-Type")):n!==null&&i.toUpperCase()!=="GET"&&i.toUpperCase()!=="HEAD"&&(d=JSON.stringify(n),h.set("Content-Type",h.get("Content-Type")??"application/json"));let f=Tp(this.base+t,o);try{let p=await fetch(f,{method:i.toUpperCase(),headers:h,body:d,signal:c.signal}),_=await p.text(),m=null;if(_!=="")try{m=JSON.parse(_)}catch(w){let y=new Error("Invalid JSON response",{cause:w});throw y.response=p,y}if(!p.ok){try{ir(m)}catch(y){throw y.response=p,y}let w=new Error(`HTTP ${p.status} ${p.statusText}`.trim());throw w.response=p,w}return ir(m)}catch(p){let _=p instanceof Error?p:new Error(String(p));if(this.onError)try{this.onError(_,{path:t,options:e})}catch{}throw _}finally{u!==null&&clearTimeout(u)}}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 Cp(s,t="",e={}){let{apiBase:i="../remotecall/",...n}=e,r=`${i}${s}${t?`:${t}`:""}/`;return new _s({...n,base:r})}function ir(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 Tp(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))ic(i,n,r);e=i.toString()}return e?s+(s.includes("?")?"&":"?")+e:s}function ic(s,t,e){if(e!=null)if(Array.isArray(e))for(let i of e)ic(s,t,i);else s.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function Ip(s,t){let e=new FormData;if(s&&typeof s=="object"&&!Array.isArray(s))for(let[n,r]of Object.entries(s))sc(e,n,r);else s!=null&&e.append("data",typeof s=="string"?s:JSON.stringify(s));let i=Ep(t)||Array.isArray(t)?Array.from(t):[t];for(let n of i)e.append("files",n);return e}function sc(s,t,e){if(e!=null)if(Array.isArray(e))for(let i of e)sc(s,t,i);else{let i=typeof Blob=="function"&&e instanceof Blob;s.append(t,typeof e=="object"&&!i?JSON.stringify(e):e)}}function Ep(s){return typeof FileList=="function"&&s instanceof FileList}var Dp=0,Mp=20,Np=3,Op=["B","KiB","MiB","GiB","TiB","PiB","EiB"],Fp=["B","kB","MB","GB","TB","PB","EB"],sr=[{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}],nc=new Map,rc=new Map;function Ot(s,t={}){let e=ms(s);if(e===null)return"";let{locale:i=ct(),decimals:n,minDecimals:r,maxDecimals:o,group:a=!0}=t;return nr(i,rr({decimals:n,minDecimals:r,maxDecimals:o,group:a}),e)}function di(s,t,e={}){let i=ms(s);if(i===null)return"";let{locale:n=ct(),decimals:r}=e,o=Bp(t);if(o===null)return Ot(i,{locale:n,decimals:r});let a=rr({decimals:r,group:!0});return nr(n,{...a,style:"currency",currency:o},i)}function fi(s,t={}){let e=ms(s);if(e===null)return"";let{locale:i=ct(),decimals:n=0}=t;return nr(i,{...rr({decimals:n,group:!0}),style:"percent"},e)}function pi(s,t={}){let e=ms(s);if(e===null)return"";let{locale:i=ct(),decimals:n=1,standard:r="iec"}=t;if(e===0)return`${Ot(0,{locale:i,decimals:0})} B`;let o=r==="si"?Fp:Op,a=r==="si"?1e3:1024,c=Math.abs(e),u=Math.min(o.length-1,Math.max(0,Math.floor(Math.log(c)/Math.log(a)))),h=c/a**u;Vp(h,u===0?0:n)>=a&&u<o.length-1&&(u+=1,h=c/a**u);let d=e<0?-h:h;return`${Ot(d,{locale:i,minDecimals:0,maxDecimals:u===0?0:n})} ${o[u]}`}function Lp(s,t={}){let e=ac(s);if(e===null)return"";let{now:i=new Date,locale:n=ct(),numeric:r="auto"}=t,o=ac(i);if(o===null)return"";let a=e.getTime()-o.getTime(),c=sr.find(({ms:h,limit:d})=>Math.abs(a)/h<d)??sr[sr.length-1],u=Math.round(a/c.ms);return Pp(n,r).format(u,c.unit)}function nr(s,t,e){let i=`${s}\0${JSON.stringify(t)}`,n=nc.get(i);return n===void 0&&(n=Rp(s,t),nc.set(i,n)),n.format(e)}function Rp(s,t){try{return new Intl.NumberFormat(s,t)}catch{try{return new Intl.NumberFormat(void 0,t)}catch{return new Intl.NumberFormat}}}function Pp(s,t){let e=`${s}\0${t}`,i=rc.get(e);if(i===void 0){try{i=new Intl.RelativeTimeFormat(s,{numeric:t})}catch{i=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"})}rc.set(e,i)}return i}function rr({decimals:s,minDecimals:t,maxDecimals:e,group:i=!0}){let n={useGrouping:i!==!1},r=oc(t??s),o=oc(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,Np)),n}function oc(s){if(s==null)return null;let t=Number(s);return Number.isFinite(t)?Math.min(Mp,Math.max(Dp,Math.round(t))):null}function ms(s){if(s==null||s==="")return null;let t=typeof s=="number"?s:Number(s);return Number.isFinite(t)?t:null}function Bp(s){if(typeof s!="string")return null;let t=s.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function ac(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 Vp(s,t){let e=10**t;return Math.round(s*e)/e}var lc="zx:__probe__";function _i(s,t={}){let{area:e="local"}=t,i=`zx:${String(s??"")}:`,n=new Map,r=jp(e),o=h=>{if(r!==null)try{return r.getItem(h)}catch{r=null}return n.has(h)?n.get(h):null},a=(h,d)=>{if(r!==null)try{r.setItem(h,d);return}catch{r=null}n.set(h,d)},c=h=>{if(r!==null)try{r.removeItem(h)}catch{r=null}n.delete(h)},u=()=>{if(r!==null)try{let h=[];for(let d=0;d<r.length;d+=1){let f=r.key(d);typeof f=="string"&&f.startsWith(i)&&h.push(f)}return h}catch{r=null}return[...n.keys()].filter(h=>h.startsWith(i))};return{get(h,d){let f=o(i+h);if(f==null)return d;try{return JSON.parse(f)}catch{return d}},set(h,d){let f;try{f=JSON.stringify(d)}catch{f=void 0}f===void 0?c(i+h):a(i+h,f)},remove(h){c(i+h)},keys(){return u().map(h=>h.slice(i.length))},clear(){for(let h of u())c(h)}}}function jp(s){let t=s==="session"?"sessionStorage":"localStorage";try{let e=globalThis[t];return!e||typeof e.getItem!="function"?null:(e.setItem(lc,"1"),e.removeItem(lc),e)}catch{return null}}var Hp=["=","+","-","@"];function qp(s,t,e={}){let{delimiter:i=",",header:n=!0,newline:r=`\r
|
|
9
|
+
`}=e,o=Up(t),a=[];n&&a.push(o.map(c=>uc(c.label,i,cc(c.label))).join(i));for(let c of s??[]){let u=o.map(h=>{let d=typeof h.value=="function"?h.value(c):Yp(c,h.id);return uc(Wp(d),i,cc(d))});a.push(u.join(i))}return a.join(r)}function $p(s,t,e={}){let{type:i="text/plain;charset=utf-8"}=e,n=Gp(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 or(s){let t=String(s??"");if(globalThis.navigator?.clipboard?.writeText)try{return await navigator.clipboard.writeText(t),!0}catch{}return Kp(t)}function Kp(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 Up(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 Yp(s,t){return s?.[t]}function Wp(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 cc(s){return typeof s!="string"?!1:Hp.includes(s.charAt(0))}function uc(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 Gp(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 g{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:Qp(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,this._labels=hc(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"},b("square",{size:15})),l("span",{class:"zx-check-button__on"},b("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=hc(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&&Xp(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 hc(s){return Array.isArray(s)?{on:String(s[0]??""),off:String(s[1]??"")}:{on:String(s??""),off:String(s??"")}}function Qp(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Xp(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 Jp=".zx-scope, [data-zx-theme], [data-zx-preset]";function st(s=null){let e=(s==null?document.activeElement instanceof Element?document.activeElement:null:q(s))?.closest?.(Jp)??null;return!e||e===document.documentElement||e===document.body?document.body:e}function Yt(s=null){if(s==null)return st(null);let t=q(s);return t?.isConnected?st(t):null}var Zp=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(","),mi=class extends g{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),fc(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||!e_(this.el,i)||this.close()}),this.on("close",()=>this.#o())}mountTarget(){return st(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=t_(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._mountInitial(t),t}_mountInitial(t){this.options.scope!=null&&!Yt(this.options.scope)||this.mountTarget().append(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(i_()),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 fc(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 t_(s){let t=s.querySelector("[autofocus]:not([disabled])");if(t&&dc(t,s))return t;for(let e of s.querySelectorAll(Zp))if(dc(e,s))return e;return null}function dc(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 fc(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 e_(s,t){let e=s.getBoundingClientRect();return t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom}function i_(){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 s_=Object.freeze({size:"md",label:"",showLabel:!1,kind:"accent"}),n_=Object.freeze({sm:!0,md:!0,lg:!0});function gi(s={}){let t={...s_,...s},e=String(t.label??""),i=l("span",{class:"zx-spinner",dataset:{size:n_[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 r_=Object.freeze({label:"",icon:null,kind:"default",size:"md",disabled:!1});function j(s={}){let t={...r_,...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:a_(t.kind),size:l_(t.size)}});return t.icon&&e.append(b(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),t.busy&&pc(e,!0),e}function o_(s){let t=l("div",{class:"zx-btn-group",role:"group"});return t.append(...s),t}function pc(s,t){if(s.hasAttribute("data-busy-guard")||(s.setAttribute("data-busy-guard",""),s.addEventListener("click",e=>{s.getAttribute("aria-busy")==="true"&&(e.preventDefault(),e.stopImmediatePropagation())},{capture:!0})),s.querySelector(":scope > .zx-btn__spinner")?.remove(),t){s.setAttribute("aria-busy","true"),s.setAttribute("aria-disabled","true");let e=gi({size:"sm",kind:"current"});e.classList.add("zx-btn__spinner"),s.prepend(e)}else s.removeAttribute("aria-busy"),s.removeAttribute("aria-disabled");return s}function a_(s){return["primary","danger","ghost"].includes(String(s))?s:"default"}function l_(s){return s==="sm"?"sm":"md"}var Wt=class s extends mi{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=gs(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._mountInitial(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,h_(this.refs.content,t),this}setButtons(t){return this.#i=gs(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"});mc(r,e?.content??null);let o={key:i,content:r,buttons:e&&Object.hasOwn(e,"buttons")?gs(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,confirmText:o=null}={}){return new Promise(a=>{let c=!1,u=_=>{c||(c=!0,d.close(_),a(_))},h=o==null?"":String(o).trim(),d=new s(null,{title:t,content:h?null:e}),f={label:n??d._message("dialog.cancel","Cancel"),action:()=>u(!1),autofocus:r&&!h},p={label:i??d._message("dialog.ok","OK"),kind:r?"danger":"primary",action:()=>u(!0),autofocus:!r&&!h};if(h){let _=l("input",{class:"zx-dialog__confirm-input",id:x("zx-dialog-confirm"),type:"text",autocomplete:"off",autocapitalize:"off",spellcheck:!1,autofocus:!0}),[m,w]=c_(d._message("dialog.typeToConfirm","Type %1 to confirm"),h),y=l("label",{class:"zx-dialog__confirm-label",for:_.id},m,l("b",{},h),w);d.setContent(l("div",{class:"zx-dialog__confirm"},u_(e)?null:l("div",{class:"zx-dialog__prompt-message"},e),y,_));let v=!1,A=()=>d.setButtons([f,{...p,autofocus:!1,disabled:!v}]);A(),d.listen(_,"input",()=>{let z=_c(_.value,h);z!==v&&(v=z,A())}),d.listen(_,"keydown",z=>{let T=z;T.key!=="Enter"||T.isComposing||(T.preventDefault(),_c(_.value,h)&&u(!0))})}else d.setButtons([f,p]);d.once("close",()=>{c||(c=!0,a(!1)),d.destroy()}),d.open()})}static prompt({title:t="",message:e="",value:i="",placeholder:n="",okLabel:r,cancelLabel:o}={}){return new Promise(a=>{let c=!1,u=l("input",{class:"zx-dialog__prompt-input",value:String(i),placeholder:String(n),autofocus:!0}),h=l("div",{class:"zx-dialog__prompt"},l("div",{class:"zx-dialog__prompt-message"},e),u),d=p=>{c||(c=!0,f.close(p),a(p))},f=new s(null,{title:t,content:h});u.setAttribute("aria-label",String(t||f._message("dialog.promptValue","Prompt value"))),f.setButtons([{label:o??f._message("dialog.cancel","Cancel"),action:()=>d(null)},{label:r??f._message("dialog.ok","OK"),kind:"primary",action:()=>d(u.value)}]),f.listen(u,"keydown",p=>{p.key==="Enter"&&(p.preventDefault(),d(u.value))}),f.once("close",()=>{c||(c=!0,a(null)),f.destroy()}),f.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=gs(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 _c(s,t){let e=t==null?"":String(t).trim();return e!==""&&String(s??"").trim()===e}function c_(s,t){let e=String(s).split("%1");return e.length===1?[`${e[0]} `,""]:[e[0],e.slice(1).join(t)]}function u_(s){return s==null||s===""}function gs(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 h_(s,t){s.replaceChildren(),mc(s,t)}function mc(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 ne=class extends g{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,u=r.nextSibling;c&&c.insertBefore(o,r),o.append(...a),r.remove(),n={original:r,details:o,children:a,parent:c,next:u},i=o}}try{super(i,e)}catch(r){throw n&&gc(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:d_(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"},b("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 g?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?gc(this._adoption):!this._createdRoot&&this._original&&f_(this.el,this._original))}};function d_(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function f_(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 gc(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 re=class extends g{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:p_(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},b("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")},b("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&&__(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 p_(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function __(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 m_=new Set(["divided","bracket","line","segmented"]),bi=class extends g{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:b_(e),this._cleaned=!1,this._tabs=[],this._active=null,this._keepAlive=!!this.options.keepAlive,this._initializing=!0,!m_.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",ariaLabel:this.options.label||null}),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 u=this._recordForTab(c);if(!(!u||u.definition.disabled)){if(a.target.closest?.(".zx-tabbox__close")){this._closeTab(u);return}this._setFocused(u),this.openTab(u.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(!g_(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"},b(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")},b("x",{size:14})));let u=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),h=l("div",{class:"zx-tabbox__panel",id:r,role:"tabpanel",tabindex:"0",ariaLabelledby:n,hidden:!0}),d={definition:i,tab:u,title:o,badge:a,panel:h,built:!1},f=Number.isFinite(e.index)?Math.trunc(e.index):this._tabs.length,p=Math.max(0,Math.min(this._tabs.length,f)),_=this._tabs[p]??null;return this._tabs.splice(p,0,d),this.refs.tablist.insertBefore(u,_?.tab??null),this._keepAlive&&this.refs.panels.insertBefore(h,_?.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&&y_(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 g?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 g_(s){return typeof s=="function"||s instanceof g?!0:!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function b_(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function y_(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 w_(s,t){return String(s).localeCompare(String(t))}function x_(s,t){return s-t}function v_(s,t){return s.getTime()-t.getTime()}function S_(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=v_(s,t):typeof s=="number"&&typeof t=="number"?r=x_(s,t):r=w_(s,t),e==="desc"?-r:r}function A_(s,t="asc"){return(e,i)=>S_(s(e),s(i),t)}function yi(s,t,e="asc"){let i=A_(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 k_=new Set(["text","number","select","date","checkbox","textarea"]),z_='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',Ft=class extends g{static cssName="table";static defaults={columns:[],data:[],rowId:"ID",sort:null,sortMode:"local",selectable:!1,stickyHeader:!0,responsive:!1,growing:!1,height:null,emptyText:null,rowClass:null,rowKind:null,rowKinds:null,zebra:!0,variant:"default",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:k(e),this._columns=yc(this.options.columns),this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._rowKind=R_(this.options.rowKind),this._rowKinds=P_(this.options.rowKinds),this._spanning=this._hasSpanningRow(),this._sortWarned=!1,this._selected=new Set,this._selectionAnchorId=null,this._sort=xc(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=j_(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=G_(this.options.growing),this._rendered=this._growStep??1/0,this._more=null,this._rovingKey=null,this._rovingCell=null,this._rovingMatched=!1,this._hierarchy=ar(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=B_(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let i of bs(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(i);return this._reconcileExpanded(),V_(this.options.variant)==="plain"&&(e.dataset.variant="plain"),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),vc(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 vc(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=yc(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=xc(o,i),this._hierarchy=ar(this.options.hierarchy,i),this._reconcileExpanded(),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(),e.silent||(ws(n,this.getColumnOrder())||this.emit("columnorderchange",{order:this.getColumnOrder()}),ws(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=K_(this._columns,t);if(ws(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=ar(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=U_(this.getColumnOrder(),String(t),String(e),i);if(ws(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 ${xs(o)} 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=zc(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),u=c.findIndex(h=>Object.is(h,t));this._rowMoveMessage.textContent=`Moved row to position ${u+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 W_(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=bs(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(f=>f.id===e);if(!i)return this;let n=this._data.find(f=>Object.is(this._idFor(f),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(f=>ze(f,n)!==!1)??null:i;if(!r||ze(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(f=>Object.is(this._idFor(f),t));if(a<0)return this;let c=this._data[a],u=this._rowElements.get(t)?.[0];if(!u)return this;let h=this._editMode==="row"?this._visibleColumns().filter(f=>ze(f,c)!==!1):[r],d=new Map;for(let f of h){let p=wc(u,f.id);if(!p)continue;let _=this._createEditor(p,f,c,a);_&&d.set(f.id,_)}return d.size===0?this:(this._edit={id:t,columnId:o,row:c,cells:d,tr:u},u.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,f]of t.cells)i[d]=f.read();let n=this._columns.filter(d=>t.cells.has(d.id)),r=L_(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=F_(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 u=this._editHasFocus(),h={...e,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(t.id,h),u&&this._focusCell(this._idFor(h),a),this}cancelEdit(){return this._abortEdit({focus:!0}),this}isEditing(){return this._edit!==null}getEditing(){return this._edit?{id:this._edit.id,columnId:this._edit.columnId}:null}_visibleData(){return this._visibleEntries().map(t=>t.row)}_projectedData(){return this._hierarchy?E_(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 ke)||(this._width=ui((e,i)=>this._setStacked(i>0&&i<ke[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:kc(t,this._rowKind,this._rowKinds)}_hasSpanningRow(){return C_(this._data,this._rowKind,this._rowKinds)}_spanColspan(){return T_(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-btn",dataset:{size:"sm"}},b("fields"),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,u=xs(n),h=c?l("label",{for:a},c,l("span",{},u)):l("span",{class:"zx-table__column-label"},u),d=this.options.columnReorder?l("span",{class:"zx-table__column-order",role:"group",ariaLabel:this._message("table.moveColumn","Move %1",[u])},l("button",{class:"zx-table__column-move",type:"button",disabled:r===0,ariaLabel:`Move ${u} earlier`,dataset:{columnId:n.id,columnAction:"up"}},b("chevron-up",{size:11})),l("button",{class:"zx-table__column-move",type:"button",disabled:r===this._columns.length-1,ariaLabel:`Move ${u} later`,dataset:{columnId:n.id,columnAction:"down"}},b("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?ft(this._hierarchy.parentId,e):null;return this._data.filter(n=>!this._hierarchy||cr(ft(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&&cr(ft(this._hierarchy.parentId,i),ft(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=>Y_(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",dataset:{column:e.id}}),n=e.align??(lr(e)?"end":null);n&&(i.dataset.align=n),e.headerTitle&&(i.title=e.headerTitle);let r=q_(e);if(r!==null&&i.setAttribute("aria-label",r),e.sortable&&!this._spanning){let o=l("button",{class:"zx-table__sort-button",type:"button",ariaLabel:r??void 0},l("span",{class:"zx-table__header-label"},e.label));this.listen(o,"click",()=>{let a=this._sort?.id===e.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(e.id,a)}),i.append(o)}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:Sc(t,this._rowKind),c=a===null?null:Ac(this._rowKinds,a),u=!!c?.span;a!==null&&(r.dataset.rowKind=a),c?.class&&r.classList.add(...String(c.class).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&!u&&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 h=this._rowElements.get(n)??[];if(h.push(r),this._rowElements.set(n,h),u){r.dataset.span="true";let d=l("th",{class:"zx-table__section-cell",scope:"colgroup",colspan:this._spanColspan()}),f=I_(t,c,this._visibleColumns(),e);return f&&typeof f=="object"&&typeof f.nodeType=="number"?d.append(f):f!=null&&d.append(document.createTextNode(String(f))),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},b("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 f=l("td"),p=d.align??(lr(d)?"end":null);p&&(f.dataset.align=p),f.dataset.label=d.label,f.dataset.column=d.id,d.popin===!1&&(f.dataset.popin="false"),this._editMode!==!1&&ze(d,t)!==!1&&(f.dataset.editable="true",f.tabIndex=-1,this._offerRovingCell(f,n,d.id)),this._renderCellContent(f,d,t,e,i),r.append(f)}),r}_renderCellContent(t,e,i,n,r=this._hierarchyMeta?.get(this._idFor(i))){let o=ur(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 u=this._expanded.has(r.id);c.append(l("button",{class:"zx-table__tree-toggle",type:"button",ariaExpanded:String(u),ariaLabel:`${u?"Collapse":"Expand"} row ${n+1}`},b(u?"chevron-down":"chevron-right",{size:14})))}else c.append(l("span",{class:"zx-table__tree-spacer",ariaHidden:"true"}));c.append(a),t.replaceChildren(c)}_handleBodyClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(this._edit&&ys(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(!(this._editMode!==!1&&bc(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&&ys(e))return;let i=e?.closest("tr[data-row]");if(!i||!this._tbody.contains(i))return;let n=this._rowMeta.get(i);if(n&&!(this._editMode!==!1&&bc(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=ze(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 u=l("div",{class:"zx-table__editor",dataset:{editor:r}});t.replaceChildren(c,u),t.dataset.editing="true";let h={column:e,type:r,td:t,host:u,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(r==="custom"){h.custom=o,h.read=()=>oe(e,h.custom,i);let p={value:o,row:i,column:e,commit:m=>{h.custom=m,this.commitEdit()},cancel:()=>this.cancelEdit()},_=e.editor(i,p);return _&&typeof _.toElement=="function"?(typeof _.destroy=="function"&&(h.component=_),u.append(_.toElement())):_&&u.append(_),h.control=u.querySelector(z_)??u,h}if(r==="number"){let p=ae(e.locale,i),_=Cc(e,i),m=e.type==="currency"?ae(e.currency,i):e.type==="unit"?ae(e.unit,i):null,w={...p!=null&&!Object.prototype.hasOwnProperty.call(a,"locale")?{locale:p}:{},..._!=null&&!Object.prototype.hasOwnProperty.call(a,"precision")?{precision:_}:{},...m!=null&&!Object.prototype.hasOwnProperty.call(a,"unit")?{unit:String(m)}:{}},y=new Dt(null,{...w,...a,value:o??null});return u.append(y.el),h.component=y,h.control=y.getInput(),h.read=()=>(y.set(y.getInput().value,{silent:!0}),oe(e,y.get(),i)),h}if(r==="select"){let p=M_(e.options,i),_=p.find(w=>Object.is(w.value,o))??p.find(w=>String(w.value)===String(o??"")),m=new K(null,{...a,items:p,valueKey:"value",labelKey:"label",value:_?_.value:null});return u.append(m.el),h.component=m,h.control=m.refs.input,h.read=()=>oe(e,m.value,i),h}if(r==="date"){let p=new it(null,{...a,value:o??null});u.append(p.el),h.component=p;let _=p.refs.input;return h.control=_,h.read=()=>{let m=String(_.value??"").trim(),w=p.get();return m===""?oe(e,null,i):(p.set(m,{silent:!0}),p.get()===null&&p.set(w,{silent:!0}),oe(e,p.get(),i))},h}if(r==="checkbox"){let p=new ot(null,{...a,checked:!!o});return u.append(p.el),h.component=p,h.control=p.el,h.read=()=>oe(e,p.get(),i),h}let d=r==="textarea",f=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??`${xs(e)} row ${n+1}`,value:N_(e,o,i)});return u.append(f),h.control=f,h.read=()=>oe(e,f.value,i),h}_focusEditor(t){let e=this._edit?.cells.get(t),i=e?.control;!i||typeof i.focus!="function"||(i.focus(),$_(e.type)&&typeof i.select=="function"&&i.select())}_focusCell(t,e){let i=this._rowElements.get(t)?.[0];(i?wc(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&&ys(e)){if(H_(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 u=n.findIndex(d=>d.id===e),h=o.length*r+r;for(let d=0;d<h;d+=1){if(u+=i,u>=r?(c+=1,u=0):u<0&&(c-=1,u=r-1),c<0||c>=o.length)return null;let f=o[c],p=n[u];if(!this._isSpanningRow(f)&&ze(p,f)!==!1)return{id:this._idFor(f),columnId:p.id,index:this._data.indexOf(f)}}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&&ys(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(u=>Object.is(this._idFor(u),t.id)),a=Math.min(r,o),c=Math.max(r,o);for(let u=a;u<=c;u+=1){if(this._isSpanningRow(n[u]))continue;let h=this._idFor(n[u]);e?this._selected.add(h):this._selected.delete(h)}}else e?this._selected.add(t.id):this._selected.delete(t.id);this._selectionAnchorId=t.id,this._syncSelection(),this._emitSelectionChange()}_syncSelection(){for(let[t,e]of this._rowElements){let 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?D_(this._data,this.options.rowId,this._hierarchy.parentId,e,this._sort.dir):yi(this._data,e,this._sort.dir)}_setRowExpanded(t,e,i){return this._hierarchy?bs(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=bs(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 Sc(s,t){if(t==null||t==="")return null;let e=typeof t=="function"?t(s):s?.[t];return e==null?null:String(e)}function Ac(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 kc(s,t,e){return!!Ac(e,Sc(s,t))?.span}function C_(s,t,e){return!Array.isArray(s)||t==null||e==null?!1:s.some(i=>kc(i,t,e))}function T_(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 I_(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 ur(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=ae(s.locale,t),o=Cc(s,t),a={...r!=null?{locale:String(r)}:{},...o!=null?{decimals:o}:{}};if(n==="number")return Ot(i,a);if(n==="currency"){let c=ae(s.currency,t);return di(i,c==null?null:String(c),a)}if(n==="percent")return fi(i,a);if(n==="unit"){let c=Ot(i,a),u=ae(s.unit,t);return c&&u!=null&&String(u)!==""?`${c}\xA0${u}`:c}return i}function E_(s,t,e,i=[]){let n=vs(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:u}=a.pop();if(o.push({row:c.row,id:c.id,index:c.index,depth:u,hasChildren:c.children.length>0,parentId:c.parent?.id??null}),!!r.has(c.id))for(let h=c.children.length-1;h>=0;h-=1)a.push({node:c.children[h],depth:u+1})}return o}function D_(s,t,e,i,n){let r=vs(s,t,e),o=u=>yi(u,h=>i(h.row),n),a=[],c=o(r.roots).reverse();for(;c.length;){let u=c.pop();a.push(u.row);let h=o(u.children);for(let d=h.length-1;d>=0;d-=1)c.push(h[d])}return a}function zc(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(ft(t,d),e)),a=s.findIndex(d=>Object.is(ft(t,d),i));if(o<0||a<0||r&&!cr(ft(r,s[o]),ft(r,s[a])))return null;if(r){let d=vs(s,t,r),f=d.nodes[o],p=d.nodes[a];if(!f||!p||f.parent!==p.parent)return null;let _=T=>{let N=[],nt=[T];for(;nt.length;){let O=nt.pop();N.push(O);for(let Z=O.children.length-1;Z>=0;Z-=1)nt.push(O.children[Z])}return N},m=new Set(_(f).map(T=>T.index)),w=new Set(_(p).map(T=>T.index)),y=s.filter((T,N)=>m.has(N)),v=s.filter((T,N)=>!m.has(N)),A=s.map((T,N)=>N).filter(T=>!m.has(T)),z=A.findIndex(T=>T===a);if(n==="after"){let T=A.map((N,nt)=>w.has(N)?nt:-1).filter(N=>N>=0);z=Math.max(...T)+1}return z<0?null:(v.splice(z,0,...y),v)}let c=[...s],[u]=c.splice(o,1),h=c.findIndex(d=>Object.is(ft(t,d),i));return c.splice(h+(n==="after"?1:0),0,u),c}function ze(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?lr(s)?"number":"text":typeof e=="string"&&k_.has(e)?e:!1}function M_(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 N_(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 oe(s,t,e){return typeof s?.parse=="function"?s.parse(t,e):t}function O_(s,t){return Object.is(s,t)?!0:s instanceof Date&&t instanceof Date?s.getTime()===t.getTime():!1}function F_(s,t){let e={};for(let[i,n]of Object.entries(t??{}))O_(s?.[i],n)||(e[i]=n);return e}function L_(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 ae(s,t){return typeof s=="function"?s(t):s}function Cc(s,t){let e=ae(s?.decimals,t);if(e==null)return null;let i=Number(e);return Number.isFinite(i)?Math.max(0,Math.trunc(i)):null}function lr(s){return["number","currency","percent","unit"].includes(s?.type)}function vs(s,t,e){let i=(Array.isArray(s)?s:[]).map((a,c)=>({row:a,id:ft(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=ft(e,a.row),u=c==null?null:n.get(c)??null;r.set(a,u===a?null:u)}for(let a of i){let c=new Set([a]),u=r.get(a)??null;for(;u;){if(c.has(u)){r.set(u,null);break}c.add(u),u=r.get(u)??null}}let o=[];for(let a of i)a.parent=r.get(a)??null,a.parent?a.parent.children.push(a):o.push(a);return{roots:o,nodes:i}}function bs(s,t,e){return vs(s,t,e).nodes.filter(i=>i.children.length>0).map(i=>i.id)}function ft(s,t){return typeof s=="function"?s(t):t?.[s]}function cr(s,t){return s==null&&t==null||Object.is(s,t)}function ar(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 R_(s){return typeof s=="function"||typeof s=="string"&&s!==""?s:null}function P_(s){return!s||typeof s!="object"||Array.isArray(s)?null:s}function B_(s){return new Set(Array.isArray(s)?s:[])}function V_(s){return s==="plain"?"plain":"default"}function j_(s){return s==="cell"||s==="row"?s:s===!0?"cell":!1}function ys(s){return!!s?.closest?.(".zx-table__editor")}function bc(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 H_(s){return s.closest("[popover]")?!0:s.getAttribute?.("aria-expanded")==="true"}function yc(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 xs(s){for(let t of[s?.ariaLabel,s?.label]){let e=t==null?"":String(t).trim();if(e)return e}return String(s?.id??"")}function q_(s){let t=s?.label==null?"":String(s.label).trim(),e=s?.ariaLabel==null?"":String(s.ariaLabel).trim();return e||(t?null:xs(s)||null)}function $_(s){return s==="text"||s==="number"||s==="date"}function K_(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 U_(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 wc(s,t){for(let e of s.cells)if(e.dataset.column===t)return e;return null}function xc(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 Y_(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 vc(s){if(!Array.isArray(s))throw new TypeError("Table data must be an array")}function W_(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}function ws(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function G_(s){let t=Math.trunc(Number(s));return Number.isFinite(t)&&t>0?t:null}var pt=Symbol("invalid attribute");function Ce(s,t="string",e=console.warn){if(Tc(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)}`),pt)}try{return JSON.parse(s)}catch{return e(`Ignoring invalid JSON attribute: ${JSON.stringify(s)}`),pt}}}function hr(s,t="string",e=console.warn){if(Tc(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)}`),pt)}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"),pt}return String(s)}function Tc(s){if(!["string","number","boolean","json"].includes(String(s)))throw new TypeError(`Unknown reflected attribute type: ${String(s)}`)}var Q_=Object.freeze(["change","input","submit","clear","open","close","cancel","invalid","query","loaded","rowclick","rowdblclick","sort","selectionchange","datachange"]),X_=_t({checked:V({always:!0,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),value:F({default:!0}),label:F({default:null,rebuild:!0}),disabled:V({always:!0,set:wi})}),J_=_t({checked:V({always:!0,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),value:F({option:null,default:"on"}),label:F({default:"",set:(s,t)=>s.setLabel(t)}),icon:V({rebuild:!0}),disabled:V({always:!0,set:wi})}),Z_=_t({items:Lt({default:[],set:(s,t)=>s.setItems(t)}),value:F({default:null,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.value}),"value-key":F({property:"valueKey",default:"ID",rebuild:!0}),"label-key":F({property:"labelKey",default:"name",rebuild:!0}),placeholder:F({default:"",set:(s,t)=>{s.refs.input.placeholder=t}}),clearable:V({default:!1,rebuild:!0}),filter:F({default:!1,normalize:fm,rebuild:!0}),"search-keys":Lt({property:"searchKeys",default:null,rebuild:!0}),"min-query":Te({property:"minQuery",default:0,rebuild:!0}),debounce:Te({default:200,rebuild:!0}),"list-height":Te({property:"listHeight",default:280,rebuild:!0}),disabled:V({always:!0,set:wi}),required:V({option:null,always:!0}),name:F({option:null,default:""})}),tm=_t({items:Lt({default:[],set:(s,t)=>s.setItems(t)}),value:Lt({option:null,default:[],set:(s,t)=>s.setValues(t),get:s=>s.getValues()}),"value-key":F({property:"valueKey",default:"ID",rebuild:!0}),"label-key":F({property:"labelKey",default:"name",rebuild:!0}),"checked-key":F({property:"checkedKey",default:"on",rebuild:!0}),search:V({rebuild:!0}),height:Te({default:280,rebuild:!0}),"default-checked":V({property:"defaultChecked",default:!1,rebuild:!0}),disabled:V({option:null,always:!0,set:dm}),name:F({option:null,default:""})}),em=_t({format:F({default:"%d.%m.%Y",rebuild:!0}),time:V({always:!0,rebuild:!0}),value:F({option:null,default:null,normalize:gm,set:(s,t)=>s.set(t,{silent:!0}),get:(s,t)=>fr(s.get(),!!t.time),serialize:bm}),placeholder:F({default:null,rebuild:!0}),clearable:V({rebuild:!0}),disabled:V({always:!0,set:wi}),required:V({option:null,always:!0}),name:F({option:null,default:""})}),im=_t({value:Te({default:0,set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),unit:F({default:"minutes",rebuild:!0}),seconds:V({always:!0,rebuild:!0}),signed:V({always:!0,rebuild:!0}),disabled:V({always:!0,set:wi}),name:F({option:null,default:""})}),sm=_t({value:F({default:"",set:(s,t)=>s.set(t,{silent:!0}),get:s=>s.get()}),placeholder:F({default:"",set:(s,t)=>{s.refs.input.placeholder=t}}),clearable:V({rebuild:!0}),debounce:Te({default:250,rebuild:!0})}),nm=_t({title:F({default:"",set:(s,t)=>s.setTitle(t)}),open:V({default:!1,always:!0,set:(s,t)=>t?s.open():s.close(),get:s=>s.isOpen()})}),rm=_t({tabs:Lt({default:[],normalize:_m,rebuild:!0}),active:F({default:null,set:(s,t)=>{t!==null&&s.openTab(t)},get:s=>s.getActive()}),variant:F({default:"divided",rebuild:!0}),"keep-alive":V({property:"keepAlive",rebuild:!0})}),om=_t({columns:Lt({default:[],rebuild:!0}),data:Lt({default:[],set:(s,t)=>s.setData(t),get:s=>s.getData()}),"row-id":F({property:"rowId",default:"ID",rebuild:!0}),sort:Lt({default:null,rebuild:!0}),"sort-mode":F({property:"sortMode",default:"local",rebuild:!0}),selectable:F({default:!1,normalize:pm,rebuild:!0}),"sticky-header":V({property:"stickyHeader",rebuild:!0}),height:F({default:null,normalize:Dc,rebuild:!0}),"empty-text":F({property:"emptyText",default:null,rebuild:!0}),zebra:V({rebuild:!0})}),am=_t({title:F({default:"",set:(s,t)=>s.setTitle(t)}),size:F({default:"md",normalize:Dc,rebuild:!0}),buttons:Lt({default:[],set:(s,t)=>s.setButtons(t)}),closable:V({rebuild:!0}),open:V({option:null,default:!1,always:!0,set:(s,t)=>t?s.open():s.close(),get:s=>s.isOpen()})}),lm=Object.freeze([["toggle",ot,{formAssociated:!0,attrs:X_}],["check-button",Ut,{formAssociated:!0,attrs:J_}],["select",K,{formAssociated:!0,attrs:Z_}],["checklist",lt,{formAssociated:!0,attrs:tm}],["datebox",it,{formAssociated:!0,attrs:em}],["timebox",Nt,{formAssociated:!0,attrs:im}],["search",re,{formAssociated:!1,attrs:sm}],["groupbox",ne,{formAssociated:!1,attrs:nm}],["tabbox",bi,{formAssociated:!1,attrs:rm}],["table",Ft,{formAssociated:!1,attrs:om}],["dialog",Wt,{formAssociated:!1,attrs:am}]]);function cm(s,{formAssociated:t=!1,attrs:e={}}={}){let i=Ec(e),n=Object.freeze(Object.keys(i)),r=s===ne||s===Wt;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,u,h){if(this._reflecting.has(c))return;let d=i[c];if(!d)return;let f=Ce(h,d.type);if(f===pt)return;this._propertyValues.delete(d.property);let p=f===void 0?Ss(d.default):f;this._applyValue(c,d,p)}formDisabledCallback(c){this._disabledByForm=!!c,this._syncEffectiveDisabled(i),this._syncFormState(s)}formResetCallback(){if(!this._defaults)return;let c=dr(s);!c||!this._defaults.has(c)||this._applyControlValue(i,c,Ss(this._defaults.get(c)))}formStateRestoreCallback(c,u){if(typeof c!="string")return;let h=wm(s,c);if(h===pt)return;let d=dr(s);d&&this._applyControlValue(i,d,h)}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 u of Object.values(c)){let h=u.property;if(!Object.prototype.hasOwnProperty.call(this,h))continue;let d=this[h];delete this[h],this[h]=d}}_captureDefaults(c){this._defaults=new Map;let u=dr(s);if(u){let h=Object.values(c).find(d=>d.property===u);h&&this._defaults.set(u,Ss(this._readProperty(h)))}}_createComponent(c,u,h){let d={};for(let[_,m]of Object.entries(u)){if(!(this._propertyValues.has(m.property)||this.hasAttribute(_)||m.always)||m.option===null)continue;let y=this._currentValue(_,m);y===pt||y===void 0||(d[m.option]=Ic(m,y,this))}let f=null;h&&(f=document.createDocumentFragment(),f.append(...this._contentNodes),d.content=f);let p=new c(null,d);this._component=p,s===ne&&f&&p.setContent(f),this.append(p.el),this._bridgeEvents(p,s);for(let[_,m]of Object.entries(u)){if(m.option!==null||!m.set||!(this._propertyValues.has(m.property)||this.hasAttribute(_)||m.always))continue;let y=this._currentValue(_,m);y!==pt&&y!==void 0&&this._applyValue(_,m,y,!0)}this._syncEffectiveDisabled(u),this._syncFormState(s)}_bridgeEvents(c,u){this._bridgeAbort?.abort(),this._bridgeAbort=new AbortController;for(let h of Q_)c.on(h,d=>{if(this._applying)return;this._syncFormState(u);let f=new CustomEvent(`zx-${h}`,{detail:d.detail??{},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(f),f.defaultPrevented&&d.preventDefault()}),c.el.addEventListener(`zx-${h}`,d=>d.stopPropagation(),{signal:this._bridgeAbort.signal})}_destroyComponent(){this._bridgeAbort?.abort(),this._bridgeAbort=null,this._component&&(this._component.destroy(),this._component=null)}_rebuildComponent(c,u=r){this._component&&(u&&this._contentNodes&&document.createDocumentFragment().append(...this._contentNodes),this._destroyComponent(),this._createComponent(s,c,u))}_applyValue(c,u,h,d=!1){if(this._component){if(u.rebuild&&!d){this._rebuildComponent(i);return}if(!u.set){this._syncFormState(s);return}this._applying=!0;try{u.set(this._component,Ic(u,h,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:u,state:h,empty:d}=ym(c,this._component,this);if(this._internals.setFormValue(u,h),(c===K||c===it)&&this.hasAttribute("required")&&d){let f=c===it?"Please enter a date.":"Please select a value.";this._internals.setValidity({valueMissing:!0},f,this._component.refs.input)}else this._internals.setValidity({})}_applyControlValue(c,u,h){let d=Object.entries(c).find(([,f])=>f.property===u);d&&this._applyValue(d[0],d[1],h)}_currentValue(c,u){if(this._propertyValues.has(u.property))return this._propertyValues.get(u.property);let h=Ce(this.getAttribute(c),u.type);return h===void 0?u.default:h}_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 u=Ce(this.getAttribute(c.attribute),c.type);return u===pt||u===void 0?Ss(c.default):u}_writeProperty(c,u){this._propertyValues.set(c.property,u);let h=c.serialize?c.serialize(u,this):hr(u,c.type);if(h!==pt){this._reflecting.add(c.attribute);try{h===null?this.removeAttribute(c.attribute):this.setAttribute(c.attribute,h)}finally{this._reflecting.delete(c.attribute)}}this._applyValue(c.attribute,c,u)}}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 um(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 lm){let r=`${t}-${e}`;customElements.get(r)||customElements.define(r,cm(i,n))}}function Ec(s){let t={};for(let[e,i]of Object.entries(s)){let n=typeof i=="string"?{type:i}:{...i},r=n.property??hm(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 _t(s){return Ec(s)}function F(s={}){return{type:"string",...s}}function Te(s={}){return{type:"number",...s}}function V(s={}){return{type:"boolean",default:!1,always:!0,...s}}function Lt(s={}){return{type:"json",...s}}function hm(s){return s.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function Ic(s,t,e){return s.normalize?s.normalize(t,e):t}function wi(s,t){t?s.disable():s.enable()}function dm(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 fm(s){return s===""||s==="true"?"local":s==="false"?!1:s}function pm(s){return s===""||s==="true"?"single":s==="false"?!1:s}function Dc(s){if(typeof s!="string"||s.trim()==="")return s;let t=Number(s);return Number.isFinite(t)?t:s}function _m(s){return Array.isArray(s)?s.map(t=>!t||typeof t!="object"||mm(t.content)||typeof t.content=="function"?t:{...t,content:document.createTextNode(String(t.content??""))}):s}function mm(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function gm(s){return typeof s!="string"?s:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(s)?tt(s,"%Y-%m-%dT%H:%M"):/^\d{4}-\d{2}-\d{2}$/.test(s)?tt(s,"%Y-%m-%d"):s}function bm(s,t){return s instanceof Date?fr(s,!!t.time):hr(s,"string")}function fr(s,t){return!(s instanceof Date)||Number.isNaN(s.getTime())?"":D(s,t?"%Y-%m-%dT%H:%M":"%Y-%m-%d")}function dr(s){return s===ot||s===Ut?"checked":[K,lt,it,Nt].includes(s)?"value":null}function ym(s,t,e){if(s===ot||s===Ut){let n=t.get(),r=s===ot?!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===K){let n=t.value;return{formValue:n===null?null:String(n),state:JSON.stringify(n),empty:n===null||n===""}}if(s===lt){let n=JSON.stringify(t.getValues());return{formValue:n,state:n,empty:n==="[]"}}if(s===it){let n=fr(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 wm(s,t){return s===ot||s===Ut?t==="true":s===K||s===lt?Ce(t,"json"):s===Nt?Ce(t,"number"):t}function Ss(s){return Array.isArray(s)?s.slice():s instanceof Date?new Date(s.getTime()):s}var xm=Object.freeze({md:40,sm:28}),vm=Object.freeze({icon:"folder-open",title:"",description:"",actions:[],size:"md",align:"center"});function Sm(s={}){let t={...vm,...s},e=km(t.size),i=l("div",{class:"zx-empty-state",dataset:{size:e,align:zm(t.align)}});t.icon&&i.append(l("div",{class:"zx-empty-state__icon",ariaHidden:"true"},b(t.icon,{size:xm[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=Am(t.actions);return n.length>0&&i.append(l("div",{class:"zx-empty-state__actions"},n)),i}function Am(s){if(!Array.isArray(s))throw new TypeError("emptyState actions must be an array");return s.map(t=>{if(E(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 km(s){return s==="sm"?"sm":"md"}function zm(s){return s==="start"?"start":"center"}var xi=class extends g{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:k(this.el);let t=this.el??l("div");this.el=t,this._max=Math.max(1,Number(this.options.max)||100),this._status=Mc(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=H(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=Mc(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(b(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 Mc(s){return s==="success"||s==="error"?s:"active"}var Cm=new Set(["inactive","active","success","error"]),pr=class extends g{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:k(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=Cm.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"?[gi({size:"sm",kind:"current"})]:this._status==="success"?[b("success",{size:t})]:this._status==="error"?[b("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:Im.has(t.radius)?t.radius:"sm"},style:{"inline-size":_r(t.width),"block-size":_r(t.height)}})}function vi(s={}){let t={lines:3,width:"100%",heading:!1,lastLineWidth:"60%",...s},e=H(Math.trunc(Number(t.lines)||0),1,20),i=l("div",{class:"zx-skeleton-text",ariaHidden:"true",style:{"inline-size":_r(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 Tm(s={}){let t={rows:5,columns:4,header:!0,...s},e=H(Math.trunc(Number(t.rows)||0),1,50),i=H(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(Nc(i,"header"));for(let r=0;r<e;r+=1)n.append(Nc(i,"body"));return n}var Im=new Set(["sm","md","full"]);function Nc(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:Em(i,s),height:"0.75rem"})));return e}function Em(s,t){return s===t-1?"55%":s%2===0?"80%":"65%"}function _r(s){return typeof s=="number"?`${s}px`:String(s??"")}function Dm(s={},...t){return l("div",{class:["zx-stack",s.class??""],dataset:{direction:s.direction==="row"?"row":null,align:Oc.has(s.align)?s.align:null,justify:Om.has(s.justify)?s.justify:null,wrap:s.wrap?"true":null,inline:s.inline?"true":null},style:Fc("--zx-stack-gap",s.gap)},t)}function Mm(s={},...t){let e=Number(s.columns),i={...Fc("--zx-grid-gap",s.gap),"--zx-grid-min":Lm(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:Oc.has(s.align)?s.align:null},style:i},t)}function Nm(s={},...t){return l("div",{class:["zx-aspect",s.class??""],style:{"--zx-aspect-ratio":String(s.ratio??"16 / 9"),"--zx-aspect-fit":Fm.has(s.fit)?s.fit:"cover"}},t)}var Oc=new Set(["start","center","end","stretch","baseline"]),Om=new Set(["start","center","end","between","around"]),Fm=new Set(["cover","contain","fill"]);function Fc(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 Lm(s){return typeof s=="number"?`${s}px`:String(s)}function Rm(s,t={}){let e=q(s);if(!e)throw new TypeError("truncate() target could not be resolved");let i=H(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 u=()=>(a=Lc(e),n&&(a?e.setAttribute("title",e.textContent?.trim()??""):o===null?e.removeAttribute("title"):e.setAttribute("title",o)),a);return u(),typeof ResizeObserver=="function"&&(c=new ResizeObserver(u),c.observe(e)),{update:u,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 Lc(s){return s.scrollWidth-s.clientWidth>1||s.scrollHeight-s.clientHeight>1}var Pm=Object.freeze({text:"",label:"",title:"Copy",feedback:"Copied",feedbackDuration:2e3,size:"md",kind:"ghost"});function mr(s={}){let t={...Pm,...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"},b("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 or(a);t.oncopy?.(a,c),c&&(clearTimeout(o),i.dataset.copied="true",n.replaceChildren(b("check",{size:t.size==="sm"?12:14})),r.textContent=String(t.feedback),o=setTimeout(()=>{i.isConnected&&(delete i.dataset.copied,n.replaceChildren(b("copy",{size:t.size==="sm"?12:14})),r.textContent="")},Math.max(0,Number(t.feedbackDuration)||0)))}),i}var gr=class extends g{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:k(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=mr({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 kt=['[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]'].join(",");function Si(s){return!!(s&&s!=="-"&&typeof s=="object"&&!["heading","separator"].includes(String(s.type??"")))}function Bm(s){return["menuitemcheckbox","menuitemradio"].includes(String(s.role))?s.role:"menuitem"}function As(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(!Si(i))return;let r=Bm(i),o=B(i.href),a=i.target==null?null:String(i.target),c=i.rel==null?a==="_blank"?"noopener noreferrer":null:String(i.rel),u=[],h=[];r!=="menuitem"&&h.push(l("span",{class:`zx-${t}__check`,"data-check-kind":r==="menuitemradio"?"radio":"checkbox"})),i.icon&&h.push(b(i.icon)),u.push(l("span",{class:`zx-${t}__leading`,ariaHidden:"true"},h)),u.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 p=i.adornment&&typeof i.adornment=="object"&&"nodeType"in i.adornment?i.adornment:String(i.adornment);d.push(l("span",{class:`zx-${t}__adornment`},p))}d.length&&u.push(l("span",{class:`zx-${t}__meta`},d));let f={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",{...f,href:o,target:a,rel:c},u)):e.push(l("button",{...f,type:"button"},u))}),e}var Pc=Symbol("zxDropdownPointerDismiss"),Bc=Symbol("zxDropdownEscapeDismiss"),mt=class extends g{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,Yt(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=st(this.options.scope??this.#t);return this.el.parentElement!==t&&t.append(this.el),this.#e=rt(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(jm()),this.#t.setAttribute("aria-expanded","true"),Hm(),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"),qm(),this):this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.#e!==null}setContent(t){return Vm(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)$m(this.#t,t,e);super.destroy()}}[Pc](t){if(!this.isOpen())return;let e=t.composedPath();e.includes(this.el)||e.includes(this.#t)||this.close()}[Bc](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))}},Ai=class extends g{constructor(){super(null),this.listen(document,"pointerdown",t=>{let e=Rc();e instanceof mt&&e[Pc](t)}),this.listen(document,"keydown",t=>{if(t.defaultPrevented||t.key!=="Escape")return;let e=Rc();e instanceof mt&&e[Bc](t)})}render(){let t=l("span",{hidden:!0,"data-zx-dropdown-dismiss-manager":""});return document.body.append(t),t}};function Vm(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 Rc(){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?g.from(s):null}function jm(){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 Hm(){let s=document.querySelector("[data-zx-dropdown-dismiss-manager]"),t=s?g.from(s):null;return t instanceof Ai?t:new Ai}function qm(){if(document.querySelector('.zx-dropdown[data-state="open"]'))return;let s=document.querySelector("[data-zx-dropdown-dismiss-manager]"),t=s?g.from(s):null;t instanceof Ai&&t.destroy()}function $m(s,t,e){e===null?s.removeAttribute(t):s.setAttribute(t,e)}var gt=class extends g{static cssName="menu-button";static defaults={label:"",icon:null,kind:"default",items:[],placement:"bottom-start"};#t;#e;#i;#s;#r=[];#n=null;#o=!0;#a=!1;#l=!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.#a=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 mt(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.id||(this.el.id=x("zx-menu-button")),this.#e.setAttribute("aria-labelledby",this.el.id),this.el.setAttribute("aria-haspopup","menu"),i&&r&&this.setLabel(this.options.label),this.setItems(this.options.items),this.#i=Mt(this.#e,kt),this.#s=ht(()=>this.#f(),o=>o.focus()),this.#t.on("open",()=>this.emit("open")),this.#t.on("close",()=>{this.#o=!0,this.emit("close")}),this.listen(this.el,"click",()=>{this.isOpen()?this.close():(this.open(),this.#i.focusFirst())}),this.listen(this.el,"keydown",o=>this.#c(o)),this.listen(this.#e,"click",o=>{let a=o.target.closest?.(kt);a&&this.#e.contains(a)&&this.#h(a,o)}),this.listen(this.#e,"keydown",o=>this.#u(o))}render(){return this.el?this.el:l("button",{class:"zx-btn",type:"button","data-kind":this.options.kind,"data-size":"md"},Vc(this.options.label,this.options.icon))}setItems(t){return this.#r=Array.isArray(t)?t.slice():[],this.#e.replaceChildren(...As(this.#r,"menu-button")),this}open(t={}){return this.isOpen()||(this.#o=t?.returnFocus??!0),this.#t.open(),this}close(){return this.#t.close(),this}isOpen(){return this.#t.isOpen()}getTrigger(){return this.el}getPanel(){return this.#e}focusFirst(t={}){return this.open(t),this.#i.focusFirst(),this}focusLast(t={}){return this.open(t),this.#i.focusLast(),this}setLabel(t){return this.el.replaceChildren(...Vc(t,this.options.icon)),this}destroy(){if(!this.#l&&(this.#l=!0,this.#i.destroy(),this.#t.destroy(),super.destroy(),!this.#a&&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)}}#c(t){["ArrowDown","ArrowUp","Enter"," "].includes(t.key)&&(t.preventDefault(),this.open(),t.key==="ArrowUp"?this.#i.focusLast():this.#i.focusFirst())}#u(t){if(t.key==="Escape"){t.preventDefault();let e=this.#d();this.close(),e?.focus();return}if(t.key==="Tab"){this.close();return}if(t.key==="Enter"||t.key===" "){let e=t.target.closest?.(kt);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(!Si(n)||n.disabled){e?.preventDefault();return}let r=this.#d(),o=document.activeElement,a=!!r&&(!o||o===document.body||this.#e.contains(o));if(a&&r?.focus(),this.emit("select",{value:n.value,item:n}).defaultPrevented){e?.preventDefault(),a&&document.activeElement===r&&t instanceof HTMLElement&&t.focus();return}try{n.onselect?.(n.value,n,this)}finally{this.close()}}#d(){let t=this.#o;return t===!1?null:t instanceof HTMLElement&&t.isConnected?t:this.el}#f(){return Array.from(this.#e.querySelectorAll(kt))}};function Vc(s,t){let e=[];return t&&e.push(l("span",{class:"zx-btn__icon"},b(t))),e.push(l("span",{class:"zx-btn__label"},String(s??""))),e}var Km=["button","a[href]","input","select","textarea","[tabindex]"],Um=Km.flatMap(s=>[`.zx-toolbar > ${s}`,`.zx-toolbar > [role="group"] > ${s}`]).join(","),br=class extends g{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 gt(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=Mt(this.el,Um,{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.#h()),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:k(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=Wm(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=Ym(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.#u(t,!1)}disable(t){return this.#u(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:Hc(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))}#u(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}#h(){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 u=c.map(_=>_.element.getBoundingClientRect().width),h=u.reduce((_,m)=>_+m,0)+i*Math.max(0,u.length-1),d=a.getBoundingClientRect().width,f=[];if(h>r){let _=r-d-i,m=0,w=!1;for(c.forEach((y,v)=>{let A=m+u[v]+(m>0?i:0);if(!w&&A<=_){m=A;return}w=!0,y.element.hidden=!0,f.push(y)});c.length>f.length;){let y=c[c.length-f.length-1];if(y.type!=="separator")break;y.element.hidden=!0,f.unshift(y)}}let p=jc(f);this.#e.setItems(p),a.hidden=p.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(jc(t))}};function Ym(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(E(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 jc(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||Hc(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 Hc(s){return(s.getAttribute("aria-label")??s.getAttribute("title")??s.textContent??"").trim()}function Wm(s){return["end","between"].includes(s)?s:"start"}var wr=class extends g{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:k(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=Jm(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}),u=l("div",{ref:"content",class:"zx-card__content",hidden:!0}),h=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,u,h))),e.dataset.variant=Qm(this.options.variant),e.dataset.orientation=Xm(this.options.orientation),this.setTitle(this.options.title),this.setMedia(this.options.media),this.options.content!==null?this.setContent(this.options.content):i.length&&(u.replaceChildren(...i),u.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 yr(this.refs.media,t,"Card media"),this.refs.media.hidden=t===null,this}setContent(t){return yr(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(E(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 yr(this.refs.footer,t,"Card footer"),this.refs.footer.hidden=t===null,this}setLink(t){let e=Gm(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 yr(s,t,e){if(t===null){s.replaceChildren();return}if(typeof t=="string"){s.textContent=t;return}let i=t instanceof g?t.toElement():t;if(i instanceof Node){s.replaceChildren(i);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}function Gm(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=B(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 Qm(s){return["raised","filled"].includes(String(s))?s:"outlined"}function Xm(s){return s==="horizontal"?"horizontal":"vertical"}function Jm(s){let t=Math.trunc(Number(s));return t>=1&&t<=6?t:3}var Zm=Object.freeze(["neutral","accent","success","warning","danger","info"]),tg=Object.freeze(["positive","negative","neutral"]),eg=Object.freeze({"statTile.up":"up %1","statTile.down":"down %1","statTile.unchanged":"no change","statTile.loading":"Loading"}),ig=Object.freeze({up:"chevron-up",down:"chevron-down",flat:"minus"}),Wc=100,Sr=30,sg=2,ng=Object.freeze({label:"",value:null,format:"number",currency:null,caption:"",delta:null,deltaKind:"neutral",deltaLabel:"",trend:[],icon:null,kind:"neutral",href:null,clickable:!1,loading:!1}),qc="http://www.w3.org/2000/svg",ks=class extends g{static cssName="stat-tile";static defaults=ng;constructor(t=null,e={}){super(t,{...e,clickable:e?.clickable===!0||typeof e?.onclick=="function"})}render(){let t=xr(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:k(e),this._closed=!1,this._state={...this.options},t==="button"&&(e.type="button"),Kc(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(xr(e)!==i)throw new TypeError(`StatTile cannot change from <${i}> to <${xr(e)}> in place: href and clickable decide the element, and an element's tag is fixed once it exists.`);return this._state=e,Kc(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(eg[t]??t,e):i}};function rg(s={}){return new ks(null,s)}function Gc(s,t={}){let{format:e="number",locale:i,currency:n=null}=t;if(typeof e=="function")return le(e(s));if(typeof s=="string")return s;if(s==null)return"";switch(e){case"currency":return di(s,n,{locale:i});case"percent":return fi(s,{locale:i});case"fileSize":return pi(s,{locale:i});case"number":return Ot(s,{locale:i});default:return le(s)}}function og(s,t={}){let e=Jc(s);if(e===null)return null;let i=e>0?"up":e<0?"down":"flat",n=i==="up"?"+":i==="down"?"\u2212":"",r=Gc(Math.abs(e),t);return{direction:i,sign:n,magnitude:r,text:`${n}${r}`}}function xr(s={}){return B(s.href)?"a":s.clickable===!0||typeof s.onclick=="function"?"button":"div"}function $c(s={}){let t=[s.value,s.caption].map(vr).filter(Boolean).join(" "),e=[s.delta,s.deltaLabel].map(vr).filter(Boolean).join(" ");return[vr(s.label),t,e].filter(Boolean).join(", ")}function Qc(s,t={}){let{width:e=Wc,height:i=Sr,inset:n=sg}=t,r=(Array.isArray(s)?s:[]).map(Jc).filter(f=>f!==null);if(r.length<2)return null;let o=Math.min(...r),a=Math.max(...r),c=n,u=Math.max(n,i-n),h=a-o,d=e/(r.length-1);return r.map((f,p)=>{let _=p===r.length-1?e:p*d,m=h===0?(c+u)/2:u-(f-o)/h*(u-c);return`${Yc(_)},${Yc(m)}`}).join(" ")}function Kc(s,t,e){let i=Xc(t.kind,Zm,"neutral"),n=le(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 _=B(t.href);_?s.setAttribute("href",_):s.removeAttribute("href")}if(r){s.setAttribute("aria-busy","true"),Uc(s,$c({label:n,value:e("statTile.loading")})),s.replaceChildren(cg(t));return}s.removeAttribute("aria-busy");let o=Gc(t.value,t),a=og(t.delta,{format:t.deltaFormat??t.format,locale:t.locale,currency:t.currency}),c=le(t.deltaLabel),u=le(t.caption).trim();Uc(s,$c({label:n,value:o,caption:u,delta:a===null?"":hg(a,e),deltaLabel:c}));let h=l("div",{class:"zx-stat-tile__header"},l("span",{class:"zx-stat-tile__label"},n)),d=ug(t.icon);d&&h.append(l("span",{class:"zx-stat-tile__icon"},d));let f=[h,l("div",{class:"zx-stat-tile__value"},o)];u&&f.push(l("div",{class:"zx-stat-tile__caption"},u)),a!==null&&f.push(ag(a,c,t.deltaKind));let p=lg(t.trend);p&&f.push(p),s.replaceChildren(...f)}function ag(s,t,e){let i=l("div",{class:"zx-stat-tile__delta",ariaHidden:"true",dataset:{kind:Xc(e,tg,"neutral"),direction:s.direction}},b(ig[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 lg(s){let t=Qc(s);if(t===null)return null;let e=document.createElementNS(qc,"svg");e.setAttribute("class","zx-stat-tile__trend"),e.setAttribute("viewBox",`0 0 ${Wc} ${Sr}`),e.setAttribute("preserveAspectRatio","none"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");let i=document.createElementNS(qc,"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 cg(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 le(s.caption).trim()&&t.push(at({width:"35%",height:"0.75rem"})),s.delta!==null&&s.delta!==void 0&&t.push(at({width:"40%",height:"0.75rem"})),Qc(s.trend)!==null&&t.push(at({width:"100%",height:`${Sr}px`,radius:"md"})),l("div",{class:"zx-stat-tile__loading"},...t)}function ug(s){return s?b(String(s),{size:16}):null}function hg(s,t){return s.direction==="flat"?t("statTile.unchanged"):t(s.direction==="up"?"statTile.up":"statTile.down",s.magnitude)}function Uc(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 Xc(s,t,e){return t.includes(s)?s:e}function Jc(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 le(s){return s==null?"":String(s)}function vr(s){return le(s).trim()}function Yc(s){return Math.round(H(s,-1e6,1e6)*100)/100}var dg=Object.freeze(["source","confluence","horizon","diagonal","edge","curtain"]),fg=Object.freeze(["subtle","balanced","vivid"]),zs=Object.freeze(["--zx-aurora-color-1","--zx-aurora-color-2","--zx-aurora-color-3","--zx-aurora-color-4"]),Ar=class extends g{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:k(e),this._cleaned=!1,this._initialColors=zs.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=pg(t),this}setColors(t){let e=mg(t),i=gg(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<zs.length;n+=1)this.el.style.setProperty(zs[n],i[n]);return this}setIntensity(t){return this.el.dataset.intensity=_g(t),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),this._createdRoot||S(this.el,this._original))}};function pg(s){let t=String(s??"").trim().toLowerCase();if(!dg.includes(t))throw new TypeError(`Unknown Aurora preset: ${s}`);return t}function _g(s){let t=String(s??"").trim().toLowerCase();if(!fg.includes(t))throw new TypeError(`Unknown Aurora intensity: ${s}`);return t}function mg(s){if(s==null)return[];if(!Array.isArray(s))throw new TypeError("Aurora colors must be an array");if(s.length>zs.length)throw new TypeError("Aurora accepts at most four colors");return s.map(t=>{if(!we(t))throw new TypeError(`Invalid Aurora color: ${t}`);return t.trim()})}function gg(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 kr=class extends g{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:bg(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"},b("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")})),u=l("div",{class:"zx-panel__content",ref:"content"}),h=l("div",{class:"zx-panel__body",ref:"body",id:n},u),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,h,d),this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):u.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 Zc(this.refs.content,t,"Panel content"),this}setButtons(t){return this.refs.buttons.replaceChildren(...this._buildButtons(t,"Panel buttons")),this}setFooter(t){return Zc(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&&yg(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(E(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 bg(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function yg(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 Zc(s,t,e){if(s.replaceChildren(),t===null)return;if(typeof t=="string"){s.append(document.createTextNode(t));return}let i=t instanceof g?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 wg=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"]),zr=class extends g{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:xg(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=Sg(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 tu(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(E(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 tu(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&&vg(this.el,this._original))}};function xg(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function vg(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 tu(s,t,e){if(s.replaceChildren(),t===null)return;if(typeof t=="string"){s.append(document.createTextNode(t));return}let i=t instanceof g?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 Sg(s){let t=String(s??"default").toLowerCase();return wg.includes(t)?t:"default"}function Ie(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,u=!1,h=0,d=y=>e?y.clientY:y.clientX,f=()=>!!t.disabled?.(),p=()=>{let y=o;if(o=null,y!==null)try{s.releasePointerCapture(y)}catch{}},_=()=>{h!==0&&(cancelAnimationFrame(h),h=0)},m=()=>{r=!1,u=!1,_(),p()};s.addEventListener("pointerdown",y=>{let v=y;if(!(f()||r||v.button!==0)&&t.onStart?.(v)!==!1){r=!0,o=v.pointerId,a=d(v),c=a,u=!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&&(u=!0),h===0&&(h=requestAnimationFrame(()=>{h=0,r&&t.onMove(c-a)})))},{signal:n});let w=y=>{let v=y;if(!r||v.pointerId!==o)return;_(),c=d(v);let A=u,z=c-a;m(),t.onEnd?.(z,A)};return s.addEventListener("pointerup",w,{signal:n}),s.addEventListener("pointercancel",w,{signal:n}),s.addEventListener("keydown",y=>{let v=y;if(f())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 A=e?"ArrowUp":"ArrowLeft",z=e?"ArrowDown":"ArrowRight";v.key!==A&&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 bt(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 Ag="split-view",Cr=class extends g{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=_i(Ag);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=Ie(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=bt(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:k(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",Cs(t.size)),t.start!=null?Ts(o,t.start,"SplitView start"):n[0]&&o.append(n[0]),t.end!=null?Ts(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=bt(t,e>0?e:Number.NaN);return Number.isFinite(o)?(this.#r(Gt({size:o,min:n,max:r,total:e,divider:i})),this):(this._size=null,this.el.style.setProperty("--zx-split-size",Cs(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=eu(this.refs.start,this._orientation);if(i>0)return i;let n=bt(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 Ts(this.refs.start,t,"SplitView start"),this}setEnd(t){return Ts(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:eu(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=Is({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=Gt({size:this._startSize+t,min:r,max:o,total:i,divider:n});e&&(a=Gt({size:iu(a,this.#h(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.#u(Gt({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=Is({min:n,max:r,total:e,divider:i});this.#u(Gt({size:o[t],min:n,max:r,total:e,divider:i}),e)}#u(t,e){t!==this._size&&(this.#r(t),this.emit("resize",{size:t,ratio:t/e}),this.#p(),this.#_())}#h(t,e){let{min:i,max:n}=this.#s(),r=Is({min:i,max:n,total:t,divider:e}),o=[r.min,r.max],a=bt(this.options.size,t);return Number.isFinite(a)&&o.unshift(a),o}#d(){if(this._disabled)return;this._collapsed!==null&&this.expand();let t=bt(this.options.size,Number.NaN);Number.isFinite(t)?this.setSize(t):(this._size=null,this.el.style.setProperty("--zx-split-size",Cs(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=bt(this.options.size,t);if(Number.isFinite(o)){let a=Gt({size:o,min:i,max:n,total:t,divider:e});this.el.style.setProperty("--zx-split-size",Math.abs(a-o)>.5?`${a}px`:Cs(this.options.size))}this.#n();return}let r=Gt({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 Gt({size:s,min:t=0,max:e=null,total:i=0,divider:n=0}){let r=Number(s),o=Is({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 iu(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 u=Number(c);if(!Number.isFinite(u))continue;let h=Math.abs(u-i);h<=n&&h<a&&(a=h,o=u)}return o}function Is({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 eu(s,t){let e=s.getBoundingClientRect(),i=t==="vertical"?e.height:e.width;return Number.isFinite(i)&&i>0?i:0}function Cs(s){return typeof s=="number"&&Number.isFinite(s)?`${s}px`:String(s)}function Ts(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 g?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 kg="dock",Er=class extends g{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=_i(kg);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:k(e),e.dataset.orientation=this._orientation,e.replaceChildren(),this._content=t.content==null?null:l("div",{class:"zx-dock__content",ref:"content"}),this._content&&Ir(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)?H(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=Tr(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"},b("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 u=l("div",{class:"zx-dock__header"},c),h=l("div",{class:"zx-dock__body",id:r}),d=l("section",{class:"zx-dock__pane",dataset:{name:e,state:"open"}},u,h),f={name:e,title:i,element:d,header:u,body:h,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){f.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),A=x("zx-dock-tab"),z=x("zx-dock-panel"),T=l("button",{class:"zx-dock__tab",type:"button",role:"tab",id:A,ariaControls:z,ariaSelected:"false",tabindex:-1},String(y.title??v)),N=l("div",{class:"zx-dock__panel",role:"tabpanel",id:z,ariaLabelledby:A,tabindex:0,hidden:!0});_.append(T),h.append(N),f.tabs.set(v,{name:v,tab:T,panel:N,content:y.content,built:!1})}u.append(_),f.roving=Mt(_,".zx-dock__tab",{orientation:"horizontal"}),this.listen(_,"click",y=>{let v=y.target.closest?.(".zx-dock__tab");if(!v||!_.contains(v))return;let A=[...f.tabs.values()].find(z=>z.tab===v);A&&this.activate(f.name,A.name)});let m=String(t.active??""),w=f.tabs.has(m)?m:[...f.tabs.keys()][0];f.active=w;for(let y of f.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 f.content=l("div",{class:"zx-dock__pane-content"}),h.append(f.content),f.factory=t.content;let p=Tr(t.size);return p!==null&&d.style.setProperty("--zx-pane-size",p),n&&this.listen(c,"click",()=>this.toggle(f.name)),t.collapsed&&n&&(f.collapsed=!0,this._syncPaneState(f)),(!this._lazy||!f.collapsed)&&this._materialize(f),f}_materialize(t){if(!t.collapsed){if(t.tabs){let e=t.tabs.get(t.active);if(!e||e.built)return;e.built=!0,Ir(e.panel,e.content,!0);return}t.built||(t.built=!0,Ir(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(Ie(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)?H(Number(e.index),0,r.length):r.length;r.splice(o,0,[i,n]),this._panes=new Map(r);let a=Tr(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=ui((u,h)=>{this._applyDockAt(n,tr(c,h))},{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||zg(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 zg(s){let t=x("zx-dock-pane");return s.id=t,t}function Tr(s){return s==null||s===""?null:typeof s=="number"?Number.isFinite(s)?`${Math.max(0,s)}px`:null:String(s)}function Ir(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 g?i.toElement():i;n&&typeof n.nodeType=="number"&&s.append(n)}var Es="44rem",nu=/^\d+(?:\.\d+)?(?:px|rem)$/,Dr=class extends g{static cssName="navigation-bar";static defaults={title:"",items:[],active:null,actions:[],overflow:!0,overflowBelow:Es,minVisible:0};constructor(t,e={}){super(t,e),this._overflow=new gt(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:Eg(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(u=>{if(!u||typeof u!="object"||Array.isArray(u))throw new TypeError("Navigation item must be an object");if(typeof u.name!="string"||u.name==="")throw new TypeError("Navigation item name must be a non-empty string");if(i.has(u.name))throw new RangeError(`Navigation item already exists: ${u.name}`);if(i.add(u.name),Object.hasOwn(u,"content")&&!Ig(u.content))throw new TypeError(`Navigation panel content for ${u.name} is invalid`);let h={name:u.name,title:String(u.title??""),badge:u.badge==null?null:String(u.badge),href:u.href==null?void 0:String(u.href),disabled:!!u.disabled,onselect:typeof u.onselect=="function"?u.onselect:void 0};return Object.hasOwn(u,"content")&&(h.content=u.content),h}),r=n.some(u=>Object.hasOwn(u,"content"));if(r&&n.some(u=>!Object.hasOwn(u,"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 u of n)this._appendItem(u);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(E(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&&Dg(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",u=>{if(c.definition.disabled){u.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 g?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=su(this.options),e=t===null?this._items.length:Cg(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===Es?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=su(this.options);if(t===null||t===Es||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<=Tg(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 su(s={}){let t=s.overflow??!0;if(typeof t!="boolean")throw new TypeError("NavigationBar overflow must be a boolean");let e=s.overflowBelow??Es;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"||!nu.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 Cg(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 Tg(s,t=16){let e=typeof s=="number"?`${s}px`:String(s).trim();if(!nu.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 Ig(s){return typeof s=="function"||s instanceof g?!0:!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Eg(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function Dg(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 ou(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 Ds(s,t){return t===null?-1:s.findIndex(e=>e.name===t)}function Ms(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 au(s,t,e){return t<0||e<=t?[]:s.slice(t,e).map(i=>i.name)}function lu(s,t,e={}){let{activeIndex:i=-1,completed:n,errored:r}=e;return ru(r,s.name)?"error":t===i?"active":ru(n,s.name)?"complete":"upcoming"}function ru(s,t){return s?s instanceof Set?s.has(t):s.includes(t):!1}var Mg=new Set(["horizontal","vertical"]),Ng=new Set(["completed","all",!1]),Mr=class extends g{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:k(this.el),this._destroyed=!1,this._steps=[],this._records=[],this._activeIndex=-1,this._completed=new Set,this._errored=new Set,!Mg.has(this.options.orientation))throw new RangeError(`Unknown stepper orientation: ${this.options.orientation}`);if(!Ng.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=ou(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:Ds(i,r);return o>=0&&i[o].disabled&&(o=-1),o<0&&(o=Ms(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=Ds(this._steps,t);if(e<0)throw new RangeError(`Unknown step: ${t}`);return this._activate(e)}next(){return this._activate(Ms(this._steps,this._activeIndex,1))}previous(){return this._activate(Ms(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 au(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 lu(t,e,{activeIndex:this._activeIndex,completed:this._completed,errored:this._errored})}_markerContent(t,e){return t==="complete"?[b("check",{size:12})]:t==="error"?[b("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=Ds(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 Og=new Set(["chevron","slash"]),Nr=class extends g{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:k(this.el),this._destroyed=!1,this._items=[],this._overflow=null,!Og.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"},b(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 gt(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"?"/":b("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 Os="\u2026",Fg=new Set(["pages","loadmore"]);function cu({page:s=1,pages:t=1,siblings:e=1,boundaries:i=1}={}){let n=ce(t);if(n<=0)return[];let r=Lr(ce(s)||1,1,n),o=Math.max(0,ce(e)),a=Math.max(0,ce(i)),c=a*2+o*2+3;if(n<=c)return Ns(1,n);let u=Ns(1,Math.min(a,n)),h=Ns(Math.max(n-a+1,a+1),n),d=Math.max(Math.min(r-o,n-a-o*2-1),a+2),f=Math.min(Math.max(r+o,a+o*2+2),h.length>0?h[0]-2:n-1);return[...u,...d>a+2?[Os]:a+1<n-a?[a+1]:[],...Ns(d,f),...f<n-a-1?[Os]:n-a>a?[n-a]:[],...h]}var Fr=class extends g{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:k(this.el),this._destroyed=!1,this._pageSize=Or(this.options.pageSize,25),this._total=Math.max(0,ce(this.options.total)),this._page=Math.max(1,ce(this.options.page)||1),this._disabled=!!this.options.disabled,this._sizeKey="",this._pageSizes=(Array.isArray(this.options.pageSizes)?this.options.pageSizes:[]).map(i=>Or(i,0)).filter(i=>i>0),!Fg.has(this.options.mode))throw new RangeError(`Unknown pagination mode: ${this.options.mode}`);this._page=Lr(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,ce(t.total))),Object.hasOwn(t,"pageSize")&&(this._pageSize=Or(t.pageSize,this._pageSize)),Object.hasOwn(t,"page")){let r=Math.trunc(Number(t.page));Number.isFinite(r)&&(this._page=r)}return this._page=Lr(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"}},b(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",Ci(e),Ci(this._total)):this._message("pagination.summary","%1\u2013%2 of %3",Ci(t+1),Ci(e),Ci(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=cu({page:this._page,pages:t,siblings:this.options.siblings,boundaries:this.options.boundaries});if(e.replaceChildren(...r.map(a=>a===Os?l("span",{class:"zx-pagination__ellipsis",ariaHidden:"true"},Os):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 ce(s){let t=Math.trunc(Number(s));return Number.isFinite(t)&&t>0?t:0}function Or(s,t){let e=Math.trunc(Number(s));return Number.isFinite(e)&&e>0?e:t}function Lr(s,t,e){return Math.min(Math.max(s,t),e)}function Ns(s,t){return t<s?[]:Array.from({length:t-s+1},(e,i)=>s+i)}function Ci(s){return s.toLocaleString()}var Fs=class extends g{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:k(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(u=>String(u??"").split(/\s+/)).filter(Boolean),this.el.classList.add(...this._appliedClasses);let e=uu(t.size,"36px"),i=uu(t.iconSize,"52%");this.el.style.setProperty("--zx-app-icon-size",e),this.el.style.setProperty("--zx-app-icon-glyph-size",i),we(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=Pg(t.glass),this.el.dataset.shape=Bg(t.shape),this.el.toggleAttribute("data-selected",!!t.selected);let n=t.label==null?"":String(t.label).trim();if(this._interactiveRoot){let u=hu(this._snapshot,"role"),h=hu(this._snapshot,"aria-label");u===null?this.el.removeAttribute("role"):this.el.setAttribute("role",u),n?this.el.setAttribute("aria-label",n):h===null?this.el.removeAttribute("aria-label"):this.el.setAttribute("aria-label",h),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=Rg(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 Lg(s={}){return new Fs(null,s).toElement()}function Rg(s){let t=typeof s=="function"?s():s;return typeof t=="string"?b(t,{size:"1em"}):t&&typeof t=="object"&&typeof t.nodeType=="number"?t:null}function uu(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 Pg(s){return s===!1||s==="none"?"none":s==="strong"?"strong":"subtle"}function Bg(s){return s==="circle"?"circle":"tile"}function hu(s,t){return s?.attributes.find(([e])=>e===t)?.[1]??null}var Rr=class extends g{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,_=>[_.name,_.value]),children:Array.from(t.childNodes)},this._items=Ti(this.options.items),this._sources=pu(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._settled=!0,this._pages=[],this._restoreActiveId=null,this._announcePending=!1,this._announceToggle=!1,this._destroyed=!1;let e=x("zx-launcher-results"),i=String(this.options.label??this._message("launcher.label","Launcher")),n=String(this.options.placeholder??this._message("launcher.placeholder","Search applications and records"));this._label=i,this._placeholder=n;let r=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:n,value:this._query}),o=l("button",{ref:"scopeBack",class:"zx-icon-btn zx-launcher__scope-back",type:"button"},b("x")),a=l("span",{ref:"scope",class:"zx-launcher__scope",hidden:!0},l("span",{ref:"scopeLabel",class:"zx-launcher__scope-label"}),o),c=l("button",{ref:"close",class:"zx-icon-btn zx-launcher__close",type:"button",ariaLabel:this.options.closeLabel??this._message("launcher.close","Close launcher")},b("x")),u=l("div",{ref:"status",class:"zx-launcher__status",role:"status",ariaLive:"polite"}),h=l("div",{ref:"announce",class:"zx-launcher__announce",role:"status",ariaLive:"polite",ariaAtomic:"true"}),d=l("div",{ref:"results",class:"zx-launcher__results",id:e,role:"listbox",ariaLabel:this.options.resultsLabel??this._message("launcher.results","Launcher results")}),f=this.options.shortcut==="mod+k"?l("kbd",{class:"zx-launcher__shortcut",ariaHidden:"true"},Vg()):null,p=jg(this.options.hints,{move:this._message("launcher.hintMove","Move"),open:this._message("launcher.hintOpen","Open"),back:this._message("launcher.hintBack","Back"),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:f?"true":"false"}},b("search"),a,r,f,c),u,d,p,h)),t.dataset.state="closed",this._createdRoot&&Yt(this.options.scope)?.append(t),this.listen(r,"input",()=>{this._query=r.value,this._announcePending=!1,this.emit("query",{query:this._query.trim()}),this._refresh()}),this.listen(r,"keydown",_=>this._onKeydown(_)),this.listen(o,"click",()=>{this.back(),r.focus()}),this.listen(c,"click",()=>this.close()),this.listen(d,"click",_=>{let m=_.target?.closest?.("[data-launcher-index]");!m||!d.contains(m)||this._activate(Number(m.getAttribute("data-launcher-index")),_)}),this.listen(d,"pointermove",_=>{let m=_.target?.closest?.("[data-launcher-index]");if(!m||!d.contains(m))return;let w=Number(m.getAttribute("data-launcher-index"));!Number.isInteger(w)||this._results[w]?.disabled||w===this._active||(this._active=w,this._syncActive())}),this.listen(t,"cancel",_=>{_.preventDefault(),this.close()}),this.listen(t,"close",()=>{t.dataset.state="closed",r.setAttribute("aria-expanded","false"),this._abortRequest(),this._pages.length&&!t.open&&(this._unwind(),this._announcePending=!1,this._syncPage(),this._renderResults(),this._emitPage()),this.emit("close")}),this.listen(document,"keydown",_=>this._onDocumentKeydown(_)),this._renderResults(),t}open(t={}){if(this._destroyed)return this;let e=t&&typeof t=="object"?t.page:void 0;if(this.isOpen()){let n=e==null?[]:this._pagePath(e);return n.length&&this._goTo(n),this}if(this._createdRoot){let n=st(this.options.scope);this.el.parentElement!==n&&n.append(this.el)}let i=this._pages.map(n=>n.page);return this.el.showModal(),this.el.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this._goTo(e==null?[]:this._pagePath(e),{emit:!1}),queueMicrotask(()=>{this.isOpen()&&(this.refs.input.focus(),this.refs.input.select())}),this.emit("open"),du(i,this._pages.map(n=>n.page))||this._emitPage(),this}back(){if(!this._pages.length)return this;let t=this._popPage();return this._syncPage(),this._announcePending=this.isOpen(),t?this._renderResults():this._refresh(!0),this._emitPage(),this}getPage(){return this._pages.at(-1)?.page??null}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._announcePending=!1,this.emit("query",{query:this._query.trim()}),this._refresh(),this}getQuery(){return this._query}setItems(t){return this._items=Ti(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._sources=pu(t),this._pages.length?(this._pages[0].parent.sourceItems=null,this):(this._abortRequest(),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(t=!1){this._abortRequest(),this._sourceItems.clear();let{sources:e}=this._level();if(this._settled=e.length===0,t&&e.length&&this._loadSources(),this._renderResults(),t||e.length===0)return;let i=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>this._loadSources(),i)}async _loadSources(){this._queryTimer=null;let t=this._query.trim(),e=this._pages?.at(-1)?.page??null,i=this._level().sources.filter(o=>Ls(o.when,t)&&t.length>=Math.max(o._page?0:Number(this.options.minQuery)||0,Number(o.minQuery)||0));if(i.length===0){this._settled=!0;return}let n=new AbortController,r=++this._requestSequence;this._request=n,this._setBusy(!0),await Promise.all(i.map(async o=>{try{let a=await o.load(t,{signal:n.signal});if(n.signal.aborted||r!==this._requestSequence)return;this._sourceItems.set(o.id,Ti(a).map((c,u)=>({...c,_source:o._page?null:o.id,_sourceOrder:o.order==="source",group:c.group??o.label??"",itemOrder:c.itemOrder??(o.order==="source"?u:void 0)}))),this._renderResults()}catch(a){if(n.signal.aborted||r!==this._requestSequence)return;this.emit("error",{source:o,error:a,page:e})}})),!(n.signal.aborted||r!==this._requestSequence)&&(this._request=null,this._settled=!0,this._setBusy(!1))}_level(){return this._pages?.at(-1)??{items:this._items,sources:this._sources}}_openPage(t){this._pushPage(t),this._syncPage(),this._announcePending=this.isOpen(),this._refresh(!0),this._emitPage()}_goTo(t,{emit:e=!0}={}){let i=this._pages.map(n=>n.page);if(this._unwind(),t.length){this._abortRequest(),this._sourceItems.clear(),this._settled=!1;for(let n of t)this._pushPage(n)}this._syncPage(),this._announcePending=this.isOpen()&&t.length>0,this._refresh(t.length>0),e&&!du(i,t)&&this._emitPage()}_unwind(){for(;this._pages.length;)this._popPage()}_pushPage(t){let e=this._active>=0?this._results[this._active]:null;this._pages.push({page:t,items:Array.isArray(t.items)?Ti(t.items):[],sources:typeof t.items=="function"?[Kg(t)]:[],parent:{query:this._query,activeId:e?String(e.id):null,sourceItems:this._settled?new Map(this._sourceItems):null}}),this._setInputQuery("")}_popPage(){let t=this._pages.pop();if(!t)return!0;this._announcePending=!1,this._abortRequest();let{parent:e}=t;return this._setInputQuery(e.query),this._sourceItems=e.sourceItems?new Map(e.sourceItems):new Map,this._settled=e.sourceItems!==null,this._restoreActiveId=e.activeId,this._settled}_setInputQuery(t){this._query=t,this.refs.input.value=t,this._renderedQuery=null}_syncPage(){let t=this.getPage(),{input:e,scope:i,scopeLabel:n,scopeBack:r,backHint:o}=this.refs;if(i.hidden=t===null,o&&(o.hidden=t===null),this.el.toggleAttribute("data-page",t!==null),t===null){e.setAttribute("aria-label",this._label),e.setAttribute("placeholder",this._placeholder),n.textContent="";return}let a=this._pages.at(-2)?.page.label??this._label;n.textContent=t.label,r.setAttribute("aria-label",this._message("launcher.back","Back to %1",a)),e.setAttribute("aria-label",this._message("launcher.pageLabel","Search %1",t.label)),e.setAttribute("placeholder",t.placeholder!=null?String(t.placeholder):this._message("launcher.pagePlaceholder","Search"))}_emitPage(){let t=this._pages.map(e=>e.page);this.emit("page",{page:t.at(-1)??null,path:t})}_pagePath(t){if(t&&typeof t=="object"){let e=t;return!Ee(e)||e.label==null?[]:[_u({...e,id:e.id??e.label})]}return Hg(this._items,t)}_pageStatus(){let t=this.getPage()?.label??this._label,e=this._results.length;return e===0?this._message("launcher.pageEmpty","%1, no results",t):e===1?this._message("launcher.pageResult","%1, 1 result",t):this._message("launcher.pageResults","%1, %2 results",t,e)}_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._restoreActiveId??null;this._restoreActiveId=null;let i=e??(this._renderedQuery===t&&this._active>=0&&this._results[this._active]?String(this._results[this._active].id):null),n=this._query.trim(),r=this._level(),o=r.items.filter(m=>Ls(m.when,n)),a=Pr(o,n,this.options.maxResults),c=r.sources.flatMap(m=>{let w=this._sourceItems.get(String(m.id))??[];return m.order==="source"?w.filter(y=>Ls(y.when,n)):Pr(w.filter(y=>Ls(y.when,n)),n,this.options.maxResults)}),u=new Set,h=[...a.map(m=>({...m,_source:null})),...c].filter(m=>{let w=String(m.id);return u.has(w)?!1:(u.add(w),!0)}).slice(0,Math.max(0,Number(this.options.maxResults)||0)),d=new Map;for(let m of h){let w=String(m.group??"");d.has(w)||d.set(w,[]),d.get(w).push(m)}this._results=[...d.values()].flat(),this._renderedQuery=t;let f=i===null?-1:this._results.findIndex(m=>!m.disabled&&String(m.id)===i);this._active=f>=0?f:this._results.findIndex(m=>!m.disabled);let p=[],_=0;for(let[m,w]of d){let y=w.map(v=>this._option(v,_++));m?p.push(l("div",{class:"zx-launcher__group",role:"group",ariaLabel:m,dataset:{layout:w.every(v=>v.kind==="application")?"grid":"list"}},l("div",{class:"zx-launcher__group-label",ariaHidden:"true"},m),y)):p.push(...y)}this.refs.results.replaceChildren(...p),this._syncActive(),this._renderStatus()}_option(t,e){let i=Ee(t),n=i?null:B(t.href),r=n?"a":"button",o=[],a=Ug(t);a&&o.push(l("span",{class:"zx-launcher__icon",ariaHidden:"true"},a)),o.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&&o.push(l("span",{class:"zx-launcher__badge"},String(t.badge))),t.hint!=null&&t.hint!==""&&o.push(l("span",{class:"zx-launcher__hint"},String(t.hint)));let c=$g(t),u=qg(t.shortcut);return u.length&&o.push(l("span",{class:"zx-launcher__keys",ariaHidden:c?"true":null},u.map(h=>l("kbd",{class:"zx-launcher__key"},h)))),i&&o.push(l("span",{class:"zx-launcher__chevron",ariaHidden:"true"},b("chevron-right"))),l(r,{class:"zx-launcher__option",type:r==="button"?"button":null,href:n,target:t.target??null,rel:r==="a"?"noopener":null,role:"option",id:x("zx-launcher-option"),tabIndex:-1,ariaSelected:"false",ariaDisabled:t.disabled?"true":null,ariaCurrent:t.current?"page":null,ariaKeyShortcuts:c,dataset:{launcherIndex:e,pinned:t.pinned!==void 0&&t.pinned!==!1?"true":null,kind:Yg(t.kind),page:i?"true":null}},o)}_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,this._announcePending&&!this._busy&&this._renderedQuery===this._query&&(this._announcePending=!1,this._announceToggle=!this._announceToggle,this.refs.announce.textContent=this._pageStatus()+(this._announceToggle?"\xA0":""))}_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}let e=!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey;if(t.key==="Backspace"&&e&&!t.repeat&&this._pages.length&&this._query===""){t.preventDefault(),this.back();return}if(t.key==="Enter"){if(this._active<0)return;t.preventDefault(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.click();return}let i=this._results.map((r,o)=>r.disabled?-1:o).filter(r=>r>=0);if(/^Arrow(?:Left|Right|Up|Down)$/.test(t.key)){let r=i.length?this._spatialIndex(t.key,i):null;if(r!==null){t.preventDefault(),this._active=r,this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"});return}if(t.key==="ArrowLeft"||t.key==="ArrowRight"){e&&!t.repeat&&this._pageKey(t.key)&&t.preventDefault();return}}if(i.length===0)return;let n=i.indexOf(this._active);if(t.key==="Home"||t.key==="PageUp")n=0;else if(t.key==="End"||t.key==="PageDown")n=i.length-1;else if(t.key==="ArrowDown")n=(n+1+i.length)%i.length;else if(t.key==="ArrowUp")n=(n-1+i.length)%i.length;else return;t.preventDefault(),this._active=i[n],this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest"})}_pageKey(t){if(t==="ArrowLeft")return!this._pages.length||this._query!==""?!1:(this.back(),!0);let e=this._active>=0?this._results[this._active]:null;if(!e||e.disabled||!Ee(e)||e.kind==="application")return!1;let i=this.refs.input,n=i.value.length;return i.selectionStart!==n||i.selectionEnd!==n?!1:(this._openPage(e),!0)}_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=Wg(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(Ee(i)){e.preventDefault(),this._openPage(i),this.refs.input.focus();return}if(this.emit("select",{item:i,value:i.value??i.id,source:i._source??null,query:this._query.trim(),page:this.getPage()}).defaultPrevented){e.preventDefault();return}this.close(),i.href||(e.preventDefault(),i.invoke?.())}_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,...i){let n=this.msg(t,...i);return n===t?I(e,i):n}};function Vg(){let s=String(navigator.userAgentData?.platform??navigator.platform??"");return/mac|iphone|ipad/i.test(s)?"\u2318 K":"Ctrl K"}function jg(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",{ref:"backHint",hidden:!0},l("kbd",{},"\u232B"),e.back??t.back),l("span",{},l("kbd",{},"Esc"),e.close??t.close))}function Ee(s){let t=s?.items;return!!s&&typeof s=="object"&&(Array.isArray(t)||typeof t=="function")}function Hg(s,t){if(t==null)return[];let e=String(t),i=new Set,n=(r,o)=>{if(!Array.isArray(r)||i.has(r))return null;i.add(r);for(let a of Ti(r)){if(!Ee(a))continue;let c=[...o,a];if(String(a.id)===e)return c;let u=n(a.items,c);if(u)return u}return null};return n(s,[])??[]}function qg(s){let t=s&&typeof s=="object"&&!Array.isArray(s)?s.label:s;return(Array.isArray(t)?t:t==null?[]:[t]).filter(i=>i!=null&&String(i).trim()!=="").map(i=>String(i).trim())}function $g(s){let t=s.shortcut,e=s.keys??(t&&typeof t=="object"&&!Array.isArray(t)?t.keys:null);return typeof e=="string"&&e.trim()?e.trim():null}function Kg(s){return{id:`page:${String(s.id)}`,load:s.items,order:s.order==="source"?"source":"rank",_page:!0}}function du(s,t){return s.length===t.length&&s.every((e,i)=>e===t[i]||String(e.id)===String(t[i].id))}function Ug(s){let t=s.icon;if(typeof t=="function"&&(t=t(s)),typeof t=="string")return b(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 Yg(s){return s==="application"||s==="record"?s:"action"}function Ls(s,t){return s==="empty"?t==="":s==="query"?t!=="":!0}function Wg(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 u=c.getBoundingClientRect(),h=u.left+u.width/2-n,d=u.top+u.height/2-r,f=!1,p=1/0;e==="ArrowLeft"?(f=h<-2&&Math.abs(d)<Math.max(i.height,u.height)/2,p=Math.abs(h)+Math.abs(d)*4):e==="ArrowRight"?(f=h>2&&Math.abs(d)<Math.max(i.height,u.height)/2,p=Math.abs(h)+Math.abs(d)*4):e==="ArrowUp"?(f=d<-2,p=Math.abs(d)*10+Math.abs(h)):e==="ArrowDown"&&(f=d>2,p=Math.abs(d)*10+Math.abs(h)),f&&p<a&&(o=c,a=p)}return o}function Pr(s,t,e=100){let i=De(t).trim(),n=s.map((o,a)=>({item:o,order:a,score:Gg(o,i)})).filter(({score:o})=>o<1/0);n.sort((o,a)=>{let c=Rs(o.item.groupOrder),u=Rs(a.item.groupOrder);if(c!==u)return c-u;if(i===""){let h=fu(o.item.pinned,o.order),d=fu(a.item.pinned,a.order);if(h!==d)return h-d}return o.score-a.score||Rs(o.item.itemOrder)-Rs(a.item.itemOrder)||Qg(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 Gg(s,t){if(!t)return s.pinned?-1:0;let e=De(s.label),i=De(s.id),n=De(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 fu(s,t){return typeof s=="number"&&Number.isFinite(s)?s:s?t:Number.MAX_SAFE_INTEGER}function Rs(s){return typeof s=="number"&&Number.isFinite(s)?s:Number.MAX_SAFE_INTEGER}function De(s){return String(s??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function Qg(s,t){let e=De(s),i=De(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 Ti(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>_u(t)):[]}function _u(s){let t={...s,label:String(s.label)};if(s.href==null)return t;let e=B(s.href);return e!==null?t.href=e:(delete t.href,typeof t.invoke!="function"&&!Ee(t)&&(t.disabled=!0)),t}function pu(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 Ii=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),mu=Object.freeze(Ii.filter(s=>s!=="slate")),Xg=24,ue=class extends g{static cssName="avatar";static defaults={src:null,name:"",initials:null,label:null,size:"md",shape:"circle",tone:null,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,tone:this.options.tone,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","tone","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();let n=String(this._state.name??""),r=typeof t=="number"&&t<Xg?1:2;this.refs.fallback.textContent=this._state.initials?Jg(String(this._state.initials),r):Ps(n,r);let o=Ii.includes(this._state.tone)?this._state.tone:Ei(n.trim()?n:this._state.initials);this.el.dataset.tone=o;let a=this._state.src==null?"":String(this._state.src).trim();a?(this.refs.image.setAttribute("src",a),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 Ps(s,t=2){let e=String(s??"").trim().split(/\s+/u).filter(Boolean);if(e.length===0)return"?";let i=gu(e[0]),n=t>1&&e.length>1?gu(e[e.length-1]):"";return`${i}${n}`}function Ei(s){let t=String(s??"").trim().normalize("NFC").toLowerCase();if(!t)return"slate";let e=2166136261;for(let i=0;i<t.length;i+=1)e^=t.charCodeAt(i),e=Math.imul(e,16777619);return mu[(e>>>0)%mu.length]}function Jg(s,t){return t>1?s:Br(s.trim())||s}function gu(s){return Br(Br(s).toUpperCase())}function Br(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 Di=class extends g{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:k(t),this._destroyed=!1,this._state=Vr(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=Vr({...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 rb(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=eb(t.icon);i.replaceChildren(...c===null?[]:[c]),i.hidden=c===null;let u=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(u),n.hidden=t.title==="",ib(r,t.subtitle),r.hidden=wu(t.subtitle),o.replaceChildren(...t.metadata.map(h=>l("div",{class:"zx-entity-ref__field",dataset:{labelVisible:String(h.showLabel!==!1)}},l("dt",{class:"zx-entity-ref__label"},h.label),l("dd",{class:"zx-entity-ref__value"},h.icon?b(h.icon,{size:12}):null,yu(h.value))))),o.hidden=t.metadata.length===0,this._renderedActions=t.actions,a.setAttribute("aria-label",t.actionsLabel),a.replaceChildren(...t.actions.map((h,d)=>E(h)?h:Zg(h,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||E(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 Vr(s={}){let t=s&&typeof s=="object"&&!Array.isArray(s)?s:{},e=String(t.title??""),i=Bs(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:bu(t.subtitle),icon:tb(t.icon),metadata:Vs(t.metadata),link:i,actions:js(t.actions),size:sb(t.size),wrap:!!t.wrap,actionsLabel:String(t.actionsLabel||"Entity actions")}}function Bs(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=B(t.href);if(e===null)return null;let i=t.target==null?void 0:String(t.target),n=xu(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 Vs(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=bu(e.value);return!i||wu(n)?[]:[{label:i,value:n,icon:e.icon==null?null:String(e.icon),showLabel:e.showLabel!==!1}]}):[]}function js(s){if(!Array.isArray(s))return[];let t=new Set,e=[];for(let i of s){if(E(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&&B(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:B(n.href),u=n.target==null?void 0:String(n.target),h=xu(n.rel,u);e.push({...n,id:r,label:o,title:a,icon:n.icon==null?null:String(n.icon),kind:nb(n.kind),disabled:!!n.disabled,...c?{href:c}:{},...u?{target:u}:{},...h?{rel:h}:{}})}return e}function Zg(s,t){let e=[s.icon?b(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 tb(s){return s==null||typeof s=="string"||typeof s=="function"?s??null:Mi(s)||s instanceof g?s:null}function eb(s){let t=typeof s=="function"?s():s;return typeof t=="string"?b(t,{size:18}):t instanceof g?t.toElement():Mi(t)?t:null}function bu(s){return s==null?null:typeof s=="string"||typeof s=="number"||Mi(s)||s instanceof g?s:String(s)}function ib(s,t){s.replaceChildren(yu(t))}function yu(s){return s instanceof g?s.toElement():Mi(s)?s:s==null?"":String(s)}function wu(s){return s==null||!Mi(s)&&!(s instanceof g)&&String(s)===""}function Mi(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function sb(s){return s==="sm"||s==="lg"?s:"md"}function nb(s){return s==="default"||s==="primary"||s==="danger"?s:"ghost"}function xu(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 rb(s){return Object.freeze({...s,metadata:s.metadata.map(t=>({...t})),link:s.link?{...s.link}:null,actions:s.actions.map(t=>E(t)?t:{...t})})}var ob=new Set(["ready","temporary","waiting","uploading","processing","success","error"]),ab=Object.freeze({ready:"",temporary:"Temporary",waiting:"Waiting",uploading:"Uploading",processing:"Processing",success:"Complete",error:"Failed"}),Ni=class extends g{static cssName="file-item";static defaults={id:null,name:"",size:null,mime:"",typeLabel:null,subtitle:null,icon:"file",metadata:[],link:null,actions:[],status:"ready",statusLabel:null,progress:null,indeterminate:!1,identitySize:"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:k(t),this._destroyed=!1,this._state=he(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 Di(e,vu(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=he({...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 gb(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.identitySize=t.identitySize,this._entity.set(vu(t));let a=fb(t);i.replaceChildren(...a?[dt({label:a,kind:pb(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 u=`${a||"Progress"}${t.indeterminate||t.progress===null?"":` \u2014 ${Math.round(t.progress)}%`}`;if(this.refs.progressHead.textContent=u,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 h=t.progress??0;r.setAttribute("aria-valuenow",String(h)),r.setAttribute("aria-valuetext",`${Math.round(h)}%`),o.style.setProperty("--zx-file-progress",`${h}%`)}}_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 he(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=ob.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??""),typeLabel:t.typeLabel==null?null:String(t.typeLabel),subtitle:_b(t.subtitle),icon:t.icon===void 0?"file":t.icon,metadata:Vs(t.metadata),link:Bs(t.link),actions:js(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,identitySize:t.identitySize==="sm"||t.identitySize==="lg"?t.identitySize:"md",wrap:!!t.wrap,actionsLabel:String(t.actionsLabel||"File actions"),locale:mb(t.locale)}}function vu(s){let t=[],e=s.typeLabel??hb(s.mime,s.name);return e&&t.push({label:"Type",value:e,showLabel:!1}),s.size!==null&&t.push({label:"Size",value:pi(s.size,{locale:s.locale}),showLabel:!1}),t.push(...s.metadata),{id:s.id,title:s.name,subtitle:s.subtitle,icon:s.icon==="file"?db(s.mime):s.icon,metadata:t,link:s.link,actions:s.actions,size:s.identitySize,wrap:s.wrap,actionsLabel:s.actionsLabel}}var lb=Object.freeze({pdf:{label:"PDF",icons:["file-pdf"]},csv:{label:"CSV",icons:["file-csv","file-excel"]},tsv:{label:"TSV",icons:["file-csv","file-excel"]},spreadsheet:{label:"Spreadsheet",icons:["file-excel"]},document:{label:"Document",icons:["file-word","file-lines"]},presentation:{label:"Presentation",icons:["file-powerpoint"]},text:{label:"Text",icons:["file-lines"]},markdown:{label:"Markdown",icons:["file-lines"]},html:{label:"HTML",icons:["file-code","code"]},css:{label:"CSS",icons:["file-code","code"]},javascript:{label:"JavaScript",icons:["file-code","code"]},json:{label:"JSON",icons:["file-code","code"]},xml:{label:"XML",icons:["file-code","code"]},zip:{label:"ZIP",icons:["file-zipper"]},gzip:{label:"GZIP",icons:["file-zipper"]},tar:{label:"TAR",icons:["file-zipper"]},rar:{label:"RAR",icons:["file-zipper"]},sevenZip:{label:"7Z",icons:["file-zipper"]},email:{label:"Email",icons:["envelope"]},calendar:{label:"Calendar",icons:["calendar"]},contact:{label:"Contact",icons:["address-card"]},image:{label:"Image",icons:["file-image","image"]},video:{label:"Video",icons:["file-video","video"]},audio:{label:"Audio",icons:["file-audio"]},font:{label:"Font",icons:["font"]}}),cb=new Map(Object.entries({"application/pdf":"pdf","text/csv":"csv","application/csv":"csv","text/comma-separated-values":"csv","text/tab-separated-values":"tsv","application/vnd.ms-excel":"spreadsheet","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"spreadsheet","application/vnd.oasis.opendocument.spreadsheet":"spreadsheet","application/msword":"document","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"document","application/vnd.oasis.opendocument.text":"document","application/rtf":"document","text/rtf":"document","application/vnd.ms-powerpoint":"presentation","application/vnd.openxmlformats-officedocument.presentationml.presentation":"presentation","application/vnd.oasis.opendocument.presentation":"presentation","text/plain":"text","text/markdown":"markdown","text/x-markdown":"markdown","text/html":"html","application/xhtml+xml":"html","text/css":"css","text/javascript":"javascript","application/javascript":"javascript","application/json":"json","application/ld+json":"json","application/xml":"xml","text/xml":"xml","application/zip":"zip","application/x-zip-compressed":"zip","application/gzip":"gzip","application/x-gzip":"gzip","application/x-tar":"tar","application/vnd.rar":"rar","application/x-rar-compressed":"rar","application/x-7z-compressed":"sevenZip","message/rfc822":"email","text/calendar":"calendar","text/vcard":"contact","text/x-vcard":"contact"})),ub=new Map([["image","image"],["video","video"],["audio","audio"],["font","font"],["text","text"]]);function Su(s){let t=String(s??"").split(";")[0].trim().toLowerCase();if(!t)return null;let e=cb.get(t)??ub.get(t.split("/")[0]);return e?lb[e]:null}function hb(s,t=""){if(!String(s??"").trim())return"";let e=Su(s);if(e)return e.label;let i=/\.([a-z0-9]{1,5})$/i.exec(String(t??""))?.[1];return i?i.toUpperCase():""}function db(s){let t=Su(s)?.icons??[];if(!t.length)return"file";if(Ge().provider==="fontawesome")return t[0];let e=new Set(Fn());return t.find(i=>e.has(i))??"file"}function fb(s){return s.statusLabel===null?ab[s.status]:s.statusLabel}function pb(s){return s==="error"?"danger":s==="success"?"success":s==="temporary"||s==="waiting"?"warning":s==="uploading"?"info":s==="processing"?"accent":"neutral"}function _b(s){return s==null?null:typeof s=="string"||typeof s=="number"||s instanceof g||typeof s=="object"&&typeof s.nodeType=="number"?s:String(s)}function mb(s){if(typeof s=="string"&&s.trim())return s}function gb(s){return Object.freeze({...s,metadata:s.metadata.map(t=>({...t})),link:s.link?{...s.link}:null,actions:s.actions.map(t=>E(t)?t:{...t})})}var jr=class extends g{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:k(t),this._destroyed=!1,this._items=Hr(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=Hr(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,he(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]=he({...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 Ni(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"},yb(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<wb(this.options.loadingCount);n+=1)i.append(l("div",{class:"zx-file-list__skeleton"},at({width:"2rem",height:"2rem",radius:"md"}),vi({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 Hr(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=he(e);if(i.id!==null){if(t.has(i.id))throw new RangeError(`Duplicate FileList id: ${String(i.id)}`);t.add(i.id)}return bb(i)})}function bb(s){return{...s,metadata:s.metadata.map(t=>({...t})),link:s.link?{...s.link}:null,actions:[...s.actions],locale:s.locale}}function yb(s,t){if(s==null)return"";if(typeof s=="string"||typeof s=="number")return String(s);if(s instanceof g)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 wb(s){let t=Math.trunc(Number(s));return Number.isFinite(t)?Math.max(1,Math.min(12,t)):3}var Fi=class extends g{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:k(e),this._cleaned=!1,this._headingId=x("zx-activity-item-heading"),this._avatarComponent=null,this._actionsByKey=new Map,this._activity=ku(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=ku({...this._activity,...t}),this._renderActivity(),this}getActivity(){return Iu(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=Cb(t.id);i===null?delete e.dataset.activityId:e.dataset.activityId=i,e.dataset.kind=Tb(t.kind);let n=xb(t.state,t.stateLabel);e.dataset.state=n.state,n.busy?e.setAttribute("aria-busy","true"):e.removeAttribute("aria-busy");let r=Oi(t.actor,"Activity actor"),o=Oi(t.title,"Activity title"),a=[];r!==null&&a.push(l("span",{class:"zx-activity-item__actor"},r)),o!==null&&(a.length&&a.push(" "),a.push(l("span",{class:"zx-activity-item__title"},o)));let c=a.length?l(`h${Db(t.headingLevel)}`,{class:"zx-activity-item__heading",id:this._headingId},a):null,u=Sb(t.timestamp,t.timeLabel),h=this._createStateBadge(n),d=c||u||h?l("header",{class:"zx-activity-item__header"},c,h,u):null,f=Oi(t.content,"Activity content"),p=f===null?null:l("div",{class:"zx-activity-item__body"},f),_=Ab(t.metadata,"zx-activity-item__metadata","Activity metadata",this._message("activityItem.metadata","Activity metadata")),m=kb(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,p,_,m,w),v=this._createAvatar(t.avatar,t.actor),A=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(A)}_createStateBadge(t){if(t.key===null||t.fallback===null)return null;let e=dt({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(E(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||qr(e),label:t.label??null,size:t.size??"md"};return this._avatarComponent=new ue(null,i),this._avatarComponent.toElement()}_createActions(t){let e=zu(t);if(e.length===0)return null;let i=e.map((r,o)=>{if(E(r))return r;let a=String(o);return this._actionsByKey.set(a,r),vb(r,a)}),n=zb(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 zu(s){if(!Array.isArray(s))return[];let t=[],e=new Set;for(let i of s){if(E(i)){t.push(i);continue}let n=Cu(i);!n||e.has(n.id)||(e.add(n.id),t.push(n))}return t}function Cu(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?B(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:Eb(t.rel,c),title:r,disabled:!!t.disabled,kind:Ib(t.kind),onselect:t.onselect}}var Au=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 xb(s,t){let e=String(s??"default"),i=Object.prototype.hasOwnProperty.call(Au,e)?Au[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 Tu(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||Mb(i)}}function ku(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 Iu(s)}function Iu(s){let t=s.avatar&&!E(s.avatar)?{...s.avatar}:s.avatar??null;return{...s,avatar:t,metadata:[...s.metadata??[]],attachments:[...s.attachments??[]],actions:[...s.actions??[]]}}function vb(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(b(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 Sb(s,t){let e=Tu(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 Ab(s,t,e,i){return s.length===0?null:l("ul",{class:t,ariaLabel:i},s.map(n=>l("li",{class:`${t}-item`},Oi(n,e))))}function kb(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`},Oi(n,e))))}function Oi(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 g)return s.toElement();throw new TypeError(`${t} must be text, a Node, a Component, or null`)}function qr(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 g?s.toElement().textContent?.trim()??"":""}function zb(s,t){return qr(s.title)||qr(s.actor)||t}function Cb(s){return typeof s=="string"||typeof s=="number"?String(s):null}function Tb(s){return String(s??"default").trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-")||"default"}function Ib(s){return["default","primary","danger"].includes(String(s))?s:"ghost"}function Eb(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 Db(s){let t=Math.trunc(Number(s));return t>=1&&t<=6?t:3}function Mb(s){try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(s)}catch{return s.toLocaleString()}}var $r=class extends g{static cssName="activity-list";static defaults={items:[],groupBy:null,groupLabel:null,label:"Activity",variant:"default",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:k(e),this._cleaned=!1,this._items=Rt(this.options.items),this._loading=!!this.options.loading,this._itemComponents=[],this._groupSequence=0,e.setAttribute("aria-label",String(this.options.label||"Activity")),this._variant=Ob(this.options.variant),this._variant==="compact"&&(e.dataset.variant="compact");try{return this._renderList(),e}catch(i){throw this._destroyItems(),t||S(e,this._original),i}}setItems(t,e={}){return this._items=Rt(t),this._renderList(),e.silent||this._emitDataChange(),this}getItems(){return this._items.map(Hs)}getItem(t){let e=this._items.find(i=>Object.is(i.id,t));return e?Hs(e):null}appendItems(t,e={}){let i=Rt(Array.isArray(t)?t:[t]);return i.length===0?this:(this._items=Rt([...this._items,...i]),this._renderList(),e.silent||this._emitDataChange(),this)}prependItems(t,e={}){let i=Rt(Array.isArray(t)?t:[t]);return i.length===0?this:(this._items=Rt([...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=Rt(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=Du(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"},Eu(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 Fi(null,{...o,avatar:this._variant==="compact"?Fb(o.avatar):o.avatar,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(Hs)):String(t.id??"Other");return i.setAttribute("aria-labelledby",n),l("section",{class:"zx-activity-list__group",ariaLabelledby:n},l(`h${Nb(this.options.groupHeadingLevel,2)}`,{class:"zx-activity-list__group-heading",id:n},Eu(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=Lb(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"}),vi({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 Du(s,t=null){let e=Rt(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 Rt(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 Hs(i)})}function Hs(s){let t=s.avatar&&Mu(s.avatar)?{...s.avatar}:s.avatar;return{...s,avatar:t,metadata:[...s.metadata??[]],attachments:[...s.attachments??[]],actions:[...s.actions??[]]}}function Eu(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 g)return s.toElement();throw new TypeError(`${t} must be text, a Node, a Component, or null`)}function Mu(s){return!s||typeof s!="object"||Array.isArray(s)?!1:typeof s.nodeType!="number"&&!(s instanceof g)}function Nb(s,t){let e=Math.trunc(Number(s));return e>=1&&e<=6?e:t}function Ob(s){return s==="compact"?"compact":"default"}function Fb(s){if(!Mu(s))return s;let t=s;return t.size==null?{...t,size:"sm"}:t}function Lb(s){let t=Math.trunc(Number(s));return Number.isFinite(t)?Math.max(1,Math.min(12,t)):3}var Kr=class extends g{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 ue(this.refs.avatar,Ou(this._account)),this._menu=new gt(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=Nu(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"},b("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=Nu(t),this._avatar.set(Ou(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 Nu(s){let t=s&&typeof s=="object"?s:{};return{...t,name:String(t.name??""),secondary:String(t.secondary??"")}}function Ou(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 Rb=new Set(["top","bottom","top-start","top-end","bottom-start","bottom-end","left","right","left-start","left-end","right-start","right-end"]),Pb=new Set(["hover","focus","both","manual"]),de=class extends g{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,Yt(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",qb(this.options.maxWidth));let n=Pb.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.#u(Number(this.options.hideDelay)))),(n==="focus"||n==="both")&&(this.listen(this.#t,"focusin",()=>{this.#o||!$b(this.#t)||this.#c(0)}),this.listen(this.#t,"focusout",()=>this.#u(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.#h(),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.#h();let t=st(this.#t);this.el.parentElement!==t&&t.append(this.el);let e=Fu(this.#e);if(e===null)return this;this.el.replaceChildren(e);let i=Rb.has(this.options.placement)?this.options.placement:"top";return this.#i=rt(this.#t,this.el,{placement:i,offset:Number(this.options.offset),flip:!0}),/^(left|right)/.test(i)&&this.el.style.getPropertyValue("position-try-fallbacks")&&this.el.style.setProperty("position-try-fallbacks","flip-inline, top span-all, bottom span-all"),this.el.dataset.state="open",this.#t.setAttribute("aria-describedby",Hb(this.#s,this.el.id)),this.emit("open"),this}hide(){return this.#h(),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=Fu(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.#h(),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)}#u(t){if(this.#h(),!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)}#h(){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 Bb(s,t=""){return new de(s,jb(t)?t:{content:t})}function Vb(s,t){return new de(s,{content:String(t??"")})}function jb(s){return s===null||typeof s!="object"||Array.isArray(s)||typeof s.nodeType=="number"?!1:typeof s.toElement!="function"}function Fu(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 Hb(s,t){let e=String(s??"").split(/\s+/).filter(Boolean);return e.includes(t)||e.push(t),e.join(" ")}function qb(s){return typeof s=="number"&&Number.isFinite(s)?`${s}px`:String(s)}function $b(s){try{return s.matches(":focus-visible")}catch{return!0}}var qs=class extends g{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=fe(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 Pu(i,this.options.header),Pu(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=fe(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&&Ru(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 Ru(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 Ur(this.el),this._items.forEach(t=>{let e=Array.isArray(t.children)&&t.children.length>0,i=Lu(t,{className:"zx-app-rail__item",index:String(t.id),iconOnly:!0,disclosure:e,disclosureIcon:Kb(this.el.dataset.side),visual:$s(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 de(i,{content:t.label,placement:Gb(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 h of t.children??[]){let d=`${i}/${h.id}`,f=!!h.children?.length,p=Lu(h,{className:"zx-app-rail__flyout-item",index:d,iconOnly:!1,disclosure:f,disclosureIcon:Ub(this.el.dataset.side),visual:$s(h,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",{},p)),f?this._buildFlyout(h,p,d,i):this._interaction.listen(p,"click",_=>{this._select(h,_).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 mt(e,{openOn:"manual",placement:n===null?Yb(this.el.dataset.side):Wb(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 u={key:i,parentKey:n,item:t,trigger:e,panel:c,dropdown:a};this._flyouts.set(i,u),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",h=>{h.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",h=>{c.contains(h.relatedTarget)||this._scheduleClose(i)}),this._interaction.listen(e,"click",h=>{h.preventDefault(),h instanceof MouseEvent&&h.detail===0?this.openFlyout(i,{focus:!0}):this.openFlyout(i)}),this._interaction.listen(c,"pointerenter",()=>this._cancelFlyoutTimers(u,!0)),this._interaction.listen(c,"pointerleave",()=>this._scheduleFlyoutClose(u,!0)),this._interaction.listen(c,"focusin",()=>this._cancelFlyoutTimers(u,!0)),this._interaction.listen(c,"focusout",h=>{h.relatedTarget!==e&&!c.contains(h.relatedTarget)&&this._scheduleFlyoutClose(u,!0)}),this._interaction.listen(c,"keydown",h=>this._onFlyoutKeydown(h,u))}_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=Qb(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],u=i.getAttribute("data-app-nav-id");if(t.key===c&&this._flyouts.has(String(u))){t.preventDefault(),this.openFlyout(String(u),{focus:!0});return}let h;if(t.key==="Home")h=0;else if(t.key==="End")h=e.length-1;else if(t.key===o)h=(n-1+e.length)%e.length;else if(t.key===a)h=(n+1)%e.length;else return;t.preventDefault(),e[h]?.focus()}_onFlyoutKeydown(t,e){let i=Bu(e.panel),n=t.target?.closest?.("a, button"),r=i.indexOf(n);if(t.key==="Escape"){t.preventDefault(),t.stopPropagation();let h=[...this._flyouts.values()].find(d=>d.trigger===n&&d.dropdown.isOpen());if(h){this.closeFlyout(h.key),this._restoreFocus(h.trigger);return}this.closeFlyout(e.key),this._restoreFocus(e.trigger);return}let o=[...this._flyouts.values()].find(h=>h.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 u;if(t.key==="Home")u=0;else if(t.key==="End")u=i.length-1;else if(t.key==="ArrowDown")u=(r+1+i.length)%i.length;else if(t.key==="ArrowUp")u=(r-1+i.length)%i.length;else return;t.preventDefault(),i[u]?.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?Yr(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&&Yr(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}},Ur=class extends g{constructor(t){super(null),t.append(this.el)}render(){return l("span",{hidden:!0,"data-zx-app-rail-listener-scope":""})}};function fe(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)?fe(t.children):[]};if(t.href==null)return e;let i=B(t.href);return i!==null?e.href=i:(delete e.href,e.children.length===0&&typeof e.invoke!="function"&&(e.disabled=!0)),e}):[]}function $s(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 b(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 Lu(s,{className:t,index:e,iconOnly:i,disclosure:n,disclosureIcon:r,visual:o}){let a=B(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"},b(r)):null)}function Kb(s){return{left:"chevron-right",right:"chevron-left",top:"chevron-down",bottom:"chevron-up"}[s]??"chevron-right"}function Ub(s){return s==="right"?"chevron-left":"chevron-right"}function Yb(s){return{left:"right-start",right:"left-start",top:"bottom-start",bottom:"top-start"}[s]??"right-start"}function Wb(s){return s==="right"?"left-start":"right-start"}function Gb(s){return{left:"right",right:"left",top:"bottom",bottom:"top"}[s]??"right"}function Bu(s){return[...s.querySelectorAll('a:not([aria-disabled="true"]), button:not([aria-disabled="true"])')]}function Ru(s){return Bu(s)[0]??null}function Qb(s){return[...s.children].map(t=>t.querySelector("[data-app-nav-id]")).filter(Boolean)}function Yr(s,t){return s.some(e=>String(e.id)===t||Yr(e.children??[],t))}function Pu(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 Gr=class extends g{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("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._items=fe(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=Vu(this._orientation,this.options.side),this._modeAbort=null,t.replaceChildren(),t}setItems(t){return this._items=fe(t),this._reconcileExpanded(),this._rail?(this._rail.setItems(this._items),this._decorateRail()):this._renderTree(),this}getItems(){return Hu(this._items)}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 Qr(this._items,e=>{this._expanded.has(String(e.id))&&t.push(e.id)}),t}toggleBranch(t,{silent:e=!1}={}){let i=Me(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=Vu(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 u=this.isCollapsed();if(a){let h=c===null?null:[...this.el.querySelectorAll("[data-app-nav-id]")].find(d=>d.getAttribute("data-app-nav-id")===c)??null;h instanceof HTMLElement?h.focus():u?this.focus():this.refs.collapse instanceof HTMLElement&&!this.refs.collapse.hidden?this.refs.collapse.focus():Ks(this.refs.list)[0]?.focus()}return r!==u&&!e&&this.emit("collapsechange",{collapsed:u}),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():Ks(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"});Wr(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")},b(this._side==="right"?"chevron-right":"chevron-left"));e.hidden=!this.options.collapsible;let i=l("footer",{class:"zx-app-sidebar__footer"});Wr(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")},b(this._side==="right"?"chevron-left":"chevron-right"));i.append(n),this._railExpandButton=n,this._listenMode(n,"click",()=>this.expand())}Wr(i,this.options.railHeader),this._rail=new qs(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=Me(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;Jb(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=$s(t,this.options.renderIcon,{orientation:this._orientation,collapsed:!1,side:this._side,level:e,location:e===1?"root":"inline"}),u=Xb(t,n,o,a,c),h=l("li",{class:"zx-app-sidebar__row",dataset:{level:e}},u);return n&&h.append(l("ul",{class:"zx-app-sidebar__sublist",id:a,hidden:!o},i.map(d=>this._treeRow(d,e+1)))),h}_onTreeClick(t){let e=t.target?.closest?.("[data-app-nav-id]");if(!e||!this.refs.list.contains(e))return;let i=Me(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=Me(this._items,e.getAttribute("data-app-nav-id")),n=Ks(this.refs.list),r=n.indexOf(e);if(t.key==="ArrowRight"&&i?.children?.length){t.preventDefault(),this._expanded.has(String(i.id))?Ks(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=Me(this._items,e.getAttribute("data-app-nav-id")),n=t!==null&&e.getAttribute("data-app-nav-id")===t,r=t!==null&&i?ju(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;Qr(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 Xb(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"},b(e?"chevron-down":"chevron-right")):null)}function Ks(s){return s?[...s.querySelectorAll("[data-app-nav-id]")].filter(t=>!t.closest(".zx-app-sidebar__sublist[hidden]")):[]}function Jb(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 Me(s,t){for(let e of s){if(String(e.id)===String(t))return e;let i=Me(e.children??[],t);if(i)return i}return null}function Qr(s,t){for(let e of s)t(e),Qr(e.children??[],t)}function ju(s,t){return s.some(e=>String(e.id)===t||ju(e.children??[],t))}function Wr(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 Vu(s,t){return s==="horizontal"?t==="bottom"?"bottom":"top":t==="right"?"right":"left"}function Hu(s){return s.map(t=>{let{children:e,...i}=t;return e?.length?{...i,children:Hu(e)}:i})}var Zb=8e3,Jr=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}},Zr=class s extends g{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:cy(e),this._entries=new Set,this._floatingHost=null,this._queue=new Jr(oy(this.options.maxVisible),i=>{this._activate(i)}),e.replaceChildren(),e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e}show(t,e={}){let i=sy(e.action),n={kind:ty(e.kind??this.options.kind),timeout:iy(e.timeout??this.options.timeout,i!==null),closable:e.closable??!!this.options.closable,action:i,leading:ny(e.leading)},r=this._createEntry(t,n);return this._entries.add(r),this._queue.enqueue(r),{close:()=>this._close(r)}}static info(t,e={}){return this.show(t,{...e,kind:"info"})}static success(t,e={}){return this.show(t,{...e,kind:"success"})}static warning(t,e={}){return this.show(t,{...e,kind:"warning"})}static error(t,e={}){return this.show(t,{...e,kind:"error"})}static show(t,e={}){return this.#e(e.scope).show(t,e)}static progress(t,e={}){return this.#e(e.scope)._progress(t)}static disposeRegion(t){if(t==null)return!1;let e=q(t);if(!e)return!1;let i=st(e),n=s.#t.get(i);return n?(s.#t.delete(i),n._disposeFloating(),!0):!1}destroy(){if(!this._cleaned){this._cleaned=!0,this._floatingHost=null;for(let t of this._entries)Xr(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&uy(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=ay(r),o!==void 0&&(e.text=String(o)),Us(i,e))},done:()=>{n||i.closed||(n=!0,e.pct=100,Us(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(b("error",{size:18})),Us(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"},e.leading??b(e.kind,{size:18})),r=l("div",{class:"zx-message__content"});Li(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,hovered:!1,focused:!1,returnFocus:null,progressBar:null,progressFill:null};if(e.leading&&(o.dataset.leading=""),i){o.dataset.progress="";let c=l("span",{class:"zx-message__progress-fill"}),u=l("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:i.text},c);r.append(u),a.progressBar=u,a.progressFill=c,Us(a,i)}if(e.action){let{label:c,kind:u,onclick:h}=e.action,d=j({label:c,kind:u,size:"sm"});d.classList.add("zx-message__action"),o.append(d),this.listen(d,"click",f=>{if(!a.closed)try{h?.(f)}finally{this._close(a)}})}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")},b("x",{size:14}));o.append(c),this.listen(c,"click",()=>this._close(a))}return this.listen(o,"mouseenter",()=>{a.hovered=!0,this._pause(a)}),this.listen(o,"mouseleave",()=>{a.hovered=!1,this._resume(a)}),this.listen(o,"focusin",c=>{if(!a.focused){let u=c.relatedTarget;a.returnFocus=Li(u)&&!o.contains(u)?u:null}a.focused=!0,this._pause(a)}),this.listen(o,"focusout",c=>{let u=c.relatedTarget;Li(u)&&o.contains(u)||(a.focused=!1,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.hovered||t.focused||(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||t.hovered||t.focused)){if(t.remaining<=0){this._close(t);return}this._schedule(t)}}_close(t){if(t.closed)return;if(t.closed=!0,Xr(t),ry(t),!this._queue.isActive(t)){this._queue.remove(t),t.node.remove(),this._entries.delete(t),this._releaseIfEmpty();return}if(t.node.dataset.state="closing",!ly()){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)&&(Xr(t),t.node.remove(),this._entries.delete(t),this._queue.remove(t),this._releaseIfEmpty())}_releaseIfEmpty(){!this._floatingHost||this._entries.size>0||s.#i(this)}_disposeFloating(){let t=this.el;this.destroy(),t.remove()}_message(t,e){let i=this.msg(t);return i===t?e:i}static#e(t){let e=st(t??null);e.isConnected||(e=st(null));let i=this.#t.get(e);if(i&&i.el.isConnected&&i.el.parentElement===e)return i;i&&(this.#t.delete(e),i._disposeFloating());let n=l("div",{class:"zx-message-region",popover:"manual",role:"status",ariaLive:"polite"});e.append(n);let r=new s(n);return r._floatingHost=e,this.#t.set(e,r),typeof n.showPopover=="function"&&n.showPopover(),r}static#i(t){let e=t._floatingHost;e&&s.#t.get(e)===t&&s.#t.delete(e),t._disposeFloating()}};function ty(s){return s==="danger"?"error":["success","warning","error"].includes(String(s))?s:"info"}function ey(s){let t=Number(s);return Number.isFinite(t)?Math.max(0,t):4e3}function iy(s,t=!1){let e=ey(s);return t&&e>0?Math.max(e,Zb):e}function sy(s){if(!s||typeof s!="object")return null;let t=s,e=t.label==null?"":String(t.label).trim();if(!e)return null;let i=["primary","danger","ghost"].includes(String(t.kind))?t.kind:"default";return{label:e,kind:i,onclick:typeof t.onclick=="function"?t.onclick:null}}function ny(s){if(Li(s))return s;if(s&&typeof s=="object"&&typeof s.toElement=="function"){let t=s.toElement();return Li(t)?t:null}return null}function ry(s){let e=s.node.getRootNode?.()?.activeElement??globalThis.document?.activeElement;if(!e||!s.node.contains(e))return;let i=s.returnFocus;s.returnFocus=null,i?.isConnected&&typeof i.focus=="function"&&i.focus({preventScroll:!0})}function oy(s){let t=Number(s);return Number.isInteger(t)&&t>0?t:5}function Li(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function ay(s){let t=Number(s);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function Us(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 Xr(s){s.timer!==null&&clearTimeout(s.timer),s.exitTimer!==null&&clearTimeout(s.exitTimer),s.timer=null,s.exitTimer=null}function ly(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function cy(s){return{attributes:Array.from(s.attributes,t=>[t.name,t.value]),children:Array.from(s.childNodes)}}function uy(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 hy=new Set(["start","end","top","bottom"]),dy=new Set(["dim","blur","none"]),fy=Object.freeze({start:1,end:-1,top:1,bottom:-1}),to=class extends Wt{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=dy.has(this.options.backdrop)?this.options.backdrop:"dim",this.el.dataset.modality=my(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=Ie(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=H(this.#i+t*fy[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 u=this.#l(i),h=u.length>0?_y(c,u):c;this._applySize(H(h,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]:qu(t,e);if(!Number.isFinite(n))return this;let{min:r,max:o}=this.#a(e);return this._applySize(H(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=>qu(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(py()))}open(){return this.isOpen()?this:(this.options.modal==="trap-focus"&&(this.#t??=Hn(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=hy.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=gy(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 py(){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 qu(s,t){return typeof s=="number"&&Number.isFinite(s)&&s>0&&s<=1?s*t:bt(s,t)}function _y(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 my(s){return s===!0?"modal":s==="trap-focus"?"trap-focus":"none"}function gy(s){return s==null||s===""?null:typeof s=="number"?Number.isFinite(s)?`${Math.max(0,s)}px`:null:String(s)}var eo=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),$u(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),$u(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],u=c.el;u.dataset.stack=r?"cascade":"stack",u.dataset.depth=String(a),u.style.setProperty("--zx-sheet-depth",String(a)),u.style.setProperty("--zx-sheet-stack-offset",`${Number(e)||0}px`),u.style.setProperty("--zx-sheet-stack-scale",String(Number(i)||0)),u.toggleAttribute("data-stack-hidden",a>=Math.max(1,Number(n)||1)),u.inert=!r&&a>0,r?(u.style.setProperty("--zx-sheet-depth-offset",`${o}px`),o+=c.getSize()):u.style.removeProperty("--zx-sheet-depth-offset")}}#o(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))}};function $u(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 Ri=class extends g{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 mt(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=Mt(this.#i,kt),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.#h(n)),this.listen(this.#t,"keydown",n=>this.#d(n)),this.listen(this.#i,"click",n=>{let r=n.target.closest?.(kt);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(...As(this.#n,"context-menu")),this}openAt(t,e,i=null){return this.#c(i)?(this.#u(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}#u(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})}#h(t){let e=t,i=this.#f(e.target);!i||!this.#c(i)||(t.preventDefault(),this.#u(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.#u(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?.(kt);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(!Si(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(kt))}};var Ws=Object.freeze(["agenda","day","week","month","year"]),by=864e5;function so(s,t,e={}){let i=pe(t,"Calendar date"),n=Xu(e.weekStart??1),r,o;if(s==="agenda")r=G(i),o=R(r,Qs(e.agendaDays??14,"agendaDays"));else if(s==="day")r=G(i),o=R(r,1);else if(s==="week")r=Ys(i,n),o=R(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=Ys(a,n),o=R(Ys(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 no(s,t,e,i={}){let n=pe(t,"Calendar date"),r=Bt(e,"direction");if(s==="day")n.setDate(n.getDate()+r);else if(s==="agenda")n.setDate(n.getDate()+r*Qs(i.agendaDays??14,"agendaDays"));else if(s==="week")n.setDate(n.getDate()+r*7);else{if(s==="month")return io(n,r);if(s==="year")return io(n,r*12);throw new RangeError(`Unknown calendar view: ${s}`)}return n}function io(s,t){let e=pe(s,"Calendar date"),i=e.getDate();return e.setDate(1),e.setMonth(e.getMonth()+Bt(t,"month amount")),e.setDate(Math.min(i,yy(e.getFullYear(),e.getMonth()))),e}function yy(s,t){return new Date(s,t+1,0).getDate()}function Ne(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=Pt(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 u=Uu(Pt(r,e.start),i,`event ${c} start`),h=Pt(r,e.end),d=h==null||h===""?new Date(u.getTime()):Uu(h,i,`event ${c} end`);if(d<u)throw new RangeError(`Calendar event ${c} ends before it starts`);let f=String(Pt(r,e.title)??"").trim()||"Untitled event",p=String(Pt(r,e.location)??"").trim(),_=Yu(Pt(r,e.editable)),m=Yu(Pt(r,e.durationEditable));return{id:a,title:f,start:u,end:d,allDay:!!Pt(r,e.allDay),color:xy(Pt(r,e.color)),location:p,editable:_,durationEditable:m,data:r}})}function Q(s){return{...s,start:new Date(s.start.getTime()),end:new Date(s.end.getTime())}}function ro(s,t,e={}){let i=Qu(e.minMinutes??0,"minMinutes"),n=Qu(e.maxMinutes??1440,"maxMinutes",!0),r=Qs(e.minimumMinutes??30,"minimumMinutes");if(n<=i)throw new RangeError("Calendar maxMinutes must exceed minMinutes");let o=G(t),a=Wu(o,i),c=Wu(o,n),u=s.filter(p=>!Ct(p)&&oo(p,a,c)).map(p=>{let _=new Date(Math.max(p.start.getTime(),a.getTime())),m=new Date(Math.min(p.end.getTime(),c.getTime()));return m<=_&&(m=new Date(Math.min(c.getTime(),_.getTime()+r*6e4))),{event:p,start:_,end:m,startMinutes:Gu(o,_),endMinutes:Gu(o,m),column:0,columns:1}}).sort((p,_)=>p.start-_.start||_.end-p.end||String(p.event.id).localeCompare(String(_.event.id))),h=[],d=-1/0,f=()=>{if(!h.length)return;let p=[],_=1;for(let m of h){let w=p.findIndex(y=>y<=m.start.getTime());w===-1&&(w=p.length),p[w]=m.end.getTime(),m.column=w,_=Math.max(_,w+1)}for(let m of h)m.columns=_;h=[],d=-1/0};for(let p of u)h.length&&p.start.getTime()>=d&&f(),h.push(p),d=Math.max(d,p.end.getTime());return f(),u}function Gs(s,t,e){let i=G(t),n=R(i,Qs(e,"days")),r=s.filter(a=>Ct(a)&&oo(a,i,n)).map(a=>{let c=G(a.start),u=wy(a);return{event:a,start:Math.max(0,zt(i,c)),end:Math.min(e,zt(i,u)),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(u=>u<=a.start);c===-1&&(c=o.length),a.lane=c,o[c]=a.end}return r}function Pi(s,t={}){let e=Bt(t.days??0,"days"),i=Bt(t.minutes??0,"minutes"),n=Bt(t.endDays??e,"endDays"),r=Bt(t.endMinutes??i,"endMinutes"),o=Q(s);if(o.start=Ku(o.start,e,i),o.end=Ku(o.end,n,r),o.end<o.start)throw new RangeError("Calendar event proposal ends before it starts");return o}function G(s){let t=pe(s,"Calendar date");return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function R(s,t){let e=pe(s,"Calendar date"),i=new Date(e.getTime());return i.setDate(i.getDate()+Bt(t,"day amount")),i}function Ys(s,t=1){let e=G(s),i=Xu(t);return R(e,-((e.getDay()-i+7)%7))}function zt(s,t){let e=G(s),i=G(t),n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(i.getFullYear(),i.getMonth(),i.getDate());return Math.round((r-n)/by)}function X(s){let t=pe(s,"Calendar date"),e=i=>String(i).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function Ct(s){if(s.allDay)return!0;if(s.end<=s.start)return!1;let t=new Date(s.end.getTime()-1);return X(s.start)!==X(t)}function Bi(s,t,e){return oo(s,t,e)}function Ku(s,t,e){let i=new Date(s.getTime());return i.setDate(i.getDate()+t),i.setMinutes(i.getMinutes()+e),i}function wy(s){if(s.end<=s.start)return R(G(s.start),1);let t=G(s.end);return s.end.getTime()===t.getTime()?t:R(t,1)}function oo(s,t,e){let i=s.end>s.start?s.end:new Date(s.start.getTime()+1);return s.start<e&&i>t}function Pt(s,t){return typeof t=="function"?t(s):s[t]}function Uu(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 pe(i,e)}function Yu(s){return s==null?null:!!s}function xy(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 Wu(s,t){let e=G(s);return e.setMinutes(t),e}function Gu(s,t){return(t.getTime()-s.getTime())/6e4}function pe(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 Xu(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 Bt(s,t){let e=Number(s);if(!Number.isInteger(e))throw new TypeError(`${t} must be an integer`);return e}function Qs(s,t){let e=Bt(s,t);if(e<=0)throw new RangeError(`${t} must be greater than zero`);return e}function Qu(s,t,e=!1){let i=Bt(s,t),n=e?1440:1439;if(i<0||i>n)throw new RangeError(`${t} must be from 0 through ${n}`);return i}var vy={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"},lo=class extends g{static cssName="calendar";static defaults={events:[],date:null,view:"month",views:[...Ws],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:vy};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:f})=>[d,f]),children:Array.from(e.childNodes)},this._views=Sy(this.options.views),this._view=this._views.includes(this.options.view)?this.options.view:this._views[0],this._date=Ju(this.options.date,this.options.dateUnit,this._now()),this._events=Ne(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},b("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"}),u=l("div",{ref:"loading",class:"zx-calendar__loading",role:"status",hidden:!0},this.msg("loading")),h=l("div",{ref:"status",class:"zx-calendar__status",role:"status",ariaLive:"polite",ariaAtomic:"true"});return e.replaceChildren(a,c,u,h),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(Q)}setEvents(t,e={}){let i=Ne(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]=Ne([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]=Ne([o],{dateUnit:this.options.dateUnit});return a.data=o.data,this._events=this._events.map((c,u)=>u===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=Ju(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="${Xs(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?b(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=so(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=zt(t.start,t.end);for(let n=0;n<i;n+=1){let r=R(t.start,n),o=R(r,1),a=this._events.filter(h=>Bi(h,r,o)?h.start>=r||n===0:!1).sort(zy),c=l("section",{class:"zx-calendar__agenda-day",role:"row",dataset:{date:X(r)}},l("button",{type:"button",class:"zx-calendar__agenda-heading",role:"rowheader",dataset:{calendarAction:"date",date:X(r),dateCell:"true"},ariaCurrent:me(r,this._now())?"date":null,disabled:this.options.disabled},this._format(r,{weekday:"long",day:"numeric",month:"long"}))),u=l("div",{class:"zx-calendar__agenda-events",role:"gridcell"});if(!a.length)u.append(l("p",{class:"zx-calendar__agenda-empty"},this.msg("noEvents")));else for(let h of a)u.append(this._eventElement(h,{variant:"agenda",day:r}));c.append(u),e.append(c)}return e}_renderTimeGrid(t){let e=Array.from({length:zt(t.start,t.end)},(y,v)=>R(t.start,v)),i=this._view==="week"&&this.options.workweek?e.filter(y=>y.getDay()>0&&y.getDay()<6):e,n=Vt(this.options.slotMinTime,0),r=Vt(this.options.slotMaxTime,1440,!0),o=yt(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)}}),u=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:X(y),dateCell:"true"},ariaCurrent:me(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"})))))),h=this._renderAllDayRail(i),d=l("div",{ref:"timeScroller",class:"zx-calendar__time-scroller"}),f=l("div",{class:"zx-calendar__time-axis",ariaHidden:"true"}),p=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;f.append(l("span",{class:"zx-calendar__time-label"},v%60===0?ao(v,this.options.locale):""));for(let A=0;A<i.length;A+=1){let z=ky(i[A],v),T=String(z.getTime()),N=this._focusedSlot?this._focusedSlot===T:m;N&&(m=!1),_.append(l("button",{type:"button",class:"zx-calendar__slot",role:"gridcell",tabindex:N?0:-1,dataset:{calendarAction:"date",slot:T,dateTime:T,dayIndex:String(A),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 A=ro(this._events,y,{minMinutes:n,maxMinutes:r,minimumMinutes:o});for(let z of A){let T=(z.startMinutes-n)/(r-n)*100,N=Math.max(o/(r-n)*100,(z.endMinutes-z.startMinutes)/(r-n)*100),nt=100/i.length,O=nt/z.columns,Z=v*nt+z.column*O,vt=this._eventElement(z.event,{variant:"timed",day:y,resizable:!0});vt.style.insetInlineStart=`${Z}%`,vt.style.inlineSize=`${O}%`,vt.style.insetBlockStart=`${T}%`,vt.style.blockSize=`${N}%`,w.append(vt)}}),p.append(_,w,this._nowLine(i,n,r)),d.append(f,p),c.append(u,h,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:X(r)},ariaHidden:"true"}));let n=Gs(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=R(t.start,r);i.append(l("span",{class:"zx-calendar__month-weekday",role:"columnheader"},this._format(o,{weekday:"short"})))}e.append(i);let n=zt(t.start,t.end)/7;for(let r=0;r<n;r+=1){let o=R(t.start,r*7),a=Gs(this._events.map(m=>({...m,allDay:!0})),o,7),c=Ay(this.options.eventLimit),u=a.filter(m=>m.lane<c),h=a.filter(m=>m.lane>=c),d=l("div",{class:"zx-calendar__month-week",role:"row",dataset:{weekStart:X(o)}});this.options.weekNumbers&&d.append(l("button",{type:"button",class:"zx-calendar__month-week-number",dataset:{calendarAction:"week",date:X(o)},ariaLabel:this.msg("weekNumber",th(o)),disabled:this.options.disabled},String(th(o))));let f=l("div",{class:"zx-calendar__month-days"});for(let m=0;m<7;m+=1){let w=R(o,m),y=this._events.filter(v=>Bi(v,w,R(w,1))).length;f.append(l("button",{type:"button",class:"zx-calendar__month-day",role:"gridcell",dataset:{calendarAction:"date",date:X(w),dateCell:"true",otherMonth:w.getMonth()===this._date.getMonth()?null:"true",eventCount:String(y)},ariaCurrent:me(w,this._now())?"date":null,ariaLabel:this._dayCountLabel(w,y),disabled:this.options.disabled},this._format(w,{day:"numeric"})))}let p=l("div",{class:"zx-calendar__month-events"});for(let m of u){let w=this._eventElement(m.event,{variant:"month",day:R(o,m.start)});w.style.gridColumn=`${m.start+1} / ${m.end+1}`,w.style.gridRow=String(m.lane+1),p.append(w)}let _=Array.from({length:7},(m,w)=>h.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=R(o,m);p.append(l("button",{type:"button",class:"zx-calendar__more",dataset:{calendarAction:"more",date:X(y),count:String(w)},style:{gridColumn:String(m+1),gridRow:String(c+1)},disabled:this.options.disabled},this.msg("more",w)))}d.append(f,p),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=R(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 u=0;u<7;u+=1){let h=R(a,u);c.append(l("span",{class:"zx-calendar__year-weekday",role:"columnheader"},this._format(h,{weekday:"narrow"})))}for(let u=0;u<42;u+=1){let h=R(a,u);if(h.getMonth()!==n){c.append(l("span",{class:"zx-calendar__year-blank",role:"gridcell",ariaHidden:"true"}));continue}let d=this._events.filter(f=>Bi(f,h,R(h,1))).length;c.append(l("button",{type:"button",class:"zx-calendar__year-day",role:"gridcell",dataset:{calendarAction:"date",date:X(h),dateCell:"true",activity:String(Math.min(3,d))},ariaCurrent:me(h,this._now())?"date":null,ariaLabel:this._dayCountLabel(h,d),disabled:this.options.disabled},String(h.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(Q(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=>me(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"},ao(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:Q(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:Q(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?R(n,1):_e(n,yt(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:Q(i),jsEvent:t});return}if(t.key===" "&&!this._keyboardEdit){if(n?!this._canResize(i):!this._canMove(i))return;t.preventDefault(),this._keyboardEdit={oldEvent:Q(i),event:Q(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 u=this._keyboardEdit;this._keyboardEdit=null,u.control.removeAttribute("aria-grabbed"),this._commitMutation(u.oldEvent,u.event,u.action,t);return}let r=0,o=0,a=!Ct(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=-yt(this.options.slotDuration):r=-7;else if(t.key==="ArrowDown")a?o=yt(this.options.slotDuration):r=7;else return;t.preventDefault();let c=this._keyboardEdit;if(c.action==="move")c.event=Pi(c.event,{days:r,minutes:o});else{let u=Pi(c.event,{days:0,minutes:0,endDays:r,endMinutes:o});u.end>u.start&&(c.event=u)}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,u=n;if(t.key==="ArrowLeft")u-=1;else if(t.key==="ArrowRight")u+=1;else if(t.key==="ArrowUp")c-=1;else if(t.key==="ArrowDown")c+=1;else if(t.key==="Home")u=0;else if(t.key==="End")u=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)),u=Math.max(0,Math.min(o-1,u));let h=r?.querySelector(`[data-row-index="${c}"][data-day-index="${u}"]`);h&&(e.tabIndex=-1,h.tabIndex=0,this._focusedSlot=h.dataset.slot,h.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=R(i,n),o=this.el.querySelector(`[data-date-cell][data-date="${X(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:Q(r),event:Q(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:_e(n,yt(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=yt(this.options.slotDuration);e.end=_e(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:_e(e.end,-yt(this.options.slotDuration)),n=e.start<e.end?e.end:_e(e.start,yt(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"&&!Ct(t),o=this._timeAtPoint(i,n,r?t.start:null);if(o&&!Ct(t)){if(e==="move"){let p=t.end.getTime()-t.start.getTime(),_=Q(t);return _.start=_e(o,-Number(this._pointer?.timeOffsetMinutes??0)),_.end=new Date(_.start.getTime()+p),_}let f=Q(t);return f.end=_e(o,yt(this.options.slotDuration)),f.end>f.start?f:null}let a=this._dayAtPoint(i,n);if(!a)return null;let c=R(a,-Number(this._pointer?.dayOffset??0)),u=zt(G(t.start),c);if(e==="move")return Pi(t,{days:u,minutes:0});let h=Q(t),d=R(a,1);return h.end=new Date(d.getTime()),h.end>h.start?h: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,u=a?Math.min(r.right,a.right):r.right,h=a?Math.max(r.top,a.top):r.top,d=a?Math.min(r.bottom,a.bottom):r.bottom;if(t<c||t>u||e<h||e>d||r.width<=0||r.height<=0)return null;let f=Number(n.closest('[role="grid"]')?.getAttribute("aria-colcount"))||1,p=Number(n.closest('[role="grid"]')?.getAttribute("aria-rowcount"))||1,_=i?this._timeGridDayIndex(i):-1,m=_>=0?_:Math.max(0,Math.min(f-1,Math.floor((t-r.left)/r.width*f))),w=Math.max(0,Math.min(p-1,Math.floor((e-r.top)/r.height*p))),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 R(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(!Ct(t)){let o=this._timeAtPoint(e,i);if(o){let a=yt(this.options.slotDuration),c=Math.max(0,Math.round((t.end.getTime()-t.start.getTime())/6e4)),u=Math.max(0,c-a),h=Math.round((o.getTime()-t.start.getTime())/6e4);return{minutes:Math.max(0,Math.min(u,h)),days:0}}}let n=this._dayAtPoint(e,i),r=n?zt(G(t.start),n):0;return{minutes:0,days:Math.max(0,r)}}_timeGridDayIndex(t){let e=X(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")||Ct(t))return null;let i=Vt(this.options.slotMinTime,0),n=Vt(this.options.slotMaxTime,1440,!0),r=yt(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 u=()=>{if(c||!this.options.optimistic||this._mutationVersions.get(o)!==a)return!1;let f=this._eventById(o);return!f||f.start.getTime()!==e.start.getTime()||f.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)},h={event:Q(e),oldEvent:Q(t),action:i,delta:Cy(t,e),jsEvent:n,revert:u};this.emit("eventchange",h).defaultPrevented?u():this._announce(this.msg("editCommitted",e.title))}_replaceNormalizedEvent(t){let e=String(t.id);this._events=this._events.map(i=>String(i.id)===e?Q(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(no(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=R(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(Ct(t))return me(t.start,e)?`${Vi(t.start,this.options.locale)} \u2192`:me(t.end,e)?`\u2192 ${Vi(t.end,this.options.locale)}`:this.msg("allDay");let i=co(t.start,this.options.locale);return t.end<=t.start?i:`${i}\u2013${co(t.end,this.options.locale)}`}_eventLabel(t){let e=t.location?`, ${t.location}`:"";return`${t.title}, ${Vi(t.start,this.options.locale)} to ${Vi(t.end,this.options.locale)}${e}`}_dateTimeLabel(t){return Vi(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="${Xs(t.eventId)}"][data-event-action="${t.eventAction??"activate"}"]`)),!e&&t.slot&&(e=this.el.querySelector(`[data-slot="${Xs(t.slot)}"]`)),!e&&t.date&&(e=this.el.querySelector(`[data-date-cell][data-date="${Xs(t.date)}"]`)),e?.focus?.()}_scrollTimeGrid(){let t=this.refs.body.querySelector(".zx-calendar__time-scroller");if(!t)return;let e=Vt(this.options.slotMinTime,0),i=Vt(this.options.slotMaxTime,1440,!0),n=Vt(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(u=>u.dataset.date===X(i)),r=Vt(this.options.slotMinTime,0),o=Vt(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=ao(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 Sy(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(!Ws.includes(e))throw new RangeError(`Unknown Calendar view: ${e}`);return t}function Ju(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 yt(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 Ay(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 Vt(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 ky(s,t){let e=G(s);return e.setMinutes(t),e}function _e(s,t){let e=new Date(s.getTime());return e.setMinutes(e.getMinutes()+t),e}function Zu(s){return`${s.getFullYear()}-${s.getMonth()}-${s.getDate()}`}function me(s,t){return Zu(s)===Zu(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 X(e)===s?e:null}function zy(s,t){return s.start-t.start||t.end-s.end||s.title.localeCompare(t.title)}function ao(s,t){let e=new Date(2026,0,1);return e.setHours(Math.floor(s/60)%24,s%60,0,0),co(e,t)}function co(s,t){return new Intl.DateTimeFormat(t,{hour:"2-digit",minute:"2-digit"}).format(s)}function Vi(s,t){return new Intl.DateTimeFormat(t,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(s)}function th(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 Cy(s,t){let e=t.start.getTime()-s.start.getTime();return{milliseconds:e,days:zt(G(s.start),G(t.start)),minutes:Math.round(e/6e4),endMilliseconds:t.end.getTime()-s.end.getTime()}}function Xs(s){return globalThis.CSS?.escape?CSS.escape(s):s.replace(/[^a-zA-Z0-9_-]/g,t=>`\\${t}`)}var wt=class extends g{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:k(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=ho(this.options.fields),this._viewFieldOrder=ji(this._viewFields,this.options.fieldOrder),this._viewHidden=fo(this._viewFields,this.options.hiddenFields,!0),this._viewData=uo(this.options.data),this._viewSort=Js(this.options.sort,this._viewFields),this._viewSelected=new Set,this._viewSelectionAnchor=null,this._viewFieldControls=null,this._viewFieldList=null,this._viewFieldSettings=jt(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=uo(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(...uo(t)),this._viewSort&&this.options.sortMode==="local"&&this._sortViewData(),this._refreshView("data"),this.emit("datachange",{records:this.getData()}),this}updateRecord(t,e){oh(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=ho(t),this._viewFieldOrder=ji(this._viewFields,e),this._viewHidden=fo(this._viewFields,i),this._viewSort=Js(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=sh(this._viewFieldOrder,String(t),String(e),i);return eh(r,this._viewFieldOrder)?this:this.setFieldOrder(r,n)}setFieldOrder(t,e={}){let i=ji(this._viewFields,t);return eh(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:Js({id:String(t),dir:e},this._viewFields);if(t!=null&&!n)throw new RangeError(`Unknown or unsortable view field: ${t}`);return Iy(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)),ih(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=rh(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-btn",dataset:{size:"sm",kind:"ghost"}},b("fields"),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,u=this._viewFieldOrder.indexOf(String(a));c==="up"&&u>0&&this.moveField(String(a),this._viewFieldOrder[u-1],"before"),c==="down"&&u>=0&&u<this._viewFieldOrder.length-1&&this.moveField(String(a),this._viewFieldOrder[u+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??jt(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 Oe(t,this.options.recordId)}_isViewSelected(t){return this._viewSelected.has(t)}_sortViewData(){this._viewSort&&(this._viewData=nh(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=!ih(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}},b("chevron-up",{size:11})),u=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}},b("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,u))});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 jt(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 ho(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??Ty(n)),sortable:!!e.sortable,type:String(e.type??"text")}})}function ji(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 sh(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 J(s,t,e=0){return typeof s.get=="function"?s.get(t,e):t?.[s.id]}function Zs(s,t,e=0){let i=J(s,t,e);return typeof s.render=="function"?s.render(t,e,i):i==null?"":String(i)}function nh(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 yi(s,r=>typeof i.sortValue=="function"?i.sortValue(r,n.get(r)??0):J(i,r,n.get(r)??0),e.dir)}function rh(s,t){let e=s&&typeof s=="object"?s:{};return{version:1,fieldOrder:ji(t,e.fieldOrder),hiddenFields:[...fo(t,e.hiddenFields)],sort:Js(e.sort,t)}}function Oe(s,t){return typeof t=="function"?t(s):s?.[String(t??"ID")]}function Js(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 fo(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 uo(s){if(!Array.isArray(s))throw new TypeError("Record view data must be an array");return s.forEach(oh),[...s]}function oh(s){if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("Record view data entries must be objects")}function Ty(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 Iy(s,t){return s===null&&t===null||!!(s&&t&&s.id===t.id&&s.dir===t.dir)}function eh(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function ih(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}var _o=class extends wt{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:k(e),this._tableViewRestored=!1,this._tableSyncDepth=0,this._tableViewDestroyed=!1,this._tableHost=l("div",{class:"zx-table-view__table"}),this._initRecordView(e);let i=jt(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=Ey(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 Ft(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(ah(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"};Dy(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);po(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=!po(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)));po(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))];My(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 ah(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,J(t,n,r));else if(typeof e.render!="function"&&typeof t.get=="function"){let n={...i};delete n.render,i.render=(r,o)=>ur(n,{...r,[t.id]:J(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=>J(t,n,0)),i})}function Ey(s,t){let e=jt(t.fieldControls),i=e.enabled&&!e.custom;return{...s&&typeof s=="object"?s:{},columns:ah(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 Dy(s,t){return s===null&&t===null||!!(s&&t&&s.id===t.id&&s.dir===t.dir)}function po(s,t){return s.size===t.size&&[...s].every(e=>t.has(e))}function My(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function sn(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=lh(s,t,r,i),c=lh(s,t,o,i),u=Oy(s,t,e.preview,e.previewAlt,i),h=Fy(s,t,e.link),d=Hi(s,t,e.actions),f=Hy(e.controls),p=$y(e.selectable),_=!!e.selected,m=x("zx-record-card-title"),w=Uy(e.headingLevel),y=h?l("a",{class:"zx-record-card__primary",href:h.href,target:h.target,rel:h.rel},tn(a)):l("span",{class:"zx-record-card__title"},tn(a)),v=l(`h${w}`,{class:"zx-record-card__heading",id:m},y),A=Ny(n,r,o),z=Ry(s,t,A.eyebrowStart,A.eyebrowEnd),T=en(s,t,A.titlePrefix,"zx-record-card__title-prefix","title-prefix"),N=T?l("div",{class:"zx-record-card__title-row"},T,v):v,nt=p==="multi"&&e.selectionTrigger!=="card"?l("label",{class:"zx-record-card__selection"},l("input",{type:"checkbox",checked:_,dataset:{recordSelection:""},ariaLabel:`Select ${ch(a)||"record"}`})):null,O=d.map(By),Z=O.length||f.length?l("div",{class:"zx-record-card__actions",role:"group",ariaLabel:`Actions for ${ch(a)||"record"}`},f,O):null,vt=l("header",{class:"zx-record-card__header"},nt,l("div",{class:"zx-record-card__titles"},N,jy(c)?null:l("p",{class:"zx-record-card__subtitle"},tn(c))),Z),gd=en(s,t,A.metadata,"zx-record-card__metadata"),bd=l("div",{class:"zx-record-card__body"},z,vt,gd);return l("li",{class:"zx-record-card",tabindex:0,ariaDescription:p?_?"Selected":"Not selected":void 0,ariaLabelledby:m,ariaKeyshortcuts:p&&e.selectionTrigger==="card"?"Space Enter":void 0,dataset:{recordIndex:String(t),variant:Ky(e.variant),selected:String(_),selectionTrigger:p&&e.selectionTrigger==="card"?"card":"checkbox"}},u?Ly(u):null,bd)}function Ny(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=Py(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 Oy(s,t,e,i,n=[]){if(e==null)return null;let r=typeof e=="function"?e(s,t):uh(s,t,e,n,!1);if(r==null||r==="")return null;let o=Vy(s,t,i,n);if(nn(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:"",u=qy(c);return{node:null,src:u,alt:a.alt==null?o:String(a.alt),fit:Yy(a.fit),rejected:u===null}}function Fy(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=B(n.href);if(r===null)return null;let o=n.target==null?void 0:String(n.target),a=hh(n.rel,o);return{href:r,...o?{target:o}:{},...a?{rel:a}:{}}}function Hi(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&&B(n.href)===null?[]:[{...n,id:r,label:o,...a?{title:a}:{}}]}):[]}function Ly(s){let t=l("span",{class:"zx-record-card__preview-fallback",ariaHidden:"true"},b("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 Ry(s,t,e,i){let n=en(s,t,e,"zx-record-card__eyebrow-group","eyebrow-start"),r=en(s,t,i,"zx-record-card__eyebrow-group","eyebrow-end");return n||r?l("div",{class:"zx-record-card__eyebrow"},n,r):null}function en(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"},tn(Zs(r,s,t))))))}function Py(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 By(s){let t=String(s.label??""),e=String(s.title??(t||s.id)),i=[s.icon?b(String(s.icon),{size:14}):null,t?l("span",{class:"zx-record-card__action-label"},t):null],n=s.href==null?null:B(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:hh(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 lh(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?Zs(n,s,t):s?.[e]??""}function uh(s,t,e,i,n){let r=i.find(o=>o.id===e);return r?J(r,s,t):Object.prototype.hasOwnProperty.call(s,e)?s[e]:n?e:null}function Vy(s,t,e,i){if(e==null)return"";let n=typeof e=="function"?e(s,t):uh(s,t,e,i,!0);return n==null?"":String(n)}function tn(s){return nn(s)?s:s==null?"":String(s)}function jy(s){return s==null||typeof s!="object"&&String(s)===""}function ch(s){return nn(s)?s.textContent?.trim()??"":s==null?"":String(s).trim()}function nn(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Hy(s){return Array.isArray(s)?s.filter(nn):[]}function qy(s){let t=B(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 hh(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 $y(s){return s==="single"||s==="multi"?s:!1}function Ky(s){return s==="raised"||s==="filled"?s:"outlined"}function Uy(s){let t=Number(s??3);return Number.isInteger(t)&&t>=1&&t<=6?t:3}function Yy(s){return["contain","fill","none","scale-down"].includes(String(s))?s:"cover"}var mo=class extends wt{static cssName="card-view";static defaults={...wt.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:k(e),this._cardCleaned=!1,this._cardNodesById=new Map;let i=this._cardOptions();this._cardGroupOrder=go(i.groupOrder),this._cardMinWidth=dh(i.minCardWidth),this._cardMaxColumns=fh(i.maxColumns),this._cardVariant=ph(i.variant),this._cardLoadingCount=Qy(i.loadingCount),this._cardHeadingLevel=Xy(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);jt(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=go(i.groupOrder)),Object.prototype.hasOwnProperty.call(i,"minCardWidth")&&(this._cardMinWidth=dh(i.minCardWidth)),Object.prototype.hasOwnProperty.call(i,"maxColumns")&&(this._cardMaxColumns=fh(i.maxColumns)),Object.prototype.hasOwnProperty.call(i,"variant")&&(this._cardVariant=ph(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=Wy(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(),u=o.map((h,d)=>this._createCardGroup(h,a,c,d));if(t.replaceChildren(...u),r!==null){let h=this._cardNodesById.get(r);h&&queueMicrotask(()=>h.isConnected&&h.focus())}}_createCardGroup(t,e,i,n){let r=this._cardOptions(),o=t.id===null?null:`zx-card-view-group-${Zy(t.id)}-${n}`,a=l("ul",{class:"zx-card-view__list",ariaLabelledby:o??void 0});for(let c of t.records){let u=this._viewData.indexOf(c),h=this._viewRecordId(c),d=sn(c,u,{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(h),variant:this._cardVariant,headingLevel:this._cardHeadingLevel});this._cardNodesById.set(h,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"},Jy(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(!(_h(e,i)||mh(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||_h(e,i)||mh(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=Hi(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 Wy(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=go(e),r=new Map(n.map(o=>[o,[]]));for(let[o,a]of s.entries()){let c=typeof t=="function"?t(a,o):Gy(a,o,t,i),u=gh(c);r.has(u)||r.set(u,[]),r.get(u).push(a)}return[...r].map(([o,a])=>({id:o,label:o||"Ungrouped",records:a}))}function Gy(s,t,e,i){let n=i.find(r=>r.id===e);return n?J(n,s,t):s?.[e]}function go(s){return Array.isArray(s)?[...new Set(s.map(gh))]:[]}function gh(s){return s==null||s===""?"":String(s)}function dh(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 fh(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 ph(s){return s==="raised"||s==="filled"?s:"outlined"}function Qy(s){let t=Number(s??6);return Number.isFinite(t)?Math.max(1,Math.min(50,Math.floor(t))):6}function Xy(s){let t=Number(s??3);return Number.isInteger(t)&&t>=1&&t<=6?t:3}function _h(s,t){let e=s?.closest?.('a,button,input,select,textarea,summary,[contenteditable="true"],[role="button"]');return!!(e&&e!==t&&t.contains(e))}function mh(s){let t=globalThis.getSelection?.();return!!(t&&!t.isCollapsed&&(t.anchorNode&&s.contains(t.anchorNode)||t.focusNode&&s.contains(t.focusNode)))}function Jy(s){return!!(s&&typeof s=="object"&&typeof s.nodeType=="number")}function Zy(s){return s.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"empty"}var bh=Object.freeze(["neutral","accent","success","warning","danger","info"]);function bo(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=bh.includes(i.tone)?i.tone:bh.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 yh(s){return dt({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 yo(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 wo(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 xo(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=B(i.src??i.image??null),o=i.initials==null?Ps(n):String(i.initials),a=Ii.includes(i.tone)?i.tone:Ei(n);return{name:n,src:r,initials:o,tone:a}}).filter(Boolean)}function wh(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 vo(s,t,e,i){if(!s.length)return null;let n=wh(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,dataset:{tone:c.tone??Ei(c.name)}},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 So(s){let t=[];s.entityIcon&&t.push(l("span",{class:"zx-kanban-view__entity",ariaHidden:"true"},b(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:yh(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 tw=Object.freeze(["neutral","accent","success","warning","danger","info"]);function Ao(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:tw.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 rn(s,t,e){return!Array.isArray(s)||!s.length?[]:s.filter(i=>{try{return i.when(t,e)===!0}catch{return!1}})}function ko(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}),u=on(e,i,r);if(u)return c(u);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 h=[];e.limit!=null&&h.push({reason:"wip",limit:e.limit,count:s.columnCount+o});let d=i?ew(e.laneLimits,i.id):null;d!=null&&h.push({reason:"wip",limit:d,count:s.cellCount+o}),i?.limit!=null&&h.push({reason:"lane-wip",limit:i.limit,count:s.laneCount+o});let f=h.find(_=>_.count>_.limit),p=f??h.find(_=>_.count===_.limit)??h[0];return f&&a==="block"?c(f.reason,{limit:f.limit,count:f.count,limitExceeded:!0}):{allowed:!0,reason:null,limit:p?p.limit:null,count:p?p.count:0,limitExceeded:!!f,limitReached:!!(p&&!f&&p.count===p.limit),policy:a}}function on(s,t,e){return s.id!==e.column&&!xh(s.from,e.column)?"transition":t&&t.id!==e.lane&&!xh(t.from,e.lane)?"lane-transition":null}function zo(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 Co(s,t){if(!t.length)return!0;let e=s.toLowerCase();return t.every(i=>e.includes(i))}function To(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 Io(s,t,e){if(!Array.isArray(s)||!Array.isArray(t)||!t.length)return null;let i=t.map(h=>({...h,index:s.findIndex(d=>Object.is(Oe(d,e.recordId),h.id))}));if(i.some(h=>h.index<0||!h.record||typeof h.record!="object"))return null;i.sort((h,d)=>h.index-d.index);let n=i.map(h=>({id:h.id,from:an(s,h.index,e)})),r=new Set(i.map(h=>h.index)),o=s.filter((h,d)=>!r.has(d)),a=o.filter((h,d)=>U(Xt(h,d,e.columnBy))===e.destination.column&&(e.swimlaneBy==null||U(Xt(h,d,e.swimlaneBy))===e.destination.lane)),c=qi(e.destination.index,a.length),u=o.length;return a[c]?u=o.indexOf(a[c]):a.length&&(u=o.indexOf(a.at(-1))+1),o.splice(u,0,...i.map(h=>h.record)),{records:o,moves:n,to:{column:e.destination.column,lane:e.swimlaneBy==null?null:e.destination.lane,index:c}}}function an(s,t,e){let i=s[t],n=U(Xt(i,t,e.columnBy)),r=e.swimlaneBy==null?null:U(Xt(i,t,e.swimlaneBy)),o=s.filter((c,u)=>U(Xt(c,u,e.columnBy))===n&&(e.swimlaneBy==null||U(Xt(c,u,e.swimlaneBy))===r)),a=Oe(i,e.recordId);return{column:n,lane:r,index:o.findIndex(c=>Object.is(Oe(c,e.recordId),a))}}function Eo(s,t){let e=qi(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 Xt(s,t,e){return typeof e=="function"?e(s,t):e==null?null:s?.[e]}function U(s){return s==null?"":String(s)}function qi(s,t){return s==null||!Number.isFinite(Number(s))?t:Math.max(0,Math.min(t,Math.trunc(Number(s))))}function xh(s,t){return s==null||!Array.isArray(s)?!0:s.length?s.some(e=>String(e)==="*"||String(e)===U(t)):!1}function ew(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 Do='a, button, input, select, textarea, summary, [contenteditable="true"]',iw=4,sw=350,nw=120,ln=56,cn=18,rw=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"}),Mo=class extends wt{static cssName="kanban-view";static defaults={...wt.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?k(e):null,this._kanbanDestroyed=!1;try{if(this._initRecordView(e),this._kanbanColumns=i.columns===null?null:un(i.columns,"column"),this._kanbanSwimlanes=i.swimlanes===null?null:un(i.swimlanes,"swimlane"),this._kanbanColumnOrder=Tt(i.columnOrder),this._kanbanSwimlaneOrder=Tt(i.swimlaneOrder),this._collapsedColumns=new Set(Tt(i.collapsedColumns)),this._collapsedSwimlanes=new Set(Tt(i.collapsedSwimlanes)),this._kanbanRules=Ao(i.rules),this._kanbanSearch=i.search==null?"":String(i.search),this._kanbanFilter=typeof i.filter=="function"?i.filter:null,this._kanbanHistory=To(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=jt(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:un(t,"column");let e=this._rawColumns();if(this._kanbanColumnOrder=Fe(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:un(t,"swimlane");let e=this._rawSwimlanes(),i=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;if(this._kanbanSwimlaneOrder=Fe(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=No(i,t);return Th(r,n)?this:(this._kanbanColumnOrder=Ch(this._kanbanColumnOrder,i,r,this._kanbanColumns===null),this._refreshView("columnorder"),e.silent||this._emitKanbanState("columnorder"),this)}moveColumn(t,e,i="before"){return this.setColumnOrder(zh(this.getColumnOrder(),t,e,i))}getSwimlaneOrder(){return this._resolvedSwimlanes().map(t=>t.id)}setSwimlaneOrder(t,e={}){let i=this._rawSwimlanes(),n=this.getSwimlaneOrder(),r=No(i,t);if(Th(r,n))return this;let o=this._kanbanSwimlanes===null&&this._kanbanOptions().swimlaneBy!=null;return this._kanbanSwimlaneOrder=Ch(this._kanbanSwimlaneOrder,i,r,o),this._refreshView("swimlaneorder"),e.silent||this._emitKanbanState("swimlaneorder"),this}moveSwimlane(t,e,i="before"){return this.setSwimlaneOrder(zh(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(O=>this.getRecord(O)),o=n.map(O=>this._recordLocation(O)),a=o[0],c=this._resolvedColumns(),u=this._resolvedSwimlanes(),h=e.column==null?a.column:String(e.column),d=i.swimlaneBy==null?null:e.lane===void 0?a.lane:U(e.lane),f=c.find(O=>O.id===h),p=i.swimlaneBy==null?null:u.find(O=>O.id===d)??null;if(!f||i.swimlaneBy!=null&&!p)return this._rejectMove("destination",{ids:n,records:r,from:a,to:null,column:null,swimlane:null}),this;let _=new Set(n),m=this._recordsIn(h,d).filter(O=>!_.has(this._viewRecordId(O.record))).length,w=qi(e.index,m),y={column:h,lane:d,index:w};if(n.length===1&&lw(a,y))return this;let v={id:n[0],from:{...a},to:{...y},column:{...f},swimlane:p?{...p}:null},A=this._evaluateMove(r,o,f,p,y,v,_);if(!A.allowed)return this._rejectMove(A.reason,{ids:n,records:r,from:a,to:y,column:f,swimlane:p,evaluation:A}),this;let z=[];for(let O=0;O<n.length;O+=1){let Z=r[O],vt=i.moveMode==="local"?this._localMovedRecord(Z,o[O],y,f,p):Z;if(!vt)return this._rejectMove("grouping",{ids:n,records:r,from:a,to:y,column:f,swimlane:p}),this;z.push({id:n[O],record:vt})}let T=Io(this._viewData,z,{recordId:i.recordId,columnBy:(O,Z)=>this._readAxis(i.columnBy,O,Z),swimlaneBy:i.swimlaneBy==null?null:(O,Z)=>this._readAxis(i.swimlaneBy,O,Z),destination:y});if(!T)return this._rejectMove("destination",{ids:n,records:r,from:a,to:y,column:f,swimlane:p}),this;let N=this._wipAnnouncement(A);return this.emit("recordmove",{record:r[0],id:n[0],records:[...r],ids:[...n],moves:T.moves.map(O=>({id:O.id,from:{...O.from}})),from:{...a},to:{...T.to},column:{...f},swimlane:p?{...p}:null,limitExceeded:A.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:N})),this):(this._commitLocalRecords(T.records),this._announce(n.length>1?this._text("movedMultiple",{count:n.length,target:this._targetName(T.to),wip:N}):this._text("moved",{name:this._recordName(z[0].record,T.to.index),target:this._targetName(T.to),wip:N})),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=Fe(n,Array.isArray(i.columnOrder)?i.columnOrder:this._kanbanColumnOrder,o),this._kanbanSwimlaneOrder=Fe(r,Array.isArray(i.swimlaneOrder)?i.swimlaneOrder:this._kanbanSwimlaneOrder,a);let c=new Set(n.map(h=>h.id)),u=new Set(r.map(h=>h.id));if(Array.isArray(i.collapsedColumns)){let h=Tt(i.collapsedColumns);this._collapsedColumns=new Set(o?h:h.filter(d=>c.has(d)))}if(Array.isArray(i.collapsedSwimlanes)){let h=Tt(i.collapsedSwimlanes);this._collapsedSwimlanes=new Set(a?h:h.filter(d=>u.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 u=this._resolvedColumns(),h=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(u,null,!1)):h.forEach(f=>d.push(this._renderLane(f,u))),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(f=>this.getRecord(f)),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 f=this._cardsById.get(n.id),p=r?f?.querySelector(".zx-kanban-view__move-handle"):f;p?.isConnected&&p.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)=>U(this._readAxis(i.swimlaneBy,w,y))===t.id),c=a.length,u=a.filter(w=>this._visibleIds.has(this._viewRecordId(w))).length,h=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}},b(n?"chevron-right":"chevron-down",{size:13})),d=t.limit??null,f=Sh(c,d),p=this._renderHook("renderSwimlaneHeader",{swimlane:{...t},count:u,total:c,columnTotal:c,limit:d,wip:f,collapsed:n}),_=l("h2",{class:"zx-kanban-view__lane-heading",id:r},h,p??[l("span",{},t.label),i.showCounts||d!=null?this._countIndicator(u,c,d):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:f}},_,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"),h=this._viewData.filter((N,nt)=>U(this._readAxis(r.columnBy,N,nt))===t.id).length,d=i.filter(N=>this._visibleIds.has(this._viewRecordId(N.record))),f=e?aw(t,e.id):null,p=f??t.limit??null,_=Sh(f==null?h:i.length,p),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}},b(o?"chevron-right":"chevron-down",{size:13})),w=this._renderHook("renderColumnHeader",{column:{...t},swimlane:e?{...e}:null,count:d.length,total:i.length,columnTotal:h,limit:p,wip:_,collapsed:o}),y=r.showCounts||p!=null?this._columnIndicator(d.length,i.length,h,p,n&&f==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]),A=l("ul",{class:"zx-kanban-view__cards",id:c,ariaLabel:`${t.label}${e?`, ${e.label}`:""}`});if(d.forEach(N=>A.append(this._renderCard(N.record,N.index,t.id,e?.id??null,n))),!d.length){let N=this._renderHook("renderColumnEmpty",{column:{...t},swimlane:e?{...e}:null,count:0,total:i.length,columnTotal:h,limit:p,wip:_,collapsed:o})??this._placeholderText();N&&A.append(l("li",{class:"zx-kanban-view__column-empty",role:"presentation"},N))}A.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??""}},b("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,A,z);return this._sectionMeta.set(T,{column:t.id,lane:e?.id??null,list:A}),T}_renderCard(t,e,i,n,r){let o=this._kanbanOptions(),a=this._viewRecordId(t),c=!!this._keyboardMove?.ids.some(w=>Object.is(w,a)),u=rn(this._kanbanRules,t,{index:e,column:i,lane:n}),h=c&&this._keyboardMove?this._keyboardMove.ids.length:1,d=o.moveHandle==="always"||o.dragFrom==="handle"?"always":"keyboard",f=l("button",{class:"zx-kanban-view__move-handle",type:"button",ariaPressed:String(c),dataset:{reveal:d},ariaLabel:h>1?this._text("moveMultiple",{count:h}):this._text("move",{name:this._recordName(t,e)})},b("drag",{size:13})),p=this._resolvedCardFields(),_=sn(t,e,{fields:p.all,visibleFields:p.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:[f]});_.tabIndex=0,c&&(_.dataset.grabbed="true"),this._applyCardContent(_,{record:t,id:a,index:e,column:i,lane:n,rules:u,selected:this._isViewSelected(a)}),this._applyCardRules(_,u),this._applyCardAnatomy(_,t,e),this._applyCardDescription(_,a);let m={record:t,id:a,index:e,column:i,lane:n};return this._cardMeta.set(_,m),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(u=>u.id===a);return i.add(a),c?(u,h)=>J(c,u,h):u=>u?.[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),u=So({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")}]});u&&o.prepend(u);let h=[],d=yo(r.progress?.(e,i),Number(n.progressMax));d&&h.push(wo(d,d.label??this._text("progress"),this._text("progressValue",{percent:d.percent})));let f=xo(r.assignees?.(e,i)),p=vo(f,Number(n.maxAvatars),this._text("assignees",{names:f.map(_=>_.name).filter(Boolean).join(", ")}),_=>this._text("assigneeOverflow",{count:_}));p&&h.push(p),h.length&&o.append(l("div",{class:"zx-kanban-view__card-footer"},h))}_cardIndicator(t,e,i,n){if(!t)return null;let r=t(i,n);return r&&typeof r=="object"&&"nodeType"in r?r:bo(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=>dt({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?vh(this._viewData,(e,i)=>this._readAxis(t.columnBy,e,i)):this._kanbanColumns.map(e=>({...e}))}_resolvedColumns(){let t=this._rawColumns();return this._kanbanColumnOrder=Fe(t,this._kanbanColumnOrder,this._kanbanColumns===null),kh(t,this._kanbanColumnOrder)}_rawSwimlanes(){let t=this._kanbanOptions();return t.swimlaneBy==null?[]:this._kanbanSwimlanes===null?vh(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=Fe(t,this._kanbanSwimlaneOrder,e),kh(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?J(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)=>{U(this._readAxis(i.columnBy,r,o))===t&&(i.swimlaneBy!=null&&U(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:an(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=zo(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&&!Co(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(u=>u.id===a);c?n.push(c):o.push(u=>u?.[a])}return{fields:n,readers:o}}_searchableText(t,e,i){let n=i.fields.map(r=>Ah(J(r,t,e)));for(let r of i.readers)n.push(Ah(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 Eo(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 U(this._readAxis(o.columnBy,a,c))!==i.column||o.swimlaneBy!=null&&U(this._readAxis(o.swimlaneBy,a,c))!==i.lane?null:a}_evaluateMove(t,e,i,n,r,o,a){let c=this._kanbanOptions();for(let p of e){let _=on(i,n,p);if(_)return{allowed:!1,reason:_,limit:null,count:0,limitExceeded:!1,limitReached:!1,policy:i.wipPolicy??(c.wipPolicy==="block"?"block":"warn")}}let u=p=>!a.has(this._viewRecordId(p)),h=this._viewData.filter((p,_)=>U(this._readAxis(c.columnBy,p,_))===r.column&&u(p)).length,d=c.swimlaneBy==null?0:this._viewData.filter((p,_)=>U(this._readAxis(c.swimlaneBy,p,_))===r.lane&&u(p)).length,f=this._recordsIn(r.column,r.lane).filter(p=>u(p.record)).length;return ko({records:t,column:i,swimlane:n,context:o,from:e[0],columnCount:h,laneCount:d,cellCount:f,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)},nw)}),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"},b("search",{size:13}),t)}_createHistoryControls(){this._undoButton=l("button",{class:"zx-btn",type:"button",disabled:!0,dataset:{kanbanHistory:"undo",size:"sm",kind:"ghost"}},this._text("undo")),this._redoButton=l("button",{class:"zx-btn",type:"button",disabled:!0,dataset:{kanbanHistory:"redo",size:"sm",kind:"ghost"}},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 Ri(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:rn(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),u=i.swimlaneBy==null?null:e.lane===void 0?a.lane:U(e.lane),h=this._resolvedColumns().find(m=>m.id===c),d=i.swimlaneBy==null?null:this._resolvedSwimlanes().find(m=>m.id===u)??null;if(!h||i.swimlaneBy!=null&&!d)return!1;let f=new Set(n),p={column:c,lane:u,index:0},_={id:n[0],from:{...a},to:{...p},column:{...h},swimlane:d?{...d}:null};return this._evaluateMove(r,o,h,d,p,_,f).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=Le(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,u=String(c.dataset.kanbanAdd),h=c.dataset.kanbanLane||null;this.emit("recordadd",{column:this._resolvedColumns().find(d=>d.id===u)??null,swimlane:h==null?null:this._resolvedSwimlanes().find(d=>d.id===h)??null,columnId:u,laneId:h,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,u=Hi(r.record,r.index,this._kanbanOptions().actions).find(d=>d.id===c);if(!u||u.disabled){t.preventDefault();return}typeof u.onclick=="function"&&u.onclick(r.record,r.index,t),this.emit("recordaction",{record:r.record,id:r.id,index:r.index,action:{...u},event:t}).defaultPrevented&&t.preventDefault();return}if(!e?.closest(".zx-kanban-view__move-handle, .zx-record-card__selection, [data-record-select]")&&!(e?.closest(Do)||Eh())){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=Le(t),i=this._metaForTarget(e);!i||e?.closest(Do)||Eh()||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=Le(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),u={...a,index:this._visibleIndex(i.id)};this._keyboardMove={ids:c,from:{...a},to:u},e.setAttribute("aria-pressed","true");let h=e.closest(".zx-record-card");h&&(h.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(u=>this.getRecord(u)).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),u=a[c+(t.key==="ArrowLeft"?-1:1)];u!=null&&(n.to.column=u)}else if((t.key==="ArrowUp"||t.key==="ArrowDown")&&r&&this._kanbanOptions().swimlaneBy!=null){let a=this.getSwimlaneOrder(),c=a.indexOf(String(n.to.lane)),u=a[c+(t.key==="ArrowUp"?-1:1)];u!=null&&(n.to.lane=u)}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=qi(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=Le(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=Le(t),i=e?.closest(".zx-kanban-view__move-handle"),n=this._metaForTarget(i??e);if(!n||!i&&(this._kanbanOptions().dragFrom!=="card"||e?.closest(Do)||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),sw))}_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<=iw)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(u=>{let h=u.getBoundingClientRect();return e<h.top+h.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+ln?this._board.scrollLeft-=cn:t>i.right-ln&&(this._board.scrollLeft+=cn);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+ln?n.scrollTop-=cn:e>r.bottom-ln&&(n.scrollTop+=cn)}_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=>!Ih(e,this._cardMeta.get(i)?.id))}_visibleCount(t,e,i){return this._recordsIn(t,e).filter(n=>{let r=this._viewRecordId(n.record);return!Ih(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=Le({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]:rw[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 un(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??Dh(r.id)),limit:Mh(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=ow(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 vh(s,t){let e=[],i=new Set;return s.forEach((n,r)=>{let o=Xt(n,r,t),a=U(o);i.has(a)||(i.add(a),e.push({id:a,label:Dh(o),value:o,limit:null}))}),e}function No(s,t){let e=s.map(r=>r.id),i=new Set(e),n=Tt(t).filter(r=>i.has(r));return[...new Set(n),...e.filter(r=>!n.includes(r))]}function Fe(s,t,e=!1){if(!e)return No(s,t);let i=Tt(t),n=s.map(r=>r.id);return[...i,...n.filter(r=>!i.includes(r))]}function Dh(s){return s==null||String(s).trim()===""?"Unassigned":String(s)}function Mh(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 ow(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=Mh(i);n!=null&&(t[e]=n)}return t}function aw(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 Sh(s,t){return t==null?"none":s>t?"exceeded":s===t?"limit":"within"}function Tt(s){return Array.isArray(s)?[...new Set(s.map(String))]:[]}function Ah(s){return s==null?"":typeof s=="object"?"nodeType"in s?String(s.textContent??""):"":String(s)}function kh(s,t){let e=new Map(s.map(i=>[i.id,i]));return t.map(i=>e.get(i)).filter(Boolean)}function zh(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 Ch(s,t,e,i){if(!i)return[...e];let n=new Set(t.map(c=>c.id)),r=[...e],o=0,a=Tt(s).flatMap(c=>n.has(c)?o<r.length?[r[o++]]:[]:[c]);return a.push(...r.slice(o)),Tt(a)}function lw(s,t){return s.column===t.column&&s.lane===t.lane&&s.index===t.index}function Th(s,t){return s.length===t.length&&s.every((e,i)=>Object.is(e,t[i]))}function Ih(s,t){for(let e of s)if(Object.is(e,t))return!0;return!1}function Le(s){let t=s.target;return t?t instanceof Element?t:t.parentElement:null}function Eh(){let s=globalThis.getSelection?.();return!!(s&&!s.isCollapsed&&String(s).trim())}var Oo=class s extends Ft{static cssName="table";constructor(t=null,e={}){super(t,{editTrigger:"single",...e})}static BillingItems(t,e={}){let i=new s(t,cw(e));return i.el.dataset.preset="billing-items",i}};function cw(s={}){let{fields:t={},units:e=[],currencies:i=[],currency:n="EUR",locale:r,decimals:o=2,columnOverrides:a={},lineTotal:c=null,columns:u,oneditcommit:h,rowClass:d,...f}=s,p={...Fh,...t},_=typeof c=="function"?c:w=>{let y=Oh(w?.[p.quantity]),v=Oh(w?.[p.unitPrice]);return y!==null&&v!==null?y*v:null},m=Array.isArray(u)?u.map(w=>({...w})):Lh(p,{units:e,currencies:i,currency:n,locale:r,decimals:o,columnOverrides:a});return{rowId:p.id,editMode:"cell",editTrigger:"single",rowReorder:!0,columnVisibility:!0,hierarchy:{parentId:p.parent,column:p.item,expanded:!0},responsive:"sm",...f,columns:m,rowClass(w){let y=hn(w,p)?"":"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(hn(y,p)){let A={...y,...v},z=_(A,v);z!=null&&Number.isFinite(Number(z))&&(v[p.total]=Number(z))}h?.(w)}}}var Fh=Object.freeze({id:"id",parent:"parent",item:"item",kind:"kind",quantity:"quantity",unit:"unit",unitPrice:"unitPrice",currency:"currency",total:"total"});function hn(s,t=Fh){let e=String(s?.[t.kind]??"line").toLowerCase();return!["group","subtotal","header","section"].includes(e)}function Lh(s,{units:t,currencies:e,currency:i,locale:n,decimals:r,columnOverrides:o}){let a=d=>f=>hn(f,s)?d:!1,c=d=>String(d?.[s.currency]||i),u=d=>String(d?.[s.unit]??""),h={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:u,editable:a("number"),editorProps:{min:0,step:.01}},unit:{id:s.unit,label:"Unit",width:".8fr",editable:a(Nh(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(Nh(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(h).map(([d,f])=>({...f,...o?.[d]??{}}))}function Nh(s){return Array.isArray(s)?s.length>0:!!(s&&typeof s=="object"&&Object.keys(s).length)}function Oh(s){if(s==null||typeof s=="string"&&s.trim()==="")return null;let t=Number(s);return Number.isFinite(t)?t:null}var Fo=class extends g{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=Ph(this.options.data),this._label=uw(this.options.label),this._chartOptions=It(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),this._stopWatchingMotion=er(t,()=>this._mountOrUpdate(!1)),t}setData(t){return this._data=Ph(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=It(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._stopWatchingMotion?.(),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||Po(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:It(this._data),options:{...fw(this.el),...It(this._chartOptions)},reducedMotion:hi(this.el),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=Po(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=pw(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(Bh(this._data,this._label))}};function uw(s){return String(s??"").trim()||"Chart"}var Lo=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=It(e)}create(t,e){let i=this.engine,n=null,r="",o=!1,a=c=>{let u=null,h=Rh(c,this.defaults,()=>u);u=new i(t,h),n=u,r=c.type};return a(e),{get instance(){return n},update:c=>{if(o)return;if(c.type!==r){let h=n;n=null,h?.destroy?.(),a(c);return}let u=Rh(c,this.defaults,()=>n);n.data=u.data,n.options=u.options,n.update()},resize:()=>{o||n?.resize?.()},destroy:()=>{o||(o=!0,n?.destroy?.(),n=null)}}}};function Rh(s,t,e){let i=It(s.options),n={responsive:!0,maintainAspectRatio:!1,...It(t),...i};s.reducedMotion&&(n.animation=!1);let r=n.onClick;return n.onClick=(o,a,c)=>{typeof r=="function"&&r(o,a,c);let u=e()??c,d=(Array.isArray(a)&&a.length?a:u?.getElementsAtEventForMode?.(o,"nearest",{intersect:!0},!0)??[])[0];if(!d)return;let f=s.data.datasets?.[d.datasetIndex]??null;s.onSelect({datasetIndex:d.datasetIndex,index:d.index,dataset:f,label:s.data.labels?.[d.index],value:f?.data?.[d.index],nativeEvent:o?.native??o??null})},{type:s.type,data:It(s.data),options:n}}function It(s){return Ro(s,new WeakMap)}function Ro(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=>Ro(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]=Ro(n,t);return e}return s}function Ph(s){return!s||typeof s!="object"?{labels:[],datasets:[]}:It({...s,labels:Array.isArray(s.labels)?s.labels:[],datasets:Array.isArray(s.datasets)?s.datasets:[]})}function Po(s){return!Array.isArray(s?.datasets)||!s.datasets.some(t=>Array.isArray(t?.data)&&t.data.length>0)}function Bh(s,t="Chart data"){let e=hw(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 hw(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=>dw(o.data?.[r]))}))}}function dw(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 fw(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 pw(s,t){let e=s&&typeof s=="object"&&"message"in s?String(s.message):"";return e.trim()?e:String(t)}function dn({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 Y(s,t){if(s?.hasChildren===!0)return!0;let e=t.children(s);return Array.isArray(e)&&e.length>0}function Re(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&&Re(a,t,e,{level:i+1,parent:r})})}function Vh(s,t,e){let i=null;return Re(s,e,n=>{i===null&&Object.is(e.value(n),t)&&(i=n)}),i}function $i(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=$i(n,t,e);if(r.length>0)return[i,...r]}return[]}function jh(s,t){let e=[],i=t.children(s);return i&&Re(i,t,n=>e.push(n)),e}function Hh(s,t,e){let i=[],n=(r,o,a)=>{r.forEach((c,u)=>{let h=t.value(c);if(i.push({node:c,id:h,level:o,parent:a,posinset:u+1,setsize:r.length}),!e.has(h))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 Vo=class extends g{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:k(this.el);let t=this.el??l("div");this.el=t,this._readers=dn(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=jo(this.options.items);for(let i of Ki(this.options.expanded))this._expanded.add(i);for(let i of Ki(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 Ki(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=jo(t),this._renderRows(),this}getItems(){return this._items}getNode(t){return Vh(this._items,t,this._readers)}getPath(t){return $i(this._items,t,this._readers)}setFilter(t){if(this._filter=String(t??""),this._filter!=="")for(let e of this._visibleItems())Re([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||!Y(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 Re(this._items,this._readers,t=>{Y(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=Ki(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&&!Y(i,this._readers)}):[...this._checked]}setChecked(t,{silent:e=!0}={}){this._checked.clear();for(let i of Ki(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=Hh(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=Y(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?b("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"},b(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=Y(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 h=this._checkState(this.getNode(r.id)??r.node);c.checked=h==="checked",c.indeterminate=h==="partial",i.setAttribute("aria-checked",h==="partial"?"mixed":String(c.checked))}let u=i.querySelector(".zx-tree__icon");u&&this.options.icons&&u.replaceChildren(b(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"){Y(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&&(Y(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=Y(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:if(!_w(t)||mw(t.target))return;t.preventDefault(),this._handleTypeahead(t)}}_expandSiblings(t){let e=t.parent?this._readers.children(t.parent)??[]:this._visibleItems(),i=this._focusId;for(let n of e)Y(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,...jh(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 jo(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]=jo(n));return e}):[]}function Ki(s){return Array.isArray(s)?s:[]}function _w(s){if(!s||s.ctrlKey||s.metaKey||s.altKey)return!1;let t=typeof s.key=="string"?s.key:"";return t.length===1&&!/\s/.test(t)}function mw(s){let t=s&&s.nodeType===1?s:null;return t?t.isContentEditable||t.localName==="textarea"||t.localName==="select"?!0:t.localName!=="input"?!1:!["checkbox","radio","button","submit","reset","image","range","color","file"].includes(t.type):!1}var Ho=class extends g{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:k(this.el);let t=this.el??l("div");return this.el=t,this._readers=dn(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 u=a.find(h=>Object.is(this._readers.value(h),c));if(!u||(o.push(c),!Y(u,this._readers)))break;if(await this._ensureChildren(u),n!==this._pathSequence)return this;a=this._readers.children(u)??[]}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=$i(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(!Y(a,this._readers))return;let u=this._readers.children(a)??[];i.push({nodes:u,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&&!Y(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=Y(r,this._readers),c=t.selectedId!==void 0&&Object.is(o,t.selectedId),u=l("div",{class:"zx-finder__row",id:x("zx-finder-row"),role:"option",tabIndex:-1,ariaSelected:String(c)});this.options.icons&&u.append(l("span",{class:"zx-finder__icon",ariaHidden:"true"},b(a?"folder":"file",{size:14}))),u.append(l("span",{class:"zx-finder__label"},this.options.renderItem?this.options.renderItem(r):this._readers.label(r))),a&&u.append(l("span",{class:"zx-finder__chevron",ariaHidden:"true"},b("chevron-right",{size:11}))),u.toggleAttribute("data-branch",a),n.append(u)}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&&(Y(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||!Y(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;Y(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,Y(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 qh(s){return String(s??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLocaleLowerCase()}function gw(s,t){let e=qh(t).trim().split(/\s+/).filter(Boolean);if(e.length===0)return!0;let i=qh(s.flat(1/0).join(" "));return e.every(n=>i.includes(n))}function $o(s){return s!=null&&!(typeof s=="string"&&s.trim()==="")}function $h(s,t){if(typeof t.get=="function")return qo(t.get(s));let e=t.fields??t.field??t.id;return(Array.isArray(e)?e:[e]).flatMap(n=>qo(typeof n=="function"?n(s):n==null?void 0:s?.[n]))}function Kh(s,t){let e=[],i=new Map;for(let n of s)for(let r of $h(n,t)){let o=Uh(r);o.value==null||o.value===""||i.has(o.value)||(i.set(o.value,!0),e.push(o))}return e}function ge(s,t,e){return s.filter(i=>t.every(n=>{let r=e?.[n.id];if(!$o(r))return!0;if(n.type==="custom")return typeof n.predicate!="function"||!!n.predicate(i,r);let o=$h(i,n);return n.type==="text"?gw(o,r):n.type==="select"?o.some(a=>bw(Uh(a).value,r)):!0}))}function qo(s){return Array.isArray(s)?s.flat(1/0):[s]}function Uh(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 bw(s,t){return Object.is(s,t)?!0:s==null||t==null?!1:String(s)===String(t)}var Yo=class extends g{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(Ko(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"?Uo(i.element):""}this._filtered=ge(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){xw(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=ge(this._data,this._filters,this._state),this}apply(){this._filtered=ge(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=ge(this._data,this._filters,this._state),this}addFilter(t){Ko(t);let e={...t};return this._filters.push(e),this._state[e.id]=e.type==="custom"?Uo(e.element):"",this._appendFilter(e),this._filtered=ge(this._data,this._filters,this._state),this._syncActiveState(),this}destroy(){this._restored||(this._originalChildren&&this.el.replaceChildren(...this._originalChildren),vw(this._customOrigins),this._restored=!0),super.destroy()}_appendFilter(t){if(Ko(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]=Uo(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(yw):Kh(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=>Yh(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=ge(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=>Yh(r.value,i));e.element.value=n>=0?String(n+1):"",n<0&&(this._state[t.id]="")}else ww(e.element,i)}}_syncActiveState(){let t=this._filters.reduce((e,i)=>e+Number($o(this._state[i.id])),0);this._badge.textContent=String(t),this._badge.hidden=t===0,this._clearButton.hidden=t===0}};function Ko(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 yw(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 Uo(s){return"checked"in s&&["checkbox","radio"].includes(s.type)?s.checked:"value"in s?s.value:s.getAttribute("data-value")??""}function ww(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 Yh(s,t){return Object.is(s,t)?!0:s==null||t==null?!1:String(s)===String(t)}function xw(s){if(!Array.isArray(s))throw new TypeError("DataFilter data must be an array")}function vw(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 Sw=8,Aw=1e11,kw=.01,Jo=class extends g{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:k(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=Cw(this.options.fields,this.options.order),this._draft=Ui(this.options.value,this.options.fields),this._applied=Zo(this._draft,this.options.fields,this.options.serialize),this._appliedDraft=Xo(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 Iw(this._applied)}setValue(t){return this._draft=Ui(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(Ui(this.options.value,this.options.fields))}clear(){return this._replaceDraft(Ui({},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=Wh(e.options),r=this._draft[t]??[],o=new lt(null,{items:n.map(a=>({...a,on:r.some(c=>Gh(c,a.value))})),valueKey:"value",labelKey:"label",search:typeof e.search=="boolean"?e.search:n.length>Sw,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 u=x("zx-filter-panel-date"),h=this._dateInput(String(this._draft[t]??""),{id:u});return this.listen(h,"change",()=>this._edited(t,h.value)),this._entries.push({key:t,write:d=>{h.value=d==null?"":String(d)}}),[l("label",{class:"zx-filter-panel__label",for:u},i),h]}let r=x("zx-filter-panel-label"),o=this._draft[t]??{},a={},c=["from","to"].map(u=>{let h=x("zx-filter-panel-date"),d=this._dateInput(String(o[u]??""),{id:h,ariaLabel:this._edgeName(i,u)});return a[u]=d,this.listen(d,"change",()=>this._editedEdge(t,u,d.value)),l("div",{class:"zx-filter-panel__edge"},l("label",{class:"zx-filter-panel__edge-label",for:h},this._edgeLabel(u)),d)});return this._entries.push({key:t,write:u=>{let h=u??{};for(let d of["from","to"])a[d].value=h[d]==null?"":String(h[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 u=this._numberField(e,n,i,this._draft[t]??null);return u.on("change",()=>this._edited(t,u.get())),this._entries.push({key:t,write:h=>u.set(h??null,{silent:!0})}),[l("span",{class:"zx-filter-panel__label",id:r},i),u.toElement()]}let o=this._draft[t]??{},a={},c=["from","to"].map(u=>{let h=this._numberField(e,n,this._edgeName(i,u),o[u]??null);return a[u]=h,h.on("change",()=>this._editedEdge(t,u,h.get())),l("div",{class:"zx-filter-panel__edge"},l("span",{class:"zx-filter-panel__edge-label"},this._edgeLabel(u)),h.toElement())});return this._entries.push({key:t,write:u=>{let h=u??{};for(let d of["from","to"])a[d].set(h[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:kw,o=new Dt(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=Xo(this._draft)}_draftValue(){return Zo(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;Xo(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 ta(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 be(s){return s==null?!1:s instanceof Date?!Number.isNaN(s.getTime()):Array.isArray(s)?s.some(t=>be(t)):typeof s=="string"?s.trim()!=="":typeof s=="number"?Number.isFinite(s):typeof s=="boolean"?s:typeof s=="object"?Object.values(s).some(t=>be(t)):!0}function zw(s){let t={};if(!Pe(s))return t;for(let[e,i]of Object.entries(s)){if(Pe(i)){let n={};for(let[r,o]of Object.entries(i))be(o)&&(n[r]=o);Object.keys(n).length>0&&(t[e]=n);continue}be(i)&&(t[e]=i)}return t}function Yi(s){if(s==null||s==="")return"";if(s instanceof Date)return Number.isNaN(s.getTime())?"":Qo(s);if(typeof s=="number")return Number.isFinite(s)?Qo(new Date(Math.abs(s)<Aw?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 Yi(Number(t));let e=new Date(t);return Number.isNaN(e.getTime())?"":Qo(e)}function Wo(s,t,e="seconds"){let i=Yi(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 Wh(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 Ui(s,t){let e=Pe(s)?s:{},i={};for(let[n,r]of Object.entries(t??{})){let o=r??{},a=ta(o.type);if(!a)continue;let c=e[n];a.kind==="text"?i[n]=c==null?"":String(c).trim():a.kind==="select"?i[n]=Tw(c,Wh(o.options)):a.kind==="date"?i[n]=a.range?{from:Yi(fn(c,"from")),to:Yi(fn(c,"to"))}:Yi(c):i[n]=a.range?{from:Go(fn(c,"from"),a),to:Go(fn(c,"to"),a)}:Go(c,a)}return i}function Zo(s,t,e="seconds"){let i=Ui(s,t),n={};for(let[r,o]of Object.entries(t??{})){let a=ta((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]=Wo(c,"from",e));continue}let d=c,f={};d.from&&(f.from=Wo(d.from,"from",e)),d.to&&(f.to=Wo(d.to,"to",e)),Object.keys(f).length>0&&(n[r]=f);continue}if(!a.range){c!==null&&(n[r]=c);continue}let u=c,h={};u.from!==null&&(h.from=u.from),u.to!==null&&(h.to=u.to),Object.keys(h).length>0&&(n[r]=h)}return n}function Cw(s,t){let e=Pe(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:ta(e[o]?.type)}))}function Tw(s,t){let e=Array.isArray(s)?s:be(s)?[s]:[];return t.length===0?e.filter(i=>be(i)):t.filter(i=>e.some(n=>Gh(n,i.value))).map(i=>i.value)}function fn(s,t){return s==null?null:Array.isArray(s)?(t==="from"?s[0]:s[1])??null:Pe(s)?t in s?s[t]:null:t==="from"?s:null}function Go(s,t){let e=Ae(s);return e===null?null:t.integer?Math.trunc(e):e}function Qo(s){let t=String(s.getMonth()+1).padStart(2,"0"),e=String(s.getDate()).padStart(2,"0");return`${s.getFullYear()}-${t}-${e}`}function Pe(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)}function Gh(s,t){return Object.is(s,t)?!0:s==null||t===null||t===void 0?!1:String(s)===String(t)}function Iw(s){let t={};for(let[e,i]of Object.entries(s))Array.isArray(i)?t[e]=i.slice():Pe(i)?t[e]={...i}:t[e]=i;return t}function Xo(s){return JSON.stringify(Object.keys(s).sort().map(t=>[t,s[t]]))}var ea=class extends g{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:k(t),this.el=t,this._value=Qh(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 K(null,{items:Ew(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=Qh(t,this.options.fields),n=Xh(i)!==Xh(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(b(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 Qh(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 Ew(s){return s.map(t=>({id:String(t.id),label:t.label}))}function Xh(s){return s?JSON.stringify([s.id,s.dir]):""}var Jh=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"}}),ia=class extends g{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:k(this.el),this._destroyed=!1,this._tools=new Map,this._views=Ow(this.options.views),this._view=Zh(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 re(null,i);let n=this._search.toElement();n.classList.add("zx-list-toolbar__search"),this._search.on("input",r=>this.emit("search",{value:id(r)})),this._search.on("submit",r=>this.emit("search",{value:id(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=nd(t),this.refs.count.textContent=Fw(t,this._countFormat()),this}getCount(){return this._count}setBadge(t,e){let i=this._tools.get(String(t));return i?(i.badge=sd(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 Nw(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(!E(t))throw new TypeError("ListToolbar.addTool() needs an Element");return this.refs.tools.contains(t)?this:(this._adopted.push(td(t)),this.refs.tools.append(t),this)}setView(t,{silent:e=!1}={}){let i=Zh(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=Dw(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&&(ed(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())ed(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(b(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=dt({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=Mw(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?Jh[e.id]?.icon??null:e.icon;return r&&n.append(b(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=Jh[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=td(e),this.refs.tools.append(e))}_findFieldControls(t){if(typeof t.getFieldControls=="function"){let i=t.getFieldControls();if(E(i))return i}if(E(t._viewFieldControls))return t._viewFieldControls;let e=typeof t.toElement=="function"?t.toElement():null;return E(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 Dw(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 sd(s){return s==null||s===!1||s===""?null:String(s)}function Mw(s,t,e="%1 (%2)"){let i=String(s??"");return t==null||t===""?i:I(e,[i,String(t)])}function Nw(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:sd(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 Ow(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 Zh(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 Fw(s,t){let e=nd(s);return e===null?"":String(t(e))}function nd(s){if(s==null||s===""||typeof s=="boolean")return null;let t=Number(s);return Number.isFinite(t)?t:null}function td(s){return{element:s,parent:s.parentNode,next:s.nextSibling}}function ed(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 id(s){return String(s.detail?.value??"")}var mn=Object.freeze([P("contains","contains","single",["text"]),P("notContains","does not contain","single",["text"]),P("eq","is","single",["text","number","money","boolean","enum","status","priority","country","currency","unit","entity","date","datetime"]),P("neq","is not","single",["text","number","money","boolean","enum","status","priority","country","currency","unit","entity","date","datetime"]),P("startsWith","starts with","single",["text"]),P("endsWith","ends with","single",["text"]),P("lt","is less than","single",["number","money"]),P("lte","is at most","single",["number","money"]),P("gt","is greater than","single",["number","money"]),P("gte","is at least","single",["number","money"]),P("on","is on","single",["date","datetime"]),P("notOn","is not on","single",["date","datetime"]),P("before","is before","single",["date","datetime"]),P("onOrBefore","is on or before","single",["date","datetime"]),P("after","is after","single",["date","datetime"]),P("onOrAfter","is on or after","single",["date","datetime"]),P("between","is between","pair",["number","money","date","datetime"]),P("notBetween","is not between","pair",["number","money","date","datetime"]),P("withinLast","is within the last","pair",["date","datetime"]),P("withinNext","is within the next","pair",["date","datetime"]),P("anyOf","is any of","many",["enum","status","priority","country","currency","unit","entity"]),P("noneOf","is none of","many",["enum","status","priority","country","currency","unit","entity"]),P("containsAny","contains any","many",["tags"]),P("containsAll","contains all","many",["tags"]),P("containsNone","contains none","many",["tags"]),P("isEmpty","is empty","none",["text","number","money","date","datetime","boolean","enum","status","priority","country","currency","unit","entity","tags"]),P("isNotEmpty","is not empty","none",["text","number","money","date","datetime","boolean","enum","status","priority","country","currency","unit","entity","tags"])]);function na(){return{version:1,root:{kind:"group",id:x("filter-root"),logic:"and",children:[]}}}function ra(s={}){return{kind:"condition",id:String(s.id||x("filter-condition")),field:String(s.field??""),operator:String(s.operator??""),value:oa(s.value??null)}}function oa(s){return _n(s)}function aa(s="and",t=[]){return{kind:"group",id:x("filter-group"),logic:s,children:t}}function Be(s,t={}){let e=rd(t.maxDepth,3),i=rd(t.maxConditions,50);if(!pn(s)||s.version!==1||!pn(s.root))throw new TypeError("Filter AST must have version 1 and a root group");let n=new Set,r=0,o=(c,u,h=!1)=>{if(!pn(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(u>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(f=>o(f,u+1,!1))}}if(h||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:_n(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 gn(s){return Be(s,{maxDepth:1/0,maxConditions:1/0})}function Lw(s){return JSON.stringify(gn(s))}function la(s,t,e=mn){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(Wi(a.id,"empty-group","Nested groups need at least one condition")),a.children.forEach(d=>o(d));return}let u=n.get(a.field);u||i.push(Wi(a.id,"unknown-field",a.field?`Unavailable field: ${a.field}`:"Choose a field"));let h=r.get(a.operator);if(!h){i.push(Wi(a.id,"unknown-operator",a.operator?`Unavailable operator: ${a.operator}`:"Choose an operator"));return}u&&(!(Array.isArray(u.operators)&&u.operators.length?u.operators:e.filter(f=>f.types.includes(u.type)).map(f=>f.id)).includes(h.id)||!h.types.includes(u.type))&&i.push(Wi(a.id,"operator-type",`${h.label} is not available for ${u.label}`)),Rw(h.arity,a.value)||i.push(Wi(a.id,"value",h.arity==="pair"?"Enter both values":h.arity==="many"?"Choose at least one value":h.arity==="none"?"This operator does not accept a value":"Enter a value"))};return o(s.root,!0),{valid:i.length===0,errors:i}}function P(s,t,e,i){return Object.freeze({id:s,label:t,arity:e,types:Object.freeze(i)})}function Wi(s,t,e){return{nodeId:s,code:t,message:e}}function Rw(s,t){return s==="none"?t===null:s==="pair"?Array.isArray(t)&&t.length===2&&t.every(sa):s==="many"?Array.isArray(t)&&t.length>0&&t.every(sa):sa(t)}function sa(s){return s!=null&&!(typeof s=="string"&&s.trim()==="")}function _n(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=>_n(n,t));return t.delete(s),i}if(!pn(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:_n(n,t),enumerable:!0,configurable:!0,writable:!0});return t.delete(s),e}function pn(s){if(!s||typeof s!="object"||Array.isArray(s))return!1;let t=Object.getPrototypeOf(s);return t===Object.prototype||t===null}function rd(s,t){if(s===1/0)return 1/0;let e=Number(s);return Number.isFinite(e)&&e>=0?Math.floor(e):t}var cd=Object.freeze({choose:"Choose\u2026",yes:"True",no:"False",commaSeparated:"Comma-separated values",value:s=>`${s} value`,valueAt:(s,t)=>`${s} value ${t}`}),ua=class extends g{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:k(t),this._fields=(Array.isArray(this.options.fields)?this.options.fields:[]).map(e=>({...e})),this._operators=Bw(mn,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?na():Be(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 gn(this._value)}setValue(t,{silent:e=!1}={}){let i=Be(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()||hd(this._value.root)>=Number(this.options.maxConditions))return null;let i=ca(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=ra({...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=ca(this._value.root,t??this._value.root.id);if(!i||dd(this._value.root,i.id)>=Number(this.options.maxDepth))return null;let n=aa(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=xt(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=ld(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=ha(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=ud(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=xt(this._value.root,t),r=ca(this._value.root,e),o=ha(this._value.root,t);if(!this._canMutate()||t===this._value.root.id||!n||!r||!o||Pw(n,e))return this;let a=o.children.findIndex(u=>u.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{Be(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=la(this._value,this._fields,this._operators),e=Vw(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="${Zt(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"},Jt("add",this._value.root.id,"plus",this._message("filter.addFilter","Add filter"),{ref:"add",disabled:this._blocked()}),this.options.allowGroups?Jt("add-group",this._value.root.id,"folder",this._message("filter.addGroup","Add group"),{disabled:this._blocked()}):null,Jt("clear","","x",String(this.options.clearLabel??this._message("filter.clear","Clear")),{disabled:this._blocked()}),this.options.showApply?Jt("apply","","check",String(this.options.applyLabel??this._message("filter.apply","Apply filters")),{kind:"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="${Zt(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"},Jt("add",t.id,"plus",this._message("filter.addFilter","Add filter"),{disabled:this._blocked()}),this.options.allowGroups&&e<Number(this.options.maxDepth)?Jt("add-group",t.id,"folder",this._message("filter.addSubgroup","Add subgroup"),{disabled:this._blocked()}):null,i?null:Jt("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(u=>({value:u.id,label:u.label}));t.field&&!e&&r.push({value:t.field,label:this._unavailable(t.field)});let o=i.map(u=>({value:u.id,label:u.label}));t.operator&&!i.some(u=>u.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",u=>{let h=this._field(String(u));this.update(t.id,{field:String(u),operator:this._defaultOperator(h)??"",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(u=>l("option",{value:u.id,selected:u.id===t.field},u.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",u=>{this.update(t.id,{operator:String(u),value:null}),queueMicrotask(()=>this.el.querySelector(`[data-node-id="${Zt(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(u=>l("option",{value:u.id,selected:u.id===t.operator},u.label)),t.operator&&!i.some(u=>u.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 u=this._renderVersion;return queueMicrotask(()=>{if(u!==this._renderVersion||!this.el.contains(n))return;let h=e.editor(n,{value:t.value,field:e,conditionId:t.id,setValue:d=>this._setNodeValue(t.id,ld(d))});h&&typeof h.destroy=="function"&&this._customEditors.push(h)}),n}let r=this._valueMessages(),o=i.arity==="pair"?Array.isArray(t.value)?t.value:[null,null]:[t.value];if(i.arity==="many"){let u=od(e,t,o[0],!0,this._blocked(),0,r);return u?l("div",{class:"zx-filter__value"},u):l("div",{class:"zx-filter__value"},ad(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((u,h)=>this.options.searchable&&a?this._searchSelect(a,u,i.arity==="pair"?r.valueAt(e.label,h+1):r.value(e.label),t.id,"value",d=>{let f=i.arity==="pair"?Array.isArray(t.value)?[...t.value]:[null,null]:null;f&&(f[h]=d),this._setNodeValue(t.id,f??d)}):od(e,t,u,!1,this._blocked(),h,r)??ad(e,t.id,u,h,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 K(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:u})=>queueMicrotask(()=>{!this._disposed&&a===this._renderVersion&&this._canMutate()&&o(u.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=xt(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=xt(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="${Zt(i)}"] [data-filter-value]`)?.focus())}else if(e.dataset.filterLogic!==void 0){let n=xt(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=xt(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=xt(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=>bn(o.value,n.type));else if(i.arity==="many")r=t.value.split(",").map(o=>o.trim()).filter(Boolean).map(o=>bn(o,n.type));else if(i.arity==="pair"){let o=Array.isArray(e.value)?[...e.value]:[null,null];o[Number(t.dataset.valueIndex)||0]=bn(t.value,n.type),r=o}else r=bn(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=xt(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="${Zt(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="${Zt(t)}"] [data-filter-value]`)?.getAttribute("list"),u=c?this.el.querySelector(`#${Zt(c)}`):null;u&&u.replaceChildren(...(Array.isArray(o)?o:[]).map(h=>l("option",{value:h.value},h.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="${Zt(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 Jt("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 Jt(s,t,e,i,n={}){let{kind:r,...o}=n;return l("button",{type:"button",class:"zx-btn",...o,dataset:{filterAction:s,nodeId:t,size:"sm",...r?{kind:r}:{}}},b(e),l("span",{},i))}function od(s,t,e,i,n,r=0,o=cd){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(u=>l("option",{value:u.value,selected:c.has(String(u.value))},u.label)))}function ad(s,t,e,i,n,r=!1,o=cd){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,u=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"},u,c?l("datalist",{id:c}):null)}function bn(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 ld(s){return oa(s===void 0?null:s)}function xt(s,t){if(!s||s.id===t)return s??null;if(s.kind==="group")for(let e of s.children){let i=xt(e,t);if(i)return i}return null}function ca(s,t){let e=xt(s,t);return e?.kind==="group"?e:null}function ha(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=ha(e,t);if(i)return i}return null}function ud(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=ud(i,t);if(n)return n}return null}function Pw(s,t){return!!(s&&xt(s,t))}function hd(s){return s.kind==="condition"?1:s.children.reduce((t,e)=>t+hd(e),0)}function dd(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=dd(i,t,e+1);if(n>=0)return n}}return-1}function Bw(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 Zt(s){return globalThis.CSS?.escape?CSS.escape(s):String(s).replaceAll(/[^a-zA-Z0-9_-]/g,"\\$&")}function Vw(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 Ve=class extends g{static cssName="fieldset";static defaults={title:"",columns:1,fields:{},idPrefix:null};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._idPrefix=this.options.idPrefix?String(this.options.idPrefix):x("zx-fieldset"),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(E(e)||e instanceof g){let o=e;n=new C(null,{id:this._controlId(i),name:i,type:"custom",label:i,value:Hw(o),disabled:qw(o),adapter:()=>jw(o)}),r=!0}else{let o=e&&typeof e=="object"?e:{},a=o.id!=null&&String(o.id)!==""&&String(o.id)!==i;n=new C(null,{...o,id:a?String(o.id):this._controlId(i),name:o.name??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}_controlId(t){return`${this._idPrefix}-${t.trim().replace(/\s+/g,"-")}`}_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 jw(s){let t=E(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 Hw(s){let t=E(s)?s:s.toElement();return typeof s.getValue=="function"?s.getValue():typeof s.getValues=="function"?s.getValues():"value"in t?t.value:null}function qw(s){let t=E(s)?s:s.toElement();return"disabled"in t?!!t.disabled:t.getAttribute("aria-disabled")==="true"}var fa=class extends g{static cssName="form";static defaults={fieldsets:[],actions:[],novalidate:!0,idPrefix:null,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._idPrefix=this.options.idPrefix?String(this.options.idPrefix):x("zx-form"),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 Ve),i=e?new Ve(null,{...t??{},idPrefix:t?.idPrefix??this._idPrefix}):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?b(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&&da(a))c=this.msg("form.required");else if(!da(a)&&o.options.type==="int"){let u=Sn(a);u.valid?o.setValue(u.value,{silent:!0}):c=this.msg("form.int")}else if(!da(a)&&o.options.type==="float"){let u=An(a);u.valid?o.setValue(u.value,{silent:!0}):c=this.msg("form.float")}c?(t[r]=c,o.setHighlight(c,"danger"),e??=o):o.clearHighlight()}return Object.keys(t).length?(this.emit("invalid",{errors:t}),e?.focus(),!1):!this.emit("submit",{values:this.getValues()}).defaultPrevented}_handleAction(t){let e=t.target instanceof Element?t.target.closest("[data-action-index]"):null;if(!e||!this._actions.contains(e))return;let 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 da(s){return s==null||s===""||s===!1||Array.isArray(s)&&s.length===0}var yn="123456789abcdefghijklmnopqrstuvwxyz";function fd(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=$w(e.choices??[],i),r=e.field&&typeof e.field=="object"?{...e.field}:null,o=Uw(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 $w(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<yn.length&&n.has(yn[r]);)r+=1;if(r>=yn.length)break;o.key=yn[r],n.add(o.key),r+=1}return i}function Kw(s,t){if(typeof s.when!="function")return!0;try{return s.when(t)!==!1}catch{return!0}}function Ht(s,t){let e={},i=[];for(let n of s)Kw(n,e)&&(i.push(n),Object.prototype.hasOwnProperty.call(t,n.name)&&(e[n.name]=t[n.name]));return{answers:e,visible:i}}function wn(s,t,e){let{answers:i,visible:n}=Ht(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(u=>u.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 ye(s){return s==null?!0:typeof s=="string"?s.trim()==="":Array.isArray(s)?s.every(t=>ye(t)):!1}function pd(s,t,e){return!s.required||!ye(t)?null:e(s.choices.length>0?"questionnaire.required":"questionnaire.requiredInput")}function _d(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 md(s,t,e){let{answers:i,visible:n}=Ht(s,t),r=new Map(n.map(p=>[p.name,p])),o=e.filter(p=>r.has(p)),a=o.length>0?r.get(o[o.length-1]):null,c=o.filter(p=>!ye(i[p])).length,u=new Set(o),h=a?n.indexOf(a):-1,d=n.slice(h+1).filter(p=>!u.has(p.name)).length,f=o.length+d;return{index:Math.max(0,o.length-1),answered:c,total:f,percent:f===0?0:Math.round(c/f*100),section:a?.section??""}}function Uw(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 Yw=260,pa=class extends g{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:k(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 xi(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);Ht(this._items,this._rawAnswers()).visible.some(n=>n.name===e)&&(this._path=[e])}return this._paint(),t}setItems(t){let e=this.getActive(),i=fd(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=Ht(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(!Ht(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?wn(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=wn(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 Ht(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 md(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=Ht(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);ye(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=pd(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?b(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}=Ht(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:ye(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(ye(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&&wn(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(b(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=_d(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()},Yw))}_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 Ww(){Bl(),Oa(),Pa(),yl(),nl(),ml(),Gl(),Jl(),kl(),xl(),Ql(),Cl(),Tl(),$l(),jl()}Ww();export{Ii as AVATAR_TONES,Kr as AccountMenu,Fi as ActivityItem,$r as ActivityList,Fs as AppIcon,Gr as AppSidebar,Ar as Aurora,ue as Avatar,Hl as BADGE_TONES,Nr as Breadcrumb,Ws as CALENDAR_VIEWS,lo as Calendar,wr as Card,mo as CardView,Fo as Chart,Lo as ChartJsAdapter,Ut as CheckButton,lt as Checklist,Ye as CodeEditor,g as Component,Ri as ContextMenu,gr as CopyInput,Yo as DataFilter,ee as DatePicker,ei as DateRangeBox,ti as DateRangePicker,jn as DateTimeBox,it as Datebox,Wt as Dialog,Er as Dock,mt as Dropdown,Di as EntityRef,C as Field,ii as FieldUpload,Ve as Fieldset,Ni as FileItem,jr as FileList,ua as Filter,Jo as FilterPanel,Ho as Finder,fa as Form,Oo as Grid,ne as Groupbox,_s as Http,pr as InlineLoading,Mo as KanbanView,Rr as Launcher,ia as ListToolbar,Zl as MOTION_ATTRIBUTE,zr as MasterPanel,gt as MenuButton,Zr as Message,mi as Modal,Xe as MonthPicker,si as MultiValueEditor,Dr as NavigationBar,Dt as NumberField,Fr as Pagination,kr as Panel,xi as ProgressBar,pa as Questionnaire,ri as Rating,wt as RecordView,re as Search,K as Select,to as Sheet,eo as SheetStack,oi as Slider,ea as SortControl,Cr as SplitView,ks as StatTile,Mr as Stepper,bi as Tabbox,Ft as Table,_o as TableView,ai as TagPicker,Qe as TimePicker,Nt as Timebox,ot as Toggle,br as Toolbar,de as Tooltip,Vo as TreeView,ci as ValueList,Cd as __,Eo as absoluteKanbanIndex,R as addCalendarDays,io as addCalendarMonths,L as addDays,$t as addMonths,on as allowsKanbanTransition,Lg as appIcon,Id as appendCompact,Ed as appendCompactChild,Td as appendContent,wa as applyCompactProperties,Nm as aspect,Ps as avatarInitials,Ei as avatarTone,dt as badge,pp as badgeGroup,Lh as billingColumns,Zn as breakpointOf,ke as breakpoints,j as button,o_ as buttonGroup,zt as calendarDayDifference,X as calendarDayKey,Bi as calendarEventIntersects,Ct as calendarEventSpansDays,no as calendarPageDate,so as calendarRange,Bh as chartSummaryTable,H as clamp,Cn as clampDate,Ze as clampRange,Gt as clampSize,Q as cloneCalendarEvent,It as cloneChartValue,gn as cloneFilterAst,Ji as compactElement,rs as configureIcons,mr as copyButton,or as copyToClipboard,vo as createKanbanAvatars,So as createKanbanCardHead,To as createKanbanHistory,yh as createKanbanIndicator,wo as createKanbanProgress,yd as debounce,He as deepMerge,fl as defaultDateRangePresets,um as defineElements,Vb as describe,$p as downloadBlob,Ra as editorPosition,na as emptyFilterAst,Sm as emptyState,qe as escapeRegExp,ko as evaluateKanbanMove,Ka as faFamilies,ss as faIconClasses,Ua as faNames,In as faStyles,ra as filterCondition,aa as filterGroup,mn as filterOperators,Bd as fireCompactEvent,Hn as focusTrap,di as formatCurrency,D as formatDate,pi as formatFileSize,Ot as formatNumber,fi as formatPercent,_l as formatRangeText,Lp as formatRelativeTime,Dd as fragment,Ge as getIconConfig,ct as getLanguage,We as getWeekStart,Mm as grid,Du as groupActivityItems,xd as groupBy,l as h,Nd as highlightMatch,Md as htmlEscape,b as icon,Fn as iconNames,Nn as icons,La as indentSelection,be as isActiveValue,hn as isBillingLine,E as isElement,Po as isEmptyChartData,W as isSameDay,Lc as isTruncated,Ul as joinTime,wh as kanbanAvatarLimit,zo as kanbanSearchTerms,ns as kitUrl,Gs as layoutCalendarSpans,ro as layoutTimedCalendarEvents,ff as loadFontAwesome,Dn as loadFontAwesomeKit,an as locateKanbanRecord,tr as matchBreakpoint,Co as matchesKanbanSearch,sh as moveViewField,Cu as normalizeActivityAction,Rt as normalizeActivityItems,Tu as normalizeActivityTimestamp,fe as normalizeAppItems,Ne as normalizeCalendarEvents,Vr as normalizeEntityRef,js as normalizeEntityRefActions,Bs as normalizeEntityRefLink,Vs as normalizeEntityRefMetadata,he as normalizeFileItem,Hr as normalizeFileListItems,Ao as normalizeKanbanRules,Se as normalizeRange,ho as normalizeViewFields,rh as normalizeViewState,Pd as offCompactEvent,ui as onBreakpoint,Sa as onCompactEvent,cu as paginationRange,ya as parseCompactTag,tt as parseDate,Be as parseFilterAst,En as parseIconSpec,Ae as parseNumber,Vn as parseRangeText,ir as parseResult,rt as position,hi as prefersReducedMotion,I as printf,Gn as priorityIcon,zw as pruneValue,Je as rangeNights,dl as rangeStateOf,Pr as rankLauncherItems,J as readViewField,ji as reconcileFieldOrder,Ww as registerFieldAdapters,pf as registerIcons,Zs as renderViewField,Io as reorderKanbanRecords,zc as reorderTableRows,zu as resolveActivityActions,q as resolveElement,xo as resolveKanbanAssignees,bo as resolveKanbanIndicator,yo as resolveKanbanProgress,rn as resolveKanbanRules,bt as resolveSize,Mt as rovingTabindex,Zo as serializeFilterValue,pc as setButtonBusy,Hd as setLanguage,jd as setTranslator,Pi as shiftCalendarEvent,at as skeleton,Tm as skeletonTable,vi as skeletonText,ds as snapNumber,iu as snapSize,vd as sortBy,nh as sortViewRecords,gi as spinner,Kl as splitTime,Dm as stack,G as startOfCalendarDay,Ys as startOfCalendarWeek,rg as statTile,Wn as statusIcon,Vl as stepPrecision,_i as storage,Lw as stringifyFilterAst,wd as throttle,Xi as toArray,qp as toCsv,Bb as tooltip,St as translate,Rm as truncate,ht as typeahead,x as uid,Sd as uniqueBy,df as useBuiltinIcons,Xa as useFontAwesome,la as validateFilterAst,Oe as viewRecordId,er as watchMotion,Cp as zeyosService};
|
|
11
|
+
/*
|
|
12
|
+
* @license Lucide 1.53.0 (ISC), including icons derived from Feather (MIT) — notices below.
|
|
13
|
+
*
|
|
14
|
+
* The bundled glyphs are Lucide 1.53.0 (https://lucide.dev), outline icons drawn on a 24-unit grid.
|
|
15
|
+
* Each Lucide icon is stored as one path: its circles, rectangles, lines, and polylines are
|
|
16
|
+
* rewritten as equivalent path data, which renders identically because every part shares the same
|
|
17
|
+
* stroke. Where a Zx name differs from the Lucide one, the Lucide name is noted beside the glyph.
|
|
18
|
+
*
|
|
19
|
+
* ISC License
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) 2026 Lucide Icons and Contributors
|
|
22
|
+
*
|
|
23
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
24
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
25
|
+
* copyright notice and this permission notice appear in all copies.
|
|
26
|
+
*
|
|
27
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
28
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
29
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
30
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
31
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
32
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
33
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
34
|
+
*
|
|
35
|
+
* Lucide icons derived from the Feather project (Lucide's LICENSE lists them) are also covered by:
|
|
36
|
+
*
|
|
37
|
+
* The MIT License (MIT)
|
|
38
|
+
*
|
|
39
|
+
* Copyright (c) 2013-present Cole Bemis
|
|
40
|
+
*
|
|
41
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
42
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
43
|
+
* in the Software without restriction, including without limitation the rights
|
|
44
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
45
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
46
|
+
* furnished to do so, subject to the following conditions:
|
|
47
|
+
*
|
|
48
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
49
|
+
* copies or substantial portions of the Software.
|
|
50
|
+
*
|
|
51
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
52
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
53
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
54
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
55
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
56
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
57
|
+
* SOFTWARE.
|
|
58
|
+
*/
|