@zeyos/zx 3.0.0 → 4.1.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.
Files changed (106) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/DESIGN-SYSTEM.md +87 -71
  3. package/README.md +16 -37
  4. package/dist/types/components/app-icon/app-icon.d.ts +88 -0
  5. package/dist/types/components/app-sidebar/app-sidebar.d.ts +106 -32
  6. package/dist/types/components/card/card.d.ts +128 -0
  7. package/dist/types/components/chart/chart.d.ts +1 -0
  8. package/dist/types/components/filter/filter-model.d.ts +87 -0
  9. package/dist/types/components/filter/filter.d.ts +331 -0
  10. package/dist/types/components/launcher/launcher.d.ts +65 -6
  11. package/dist/types/components/select/select.d.ts +97 -4
  12. package/dist/types/components/table/table.d.ts +107 -3
  13. package/dist/types/components/tag-picker/tag-picker.d.ts +16 -0
  14. package/dist/types/core/dom.d.ts +9 -1
  15. package/dist/types/core/util.d.ts +9 -0
  16. package/dist/types/index.d.ts +6 -2
  17. package/dist/types/{components/app-rail → internal}/app-rail.d.ts +34 -19
  18. package/dist/types/zeyos/icons.d.ts +24 -2
  19. package/dist/types/zeyos/index.d.ts +3 -2
  20. package/dist/types/zeyos/launcher.d.ts +147 -0
  21. package/dist/types/zeyos/select.d.ts +41 -0
  22. package/dist/zx-zeyos.esm.js +2018 -113
  23. package/dist/zx-zeyos.esm.min.js +1 -1
  24. package/dist/zx.css +815 -16
  25. package/dist/zx.esm.js +2661 -338
  26. package/dist/zx.esm.min.js +3 -3
  27. package/dist/zx.global.js +2661 -338
  28. package/dist/zx.global.min.js +3 -3
  29. package/dist/zx.min.css +1 -1
  30. package/docs/api.json +602 -110
  31. package/docs/llms.md +181 -123
  32. package/docs/llms.txt +24 -21
  33. package/package.json +8 -17
  34. package/src/components/app-icon/app-icon.css +105 -0
  35. package/src/components/app-icon/app-icon.js +134 -0
  36. package/src/components/app-sidebar/app-sidebar.css +12 -0
  37. package/src/components/app-sidebar/app-sidebar.js +310 -110
  38. package/src/components/card/card.css +149 -0
  39. package/src/components/card/card.js +285 -0
  40. package/src/components/chart/chart.js +8 -3
  41. package/src/components/filter/filter-model.js +226 -0
  42. package/src/components/filter/filter.css +147 -0
  43. package/src/components/filter/filter.js +554 -0
  44. package/src/components/grid/grid.css +1 -1
  45. package/src/components/grid/grid.js +14 -4
  46. package/src/components/launcher/launcher.css +113 -3
  47. package/src/components/launcher/launcher.js +234 -26
  48. package/src/components/message/message.css +36 -3
  49. package/src/components/select/field-adapter.js +9 -4
  50. package/src/components/select/select.css +161 -10
  51. package/src/components/select/select.js +361 -48
  52. package/src/components/table/table.css +85 -0
  53. package/src/components/table/table.js +426 -31
  54. package/src/components/tag-picker/tag-picker.css +19 -0
  55. package/src/components/tag-picker/tag-picker.js +42 -5
  56. package/src/core/dom.js +21 -1
  57. package/src/core/util.js +20 -0
  58. package/src/index.js +9 -2
  59. package/src/{components/app-rail → internal}/app-rail.js +80 -30
  60. package/src/zeyos/icons.js +38 -20
  61. package/src/zeyos/index.js +8 -2
  62. package/src/zeyos/launcher.js +338 -0
  63. package/src/zeyos/modules.js +1 -0
  64. package/src/zeyos/select.js +116 -1
  65. package/styles/tokens/global.css +1 -1
  66. package/styles/tokens/modules.css +1 -0
  67. package/styles/tokens/semantic.css +9 -0
  68. package/styles/tokens/themes.css +2 -2
  69. package/styles/zx.css +3 -0
  70. package/MIGRATION.md +0 -749
  71. package/dist/types/compat/base.d.ts +0 -156
  72. package/dist/types/compat/globals.d.ts +0 -20
  73. package/dist/types/compat/index.d.ts +0 -128
  74. package/dist/types/compat/map/basic.d.ts +0 -175
  75. package/dist/types/compat/map/data.d.ts +0 -103
  76. package/dist/types/compat/map/date-time.d.ts +0 -80
  77. package/dist/types/compat/map/factory.d.ts +0 -9
  78. package/dist/types/compat/map/form.d.ts +0 -98
  79. package/dist/types/compat/map/helpers.d.ts +0 -12
  80. package/dist/types/compat/map/http.d.ts +0 -36
  81. package/dist/types/compat/map/layout.d.ts +0 -106
  82. package/dist/types/compat/map/options.d.ts +0 -80
  83. package/dist/types/compat/map/select.d.ts +0 -95
  84. package/dist/types/compat/map/stubs.d.ts +0 -32
  85. package/dist/types/compat/map/utilities.d.ts +0 -37
  86. package/dist/types/compat-entry.d.ts +0 -5
  87. package/dist/zx-compat.esm.js +0 -17848
  88. package/dist/zx-compat.esm.min.js +0 -1
  89. package/dist/zx-compat.global.js +0 -29008
  90. package/dist/zx-compat.global.min.js +0 -3
  91. package/src/compat/base.js +0 -291
  92. package/src/compat/globals.js +0 -167
  93. package/src/compat/index.js +0 -84
  94. package/src/compat/map/basic.js +0 -464
  95. package/src/compat/map/data.js +0 -254
  96. package/src/compat/map/date-time.js +0 -177
  97. package/src/compat/map/factory.js +0 -45
  98. package/src/compat/map/form.js +0 -330
  99. package/src/compat/map/helpers.js +0 -46
  100. package/src/compat/map/http.js +0 -117
  101. package/src/compat/map/layout.js +0 -256
  102. package/src/compat/map/options.js +0 -267
  103. package/src/compat/map/select.js +0 -198
  104. package/src/compat/map/stubs.js +0 -26
  105. package/src/compat/map/utilities.js +0 -113
  106. package/src/compat-entry.js +0 -11
@@ -1,3 +1,3 @@
1
- var zx=(()=>{var Js=Object.defineProperty;var xa=Object.getOwnPropertyDescriptor;var va=Object.getOwnPropertyNames;var wa=Object.prototype.hasOwnProperty;var Sa=(i,t)=>{for(var e in t)Js(i,e,{get:t[e],enumerable:!0})},Aa=(i,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of va(t))!wa.call(i,r)&&r!==e&&Js(i,r,{get:()=>t[r],enumerable:!(s=xa(t,r))||s.enumerable});return i};var ka=i=>Aa(Js({},"__esModule",{value:!0}),i);var rd={};Sa(rd,{AccountMenu:()=>Ds,AppRail:()=>ae,AppSidebar:()=>Ns,Avatar:()=>oe,Breadcrumb:()=>ks,Chart:()=>qs,ChartJsAdapter:()=>Hs,CheckButton:()=>lt,Checklist:()=>X,Component:()=>_,ContextMenu:()=>Ps,CopyInput:()=>us,DataFilter:()=>Us,DatePicker:()=>ft,DateRangeBox:()=>jt,DateRangePicker:()=>Vt,DateTimeBox:()=>We,Datebox:()=>B,Dialog:()=>ht,Dock:()=>xs,Dropdown:()=>W,Field:()=>S,FieldUpload:()=>$t,Fieldset:()=>It,Finder:()=>Ks,Form:()=>Ys,Grid:()=>Bs,Groupbox:()=>bt,Http:()=>we,InlineLoading:()=>ls,Launcher:()=>Es,MasterPanel:()=>_s,MenuButton:()=>G,Message:()=>Os,Modal:()=>Xt,MonthPicker:()=>Bt,MultiValueEditor:()=>Kt,NavigationBar:()=>vs,NumberField:()=>mt,Pagination:()=>Ts,Panel:()=>fs,ProgressBar:()=>ie,Questionnaire:()=>Qs,Rating:()=>Ut,Search:()=>Zt,Select:()=>$,Sheet:()=>Fs,SheetStack:()=>Ls,Slider:()=>Yt,SplitView:()=>ys,Stepper:()=>As,Tabbox:()=>te,Table:()=>yt,TagPicker:()=>Wt,TimePicker:()=>Pt,Timebox:()=>nt,Toggle:()=>K,Toolbar:()=>ps,Tooltip:()=>xt,TreeView:()=>$s,ValueList:()=>Gt,__:()=>br,addDays:()=>T,addMonths:()=>ot,appendCompact:()=>xr,appendCompactChild:()=>vr,appendContent:()=>yr,applyCompactProperties:()=>ti,aspect:()=>Ao,avatarInitials:()=>$i,badge:()=>_o,badgeGroup:()=>mo,billingColumns:()=>Ji,breakpointOf:()=>Qe,breakpoints:()=>zt,button:()=>q,buttonGroup:()=>fo,chartSummaryTable:()=>Zi,clamp:()=>N,clampDate:()=>Le,clampRange:()=>Ht,clampSize:()=>ut,cloneChartValue:()=>st,compactElement:()=>pe,configureIcons:()=>ge,copyButton:()=>cs,copyToClipboard:()=>ss,debounce:()=>dr,deepMerge:()=>Mt,defaultDateRangePresets:()=>bi,defineElements:()=>co,describe:()=>Go,downloadBlob:()=>Zn,emptyState:()=>go,escapeRegExp:()=>Ot,faFamilies:()=>li,faIconClasses:()=>_e,faNames:()=>hi,faStyles:()=>Re,fireCompactEvent:()=>Tr,focusTrap:()=>Ge,formatCurrency:()=>Ze,formatDate:()=>A,formatFileSize:()=>Yn,formatNumber:()=>gt,formatPercent:()=>ts,formatRangeText:()=>xi,formatRelativeTime:()=>Wn,fragment:()=>wr,getIconConfig:()=>He,getLanguage:()=>U,getWeekStart:()=>Lt,grid:()=>So,groupBy:()=>fr,h:()=>a,highlightMatch:()=>Ar,htmlEscape:()=>Sr,icon:()=>m,iconNames:()=>Zr,icons:()=>qe,isBillingLine:()=>Ee,isElement:()=>D,isEmptyChartData:()=>Vs,isSameDay:()=>F,isTruncated:()=>Fi,joinTime:()=>Ai,kitUrl:()=>me,loadFontAwesome:()=>Jr,loadFontAwesomeKit:()=>Be,matchBreakpoint:()=>Je,normalizeAppItems:()=>vt,normalizeRange:()=>At,offCompactEvent:()=>Cr,onBreakpoint:()=>Qt,onCompactEvent:()=>ei,paginationRange:()=>Hi,parseCompactTag:()=>Zs,parseDate:()=>P,parseIconSpec:()=>Pe,parseNumber:()=>be,parseRangeText:()=>Ye,parseResult:()=>Xe,position:()=>V,printf:()=>O,rangeNights:()=>qt,rangeStateOf:()=>gi,rankLauncherItems:()=>ji,registerFieldAdapters:()=>ya,registerIcons:()=>Xr,resolveElement:()=>R,resolveSize:()=>Q,rovingTabindex:()=>rt,setLanguage:()=>Nr,setTranslator:()=>Ir,skeleton:()=>hs,skeletonTable:()=>vo,skeletonText:()=>xo,snapNumber:()=>ye,snapSize:()=>Li,sortBy:()=>_r,spinner:()=>as,splitTime:()=>Si,stack:()=>wo,stepPrecision:()=>wi,storage:()=>Jt,throttle:()=>pr,toArray:()=>ce,toCsv:()=>Xn,tooltip:()=>Wo,translate:()=>J,truncate:()=>Co,typeahead:()=>Y,uid:()=>y,uniqueBy:()=>mr,useBuiltinIcons:()=>Qr,useFontAwesome:()=>di,zeyosService:()=>qn});function dr(i,t){let e=null;return function(...r){let n=this;e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,i.apply(n,r)},t)}}function pr(i,t,{leading:e=!0,trailing:s=!0}={}){let r=Math.max(0,Number(t)||0),n=null,o=0,l=null,h=null,c=()=>{n=null,o=e?Date.now():0;let u=l,d=h;l=null,h=null,u!==null&&i.apply(d,u)};return function(...d){let f=Date.now();o===0&&!e&&(o=f);let p=r-(f-o);if(p<=0||p>r){n!==null&&(clearTimeout(n),n=null),o=f,l=null,h=null,i.apply(this,d);return}s&&(l=d,h=this,n===null&&(n=setTimeout(c,p)))}}var hr=0;function y(i="zx"){return hr+=1,`${i}-${Date.now().toString(36)}-${hr.toString(36)}`}function Mt(i,t){let e=he(i)?gr(i):{};if(!he(t))return Me(t);for(let[s,r]of Object.entries(t))he(r)&&he(e[s])?e[s]=Mt(e[s],r):e[s]=Me(r);return e}function D(i){return!!(i&&typeof i=="object"&&i.nodeType===1)}function N(i,t,e){return Math.min(e,Math.max(t,i))}function ce(i){if(i==null)return[];if(Array.isArray(i))return i.slice();let t=i;return typeof i!="string"&&typeof t?.[Symbol.iterator]=="function"||typeof i!="string"&&typeof t?.length=="number"?Array.from(t):[i]}function fr(i,t){let e=Ne(t),s=new Map;for(let r of ce(i)){let n=String(e(r)),o=s.get(n);o===void 0?s.set(n,[r]):o.push(r)}return Object.fromEntries(s)}function _r(i,...t){let e=ce(i),s=t.map(za);return s.length===0?e:e.sort((r,n)=>{for(let o of s){let l=o(r,n);if(l!==0)return l}return 0})}function mr(i,t){let e=t==null?n=>n:Ne(t),s=new Set,r=[];for(let n of ce(i)){let o=e(n);s.has(o)||(s.add(o),r.push(n))}return r}function Ot(i){return String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ne(i){if(typeof i=="function")return i;let t=String(i);return e=>e?.[t]}function za(i){let t,e=1;if(typeof i=="function")t=i;else if(i!==null&&typeof i=="object")t=Ne(i.key),String(i.dir).toLowerCase()==="desc"&&(e=-1);else{let s=String(i);s.startsWith("-")?(e=-1,s=s.slice(1)):s.startsWith("+")&&(s=s.slice(1)),t=Ne(s)}return(s,r)=>{let n=t(s),o=t(r),l=cr(n),h=cr(o);return l||h?l&&h?0:l?1:-1:e*Ca(n,o)}}function cr(i){return i==null||typeof i=="number"&&Number.isNaN(i)}function Ca(i,t){return i instanceof Date||t instanceof Date?Xs(ur(i)-ur(t)):typeof i=="boolean"||typeof t=="boolean"?Xs(Number(i)-Number(t)):typeof i=="number"&&typeof t=="number"?Xs(i-t):String(i).localeCompare(String(t),void 0,{numeric:!0})}function ur(i){if(i instanceof Date)return i.getTime();let t=Number(i);return Number.isFinite(t)?t:0}function Xs(i){return Number.isNaN(i)?0:i<0?-1:i>0?1:0}function he(i){if(i===null||typeof i!="object")return!1;let t=Object.getPrototypeOf(i);return t===Object.prototype||t===null}function gr(i){let t={};for(let[e,s]of Object.entries(i))t[e]=Me(s);return t}function Me(i){return he(i)?gr(i):Array.isArray(i)?i.map(Me):i}var ue=null,Ta=new Set(["href","id","lang","name","rel","src","target","title","value"]),de=new WeakMap;function Zs(i){if(typeof i!="string")throw new TypeError("DOM builder tag must be a string");let t=i,e="",s="",r=t.indexOf(".");return r!==-1&&(e=t.slice(r+1),t=t.slice(0,r)),r=t.indexOf("#"),r!==-1&&(s=t.slice(r+1),t=t.slice(0,r)),{tag:t||"div",id:s,className:e}}function pe(i,t=null,e=null){let s=Zs(i),r=document.createElement(s.tag);if(s.id&&(r.id=s.id),s.className&&(r.className=s.className),s.tag==="a"){let n=r;n.rel="noopener",n.tabIndex=-1}else if(s.tag==="button")r.type="button";else if(s.tag==="input"||s.tag==="textarea"){let n=r;n.autocapitalize="none",n.autocomplete="off",n.autocorrect="off",n.spellcheck=!1}return t&&ti(r,t),Na(r,e),r}var br=pe;function ti(i,t){for(let e in t??{}){let s=t[e];if(s!=null)if(e[0]==="D")i.setAttribute(`data-${e.slice(1)}`,String(s));else if(e[0]==="S")i.style[e.slice(1)]=s;else if(e.startsWith("on")){if(typeof s!="function")throw new TypeError(`Compact DOM event ${e} must be a function`);ei(i,e.slice(2),s)}else typeof s=="boolean"||Ta.has(e)?i[e]=s:i.setAttribute(e,String(s))}return i}function yr(i,t){if(t==null)return i;let e=zr(t);return e==null||(typeof e=="object"?i.appendChild(e):i.appendChild(document.createTextNode(String(e)))),i}function xr(i,t,e=null,s=null){return i.appendChild(pe(t,e,s)),i}function vr(i,t,e=null,s=null){let r=pe(t,e,s);return i.appendChild(r),r}function wr(...i){let t=document.createDocumentFragment();return kr(t,i),t}function a(i,t,...e){let s=document.createElement(i),r=t;Ea(r)||(e.unshift(r),r={});for(let[n,o]of Object.entries(r))Da(s,n,o);return kr(s,e),s}a.scope=function(t,e){let s=ue;ue=t;try{return e()}finally{ue=s}};a.raw=function(t){let e=document.createElement("template");return e.innerHTML=String(t),e.content};function k(i){return{children:Array.from(i.childNodes),attributes:Array.from(i.attributes,t=>[t.name,t.value])}}function z(i,t){if(t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}}function Sr(i){return String(i).replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function Ar(i,t,e={}){let{className:s="zx-mark"}=e,r=i==null?"":String(i),n=t==null?"":String(t).trim(),o=document.createDocumentFragment();if(n===""||r==="")return o.append(document.createTextNode(r)),o;let l=new RegExp(Ot(n),"gi"),h=0;for(let c of r.matchAll(l)){c.index>h&&o.append(document.createTextNode(r.slice(h,c.index)));let u=document.createElement("mark");s&&(u.className=String(s)),u.append(document.createTextNode(c[0])),o.append(u),h=c.index+c[0].length}return h<r.length&&o.append(document.createTextNode(r.slice(h))),o}function R(i){if(i==null)return null;if(D(i))return i;if(typeof i=="string")return document.querySelector(i);if(typeof i.toElement=="function"){let t=i.toElement();return D(t)?t:null}return null}function Ea(i){if(i===null||typeof i!="object"||Array.isArray(i))return!1;let t=i;return typeof t.nodeType=="number"?!1:typeof t.toElement!="function"}function Da(i,t,e){if(t==="ref"){ue&&typeof e=="string"&&(ue[e]=i);return}if(t==="class"){i.className=Array.isArray(e)?e.flat(1/0).filter(Boolean).join(" "):String(e??"");return}if(t==="style"){if(typeof e=="string")i.style.cssText=e;else if(e&&typeof e=="object")for(let[r,n]of Object.entries(e))r.startsWith("--")||r.includes("-")?i.style.setProperty(r,String(n)):i.style[r]=n;return}if(t==="dataset"&&e&&typeof e=="object"){for(let[r,n]of Object.entries(e))n==null?delete i.dataset[r]:i.dataset[r]=String(n);return}if(/^on[a-z]/.test(t)&&typeof e=="function"){i.addEventListener(t.slice(2),e);return}if(e==null)return;let s=Ia(t);if(s!==null)i.setAttribute(s,String(e));else if(t in i)try{i[t]=e}catch{i.setAttribute(t,String(e))}else typeof e=="boolean"?e?i.setAttribute(t,""):i.removeAttribute(t):i.setAttribute(t,String(e))}function Ia(i){return i.startsWith("aria-")?i:/^aria[A-Z]/.test(i)?"aria-"+i.slice(4).toLowerCase():null}function kr(i,t){let e=i;for(let s of t.flat(1/0)){if(s==null)continue;if(typeof s=="string"||typeof s=="number"){e.append(document.createTextNode(String(s)));continue}if(typeof s!="object")continue;let r=s;if(typeof r.nodeType=="number")e.append(s);else if(typeof r.toElement=="function"){let n=r.toElement();n&&e.append(n)}}}function Na(i,t){if(t==null)return;let e=zr(t);e!=null&&(typeof e=="object"?i.appendChild(e):i.textContent=String(e))}function zr(i){if(i&&typeof i=="object"){if(typeof i.nodeType=="number")return i;if(typeof i.toElement=="function")return i.toElement()}return i}function ei(i,t,e,s=!1){if(typeof e!="function")throw new TypeError("Compact DOM event handler must be a function");let r=String(t),n=de.get(i);n||(n=new Map,de.set(i,n));let o=n.get(r);if(o)return o.handlers.push(e),i;let l=[e],h=c=>Er(i,l,c);n.set(r,{handlers:l,listener:h});try{i.addEventListener(r,h,{passive:s})}catch{i.addEventListener(r,h)}return i}function Cr(i,t,e){let s=String(t),r=de.get(i),n=r?.get(s);if(!n)return i;let o=n.handlers.indexOf(e);return o===-1||(n.handlers.splice(o,1),n.handlers.length===0&&(i.removeEventListener(s,n.listener),r.delete(s),r.size===0&&de.delete(i))),i}function Tr(i,t,e=null){let s=String(t),r=de.get(i);if(!r?.has(s))return i;let n=e??Ma(i,s),o=r.get(String(n.type));return o&&Er(i,o.handlers,n),i}function Er(i,t,e){let s=e,r=String(s.type).startsWith("key")?s.which:s.target;for(let n=t.length-1;n>=0;n-=1)t[n].call(i,e,r)===!1&&s.preventDefault()}function Ma(i,t){let e={target:i,type:t,which:-1,defaultPrevented:!1,preventDefault(){e.defaultPrevented=!0}};return e}var si=null,Dr="en";function Ir(i){if(i!==null&&typeof i!="function")throw new TypeError("Translator must be a function or null");si=i}function Nr(i){Dr=String(i||"en")}function U(){return Dr}function J(i,t){let e=si?si(i):i;return O(e==null?i:String(e),t)}function O(i,t){if(t==null)return String(i);let e=Array.isArray(t)?t:typeof t=="object"?null:[t],s=String(i).replace(/%(\d+)/g,(n,o)=>{let l=Number(o)-1,h;return e?h=e[l]:Object.prototype.hasOwnProperty.call(t,o)&&(h=t[o]),h==null?n:String(h)}),r=0;return s=s.replace(/%([A-Za-z_][\w.-]*)%/g,(n,o)=>{if(!e&&Object.prototype.hasOwnProperty.call(t,o)){let l=t[o];return l==null?n:String(l)}if(e&&r<e.length){let l=e[r];return r+=1,l==null?n:String(l)}return n}),s}var Oe=new WeakMap,_=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#t=new AbortController;#e=!1;#s=!1;#i=!1;constructor(t,e={}){super();let s=this.constructor;this.#e=t===null;let r=R(t);if(t!==null&&!r)throw new TypeError("Component target could not be resolved");this.el=r,this.refs={};let n=Oa(s,e),o=[];for(let[c,u]of Object.entries(n))/^on[a-z]/.test(c)&&typeof u=="function"&&(o.push([c.slice(2),u]),delete n[c]);n.msg&&typeof n.msg=="object"&&Object.freeze(n.msg),this.options=Object.freeze(n);for(let[c,u]of o)this.on(c,u);let l;try{l=a.scope(this.refs,()=>this.render())}catch(c){throw this.#t.abort(),c}if(this.#e){let c=D(l)?l:this.el;if(!D(c))throw this.#t.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=c}if(!D(this.el))throw this.#t.abort(),new TypeError("Component requires a root Element");let h=s.cssName;if(typeof h=="string"&&h){let c=`zx-${h}`;this.#i=!this.el.classList.contains(c),this.el.classList.add(c)}Oe.set(this.el,this)}render(){return this.el??null}on(t,e){return this.addEventListener(t,e,{signal:this.#t.signal}),this}off(t,e){return this.removeEventListener(t,e),this}once(t,e){return this.addEventListener(t,e,{once:!0,signal:this.#t.signal}),this}addEvent(t,e){return this.on(t,e)}emit(t,e={}){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("Event detail must be an object");let s=Mr(t,e,{cancelable:!0});return this.dispatchEvent(s),this.el&&this.el.dispatchEvent(Mr(`zx-${t}`,e,{bubbles:!0,composed:!0,cancelable:!0})),s}listen(t,e,s,r={}){let n=typeof r=="boolean"?{capture:r}:{...r};return t.addEventListener(e,s,{...n,signal:this.#t.signal}),this}toElement(){return this.el}msg(t,...e){let s=this.options.msg,r=this.options.lang??this.options.language??U(),n=s?.[r]?.[t];if(n!=null)return O(String(n),e);let o=s?.[t];return o!=null?O(String(o),e):J(t,e)}destroy(){if(this.#s)return;this.#s=!0,this.#t.abort(),Oe.get(this.el)===this&&Oe.delete(this.el);let t=this.constructor.cssName;this.#i&&typeof t=="string"&&this.el&&this.el.classList.remove(`zx-${t}`),this.#e&&this.el&&this.el.remove()}static from(t){return Oe.get(t)??null}};function Oa(i,t){let e=[],s=i;for(;s&&s!==Function.prototype;)Object.prototype.hasOwnProperty.call(s,"defaults")&&e.unshift(s.defaults),s=Object.getPrototypeOf(s);let r={},n={},o=!1;for(let l of e)!l||typeof l!="object"||(Object.assign(r,l),l.msg&&typeof l.msg=="object"&&(o=!0,n=Mt(n,l.msg)));return Object.assign(r,t&&typeof t=="object"?t:{}),t?.msg&&typeof t.msg=="object"&&(o=!0,n=Mt(n,t.msg)),o&&(r.msg=n),r}function Mr(i,t,e){if(typeof CustomEvent=="function")return new CustomEvent(i,{...e,detail:t});let s=new Event(i,e);return Object.defineProperty(s,"detail",{configurable:!0,enumerable:!0,value:t}),s}var S=class i extends _{static cssName="field";static defaults={id:null,type:"text",label:"",description:"",value:void 0,placeholder:"",required:!1,disabled:!1,options:null,layout:"stack",props:{},msg:{"field.int":"Enter a whole number.","field.float":"Enter a valid number.","field.unknown":"Unknown field type: %1"}};static#t=new Map;static register(t,e){let s=String(t).trim().toLowerCase();if(!s)throw new TypeError("Field adapter type must not be empty");if(typeof e!="function")throw new TypeError("Field adapter must be a function");return i.#t.set(s,e),this}static has(t){return i.#t.has(String(t).trim().toLowerCase())}render(){let t=this.el??a("div");this.el=t;let e=String(this.options.type||"text").toLowerCase(),s=this.options.layout==="inline"?"inline":"stack";this._ownedComponents=new Set,this._ownedNodes=[],this._rootAttributes=Pa(t,["data-layout","data-field-type","data-disabled","data-state"]),t.dataset.layout=s,t.dataset.fieldType=e,this.controlId=this.options.id?String(this.options.id):y("zx-field");let r=`${this.controlId}-label`,n=`${this.controlId}-description`,o=`${this.controlId}-highlight`,l=a("label",{class:"zx-field__label",id:r,htmlFor:this.controlId},String(this.options.label??""),this.options.required?a("span",{class:"zx-field__required",ariaHidden:"true"}," *"):null),h=a("div",{class:"zx-field__control"}),c=a("div",{class:"zx-field__description",id:n},String(this.options.description??"")),u=a("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),d=a("div",{class:"zx-field__body"},h,c,u);this._ownedNodes.push(l,d),t.append(l,d);let f=i.#t.get(e);if(f)try{this.adapter=La(f(this,this.options))}catch(g){let x=g instanceof Error?g.message:String(g);console.warn(`[zx.Field] Adapter "${e}" failed: ${x}`),this.adapter=Fr(x,this.controlId)}else{let g=this.msg("field.unknown",e);console.warn(`[zx.Field] ${g}`),this.adapter=Fr(g,this.controlId)}let p=this.adapter.el;return p.id||(p.id=this.controlId),l.htmlFor=p.id,Ra(p)||p.setAttribute("aria-labelledby",r),this._baseDescribedBy=p.getAttribute("aria-describedby")??"",h.append(p),this._descriptionId=String(this.options.description??"")?n:"",this._highlightId=o,this._highlight=u,this._syncDescription(),this.initialValue=Fa(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 s=["danger","warning","success"].includes(e)?e:"danger";return this.el.dataset.state=s,this._highlight.textContent=String(t??""),this._highlight.hidden=!t,s==="danger"&&t?(this._highlight.setAttribute("role","alert"),this.adapter.el.setAttribute("aria-invalid","true"),this.emit("invalid",{message:String(t)})):(this._highlight.removeAttribute("role"),this.adapter.el.removeAttribute("aria-invalid")),this._syncDescription(!!t),this}clearHighlight(){return delete this.el.dataset.state,this._highlight.textContent="",this._highlight.hidden=!0,this._highlight.removeAttribute("role"),this.adapter.el.removeAttribute("aria-invalid"),this._syncDescription(!1),this}getInput(){return this.adapter.el}own(t){if(!(t instanceof _))throw new TypeError("Field.own() requires a Component");return this._ownedComponents.add(t),t}_syncDescription(t=!1){let e=[this._baseDescribedBy,this._descriptionId,t?this._highlightId:""].flatMap(s=>s.split(/\s+/)).filter(Boolean);e.length?this.adapter.el.setAttribute("aria-describedby",[...new Set(e)].join(" ")):this.adapter.el.removeAttribute("aria-describedby")}destroy(){this.adapter?.destroy?.();for(let t of this._ownedComponents??[])t.destroy();this._ownedComponents?.clear();for(let t of this._ownedNodes??[])t.remove();Ba(this.el,this._rootAttributes??new Map),super.destroy()}};function ii(i){if(typeof i=="number")return Number.isInteger(i)?{valid:!0,value:i}:{valid:!1,value:String(i)};let t=String(i??"").trim();if(t==="")return{valid:!0,value:""};let e=Rr(t);return e!==null&&Number.isInteger(e)?{valid:!0,value:e}:{valid:!1,value:t}}function ri(i){if(typeof i=="number")return Number.isFinite(i)?{valid:!0,value:i}:{valid:!1,value:String(i)};let t=String(i??"").trim();if(t==="")return{valid:!0,value:""};let e=Rr(t);return e!==null?{valid:!0,value:e}:{valid:!1,value:t}}function Rr(i){let t=i.replace(/[\s\u00a0]/g,"");if(!/^[+-]?[\d.,]+$/.test(t))return null;let e=/^[+-]/.test(t)?t[0]:"",s=e?t.slice(1):t;if(!/\d/.test(s))return null;let r=[...s.matchAll(/\./g)].map(h=>h.index),n=[...s.matchAll(/,/g)].map(h=>h.index),o;if(r.length&&n.length){let h=r.at(-1)>n.at(-1)?".":",",c=h==="."?",":".",u=s.lastIndexOf(h),d=s.slice(0,u),f=s.slice(u+1);if(!/^\d+$/.test(f)||!Or(d,c))return null;o=d.split(c).join("")+"."+f}else if(n.length>1||r.length>1){let h=n.length?",":".";if(!Or(s,h))return null;o=s.split(h).join("")}else n.length===1?o=s.replace(",","."):o=s;if(!/^(?:\d+(?:\.\d+)?|\.\d+)$/.test(o))return null;let l=Number(e+o);return Number.isFinite(l)?l:null}function Or(i,t){let e=i.split(t);return e.length>0&&/^\d{1,3}$/.test(e[0])&&e.slice(1).every(s=>/^\d{3}$/.test(s))}function Fa(i,t){return t!==void 0?t:i==="checkbox"?!1:""}function La(i){if(!i||typeof i!="object")throw new TypeError("Adapter must return an object");if(!(i.el&&i.el.nodeType===1))throw new TypeError("Adapter must provide an Element");for(let t of["get","set","focus","setDisabled"])if(typeof i[t]!="function")throw new TypeError(`Adapter is missing ${t}()`);return i}function Fr(i,t){let e=a("div",{class:"zx-field__error-control",id:t,role:"alert",tabIndex:-1},i);return{el:e,get:()=>null,set:()=>{},focus:()=>e.focus(),setDisabled:()=>{}}}function Ra(i){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(i.tagName)}function Pa(i,t){return new Map(t.map(e=>[e,i.getAttribute(e)]))}function Ba(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}function fe(i,t){let e={...i.props??{}};for(let s of Object.keys(e))(/^on[a-z]/i.test(s)||s==="content")&&delete e[s];return{...e,...t}}function Fe(i,t){return(e,s)=>{let r=a(i,fe(s,{type:i==="input"?t:void 0,placeholder:s.placeholder,required:s.required,disabled:s.disabled}));return ni(r)}}function ni(i){return{el:i,get:()=>i.value,set:t=>{i.value=t==null?"":String(t)},focus:()=>i.focus(),setDisabled:t=>{i.disabled=t}}}function Pr(i){return(t,e)=>{let s=i==="int"?ii:ri,r=a("input",fe(e,{type:"text",inputMode:i==="int"?"numeric":"decimal",placeholder:e.placeholder,required:e.required,disabled:e.disabled}));return t.listen(r,"blur",()=>{let n=s(r.value);if(!n.valid){t.setHighlight(t.msg(`field.${i}`),"danger");return}n.value!==""&&(r.value=String(n.value)),t.clearHighlight()}),{...ni(r),get:()=>s(r.value).value}}}var qa=(i,t)=>{let e=a("input",fe(t,{type:"checkbox",required:t.required,disabled:t.disabled}));return{el:e,get:()=>e.checked,set:s=>{e.checked=!!s},focus:()=>e.focus(),setDisabled:s=>{e.disabled=s}}},Ha=(i,t)=>{let e=a("select",fe(t,{required:t.required,disabled:t.disabled}));for(let[s,r]of Br(t.options))e.append(a("option",{value:s},r));return ni(e)},Va=(i,t)=>{let e=a("div",{class:"zx-field__option-list",role:"radiogroup"}),s=t.id?String(t.id):y("zx-option-list"),r=Br(t.options).map(([n,o],l)=>{let h=a("input",{type:"radio",name:s,value:n,required:!!t.required&&l===0,disabled:t.disabled});return e.append(a("label",{class:"zx-field__option"},h,a("span",{},o))),h});return{el:e,get:()=>r.find(n=>n.checked)?.value??"",set:n=>{for(let o of r)o.checked=String(n??"")===o.value},focus:()=>(r.find(n=>n.checked)??r[0])?.focus(),setDisabled:n=>{for(let o of r)o.disabled=n;e.setAttribute("aria-disabled",String(n))}}},ja=(i,t)=>{let e=a("div",fe(t,{class:"zx-field__static"})),s=null;return{el:e,get:()=>e.textContent,set:n=>{Lr(s),s=null,n&&typeof n=="object"&&typeof n.nodeType=="number"?(s={node:n,parent:n.parentNode,next:n.nextSibling},e.replaceChildren(n)):e.textContent=n==null?"":String(n)},focus:()=>{},setDisabled:n=>{e.setAttribute("aria-disabled",String(n))},destroy:()=>Lr(s)}};function Lr(i){i&&(i.parent?i.parent.insertBefore(i.node,i.next?.parentNode===i.parent?i.next:null):i.node.remove())}var $a=(i,t)=>{if(typeof t.adapter!="function")throw new TypeError("Custom fields require options.adapter");return t.adapter(i,t)};function Br(i){return Array.isArray(i)?i.map(t=>[String(t),String(t)]):i&&typeof i=="object"?Object.entries(i).map(([t,e])=>[t,String(e)]):[]}S.register("text",Fe("input","text"));S.register("password",Fe("input","password"));S.register("textarea",Fe("textarea","text"));S.register("checkbox",qa);S.register("int",Pr("int"));S.register("float",Pr("float"));S.register("select",Ha);S.register("optionlist",Va);S.register("hidden",Fe("input","hidden"));S.register("html",ja);S.register("custom",$a);function pt(i,t,e){let s=qr(t).split(/\s+/).filter(Boolean);return s.length===0?i.slice():i.filter(r=>{let n=Ka(r,e).map(qr);return s.every(o=>n.some(l=>l.includes(o)))})}function Ka(i,t){return i===null||typeof i!="object"?[i]:!Array.isArray(t)||t.length===0?[i]:t.map(e=>typeof e=="function"?e(i):i[e])}function qr(i){return String(i??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var X=class extends _{static cssName="checklist";static defaults={items:[],valueKey:"ID",labelKey:"name",checkedKey:"on",search:!0,height:280,defaultChecked:!1,load:null};render(){this._items=[],this._visibleItems=[],this._checked=new Set,this._query="",this._loadSequence=0,this._createdRoot=!1,this._active=!0,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let t=this.el??a("div");this.el=t,this._createdRoot||(this._originalChildren=Array.from(t.childNodes));for(let o of["role","aria-labelledby","data-state"])this._originalAttributes.set(o,t.getAttribute(o));let e=y("zx-checklist-label"),s=a("div",{class:"zx-checklist__label",id:e},this._message("checklist.label","Checklist")),r=a("input",{ref:"search",class:"zx-checklist__search",type:"search",autocomplete:"off",placeholder:this._message("checklist.search","Search"),ariaLabel:this._message("checklist.search","Search checklist"),hidden:!this.options.search}),n=a("div",{ref:"list",class:"zx-checklist__list"});return n.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,t.replaceChildren(s,r,n),t.setAttribute("role","group"),t.setAttribute("aria-labelledby",e),this.listen(r,"input",()=>this.search(r.value)),this.listen(n,"change",o=>{let l=o.target;if(!l?.matches?.('input[type="checkbox"][data-index]'))return;let h=this._visibleItems[Number(l.dataset.index)];if(h===void 0)return;let c=this._itemValue(h);l.checked?this._checked.add(c):this._checked.delete(c),this.emit("change",{values:this.getValues()})}),this._replaceItems(this.options.items),typeof this.options.load=="function"&&queueMicrotask(()=>{this._active&&this.reload().catch(()=>{})}),t}setItems(t){return this._replaceItems(t),this}getValues(){return this._items.map(t=>this._itemValue(t)).filter(t=>this._checked.has(t))}setValues(t){let e=new Set(t==null?[]:Array.from(t)),s=new Set(this._items.map(r=>this._itemValue(r)).filter(r=>e.has(r)));return this._replaceChecked(s),this}checkAll(){return this._replaceChecked(new Set(this._items.map(t=>this._itemValue(t)))),this}uncheckAll(){return this._replaceChecked(new Set),this}search(t){this._query=String(t??"");let e=this.refs.search;return e.value!==this._query&&(e.value=this._query),this._visibleItems=pt(this._items,this._query,[this.options.labelKey]),this._renderItems(),this}async reload(){if(!this._active||typeof this.options.load!="function")return this;let t=++this._loadSequence;this.el.setAttribute("data-state","loading"),this.refs.list.setAttribute("aria-busy","true");try{let e=await this.options.load();if(t!==this._loadSequence)return this;this._replaceItems(e),this.emit("loaded",{items:this._items.slice()})}finally{t===this._loadSequence&&(this.el.removeAttribute("data-state"),this.refs.list.setAttribute("aria-busy","false"))}return this}destroy(){this._active=!1,this._loadSequence+=1;let t=this.el;if(!this._createdRoot&&t){t.replaceChildren(...this._originalChildren);for(let[e,s]of this._originalAttributes)s===null?t.removeAttribute(e):t.setAttribute(e,s)}super.destroy()}_replaceItems(t){this._items=Array.isArray(t)?t.slice():[],this._checked=new Set(this._items.filter(e=>!!this._initialChecked(e)).map(e=>this._itemValue(e))),this._visibleItems=pt(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let t=this._visibleItems.map((e,s)=>{let r=y("zx-checklist-item"),n=a("input",{type:"checkbox",id:r,checked:this._checked.has(this._itemValue(e)),dataset:{index:s}});return a("label",{class:"zx-checklist__item",for:r},n,a("span",{},this._itemLabel(e)))});t.length===0&&t.push(a("div",{class:"zx-checklist__empty",role:"status"},this._message("checklist.empty","No matches"))),this.refs.list.replaceChildren(...t)}_replaceChecked(t){Ua(this._checked,t)||(this._checked=t,this._renderItems(),this.emit("change",{values:this.getValues()}))}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){return String(this._read(t,this.options.labelKey)??"")}_initialChecked(t){let e;return typeof this.options.checkedKey=="function"?e=this.options.checkedKey(t):t!==null&&typeof t=="object"&&(e=t[this.options.checkedKey]),e??this.options.defaultChecked}_read(t,e){return typeof e=="function"?e(t):t===null||typeof t!="object"?t:t[e]}_message(t,e){let s=this.msg(t);return s===t?e:s}};function Ua(i,t){return i.size===t.size&&Array.from(i).every(e=>t.has(e))}function Hr(){S.register("checklist",(i,t)=>{let e=i.own(new X(null,{...t.props??{}})),s=!1,r=!1,n=()=>{e.el.setAttribute("aria-disabled",String(s));for(let o of e.el.querySelectorAll("input, button, select, textarea"))o.disabled=s};return i.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>{r||i.emit("change",{value:o.detail.values})}),e.on("loaded",n),{el:e.el,get:()=>e.getValues(),set:o=>{r=!0;try{e.setValues(Array.isArray(o)?o:[])}finally{r=!1}n()},focus:()=>{(e.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])")??e.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus()},setDisabled:o=>{s=!!o,n()}}})}var Vr=["January","February","March","April","May","June","July","August","September","October","November","December"],jr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ur=/%[demYyHMSaAbBs]/g;function A(i,t){return!(i instanceof Date)||Number.isNaN(i.getTime())?"":String(t).replace(Ur,e=>{switch(e){case"%d":return Ft(i.getDate());case"%e":return String(i.getDate());case"%m":return Ft(i.getMonth()+1);case"%Y":return String(i.getFullYear()).padStart(4,"0");case"%y":return Ft(i.getFullYear()%100);case"%H":return Ft(i.getHours());case"%M":return Ft(i.getMinutes());case"%S":return Ft(i.getSeconds());case"%a":return $r("weekday",i.getDay(),jr[i.getDay()]);case"%A":return oi("weekday",i.getDay(),jr[i.getDay()]);case"%b":return $r("month",i.getMonth(),Vr[i.getMonth()]);case"%B":return oi("month",i.getMonth(),Vr[i.getMonth()]);case"%s":return String(Math.floor(i.getTime()/1e3));default:return e}})}function P(i,t){let e=[],s="^",r=0;for(let g of String(t).matchAll(Ur)){s+=Kr(String(t).slice(r,g.index));let x=g[0],v=Ya(x);if(v===null)return null;s+=`(${v})`,e.push(x),r=g.index+x.length}s+=Kr(String(t).slice(r))+"$";let n=new RegExp(s).exec(String(i));if(!n)return null;let o=Object.create(null);if(e.forEach((g,x)=>{o[g]=Number(n[x+1])}),o["%s"]!==void 0){let g=o["%s"]*1e3,x=new Date(g);return Number.isNaN(x.getTime())?null:x}let l=o["%Y"]??Wa(o["%y"])??1970,h=(o["%m"]??1)-1,c=o["%d"]??o["%e"]??1,u=o["%H"]??0,d=o["%M"]??0,f=o["%S"]??0,p=new Date(0);return p.setHours(0,0,0,0),p.setFullYear(l,h,c),p.setHours(u,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()!==h||o["%d"]!==void 0&&p.getDate()!==c||o["%e"]!==void 0&&p.getDate()!==c||o["%H"]!==void 0&&p.getHours()!==u||o["%M"]!==void 0&&p.getMinutes()!==d||o["%S"]!==void 0&&p.getSeconds()!==f?null:p}function Le(i,t,e){let s=i.getTime(),r=t instanceof Date?t.getTime():-1/0,n=e instanceof Date?e.getTime():1/0;return new Date(Math.min(n,Math.max(r,s)))}function F(i,t){return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()&&i.getDate()===t.getDate()}function T(i,t){let e=new Date(i.getTime());return e.setDate(e.getDate()+t),e}function ot(i,t){let e=new Date(i.getTime()),s=e.getDate();e.setDate(1),e.setMonth(e.getMonth()+t);let r=new Date(e.getFullYear(),e.getMonth()+1,0).getDate();return e.setDate(Math.min(s,r)),e}function Lt(i=U()){if(!i||i.toLowerCase()==="en")return 1;try{let t=new Intl.Locale(i),e=t.getWeekInfo?.()??t.weekInfo;if(e?.firstDay)return e.firstDay%7}catch{}return 1}function Ft(i){return String(i).padStart(2,"0")}function oi(i,t,e){let s=`date.${i}.${t}`,r=J(s);return r===s?e:r}function $r(i,t,e){let s=`date.${i}.short.${t}`,r=J(s);return r!==s?r:oi(i,t,e).slice(0,3)}function Ya(i){return{"%d":"\\d{1,2}","%e":"\\d{1,2}","%m":"\\d{1,2}","%Y":"\\d{4}","%y":"\\d{2}","%H":"\\d{1,2}","%M":"\\d{1,2}","%S":"\\d{1,2}","%s":"-?\\d+"}[i]??null}function Wa(i){if(i!==void 0)return i>=69?1900+i:2e3+i}function Kr(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Re=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),li=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),Yr=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"}),hi=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"}),ai=new Map;function Pe(i){let t=String(i).trim();if(/\s/.test(t)||t.startsWith("fa-"))return{provider:"fa",name:"",style:null,classes:t.split(/\s+/).filter(Boolean)};let e=t.indexOf(":");if(e>0){let s=t.slice(0,e).toLowerCase(),r=t.slice(e+1);if(s==="builtin"||s==="zx")return{provider:"builtin",name:r,style:null,classes:null};if(Object.hasOwn(Yr,s))return{provider:"fa",name:r,style:Yr[s],classes:null}}return{provider:null,name:t,style:null,classes:null}}function _e(i,t={}){let{style:e="solid",family:s="classic",fixedWidth:r=!1,translate:n=!0}=t,o=String(i).replace(/^fa-/,""),l=n?hi[o]??o:o,h=[],c=li[s];return c&&h.push(c),h.push(Re[e]??Re.solid,`fa-${l}`),r&&h.push("fa-fw"),h}function me(i){let t=String(i).trim();if(/^(https?:)?\/\//.test(t)||t.startsWith("/")||t.endsWith(".js"))return t;if(!/^[a-z0-9]+$/.test(t))throw new RangeError(`Invalid Font Awesome kit token: ${i}`);return`https://kit.fontawesome.com/${t}.js`}function Be(i){let t=me(i),e=ai.get(t);if(e)return e;let s=new Promise((r,n)=>{let o=new URL(t,document.baseURI).href,l=[...document.scripts].find(c=>c.src===o);if(l&&globalThis.FontAwesomeKitConfig){r();return}let h=l??document.createElement("script");h.addEventListener("load",()=>r(),{once:!0}),h.addEventListener("error",()=>{ai.delete(t),n(new Error(`Font Awesome kit failed to load: ${t}`))},{once:!0}),!l&&(h.src=t,h.async=!0,h.crossOrigin="anonymous",document.head.append(h))});return ai.set(t,s),s}var Wr="http://www.w3.org/2000/svg",qe=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"]}),Ga=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list"}),ui=Object.create(null),at={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function He(){return{...at}}function ge(i={}){for(let t of["provider","style","family","fixedWidth","kit"])i[t]!==void 0&&(at[t]=i[t]);return He()}function di(i={}){return ge({...i,provider:"fontawesome"})}function Qr(){return ge({provider:"builtin"})}async function Jr(i){let t=typeof i=="string"?{kit:i}:{...i},{kit:e,activate:s=!0,...r}=t;if(!e)throw new TypeError("loadFontAwesome() needs a kit token or URL");return ge({...r,kit:me(e)}),await Be(e),s?di():He()}function Xr(i){for(let[t,e]of Object.entries(i)){if(!Array.isArray(e)||e.length!==2)throw new TypeError(`Icon "${t}" must be a [viewBox, path] pair`);ui[t]=[String(e[0]),String(e[1])]}}function Zr(){return[...new Set([...Object.keys(qe),...Object.keys(ui)])].sort()}function m(i,t={}){let e=Pe(i);if(e.classes)return ci(e.classes,t);let s=Ga[e.name]??e.name;return e.provider==="builtin"?Gr(s,t):e.provider==="fa"?ci(_e(s,{style:e.style??t.style??at.style,family:t.family??at.family,fixedWidth:t.fixedWidth??at.fixedWidth}),t):at.provider==="fontawesome"?ci(_e(s,{style:t.style??at.style,family:t.family??at.family,fixedWidth:t.fixedWidth??at.fixedWidth}),t):Gr(s,t)}function Gr(i,t){let e=ui[i]??qe[i];if(!e)throw new RangeError(`Unknown icon: ${i}`);let[s,r]=e,{size:n=16}=t,o=document.createElementNS(Wr,"svg"),l=document.createElementNS(Wr,"path");return o.setAttribute("class",en("zx-icon",t.class)),o.setAttribute("viewBox",s),o.setAttribute("width",String(n)),o.setAttribute("height",String(n)),o.setAttribute("fill","currentColor"),o.setAttribute("focusable","false"),tn(o,t.label??null),l.setAttribute("d",r),o.append(l),o}function ci(i,t){let{size:e=16}=t,s=document.createElement("i");return s.className=en("zx-icon",...i,t.class),s.style.fontSize=typeof e=="number"?`${e}px`:String(e),tn(s,t.label??null),s}function tn(i,t){if(t===null){i.setAttribute("aria-hidden","true");return}i.setAttribute("role","img"),i.setAttribute("aria-label",t)}function en(...i){return i.flat().filter(Boolean).join(" ")}var Qa=5,Pt=class extends _{static cssName="time-picker";static defaults={value:null,seconds:!1,step:5,clock:!0};render(){let t=this.el??a("div");this.el=t;let e=sn(this.options.value);this._value=e,this._display=e??{h:0,m:0,s:0},this._inputs=[],this._clockOpen=!1,this._clockUnit="h",this._clock=null;let s=a("div",{class:"zx-time-picker__segments",role:"group",ariaLabel:"Time"});if(this._content=s,this._addSpin(s,"h","Hour",23),s.append(a("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"m","Minute",59),this.options.seconds&&(s.append(a("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"s","Second",59)),t.append(s),this.options.clock){let r=y("zx-time-picker-clock");s.append(a("button",{ref:"clockToggle",class:"zx-icon-btn zx-time-picker__clock-toggle",type:"button",ariaLabel:"Pick the time on a clock",ariaExpanded:"false",ariaControls:r},m("clock",{size:15}))),this._clock=this._buildClock(r),t.append(this._clock),this.listen(this.refs.clockToggle,"click",()=>this.toggleClock())}return this._writeInputs(),t}get(){return this._value?{...this._value}:null}set(t,{silent:e=!1}={}){let s=sn(t);return this._value=s,this._display=s??{h:0,m:0,s:0},this._writeInputs(),!e&&s&&this.emit("change",{time:{...s}}),this}openClock(t="h"){return this._clock?(this._clockOpen=!0,this._clockUnit=t==="m"?"m":"h",this._syncClock(),this):this}closeClock(){return this._clock?(this._clockOpen=!1,this._syncClock(),this):this}toggleClock(){return this._clockOpen?this.closeClock():this.openClock("h")}destroy(){this._content?.remove(),this._clock?.remove(),this._clock=null,super.destroy()}_addSpin(t,e,s,r){let n=a("input",{class:"zx-time-picker__spin",type:"text",role:"spinbutton",inputMode:"numeric",maxLength:2,autocomplete:"off",ariaLabel:s,ariaValueMin:"0",ariaValueMax:String(r),dataset:{segment:e}});this._inputs.push(n),t.append(n),this.listen(n,"focus",()=>n.select()),this.listen(n,"keydown",o=>this._onKeydown(o,e,r)),this.listen(n,"input",()=>this._onInput(n,e,r)),this.listen(n,"blur",()=>this._commitFromInputs())}_onKeydown(t,e,s){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return;t.preventDefault();let r=t.key==="ArrowUp"?1:-1,n=e==="m"?tl(this.options.step):1,o=Rt(t.currentTarget.value,0,s),l=s+1,h=(o+r*n+l*n)%l;t.currentTarget.value=wt(h),this._commitFromInputs()}_onInput(t,e,s){if(t.value=t.value.replace(/\D/g,"").slice(0,2),t.value.length<2)return;t.value=wt(Rt(t.value,0,s)),this._commitFromInputs();let r=this._inputs.indexOf(t);this._inputs[r+1]?.focus()}_commitFromInputs(){let t={h:0,m:0,s:0};for(let s of this._inputs){let r=s.dataset.segment,n=r==="h"?23:59;t[r]=Rt(s.value,0,n)}let e=!this._value||!el(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=wt(this._display[e]),t.setAttribute("aria-valuenow",String(this._display[e])),t.setAttribute("aria-valuetext",t.value)}this._syncClock()}_buildClock(t){let e=a("div",{class:"zx-time-picker__clock",id:t,hidden:!0},a("div",{class:"zx-time-picker__clock-head"},a("button",{ref:"headHour",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:"Select the hour",dataset:{unit:"h"}}),a("span",{class:"zx-time-picker__clock-colon",ariaHidden:"true"},":"),a("button",{ref:"headMinute",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:"Select the minutes",dataset:{unit:"m"}})),a("div",{ref:"dial",class:"zx-time-picker__dial",role:"radiogroup"},a("span",{ref:"hand",class:"zx-time-picker__hand",ariaHidden:"true"}),a("span",{class:"zx-time-picker__pivot",ariaHidden:"true"})));return this.listen(this.refs.headHour,"click",()=>this.openClock("h")),this.listen(this.refs.headMinute,"click",()=>this.openClock("m")),this.listen(this.refs.dial,"click",s=>{let r=s.target.closest?.(".zx-time-picker__mark");r&&this._pick(Number(r.dataset.value))}),this.listen(this.refs.dial,"keydown",s=>this._onDialKeydown(s)),e}_pick(t){let e={...this._display,[this._clockUnit]:t},s=this._clockUnit==="h";this.set(e),s&&this.openClock("m")}_onDialKeydown(t){let e=[...this.refs.dial.querySelectorAll(".zx-time-picker__mark")],s=t.target.closest?.(".zx-time-picker__mark"),r=e.indexOf(s);if(r<0)return;let n={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[t.key],o=null;n!==void 0?o=(r+n+e.length)%e.length:t.key==="Home"?o=0:t.key==="End"&&(o=e.length-1),o!==null&&(t.preventDefault(),this._pick(Number(e[o].dataset.value)),this.refs.dial.querySelector(`[data-value="${e[o].dataset.value}"]`)?.focus())}_syncClock(){if(!this._clock)return;let t=this._clockUnit==="h";if(this._clock.hidden=!this._clockOpen,this.refs.clockToggle.setAttribute("aria-expanded",String(this._clockOpen)),this.refs.headHour.textContent=wt(this._display.h),this.refs.headMinute.textContent=wt(this._display.m),this.refs.headHour.setAttribute("aria-pressed",String(t)),this.refs.headMinute.setAttribute("aria-pressed",String(!t)),this.refs.dial.setAttribute("aria-label",t?"Hour":"Minutes"),!this._clockOpen)return;let e=t?this._display.h:this._display.m,s=t?Ja():Xa(),r=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(r.length!==s.length||this.refs.dial.dataset.unit!==this._clockUnit){for(let l of r)l.remove();this.refs.dial.dataset.unit=this._clockUnit,this.refs.dial.append(...s.map(l=>this._buildMark(l,e)))}else s.forEach((l,h)=>this._syncMark(r[h],l,e));let n=t&&!Za(e)?"inner":"outer",o=t?e%12*30:e*6;this.refs.hand.dataset.ring=n,this.refs.hand.style.setProperty("--zx-clock-angle",`${o}deg`)}_buildMark(t,e){let s=a("button",{class:"zx-time-picker__mark",type:"button",role:"radio",dataset:{value:String(t.value),ring:t.ring}},t.label);return s.style.setProperty("--zx-clock-angle",`${t.angle}deg`),this._syncMark(s,t,e),s}_syncMark(t,e,s){let r=e.value===s;t.setAttribute("aria-checked",String(r)),t.tabIndex=r?0:-1}};function Ja(){let i=[];for(let t=1;t<=12;t+=1)i.push({value:t,label:String(t),angle:t%12*30,ring:"outer"});for(let t=0;t<12;t+=1){let e=t===0?0:12+t;i.push({value:e,label:wt(e),angle:t*30,ring:"inner"})}return i}function Xa(){let i=[];for(let t=0;t<60;t+=Qa)i.push({value:t,label:wt(t),angle:t*6,ring:"outer"});return i}function Za(i){return i>=1&&i<=12}function sn(i){return i instanceof Date&&!Number.isNaN(i.getTime())?{h:i.getHours(),m:i.getMinutes(),s:i.getSeconds()}:!i||typeof i!="object"?null:{h:Rt(i.h,0,23),m:Rt(i.m,0,59),s:Rt(i.s,0,59)}}function Rt(i,t,e){let s=Number.parseInt(String(i??""),10);return Number.isFinite(s)?Math.max(t,Math.min(e,s)):t}function tl(i){let t=Math.round(Number(i));return Number.isFinite(t)&&t>0&&t<=59?t:5}function wt(i){return String(i).padStart(2,"0")}function el(i,t){return i.h===t.h&&i.m===t.m&&i.s===t.s}var ft=class extends _{static cssName="date-picker";static defaults={value:null,min:null,max:null,weekStart:1,showWeekNumbers:!1,time:!1};render(){let t=this.el??a("div");this._min=Z(Ve(this.options.min)),this._max=Z(Ve(this.options.max)),this._value=this._normalizeValue(Ve(this.options.value)),this._focused=Z(this._value)??this._clampFocus(Z(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=sl(this.options.weekStart),this._quickOpen=!1,this._timePicker=null;let e=a("div",{class:"zx-date-picker__surface"},a("div",{class:"zx-date-picker__header"},a("button",{ref:"previous",class:"zx-date-picker__nav",type:"button",ariaLabel:"Previous month"},m("chevron-left")),a("button",{ref:"heading",class:"zx-date-picker__heading",type:"button",ariaExpanded:"false","aria-haspopup":"grid"}),a("button",{ref:"next",class:"zx-date-picker__nav",type:"button",ariaLabel:"Next month"},m("chevron-right"))),a("div",{ref:"quickPanel",class:"zx-date-picker__quick",hidden:!0},a("div",{class:"zx-date-picker__quick-header"},a("button",{ref:"quickPrevious",class:"zx-date-picker__nav",type:"button",ariaLabel:"Previous year"},m("chevron-left")),a("span",{ref:"quickYear",class:"zx-date-picker__quick-year",ariaLive:"polite"}),a("button",{ref:"quickNext",class:"zx-date-picker__nav",type:"button",ariaLabel:"Next year"},m("chevron-right"))),a("div",{ref:"quickGrid",class:"zx-date-picker__quick-grid",role:"grid"})),a("table",{ref:"grid",class:"zx-date-picker__grid",role:"grid",ariaLabel:"Calendar"},a("thead",{ref:"weekdays"}),a("tbody",{ref:"days"})));return this._content=e,t.append(e),this.listen(this.refs.previous,"click",()=>this._pageMonth(-1)),this.listen(this.refs.next,"click",()=>this._pageMonth(1)),this.listen(this.refs.heading,"click",()=>this._toggleQuickPick()),this.listen(this.refs.quickPrevious,"click",()=>this._stepQuickYear(-1)),this.listen(this.refs.quickNext,"click",()=>this._stepQuickYear(1)),this.listen(this.refs.quickGrid,"click",s=>this._onQuickClick(s)),this.listen(this.refs.quickGrid,"keydown",s=>this._onQuickKeydown(s)),this.listen(this.refs.days,"click",s=>this._onDayClick(s)),this.listen(this.refs.days,"keydown",s=>this._onDayKeydown(s)),this._renderWeekdays(),this._renderCalendar(),this.options.time&&(this._timePicker=new Pt(null,{value:this._value,seconds:!1}),this._timePicker.on("change",s=>{let r=s.detail.time,n=this._value??this._focused,o=new Date(n.getTime());o.setHours(r.h,r.m,r.s,0),this.set(o)}),e.append(this._timePicker.el)),t}get(){return pi(this._value)}set(t,{silent:e=!1}={}){let s=this._normalizeValue(Ve(t));return this._value=s,s&&(this._focused=Z(s),this._viewYear=s.getFullYear(),this._viewMonth=s.getMonth()),this._timePicker?.set(s,{silent:!0}),this._renderCalendar(),e||this.emit("change",{date:pi(this._value)}),this}focus(){return this._closeQuickPick(),this._buttonForDate(this._focused)?.focus(),this}destroy(){this._timePicker?.destroy(),this._timePicker=null,this._content?.remove(),super.destroy()}_normalizeValue(t){if(!t)return null;let e=new Date(t.getTime()),s=Z(e);return this._min&&s<this._min&&rn(e,this._min),this._max&&s>this._max&&rn(e,this._max),e}_clampFocus(t){return this._min&&t<this._min?new Date(this._min.getTime()):this._max&&t>this._max?new Date(this._max.getTime()):t}_renderWeekdays(){let t=a("tr");this.options.showWeekNumbers&&t.append(a("th",{class:"zx-date-picker__week-heading",scope:"col",ariaLabel:"Week number"},"#"));let e=new Date(2023,0,1);for(let s=0;s<7;s+=1){let r=T(e,(this._weekStart+s)%7);t.append(a("th",{scope:"col",ariaLabel:A(r,"%A")},A(r,"%a")))}this.refs.weekdays.replaceChildren(t)}_renderCalendar(){if(!this.refs?.days)return;let t=new Date(this._viewYear,this._viewMonth,1),e=(t.getDay()-this._weekStart+7)%7,s=T(t,-e);this.refs.heading.textContent=A(t,"%B %Y"),this.refs.heading.setAttribute("aria-label",`Choose month and year, ${A(t,"%B %Y")}`);let r=[];for(let n=0;n<6;n+=1){let o=T(s,n*7),l=a("tr");this.options.showWeekNumbers&&l.append(a("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:`Week ${nn(o)}`},String(nn(o))));for(let h=0;h<7;h+=1){let c=T(o,h),u=!!(this._value&&F(c,this._value)),d=!this._inRange(c),f=a("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:F(c,this._focused)?0:-1,ariaSelected:String(u),ariaDisabled:String(d),ariaCurrent:F(c,new Date)?"date":null,ariaLabel:`${A(c,"%e")} ${A(c,"%B %Y")}`,dataset:{date:A(c,"%Y-%m-%d"),otherMonth:c.getMonth()===this._viewMonth?null:"true"}},A(c,"%e"));l.append(a("td",{role:"presentation"},f))}r.push(l)}this.refs.days.replaceChildren(...r),this._quickOpen&&this._renderQuickPick()}_onDayClick(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let s=P(e.dataset.date,"%Y-%m-%d");s&&this._inRange(s)&&this._selectDate(s)}_onDayKeydown(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let s=P(e.dataset.date,"%Y-%m-%d");if(!s)return;let r=null;if(t.key==="ArrowLeft")r=T(s,-1);else if(t.key==="ArrowRight")r=T(s,1);else if(t.key==="ArrowUp")r=T(s,-7);else if(t.key==="ArrowDown")r=T(s,7);else if(t.key==="PageUp")r=ot(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")r=ot(s,t.shiftKey?12:1);else if(t.key==="Home")r=T(s,-((s.getDay()-this._weekStart+7)%7));else if(t.key==="End")r=T(s,6-(s.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._inRange(s)&&this._selectDate(s);return}r&&(t.preventDefault(),this._moveFocus(r))}_moveFocus(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;this._focused=Z(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._renderCalendar(),e&&this._emitMonthChange(),this._buttonForDate(t)?.focus()}_selectDate(t){let e=new Date(t.getTime()),s=this._timePicker?.get();s?e.setHours(s.h,s.m,s.s,0):this._value&&e.setHours(this._value.getHours(),this._value.getMinutes(),this._value.getSeconds(),this._value.getMilliseconds());let r=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;this._value=e,this._focused=Z(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._timePicker?.set(e,{silent:!0}),this._renderCalendar(),r&&this._emitMonthChange(),this.emit("change",{date:pi(e)})}_pageMonth(t){this._closeQuickPick();let e=ot(this._focused,t);this._focused=Z(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._renderCalendar(),this._emitMonthChange()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_toggleQuickPick(){if(this._quickOpen){this._closeQuickPick(),this.refs.heading.focus();return}this._quickOpen=!0,this.refs.quickPanel.hidden=!1,this.refs.heading.setAttribute("aria-expanded","true"),this._renderQuickPick(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_closeQuickPick(){this._quickOpen&&(this._quickOpen=!1,this.refs.quickPanel.hidden=!0,this.refs.heading.setAttribute("aria-expanded","false"))}_renderQuickPick(){this.refs.quickYear.textContent=String(this._viewYear);let t=[];for(let e=0;e<12;e+=1){let s=new Date(this._viewYear,e,1);t.push(a("button",{class:"zx-date-picker__quick-month",type:"button",role:"gridcell",tabindex:e===this._viewMonth?0:-1,ariaSelected:String(e===this._viewMonth),dataset:{month:e}},A(s,"%b")))}this.refs.quickGrid.replaceChildren(...t)}_stepQuickYear(t){this._viewYear+=t,this._renderQuickPick(),this._emitMonthChange(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_onQuickClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.quickGrid.contains(e)||this._chooseQuickMonth(Number(e.dataset.month))}_onQuickKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.quickGrid.contains(e))return;let s=Number(e.dataset.month),r=null;if(t.key==="ArrowLeft")r=s-1;else if(t.key==="ArrowRight")r=s+1;else if(t.key==="ArrowUp")r=s-3;else if(t.key==="ArrowDown")r=s+3;else if(t.key==="Home")r=0;else if(t.key==="End")r=11;else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._chooseQuickMonth(s);return}else if(t.key==="Escape"){t.preventDefault(),this._closeQuickPick(),this.refs.heading.focus();return}if(r===null)return;t.preventDefault(),r=Math.max(0,Math.min(11,r));let n=this.refs.quickGrid.querySelectorAll("[data-month]");for(let o of n)o.tabIndex=Number(o.dataset.month)===r?0:-1;n[r]?.focus()}_chooseQuickMonth(t){let e=new Date(this._viewYear,t,Math.min(this._focused.getDate(),new Date(this._viewYear,t+1,0).getDate()));this._focused=Z(e),this._viewMonth=t,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(t){let e=Z(t);return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_buttonForDate(t){return this.refs.days.querySelector(`[data-date="${A(t,"%Y-%m-%d")}"]`)}};function Ve(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function Z(i){return i?new Date(i.getFullYear(),i.getMonth(),i.getDate()):null}function pi(i){return i?new Date(i.getTime()):null}function rn(i,t){i.setFullYear(t.getFullYear(),t.getMonth(),t.getDate())}function sl(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:Lt()}function nn(i){let t=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let s=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-s.getTime())/864e5+1)/7)}var Bt=class extends ft{static cssName="month-picker";static defaults={value:null,min:null,max:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??a("div");this._min=$e(je(this.options.min)),this._max=$e(je(this.options.max)),this._value=this._normalizeMonth(je(this.options.value));let e=this._value??$e(new Date);this._year=e.getFullYear(),this._focusedMonth=e.getMonth();let s=a("div",{class:"zx-month-picker__surface"},a("div",{class:"zx-month-picker__header"},a("button",{ref:"previousYear",class:"zx-month-picker__nav",type:"button",ariaLabel:"Previous year"},m("chevron-left")),a("span",{ref:"year",class:"zx-month-picker__year",ariaLive:"polite"}),a("button",{ref:"nextYear",class:"zx-month-picker__nav",type:"button",ariaLabel:"Next year"},m("chevron-right"))),a("div",{ref:"grid",class:"zx-month-picker__grid",role:"grid",ariaLabel:"Choose month"}));return this._content=s,t.append(s),this.listen(this.refs.previousYear,"click",()=>this._stepYear(-1)),this.listen(this.refs.nextYear,"click",()=>this._stepYear(1)),this.listen(this.refs.grid,"click",r=>this._onMonthClick(r)),this.listen(this.refs.grid,"keydown",r=>this._onMonthKeydown(r)),this._renderMonths(),t}get(){return this._value?new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeMonth(je(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=$e(t);return this._min&&e<this._min&&(e=new Date(this._min.getTime())),this._max&&e>this._max&&(e=new Date(this._max.getTime())),e}_renderMonths(){if(!this.refs?.grid)return;this.refs.year.textContent=String(this._year);let t=[];for(let e=0;e<12;e+=1){let s=new Date(this._year,e,1),r=!!(this._value&&il(s,this._value));t.push(a("button",{class:"zx-month-picker__month",type:"button",role:"gridcell",tabindex:e===this._focusedMonth?0:-1,ariaSelected:String(r),ariaDisabled:String(!this._inRange(s)),ariaLabel:A(s,"%B %Y"),dataset:{month:e}},A(s,"%b")))}this.refs.grid.replaceChildren(...t)}_stepYear(t){this._year+=t,this._renderMonths()}_onMonthClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.grid.contains(e)||this._selectMonth(Number(e.dataset.month))}_onMonthKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.grid.contains(e))return;let s=Number(e.dataset.month),r=null;if(t.key==="ArrowLeft")r=-1;else if(t.key==="ArrowRight")r=1;else if(t.key==="ArrowUp")r=-3;else if(t.key==="ArrowDown")r=3;else if(t.key==="Home")r=-(s%3);else if(t.key==="End")r=2-s%3;else if(t.key==="PageUp"){t.preventDefault(),this._stepYear(-1),this.focus();return}else if(t.key==="PageDown"){t.preventDefault(),this._stepYear(1),this.focus();return}else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._selectMonth(s);return}if(r===null)return;t.preventDefault();let n=this._year*12+s+r;this._year=Math.floor(n/12),this._focusedMonth=(n%12+12)%12,this._renderMonths(),this.focus()}_selectMonth(t){let e=new Date(this._year,t,1);this._inRange(e)&&(this._focusedMonth=t,this._value=e,this._renderMonths(),this.emit("change",{date:this.get()}))}_inRange(t){return!(this._min&&t<this._min)&&!(this._max&&t>this._max)}_button(t){return this.refs.grid.querySelector(`[data-month="${t}"]`)}};function je(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function $e(i){return i?new Date(i.getFullYear(),i.getMonth(),1):null}function il(i,t){return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()}function on(){S.register("month",(i,t)=>{let e=i.own(new Bt(null,{...t.props??{},value:t.value})),s=!1,r=()=>{e.el.setAttribute("aria-disabled",String(s));for(let n of e.el.querySelectorAll("button"))n.disabled=s};return i.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>i.emit("change",{value:n.detail.date})),{el:e.el,get:()=>e.get(),set:n=>{e.set(n instanceof Date?n:null,{silent:!0}),r()},focus:()=>e.focus(),setDisabled:n=>{s=!!n,r()}}})}var rl=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function V(i,t,e={}){if(!(i instanceof Element)||!(t instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let s=rl.has(e.placement)?e.placement:"bottom-start",r=Number(e.offset??4),n=e.flip??!0,o=e.matchWidth??!1,l=i.getAttribute("style"),h=t.getAttribute("style"),c=t.getAttribute("popover"),u=!1,d=null,f=()=>{},p=()=>{};if(t.setAttribute("popover","manual"),typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a")){let x=`--${y("zx-a")}`;i.style.setProperty("anchor-name",x),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.setProperty("position-anchor",x);let v=nl(s,getComputedStyle(i).direction==="rtl");t.style.setProperty("position-area",v),t.style.setProperty("inset-area",v),t.style.setProperty("position-try-fallbacks",n?"flip-block, flip-inline, flip-block flip-inline":"none");let b=s.startsWith("top")?"margin-bottom":s.startsWith("bottom")?"margin-top":s.startsWith("left")?"margin-right":"margin-left";t.style.setProperty(b,`${r}px`),f=()=>{o&&(t.style.minWidth=`${i.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(d=new ResizeObserver(f),d.observe(i))}else t.style.position="fixed",t.style.inset="auto",t.style.margin="0",f=()=>ol(i,t,{placement:s,offset:r,flip:n,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(i)),p=()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)};return al(t),f(),{update(){u||f()},destroy(){u||(u=!0,d?.disconnect(),p(),ll(t),fi(i,"style",l),fi(t,"style",h),fi(t,"popover",c))}}}function nl(i,t){return{"bottom-start":t?"bottom span-left":"bottom span-right","bottom-end":t?"bottom span-right":"bottom span-left","top-start":t?"top span-left":"top span-right","top-end":t?"top span-right":"top span-left","right-start":"right span-bottom","right-end":"right span-top","left-start":"left span-bottom","left-end":"left span-top",bottom:"bottom",top:"top",right:"right",left:"left"}[i]}function ol(i,t,{placement:e,offset:s,flip:r,matchWidth:n}){let o=i.getBoundingClientRect();n&&(t.style.minWidth=`${o.width}px`);let l=t.getBoundingClientRect(),h=document.documentElement.clientWidth||window.innerWidth,c=document.documentElement.clientHeight||window.innerHeight,u=e,d=an(e),f=o.bottom+s,p=o.top-s-l.height,g=o.right+s,x=o.left-s-l.width;r&&(d==="bottom"&&f+l.height>c&&p>=0?u=Ke(e,"bottom","top"):d==="top"&&p<0&&f+l.height<=c?u=Ke(e,"top","bottom"):d==="right"&&g+l.width>h&&x>=0?u=Ke(e,"right","left"):d==="left"&&x<0&&g+l.width<=h&&(u=Ke(e,"left","right")));let v=an(u),b,w;if(v==="bottom"||v==="top"){let E=getComputedStyle(i).direction==="rtl";u.endsWith("-end")?b=E?o.left:o.right-l.width:u.endsWith("-start")?b=E?o.right-l.width:o.left:b=o.left+(o.width-l.width)/2,w=v==="bottom"?f:p}else b=v==="right"?g:x,u.endsWith("-end")?w=o.bottom-l.height:u.endsWith("-start")?w=o.top:w=o.top+(o.height-l.height)/2;t.style.left=`${Math.round(N(b,0,Math.max(0,h-l.width)))}px`,t.style.top=`${Math.round(N(w,0,Math.max(0,c-l.height)))}px`}function an(i){return i.split("-")[0]}function Ke(i,t,e){return i.replace(t,e)}function al(i){if(typeof i.showPopover=="function")try{i.showPopover()}catch{}}function ll(i){if(typeof i.hidePopover=="function")try{i.hidePopover()}catch{}}function fi(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}var hl=6,pn=864e5;function At(i,t){let e=j(St(i)),s=j(St(t));return e&&s&&e.getTime()>s.getTime()?{start:s,end:e}:{start:e,end:s}}function qt(i,t){let e=At(i,t);return!e.start||!e.end?0:Math.round((cn(e.end)-cn(e.start))/pn)}function gi(i,t,e){let s=j(St(i));if(!s)return null;let r=At(t,e);return!r.start&&!r.end?null:r.end?r.start?s.getTime()<r.start.getTime()||s.getTime()>r.end.getTime()?null:F(s,r.start)?"start":F(s,r.end)?"end":"middle":F(s,r.end)?"end":null:F(s,r.start)?"start":null}function Ht(i,t={}){let e=j(St(t.min)),s=j(St(t.max)),r=Ue(t.minNights)??0,n=Ue(t.maxNights),{start:o,end:l}=At(i?.start,i?.end);return o&&(o=mi(o,e,s)),l&&(l=mi(l,e,s)),!o||!l?{start:o,end:l}:(n!==null&&qt(o,l)>n&&(l=T(o,n)),r>0&&qt(o,l)<r&&(l=T(o,r),s&&l.getTime()>s.getTime()&&(l=new Date(s.getTime()),o=T(l,-r),e&&o.getTime()<e.getTime()))?{start:null,end:null}:{start:o,end:l})}var Vt=class extends _{static cssName="date-range-picker";static defaults={start:null,end:null,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??a("div");this.el=t,this._rootAttributes=_l(t,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=j(St(this.options.min)),this._max=j(St(this.options.max)),this._minNights=Ue(this.options.minNights)??0,this._maxNights=Ue(this.options.maxNights),this._weekStart=dl(this.options.weekStart),this._monthCount=pl(this.options.months),this._presets=ul(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let e=Ht({start:this.options.start,end:this.options.end},this._bounds());this._start=e.start,this._end=e.end,this._picking=!!(e.start&&!e.end),this._remember(),this._focused=_t(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",M("daterange.label","Date range")),t.dataset.months=String(this._monthCount),this._presets.length&&(t.dataset.presets="true");let s=a("div",{class:"zx-date-range-picker__surface"},this._presets.length?a("div",{ref:"presets",class:"zx-date-range-picker__presets",role:"group",ariaLabel:M("daterange.presets","Date range presets")},this._presets.map(n=>a("button",{class:"zx-date-range-picker__preset",type:"button",dataset:{preset:n.name}},n.label))):null,a("div",{ref:"calendars",class:"zx-date-range-picker__calendars"})),r=a("div",{ref:"status",class:"zx-date-range-picker__status",role:"status",ariaLive:"polite"});return this._nodes=[s,r],t.append(s,r),this.refs.presets&&this.listen(this.refs.presets,"click",n=>this._onPresetClick(n)),this.listen(this.refs.calendars,"click",n=>this._onCalendarClick(n)),this.listen(this.refs.calendars,"keydown",n=>this._onDayKeydown(n)),this.listen(this.refs.calendars,"mouseover",n=>this._onDayHover(n)),this.listen(this.refs.calendars,"mouseleave",()=>this._setHover(null)),this._renderCalendars(),this._announce(),t}get(){return{start:_t(this._start),end:_t(this._end)}}set(t={},{silent:e=!1}={}){let s=Ht({start:t?.start??null,end:t?.end??null},this._bounds());return this._start=s.start,this._end=s.end,this._picking=!!(s.start&&!s.end),this._remember(),this._hover=null,s.start?(this._focused=_t(s.start),this._setView(s.start)):this._paint(),this._announce(),e||this.emit("change",this.get()),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}focus(){return this._buttonForDate(this._focused)?.focus(),this}enable(){return this._disabled=!1,this._paint(),this._syncDisabled(),this}disable(){return this._disabled=!0,this._hover=null,this._paint(),this._syncDisabled(),this}destroy(){for(let t of this._nodes??[])t.remove();this._nodes=[],this._dayCells=[],ml(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 s=qt(this._start,e);return!(s<this._minNights||this._maxNights!==null&&s>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?_t(this._start):null,this._committedEnd=t?_t(this._end):null}_abandon(){return this._picking?(this._start=_t(this._committedStart),this._end=_t(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(t){return mi(t,this._min,this._max)}_visibleMonthCount(){let t=this.refs.calendars?.children??[],e=0;for(let s of t)s.getClientRects().length>0&&(e+=1);return e||this._monthCount}_setView(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;if(this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),!e){this._paint();return}this._renderCalendars(),this._emitMonthChange()}_ensureVisible(t){let e=this._visibleMonthCount(),s=un(t)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<e)return!1;let r=s<0?s:s-(e-1),n=new Date(this._viewYear,this._viewMonth+r,1);return this._viewYear=n.getFullYear(),this._viewMonth=n.getMonth(),!0}_pageView(t){if(this._disabled)return;let e=new Date(this._viewYear,this._viewMonth+t,1);this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._focused=this._focusInView(this._focused),this._renderCalendars(),this._emitMonthChange()}_focusInView(t){let e=this._visibleMonthCount(),s=un(t)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<e)return t;let r=new Date(this._viewYear,this._viewMonth+1,0).getDate();return new Date(this._viewYear,this._viewMonth,Math.min(t.getDate(),r))}_moveFocus(t){let e=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 s=this._presets.find(n=>n.name===e.dataset.preset);if(!s)return;let r=s.range();this.set({start:r?.start??null,end:r?.end??null},{silent:!0}),this.emit("select",this.get()),this.emit("change",this.get())}_onCalendarClick(t){let e=t.target,s=e?.closest?.("[data-nav]");if(s){this._pageView(s.dataset.nav==="next"?1:-1);return}let r=this._cellFor(e);r&&this._choose(r.date)}_onDayHover(t){let e=this._cellFor(t.target);this._setHover(e?e.date:null)}_setHover(t){if(this._disabled||!this._picking)return;let e=t?j(t):null;!e&&!this._hover||e&&this._hover&&F(e,this._hover)||(this._hover=e,this._paint())}_onDayKeydown(t){let e=this._cellFor(t.target);if(!e)return;let s=e.date,r=null;if(t.key==="ArrowLeft")r=T(s,-1);else if(t.key==="ArrowRight")r=T(s,1);else if(t.key==="ArrowUp")r=T(s,-7);else if(t.key==="ArrowDown")r=T(s,7);else if(t.key==="PageUp")r=ot(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")r=ot(s,t.shiftKey?12:1);else if(t.key==="Home")r=T(s,-((s.getDay()-this._weekStart+7)%7));else if(t.key==="End")r=T(s,6-(s.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._choose(s);return}else if(t.key==="Escape"){if(!this._abandon())return;t.preventDefault(),t.stopPropagation();return}!r||this._disabled||(t.preventDefault(),this._moveFocus(r))}_renderCalendars(){if(!this.refs?.calendars)return;this._dayCells=[];let t=[];for(let e=0;e<this._monthCount;e+=1)t.push(this._renderMonth(new Date(this._viewYear,this._viewMonth+e,1)));this.refs.calendars.replaceChildren(...t),this._paint(),this._syncDisabled()}_renderMonth(t){let e=A(t,"%B %Y"),s=(t.getDay()-this._weekStart+7)%7,r=T(t,-s),n=[];for(let o=0;o<hl;o+=1){let l=T(r,o*7),h=a("tr"),c=fl(l,t);this.options.showWeekNumbers&&h.append(a("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:c?M("daterange.week","Week %1",[dn(l)]):null},c?String(dn(l)):""));for(let u=0;u<7;u+=1){let d=T(l,u),f=a("td",{role:"presentation"});if(d.getMonth()===t.getMonth()&&d.getFullYear()===t.getFullYear()){let p=a("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:A(d,"%Y-%m-%d")}},A(d,"%e"));f.append(p),this._dayCells.push({date:d,cell:f,button:p})}h.append(f)}n.push(h)}return a("div",{class:"zx-date-range-picker__month"},a("div",{class:"zx-date-range-picker__header"},a("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"previous"},ariaLabel:M("daterange.previousMonth","Previous month")},m("chevron-left")),a("div",{class:"zx-date-range-picker__caption",ariaHidden:"true"},e),a("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"next"},ariaLabel:M("daterange.nextMonth","Next month")},m("chevron-right"))),a("table",{class:"zx-date-range-picker__grid",role:"grid",ariaLabel:e},a("thead",{},this._weekdayRow()),a("tbody",{},...n)))}_weekdayRow(){let t=a("tr");this.options.showWeekNumbers&&t.append(a("th",{class:"zx-date-range-picker__week-heading",scope:"col",ariaLabel:M("daterange.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let s=0;s<7;s+=1){let r=T(e,(this._weekStart+s)%7);t.append(a("th",{scope:"col",ariaLabel:A(r,"%A")},A(r,"%a")))}return t}_paint(){let t=new Date,e=null;for(let s of this._dayCells)F(s.date,this._focused)&&(e=s);e||(e=this._dayCells[0]??null);for(let s of this._dayCells){let{date:r,cell:n,button:o}=s,l=this._dayState(r);_i(n,"range",l.range),_i(n,"rangeEdge",l.edge),_i(o,"range",l.range),o.tabIndex=s===e?0:-1,o.setAttribute("aria-selected",String(l.range!==null&&l.range!=="preview")),o.setAttribute("aria-disabled",String(!this._selectable(r))),o.setAttribute("aria-label",this._dayLabel(r,l.range)),F(r,t)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(t){if(this._start&&this._end){let s=gi(t,this._start,this._end);if(!s)return{range:null,edge:null};let r=F(this._start,this._end);return s==="start"?{range:s,edge:r?"both":"start"}:s==="end"?{range:s,edge:r?"both":"end"}:{range:s,edge:null}}if(!this._start)return{range:null,edge:null};let e=this._previewEnd();return F(t,this._start)?{range:"start",edge:e?"start":"both"}:e?t.getTime()>this._start.getTime()&&t.getTime()<=e.getTime()?{range:"preview",edge:F(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 s=A(t,"%A, %e %B %Y");return e==="start"?`${s}, ${M("daterange.day.start","range start")}`:e==="end"?`${s}, ${M("daterange.day.end","range end")}`:e==="middle"?`${s}, ${M("daterange.day.middle","in selected range")}`:s}_syncDisabled(){this.el.setAttribute("aria-disabled",String(this._disabled));for(let t of this.el.querySelectorAll("button"))t.disabled=this._disabled}_announce(){this.refs?.status&&(this.refs.status.textContent=this._selectionLabel())}_selectionLabel(){if(!this._start)return M("daterange.status.empty","No date range selected");if(!this._end)return M("daterange.status.start","%1 selected, choose an end date",[A(this._start,"%e %B %Y")]);let t=qt(this._start,this._end),e=t===1?M("daterange.night","1 night"):M("daterange.nights","%1 nights",[t]);return`${cl(this._start,this._end)}, ${e}`}_cellFor(t){let e=t?.closest?.("[data-date]");return e?this._dayCells.find(s=>s.button===e)??null:null}_buttonForDate(t){return this._dayCells.find(e=>F(e.date,t))?.button??null}};function bi(){return[{name:"today",label:M("daterange.preset.today","Today"),range:()=>ln(it())},{name:"yesterday",label:M("daterange.preset.yesterday","Yesterday"),range:()=>ln(T(it(),-1))},{name:"last7",label:M("daterange.preset.last7","Last 7 days"),range:()=>({start:T(it(),-6),end:it()})},{name:"last30",label:M("daterange.preset.last30","Last 30 days"),range:()=>({start:T(it(),-29),end:it()})},{name:"thisMonth",label:M("daterange.preset.thisMonth","This month"),range:()=>hn(it(),0)},{name:"lastMonth",label:M("daterange.preset.lastMonth","Last month"),range:()=>hn(it(),-1)},{name:"thisQuarter",label:M("daterange.preset.thisQuarter","This quarter"),range:()=>{let i=it(),t=Math.floor(i.getMonth()/3)*3;return{start:new Date(i.getFullYear(),t,1),end:new Date(i.getFullYear(),t+3,0)}}},{name:"thisYear",label:M("daterange.preset.thisYear","This year"),range:()=>{let i=it();return{start:new Date(i.getFullYear(),0,1),end:new Date(i.getFullYear(),11,31)}}}]}function M(i,t,e){let s=J(i);return O(s===i?t:s,e)}function cl(i,t){if(F(i,t))return A(i,"%e %B %Y");let e=A(t,"%e %B %Y");return i.getFullYear()!==t.getFullYear()?`${A(i,"%e %B %Y")} \u2013 ${e}`:i.getMonth()!==t.getMonth()?`${A(i,"%e %B")} \u2013 ${e}`:`${A(i,"%e")} \u2013 ${e}`}function ul(i){return i===!0?bi():Array.isArray(i)?i.filter(t=>t&&typeof t.range=="function").map((t,e)=>({name:String(t.name??`preset-${e}`),label:String(t.label??t.name??""),range:t.range})):[]}function it(){return j(new Date)}function ln(i){return{start:i,end:new Date(i.getTime())}}function hn(i,t){return{start:new Date(i.getFullYear(),i.getMonth()+t,1),end:new Date(i.getFullYear(),i.getMonth()+t+1,0)}}function St(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function j(i){return!i||Number.isNaN(i.getTime())?null:new Date(i.getFullYear(),i.getMonth(),i.getDate())}function _t(i){return i?new Date(i.getTime()):null}function mi(i,t,e){return t&&i.getTime()<t.getTime()?new Date(t.getTime()):e&&i.getTime()>e.getTime()?new Date(e.getTime()):new Date(i.getTime())}function cn(i){return Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())}function un(i){return i.getFullYear()*12+i.getMonth()}function Ue(i){if(i==null||i==="")return null;let t=Number(i);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):null}function dl(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:Lt()}function pl(i){let t=Number(i);return Number.isInteger(t)&&t>=1&&t<=4?t:2}function fl(i,t){for(let e=0;e<7;e+=1){let s=T(i,e);if(s.getMonth()===t.getMonth()&&s.getFullYear()===t.getFullYear())return!0}return!1}function dn(i){let t=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let s=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-s.getTime())/pn+1)/7)}function _i(i,t,e){e==null?delete i.dataset[t]:i.dataset[t]=e}function _l(i,t){return new Map(t.map(e=>[e,i.getAttribute(e)]))}function ml(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}var gl={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function Ye(i,t,e){let s=String(i??"").trim();if(s==="")return{start:null,end:null};let r=String(e??" \u2013 "),n=r.trim(),o=n!==""&&String(t).includes(n)&&/^\s|\s$/.test(r),l=o?"\\s+":"\\s*",h=o?"(?:\\s+|$)":"\\s*",c=n===""?[s]:s.split(new RegExp(`${l}${Ot(n)}${h}`));if(c.length>2)return null;let u=P(c[0].trim(),t);if(!u)return null;if(c.length===1)return{start:u,end:new Date(u.getTime())};if(c[1].trim()==="")return{start:u,end:null};let d=P(c[1].trim(),t);return d?At(u,d):null}function xi(i,t,e){let s=i?.start??null,r=i?.end??null;return!s&&!r?"":r?s?`${A(s,t)}${e}${A(r,t)}`:A(r,t):A(s,t)}var jt=class extends _{static cssName="date-range-box";static defaults={start:null,end:null,format:"%d.%m.%Y",separator:" \u2013 ",placeholder:null,clearable:!0,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??a("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._format=String(this.options.format||"%d.%m.%Y"),this._separator=String(this.options.separator??" \u2013 "),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._range=this._coerce({start:this.options.start,end:this.options.end});let e=y("zx-date-range-box-popover"),s=a("div",{class:"zx-date-range-box__content"},a("div",{ref:"control",class:"zx-date-range-box__control"},a("input",{ref:"input",class:"zx-date-range-box__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??this._placeholder(),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),a("button",{ref:"clear",class:"zx-icon-btn zx-date-range-box__clear",type:"button",ariaLabel:fn("daterange.clear","Clear date range")},m("x",{size:13})),a("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:fn("daterange.choose","Choose date range"),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},m("calendar"))),a("div",{ref:"popover",id:e,class:"zx-date-range-box__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=s,t.append(s),this._picker=new Vt(null,{start:this._range.start,end:this._range.end,min:this.options.min,max:this.options.max,months:this.options.months,weekStart:this.options.weekStart,showWeekNumbers:this.options.showWeekNumbers,minNights:this.options.minNights,maxNights:this.options.maxNights,presets:this.options.presets}),this.refs.popover.append(this._picker.el),this._picker.on("select",r=>{this._range={start:r.detail.start,end:r.detail.end},this._setValid(),this._syncDisplay()}),this._picker.on("change",r=>{this._apply({start:r.detail.start,end:r.detail.end},{push:!1}),r.detail.start&&r.detail.end&&this._close(!0)}),this.listen(this.refs.input,"blur",()=>{this._open||this._commitText()}),this.listen(this.refs.input,"keydown",r=>this._onInputKeydown(r)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",r=>{r.key==="ArrowDown"&&(r.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.clear(),this.focus()}),this.listen(document,"keydown",r=>{!this._open||r.key!=="Escape"||(r.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",r=>{this._open&&!t.contains(r.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return t==="seconds"?{start:this._range.start?Math.floor(this._range.start.getTime()/1e3):null,end:this._range.end?Math.floor(this._range.end.getTime()/1e3):null}:{start:this._range.start?new Date(this._range.start.getTime()):null,end:this._range.end?new Date(this._range.end.getTime()):null}}set(t,{silent:e=!1}={}){return this._apply(this._coerce(t),{silent:e}),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}open(){return this._disabled||this._open?this:(this._picker.set(this._range,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=V(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(),yi(this.el,"data-state",this._originalState),yi(this.el,"aria-disabled",this._originalAriaDisabled),super.destroy()}_apply(t,{silent:e=!1,push:s=!0}={}){this._range=t,s&&this._picker?.set(this._range,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",this.get())}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set({start:null,end:null});return}let e=Ye(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(Ye(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()!==""?P(t.trim(),this._format):null}_clamp(t){return Ht(t,{min:this.options.min,max:this.options.max,minNights:this.options.minNights,maxNights:this.options.maxNights})}_placeholder(){let t=this._format.replace(/%[demYy]/g,e=>gl[e]??e);return`${t}${this._separator}${t}`}_syncDisplay(){this.refs.input.value=xi(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"&&yi(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 fn(i,t,e){let s=J(i);return O(s===i?t:s,e)}function yi(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}function _n(){S.register("daterange",(i,t)=>{let e=i.own(new jt(null,{...t.props??{},disabled:!!t.disabled,start:t.value?.start??null,end:t.value?.end??null}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:{start:s.detail.start,end:s.detail.end}})),{el:e.el,get:()=>e.get(),set:s=>e.set(s,{silent:!0}),focus:()=>e.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var B=class extends _{static cssName="datebox";static defaults={value:null,format:"%d.%m.%Y",time:!1,min:null,max:null,placeholder:null,clearable:!0,disabled:!1};render(){let t=this.el??a("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._format=bl(this.options.format,this.options.time),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._min=mn(this.options.min),this._max=mn(this.options.max),this._value=this._normalizeValue(this.options.value);let e=y("zx-datebox-popover"),s=a("div",{class:"zx-datebox__content"},a("div",{ref:"control",class:"zx-datebox__control"},a("input",{ref:"input",class:"zx-datebox__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??yl(this._format),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),a("button",{ref:"clear",class:"zx-icon-btn zx-datebox__clear",type:"button",ariaLabel:"Clear date"},m("x",{size:13})),a("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:"Choose date","aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},m("calendar"))),a("div",{ref:"popover",id:e,class:"zx-datebox__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=s,t.append(s),this._picker=new ft(null,{value:this._value,min:this._min,max:this._max,time:!!this.options.time}),this.refs.popover.append(this._picker.el),this._picker.on("change",r=>{this.set(r.detail.date),this.options.time||this._close(!0)}),this.listen(this.refs.input,"blur",()=>this._commitText()),this.listen(this.refs.input,"keydown",r=>this._onInputKeydown(r)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",r=>{r.key==="ArrowDown"&&(r.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.set(null),this.focus()}),this.listen(document,"keydown",r=>{!this._open||r.key!=="Escape"||(r.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",r=>{this._open&&!t.contains(r.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return this._value?t==="seconds"?Math.floor(this._value.getTime()/1e3):new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeValue(t),this._picker?.set(this._value,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",{date:this._copyValue()}),this}open(){return this._disabled||this._open?this:(this._picker.set(this._value,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=V(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=P(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=P(t,this._format)),!e||Number.isNaN(e.getTime())?null:Le(e,this._min,this._max)}_syncDisplay(){this.refs.input.value=this._value?A(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}},We=function(t,e={}){return new B(t,{...e,time:!0})};function mn(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function bl(i,t){let e=String(i||"%d.%m.%Y");return t&&!/%[HM]/.test(e)?`${e} %H:%M`:e}function yl(i){return i.replace(/%[demYyHMS]/g,t=>({"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY","%H":"HH","%M":"MM","%S":"SS"})[t]??t)}function bn(){gn("date",i=>new B(null,i)),gn("datetime",i=>We(null,i))}function gn(i,t){S.register(i,(e,s)=>{let r=e.own(t({...s.props??{},value:s.value}));return e.listen(r.el,"change",n=>n.stopImmediatePropagation()),r.on("change",n=>e.emit("change",{value:n.detail.date})),{el:r.el,get:()=>r.get(),set:n=>r.set(n,{silent:!0}),focus:()=>r.focus(),setDisabled:n=>n?r.disable():r.enable()}})}var $t=class extends _{static cssName="field-upload";static defaults={url:"",paramName:"upload",params:{},headers:{},multiple:!1,accept:null,maxSize:null,autoUpload:!0,preview:!0,http:null};render(){let t=this.el??a("div");this.el=t,this._ownedNodes=[],this._files=[],this._disabled=!1,this._running=!1,this._runId=0,this._xhr=null,this._transportController=null,this._previewUrl=null,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled");let e=y("zx-upload");return this._input=a("input",{class:"zx-field-upload__input",id:e,type:"file",multiple:!!this.options.multiple,accept:this.options.accept??void 0,tabIndex:-1}),this._dropzone=a("button",{class:"zx-field-upload__dropzone",type:"button",ariaControls:e,ariaLabel:this.options.multiple?"Choose files or drop them here":"Choose a file or drop it here"},a("span",{class:"zx-field-upload__prompt"},this.options.multiple?"Drop files here or choose files":"Drop a file here or choose a file"),a("span",{class:"zx-field-upload__hint"},xl(this.options))),this._preview=a("div",{class:"zx-field-upload__preview"}),this._progress=a("progress",{class:"zx-field-upload__progress",max:100,value:0,ariaLabel:"Upload progress"}),this._progressText=a("span",{class:"zx-field-upload__progress-text"},"0%"),this._abort=a("button",{class:"zx-btn zx-field-upload__abort",type:"button"},"Abort"),this._progressWrap=a("div",{class:"zx-field-upload__progress-wrap",hidden:!0},this._progress,this._progressText,this._abort),this._status=a("div",{class:"zx-field-upload__status",role:"status",ariaLive:"polite"}),this._ownedNodes.push(this._input,this._dropzone,this._preview,this._progressWrap,this._status),t.append(...this._ownedNodes),this.listen(this._dropzone,"click",()=>{!this._disabled&&!this._running&&this._input.click()}),this.listen(this._input,"change",()=>this._selectFiles(this._input.files)),this.listen(this._dropzone,"dragenter",s=>this._handleDragOver(s)),this.listen(this._dropzone,"dragover",s=>this._handleDragOver(s)),this.listen(this._dropzone,"dragleave",s=>{(!(s.relatedTarget instanceof Node)||!this._dropzone.contains(s.relatedTarget))&&this._setState("idle")}),this.listen(this._dropzone,"drop",s=>{s.preventDefault(),!(this._disabled||this._running)&&(this._setState("idle"),this._selectFiles(s.dataTransfer?.files??[]))}),this.listen(this._abort,"click",()=>this.abort()),this.setDisabled(!1),t}async upload(t=null){if(t!==null&&!this._setFiles(t)||this._disabled||this._running||this._files.length===0)return null;this._running=!0,this._runId+=1;let e=this._runId;this._setState("uploading"),this._progressWrap.hidden=!1,this._abort.hidden=!1,this._setProgress(0),this._status.textContent="Uploading\u2026";try{let s=this.options.http?await this._uploadInjected():await this._uploadXhr();return e!==this._runId?null:(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setProgress(100),this._setState("success"),this._status.textContent="Upload complete.",this.emit("success",{response:s}),s)}catch(s){if(e!==this._runId)return null;let r=s instanceof Error?s:new Error(String(s));return r.name==="AbortError"?(this._finishAbort(),null):(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("error"),this._status.textContent=r.message,this.emit("error",{error:r}),null)}}abort(){return this._running?(this._xhr?.abort(),this._transportController?.abort(),this._finishAbort(),this):this}clear(){return this._running&&this.abort(),this._files=[],this._input.value="",this._revokePreview(),this._preview.replaceChildren(),this._progress.value=0,this._progressText.textContent="0%",this._progressWrap.hidden=!0,this._status.textContent="",this._setState("idle"),this}setDisabled(t){return this._disabled=!!t,this._input.disabled=this._disabled,this._dropzone.disabled=this._disabled,this.el.dataset.disabled=String(this._disabled),this}_selectFiles(t){this._setFiles(t)&&(this._input.value="",this.options.autoUpload&&this.upload())}_setFiles(t){if(this._disabled||this._running)return!1;let e=Array.from(t??[]),s=this.options.multiple?e:e.slice(0,1);if(s.length===0)return!1;let r=s.find(o=>!wl(o,this.options.accept));if(r)return this._selectionError(new Error(`${r.name} is not an accepted file type.`)),!1;let n=this.options.maxSize==null?null:s.find(o=>o.size>Number(this.options.maxSize));return n?(this._selectionError(new Error(`${n.name} exceeds the maximum file size.`)),!1):(this._files=s,this._renderPreview(),this._status.textContent=s.map(o=>o.name).join(", "),this._setState("selected"),this.emit("select",{files:this._files.slice()}),!0)}_handleDragOver(t){t.preventDefault(),!this._disabled&&!this._running&&this._setState("dragover")}_uploadInjected(){let t=this.options.http;this._transportController=new AbortController;let e={files:this._files.slice(),paramName:String(this.options.paramName),params:{...this.options.params},headers:{...this.options.headers},signal:this._transportController.signal,onProgress:s=>this._setProgress(s)};return typeof t.upload=="function"?t.upload(String(this.options.url),e):typeof t.request=="function"?t.request(String(this.options.url),{method:"POST",data:e.params,files:e.files,headers:e.headers,signal:e.signal,onProgress:e.onProgress,paramName:e.paramName}):Promise.reject(new TypeError("Injected upload transport requires upload() or request()"))}_uploadXhr(){return typeof XMLHttpRequest!="function"?Promise.reject(new Error("XMLHttpRequest is not available")):new Promise((t,e)=>{let s=new XMLHttpRequest;this._xhr=s,s.open("POST",String(this.options.url));for(let[r,n]of Object.entries(this.options.headers??{}))s.setRequestHeader(r,String(n));this.listen(s.upload,"progress",r=>{r.lengthComputable&&this._setProgress(r.loaded/r.total*100)}),this.listen(s,"load",()=>{if(s.status<200||s.status>=300){e(new Error(`Upload failed with HTTP ${s.status}`));return}t(Al(s.responseText))}),this.listen(s,"error",()=>e(new Error("Upload request failed"))),this.listen(s,"abort",()=>e(kl())),s.send(Sl(this._files,String(this.options.paramName),this.options.params))})}_setProgress(t){let e=Math.max(0,Math.min(100,Number(t)||0));this._progress.value=e,this._progressText.textContent=`${Math.round(e)}%`,this.emit("progress",{percent:e})}_finishAbort(){this._running&&(this._runId+=1,this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("idle"),this._status.textContent="Upload aborted.",this.emit("abort",{}))}_selectionError(t){this._setState("error"),this._status.textContent=t.message,this.emit("error",{error:t})}_renderPreview(){this._revokePreview(),this._preview.replaceChildren();let t=this._files[0];!this.options.preview||!t?.type?.startsWith("image/")||typeof URL>"u"||typeof URL.createObjectURL!="function"||(this._previewUrl=URL.createObjectURL(t),this._preview.append(a("img",{class:"zx-field-upload__image",src:this._previewUrl,alt:`Preview of ${t.name}`})))}_revokePreview(){this._previewUrl&&typeof URL<"u"&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(this._previewUrl),this._previewUrl=null}_setState(t){t==="idle"?this.el.removeAttribute("data-state"):this.el.dataset.state=t}destroy(){this._running&&this.abort(),this._revokePreview();for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function xl(i){let t=[];return i.accept&&t.push(String(i.accept)),i.maxSize!=null&&t.push(`up to ${vl(Number(i.maxSize))}`),t.join(" \xB7 ")||"Choose from this device"}function vl(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/1024)} KB`:`${Math.round(i/(1024*1024))} MB`}function wl(i,t){if(!t)return!0;let e=String(i.type??"").toLowerCase();return String(t).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean).some(s=>s.startsWith(".")?i.name.toLowerCase().endsWith(s):s.endsWith("/*")?e.startsWith(s.slice(0,-1)):e===s)}function Sl(i,t,e){let s=new FormData;for(let r of i)s.append(t,r);for(let[r,n]of Object.entries(e??{}))yn(s,r,n);return s}function yn(i,t,e){if(e==null)return;if(Array.isArray(e)){for(let r of e)yn(i,t,r);return}typeof Blob=="function"&&e instanceof Blob?i.append(t,e):i.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function Al(i){if(!i)return null;try{return JSON.parse(i)}catch{return i}}function kl(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let i=new Error("Upload aborted");return i.name="AbortError",i}function xn(){S.register("upload",(i,t)=>{let e=i.own(new $t(null,{...t.props??{}}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("select",()=>i.emit("change",{value:null})),{el:e.el,get:()=>null,set:()=>e.clear(),focus:()=>e.el.querySelector(".zx-field-upload__dropzone")?.focus(),setDisabled:s=>e.setDisabled(s)}})}var vn=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),wn=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),Kt=class extends _{static cssName="multi-value-editor";static defaults={values:[],options:null,addLabel:"Add value",reorder:"both"};render(){let t=this.el??a("div");return this.el=t,this._values=Array.isArray(this.options.values)?this.options.values.map(String):[],this._ownedNodes=[],this._initialState=t.getAttribute("data-state"),this._dragIndex=-1,this._armed=null,this._rows=a("div",{class:"zx-multi-value-editor__rows"}),this._add=a("button",{class:"zx-btn zx-multi-value-editor__add",type:"button",dataset:{action:"add"}},String(this.options.addLabel??"Add value")),this._ownedNodes.push(this._rows,this._add),t.append(this._rows,this._add),this.listen(t,"click",e=>this._handleClick(e)),this.listen(this._rows,"change",e=>this._handleChange(e)),this.listen(this._rows,"keydown",e=>this._handleKeydown(e)),this._reorder().drag&&(this.listen(this._rows,"pointerdown",e=>this._handlePointerDown(e)),this.listen(this._rows,"dragstart",e=>this._handleDragStart(e)),this.listen(this._rows,"dragover",e=>this._handleDragOver(e)),this.listen(this._rows,"dragleave",e=>this._handleDragLeave(e)),this.listen(this._rows,"drop",e=>this._handleDrop(e)),this.listen(this._rows,"dragend",()=>this._finishDrag()),this.listen(document,"pointerup",()=>this._disarm()),this.listen(document,"pointercancel",()=>this._disarm())),this._renderRows(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=Array.isArray(t)?t.map(String):[],this._renderRows(),e||this.emit("change",{values:this.getValues()}),this}_reorder(){return vn[this.options.reorder]??vn.both}_renderRows(t=-1,e="value"){let s=Sn(this.options.options),r=this.options.options!==null,{drag:n,buttons:o}=this._reorder(),l=this._values.length-1,h=this._values.map((c,u)=>{let d=!r||s.some(([p])=>p===c)?s:[[c,c],...s],f=r?a("select",{class:"zx-multi-value-editor__value",ariaLabel:`Value ${u+1}`,dataset:{index:u}},d.map(([p,g])=>a("option",{value:p,selected:p===c},g))):a("input",{class:"zx-multi-value-editor__value",type:"text",value:c,ariaLabel:`Value ${u+1}`,dataset:{index:u}});return a("div",{class:"zx-multi-value-editor__row",dataset:{row:u}},n?a("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:`Reorder value ${u+1}. Use the arrow keys to move it.`,dataset:{action:"grab",index:u}},m("drag",{size:12})):null,f,a("div",{class:"zx-multi-value-editor__controls"},o?a("button",{class:"zx-btn",type:"button",ariaDisabled:String(u===0),ariaLabel:`Move value ${u+1} up`,dataset:{action:"up",index:u}},m("chevron-up",{size:12})):null,o?a("button",{class:"zx-btn",type:"button",ariaDisabled:String(u===l),ariaLabel:`Move value ${u+1} down`,dataset:{action:"down",index:u}},m("chevron-down",{size:12})):null,a("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${u+1}`,dataset:{action:"remove",index:u}},m("x",{size:12}))))});this._rows.replaceChildren(...h),t>=0&&h[Math.min(t,h.length-1)]?.querySelector(wn[e]??wn.value)?.focus()}_handleClick(t){let e=t.target instanceof Element?t.target.closest("[data-action]"):null;if(!e||!this.el.contains(e)||e.getAttribute("aria-disabled")==="true")return;let s=e.dataset.action,r=Number(e.dataset.index);if(s==="add"){let n=Sn(this.options.options);this._values.push(this.options.options===null?"":n[0]?.[0]??""),this._renderRows(this._values.length-1),this._emitChange()}else s==="remove"&&Number.isInteger(r)?(this._values.splice(r,1),this._renderRows(Math.min(r,this._values.length-1)),this._emitChange()):(s==="up"||s==="down")&&Number.isInteger(r)&&this._move(r,r+(s==="up"?-1:1),s)}_handleChange(t){let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e||!("value"in e))return;let s=Number(e.dataset.index);!Number.isInteger(s)||s<0||s>=this._values.length||(this._values[s]=e.value,this._emitChange())}_handleKeydown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(!e)return;let s=Number(e.dataset.index),r=t.key==="ArrowUp"?s-1:t.key==="ArrowDown"?s+1:t.key==="Home"?0:t.key==="End"?this._values.length-1:-1;r<0||r>=this._values.length||(t.preventDefault(),this._move(s,r,"handle"))}_handlePointerDown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(this._disarm(),!e||e.disabled)return;let s=e.closest(".zx-multi-value-editor__row");s&&(s.draggable=!0,this._armed=s)}_disarm(){this._armed&&(this._armed.draggable=!1),this._armed=null}_handleDragStart(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__row"):null;if(!e||e!==this._armed){t.preventDefault();return}this._dragIndex=Number(e.dataset.row),e.dataset.dragging="true",this.el.setAttribute("data-state","dragging"),t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move")}_handleDragOver(t){this._dragIndex<0||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._showDrop(this._dropTarget(t.clientY)))}_handleDragLeave(t){let e=t.relatedTarget;e instanceof Node&&this._rows.contains(e)||this._clearDrop()}_handleDrop(t){if(this._dragIndex<0)return;t.preventDefault();let e=this._dragIndex,s=this._dropTarget(t.clientY);this._finishDrag(),this._move(e,s>e?s-1:s,"handle")}_finishDrag(){this._dragIndex=-1,this._disarm(),this._clearDrop();for(let t of this._rows.children)delete t.dataset.dragging;this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_dropTarget(t){let e=[...this._rows.children];for(let[s,r]of e.entries()){let n=r.getBoundingClientRect();if(t<n.top+n.height/2)return s}return e.length}_showDrop(t){let e=[...this._rows.children],s=t===this._dragIndex||t===this._dragIndex+1;for(let[r,n]of e.entries()){let o=n;!s&&r===t?o.dataset.drop="before":!s&&t===e.length&&r===e.length-1?o.dataset.drop="after":delete o.dataset.drop}}_clearDrop(){for(let t of this._rows.children)delete t.dataset.drop}_move(t,e,s){let r=this._values.length;if(t===e||t<0||e<0||t>=r||e>=r)return!1;let[n]=this._values.splice(t,1);return this._values.splice(e,0,n),this._renderRows(e,s),this._emitChange(),!0}_emitChange(){this.emit("change",{values:this.getValues()})}destroy(){this._initialState===null?this.el?.removeAttribute("data-state"):this.el?.setAttribute("data-state",this._initialState);for(let t of this._ownedNodes??[])t.remove();super.destroy()}};function Sn(i){return Array.isArray(i)?i.map(t=>[String(t),String(t)]):i&&typeof i=="object"?Object.entries(i).map(([t,e])=>[t,String(e)]):[]}function An(){S.register("multivalueeditor",(i,t)=>{let e=i.own(new Kt(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]})),s=new WeakMap,r=!1,n=()=>{e.el.setAttribute("aria-disabled",String(r));for(let o of e.el.querySelectorAll("input, button, select, textarea"))r?(s.has(o)||s.set(o,!!o.disabled),o.disabled=!0):s.has(o)&&(o.disabled=s.get(o),s.delete(o))};return i.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>i.emit("change",{value:o.detail.values})),{el:e.el,get:()=>e.getValues(),set:o=>{e.setValues(Array.isArray(o)?o:[],{silent:!0}),n()},focus:()=>e.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),setDisabled:o=>{r=!!o,n()}}})}var mt=class extends _{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??a("div");this.el=t;let e=zl(this.options.step);this._step=e,this._precision=this.options.precision===null?Cl(e):Math.max(0,Math.trunc(Number(this.options.precision)||0));let s=this._stepButton("down","minus"),r=this._stepButton("up","plus"),n=a("input",{ref:"input",class:"zx-number-field__input",type:"text",role:"spinbutton",inputMode:this._precision>0?"decimal":"numeric",autocomplete:"off",spellcheck:!1,placeholder:String(this.options.placeholder??""),ariaLabel:this.options.label??void 0,name:this.options.name??void 0,required:!!this.options.required}),o=[s,n];return this.options.unit!==null&&o.push(a("span",{ref:"unit",class:"zx-number-field__unit",ariaHidden:"true"},String(this.options.unit))),o.push(r),t.replaceChildren(...o),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(n,"input",()=>this._onInput()),this.listen(n,"keydown",l=>this._onKeydown(l)),this.listen(n,"focus",()=>{this._editing=!0,this._syncInput()}),this.listen(n,"blur",()=>{this._commit(),this._editing=!1,this._syncInput()}),this.listen(s,"click",()=>this._stepBy(-1)),this.listen(r,"click",()=>this._stepBy(1)),this.listen(n,"wheel",l=>{document.activeElement!==n||this._disabled||this._readonly||(l.preventDefault(),this._stepBy(l.deltaY<0?1:-1))},{passive:!1}),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=this._coerce(t),r=s!==this._value;return this._value=s,this._syncInput(),r&&!e&&this.emit("change",{value:this._value}),this}stepUp(t=1){return this._stepBy(t)}stepDown(t=1){return this._stepBy(-t)}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}focus(){return this.refs.input.focus(),this}getInput(){return this.refs.input}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}setRange(t,e){return this._min=t==null?null:Number(t),this._max=e==null?null:Number(e),this.set(this._value,{silent:!0})}_stepButton(t,e){return a("button",{ref:t,class:"zx-number-field__step",type:"button",tabIndex:-1,ariaHidden:"true",dataset:{step:t}},m(e,{size:13}))}get _rangeMin(){return this._min!==void 0?this._min:this.options.min===null||this.options.min===void 0?null:Number(this.options.min)}get _rangeMax(){return this._max!==void 0?this._max:this.options.max===null||this.options.max===void 0?null:Number(this.options.max)}_coerce(t){let e=be(t,this.options.group?this._separators():null);return e===null?null:ye(e,{min:this._rangeMin,max:this._rangeMax,step:this._step,precision:this._precision})}_stepBy(t){if(this._disabled||this._readonly)return this;let e=this._rangeMin,s=this._rangeMax,n=be(this.refs.input.value)??this._value,o=n===null?e??0:n,l=n===null&&t>0&&e!==null?e-this._step*t:o,h=kn(l+this._step*t,this._precision);return this.options.wrap&&e!==null&&s!==null&&(h>s?h=e:h<e&&(h=s)),this.set(h),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=be(this.refs.input.value,this.options.group?this._separators():null);this._syncAria(t),this.emit("input",{value:t})}_onKeydown(t){if(this._disabled||this._readonly)return;let e=Math.max(1,Math.trunc(Number(this.options.largeStep)||1)),r={ArrowUp:()=>this._stepBy(1),ArrowDown:()=>this._stepBy(-1),PageUp:()=>this._stepBy(e),PageDown:()=>this._stepBy(-e),Home:()=>this._rangeMin===null?null:this.set(this._rangeMin),End:()=>this._rangeMax===null?null:this.set(this._rangeMax),Enter:()=>this._commit()}[t.key];r&&(t.key==="Home"&&this._rangeMin===null||t.key==="End"&&this._rangeMax===null||(t.preventDefault(),r()))}_commit(){this.set(this.refs.input.value)}_syncInput(){let t=this.refs.input,e=this._value===null?"":this._format(this._value,this._editing);t.value!==e&&(t.value=e),this._syncAria(this._value)}_syncAria(t){let e=this.refs.input,s=this._rangeMin,r=this._rangeMax;if(s===null?e.removeAttribute("aria-valuemin"):e.setAttribute("aria-valuemin",String(s)),r===null?e.removeAttribute("aria-valuemax"):e.setAttribute("aria-valuemax",String(r)),t===null)e.removeAttribute("aria-valuenow"),e.setAttribute("aria-valuetext",this._message("numberField.empty","Empty"));else{e.setAttribute("aria-valuenow",String(t));let n=this.options.unit===null?"":` ${this.options.unit}`;e.setAttribute("aria-valuetext",`${this._format(t,!1)}${n}`)}this.el.toggleAttribute("data-empty",t===null)}_format(t,e){return this.options.group?new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:this._precision,maximumFractionDigits:this._precision,useGrouping:!e}).format(t):t.toFixed(this._precision)}_message(t,e){let s=this.msg(t);return s===t?e:s}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.up.disabled=this._disabled||this._readonly,this.refs.down.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&z(t,this._snapshot)}};function be(i,t=null){if(typeof i=="number")return Number.isFinite(i)?i:null;if(i==null)return null;let e=String(i).trim();if(e==="")return null;let s;if(t)s=e.split(t.group).join("").replace(t.decimal,".").replace(/[^\d.\-+eE]/g,"");else{let n=e.replace(/[^\d,.\-+eE]/g,""),o=n.lastIndexOf(","),l=n.lastIndexOf(".");s=n,o>=0&&o>l?s=n.replace(/\./g,"").replace(",","."):o>=0&&(s=n.replace(/,/g,""))}if(!/\d/.test(s))return null;let r=Number(s);return Number.isFinite(r)?r:null}function ye(i,{min:t,max:e,step:s,precision:r}){let n=i;if(s>0){let o=t??0;n=o+Math.round((i-o)/s)*s}return n=kn(n,r),t!==null&&n<t?t:e!==null&&n>e?e:n}function zl(i){let t=Number(i);return Number.isFinite(t)&&t>0?t:1}function Cl(i){let t=String(i),e=t.match(/e-(\d+)/i);if(e)return Number(e[1]);let s=t.split(".")[1];return s?s.length:0}function kn(i,t){return Number.isFinite(i)?Number(i.toFixed(Math.min(15,Math.max(0,t)))):i}function zn(){S.register("number",(i,t)=>{let e=i.own(new mt(null,{label:t.label?String(t.label):void 0,placeholder:t.placeholder,required:t.required,...t.props??{}})),s=!1;return i.listen(e.el,"change",r=>r.stopImmediatePropagation()),e.on("change",r=>{s||i.emit("change",{value:r.detail.value})}),{el:e.el,get:()=>e.get(),set:r=>{s=!0;try{e.set(r===""||r===null||r===void 0?null:r,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}var Ut=class extends _{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??a("div");this.el=t,this._max=Math.max(1,Math.trunc(Number(this.options.max)||5)),this._step=this.options.allowHalf?.5:1,this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this._name=y("zx-rating");let e=a("div",{ref:"symbols",class:"zx-rating__symbols",role:"radiogroup",ariaLabel:String(this.options.label??"Rating")});for(let s=1;s<=this._max;s+=1){let r=a("span",{class:"zx-rating__symbol"},a("span",{class:"zx-rating__glyph",ariaHidden:"true"},m(this.options.icon,{size:xe[this.options.size]??xe.md})),a("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},m(this.options.icon,{size:xe[this.options.size]??xe.md})));this.options.allowHalf?r.append(this._radio(s-.5,"half"),this._radio(s,"full")):r.append(this._radio(s,"full")),e.append(r)}return t.replaceChildren(e,a("span",{ref:"readout",class:"zx-rating__readout"})),t.dataset.size=xe[this.options.size]?this.options.size:"md",this.listen(e,"keydown",s=>this._onKeydown(s)),this.listen(e,"pointerleave",()=>this._setPreview(null)),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=this._clamp(t),r=s!==this._value;return this._value=s,this._preview=null,this._sync(),r&&!e&&this.emit("change",{value:this._value}),this}clear({silent:t=!1}={}){return this.set(0,{silent:t})}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}setCount(t){return this._count=t,this._syncReadout(),this}focus(){return(this._radios.find(e=>e.tabIndex===0)??this._radios[0])?.focus(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}_radio(t,e){let s=a("button",{class:"zx-rating__radio",type:"button",role:"radio",tabIndex:-1,ariaChecked:"false",ariaLabel:this._stepLabel(t),dataset:{value:String(t),part:e}});return this.listen(s,"click",r=>{this._choose(t,r.detail>0)}),this.listen(s,"pointerenter",()=>this._setPreview(t)),this.listen(s,"focus",()=>this._setPreview(t)),this.listen(s,"blur",()=>this._setPreview(null)),this._radios.push(s),s}_stepLabel(t){let e=this.options.labels;if(Array.isArray(e)){let s=Math.round(t/this._step)-1;if(e[s]!=null)return String(e[s])}return this._message("rating.value","%1 of %2",[t,this._max])}_message(t,e,s){let r=this.msg(t,...s);return r===t?O(e,s):r}_choose(t,e){this._disabled||this._readonly||(e&&this.options.clearable&&t===this._value?this.set(0):this.set(t))}_onKeydown(t){if(this._disabled||this._readonly)return;let e=["ArrowRight","ArrowDown"],s=["ArrowLeft","ArrowUp"];if(e.includes(t.key))t.preventDefault(),this.set(this._value>=this._max?this._step:(this._value||0)+this._step);else if(s.includes(t.key))t.preventDefault(),this.set(this._value<=this._step?this._max:this._value-this._step);else if(t.key==="Home")t.preventDefault(),this.set(this._step);else if(t.key==="End")t.preventDefault(),this.set(this._max);else if((t.key==="Delete"||t.key==="Backspace")&&this.options.clearable)t.preventDefault(),this.set(0);else return;this.focus()}_setPreview(t){let e=this._disabled||this._readonly?null:t;e!==this._preview&&(this._preview=e,this._paint(),this.emit("hover",{value:this._preview}))}_clamp(t){let e=Number(t);if(!Number.isFinite(e)||e<=0)return 0;let s=Math.round(e/this._step)*this._step;return Math.min(this._max,Math.max(0,s))}_sync(){for(let e of this._radios){let s=Number(e.dataset.value);e.setAttribute("aria-checked",String(s===this._value))}let t=this._radios.find(e=>e.getAttribute("aria-checked")==="true");for(let e of this._radios)e.tabIndex=-1;(t??this._radios[0]).tabIndex=0,this._paint(),this._syncReadout()}_paint(){let t=this._preview??this._value;this.refs.symbols.querySelectorAll(".zx-rating__symbol").forEach((s,r)=>{let n=Math.min(1,Math.max(0,t-r));s.style.setProperty("--zx-rating-fill",`${n*100}%`),s.toggleAttribute("data-preview",this._preview!==null)}),this.el.dataset.value=String(t)}_syncReadout(){let t=this.refs.readout;if(!t)return;let e=this._count===void 0?this.options.count:this._count,s=[];this.options.showValue&&s.push(Tl(this._value,this._step)),e!=null&&s.push(this._message("rating.count","%1 ratings",[e])),t.textContent=s.join(" \xB7 ")}_syncDisabled(){let t=this._disabled||this._readonly;for(let e of this._radios)e.disabled=this._disabled;this.refs.symbols.setAttribute("aria-readonly",String(this._readonly)),this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this.el.toggleAttribute("data-inert",t),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&z(t,this._snapshot)}},xe={sm:14,md:18,lg:24};function Tl(i,t){return t<1?i.toFixed(1):String(i)}function Cn(){S.register("rating",(i,t)=>{let e=i.own(new Ut(null,{label:t.label?String(t.label):void 0,...t.props??{}})),s=!1;return e.on("change",r=>{s||i.emit("change",{value:r.detail.value})}),{el:e.el,get:()=>e.get()||null,set:r=>{s=!0;try{e.set(Number(r)||0,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}var El=["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 Ge(i){let t=!1,e=null;function s(r){if(r.key!=="Tab")return;let n=Tn(i);if(n.length===0){r.preventDefault();return}let o=n[0],l=n[n.length-1];r.shiftKey&&(document.activeElement===o||!i.contains(document.activeElement))?(r.preventDefault(),l.focus()):!r.shiftKey&&(document.activeElement===l||!i.contains(document.activeElement))&&(r.preventDefault(),o.focus())}return{activate(){t||(t=!0,e=document.activeElement,document.addEventListener("keydown",s),Tn(i)[0]?.focus())},deactivate(){t&&(t=!1,document.removeEventListener("keydown",s),e?.isConnected&&typeof e.focus=="function"&&e.focus(),e=null)}}}function rt(i,t,{orientation:e="vertical",wrap:s=!0}={}){let r=new AbortController,n=new Map,o=!1;function l(){return Array.from(i.querySelectorAll(t)).filter(p=>(h(p),En(p)))}function h(p){n.has(p)||n.set(p,p.getAttribute("tabindex"))}function c(p=null){let g=l(),x=p&&g.includes(p)?p:g.find(v=>v.tabIndex===0)??g[0];for(let v of g){let b=v===x?0:-1;v.tabIndex!==b&&(v.tabIndex=b)}}function u(p){let g=l(),x=p.target?.closest?.(t)??null,v=g.indexOf(x);if(v<0)return;let b=e==="horizontal"?"ArrowLeft":"ArrowUp",w=e==="horizontal"?"ArrowRight":"ArrowDown",E=null;p.key==="Home"?E=0:p.key==="End"?E=g.length-1:p.key===b?E=v-1:p.key===w&&(E=v+1),!(E===null||g.length===0)&&(s?E=(E+g.length)%g.length:E=Math.max(0,Math.min(g.length-1,E)),p.preventDefault(),c(g[E]),g[E].focus())}function d(p){let g=p.target?.closest?.(t)??null;g&&i.contains(g)&&c(g)}i.addEventListener("keydown",u,{signal:r.signal}),i.addEventListener("focusin",d,{signal:r.signal});let f=typeof MutationObserver=="function"?new MutationObserver(()=>c()):null;return f?.observe(i,{childList:!0,subtree:!0,attributes:!0}),c(),{focusFirst(){let p=l()[0];p&&(c(p),p.focus())},focusLast(){let p=l(),g=p[p.length-1];g&&(c(g),g.focus())},destroy(){if(!o){o=!0,r.abort(),f?.disconnect();for(let[p,g]of n)g===null?p.removeAttribute("tabindex"):p.setAttribute("tabindex",g);n.clear()}}}}function Y(i,t){let e="",s=null;return function(n){let o=typeof n=="string"?n:n.key;if(typeof n!="string"&&(n.ctrlKey||n.metaKey||n.altKey)||!o||o.length!==1||/\s/.test(o))return;s!==null&&clearTimeout(s),e+=o.toLocaleLowerCase(),e.split("").every(c=>c===e[0])&&(e=e[0]),s=setTimeout(()=>{e="",s=null},500);let l=i(),h=l.findIndex(c=>Dl(c).startsWith(e));h>=0&&t(l[h],h)}}function Tn(i){return Array.from(i.querySelectorAll(El)).filter(t=>En(t)&&t.getClientRects().length>0)}function En(i){return!(!(i instanceof HTMLElement)||i.hidden||i.getAttribute("aria-hidden")==="true"||i.matches(":disabled"))}function Dl(i){if(typeof i=="string"||typeof i=="number")return String(i).trim().toLocaleLowerCase();if(i&&typeof i=="object"&&"textContent"in i)return String(i.textContent??"").trim().toLocaleLowerCase();if(i&&typeof i=="object"){let t=i,e=t.label??t.text??t.value;if(e!=null)return String(e).trim().toLocaleLowerCase()}return String(i??"").trim().toLocaleLowerCase()}var Il=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],Nl=["Lowest","Low","Normal","High","Highest"],$=class i extends _{static cssName="select";static defaults={items:[],fixedItems:[],valueKey:"ID",labelKey:"name",renderItem:null,renderValue:null,value:null,disabled:!1,placeholder:"",clearable:!1,filter:!1,searchKeys:null,minQuery:0,debounce:200,listHeight:280,groupKey:null};render(){this._items=[],this._visibleItems=[],this._fixedItems=[],this._visibleFixed=[],this._selected=null,this._optionEntries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._createdRoot=!1,this._root=null,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let t=this.el??a("div");this.el=t,this._root=t,this._createdRoot||(this._originalChildren=Array.from(t.childNodes)),this._rememberAttribute(t,"data-state"),this._rememberAttribute(t,"data-loading"),this._rememberAttribute(t,"aria-disabled");let e=y("zx-select-list"),s=a("input",{ref:"input",class:"zx-select__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:this.options.filter?"list":"none",placeholder:String(this.options.placeholder??""),readOnly:!this.options.filter}),r=a("button",{ref:"clear",class:"zx-icon-btn zx-select__clear",type:"button",tabIndex:-1,ariaLabel:this._message("select.clear","Clear selection"),hidden:!0},m("x",{size:13})),n=a("span",{ref:"loading",class:"zx-select__loading",role:"status",ariaLabel:this._message("select.loading","Loading"),hidden:!0}),o=a("button",{ref:"toggle",class:"zx-select__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("select.toggle","Toggle options")},m("chevron-down",{size:16})),l=a("div",{ref:"control",class:"zx-select__control"},s,r,n,o),h=a("div",{ref:"list",class:"zx-select__list",id:e,role:"listbox"});h.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let c=a("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},h);return t.replaceChildren(l,c),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visibleItems=this._items.slice(),this._fixedItems=Array.isArray(this.options.fixedItems)?this.options.fixedItems.slice():[],this._visibleFixed=this._fixedItems.slice(),this._disabled=!!this.options.disabled,this._handleTypeahead=Y(()=>this._optionEntries.filter(u=>!u.clear).map(u=>u.element),(u,d)=>{this._open||this.open(),this._setActive(this._itemEntryIndex(d))}),this.listen(s,"click",()=>this.open()),this.listen(s,"input",()=>this._onInput()),this.listen(s,"keydown",u=>this._onKeydown(u)),this.listen(o,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(r,"click",()=>{this.set(null),this.focus()}),this.listen(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._renderOptions(),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._selected===null?null:this._itemValue(this._selected)}set value(t){this.set(t)}get selected(){return this._selected}set(t,{silent:e=!1}={}){let s=this.value,r=t==null?null:this._findItem(t);this._selected=r,this._syncInputValue(),this._renderOptions();let n=this.value;return!e&&!Object.is(s,n)&&this.emit("change",{value:n,item:r}),this}setItems(t){let e=this.value;return this._items=Array.isArray(t)?t.slice():[],this._visibleItems=this._items.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setFixedItems(t){let e=this.value;return this._fixedItems=Array.isArray(t)?t.slice():[],this._visibleFixed=this._fixedItems.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t}),this}open(){return this._disabled||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=V(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._selectedEntryIndex()),this._activeIndex<0&&this._optionEntries.length>0&&this._setActive(0),this.options.filter&&this._selected!==null&&this.refs.input.select(),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(""),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._setLoading(!1),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._visibleItems=this._items.slice(),this._visibleFixed=this._fixedItems.slice(),this._syncInputValue(),this.emit("close",{}),this):this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}static priority(t,e={}){let s=e.value??null,r=new i(t,{...e,value:null,items:[],renderItem(n){return a("span",{class:"zx-select__priority"},a("span",{class:"zx-select__priority-icon",dataset:{level:n.level},ariaHidden:"true"}),a("span",{},String(n.name)))}});return r.setItems(Il.map((n,o)=>({ID:o,name:r._message(n,Nl[o]),level:o}))),r.set(s,{silent:!0}),r}static permission(t,e={}){let{groups:s=[],value:r=!0,valueKey:n="ID",labelKey:o="name",...l}=e,h=typeof s=="function"?s:null,c=h?[]:s,u=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],d=new i(t,{filter:h??"local",...l,value:null,items:c,fixedItems:[],valueKey:f=>u.includes(f)?f.ID:vi(f,n),labelKey:f=>u.includes(f)?f.name:String(vi(f,o)??"")});return u[0].name=d._message("permission.private","Private"),u[1].name=d._message("permission.public","Public"),d.setFixedItems(u),d.set(r,{silent:!0}),d}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;if(!this._createdRoot&&t){t.replaceChildren(...this._originalChildren);for(let[e,s]of this._originalAttributes)s===null?t.removeAttribute(e):t.setAttribute(e,s)}super.destroy()}_onKeydown(t){if(!this._disabled){if(t.key==="ArrowDown"){t.preventDefault(),this._open?this._moveActive(1):this.open();return}if(t.key==="ArrowUp"){t.preventDefault(),this._open?this._moveActive(-1):(this.open(),this._setActive(this._optionEntries.length-1));return}if(t.key==="Home"&&this._open){t.preventDefault(),this._setActive(0);return}if(t.key==="End"&&this._open){t.preventDefault(),this._setActive(this._optionEntries.length-1);return}if(t.key==="Enter"&&this._open){t.preventDefault(),this._chooseEntry(this._optionEntries[this._activeIndex]);return}if(t.key==="Escape"&&this._open){t.preventDefault(),this.close();return}if(t.key==="Tab"&&this._open){this.close();return}!this.options.filter&&Ml(t)&&this._handleTypeahead(t)}}_onInput(){if(!this.options.filter)return;let t=this.refs.input.value;this._open||this.open(),this.options.filter==="local"?(this._visibleFixed=this._matchFixed(t),this._visibleItems=pt(this._items,t,this._searchKeys()),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update()):typeof this.options.filter=="function"&&this._scheduleAsyncQuery(t)}_onOptionClick(t){let e=t.target?.closest?.('[role="option"]');!e||!this.refs.panel.contains(e)||this._chooseEntry(this._optionEntries[Number(e.getAttribute("data-index"))])}_chooseEntry(t){t&&(this.set(t.clear?null:t.item),this.close(),this.focus())}_moveActive(t){let e=this._optionEntries.length;e!==0&&this._setActive((this._activeIndex+t+e)%e)}_setActive(t){this._activeIndex=t>=0&&t<this._optionEntries.length?t:-1,this._optionEntries.forEach((s,r)=>{r===this._activeIndex?s.element.setAttribute("data-active","true"):s.element.removeAttribute("data-active")});let e=this._optionEntries[this._activeIndex]?.element;e?(this.refs.input.setAttribute("aria-activedescendant",e.id),e.scrollIntoView?.({block:"nearest"})):this.refs.input.removeAttribute("aria-activedescendant")}_renderOptions(){let t=this.refs.list;if(!t)return;t.replaceChildren(),this._optionEntries=[];let e=Symbol("initial-group");this.options.clearable&&this._appendOption(null,!0,this.options.placeholder||this._message("select.none","No selection"));for(let s of this._visibleFixed)this._appendOption(s,!1);this._visibleFixed.length>0&&this._visibleItems.length>0&&!this.options.groupKey&&t.append(a("div",{class:"zx-select__separator",role:"presentation"}));for(let s of this._visibleItems){if(this.options.groupKey){let r=this._read(s,this.options.groupKey);Object.is(r,e)||(t.append(a("div",{class:"zx-select__group",role:"presentation"},String(r??""))),e=r)}this._appendOption(s,!1)}this._visibleItems.length===0&&this._visibleFixed.length===0&&!this._loading&&t.append(a("div",{class:"zx-select__empty",role:"status"},this._message("select.empty","No matches"))),this._setActive(-1)}_appendOption(t,e,s){let r=e?this._selected===null:this._selected!==null&&Object.is(this._itemValue(t),this.value),n=this._optionEntries.length,o=e?String(s??""):this._renderItem(t),l=a("div",{class:"zx-select__option",id:y("zx-select-option"),role:"option",ariaSelected:String(r),dataset:{index:n}},a("span",{class:"zx-select__option-content"},o));r&&l.append(m("check",{size:15})),this.refs.list.append(l),this._optionEntries.push({item:t,clear:e,element:l})}_renderItem(t){if(typeof this.options.renderItem=="function"){let e=this.options.renderItem(t);return e&&typeof e=="object"&&"nodeType"in e?e:String(e??"")}return this._itemLabel(t)}_scheduleAsyncQuery(t){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._requestSequence+=1;let e=this._requestSequence;if(this._visibleFixed=this._matchFixed(t),t.length<Math.max(0,Number(this.options.minQuery)||0)){this._setLoading(!1),this._visibleItems=[],this._renderOptions();return}this._setLoading(!0),this._renderOptions(),this._position?.update();let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runAsyncQuery(t,e)},s)}async _runAsyncQuery(t,e){if(!(e!==this._requestSequence||typeof this.options.filter!="function")){this.emit("query",{query:t});try{let s=await this.options.filter(t);if(e!==this._requestSequence||!this._open)return;this._items=Array.isArray(s)?s.slice():[],this._visibleItems=this._items.slice(),this._setLoading(!1),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update(),this.emit("loaded",{items:this._items.slice()})}catch{if(e!==this._requestSequence||!this._open)return;this._items=[],this._visibleItems=[],this._setLoading(!1),this._renderOptions(),this._position?.update()}}}_cancelQuery(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._requestSequence+=1}_setLoading(t){this._loading=t,this.refs.loading.hidden=!t,this.refs.input.setAttribute("aria-busy",String(t)),this.refs.list.setAttribute("aria-busy",String(t)),t?this._root?.setAttribute("data-loading","true"):this._root?.removeAttribute("data-loading")}_syncInputValue(){if(!this.refs.input)return;let t=this.refs.input;t.value=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),this.refs.clear.hidden=!this.options.clearable||this._selected===null}_syncDisabled(){let t=this.refs.input,e=this.refs.clear,s=this.refs.toggle;t.disabled=this._disabled,e.disabled=this._disabled,s.disabled=this._disabled,this._root?.setAttribute("aria-disabled",String(this._disabled))}_findItem(t){let e=this._fixedItems.length===0?this._items:[...this._fixedItems,...this._items],s=e.find(n=>n===t);if(s!==void 0)return s;let r=t!==null&&typeof t=="object"?this._itemValue(t):t;return e.find(n=>Object.is(this._itemValue(n),r))??null}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){let e=this._read(t,this.options.labelKey);return String(e??"")}_read(t,e){return vi(t,e)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(t){return pt(this._fixedItems,t,this._searchKeys())}_selectedEntryIndex(){return this._selected===null?this.options.clearable?0:-1:this._optionEntries.findIndex(t=>!t.clear&&Object.is(this._itemValue(t.item),this.value))}_itemEntryIndex(t){return t+(this.options.clearable?1:0)}_rememberAttribute(t,e){this._originalAttributes.set(e,t.getAttribute(e))}_message(t,e){let s=this.msg(t);return s===t?e:s}};function vi(i,t){return typeof t=="function"?t(i):i===null||typeof i!="object"?i:i[t]}function Ml(i){return i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey}function Dn(){S.register("zxselect",(i,t)=>{let e=i.own(new $(null,{...t.props??{},value:t.value}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:s.detail.value})),{el:e.el,get:()=>e.value,set:s=>e.set(s,{silent:!0}),focus:()=>e.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var Yt=class extends _{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??a("div");this.el=t,this._min=Number(this.options.min)||0,this._max=Number(this.options.max),(!Number.isFinite(this._max)||this._max<=this._min)&&(this._max=this._min+100),this._step=Math.abs(Number(this.options.step))||1,this._id=y("zx-slider");let e=a("input",{ref:"input",class:"zx-slider__input",type:"range",id:this._id,min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled}),s=a("div",{class:"zx-slider__track"},e,this._marks()),r=a("div",{class:"zx-slider__control"});return this.options.showBounds&&r.append(a("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._min))),r.append(s),this.options.showBounds&&r.append(a("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._max))),this.options.showInput&&r.append(this._numberBox()),t.replaceChildren(a("div",{class:"zx-slider__head"},a("label",{ref:"label",class:"zx-slider__label",for:this._id},String(this.options.label??"")),a("span",{ref:"output",class:"zx-slider__value",ariaHidden:"true"})),r),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(e,"input",()=>this._onInput()),this.listen(e,"change",()=>this._onCommit()),this.listen(e,"keydown",n=>{this._readonly&&Ol.has(n.key)&&n.preventDefault()}),this.set(this.options.value,{silent:!0}),this._syncState(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=this._snap(t),r=s!==this._value;return this._value=s,this._paint(),r&&!e&&this.emit("change",{value:s}),this}setRange(t,e,s){let r=Number(t),n=Number(e);if(!Number.isFinite(r)||!Number.isFinite(n)||n<=r)throw new RangeError("Slider range requires min < max");this._min=r,this._max=n,s!==void 0&&(this._step=Math.abs(Number(s))||1);let{input:o}=this.refs;o.min=String(this._min),o.max=String(this._max),o.step=String(this._step);for(let[l,h]of[...this.el.querySelectorAll(".zx-slider__bound")].entries())h.textContent=this._format(l===0?this._min:this._max);return this.set(this._value,{silent:!0})}focus(){return this.refs.input.focus(),this}enable(){return this.refs.input.disabled=!1,this.refs.number&&(this.refs.number.disabled=!1),this._syncState(),this}disable(){return this.refs.input.disabled=!0,this.refs.number&&(this.refs.number.disabled=!0),this._syncState(),this}setReadonly(t){return this._readonly=!!t,this.refs.number&&(this.refs.number.readOnly=this._readonly),this._syncState(),this}setLabel(t){return this.refs.label.textContent=String(t??""),this}_numberBox(){let t=a("input",{ref:"number",class:"zx-slider__number",type:"number",min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled,readOnly:this._readonly,ariaLabel:String(this.options.label??"Value")});return this.listen(t,"input",()=>{if(this._readonly)return;let e=Number(t.value);t.value===""||!Number.isFinite(e)||(this._value=this._snap(e),this.refs.input.value=String(this._value),this._paintTrack(),this.emit("input",{value:this._value}))}),this.listen(t,"change",()=>{if(this._readonly){t.value=String(this._value);return}this.set(t.value===""?this._min:Number(t.value))}),t}_marks(){let t=this.options.marks;if(!Array.isArray(t)||t.length===0)return null;let e=a("div",{class:"zx-slider__marks",ariaHidden:"true"});for(let s of t){let r=typeof s=="number"?s:Number(s?.value);if(!Number.isFinite(r))continue;let n=typeof s=="number"?this._format(r):String(s.label??this._format(r));e.append(a("span",{class:"zx-slider__mark",style:{"--zx-slider-mark":`${this._ratio(r)*100}%`}},n))}return e}_onInput(){if(this._readonly){this.refs.input.value=String(this._value);return}this._value=this._snap(this.refs.input.value),this._paintTrack(),this.refs.number&&(this.refs.number.value=String(this._value)),this.emit("input",{value:this._value})}_onCommit(){if(this._readonly){this.refs.input.value=String(this._value);return}this.emit("change",{value:this._value})}_paint(){this.refs.input.value=String(this._value),this.refs.number&&(this.refs.number.value=String(this._value)),this._paintTrack()}_paintTrack(){this.el.style.setProperty("--zx-slider-fill",`${this._ratio(this._value)*100}%`);let{output:t}=this.refs;t.textContent=this.options.showValue?this._format(this._value):""}_syncState(){let t=this.refs.input.disabled;this.el.toggleAttribute("data-disabled",t),this.el.toggleAttribute("data-readonly",this._readonly),this.refs.input.setAttribute("aria-readonly",String(this._readonly))}_snap(t){let e=Number(t);return Number.isFinite(e)?ye(e,{min:this._min,max:this._max,step:this._step,precision:wi(this._step)}):this._min}_ratio(t){return N((t-this._min)/(this._max-this._min),0,1)}_format(t){let e=this.options.formatValue;return typeof e=="function"?String(e(t)):`${Fl(t)}${this.options.unit??""}`}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&z(t,this._snapshot)}},Ol=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function wi(i){let t=String(i),e=/e-(\d+)$/i.exec(t);return e?Number(e[1]):(t.split(".")[1]??"").length}function Fl(i){return String(Number(i.toFixed(6)))}function In(){S.register("slider",(i,t)=>{let e=i.own(new Yt(null,{label:t.label?String(t.label):void 0,hideLabel:!0,disabled:!!t.disabled,...t.props??{}})),s=!1;return e.on("change",r=>{s||i.emit("change",{value:r.detail.value})}),{el:e.el,get:()=>e.get(),set:r=>{s=!0;try{e.set(Number(r)||0,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}var Wt=class extends _{static cssName="tag-picker";static defaults={items:[],values:[],valueKey:"ID",labelKey:"name",searchKeys:null,filter:"local",minQuery:0,debounce:200,allowCreate:!1,max:null,closeOnSelect:!1,placeholder:"",listHeight:260,disabled:!1,readonly:!1,renderItem:null,renderTag:null};render(){this._items=[],this._selected=[],this._visible=[],this._entries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._readonly=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._activeId=null,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:k(this.el);let t=this.el??a("div");this.el=t;let e=y("zx-tag-picker-list"),s=a("span",{ref:"tags",class:"zx-tag-picker__tags"}),r=a("input",{ref:"input",class:"zx-tag-picker__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:"list",ariaLabel:this._message("tagPicker.input","Add a value"),placeholder:String(this.options.placeholder??"")}),n=a("button",{ref:"toggle",class:"zx-tag-picker__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("tagPicker.toggle","Toggle options")},m("chevron-down",{size:15})),o=a("div",{ref:"control",class:"zx-tag-picker__control"},s,r,n),l=a("div",{ref:"list",class:"zx-tag-picker__list",id:e,role:"listbox",ariaMultiSelectable:"true"});l.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let h=a("div",{ref:"panel",class:"zx-tag-picker__panel",popover:"manual"},l);return t.replaceChildren(o,h),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",c=>{let u=c.target;u.closest(".zx-tag-picker__remove")||u.closest(".zx-tag-picker__toggle")||(c.target!==r&&(c.preventDefault(),this.focus()),this._open||this.open())}),this.listen(s,"click",c=>{let u=c.target.closest(".zx-tag-picker__remove");if(!u||this._disabled||this._readonly)return;c.stopPropagation();let d=[...s.children].indexOf(u.closest(".zx-tag-picker__tag")),f=this._selected[d];f!==void 0&&(this.removeValue(this._valueOf(f)),this.focus())}),this.listen(r,"input",()=>this._onInput()),this.listen(r,"keydown",c=>this._onKeydown(c)),this.listen(r,"blur",()=>this.el.removeAttribute("data-focus")),this.listen(r,"focus",()=>this.el.setAttribute("data-focus","")),this.listen(n,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(h,"pointerdown",c=>c.preventDefault()),this.listen(h,"click",c=>this._onOptionClick(c)),this.listen(document,"pointerdown",c=>{this._open&&!t.contains(c.target)&&this.close()},{capture:!0}),this.setValues(this.options.values,{silent:!0}),this._syncDisabled(),t}get values(){return this.getValues()}set values(t){this.setValues(t)}getValues(){return this._selected.map(t=>this._valueOf(t))}getItems(){return this._selected.slice()}setValues(t,{silent:e=!1}={}){let s=Array.isArray(t)?t:[],r=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),n=[];for(let l of s){if(n.length>=r)break;let h=this._resolve(l);h!==null&&!n.some(c=>this._sameValue(c,h))&&n.push(h)}let o=!Ll(n,this._selected,l=>this._valueOf(l));return this._selected=n,this._renderTags(),this._renderOptions(),o&&!e&&this._emitChange(),this}addValue(t,{silent:e=!1}={}){if(this.isFull())return this;let s=this._resolve(t);return s===null?this:this._selected.some(r=>this._sameValue(r,s))?this:(this._selected.push(s),this._renderTags(),this._renderOptions(),e||(this.emit("add",{value:this._valueOf(s),item:s}),this._emitChange()),this)}removeValue(t,{silent:e=!1}={}){let s=this._valueOf(this._resolve(t)??t),r=this._selected.findIndex(o=>Object.is(this._valueOf(o),s));if(r<0)return this;let[n]=this._selected.splice(r,1);return this._renderTags(),this._renderOptions(),e||(this.emit("remove",{value:this._valueOf(n),item:n}),this._emitChange()),this}clear({silent:t=!1}={}){return this.setValues([],{silent:t})}reset({silent:t=!1}={}){return this.setValues(this.options.values,{silent:t})}setItems(t){return this._cancelQuery(),this._items=Array.isArray(t)?t.slice():[],typeof this.options.filter=="function"?this._visible=this._items.slice():this._applyLocalFilter(this.refs.input.value),this._renderOptions(),this._position?.update(),this}isFull(){let t=this.options.max;return t!=null&&this._selected.length>=Number(t)}open(){return this._disabled||this._readonly||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=V(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&&z(t,this._snapshot)}_renderTags(){let t=this._selected.map(e=>{let s=this._labelOf(e),r=this.options.renderTag?this.options.renderTag(e):s,n=a("span",{class:"zx-tag-picker__tag"},a("span",{class:"zx-tag-picker__tag-label"},r));return!this._readonly&&!this._disabled&&n.append(a("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[s])},m("x",{size:11}))),n});this.refs.tags.replaceChildren(...t),this.el.toggleAttribute("data-empty",this._selected.length===0),this._syncPlaceholder()}_renderOptions(){let t=this.refs.list;this._entries=[];let e=[];for(let n of this._visible){let o=this._valueOf(n),l=this._isSelected(o),h=a("div",{class:"zx-tag-picker__option",id:y("zx-tag-picker-option"),role:"option",ariaSelected:String(l)},a("span",{class:"zx-tag-picker__check",ariaHidden:"true"},l?m("check",{size:13}):null),a("span",{class:"zx-tag-picker__option-label"},this.options.renderItem?this.options.renderItem(n):this._labelOf(n)));!l&&this.isFull()&&h.setAttribute("aria-disabled","true"),this._entries.push({item:n,element:h,create:!1}),e.push(h)}let s=this.refs.input.value.trim();if(this._canCreate(s)){let n=a("div",{class:"zx-tag-picker__option",id:y("zx-tag-picker-option"),role:"option",ariaSelected:"false",dataset:{create:"true"}},a("span",{class:"zx-tag-picker__check",ariaHidden:"true"},m("plus",{size:13})),a("span",{class:"zx-tag-picker__option-label"},this._message("tagPicker.create","Create \u201C%1\u201D",[s])));this._entries.push({item:null,element:n,create:!0}),e.push(n)}e.length===0&&e.push(a("div",{class:"zx-tag-picker__empty"},this._loading?this._message("tagPicker.loading","Loading\u2026"):this._message("tagPicker.empty","No matches"))),t.replaceChildren(...e);let r=this._entries.findIndex(n=>this._entryId(n)===this._activeId);this._setActive(r>=0?r:this._entries.length>0?0:-1)}_entryId(t){return t.create?"\0create":String(this._valueOf(t.item))}_syncPlaceholder(){let t=this.refs.input;t.placeholder=this._selected.length===0?String(this.options.placeholder??""):""}_onInput(){let t=this.refs.input.value;this._syncInputWidth(),this._open||this.open(),typeof this.options.filter=="function"?this._scheduleAsyncQuery(t):this._applyLocalFilter(t),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update()}_onKeydown(t){if(this._disabled||this._readonly)return;let e=this.refs.input;switch(t.key){case"ArrowDown":t.preventDefault(),this._open?this._move(1):this.open();return;case"ArrowUp":t.preventDefault(),this._open&&this._move(-1);return;case"Home":this._open&&e.value===""&&(t.preventDefault(),this._setActive(0));return;case"End":this._open&&e.value===""&&(t.preventDefault(),this._setActive(this._entries.length-1));return;case"Enter":{if(!this._open||this._activeIndex<0)return;t.preventDefault(),this._commitEntry(this._entries[this._activeIndex]);return}case"Escape":this._open&&(t.preventDefault(),this.close());return;case"Backspace":e.value===""&&this._selected.length>0&&(t.preventDefault(),this.removeValue(this._valueOf(this._selected[this._selected.length-1])));return;case"Tab":this._open&&this.close();return;default:}}_onOptionClick(t){let e=t.target.closest(".zx-tag-picker__option");if(!e)return;let s=this._entries.find(r=>r.element===e);s&&this._commitEntry(s)}_commitEntry(t){if(!t)return;let e=this.refs.input;if(t.create){let s=e.value.trim(),r=this._createItem(s);this._items=this._items.concat([r]),this.addValue(r),this.emit("create",{value:this._valueOf(r),item:r})}else{let s=this._valueOf(t.item);if(this._isSelected(s))this.removeValue(s);else if(!this.isFull())this.addValue(t.item);else return}e.value="",this._syncInputWidth(),this._applyLocalFilter(""),this._renderOptions(),this.options.closeOnSelect?this.close():(this._setActive(this._entries.length>0?0:-1),this._position?.update()),this.focus()}_move(t){if(this._entries.length===0)return;let e=this._activeIndex<0?t>0?0:this._entries.length-1:Math.min(this._entries.length-1,Math.max(0,this._activeIndex+t));this._setActive(e)}_setActive(t){this._activeIndex=t,this._activeId=this._entries[t]?this._entryId(this._entries[t]):null;for(let[e,s]of this._entries.entries()){let r=e===t;s.element.toggleAttribute("data-active",r),r&&(this.refs.input.setAttribute("aria-activedescendant",s.element.id),s.element.scrollIntoView({block:"nearest"}))}t<0&&this.refs.input.removeAttribute("aria-activedescendant")}_applyLocalFilter(t){if(typeof this.options.filter=="function")return;let e=this.options.searchKeys??[this.options.labelKey];this._visible=pt(this._items,t,e)}_scheduleAsyncQuery(t){this._cancelQuery();let e=String(t??"");if(e.length<Number(this.options.minQuery??0)){this._visible=[],this._renderOptions();return}this._visible=[],this._setLoading(!0),this._renderOptions();let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runQuery(e)},s)}async _runQuery(t){let e=this._requestSequence+1;this._requestSequence=e,this._setLoading(!0),this.emit("query",{query:t});try{let s=await this.options.filter(t);if(e!==this._requestSequence)return;this._items=Array.isArray(s)?s.slice():[],this._visible=this._items.slice()}catch(s){if(e!==this._requestSequence)return;this._visible=[],this.emit("error",{error:s})}finally{e===this._requestSequence&&(this._setLoading(!1),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update())}}_cancelQuery(){this._queryTimer!==null&&(clearTimeout(this._queryTimer),this._queryTimer=null),this._requestSequence+=1,this._setLoading(!1)}_setLoading(t){this._loading=t,this.el.toggleAttribute("data-loading",t)}_isSelected(t){return this._selected.some(e=>Object.is(this._valueOf(e),t))}_canCreate(t){if(!this.options.allowCreate||t===""||this.isFull())return!1;let e=s=>s.some(r=>Nn(this._labelOf(r))===Nn(t));return!e(this._items)&&!e(this._selected)}_createItem(t,e=t){return typeof this.options.valueKey!="string"||typeof this.options.labelKey!="string"?t:{[this.options.valueKey]:e,[this.options.labelKey]:t,created:!0}}_resolve(t){if(t==null)return null;let e=this._valueOf(t),s=this._items.find(n=>Object.is(this._valueOf(n),e));if(s!==void 0)return s;let r=this._selected.find(n=>Object.is(this._valueOf(n),e));return r!==void 0?r:typeof t=="object"?t:this._createItem(String(t),t)}_sameValue(t,e){return Object.is(this._valueOf(t),this._valueOf(e))}_valueOf(t){let e=this.options.valueKey;return typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]:t}_labelOf(t){let e=this.options.labelKey;return String(typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]??"":t??"")}_emitChange(){this.emit("change",{values:this.getValues(),items:this.getItems()})}_syncInputWidth(){let t=this.refs.input,e=t.value.length;t.style.inlineSize=e===0?"":`${Math.min(40,e+1)}ch`}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.toggle.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}_message(t,e,s=[]){let r=this.msg(t,...s);return r!==t?r:s.reduce((n,o,l)=>n.replaceAll(`%${l+1}`,String(o)),e)}};function Nn(i){return String(i??"").trim().toLocaleLowerCase()}function Ll(i,t,e){return i.length!==t.length?!1:i.every((s,r)=>Object.is(e(s),e(t[r])))}function Mn(){S.register("tagpicker",(i,t)=>{let e=i.own(new Wt(null,{placeholder:t.placeholder,...t.props??{}})),s=!1;return i.listen(e.el,"change",r=>r.stopImmediatePropagation()),e.on("change",r=>{s||i.emit("change",{value:r.detail.values})}),{el:e.el,get:()=>e.getValues(),set:r=>{s=!0;try{e.setValues(Array.isArray(r)?r:[],{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:r=>r?e.disable():e.enable()}})}function Si(i,t="minutes"){let e=Math.round(Math.abs(On(kt(i),t)));return{hours:Math.floor(e/3600),minutes:Math.floor(e/60)%60,seconds:e%60,negative:kt(i)<0}}function Ai(i,t="minutes"){ve(t);let e=Math.abs(Math.trunc(kt(i?.hours))),s=Math.abs(Math.trunc(kt(i?.minutes))),r=Math.abs(Math.trunc(kt(i?.seconds))),n=i?.negative?-1:1;return Fn(n*(e*3600+s*60+r),t)}var nt=class extends _{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){ve(this.options.unit);let t=this.el??a("div");this.el=t,this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._disabled=!!this.options.disabled,this._parts={hours:0,minutes:0,seconds:0,negative:!1},this._inputs=[];let e=a("div",{class:"zx-timebox__content",role:"group",ariaLabel:this.options.seconds?"Duration in hours, minutes, and seconds":"Duration in hours and minutes"});return this._content=e,this.options.signed&&(e.append(a("button",{ref:"sign",class:"zx-timebox__sign",type:"button",ariaLabel:"Toggle duration sign",ariaPressed:"false"},"+")),this.listen(this.refs.sign,"click",()=>{this._disabled||(this._parts.negative=!this._parts.negative,this._writeParts(),this._emitChange())})),this._addSegment(e,"hours","Hours",!1),e.append(a("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"minutes","Minutes",!0),this.options.seconds&&(e.append(a("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"seconds","Seconds",!0)),t.append(e),this.set(this.options.value,this.options.unit,{silent:!0}),this._syncDisabled(),t}get(t=this.options.unit){return Ai(this._readParts(),t)}set(t,e=this.options.unit,s={}){e&&typeof e=="object"&&(s=e,e=this.options.unit),ve(e);let r=kt(t);return!this.options.signed&&r<0&&(r=0),this.options.seconds||(r=Fn(Math.round(On(r,e)/60)*60,e)),this._parts=Si(r,e),this.options.signed||(this._parts.negative=!1),this._writeParts(),s.silent||this._emitChange(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}destroy(){this._content?.remove(),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_addSegment(t,e,s,r){let n=a("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:s,maxLength:r?2:null,dataset:{segment:e,bounded:String(r)}});this._inputs.push(n),t.append(n),this.listen(n,"focus",()=>n.select()),this.listen(n,"input",()=>{e==="hours"&&this.options.signed&&n.value.trim().startsWith("-")&&(this._parts.negative=!0);let o=n.value.replace(/\D/g,"");n.value=r?o.slice(0,2):o}),this.listen(n,"change",()=>this._commitSegments()),this.listen(n,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this._commitSegments(),n.select())})}_readParts(){let t={...this._parts};for(let e of this._inputs){let s=e.dataset.segment,r=e.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;t[s]=Math.max(0,Math.min(r,Math.trunc(kt(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]):Rl(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 kt(i){let t=Number(i);return Number.isFinite(t)?t:0}function On(i,t){return ve(t),t==="hours"?i*3600:t==="minutes"?i*60:i}function Fn(i,t){return ve(t),t==="hours"?i/3600:t==="minutes"?i/60:i}function ve(i){if(i!=="hours"&&i!=="minutes"&&i!=="seconds")throw new RangeError(`Unknown time unit: ${i}`)}function Rl(i){return String(i).padStart(2,"0")}function Ln(){S.register("time",(i,t)=>{let e=i.own(new nt(null,{...t.props??{},value:t.value}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:s.detail.value})),{el:e.el,get:()=>e.get(),set:s=>e.set(Number(s)||0,{silent:!0}),focus:()=>e.el.querySelector("input:not([disabled]), button:not([disabled])")?.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var K=class extends _{static cssName="toggle";static defaults={checked:!1,value:!0,label:null,disabled:!1};render(){let t=!this.el,e=this.el??a("button");if(this.el=e,e.localName!=="button")throw new TypeError("Toggle target must be a button element");this._createdRoot=t,this._original=t?null:Pl(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,e.type="button",e.setAttribute("role","switch");let s=[a("span",{class:"zx-toggle__track",ariaHidden:"true"},a("span",{class:"zx-toggle__thumb"}))];return this.options.label!==null&&s.push(a("span",{class:"zx-toggle__label"},String(this.options.label))),e.replaceChildren(...s),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let s=!!t;return s===this._checked?this:(this._checked=s,this._sync(),e||this.emit("change",{checked:this._checked,value:this.getValue()}),this)}toggle(){return this.set(!this._checked)}getValue(){return this._checked?this.options.value:!1}enable(){return this._disabled=!1,this.el.removeAttribute("disabled"),this}disable(){return this._disabled=!0,this.el.setAttribute("disabled",""),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&Bl(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function Pl(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Bl(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function Rn(){S.register("toggle",(i,t)=>{let e=i.own(new K(null,{...t.props??{},checked:!!t.value}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:s.detail.value})),{el:e.el,get:()=>e.getValue(),set:s=>e.set(!!s,{silent:!0}),focus:()=>e.el.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var Gt=class extends _{static cssName="value-list";static defaults={values:[],placeholder:"",deletable:!0,sortable:!0,unique:!0,validate:null};render(){let t=this.el??a("div");this._ownedNodes=[],this._disabled=!1,this._dragIndex=-1,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled"),this._values=Pn(this.options.values,!!this.options.unique);let e=y("zx-value-list-instructions");return this._list=a("ul",{class:"zx-value-list__list",role:"listbox",ariaLabel:"Values",ariaOrientation:"horizontal"}),this._input=a("input",{class:"zx-value-list__input",type:"text",placeholder:String(this.options.placeholder??""),ariaLabel:"Add value",ariaDescribedby:e}),this._status=a("div",{class:"zx-value-list__status",role:"status",ariaLive:"polite"}),this._instructions=a("span",{class:"zx-value-list__instructions",id:e},"Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder."),this._ownedNodes.push(this._list,this._input,this._status,this._instructions),t.append(this._list,this._input,this._status,this._instructions),this.listen(this._input,"keydown",s=>this._handleInputKeydown(s)),this.listen(this._list,"keydown",s=>this._handleChipKeydown(s)),this.listen(this._list,"click",s=>this._handleChipClick(s)),this.listen(this._list,"dragstart",s=>this._handleDragStart(s)),this.listen(this._list,"dragover",s=>{this._dragIndex>=0&&!this._disabled&&s.preventDefault()}),this.listen(this._list,"drop",s=>this._handleDrop(s)),this.listen(this._list,"dragend",()=>this._finishDrag()),this.listen(t,"click",s=>{s.target===t&&!this._disabled&&this.focus()}),this._renderChips(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=Pn(t,!!this.options.unique),this._renderChips(),e||this.emit("change",{values:this.getValues()}),this}addValue(t){if(this._disabled)return!1;let e=String(t??"").trim();if(!e)return!1;if(this.options.unique&&this._values.includes(e))return this._showError("This value already exists."),!1;if(typeof this.options.validate=="function"){let s=this.options.validate(e);if(s!==!0)return this._showError(typeof s=="string"?s:"This value is not valid."),!1}return this._status.textContent="",this._input.removeAttribute("aria-invalid"),this._values.push(e),this._renderChips(),this.emit("add",{value:e}),this.emit("change",{values:this.getValues()}),!0}removeValue(t){if(this._disabled||!this.options.deletable)return!1;let e=this._values.indexOf(String(t));return e<0?!1:(this._removeAt(e),!0)}focus(){return this._input.focus(),this}enable(){return this._disabled=!1,this._input.disabled=!1,this.el.dataset.disabled="false",this._renderChips(),this}disable(){return this._disabled=!0,this._input.disabled=!0,this.el.dataset.disabled="true",this._renderChips(),this}_renderChips(t=-1){let e=this._values.map((s,r)=>a("li",{class:"zx-value-list__chip",role:"option",tabIndex:this._disabled?-1:0,draggable:!!this.options.sortable&&!this._disabled,ariaSelected:"false",ariaDisabled:String(this._disabled),ariaLabel:this.options.deletable?`${s}. Press Delete to remove.`:s,dataset:{index:r}},a("span",{class:"zx-value-list__value"},s),this.options.deletable?a("span",{class:"zx-value-list__remove",dataset:{remove:""},ariaHidden:"true"},"\xD7"):null));this._list.replaceChildren(...e),t>=0&&e[Math.min(t,e.length-1)]?.focus()}_handleInputKeydown(t){this._disabled||(t.key==="Enter"?(t.preventDefault(),this.addValue(this._input.value)&&(this._input.value="")):t.key==="Backspace"&&this._input.value===""&&this._values.length&&this.options.deletable&&(t.preventDefault(),this._removeAt(this._values.length-1)))}_handleChipKeydown(t){if(this._disabled)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e)return;let s=Number(e.dataset.index);if((t.key==="Delete"||t.key==="Backspace")&&this.options.deletable){t.preventDefault(),this._removeAt(s,Math.min(s,this._values.length-2));return}let r=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0,n=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0,o=r||n;if(!o)return;t.preventDefault();let l=Math.max(0,Math.min(this._values.length-1,s+o));t.ctrlKey&&r&&this.options.sortable?this._move(s,l,!0):this._list.querySelector(`[data-index="${l}"]`)?.focus()}_handleChipClick(t){let e=t.target instanceof Element?t.target:null,s=e?.closest("[data-index]");!s||this._disabled||(e.closest("[data-remove]")&&this.options.deletable?this._removeAt(Number(s.dataset.index)):s.focus())}_handleDragStart(t){if(this._disabled||!this.options.sortable)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;e&&(this._dragIndex=Number(e.dataset.index),this.el.dataset.state="dragging",t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"))}_handleDrop(t){if(this._dragIndex<0||this._disabled)return;t.preventDefault();let e=t.target instanceof Element?t.target.closest("[data-index]"):null,s=e?Number(e.dataset.index):this._values.length-1;this._move(this._dragIndex,s,!0),this._finishDrag()}_finishDrag(){this._dragIndex=-1,this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_move(t,e,s){if(t===e||t<0||e<0||t>=this._values.length||e>=this._values.length)return;let[r]=this._values.splice(t,1);this._values.splice(e,0,r),this._renderChips(s?e:-1),this.emit("change",{values:this.getValues()})}_removeAt(t,e=-1){let[s]=this._values.splice(t,1);s!==void 0&&(this._renderChips(e),e<0&&this._values.length===0&&this._input.focus(),this.emit("remove",{value:s}),this.emit("change",{values:this.getValues()}))}_showError(t){this._status.textContent=t,this._input.setAttribute("aria-invalid","true")}destroy(){for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function Pn(i,t){if(!Array.isArray(i))return[];let e=i.map(s=>String(s));return t?[...new Set(e)]:e}function Bn(){S.register("valuelist",(i,t)=>{let e=i.own(new Gt(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:s.detail.values})),{el:e.el,get:()=>e.getValues(),set:s=>e.setValues(Array.isArray(s)?s:[],{silent:!0}),focus:()=>e.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var zt=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),ql=["xl","lg","md","sm"];function Qe(i){let t=Number(i);if(!Number.isFinite(t))return"xs";for(let e of ql)if(t>=zt[e])return e;return"xs"}function Je(i,t){if(i==="xs")return!0;let e=zt[i];if(e===void 0)throw new RangeError(`Unknown breakpoint "${i}"`);return Number(t)>=e}function Qt(i,t={}){if(typeof i!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in t&&!D(t.target)&&t.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let e=t.target??globalThis,s=D(e)?e:null,r=null,n=!1,o=null,l=()=>s?s.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,h=()=>{if(n)return;let d=l();if(s&&d===0)return;let f=Qe(d);f!==r&&(r=f,i(r,d))};h();let c=0,u=()=>{c||n||(c=requestAnimationFrame(()=>{c=0,h()}))};return s&&typeof ResizeObserver=="function"?(o=new ResizeObserver(u),o.observe(s)):globalThis.addEventListener?.("resize",h,{passive:!0}),{current:()=>r??Qe(l()),destroy:()=>{n||(n=!0,c&&cancelAnimationFrame(c),o?.disconnect(),globalThis.removeEventListener?.("resize",h))}}}var we=class{base;headers;onError;timeout;constructor({base:t="",headers:e={},onError:s=null,timeout:r=3e4}={}){this.base=String(t),this.headers=Object.freeze({...e}),this.onError=s,this.timeout=Number(r)}async request(t,e={}){let{method:s="GET",data:r=null,files:n=null,query:o=null,headers:l={}}=e,h=new AbortController,c=this.timeout>0?setTimeout(()=>h.abort(),this.timeout):null,u=new Headers(this.headers);for(let[p,g]of Object.entries(l))u.set(p,g);u.set("Accept",u.get("Accept")??"application/json");let d;n!==null?(d=Vl(r,n),u.delete("Content-Type")):r!==null&&s.toUpperCase()!=="GET"&&s.toUpperCase()!=="HEAD"&&(d=JSON.stringify(r),u.set("Content-Type",u.get("Content-Type")??"application/json"));let f=Hl(this.base+t,o);try{let p=await fetch(f,{method:s.toUpperCase(),headers:u,body:d,signal:h.signal}),g=await p.text(),x=null;if(g!=="")try{x=JSON.parse(g)}catch(v){let b=new Error("Invalid JSON response",{cause:v});throw b.response=p,b}if(!p.ok){try{Xe(x)}catch(b){throw b.response=p,b}let v=new Error(`HTTP ${p.status} ${p.statusText}`.trim());throw v.response=p,v}return Xe(x)}catch(p){let g=p instanceof Error?p:new Error(String(p));if(this.onError)try{this.onError(g,{path:t,options:e})}catch{}throw g}finally{c!==null&&clearTimeout(c)}}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 qn(i,t="",e={}){let{apiBase:s="../remotecall/",...r}=e,n=`${s}${i}${t?`:${t}`:""}/`;return new we({...r,base:n})}function Xe(i){if(i&&typeof i=="object"){if(Object.prototype.hasOwnProperty.call(i,"error")&&i.error!=null){let t=typeof i.error=="string"?i.error:JSON.stringify(i.error);throw new Error(t||"Server error")}if(Object.prototype.hasOwnProperty.call(i,"result"))return i.result}return i}function Hl(i,t){if(t==null)return i;let e;if(typeof t=="string")e=t.replace(/^\?/,"");else if(t instanceof URLSearchParams)e=t.toString();else{let s=new URLSearchParams;for(let[r,n]of Object.entries(t))Hn(s,r,n);e=s.toString()}return e?i+(i.includes("?")?"&":"?")+e:i}function Hn(i,t,e){if(e!=null)if(Array.isArray(e))for(let s of e)Hn(i,t,s);else i.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function Vl(i,t){let e=new FormData;if(i&&typeof i=="object"&&!Array.isArray(i))for(let[r,n]of Object.entries(i))Vn(e,r,n);else i!=null&&e.append("data",typeof i=="string"?i:JSON.stringify(i));let s=jl(t)||Array.isArray(t)?Array.from(t):[t];for(let r of s)e.append("files",r);return e}function Vn(i,t,e){if(e!=null)if(Array.isArray(e))for(let s of e)Vn(i,t,s);else{let s=typeof Blob=="function"&&e instanceof Blob;i.append(t,typeof e=="object"&&!s?JSON.stringify(e):e)}}function jl(i){return typeof FileList=="function"&&i instanceof FileList}var $l=0,Kl=20,Ul=3,Yl=["B","KiB","MiB","GiB","TiB","PiB","EiB"],Wl=["B","kB","MB","GB","TB","PB","EB"],ki=[{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}],jn=new Map,$n=new Map;function gt(i,t={}){let e=es(i);if(e===null)return"";let{locale:s=U(),decimals:r,minDecimals:n,maxDecimals:o,group:l=!0}=t;return zi(s,Ci({decimals:r,minDecimals:n,maxDecimals:o,group:l}),e)}function Ze(i,t,e={}){let s=es(i);if(s===null)return"";let{locale:r=U(),decimals:n}=e,o=Jl(t);if(o===null)return gt(s,{locale:r,decimals:n});let l=Ci({decimals:n,group:!0});return zi(r,{...l,style:"currency",currency:o},s)}function ts(i,t={}){let e=es(i);if(e===null)return"";let{locale:s=U(),decimals:r=0}=t;return zi(s,{...Ci({decimals:r,group:!0}),style:"percent"},e)}function Yn(i,t={}){let e=es(i);if(e===null)return"";let{locale:s=U(),decimals:r=1,standard:n="iec"}=t;if(e===0)return`${gt(0,{locale:s,decimals:0})} B`;let o=n==="si"?Wl:Yl,l=n==="si"?1e3:1024,h=Math.abs(e),c=Math.min(o.length-1,Math.max(0,Math.floor(Math.log(h)/Math.log(l)))),u=h/l**c;Xl(u,c===0?0:r)>=l&&c<o.length-1&&(c+=1,u=h/l**c);let d=e<0?-u:u;return`${gt(d,{locale:s,minDecimals:0,maxDecimals:c===0?0:r})} ${o[c]}`}function Wn(i,t={}){let e=Un(i);if(e===null)return"";let{now:s=new Date,locale:r=U(),numeric:n="auto"}=t,o=Un(s);if(o===null)return"";let l=e.getTime()-o.getTime(),h=ki.find(({ms:u,limit:d})=>Math.abs(l)/u<d)??ki[ki.length-1],c=Math.round(l/h.ms);return Ql(r,n).format(c,h.unit)}function zi(i,t,e){let s=`${i}\0${JSON.stringify(t)}`,r=jn.get(s);return r===void 0&&(r=Gl(i,t),jn.set(s,r)),r.format(e)}function Gl(i,t){try{return new Intl.NumberFormat(i,t)}catch{try{return new Intl.NumberFormat(void 0,t)}catch{return new Intl.NumberFormat}}}function Ql(i,t){let e=`${i}\0${t}`,s=$n.get(e);if(s===void 0){try{s=new Intl.RelativeTimeFormat(i,{numeric:t})}catch{s=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"})}$n.set(e,s)}return s}function Ci({decimals:i,minDecimals:t,maxDecimals:e,group:s=!0}){let r={useGrouping:s!==!1},n=Kn(t??i),o=Kn(e??i);return n!==null&&(r.minimumFractionDigits=n),o!==null?(r.maximumFractionDigits=o,n!==null&&n>o&&(r.minimumFractionDigits=o)):n!==null&&(r.maximumFractionDigits=Math.max(n,Ul)),r}function Kn(i){if(i==null)return null;let t=Number(i);return Number.isFinite(t)?Math.min(Kl,Math.max($l,Math.round(t))):null}function es(i){if(i==null||i==="")return null;let t=typeof i=="number"?i:Number(i);return Number.isFinite(t)?t:null}function Jl(i){if(typeof i!="string")return null;let t=i.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function Un(i){if(i instanceof Date)return Number.isNaN(i.getTime())?null:i;if(typeof i=="number")return Number.isFinite(i)?new Date(i*1e3):null;if(typeof i=="string"){let t=i.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 Xl(i,t){let e=10**t;return Math.round(i*e)/e}var Gn="zx:__probe__";function Jt(i,t={}){let{area:e="local"}=t,s=`zx:${String(i??"")}:`,r=new Map,n=Zl(e),o=u=>{if(n!==null)try{return n.getItem(u)}catch{n=null}return r.has(u)?r.get(u):null},l=(u,d)=>{if(n!==null)try{n.setItem(u,d);return}catch{n=null}r.set(u,d)},h=u=>{if(n!==null)try{n.removeItem(u)}catch{n=null}r.delete(u)},c=()=>{if(n!==null)try{let u=[];for(let d=0;d<n.length;d+=1){let f=n.key(d);typeof f=="string"&&f.startsWith(s)&&u.push(f)}return u}catch{n=null}return[...r.keys()].filter(u=>u.startsWith(s))};return{get(u,d){let f=o(s+u);if(f==null)return d;try{return JSON.parse(f)}catch{return d}},set(u,d){let f;try{f=JSON.stringify(d)}catch{f=void 0}f===void 0?h(s+u):l(s+u,f)},remove(u){h(s+u)},keys(){return c().map(u=>u.slice(s.length))},clear(){for(let u of c())h(u)}}}function Zl(i){let t=i==="session"?"sessionStorage":"localStorage";try{let e=globalThis[t];return!e||typeof e.getItem!="function"?null:(e.setItem(Gn,"1"),e.removeItem(Gn),e)}catch{return null}}var th=["=","+","-","@"];function Xn(i,t,e={}){let{delimiter:s=",",header:r=!0,newline:n=`\r
2
- `}=e,o=sh(t),l=[];r&&l.push(o.map(h=>Jn(h.label,s,Qn(h.label))).join(s));for(let h of i??[]){let c=o.map(u=>{let d=typeof u.value=="function"?u.value(h):ih(h,u.id);return Jn(rh(d),s,Qn(d))});l.push(c.join(s))}return l.join(n)}function Zn(i,t,e={}){let{type:s="text/plain;charset=utf-8"}=e,r=nh(t,s),n=URL.createObjectURL(r),o=document.createElement("a");o.href=n,o.download=String(i??"download"),o.rel="noopener",o.style.display="none",document.body.append(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}async function ss(i){let t=String(i??"");if(globalThis.navigator?.clipboard?.writeText)try{return await navigator.clipboard.writeText(t),!0}catch{}return eh(t)}function eh(i){if(typeof document>"u"||!document.body)return!1;let t=document.activeElement,e=document.createElement("textarea");e.value=i,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 s=!1;try{e.select(),e.setSelectionRange(0,i.length),s=document.execCommand?.("copy")===!0}catch{s=!1}finally{e.remove(),t instanceof HTMLElement&&t.focus({preventScroll:!0})}return s}function sh(i){return(i??[]).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 ih(i,t){return i?.[t]}function rh(i){if(i==null)return"";if(i instanceof Date)return Number.isNaN(i.getTime())?"":i.toISOString();if(typeof i=="number")return Number.isFinite(i)?String(i):"";if(typeof i=="boolean")return i?"true":"false";if(typeof i=="object")try{return JSON.stringify(i)}catch{return String(i)}return String(i)}function Qn(i){return typeof i!="string"?!1:th.includes(i.charAt(0))}function Jn(i,t,e=!1){let s=e?` ${i}`:i;return s.includes(t)||s.includes('"')||s.includes(`
3
- `)||s.includes("\r")?`"${s.replaceAll('"','""')}"`:s}function nh(i,t){if(typeof Blob=="function"&&i instanceof Blob)return i;let e=typeof i=="string"&&/^text\/csv\b/i.test(t)?["\uFEFF",i]:[i];return new Blob(e,{type:t})}var lt=class extends _{static cssName="check-button";static defaults={label:"",checked:!1,icon:!0,disabled:!1};render(){let t=!this.el,e=this.el??a("button");if(this.el=e,e.localName!=="button")throw new TypeError("CheckButton target must be a button element");this._createdRoot=t,this._original=t?null:oh(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,this._labels=to(this.options.label),e.type="button";let s=[];return this.options.icon&&s.push(a("span",{class:"zx-check-button__icon",ariaHidden:"true"},a("span",{class:"zx-check-button__off"},m("square",{size:15})),a("span",{class:"zx-check-button__on"},m("check",{size:15})))),s.push(a("span",{class:"zx-check-button__label",ref:"label"})),e.replaceChildren(...s),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let s=!!t;return s===this._checked?this:(this._checked=s,this._sync(),e||this.emit("change",{checked:this._checked}),this)}toggle(){return this.set(!this._checked)}setLabel(t){return this._labels=to(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&&ah(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 to(i){return Array.isArray(i)?{on:String(i[0]??""),off:String(i[1]??"")}:{on:String(i??""),off:String(i??"")}}function oh(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function ah(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}var Xt=class extends _{static cssName="modal";static defaults={content:null,width:"auto",closable:!0,lightDismiss:!1,destroyOnClose:!1};#t;#e=!1;#s=!1;constructor(t=null,e={}){super(null,e),this.#i(this.options.width),eo(this.refs.content,this.options.content),this.listen(this.el,"cancel",s=>{let r=this.emit("cancel");(!this.options.closable||r.defaultPrevented)&&s.preventDefault()}),this.listen(this.el,"close",()=>{if(!this._isRealClose())return;this.el.dataset.state="closed",delete this.el.dataset.zxOverlayOrder;let s=this.#e?this.#t:this.el.returnValue||void 0;this.#t=void 0,this.#e=!1,this.emit("close",{result:s}),this.options.destroyOnClose&&!this.#s&&this.destroy()}),this.listen(this.el,"click",s=>{!this.options.lightDismiss||s.target!==this.el||!lh(this.el,s)||this.close()})}mountTarget(){return document.body}_show(){this.el.showModal()}_isRealClose(){return!0}render(){let t=a("dialog",{class:"zx-modal"},a("div",{class:"zx-modal__content",ref:"content"}));return t.dataset.state="closed",this.mountTarget().append(t),t}open(){if(this.isOpen())return this;this.el.dataset.zxOverlayOrder=String(hh()),this.el.returnValue="";try{this._show()}catch(t){throw delete this.el.dataset.zxOverlayOrder,t}return this.el.dataset.state="open",this.emit("open"),this}close(t){return this.isOpen()?(this.#t=t,this.#e=!0,this.el.close(typeof t=="string"?t:""),this):this}setContent(t){return eo(this.refs.content,t),this}isOpen(){return this.el.open}destroy(){this.#s||(this.#s=!0,this.isOpen()&&this.el.close(),super.destroy())}#i(t){typeof t=="number"&&Number.isFinite(t)?this.el.style.inlineSize=`${Math.max(0,t)}px`:this.el.style.inlineSize=String(t??"auto")}};function eo(i,t){if(i.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t.nodeType=="number"&&i.append(t)}function lh(i,t){let e=i.getBoundingClientRect();return t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom}function hh(){let i=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...i)+1}var ch=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(","),ht=class i extends Xt{static cssName="dialog";static defaults={title:"",size:"md",buttons:[],closable:!0};#t=new Map;#e=null;#s=[];#i="";#n=null;constructor(t=null,e={}){super(null,e),this._applySize(this.options.size),this.#i=String(this.options.title??""),this.#o(this.#i),this.#s=is(this.options.buttons),this.#a(this.#s),this.refs.close.hidden=!this.options.closable,this.listen(this.refs.close,"click",()=>this.close()),this.listen(this.refs.footer,"click",s=>{let r=s.target.closest?.("[data-dialog-button]");if(!r||!this.refs.footer.contains(r))return;let n=this.#r[Number(r.dataset.dialogButton)];n&&this.#l(n)}),this.on("close",()=>this.#h())}#r=[];render(){let t=y("zx-dialog-title"),e=a("dialog",{class:"zx-modal zx-dialog",ariaLabelledby:t},a("header",{class:"zx-dialog__header"},a("h2",{class:"zx-dialog__title",id:t,ref:"title"}),a("button",{class:"zx-btn zx-dialog__close",ref:"close",type:"button","data-kind":"ghost",ariaLabel:"Close",title:"Close"},"\xD7")),a("div",{class:"zx-modal__content zx-dialog__body",ref:"content"}),a("footer",{class:"zx-dialog__footer",ref:"footer"}));return e.dataset.state="closed",this.mountTarget().append(e),e}open(){return this.isOpen()?this:(this.#n=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(ch);e instanceof HTMLElement&&e.focus()}),this)}setTitle(t){return this.#i=String(t??""),this.#o(this.#i),this}setContent(t){return this.#t.clear(),this.#e=null,uh(this.refs.content,t),this}setButtons(t){return this.#s=is(t),this.#a(this.#s),this}addView(t,e){let s=String(t);this.#t.get(s)?.content.remove();let n=a("section",{class:"zx-dialog__view",hidden:!0,ariaHidden:"true"});so(n,e?.content??null);let o={key:s,content:n,buttons:e&&Object.hasOwn(e,"buttons")?is(e.buttons??[]):null,title:e&&Object.hasOwn(e,"title")?String(e.title??""):null};return this.#t.set(s,o),this.#t.size===1||this.#e?.key===s?this.showView(s):this.refs.content.append(n),o}showView(t){let e=this.#t.get(String(t));if(!e)throw new RangeError(`Unknown dialog view: ${t}`);this.#e||this.refs.content.replaceChildren();for(let s of this.#t.values()){s.content.isConnected||this.refs.content.append(s.content);let r=s===e;s.content.hidden=!r,s.content.setAttribute("aria-hidden",String(!r))}return this.#e=e,this.#o(e.title??this.#i),this.#a(e.buttons??this.#s),e}getView(t){return this.#t.get(String(t))??null}static alert({title:t="",message:e="",okLabel:s="OK"}={}){return new Promise(r=>{let n=!1,o=()=>{n||(n=!0,l.close(),r())},l=new i(null,{title:t,content:e,buttons:[{label:s,kind:"primary",action:o,autofocus:!0}]});l.once("close",()=>{n||(n=!0,r()),l.destroy()}),l.open()})}static confirm({title:t="",message:e="",okLabel:s="OK",cancelLabel:r="Cancel",danger:n=!1}={}){return new Promise(o=>{let l=!1,h=u=>{l||(l=!0,c.close(u),o(u))},c=new i(null,{title:t,content:e,buttons:[{label:r,action:()=>h(!1)},{label:s,kind:n?"danger":"primary",action:()=>h(!0),autofocus:!0}]});c.once("close",()=>{l||(l=!0,o(!1)),c.destroy()}),c.open()})}static prompt({title:t="",message:e="",value:s="",placeholder:r=""}={}){return new Promise(n=>{let o=!1,l=a("input",{class:"zx-dialog__prompt-input",value:String(s),placeholder:String(r),autofocus:!0,ariaLabel:String(t||"Prompt value")}),h=a("div",{class:"zx-dialog__prompt"},a("div",{class:"zx-dialog__prompt-message"},e),l),c=d=>{o||(o=!0,u.close(d),n(d))},u=new i(null,{title:t,content:h,buttons:[{label:"Cancel",action:()=>c(null)},{label:"OK",kind:"primary",action:()=>c(l.value)}]});u.listen(l,"keydown",d=>{d.key==="Enter"&&(d.preventDefault(),c(l.value))}),u.once("close",()=>{o||(o=!0,n(null)),u.destroy()}),u.open()})}_applySize(t){let e={sm:400,md:600,lg:840},s=typeof t=="number"&&Number.isFinite(t)?t:e[t]??e.md;this.el.style.inlineSize=`${Math.max(0,s)}px`}#o(t){this.refs.title.textContent=t}#a(t){this.#r=is(t),this.refs.footer.replaceChildren(),this.refs.footer.hidden=this.#r.length===0,this.#r.forEach((e,s)=>{this.refs.footer.append(a("button",{class:"zx-btn",type:"button","data-kind":e.kind??"default","data-size":"md","data-dialog-button":String(s),autofocus:!!e.autofocus},a("span",{class:"zx-btn__label"},e.label)))})}#l(t){let e=t.action??"close";e==="close"?this.close():e==="cancel"?this.emit("cancel").defaultPrevented||this.close():typeof e=="function"&&e(this)}#h(){this.#n?.isConnected&&typeof this.#n.focus=="function"&&this.#n.focus(),this.#n=null}};function is(i){return Array.isArray(i)?i.map(t=>({...t,label:String(t.label??"")})):[]}function uh(i,t){i.replaceChildren(),so(i,t)}function so(i,t){if(t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t.nodeType=="number"&&i.append(t)}var bt=class extends _{static cssName="groupbox";static defaults={title:"",open:!0};constructor(t,e={}){let s=t,r=null;if(t!==null){let n=R(t);if(n&&n.localName!=="details"){let o=document.createElement("details"),l=Array.from(n.childNodes),h=n.parentNode,c=n.nextSibling;h&&h.insertBefore(o,n),o.append(...l),n.remove(),r={original:n,details:o,children:l,parent:h,next:c},s=o}}try{super(s,e)}catch(n){throw r&&io(r),n}this._adoption=r}render(){let t=!this.el,e=this.el??a("details");if(e.localName!=="details")throw new TypeError("Groupbox requires a details element");this._createdRoot=t,this._original=t?null:dh(e);let s=Array.from(e.childNodes).filter(o=>!(o.nodeType===1&&o.localName==="summary")),r=a("summary",{class:"zx-groupbox__summary",ref:"summary"},a("span",{class:"zx-groupbox__chevron",ariaHidden:"true"},m("chevron-right",{size:16})),a("span",{class:"zx-groupbox__title",ref:"title"},String(this.options.title))),n=a("div",{class:"zx-groupbox__content",ref:"content"},s);return e.replaceChildren(r,n),e.open=!!this.options.open,this._lastOpen=e.open,this.listen(e,"toggle",()=>{let o=e.open;o!==this._lastOpen&&(this._lastOpen=o,this.emit(o?"open":"close"))}),e}open(){return this.el.setAttribute("open",""),this}close(){return this.el.removeAttribute("open"),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.el.open}setTitle(t){return this.refs.title.textContent=String(t),this}setContent(t){let e=t instanceof _?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?io(this._adoption):!this._createdRoot&&this._original&&ph(this.el,this._original))}};function dh(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function ph(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function io(i){if(i.original.replaceChildren(...i.children),i.details.parentNode)i.details.replaceWith(i.original);else if(i.parent){let t=i.next?.parentNode===i.parent?i.next:null;i.parent.insertBefore(i.original,t)}}var Zt=class extends _{static cssName="search";static defaults={placeholder:"",value:"",clearable:!0,debounce:250};render(){let t=!this.el,e=this.el??a("form");this._createdRoot=t,this._original=t?null:fh(e),this._inputTimer=null,e.setAttribute("role","search");let s=a("input",{class:"zx-search__input",ref:"input",type:"search",placeholder:String(this.options.placeholder),value:String(this.options.value),ariaLabel:String(this.options.placeholder||"Search")}),r=this.options.clearable?a("button",{class:"zx-search__clear",ref:"clear",type:"button",ariaLabel:"Clear search",title:"Clear search"},m("x",{size:15})):null,n=a("button",{class:"zx-search__submit",ref:"submit",type:e.localName==="form"?"submit":"button",ariaLabel:"Submit search",title:"Search"},m("search",{size:16}));return e.replaceChildren(...[s,r,n].filter(Boolean)),this._syncClear(),this.listen(s,"input",()=>{this._syncClear(),this._scheduleInput()}),e.localName==="form"?this.listen(e,"submit",o=>{o.preventDefault(),this.emit("submit",{value:this.get()})}):(this.listen(s,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this.emit("submit",{value:this.get()}))}),this.listen(n,"click",()=>this.emit("submit",{value:this.get()}))),r&&this.listen(r,"click",()=>this.clear()),e}get(){return this.refs.input.value}set(t,{silent:e=!1}={}){return this._inputTimer!==null&&(clearTimeout(this._inputTimer),this._inputTimer=null),this.refs.input.value=String(t),this._syncClear(),e||this._scheduleInput(),this}focus(){return this.refs.input.focus(),this}clear(){return this.set(""),this.emit("clear"),this.focus(),this}destroy(){this._cleaned||(this._cleaned=!0,this._inputTimer!==null&&clearTimeout(this._inputTimer),super.destroy(),!this._createdRoot&&this._original&&_h(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 fh(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function _h(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}var mh=new Set(["divided","bracket","line","segmented"]),te=class extends _{static cssName="tabbox";static defaults={tabs:[],active:null,variant:"divided",keepAlive:!0};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??a("section");if(this.el=e,this._createdRoot=t,this._original=t?null:bh(e),this._cleaned=!1,this._tabs=[],this._active=null,this._keepAlive=!!this.options.keepAlive,this._initializing=!0,!mh.has(this.options.variant))throw new RangeError(`Unknown tabbox variant: ${this.options.variant}`);e.dataset.variant=this.options.variant;let s=a("div",{class:"zx-tabbox__tablist",ref:"tablist",role:"tablist",ariaOrientation:"horizontal"}),r=a("div",{class:"zx-tabbox__panels",ref:"panels"});if(e.replaceChildren(s,r),!Array.isArray(this.options.tabs))throw new TypeError("Tabbox tabs must be an array");for(let l of this.options.tabs)this.addTab(l);this._initializing=!1;let n=this.options.active===null?null:this._find(this.options.active),o=n&&!n.definition.disabled?n:this._enabledTabs()[0];return o&&this._applyActive(o),this.listen(s,"click",l=>{let h=l.target.closest?.('[role="tab"]');if(!h||!s.contains(h))return;let c=this._recordForTab(h);if(!(!c||c.definition.disabled)){if(l.target.closest?.(".zx-tabbox__close")){this._closeTab(c);return}this._setFocused(c),this.openTab(c.definition.name)}}),this.listen(s,"keydown",l=>this._onKeydown(l)),e}addTab(t,e={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Tab definition must be an object");if(typeof t.name!="string"||t.name==="")throw new TypeError("Tab name must be a non-empty string");if(this._find(t.name))throw new RangeError(`Tab already exists: ${t.name}`);if(!gh(t.content))throw new TypeError("Tab content must be a Node, Component, or function");let s={name:t.name,title:String(t.title??""),content:t.content,icon:t.icon?String(t.icon):null,closable:!!t.closable,disabled:!!t.disabled},r=y("zx-tab"),n=y("zx-tabpanel"),o=a("span",{class:"zx-tabbox__title"},s.title),l=a("span",{class:"zx-tabbox__badge",hidden:!0}),h=[];s.icon&&h.push(a("span",{class:"zx-tabbox__icon",ariaHidden:"true"},m(s.icon,{size:16}))),h.push(o,l),s.closable&&h.push(a("span",{class:"zx-tabbox__close zx-icon-btn",ariaHidden:"true",title:"Close"},m("x",{size:14})));let c=a("button",{class:"zx-tabbox__tab",type:"button",id:r,role:"tab",tabindex:"-1",ariaControls:n,ariaSelected:"false",ariaDisabled:s.disabled?"true":null,dataset:{closable:s.closable?"true":null}},h),u=a("div",{class:"zx-tabbox__panel",id:n,role:"tabpanel",tabindex:"0",ariaLabelledby:r,hidden:!0}),d={definition:s,tab:c,title:o,badge:l,panel:u,built:!1},f=Number.isFinite(e.index)?Math.trunc(e.index):this._tabs.length,p=Math.max(0,Math.min(this._tabs.length,f)),g=this._tabs[p]??null;return this._tabs.splice(p,0,d),this.refs.tablist.insertBefore(c,g?.tab??null),this._keepAlive&&this.refs.panels.insertBefore(u,g?.panel??null),!this._initializing&&!this._active&&!s.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 s=this._active?.definition.name??null;return this.emit("change",{name:e.definition.name,previous:s}).defaultPrevented?this:(this._applyActive(e),this)}show(t){return this.openTab(t)}getActive(){return this._active?.definition.name??null}setTitle(t,e){let s=this._require(t);return s.definition.title=String(e??""),s.title.textContent=s.definition.title,this}setBadge(t,e){let s=this._require(t);return s.badge.textContent=e===null?"":String(e),s.badge.hidden=e===null,this}enableTab(t){let e=this._require(t);return e.definition.disabled?(e.definition.disabled=!1,e.tab.removeAttribute("aria-disabled"),this._active||this._applyActive(e),this):this}disableTab(t){let e=this._require(t);if(e.definition.disabled)return this;if(e===this._active){let s=this._enabledTabs().find(r=>r!==e)??null;if(s){if(this.openTab(s.definition.name),this._active===e)return this}else e.tab.setAttribute("aria-selected","false"),e.tab.tabIndex=-1,e.panel.hidden=!0,this._keepAlive||e.panel.remove(),this._active=null}return e.definition.disabled=!0,e.tab.setAttribute("aria-disabled","true"),e.tab.tabIndex=-1,this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&yh(this.el,this._original))}_onKeydown(t){let e=t.target.closest?.('[role="tab"]');if(!e||!this.refs.tablist.contains(e))return;let s=this._recordForTab(e);if(!s)return;let r=this._enabledTabs();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let n=t.key==="ArrowRight"?1:-1,o=r.indexOf(s),l=r[(o+n+r.length)%r.length];l&&this._setFocused(l);return}if(t.key==="Home"||t.key==="End"){t.preventDefault();let n=t.key==="Home"?r[0]:r[r.length-1];n&&this._setFocused(n);return}if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.openTab(s.definition.name);return}t.key==="Delete"&&s.definition.closable&&(t.preventDefault(),this._closeTab(s))}_closeTab(t){let e=this._tabs.indexOf(t),s=t.tab.contains(document.activeElement);if(!this._removeTab(t.definition.name,!0))return;let r=this._tabs[Math.min(e,this._tabs.length-1)]??this._tabs[e-1],n=r&&!r.definition.disabled?r:this._active;n&&this._setFocused(n,s)}_removeTab(t,e){let s=this._find(t);if(!s)return!1;let r=this._tabs.indexOf(s),o=this._tabs.filter(h=>h!==s).filter(h=>!h.definition.disabled),l=o.find(h=>this._tabs.indexOf(h)>r)??o.at(-1)??null;return s===this._active&&l&&this.emit("change",{name:l.definition.name,previous:s.definition.name}).defaultPrevented?!1:(this._tabs.splice(r,1),s.tab.remove(),s.panel.remove(),s===this._active&&(this._active=null,l&&this._applyActive(l)),e&&this.emit("close",{name:s.definition.name}),!0)}_applyActive(t){this._ensureContent(t);let e=this._active;e&&e!==t&&(e.tab.setAttribute("aria-selected","false"),e.panel.hidden=!0,this._keepAlive||e.panel.remove()),this._active=t,t.tab.setAttribute("aria-selected","true"),t.panel.hidden=!1,t.panel.parentNode!==this.refs.panels&&this.refs.panels.append(t.panel),this._setFocused(t,!1)}_ensureContent(t){if(t.built)return;let e=typeof t.definition.content=="function"?t.definition.content():t.definition.content,s=e instanceof _?e.toElement():e;if(!s||typeof s.nodeType!="number")throw new TypeError(`Tab content factory for ${t.definition.name} must return a Node or Component`);t.panel.append(s),t.built=!0}_setFocused(t,e=!0){for(let s of this._tabs)s.tab.tabIndex=s===t?0:-1;e&&t.tab.focus()}_enabledTabs(){return this._tabs.filter(t=>!t.definition.disabled)}_find(t){return this._tabs.find(e=>e.definition.name===t)??null}_require(t){let e=this._find(t);if(!e)throw new RangeError(`Unknown tab: ${t}`);return e}_recordForTab(t){return this._tabs.find(e=>e.tab===t)??null}};function gh(i){return typeof i=="function"||i instanceof _?!0:!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function bh(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function yh(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function xh(i,t){return String(i).localeCompare(String(t))}function vh(i,t){return i-t}function wh(i,t){return i.getTime()-t.getTime()}function Sh(i,t,e="asc"){let s=i==null,r=t==null;if(s||r)return s&&r?0:s?1:-1;let n;return i instanceof Date&&t instanceof Date?n=wh(i,t):typeof i=="number"&&typeof t=="number"?n=vh(i,t):n=xh(i,t),e==="desc"?-n:n}function Ah(i,t="asc"){return(e,s)=>Sh(i(e),i(s),t)}function Ti(i,t,e="asc"){let s=Ah(t,e);return i.map((r,n)=>({row:r,index:n})).sort((r,n)=>s(r.row,n.row)||r.index-n.index).map(({row:r})=>r)}var kh=new Set(["text","number","select","date","checkbox","textarea"]),zh='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',yt=class extends _{static cssName="table";static defaults={columns:[],data:[],rowId:"ID",sort:null,sortMode:"local",selectable:!1,stickyHeader:!0,responsive:!1,growing:!1,height:null,emptyText:null,rowClass:null,zebra:!0,editMode:!1,hierarchy:!1};constructor(t,e={}){super(t,e)}render(){let t=this.el??a("div");if(this.el=t,this._originalChildren=this.el?Array.from(this.el.childNodes):null,this._columns=Array.isArray(this.options.columns)?this.options.columns.map(e=>({...e})):[],this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._selected=new Set,this._selectionAnchorId=null,this._sort=Bh(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=Rh(this.options.editMode),this._edit=null,this._editMessage=null,this._stacked=!1,this._width=null,this._growStep=Vh(this.options.growing),this._rendered=this._growStep??1/0,this._more=null,this._rovingKey=null,this._rovingCell=null,this._rovingMatched=!1,this._hierarchy=Fh(this.options.hierarchy,this._columns),this._expanded=Lh(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let e of rs(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(e);return this._reconcileExpanded(),this._table=a("table",{class:"zx-table__table"}),this._hierarchy&&this._table.setAttribute("role","treegrid"),this._colgroup=a("colgroup",{class:"zx-table__columns"}),this._thead=a("thead",{class:"zx-table__head"}),this._tbody=a("tbody",{class:"zx-table__body"}),this._table.append(this._colgroup,this._thead,this._tbody),this._scroll=a("div",{class:"zx-table__scroll",dataset:{stickyHeader:String(!!this.options.stickyHeader),zebra:String(!!this.options.zebra)}},this._table),this.options.height!=null&&(this._scroll.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._editMode===!1?t.replaceChildren(this._scroll):(t.dataset.editMode=this._editMode,this._editMessage=a("div",{class:"zx-table__message",id:y("zx-table-message"),role:"status",ariaLive:"polite"}),t.replaceChildren(this._scroll,this._editMessage)),this._renderColumns(),this._renderHeader(),this._renderBody(),this._watchWidth(),this.listen(this._tbody,"click",e=>this._handleBodyClick(e)),this.listen(this._tbody,"dblclick",e=>this._handleBodyDoubleClick(e)),this._editMode!==!1&&(this.listen(this._tbody,"keydown",e=>this._handleEditKeydown(e)),this.listen(this._tbody,"focusin",e=>this._handleEditFocusIn(e)),this.listen(document,"pointerdown",e=>this._handleDocumentPointerDown(e),{capture:!0})),t}setLoading(t=!0){return t?this.el.dataset.loading="true":delete this.el.dataset.loading,this.el.setAttribute("aria-busy",String(!!t)),this}setData(t){this._rendered=this._growStep??1/0,this.setLoading(!1),oo(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 oo(t),this._data.push(...t),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),this._emitDataChange(),this}updateRow(t,e){let s=this._data.findIndex(n=>Object.is(this._idFor(n),t));if(s<0)return this;let r=this._selected.delete(t);return this._data[s]=e,r&&this._selected.add(this._idFor(e)),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),r&&!Object.is(t,this._idFor(e))&&this._emitSelectionChange(),this._emitDataChange(),this}removeRow(t){let e=this._data.findIndex(r=>Object.is(this._idFor(r),t));if(e<0)return this;this._data.splice(e,1),this._reconcileExpanded();let s=this._selected.delete(t);return Object.is(this._selectionAnchorId,t)&&(this._selectionAnchorId=null),this._renderBody(),s&&this._emitSelectionChange(),this._emitDataChange(),this}getRow(t){return this._data.find(e=>Object.is(this._idFor(e),t))??null}getData(){return[...this._data]}empty(){let t=this._selected.size>0;return this._data=[],this._expanded.clear(),this._selected.clear(),this._selectionAnchorId=null,this._renderBody(),t&&this._emitSelectionChange(),this._emitDataChange(),this}setSort(t,e,s={}){if(this._abortEdit({focus:!1}),!this._columns.find(o=>o.id===t))throw new RangeError(`Unknown table column: ${t}`);let n=e??(this._sort?.id===t&&this._sort.dir==="asc"?"desc":"asc");if(n!=="asc"&&n!=="desc")throw new TypeError('Table sort direction must be "asc" or "desc"');return this._sort={id:t,dir:n},this.options.sortMode==="local"&&(this._sortData(),this._renderBody()),this._syncSortHeader(),s.silent||this.emit("sort",{id:t,dir:n}),this}getSelection(){return this._data.filter(t=>this._selected.has(this._idFor(t)))}setSelection(t){if(!Array.isArray(t))throw new TypeError("Table selection must be an array of row ids");let e=new Set(this._data.map(r=>this._idFor(r))),s=new Set;if(this.options.selectable!==!1){for(let r of t)if(e.has(r)&&s.add(r),this.options.selectable==="single"&&s.size>0)break}return Hh(this._selected,s)?this:(this._selected=s,this._syncSelection(),this._emitSelectionChange(),this)}clearSelection(){return this._selected.size===0?this:(this._selected.clear(),this._selectionAnchorId=null,this._syncSelection(),this._emitSelectionChange(),this)}toggleRow(t,e={}){return this._expanded.has(t)?this.collapseRow(t,e):this.expandRow(t,e)}expandRow(t,e={}){return this._setRowExpanded(t,!0,e)}collapseRow(t,e={}){return this._setRowExpanded(t,!1,e)}expandAll(t={}){if(!this._hierarchy)return this;let s=rs(this._data,this.options.rowId,this._hierarchy.parentId).filter(r=>!this._expanded.has(r));for(let r of s)this._expanded.add(r);if(s.length&&this._renderBody(),!t.silent)for(let r of s)this._emitRowToggle(r,!0);return this}collapseAll(t={}){if(!this._hierarchy||this._expanded.size===0)return this;let e=[...this._expanded];if(this._expanded.clear(),this._renderBody(),!t.silent)for(let s of e)this._emitRowToggle(s,!1);return this}getExpanded(){return this._data.map(t=>this._idFor(t)).filter(t=>this._expanded.has(t))}startEdit(t,e){if(this._editMode===!1)return this;let s=this._columns.find(u=>u.id===e);if(!s)return this;let r=this._data.find(u=>Object.is(this._idFor(u),t));if(r===void 0||Se(s,r)===!1)return this;if(this._edit){if(Object.is(this._edit.id,t)&&this._edit.cells.has(e))return this._edit.columnId=e,this._focusEditor(e),this;if(this.commitEdit(),this._edit)return this}let n=this._data.findIndex(u=>Object.is(this._idFor(u),t));if(n<0)return this;let o=this._data[n],l=this._rowElements.get(t)?.[0];if(!l)return this;let h=this._editMode==="row"?this._columns.filter(u=>Se(u,o)!==!1):[s],c=new Map;for(let u of h){let d=no(l,u.id);if(!d)continue;let f=this._createEditor(d,u,o,n);f&&c.set(u.id,f)}return c.size===0?this:(this._edit={id:t,columnId:e,row:o,cells:c,tr:l},l.dataset.editing="true",this.emit("editstart",{row:o,id:t,column:s,columnId:e,value:o?.[e]}),this._focusEditor(e),this)}commitEdit(){let t=this._edit;if(!t)return this;let e=this.getRow(t.id)??t.row,s={};for(let[d,f]of t.cells)s[d]=f.read();let r=this._columns.filter(d=>t.cells.has(d.id)),n=Oh(s,r,e,this._msgOr("table.invalid","Invalid value"));if(n)return this._markInvalid(n.columnId,n.message),t.columnId=n.columnId,this.emit("editinvalid",{row:e,id:t.id,column:this._columns.find(d=>d.id===n.columnId)??null,columnId:n.columnId,value:s[n.columnId],message:n.message}),this._focusEditor(n.columnId),this;this._clearInvalid();let o=Mh(e,s),l=t.columnId;if(this.emit("editcommit",{row:e,id:t.id,column:this._columns.find(d=>d.id===l)??null,columnId:l,value:s[l],previous:e?.[l],changes:o}).defaultPrevented)return this;let c=this._editHasFocus(),u={...e,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(t.id,u),c&&this._focusCell(this._idFor(u),l),this}cancelEdit(){return this._abortEdit({focus:!0}),this}isEditing(){return this._edit!==null}getEditing(){return this._edit?{id:this._edit.id,columnId:this._edit.columnId}:null}_visibleData(){return this._visibleEntries().map(t=>t.row)}_projectedData(){return this._hierarchy?Th(this._data,this.options.rowId,this._hierarchy.parentId,this._expanded):this._data.map((t,e)=>({row:t,id:this._idFor(t),index:e,depth:0,hasChildren:!1,parentId:null}))}_visibleEntries(){let t=this._projectedData();return this._rendered===1/0?t:t.slice(0,this._rendered)}growBy(t){if(!this._growStep)return this;let e=Number(t)>0?Math.trunc(Number(t)):this._growStep,s=this._rendered,r=this._projectedData().length;return this._rendered=Math.min(r,this._rendered+e),this._rendered===s?this:(this._renderBody(),this.emit("grow",{rendered:this._rendered,total:r}),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=a("button",{class:"zx-table__more",type:"button",onclick:()=>this.growBy()}),this.el.append(this._more)),this._more.textContent=e,this._more.setAttribute("aria-label",e)}_message(t,e,s){let r=this.msg(t,...s);return r===t?O(e,s):r}_watchWidth(){this._width?.destroy(),this._width=null;let t=this.options.responsive;!t||!(t in zt)||(this._width=Qt((e,s)=>this._setStacked(s>0&&s<zt[t]),{target:this.el}))}_setStacked(t){this._stacked!==t&&(this._stacked=t,this.el.toggleAttribute("data-stacked",t),this._applyStackedRoles(t),this.emit("stackedchange",{stacked:t}))}_applyStackedRoles(t){let e=[[this._table,this._hierarchy?"treegrid":"table"],[this._thead,"rowgroup"],[this._tbody,"rowgroup"]];for(let[s,r]of e)s&&(t?s.setAttribute("role",r):s===this._table&&this._hierarchy?s.setAttribute("role","treegrid"):s.removeAttribute("role"));for(let[s,r]of[["tr","row"],["td","cell"],["th","columnheader"]])for(let n of this._table.querySelectorAll(s))t?n.setAttribute("role",r):n.removeAttribute("role")}isStacked(){return!!this._stacked}destroy(){this._teardownEdit(),this._width?.destroy(),this._width=null,this.el&&delete this.el.dataset.editMode,!this._restored&&this._originalChildren&&(this.el.replaceChildren(...this._originalChildren),this._restored=!0),super.destroy()}_renderColumns(){let t=document.createDocumentFragment();this.options.selectable==="multi"&&t.append(a("col",{class:"zx-table__selection-column"}));let e=this._columns.map(r=>qh(r.width)),s=e.reduce((r,n)=>r+n,0);this._table.dataset.layout=s>0?"fixed":"auto",this._columns.forEach((r,n)=>{let o=a("col");e[n]>0?o.style.width=`${e[n]/s*100}%`:r.width&&r.width!=="auto"&&(o.style.width=String(r.width)),t.append(o)}),this._colgroup.replaceChildren(t)}_renderHeader(){let t=a("tr",{class:"zx-table__header-row"});if(this._growStep&&t.setAttribute("aria-rowindex","1"),this.options.selectable==="multi"){this._selectAll=a("input",{class:"zx-table__checkbox zx-table__select-all",type:"checkbox",ariaLabel:"Select all rows"});let e=a("th",{class:"zx-table__selection-header",scope:"col"},this._selectAll);t.append(e),this.listen(this._selectAll,"click",()=>{if(this._selectAll.checked)for(let s of this._visibleData())this._selected.add(this._idFor(s));else for(let s of this._visibleData())this._selected.delete(this._idFor(s));this._selectionAnchorId=null,this._syncSelection(),this._emitSelectionChange()})}else this._selectAll=null;this._headers=new Map;for(let e of this._columns){let s=a("th",{scope:"col"}),r=e.align??(Ei(e)?"end":null);if(r&&(s.dataset.align=r),e.headerTitle&&(s.title=e.headerTitle),e.sortable){let n=a("button",{class:"zx-table__sort-button",type:"button"},a("span",{class:"zx-table__header-label"},e.label));this.listen(n,"click",()=>{let o=this._sort?.id===e.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(e.id,o)}),s.append(n)}else s.append(a("span",{class:"zx-table__header-label"},e.label));this._headers.set(e.id,s),t.append(s)}this._thead.replaceChildren(t),this._syncSortHeader()}_renderBody(){this._abortEdit({focus:!1});let t=document.createDocumentFragment();this._rowMeta=new WeakMap,this._rowElements=new Map,this._rovingCell=null,this._rovingMatched=!1;let e=this._projectedData();this._hierarchyMeta=new Map(e.map(s=>[s.id,s])),this._data.length===0?t.append(a("tr",{class:"zx-table__empty-row"},a("td",{class:"zx-table__empty",colspan:this._columns.length+(this.options.selectable==="multi"?1:0)},this._emptyContent()))):this._visibleEntries().forEach((s,r)=>{t.append(this._createRow(s.row,s.index,{...s,visibleIndex:r}))}),this._tbody.replaceChildren(t),this._growStep&&this._table.setAttribute("aria-rowcount",String(e.length+1)),this._syncSelectAll(),this._syncGrowing(),this._stacked&&this._applyStackedRoles(!0)}_emptyContent(){let t=this.options.emptyText;return t==null?this.msg("table.empty"):typeof t=="function"?t():t}_createRow(t,e,s){let r=this._idFor(t),n=a("tr",{dataset:{row:""}});this._growStep&&n.setAttribute("aria-rowindex",String(s.visibleIndex+2));let o=typeof this.options.rowClass=="function"?this.options.rowClass(t):"";o&&n.classList.add(...String(o).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&n.setAttribute("aria-selected",String(this._selected.has(r))),this._hierarchy&&(n.setAttribute("aria-level",String(s.depth+1)),s.hasChildren&&n.setAttribute("aria-expanded",String(this._expanded.has(r)))),this._rowMeta.set(n,{row:t,id:r,index:e,visibleIndex:s.visibleIndex});let l=this._rowElements.get(r)??[];if(l.push(n),this._rowElements.set(r,l),this.options.selectable==="multi"){let h=a("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",checked:this._selected.has(r),ariaLabel:`Select row ${e+1}`});n.append(a("td",{class:"zx-table__selection-cell"},h))}return this._columns.forEach(h=>{let c=a("td"),u=h.align??(Ei(h)?"end":null);u&&(c.dataset.align=u),c.dataset.label=h.label,h.popin===!1&&(c.dataset.popin="false"),this._editMode!==!1&&(c.dataset.column=h.id,Se(h,t)!==!1&&(c.dataset.editable="true",c.tabIndex=-1,this._offerRovingCell(c,r,h.id))),this._renderCellContent(c,h,t,e,s),n.append(c)}),n}_renderCellContent(t,e,s,r,n=this._hierarchyMeta?.get(this._idFor(s))){let o=Ch(e,s,r),l=a("span",{class:"zx-table__cell-content"});if(o&&typeof o=="object"&&typeof o.nodeType=="number"?l.append(o):o!=null&&l.append(document.createTextNode(String(o))),!this._hierarchy||e.id!==this._hierarchy.column||!n){t.replaceChildren(...l.childNodes);return}let h=a("span",{class:"zx-table__tree-cell"});if(h.style.setProperty("--zx-table-depth",String(n.depth)),n.hasChildren){let c=this._expanded.has(n.id);h.append(a("button",{class:"zx-table__tree-toggle",type:"button",ariaExpanded:String(c),ariaLabel:`${c?"Collapse":"Expand"} row ${r+1}`},m(c?"chevron-down":"chevron-right",{size:14})))}else h.append(a("span",{class:"zx-table__tree-spacer",ariaHidden:"true"}));h.append(l),t.replaceChildren(h)}_handleBodyClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(this._edit&&ns(e))return;let s=e?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let r=this._rowMeta.get(s);if(!r||this._edit&&(this.commitEdit(),this._edit))return;if(e.closest(".zx-table__tree-toggle")){this.toggleRow(r.id);return}let o=e.closest(".zx-table__row-checkbox");if(o&&this.options.selectable==="multi"){this._toggleMultiSelection(r,o.checked,t.shiftKey);return}this.emit("rowclick",{...r,event:t}),this.options.selectable==="single"&&!this._selected.has(r.id)&&(this._selected=new Set([r.id]),this._selectionAnchorId=r.id,this._syncSelection(),this._emitSelectionChange())}_handleBodyDoubleClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(e?.closest(".zx-table__row-checkbox")||this._edit&&ns(e))return;let s=e?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let r=this._rowMeta.get(s);if(r){if(this._editMode!==!1){let n=e?.closest('td[data-editable="true"]');if(n&&this._tbody.contains(n)){this.startEdit(r.id,String(n.dataset.column));return}}this.emit("rowdblclick",{...r,event:t})}}_createEditor(t,e,s,r){let n=Se(e,s);if(n===!1)return null;let o=s?.[e.id],l=e.editorProps&&typeof e.editorProps=="object"?e.editorProps:{},h=a("span",{class:"zx-table__cell-shadow",ariaHidden:"true"});h.append(...t.childNodes);let c=a("div",{class:"zx-table__editor",dataset:{editor:n}});t.replaceChildren(h,c),t.dataset.editing="true";let u={column:e,type:n,td:t,host:c,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(n==="custom"){u.custom=o,u.read=()=>Ct(e,u.custom,s);let p={value:o,row:s,column:e,commit:x=>{u.custom=x,this.commitEdit()},cancel:()=>this.cancelEdit()},g=e.editor(s,p);return g&&typeof g.toElement=="function"?(typeof g.destroy=="function"&&(u.component=g),c.append(g.toElement())):g&&c.append(g),u.control=c.querySelector(zh)??c,u}if(n==="number"){let p=Tt(e.locale,s),g=ao(e,s),x=e.type==="currency"?Tt(e.currency,s):e.type==="unit"?Tt(e.unit,s):null,v={...p!=null&&!Object.prototype.hasOwnProperty.call(l,"locale")?{locale:p}:{},...g!=null&&!Object.prototype.hasOwnProperty.call(l,"precision")?{precision:g}:{},...x!=null&&!Object.prototype.hasOwnProperty.call(l,"unit")?{unit:String(x)}:{}},b=new mt(null,{...v,...l,value:o??null});return c.append(b.el),u.component=b,u.control=b.getInput(),u.read=()=>(b.set(b.getInput().value,{silent:!0}),Ct(e,b.get(),s)),u}if(n==="select"){let p=Dh(e.options,s),g=p.find(v=>Object.is(v.value,o))??p.find(v=>String(v.value)===String(o??"")),x=new $(null,{...l,items:p,valueKey:"value",labelKey:"label",value:g?g.value:null});return c.append(x.el),u.component=x,u.control=x.refs.input,u.read=()=>Ct(e,x.value,s),u}if(n==="date"){let p=new B(null,{...l,value:o??null});c.append(p.el),u.component=p;let g=p.refs.input;return u.control=g,u.read=()=>{let x=String(g.value??"").trim(),v=p.get();return x===""?Ct(e,null,s):(p.set(x,{silent:!0}),p.get()===null&&p.set(v,{silent:!0}),Ct(e,p.get(),s))},u}if(n==="checkbox"){let p=new K(null,{...l,checked:!!o});return c.append(p.el),u.component=p,u.control=p.el,u.read=()=>Ct(e,p.get(),s),u}let d=n==="textarea",f=a(d?"textarea":"input",{...l,class:d?"zx-table__editor-input zx-table__editor-textarea":"zx-table__editor-input",...d?{}:{type:"text"},ariaLabel:l.ariaLabel??`${e.label} row ${r+1}`,value:Ih(e,o,s)});return c.append(f),u.control=f,u.read=()=>Ct(e,f.value,s),u}_focusEditor(t){let e=this._edit?.cells.get(t),s=e?.control;!s||typeof s.focus!="function"||(s.focus(),e.type==="text"&&typeof s.select=="function"&&s.select())}_focusCell(t,e){let s=this._rowElements.get(t)?.[0];(s?no(s,e):null)?.focus()}_teardownEdit(){let t=this._edit;if(!t)return;this._edit=null;let e=this._data.findIndex(r=>Object.is(this._idFor(r),t.id)),s=e<0?t.row:this._data[e];for(let r of t.cells.values())r.destroy(),delete r.td.dataset.editing,delete r.td.dataset.invalid,this._renderCellContent(r.td,r.column,s,e<0?0:e);t.cells.clear(),delete t.tr.dataset.editing,this._clearInvalid()}_abortEdit({focus:t=!0}={}){let e=this._edit;if(!e)return;let s=t&&this._editHasFocus(),r=this.getRow(e.id)??e.row,n=this._columns.find(o=>o.id===e.columnId)??null;this._teardownEdit(),s&&this._focusCell(e.id,e.columnId),this.emit("editcancel",{row:r,id:e.id,column:n,columnId:e.columnId})}_editHasFocus(){let t=document.activeElement;return!!(t&&this.el?.contains(t))}_markInvalid(t,e){this._clearInvalid();let s=this._edit?.cells.get(t);s&&(s.td.dataset.invalid="true",s.control?.setAttribute("aria-invalid","true"),this._editMessage&&(s.control?.setAttribute("aria-describedby",this._editMessage.id),this._editMessage.textContent=e))}_clearInvalid(){if(this._edit)for(let t of this._edit.cells.values())delete t.td.dataset.invalid,t.control?.removeAttribute("aria-invalid"),t.control?.removeAttribute("aria-describedby");this._editMessage&&(this._editMessage.textContent="")}_handleEditKeydown(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(!e)return;if(this._edit&&ns(e)){if(Ph(e))return;if(t.key==="Escape"){if(t.defaultPrevented)return;t.preventDefault(),this.cancelEdit();return}if(t.key==="Enter"){if(e.localName==="textarea"&&t.shiftKey)return;t.preventDefault(),this.commitEdit();return}t.key==="Tab"&&this._moveEdit(t);return}if(t.key!=="Enter"&&t.key!=="F2")return;let s=e.closest('td[data-editable="true"]');if(!s||!this._tbody.contains(s))return;let r=this._rowMeta.get(s.parentElement);r&&(t.preventDefault(),this.startEdit(r.id,String(s.dataset.column)))}_moveEdit(t){let e=this._edit;if(!e)return;let s=t.shiftKey?-1:1,r=this._data.findIndex(o=>Object.is(this._idFor(o),e.id)),n=this._nextEditableCell(r,e.columnId,s);if(n&&Object.is(n.id,e.id)&&e.cells.has(n.columnId)){t.preventDefault(),e.columnId=n.columnId,this._focusEditor(n.columnId);return}if(!n){this.commitEdit(),this._edit&&t.preventDefault();return}t.preventDefault(),this.commitEdit(),this._edit||this.startEdit(n.id,n.columnId)}_nextEditableCell(t,e,s){let r=this._columns.length;if(t<0||r===0)return null;let n=this._visibleData(),o=this._idFor(this._data[t]),l=n.findIndex(u=>Object.is(this._idFor(u),o));if(l<0)return null;let h=this._columns.findIndex(u=>u.id===e),c=n.length*r+r;for(let u=0;u<c;u+=1){if(h+=s,h>=r?(l+=1,h=0):h<0&&(l-=1,h=r-1),l<0||l>=n.length)return null;let d=n[l],f=this._columns[h];if(Se(f,d)!==!1)return{id:this._idFor(d),columnId:f.id,index:this._data.indexOf(d)}}return null}_handleEditFocusIn(t){let s=(t.target?.nodeType===1?t.target:null)?.closest('td[data-editable="true"]');if(!s||!this._tbody.contains(s))return;let r=this._rowMeta.get(s.parentElement);r&&this._setRovingCell(s,r.id,String(s.dataset.column))}_handleDocumentPointerDown(t){if(!this._edit)return;let e=t.target?.nodeType===1?t.target:t.target?.parentElement;e&&ns(e)||e&&this._tbody.contains(e)||this.commitEdit()}_offerRovingCell(t,e,s){if(this._rovingMatched)return;let r=this._rovingKey!==null&&Object.is(this._rovingKey.id,e)&&this._rovingKey.columnId===s;!r&&this._rovingCell||(r&&this._rovingCell&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=r)}_setRovingCell(t,e,s){this._rovingCell&&this._rovingCell!==t&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=!0,this._rovingKey={id:e,columnId:s}}_msgOr(t,e){let s=this.msg(t);return s===t?e:s}_toggleMultiSelection(t,e,s){let r=this._visibleData(),n=r.findIndex(o=>Object.is(this._idFor(o),this._selectionAnchorId));if(s&&n>=0){let o=t.visibleIndex??r.findIndex(c=>Object.is(this._idFor(c),t.id)),l=Math.min(n,o),h=Math.max(n,o);for(let c=l;c<=h;c+=1){let u=this._idFor(r[c]);e?this._selected.add(u):this._selected.delete(u)}}else e?this._selected.add(t.id):this._selected.delete(t.id);this._selectionAnchorId=t.id,this._syncSelection(),this._emitSelectionChange()}_syncSelection(){for(let[t,e]of this._rowElements){let s=this._selected.has(t);for(let r of e){r.setAttribute("aria-selected",String(s));let n=r.querySelector(".zx-table__row-checkbox");n&&(n.checked=s)}}this._syncSelectAll()}_syncSelectAll(){if(!this._selectAll)return;let t=this._visibleData(),e=t.reduce((s,r)=>s+Number(this._selected.has(this._idFor(r))),0);this._selectAll.disabled=t.length===0,this._selectAll.checked=t.length>0&&e===t.length,this._selectAll.indeterminate=e>0&&e<t.length}_syncSortHeader(){if(this._headers)for(let[t,e]of this._headers)this._sort?.id===t?e.setAttribute("aria-sort",this._sort.dir==="asc"?"ascending":"descending"):e.removeAttribute("aria-sort")}_sortData(){if(!this._sort)return;let t=this._columns.find(s=>s.id===this._sort.id);if(!t)return;let e=typeof t.sortValue=="function"?t.sortValue:s=>s?.[t.id];this._data=this._hierarchy?Eh(this._data,this.options.rowId,this._hierarchy.parentId,e,this._sort.dir):Ti(this._data,e,this._sort.dir)}_setRowExpanded(t,e,s){return this._hierarchy?rs(this._data,this.options.rowId,this._hierarchy.parentId).some(n=>Object.is(n,t))?this._expanded.has(t)===e?this:(e?this._expanded.add(t):this._expanded.delete(t),this._renderBody(),s.silent||this._emitRowToggle(t,e),this):this:this}_emitRowToggle(t,e){let s=this.getRow(t);s&&this.emit("rowtoggle",{row:s,id:t,expanded:e})}_reconcileExpanded(){if(!this._hierarchy){this._expanded.clear();return}let t=rs(this._data,this.options.rowId,this._hierarchy.parentId),e=new Set(t);for(let s of this._expanded)e.has(s)||this._expanded.delete(s)}_pruneSelection(){let t=new Set(this._data.map(s=>this._idFor(s))),e=this._selected.size;for(let s of this._selected)t.has(s)||this._selected.delete(s);return t.has(this._selectionAnchorId)||(this._selectionAnchorId=null),e!==this._selected.size}_idFor(t){return typeof this.options.rowId=="function"?this.options.rowId(t):t?.[this.options.rowId]}_emitSelectionChange(){let t=this.getSelection();this.emit("selectionchange",{rows:t,ids:t.map(e=>this._idFor(e))})}_emitDataChange(){this.emit("datachange",{rows:this.getData()})}};function Ch(i,t,e=0){if(typeof i?.render=="function")return i.render(t,e);let s=t?.[i?.id],r=i?.type??"text";if(r==="text")return s;let n=Tt(i.locale,t),o=ao(i,t),l={...n!=null?{locale:String(n)}:{},...o!=null?{decimals:o}:{}};if(r==="number")return gt(s,l);if(r==="currency"){let h=Tt(i.currency,t);return Ze(s,h==null?null:String(h),l)}if(r==="percent")return ts(s,l);if(r==="unit"){let h=gt(s,l),c=Tt(i.unit,t);return h&&c!=null&&String(c)!==""?`${h}\xA0${c}`:h}return s}function Th(i,t,e,s=[]){let r=Di(i,t,e),n=s instanceof Set?s:new Set(s),o=[],l=r.roots.slice().reverse().map(h=>({node:h,depth:0}));for(;l.length;){let{node:h,depth:c}=l.pop();if(o.push({row:h.row,id:h.id,index:h.index,depth:c,hasChildren:h.children.length>0,parentId:h.parent?.id??null}),!!n.has(h.id))for(let u=h.children.length-1;u>=0;u-=1)l.push({node:h.children[u],depth:c+1})}return o}function Eh(i,t,e,s,r){let n=Di(i,t,e),o=c=>Ti(c,u=>s(u.row),r),l=[],h=o(n.roots).reverse();for(;h.length;){let c=h.pop();l.push(c.row);let u=o(c.children);for(let d=u.length-1;d>=0;d-=1)h.push(u[d])}return l}function Se(i,t){if(!i||typeof i!="object")return!1;if(typeof i.editor=="function")return typeof i.editable=="function"&&i.editable(t)===!1?!1:"custom";let e=typeof i.editable=="function"?i.editable(t):i.editable;return e===!0?Ei(i)?"number":"text":typeof e=="string"&&kh.has(e)?e:!1}function Dh(i,t){let e=typeof i=="function"?i(t):i;return Array.isArray(e)?e.map(s=>s!==null&&typeof s=="object"?{value:s.value,label:String(s.label??s.value??"")}:{value:s,label:String(s??"")}):e!==null&&typeof e=="object"?Object.entries(e).map(([s,r])=>({value:s,label:String(r??"")})):[]}function Ih(i,t,e){if(typeof i?.format=="function"){let s=i.format(t,e);return s==null?"":String(s)}return t==null?"":String(t)}function Ct(i,t,e){return typeof i?.parse=="function"?i.parse(t,e):t}function Nh(i,t){return Object.is(i,t)?!0:i instanceof Date&&t instanceof Date?i.getTime()===t.getTime():!1}function Mh(i,t){let e={};for(let[s,r]of Object.entries(t??{}))Nh(i?.[s],r)||(e[s]=r);return e}function Oh(i,t,e,s="Invalid value"){for(let r of t??[]){if(typeof r?.validate!="function"||!Object.prototype.hasOwnProperty.call(i??{},r.id))continue;let n=r.validate(i[r.id],e);if(typeof n=="string")return{columnId:r.id,message:n};if(n===!1)return{columnId:r.id,message:s}}return null}function Tt(i,t){return typeof i=="function"?i(t):i}function ao(i,t){let e=Tt(i?.decimals,t);if(e==null)return null;let s=Number(e);return Number.isFinite(s)?Math.max(0,Math.trunc(s)):null}function Ei(i){return["number","currency","percent","unit"].includes(i?.type)}function Di(i,t,e){let s=(Array.isArray(i)?i:[]).map((l,h)=>({row:l,id:ro(t,l),index:h,parent:null,children:[]})),r=new Map;for(let l of s)r.has(l.id)||r.set(l.id,l);let n=new Map;for(let l of s){let h=r.get(ro(e,l.row))??null;n.set(l,h===l?null:h)}for(let l of s){let h=new Set([l]),c=n.get(l)??null;for(;c;){if(h.has(c)){n.set(c,null);break}h.add(c),c=n.get(c)??null}}let o=[];for(let l of s)l.parent=n.get(l)??null,l.parent?l.parent.children.push(l):o.push(l);return{roots:o,nodes:s}}function rs(i,t,e){return Di(i,t,e).nodes.filter(s=>s.children.length>0).map(s=>s.id)}function ro(i,t){return typeof i=="function"?i(t):t?.[i]}function Fh(i,t){if(!i||typeof i!="object")return null;let e=i.parentId;if(typeof e!="string"&&typeof e!="function")return null;let s=typeof i.column=="string"?i.column:null,r=t.some(n=>n.id===s)?s:t[0]?.id;return r?{...i,parentId:e,column:r}:null}function Lh(i){return new Set(Array.isArray(i)?i:[])}function Rh(i){return i==="cell"||i==="row"?i:i===!0?"cell":!1}function ns(i){return!!i?.closest?.(".zx-table__editor")}function Ph(i){return i.closest("[popover]")?!0:i.getAttribute?.("aria-expanded")==="true"}function no(i,t){for(let e of i.cells)if(e.dataset.column===t)return e;return null}function Bh(i,t){return!i||typeof i!="object"||!t.some(e=>e.id===i.id)?null:{id:i.id,dir:i.dir==="desc"?"desc":"asc"}}function qh(i){if(typeof i!="string")return 0;let t=/^(\d*\.?\d+)fr$/.exec(i.trim());return t?Math.max(0,Number(t[1])):0}function oo(i){if(!Array.isArray(i))throw new TypeError("Table data must be an array")}function Hh(i,t){return i.size===t.size&&[...i].every(e=>t.has(e))}function Vh(i){let t=Math.trunc(Number(i));return Number.isFinite(t)&&t>0?t:null}var tt=Symbol("invalid attribute");function ee(i,t="string",e=console.warn){if(lo(t),t==="boolean")return i!==null;if(i!==null){if(t==="string")return i;if(t==="number"){let s=Number(i);return Number.isFinite(s)?s:(e(`Ignoring invalid number attribute: ${JSON.stringify(i)}`),tt)}try{return JSON.parse(i)}catch{return e(`Ignoring invalid JSON attribute: ${JSON.stringify(i)}`),tt}}}function Ii(i,t="string",e=console.warn){if(lo(t),t==="boolean")return i?"":null;if(i==null)return null;if(t==="number"){let s=Number(i);return Number.isFinite(s)?String(s):(e(`Ignoring invalid number property: ${String(i)}`),tt)}if(t==="json"){try{let s=JSON.stringify(i);if(s!==void 0)return s}catch{}return e("Ignoring property that cannot be serialized as JSON"),tt}return String(i)}function lo(i){if(!["string","number","boolean","json"].includes(String(i)))throw new TypeError(`Unknown reflected attribute type: ${String(i)}`)}var jh=Object.freeze(["change","input","submit","clear","open","close","cancel","invalid","query","loaded","rowclick","rowdblclick","sort","selectionchange","datachange"]),$h=et({checked:I({always:!0,set:(i,t)=>i.set(t,{silent:!0}),get:i=>i.get()}),value:C({default:!0}),label:C({default:null,rebuild:!0}),disabled:I({always:!0,set:Ae})}),Kh=et({checked:I({always:!0,set:(i,t)=>i.set(t,{silent:!0}),get:i=>i.get()}),value:C({option:null,default:"on"}),label:C({default:"",set:(i,t)=>i.setLabel(t)}),icon:I({rebuild:!0}),disabled:I({always:!0,set:Ae})}),Uh=et({items:ct({default:[],set:(i,t)=>i.setItems(t)}),value:C({default:null,set:(i,t)=>i.set(t,{silent:!0}),get:i=>i.value}),"value-key":C({property:"valueKey",default:"ID",rebuild:!0}),"label-key":C({property:"labelKey",default:"name",rebuild:!0}),placeholder:C({default:"",set:(i,t)=>{i.refs.input.placeholder=t}}),clearable:I({default:!1,rebuild:!0}),filter:C({default:!1,normalize:nc,rebuild:!0}),"search-keys":ct({property:"searchKeys",default:null,rebuild:!0}),"min-query":se({property:"minQuery",default:0,rebuild:!0}),debounce:se({default:200,rebuild:!0}),"list-height":se({property:"listHeight",default:280,rebuild:!0}),disabled:I({always:!0,set:Ae}),required:I({option:null,always:!0}),name:C({option:null,default:""})}),Yh=et({items:ct({default:[],set:(i,t)=>i.setItems(t)}),value:ct({option:null,default:[],set:(i,t)=>i.setValues(t),get:i=>i.getValues()}),"value-key":C({property:"valueKey",default:"ID",rebuild:!0}),"label-key":C({property:"labelKey",default:"name",rebuild:!0}),"checked-key":C({property:"checkedKey",default:"on",rebuild:!0}),search:I({rebuild:!0}),height:se({default:280,rebuild:!0}),"default-checked":I({property:"defaultChecked",default:!1,rebuild:!0}),disabled:I({option:null,always:!0,set:rc}),name:C({option:null,default:""})}),Wh=et({format:C({default:"%d.%m.%Y",rebuild:!0}),time:I({always:!0,rebuild:!0}),value:C({option:null,default:null,normalize:hc,set:(i,t)=>i.set(t,{silent:!0}),get:(i,t)=>Mi(i.get(),!!t.time),serialize:cc}),placeholder:C({default:null,rebuild:!0}),clearable:I({rebuild:!0}),disabled:I({always:!0,set:Ae}),required:I({option:null,always:!0}),name:C({option:null,default:""})}),Gh=et({value:se({default:0,set:(i,t)=>i.set(t,{silent:!0}),get:i=>i.get()}),unit:C({default:"minutes",rebuild:!0}),seconds:I({always:!0,rebuild:!0}),signed:I({always:!0,rebuild:!0}),disabled:I({always:!0,set:Ae}),name:C({option:null,default:""})}),Qh=et({value:C({default:"",set:(i,t)=>i.set(t,{silent:!0}),get:i=>i.get()}),placeholder:C({default:"",set:(i,t)=>{i.refs.input.placeholder=t}}),clearable:I({rebuild:!0}),debounce:se({default:250,rebuild:!0})}),Jh=et({title:C({default:"",set:(i,t)=>i.setTitle(t)}),open:I({default:!1,always:!0,set:(i,t)=>t?i.open():i.close(),get:i=>i.isOpen()})}),Xh=et({tabs:ct({default:[],normalize:ac,rebuild:!0}),active:C({default:null,set:(i,t)=>{t!==null&&i.openTab(t)},get:i=>i.getActive()}),variant:C({default:"divided",rebuild:!0}),"keep-alive":I({property:"keepAlive",rebuild:!0})}),Zh=et({columns:ct({default:[],rebuild:!0}),data:ct({default:[],set:(i,t)=>i.setData(t),get:i=>i.getData()}),"row-id":C({property:"rowId",default:"ID",rebuild:!0}),sort:ct({default:null,rebuild:!0}),"sort-mode":C({property:"sortMode",default:"local",rebuild:!0}),selectable:C({default:!1,normalize:oc,rebuild:!0}),"sticky-header":I({property:"stickyHeader",rebuild:!0}),height:C({default:null,normalize:po,rebuild:!0}),"empty-text":C({property:"emptyText",default:null,rebuild:!0}),zebra:I({rebuild:!0})}),tc=et({title:C({default:"",set:(i,t)=>i.setTitle(t)}),size:C({default:"md",normalize:po,rebuild:!0}),buttons:ct({default:[],set:(i,t)=>i.setButtons(t)}),closable:I({rebuild:!0}),open:I({option:null,default:!1,always:!0,set:(i,t)=>t?i.open():i.close(),get:i=>i.isOpen()})}),ec=Object.freeze([["toggle",K,{formAssociated:!0,attrs:$h}],["check-button",lt,{formAssociated:!0,attrs:Kh}],["select",$,{formAssociated:!0,attrs:Uh}],["checklist",X,{formAssociated:!0,attrs:Yh}],["datebox",B,{formAssociated:!0,attrs:Wh}],["timebox",nt,{formAssociated:!0,attrs:Gh}],["search",Zt,{formAssociated:!1,attrs:Qh}],["groupbox",bt,{formAssociated:!1,attrs:Jh}],["tabbox",te,{formAssociated:!1,attrs:Xh}],["table",yt,{formAssociated:!1,attrs:Zh}],["dialog",ht,{formAssociated:!1,attrs:tc}]]);function sc(i,{formAssociated:t=!1,attrs:e={}}={}){let s=uo(e),r=Object.freeze(Object.keys(s)),n=i===bt||i===ht;class o extends HTMLElement{static formAssociated=!!t;static get observedAttributes(){return r}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(s),n&&this._contentNodes===null&&(this._contentNodes=Array.from(this.childNodes)),t&&this._defaults===null&&this._captureDefaults(s),this._createComponent(i,s,n))}disconnectedCallback(){this._destroyComponent()}attributeChangedCallback(h,c,u){if(this._reflecting.has(h))return;let d=s[h];if(!d)return;let f=ee(u,d.type);if(f===tt)return;this._propertyValues.delete(d.property);let p=f===void 0?os(d.default):f;this._applyValue(h,d,p)}formDisabledCallback(h){this._disabledByForm=!!h,this._syncEffectiveDisabled(s),this._syncFormState(i)}formResetCallback(){if(!this._defaults)return;let h=Ni(i);!h||!this._defaults.has(h)||this._applyControlValue(s,h,os(this._defaults.get(h)))}formStateRestoreCallback(h,c){if(typeof h!="string")return;let u=dc(i,h);if(u===tt)return;let d=Ni(i);d&&this._applyControlValue(s,d,u)}get component(){return this._component}get form(){return this._internals?.form??null}get labels(){return this._internals?.labels??null}get validity(){return this._internals?.validity??null}get validationMessage(){return this._internals?.validationMessage??""}get willValidate(){return this._internals?.willValidate??!1}checkValidity(){return this._internals?.checkValidity()??!0}reportValidity(){return this._internals?.reportValidity()??!0}_upgradeProperties(h){for(let c of Object.values(h)){let u=c.property;if(!Object.prototype.hasOwnProperty.call(this,u))continue;let d=this[u];delete this[u],this[u]=d}}_captureDefaults(h){this._defaults=new Map;let c=Ni(i);if(c){let u=Object.values(h).find(d=>d.property===c);u&&this._defaults.set(c,os(this._readProperty(u)))}}_createComponent(h,c,u){let d={};for(let[g,x]of Object.entries(c)){if(!(this._propertyValues.has(x.property)||this.hasAttribute(g)||x.always)||x.option===null)continue;let b=this._currentValue(g,x);b===tt||b===void 0||(d[x.option]=ho(x,b,this))}let f=null;u&&(f=document.createDocumentFragment(),f.append(...this._contentNodes),d.content=f);let p=new h(null,d);this._component=p,i===bt&&f&&p.setContent(f),this.append(p.el),this._bridgeEvents(p,i);for(let[g,x]of Object.entries(c)){if(x.option!==null||!x.set||!(this._propertyValues.has(x.property)||this.hasAttribute(g)||x.always))continue;let b=this._currentValue(g,x);b!==tt&&b!==void 0&&this._applyValue(g,x,b,!0)}this._syncEffectiveDisabled(c),this._syncFormState(i)}_bridgeEvents(h,c){this._bridgeAbort?.abort(),this._bridgeAbort=new AbortController;for(let u of jh)h.on(u,d=>{if(this._applying)return;this._syncFormState(c);let f=new CustomEvent(`zx-${u}`,{detail:d.detail??{},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(f),f.defaultPrevented&&d.preventDefault()}),h.el.addEventListener(`zx-${u}`,d=>d.stopPropagation(),{signal:this._bridgeAbort.signal})}_destroyComponent(){this._bridgeAbort?.abort(),this._bridgeAbort=null,this._component&&(this._component.destroy(),this._component=null)}_rebuildComponent(h,c=n){this._component&&(c&&this._contentNodes&&document.createDocumentFragment().append(...this._contentNodes),this._destroyComponent(),this._createComponent(i,h,c))}_applyValue(h,c,u,d=!1){if(this._component){if(c.rebuild&&!d){this._rebuildComponent(s);return}if(!c.set){this._syncFormState(i);return}this._applying=!0;try{c.set(this._component,ho(c,u,this),this)}finally{this._applying=!1}h!=="disabled"&&this._syncEffectiveDisabled(s),this._syncFormState(i)}}_syncEffectiveDisabled(h){if(!(!this._component||!h.disabled?.set)){this._applying=!0;try{h.disabled.set(this._component,this.hasAttribute("disabled")||this._disabledByForm,this)}finally{this._applying=!1}}}_syncFormState(h){if(!this._internals||!this._component)return;let{formValue:c,state:u,empty:d}=uc(h,this._component,this);if(this._internals.setFormValue(c,u),(h===$||h===B)&&this.hasAttribute("required")&&d){let f=h===B?"Please enter a date.":"Please select a value.";this._internals.setValidity({valueMissing:!0},f,this._component.refs.input)}else this._internals.setValidity({})}_applyControlValue(h,c,u){let d=Object.entries(h).find(([,f])=>f.property===c);d&&this._applyValue(d[0],d[1],u)}_currentValue(h,c){if(this._propertyValues.has(c.property))return this._propertyValues.get(c.property);let u=ee(this.getAttribute(h),c.type);return u===void 0?c.default:u}_readProperty(h){if(this._component&&h.get)return h.get(this._component,this);if(this._propertyValues.has(h.property))return this._propertyValues.get(h.property);let c=ee(this.getAttribute(h.attribute),h.type);return c===tt||c===void 0?os(h.default):c}_writeProperty(h,c){this._propertyValues.set(h.property,c);let u=h.serialize?h.serialize(c,this):Ii(c,h.type);if(u!==tt){this._reflecting.add(h.attribute);try{u===null?this.removeAttribute(h.attribute):this.setAttribute(h.attribute,u)}finally{this._reflecting.delete(h.attribute)}}this._applyValue(h.attribute,h,c)}}for(let l of Object.values(s))Object.prototype.hasOwnProperty.call(o.prototype,l.property)||Object.defineProperty(o.prototype,l.property,{configurable:!0,enumerable:!0,get(){return this._readProperty(l)},set(h){this._writeProperty(l,h)}});return o}function co(i="zx"){if(typeof customElements>"u")throw new Error("Custom elements are not available in this environment");let t=String(i).trim();for(let[e,s,r]of ec){let n=`${t}-${e}`;customElements.get(n)||customElements.define(n,sc(s,r))}}function uo(i){let t={};for(let[e,s]of Object.entries(i)){let r=typeof s=="string"?{type:s}:{...s},n=r.property??ic(e);t[e]=Object.freeze({type:r.type??"string",option:Object.prototype.hasOwnProperty.call(r,"option")?r.option:n,property:n,default:r.default,always:!!r.always,rebuild:!!r.rebuild,normalize:r.normalize,serialize:r.serialize,set:r.set,get:r.get,attribute:e})}return Object.freeze(t)}function et(i){return uo(i)}function C(i={}){return{type:"string",...i}}function se(i={}){return{type:"number",...i}}function I(i={}){return{type:"boolean",default:!1,always:!0,...i}}function ct(i={}){return{type:"json",...i}}function ic(i){return i.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function ho(i,t,e){return i.normalize?i.normalize(t,e):t}function Ae(i,t){t?i.disable():i.enable()}function rc(i,t){i.el.setAttribute("aria-disabled",String(t)),i.refs.search&&(i.refs.search.disabled=t);for(let e of i.refs.list?.querySelectorAll("input")??[])e.disabled=t}function nc(i){return i===""||i==="true"?"local":i==="false"?!1:i}function oc(i){return i===""||i==="true"?"single":i==="false"?!1:i}function po(i){if(typeof i!="string"||i.trim()==="")return i;let t=Number(i);return Number.isFinite(t)?t:i}function ac(i){return Array.isArray(i)?i.map(t=>!t||typeof t!="object"||lc(t.content)||typeof t.content=="function"?t:{...t,content:document.createTextNode(String(t.content??""))}):i}function lc(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function hc(i){return typeof i!="string"?i:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(i)?P(i,"%Y-%m-%dT%H:%M"):/^\d{4}-\d{2}-\d{2}$/.test(i)?P(i,"%Y-%m-%d"):i}function cc(i,t){return i instanceof Date?Mi(i,!!t.time):Ii(i,"string")}function Mi(i,t){return!(i instanceof Date)||Number.isNaN(i.getTime())?"":A(i,t?"%Y-%m-%dT%H:%M":"%Y-%m-%d")}function Ni(i){return i===K||i===lt?"checked":[$,X,B,nt].includes(i)?"value":null}function uc(i,t,e){if(i===K||i===lt){let r=t.get(),n=i===K?!0:"on";return e._propertyValues.has("value")?n=e._propertyValues.get("value"):e.hasAttribute("value")&&(n=e.getAttribute("value")),{formValue:r?String(n):null,state:String(r),empty:!r}}if(i===$){let r=t.value;return{formValue:r===null?null:String(r),state:JSON.stringify(r),empty:r===null||r===""}}if(i===X){let r=JSON.stringify(t.getValues());return{formValue:r,state:r,empty:r==="[]"}}if(i===B){let r=Mi(t.get(),!!e.time);return{formValue:r||null,state:r,empty:r===""}}let s=String(t.get());return{formValue:s,state:s,empty:!1}}function dc(i,t){return i===K||i===lt?t==="true":i===$||i===X?ee(t,"json"):i===nt?ee(t,"number"):t}function os(i){return Array.isArray(i)?i.slice():i instanceof Date?new Date(i.getTime()):i}var pc=Object.freeze({label:"",icon:null,kind:"default",size:"md",disabled:!1});function q(i={}){let t={...pc,...i},e=a("button",{class:"zx-btn",type:"button",disabled:!!t.disabled,title:t.title,dataset:{kind:fc(t.kind),size:_c(t.size)}});return t.icon&&e.append(m(t.icon,{size:16})),t.label!==""&&e.append(a("span",{class:"zx-btn__label"},String(t.label))),!t.label&&t.title&&e.setAttribute("aria-label",t.title),typeof t.onclick=="function"&&(e.onclick=t.onclick),e}function fo(i){let t=a("div",{class:"zx-btn-group",role:"group"});return t.append(...i),t}function fc(i){return["primary","danger","ghost"].includes(String(i))?i:"default"}function _c(i){return i==="sm"?"sm":"md"}var mc=Object.freeze(["neutral","accent","success","warning","danger","info"]),gc=Object.freeze(["soft","solid","outline"]),bc=Object.freeze({label:"",icon:null,kind:"neutral",variant:"soft",size:"md",dot:!1});function _o(i={}){let t={...bc,...i},e=a("span",{class:"zx-badge",title:t.title,dataset:{kind:yc(t.kind),variant:xc(t.variant),size:vc(t.size)}});return t.dot?e.append(a("span",{class:"zx-badge__dot",ariaHidden:"true"})):t.icon&&e.append(m(t.icon,{size:12,class:"zx-badge__icon"})),t.label!==""&&t.label!=null?e.append(a("span",{class:"zx-badge__label"},String(t.label))):t.title&&(e.setAttribute("role","img"),e.setAttribute("aria-label",t.title)),e}function mo(i){let t=a("span",{class:"zx-badge-group"});return t.append(...i),t}function yc(i){return mc.includes(i)?i:"neutral"}function xc(i){return gc.includes(i)?i:"soft"}function vc(i){return i==="sm"?"sm":"md"}var wc=Object.freeze({md:40,sm:28}),Sc=Object.freeze({icon:"folder-open",title:"",description:"",actions:[],size:"md",align:"center"});function go(i={}){let t={...Sc,...i},e=kc(t.size),s=a("div",{class:"zx-empty-state",dataset:{size:e,align:zc(t.align)}});t.icon&&s.append(a("div",{class:"zx-empty-state__icon",ariaHidden:"true"},m(t.icon,{size:wc[e]}))),t.title&&s.append(a("p",{class:"zx-empty-state__title"},String(t.title))),t.description&&s.append(a("p",{class:"zx-empty-state__description"},String(t.description)));let r=Ac(t.actions);return r.length>0&&s.append(a("div",{class:"zx-empty-state__actions"},r)),s}function Ac(i){if(!Array.isArray(i))throw new TypeError("emptyState actions must be an array");return i.map(t=>{if(D(t))return t;if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("emptyState actions must be Elements or button descriptors");return q(t)})}function kc(i){return i==="sm"?"sm":"md"}function zc(i){return i==="start"?"start":"center"}var Cc=Object.freeze({size:"md",label:"",showLabel:!1,kind:"accent"}),Tc=Object.freeze({sm:!0,md:!0,lg:!0});function as(i={}){let t={...Cc,...i},e=String(t.label??""),s=a("span",{class:"zx-spinner",dataset:{size:Tc[t.size]?t.size:"md",kind:t.kind==="current"?"current":"accent"}},a("span",{class:"zx-spinner__ring",ariaHidden:"true"}));return e?(s.setAttribute("role","status"),s.append(a("span",{class:"zx-spinner__label",dataset:{visible:t.showLabel?"true":null}},e))):s.setAttribute("aria-hidden","true"),s}var ie=class extends _{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??a("div");this.el=t,this._max=Math.max(1,Number(this.options.max)||100),this._status=bo(this.options.status),this._indeterminate=!!this.options.indeterminate,this._labelId=y("zx-progress-label");let e=a("div",{ref:"head",class:"zx-progress-bar__head"},a("span",{ref:"label",class:"zx-progress-bar__label",id:this._labelId},String(this.options.label??"")),a("span",{ref:"value",class:"zx-progress-bar__value"})),s=a("div",{ref:"track",class:"zx-progress-bar__track",role:"progressbar",ariaValuemin:"0",ariaValuemax:String(this._max),ariaLabelledby:this._labelId},a("div",{ref:"fill",class:"zx-progress-bar__fill"}));return t.replaceChildren(e,s,a("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 s=Number(t),r=N(Number.isFinite(s)?s:0,0,this._max),n=r!==this._value,o=n&&r>=this._max;return this._value=r,this._sync(),!e&&n&&this.emit("change",{value:r,percent:this.percent()}),!e&&o&&this.emit("complete",{value:r}),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=bo(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:s}=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"),s.textContent="";return}let r=this._format();t.setAttribute("aria-valuenow",String(this._value)),t.setAttribute("aria-valuetext",r),e.style.setProperty("--zx-progress-fill",`${this.percent()}%`),s.replaceChildren(...this._readout(r))}_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(m(this._status==="success"?"success":"error",{size:14})),e.push(a("span",{class:"zx-progress-bar__percent"},t)),e}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&z(t,this._snapshot)}};function bo(i){return i==="success"||i==="error"?i:"active"}var Ec=new Set(["inactive","active","success","error"]),ls=class extends _{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??a("span");return this.el=t,t.replaceChildren(a("span",{ref:"indicator",class:"zx-inline-loading__indicator"}),a("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:s=!1}={}){let r=Ec.has(t)?t:"inactive";e!==void 0&&(this._description=String(e??""));let n=r!==this._status;return this._status=r,this._sync(),n&&!s&&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"?[as({size:"sm",kind:"current"})]:this._status==="success"?[m("success",{size:t})]:this._status==="error"?[m("error",{size:t})]:[]}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&z(t,this._snapshot)}};function hs(i={}){let t={width:"100%",height:"1rem",radius:"sm",...i};return a("span",{class:"zx-skeleton",ariaHidden:"true",dataset:{radius:Dc.has(t.radius)?t.radius:"sm"},style:{"inline-size":Oi(t.width),"block-size":Oi(t.height)}})}function xo(i={}){let t={lines:3,width:"100%",heading:!1,lastLineWidth:"60%",...i},e=N(Math.trunc(Number(t.lines)||0),1,20),s=a("div",{class:"zx-skeleton-text",ariaHidden:"true",style:{"inline-size":Oi(t.width)}});for(let r=0;r<e;r+=1){let n=t.heading&&r===0,o=r===e-1&&e>1;s.append(hs({width:o?t.lastLineWidth:"100%",height:n?"1.5rem":"0.75rem"}))}return s}function vo(i={}){let t={rows:5,columns:4,header:!0,...i},e=N(Math.trunc(Number(t.rows)||0),1,50),s=N(Math.trunc(Number(t.columns)||0),1,20),r=a("div",{class:"zx-skeleton-table",ariaHidden:"true",style:{"--zx-skeleton-columns":String(s)}});t.header!==!1&&r.append(yo(s,"header"));for(let n=0;n<e;n+=1)r.append(yo(s,"body"));return r}var Dc=new Set(["sm","md","full"]);function yo(i,t){let e=a("div",{class:"zx-skeleton-table__row",dataset:{kind:t}});for(let s=0;s<i;s+=1)e.append(a("span",{class:"zx-skeleton-table__cell"},hs({width:Ic(s,i),height:"0.75rem"})));return e}function Ic(i,t){return i===t-1?"55%":i%2===0?"80%":"65%"}function Oi(i){return typeof i=="number"?`${i}px`:String(i??"")}function wo(i={},...t){return a("div",{class:["zx-stack",i.class??""],dataset:{direction:i.direction==="row"?"row":null,align:ko.has(i.align)?i.align:null,justify:Nc.has(i.justify)?i.justify:null,wrap:i.wrap?"true":null,inline:i.inline?"true":null},style:zo("--zx-stack-gap",i.gap)},t)}function So(i={},...t){let e=Number(i.columns),s={...zo("--zx-grid-gap",i.gap),"--zx-grid-min":Oc(i.min??"16rem")};return Number.isFinite(e)&&e>=1&&(s["--zx-grid-columns"]=String(Math.trunc(e))),a("div",{class:["zx-grid",i.class??""],dataset:{columns:Number.isFinite(e)&&e>=1?"true":null,align:ko.has(i.align)?i.align:null},style:s},t)}function Ao(i={},...t){return a("div",{class:["zx-aspect",i.class??""],style:{"--zx-aspect-ratio":String(i.ratio??"16 / 9"),"--zx-aspect-fit":Mc.has(i.fit)?i.fit:"cover"}},t)}var ko=new Set(["start","center","end","stretch","baseline"]),Nc=new Set(["start","center","end","between","around"]),Mc=new Set(["cover","contain","fill"]);function zo(i,t){if(t==null||t==="")return{};let e=Number(t);return Number.isInteger(e)&&e>=1&&e<=8?{[i]:`var(--zx-space-${e})`}:{[i]:String(t)}}function Oc(i){return typeof i=="number"?`${i}px`:String(i)}function Co(i,t={}){let e=R(i);if(!e)throw new TypeError("truncate() target could not be resolved");let s=N(Math.trunc(Number(t.lines)||1),1,10),r=t.title!==!1,n=e.classList.contains("zx-truncate"),o=e.getAttribute("title"),l=!1,h=null;e.classList.add("zx-truncate"),s>1&&(e.dataset.lines=String(s),e.style.setProperty("--zx-truncate-lines",String(s)));let c=()=>(l=Fi(e),r&&(l?e.setAttribute("title",e.textContent?.trim()??""):o===null?e.removeAttribute("title"):e.setAttribute("title",o)),l);return c(),typeof ResizeObserver=="function"&&(h=new ResizeObserver(c),h.observe(e)),{update:c,isTruncated:()=>l,destroy:()=>{h?.disconnect(),h=null,n||e.classList.remove("zx-truncate"),delete e.dataset.lines,e.style.removeProperty("--zx-truncate-lines"),r&&(o===null?e.removeAttribute("title"):e.setAttribute("title",o))}}}function Fi(i){return i.scrollWidth-i.clientWidth>1||i.scrollHeight-i.clientHeight>1}var Fc=Object.freeze({text:"",label:"",title:"Copy",feedback:"Copied",feedbackDuration:2e3,size:"md",kind:"ghost"});function cs(i={}){let t={...Fc,...i},e=!t.label,s=a("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}),r=a("span",{class:"zx-copy-button__icon",ariaHidden:"true"},m("copy",{size:t.size==="sm"?12:14})),n=a("span",{class:"zx-copy-button__status",role:"status"});s.append(r),e||s.append(a("span",{class:"zx-copy-button__label"},String(t.label))),s.append(n);let o=0;return s.addEventListener("click",async()=>{let l=typeof t.text=="function"?String(t.text()):String(t.text??""),h=await ss(l);t.oncopy?.(l,h),h&&(clearTimeout(o),s.dataset.copied="true",r.replaceChildren(m("check",{size:t.size==="sm"?12:14})),n.textContent=String(t.feedback),o=setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,r.replaceChildren(m("copy",{size:t.size==="sm"?12:14})),n.textContent="")},Math.max(0,Number(t.feedbackDuration)||0)))}),s}var us=class extends _{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??a("div");this.el=t;let e=y("zx-copy-input"),s=a("input",{ref:"input",class:"zx-copy-input__field",type:"text",id:e,readOnly:!0,value:String(this.options.value??"")}),r=cs({text:()=>this.get(),title:String(this.options.buttonTitle),feedback:String(this.options.feedback),size:this.options.size==="sm"?"sm":"md",oncopy:(n,o)=>this.emit("copy",{value:n,copied:o})});return t.replaceChildren(a("label",{ref:"label",class:"zx-copy-input__label",for:e},String(this.options.label??"")),a("div",{class:"zx-copy-input__box"},s,r)),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(s,"focus",()=>s.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&&z(t,this._snapshot)}};var Eo=Symbol("zxDropdownPointerDismiss"),Do=Symbol("zxDropdownEscapeDismiss"),W=class extends _{static cssName="dropdown";static defaults={content:null,placement:"bottom-start",offset:4,matchWidth:!1,openOn:"click",closeOnSelect:!1};#t;#e=null;#s=new Map;#i=!1;constructor(t,e={}){let s=R(t);if(!s)throw new TypeError("Dropdown anchor could not be resolved");super(null,e),this.#t=s,this.#n("aria-expanded"),this.#n("aria-controls"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("aria-controls",this.el.id),this.setContent(this.options.content),this.options.openOn==="click"&&this.listen(this.#t,"click",()=>this.toggle()),this.listen(this.el,"click",()=>{this.options.closeOnSelect&&this.close()})}render(){let t=a("div",{id:y("zx-dropdown"),popover:"manual"});return t.dataset.state="closed",document.body.append(t),t}open(){return this.isOpen()||this.#i?this:(this.#e=V(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(Rc()),this.#t.setAttribute("aria-expanded","true"),Pc(),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"),Bc(),this):this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.#e!==null}setContent(t){return Lc(this.el,t),this.#e?.update(),this}getPanel(){return this.el}destroy(){if(!this.#i){this.#i=!0,this.close();for(let[t,e]of this.#s)qc(this.#t,t,e);super.destroy()}}[Eo](t){if(!this.isOpen())return;let e=t.composedPath();e.includes(this.el)||e.includes(this.#t)||this.close()}[Do](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()}#n(t){this.#s.set(t,this.#t.getAttribute(t))}},ke=class extends _{constructor(){super(null),this.listen(document,"pointerdown",t=>{let e=To();e instanceof W&&e[Eo](t)}),this.listen(document,"keydown",t=>{if(t.key!=="Escape")return;let e=To();e instanceof W&&e[Do](t)})}render(){let t=a("span",{hidden:!0,"data-zx-dropdown-dismiss-manager":""});return document.body.append(t),t}};function Lc(i,t){if(i.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t.nodeType=="number"&&i.append(t)}function To(){let i=null,t=-1;for(let e of document.querySelectorAll("[data-zx-overlay-order]")){let s=Number(e.getAttribute("data-zx-overlay-order"))||0;s>t&&(t=s,i=e)}return i?_.from(i):null}function Rc(){let i=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...i)+1}function Pc(){let i=document.querySelector("[data-zx-dropdown-dismiss-manager]"),t=i?_.from(i):null;return t instanceof ke?t:new ke}function Bc(){if(document.querySelector('.zx-dropdown[data-state="open"]'))return;let i=document.querySelector("[data-zx-dropdown-dismiss-manager]"),t=i?_.from(i):null;t instanceof ke&&t.destroy()}function qc(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}var ds='[role="menuitem"]',G=class extends _{static cssName="menu-button";static defaults={label:"",icon:null,kind:"default",items:[],placement:"bottom-start"};#t;#e;#s;#i;#n=[];#r=null;#o=!1;#a=!1;constructor(t=null,e={}){let s=t===null?null:R(t);if(t!==null&&(!s||s.tagName!=="BUTTON"))throw new TypeError("MenuButton target must resolve to a button");let r=s?{attributes:Array.from(s.attributes,o=>[o.name,o.value]),children:Array.from(s.childNodes)}:null,n=Object.hasOwn(e,"label");super(t,e),this.#o=s===null,this.#r=r,this.el.classList.add("zx-btn"),this.el.setAttribute("type","button"),this.el.setAttribute("data-kind",String(this.options.kind)),this.el.setAttribute("data-size","md"),this.#t=new W(this.el,{openOn:"manual",placement:this.options.placement,content:null}),this.#e=this.#t.getPanel(),this.#e.classList.add("zx-menu-button__menu"),this.#e.setAttribute("role","menu"),this.el.setAttribute("aria-haspopup","menu"),s&&n&&this.setLabel(this.options.label),this.setItems(this.options.items),this.#s=rt(this.#e,ds),this.#i=Y(()=>this.#u(),o=>o.focus()),this.#t.on("open",()=>this.emit("open")),this.#t.on("close",()=>this.emit("close")),this.listen(this.el,"click",()=>{this.isOpen()?this.close():(this.open(),this.#s.focusFirst())}),this.listen(this.el,"keydown",o=>this.#l(o)),this.listen(this.#e,"click",o=>{let l=o.target.closest?.(ds);l&&this.#e.contains(l)&&this.#c(l)}),this.listen(this.#e,"keydown",o=>this.#h(o))}render(){return this.el?this.el:a("button",{class:"zx-btn",type:"button","data-kind":this.options.kind,"data-size":"md"},Io(this.options.label,this.options.icon))}setItems(t){return this.#n=Array.isArray(t)?t.slice():[],this.#e.replaceChildren(),this.#n.forEach((e,s)=>{if(e==="-"){this.#e.append(a("div",{class:"zx-menu-button__separator",role:"separator"}));return}let r=[];e.icon&&r.push(a("span",{class:"zx-menu-button__icon"},m(e.icon))),r.push(a("span",{class:"zx-menu-button__label"},e.label)),this.#e.append(a("button",{class:"zx-menu-button__item",type:"button",role:"menuitem",tabindex:"-1","data-menu-item":String(s),"data-danger":e.danger?"true":null,ariaDisabled:e.disabled?"true":null},r))}),this}open(){return this.#t.open(),this}close(){return this.#t.close(),this}isOpen(){return this.#t.isOpen()}getTrigger(){return this.el}getPanel(){return this.#e}focusFirst(){return this.open(),this.#s.focusFirst(),this}focusLast(){return this.open(),this.#s.focusLast(),this}setLabel(t){return this.el.replaceChildren(...Io(t,this.options.icon)),this}destroy(){if(!this.#a&&(this.#a=!0,this.#s.destroy(),this.#t.destroy(),super.destroy(),!this.#o&&this.#r)){for(let t of Array.from(this.el.attributes))this.el.removeAttribute(t.name);for(let[t,e]of this.#r.attributes)this.el.setAttribute(t,e);this.el.replaceChildren(...this.#r.children)}}#l(t){["ArrowDown","ArrowUp","Enter"," "].includes(t.key)&&(t.preventDefault(),this.open(),t.key==="ArrowUp"?this.#s.focusLast():this.#s.focusFirst())}#h(t){if(t.key==="Escape"){t.preventDefault(),this.close(),this.el.focus();return}if(t.key==="Tab"){this.close();return}if(t.key==="Enter"||t.key===" "){let e=t.target.closest?.(ds);if(!e||!this.#e.contains(e))return;t.preventDefault(),this.#c(e);return}this.#i(t)}#c(t){let e=Number(t.getAttribute("data-menu-item")),s=this.#n[e];if(!(!s||s==="-"||s.disabled||this.emit("select",{value:s.value,item:s}).defaultPrevented))try{s.onselect?.(s.value,s,this)}finally{this.close()}}#u(){return Array.from(this.#e.querySelectorAll(ds))}};function Io(i,t){let e=[];return t&&e.push(a("span",{class:"zx-btn__icon"},m(t))),e.push(a("span",{class:"zx-btn__label"},String(i??""))),e}var Hc=["button","a[href]","input","select","textarea","[tabindex]"],Vc=Hc.flatMap(i=>[`.zx-toolbar > ${i}`,`.zx-toolbar > [role="group"] > ${i}`]).join(","),ps=class extends _{static cssName="toolbar";static defaults={items:[],align:"start",label:"Toolbar",overflow:!0,overflowLabel:"More",dense:!1};#t;#e=null;#s=null;#i=!1;#n=-1;#r=-1;#o=0;#a=!1;constructor(t=null,e={}){if(super(t,e),this.options.overflow){this.#e=new G(null,{icon:"dots",label:"",kind:"ghost",placement:"bottom-end"});let s=this.#e.toElement();s.classList.add("zx-toolbar__overflow"),s.setAttribute("aria-label",String(this.options.overflowLabel)),s.setAttribute("title",String(this.options.overflowLabel)),this.options.dense&&s.setAttribute("data-size","sm"),s.hidden=!0}this.#t=rt(this.el,Vc,{orientation:"horizontal"}),this.listen(this.el,"click",s=>this.#h(s)),this.setItems(this._initialItems),this.#e&&typeof ResizeObserver=="function"&&(this.#s=new ResizeObserver(()=>this.#u()),this.#s.observe(this.el))}render(){this._records=[],this._named=new Map,this._createdRoot=!this.el;let t=this.el??a("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=$c(this.options.align),t.dataset.overflow=this.options.overflow?"true":"false",this.options.dense&&(t.dataset.dense="true"),t}setItems(t){for(let s of this._records)s.type==="element"&&(s.element.hidden=s.userHidden);this._records=jc(t).map(s=>this.#l(s)),this._named=new Map;for(let s of this._records)s.name!==null&&!this._named.has(s.name)&&this._named.set(s.name,s);let e=this._records.map(s=>s.element);if(this.#e){this.#e.setItems([]);let s=this.#e.toElement();s.hidden=!0,e.push(s)}return this.el.replaceChildren(...e),this.#n=-1,this.#r=-1,this.#d(),this}getItem(t){return this._named.get(String(t))?.element??null}enable(t){return this.#c(t,!1)}disable(t){return this.#c(t,!0)}setActive(t,e=!0){let s=this._named.get(String(t));return s&&s.element.setAttribute("aria-pressed",e?"true":"false"),this}destroy(){if(!this.#a){this.#a=!0,this.#s?.disconnect(),this.#s=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||z(this.el,this._snapshot)}}#l(t){if(t.type==="separator")return{type:"separator",element:a("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 l=t.element;return{type:"element",element:l,name:l.dataset?.name??null,label:Mo(l),icon:null,onclick:null,userHidden:!!l.hidden}}let{name:e=null,active:s,onclick:r,...n}=t.descriptor,o=q({size:this.options.dense?"sm":"md",...n});return s!==void 0&&o.setAttribute("aria-pressed",s?"true":"false"),e!==null&&(o.dataset.name=String(e)),{type:"descriptor",element:o,name:e===null?null:String(e),label:String(n.label??n.title??""),icon:n.icon??null,onclick:typeof r=="function"?r:null,userHidden:!1}}#h(t){let e=t.target;if(!e)return;let s=this._records.find(r=>r.type==="descriptor"&&r.element.contains(e));s&&(this.emit("action",{name:s.name,item:s.element}),s.onclick?.(t))}#c(t,e){let s=this._named.get(String(t));if(!s)return this;let r=s.element;return"disabled"in r?r.disabled=e:e?r.setAttribute("aria-disabled","true"):r.removeAttribute("aria-disabled"),this.#p(),this}#u(){if(!(this.#o!==0||this.#a)){if(typeof requestAnimationFrame!="function"){this.#d();return}this.#o=requestAnimationFrame(()=>{this.#o=0,this.#d()})}}#d(){if(this.#i||this.#a||!this.#e)return;let t=this.el;if(typeof getComputedStyle!="function"||!t.isConnected)return;let e=getComputedStyle(t),s=parseFloat(e.columnGap)||0,r=(parseFloat(e.paddingInlineStart)||0)+(parseFloat(e.paddingInlineEnd)||0),n=t.clientWidth-r,o=t.clientHeight;if(!(!(n>0)||n===this.#n&&o===this.#r)){this.#i=!0;try{let l=this.#e.toElement(),h=this._records.filter(g=>!g.userHidden);for(let g of h)g.element.hidden=!1;l.hidden=!1;let c=h.map(g=>g.element.getBoundingClientRect().width),u=c.reduce((g,x)=>g+x,0)+s*Math.max(0,c.length-1),d=l.getBoundingClientRect().width,f=[];if(u>n){let g=n-d-s,x=0,v=!1;for(h.forEach((b,w)=>{let E=x+c[w]+(x>0?s:0);if(!v&&E<=g){x=E;return}v=!0,b.element.hidden=!0,f.push(b)});h.length>f.length;){let b=h[h.length-f.length-1];if(b.type!=="separator")break;b.element.hidden=!0,f.unshift(b)}}let p=No(f);this.#e.setItems(p),l.hidden=p.length===0,this.#n=n,this.#r=t.clientHeight}finally{this.#i=!1}}}#p(){if(!this.#e)return;let t=this._records.filter(e=>!e.userHidden&&e.element.hidden);this.#e.setItems(No(t))}};function jc(i){if(i!=null&&!Array.isArray(i))throw new TypeError("Toolbar items must be an array");let t=[];for(let e of i??[])if(e!=null){if(e==="-"){t.length>0&&t[t.length-1].type!=="separator"&&t.push({type:"separator"});continue}if(D(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 No(i){let t=[];for(let e of i){if(e.type==="separator"){t.length>0&&t[t.length-1]!=="-"&&t.push("-");continue}let s=e.element;t.push({label:e.label||Mo(s)||"\u2026",icon:e.icon??void 0,value:e.name,disabled:!!s.disabled||s.getAttribute("aria-disabled")==="true",onselect:()=>s.click()})}for(;t.length>0&&t[t.length-1]==="-";)t.pop();return t}function Mo(i){return(i.getAttribute("aria-label")??i.getAttribute("title")??i.textContent??"").trim()}function $c(i){return["end","between"].includes(i)?i:"start"}var fs=class extends _{static cssName="panel";static defaults={title:"",content:null,open:!0,collapsible:!0,buttons:[],footer:null,footerButtons:[]};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??a("section");this.el=e,this._createdRoot=t,this._original=t?null:Kc(e),this._cleaned=!1,this._open=!!this.options.open,this._collapsible=!!this.options.collapsible,this._hasFooterContent=!1;let s=t?[]:Array.from(e.childNodes),r=y("zx-panel-body"),n=a("span",{class:"zx-panel__title",ref:"title"}),o=[];this._collapsible&&o.push(a("span",{class:"zx-panel__chevron",ariaHidden:"true"},m("chevron-right",{size:16}))),o.push(n);let l=this._collapsible?a("button",{class:"zx-panel__toggle",ref:"toggle",type:"button",ariaControls:r,ariaExpanded:String(this._open)},o):a("div",{class:"zx-panel__toggle",ref:"toggle"},o),h=a("div",{class:"zx-panel__header",ref:"header"},l,a("div",{class:"zx-panel__buttons",ref:"buttons",role:"group",ariaLabel:"Panel actions"})),c=a("div",{class:"zx-panel__content",ref:"content"}),u=a("div",{class:"zx-panel__body",ref:"body",id:r},c),d=a("div",{class:"zx-panel__footer",ref:"footer",hidden:!0},a("div",{class:"zx-panel__footer-content",ref:"footerContent"}),a("div",{class:"zx-panel__footer-buttons",ref:"footerButtons",role:"group",ariaLabel:"Panel footer actions"}));return e.replaceChildren(h,u,d),this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):c.append(...s),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),this.setFooterButtons(this.options.footerButtons),this._syncOpenState(),this._collapsible&&this.listen(l,"click",()=>this.toggle()),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return Oo(this.refs.content,t,"Panel content"),this}setButtons(t){return this.refs.buttons.replaceChildren(...this._buildButtons(t,"Panel buttons")),this}setFooter(t){return Oo(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&&Uc(this.el,this._original))}_syncOpenState(){this.el.setAttribute("data-state",this._open?"open":"closed"),this.refs.body.hidden=!this._open,this._collapsible&&this.refs.toggle.setAttribute("aria-expanded",String(this._open))}_syncFooter(){this.refs.footer.hidden=!this._hasFooterContent&&this.refs.footerButtons.childElementCount===0}_buildButtons(t,e){if(!Array.isArray(t))throw new TypeError(`${e} must be an array`);return t.map(s=>{if(D(s))return s;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError(`${e} must be Elements or button descriptors`);let r={...s},n=r.onclick;delete r.onclick;let o=q(r);return typeof n=="function"&&this.listen(o,"click",n),o})}};function Kc(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Uc(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function Oo(i,t,e){if(i.replaceChildren(),t===null)return;if(typeof t=="string"){i.append(document.createTextNode(t));return}let s=t instanceof _?t.toElement():t;if(s&&typeof s.nodeType=="number"){i.append(s);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}var Yc=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"]),_s=class extends _{static cssName="master-panel";static defaults={title:"",content:null,buttons:[],module:null,footer:null};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??a("section");this.el=e,this._createdRoot=t,this._original=t?null:Wc(e),this._cleaned=!1;let s=t?[]:Array.from(e.childNodes),r=a("header",{class:"zx-master-panel__header"},a("h1",{class:"zx-master-panel__title",ref:"title"}),a("div",{class:"zx-master-panel__buttons",ref:"buttons",role:"group",ariaLabel:"Panel actions"})),n=a("div",{class:"zx-master-panel__content",ref:"content"}),o=a("footer",{class:"zx-master-panel__footer",ref:"footer",hidden:!0});e.replaceChildren(r,n,o);let l=Qc(this.options.module);return e.dataset.module=l,e.style.setProperty("--zx-master-panel-accent",`var(--zx-module-${l})`),this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):n.append(...s),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return Fo(this.refs.content,t,"MasterPanel content"),this}setButtons(t){if(!Array.isArray(t))throw new TypeError("MasterPanel buttons must be an array");let e=t.map(s=>{if(D(s))return s;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("MasterPanel buttons must be Elements or button descriptors");let r={...s},n=r.onclick;delete r.onclick;let o=q(r);return typeof n=="function"&&this.listen(o,"click",n),o});return this.refs.buttons.replaceChildren(...e),this}setFooter(t){return Fo(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&&Gc(this.el,this._original))}};function Wc(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Gc(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function Fo(i,t,e){if(i.replaceChildren(),t===null)return;if(typeof t=="string"){i.append(document.createTextNode(t));return}let s=t instanceof _?t.toElement():t;if(s&&typeof s.nodeType=="number"){i.append(s);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}function Qc(i){let t=String(i??"default").toLowerCase();return Yc.includes(t)?t:"default"}function re(i,t){if(!i)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",s=new AbortController,{signal:r}=s,n=!1,o=null,l=0,h=0,c=!1,u=0,d=b=>e?b.clientY:b.clientX,f=()=>!!t.disabled?.(),p=()=>{let b=o;if(o=null,b!==null)try{i.releasePointerCapture(b)}catch{}},g=()=>{u!==0&&(cancelAnimationFrame(u),u=0)},x=()=>{n=!1,c=!1,g(),p()};i.addEventListener("pointerdown",b=>{let w=b;if(!(f()||n||w.button!==0)&&t.onStart?.(w)!==!1){n=!0,o=w.pointerId,l=d(w),h=l,c=!1;try{i.setPointerCapture(w.pointerId)}catch{}}},{signal:r}),i.addEventListener("pointermove",b=>{let w=b;!n||w.pointerId!==o||(h=d(w),h!==l&&(c=!0),u===0&&(u=requestAnimationFrame(()=>{u=0,n&&t.onMove(h-l)})))},{signal:r});let v=b=>{let w=b;if(!n||w.pointerId!==o)return;g(),h=d(w);let E=c,H=h-l;x(),t.onEnd?.(H,E)};return i.addEventListener("pointerup",v,{signal:r}),i.addEventListener("pointercancel",v,{signal:r}),i.addEventListener("keydown",b=>{let w=b;if(f())return;if((w.key==="Enter"||w.key===" ")&&t.onActivate){w.preventDefault(),t.onActivate();return}if(w.key==="Home"||w.key==="End"){if(!t.onJump)return;w.preventDefault(),t.onJump(w.key==="Home"?"min":"max");return}let E=e?"ArrowUp":"ArrowLeft",H=e?"ArrowDown":"ArrowRight";w.key!==E&&w.key!==H||t.onStep&&(w.preventDefault(),t.onStep(w.key===H?1:-1,w.shiftKey))},{signal:r}),{isDragging:()=>n,cancel(){n&&x()},destroy(){x(),s.abort()}}}function Q(i,t){if(typeof i=="number")return Number.isFinite(i)?i:Number.NaN;if(typeof i!="string")return Number.NaN;let e=/^([+-]?(?:\d+\.?\d*|\.\d+))(px|%)?$/i.exec(i.trim());if(!e)return Number.NaN;let s=Number(e[1]);if(!Number.isFinite(s))return Number.NaN;if((e[2]??"").toLowerCase()!=="%")return s;let r=Number(t);return Number.isFinite(r)?s/100*r:Number.NaN}var Jc="split-view",ys=class extends _{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;#s=null;constructor(t=null,e={}){super(t,e);let s=this.options.storageKey;if(s!=null&&s!==""){this.#e=Jt(Jc);let o=this.#e.get(String(s));typeof o=="number"&&Number.isFinite(o)&&o>=0&&this.setSize(o)}let r=this.options.collapsed;r==="start"||r==="end"?this.#o(r,!1):r===!0&&this.options.collapsible&&this.#o(this.options.collapsible==="end"?"end":"start",!1);let n=this.refs.divider;this.#s=re(n,{orientation:this._orientation,disabled:()=>this._disabled,onStart:()=>{this._startSize=this.getSize(),this.el.dataset.dragging="true"},onMove:o=>this.#a(o,!1),onEnd:(o,l)=>{l&&this.#a(o,!0),delete this.el.dataset.dragging,l&&(this.#_(),this.#f())},onStep:(o,l)=>this.#l(o*(l?64:16)),onJump:o=>this.#h(o),onActivate:()=>{this.options.collapsible&&(this._collapsed===null?this.collapse(this.options.collapsible):this.expand())}}),this.listen(n,"dblclick",()=>this.#d()),typeof ResizeObserver=="function"&&(this.#t=new ResizeObserver(()=>this.#p()),this.#t.observe(this.el)),this.#r()}render(){let t=this.options;this._orientation=t.orientation==="vertical"?"vertical":"horizontal";let e=Q(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 s=this.el??a("div");this.el=s,this._snapshot=this._createdRoot?null:k(s);let r=this._createdRoot||t.start!=null||t.end!=null?[]:Array.from(s.children),n=y("zx-split-start"),o=a("div",{class:"zx-split-view__pane",id:n,ref:"start",dataset:{pane:"start"}}),l=a("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:n}),h=a("div",{class:"zx-split-view__pane",ref:"end",dataset:{pane:"end"}});return s.replaceChildren(o,l,h),s.dataset.orientation=this._orientation,this._disabled&&l.setAttribute("aria-disabled","true"),s.style.setProperty("--zx-split-size",ms(t.size)),t.start!=null?gs(o,t.start,"SplitView start"):r[0]&&o.append(r[0]),t.end!=null?gs(h,t.end,"SplitView end"):r[1]&&h.append(...r.slice(1)),s}setSize(t){let{total:e,divider:s,min:r,max:n}=this.#i(),o=Q(t,e>0?e:Number.NaN);return Number.isFinite(o)?(this.#n(ut({size:o,min:r,max:n,total:e,divider:s})),this):(this._size=null,this.el.style.setProperty("--zx-split-size",ms(t)),this.#r(),this)}getSize(){if(this._collapsed==="start")return 0;let{total:t,divider:e}=this.#i();if(this._collapsed==="end")return Math.max(0,t-e);if(this._size!==null)return this._size;let s=Lo(this.refs.start,this._orientation);if(s>0)return s;let r=Q(this.options.size,t);return Number.isFinite(r)?Math.max(0,r):0}getRatio(){let{total:t}=this.#i();return t>0?this.getSize()/t:0}setStart(t){return gs(this.refs.start,t,"SplitView start"),this}setEnd(t){return gs(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.#r(),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.#s?.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.#s?.destroy(),this.#s=null,this.#t?.disconnect(),this.#t=null,super.destroy(),!this._createdRoot&&this._snapshot&&z(this.el,this._snapshot))}#i(){let t=this.el,e=this._orientation==="vertical"?t.clientHeight:t.clientWidth,s=this.options.max==null?null:Number(this.options.max);return{total:Number.isFinite(e)&&e>0?e:0,divider:Lo(this.refs.divider,this._orientation),min:Math.max(0,Number(this.options.min)||0),max:Number.isFinite(s)?s:null}}#n(t){this._size=t,this.el.style.setProperty("--zx-split-size",`${t}px`),this.#r()}#r(){let{total:t,divider:e,min:s,max:r}=this.#i(),n=bs({min:s,max:r,total:t,divider:e}),o=this.refs.divider;o.setAttribute("aria-valuemin",String(Math.round(n.min))),o.setAttribute("aria-valuemax",String(Math.round(n.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.#r(),e&&this.emit("collapse",{pane:t}),this)}#a(t,e){if(this._destroyed)return;let{total:s,divider:r,min:n,max:o}=this.#i();if(s<=0)return;this._collapsed!==null&&this.expand();let l=ut({size:this._startSize+t,min:n,max:o,total:s,divider:r});e&&(l=ut({size:Li(l,this.#u(s,r),Number(this.options.snap)),min:n,max:o,total:s,divider:r})),l!==this._size&&(this.#n(l),this.emit("resize",{size:l,ratio:l/s}))}#l(t){let{total:e,divider:s,min:r,max:n}=this.#i();e<=0||(this._collapsed!==null&&this.expand(),this.#c(ut({size:this.getSize()+t,min:r,max:n,total:e,divider:s}),e))}#h(t){let{total:e,divider:s,min:r,max:n}=this.#i();if(e<=0)return;this._collapsed!==null&&this.expand();let o=bs({min:r,max:n,total:e,divider:s});this.#c(ut({size:o[t],min:r,max:n,total:e,divider:s}),e)}#c(t,e){t!==this._size&&(this.#n(t),this.emit("resize",{size:t,ratio:t/e}),this.#_(),this.#f())}#u(t,e){let{min:s,max:r}=this.#i(),n=bs({min:s,max:r,total:t,divider:e}),o=[n.min,n.max],l=Q(this.options.size,t);return Number.isFinite(l)&&o.unshift(l),o}#d(){if(this._disabled)return;this._collapsed!==null&&this.expand();let t=Q(this.options.size,Number.NaN);Number.isFinite(t)?this.setSize(t):(this._size=null,this.el.style.setProperty("--zx-split-size",ms(this.options.size)),this._lastTotal=-1,this.#p());let{total:e}=this.#i(),s=this.getSize();this.emit("resize",{size:s,ratio:e>0?s/e:0}),this.#_(),this.#f()}#p(){if(this._destroyed||this.#s?.isDragging())return;let{total:t,divider:e,min:s,max:r}=this.#i();if(t<=0||t===this._lastTotal)return;if(this._lastTotal=t,this._size===null){let o=Q(this.options.size,t);if(Number.isFinite(o)){let l=ut({size:o,min:s,max:r,total:t,divider:e});this.el.style.setProperty("--zx-split-size",Math.abs(l-o)>.5?`${l}px`:ms(this.options.size))}this.#r();return}let n=ut({size:this._size,min:s,max:r,total:t,divider:e});if(n===this._size){this.#r();return}this.#n(n),this.emit("resize",{size:n,ratio:n/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)))}#f(){let{total:t}=this.#i(),e=this.getSize();this.emit("resizeend",{size:e,ratio:t>0?e/t:0})}};function ut({size:i,min:t=0,max:e=null,total:s=0,divider:r=0}){let n=Number(i),o=bs({min:t,max:e,total:s,divider:r});return Math.max(0,(Number(s)||0)-Math.max(0,Number(r)||0))>0?Number.isFinite(n)?Math.min(o.max,Math.max(o.min,n)):o.min:Number.isFinite(n)?Math.max(0,n):o.min}function Li(i,t,e){let s=Number(i),r=Number(e);if(!Number.isFinite(s)||!Number.isFinite(r)||r<=0)return s;let n=Array.isArray(t)?t:t==null?[]:[t],o=s,l=Number.POSITIVE_INFINITY;for(let h of n){let c=Number(h);if(!Number.isFinite(c))continue;let u=Math.abs(c-s);u<=r&&u<l&&(l=u,o=c)}return o}function bs({min:i=0,max:t=null,total:e=0,divider:s=0}){let r=Math.max(0,(Number(e)||0)-Math.max(0,Number(s)||0)),n=t==null||!Number.isFinite(Number(t))?r:Math.min(r,Math.max(0,Number(t)));return{min:Math.min(Math.max(0,Number(i)||0),n),max:n}}function Lo(i,t){let e=i.getBoundingClientRect(),s=t==="vertical"?e.height:e.width;return Number.isFinite(s)&&s>0?s:0}function ms(i){return typeof i=="number"&&Number.isFinite(i)?`${i}px`:String(i)}function gs(i,t,e){if(i.replaceChildren(),t==null)return;if(typeof t=="string"||typeof t=="number"){i.append(document.createTextNode(String(t)));return}let s=t instanceof _?t.toElement():t;if(s&&typeof s.nodeType=="number"){i.append(s);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}var Xc="dock",xs=class extends _{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 s=this.options.storageKey;if(s!=null&&s!==""){this._store=Jt(Xc);let r=this._store.get(String(s));r&&typeof r=="object"&&this.setState(r)}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??a("div");this.el=e,this._snapshot=this._createdRoot?null:k(e),e.dataset.orientation=this._orientation,e.replaceChildren(),this._content=t.content==null?null:a("div",{class:"zx-dock__content",ref:"content"}),this._content&&Pi(this._content,t.content,!1);for(let s of Array.isArray(t.panes)?t.panes:[])this._panes.set(String(s.name),this._buildPane(s));return this._layout(),e}pane(t){return this._panes.get(String(t))??null}names(){return[...this._panes.keys()]}add(t,e={}){let s=String(t?.name??"");if(!s)throw new TypeError("Dock pane requires a name");this._panes.has(s)&&this.remove(s);let r=this._buildPane(t),n=[...this._panes.entries()],o=Number.isInteger(e.index)?N(Number(e.index),0,n.length):n.length;return n.splice(o,0,[s,r]),this._panes=new Map(n),this._layout(),this._syncGrow(),this._syncDividers(),r}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),s=this._panes.get(e);if(s)this.expand(e);else for(let r of this._panes.values())if(r.tabs?.has(e)){s=r,this.expand(r.name),this.activate(r.name,e);break}return s?(s.element.scrollIntoView({block:"nearest",inline:"nearest"}),this.emit("reveal",{name:s.name}),this):this}setSize(t,e){let s=this._panes.get(String(t));if(!s)return this;let r=Ri(e);return r===null?s.element.style.removeProperty("--zx-pane-size"):s.element.style.setProperty("--zx-pane-size",r),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 s=this._panes.get(String(t)),r=s?.tabs?.get(String(e));if(!r||s.active===r.name)return this;let n=s.active;s.active=r.name;for(let o of s.tabs.values()){let l=o===r;o.tab.setAttribute("aria-selected",String(l)),o.tab.tabIndex=l?0:-1,o.panel.hidden=!l}return this._materialize(s),this._persist(),this.emit("tabchange",{pane:s.name,tab:r.name,previous:n}),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 s=this._axisSize(e.element);s>0&&(t.sizes[e.name]=s)}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 s of this._panes.values()){if(s.kind==="sheet")continue;let r=t.sizes?.[s.name];typeof r=="number"&&Number.isFinite(r)&&r>0&&s.element.style.setProperty("--zx-pane-size",`${r}px`);let n=t.active?.[s.name];n&&s.tabs?.has(String(n))&&this.activate(s.name,String(n));let o=e.has(s.name);o!==s.collapsed&&s.collapsible&&(s.collapsed=o,this._syncPaneState(s))}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&&z(this.el,this._snapshot)}}_buildPane(t){let e=String(t.name),s=String(t.title??""),r=t.collapsible??this.options.collapsible!==!1,n=y("zx-dock-body"),o=Array.isArray(t.tabs)&&t.tabs.length>0,l=a("span",{class:"zx-dock__chevron",ariaHidden:"true"},m("chevron-right",{size:14})),h=a("button",{class:"zx-dock__toggle",type:"button",ariaControls:n,ariaExpanded:"true",ariaLabel:o?s||e:null},l,o?null:a("span",{class:"zx-dock__title"},s));r||(h.disabled=!0);let c=a("div",{class:"zx-dock__header"},h),u=a("div",{class:"zx-dock__body",id:n}),d=a("section",{class:"zx-dock__pane",dataset:{name:e,state:"open"}},c,u),f={name:e,title:s,element:d,header:c,body:u,toggle:h,collapsible:r,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 g=a("div",{class:"zx-dock__tabs",role:"tablist",ariaOrientation:"horizontal",ariaLabel:s||e});for(let b of t.tabs){let w=String(b.name),E=y("zx-dock-tab"),H=y("zx-dock-panel"),ar=a("button",{class:"zx-dock__tab",type:"button",role:"tab",id:E,ariaControls:H,ariaSelected:"false",tabindex:-1},String(b.title??w)),lr=a("div",{class:"zx-dock__panel",role:"tabpanel",id:H,ariaLabelledby:E,tabindex:0,hidden:!0});g.append(ar),u.append(lr),f.tabs.set(w,{name:w,tab:ar,panel:lr,content:b.content,built:!1})}c.append(g),f.roving=rt(g,".zx-dock__tab",{orientation:"horizontal"}),this.listen(g,"click",b=>{let w=b.target.closest?.(".zx-dock__tab");if(!w||!g.contains(w))return;let E=[...f.tabs.values()].find(H=>H.tab===w);E&&this.activate(f.name,E.name)});let x=String(t.active??""),v=f.tabs.has(x)?x:[...f.tabs.keys()][0];f.active=v;for(let b of f.tabs.values()){let w=b.name===v;b.tab.setAttribute("aria-selected",String(w)),b.tab.tabIndex=w?0:-1,b.panel.hidden=!w}}else f.content=a("div",{class:"zx-dock__pane-content"}),u.append(f.content),f.factory=t.content;let p=Ri(t.size);return p!==null&&d.style.setProperty("--zx-pane-size",p),r&&this.listen(h,"click",()=>this.toggle(f.name)),t.collapsed&&r&&(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,Pi(e.panel,e.content,!0);return}t.built||(t.built=!0,Pi(t.content,t.factory,!0))}}_layout(){let t=[...this._panes.values()].filter(r=>r.kind!=="sheet"||r.sheet.isDocked()),e=this._content?[...t.filter(r=>r.side==="start"),this._content,...t.filter(r=>r.side==="end")]:t;for(let r of this._dividerDrags)r.destroy();this._dividerDrags=[];let s=[];e.forEach((r,n)=>{n>0&&s.push(this._divider()),s.push(r instanceof Element?r:r.element)}),this.el.replaceChildren(...s)}_divider(){let t=a("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(re(t,{orientation:this._orientation,disabled:()=>!this._resizable,onStart:()=>{let{before:e,after:s}=this._neighbours(t),r=this._resizeSubject(e,s);return r?(this._drag={subject:r,startSize:this._axisSize(r.element),oppositeStart:r.opposite?this._axisSize(r.opposite.element):0},this.el.dataset.dragging="true",!0):!1},onMove:e=>this._trackDelta(e),onEnd:(e,s)=>{s&&this._trackDelta(e),this._drag=null,delete this.el.dataset.dragging,s&&this._persist()},onStep:(e,s)=>this._stepDivider(t,e*(s?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 s=String(e.name??t.el.id??"")||y("zx-dock-sheet"),r={kind:"sheet",name:s,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},n=[...this._panes.entries()],o=Number.isInteger(e.index)?N(Number(e.index),0,n.length):n.length;n.splice(o,0,[s,r]),this._panes=new Map(n);let l=Ri(e.size);l!==null&&t.el.style.setProperty("--zx-pane-size",l),r.resync=()=>{this._syncGrow(),this._syncDividers()},t.on("open",r.resync),t.on("close",r.resync);let h=e.dockAt??null;return h?r.breakpoint=Qt((c,u)=>{this._applyDockAt(r,Je(h,u))},{target:this.el}):this._applyDockAt(r,!0),r}release(t){let e=[...this._panes.values()].find(s=>s.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(s=>s.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 r of t)r.element.removeAttribute("data-grow");if(this._content)return;let e=t.filter(r=>!this._isHidden(r));if(e.length===0)return;let s=e.find(r=>r.grow);(s??e[e.length-1]).element.dataset.grow="true"}_syncDividers(){for(let t of this._dividers()){let{before:e,after:s}=this._neighbours(t),r=this._resizeSubject(e,s),n=this._resizable&&r!==null;if(t.toggleAttribute("data-disabled",!n),t.tabIndex=n?0:-1,!n){t.removeAttribute("aria-valuenow");continue}let o=this._axisSize(this.el);t.setAttribute("aria-valuenow",String(Math.round(this._axisSize(r.element)))),t.setAttribute("aria-valuemin",String(Math.round(this._minSize(r)))),t.setAttribute("aria-valuemax",String(Math.round(o))),t.setAttribute("aria-controls",r.element.id||Zc(r.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=s=>{if(!s)return null;for(let r of this._panes.values())if(r.element===s)return r;return null};return{before:e(t.previousElementSibling),after:e(t.nextElementSibling)}}_resizeSubject(t,e){let s=r=>!!r&&!this._isHidden(r)&&r.element.dataset.grow!=="true";return s(t)?{element:t.element,record:t,sign:1,opposite:s(e)?e:null}:s(e)?{element:e.element,record:e,sign:-1,opposite:null}:null}_minSize(t){let s=(t.record.header??t.record.element.querySelector(".zx-dialog__header")??t.record.element).getBoundingClientRect(),r=this._orientation==="vertical"?s.height:s.width;return Math.max(t.record.min,r)}_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:s,oppositeStart:r}=this._drag,n=this._minSize(e),o=Math.max(n,s+t*e.sign);if(e.opposite){let l=this._minSize({record:e.opposite,element:e.opposite.element});o=Math.max(n,Math.min(o,s+r-l)),e.opposite.element.style.setProperty("--zx-pane-size",`${s+r-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:s,after:r}=this._neighbours(t),n=this._resizeSubject(s,r);if(!n)return;let o=Math.max(this._minSize(n),this._axisSize(n.element)+e*n.sign);n.element.style.setProperty("--zx-pane-size",`${o}px`),this._syncDividers(),this._persist(),this.emit("resize",{name:n.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 Zc(i){let t=y("zx-dock-pane");return i.id=t,t}function Ri(i){return i==null||i===""?null:typeof i=="number"?Number.isFinite(i)?`${Math.max(0,i)}px`:null:String(i)}function Pi(i,t,e){let s=e&&typeof t=="function"?t():t;if(s==null)return;if(typeof s=="string"||typeof s=="number"){i.append(document.createTextNode(String(s)));return}let r=s instanceof _?s.toElement():s;r&&typeof r.nodeType=="number"&&i.append(r)}var vs=class extends _{static cssName="navigation-bar";static defaults={title:"",items:[],active:null,actions:[]};constructor(t,e={}){super(t,e),this._overflow=new G(this.refs.moreTrigger,{label:"More",icon:"dots",kind:"ghost",items:[],placement:"bottom-end"}),this._overflow.on("select",s=>{let r=this._find(String(s.detail.value));!r||r.definition.disabled||(this.setActive(r.definition.name),r.definition.onselect?.(r.definition.name,r.definition,this),r.definition.href&&globalThis.location?.assign(r.definition.href))}),this._syncOverflow()}render(){let t=!this.el,e=this.el??a("section");this.el=e,this._createdRoot=t,this._original=t?null:eu(e),this._cleaned=!1,this._items=[],this._activeName=null,this._tabMode=!1,this._overflow=null;let s=a("header",{class:"zx-navigation-bar__bar"},a("div",{class:"zx-navigation-bar__brand",ref:"title"}),a("nav",{class:"zx-navigation-bar__navigation",ariaLabel:"Primary navigation"},a("div",{class:"zx-navigation-bar__items",ref:"items"}),a("div",{class:"zx-navigation-bar__more",ref:"more"},a("button",{class:"zx-navigation-bar__more-trigger",ref:"moreTrigger"}))),a("div",{class:"zx-navigation-bar__actions",ref:"actions",role:"group",ariaLabel:"Application actions"})),r=a("div",{class:"zx-navigation-bar__panels",ref:"panels",hidden:!0});return e.replaceChildren(s,r),this.setTitle(this.options.title),this.setItems(this.options.items),this.setActions(this.options.actions),this.listen(this.refs.items,"keydown",n=>this._onTabKeydown(n)),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setItems(t){if(!Array.isArray(t))throw new TypeError("NavigationBar items must be an array");let e=this._activeName,s=new Set,r=t.map(c=>{if(!c||typeof c!="object"||Array.isArray(c))throw new TypeError("Navigation item must be an object");if(typeof c.name!="string"||c.name==="")throw new TypeError("Navigation item name must be a non-empty string");if(s.has(c.name))throw new RangeError(`Navigation item already exists: ${c.name}`);if(s.add(c.name),Object.hasOwn(c,"content")&&!tu(c.content))throw new TypeError(`Navigation panel content for ${c.name} is invalid`);let u={name:c.name,title:String(c.title??""),badge:c.badge==null?null:String(c.badge),href:c.href==null?void 0:String(c.href),disabled:!!c.disabled,onselect:typeof c.onselect=="function"?c.onselect:void 0};return Object.hasOwn(c,"content")&&(u.content=c.content),u}),n=r.some(c=>Object.hasOwn(c,"content"));if(n&&r.some(c=>!Object.hasOwn(c,"content")))throw new TypeError("NavigationBar panel items must all define content");this._items=[],this._activeName=null,this._tabMode=n,this.refs.items.replaceChildren(),this.refs.panels.replaceChildren(),this.refs.panels.hidden=!this._tabMode,this._tabMode?(this.refs.items.setAttribute("role","tablist"),this.refs.items.setAttribute("aria-orientation","horizontal")):(this.refs.items.removeAttribute("role"),this.refs.items.removeAttribute("aria-orientation"));for(let c of r)this._appendItem(c);let o=e??this.options.active,l=o===null?null:this._find(o),h=l&&!l.definition.disabled?l:this._enabledItems()[0];return h&&this._applyActive(h),this._syncOverflow(),this}setActive(t){let e=this._find(t);return!e||e.definition.disabled||t===this._activeName?this:(this._applyActive(e),this.emit("change",{name:e.definition.name}),this)}setBadge(t,e){let s=this._require(t);return s.definition.badge=e===null?null:String(e),s.badge.textContent=s.definition.badge??"",s.badge.hidden=s.definition.badge===null,this._syncOverflow(),this}setActions(t){if(!Array.isArray(t))throw new TypeError("NavigationBar actions must be an array");let e=t.map(s=>{if(D(s))return s;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("NavigationBar actions must be Elements or button descriptors");let r={...s},n=r.onclick;delete r.onclick;let o=q(r);return typeof n=="function"&&this.listen(o,"click",n),o});return this.refs.actions.replaceChildren(...e),this}destroy(){this._cleaned||(this._cleaned=!0,this._overflow?.destroy(),super.destroy(),!this._createdRoot&&this._original&&su(this.el,this._original))}_appendItem(t){let e=y("zx-navigation-item"),s=y("zx-navigation-panel"),r=a("span",{class:"zx-navigation-bar__badge",hidden:t.badge===null},t.badge??""),n={class:"zx-navigation-bar__item",id:e,ariaDisabled:t.disabled?"true":null},o;this._tabMode?o=a("button",{...n,type:"button",role:"tab",tabindex:"-1",ariaControls:s,ariaSelected:"false"},a("span",{class:"zx-navigation-bar__label"},t.title),r):t.href?o=a("a",{...n,href:t.href},a("span",{class:"zx-navigation-bar__label"},t.title),r):o=a("button",{...n,type:"button"},a("span",{class:"zx-navigation-bar__label"},t.title),r);let l=null;this._tabMode&&(l=a("div",{class:"zx-navigation-bar__panel",id:s,role:"tabpanel",tabindex:"0",ariaLabelledby:e,hidden:!0}),this.refs.panels.append(l));let h={definition:t,item:o,badge:r,panel:l,built:!1};this._items.push(h),this.refs.items.append(o),this.listen(o,"click",c=>{if(h.definition.disabled){c.preventDefault();return}this.setActive(h.definition.name),h.definition.onselect?.(h.definition.name,h.definition,this)})}_applyActive(t){this._tabMode&&this._ensurePanel(t);for(let e of this._items){let s=e===t;this._tabMode?(e.item.setAttribute("aria-selected",String(s)),e.item.tabIndex=s?0:-1,e.panel&&(e.panel.hidden=!s)):s?e.item.setAttribute("aria-current","page"):e.item.removeAttribute("aria-current")}this._activeName=t.definition.name}_ensurePanel(t){if(!t.panel||t.built)return;let e=t.definition.content,s=typeof e=="function"?e():e,r=s instanceof _?s.toElement():s;if(!r||typeof r.nodeType!="number")throw new TypeError(`Navigation panel factory for ${t.definition.name} must return a Node or Component`);t.panel.append(r),t.built=!0}_onTabKeydown(t){if(!this._tabMode)return;let e=t.target.closest?.('[role="tab"]');if(!e||!this.refs.items.contains(e))return;let s=this._items.find(n=>n.item===e);if(!s)return;let r=this._enabledItems();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let n=t.key==="ArrowRight"?1:-1,o=r.indexOf(s),l=r[(o+n+r.length)%r.length];l&&this._focusTab(l);return}if(t.key==="Home"||t.key==="End"){t.preventDefault();let n=t.key==="Home"?r[0]:r[r.length-1];n&&this._focusTab(n);return}(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.setActive(s.definition.name))}_syncOverflow(){this._overflow&&(this.refs.more.dataset.empty=this._items.length===0?"true":"false",this._overflow.setItems(this._items.map(t=>({label:t.definition.badge===null?t.definition.title:`${t.definition.title} (${t.definition.badge})`,value:t.definition.name,disabled:t.definition.disabled}))))}_focusTab(t){for(let e of this._items)e.item.tabIndex=e===t?0:-1;t.item.focus()}_enabledItems(){return this._items.filter(t=>!t.definition.disabled)}_find(t){return this._items.find(e=>e.definition.name===t)??null}_require(t){let e=this._find(t);if(!e)throw new RangeError(`Unknown navigation item: ${t}`);return e}};function tu(i){return typeof i=="function"||i instanceof _?!0:!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function eu(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function su(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function Po(i){if(!Array.isArray(i))throw new TypeError("Stepper steps must be an array");let t=new Set;return i.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 ws(i,t){return t===null?-1:i.findIndex(e=>e.name===t)}function Ss(i,t,e){let s=e<0?-1:1,r=t<0?s>0?0:i.length-1:t+s;for(;r>=0&&r<i.length;){if(!i[r].disabled)return r;r+=s}return-1}function Bo(i,t,e){return t<0||e<=t?[]:i.slice(t,e).map(s=>s.name)}function qo(i,t,e={}){let{activeIndex:s=-1,completed:r,errored:n}=e;return Ro(n,i.name)?"error":t===s?"active":Ro(r,i.name)?"complete":"upcoming"}function Ro(i,t){return i?i instanceof Set?i.has(t):i.includes(t):!1}var iu=new Set(["horizontal","vertical"]),ru=new Set(["completed","all",!1]),As=class extends _{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,!iu.has(this.options.orientation))throw new RangeError(`Unknown stepper orientation: ${this.options.orientation}`);if(!ru.has(this.options.clickable))throw new RangeError(`Unknown stepper clickable mode: ${this.options.clickable}`);let t=this.el??a("div");this.el=t,t.dataset.orientation=this.options.orientation;let e=a("p",{class:"zx-stepper__counter",ref:"counter",ariaLive:"polite",hidden:!0}),s=a("ol",{class:"zx-stepper__list",ref:"list"});return t.replaceChildren(...this.options.counter?[e,s]:[s]),this.setSteps(this.options.steps),this.listen(s,"click",r=>{let n=r.target.closest?.(".zx-stepper__control");if(!n||!s.contains(n)||n.tagName!=="BUTTON")return;let o=n.dataset.step;typeof o=="string"&&this.goTo(o)}),t}setSteps(t){let e=this.getActive(),s=Po(t),r=new Set(s.map(l=>l.name));this._steps=s,this._completed=new Set([...this._completed].filter(l=>r.has(l))),this._errored=new Set([...this._errored].filter(l=>r.has(l)));let n=e??(this.options.active===null?null:String(this.options.active)),o=n===null?-1:ws(s,n);return o>=0&&s[o].disabled&&(o=-1),o<0&&(o=Ss(s,-1,1)),this._activeIndex=o,this._records=s.map(l=>this._createRecord(l)),this.refs.list.replaceChildren(...this._records.map(l=>l.item)),this._sync(),this}goTo(t){let e=ws(this._steps,t);if(e<0)throw new RangeError(`Unknown step: ${t}`);return this._activate(e)}next(){return this._activate(Ss(this._steps,this._activeIndex,1))}previous(){return this._activate(Ss(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&&z(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 s=this._activeIndex;if(this.emit("change",{name:e.name,previous:s<0?null:this._steps[s].name,index:t}).defaultPrevented)return this;for(let n of Bo(this._steps,s,t))this._completed.add(n);return this._activeIndex=t,this._sync(),this}_createRecord(t){let e=a("span",{class:"zx-stepper__marker",ariaHidden:"true"}),s=a("span",{class:"zx-stepper__status"}),r=[a("span",{class:"zx-stepper__title"},t.title)];t.description&&r.push(a("span",{class:"zx-stepper__description"},t.description)),t.optional&&r.push(a("span",{class:"zx-stepper__optional"},this._message("stepper.optional","Optional")));let n=[e,a("span",{class:"zx-stepper__text"},r),s],o=this.options.clickable===!1?a("span",{class:"zx-stepper__control"},n):a("button",{class:"zx-stepper__control",type:"button",dataset:{step:t.name}},n);return{step:t,item:a("li",{class:"zx-stepper__step"},o),control:o,marker:e,status:s}}_sync(){this._records.forEach((t,e)=>{let s=this._stateFor(t.step,e);t.item.dataset.state=s,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(s,e)),t.status.textContent=this._statusText(s),t.control.tagName==="BUTTON"&&(t.control.disabled=!this._isClickable(t.step))}),this._syncCounter()}_stateFor(t,e){return qo(t,e,{activeIndex:this._activeIndex,completed:this._completed,errored:this._errored})}_markerContent(t,e){return t==="complete"?[m("check",{size:12})]:t==="error"?[m("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=ws(this._steps,t);if(e<0)throw new RangeError(`Unknown step: ${t}`);return this._steps[e]}_message(t,e,...s){let r=this.msg(t,...s);return r===t?O(e,s):r}};var nu=new Set(["chevron","slash"]),ks=class extends _{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,!nu.has(this.options.separator))throw new RangeError(`Unknown breadcrumb separator: ${this.options.separator}`);let t=this.el??a("nav");this.el=t,t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.setAttribute("aria-label",this._message("breadcrumb.label","Breadcrumb"));let e=a("ol",{class:"zx-breadcrumb__list",ref:"list"});return t.replaceChildren(e),this.setItems(this.options.items),this.listen(e,"click",s=>{let r=s.target.closest?.("[data-crumb]");!r||!e.contains(r)||this._select(r.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(s=>{if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("Breadcrumb item must be an object");if(typeof s.name!="string"||s.name==="")throw new TypeError("Breadcrumb item name must be a non-empty string");if(e.has(s.name))throw new RangeError(`Breadcrumb item already exists: ${s.name}`);return e.add(s.name),{name:s.name,label:String(s.label??""),icon:s.icon?String(s.icon):null,href:s.href==null?null:String(s.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(s=>s.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&&z(t,this._snapshot)}_build(){let{head:t,hidden:e,tail:s}=this._split(),r=this._items[this._items.length-1]??null,n=[];for(let o of t)n.push(this._renderItem(o,o===r));e.length>0&&n.push(this._renderOverflow(e));for(let o of s)n.push(this._renderItem(o,o===r));this.refs.list.replaceChildren(...n.map((o,l)=>a("li",{class:"zx-breadcrumb__item"},l===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 s=Math.max(2,e);if(t.length<=s)return{head:t,hidden:[],tail:[]};let r=s-1;return{head:t.slice(0,1),hidden:t.slice(1,t.length-r),tail:t.slice(t.length-r)}}_renderItem(t,e){let s=[],r=t.icon??(t===this._items[0]?this.options.rootIcon:null);return r&&s.push(a("span",{class:"zx-breadcrumb__icon",ariaHidden:"true"},m(String(r),{size:13}))),s.push(a("span",{class:"zx-breadcrumb__label"},t.label)),e?a("span",{class:"zx-breadcrumb__current",ariaCurrent:"page"},s):t.href!==null?a("a",{class:"zx-breadcrumb__link",href:t.href,dataset:{crumb:t.name}},s):a("button",{class:"zx-breadcrumb__link",type:"button",dataset:{crumb:t.name}},s)}_renderOverflow(t){if(!this._overflow){this._overflow=new G(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",s=>this._select(String(s.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 a("span",{class:"zx-breadcrumb__separator",ariaHidden:"true"},this.options.separator==="slash"?"/":m("chevron-right",{size:11}))}_select(t){let e=this._items.findIndex(s=>s.name===t);e<0||this.emit("select",{name:this._items[e].name,item:{...this._items[e]},index:e})}_message(t,e,...s){let r=this.msg(t,...s);return r===t?O(e,s):r}};var Cs="\u2026",ou=new Set(["pages","loadmore"]);function Hi({page:i=1,pages:t=1,siblings:e=1,boundaries:s=1}={}){let r=Et(t);if(r<=0)return[];let n=qi(Et(i)||1,1,r),o=Math.max(0,Et(e)),l=Math.max(0,Et(s)),h=l*2+o*2+3;if(r<=h)return zs(1,r);let c=zs(1,Math.min(l,r)),u=zs(Math.max(r-l+1,l+1),r),d=Math.max(Math.min(n-o,r-l-o*2-1),l+2),f=Math.min(Math.max(n+o,l+o*2+2),u.length>0?u[0]-2:r-1);return[...c,...d>l+2?[Cs]:l+1<r-l?[l+1]:[],...zs(d,f),...f<r-l-1?[Cs]:r-l>l?[r-l]:[],...u]}var Ts=class extends _{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=Bi(this.options.pageSize,25),this._total=Math.max(0,Et(this.options.total)),this._page=Math.max(1,Et(this.options.page)||1),this._disabled=!!this.options.disabled,this._sizeKey="",this._pageSizes=(Array.isArray(this.options.pageSizes)?this.options.pageSizes:[]).map(s=>Bi(s,0)).filter(s=>s>0),!ou.has(this.options.mode))throw new RangeError(`Unknown pagination mode: ${this.options.mode}`);this._page=qi(this._page,1,this._pageCount());let t=this.el??a("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(a("span",{class:"zx-pagination__summary",ref:"summary",ariaLive:"polite"})),e.push(a("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 s=this._page,r=this._pageSize;if(Object.hasOwn(t,"total")&&(this._total=Math.max(0,Et(t.total))),Object.hasOwn(t,"pageSize")&&(this._pageSize=Bi(t.pageSize,this._pageSize)),Object.hasOwn(t,"page")){let n=Math.trunc(Number(t.page));Number.isFinite(n)&&(this._page=n)}return this._page=qi(this._page,1,this._pageCount()),this._sync(),!e&&(this._page!==s||this._pageSize!==r)&&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&&z(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 a("label",{class:"zx-pagination__size"},a("span",{class:"zx-pagination__size-label"},t),a("select",{class:"zx-pagination__select",ref:"select",ariaLabel:t}))}_renderPages(){return a("div",{class:"zx-pagination__controls"},this._navButton("prev","chevron-left",this._message("pagination.previous","Previous page")),a("div",{class:"zx-pagination__pages",ref:"pages"}),this._navButton("next","chevron-right",this._message("pagination.next","Next page")))}_navButton(t,e,s){return a("button",{class:"zx-btn zx-pagination__nav",type:"button",ref:t,ariaLabel:s,dataset:{kind:"default",size:"sm"}},m(e,{size:14}))}_renderLoadMore(){return a("button",{class:"zx-btn zx-pagination__more",type:"button",ref:"more",dataset:{kind:"default",size:"md"}},a("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",Te(e),Te(this._total)):this._message("pagination.summary","%1\u2013%2 of %3",Te(t+1),Te(e),Te(this._total))}_syncPageSize(){let t=this.refs.select,e=[...new Set([...this._pageSizes,this._pageSize])].sort((r,n)=>r-n),s=e.join(",");s!==this._sizeKey&&(this._sizeKey=s,t.replaceChildren(...e.map(r=>a("option",{value:String(r)},String(r))))),t.value=String(this._pageSize),t.disabled=this._disabled}_syncPages(t){let e=this.refs.pages,s=this.el.ownerDocument?.activeElement??null,r=s&&e.contains(s)?s.dataset.page??null:null,n=Hi({page:this._page,pages:t,siblings:this.options.siblings,boundaries:this.options.boundaries});if(e.replaceChildren(...n.map(l=>l===Cs?a("span",{class:"zx-pagination__ellipsis",ariaHidden:"true"},Cs):a("button",{class:"zx-btn zx-pagination__page",type:"button",disabled:this._disabled,ariaCurrent:l===this._page?"page":null,ariaLabel:this._message("pagination.page","Page %1",l),dataset:{kind:"default",size:"sm",page:String(l)}},String(l)))),r===null)return;let o=e.querySelector(`[data-page="${r}"]`);o&&!o.disabled&&o.focus()}_message(t,e,...s){let r=this.msg(t,...s);return r===t?O(e,s):r}};function Et(i){let t=Math.trunc(Number(i));return Number.isFinite(t)&&t>0?t:0}function Bi(i,t){let e=Math.trunc(Number(i));return Number.isFinite(e)&&e>0?e:t}function qi(i,t,e){return Math.min(Math.max(i,t),e)}function zs(i,t){return t<i?[]:Array.from({length:t-i+1},(e,s)=>i+s)}function Te(i){return i.toLocaleString()}var Es=class extends _{static cssName="launcher";static defaults={items:[],sources:[],query:"",debounce:250,minQuery:0,maxResults:100,placeholder:"Search applications and records",label:"Launcher",emptyText:"No results",loadingText:"Searching\u2026",shortcut:"mod+k"};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??a("dialog");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,l=>[l.name,l.value]),children:Array.from(t.childNodes)},this._items=Vi(this.options.items),this._sources=Vo(this.options.sources),this._sourceItems=new Map,this._query=String(this.options.query??""),this._results=[],this._active=-1,this._request=null,this._requestSequence=0,this._queryTimer=null,this._busy=!1,this._destroyed=!1;let e=y("zx-launcher-results"),s=a("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}),r=a("button",{ref:"close",class:"zx-icon-btn zx-launcher__close",type:"button",ariaLabel:"Close launcher"},m("x")),n=a("div",{ref:"status",class:"zx-launcher__status",role:"status",ariaLive:"polite"}),o=a("div",{ref:"results",class:"zx-launcher__results",id:e,role:"listbox",ariaLabel:"Launcher results"});return t.setAttribute("aria-label",String(this.options.label)),t.replaceChildren(a("div",{class:"zx-launcher__surface"},a("div",{class:"zx-launcher__search"},m("search"),s,r),n,o)),t.dataset.state="closed",this._createdRoot&&document.body.append(t),this.listen(s,"input",()=>{this._query=s.value,this.emit("query",{query:this._query.trim()}),this._refresh()}),this.listen(s,"keydown",l=>this._onKeydown(l)),this.listen(r,"click",()=>this.close()),this.listen(o,"click",l=>{let h=l.target?.closest?.("[data-launcher-index]");!h||!o.contains(h)||this._activate(Number(h.getAttribute("data-launcher-index")),l)}),this.listen(t,"cancel",l=>{l.preventDefault(),this.close()}),this.listen(t,"close",()=>{t.dataset.state="closed",s.setAttribute("aria-expanded","false"),this._abortRequest(),this.emit("close")}),this.listen(document,"keydown",l=>this._onDocumentKeydown(l)),this._renderResults(),t}open(){return this.isOpen()||this._destroyed?this:(this.el.showModal(),this.el.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this._refresh(),queueMicrotask(()=>{this.isOpen()&&(this.refs.input.focus(),this.refs.input.select())}),this.emit("open"),this)}close(){return this.isOpen()&&this.el.close(),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return!!this.el.open}focus(){return this.refs.input.focus(),this.refs.input.select(),this}setQuery(t){return this._query=String(t??""),this.refs.input.value=this._query,this.emit("query",{query:this._query.trim()}),this._refresh(),this}getQuery(){return this._query}setItems(t){return this._items=Vi(t),this._renderResults(),this}setSources(t){return this._abortRequest(),this._sources=Vo(t),this._sourceItems.clear(),this._refresh(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this._original;if(this._abortRequest(),this.isOpen()&&this.el.close(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_refresh(){if(this._sourceItems.clear(),this._renderResults(),this._abortRequest(),this._sources.length===0)return;let t=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>this._loadSources(),t)}async _loadSources(){this._queryTimer=null;let t=this._query.trim(),e=this._sources.filter(n=>t.length>=Math.max(Number(this.options.minQuery)||0,Number(n.minQuery)||0));if(e.length===0)return;let s=new AbortController,r=++this._requestSequence;this._request=s,this._setBusy(!0),await Promise.all(e.map(async n=>{try{let o=await n.load(t,{signal:s.signal});if(s.signal.aborted||r!==this._requestSequence)return;this._sourceItems.set(n.id,Vi(o).map(l=>({...l,_source:n.id,group:l.group??n.label??""}))),this._renderResults()}catch(o){if(s.signal.aborted||r!==this._requestSequence)return;this.emit("error",{source:n,error:o})}})),!(s.signal.aborted||r!==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=hu(this._sources,this._sourceItems),e=new Set,s=[...this._items.map(h=>({...h,_source:null})),...t].filter(h=>{let c=String(h.id);return e.has(c)?!1:(e.add(c),!0)}),r=ji(s,this._query,this.options.maxResults),n=new Map;for(let h of r){let c=String(h.group??"");n.has(c)||n.set(c,[]),n.get(c).push(h)}this._results=[...n.values()].flat(),this._active=this._results.findIndex(h=>!h.disabled);let o=[],l=0;for(let[h,c]of n){let u=c.map(d=>this._option(d,l++));h?o.push(a("div",{class:"zx-launcher__group",role:"group",ariaLabel:h},a("div",{class:"zx-launcher__group-label",ariaHidden:"true"},h),u)):o.push(...u)}this.refs.results.replaceChildren(...o),this._syncActive(),this._renderStatus()}_option(t,e){let s=t.href?"a":"button",r=[];return t.icon&&r.push(a("span",{class:"zx-launcher__icon"},m(t.icon))),r.push(a("span",{class:"zx-launcher__copy"},a("span",{class:"zx-launcher__label"},t.label),t.description?a("span",{class:"zx-launcher__description"},t.description):null)),t.badge!=null&&r.push(a("span",{class:"zx-launcher__badge"},String(t.badge))),a(s,{class:"zx-launcher__option",type:s==="button"?"button":null,href:t.href??null,target:t.target??null,role:"option",id:y("zx-launcher-option"),tabIndex:-1,ariaSelected:"false",ariaDisabled:t.disabled?"true":null,dataset:{launcherIndex:e,pinned:t.pinned?"true":null}},r)}_renderStatus(){this._busy?this.refs.status.textContent=String(this.options.loadingText):this._results.length===0?this.refs.status.textContent=String(this.options.emptyText):this.refs.status.textContent="",this.refs.status.hidden=!this.refs.status.textContent}_syncActive(){let t=[...this.refs.results.querySelectorAll("[data-launcher-index]")];for(let s of t){let r=Number(s.getAttribute("data-launcher-index"))===this._active;s.setAttribute("aria-selected",String(r))}let e=t.find(s=>Number(s.getAttribute("data-launcher-index"))===this._active);e?this.refs.input.setAttribute("aria-activedescendant",e.id):this.refs.input.removeAttribute("aria-activedescendant")}_onKeydown(t){if(t.key==="Escape"){this.close();return}if(t.key==="Enter"){if(this._active<0)return;t.preventDefault(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.click();return}let e=this._results.map((r,n)=>r.disabled?-1:n).filter(r=>r>=0);if(e.length===0)return;let s=e.indexOf(this._active);if(t.key==="Home"||t.key==="PageUp")s=0;else if(t.key==="End"||t.key==="PageDown")s=e.length-1;else if(t.key==="ArrowDown")s=(s+1+e.length)%e.length;else if(t.key==="ArrowUp")s=(s-1+e.length)%e.length;else return;t.preventDefault(),this._active=e[s],this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest"})}_activate(t,e){let s=this._results[t];if(!s||s.disabled){e.preventDefault();return}if(this.emit("select",{item:s,value:s.value??s.id,source:s._source??null,query:this._query.trim()}).defaultPrevented){e.preventDefault();return}s.href||(e.preventDefault(),s.invoke?.()),this.close()}_onDocumentKeydown(t){if(this.options.shortcut!=="mod+k"||t.isComposing||t.key.toLowerCase()!=="k"||!t.metaKey&&!t.ctrlKey||t.altKey)return;let e=document.activeElement;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable)return;let s=document.querySelector("dialog:modal");s&&s!==this.el||(t.preventDefault(),this.open())}};function ji(i,t,e=100){let s=ne(t).trim(),r=i.map((o,l)=>({item:o,order:l,score:au(o,s)})).filter(({score:o})=>o<1/0);r.sort((o,l)=>{if(s===""){let h=Ho(o.item.pinned,o.order),c=Ho(l.item.pinned,l.order);if(h!==c)return h-c}return o.score-l.score||lu(o.item.label,l.item.label)||o.order-l.order});let n=Math.max(0,Number(e)||0);return r.slice(0,n||0).map(({item:o,score:l})=>({...o,_score:l}))}function au(i,t){if(!t)return i.pinned?-1:0;let e=ne(i.label),s=ne(i.id),r=ne(Array.isArray(i.keywords)?i.keywords.join(" "):i.keywords??"");return e===t?0:e.startsWith(t)?10:e.split(/[^\p{L}\p{N}]+/u).some(o=>o.startsWith(t))?20:e.includes(t)||r.includes(t)?30:s.includes(t)?40:e.split(/[^\p{L}\p{N}]+/u).filter(Boolean).map(o=>o[0]).join("").startsWith(t)?50:1/0}function Ho(i,t){return typeof i=="number"&&Number.isFinite(i)?i:i?t:Number.MAX_SAFE_INTEGER}function ne(i){return String(i??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function lu(i,t){let e=ne(i),s=ne(t);if(e<s)return-1;if(e>s)return 1;let r=String(i??"").normalize("NFC"),n=String(t??"").normalize("NFC");return r<n?-1:r>n?1:0}function Vi(i){return Array.isArray(i)?i.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>({...t,label:String(t.label)})):[]}function Vo(i){return Array.isArray(i)?i.filter(t=>t&&typeof t=="object"&&t.id!=null&&typeof t.load=="function").map(t=>({...t,id:String(t.id)})):[]}function hu(i,t){return i.flatMap(e=>t.get(String(e.id))??[])}var oe=class extends _{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??a("span");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,n=>[n.name,n.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=a("img",{ref:"image",class:"zx-avatar__image",alt:"",draggable:!1}),s=a("span",{ref:"fallback",class:"zx-avatar__fallback",ariaHidden:"true"}),r=a("span",{ref:"status",class:"zx-avatar__status",ariaHidden:"true",hidden:!0});return t.replaceChildren(e,s,r),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,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_sync(){let{size:t,shape:e,label:s}=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||$i(this._state.name));let r=this._state.src==null?"":String(this._state.src).trim();r?(this.refs.image.setAttribute("src",r),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:s}=this._state;if(t){let r=["online","away","busy","offline"].includes(e)?s:null;this.el.setAttribute("role","img"),this.el.setAttribute("aria-label",[t,r].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 s=this._state.statusLabel;s?this.refs.status.setAttribute("title",String(s)):this.refs.status.removeAttribute("title")}};function $i(i){let t=String(i??"").trim().split(/\s+/u).filter(Boolean);if(t.length===0)return"?";let e=jo(t[0]),s=t.length>1?jo(t[t.length-1]):"";return`${e}${s}`}function jo(i){return $o($o(i).toUpperCase())}function $o(i){return typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(i)[Symbol.iterator]().next().value?.segment??"":Array.from(i)[0]??""}var Ds=class extends _{static cssName="account-menu";static defaults={account:{},items:[],compact:!1,label:null,placement:"top-start"};constructor(t=null,e={}){super(t,e);for(let s of["select","open","close"])this.listen(this.refs.trigger,`zx-${s}`,r=>r.stopPropagation());this._avatar=new oe(this.refs.avatar,Uo(this._account)),this._menu=new G(this.refs.trigger,{items:this.options.items,placement:this.options.placement}),this._menu.on("select",s=>{this.emit("select",s.detail).defaultPrevented&&s.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??a("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=Ko(this.options.account),t.dataset.compact=String(!!this.options.compact),t.replaceChildren(a("button",{ref:"trigger",class:"zx-account-menu__trigger",type:"button"},a("span",{ref:"avatar",class:"zx-account-menu__avatar"}),a("span",{class:"zx-account-menu__identity"},a("span",{ref:"name",class:"zx-account-menu__name"}),a("span",{ref:"secondary",class:"zx-account-menu__secondary"})),a("span",{class:"zx-account-menu__chevron",ariaHidden:"true"},m("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=Ko(t),this._avatar.set(Uo(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,s]of t.attributes)this.el.setAttribute(e,s);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}`:"",s=this.options.label||`Account menu${this._account.name?` for ${this._account.name}`:""}${e}`;this.refs.trigger.setAttribute("aria-label",s),this._renderPanelHeader()}_renderPanelHeader(){let t=this._menu.getPanel();t.querySelector(".zx-account-menu__panel-identity")?.remove(),t.prepend(a("div",{class:"zx-account-menu__panel-identity",role:"presentation"},a("strong",{},this._account.name||"Account"),this._account.secondary?a("span",{},this._account.secondary):null))}};function Ko(i){let t=i&&typeof i=="object"?i:{};return{...t,name:String(t.name??""),secondary:String(t.secondary??"")}}function Uo(i){return{name:i.name,src:i.src??null,initials:i.initials??null,status:i.status??null,statusLabel:i.statusLabel??null,label:null,size:"md"}}var cu=new Set(["top","bottom","top-start","top-end","bottom-start","bottom-end","left","right","left-start","left-end","right-start","right-end"]),uu=new Set(["hover","focus","both","manual"]),xt=class extends _{static cssName="tooltip";static defaults={content:"",placement:"top",offset:6,delay:400,hideDelay:80,maxWidth:260,trigger:"both",disabled:!1};#t;#e;#s=null;#i=null;#n=0;#r=0;#o=!1;#a=!1;#l=!1;constructor(t,e={}){let s=R(t);if(!s)throw new TypeError("Tooltip anchor could not be resolved");super(null,e),this.#t=s,this.#e=this.options.content,this.#a=!!this.options.disabled,this.#i=s.getAttribute("aria-describedby"),this.el.style.setProperty("--zx-tooltip-max-inline-size",fu(this.options.maxWidth));let r=uu.has(this.options.trigger)?this.options.trigger:"both";r!=="manual"&&((r==="hover"||r==="both")&&(this.listen(this.#t,"pointerenter",n=>{n.pointerType!=="touch"&&this.#h(Number(this.options.delay))}),this.listen(this.#t,"pointerleave",()=>this.#c(Number(this.options.hideDelay)))),(r==="focus"||r==="both")&&(this.listen(this.#t,"focusin",()=>{this.#o||!_u(this.#t)||this.#h(0)}),this.listen(this.#t,"focusout",()=>this.#c(Number(this.options.hideDelay)))),this.listen(document,"keydown",n=>{n.key!=="Escape"||!this.isOpen()||(n.preventDefault(),this.hide())}),this.listen(document,"pointerdown",()=>{this.#o=!0,this.#u(),this.hide()},{capture:!0}),this.listen(document,"pointerup",()=>{this.#o=!1},{capture:!0}),this.listen(document,"pointercancel",()=>{this.#o=!1},{capture:!0}),this.listen(document,"focusin",n=>{!this.isOpen()||n.composedPath().includes(this.#t)||this.hide()}))}render(){let t=a("div",{id:y("zx-tooltip"),role:"tooltip",popover:"manual"});return t.dataset.state="closed",document.body.append(t),t}show(){if(this.#l||this.#a||this.isOpen())return this;this.#u();let t=Yo(this.#e);return t===null?this:(this.el.replaceChildren(t),this.#s=V(this.#t,this.el,{placement:cu.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",pu(this.#i,this.el.id)),this.emit("open"),this)}hide(){return this.#u(),this.isOpen()?(this.#s?.destroy(),this.#s=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.#s!==null}setContent(t){if(this.#e=t,!this.isOpen())return this;let e=Yo(t);return e===null?this.hide():(this.el.replaceChildren(e),this.#s?.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())}#h(t){if(this.#u(),this.#l||this.#a||this.isOpen())return;let e=Number.isFinite(t)?Math.max(0,t):0;if(e===0){this.show();return}this.#n=setTimeout(()=>{this.#n=0,this.show()},e)}#c(t){if(this.#u(),!this.isOpen())return;let e=Number.isFinite(t)?Math.max(0,t):0;if(e===0){this.hide();return}this.#r=setTimeout(()=>{this.#r=0,this.hide()},e)}#u(){this.#n!==0&&clearTimeout(this.#n),this.#r!==0&&clearTimeout(this.#r),this.#n=0,this.#r=0}#d(){this.#i===null?this.#t.removeAttribute("aria-describedby"):this.#t.setAttribute("aria-describedby",this.#i)}};function Wo(i,t=""){return new xt(i,du(t)?t:{content:t})}function Go(i,t){return new xt(i,{content:String(t??"")})}function du(i){return i===null||typeof i!="object"||Array.isArray(i)||typeof i.nodeType=="number"?!1:typeof i.toElement!="function"}function Yo(i){let t=typeof i=="function"?i():i;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 pu(i,t){let e=String(i??"").split(/\s+/).filter(Boolean);return e.includes(t)||e.push(t),e.join(" ")}function fu(i){return typeof i=="number"&&Number.isFinite(i)?`${i}px`:String(i)}function _u(i){try{return i.matches(":focus-visible")}catch{return!0}}var ae=class extends _{static cssName="app-rail";static defaults={items:[],active:null,orientation:"vertical",side:"left",label:"Applications",header:null,footer:null,openDelay:80,closeDelay:160};constructor(t=null,e={}){super(t,e),this._rebuild()}render(){this._createdRoot=this.el===null;let t=this.el??a("nav");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,n=>[n.name,n.value]),children:Array.from(t.childNodes)},this._items=vt(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 s=a("div",{class:"zx-app-rail__header"}),r=a("div",{class:"zx-app-rail__footer"});return Xo(s,this.options.header),Xo(r,this.options.footer),s.hidden=!s.hasChildNodes(),r.hidden=!r.hasChildNodes(),t.replaceChildren(s,a("ul",{ref:"list",class:"zx-app-rail__list"}),r),this.listen(t,"keydown",n=>this._onRailKeydown(n)),t}setItems(t){return this._items=vt(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 s=this._resolveFlyout(t);if(!s)return this;let r=[s],n=s.parentKey===null?null:this._flyouts.get(s.parentKey)??null;for(;n;)r.unshift(n),n=n.parentKey===null?null:this._flyouts.get(n.parentKey)??null;if(r.some(o=>o.item.disabled))return this;this._cancelFlyoutTimers(s,!0);for(let[o,l]of this._flyouts)o!==s.key&&l.dropdown.isOpen()&&!this._isAncestor(l,s)&&this.closeFlyout(o);for(let o of r)this._tooltipById.get(String(o.item.id))?.hide(),o.dropdown.open();return e&&Jo(s.panel)?.focus(),this}closeFlyout(t){let e=this._resolveFlyout(t);if(!e)return this;for(let s of[...this._flyouts.values()].reverse())s!==e&&this._isAncestor(e,s)&&(this._cancelTimers(s.key),s.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 Jo(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,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_rebuild(){this._clearArtifacts(),this.refs.list.replaceChildren(),this._interaction=new Ki(this.el),this._items.forEach(t=>{let e=Array.isArray(t.children)&&t.children.length>0,s=Qo(t,{className:"zx-app-rail__item",index:String(t.id),iconOnly:!0,disclosure:e,disclosureIcon:mu(this.el.dataset.side)}),r=a("li",{class:"zx-app-rail__row"},s);this.refs.list.append(r);let n=new xt(s,{content:t.label,placement:xu(this.el.dataset.side),delay:450});this._tooltips.push(n),this._tooltipById.set(String(t.id),n),e?this._buildFlyout(t,s,String(t.id),null):this._interaction.listen(s,"click",o=>{if(!this._select(t,o).defaultPrevented)for(let h of this._flyouts.values())h.parentKey===null&&h.dropdown.isOpen()&&this.closeFlyout(h.key)})}),this._interaction.listen(document,"pointerdown",t=>{let e=[...this._flyouts.values()].filter(r=>r.dropdown.isOpen());if(e.length===0)return;let s=t.composedPath();if(!e.some(r=>s.includes(r.panel)||s.includes(r.trigger)))for(let r of e)r.parentKey===null&&this.closeFlyout(r.key)}),this._syncActive()}_buildFlyout(t,e,s,r){let n=a("ul",{class:"zx-app-rail__flyout-list"});for(let u of t.children??[]){let d=`${s}/${u.id}`,f=!!u.children?.length,p=Qo(u,{className:"zx-app-rail__flyout-item",index:d,iconOnly:!1,disclosure:f,disclosureIcon:gu(this.el.dataset.side)});n.append(a("li",{},p)),f?this._buildFlyout(u,p,d,s):this._interaction.listen(p,"click",g=>{this._select(u,g).defaultPrevented||this._closeFlyoutChain(s)})}let o=a("div",{class:"zx-app-rail__flyout"},a("div",{class:"zx-app-rail__flyout-title"},t.label),n),l=new W(e,{openOn:"manual",placement:r===null?bu(this.el.dataset.side):yu(this.el.dataset.side),content:o,offset:6}),h=l.getPanel();h.classList.add("zx-app-rail__popover"),h.setAttribute("role","region"),h.setAttribute("aria-label",`${t.label} sub-navigation`);let c={key:s,parentKey:r,item:t,trigger:e,panel:h,dropdown:l};this._flyouts.set(s,c),l.on("open",()=>{this._silenceFlyoutEvents||this.emit("flyoutchange",{item:t,id:t.id,open:!0})}),l.on("close",()=>{this._silenceFlyoutEvents||this.emit("flyoutchange",{item:t,id:t.id,open:!1})}),this._interaction.listen(e,"pointerdown",()=>{this._pointerFocus.add(e),queueMicrotask(()=>this._pointerFocus.delete(e))}),this._interaction.listen(e,"pointerenter",u=>{u.pointerType!=="touch"&&this._scheduleOpen(s)}),this._interaction.listen(e,"pointerleave",()=>this._scheduleClose(s)),this._interaction.listen(e,"focus",()=>{this._pointerFocus.has(e)||this.openFlyout(s)}),this._interaction.listen(e,"focusout",u=>{h.contains(u.relatedTarget)||this._scheduleClose(s)}),this._interaction.listen(e,"click",u=>{u.preventDefault(),u instanceof MouseEvent&&u.detail===0?this.openFlyout(s,{focus:!0}):l.isOpen()?this.closeFlyout(s):this.openFlyout(s)}),this._interaction.listen(h,"pointerenter",()=>this._cancelFlyoutTimers(c,!0)),this._interaction.listen(h,"pointerleave",()=>this._scheduleFlyoutClose(c,!0)),this._interaction.listen(h,"focusin",()=>this._cancelFlyoutTimers(c,!0)),this._interaction.listen(h,"focusout",u=>{u.relatedTarget!==e&&!h.contains(u.relatedTarget)&&this._scheduleFlyoutClose(c,!0)}),this._interaction.listen(h,"keydown",u=>this._onFlyoutKeydown(u,c))}_select(t,e){if(t.disabled){e.preventDefault();let r=new Event("select",{cancelable:!0});return r.preventDefault(),r}let s=this.emit("select",{item:t,id:t.id,value:t.value??t.id,href:t.href??null,event:e});return s.defaultPrevented?e.preventDefault():t.href||(e.preventDefault(),t.invoke?.()),s}_onRailKeydown(t){let e=vu(this.refs.list),s=t.target?.closest?.("[data-app-nav-id]"),r=e.indexOf(s);if(r<0)return;let n=this.el.dataset.orientation==="horizontal",o=n?"ArrowLeft":"ArrowUp",l=n?"ArrowRight":"ArrowDown",h={left:"ArrowRight",right:"ArrowLeft",top:"ArrowDown",bottom:"ArrowUp"}[this.el.dataset.side],c=s.getAttribute("data-app-nav-id");if(t.key===h&&this._flyouts.has(String(c))){t.preventDefault(),this.openFlyout(String(c),{focus:!0});return}let u;if(t.key==="Home")u=0;else if(t.key==="End")u=e.length-1;else if(t.key===o)u=(r-1+e.length)%e.length;else if(t.key===l)u=(r+1)%e.length;else return;t.preventDefault(),e[u]?.focus()}_onFlyoutKeydown(t,e){let s=Zo(e.panel),r=t.target?.closest?.("a, button"),n=s.indexOf(r);if(t.key==="Escape"){t.preventDefault(),t.stopPropagation();let u=[...this._flyouts.values()].find(d=>d.trigger===r&&d.dropdown.isOpen());if(u){this.closeFlyout(u.key),this._restoreFocus(u.trigger);return}this.closeFlyout(e.key),this._restoreFocus(e.trigger);return}let o=[...this._flyouts.values()].find(u=>u.trigger===r),l=this.el.dataset.side==="right"?"ArrowLeft":"ArrowRight",h=l==="ArrowRight"?"ArrowLeft":"ArrowRight";if(o&&t.key===l){t.preventDefault(),t.stopPropagation(),this.openFlyout(o.key,{focus:!0});return}if(e.parentKey!==null&&t.key===h){t.preventDefault(),t.stopPropagation(),this.closeFlyout(e.key),this._restoreFocus(e.trigger);return}if(s.length===0)return;let c;if(t.key==="Home")c=0;else if(t.key==="End")c=s.length-1;else if(t.key==="ArrowDown")c=(n+1+s.length)%s.length;else if(t.key==="ArrowUp")c=(n-1+s.length)%s.length;else return;t.preventDefault(),s[c]?.focus()}_scheduleOpen(t){let e=String(t);this._cancelTimer(this._closeTimers,e),this._cancelTimer(this._openTimers,e);let s=Math.max(0,Number(this.options.openDelay)||0);this._openTimers.set(e,setTimeout(()=>{this._openTimers.delete(e),this.openFlyout(t)},s))}_scheduleClose(t){let e=String(t);this._cancelTimer(this._openTimers,e),this._cancelTimer(this._closeTimers,e);let s=Math.max(0,Number(this.options.closeDelay)||0);this._closeTimers.set(e,setTimeout(()=>{this._closeTimers.delete(e);let r=this._flyouts.get(e);r&&(this._branchInteracting(r)||this.closeFlyout(e))},s))}_scheduleFlyoutClose(t,e){let s=t;for(;s&&(this._scheduleClose(s.key),!(!e||s.parentKey===null));)s=this._flyouts.get(s.parentKey)??null}_resolveFlyout(t){let e=String(t);return this._flyouts.get(e)??[...this._flyouts.values()].find(s=>String(s.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 s=e.parentKey;for(;s!==null;){if(s===t.key)return!0;s=this._flyouts.get(s)?.parentKey??null}return!1}_cancelFlyoutTimers(t,e){let s=t;for(;s&&(this._cancelTimers(s.key),!(!e||s.parentKey===null));)s=this._flyouts.get(s.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 s=t.get(e);s!==void 0&&clearTimeout(s),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 s=t!==null&&e.getAttribute("data-app-nav-value-id")===t,r=this._flyouts.get(String(e.getAttribute("data-app-nav-id"))),n=t!==null&&r?Ui(r.item.children??[],t):!1;s?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current"),n?e.dataset.activeDescendant="true":delete e.dataset.activeDescendant}for(let e of this._flyouts.values()){t!==null&&Ui(e.item.children??[],t)?e.trigger.dataset.activeDescendant="true":delete e.trigger.dataset.activeDescendant;for(let r of e.panel.querySelectorAll("[data-app-nav-value-id]"))t!==null&&r.getAttribute("data-app-nav-value-id")===t?r.setAttribute("aria-current","page"):r.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}},Ki=class extends _{constructor(t){super(null),t.append(this.el)}render(){return a("span",{hidden:!0,"data-zx-app-rail-listener-scope":""})}};function vt(i){return Array.isArray(i)?i.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>({...t,label:String(t.label),children:Array.isArray(t.children)?vt(t.children):[]})):[]}function Qo(i,{className:t,index:e,iconOnly:s,disclosure:r,disclosureIcon:n}){let o=i.href&&!r?"a":"button";return a(o,{class:t,type:o==="button"?"button":null,href:o==="a"?i.href:null,target:o==="a"?i.target??null:null,ariaLabel:s?i.label:null,ariaDisabled:i.disabled?"true":null,dataset:{appNavId:e,appNavValueId:String(i.id)}},i.icon?a("span",{class:`${t}-icon`,ariaHidden:"true"},m(i.icon)):null,a("span",{class:`${t}-label`},i.label),i.badge!=null?a("span",{class:`${t}-badge`},String(i.badge)):null,r?a("span",{class:`${t}-disclosure`,ariaHidden:"true"},m(n)):null)}function mu(i){return{left:"chevron-right",right:"chevron-left",top:"chevron-down",bottom:"chevron-up"}[i]??"chevron-right"}function gu(i){return i==="right"?"chevron-left":"chevron-right"}function bu(i){return{left:"right-start",right:"left-start",top:"bottom-start",bottom:"top-start"}[i]??"right-start"}function yu(i){return i==="right"?"left-start":"right-start"}function xu(i){return{left:"right",right:"left",top:"bottom",bottom:"top"}[i]??"right"}function Zo(i){return[...i.querySelectorAll('a:not([aria-disabled="true"]), button:not([aria-disabled="true"])')]}function Jo(i){return Zo(i)[0]??null}function vu(i){return[...i.children].map(t=>t.querySelector("[data-app-nav-id]")).filter(Boolean)}function Ui(i,t){return i.some(e=>String(e.id)===t||Ui(e.children??[],t))}function Xo(i,t){if(t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t=="object"&&typeof t.nodeType=="number"&&i.append(t)}var Ns=class extends _{static cssName="app-sidebar";static defaults={items:[],active:null,expanded:[],collapsed:!1,side:"left",label:"Applications",header:null,footer:null,railHeader:null,railFooter:null};constructor(t=null,e={}){super(t,e),this.listen(this.refs.rail,"zx-select",n=>n.stopPropagation());let s=a("button",{class:"zx-app-sidebar__rail-toggle zx-icon-btn",type:"button",ariaLabel:"Expand application sidebar"},m(this.el.dataset.side==="right"?"chevron-left":"chevron-right"));this._railExpandButton=s;let r=a("div",{class:"zx-app-sidebar__rail-header"},s);Yi(r,this.options.railHeader),this._rail=new ae(this.refs.rail,{items:this._items,active:this._active,orientation:"vertical",side:this.el.dataset.side,label:this.options.label,header:r,footer:this.options.railFooter,onselect:n=>{this.emit("select",n.detail).defaultPrevented&&n.preventDefault()}}),this.listen(s,"click",()=>{this.expand()}),this._renderTree(),this.setCollapsed(!!this.options.collapsed,{silent:!0})}render(){this._createdRoot=this.el===null;let t=this.el??a("aside");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,l=>[l.name,l.value]),children:Array.from(t.childNodes)},this._items=vt(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,t.dataset.side=this.options.side==="right"?"right":"left";let e=a("div",{class:"zx-app-sidebar__header-content"});Yi(e,this.options.header);let s=a("button",{ref:"collapse",class:"zx-app-sidebar__collapse zx-icon-btn",type:"button",ariaLabel:"Minimize application sidebar"},m(t.dataset.side==="right"?"chevron-right":"chevron-left")),r=a("footer",{class:"zx-app-sidebar__footer"});Yi(r,this.options.footer),r.hidden=!r.hasChildNodes();let n=a("div",{ref:"expanded",class:"zx-app-sidebar__expanded"},a("header",{class:"zx-app-sidebar__header"},e,s),a("nav",{class:"zx-app-sidebar__nav",ariaLabel:this.options.label},a("ul",{ref:"list",class:"zx-app-sidebar__list"})),r),o=a("div",{ref:"rail",class:"zx-app-sidebar__rail"});return t.replaceChildren(n,o),this.listen(s,"click",()=>{this.collapse()}),this.listen(this.refs.list,"click",l=>this._onTreeClick(l)),t}setItems(t){return this._items=vt(t),this._reconcileExpanded(),this._renderTree(),this._rail.setItems(this._items),this}setActive(t){return this._active=t,this._syncActive(),this._rail.setActive(t),this}setExpanded(t,{silent:e=!1}={}){return this._expanded=new Set(Array.isArray(t)?t.map(String):[]),this._reconcileExpanded(),this._renderTree(),e||this.emit("branchchange",{item:null,id:null,expanded:null,ids:this.getExpanded()}),this}getExpanded(){let t=[];return Wi(this._items,e=>{this._expanded.has(String(e.id))&&t.push(e.id)}),t}toggleBranch(t,{silent:e=!1}={}){let s=Is(this._items,t);if(!s?.children?.length)return this;let r=String(t),n=!this._expanded.has(r);return n?this._expanded.add(r):this._expanded.delete(r),this._renderTree(),e||this.emit("branchchange",{item:s,id:s.id,expanded:n,ids:this.getExpanded()}),this}expand(t={}){return this.setCollapsed(!1,t)}collapse(t={}){return this.setCollapsed(!0,t)}setCollapsed(t,{silent:e=!1}={}){let s=!!t,r=s!==this._collapsed,n=document.activeElement,o=s&&!!(n&&this.refs.expanded.contains(n)),l=!s&&this._rail?._containsNode(n);return s||this._rail?.closeAllFlyouts(),this._collapsed=s,this.el.dataset.collapsed=String(s),this.refs.expanded.hidden=s,this.refs.rail.hidden=!s,o?this._railExpandButton?.focus():l&&this.refs.collapse.focus(),r&&!e&&this.emit("collapsechange",{collapsed:s}),this}isCollapsed(){return this._collapsed}getRail(){return this._rail}destroy(){let t=this._original;if(this._rail.destroy(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_renderTree(){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(s=>s.getAttribute("data-app-nav-id")===t)??null;Su(e)?.focus()}}_treeRow(t,e){let s=t.children??[],r=s.length>0,n=String(t.id),o=r&&this._expanded.has(n),l=r?y("zx-app-sidebar-branch"):null,h=wu(t,r,o,l),c=a("li",{class:"zx-app-sidebar__row",dataset:{level:e}},h);return r&&c.append(a("ul",{class:"zx-app-sidebar__sublist",id:l,hidden:!o},s.map(u=>this._treeRow(u,e+1)))),c}_onTreeClick(t){let e=t.target?.closest?.("[data-app-nav-id]");if(!e||!this.refs.list.contains(e))return;let s=Is(this._items,e.getAttribute("data-app-nav-id"));if(!s||s.disabled){t.preventDefault();return}s.children?.length?this.toggleBranch(s.id):this._select(s,t)}_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(){let t=this._active==null?null:String(this._active);for(let e of this.refs.list.querySelectorAll("[data-app-nav-id]")){let s=Is(this._items,e.getAttribute("data-app-nav-id")),r=t!==null&&e.getAttribute("data-app-nav-id")===t,n=t!==null&&s?ta(s.children??[],t):!1;r?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current"),n?e.dataset.activeDescendant="true":delete e.dataset.activeDescendant}}_reconcileExpanded(){let t=new Set;Wi(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 wu(i,t,e,s){let r=i.href&&!t?"a":"button";return a(r,{class:"zx-app-sidebar__item",type:r==="button"?"button":null,href:r==="a"?i.href:null,target:r==="a"?i.target??null:null,ariaDisabled:i.disabled?"true":null,ariaExpanded:t?String(e):null,ariaControls:s,dataset:{appNavId:String(i.id)}},i.icon?a("span",{class:"zx-app-sidebar__item-icon",ariaHidden:"true"},m(i.icon)):null,a("span",{class:"zx-app-sidebar__item-label"},i.label),i.badge!=null?a("span",{class:"zx-app-sidebar__item-badge"},String(i.badge)):null,t?a("span",{class:"zx-app-sidebar__item-disclosure",ariaHidden:"true"},m(e?"chevron-down":"chevron-right")):null)}function Su(i){let t=i;for(;t;){let e=t.closest(".zx-app-sidebar__sublist[hidden]");if(!e)return t;t=e.parentElement?.firstElementChild??null}return null}function Is(i,t){for(let e of i){if(String(e.id)===String(t))return e;let s=Is(e.children??[],t);if(s)return s}return null}function Wi(i,t){for(let e of i)t(e),Wi(e.children??[],t)}function ta(i,t){return i.some(e=>String(e.id)===t||ta(e.children??[],t))}function Yi(i,t){if(t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t=="object"&&typeof t.nodeType=="number"&&i.append(t)}var Qi=class{#t;#e=[];#s=[];#i;constructor(t=5,e=()=>{}){if(!Number.isInteger(t)||t<1)throw new RangeError("Queue limit must be positive");if(typeof e!="function")throw new TypeError("Activation callback must be a function");this.#t=t,this.#i=e}enqueue(t){return this.#e.length<this.#t?(this.#e.push(t),this.#i(t),"active"):(this.#s.push(t),"pending")}remove(t){let e=this.#s.indexOf(t);if(e!==-1)return this.#s.splice(e,1),"pending";let s=this.#e.indexOf(t);if(s===-1)return null;if(this.#e.splice(s,1),this.#s.length>0){let r=this.#s.shift();this.#e.push(r),this.#i(r)}return"active"}isActive(t){return this.#e.includes(t)}clear(){let t={active:this.#e.slice(),pending:this.#s.slice()};return this.#e.length=0,this.#s.length=0,t}get activeCount(){return this.#e.length}get pendingCount(){return this.#s.length}},Os=class i extends _{static cssName="message";static defaults={kind:"info",timeout:4e3,closable:!0,maxVisible:5};static#t=null;render(){let t=!this.el,e=this.el??a("div");return this._createdRoot=t,this._original=t?null:Du(e),this._entries=new Set,this._queue=new Qi(zu(this.options.maxVisible),s=>{this._activate(s)}),e.replaceChildren(),e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e}show(t,e={}){let s={kind:Au(e.kind??this.options.kind),timeout:ku(e.timeout??this.options.timeout),closable:e.closable??!!this.options.closable},r=this._createEntry(t,s);return this._entries.add(r),this._queue.enqueue(r),{close:()=>this._close(r)}}static info(t,e={}){return this.show(t,{...e,kind:"info"})}static success(t,e={}){return this.show(t,{...e,kind:"success"})}static warning(t,e={}){return this.show(t,{...e,kind:"warning"})}static error(t,e={}){return this.show(t,{...e,kind:"error"})}static show(t,e={}){return this.#e().show(t,e)}static progress(t){return this.#e()._progress(t)}destroy(){if(!this._cleaned){this._cleaned=!0;for(let t of this._entries)Gi(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&Iu(this.el,this._original)}}_progress(t){let e={pct:0,text:String(t)},s=this._createEntry(e.text,{kind:"info",timeout:0,closable:!1},e);this._entries.add(s),this._queue.enqueue(s);let r=!1;return{update:(n,o)=>{r||s.closed||(e.pct=Tu(n),o!==void 0&&(e.text=String(o)),Ms(s,e))},done:()=>{r||s.closed||(r=!0,e.pct=100,Ms(s,e),s.remaining=600,this._queue.isActive(s)&&this._schedule(s))},fail:n=>{r||s.closed||(r=!0,n!==void 0&&(e.text=String(n)),s.kind="error",s.node.dataset.kind="error",s.node.setAttribute("role","alert"),s.iconHost.replaceChildren(m("error",{size:18})),Ms(s,e),s.remaining=4e3,this._queue.isActive(s)&&this._schedule(s))}}}_createEntry(t,e,s=null){let r=a("span",{class:"zx-message__icon",ariaHidden:"true"},m(e.kind,{size:18})),n=a("div",{class:"zx-message__content"});Cu(t)?n.append(t):n.append(document.createTextNode(String(t)));let o=a("div",{class:"zx-message__toast",role:e.kind==="error"?"alert":"status",dataset:{kind:e.kind,state:"queued"}},r,n),l={node:o,content:n,iconHost:r,kind:e.kind,timeout:e.timeout,remaining:e.timeout,startedAt:0,timer:null,exitTimer:null,closed:!1,progressBar:null,progressFill:null};if(s){o.dataset.progress="";let h=a("span",{class:"zx-message__progress-fill"}),c=a("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:s.text},h);n.append(c),l.progressBar=c,l.progressFill=h,Ms(l,s)}if(e.closable){let h=a("button",{class:"zx-icon-btn zx-message__close",type:"button",ariaLabel:"Close message",title:"Close"},m("x",{size:14}));o.append(h),this.listen(h,"click",()=>this._close(l))}return this.listen(o,"mouseenter",()=>this._pause(l)),this.listen(o,"mouseleave",()=>this._resume(l)),l}_activate(t){t.closed||(t.node.dataset.state="open",this.el.append(t.node),this._schedule(t))}_schedule(t){t.closed||t.remaining<=0||(t.startedAt=Date.now(),t.timer=setTimeout(()=>this._close(t),t.remaining))}_pause(t){t.closed||t.timer===null||(clearTimeout(t.timer),t.timer=null,t.remaining=Math.max(0,t.remaining-(Date.now()-t.startedAt)))}_resume(t){if(!(t.closed||t.timer!==null)){if(t.remaining<=0){this._close(t);return}this._schedule(t)}}_close(t){if(t.closed)return;if(t.closed=!0,Gi(t),!this._queue.isActive(t)){this._queue.remove(t),t.node.remove(),this._entries.delete(t);return}if(t.node.dataset.state="closing",!Eu()){this._finish(t);return}let e=s=>{s.target===t.node&&this._finish(t)};this.listen(t.node,"animationend",e,{once:!0}),t.exitTimer=setTimeout(()=>this._finish(t),260)}_finish(t){this._entries.has(t)&&(Gi(t),t.node.remove(),this._entries.delete(t),this._queue.remove(t))}static#e(){if(this.#t)return this.#t;let t=a("div",{class:"zx-message-region",popover:"manual",role:"status",ariaLive:"polite"});return document.body.append(t),this.#t=new i(t),typeof t.showPopover=="function"&&t.showPopover(),this.#t}};function Au(i){return i==="danger"?"error":["success","warning","error"].includes(String(i))?i:"info"}function ku(i){let t=Number(i);return Number.isFinite(t)?Math.max(0,t):4e3}function zu(i){let t=Number(i);return Number.isInteger(t)&&t>0?t:5}function Cu(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function Tu(i){let t=Number(i);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function Ms(i,t){i.content.firstChild.textContent=t.text,i.progressBar?.setAttribute("aria-valuenow",String(t.pct)),i.progressBar?.setAttribute("aria-label",t.text),i.progressFill&&(i.progressFill.style.inlineSize=`${t.pct}%`)}function Gi(i){i.timer!==null&&clearTimeout(i.timer),i.exitTimer!==null&&clearTimeout(i.exitTimer),i.timer=null,i.exitTimer=null}function Eu(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function Du(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Iu(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}var Nu=new Set(["start","end","top","bottom"]),Mu=new Set(["dim","blur","none"]),Ou=Object.freeze({start:1,end:-1,top:1,bottom:-1}),Fs=class extends ht{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;#s=0;constructor(t=null,e={}){super(null,e),this._dock=null,this._handoff=!1,this.setSide(this.options.side),this.el.dataset.backdrop=Mu.has(this.options.backdrop)?this.options.backdrop:"dim",this.el.dataset.modality=Ru(this.options.modal),this.refs.close.hidden=!this.options.closeButton,this.options.modal!==!0&&(this.listen(this.el,"keydown",s=>{let r=s;r.key!=="Escape"||!this.options.closable||this._dock||(r.preventDefault(),this.emit("cancel").defaultPrevented||this.close())}),this.options.lightDismiss&&this.listen(document,"pointerdown",s=>{let r=s.target;!this.isOpen()||this._dock||this.el.contains(r)||this.close()})),this.on("close",()=>this.#t?.deactivate()),this.#i()&&this.#n()}#i(){let t=this.options.handle,e=this.getSide(),s=t===!0||t==="auto"&&(e==="top"||e==="bottom");return!!this.options.resizable||Array.isArray(this.options.snap)||s}#n(){let t=this.getSide()==="top"||this.getSide()==="bottom",e=a("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.#h(),this.#e=re(e,{orientation:t?"vertical":"horizontal",disabled:()=>this.isDocked(),onStart:()=>{this.#s=this.getSize(),this.el.dataset.dragging="true"},onMove:s=>this.#r(s,!1),onEnd:(s,r)=>{delete this.el.dataset.dragging,r&&this.#r(s,!0)},onStep:(s,r)=>{this.#s=this.getSize(),this.#r(s*(r?64:16),!0)}})}#r(t,e){let s=this.#o(),{min:r,max:n}=this.#a(s),l=!!this.options.resizable||this.#l(s).length>0?n:Math.min(n,this.#s),h=N(this.#s+t*Ou[this.getSide()],0,l);if(!e){this._applySize(h),this.#h();return}if(this.options.closable&&h<r/2){this._applySize(this.#s),this.close();return}let c=this.#l(s),u=c.length>0?Lu(h,c):h;this._applySize(N(u,r,l)),this.#h(),this.emit("resize",{size:this.getSize(),ratio:s>0?this.getSize()/s:0})}snapTo(t){let e=this.#o(),s=this.#l(e);if(s.length===0)return this;let r=typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<s.length?s[t]:ea(t,e);if(!Number.isFinite(r))return this;let{min:n,max:o}=this.#a(e);return this._applySize(N(r,n,o)),this.#h(),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 s=this.msg(t);return s===t?e:s}#o(){return this.getSide()==="top"||this.getSide()==="bottom"?window.innerHeight:window.innerWidth}#a(t){let e=this.#l(t),s=Math.max(0,Number(this.options.min)||0),r=this.options.max==null?t:Math.min(t,Number(this.options.max)||t),n=e.length>0?Math.max(s,Math.min(...e)):s;return{min:Math.min(n,r),max:r}}#l(t){let e=this.options.snap;return Array.isArray(e)?e.map(s=>ea(s,t)).filter(s=>Number.isFinite(s)&&s>0).sort((s,r)=>s-r):[]}#h(){let t=this.refs.handle;if(!t)return;let e=this.#o(),{min:s,max:r}=this.#a(e);t.setAttribute("aria-valuenow",String(Math.round(this.getSize()))),t.setAttribute("aria-valuemin",String(Math.round(s))),t.setAttribute("aria-valuemax",String(Math.round(r)))}mountTarget(){return this._dock?.el??document.body}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._handoff=!0,this.el.close()),this.mountTarget().append(this.el),t&&(this.el.returnValue="",this._show(),this.el.dataset.state="open",this._dock?delete this.el.dataset.zxOverlayOrder:this.el.dataset.zxOverlayOrder=String(Fu()))}_isRealClose(){return this._handoff?(this._handoff=!1,!1):!0}open(){return this.isOpen()?this:(this.options.modal==="trap-focus"&&(this.#t??=Ge(this.el),this.#t.activate()),super.open(),this.#h(),this)}close(t){return this.#t?.deactivate(),super.close(t)}setSide(t){return this.el.dataset.side=Nu.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=Pu(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){super._show();return}this.el.show()}destroy(){this.#t?.deactivate(),this.#t=null,this.#e?.destroy(),this.#e=null,this._dock?._forget(this),this._dock=null,super.destroy()}};function Fu(){let i=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...i)+1}function ea(i,t){return typeof i=="number"&&Number.isFinite(i)&&i>0&&i<=1?i*t:Q(i,t)}function Lu(i,t){let e=i,s=Number.POSITIVE_INFINITY;for(let r of t){let n=Math.abs(r-i);n<s&&(s=n,e=r)}return e}function Ru(i){return i===!0?"modal":i==="trap-focus"?"trap-focus":"none"}function Pu(i){return i==null||i===""?null:typeof i=="number"?Number.isFinite(i)?`${Math.max(0,i)}px`:null:String(i)}var Ls=class i extends EventTarget{static defaults=Object.freeze({layout:"stack",offset:24,scale:.04,max:3});#t=[];#e=new WeakMap;#s=!1;constructor(t={}){super();let e={...i.defaults,...t&&typeof t=="object"?t:{}};for(let[s,r]of Object.entries(e))!/^on[a-z]/.test(s)||typeof r!="function"||(this.on(s.slice(2),r),delete e[s]);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 s=()=>this.#i(t);this.#e.set(t,s),t.on("close",s)}return t.isOpen()||t.open(),this.#r(),this.#o("push",{sheet:t,depth:0}),this}pop(){let t=this.top();return t?(this.#n(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.#s){this.#s=!0;for(let t of this.#t){let e=this.#e.get(t);e&&t.off("close",e),sa(t)}this.#t=[]}}#i(t){this.#t.includes(t)&&this.#n(t)}#n(t){let e=this.#t.indexOf(t);if(e===-1)return;this.#t.splice(e,1);let s=this.#e.get(t);s&&t.off("close",s),this.#e.delete(t),sa(t),this.#r(),this.#o("pop",{sheet:t})}#r(){let{layout:t,offset:e,scale:s,max:r}=this.options,n=t==="cascade",o=0;for(let l=0;l<this.#t.length;l+=1){let h=this.#t[this.#t.length-1-l],c=h.el;c.dataset.stack=n?"cascade":"stack",c.dataset.depth=String(l),c.style.setProperty("--zx-sheet-depth",String(l)),c.style.setProperty("--zx-sheet-stack-offset",`${Number(e)||0}px`),c.style.setProperty("--zx-sheet-stack-scale",String(Number(s)||0)),c.toggleAttribute("data-stack-hidden",l>=Math.max(1,Number(r)||1)),c.inert=!n&&l>0,n?(c.style.setProperty("--zx-sheet-depth-offset",`${o}px`),o+=h.getSize()):c.style.removeProperty("--zx-sheet-depth-offset")}}#o(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))}};function sa(i){let t=i.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 Rs='[role="menuitem"]',Ps=class extends _{static defaults={items:[],selector:null};#t;#e;#s;#i;#n;#r=[];#o=null;#a=null;#l=!1;constructor(t,e={}){let s=R(t);if(!s)throw new TypeError("ContextMenu target could not be resolved");super(null,e),this.#t=s,document.body.append(this.el),this.#e=new W(this.el,{openOn:"manual",placement:"bottom-start"}),this.#s=this.#e.getPanel(),this.#s.classList.add("zx-context-menu"),this.#s.setAttribute("role","menu"),Array.isArray(this.options.items)&&this.setItems(this.options.items),this.#i=rt(this.#s,Rs),this.#n=Y(()=>this.#m(),r=>r.focus()),this.#e.on("close",()=>{this.#o=null;let r=this.#a;this.#a=null,r instanceof HTMLElement&&r.isConnected&&r.focus(),this.emit("close")}),this.listen(this.#t,"contextmenu",r=>this.#u(r)),this.listen(this.#t,"keydown",r=>this.#d(r)),this.listen(this.#s,"click",r=>{let n=r.target.closest?.(Rs);n&&this.#s.contains(n)&&this.#f(n)}),this.listen(this.#s,"keydown",r=>this.#_(r))}render(){return a("span",{class:"zx-context-menu__anchor",ariaHidden:"true"})}setItems(t){return this.#r=Array.isArray(t)?t.slice():[],this.#s.replaceChildren(),this.#r.forEach((e,s)=>{if(e==="-"){this.#s.append(a("div",{class:"zx-context-menu__separator",role:"separator"}));return}let r=[];e.icon&&r.push(a("span",{class:"zx-context-menu__icon"},m(e.icon))),r.push(a("span",{class:"zx-context-menu__label"},String(e.label??""))),this.#s.append(a("button",{class:"zx-context-menu__item",type:"button",role:"menuitem",tabindex:"-1","data-menu-item":String(s),"data-danger":e.danger?"true":null,ariaDisabled:e.disabled?"true":null},r))}),this}openAt(t,e,s=null){return this.#h(s)?(this.#c(t,e,s),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.#i.destroy(),this.#e.destroy(),super.destroy())}#h(t){let e=this.options.items;if(typeof e=="function"){let s=e(t);if(!Array.isArray(s)||s.length===0)return!1;this.setItems(s)}return this.#r.length>0}#c(t,e,s){let r=this.el;r.style.left=`${t}px`,r.style.top=`${e}px`,this.#o=s,this.#a=document.activeElement,this.#e.open(),this.#i.focusFirst(),this.emit("open",{context:s})}#u(t){let e=t,s=this.#p(e.target);!s||!this.#h(s)||(t.preventDefault(),this.#c(e.clientX,e.clientY,s))}#d(t){let e=t;if(e.key!=="ContextMenu"&&!(e.key==="F10"&&e.shiftKey))return;let s=this.#p(e.target);if(!s||!this.#h(s))return;t.preventDefault();let r=s.getBoundingClientRect();this.#c(r.left,r.bottom,s)}#p(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 s=e.target.closest?.(Rs);if(!s||!this.#s.contains(s))return;t.preventDefault(),this.#f(s);return}this.#n(e)}#f(t){let e=Number(t.getAttribute("data-menu-item")),s=this.#r[e];if(!s||s==="-"||s.disabled)return;let r=this.#o;this.emit("select",{value:s.value,item:s,context:r});try{s.onselect?.(s.value,s,this)}finally{this.close()}}#m(){return Array.from(this.#s.querySelectorAll(Rs))}};var Bs=class i extends yt{static cssName="table";constructor(t=null,e={}){super(t,e)}static BillingItems(t,e={}){let s=new i(t,Bu(e));return s.el.dataset.preset="billing-items",s}};function Bu(i={}){let{fields:t={},units:e=[],currencies:s=[],currency:r="EUR",locale:n,decimals:o=2,columnOverrides:l={},lineTotal:h=null,columns:c,oneditcommit:u,rowClass:d,...f}=i,p={...ra,...t},g=typeof h=="function"?h:v=>{let b=Number(v?.[p.quantity]),w=Number(v?.[p.unitPrice]);return Number.isFinite(b)&&Number.isFinite(w)?b*w:null},x=Array.isArray(c)?c.map(v=>({...v})):Ji(p,{units:e,currencies:s,currency:r,locale:n,decimals:o,columnOverrides:l});return{rowId:p.id,editMode:"cell",hierarchy:{parentId:p.parent,column:p.item,expanded:!0},responsive:"sm",...f,columns:x,rowClass(v){let b=Ee(v,p)?"":"zx-grid-billing__summary",w=typeof d=="function"?d(v):"";return[b,w].filter(Boolean).join(" ")},oneditcommit(v){let{row:b,changes:w}=v.detail;if(Ee(b,p)){let E={...b,...w},H=g(E,w);H!=null&&Number.isFinite(Number(H))&&(w[p.total]=Number(H))}u?.(v)}}}var ra=Object.freeze({id:"id",parent:"parent",item:"item",kind:"kind",quantity:"quantity",unit:"unit",unitPrice:"unitPrice",currency:"currency",total:"total"});function Ee(i,t=ra){let e=String(i?.[t.kind]??"line").toLowerCase();return!["group","subtotal","header","section"].includes(e)}function Ji(i,{units:t,currencies:e,currency:s,locale:r,decimals:n,columnOverrides:o}){let l=d=>f=>Ee(f,i)?d:!1,h=d=>String(d?.[i.currency]||s),c=d=>String(d?.[i.unit]??""),u={item:{id:i.item,label:"Item",width:"2fr",sortable:!0,editable:l("text")},quantity:{id:i.quantity,label:"Quantity",width:"1fr",type:"unit",locale:r,unit:c,editable:l("number"),editorProps:{min:0,step:.01}},unit:{id:i.unit,label:"Unit",width:".8fr",editable:l(ia(t)?"select":"text"),options:t},unitPrice:{id:i.unitPrice,label:"Unit price",width:"1fr",type:"currency",locale:r,decimals:n,currency:h,editable:l("number"),editorProps:{min:0,step:.01}},currency:{id:i.currency,label:"Currency",width:".8fr",editable:l(ia(e)?"select":"text"),options:e},total:{id:i.total,label:"Line total",width:"1fr",type:"currency",locale:r,decimals:n,currency:h}};return Object.entries(u).map(([d,f])=>({...f,...o?.[d]??{}}))}function ia(i){return Array.isArray(i)?i.length>0:!!(i&&typeof i=="object"&&Object.keys(i).length)}var qs=class extends _{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??a("div");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,h=>[h.name,h.value]),children:Array.from(t.childNodes)},this._adapter=this.options.adapter,this._type=String(this.options.type||"bar"),this._data=oa(this.options.data),this._label=qu(this.options.label),this._chartOptions=st(this.options.chartOptions),this._loading=!!this.options.loading,this._error=null,this._handle=null,this._destroyed=!1;let e=y("zx-chart-description"),s=a("canvas",{ref:"canvas",class:"zx-chart__canvas",role:"img",ariaLabel:this._label,ariaDescribedby:e}),r=a("div",{ref:"viewport",class:"zx-chart__viewport"},s);r.style.setProperty("--zx-chart-aspect-ratio",String(this.options.aspectRatio));let n=a("p",{ref:"description",class:"zx-chart__description",id:e},this.options.description),o=a("div",{ref:"status",class:"zx-chart__status",role:"status",ariaLive:"polite"}),l=a("div",{ref:"summary",class:"zx-chart__summary",dataset:{summary:this.options.summary==="visible"?"visible":"hidden"}});return t.replaceChildren(r,n,o,l),this._renderSummary(),this._syncState(),this._observer=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.resize()):null,this._observer?.observe(r),t}setData(t){return this._data=oa(t),this._error=null,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=st(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._loading=!1,this._destroyHandle(),this._syncState(),this.emit("error",{error:this._error}),this}clearError(){return this._error=null,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,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_mountOrUpdate(t){if(this._syncState(),this._loading||this._error||Vs(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(s){this.setError(s)}}_spec(){return{type:this._type,data:st(this._data),options:{...ju(this.el),...st(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=Vs(this._data),e=this._loading?"loading":this._error?"error":t?"empty":"ready";this.el.dataset.state=e,this.refs.viewport.hidden=e!=="ready";let s="";e==="loading"?s=String(this.options.loadingText):e==="error"?s=$u(this._error,this.options.errorText):e==="empty"&&(s=String(this.options.emptyText)),this.refs.status.textContent=s,this.refs.status.hidden=!s}_renderSummary(){this.refs.summary.replaceChildren(Zi(this._data,this._label))}};function qu(i){return String(i??"").trim()||"Chart"}var Hs=class{constructor(t,e={}){let s=typeof t=="function"?t:t?.Chart;if(typeof s!="function")throw new TypeError("ChartJsAdapter requires an injected Chart.js constructor");this.engine=s,this.defaults=st(e)}create(t,e){let s=this.engine,r=null,n="",o=!1,l=h=>{let c=null,u=na(h,this.defaults,()=>c);c=new s(t,u),r=c,n=h.type};return l(e),{get instance(){return r},update:h=>{if(o)return;if(h.type!==n){let u=r;r=null,u?.destroy?.(),l(h);return}let c=na(h,this.defaults,()=>r);r.data=c.data,r.options=c.options,r.update()},resize:()=>{o||r?.resize?.()},destroy:()=>{o||(o=!0,r?.destroy?.(),r=null)}}}};function na(i,t,e){let s=st(i.options),r={responsive:!0,maintainAspectRatio:!1,...st(t),...s},n=r.onClick;return r.onClick=(o,l,h)=>{typeof n=="function"&&n(o,l,h);let c=e()??h,d=(Array.isArray(l)&&l.length?l:c?.getElementsAtEventForMode?.(o,"nearest",{intersect:!0},!0)??[])[0];if(!d)return;let f=i.data.datasets?.[d.datasetIndex]??null;i.onSelect({datasetIndex:d.datasetIndex,index:d.index,dataset:f,label:i.data.labels?.[d.index],value:f?.data?.[d.index],nativeEvent:o?.native??o??null})},{type:i.type,data:st(i.data),options:r}}function st(i){return Xi(i,new WeakMap)}function Xi(i,t){if(Array.isArray(i)){if(t.has(i))return t.get(i);let e=[];return t.set(i,e),e.push(...i.map(s=>Xi(s,t))),e}if(i&&typeof i=="object"&&Object.getPrototypeOf(i)===Object.prototype){if(t.has(i))return t.get(i);let e={};t.set(i,e);for(let[s,r]of Object.entries(i))e[s]=Xi(r,t);return e}return i}function oa(i){return!i||typeof i!="object"?{labels:[],datasets:[]}:st({...i,labels:Array.isArray(i.labels)?i.labels:[],datasets:Array.isArray(i.datasets)?i.datasets:[]})}function Vs(i){return!Array.isArray(i?.datasets)||!i.datasets.some(t=>Array.isArray(t?.data)&&t.data.length>0)}function Zi(i,t="Chart data"){let e=Hu(i);return a("table",{class:"zx-chart__table"},a("caption",{},t),a("thead",{},a("tr",{},a("th",{scope:"col"},"Label"),e.headers.map(r=>a("th",{scope:"col"},r)))),a("tbody",{},e.rows.map(r=>a("tr",{},a("th",{scope:"row"},r.label),r.values.map(n=>a("td",{},n))))))}function Hu(i){let t=Array.isArray(i?.datasets)?i.datasets:[],e=Array.isArray(i?.labels)?i.labels:[],s=Math.max(e.length,...t.map(r=>Array.isArray(r.data)?r.data.length:0),0);return{headers:t.map((r,n)=>String(r.label??`Series ${n+1}`)),rows:Array.from({length:s},(r,n)=>({label:String(e[n]??n+1),values:t.map(o=>Vu(o.data?.[n]))}))}}function Vu(i){if(i==null)return"";if(typeof i=="object"){if("y"in i)return String(i.y??"");if("r"in i)return String(i.r??"");try{return JSON.stringify(i)}catch{return String(i)}}return String(i)}function ju(i){if(typeof getComputedStyle!="function")return{};let t=getComputedStyle(i),e=t.getPropertyValue("--zx-color-text").trim(),s=t.getPropertyValue("--zx-color-border").trim();return{color:e||void 0,borderColor:s||void 0}}function $u(i,t){return i&&typeof i=="object"&&"message"in i?String(i.message):String(t)}function js({valueKey:i="ID",labelKey:t="name",childrenKey:e="children"}={}){return{value:s=>typeof i=="function"?i(s):s?.[i],label:s=>String((typeof t=="function"?t(s):s?.[t])??""),children:s=>{let r=s?.[e];return Array.isArray(r)?r:null}}}function L(i,t){if(i?.hasChildren===!0)return!0;let e=t.children(i);return Array.isArray(e)&&e.length>0}function le(i,t,e,{level:s=1,parent:r=null}={}){i.forEach((n,o)=>{e(n,{level:s,parent:r,index:o,siblings:i});let l=t.children(n);l&&le(l,t,e,{level:s+1,parent:n})})}function aa(i,t,e){let s=null;return le(i,e,r=>{s===null&&Object.is(e.value(r),t)&&(s=r)}),s}function De(i,t,e){for(let s of i){if(Object.is(e.value(s),t))return[s];let r=e.children(s);if(!r)continue;let n=De(r,t,e);if(n.length>0)return[s,...n]}return[]}function la(i,t){let e=[],s=t.children(i);return s&&le(s,t,r=>e.push(r)),e}function ha(i,t,e){let s=[],r=(n,o,l)=>{n.forEach((h,c)=>{let u=t.value(h);if(s.push({node:h,id:u,level:o,parent:l,posinset:c+1,setsize:n.length}),!e.has(u))return;let d=t.children(h);d&&d.length>0&&r(d,o+1,h)})};return r(i,1,null),s}function tr(i,t,e,s){let r=[];for(let n of i){let o=t.children(n)??[],l=tr(o,t,e,s);(e(n)||l.length>0)&&r.push(l.length>0||o.length>0?{...n,[s]:l}:n)}return r}var $s=class extends _{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??a("div");this.el=t,this._readers=js(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=er(this.options.items);for(let s of Ie(this.options.expanded))this._expanded.add(s);for(let s of Ie(this.options.selected))this._selected.add(s);let[e]=this._selected;if(e!==void 0){this._focusId=e;for(let s of this.getPath(e).slice(0,-1))this._expanded.add(this._readers.value(s))}for(let s of Ie(this.options.checked))this._applyCheck(s,!0,{silent:!0});return this._handleTypeahead=Y(()=>this._rotatedRows().map(s=>this._readers.label(s.node)),(s,r)=>this._focusNodeId(this._rotatedRows()[r]?.id)),this.listen(t,"keydown",s=>this._onKeydown(s)),this.listen(t,"click",s=>this._onClick(s)),this.listen(t,"dblclick",s=>this._onDoubleClick(s)),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=er(t),this._renderRows(),this}getItems(){return this._items}getNode(t){return aa(this._items,t,this._readers)}getPath(t){return De(this._items,t,this._readers)}setFilter(t){if(this._filter=String(t??""),this._filter!=="")for(let e of this._visibleItems())le([e],this._readers,s=>this._expanded.add(this._readers.value(s)));return this._renderRows(),this}async expand(t){let e=this.getNode(t);if(!e||!L(e,this._readers))return this;let s=this._readers.children(e),r=!!this.options.load&&(!s||s.length===0);return this._expanded.has(t)&&!r?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 le(this._items,this._readers,t=>{L(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 s of e.slice(0,-1))this._expanded.add(this._readers.value(s));return this._renderRows(),this}select(t,{silent:e=!1,additive:s=!1}={}){if(this.options.selection===!1)return this;let r=this.getNode(t);return r?(this.options.selection==="multi"&&s?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:r,id:t,ids:this.getSelection()}),this):this}getSelection(){return[...this._selected]}setSelection(t,{silent:e=!0}={}){let s=Ie(t);if(this._selected=new Set(this.options.selection==="multi"?s:s.slice(0,1)),this._syncRows(),!e){let[r]=this._selected;this.emit("select",{node:this.getNode(r)??null,id:r,ids:this.getSelection()})}return this}clearSelection(){return this._selected.clear(),this._syncRows(),this}getChecked({leavesOnly:t=!1}={}){return t?[...this._checked].filter(e=>{let s=this.getNode(e);return s!==null&&!L(s,this._readers)}):[...this._checked]}setChecked(t,{silent:e=!0}={}){this._checked.clear();for(let s of Ie(t))this._applyCheck(s,!0,{silent:!0});return this._syncRows(),e||this.emit("check",{ids:this.getChecked(),node:null}),this}check(t,e,{silent:s=!1}={}){let r=this._applyCheck(t,e,{silent:!0});return this._syncRows(),!s&&r&&this.emit("check",{ids:this.getChecked(),node:r}),this}focusNode(t){this.reveal(t);let e=this._rows.findIndex(s=>Object.is(s.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:tr(this._items,this._readers,e=>this._readers.label(e).toLocaleLowerCase().includes(t),this._childrenKey)}_renderRows(){let t=this._visibleItems();if(this._rows=ha(t,this._readers,this._expanded),this._rows.length===0){this.el.replaceChildren(a("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=L(t.node,this._readers),s=e&&this._expanded.has(t.id),r=a("div",{class:"zx-tree__row",role:"treeitem",id:y("zx-tree-item"),tabIndex:-1,ariaLevel:String(t.level),ariaSetSize:String(t.setsize),ariaPosInSet:String(t.posinset),dataset:{level:String(t.level)}});r.style.setProperty("--zx-tree-level",String(t.level-1));let n=a("span",{class:"zx-tree__twisty",ariaHidden:"true"},e?m("chevron-right",{size:12}):null);if(n.dataset.action="twisty",r.append(n),this.options.checkboxes){let l=a("input",{class:"zx-tree__checkbox",type:"checkbox",tabIndex:-1,ariaHidden:"true"});l.dataset.action="checkbox",r.append(l)}this.options.icons&&r.append(a("span",{class:"zx-tree__icon",ariaHidden:"true"},m(e?s?"folder-open":"folder":"file",{size:14})));let o=this.options.renderLabel?this.options.renderLabel(t.node):this._readers.label(t.node);return r.append(a("span",{class:"zx-tree__label"},o)),t.node.badge!=null&&r.append(a("span",{class:"zx-tree__badge"},String(t.node.badge))),r}_syncRows(){let t=this.el.querySelectorAll(".zx-tree__row"),e=this._rows.findIndex(s=>Object.is(s.id,this._focusId));e<0&&(e=0),t.forEach((s,r)=>{let n=this._rows[r];if(!n)return;let o=L(n.node,this._readers),l=o&&this._expanded.has(n.id);o?s.setAttribute("aria-expanded",String(l)):s.removeAttribute("aria-expanded"),this.options.selection!==!1&&s.setAttribute("aria-selected",String(this._selected.has(n.id))),s.toggleAttribute("data-branch",o),s.toggleAttribute("data-loading",this._loading.has(n.id)),s.tabIndex=r===e?0:-1;let h=s.querySelector(".zx-tree__checkbox");if(h){let u=this._checkState(this.getNode(n.id)??n.node);h.checked=u==="checked",h.indeterminate=u==="partial",s.setAttribute("aria-checked",u==="partial"?"mixed":String(h.checked))}let c=s.querySelector(".zx-tree__icon");c&&this.options.icons&&c.replaceChildren(m(o?l?"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 s=this._rowIndex(e);if(s<0)return;let r=this._rows[s];this._focusRow(s);let n=t.target.closest("[data-action]");if(n?.dataset.action==="twisty"){L(r.node,this._readers)&&this.toggle(r.id).then(()=>this._focusNodeId(r.id));return}let o=this.getNode(r.id)??r.node;if(n?.dataset.action==="checkbox"){this.check(r.id,this._checkState(o)!=="checked");return}if(this.options.checkboxes&&this.options.selection===!1){this.check(r.id,this._checkState(o)!=="checked");return}this.select(r.id,{additive:t.ctrlKey||t.metaKey})}_onDoubleClick(t){let e=t.target.closest(".zx-tree__row");if(!e)return;let s=this._rows[this._rowIndex(e)];s&&(L(s.node,this._readers)?this.toggle(s.id).then(()=>this._focusNodeId(s.id)):this.emit("activate",{node:s.node,id:s.id}))}_onKeydown(t){let e=this._rows.findIndex(o=>Object.is(o.id,this._focusId));if(e<0||this._rows.length===0)return;let s=this._rows[e],r=L(s.node,this._readers),n=r&&this._expanded.has(s.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(),r&&!n?this.expand(s.id).then(()=>this._focusNodeId(s.id)):n&&this._focusRow(Math.min(this._rows.length-1,e+1));return;case"ArrowLeft":{t.preventDefault(),n?(this.collapse(s.id),this._focusNodeId(s.id)):s.parent&&this._focusNodeId(this._readers.value(s.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(s.id),this.emit("activate",{node:s.node,id:s.id});return;case" ":t.preventDefault(),this.options.checkboxes?this.check(s.id,this._checkState(this.getNode(s.id)??s.node)!=="checked"):this.options.selection!==!1&&this.select(s.id,{additive:this.options.selection==="multi"});return;case"*":t.preventDefault(),this._expandSiblings(s);return;default:this._handleTypeahead(t)}}_expandSiblings(t){let e=t.parent?this._readers.children(t.parent)??[]:this._visibleItems(),s=this._focusId;for(let r of e)L(r,this._readers)&&this._expanded.add(this._readers.value(r));this._renderRows(),this._focusNodeId(s)}async _ensureChildren(t,e){let s=this._readers.children(t);if(!this.options.load||s&&s.length>0)return!0;if(this._loading.has(e))return await this._loading.get(e),Array.isArray(this._readers.children(t));let r=(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,r),this._syncRows();let n=await r;return this._syncRows(),n}_applyCheck(t,e,{silent:s}){let r=this.getNode(t);if(!r)return null;let n=[t,...la(r,this._readers).map(o=>this._readers.value(o))];for(let o of n)e?this._checked.add(o):this._checked.delete(o);return s||this._syncRows(),r}_checkState(t){let e=this._readers.children(t);if(!e||e.length===0)return this._checked.has(this._readers.value(t))?"checked":"unchecked";let s=e.map(r=>this._checkState(r));return s.every(r=>r==="checked")?"checked":s.every(r=>r==="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(s=>Object.is(s.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 s=this._rowElement(e.id);s?.focus(),s?.scrollIntoView({block:"nearest"})}_focusNodeId(t){if(t===void 0)return;let e=this._rows.findIndex(s=>Object.is(s.id,t));e>=0&&this._focusRow(e)}_message(t,e){let s=this.msg(t);return s===t?e:s}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&z(t,this._snapshot)}};function er(i){return Array.isArray(i)?i.map(t=>{if(t===null||typeof t!="object")return t;let e={...t};for(let[s,r]of Object.entries(e))Array.isArray(r)&&(e[s]=er(r));return e}):[]}function Ie(i){return Array.isArray(i)?i:[]}var Ks=class extends _{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??a("div");return this.el=t,this._readers=js(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=Y(()=>this._columnNodes(this._activeColumn).map(e=>this._readers.label(e)),(e,s)=>this._selectAt(this._activeColumn,s,{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 s of this._path){let r=t.find(n=>Object.is(this._readers.value(n),s));if(!r)break;e.push(r),t=this._readers.children(r)??[]}return e}getSelection(){let t=this.getNodes();return t.length>0?t[t.length-1]:null}async setPath(t,{silent:e=!1,focus:s=!1}={}){let r=this._pathSequence+1;this._pathSequence=r;let n=Array.isArray(t)?t.slice():[],o=[],l=this._items;for(let h of n){let c=l.find(u=>Object.is(this._readers.value(u),h));if(!c||(o.push(h),!L(c,this._readers)))break;if(await this._ensureChildren(c),r!==this._pathSequence)return this;l=this._readers.children(c)??[]}return this._path=o,this._activeColumn=Math.max(0,o.length-1),this._render({focus:s}),e||this._emitChange(),this}async reveal(t,{silent:e=!1}={}){let s=De(this._items,t,this._readers);return s.length===0?this:this.setPath(s.map(r=>this._readers.value(r)),{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(),s=[{nodes:this._items,selectedId:this._path[0],owner:null}];e.forEach((l,h)=>{if(!L(l,this._readers))return;let c=this._readers.children(l)??[];s.push({nodes:c,selectedId:this._path[h+1],owner:l})}),this._columns=s,this._activeColumn=Math.min(this._activeColumn,s.length-1);let r=s.map((l,h)=>this._renderColumn(l,h)),n=e[e.length-1]??null;if(this.options.preview&&n&&!L(n,this._readers)){let l=this.options.preview(n);l&&r.push(a("div",{class:"zx-finder__preview"},l))}this.el.replaceChildren(...r),this._syncTabStop(),this.el.lastElementChild?.scrollIntoView({block:"nearest",inline:"nearest"}),t&&this.focus()}_renderColumn(t,e){let s=t.owner?this._readers.label(t.owner):String(this.options.rootLabel||this._message("finder.root","Root")),r=a("div",{class:"zx-finder__list",role:"listbox",ariaLabel:s,dataset:{column:String(e)}});if(t.nodes.length===0){let n=t.owner!==null&&this._loading.has(this._readers.value(t.owner));r.append(a("div",{class:"zx-finder__empty"},n?this._message("finder.loading","Loading\u2026"):this._message("finder.empty",this.options.emptyText)))}for(let n of t.nodes){let o=this._readers.value(n),l=L(n,this._readers),h=t.selectedId!==void 0&&Object.is(o,t.selectedId),c=a("div",{class:"zx-finder__row",id:y("zx-finder-row"),role:"option",tabIndex:-1,ariaSelected:String(h)});this.options.icons&&c.append(a("span",{class:"zx-finder__icon",ariaHidden:"true"},m(l?"folder":"file",{size:14}))),c.append(a("span",{class:"zx-finder__label"},this.options.renderItem?this.options.renderItem(n):this._readers.label(n))),l&&c.append(a("span",{class:"zx-finder__chevron",ariaHidden:"true"},m("chevron-right",{size:11}))),c.toggleAttribute("data-branch",l),r.append(c)}return a("div",{class:"zx-finder__column"},r)}_syncTabStop(){let t=this.el.querySelectorAll(".zx-finder__row");t.forEach(s=>{s.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:s,index:r}=this._locate(e);s<0||this._selectAt(s,r,{focus:!0})}_onDoubleClick(t){let e=t.target.closest(".zx-finder__row");if(!e)return;let{column:s,index:r}=this._locate(e),n=this._columnNodes(s)[r];n&&(L(n,this._readers)?this._enter(s,r):this.emit("activate",{node:n,id:this._readers.value(n)}))}_onKeydown(t){if(t.target.closest(".zx-finder__preview"))return;let e=this._activeColumn,s=this._columnNodes(e);if(s.length===0&&!["ArrowLeft"].includes(t.key))return;let r=Math.max(0,s.findIndex(n=>Object.is(this._readers.value(n),this._columns[e]?.selectedId)));switch(t.key){case"ArrowDown":t.preventDefault(),this._selectAt(e,Math.min(s.length-1,r+1),{focus:!0});return;case"ArrowUp":t.preventDefault(),this._selectAt(e,Math.max(0,r-1),{focus:!0});return;case"Home":t.preventDefault(),this._selectAt(e,0,{focus:!0});return;case"End":t.preventDefault(),this._selectAt(e,s.length-1,{focus:!0});return;case"ArrowRight":{t.preventDefault();let n=s[r];if(!n||!L(n,this._readers))return;this._enter(e,r);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 n=s[r];if(!n)return;L(n,this._readers)?this._enter(e,r):this.emit("activate",{node:n,id:this._readers.value(n)});return}default:this._handleTypeahead(t)}}async _selectAt(t,e,{focus:s=!1}={}){let r=this._columnNodes(t)[e];if(!r)return;let n=this._readers.value(r);if(this._path.length===t+1&&Object.is(this._path[t],n)){this._activeColumn=t,this._syncTabStop(),s&&this.focus();return}this._path=[...this._path.slice(0,t),n],this._activeColumn=t,L(r,this._readers)&&await this._ensureChildren(r),this._render({focus:s}),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 s=this._readers.value(t),r=this._loading.get(s);if(r)return r;let n=(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:s})}finally{this._loading.delete(s)}})();return this._loading.set(s,n),n}_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 s=this.msg(t);return s===t?e:s}destroy(){this._pathSequence+=1;let t=this.el;super.destroy(),!this._createdRoot&&t&&z(t,this._snapshot)}};function ca(i){return String(i??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLocaleLowerCase()}function Ku(i,t){let e=ca(t).trim().split(/\s+/).filter(Boolean);if(e.length===0)return!0;let s=ca(i.flat(1/0).join(" "));return e.every(r=>s.includes(r))}function ir(i){return i!=null&&!(typeof i=="string"&&i.trim()==="")}function ua(i,t){if(typeof t.get=="function")return sr(t.get(i));let e=t.fields??t.field??t.id;return(Array.isArray(e)?e:[e]).flatMap(r=>sr(typeof r=="function"?r(i):r==null?void 0:i?.[r]))}function da(i,t){let e=[],s=new Map;for(let r of i)for(let n of ua(r,t)){let o=pa(n);o.value==null||o.value===""||s.has(o.value)||(s.set(o.value,!0),e.push(o))}return e}function Dt(i,t,e){return i.filter(s=>t.every(r=>{let n=e?.[r.id];if(!ir(n))return!0;if(r.type==="custom")return typeof r.predicate!="function"||!!r.predicate(s,n);let o=ua(s,r);return r.type==="text"?Ku(o,n):r.type==="select"?o.some(l=>Uu(pa(l).value,n)):!0}))}function sr(i){return Array.isArray(i)?i.flat(1/0):[i]}function pa(i){if(i&&typeof i=="object"&&!(i instanceof Date)){if(Object.prototype.hasOwnProperty.call(i,"value"))return{value:i.value,label:String(i.label??i.value??"")};if(Object.prototype.hasOwnProperty.call(i,"field"))return{value:i.field,label:String(i.label??i.field??"")}}return{value:i,label:String(i??"")}}function Uu(i,t){return Object.is(i,t)?!0:i==null||t==null?!1:String(i)===String(t)}var Us=class extends _{static cssName="data-filter";static defaults={filters:[],data:[],autoApply:!0,clearLabel:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??a("div");this._originalChildren=this.el?Array.from(this.el.childNodes):null,this._filters=Array.isArray(this.options.filters)?this.options.filters.map(s=>({...s})):[],this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._state={},this._entries=new Map,this._customOrigins=new Map,this._restored=!1;let e=new Set;for(let s of this._filters){if(rr(s),e.has(s.id))throw new RangeError(`Duplicate filter id: ${s.id}`);e.add(s.id),s.type==="custom"&&!this._customOrigins.has(s.element)&&this._customOrigins.set(s.element,{parent:s.element.parentNode,nextSibling:s.element.nextSibling}),this._state[s.id]=s.type==="custom"?nr(s.element):""}this._filtered=Dt(this._data,this._filters,this._state),this._controls=a("div",{class:"zx-data-filter__controls"}),this._badge=a("span",{class:"zx-data-filter__badge",ariaLive:"polite",hidden:!0},"0"),this._clearButton=a("button",{class:"zx-data-filter__clear",type:"button",hidden:!0},this.options.clearLabel==null?this.msg("dataFilter.clear"):String(this.options.clearLabel)),t.replaceChildren(this._controls,this._badge,this._clearButton),this.listen(this._clearButton,"click",()=>this.clear());for(let s of this._filters)this._appendFilter(s);return this._syncActiveState(),t}setData(t){Gu(t),this._data=[...t];for(let e of this._filters){if(e.type!=="select")continue;let s=this._entries.get(e.id);s&&this._populateSelect(e,s)}return this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=Dt(this._data,this._filters,this._state),this}apply(){this._filtered=Dt(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=Dt(this._data,this._filters,this._state),this}addFilter(t){rr(t);let e={...t};return this._filters.push(e),this._state[e.id]=e.type==="custom"?nr(e.element):"",this._appendFilter(e),this._filtered=Dt(this._data,this._filters,this._state),this._syncActiveState(),this}destroy(){this._restored||(this._originalChildren&&this.el.replaceChildren(...this._originalChildren),Qu(this._customOrigins),this._restored=!0),super.destroy()}_appendFilter(t){if(rr(t),this._entries.has(t.id))throw new RangeError(`Duplicate filter id: ${t.id}`);let e,s={element:null,options:[]};if(t.type==="select")e=a("select",{ariaLabel:t.label}),s.element=e,this._populateSelect(t,s),this.listen(e,"change",()=>{let n=Number(e.value)-1;this._state[t.id]=n>=0?s.options[n]?.value??"":"",this._controlChanged()});else if(t.type==="text")e=a("input",{type:"search",placeholder:t.placeholder??"",ariaLabel:t.label,autocomplete:"off"}),s.element=e,this.listen(e,"input",()=>{this._state[t.id]=e.value,this._controlChanged()});else{e=t.element,this._customOrigins.has(e)||this._customOrigins.set(e,{parent:e.parentNode,nextSibling:e.nextSibling}),s.element=e;let n=e.matches?.('input:not([type="checkbox"]):not([type="radio"]), textarea')?"input":"change";this.listen(e,n,()=>{this._state[t.id]=nr(e),this._controlChanged()})}this._entries.set(t.id,s);let r=a("label",{class:"zx-data-filter__field"},a("span",{class:"zx-data-filter__label"},t.label),e);this._controls.append(r)}_populateSelect(t,e){let s=this._state[t.id];e.options=Array.isArray(t.options)?t.options.map(Yu):da(this._data,t);let r=a("option",{value:""},t.emptyLabel??this.msg("dataFilter.all")),n=document.createDocumentFragment();n.append(r),e.options.forEach((l,h)=>{n.append(a("option",{value:String(h+1)},l.label))}),e.element.replaceChildren(n);let o=e.options.findIndex(l=>fa(l.value,s));e.element.value=o>=0?String(o+1):"",o<0&&(this._state[t.id]="")}_controlChanged(){this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=Dt(this._data,this._filters,this._state)}_syncControls(){for(let t of this._filters){let e=this._entries.get(t.id);if(!e)continue;let s=this._state[t.id];if(t.type==="select"){let r=e.options.findIndex(n=>fa(n.value,s));e.element.value=r>=0?String(r+1):"",r<0&&(this._state[t.id]="")}else Wu(e.element,s)}}_syncActiveState(){let t=this._filters.reduce((e,s)=>e+Number(ir(this._state[s.id])),0);this._badge.textContent=String(t),this._badge.hidden=t===0,this._clearButton.hidden=t===0}};function rr(i){if(!i||typeof i!="object")throw new TypeError("Filter definition must be an object");if(!["select","text","custom"].includes(i.type))throw new TypeError(`Unknown filter type: ${i.type}`);if(typeof i.id!="string"||!i.id)throw new TypeError("Filter definition requires an id");if(i.type==="custom"){if(!i.element||i.element.nodeType!==1)throw new TypeError("Custom filter requires an Element");if(typeof i.predicate!="function")throw new TypeError("Custom filter requires a predicate")}}function Yu(i){return i&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,"value")?{value:i.value,label:String(i.label??i.value??"")}:{value:i,label:String(i??"")}}function nr(i){return"checked"in i&&["checkbox","radio"].includes(i.type)?i.checked:"value"in i?i.value:i.getAttribute("data-value")??""}function Wu(i,t){"checked"in i&&["checkbox","radio"].includes(i.type)?i.checked=!!t:"value"in i?i.value=t==null?"":String(t):t==null||t===""?i.removeAttribute("data-value"):i.setAttribute("data-value",String(t))}function fa(i,t){return Object.is(i,t)?!0:i==null||t==null?!1:String(i)===String(t)}function Gu(i){if(!Array.isArray(i))throw new TypeError("DataFilter data must be an array")}function Qu(i){let t=[...i];for(let e=t.length;t.length>0&&e>=0;e-=1){let s=0;for(let r=t.length-1;r>=0;r-=1){let[n,o]=t[r];if(!o.parent)n.remove();else{if(o.nextSibling&&o.nextSibling.parentNode!==o.parent)continue;o.parent.insertBefore(n,o.nextSibling)}t.splice(r,1),s+=1}if(s===0)break}for(let[e,s]of t)s.parent?s.parent.append(e):e.remove()}var It=class extends _{static cssName="fieldset";static defaults={title:"",columns:1,fields:{}};render(){let t=this.el??a("fieldset");this._fields=new Map,this._ownedFields=new Set,this._origins=new Map,this._fieldIdAttributes=new Map,this._ownedNodes=[],this._columnAttribute=t.getAttribute("data-columns");let e=[1,2,3].includes(Number(this.options.columns))?Number(this.options.columns):1;if(t.dataset.columns=String(e),this.options.title){let r=a("legend",{class:"zx-fieldset__legend"},String(this.options.title));this._ownedNodes.push(r),t.append(r)}this._grid=a("div",{class:"zx-fieldset__grid"}),this._ownedNodes.push(this._grid),t.append(this._grid);let s=this.options.fields&&typeof this.options.fields=="object"?this.options.fields:{};for(let[r,n]of Object.entries(s))this.addField(r,n);return t}addField(t,e){let s=String(t);if(this._fields.has(s))throw new Error(`Field "${s}" already exists`);let r,n=!1;if(e instanceof S)r=e;else if(D(e)||e instanceof _){let o=e;r=new S(null,{id:s,type:"custom",label:s,value:Xu(o),disabled:Zu(o),adapter:()=>Ju(o)}),n=!0}else{let o=e&&typeof e=="object"?e:{};r=new S(null,{...o,id:o.id??s}),n=!0}return n?this._ownedFields.add(r):this._origins.set(r,{parent:r.el.parentNode,next:r.el.nextSibling}),this._fields.set(s,r),this._fieldIdAttributes.set(r,r.el.getAttribute("data-field-id")),r.el.dataset.fieldId=s,this._grid.append(r.el),r}getField(t){return this._fields.get(String(t))??null}hasField(t){return this._fields.has(String(t))}getFields(){return Object.fromEntries(this._fields)}getValues(){let t={};for(let[e,s]of this._fields)t[e]=s.getValue();return t}setValues(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[s,r]of Object.entries(t))this._fields.get(s)?.setValue(r,{silent:e});return this}getValue(t){return this._fields.get(String(t))?.getValue()??null}setValue(t,e){return this._fields.get(String(t))?.setValue(e),this}reset(){for(let t of this._fields.values())t.reset();return this}clear(){for(let t of[...this._fields.values()])this._releaseField(t);return this._fields.clear(),this}focus(t){return this._fields.get(String(t))?.focus(),this}setHighlights(t={},e="danger"){let s=0;for(let[r,n]of this._fields){let o=t?.[r];o?(n.setHighlight(String(o),e),s+=1):n.clearHighlight()}return s}clearHighlights(){for(let t of this._fields.values())t.clearHighlight();return this}_releaseField(t){let e=this._fieldIdAttributes.get(t);if(e==null?t.el.removeAttribute("data-field-id"):t.el.setAttribute("data-field-id",e),this._fieldIdAttributes.delete(t),this._ownedFields.has(t)){t.destroy(),this._ownedFields.delete(t);return}let s=this._origins.get(t);s?.parent?s.parent.insertBefore(t.el,s.next?.parentNode===s.parent?s.next:null):t.el.remove(),this._origins.delete(t)}destroy(){this.clear();for(let t of this._ownedNodes??[])t.remove();this._columnAttribute===null?this.el.removeAttribute("data-columns"):this.el.setAttribute("data-columns",this._columnAttribute),super.destroy()}};function Ju(i){let t=D(i)?i:i.toElement(),e=t.parentNode,s=t.nextSibling,r=new Map(["id","aria-labelledby","aria-describedby","aria-disabled","aria-invalid"].map(l=>[l,t.getAttribute(l)])),n="disabled"in t?t.disabled:void 0,o="value"in t?t.value:void 0;return{el:t,get:()=>typeof i.getValue=="function"?i.getValue():typeof i.getValues=="function"?i.getValues():"value"in t?t.value:null,set:(l,h)=>{typeof i.setValue=="function"?i.setValue(l,h):typeof i.setValues=="function"&&l&&typeof l=="object"?i.setValues(l,h):"value"in t&&(t.value=l??"")},focus:()=>{typeof i.focus=="function"?i.focus():typeof t.focus=="function"&&t.focus()},setDisabled:l=>{typeof i.setDisabled=="function"?i.setDisabled(l):"disabled"in t?t.disabled=l:t.setAttribute("aria-disabled",String(l))},destroy:()=>{for(let[l,h]of r)h===null?t.removeAttribute(l):t.setAttribute(l,h);n!==void 0&&(t.disabled=n),o!==void 0&&(t.value=o),e?e.insertBefore(t,s?.parentNode===e?s:null):t.remove()}}}function Xu(i){let t=D(i)?i:i.toElement();return typeof i.getValue=="function"?i.getValue():typeof i.getValues=="function"?i.getValues():"value"in t?t.value:null}function Zu(i){let t=D(i)?i:i.toElement();return"disabled"in t?!!t.disabled:t.getAttribute("aria-disabled")==="true"}var Ys=class extends _{static cssName="form";static defaults={fieldsets:[],actions:[],novalidate:!0,msg:{"form.required":"This field is required.","form.int":"Enter a whole number.","form.float":"Enter a valid number."}};render(){let t=this.el??a("form");this._fieldsets=[],this._ownedFieldsets=new Set,this._origins=new Map,this._ownedNodes=[],this._novalidateAttribute=t.getAttribute("novalidate"),t.toggleAttribute("novalidate",!!this.options.novalidate),this._body=a("div",{class:"zx-form__body"}),this._actions=a("div",{class:"zx-form__actions"}),this._ownedNodes.push(this._body,this._actions),t.append(this._body,this._actions),this.listen(t,"submit",s=>{s.preventDefault(),this.submit()}),this.listen(t,"reset",s=>{s.preventDefault(),this.reset()}),this.listen(this._actions,"click",s=>this._handleAction(s));let e=Array.isArray(this.options.fieldsets)?this.options.fieldsets:[];for(let s of e)this.addFieldset(s);return this.setActions(Array.isArray(this.options.actions)?this.options.actions:[]),t}addFieldset(t){let e=!(t instanceof It),s=e?new It(null,t??{}):t;return this._fieldsets.includes(s)||(e?this._ownedFieldsets.add(s):this._origins.set(s,{parent:s.el.parentNode,next:s.el.nextSibling}),this._fieldsets.push(s),this._body.append(s.el),this.listen(s.el,"zx-change",r=>{let n=r.target,o=n instanceof Element?n.dataset.fieldId:null;o&&this.emit("change",{id:o,value:s.getValue(o)})})),s}setActions(t){return this._actionDescriptors=Array.isArray(t)?t.map(e=>({...e})):[],this._actions.replaceChildren(...this._actionDescriptors.map((e,s)=>{let r=String(e.label??e.id??"Action");return a("button",{class:"zx-btn",type:["submit","reset"].includes(e.type)?e.type:"button",disabled:!!e.disabled,title:e.title,ariaLabel:!r&&e.title?e.title:void 0,dataset:{actionIndex:s,kind:["primary","danger","ghost"].includes(e.kind)?e.kind:"default",size:e.size==="sm"?"sm":"md"}},e.icon?m(e.icon,{size:16}):null,r?a("span",{class:"zx-btn__label"},r):null)})),this._actions.hidden=this._actionDescriptors.length===0,this}getValues(){return Object.assign({},...this._fieldsets.map(t=>t.getValues()))}setValues(t,{silent:e=!1}={}){for(let s of this._fieldsets)s.setValues(t,{silent:e});return this}getField(t){for(let e of this._fieldsets){let s=e.getField(t);if(s)return s}return null}setValue(t,e){return this.getField(t)?.setValue(e),this}getValue(t){return this.getField(t)?.getValue()??null}reset(){for(let t of this._fieldsets)t.reset().clearHighlights();return this}setHighlights(t,e="danger"){return this._fieldsets.reduce((s,r)=>s+r.setHighlights(t,e),0)}clearHighlights(){for(let t of this._fieldsets)t.clearHighlights();return this}submit(){let t={},e=null;for(let r of this._fieldsets)for(let[n,o]of Object.entries(r.getFields())){let l=o.getValue(),h="";if(o.options.required&&or(l))h=this.msg("form.required");else if(!or(l)&&o.options.type==="int"){let c=ii(l);c.valid?o.setValue(c.value,{silent:!0}):h=this.msg("form.int")}else if(!or(l)&&o.options.type==="float"){let c=ri(l);c.valid?o.setValue(c.value,{silent:!0}):h=this.msg("form.float")}h?(t[n]=h,o.setHighlight(h,"danger"),e??=o):o.clearHighlight()}return Object.keys(t).length?(this.emit("invalid",{errors:t}),e?.focus(),!1):!this.emit("submit",{values:this.getValues()}).defaultPrevented}_handleAction(t){let e=t.target instanceof Element?t.target.closest("[data-action-index]"):null;if(!e||!this._actions.contains(e))return;let s=this._actionDescriptors[Number(e.dataset.actionIndex)],r=s?.onClick??s?.onclick??s?.handler;typeof r=="function"&&r(t,this)}destroy(){for(let t of this._fieldsets??[])if(this._ownedFieldsets.has(t))t.destroy();else{let e=this._origins.get(t);e?.parent?e.parent.insertBefore(t.el,e.next?.parentNode===e.parent?e.next:null):t.el.remove()}this._fieldsets=[];for(let t of this._ownedNodes??[])t.remove();this._novalidateAttribute===null?this.el.removeAttribute("novalidate"):this.el.setAttribute("novalidate",this._novalidateAttribute),super.destroy()}};function or(i){return i==null||i===""||i===!1||Array.isArray(i)&&i.length===0}var Ws="123456789abcdefghijklmnopqrstuvwxyz";function _a(i){if(!Array.isArray(i))throw new TypeError("Questionnaire items must be an array");let t=new Set;return i.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 s=e.name;if(t.has(s))throw new TypeError(`Item already exists: ${s}`);t.add(s);let r=td(e.choices??[],s),n=e.field&&typeof e.field=="object"?{...e.field}:null,o=sd(e.input);if(r.length===0&&!n&&!o)throw new TypeError(`Item "${s}" needs choices, an input, or a field`);return{name:s,prompt:String(e.prompt??s),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:r,input:o,field:n,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 td(i,t=""){if(!Array.isArray(i))throw new TypeError("Questionnaire choices must be an array");let e=new Set,s=i.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 l=typeof o.value=="number"?o.value:String(o.value),h=String(l);if(e.has(h))throw new TypeError(`Choice already exists in "${t}": ${h}`);return e.add(h),{value:l,label:String(o.label??l),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}}),r=new Set(s.map(o=>o.key).filter(Boolean)),n=0;for(let o of s)if(!o.key){for(;n<Ws.length&&r.has(Ws[n]);)n+=1;if(n>=Ws.length)break;o.key=Ws[n],r.add(o.key),n+=1}return s}function ed(i,t){if(typeof i.when!="function")return!0;try{return i.when(t)!==!1}catch{return!0}}function dt(i,t){let e={},s=[];for(let r of i)ed(r,e)&&(s.push(r),Object.prototype.hasOwnProperty.call(t,r.name)&&(e[r.name]=t[r.name]));return{answers:e,visible:s}}function Gs(i,t,e){let{answers:s,visible:r}=dt(i,e),n=new Set(r.map(h=>h.name)),o=null;if(typeof t.next=="string")o=t.next;else if(typeof t.next=="function"){let h=t.next(s[t.name],s);o=h==null||h===""?null:String(h)}let l=i.indexOf(t);if(o!==null){let h=i.findIndex(c=>c.name===o);if(h<0)throw new RangeError(`Unknown questionnaire item: ${o}`);if(n.has(o))return o;l=h}for(let h=l+1;h<i.length;h+=1)if(n.has(i[h].name))return i[h].name;return null}function Nt(i){return i==null?!0:typeof i=="string"?i.trim()==="":Array.isArray(i)?i.every(t=>Nt(t)):!1}function ma(i,t,e){return!i.required||!Nt(t)?null:e(i.choices.length>0?"questionnaire.required":"questionnaire.requiredInput")}function ga(i,t,e=null){let s=new Set(t.map(n=>String(n))),r=new Set(i.filter(n=>n.exclusive).map(n=>String(n.value)));return r.size>0&&e!==null&&s.has(String(e))&&(r.has(String(e))?s.forEach(n=>n!==String(e)&&s.delete(n)):r.forEach(n=>s.delete(n))),i.filter(n=>s.has(String(n.value))).map(n=>n.value)}function ba(i,t,e){let{answers:s,visible:r}=dt(i,t),n=new Map(r.map(p=>[p.name,p])),o=e.filter(p=>n.has(p)),l=o.length>0?n.get(o[o.length-1]):null,h=o.filter(p=>!Nt(s[p])).length,c=new Set(o),u=l?r.indexOf(l):-1,d=r.slice(u+1).filter(p=>!c.has(p.name)).length,f=o.length+d;return{index:Math.max(0,o.length-1),answered:h,total:f,percent:f===0?0:Math.round(h/f*100),section:l?.section??""}}function sd(i){if(!i)return null;let t=typeof i=="object"&&!Array.isArray(i)?i:{};return{label:String(t.label??"Other"),placeholder:String(t.placeholder??""),multiline:!!t.multiline,maxLength:Math.max(0,Number(t.maxLength)||0)}}var id=260,Qs=class extends _{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=y("zx-questionnaire");let t=this.el??a("form");if(this.el=t,this._form=t.localName==="form"?t:a("form",{class:"zx-questionnaire__form"}),this._form.setAttribute("novalidate",""),this._progressHost=a("div",{class:"zx-questionnaire__progress",hidden:!this.options.progress}),this._itemHost=a("fieldset",{class:"zx-questionnaire__item",tabIndex:-1}),this._reviewHost=a("div",{class:"zx-questionnaire__review",tabIndex:-1,hidden:!0}),this._actionsHost=a("div",{class:"zx-questionnaire__actions"}),this.refs.item=this._itemHost,this.refs.review=this._reviewHost,this.refs.actions=this._actionsHost,this._bar=new ie(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,a("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);dt(this._items,this._rawAnswers()).visible.some(r=>r.name===e)&&(this._path=[e])}return this._paint(),t}setItems(t){let e=this.getActive(),s=_a(t),r=new Set(s.map(l=>l.name));this._items=s;for(let l of[this._selected,this._freeform])for(let h of[...l.keys()])r.has(h)||l.delete(h);for(let[l,h]of[...this._fields])r.has(l)||(h.destroy(),this._fields.delete(l));let n=dt(s,this._rawAnswers()).visible,o=this._path.filter(l=>n.some(h=>h.name===l));return e&&o[o.length-1]===e?this._path=o:this._path=n.length>0?[n[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(n=>n.name===t);if(!e)throw new RangeError(`Unknown questionnaire item: ${t}`);if(!dt(this._items,this._rawAnswers()).visible.includes(e))return!1;let r=this._returnToReview;return this._returnToReview=r||this._status==="review",this._navigate(t,"goto")?!0:(this._returnToReview=r,!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?Gs(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 r=this._path[this._path.length-1];return!r||this.emit("navigate",{from:null,to:r,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=Gs(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 dt(this._items,this._rawAnswers()).answers}getAnswer(t){let e=this._items.find(s=>s.name===t);return e?this._answerOf(e):null}setAnswers(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[s,r]of Object.entries(t))this._items.some(n=>n.name===s)&&this.setAnswer(s,r,{silent:!0});if(this._paint(),!e){let s=this.getAnswers();for(let r of Object.keys(t))r in s&&this.emit("change",{name:r,value:s[r],answers:s})}return this}setAnswer(t,e,{silent:s=!1}={}){let r=this._items.find(n=>n.name===t);if(!r)throw new RangeError(`Unknown questionnaire item: ${t}`);if(r.field)this._field(r).setValue(e===void 0?null:e,{silent:!0});else{let n=Array.isArray(e)?e:e==null||e===""?[]:[e],o=new Set(n.map(h=>String(h))),l=r.choices.filter(h=>o.has(String(h.value)));for(let h of l)o.delete(String(h.value));this._selected.set(t,l.map(h=>h.value)),this._freeform.set(t,r.input?[...o][0]??"":"")}return this._paint(),s||this._emitChange(r),this}getActive(){return this._status!=="asking"?null:this._path[this._path.length-1]??null}getPath(){return[...this._path]}getProgress(){return ba(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,s]of Object.entries(this.getAnswers()))if(Array.isArray(s))for(let r of s)t.append(e,String(r));else s instanceof File||s instanceof Blob?t.append(e,s):t.append(e,s==null?"":String(s));return t}reset(){this._selected.clear(),this._freeform.clear();for(let[e,s]of this._fields){let r=this._items.find(n=>n.name===e);s.setValue(r?.field?.value??null,{silent:!0})}let t=dt(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||z(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 s=this._answerOf(e);Nt(s)||(t[e.name]=s)}return t}_answerOf(t){if(t.field)return this._fields.get(t.name)?.getValue()??null;let e=this._selected.get(t.name)??[],s=(this._freeform.get(t.name)??"").trim();return t.multiple?s?[...e,s]:[...e]:s||(e.length>0?e[0]:null)}_field(t){let e=this._fields.get(t.name);if(e)return e;let s=t.field??{};return e=new S(null,{...s,label:s.label??t.prompt,required:t.required}),e.el.classList.add("zx-questionnaire__field"),s.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 s=this.getActive();if(s===t&&this._status==="asking"||this.emit("navigate",{from:s,to:t,reason:e}).defaultPrevented)return!1;let r=this._path.indexOf(t);return r>=0?this._path=this._path.slice(0,r+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),s=ma(t,e,r=>this.msg(r));if(!s&&typeof t.validate=="function"){this._setBusy(!0);try{s=await t.validate(e,this.getAnswers())}catch(r){s=r instanceof Error?r.message:String(r)}finally{this._destroyed||this._setBusy(!1)}}return this._destroyed?!1:(this._error=s?String(s):"",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(a("p",{class:"zx-questionnaire__prompt"},this.msg("questionnaire.empty")));return}let e=`${this._uid}-prompt`,s=`${this._uid}-description`,r=`${this._uid}-error`,n=[a("legend",{class:"zx-questionnaire__prompt",id:e},t.prompt)];t.description&&n.push(a("p",{class:"zx-questionnaire__description",id:s},t.description)),n.push(t.field?this._field(t).el:this._choices(t)),n.push(a("p",{class:"zx-questionnaire__error",id:r,role:"alert",hidden:!0})),this._itemHost.replaceChildren(...n),this._itemHost.dataset.item=t.name,this._itemHost.setAttribute("aria-describedby",[t.description?s:"",r].filter(Boolean).join(" ")),this._paintError(t)}_choices(t){let e=new Set((this._selected.get(t.name)??[]).map(r=>String(r))),s=a("div",{class:"zx-questionnaire__choices"});if(s.append(...t.choices.map((r,n)=>a("label",{class:"zx-questionnaire__choice",dataset:{disabled:r.disabled?"true":null}},a("input",{type:t.multiple?"checkbox":"radio",class:"zx-questionnaire__control",name:t.name,value:String(r.value),checked:e.has(String(r.value)),disabled:r.disabled,dataset:{index:n}}),a("span",{class:"zx-questionnaire__marker",ariaHidden:"true"}),r.icon?m(r.icon,{size:16}):null,a("span",{class:"zx-questionnaire__text"},a("span",{class:"zx-questionnaire__label"},r.label),r.description?a("span",{class:"zx-questionnaire__hint"},r.description):null),r.key?a("kbd",{class:"zx-questionnaire__key",ariaHidden:"true"},r.key):null))),t.input){let r=`${this._uid}-freeform`,n=this._freeform.get(t.name)??"",o=a(t.input.multiline?"textarea":"input",{type:t.input.multiline?void 0:"text",class:"zx-questionnaire__freeform-input",id:r,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:n});s.append(a("div",{class:"zx-questionnaire__freeform"},a("label",{class:"zx-questionnaire__freeform-label",htmlFor:r},t.input.label),o))}return s}_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 s=t?.field?this._fields.get(t.name):null;s&&(this._error?s.setHighlight(this._error,"danger"):s.clearHighlight(),e instanceof HTMLElement&&(e.hidden=!0))}_paintReview(){let{answers:t,visible:e}=dt(this._items,this._rawAnswers()),s=this._path.map(r=>e.find(n=>n.name===r)).filter(r=>!!r).map(r=>a("div",{class:"zx-questionnaire__answer"},a("dt",{class:"zx-questionnaire__answer-prompt"},r.prompt),a("dd",{class:"zx-questionnaire__answer-value",dataset:{empty:Nt(t[r.name])?"true":null}},this._formatAnswer(r,t[r.name])),q({label:this.msg("questionnaire.edit"),kind:"ghost",size:"sm"})));for(let[r,n]of s.entries()){let o=n.querySelector("button");o instanceof HTMLElement&&(o.dataset.edit=this._path[r])}this._reviewHost.replaceChildren(a("p",{class:"zx-questionnaire__review-title"},this.msg("questionnaire.reviewTitle")),a("dl",{class:"zx-questionnaire__answers"},...s))}_formatAnswer(t,e){if(Nt(e))return this.msg("questionnaire.noAnswer");let s=new Map(t.choices.map(n=>[String(n.value),n.label]));return(Array.isArray(e)?e:[e]).map(n=>s.get(String(n))??String(n)).join(", ")}_paintActions(){let t=this._activeItem(),e=this._status==="review",s=this._status==="complete",r=!1;try{r=!!t&&Gs(this._items,t,this._rawAnswers())!==null}catch{r=!1}this._back.hidden=s||!e&&(!this.options.allowBack||this._path.length<=1),this._back.disabled=this._busy,this._skip.hidden=e||s||!t?.skippable,this._skip.disabled=this._busy,this._forward.hidden=s,this._forward.disabled=this._busy||!t&&!e;let n=e?"submit":this._returnToReview||!r&&this.options.review?"review":r?"next":"submit";if(this._forward.dataset.role!==n){this._forward.dataset.role=n;let o=n==="next"?"chevron-right":n==="review"?"list":"check";this._forward.replaceChildren(m(o,{size:16}),a("span",{class:"zx-btn__label"},this.msg(`questionnaire.${n}`)))}}_action(t,e,s,r){let n=q({label:e,icon:s,kind:r});return n.dataset.action=t,n}_onControlChange(t){let e=t.target;if(!(e instanceof HTMLInputElement)||!e.classList.contains("zx-questionnaire__control"))return;let s=this._activeItem();if(!s)return;let r=s.choices[Number(e.dataset.index)];if(r){if(s.multiple){let n=[...this._itemHost.querySelectorAll(".zx-questionnaire__control")].filter(h=>h.checked).map(h=>s.choices[Number(h.dataset.index)].value),o=ga(s.choices,n,e.checked?r.value:null);this._selected.set(s.name,o);let l=new Set(o.map(h=>String(h)));for(let h of this._itemHost.querySelectorAll(".zx-questionnaire__control"))h.checked=l.has(h.value)}else{this._selected.set(s.name,[r.value]),this._freeform.set(s.name,"");let n=this._itemHost.querySelector(".zx-questionnaire__freeform-input");(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&(n.value="")}this._error="",this._paintError(s),this._paintProgress(),this._paintActions(),this._emitChange(s),this._maybeAutoAdvance(s)}}_onFreeformInput(t){let e=t.target;if(!((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.classList.contains("zx-questionnaire__freeform-input")))return;let r=this._activeItem();if(r){if(this._freeform.set(r.name,e.value),!r.multiple&&e.value.trim()!==""){this._selected.set(r.name,[]);for(let n of this._itemHost.querySelectorAll(".zx-questionnaire__control"))n.checked=!1}this._error="",this._paintError(r),this._paintProgress(),this._paintActions(),this._emitChange(r)}}_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,s=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||s||t.key.length!==1)return;let r=this._activeItem();if(!r||this._status!=="asking")return;let n=t.key.toLowerCase(),o=r.choices.findIndex(h=>h.key===n&&!h.disabled);if(o<0)return;let l=this._itemHost.querySelector(`.zx-questionnaire__control[data-index="${o}"]`);l instanceof HTMLInputElement&&(t.preventDefault(),l.checked=r.multiple?!l.checked:!0,l.focus(),l.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()},id))}_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 s=this._itemHost.querySelector(".zx-questionnaire__control:not(:disabled), .zx-questionnaire__freeform-input");s instanceof HTMLElement?s.focus():this._focusItem()}};function ya(){Dn(),Hr(),bn(),on(),_n(),Ln(),Bn(),An(),xn(),Rn(),zn(),Cn(),Mn(),In()}ya();return ka(rd);})();
1
+ var zx=(()=>{var Ii=Object.defineProperty;var xl=Object.getOwnPropertyDescriptor;var vl=Object.getOwnPropertyNames;var wl=Object.prototype.hasOwnProperty;var Al=(i,t)=>{for(var e in t)Ii(i,e,{get:t[e],enumerable:!0})},Sl=(i,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of vl(t))!wl.call(i,n)&&n!==e&&Ii(i,n,{get:()=>t[n],enumerable:!(s=xl(t,n))||s.enumerable});return i};var kl=i=>Sl(Ii({},"__esModule",{value:!0}),i);var wp={};Al(wp,{AccountMenu:()=>Js,AppIcon:()=>Be,AppSidebar:()=>ei,Avatar:()=>ge,Breadcrumb:()=>js,Card:()=>Ds,Chart:()=>ci,ChartJsAdapter:()=>hi,CheckButton:()=>pt,Checklist:()=>et,Component:()=>_,ContextMenu:()=>ai,CopyInput:()=>Ts,DataFilter:()=>_i,DatePicker:()=>xt,DateRangeBox:()=>Zt,DateRangePicker:()=>Xt,DateTimeBox:()=>cs,Datebox:()=>K,Dialog:()=>ft,Dock:()=>qs,Dropdown:()=>J,Field:()=>A,FieldUpload:()=>te,Fieldset:()=>Pt,Filter:()=>Ai,Finder:()=>fi,Form:()=>Si,Grid:()=>li,Groupbox:()=>St,Http:()=>Me,InlineLoading:()=>ks,Launcher:()=>Gs,MasterPanel:()=>Ms,MenuButton:()=>X,Message:()=>ii,Modal:()=>le,MonthPicker:()=>Gt,MultiValueEditor:()=>ee,NavigationBar:()=>Bs,NumberField:()=>wt,Pagination:()=>Us,Panel:()=>Ns,ProgressBar:()=>fe,Questionnaire:()=>Ci,Rating:()=>se,Search:()=>ce,Select:()=>V,Sheet:()=>ni,SheetStack:()=>ri,Slider:()=>ie,SplitView:()=>Rs,Stepper:()=>Vs,Tabbox:()=>he,Table:()=>kt,TagPicker:()=>ne,TimePicker:()=>Wt,Timebox:()=>ht,Toggle:()=>W,Toolbar:()=>Is,Tooltip:()=>zt,TreeView:()=>pi,ValueList:()=>re,__:()=>sr,addDays:()=>E,addMonths:()=>ut,appIcon:()=>Ia,appendCompact:()=>nr,appendCompactChild:()=>rr,appendContent:()=>ir,applyCompactProperties:()=>Mi,aspect:()=>da,avatarInitials:()=>zn,badge:()=>ia,badgeGroup:()=>na,billingColumns:()=>Mn,breakpointOf:()=>ds,breakpoints:()=>Mt,button:()=>P,buttonGroup:()=>sa,chartSummaryTable:()=>Fn,clamp:()=>F,clampDate:()=>Je,clampRange:()=>Jt,clampSize:()=>mt,cloneChartValue:()=>ot,cloneFilterAst:()=>Ue,compactElement:()=>Se,configureIcons:()=>Te,copyButton:()=>Cs,copyToClipboard:()=>bs,debounce:()=>Qn,deepMerge:()=>Vt,defaultDateRangePresets:()=>Ji,defineElements:()=>Zo,describe:()=>Ba,downloadBlob:()=>Vo,emptyFilterAst:()=>bi,emptyState:()=>ra,escapeRegExp:()=>$t,faFamilies:()=>Hi,faIconClasses:()=>ze,faNames:()=>Vi,faStyles:()=>Xe,filterCondition:()=>yi,filterGroup:()=>xi,filterOperators:()=>Ke,fireCompactEvent:()=>dr,focusTrap:()=>hs,formatCurrency:()=>_s,formatDate:()=>z,formatFileSize:()=>Lo,formatNumber:()=>At,formatPercent:()=>ms,formatRangeText:()=>Zi,formatRelativeTime:()=>Ro,fragment:()=>or,getIconConfig:()=>ss,getLanguage:()=>G,getWeekStart:()=>Ut,grid:()=>ua,groupBy:()=>Xn,h:()=>a,highlightMatch:()=>lr,htmlEscape:()=>ar,icon:()=>g,iconNames:()=>Rr,icons:()=>es,isBillingLine:()=>He,isElement:()=>D,isEmptyChartData:()=>ui,isSameDay:()=>q,isTruncated:()=>gn,joinTime:()=>rn,kitUrl:()=>Ce,loadFontAwesome:()=>Fr,loadFontAwesomeKit:()=>ts,matchBreakpoint:()=>ps,normalizeAppItems:()=>Ct,normalizeRange:()=>Dt,offCompactEvent:()=>ur,onBreakpoint:()=>oe,onCompactEvent:()=>Oi,paginationRange:()=>Sn,parseCompactTag:()=>Ni,parseDate:()=>$,parseFilterAst:()=>qt,parseIconSpec:()=>Ze,parseNumber:()=>Ee,parseRangeText:()=>ls,parseResult:()=>fs,position:()=>U,printf:()=>R,rangeNights:()=>Qt,rangeStateOf:()=>Qi,rankLauncherItems:()=>Qs,registerFieldAdapters:()=>yl,registerIcons:()=>Lr,reorderTableRows:()=>dn,resolveElement:()=>H,resolveSize:()=>Z,rovingTabindex:()=>ct,setLanguage:()=>mr,setTranslator:()=>_r,skeleton:()=>zs,skeletonTable:()=>ca,skeletonText:()=>la,snapNumber:()=>Ie,snapSize:()=>yn,sortBy:()=>Zn,spinner:()=>Ss,splitTime:()=>nn,stack:()=>ha,stepPrecision:()=>sn,storage:()=>ae,stringifyFilterAst:()=>ll,throttle:()=>Jn,toArray:()=>ve,toCsv:()=>Ho,tooltip:()=>qa,translate:()=>tt,truncate:()=>_a,typeahead:()=>Q,uid:()=>y,uniqueBy:()=>tr,useBuiltinIcons:()=>Or,useFontAwesome:()=>Ki,validateFilterAst:()=>vi,zeyosService:()=>Eo});function Qn(i,t){let e=null;return function(...n){let r=this;e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,i.apply(r,n)},t)}}function Jn(i,t,{leading:e=!0,trailing:s=!0}={}){let n=Math.max(0,Number(t)||0),r=null,o=0,l=null,c=null,h=()=>{r=null,o=e?Date.now():0;let u=l,d=c;l=null,c=null,u!==null&&i.apply(d,u)};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,l=null,c=null,i.apply(this,d);return}s&&(l=d,c=this,r===null&&(r=setTimeout(h,p)))}}var Yn=0;function y(i="zx"){return Yn+=1,`${i}-${Date.now().toString(36)}-${Yn.toString(36)}`}function Vt(i,t){let e=xe(i)?er(i):{};if(!xe(t))return We(t);for(let[s,n]of Object.entries(t))xe(n)&&xe(e[s])?e[s]=Vt(e[s],n):e[s]=We(n);return e}function D(i){return!!(i&&typeof i=="object"&&i.nodeType===1)}function jt(i){if(typeof i!="string")return!1;let t=i.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 F(i,t,e){return Math.min(e,Math.max(t,i))}function ve(i){if(i==null)return[];if(Array.isArray(i))return i.slice();let t=i;return typeof i!="string"&&typeof t?.[Symbol.iterator]=="function"||typeof i!="string"&&typeof t?.length=="number"?Array.from(t):[i]}function Xn(i,t){let e=Ye(t),s=new Map;for(let n of ve(i)){let r=String(e(n)),o=s.get(r);o===void 0?s.set(r,[n]):o.push(n)}return Object.fromEntries(s)}function Zn(i,...t){let e=ve(i),s=t.map(zl);return s.length===0?e:e.sort((n,r)=>{for(let o of s){let l=o(n,r);if(l!==0)return l}return 0})}function tr(i,t){let e=t==null?r=>r:Ye(t),s=new Set,n=[];for(let r of ve(i)){let o=e(r);s.has(o)||(s.add(o),n.push(r))}return n}function $t(i){return String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ye(i){if(typeof i=="function")return i;let t=String(i);return e=>e?.[t]}function zl(i){let t,e=1;if(typeof i=="function")t=i;else if(i!==null&&typeof i=="object")t=Ye(i.key),String(i.dir).toLowerCase()==="desc"&&(e=-1);else{let s=String(i);s.startsWith("-")?(e=-1,s=s.slice(1)):s.startsWith("+")&&(s=s.slice(1)),t=Ye(s)}return(s,n)=>{let r=t(s),o=t(n),l=Wn(r),c=Wn(o);return l||c?l&&c?0:l?1:-1:e*Cl(r,o)}}function Wn(i){return i==null||typeof i=="number"&&Number.isNaN(i)}function Cl(i,t){return i instanceof Date||t instanceof Date?Di(Gn(i)-Gn(t)):typeof i=="boolean"||typeof t=="boolean"?Di(Number(i)-Number(t)):typeof i=="number"&&typeof t=="number"?Di(i-t):String(i).localeCompare(String(t),void 0,{numeric:!0})}function Gn(i){if(i instanceof Date)return i.getTime();let t=Number(i);return Number.isFinite(t)?t:0}function Di(i){return Number.isNaN(i)?0:i<0?-1:i>0?1:0}function xe(i){if(i===null||typeof i!="object")return!1;let t=Object.getPrototypeOf(i);return t===Object.prototype||t===null}function er(i){let t={};for(let[e,s]of Object.entries(i))t[e]=We(s);return t}function We(i){return xe(i)?er(i):Array.isArray(i)?i.map(We):i}var we=null,Tl=new Set(["href","id","lang","name","rel","src","target","title","value"]),Ae=new WeakMap;function Ni(i){if(typeof i!="string")throw new TypeError("DOM builder tag must be a string");let t=i,e="",s="",n=t.indexOf(".");return n!==-1&&(e=t.slice(n+1),t=t.slice(0,n)),n=t.indexOf("#"),n!==-1&&(s=t.slice(n+1),t=t.slice(0,n)),{tag:t||"div",id:s,className:e}}function Se(i,t=null,e=null){let s=Ni(i),n=document.createElement(s.tag);if(s.id&&(n.id=s.id),s.className&&(n.className=s.className),s.tag==="a"){let r=n;r.rel="noopener",r.tabIndex=-1}else if(s.tag==="button")n.type="button";else if(s.tag==="input"||s.tag==="textarea"){let r=n;r.autocapitalize="none",r.autocomplete="off",r.autocorrect="off",r.spellcheck=!1}return t&&Mi(n,t),Nl(n,e),n}var sr=Se;function bt(i){if(typeof i!="string")return null;let t=i.trim();if(!t)return null;try{let e=new URL(t,globalThis.location?.href??"https://zx.invalid/").protocol;if(["javascript:","data:","vbscript:"].includes(e.toLowerCase()))return null}catch{return null}return t}function Mi(i,t){for(let e in t??{}){let s=t[e];if(s!=null)if(e[0]==="D")i.setAttribute(`data-${e.slice(1)}`,String(s));else if(e[0]==="S")i.style[e.slice(1)]=s;else if(e.startsWith("on")){if(typeof s!="function")throw new TypeError(`Compact DOM event ${e} must be a function`);Oi(i,e.slice(2),s)}else typeof s=="boolean"||Tl.has(e)?i[e]=s:i.setAttribute(e,String(s))}return i}function ir(i,t){if(t==null)return i;let e=hr(t);return e==null||(typeof e=="object"?i.appendChild(e):i.appendChild(document.createTextNode(String(e)))),i}function nr(i,t,e=null,s=null){return i.appendChild(Se(t,e,s)),i}function rr(i,t,e=null,s=null){let n=Se(t,e,s);return i.appendChild(n),n}function or(...i){let t=document.createDocumentFragment();return cr(t,i),t}function a(i,t,...e){let s=document.createElement(i),n=t;El(n)||(e.unshift(n),n={});for(let[r,o]of Object.entries(n))Il(s,r,o);return cr(s,e),s}a.scope=function(t,e){let s=we;we=t;try{return e()}finally{we=s}};a.raw=function(t){let e=document.createElement("template");return e.innerHTML=String(t),e.content};function k(i){return{children:Array.from(i.childNodes),attributes:Array.from(i.attributes,t=>[t.name,t.value])}}function S(i,t){if(t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}}function ar(i){return String(i).replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function lr(i,t,e={}){let{className:s="zx-mark"}=e,n=i==null?"":String(i),r=t==null?"":String(t).trim(),o=document.createDocumentFragment();if(r===""||n==="")return o.append(document.createTextNode(n)),o;let l=new RegExp($t(r),"gi"),c=0;for(let h of n.matchAll(l)){h.index>c&&o.append(document.createTextNode(n.slice(c,h.index)));let u=document.createElement("mark");s&&(u.className=String(s)),u.append(document.createTextNode(h[0])),o.append(u),c=h.index+h[0].length}return c<n.length&&o.append(document.createTextNode(n.slice(c))),o}function H(i){if(i==null)return null;if(D(i))return i;if(typeof i=="string")return document.querySelector(i);if(typeof i.toElement=="function"){let t=i.toElement();return D(t)?t:null}return null}function El(i){if(i===null||typeof i!="object"||Array.isArray(i))return!1;let t=i;return typeof t.nodeType=="number"?!1:typeof t.toElement!="function"}function Il(i,t,e){if(t==="ref"){we&&typeof e=="string"&&(we[e]=i);return}if(t==="class"){i.className=Array.isArray(e)?e.flat(1/0).filter(Boolean).join(" "):String(e??"");return}if(t==="style"){if(typeof e=="string")i.style.cssText=e;else if(e&&typeof e=="object")for(let[n,r]of Object.entries(e))n.startsWith("--")||n.includes("-")?i.style.setProperty(n,String(r)):i.style[n]=r;return}if(t==="dataset"&&e&&typeof e=="object"){for(let[n,r]of Object.entries(e))r==null?delete i.dataset[n]:i.dataset[n]=String(r);return}if(/^on[a-z]/.test(t)&&typeof e=="function"){i.addEventListener(t.slice(2),e);return}if(e==null)return;let s=Dl(t);if(s!==null)i.setAttribute(s,String(e));else if(t in i)try{i[t]=e}catch{i.setAttribute(t,String(e))}else typeof e=="boolean"?e?i.setAttribute(t,""):i.removeAttribute(t):i.setAttribute(t,String(e))}function Dl(i){return i.startsWith("aria-")?i:/^aria[A-Z]/.test(i)?"aria-"+i.slice(4).toLowerCase():null}function cr(i,t){let e=i;for(let s of t.flat(1/0)){if(s==null)continue;if(typeof s=="string"||typeof s=="number"){e.append(document.createTextNode(String(s)));continue}if(typeof s!="object")continue;let n=s;if(typeof n.nodeType=="number")e.append(s);else if(typeof n.toElement=="function"){let r=n.toElement();r&&e.append(r)}}}function Nl(i,t){if(t==null)return;let e=hr(t);e!=null&&(typeof e=="object"?i.appendChild(e):i.textContent=String(e))}function hr(i){if(i&&typeof i=="object"){if(typeof i.nodeType=="number")return i;if(typeof i.toElement=="function")return i.toElement()}return i}function Oi(i,t,e,s=!1){if(typeof e!="function")throw new TypeError("Compact DOM event handler must be a function");let n=String(t),r=Ae.get(i);r||(r=new Map,Ae.set(i,r));let o=r.get(n);if(o)return o.handlers.push(e),i;let l=[e],c=h=>pr(i,l,h);r.set(n,{handlers:l,listener:c});try{i.addEventListener(n,c,{passive:s})}catch{i.addEventListener(n,c)}return i}function ur(i,t,e){let s=String(t),n=Ae.get(i),r=n?.get(s);if(!r)return i;let o=r.handlers.indexOf(e);return o===-1||(r.handlers.splice(o,1),r.handlers.length===0&&(i.removeEventListener(s,r.listener),n.delete(s),n.size===0&&Ae.delete(i))),i}function dr(i,t,e=null){let s=String(t),n=Ae.get(i);if(!n?.has(s))return i;let r=e??Ml(i,s),o=n.get(String(r.type));return o&&pr(i,o.handlers,r),i}function pr(i,t,e){let s=e,n=String(s.type).startsWith("key")?s.which:s.target;for(let r=t.length-1;r>=0;r-=1)t[r].call(i,e,n)===!1&&s.preventDefault()}function Ml(i,t){let e={target:i,type:t,which:-1,defaultPrevented:!1,preventDefault(){e.defaultPrevented=!0}};return e}var Fi=null,fr="en";function _r(i){if(i!==null&&typeof i!="function")throw new TypeError("Translator must be a function or null");Fi=i}function mr(i){fr=String(i||"en")}function G(){return fr}function tt(i,t){let e=Fi?Fi(i):i;return R(e==null?i:String(e),t)}function R(i,t){if(t==null)return String(i);let e=Array.isArray(t)?t:typeof t=="object"?null:[t],s=String(i).replace(/%(\d+)/g,(r,o)=>{let l=Number(o)-1,c;return e?c=e[l]:Object.prototype.hasOwnProperty.call(t,o)&&(c=t[o]),c==null?r:String(c)}),n=0;return s=s.replace(/%([A-Za-z_][\w.-]*)%/g,(r,o)=>{if(!e&&Object.prototype.hasOwnProperty.call(t,o)){let l=t[o];return l==null?r:String(l)}if(e&&n<e.length){let l=e[n];return n+=1,l==null?r:String(l)}return r}),s}var Ge=new WeakMap,_=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#t=new AbortController;#e=!1;#s=!1;#i=!1;constructor(t,e={}){super();let s=this.constructor;this.#e=t===null;let n=H(t);if(t!==null&&!n)throw new TypeError("Component target could not be resolved");this.el=n,this.refs={};let r=Ol(s,e),o=[];for(let[h,u]of Object.entries(r))/^on[a-z]/.test(h)&&typeof u=="function"&&(o.push([h.slice(2),u]),delete r[h]);r.msg&&typeof r.msg=="object"&&Object.freeze(r.msg),this.options=Object.freeze(r);for(let[h,u]of o)this.on(h,u);let l;try{l=a.scope(this.refs,()=>this.render())}catch(h){throw this.#t.abort(),h}if(this.#e){let h=D(l)?l:this.el;if(!D(h))throw this.#t.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=h}if(!D(this.el))throw this.#t.abort(),new TypeError("Component requires a root Element");let c=s.cssName;if(typeof c=="string"&&c){let h=`zx-${c}`;this.#i=!this.el.classList.contains(h),this.el.classList.add(h)}Ge.set(this.el,this)}render(){return this.el??null}on(t,e){return this.addEventListener(t,e,{signal:this.#t.signal}),this}off(t,e){return this.removeEventListener(t,e),this}once(t,e){return this.addEventListener(t,e,{once:!0,signal:this.#t.signal}),this}addEvent(t,e){return this.on(t,e)}emit(t,e={}){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("Event detail must be an object");let s=gr(t,e,{cancelable:!0});return this.dispatchEvent(s),this.el&&this.el.dispatchEvent(gr(`zx-${t}`,e,{bubbles:!0,composed:!0,cancelable:!0})),s}listen(t,e,s,n={}){let r=typeof n=="boolean"?{capture:n}:{...n};return t.addEventListener(e,s,{...r,signal:this.#t.signal}),this}toElement(){return this.el}msg(t,...e){let s=this.options.msg,n=this.options.lang??this.options.language??G(),r=s?.[n]?.[t];if(r!=null)return R(String(r),e);let o=s?.[t];return o!=null?R(String(o),e):tt(t,e)}destroy(){if(this.#s)return;this.#s=!0,this.#t.abort(),Ge.get(this.el)===this&&Ge.delete(this.el);let t=this.constructor.cssName;this.#i&&typeof t=="string"&&this.el&&this.el.classList.remove(`zx-${t}`),this.#e&&this.el&&this.el.remove()}static from(t){return Ge.get(t)??null}};function Ol(i,t){let e=[],s=i;for(;s&&s!==Function.prototype;)Object.prototype.hasOwnProperty.call(s,"defaults")&&e.unshift(s.defaults),s=Object.getPrototypeOf(s);let n={},r={},o=!1;for(let l of e)!l||typeof l!="object"||(Object.assign(n,l),l.msg&&typeof l.msg=="object"&&(o=!0,r=Vt(r,l.msg)));return Object.assign(n,t&&typeof t=="object"?t:{}),t?.msg&&typeof t.msg=="object"&&(o=!0,r=Vt(r,t.msg)),o&&(n.msg=r),n}function gr(i,t,e){if(typeof CustomEvent=="function")return new CustomEvent(i,{...e,detail:t});let s=new Event(i,e);return Object.defineProperty(s,"detail",{configurable:!0,enumerable:!0,value:t}),s}var A=class i extends _{static cssName="field";static defaults={id:null,type:"text",label:"",description:"",value:void 0,placeholder:"",required:!1,disabled:!1,options:null,layout:"stack",props:{},msg:{"field.int":"Enter a whole number.","field.float":"Enter a valid number.","field.unknown":"Unknown field type: %1"}};static#t=new Map;static register(t,e){let s=String(t).trim().toLowerCase();if(!s)throw new TypeError("Field adapter type must not be empty");if(typeof e!="function")throw new TypeError("Field adapter must be a function");return i.#t.set(s,e),this}static has(t){return i.#t.has(String(t).trim().toLowerCase())}render(){let t=this.el??a("div");this.el=t;let e=String(this.options.type||"text").toLowerCase(),s=this.options.layout==="inline"?"inline":"stack";this._ownedComponents=new Set,this._ownedNodes=[],this._rootAttributes=ql(t,["data-layout","data-field-type","data-disabled","data-state"]),t.dataset.layout=s,t.dataset.fieldType=e,this.controlId=this.options.id?String(this.options.id):y("zx-field");let n=`${this.controlId}-label`,r=`${this.controlId}-description`,o=`${this.controlId}-highlight`,l=a("label",{class:"zx-field__label",id:n,htmlFor:this.controlId},String(this.options.label??""),this.options.required?a("span",{class:"zx-field__required",ariaHidden:"true"}," *"):null),c=a("div",{class:"zx-field__control"}),h=a("div",{class:"zx-field__description",id:r},String(this.options.description??"")),u=a("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),d=a("div",{class:"zx-field__body"},c,h,u);this._ownedNodes.push(l,d),t.append(l,d);let f=i.#t.get(e);if(f)try{this.adapter=Ll(f(this,this.options))}catch(m){let b=m instanceof Error?m.message:String(m);console.warn(`[zx.Field] Adapter "${e}" failed: ${b}`),this.adapter=yr(b,this.controlId)}else{let m=this.msg("field.unknown",e);console.warn(`[zx.Field] ${m}`),this.adapter=yr(m,this.controlId)}let p=this.adapter.el;return p.id||(p.id=this.controlId),l.htmlFor=p.id,Rl(p)||p.setAttribute("aria-labelledby",n),this._baseDescribedBy=p.getAttribute("aria-describedby")??"",c.append(p),this._descriptionId=String(this.options.description??"")?r:"",this._highlightId=o,this._highlight=u,this._syncDescription(),this.initialValue=Fl(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 s=["danger","warning","success"].includes(e)?e:"danger";return this.el.dataset.state=s,this._highlight.textContent=String(t??""),this._highlight.hidden=!t,s==="danger"&&t?(this._highlight.setAttribute("role","alert"),this.adapter.el.setAttribute("aria-invalid","true"),this.emit("invalid",{message:String(t)})):(this._highlight.removeAttribute("role"),this.adapter.el.removeAttribute("aria-invalid")),this._syncDescription(!!t),this}clearHighlight(){return delete this.el.dataset.state,this._highlight.textContent="",this._highlight.hidden=!0,this._highlight.removeAttribute("role"),this.adapter.el.removeAttribute("aria-invalid"),this._syncDescription(!1),this}getInput(){return this.adapter.el}own(t){if(!(t instanceof _))throw new TypeError("Field.own() requires a Component");return this._ownedComponents.add(t),t}_syncDescription(t=!1){let e=[this._baseDescribedBy,this._descriptionId,t?this._highlightId:""].flatMap(s=>s.split(/\s+/)).filter(Boolean);e.length?this.adapter.el.setAttribute("aria-describedby",[...new Set(e)].join(" ")):this.adapter.el.removeAttribute("aria-describedby")}destroy(){this.adapter?.destroy?.();for(let t of this._ownedComponents??[])t.destroy();this._ownedComponents?.clear();for(let t of this._ownedNodes??[])t.remove();Bl(this.el,this._rootAttributes??new Map),super.destroy()}};function Li(i){if(typeof i=="number")return Number.isInteger(i)?{valid:!0,value:i}:{valid:!1,value:String(i)};let t=String(i??"").trim();if(t==="")return{valid:!0,value:""};let e=vr(t);return e!==null&&Number.isInteger(e)?{valid:!0,value:e}:{valid:!1,value:t}}function Ri(i){if(typeof i=="number")return Number.isFinite(i)?{valid:!0,value:i}:{valid:!1,value:String(i)};let t=String(i??"").trim();if(t==="")return{valid:!0,value:""};let e=vr(t);return e!==null?{valid:!0,value:e}:{valid:!1,value:t}}function vr(i){let t=i.replace(/[\s\u00a0]/g,"");if(!/^[+-]?[\d.,]+$/.test(t))return null;let e=/^[+-]/.test(t)?t[0]:"",s=e?t.slice(1):t;if(!/\d/.test(s))return null;let n=[...s.matchAll(/\./g)].map(c=>c.index),r=[...s.matchAll(/,/g)].map(c=>c.index),o;if(n.length&&r.length){let c=n.at(-1)>r.at(-1)?".":",",h=c==="."?",":".",u=s.lastIndexOf(c),d=s.slice(0,u),f=s.slice(u+1);if(!/^\d+$/.test(f)||!br(d,h))return null;o=d.split(h).join("")+"."+f}else if(r.length>1||n.length>1){let c=r.length?",":".";if(!br(s,c))return null;o=s.split(c).join("")}else r.length===1?o=s.replace(",","."):o=s;if(!/^(?:\d+(?:\.\d+)?|\.\d+)$/.test(o))return null;let l=Number(e+o);return Number.isFinite(l)?l:null}function br(i,t){let e=i.split(t);return e.length>0&&/^\d{1,3}$/.test(e[0])&&e.slice(1).every(s=>/^\d{3}$/.test(s))}function Fl(i,t){return t!==void 0?t:i==="checkbox"?!1:""}function Ll(i){if(!i||typeof i!="object")throw new TypeError("Adapter must return an object");if(!(i.el&&i.el.nodeType===1))throw new TypeError("Adapter must provide an Element");for(let t of["get","set","focus","setDisabled"])if(typeof i[t]!="function")throw new TypeError(`Adapter is missing ${t}()`);return i}function yr(i,t){let e=a("div",{class:"zx-field__error-control",id:t,role:"alert",tabIndex:-1},i);return{el:e,get:()=>null,set:()=>{},focus:()=>e.focus(),setDisabled:()=>{}}}function Rl(i){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(i.tagName)}function ql(i,t){return new Map(t.map(e=>[e,i.getAttribute(e)]))}function Bl(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}function ke(i,t){let e={...i.props??{}};for(let s of Object.keys(e))(/^on[a-z]/i.test(s)||s==="content")&&delete e[s];return{...e,...t}}function Qe(i,t){return(e,s)=>{let n=a(i,ke(s,{type:i==="input"?t:void 0,placeholder:s.placeholder,required:s.required,disabled:s.disabled}));return qi(n)}}function qi(i){return{el:i,get:()=>i.value,set:t=>{i.value=t==null?"":String(t)},focus:()=>i.focus(),setDisabled:t=>{i.disabled=t}}}function wr(i){return(t,e)=>{let s=i==="int"?Li:Ri,n=a("input",ke(e,{type:"text",inputMode:i==="int"?"numeric":"decimal",placeholder:e.placeholder,required:e.required,disabled:e.disabled}));return t.listen(n,"blur",()=>{let r=s(n.value);if(!r.valid){t.setHighlight(t.msg(`field.${i}`),"danger");return}r.value!==""&&(n.value=String(r.value)),t.clearHighlight()}),{...qi(n),get:()=>s(n.value).value}}}var Pl=(i,t)=>{let e=a("input",ke(t,{type:"checkbox",required:t.required,disabled:t.disabled}));return{el:e,get:()=>e.checked,set:s=>{e.checked=!!s},focus:()=>e.focus(),setDisabled:s=>{e.disabled=s}}},Hl=(i,t)=>{let e=a("select",ke(t,{required:t.required,disabled:t.disabled}));for(let[s,n]of Ar(t.options))e.append(a("option",{value:s},n));return qi(e)},Vl=(i,t)=>{let e=a("div",{class:"zx-field__option-list",role:"radiogroup"}),s=t.id?String(t.id):y("zx-option-list"),n=Ar(t.options).map(([r,o],l)=>{let c=a("input",{type:"radio",name:s,value:r,required:!!t.required&&l===0,disabled:t.disabled});return e.append(a("label",{class:"zx-field__option"},c,a("span",{},o))),c});return{el:e,get:()=>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))}}},jl=(i,t)=>{let e=a("div",ke(t,{class:"zx-field__static"})),s=null;return{el:e,get:()=>e.textContent,set:r=>{xr(s),s=null,r&&typeof r=="object"&&typeof r.nodeType=="number"?(s={node:r,parent:r.parentNode,next:r.nextSibling},e.replaceChildren(r)):e.textContent=r==null?"":String(r)},focus:()=>{},setDisabled:r=>{e.setAttribute("aria-disabled",String(r))},destroy:()=>xr(s)}};function xr(i){i&&(i.parent?i.parent.insertBefore(i.node,i.next?.parentNode===i.parent?i.next:null):i.node.remove())}var $l=(i,t)=>{if(typeof t.adapter!="function")throw new TypeError("Custom fields require options.adapter");return t.adapter(i,t)};function Ar(i){return Array.isArray(i)?i.map(t=>[String(t),String(t)]):i&&typeof i=="object"?Object.entries(i).map(([t,e])=>[t,String(e)]):[]}A.register("text",Qe("input","text"));A.register("password",Qe("input","password"));A.register("textarea",Qe("textarea","text"));A.register("checkbox",Pl);A.register("int",wr("int"));A.register("float",wr("float"));A.register("select",Hl);A.register("optionlist",Vl);A.register("hidden",Qe("input","hidden"));A.register("html",jl);A.register("custom",$l);function yt(i,t,e){let s=Sr(t).split(/\s+/).filter(Boolean);return s.length===0?i.slice():i.filter(n=>{let r=Kl(n,e).map(Sr);return s.every(o=>r.some(l=>l.includes(o)))})}function Kl(i,t){return i===null||typeof i!="object"?[i]:!Array.isArray(t)||t.length===0?[i]:t.map(e=>typeof e=="function"?e(i):i[e])}function Sr(i){return String(i??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var et=class extends _{static cssName="checklist";static defaults={items:[],valueKey:"ID",labelKey:"name",checkedKey:"on",search:!0,height:280,defaultChecked:!1,load:null};render(){this._items=[],this._visibleItems=[],this._checked=new Set,this._query="",this._loadSequence=0,this._createdRoot=!1,this._active=!0,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let t=this.el??a("div");this.el=t,this._createdRoot||(this._originalChildren=Array.from(t.childNodes));for(let o of["role","aria-labelledby","data-state"])this._originalAttributes.set(o,t.getAttribute(o));let e=y("zx-checklist-label"),s=a("div",{class:"zx-checklist__label",id:e},this._message("checklist.label","Checklist")),n=a("input",{ref:"search",class:"zx-checklist__search",type:"search",autocomplete:"off",placeholder:this._message("checklist.search","Search"),ariaLabel:this._message("checklist.search","Search checklist"),hidden:!this.options.search}),r=a("div",{ref:"list",class:"zx-checklist__list"});return r.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,t.replaceChildren(s,n,r),t.setAttribute("role","group"),t.setAttribute("aria-labelledby",e),this.listen(n,"input",()=>this.search(n.value)),this.listen(r,"change",o=>{let l=o.target;if(!l?.matches?.('input[type="checkbox"][data-index]'))return;let c=this._visibleItems[Number(l.dataset.index)];if(c===void 0)return;let h=this._itemValue(c);l.checked?this._checked.add(h):this._checked.delete(h),this.emit("change",{values:this.getValues()})}),this._replaceItems(this.options.items),typeof this.options.load=="function"&&queueMicrotask(()=>{this._active&&this.reload().catch(()=>{})}),t}setItems(t){return this._replaceItems(t),this}getValues(){return this._items.map(t=>this._itemValue(t)).filter(t=>this._checked.has(t))}setValues(t){let e=new Set(t==null?[]:Array.from(t)),s=new Set(this._items.map(n=>this._itemValue(n)).filter(n=>e.has(n)));return this._replaceChecked(s),this}checkAll(){return this._replaceChecked(new Set(this._items.map(t=>this._itemValue(t)))),this}uncheckAll(){return this._replaceChecked(new Set),this}search(t){this._query=String(t??"");let e=this.refs.search;return e.value!==this._query&&(e.value=this._query),this._visibleItems=yt(this._items,this._query,[this.options.labelKey]),this._renderItems(),this}async reload(){if(!this._active||typeof this.options.load!="function")return this;let t=++this._loadSequence;this.el.setAttribute("data-state","loading"),this.refs.list.setAttribute("aria-busy","true");try{let e=await this.options.load();if(t!==this._loadSequence)return this;this._replaceItems(e),this.emit("loaded",{items:this._items.slice()})}finally{t===this._loadSequence&&(this.el.removeAttribute("data-state"),this.refs.list.setAttribute("aria-busy","false"))}return this}destroy(){this._active=!1,this._loadSequence+=1;let t=this.el;if(!this._createdRoot&&t){t.replaceChildren(...this._originalChildren);for(let[e,s]of this._originalAttributes)s===null?t.removeAttribute(e):t.setAttribute(e,s)}super.destroy()}_replaceItems(t){this._items=Array.isArray(t)?t.slice():[],this._checked=new Set(this._items.filter(e=>!!this._initialChecked(e)).map(e=>this._itemValue(e))),this._visibleItems=yt(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let t=this._visibleItems.map((e,s)=>{let n=y("zx-checklist-item"),r=a("input",{type:"checkbox",id:n,checked:this._checked.has(this._itemValue(e)),dataset:{index:s}});return a("label",{class:"zx-checklist__item",for:n},r,a("span",{},this._itemLabel(e)))});t.length===0&&t.push(a("div",{class:"zx-checklist__empty",role:"status"},this._message("checklist.empty","No matches"))),this.refs.list.replaceChildren(...t)}_replaceChecked(t){Ul(this._checked,t)||(this._checked=t,this._renderItems(),this.emit("change",{values:this.getValues()}))}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){return String(this._read(t,this.options.labelKey)??"")}_initialChecked(t){let e;return typeof this.options.checkedKey=="function"?e=this.options.checkedKey(t):t!==null&&typeof t=="object"&&(e=t[this.options.checkedKey]),e??this.options.defaultChecked}_read(t,e){return typeof e=="function"?e(t):t===null||typeof t!="object"?t:t[e]}_message(t,e){let s=this.msg(t);return s===t?e:s}};function Ul(i,t){return i.size===t.size&&Array.from(i).every(e=>t.has(e))}function kr(){A.register("checklist",(i,t)=>{let e=i.own(new et(null,{...t.props??{}})),s=!1,n=!1,r=()=>{e.el.setAttribute("aria-disabled",String(s));for(let o of e.el.querySelectorAll("input, button, select, textarea"))o.disabled=s};return i.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>{n||i.emit("change",{value:o.detail.values})}),e.on("loaded",r),{el:e.el,get:()=>e.getValues(),set:o=>{n=!0;try{e.setValues(Array.isArray(o)?o:[])}finally{n=!1}r()},focus:()=>{(e.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])")??e.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus()},setDisabled:o=>{s=!!o,r()}}})}var zr=["January","February","March","April","May","June","July","August","September","October","November","December"],Cr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ir=/%[demYyHMSaAbBs]/g;function z(i,t){return!(i instanceof Date)||Number.isNaN(i.getTime())?"":String(t).replace(Ir,e=>{switch(e){case"%d":return Kt(i.getDate());case"%e":return String(i.getDate());case"%m":return Kt(i.getMonth()+1);case"%Y":return String(i.getFullYear()).padStart(4,"0");case"%y":return Kt(i.getFullYear()%100);case"%H":return Kt(i.getHours());case"%M":return Kt(i.getMinutes());case"%S":return Kt(i.getSeconds());case"%a":return Tr("weekday",i.getDay(),Cr[i.getDay()]);case"%A":return Bi("weekday",i.getDay(),Cr[i.getDay()]);case"%b":return Tr("month",i.getMonth(),zr[i.getMonth()]);case"%B":return Bi("month",i.getMonth(),zr[i.getMonth()]);case"%s":return String(Math.floor(i.getTime()/1e3));default:return e}})}function $(i,t){let e=[],s="^",n=0;for(let m of String(t).matchAll(Ir)){s+=Er(String(t).slice(n,m.index));let b=m[0],w=Yl(b);if(w===null)return null;s+=`(${w})`,e.push(b),n=m.index+b.length}s+=Er(String(t).slice(n))+"$";let r=new RegExp(s).exec(String(i));if(!r)return null;let o=Object.create(null);if(e.forEach((m,b)=>{o[m]=Number(r[b+1])}),o["%s"]!==void 0){let m=o["%s"]*1e3,b=new Date(m);return Number.isNaN(b.getTime())?null:b}let l=o["%Y"]??Wl(o["%y"])??1970,c=(o["%m"]??1)-1,h=o["%d"]??o["%e"]??1,u=o["%H"]??0,d=o["%M"]??0,f=o["%S"]??0,p=new Date(0);return p.setHours(0,0,0,0),p.setFullYear(l,c,h),p.setHours(u,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()!==h||o["%e"]!==void 0&&p.getDate()!==h||o["%H"]!==void 0&&p.getHours()!==u||o["%M"]!==void 0&&p.getMinutes()!==d||o["%S"]!==void 0&&p.getSeconds()!==f?null:p}function Je(i,t,e){let s=i.getTime(),n=t instanceof Date?t.getTime():-1/0,r=e instanceof Date?e.getTime():1/0;return new Date(Math.min(r,Math.max(n,s)))}function q(i,t){return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()&&i.getDate()===t.getDate()}function E(i,t){let e=new Date(i.getTime());return e.setDate(e.getDate()+t),e}function ut(i,t){let e=new Date(i.getTime()),s=e.getDate();e.setDate(1),e.setMonth(e.getMonth()+t);let n=new Date(e.getFullYear(),e.getMonth()+1,0).getDate();return e.setDate(Math.min(s,n)),e}function Ut(i=G()){if(!i||i.toLowerCase()==="en")return 1;try{let t=new Intl.Locale(i),e=t.getWeekInfo?.()??t.weekInfo;if(e?.firstDay)return e.firstDay%7}catch{}return 1}function Kt(i){return String(i).padStart(2,"0")}function Bi(i,t,e){let s=`date.${i}.${t}`,n=tt(s);return n===s?e:n}function Tr(i,t,e){let s=`date.${i}.short.${t}`,n=tt(s);return n!==s?n:Bi(i,t,e).slice(0,3)}function Yl(i){return{"%d":"\\d{1,2}","%e":"\\d{1,2}","%m":"\\d{1,2}","%Y":"\\d{4}","%y":"\\d{2}","%H":"\\d{1,2}","%M":"\\d{1,2}","%S":"\\d{1,2}","%s":"-?\\d+"}[i]??null}function Wl(i){if(i!==void 0)return i>=69?1900+i:2e3+i}function Er(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Xe=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),Hi=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),Dr=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"}),Vi=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"}),Pi=new Map;function Ze(i){let t=String(i).trim();if(/\s/.test(t)||t.startsWith("fa-"))return{provider:"fa",name:"",style:null,classes:t.split(/\s+/).filter(Boolean)};let e=t.indexOf(":");if(e>0){let s=t.slice(0,e).toLowerCase(),n=t.slice(e+1);if(s==="builtin"||s==="zx")return{provider:"builtin",name:n,style:null,classes:null};if(Object.hasOwn(Dr,s))return{provider:"fa",name:n,style:Dr[s],classes:null}}return{provider:null,name:t,style:null,classes:null}}function ze(i,t={}){let{style:e="solid",family:s="classic",fixedWidth:n=!1,translate:r=!0}=t,o=String(i).replace(/^fa-/,""),l=r?Vi[o]??o:o,c=[],h=Hi[s];return h&&c.push(h),c.push(Xe[e]??Xe.solid,`fa-${l}`),n&&c.push("fa-fw"),c}function Ce(i){let t=String(i).trim();if(/^(https?:)?\/\//.test(t)||t.startsWith("/")||t.endsWith(".js"))return t;if(!/^[a-z0-9]+$/.test(t))throw new RangeError(`Invalid Font Awesome kit token: ${i}`);return`https://kit.fontawesome.com/${t}.js`}function ts(i){let t=Ce(i),e=Pi.get(t);if(e)return e;let s=new Promise((n,r)=>{let o=new URL(t,document.baseURI).href,l=[...document.scripts].find(h=>h.src===o);if(l&&globalThis.FontAwesomeKitConfig){n();return}let c=l??document.createElement("script");c.addEventListener("load",()=>n(),{once:!0}),c.addEventListener("error",()=>{Pi.delete(t),r(new Error(`Font Awesome kit failed to load: ${t}`))},{once:!0}),!l&&(c.src=t,c.async=!0,c.crossOrigin="anonymous",document.head.append(c))});return Pi.set(t,s),s}var Nr="http://www.w3.org/2000/svg",es=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"]}),Gl=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list"}),$i=Object.create(null),dt={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function ss(){return{...dt}}function Te(i={}){for(let t of["provider","style","family","fixedWidth","kit"])i[t]!==void 0&&(dt[t]=i[t]);return ss()}function Ki(i={}){return Te({...i,provider:"fontawesome"})}function Or(){return Te({provider:"builtin"})}async function Fr(i){let t=typeof i=="string"?{kit:i}:{...i},{kit:e,activate:s=!0,...n}=t;if(!e)throw new TypeError("loadFontAwesome() needs a kit token or URL");return Te({...n,kit:Ce(e)}),await ts(e),s?Ki():ss()}function Lr(i){for(let[t,e]of Object.entries(i)){if(!Array.isArray(e)||e.length!==2)throw new TypeError(`Icon "${t}" must be a [viewBox, path] pair`);$i[t]=[String(e[0]),String(e[1])]}}function Rr(){return[...new Set([...Object.keys(es),...Object.keys($i)])].sort()}function g(i,t={}){let e=Ze(i);if(e.classes)return ji(e.classes,t);let s=Gl[e.name]??e.name;return e.provider==="builtin"?Mr(s,t):e.provider==="fa"?ji(ze(s,{style:e.style??t.style??dt.style,family:t.family??dt.family,fixedWidth:t.fixedWidth??dt.fixedWidth}),t):dt.provider==="fontawesome"?ji(ze(s,{style:t.style??dt.style,family:t.family??dt.family,fixedWidth:t.fixedWidth??dt.fixedWidth}),t):Mr(s,t)}function Mr(i,t){let e=$i[i]??es[i];if(!e)throw new RangeError(`Unknown icon: ${i}`);let[s,n]=e,{size:r=16}=t,o=document.createElementNS(Nr,"svg"),l=document.createElementNS(Nr,"path");return o.setAttribute("class",Br("zx-icon",t.class)),o.setAttribute("viewBox",s),o.setAttribute("width",String(r)),o.setAttribute("height",String(r)),o.setAttribute("fill","currentColor"),o.setAttribute("focusable","false"),qr(o,t.label??null),l.setAttribute("d",n),o.append(l),o}function ji(i,t){let{size:e=16}=t,s=document.createElement("i");return s.className=Br("zx-icon",...i,t.class),s.style.fontSize=typeof e=="number"?`${e}px`:String(e),qr(s,t.label??null),s}function qr(i,t){if(t===null){i.setAttribute("aria-hidden","true");return}i.setAttribute("role","img"),i.setAttribute("aria-label",t)}function Br(...i){return i.flat().filter(Boolean).join(" ")}var Ql=5,Wt=class extends _{static cssName="time-picker";static defaults={value:null,seconds:!1,step:5,clock:!0};render(){let t=this.el??a("div");this.el=t;let e=Pr(this.options.value);this._value=e,this._display=e??{h:0,m:0,s:0},this._inputs=[],this._clockOpen=!1,this._clockUnit="h",this._clock=null;let s=a("div",{class:"zx-time-picker__segments",role:"group",ariaLabel:"Time"});if(this._content=s,this._addSpin(s,"h","Hour",23),s.append(a("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"m","Minute",59),this.options.seconds&&(s.append(a("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"s","Second",59)),t.append(s),this.options.clock){let n=y("zx-time-picker-clock");s.append(a("button",{ref:"clockToggle",class:"zx-icon-btn zx-time-picker__clock-toggle",type:"button",ariaLabel:"Pick the time on a clock",ariaExpanded:"false",ariaControls: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 s=Pr(t);return this._value=s,this._display=s??{h:0,m:0,s:0},this._writeInputs(),!e&&s&&this.emit("change",{time:{...s}}),this}openClock(t="h"){return this._clock?(this._clockOpen=!0,this._clockUnit=t==="m"?"m":"h",this._syncClock(),this):this}closeClock(){return this._clock?(this._clockOpen=!1,this._syncClock(),this):this}toggleClock(){return this._clockOpen?this.closeClock():this.openClock("h")}destroy(){this._content?.remove(),this._clock?.remove(),this._clock=null,super.destroy()}_addSpin(t,e,s,n){let r=a("input",{class:"zx-time-picker__spin",type:"text",role:"spinbutton",inputMode:"numeric",maxLength:2,autocomplete:"off",ariaLabel:s,ariaValueMin:"0",ariaValueMax:String(n),dataset:{segment:e}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"keydown",o=>this._onKeydown(o,e,n)),this.listen(r,"input",()=>this._onInput(r,e,n)),this.listen(r,"blur",()=>this._commitFromInputs())}_onKeydown(t,e,s){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return;t.preventDefault();let n=t.key==="ArrowUp"?1:-1,r=e==="m"?tc(this.options.step):1,o=Yt(t.currentTarget.value,0,s),l=s+1,c=(o+n*r+l*r)%l;t.currentTarget.value=Et(c),this._commitFromInputs()}_onInput(t,e,s){if(t.value=t.value.replace(/\D/g,"").slice(0,2),t.value.length<2)return;t.value=Et(Yt(t.value,0,s)),this._commitFromInputs();let n=this._inputs.indexOf(t);this._inputs[n+1]?.focus()}_commitFromInputs(){let t={h:0,m:0,s:0};for(let s of this._inputs){let n=s.dataset.segment,r=n==="h"?23:59;t[n]=Yt(s.value,0,r)}let e=!this._value||!ec(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=Et(this._display[e]),t.setAttribute("aria-valuenow",String(this._display[e])),t.setAttribute("aria-valuetext",t.value)}this._syncClock()}_buildClock(t){let e=a("div",{class:"zx-time-picker__clock",id:t,hidden:!0},a("div",{class:"zx-time-picker__clock-head"},a("button",{ref:"headHour",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:"Select the hour",dataset:{unit:"h"}}),a("span",{class:"zx-time-picker__clock-colon",ariaHidden:"true"},":"),a("button",{ref:"headMinute",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:"Select the minutes",dataset:{unit:"m"}})),a("div",{ref:"dial",class:"zx-time-picker__dial",role:"radiogroup"},a("span",{ref:"hand",class:"zx-time-picker__hand",ariaHidden:"true"}),a("span",{class:"zx-time-picker__pivot",ariaHidden:"true"})));return this.listen(this.refs.headHour,"click",()=>this.openClock("h")),this.listen(this.refs.headMinute,"click",()=>this.openClock("m")),this.listen(this.refs.dial,"click",s=>{let n=s.target.closest?.(".zx-time-picker__mark");n&&this._pick(Number(n.dataset.value))}),this.listen(this.refs.dial,"keydown",s=>this._onDialKeydown(s)),e}_pick(t){let e={...this._display,[this._clockUnit]:t},s=this._clockUnit==="h";this.set(e),s&&this.openClock("m")}_onDialKeydown(t){let e=[...this.refs.dial.querySelectorAll(".zx-time-picker__mark")],s=t.target.closest?.(".zx-time-picker__mark"),n=e.indexOf(s);if(n<0)return;let r={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[t.key],o=null;r!==void 0?o=(n+r+e.length)%e.length:t.key==="Home"?o=0:t.key==="End"&&(o=e.length-1),o!==null&&(t.preventDefault(),this._pick(Number(e[o].dataset.value)),this.refs.dial.querySelector(`[data-value="${e[o].dataset.value}"]`)?.focus())}_syncClock(){if(!this._clock)return;let t=this._clockUnit==="h";if(this._clock.hidden=!this._clockOpen,this.refs.clockToggle.setAttribute("aria-expanded",String(this._clockOpen)),this.refs.headHour.textContent=Et(this._display.h),this.refs.headMinute.textContent=Et(this._display.m),this.refs.headHour.setAttribute("aria-pressed",String(t)),this.refs.headMinute.setAttribute("aria-pressed",String(!t)),this.refs.dial.setAttribute("aria-label",t?"Hour":"Minutes"),!this._clockOpen)return;let e=t?this._display.h:this._display.m,s=t?Jl():Xl(),n=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(n.length!==s.length||this.refs.dial.dataset.unit!==this._clockUnit){for(let l of n)l.remove();this.refs.dial.dataset.unit=this._clockUnit,this.refs.dial.append(...s.map(l=>this._buildMark(l,e)))}else s.forEach((l,c)=>this._syncMark(n[c],l,e));let r=t&&!Zl(e)?"inner":"outer",o=t?e%12*30:e*6;this.refs.hand.dataset.ring=r,this.refs.hand.style.setProperty("--zx-clock-angle",`${o}deg`)}_buildMark(t,e){let s=a("button",{class:"zx-time-picker__mark",type:"button",role:"radio",dataset:{value:String(t.value),ring:t.ring}},t.label);return s.style.setProperty("--zx-clock-angle",`${t.angle}deg`),this._syncMark(s,t,e),s}_syncMark(t,e,s){let n=e.value===s;t.setAttribute("aria-checked",String(n)),t.tabIndex=n?0:-1}};function Jl(){let i=[];for(let t=1;t<=12;t+=1)i.push({value:t,label:String(t),angle:t%12*30,ring:"outer"});for(let t=0;t<12;t+=1){let e=t===0?0:12+t;i.push({value:e,label:Et(e),angle:t*30,ring:"inner"})}return i}function Xl(){let i=[];for(let t=0;t<60;t+=Ql)i.push({value:t,label:Et(t),angle:t*6,ring:"outer"});return i}function Zl(i){return i>=1&&i<=12}function Pr(i){return i instanceof Date&&!Number.isNaN(i.getTime())?{h:i.getHours(),m:i.getMinutes(),s:i.getSeconds()}:!i||typeof i!="object"?null:{h:Yt(i.h,0,23),m:Yt(i.m,0,59),s:Yt(i.s,0,59)}}function Yt(i,t,e){let s=Number.parseInt(String(i??""),10);return Number.isFinite(s)?Math.max(t,Math.min(e,s)):t}function tc(i){let t=Math.round(Number(i));return Number.isFinite(t)&&t>0&&t<=59?t:5}function Et(i){return String(i).padStart(2,"0")}function ec(i,t){return i.h===t.h&&i.m===t.m&&i.s===t.s}var xt=class extends _{static cssName="date-picker";static defaults={value:null,min:null,max:null,weekStart:1,showWeekNumbers:!1,time:!1};render(){let t=this.el??a("div");this._min=st(is(this.options.min)),this._max=st(is(this.options.max)),this._value=this._normalizeValue(is(this.options.value)),this._focused=st(this._value)??this._clampFocus(st(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=sc(this.options.weekStart),this._quickOpen=!1,this._timePicker=null;let e=a("div",{class:"zx-date-picker__surface"},a("div",{class:"zx-date-picker__header"},a("button",{ref:"previous",class:"zx-date-picker__nav",type:"button",ariaLabel:"Previous month"},g("chevron-left")),a("button",{ref:"heading",class:"zx-date-picker__heading",type:"button",ariaExpanded:"false","aria-haspopup":"grid"}),a("button",{ref:"next",class:"zx-date-picker__nav",type:"button",ariaLabel:"Next month"},g("chevron-right"))),a("div",{ref:"quickPanel",class:"zx-date-picker__quick",hidden:!0},a("div",{class:"zx-date-picker__quick-header"},a("button",{ref:"quickPrevious",class:"zx-date-picker__nav",type:"button",ariaLabel:"Previous year"},g("chevron-left")),a("span",{ref:"quickYear",class:"zx-date-picker__quick-year",ariaLive:"polite"}),a("button",{ref:"quickNext",class:"zx-date-picker__nav",type:"button",ariaLabel:"Next year"},g("chevron-right"))),a("div",{ref:"quickGrid",class:"zx-date-picker__quick-grid",role:"grid"})),a("table",{ref:"grid",class:"zx-date-picker__grid",role:"grid",ariaLabel:"Calendar"},a("thead",{ref:"weekdays"}),a("tbody",{ref:"days"})));return this._content=e,t.append(e),this.listen(this.refs.previous,"click",()=>this._pageMonth(-1)),this.listen(this.refs.next,"click",()=>this._pageMonth(1)),this.listen(this.refs.heading,"click",()=>this._toggleQuickPick()),this.listen(this.refs.quickPrevious,"click",()=>this._stepQuickYear(-1)),this.listen(this.refs.quickNext,"click",()=>this._stepQuickYear(1)),this.listen(this.refs.quickGrid,"click",s=>this._onQuickClick(s)),this.listen(this.refs.quickGrid,"keydown",s=>this._onQuickKeydown(s)),this.listen(this.refs.days,"click",s=>this._onDayClick(s)),this.listen(this.refs.days,"keydown",s=>this._onDayKeydown(s)),this._renderWeekdays(),this._renderCalendar(),this.options.time&&(this._timePicker=new Wt(null,{value:this._value,seconds:!1}),this._timePicker.on("change",s=>{let n=s.detail.time,r=this._value??this._focused,o=new Date(r.getTime());o.setHours(n.h,n.m,n.s,0),this.set(o)}),e.append(this._timePicker.el)),t}get(){return Ui(this._value)}set(t,{silent:e=!1}={}){let s=this._normalizeValue(is(t));return this._value=s,s&&(this._focused=st(s),this._viewYear=s.getFullYear(),this._viewMonth=s.getMonth()),this._timePicker?.set(s,{silent:!0}),this._renderCalendar(),e||this.emit("change",{date:Ui(this._value)}),this}focus(){return this._closeQuickPick(),this._buttonForDate(this._focused)?.focus(),this}destroy(){this._timePicker?.destroy(),this._timePicker=null,this._content?.remove(),super.destroy()}_normalizeValue(t){if(!t)return null;let e=new Date(t.getTime()),s=st(e);return this._min&&s<this._min&&Hr(e,this._min),this._max&&s>this._max&&Hr(e,this._max),e}_clampFocus(t){return this._min&&t<this._min?new Date(this._min.getTime()):this._max&&t>this._max?new Date(this._max.getTime()):t}_renderWeekdays(){let t=a("tr");this.options.showWeekNumbers&&t.append(a("th",{class:"zx-date-picker__week-heading",scope:"col",ariaLabel:"Week number"},"#"));let e=new Date(2023,0,1);for(let s=0;s<7;s+=1){let n=E(e,(this._weekStart+s)%7);t.append(a("th",{scope:"col",ariaLabel:z(n,"%A")},z(n,"%a")))}this.refs.weekdays.replaceChildren(t)}_renderCalendar(){if(!this.refs?.days)return;let t=new Date(this._viewYear,this._viewMonth,1),e=(t.getDay()-this._weekStart+7)%7,s=E(t,-e);this.refs.heading.textContent=z(t,"%B %Y"),this.refs.heading.setAttribute("aria-label",`Choose month and year, ${z(t,"%B %Y")}`);let n=[];for(let r=0;r<6;r+=1){let o=E(s,r*7),l=a("tr");this.options.showWeekNumbers&&l.append(a("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:`Week ${Vr(o)}`},String(Vr(o))));for(let c=0;c<7;c+=1){let h=E(o,c),u=!!(this._value&&q(h,this._value)),d=!this._inRange(h),f=a("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:q(h,this._focused)?0:-1,ariaSelected:String(u),ariaDisabled:String(d),ariaCurrent:q(h,new Date)?"date":null,ariaLabel:`${z(h,"%e")} ${z(h,"%B %Y")}`,dataset:{date:z(h,"%Y-%m-%d"),otherMonth:h.getMonth()===this._viewMonth?null:"true"}},z(h,"%e"));l.append(a("td",{role:"presentation"},f))}n.push(l)}this.refs.days.replaceChildren(...n),this._quickOpen&&this._renderQuickPick()}_onDayClick(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let s=$(e.dataset.date,"%Y-%m-%d");s&&this._inRange(s)&&this._selectDate(s)}_onDayKeydown(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let s=$(e.dataset.date,"%Y-%m-%d");if(!s)return;let n=null;if(t.key==="ArrowLeft")n=E(s,-1);else if(t.key==="ArrowRight")n=E(s,1);else if(t.key==="ArrowUp")n=E(s,-7);else if(t.key==="ArrowDown")n=E(s,7);else if(t.key==="PageUp")n=ut(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=ut(s,t.shiftKey?12:1);else if(t.key==="Home")n=E(s,-((s.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=E(s,6-(s.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._inRange(s)&&this._selectDate(s);return}n&&(t.preventDefault(),this._moveFocus(n))}_moveFocus(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;this._focused=st(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._renderCalendar(),e&&this._emitMonthChange(),this._buttonForDate(t)?.focus()}_selectDate(t){let e=new Date(t.getTime()),s=this._timePicker?.get();s?e.setHours(s.h,s.m,s.s,0):this._value&&e.setHours(this._value.getHours(),this._value.getMinutes(),this._value.getSeconds(),this._value.getMilliseconds());let n=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;this._value=e,this._focused=st(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._timePicker?.set(e,{silent:!0}),this._renderCalendar(),n&&this._emitMonthChange(),this.emit("change",{date:Ui(e)})}_pageMonth(t){this._closeQuickPick();let e=ut(this._focused,t);this._focused=st(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._renderCalendar(),this._emitMonthChange()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_toggleQuickPick(){if(this._quickOpen){this._closeQuickPick(),this.refs.heading.focus();return}this._quickOpen=!0,this.refs.quickPanel.hidden=!1,this.refs.heading.setAttribute("aria-expanded","true"),this._renderQuickPick(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_closeQuickPick(){this._quickOpen&&(this._quickOpen=!1,this.refs.quickPanel.hidden=!0,this.refs.heading.setAttribute("aria-expanded","false"))}_renderQuickPick(){this.refs.quickYear.textContent=String(this._viewYear);let t=[];for(let e=0;e<12;e+=1){let s=new Date(this._viewYear,e,1);t.push(a("button",{class:"zx-date-picker__quick-month",type:"button",role:"gridcell",tabindex:e===this._viewMonth?0:-1,ariaSelected:String(e===this._viewMonth),dataset:{month:e}},z(s,"%b")))}this.refs.quickGrid.replaceChildren(...t)}_stepQuickYear(t){this._viewYear+=t,this._renderQuickPick(),this._emitMonthChange(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_onQuickClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.quickGrid.contains(e)||this._chooseQuickMonth(Number(e.dataset.month))}_onQuickKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.quickGrid.contains(e))return;let s=Number(e.dataset.month),n=null;if(t.key==="ArrowLeft")n=s-1;else if(t.key==="ArrowRight")n=s+1;else if(t.key==="ArrowUp")n=s-3;else if(t.key==="ArrowDown")n=s+3;else if(t.key==="Home")n=0;else if(t.key==="End")n=11;else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._chooseQuickMonth(s);return}else if(t.key==="Escape"){t.preventDefault(),this._closeQuickPick(),this.refs.heading.focus();return}if(n===null)return;t.preventDefault(),n=Math.max(0,Math.min(11,n));let r=this.refs.quickGrid.querySelectorAll("[data-month]");for(let o of r)o.tabIndex=Number(o.dataset.month)===n?0:-1;r[n]?.focus()}_chooseQuickMonth(t){let e=new Date(this._viewYear,t,Math.min(this._focused.getDate(),new Date(this._viewYear,t+1,0).getDate()));this._focused=st(e),this._viewMonth=t,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(t){let e=st(t);return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_buttonForDate(t){return this.refs.days.querySelector(`[data-date="${z(t,"%Y-%m-%d")}"]`)}};function is(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function st(i){return i?new Date(i.getFullYear(),i.getMonth(),i.getDate()):null}function Ui(i){return i?new Date(i.getTime()):null}function Hr(i,t){i.setFullYear(t.getFullYear(),t.getMonth(),t.getDate())}function sc(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:Ut()}function Vr(i){let t=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let s=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-s.getTime())/864e5+1)/7)}var Gt=class extends xt{static cssName="month-picker";static defaults={value:null,min:null,max:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??a("div");this._min=rs(ns(this.options.min)),this._max=rs(ns(this.options.max)),this._value=this._normalizeMonth(ns(this.options.value));let e=this._value??rs(new Date);this._year=e.getFullYear(),this._focusedMonth=e.getMonth();let s=a("div",{class:"zx-month-picker__surface"},a("div",{class:"zx-month-picker__header"},a("button",{ref:"previousYear",class:"zx-month-picker__nav",type:"button",ariaLabel:"Previous year"},g("chevron-left")),a("span",{ref:"year",class:"zx-month-picker__year",ariaLive:"polite"}),a("button",{ref:"nextYear",class:"zx-month-picker__nav",type:"button",ariaLabel:"Next year"},g("chevron-right"))),a("div",{ref:"grid",class:"zx-month-picker__grid",role:"grid",ariaLabel:"Choose month"}));return this._content=s,t.append(s),this.listen(this.refs.previousYear,"click",()=>this._stepYear(-1)),this.listen(this.refs.nextYear,"click",()=>this._stepYear(1)),this.listen(this.refs.grid,"click",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(ns(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=rs(t);return this._min&&e<this._min&&(e=new Date(this._min.getTime())),this._max&&e>this._max&&(e=new Date(this._max.getTime())),e}_renderMonths(){if(!this.refs?.grid)return;this.refs.year.textContent=String(this._year);let t=[];for(let e=0;e<12;e+=1){let s=new Date(this._year,e,1),n=!!(this._value&&ic(s,this._value));t.push(a("button",{class:"zx-month-picker__month",type:"button",role:"gridcell",tabindex:e===this._focusedMonth?0:-1,ariaSelected:String(n),ariaDisabled:String(!this._inRange(s)),ariaLabel:z(s,"%B %Y"),dataset:{month:e}},z(s,"%b")))}this.refs.grid.replaceChildren(...t)}_stepYear(t){this._year+=t,this._renderMonths()}_onMonthClick(t){let e=t.target?.closest?.("[data-month]");!e||!this.refs.grid.contains(e)||this._selectMonth(Number(e.dataset.month))}_onMonthKeydown(t){let e=t.target?.closest?.("[data-month]");if(!e||!this.refs.grid.contains(e))return;let s=Number(e.dataset.month),n=null;if(t.key==="ArrowLeft")n=-1;else if(t.key==="ArrowRight")n=1;else if(t.key==="ArrowUp")n=-3;else if(t.key==="ArrowDown")n=3;else if(t.key==="Home")n=-(s%3);else if(t.key==="End")n=2-s%3;else if(t.key==="PageUp"){t.preventDefault(),this._stepYear(-1),this.focus();return}else if(t.key==="PageDown"){t.preventDefault(),this._stepYear(1),this.focus();return}else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._selectMonth(s);return}if(n===null)return;t.preventDefault();let r=this._year*12+s+n;this._year=Math.floor(r/12),this._focusedMonth=(r%12+12)%12,this._renderMonths(),this.focus()}_selectMonth(t){let e=new Date(this._year,t,1);this._inRange(e)&&(this._focusedMonth=t,this._value=e,this._renderMonths(),this.emit("change",{date:this.get()}))}_inRange(t){return!(this._min&&t<this._min)&&!(this._max&&t>this._max)}_button(t){return this.refs.grid.querySelector(`[data-month="${t}"]`)}};function ns(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function rs(i){return i?new Date(i.getFullYear(),i.getMonth(),1):null}function ic(i,t){return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()}function jr(){A.register("month",(i,t)=>{let e=i.own(new Gt(null,{...t.props??{},value:t.value})),s=!1,n=()=>{e.el.setAttribute("aria-disabled",String(s));for(let r of e.el.querySelectorAll("button"))r.disabled=s};return i.listen(e.el,"change",r=>r.stopImmediatePropagation()),e.on("change",r=>i.emit("change",{value:r.detail.date})),{el:e.el,get:()=>e.get(),set:r=>{e.set(r instanceof Date?r:null,{silent:!0}),n()},focus:()=>e.focus(),setDisabled:r=>{s=!!r,n()}}})}var nc=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function U(i,t,e={}){if(!(i instanceof Element)||!(t instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let s=nc.has(e.placement)?e.placement:"bottom-start",n=Number(e.offset??4),r=e.flip??!0,o=e.matchWidth??!1,l=i.getAttribute("style"),c=t.getAttribute("style"),h=t.getAttribute("popover"),u=!1,d=null,f=()=>{},p=()=>{};if(t.setAttribute("popover","manual"),typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a")){let b=`--${y("zx-a")}`;i.style.setProperty("anchor-name",b),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.setProperty("position-anchor",b);let w=rc(s,getComputedStyle(i).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 x=s.startsWith("top")?"margin-bottom":s.startsWith("bottom")?"margin-top":s.startsWith("left")?"margin-right":"margin-left";t.style.setProperty(x,`${n}px`),f=()=>{o&&(t.style.minWidth=`${i.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(d=new ResizeObserver(f),d.observe(i))}else t.style.position="fixed",t.style.inset="auto",t.style.margin="0",f=()=>oc(i,t,{placement:s,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(i)),p=()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)};return ac(t),f(),{update(){u||f()},destroy(){u||(u=!0,d?.disconnect(),p(),lc(t),Yi(i,"style",l),Yi(t,"style",c),Yi(t,"popover",h))}}}function rc(i,t){return{"bottom-start":t?"bottom span-left":"bottom span-right","bottom-end":t?"bottom span-right":"bottom span-left","top-start":t?"top span-left":"top span-right","top-end":t?"top span-right":"top span-left","right-start":"right span-bottom","right-end":"right span-top","left-start":"left span-bottom","left-end":"left span-top",bottom:"bottom",top:"top",right:"right",left:"left"}[i]}function oc(i,t,{placement:e,offset:s,flip:n,matchWidth:r}){let o=i.getBoundingClientRect();r&&(t.style.minWidth=`${o.width}px`);let l=t.getBoundingClientRect(),c=document.documentElement.clientWidth||window.innerWidth,h=document.documentElement.clientHeight||window.innerHeight,u=e,d=$r(e),f=o.bottom+s,p=o.top-s-l.height,m=o.right+s,b=o.left-s-l.width;n&&(d==="bottom"&&f+l.height>h&&p>=0?u=os(e,"bottom","top"):d==="top"&&p<0&&f+l.height<=h?u=os(e,"top","bottom"):d==="right"&&m+l.width>c&&b>=0?u=os(e,"right","left"):d==="left"&&b<0&&m+l.width<=c&&(u=os(e,"left","right")));let w=$r(u),x,v;if(w==="bottom"||w==="top"){let C=getComputedStyle(i).direction==="rtl";u.endsWith("-end")?x=C?o.left:o.right-l.width:u.endsWith("-start")?x=C?o.right-l.width:o.left:x=o.left+(o.width-l.width)/2,v=w==="bottom"?f:p}else x=w==="right"?m:b,u.endsWith("-end")?v=o.bottom-l.height:u.endsWith("-start")?v=o.top:v=o.top+(o.height-l.height)/2;t.style.left=`${Math.round(F(x,0,Math.max(0,c-l.width)))}px`,t.style.top=`${Math.round(F(v,0,Math.max(0,h-l.height)))}px`}function $r(i){return i.split("-")[0]}function os(i,t,e){return i.replace(t,e)}function ac(i){if(typeof i.showPopover=="function")try{i.showPopover()}catch{}}function lc(i){if(typeof i.hidePopover=="function")try{i.hidePopover()}catch{}}function Yi(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}var cc=6,Qr=864e5;function Dt(i,t){let e=Y(It(i)),s=Y(It(t));return e&&s&&e.getTime()>s.getTime()?{start:s,end:e}:{start:e,end:s}}function Qt(i,t){let e=Dt(i,t);return!e.start||!e.end?0:Math.round((Yr(e.end)-Yr(e.start))/Qr)}function Qi(i,t,e){let s=Y(It(i));if(!s)return null;let n=Dt(t,e);return!n.start&&!n.end?null:n.end?n.start?s.getTime()<n.start.getTime()||s.getTime()>n.end.getTime()?null:q(s,n.start)?"start":q(s,n.end)?"end":"middle":q(s,n.end)?"end":null:q(s,n.start)?"start":null}function Jt(i,t={}){let e=Y(It(t.min)),s=Y(It(t.max)),n=as(t.minNights)??0,r=as(t.maxNights),{start:o,end:l}=Dt(i?.start,i?.end);return o&&(o=Gi(o,e,s)),l&&(l=Gi(l,e,s)),!o||!l?{start:o,end:l}:(r!==null&&Qt(o,l)>r&&(l=E(o,r)),n>0&&Qt(o,l)<n&&(l=E(o,n),s&&l.getTime()>s.getTime()&&(l=new Date(s.getTime()),o=E(l,-n),e&&o.getTime()<e.getTime()))?{start:null,end:null}:{start:o,end:l})}var Xt=class extends _{static cssName="date-range-picker";static defaults={start:null,end:null,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??a("div");this.el=t,this._rootAttributes=_c(t,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=Y(It(this.options.min)),this._max=Y(It(this.options.max)),this._minNights=as(this.options.minNights)??0,this._maxNights=as(this.options.maxNights),this._weekStart=dc(this.options.weekStart),this._monthCount=pc(this.options.months),this._presets=uc(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let e=Jt({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=vt(this._start)??this._clampFocus(Y(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),t.setAttribute("role","group"),t.setAttribute("aria-label",L("daterange.label","Date range")),t.dataset.months=String(this._monthCount),this._presets.length&&(t.dataset.presets="true");let s=a("div",{class:"zx-date-range-picker__surface"},this._presets.length?a("div",{ref:"presets",class:"zx-date-range-picker__presets",role:"group",ariaLabel:L("daterange.presets","Date range presets")},this._presets.map(r=>a("button",{class:"zx-date-range-picker__preset",type:"button",dataset:{preset:r.name}},r.label))):null,a("div",{ref:"calendars",class:"zx-date-range-picker__calendars"})),n=a("div",{ref:"status",class:"zx-date-range-picker__status",role:"status",ariaLive:"polite"});return this._nodes=[s,n],t.append(s,n),this.refs.presets&&this.listen(this.refs.presets,"click",r=>this._onPresetClick(r)),this.listen(this.refs.calendars,"click",r=>this._onCalendarClick(r)),this.listen(this.refs.calendars,"keydown",r=>this._onDayKeydown(r)),this.listen(this.refs.calendars,"mouseover",r=>this._onDayHover(r)),this.listen(this.refs.calendars,"mouseleave",()=>this._setHover(null)),this._renderCalendars(),this._announce(),t}get(){return{start:vt(this._start),end:vt(this._end)}}set(t={},{silent:e=!1}={}){let s=Jt({start:t?.start??null,end:t?.end??null},this._bounds());return this._start=s.start,this._end=s.end,this._picking=!!(s.start&&!s.end),this._remember(),this._hover=null,s.start?(this._focused=vt(s.start),this._setView(s.start)):this._paint(),this._announce(),e||this.emit("change",this.get()),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}focus(){return this._buttonForDate(this._focused)?.focus(),this}enable(){return this._disabled=!1,this._paint(),this._syncDisabled(),this}disable(){return this._disabled=!0,this._hover=null,this._paint(),this._syncDisabled(),this}destroy(){for(let t of this._nodes??[])t.remove();this._nodes=[],this._dayCells=[],mc(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=Y(t);if(!e||this._min&&e.getTime()<this._min.getTime()||this._max&&e.getTime()>this._max.getTime())return!1;if(!this._picking||!this._start||e.getTime()<=this._start.getTime())return!0;let s=Qt(this._start,e);return!(s<this._minNights||this._maxNights!==null&&s>this._maxNights)}_choose(t){let e=Y(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?vt(this._start):null,this._committedEnd=t?vt(this._end):null}_abandon(){return this._picking?(this._start=vt(this._committedStart),this._end=vt(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(t){return Gi(t,this._min,this._max)}_visibleMonthCount(){let t=this.refs.calendars?.children??[],e=0;for(let s of t)s.getClientRects().length>0&&(e+=1);return e||this._monthCount}_setView(t){let e=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;if(this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),!e){this._paint();return}this._renderCalendars(),this._emitMonthChange()}_ensureVisible(t){let e=this._visibleMonthCount(),s=Wr(t)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<e)return!1;let n=s<0?s:s-(e-1),r=new Date(this._viewYear,this._viewMonth+n,1);return this._viewYear=r.getFullYear(),this._viewMonth=r.getMonth(),!0}_pageView(t){if(this._disabled)return;let e=new Date(this._viewYear,this._viewMonth+t,1);this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._focused=this._focusInView(this._focused),this._renderCalendars(),this._emitMonthChange()}_focusInView(t){let e=this._visibleMonthCount(),s=Wr(t)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<e)return t;let n=new Date(this._viewYear,this._viewMonth+1,0).getDate();return new Date(this._viewYear,this._viewMonth,Math.min(t.getDate(),n))}_moveFocus(t){let e=Y(t);this._focused=e,this._ensureVisible(e)?(this._renderCalendars(),this._emitMonthChange()):this._paint(),this._buttonForDate(e)?.focus()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_onPresetClick(t){let e=t.target?.closest?.("[data-preset]");if(!e||this._disabled)return;let s=this._presets.find(r=>r.name===e.dataset.preset);if(!s)return;let n=s.range();this.set({start:n?.start??null,end:n?.end??null},{silent:!0}),this.emit("select",this.get()),this.emit("change",this.get())}_onCalendarClick(t){let e=t.target,s=e?.closest?.("[data-nav]");if(s){this._pageView(s.dataset.nav==="next"?1:-1);return}let n=this._cellFor(e);n&&this._choose(n.date)}_onDayHover(t){let e=this._cellFor(t.target);this._setHover(e?e.date:null)}_setHover(t){if(this._disabled||!this._picking)return;let e=t?Y(t):null;!e&&!this._hover||e&&this._hover&&q(e,this._hover)||(this._hover=e,this._paint())}_onDayKeydown(t){let e=this._cellFor(t.target);if(!e)return;let s=e.date,n=null;if(t.key==="ArrowLeft")n=E(s,-1);else if(t.key==="ArrowRight")n=E(s,1);else if(t.key==="ArrowUp")n=E(s,-7);else if(t.key==="ArrowDown")n=E(s,7);else if(t.key==="PageUp")n=ut(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=ut(s,t.shiftKey?12:1);else if(t.key==="Home")n=E(s,-((s.getDay()-this._weekStart+7)%7));else if(t.key==="End")n=E(s,6-(s.getDay()-this._weekStart+7)%7);else if(t.key==="Enter"||t.key===" "){t.preventDefault(),this._choose(s);return}else if(t.key==="Escape"){if(!this._abandon())return;t.preventDefault(),t.stopPropagation();return}!n||this._disabled||(t.preventDefault(),this._moveFocus(n))}_renderCalendars(){if(!this.refs?.calendars)return;this._dayCells=[];let t=[];for(let e=0;e<this._monthCount;e+=1)t.push(this._renderMonth(new Date(this._viewYear,this._viewMonth+e,1)));this.refs.calendars.replaceChildren(...t),this._paint(),this._syncDisabled()}_renderMonth(t){let e=z(t,"%B %Y"),s=(t.getDay()-this._weekStart+7)%7,n=E(t,-s),r=[];for(let o=0;o<cc;o+=1){let l=E(n,o*7),c=a("tr"),h=fc(l,t);this.options.showWeekNumbers&&c.append(a("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:h?L("daterange.week","Week %1",[Gr(l)]):null},h?String(Gr(l)):""));for(let u=0;u<7;u+=1){let d=E(l,u),f=a("td",{role:"presentation"});if(d.getMonth()===t.getMonth()&&d.getFullYear()===t.getFullYear()){let p=a("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:z(d,"%Y-%m-%d")}},z(d,"%e"));f.append(p),this._dayCells.push({date:d,cell:f,button:p})}c.append(f)}r.push(c)}return a("div",{class:"zx-date-range-picker__month"},a("div",{class:"zx-date-range-picker__header"},a("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"previous"},ariaLabel:L("daterange.previousMonth","Previous month")},g("chevron-left")),a("div",{class:"zx-date-range-picker__caption",ariaHidden:"true"},e),a("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"next"},ariaLabel:L("daterange.nextMonth","Next month")},g("chevron-right"))),a("table",{class:"zx-date-range-picker__grid",role:"grid",ariaLabel:e},a("thead",{},this._weekdayRow()),a("tbody",{},...r)))}_weekdayRow(){let t=a("tr");this.options.showWeekNumbers&&t.append(a("th",{class:"zx-date-range-picker__week-heading",scope:"col",ariaLabel:L("daterange.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let s=0;s<7;s+=1){let n=E(e,(this._weekStart+s)%7);t.append(a("th",{scope:"col",ariaLabel:z(n,"%A")},z(n,"%a")))}return t}_paint(){let t=new Date,e=null;for(let s of this._dayCells)q(s.date,this._focused)&&(e=s);e||(e=this._dayCells[0]??null);for(let s of this._dayCells){let{date:n,cell:r,button:o}=s,l=this._dayState(n);Wi(r,"range",l.range),Wi(r,"rangeEdge",l.edge),Wi(o,"range",l.range),o.tabIndex=s===e?0:-1,o.setAttribute("aria-selected",String(l.range!==null&&l.range!=="preview")),o.setAttribute("aria-disabled",String(!this._selectable(n))),o.setAttribute("aria-label",this._dayLabel(n,l.range)),q(n,t)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(t){if(this._start&&this._end){let s=Qi(t,this._start,this._end);if(!s)return{range:null,edge:null};let n=q(this._start,this._end);return s==="start"?{range:s,edge:n?"both":"start"}:s==="end"?{range:s,edge:n?"both":"end"}:{range:s,edge:null}}if(!this._start)return{range:null,edge:null};let e=this._previewEnd();return q(t,this._start)?{range:"start",edge:e?"start":"both"}:e?t.getTime()>this._start.getTime()&&t.getTime()<=e.getTime()?{range:"preview",edge:q(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=Y(t);return e.getTime()<=this._start.getTime()?null:this._selectable(e)?e:null}_dayLabel(t,e){let s=z(t,"%A, %e %B %Y");return e==="start"?`${s}, ${L("daterange.day.start","range start")}`:e==="end"?`${s}, ${L("daterange.day.end","range end")}`:e==="middle"?`${s}, ${L("daterange.day.middle","in selected range")}`:s}_syncDisabled(){this.el.setAttribute("aria-disabled",String(this._disabled));for(let t of this.el.querySelectorAll("button"))t.disabled=this._disabled}_announce(){this.refs?.status&&(this.refs.status.textContent=this._selectionLabel())}_selectionLabel(){if(!this._start)return L("daterange.status.empty","No date range selected");if(!this._end)return L("daterange.status.start","%1 selected, choose an end date",[z(this._start,"%e %B %Y")]);let t=Qt(this._start,this._end),e=t===1?L("daterange.night","1 night"):L("daterange.nights","%1 nights",[t]);return`${hc(this._start,this._end)}, ${e}`}_cellFor(t){let e=t?.closest?.("[data-date]");return e?this._dayCells.find(s=>s.button===e)??null:null}_buttonForDate(t){return this._dayCells.find(e=>q(e.date,t))?.button??null}};function Ji(){return[{name:"today",label:L("daterange.preset.today","Today"),range:()=>Kr(lt())},{name:"yesterday",label:L("daterange.preset.yesterday","Yesterday"),range:()=>Kr(E(lt(),-1))},{name:"last7",label:L("daterange.preset.last7","Last 7 days"),range:()=>({start:E(lt(),-6),end:lt()})},{name:"last30",label:L("daterange.preset.last30","Last 30 days"),range:()=>({start:E(lt(),-29),end:lt()})},{name:"thisMonth",label:L("daterange.preset.thisMonth","This month"),range:()=>Ur(lt(),0)},{name:"lastMonth",label:L("daterange.preset.lastMonth","Last month"),range:()=>Ur(lt(),-1)},{name:"thisQuarter",label:L("daterange.preset.thisQuarter","This quarter"),range:()=>{let i=lt(),t=Math.floor(i.getMonth()/3)*3;return{start:new Date(i.getFullYear(),t,1),end:new Date(i.getFullYear(),t+3,0)}}},{name:"thisYear",label:L("daterange.preset.thisYear","This year"),range:()=>{let i=lt();return{start:new Date(i.getFullYear(),0,1),end:new Date(i.getFullYear(),11,31)}}}]}function L(i,t,e){let s=tt(i);return R(s===i?t:s,e)}function hc(i,t){if(q(i,t))return z(i,"%e %B %Y");let e=z(t,"%e %B %Y");return i.getFullYear()!==t.getFullYear()?`${z(i,"%e %B %Y")} \u2013 ${e}`:i.getMonth()!==t.getMonth()?`${z(i,"%e %B")} \u2013 ${e}`:`${z(i,"%e")} \u2013 ${e}`}function uc(i){return i===!0?Ji():Array.isArray(i)?i.filter(t=>t&&typeof t.range=="function").map((t,e)=>({name:String(t.name??`preset-${e}`),label:String(t.label??t.name??""),range:t.range})):[]}function lt(){return Y(new Date)}function Kr(i){return{start:i,end:new Date(i.getTime())}}function Ur(i,t){return{start:new Date(i.getFullYear(),i.getMonth()+t,1),end:new Date(i.getFullYear(),i.getMonth()+t+1,0)}}function It(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function Y(i){return!i||Number.isNaN(i.getTime())?null:new Date(i.getFullYear(),i.getMonth(),i.getDate())}function vt(i){return i?new Date(i.getTime()):null}function Gi(i,t,e){return t&&i.getTime()<t.getTime()?new Date(t.getTime()):e&&i.getTime()>e.getTime()?new Date(e.getTime()):new Date(i.getTime())}function Yr(i){return Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())}function Wr(i){return i.getFullYear()*12+i.getMonth()}function as(i){if(i==null||i==="")return null;let t=Number(i);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):null}function dc(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:Ut()}function pc(i){let t=Number(i);return Number.isInteger(t)&&t>=1&&t<=4?t:2}function fc(i,t){for(let e=0;e<7;e+=1){let s=E(i,e);if(s.getMonth()===t.getMonth()&&s.getFullYear()===t.getFullYear())return!0}return!1}function Gr(i){let t=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let s=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-s.getTime())/Qr+1)/7)}function Wi(i,t,e){e==null?delete i.dataset[t]:i.dataset[t]=e}function _c(i,t){return new Map(t.map(e=>[e,i.getAttribute(e)]))}function mc(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}var gc={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function ls(i,t,e){let s=String(i??"").trim();if(s==="")return{start:null,end:null};let n=String(e??" \u2013 "),r=n.trim(),o=r!==""&&String(t).includes(r)&&/^\s|\s$/.test(n),l=o?"\\s+":"\\s*",c=o?"(?:\\s+|$)":"\\s*",h=r===""?[s]:s.split(new RegExp(`${l}${$t(r)}${c}`));if(h.length>2)return null;let u=$(h[0].trim(),t);if(!u)return null;if(h.length===1)return{start:u,end:new Date(u.getTime())};if(h[1].trim()==="")return{start:u,end:null};let d=$(h[1].trim(),t);return d?Dt(u,d):null}function Zi(i,t,e){let s=i?.start??null,n=i?.end??null;return!s&&!n?"":n?s?`${z(s,t)}${e}${z(n,t)}`:z(n,t):z(s,t)}var Zt=class extends _{static cssName="date-range-box";static defaults={start:null,end:null,format:"%d.%m.%Y",separator:" \u2013 ",placeholder:null,clearable:!0,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??a("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._format=String(this.options.format||"%d.%m.%Y"),this._separator=String(this.options.separator??" \u2013 "),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._range=this._coerce({start:this.options.start,end:this.options.end});let e=y("zx-date-range-box-popover"),s=a("div",{class:"zx-date-range-box__content"},a("div",{ref:"control",class:"zx-date-range-box__control"},a("input",{ref:"input",class:"zx-date-range-box__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??this._placeholder(),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),a("button",{ref:"clear",class:"zx-icon-btn zx-date-range-box__clear",type:"button",ariaLabel:Jr("daterange.clear","Clear date range")},g("x",{size:13})),a("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:Jr("daterange.choose","Choose date range"),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},g("calendar"))),a("div",{ref:"popover",id:e,class:"zx-date-range-box__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=s,t.append(s),this._picker=new Xt(null,{start:this._range.start,end:this._range.end,min:this.options.min,max:this.options.max,months:this.options.months,weekStart:this.options.weekStart,showWeekNumbers:this.options.showWeekNumbers,minNights:this.options.minNights,maxNights:this.options.maxNights,presets:this.options.presets}),this.refs.popover.append(this._picker.el),this._picker.on("select",n=>{this._range={start:n.detail.start,end:n.detail.end},this._setValid(),this._syncDisplay()}),this._picker.on("change",n=>{this._apply({start:n.detail.start,end:n.detail.end},{push:!1}),n.detail.start&&n.detail.end&&this._close(!0)}),this.listen(this.refs.input,"blur",()=>{this._open||this._commitText()}),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.clear(),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return t==="seconds"?{start:this._range.start?Math.floor(this._range.start.getTime()/1e3):null,end:this._range.end?Math.floor(this._range.end.getTime()/1e3):null}:{start:this._range.start?new Date(this._range.start.getTime()):null,end:this._range.end?new Date(this._range.end.getTime()):null}}set(t,{silent:e=!1}={}){return this._apply(this._coerce(t),{silent:e}),this}clear({silent:t=!1}={}){return this.set({start:null,end:null},{silent:t})}open(){return this._disabled||this._open?this:(this._picker.set(this._range,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=U(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),Xi(this.el,"data-state",this._originalState),Xi(this.el,"aria-disabled",this._originalAriaDisabled),super.destroy()}_apply(t,{silent:e=!1,push:s=!0}={}){this._range=t,s&&this._picker?.set(this._range,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",this.get())}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set({start:null,end:null});return}let e=ls(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(ls(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()!==""?$(t.trim(),this._format):null}_clamp(t){return Jt(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=>gc[e]??e);return`${t}${this._separator}${t}`}_syncDisplay(){this.refs.input.value=Zi(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"&&Xi(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 Jr(i,t,e){let s=tt(i);return R(s===i?t:s,e)}function Xi(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}function Xr(){A.register("daterange",(i,t)=>{let e=i.own(new Zt(null,{...t.props??{},disabled:!!t.disabled,start:t.value?.start??null,end:t.value?.end??null}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:{start:s.detail.start,end:s.detail.end}})),{el:e.el,get:()=>e.get(),set:s=>e.set(s,{silent:!0}),focus:()=>e.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var K=class extends _{static cssName="datebox";static defaults={value:null,format:"%d.%m.%Y",time:!1,min:null,max:null,placeholder:null,clearable:!0,disabled:!1};render(){let t=this.el??a("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._format=bc(this.options.format,this.options.time),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._min=Zr(this.options.min),this._max=Zr(this.options.max),this._value=this._normalizeValue(this.options.value);let e=y("zx-datebox-popover"),s=a("div",{class:"zx-datebox__content"},a("div",{ref:"control",class:"zx-datebox__control"},a("input",{ref:"input",class:"zx-datebox__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??yc(this._format),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),a("button",{ref:"clear",class:"zx-icon-btn zx-datebox__clear",type:"button",ariaLabel:"Clear date"},g("x",{size:13})),a("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:"Choose date","aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},g("calendar"))),a("div",{ref:"popover",id:e,class:"zx-datebox__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=s,t.append(s),this._picker=new xt(null,{value:this._value,min:this._min,max:this._max,time:!!this.options.time}),this.refs.popover.append(this._picker.el),this._picker.on("change",n=>{this.set(n.detail.date),this.options.time||this._close(!0)}),this.listen(this.refs.input,"blur",()=>this._commitText()),this.listen(this.refs.input,"keydown",n=>this._onInputKeydown(n)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",n=>{n.key==="ArrowDown"&&(n.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.set(null),this.focus()}),this.listen(document,"keydown",n=>{!this._open||n.key!=="Escape"||(n.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",n=>{this._open&&!t.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),t}get(t="date"){return this._value?t==="seconds"?Math.floor(this._value.getTime()/1e3):new Date(this._value.getTime()):null}set(t,{silent:e=!1}={}){return this._value=this._normalizeValue(t),this._picker?.set(this._value,{silent:!0}),this._setValid(),this._syncDisplay(),e||this.emit("change",{date:this._copyValue()}),this}open(){return this._disabled||this._open?this:(this._picker.set(this._value,{silent:!0}),this._open=!0,this.refs.popover.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this.refs.toggle.setAttribute("aria-expanded","true"),this._position=U(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set(null);return}let e=$(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=$(t,this._format)),!e||Number.isNaN(e.getTime())?null:Je(e,this._min,this._max)}_syncDisplay(){this.refs.input.value=this._value?z(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}},cs=function(t,e={}){return new K(t,{...e,time:!0})};function Zr(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function bc(i,t){let e=String(i||"%d.%m.%Y");return t&&!/%[HM]/.test(e)?`${e} %H:%M`:e}function yc(i){return i.replace(/%[demYyHMS]/g,t=>({"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY","%H":"HH","%M":"MM","%S":"SS"})[t]??t)}function eo(){to("date",i=>new K(null,i)),to("datetime",i=>cs(null,i))}function to(i,t){A.register(i,(e,s)=>{let n=e.own(t({...s.props??{},value:s.value}));return e.listen(n.el,"change",r=>r.stopImmediatePropagation()),n.on("change",r=>e.emit("change",{value:r.detail.date})),{el:n.el,get:()=>n.get(),set:r=>n.set(r,{silent:!0}),focus:()=>n.focus(),setDisabled:r=>r?n.disable():n.enable()}})}var te=class extends _{static cssName="field-upload";static defaults={url:"",paramName:"upload",params:{},headers:{},multiple:!1,accept:null,maxSize:null,autoUpload:!0,preview:!0,http:null};render(){let t=this.el??a("div");this.el=t,this._ownedNodes=[],this._files=[],this._disabled=!1,this._running=!1,this._runId=0,this._xhr=null,this._transportController=null,this._previewUrl=null,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled");let e=y("zx-upload");return this._input=a("input",{class:"zx-field-upload__input",id:e,type:"file",multiple:!!this.options.multiple,accept:this.options.accept??void 0,tabIndex:-1}),this._dropzone=a("button",{class:"zx-field-upload__dropzone",type:"button",ariaControls:e,ariaLabel:this.options.multiple?"Choose files or drop them here":"Choose a file or drop it here"},a("span",{class:"zx-field-upload__prompt"},this.options.multiple?"Drop files here or choose files":"Drop a file here or choose a file"),a("span",{class:"zx-field-upload__hint"},xc(this.options))),this._preview=a("div",{class:"zx-field-upload__preview"}),this._progress=a("progress",{class:"zx-field-upload__progress",max:100,value:0,ariaLabel:"Upload progress"}),this._progressText=a("span",{class:"zx-field-upload__progress-text"},"0%"),this._abort=a("button",{class:"zx-btn zx-field-upload__abort",type:"button"},"Abort"),this._progressWrap=a("div",{class:"zx-field-upload__progress-wrap",hidden:!0},this._progress,this._progressText,this._abort),this._status=a("div",{class:"zx-field-upload__status",role:"status",ariaLive:"polite"}),this._ownedNodes.push(this._input,this._dropzone,this._preview,this._progressWrap,this._status),t.append(...this._ownedNodes),this.listen(this._dropzone,"click",()=>{!this._disabled&&!this._running&&this._input.click()}),this.listen(this._input,"change",()=>this._selectFiles(this._input.files)),this.listen(this._dropzone,"dragenter",s=>this._handleDragOver(s)),this.listen(this._dropzone,"dragover",s=>this._handleDragOver(s)),this.listen(this._dropzone,"dragleave",s=>{(!(s.relatedTarget instanceof Node)||!this._dropzone.contains(s.relatedTarget))&&this._setState("idle")}),this.listen(this._dropzone,"drop",s=>{s.preventDefault(),!(this._disabled||this._running)&&(this._setState("idle"),this._selectFiles(s.dataTransfer?.files??[]))}),this.listen(this._abort,"click",()=>this.abort()),this.setDisabled(!1),t}async upload(t=null){if(t!==null&&!this._setFiles(t)||this._disabled||this._running||this._files.length===0)return null;this._running=!0,this._runId+=1;let e=this._runId;this._setState("uploading"),this._progressWrap.hidden=!1,this._abort.hidden=!1,this._setProgress(0),this._status.textContent="Uploading\u2026";try{let s=this.options.http?await this._uploadInjected():await this._uploadXhr();return e!==this._runId?null:(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setProgress(100),this._setState("success"),this._status.textContent="Upload complete.",this.emit("success",{response:s}),s)}catch(s){if(e!==this._runId)return null;let n=s instanceof Error?s:new Error(String(s));return n.name==="AbortError"?(this._finishAbort(),null):(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("error"),this._status.textContent=n.message,this.emit("error",{error:n}),null)}}abort(){return this._running?(this._xhr?.abort(),this._transportController?.abort(),this._finishAbort(),this):this}clear(){return this._running&&this.abort(),this._files=[],this._input.value="",this._revokePreview(),this._preview.replaceChildren(),this._progress.value=0,this._progressText.textContent="0%",this._progressWrap.hidden=!0,this._status.textContent="",this._setState("idle"),this}setDisabled(t){return this._disabled=!!t,this._input.disabled=this._disabled,this._dropzone.disabled=this._disabled,this.el.dataset.disabled=String(this._disabled),this}_selectFiles(t){this._setFiles(t)&&(this._input.value="",this.options.autoUpload&&this.upload())}_setFiles(t){if(this._disabled||this._running)return!1;let e=Array.from(t??[]),s=this.options.multiple?e:e.slice(0,1);if(s.length===0)return!1;let n=s.find(o=>!wc(o,this.options.accept));if(n)return this._selectionError(new Error(`${n.name} is not an accepted file type.`)),!1;let r=this.options.maxSize==null?null:s.find(o=>o.size>Number(this.options.maxSize));return r?(this._selectionError(new Error(`${r.name} exceeds the maximum file size.`)),!1):(this._files=s,this._renderPreview(),this._status.textContent=s.map(o=>o.name).join(", "),this._setState("selected"),this.emit("select",{files:this._files.slice()}),!0)}_handleDragOver(t){t.preventDefault(),!this._disabled&&!this._running&&this._setState("dragover")}_uploadInjected(){let t=this.options.http;this._transportController=new AbortController;let e={files:this._files.slice(),paramName:String(this.options.paramName),params:{...this.options.params},headers:{...this.options.headers},signal:this._transportController.signal,onProgress:s=>this._setProgress(s)};return typeof t.upload=="function"?t.upload(String(this.options.url),e):typeof t.request=="function"?t.request(String(this.options.url),{method:"POST",data:e.params,files:e.files,headers:e.headers,signal:e.signal,onProgress:e.onProgress,paramName:e.paramName}):Promise.reject(new TypeError("Injected upload transport requires upload() or request()"))}_uploadXhr(){return typeof XMLHttpRequest!="function"?Promise.reject(new Error("XMLHttpRequest is not available")):new Promise((t,e)=>{let s=new XMLHttpRequest;this._xhr=s,s.open("POST",String(this.options.url));for(let[n,r]of Object.entries(this.options.headers??{}))s.setRequestHeader(n,String(r));this.listen(s.upload,"progress",n=>{n.lengthComputable&&this._setProgress(n.loaded/n.total*100)}),this.listen(s,"load",()=>{if(s.status<200||s.status>=300){e(new Error(`Upload failed with HTTP ${s.status}`));return}t(Sc(s.responseText))}),this.listen(s,"error",()=>e(new Error("Upload request failed"))),this.listen(s,"abort",()=>e(kc())),s.send(Ac(this._files,String(this.options.paramName),this.options.params))})}_setProgress(t){let e=Math.max(0,Math.min(100,Number(t)||0));this._progress.value=e,this._progressText.textContent=`${Math.round(e)}%`,this.emit("progress",{percent:e})}_finishAbort(){this._running&&(this._runId+=1,this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("idle"),this._status.textContent="Upload aborted.",this.emit("abort",{}))}_selectionError(t){this._setState("error"),this._status.textContent=t.message,this.emit("error",{error:t})}_renderPreview(){this._revokePreview(),this._preview.replaceChildren();let t=this._files[0];!this.options.preview||!t?.type?.startsWith("image/")||typeof URL>"u"||typeof URL.createObjectURL!="function"||(this._previewUrl=URL.createObjectURL(t),this._preview.append(a("img",{class:"zx-field-upload__image",src:this._previewUrl,alt:`Preview of ${t.name}`})))}_revokePreview(){this._previewUrl&&typeof URL<"u"&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(this._previewUrl),this._previewUrl=null}_setState(t){t==="idle"?this.el.removeAttribute("data-state"):this.el.dataset.state=t}destroy(){this._running&&this.abort(),this._revokePreview();for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function xc(i){let t=[];return i.accept&&t.push(String(i.accept)),i.maxSize!=null&&t.push(`up to ${vc(Number(i.maxSize))}`),t.join(" \xB7 ")||"Choose from this device"}function vc(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/1024)} KB`:`${Math.round(i/(1024*1024))} MB`}function wc(i,t){if(!t)return!0;let e=String(i.type??"").toLowerCase();return String(t).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean).some(s=>s.startsWith(".")?i.name.toLowerCase().endsWith(s):s.endsWith("/*")?e.startsWith(s.slice(0,-1)):e===s)}function Ac(i,t,e){let s=new FormData;for(let n of i)s.append(t,n);for(let[n,r]of Object.entries(e??{}))so(s,n,r);return s}function so(i,t,e){if(e==null)return;if(Array.isArray(e)){for(let n of e)so(i,t,n);return}typeof Blob=="function"&&e instanceof Blob?i.append(t,e):i.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function Sc(i){if(!i)return null;try{return JSON.parse(i)}catch{return i}}function kc(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let i=new Error("Upload aborted");return i.name="AbortError",i}function io(){A.register("upload",(i,t)=>{let e=i.own(new te(null,{...t.props??{}}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("select",()=>i.emit("change",{value:null})),{el:e.el,get:()=>null,set:()=>e.clear(),focus:()=>e.el.querySelector(".zx-field-upload__dropzone")?.focus(),setDisabled:s=>e.setDisabled(s)}})}var no=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),ro=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),ee=class extends _{static cssName="multi-value-editor";static defaults={values:[],options:null,addLabel:"Add value",reorder:"both"};render(){let t=this.el??a("div");return this.el=t,this._values=Array.isArray(this.options.values)?this.options.values.map(String):[],this._ownedNodes=[],this._initialState=t.getAttribute("data-state"),this._dragIndex=-1,this._armed=null,this._rows=a("div",{class:"zx-multi-value-editor__rows"}),this._add=a("button",{class:"zx-btn zx-multi-value-editor__add",type:"button",dataset:{action:"add"}},String(this.options.addLabel??"Add value")),this._ownedNodes.push(this._rows,this._add),t.append(this._rows,this._add),this.listen(t,"click",e=>this._handleClick(e)),this.listen(this._rows,"change",e=>this._handleChange(e)),this.listen(this._rows,"keydown",e=>this._handleKeydown(e)),this._reorder().drag&&(this.listen(this._rows,"pointerdown",e=>this._handlePointerDown(e)),this.listen(this._rows,"dragstart",e=>this._handleDragStart(e)),this.listen(this._rows,"dragover",e=>this._handleDragOver(e)),this.listen(this._rows,"dragleave",e=>this._handleDragLeave(e)),this.listen(this._rows,"drop",e=>this._handleDrop(e)),this.listen(this._rows,"dragend",()=>this._finishDrag()),this.listen(document,"pointerup",()=>this._disarm()),this.listen(document,"pointercancel",()=>this._disarm())),this._renderRows(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=Array.isArray(t)?t.map(String):[],this._renderRows(),e||this.emit("change",{values:this.getValues()}),this}_reorder(){return no[this.options.reorder]??no.both}_renderRows(t=-1,e="value"){let s=oo(this.options.options),n=this.options.options!==null,{drag:r,buttons:o}=this._reorder(),l=this._values.length-1,c=this._values.map((h,u)=>{let d=!n||s.some(([p])=>p===h)?s:[[h,h],...s],f=n?a("select",{class:"zx-multi-value-editor__value",ariaLabel:`Value ${u+1}`,dataset:{index:u}},d.map(([p,m])=>a("option",{value:p,selected:p===h},m))):a("input",{class:"zx-multi-value-editor__value",type:"text",value:h,ariaLabel:`Value ${u+1}`,dataset:{index:u}});return a("div",{class:"zx-multi-value-editor__row",dataset:{row:u}},r?a("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:`Reorder value ${u+1}. Use the arrow keys to move it.`,dataset:{action:"grab",index:u}},g("drag",{size:12})):null,f,a("div",{class:"zx-multi-value-editor__controls"},o?a("button",{class:"zx-btn",type:"button",ariaDisabled:String(u===0),ariaLabel:`Move value ${u+1} up`,dataset:{action:"up",index:u}},g("chevron-up",{size:12})):null,o?a("button",{class:"zx-btn",type:"button",ariaDisabled:String(u===l),ariaLabel:`Move value ${u+1} down`,dataset:{action:"down",index:u}},g("chevron-down",{size:12})):null,a("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${u+1}`,dataset:{action:"remove",index:u}},g("x",{size:12}))))});this._rows.replaceChildren(...c),t>=0&&c[Math.min(t,c.length-1)]?.querySelector(ro[e]??ro.value)?.focus()}_handleClick(t){let e=t.target instanceof Element?t.target.closest("[data-action]"):null;if(!e||!this.el.contains(e)||e.getAttribute("aria-disabled")==="true")return;let s=e.dataset.action,n=Number(e.dataset.index);if(s==="add"){let r=oo(this.options.options);this._values.push(this.options.options===null?"":r[0]?.[0]??""),this._renderRows(this._values.length-1),this._emitChange()}else s==="remove"&&Number.isInteger(n)?(this._values.splice(n,1),this._renderRows(Math.min(n,this._values.length-1)),this._emitChange()):(s==="up"||s==="down")&&Number.isInteger(n)&&this._move(n,n+(s==="up"?-1:1),s)}_handleChange(t){let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e||!("value"in e))return;let s=Number(e.dataset.index);!Number.isInteger(s)||s<0||s>=this._values.length||(this._values[s]=e.value,this._emitChange())}_handleKeydown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(!e)return;let s=Number(e.dataset.index),n=t.key==="ArrowUp"?s-1:t.key==="ArrowDown"?s+1:t.key==="Home"?0:t.key==="End"?this._values.length-1:-1;n<0||n>=this._values.length||(t.preventDefault(),this._move(s,n,"handle"))}_handlePointerDown(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__handle"):null;if(this._disarm(),!e||e.disabled)return;let s=e.closest(".zx-multi-value-editor__row");s&&(s.draggable=!0,this._armed=s)}_disarm(){this._armed&&(this._armed.draggable=!1),this._armed=null}_handleDragStart(t){let e=t.target instanceof Element?t.target.closest(".zx-multi-value-editor__row"):null;if(!e||e!==this._armed){t.preventDefault();return}this._dragIndex=Number(e.dataset.row),e.dataset.dragging="true",this.el.setAttribute("data-state","dragging"),t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move")}_handleDragOver(t){this._dragIndex<0||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._showDrop(this._dropTarget(t.clientY)))}_handleDragLeave(t){let e=t.relatedTarget;e instanceof Node&&this._rows.contains(e)||this._clearDrop()}_handleDrop(t){if(this._dragIndex<0)return;t.preventDefault();let e=this._dragIndex,s=this._dropTarget(t.clientY);this._finishDrag(),this._move(e,s>e?s-1:s,"handle")}_finishDrag(){this._dragIndex=-1,this._disarm(),this._clearDrop();for(let t of this._rows.children)delete t.dataset.dragging;this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_dropTarget(t){let e=[...this._rows.children];for(let[s,n]of e.entries()){let r=n.getBoundingClientRect();if(t<r.top+r.height/2)return s}return e.length}_showDrop(t){let e=[...this._rows.children],s=t===this._dragIndex||t===this._dragIndex+1;for(let[n,r]of e.entries()){let o=r;!s&&n===t?o.dataset.drop="before":!s&&t===e.length&&n===e.length-1?o.dataset.drop="after":delete o.dataset.drop}}_clearDrop(){for(let t of this._rows.children)delete t.dataset.drop}_move(t,e,s){let n=this._values.length;if(t===e||t<0||e<0||t>=n||e>=n)return!1;let[r]=this._values.splice(t,1);return this._values.splice(e,0,r),this._renderRows(e,s),this._emitChange(),!0}_emitChange(){this.emit("change",{values:this.getValues()})}destroy(){this._initialState===null?this.el?.removeAttribute("data-state"):this.el?.setAttribute("data-state",this._initialState);for(let t of this._ownedNodes??[])t.remove();super.destroy()}};function oo(i){return Array.isArray(i)?i.map(t=>[String(t),String(t)]):i&&typeof i=="object"?Object.entries(i).map(([t,e])=>[t,String(e)]):[]}function ao(){A.register("multivalueeditor",(i,t)=>{let e=i.own(new ee(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]})),s=new WeakMap,n=!1,r=()=>{e.el.setAttribute("aria-disabled",String(n));for(let o of e.el.querySelectorAll("input, button, select, textarea"))n?(s.has(o)||s.set(o,!!o.disabled),o.disabled=!0):s.has(o)&&(o.disabled=s.get(o),s.delete(o))};return i.listen(e.el,"change",o=>o.stopImmediatePropagation()),e.on("change",o=>i.emit("change",{value:o.detail.values})),{el:e.el,get:()=>e.getValues(),set:o=>{e.setValues(Array.isArray(o)?o:[],{silent:!0}),r()},focus:()=>e.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),setDisabled:o=>{n=!!o,r()}}})}var wt=class extends _{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??a("div");this.el=t;let e=zc(this.options.step);this._step=e,this._precision=this.options.precision===null?Cc(e):Math.max(0,Math.trunc(Number(this.options.precision)||0));let s=this._stepButton("down","minus"),n=this._stepButton("up","plus"),r=a("input",{ref:"input",class:"zx-number-field__input",type:"text",role:"spinbutton",inputMode:this._precision>0?"decimal":"numeric",autocomplete:"off",spellcheck:!1,placeholder:String(this.options.placeholder??""),ariaLabel:this.options.label??void 0,name:this.options.name??void 0,required:!!this.options.required}),o=[s,r];return this.options.unit!==null&&o.push(a("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",l=>this._onKeydown(l)),this.listen(r,"focus",()=>{this._editing=!0,this._syncInput()}),this.listen(r,"blur",()=>{this._commit(),this._editing=!1,this._syncInput()}),this.listen(s,"click",()=>this._stepBy(-1)),this.listen(n,"click",()=>this._stepBy(1)),this.listen(r,"wheel",l=>{document.activeElement!==r||this._disabled||this._readonly||(l.preventDefault(),this._stepBy(l.deltaY<0?1:-1))},{passive:!1}),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=this._coerce(t),n=s!==this._value;return this._value=s,this._syncInput(),n&&!e&&this.emit("change",{value:this._value}),this}stepUp(t=1){return this._stepBy(t)}stepDown(t=1){return this._stepBy(-t)}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}focus(){return this.refs.input.focus(),this}getInput(){return this.refs.input}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}setRange(t,e){return this._min=t==null?null:Number(t),this._max=e==null?null:Number(e),this.set(this._value,{silent:!0})}_stepButton(t,e){return a("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=Ee(t,this.options.group?this._separators():null);return e===null?null:Ie(e,{min:this._rangeMin,max:this._rangeMax,step:this._step,precision:this._precision})}_stepBy(t){if(this._disabled||this._readonly)return this;let e=this._rangeMin,s=this._rangeMax,r=Ee(this.refs.input.value)??this._value,o=r===null?e??0:r,l=r===null&&t>0&&e!==null?e-this._step*t:o,c=lo(l+this._step*t,this._precision);return this.options.wrap&&e!==null&&s!==null&&(c>s?c=e:c<e&&(c=s)),this.set(c),this}_separators(){if(this._localeSeparators)return this._localeSeparators;let t=new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:1}).formatToParts(1234.5);return this._localeSeparators={group:t.find(e=>e.type==="group")?.value??",",decimal:t.find(e=>e.type==="decimal")?.value??"."},this._localeSeparators}_onInput(){let t=Ee(this.refs.input.value,this.options.group?this._separators():null);this._syncAria(t),this.emit("input",{value:t})}_onKeydown(t){if(this._disabled||this._readonly)return;let e=Math.max(1,Math.trunc(Number(this.options.largeStep)||1)),n={ArrowUp:()=>this._stepBy(1),ArrowDown:()=>this._stepBy(-1),PageUp:()=>this._stepBy(e),PageDown:()=>this._stepBy(-e),Home:()=>this._rangeMin===null?null:this.set(this._rangeMin),End:()=>this._rangeMax===null?null:this.set(this._rangeMax),Enter:()=>this._commit()}[t.key];n&&(t.key==="Home"&&this._rangeMin===null||t.key==="End"&&this._rangeMax===null||(t.preventDefault(),n()))}_commit(){this.set(this.refs.input.value)}_syncInput(){let t=this.refs.input,e=this._value===null?"":this._format(this._value,this._editing);t.value!==e&&(t.value=e),this._syncAria(this._value)}_syncAria(t){let e=this.refs.input,s=this._rangeMin,n=this._rangeMax;if(s===null?e.removeAttribute("aria-valuemin"):e.setAttribute("aria-valuemin",String(s)),n===null?e.removeAttribute("aria-valuemax"):e.setAttribute("aria-valuemax",String(n)),t===null)e.removeAttribute("aria-valuenow"),e.setAttribute("aria-valuetext",this._message("numberField.empty","Empty"));else{e.setAttribute("aria-valuenow",String(t));let r=this.options.unit===null?"":` ${this.options.unit}`;e.setAttribute("aria-valuetext",`${this._format(t,!1)}${r}`)}this.el.toggleAttribute("data-empty",t===null)}_format(t,e){return this.options.group?new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:this._precision,maximumFractionDigits:this._precision,useGrouping:!e}).format(t):t.toFixed(this._precision)}_message(t,e){let s=this.msg(t);return s===t?e:s}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.up.disabled=this._disabled||this._readonly,this.refs.down.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function Ee(i,t=null){if(typeof i=="number")return Number.isFinite(i)?i:null;if(i==null)return null;let e=String(i).trim();if(e==="")return null;let s;if(t)s=e.split(t.group).join("").replace(t.decimal,".").replace(/[^\d.\-+eE]/g,"");else{let r=e.replace(/[^\d,.\-+eE]/g,""),o=r.lastIndexOf(","),l=r.lastIndexOf(".");s=r,o>=0&&o>l?s=r.replace(/\./g,"").replace(",","."):o>=0&&(s=r.replace(/,/g,""))}if(!/\d/.test(s))return null;let n=Number(s);return Number.isFinite(n)?n:null}function Ie(i,{min:t,max:e,step:s,precision:n}){let r=i;if(s>0){let o=t??0;r=o+Math.round((i-o)/s)*s}return r=lo(r,n),t!==null&&r<t?t:e!==null&&r>e?e:r}function zc(i){let t=Number(i);return Number.isFinite(t)&&t>0?t:1}function Cc(i){let t=String(i),e=t.match(/e-(\d+)/i);if(e)return Number(e[1]);let s=t.split(".")[1];return s?s.length:0}function lo(i,t){return Number.isFinite(i)?Number(i.toFixed(Math.min(15,Math.max(0,t)))):i}function co(){A.register("number",(i,t)=>{let e=i.own(new wt(null,{label:t.label?String(t.label):void 0,placeholder:t.placeholder,required:t.required,...t.props??{}})),s=!1;return i.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get(),set:n=>{s=!0;try{e.set(n===""||n===null||n===void 0?null:n,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var se=class extends _{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??a("div");this.el=t,this._max=Math.max(1,Math.trunc(Number(this.options.max)||5)),this._step=this.options.allowHalf?.5:1,this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this._name=y("zx-rating");let e=a("div",{ref:"symbols",class:"zx-rating__symbols",role:"radiogroup",ariaLabel:String(this.options.label??"Rating")});for(let s=1;s<=this._max;s+=1){let n=a("span",{class:"zx-rating__symbol"},a("span",{class:"zx-rating__glyph",ariaHidden:"true"},g(this.options.icon,{size:De[this.options.size]??De.md})),a("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},g(this.options.icon,{size:De[this.options.size]??De.md})));this.options.allowHalf?n.append(this._radio(s-.5,"half"),this._radio(s,"full")):n.append(this._radio(s,"full")),e.append(n)}return t.replaceChildren(e,a("span",{ref:"readout",class:"zx-rating__readout"})),t.dataset.size=De[this.options.size]?this.options.size:"md",this.listen(e,"keydown",s=>this._onKeydown(s)),this.listen(e,"pointerleave",()=>this._setPreview(null)),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=this._clamp(t),n=s!==this._value;return this._value=s,this._preview=null,this._sync(),n&&!e&&this.emit("change",{value:this._value}),this}clear({silent:t=!1}={}){return this.set(0,{silent:t})}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}setCount(t){return this._count=t,this._syncReadout(),this}focus(){return(this._radios.find(e=>e.tabIndex===0)??this._radios[0])?.focus(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}_radio(t,e){let s=a("button",{class:"zx-rating__radio",type:"button",role:"radio",tabIndex:-1,ariaChecked:"false",ariaLabel:this._stepLabel(t),dataset:{value:String(t),part:e}});return this.listen(s,"click",n=>{this._choose(t,n.detail>0)}),this.listen(s,"pointerenter",()=>this._setPreview(t)),this.listen(s,"focus",()=>this._setPreview(t)),this.listen(s,"blur",()=>this._setPreview(null)),this._radios.push(s),s}_stepLabel(t){let e=this.options.labels;if(Array.isArray(e)){let s=Math.round(t/this._step)-1;if(e[s]!=null)return String(e[s])}return this._message("rating.value","%1 of %2",[t,this._max])}_message(t,e,s){let n=this.msg(t,...s);return n===t?R(e,s):n}_choose(t,e){this._disabled||this._readonly||(e&&this.options.clearable&&t===this._value?this.set(0):this.set(t))}_onKeydown(t){if(this._disabled||this._readonly)return;let e=["ArrowRight","ArrowDown"],s=["ArrowLeft","ArrowUp"];if(e.includes(t.key))t.preventDefault(),this.set(this._value>=this._max?this._step:(this._value||0)+this._step);else if(s.includes(t.key))t.preventDefault(),this.set(this._value<=this._step?this._max:this._value-this._step);else if(t.key==="Home")t.preventDefault(),this.set(this._step);else if(t.key==="End")t.preventDefault(),this.set(this._max);else if((t.key==="Delete"||t.key==="Backspace")&&this.options.clearable)t.preventDefault(),this.set(0);else return;this.focus()}_setPreview(t){let e=this._disabled||this._readonly?null:t;e!==this._preview&&(this._preview=e,this._paint(),this.emit("hover",{value:this._preview}))}_clamp(t){let e=Number(t);if(!Number.isFinite(e)||e<=0)return 0;let s=Math.round(e/this._step)*this._step;return Math.min(this._max,Math.max(0,s))}_sync(){for(let e of this._radios){let s=Number(e.dataset.value);e.setAttribute("aria-checked",String(s===this._value))}let t=this._radios.find(e=>e.getAttribute("aria-checked")==="true");for(let e of this._radios)e.tabIndex=-1;(t??this._radios[0]).tabIndex=0,this._paint(),this._syncReadout()}_paint(){let t=this._preview??this._value;this.refs.symbols.querySelectorAll(".zx-rating__symbol").forEach((s,n)=>{let r=Math.min(1,Math.max(0,t-n));s.style.setProperty("--zx-rating-fill",`${r*100}%`),s.toggleAttribute("data-preview",this._preview!==null)}),this.el.dataset.value=String(t)}_syncReadout(){let t=this.refs.readout;if(!t)return;let e=this._count===void 0?this.options.count:this._count,s=[];this.options.showValue&&s.push(Tc(this._value,this._step)),e!=null&&s.push(this._message("rating.count","%1 ratings",[e])),t.textContent=s.join(" \xB7 ")}_syncDisabled(){let t=this._disabled||this._readonly;for(let e of this._radios)e.disabled=this._disabled;this.refs.symbols.setAttribute("aria-readonly",String(this._readonly)),this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this.el.toggleAttribute("data-inert",t),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}},De={sm:14,md:18,lg:24};function Tc(i,t){return t<1?i.toFixed(1):String(i)}function ho(){A.register("rating",(i,t)=>{let e=i.own(new se(null,{label:t.label?String(t.label):void 0,...t.props??{}})),s=!1;return e.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get()||null,set:n=>{s=!0;try{e.set(Number(n)||0,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var Ec=["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 hs(i){let t=!1,e=null;function s(n){if(n.key!=="Tab")return;let r=uo(i);if(r.length===0){n.preventDefault();return}let o=r[0],l=r[r.length-1];n.shiftKey&&(document.activeElement===o||!i.contains(document.activeElement))?(n.preventDefault(),l.focus()):!n.shiftKey&&(document.activeElement===l||!i.contains(document.activeElement))&&(n.preventDefault(),o.focus())}return{activate(){t||(t=!0,e=document.activeElement,document.addEventListener("keydown",s),uo(i)[0]?.focus())},deactivate(){t&&(t=!1,document.removeEventListener("keydown",s),e?.isConnected&&typeof e.focus=="function"&&e.focus(),e=null)}}}function ct(i,t,{orientation:e="vertical",wrap:s=!0}={}){let n=new AbortController,r=new Map,o=!1;function l(){return Array.from(i.querySelectorAll(t)).filter(p=>(c(p),po(p)))}function c(p){r.has(p)||r.set(p,p.getAttribute("tabindex"))}function h(p=null){let m=l(),b=p&&m.includes(p)?p:m.find(w=>w.tabIndex===0)??m[0];for(let w of m){let x=w===b?0:-1;w.tabIndex!==x&&(w.tabIndex=x)}}function u(p){let m=l(),b=p.target?.closest?.(t)??null,w=m.indexOf(b);if(w<0)return;let x=e==="horizontal"?"ArrowLeft":"ArrowUp",v=e==="horizontal"?"ArrowRight":"ArrowDown",C=null;p.key==="Home"?C=0:p.key==="End"?C=m.length-1:p.key===x?C=w-1:p.key===v&&(C=w+1),!(C===null||m.length===0)&&(s?C=(C+m.length)%m.length:C=Math.max(0,Math.min(m.length-1,C)),p.preventDefault(),h(m[C]),m[C].focus())}function d(p){let m=p.target?.closest?.(t)??null;m&&i.contains(m)&&h(m)}i.addEventListener("keydown",u,{signal:n.signal}),i.addEventListener("focusin",d,{signal:n.signal});let f=typeof MutationObserver=="function"?new MutationObserver(()=>h()):null;return f?.observe(i,{childList:!0,subtree:!0,attributes:!0}),h(),{focusFirst(){let p=l()[0];p&&(h(p),p.focus())},focusLast(){let p=l(),m=p[p.length-1];m&&(h(m),m.focus())},destroy(){if(!o){o=!0,n.abort(),f?.disconnect();for(let[p,m]of r)m===null?p.removeAttribute("tabindex"):p.setAttribute("tabindex",m);r.clear()}}}}function Q(i,t){let e="",s=null;return function(r){let o=typeof r=="string"?r:r.key;if(typeof r!="string"&&(r.ctrlKey||r.metaKey||r.altKey)||!o||o.length!==1||/\s/.test(o))return;s!==null&&clearTimeout(s),e+=o.toLocaleLowerCase(),e.split("").every(h=>h===e[0])&&(e=e[0]),s=setTimeout(()=>{e="",s=null},500);let l=i(),c=l.findIndex(h=>Ic(h).startsWith(e));c>=0&&t(l[c],c)}}function uo(i){return Array.from(i.querySelectorAll(Ec)).filter(t=>po(t)&&t.getClientRects().length>0)}function po(i){return!(!(i instanceof HTMLElement)||i.hidden||i.getAttribute("aria-hidden")==="true"||i.matches(":disabled"))}function Ic(i){if(typeof i=="string"||typeof i=="number")return String(i).trim().toLocaleLowerCase();if(i&&typeof i=="object"&&"textContent"in i)return String(i.textContent??"").trim().toLocaleLowerCase();if(i&&typeof i=="object"){let t=i,e=t.label??t.text??t.value;if(e!=null)return String(e).trim().toLocaleLowerCase()}return String(i??"").trim().toLocaleLowerCase()}var Dc=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],fo=["Lowest","Low","Medium","High","Highest"],Nc=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"]]),V=class i extends _{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??a("div");this.el=t,this._root=t,this._snapshot=this._createdRoot?null:k(t);let e=y("zx-select-list"),s=a("input",{ref:"input",class:"zx-select__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:this.options.filter?"list":"none",placeholder:String(this.options.placeholder??""),readOnly:!this.options.filter}),n=a("span",{ref:"valueAdornment",class:"zx-select__value-adornment",ariaHidden:"true",hidden:!0}),r=a("button",{ref:"clear",class:"zx-icon-btn zx-select__clear",type:"button",tabIndex:-1,ariaLabel:this._message("select.clear","Clear selection"),hidden:!0},g("x",{size:13})),o=a("span",{ref:"loading",class:"zx-select__loading",role:"status",ariaLabel:this._message("select.loading","Loading"),hidden:!0}),l=a("button",{ref:"toggle",class:"zx-select__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("select.toggle","Toggle options")},g("chevron-down",{size:16})),c=a("div",{ref:"control",class:"zx-select__control"},n,s,r,o,l),h=a("div",{ref:"list",class:"zx-select__list",id:e,role:"listbox"});h.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let u=a("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},h);return t.replaceChildren(c,u),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visibleItems=this._items.slice(),this._fixedItems=Array.isArray(this.options.fixedItems)?this.options.fixedItems.slice():[],this._visibleFixed=this._fixedItems.slice(),this._actions=_o(this.options.actions),this._disabled=!!this.options.disabled,this._handleTypeahead=Q(()=>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(s,"click",()=>this.open()),this.listen(s,"input",()=>this._onInput()),this.listen(s,"keydown",d=>this._onKeydown(d)),this.listen(l,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(r,"click",()=>{this.set(null),this.focus()}),this.listen(u,"pointerdown",d=>d.preventDefault()),this.listen(u,"click",d=>this._onOptionClick(d)),this.listen(document,"pointerdown",d=>{this._open&&!t.contains(d.target)&&this.close()},{capture:!0}),this._renderOptions(),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._selected===null?null:this._itemValue(this._selected)}set value(t){this.set(t)}get selected(){return this._selected}set(t,{silent:e=!1}={}){let s=this.value,n=t==null?null:this._findItem(t);this._selected=n,this._syncInputValue(),this._renderOptions();let r=this.value;return!e&&!Object.is(s,r)&&this.emit("change",{value:r,item:n}),this}setItems(t){let e=this.value;return this._items=Array.isArray(t)?t.slice():[],this._visibleItems=this._items.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setFixedItems(t){let e=this.value;return this._fixedItems=Array.isArray(t)?t.slice():[],this._visibleFixed=this._fixedItems.slice(),this._selected=e==null?null:this._findItem(e),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setActions(t){return this._actions=_o(t),this._renderOptions(),this._position?.update(),this}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t}),this}open(){return this._disabled||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=U(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._selectedEntryIndex()),this._activeIndex<0&&this._optionEntries.length>0&&this._setActive(0),this.options.filter&&this._selected!==null&&this.refs.input.select(),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(""),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._setLoading(!1),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._visibleItems=this._items.slice(),this._visibleFixed=this._fixedItems.slice(),this._syncInputValue(),this.emit("close",{}),this):this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}static priority(t,e={}){let s=e.value??null,n=new i(t,{...e,value:null,items:[],renderItem(r){return Fc(r,!0)},renderValueAdornment(r){return go(r.level)}});return n.setItems(Dc.map((r,o)=>{let l=o===2?n.msg("priority.medium"):r;return(l==="priority.medium"||o!==2)&&(l=n._message(r,fo[o])),{ID:o,name:l,level:o}})),n.set(s,{silent:!0}),n}static status(t,e={}){let{items:s=null,value:n=null,...r}=e,o=new i(t,{...r,value:null,items:[],renderItem(c){return Rc(c)},renderValueAdornment(c){return bo(c)}}),l=Array.isArray(s)?s.map(Lc).filter(Boolean):Nc.map(([c,h,u,d,f],p)=>({ID:c,name:o._message(h,u),indicator:d,tone:f,shortcut:String(p+1)}));return o.setItems(l),o.set(n,{silent:!0}),o}static entity(t,e={}){let{recent:s=[],recentLabel:n="Recent",create:r=!1,iconKey:o="icon",colorKey:l="color",subtitleKey:c="description",renderIcon:h=null,fixedItems:u=[],actions:d=[],renderItem:f=null,renderValueAdornment:p=null,...m}=e,b=(v,C=!1)=>{if(typeof h=="function")return h(v,{selected:C});let I=us(v,o);if(I&&typeof I=="object"&&typeof I.nodeType=="number")return I.cloneNode(!0);if(typeof I!="string"||!I)return null;let O=us(v,l);return a("span",{class:"zx-select__entity-glyph",style:jt(O)?{"--zx-select-entity-color":String(O)}:null,ariaHidden:"true"},g(I,{size:14}))},w=r?Mc(r):null,x=new i(t,{...m,fixedItems:[...Array.isArray(s)?s:[],...Array.isArray(u)?u:[]],fixedLabel:Array.isArray(s)&&s.length?n:m.fixedLabel??null,actions:[...Array.isArray(d)?d:[],...w?[w]:[]],renderItem:f??(v=>{let C=b(v,!1),I=us(v,c),O=a("span",{class:"zx-select__entity-copy"},a("span",{class:"zx-select__entity-label"},String(us(v,m.labelKey??"name")??"")),I==null||I===""?null:a("span",{class:"zx-select__entity-subtitle"},String(I)));return a("span",{class:"zx-select__entity"},C?a("span",{class:"zx-select__entity-icon",ariaHidden:"true"},C):null,O)}),renderValueAdornment:p??(v=>b(v,!0))});return x.el.dataset.preset="entity",x}static permission(t,e={}){let{groups:s=[],value:n=!0,valueKey:r="ID",labelKey:o="name",filter:l="local",...c}=e,h=typeof s=="function"?s:null,u=h?[]:s,d=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],f=new i(t,{filter:h??l,...c,value:null,items:u,fixedItems:[],valueKey:p=>d.includes(p)?p.ID:en(p,r),labelKey:p=>d.includes(p)?p.name:String(en(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&&mo(t)){let e=this._optionEntries.findIndex(s=>!s.clear&&!s.action&&String(s.item?.shortcut??"")===t.key);if(e>=0){t.preventDefault(),this._setActive(e),this._chooseEntry(this._optionEntries[e]);return}}if(t.key==="ArrowDown"){t.preventDefault(),this._open?this._moveActive(1):this.open();return}if(t.key==="ArrowUp"){t.preventDefault(),this._open?this._moveActive(-1):(this.open(),this._setActive(this._optionEntries.length-1));return}if(t.key==="Home"&&this._open){t.preventDefault(),this._setActive(0);return}if(t.key==="End"&&this._open){t.preventDefault(),this._setActive(this._optionEntries.length-1);return}if(t.key==="Enter"&&this._open){t.preventDefault(),this._chooseEntry(this._optionEntries[this._activeIndex]);return}if(t.key==="Escape"&&this._open){t.preventDefault(),this.close();return}if(t.key==="Tab"&&this._open){this.close();return}!this.options.filter&&mo(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=yt(this._items,t,this._searchKeys()),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update()):typeof this.options.filter=="function"&&this._scheduleAsyncQuery(t)}_onOptionClick(t){let e=t.target?.closest?.('[role="option"]');!e||!this.refs.panel.contains(e)||this._chooseEntry(this._optionEntries[Number(e.getAttribute("data-index"))])}_chooseEntry(t){if(t){if(t.action){let e={id:t.action.id,action:t.action,query:this.refs.input.value,select:this};this.emit("action",e).defaultPrevented||t.action.invoke?.(e),this.close(),this.focus();return}this.set(t.clear?null:t.item),this.close(),this.focus()}}_moveActive(t){let e=this._optionEntries.length;e!==0&&this._setActive((this._activeIndex+t+e)%e)}_setActive(t){this._activeIndex=t>=0&&t<this._optionEntries.length?t:-1,this._optionEntries.forEach((s,n)=>{n===this._activeIndex?s.element.setAttribute("data-active","true"):s.element.removeAttribute("data-active")});let e=this._optionEntries[this._activeIndex]?.element;e?(this.refs.input.setAttribute("aria-activedescendant",e.id),e.scrollIntoView?.({block:"nearest"})):this.refs.input.removeAttribute("aria-activedescendant")}_renderOptions(){let t=this.refs.list;if(!t)return;t.replaceChildren(),this._optionEntries=[];let e=Symbol("initial-group"),s=this._uniqueItems(this._visibleFixed),n=this._uniqueItems(this._visibleItems,s);this.options.clearable&&this._appendOption(null,!0,this.options.noneLabel??this._message("select.none","No selection")),s.length>0&&this.options.fixedLabel&&t.append(a("div",{class:"zx-select__group",role:"presentation"},String(this.options.fixedLabel)));for(let r of s)this._appendOption(r,!1);s.length>0&&n.length>0&&!this.options.groupKey&&t.append(a("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(a("div",{class:"zx-select__group",role:"presentation"},String(o??""))),e=o)}this._appendOption(r,!1)}if(this._actions.length>0){(s.length>0||n.length>0||this.options.clearable)&&t.append(a("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(a("div",{class:"zx-select__group",role:"presentation"},o.group)),r=o.group),this._appendAction(o)}n.length===0&&s.length===0&&this._actions.length===0&&!this._loading&&t.append(a("div",{class:"zx-select__empty",role:"status"},this._message("select.empty","No matches"))),this._setActive(-1)}_appendOption(t,e,s){let 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"?tn(this.options.renderNone(String(s??""))):e?String(s??""):this._renderItem(t),l=a("div",{class:"zx-select__option",id:y("zx-select-option"),role:"option",ariaSelected:String(n),dataset:{index:r}},a("span",{class:"zx-select__option-content"},o));n&&l.append(g("check",{size:15})),this.refs.list.append(l),this._optionEntries.push({item:t,clear:e,action:null,element:l})}_appendAction(t){let e=this._optionEntries.length,s=Oc(t.icon),n=a("div",{class:"zx-select__option zx-select__action",id:y("zx-select-option"),role:"option",ariaSelected:"false",dataset:{index:e,kind:"action"}},a("span",{class:"zx-select__option-content zx-select__action-content"},s?a("span",{class:"zx-select__action-icon",ariaHidden:"true"},s):null,a("span",{class:"zx-select__action-copy"},a("span",{class:"zx-select__action-label"},t.label),t.description?a("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 tn(e)}return this._itemLabel(t)}_scheduleAsyncQuery(t){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._requestSequence+=1;let e=this._requestSequence;if(this._visibleFixed=this._matchFixed(t),t.length<Math.max(0,Number(this.options.minQuery)||0)){this._setLoading(!1),this._visibleItems=[],this._renderOptions();return}this._setLoading(!0),this._renderOptions(),this._position?.update();let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runAsyncQuery(t,e)},s)}async _runAsyncQuery(t,e){if(!(e!==this._requestSequence||typeof this.options.filter!="function")){this.emit("query",{query:t});try{let s=await this.options.filter(t);if(e!==this._requestSequence||!this._open)return;this._items=Array.isArray(s)?s.slice():[],this._visibleItems=this._items.slice(),this._setLoading(!1),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update(),this.emit("loaded",{items:this._items.slice()})}catch{if(e!==this._requestSequence||!this._open)return;this._items=[],this._visibleItems=[],this._setLoading(!1),this._renderOptions(),this._position?.update()}}}_cancelQuery(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._requestSequence+=1}_setLoading(t){this._loading=t,this.refs.loading.hidden=!t,this.refs.input.setAttribute("aria-busy",String(t)),this.refs.list.setAttribute("aria-busy",String(t)),t?this._root?.setAttribute("data-loading","true"):this._root?.removeAttribute("data-loading")}_syncInputValue(){if(!this.refs.input)return;let t=this.refs.input;t.value=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),this._syncValueAdornment(),this.refs.clear.hidden=!this.options.clearable||this._selected===null}_syncValueAdornment(){let t=this.refs.valueAdornment;if(!t)return;let e=this._selected===null?"":typeof this.options.renderValue=="function"?String(this.options.renderValue(this._selected)??""):this._itemLabel(this._selected),s=String(this.refs.input?.value??"");if(this._selected===null||typeof this.options.renderValueAdornment!="function"||this.options.filter&&s!==e){t.replaceChildren(),t.hidden=!0;return}let n=this.options.renderValueAdornment(this._selected),r=tn(n);t.replaceChildren(r instanceof Node?r:document.createTextNode(r)),t.hidden=n==null||typeof r=="string"&&r===""}_syncDisabled(){let t=this.refs.input,e=this.refs.clear,s=this.refs.toggle;t.disabled=this._disabled,e.disabled=this._disabled,s.disabled=this._disabled,this._root?.setAttribute("aria-disabled",String(this._disabled))}_findItem(t){let e=this._fixedItems.length===0?this._items:[...this._fixedItems,...this._items],s=e.find(r=>r===t);if(s!==void 0)return s;let n=t!==null&&typeof t=="object"?this._itemValue(t):t;return e.find(r=>Object.is(this._itemValue(r),n))??null}_itemValue(t){return this._read(t,this.options.valueKey)}_itemLabel(t){let e=this._read(t,this.options.labelKey);return String(e??"")}_read(t,e){return en(t,e)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(t){return yt(this._fixedItems,t,this._searchKeys())}_uniqueItems(t,e=[]){let s=e.map(n=>this._itemValue(n));return t.filter(n=>{let r=this._itemValue(n);return s.some(o=>Object.is(o,r))?!1:(s.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 s=this.msg(t);return s===t?e:s}};function us(i,t){return typeof t=="function"?t(i):i!==null&&typeof i=="object"&&typeof t=="string"?i[t]:null}function Mc(i){let t=i===!0?{}:i;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 tn(i){return i&&typeof i=="object"&&"nodeType"in i?i:String(i??"")}function _o(i){return Array.isArray(i)?i.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>({...t,label:String(t.label),description:t.description==null?void 0:String(t.description),group:t.group==null?void 0:String(t.group)})):[]}function Oc(i){return typeof i=="string"?g(i):i instanceof Node?i.cloneNode(!0):null}function Fc(i,t){return a("span",{class:"zx-select__priority"},go(i.level),t?a("span",{},String(i.name)):null)}function go(i){let t=Math.max(0,Math.min(4,Math.trunc(Number(i)||0)));return a("span",{class:"zx-select__priority-icon",dataset:{level:t},ariaHidden:"true"},Array.from({length:5},(e,s)=>a("span",{dataset:{filled:String(s<=t)}})))}function Lc(i){if(!i||typeof i!="object"||i.ID==null||i.name==null)return null;let t=["dotted","ring","progress","review","ready","waiting","done","canceled","duplicate"],e=["muted","neutral","warning","info","accent","success","danger"];return{...i,name:String(i.name),indicator:t.includes(String(i.indicator))?String(i.indicator):"ring",tone:e.includes(String(i.tone))?String(i.tone):"muted",description:i.description==null?"":String(i.description),shortcut:i.shortcut==null?"":String(i.shortcut)}}function Rc(i){return a("span",{class:"zx-select__status"},bo(i),a("span",{class:"zx-select__status-copy"},a("span",{class:"zx-select__status-label"},String(i.name)),i.description?a("span",{class:"zx-select__status-description"},i.description):null),i.shortcut?a("kbd",{class:"zx-select__status-shortcut"},i.shortcut):null)}function bo(i){let t=String(i.indicator??"ring"),e=a("span",{class:"zx-select__status-indicator",dataset:{indicator:t,tone:String(i.tone??"muted")},ariaHidden:"true"});return t==="done"&&e.append(g("check",{size:8})),t==="canceled"&&e.append(g("x",{size:7})),e}function en(i,t){return typeof t=="function"?t(i):i===null||typeof i!="object"?i:i[t]}function mo(i){return i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey}function yo(){A.register("zxselect",(i,t)=>{let e=t.props??{},s=e.preset,n={...e,value:t.value};delete n.preset;let r=i.own(s==="priority"?V.priority(null,n):s==="status"?V.status(null,n):new V(null,n));return i.listen(r.el,"change",o=>o.stopImmediatePropagation()),r.on("change",o=>i.emit("change",{value:o.detail.value})),{el:r.el,get:()=>r.value,set:o=>r.set(o,{silent:!0}),focus:()=>r.focus(),setDisabled:o=>o?r.disable():r.enable()}})}var ie=class extends _{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??a("div");this.el=t,this._min=Number(this.options.min)||0,this._max=Number(this.options.max),(!Number.isFinite(this._max)||this._max<=this._min)&&(this._max=this._min+100),this._step=Math.abs(Number(this.options.step))||1,this._id=y("zx-slider");let e=a("input",{ref:"input",class:"zx-slider__input",type:"range",id:this._id,min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled}),s=a("div",{class:"zx-slider__track"},e,this._marks()),n=a("div",{class:"zx-slider__control"});return this.options.showBounds&&n.append(a("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._min))),n.append(s),this.options.showBounds&&n.append(a("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._max))),this.options.showInput&&n.append(this._numberBox()),t.replaceChildren(a("div",{class:"zx-slider__head"},a("label",{ref:"label",class:"zx-slider__label",for:this._id},String(this.options.label??"")),a("span",{ref:"output",class:"zx-slider__value",ariaHidden:"true"})),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&&qc.has(r.key)&&r.preventDefault()}),this.set(this.options.value,{silent:!0}),this._syncState(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=this._snap(t),n=s!==this._value;return this._value=s,this._paint(),n&&!e&&this.emit("change",{value:s}),this}setRange(t,e,s){let n=Number(t),r=Number(e);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)throw new RangeError("Slider range requires min < max");this._min=n,this._max=r,s!==void 0&&(this._step=Math.abs(Number(s))||1);let{input:o}=this.refs;o.min=String(this._min),o.max=String(this._max),o.step=String(this._step);for(let[l,c]of[...this.el.querySelectorAll(".zx-slider__bound")].entries())c.textContent=this._format(l===0?this._min:this._max);return this.set(this._value,{silent:!0})}focus(){return this.refs.input.focus(),this}enable(){return this.refs.input.disabled=!1,this.refs.number&&(this.refs.number.disabled=!1),this._syncState(),this}disable(){return this.refs.input.disabled=!0,this.refs.number&&(this.refs.number.disabled=!0),this._syncState(),this}setReadonly(t){return this._readonly=!!t,this.refs.number&&(this.refs.number.readOnly=this._readonly),this._syncState(),this}setLabel(t){return this.refs.label.textContent=String(t??""),this}_numberBox(){let t=a("input",{ref:"number",class:"zx-slider__number",type:"number",min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled,readOnly:this._readonly,ariaLabel:String(this.options.label??"Value")});return this.listen(t,"input",()=>{if(this._readonly)return;let e=Number(t.value);t.value===""||!Number.isFinite(e)||(this._value=this._snap(e),this.refs.input.value=String(this._value),this._paintTrack(),this.emit("input",{value:this._value}))}),this.listen(t,"change",()=>{if(this._readonly){t.value=String(this._value);return}this.set(t.value===""?this._min:Number(t.value))}),t}_marks(){let t=this.options.marks;if(!Array.isArray(t)||t.length===0)return null;let e=a("div",{class:"zx-slider__marks",ariaHidden:"true"});for(let s of t){let n=typeof s=="number"?s:Number(s?.value);if(!Number.isFinite(n))continue;let r=typeof s=="number"?this._format(n):String(s.label??this._format(n));e.append(a("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)?Ie(e,{min:this._min,max:this._max,step:this._step,precision:sn(this._step)}):this._min}_ratio(t){return F((t-this._min)/(this._max-this._min),0,1)}_format(t){let e=this.options.formatValue;return typeof e=="function"?String(e(t)):`${Bc(t)}${this.options.unit??""}`}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}},qc=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function sn(i){let t=String(i),e=/e-(\d+)$/i.exec(t);return e?Number(e[1]):(t.split(".")[1]??"").length}function Bc(i){return String(Number(i.toFixed(6)))}function xo(){A.register("slider",(i,t)=>{let e=i.own(new ie(null,{label:t.label?String(t.label):void 0,hideLabel:!0,disabled:!!t.disabled,...t.props??{}})),s=!1;return e.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.get(),set:n=>{s=!0;try{e.set(Number(n)||0,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var ne=class extends _{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:k(this.el);let t=this.el??a("div");this.el=t;let e=y("zx-tag-picker-list"),s=a("span",{ref:"tags",class:"zx-tag-picker__tags"}),n=a("input",{ref:"input",class:"zx-tag-picker__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:"list",ariaLabel:this._message("tagPicker.input","Add a value"),placeholder:String(this.options.placeholder??"")}),r=a("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=a("div",{ref:"control",class:"zx-tag-picker__control"},s,n,r),l=a("div",{ref:"list",class:"zx-tag-picker__list",id:e,role:"listbox",ariaMultiSelectable:"true"});l.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let c=a("div",{ref:"panel",class:"zx-tag-picker__panel",popover:"manual"},l);return t.replaceChildren(o,c),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visible=this._items.slice(),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(o,"pointerdown",h=>{let u=h.target;u.closest(".zx-tag-picker__remove")||u.closest(".zx-tag-picker__toggle")||(h.target!==n&&(h.preventDefault(),this.focus()),this._open||this.open())}),this.listen(s,"click",h=>{let u=h.target.closest(".zx-tag-picker__remove");if(!u||this._disabled||this._readonly)return;h.stopPropagation();let d=[...s.children].indexOf(u.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",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 s=Array.isArray(t)?t:[],n=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),r=[];for(let l of s){if(r.length>=n)break;let c=this._resolve(l);c!==null&&!r.some(h=>this._sameValue(h,c))&&r.push(c)}let o=!Pc(r,this._selected,l=>this._valueOf(l));return this._selected=r,this._renderTags(),this._renderOptions(),o&&!e&&this._emitChange(),this}addValue(t,{silent:e=!1}={}){if(this.isFull())return this;let s=this._resolve(t);return s===null?this:this._selected.some(n=>this._sameValue(n,s))?this:(this._selected.push(s),this._renderTags(),this._renderOptions(),e||(this.emit("add",{value:this._valueOf(s),item:s}),this._emitChange()),this)}removeValue(t,{silent:e=!1}={}){let s=this._valueOf(this._resolve(t)??t),n=this._selected.findIndex(o=>Object.is(this._valueOf(o),s));if(n<0)return this;let[r]=this._selected.splice(n,1);return this._renderTags(),this._renderOptions(),e||(this.emit("remove",{value:this._valueOf(r),item:r}),this._emitChange()),this}clear({silent:t=!1}={}){return this.setValues([],{silent:t})}reset({silent:t=!1}={}){return this.setValues(this.options.values,{silent:t})}setItems(t){return this._cancelQuery(),this._items=Array.isArray(t)?t.slice():[],typeof this.options.filter=="function"?this._visible=this._items.slice():this._applyLocalFilter(this.refs.input.value),this._renderOptions(),this._position?.update(),this}isFull(){let t=this.options.max;return t!=null&&this._selected.length>=Number(t)}open(){return this._disabled||this._readonly||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=U(this.refs.control,this.refs.panel,{placement:"bottom-start",flip:!0,matchWidth:!0}),this._setActive(this._entries.length>0?0:-1),typeof this.options.filter=="function"&&this._scheduleAsyncQuery(this.refs.input.value),this.emit("open",{}),this)}close(){return this._open?(this._open=!1,this._cancelQuery(),this._position?.destroy(),this._position=null,this.el.setAttribute("data-state","closed"),this.refs.input.setAttribute("aria-expanded","false"),this.refs.input.removeAttribute("aria-activedescendant"),this._activeIndex=-1,this._activeId=null,this.refs.input.value="",this._syncInputWidth(),this._applyLocalFilter(""),this.emit("close",{}),this):this}focus(){return this.refs.input.focus(),this}enable(){return this._disabled=!1,this._renderTags(),this._syncDisabled(),this}disable(){return this.close(),this._disabled=!0,this._renderTags(),this._syncDisabled(),this}setReadonly(t){return t&&this.close(),this._readonly=!!t,this._renderTags(),this._syncDisabled(),this}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}_renderTags(){let t=this._selected.map(e=>{let s=this._labelOf(e),n=this._colorOf(e),r=this.options.renderTag?this.options.renderTag(e):[this._iconOf(e),a("span",{class:"zx-tag-picker__tag-label"},s)],o=a("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(a("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[s])},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),l=this._isSelected(o),c=a("div",{class:"zx-tag-picker__option",id:y("zx-tag-picker-option"),role:"option",ariaSelected:String(l)},a("span",{class:"zx-tag-picker__check",ariaHidden:"true"},l?g("check",{size:13}):null),a("span",{class:"zx-tag-picker__option-label"},this.options.renderItem?this.options.renderItem(r):[this._iconOf(r),a("span",{},this._labelOf(r))]));!l&&this.isFull()&&c.setAttribute("aria-disabled","true"),this._entries.push({item:r,element:c,create:!1}),e.push(c)}let s=this.refs.input.value.trim();if(this._canCreate(s)){let r=a("div",{class:"zx-tag-picker__option",id:y("zx-tag-picker-option"),role:"option",ariaSelected:"false",dataset:{create:"true"}},a("span",{class:"zx-tag-picker__check",ariaHidden:"true"},g("plus",{size:13})),a("span",{class:"zx-tag-picker__option-label"},this._message("tagPicker.create","Create \u201C%1\u201D",[s])));this._entries.push({item:null,element:r,create:!0}),e.push(r)}e.length===0&&e.push(a("div",{class:"zx-tag-picker__empty"},this._loading?this._message("tagPicker.loading","Loading\u2026"):this._message("tagPicker.empty","No matches"))),t.replaceChildren(...e);let n=this._entries.findIndex(r=>this._entryId(r)===this._activeId);this._setActive(n>=0?n:this._entries.length>0?0:-1)}_entryId(t){return t.create?"\0create":String(this._valueOf(t.item))}_syncPlaceholder(){let t=this.refs.input;t.placeholder=this._selected.length===0?String(this.options.placeholder??""):""}_onInput(){let t=this.refs.input.value;this._syncInputWidth(),this._open||this.open(),typeof this.options.filter=="function"?this._scheduleAsyncQuery(t):this._applyLocalFilter(t),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update()}_onKeydown(t){if(this._disabled||this._readonly)return;let e=this.refs.input;switch(t.key){case"ArrowDown":t.preventDefault(),this._open?this._move(1):this.open();return;case"ArrowUp":t.preventDefault(),this._open&&this._move(-1);return;case"Home":this._open&&e.value===""&&(t.preventDefault(),this._setActive(0));return;case"End":this._open&&e.value===""&&(t.preventDefault(),this._setActive(this._entries.length-1));return;case"Enter":{if(!this._open||this._activeIndex<0)return;t.preventDefault(),this._commitEntry(this._entries[this._activeIndex]);return}case"Escape":this._open&&(t.preventDefault(),this.close());return;case"Backspace":e.value===""&&this._selected.length>0&&(t.preventDefault(),this.removeValue(this._valueOf(this._selected[this._selected.length-1])));return;case"Tab":this._open&&this.close();return;default:}}_onOptionClick(t){let e=t.target.closest(".zx-tag-picker__option");if(!e)return;let s=this._entries.find(n=>n.element===e);s&&this._commitEntry(s)}_commitEntry(t){if(!t)return;let e=this.refs.input;if(t.create){let s=e.value.trim(),n=this._createItem(s);this._items=this._items.concat([n]),this.addValue(n),this.emit("create",{value:this._valueOf(n),item:n})}else{let s=this._valueOf(t.item);if(this._isSelected(s))this.removeValue(s);else if(!this.isFull())this.addValue(t.item);else return}e.value="",this._syncInputWidth(),this._applyLocalFilter(""),this._renderOptions(),this.options.closeOnSelect?this.close():(this._setActive(this._entries.length>0?0:-1),this._position?.update()),this.focus()}_move(t){if(this._entries.length===0)return;let e=this._activeIndex<0?t>0?0:this._entries.length-1:Math.min(this._entries.length-1,Math.max(0,this._activeIndex+t));this._setActive(e)}_setActive(t){this._activeIndex=t,this._activeId=this._entries[t]?this._entryId(this._entries[t]):null;for(let[e,s]of this._entries.entries()){let n=e===t;s.element.toggleAttribute("data-active",n),n&&(this.refs.input.setAttribute("aria-activedescendant",s.element.id),s.element.scrollIntoView({block:"nearest"}))}t<0&&this.refs.input.removeAttribute("aria-activedescendant")}_applyLocalFilter(t){if(typeof this.options.filter=="function")return;let e=this.options.searchKeys??[this.options.labelKey];this._visible=yt(this._items,t,e)}_scheduleAsyncQuery(t){this._cancelQuery();let e=String(t??"");if(e.length<Number(this.options.minQuery??0)){this._visible=[],this._renderOptions();return}this._visible=[],this._setLoading(!0),this._renderOptions();let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>{this._queryTimer=null,this._runQuery(e)},s)}async _runQuery(t){let e=this._requestSequence+1;this._requestSequence=e,this._setLoading(!0),this.emit("query",{query:t});try{let s=await this.options.filter(t);if(e!==this._requestSequence)return;this._items=Array.isArray(s)?s.slice():[],this._visible=this._items.slice()}catch(s){if(e!==this._requestSequence)return;this._visible=[],this.emit("error",{error:s})}finally{e===this._requestSequence&&(this._setLoading(!1),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update())}}_cancelQuery(){this._queryTimer!==null&&(clearTimeout(this._queryTimer),this._queryTimer=null),this._requestSequence+=1,this._setLoading(!1)}_setLoading(t){this._loading=t,this.el.toggleAttribute("data-loading",t)}_isSelected(t){return this._selected.some(e=>Object.is(this._valueOf(e),t))}_canCreate(t){if(!this.options.allowCreate||t===""||this.isFull())return!1;let e=s=>s.some(n=>vo(this._labelOf(n))===vo(t));return!e(this._items)&&!e(this._selected)}_createItem(t,e=t){return typeof this.options.valueKey!="string"||typeof this.options.labelKey!="string"?t:{[this.options.valueKey]:e,[this.options.labelKey]:t,created:!0}}_resolve(t){if(t==null)return null;let e=this._valueOf(t),s=this._items.find(r=>Object.is(this._valueOf(r),e));if(s!==void 0)return s;let n=this._selected.find(r=>Object.is(this._valueOf(r),e));return n!==void 0?n:typeof t=="object"?t:this._createItem(String(t),t)}_sameValue(t,e){return Object.is(this._valueOf(t),this._valueOf(e))}_valueOf(t){let e=this.options.valueKey;return typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]:t}_labelOf(t){let e=this.options.labelKey;return String(typeof e=="function"?e(t):t!==null&&typeof t=="object"?t[e]??"":t??"")}_iconOf(t){let e=this._readItem(t,this.options.iconKey),s=e&&typeof e=="object"&&typeof e.nodeType=="number"?e.cloneNode(!0):typeof e=="string"&&e.trim()?g(e,{size:12}):null;return s?a("span",{class:"zx-tag-picker__visual",style:this._colorOf(t)?{"--zx-tag-color":this._colorOf(t)}:null,ariaHidden:"true"},s):null}_colorOf(t){let e=this._readItem(t,this.options.colorKey);return jt(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,s=[]){let n=this.msg(t,...s);return n!==t?n:s.reduce((r,o,l)=>r.replaceAll(`%${l+1}`,String(o)),e)}};function vo(i){return String(i??"").trim().toLocaleLowerCase()}function Pc(i,t,e){return i.length!==t.length?!1:i.every((s,n)=>Object.is(e(s),e(t[n])))}function wo(){A.register("tagpicker",(i,t)=>{let e=i.own(new ne(null,{placeholder:t.placeholder,...t.props??{}})),s=!1;return i.listen(e.el,"change",n=>n.stopImmediatePropagation()),e.on("change",n=>{s||i.emit("change",{value:n.detail.values})}),{el:e.el,get:()=>e.getValues(),set:n=>{s=!0;try{e.setValues(Array.isArray(n)?n:[],{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}function nn(i,t="minutes"){let e=Math.round(Math.abs(Ao(Nt(i),t)));return{hours:Math.floor(e/3600),minutes:Math.floor(e/60)%60,seconds:e%60,negative:Nt(i)<0}}function rn(i,t="minutes"){Ne(t);let e=Math.abs(Math.trunc(Nt(i?.hours))),s=Math.abs(Math.trunc(Nt(i?.minutes))),n=Math.abs(Math.trunc(Nt(i?.seconds))),r=i?.negative?-1:1;return So(r*(e*3600+s*60+n),t)}var ht=class extends _{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){Ne(this.options.unit);let t=this.el??a("div");this.el=t,this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._disabled=!!this.options.disabled,this._parts={hours:0,minutes:0,seconds:0,negative:!1},this._inputs=[];let e=a("div",{class:"zx-timebox__content",role:"group",ariaLabel:this.options.seconds?"Duration in hours, minutes, and seconds":"Duration in hours and minutes"});return this._content=e,this.options.signed&&(e.append(a("button",{ref:"sign",class:"zx-timebox__sign",type:"button",ariaLabel:"Toggle duration sign",ariaPressed:"false"},"+")),this.listen(this.refs.sign,"click",()=>{this._disabled||(this._parts.negative=!this._parts.negative,this._writeParts(),this._emitChange())})),this._addSegment(e,"hours","Hours",!1),e.append(a("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"minutes","Minutes",!0),this.options.seconds&&(e.append(a("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"seconds","Seconds",!0)),t.append(e),this.set(this.options.value,this.options.unit,{silent:!0}),this._syncDisabled(),t}get(t=this.options.unit){return rn(this._readParts(),t)}set(t,e=this.options.unit,s={}){e&&typeof e=="object"&&(s=e,e=this.options.unit),Ne(e);let n=Nt(t);return!this.options.signed&&n<0&&(n=0),this.options.seconds||(n=So(Math.round(Ao(n,e)/60)*60,e)),this._parts=nn(n,e),this.options.signed||(this._parts.negative=!1),this._writeParts(),s.silent||this._emitChange(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}destroy(){this._content?.remove(),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_addSegment(t,e,s,n){let r=a("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:s,maxLength:n?2:null,dataset:{segment:e,bounded:String(n)}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"input",()=>{e==="hours"&&this.options.signed&&r.value.trim().startsWith("-")&&(this._parts.negative=!0);let o=r.value.replace(/\D/g,"");r.value=n?o.slice(0,2):o}),this.listen(r,"change",()=>this._commitSegments()),this.listen(r,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this._commitSegments(),r.select())})}_readParts(){let t={...this._parts};for(let e of this._inputs){let s=e.dataset.segment,n=e.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;t[s]=Math.max(0,Math.min(n,Math.trunc(Nt(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]):Hc(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 Nt(i){let t=Number(i);return Number.isFinite(t)?t:0}function Ao(i,t){return Ne(t),t==="hours"?i*3600:t==="minutes"?i*60:i}function So(i,t){return Ne(t),t==="hours"?i/3600:t==="minutes"?i/60:i}function Ne(i){if(i!=="hours"&&i!=="minutes"&&i!=="seconds")throw new RangeError(`Unknown time unit: ${i}`)}function Hc(i){return String(i).padStart(2,"0")}function ko(){A.register("time",(i,t)=>{let e=i.own(new ht(null,{...t.props??{},value:t.value}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:s.detail.value})),{el:e.el,get:()=>e.get(),set:s=>e.set(Number(s)||0,{silent:!0}),focus:()=>e.el.querySelector("input:not([disabled]), button:not([disabled])")?.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var W=class extends _{static cssName="toggle";static defaults={checked:!1,value:!0,label:null,disabled:!1};render(){let t=!this.el,e=this.el??a("button");if(this.el=e,e.localName!=="button")throw new TypeError("Toggle target must be a button element");this._createdRoot=t,this._original=t?null:Vc(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,e.type="button",e.setAttribute("role","switch");let s=[a("span",{class:"zx-toggle__track",ariaHidden:"true"},a("span",{class:"zx-toggle__thumb"}))];return this.options.label!==null&&s.push(a("span",{class:"zx-toggle__label"},String(this.options.label))),e.replaceChildren(...s),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let s=!!t;return s===this._checked?this:(this._checked=s,this._sync(),e||this.emit("change",{checked:this._checked,value:this.getValue()}),this)}toggle(){return this.set(!this._checked)}getValue(){return this._checked?this.options.value:!1}enable(){return this._disabled=!1,this.el.removeAttribute("disabled"),this}disable(){return this._disabled=!0,this.el.setAttribute("disabled",""),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&jc(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function Vc(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function jc(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function zo(){A.register("toggle",(i,t)=>{let e=i.own(new W(null,{...t.props??{},checked:!!t.value}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:s.detail.value})),{el:e.el,get:()=>e.getValue(),set:s=>e.set(!!s,{silent:!0}),focus:()=>e.el.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var re=class extends _{static cssName="value-list";static defaults={values:[],placeholder:"",deletable:!0,sortable:!0,unique:!0,validate:null};render(){let t=this.el??a("div");this._ownedNodes=[],this._disabled=!1,this._dragIndex=-1,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled"),this._values=Co(this.options.values,!!this.options.unique);let e=y("zx-value-list-instructions");return this._list=a("ul",{class:"zx-value-list__list",role:"listbox",ariaLabel:"Values",ariaOrientation:"horizontal"}),this._input=a("input",{class:"zx-value-list__input",type:"text",placeholder:String(this.options.placeholder??""),ariaLabel:"Add value",ariaDescribedby:e}),this._status=a("div",{class:"zx-value-list__status",role:"status",ariaLive:"polite"}),this._instructions=a("span",{class:"zx-value-list__instructions",id:e},"Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder."),this._ownedNodes.push(this._list,this._input,this._status,this._instructions),t.append(this._list,this._input,this._status,this._instructions),this.listen(this._input,"keydown",s=>this._handleInputKeydown(s)),this.listen(this._list,"keydown",s=>this._handleChipKeydown(s)),this.listen(this._list,"click",s=>this._handleChipClick(s)),this.listen(this._list,"dragstart",s=>this._handleDragStart(s)),this.listen(this._list,"dragover",s=>{this._dragIndex>=0&&!this._disabled&&s.preventDefault()}),this.listen(this._list,"drop",s=>this._handleDrop(s)),this.listen(this._list,"dragend",()=>this._finishDrag()),this.listen(t,"click",s=>{s.target===t&&!this._disabled&&this.focus()}),this._renderChips(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=Co(t,!!this.options.unique),this._renderChips(),e||this.emit("change",{values:this.getValues()}),this}addValue(t){if(this._disabled)return!1;let e=String(t??"").trim();if(!e)return!1;if(this.options.unique&&this._values.includes(e))return this._showError("This value already exists."),!1;if(typeof this.options.validate=="function"){let s=this.options.validate(e);if(s!==!0)return this._showError(typeof s=="string"?s:"This value is not valid."),!1}return this._status.textContent="",this._input.removeAttribute("aria-invalid"),this._values.push(e),this._renderChips(),this.emit("add",{value:e}),this.emit("change",{values:this.getValues()}),!0}removeValue(t){if(this._disabled||!this.options.deletable)return!1;let e=this._values.indexOf(String(t));return e<0?!1:(this._removeAt(e),!0)}focus(){return this._input.focus(),this}enable(){return this._disabled=!1,this._input.disabled=!1,this.el.dataset.disabled="false",this._renderChips(),this}disable(){return this._disabled=!0,this._input.disabled=!0,this.el.dataset.disabled="true",this._renderChips(),this}_renderChips(t=-1){let e=this._values.map((s,n)=>a("li",{class:"zx-value-list__chip",role:"option",tabIndex:this._disabled?-1:0,draggable:!!this.options.sortable&&!this._disabled,ariaSelected:"false",ariaDisabled:String(this._disabled),ariaLabel:this.options.deletable?`${s}. Press Delete to remove.`:s,dataset:{index:n}},a("span",{class:"zx-value-list__value"},s),this.options.deletable?a("span",{class:"zx-value-list__remove",dataset:{remove:""},ariaHidden:"true"},"\xD7"):null));this._list.replaceChildren(...e),t>=0&&e[Math.min(t,e.length-1)]?.focus()}_handleInputKeydown(t){this._disabled||(t.key==="Enter"?(t.preventDefault(),this.addValue(this._input.value)&&(this._input.value="")):t.key==="Backspace"&&this._input.value===""&&this._values.length&&this.options.deletable&&(t.preventDefault(),this._removeAt(this._values.length-1)))}_handleChipKeydown(t){if(this._disabled)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e)return;let s=Number(e.dataset.index);if((t.key==="Delete"||t.key==="Backspace")&&this.options.deletable){t.preventDefault(),this._removeAt(s,Math.min(s,this._values.length-2));return}let 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 l=Math.max(0,Math.min(this._values.length-1,s+o));t.ctrlKey&&n&&this.options.sortable?this._move(s,l,!0):this._list.querySelector(`[data-index="${l}"]`)?.focus()}_handleChipClick(t){let e=t.target instanceof Element?t.target:null,s=e?.closest("[data-index]");!s||this._disabled||(e.closest("[data-remove]")&&this.options.deletable?this._removeAt(Number(s.dataset.index)):s.focus())}_handleDragStart(t){if(this._disabled||!this.options.sortable)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;e&&(this._dragIndex=Number(e.dataset.index),this.el.dataset.state="dragging",t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"))}_handleDrop(t){if(this._dragIndex<0||this._disabled)return;t.preventDefault();let e=t.target instanceof Element?t.target.closest("[data-index]"):null,s=e?Number(e.dataset.index):this._values.length-1;this._move(this._dragIndex,s,!0),this._finishDrag()}_finishDrag(){this._dragIndex=-1,this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_move(t,e,s){if(t===e||t<0||e<0||t>=this._values.length||e>=this._values.length)return;let[n]=this._values.splice(t,1);this._values.splice(e,0,n),this._renderChips(s?e:-1),this.emit("change",{values:this.getValues()})}_removeAt(t,e=-1){let[s]=this._values.splice(t,1);s!==void 0&&(this._renderChips(e),e<0&&this._values.length===0&&this._input.focus(),this.emit("remove",{value:s}),this.emit("change",{values:this.getValues()}))}_showError(t){this._status.textContent=t,this._input.setAttribute("aria-invalid","true")}destroy(){for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function Co(i,t){if(!Array.isArray(i))return[];let e=i.map(s=>String(s));return t?[...new Set(e)]:e}function To(){A.register("valuelist",(i,t)=>{let e=i.own(new re(null,{...t.props??{},values:Array.isArray(t.value)?t.value:[]}));return i.listen(e.el,"change",s=>s.stopImmediatePropagation()),e.on("change",s=>i.emit("change",{value:s.detail.values})),{el:e.el,get:()=>e.getValues(),set:s=>e.setValues(Array.isArray(s)?s:[],{silent:!0}),focus:()=>e.focus(),setDisabled:s=>s?e.disable():e.enable()}})}var Mt=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),$c=["xl","lg","md","sm"];function ds(i){let t=Number(i);if(!Number.isFinite(t))return"xs";for(let e of $c)if(t>=Mt[e])return e;return"xs"}function ps(i,t){if(i==="xs")return!0;let e=Mt[i];if(e===void 0)throw new RangeError(`Unknown breakpoint "${i}"`);return Number(t)>=e}function oe(i,t={}){if(typeof i!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in t&&!D(t.target)&&t.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let e=t.target??globalThis,s=D(e)?e:null,n=null,r=!1,o=null,l=()=>s?s.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,c=()=>{if(r)return;let d=l();if(s&&d===0)return;let f=ds(d);f!==n&&(n=f,i(n,d))};c();let h=0,u=()=>{h||r||(h=requestAnimationFrame(()=>{h=0,c()}))};return s&&typeof ResizeObserver=="function"?(o=new ResizeObserver(u),o.observe(s)):globalThis.addEventListener?.("resize",c,{passive:!0}),{current:()=>n??ds(l()),destroy:()=>{r||(r=!0,h&&cancelAnimationFrame(h),o?.disconnect(),globalThis.removeEventListener?.("resize",c))}}}var Me=class{base;headers;onError;timeout;constructor({base:t="",headers:e={},onError:s=null,timeout:n=3e4}={}){this.base=String(t),this.headers=Object.freeze({...e}),this.onError=s,this.timeout=Number(n)}async request(t,e={}){let{method:s="GET",data:n=null,files:r=null,query:o=null,headers:l={}}=e,c=new AbortController,h=this.timeout>0?setTimeout(()=>c.abort(),this.timeout):null,u=new Headers(this.headers);for(let[p,m]of Object.entries(l))u.set(p,m);u.set("Accept",u.get("Accept")??"application/json");let d;r!==null?(d=Uc(n,r),u.delete("Content-Type")):n!==null&&s.toUpperCase()!=="GET"&&s.toUpperCase()!=="HEAD"&&(d=JSON.stringify(n),u.set("Content-Type",u.get("Content-Type")??"application/json"));let f=Kc(this.base+t,o);try{let p=await fetch(f,{method:s.toUpperCase(),headers:u,body:d,signal:c.signal}),m=await p.text(),b=null;if(m!=="")try{b=JSON.parse(m)}catch(w){let x=new Error("Invalid JSON response",{cause:w});throw x.response=p,x}if(!p.ok){try{fs(b)}catch(x){throw x.response=p,x}let w=new Error(`HTTP ${p.status} ${p.statusText}`.trim());throw w.response=p,w}return fs(b)}catch(p){let m=p instanceof Error?p:new Error(String(p));if(this.onError)try{this.onError(m,{path:t,options:e})}catch{}throw m}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 Eo(i,t="",e={}){let{apiBase:s="../remotecall/",...n}=e,r=`${s}${i}${t?`:${t}`:""}/`;return new Me({...n,base:r})}function fs(i){if(i&&typeof i=="object"){if(Object.prototype.hasOwnProperty.call(i,"error")&&i.error!=null){let t=typeof i.error=="string"?i.error:JSON.stringify(i.error);throw new Error(t||"Server error")}if(Object.prototype.hasOwnProperty.call(i,"result"))return i.result}return i}function Kc(i,t){if(t==null)return i;let e;if(typeof t=="string")e=t.replace(/^\?/,"");else if(t instanceof URLSearchParams)e=t.toString();else{let s=new URLSearchParams;for(let[n,r]of Object.entries(t))Io(s,n,r);e=s.toString()}return e?i+(i.includes("?")?"&":"?")+e:i}function Io(i,t,e){if(e!=null)if(Array.isArray(e))for(let s of e)Io(i,t,s);else i.append(t,typeof e=="object"?JSON.stringify(e):String(e))}function Uc(i,t){let e=new FormData;if(i&&typeof i=="object"&&!Array.isArray(i))for(let[n,r]of Object.entries(i))Do(e,n,r);else i!=null&&e.append("data",typeof i=="string"?i:JSON.stringify(i));let s=Yc(t)||Array.isArray(t)?Array.from(t):[t];for(let n of s)e.append("files",n);return e}function Do(i,t,e){if(e!=null)if(Array.isArray(e))for(let s of e)Do(i,t,s);else{let s=typeof Blob=="function"&&e instanceof Blob;i.append(t,typeof e=="object"&&!s?JSON.stringify(e):e)}}function Yc(i){return typeof FileList=="function"&&i instanceof FileList}var Wc=0,Gc=20,Qc=3,Jc=["B","KiB","MiB","GiB","TiB","PiB","EiB"],Xc=["B","kB","MB","GB","TB","PB","EB"],on=[{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}],No=new Map,Mo=new Map;function At(i,t={}){let e=gs(i);if(e===null)return"";let{locale:s=G(),decimals:n,minDecimals:r,maxDecimals:o,group:l=!0}=t;return an(s,ln({decimals:n,minDecimals:r,maxDecimals:o,group:l}),e)}function _s(i,t,e={}){let s=gs(i);if(s===null)return"";let{locale:n=G(),decimals:r}=e,o=eh(t);if(o===null)return At(s,{locale:n,decimals:r});let l=ln({decimals:r,group:!0});return an(n,{...l,style:"currency",currency:o},s)}function ms(i,t={}){let e=gs(i);if(e===null)return"";let{locale:s=G(),decimals:n=0}=t;return an(s,{...ln({decimals:n,group:!0}),style:"percent"},e)}function Lo(i,t={}){let e=gs(i);if(e===null)return"";let{locale:s=G(),decimals:n=1,standard:r="iec"}=t;if(e===0)return`${At(0,{locale:s,decimals:0})} B`;let o=r==="si"?Xc:Jc,l=r==="si"?1e3:1024,c=Math.abs(e),h=Math.min(o.length-1,Math.max(0,Math.floor(Math.log(c)/Math.log(l)))),u=c/l**h;sh(u,h===0?0:n)>=l&&h<o.length-1&&(h+=1,u=c/l**h);let d=e<0?-u:u;return`${At(d,{locale:s,minDecimals:0,maxDecimals:h===0?0:n})} ${o[h]}`}function Ro(i,t={}){let e=Fo(i);if(e===null)return"";let{now:s=new Date,locale:n=G(),numeric:r="auto"}=t,o=Fo(s);if(o===null)return"";let l=e.getTime()-o.getTime(),c=on.find(({ms:u,limit:d})=>Math.abs(l)/u<d)??on[on.length-1],h=Math.round(l/c.ms);return th(n,r).format(h,c.unit)}function an(i,t,e){let s=`${i}\0${JSON.stringify(t)}`,n=No.get(s);return n===void 0&&(n=Zc(i,t),No.set(s,n)),n.format(e)}function Zc(i,t){try{return new Intl.NumberFormat(i,t)}catch{try{return new Intl.NumberFormat(void 0,t)}catch{return new Intl.NumberFormat}}}function th(i,t){let e=`${i}\0${t}`,s=Mo.get(e);if(s===void 0){try{s=new Intl.RelativeTimeFormat(i,{numeric:t})}catch{s=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"})}Mo.set(e,s)}return s}function ln({decimals:i,minDecimals:t,maxDecimals:e,group:s=!0}){let n={useGrouping:s!==!1},r=Oo(t??i),o=Oo(e??i);return r!==null&&(n.minimumFractionDigits=r),o!==null?(n.maximumFractionDigits=o,r!==null&&r>o&&(n.minimumFractionDigits=o)):r!==null&&(n.maximumFractionDigits=Math.max(r,Qc)),n}function Oo(i){if(i==null)return null;let t=Number(i);return Number.isFinite(t)?Math.min(Gc,Math.max(Wc,Math.round(t))):null}function gs(i){if(i==null||i==="")return null;let t=typeof i=="number"?i:Number(i);return Number.isFinite(t)?t:null}function eh(i){if(typeof i!="string")return null;let t=i.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function Fo(i){if(i instanceof Date)return Number.isNaN(i.getTime())?null:i;if(typeof i=="number")return Number.isFinite(i)?new Date(i*1e3):null;if(typeof i=="string"){let t=i.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 sh(i,t){let e=10**t;return Math.round(i*e)/e}var qo="zx:__probe__";function ae(i,t={}){let{area:e="local"}=t,s=`zx:${String(i??"")}:`,n=new Map,r=ih(e),o=u=>{if(r!==null)try{return r.getItem(u)}catch{r=null}return n.has(u)?n.get(u):null},l=(u,d)=>{if(r!==null)try{r.setItem(u,d);return}catch{r=null}n.set(u,d)},c=u=>{if(r!==null)try{r.removeItem(u)}catch{r=null}n.delete(u)},h=()=>{if(r!==null)try{let u=[];for(let d=0;d<r.length;d+=1){let f=r.key(d);typeof f=="string"&&f.startsWith(s)&&u.push(f)}return u}catch{r=null}return[...n.keys()].filter(u=>u.startsWith(s))};return{get(u,d){let f=o(s+u);if(f==null)return d;try{return JSON.parse(f)}catch{return d}},set(u,d){let f;try{f=JSON.stringify(d)}catch{f=void 0}f===void 0?c(s+u):l(s+u,f)},remove(u){c(s+u)},keys(){return h().map(u=>u.slice(s.length))},clear(){for(let u of h())c(u)}}}function ih(i){let t=i==="session"?"sessionStorage":"localStorage";try{let e=globalThis[t];return!e||typeof e.getItem!="function"?null:(e.setItem(qo,"1"),e.removeItem(qo),e)}catch{return null}}var nh=["=","+","-","@"];function Ho(i,t,e={}){let{delimiter:s=",",header:n=!0,newline:r=`\r
2
+ `}=e,o=oh(t),l=[];n&&l.push(o.map(c=>Po(c.label,s,Bo(c.label))).join(s));for(let c of i??[]){let h=o.map(u=>{let d=typeof u.value=="function"?u.value(c):ah(c,u.id);return Po(lh(d),s,Bo(d))});l.push(h.join(s))}return l.join(r)}function Vo(i,t,e={}){let{type:s="text/plain;charset=utf-8"}=e,n=ch(t,s),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=String(i??"download"),o.rel="noopener",o.style.display="none",document.body.append(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}async function bs(i){let t=String(i??"");if(globalThis.navigator?.clipboard?.writeText)try{return await navigator.clipboard.writeText(t),!0}catch{}return rh(t)}function rh(i){if(typeof document>"u"||!document.body)return!1;let t=document.activeElement,e=document.createElement("textarea");e.value=i,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 s=!1;try{e.select(),e.setSelectionRange(0,i.length),s=document.execCommand?.("copy")===!0}catch{s=!1}finally{e.remove(),t instanceof HTMLElement&&t.focus({preventScroll:!0})}return s}function oh(i){return(i??[]).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 ah(i,t){return i?.[t]}function lh(i){if(i==null)return"";if(i instanceof Date)return Number.isNaN(i.getTime())?"":i.toISOString();if(typeof i=="number")return Number.isFinite(i)?String(i):"";if(typeof i=="boolean")return i?"true":"false";if(typeof i=="object")try{return JSON.stringify(i)}catch{return String(i)}return String(i)}function Bo(i){return typeof i!="string"?!1:nh.includes(i.charAt(0))}function Po(i,t,e=!1){let s=e?` ${i}`:i;return s.includes(t)||s.includes('"')||s.includes(`
3
+ `)||s.includes("\r")?`"${s.replaceAll('"','""')}"`:s}function ch(i,t){if(typeof Blob=="function"&&i instanceof Blob)return i;let e=typeof i=="string"&&/^text\/csv\b/i.test(t)?["\uFEFF",i]:[i];return new Blob(e,{type:t})}var pt=class extends _{static cssName="check-button";static defaults={label:"",checked:!1,icon:!0,disabled:!1};render(){let t=!this.el,e=this.el??a("button");if(this.el=e,e.localName!=="button")throw new TypeError("CheckButton target must be a button element");this._createdRoot=t,this._original=t?null:hh(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,this._labels=jo(this.options.label),e.type="button";let s=[];return this.options.icon&&s.push(a("span",{class:"zx-check-button__icon",ariaHidden:"true"},a("span",{class:"zx-check-button__off"},g("square",{size:15})),a("span",{class:"zx-check-button__on"},g("check",{size:15})))),s.push(a("span",{class:"zx-check-button__label",ref:"label"})),e.replaceChildren(...s),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let s=!!t;return s===this._checked?this:(this._checked=s,this._sync(),e||this.emit("change",{checked:this._checked}),this)}toggle(){return this.set(!this._checked)}setLabel(t){return this._labels=jo(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&&uh(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 jo(i){return Array.isArray(i)?{on:String(i[0]??""),off:String(i[1]??"")}:{on:String(i??""),off:String(i??"")}}function hh(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function uh(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}var le=class extends _{static cssName="modal";static defaults={content:null,width:"auto",closable:!0,lightDismiss:!1,destroyOnClose:!1};#t;#e=!1;#s=!1;constructor(t=null,e={}){super(null,e),this.#i(this.options.width),$o(this.refs.content,this.options.content),this.listen(this.el,"cancel",s=>{let n=this.emit("cancel");(!this.options.closable||n.defaultPrevented)&&s.preventDefault()}),this.listen(this.el,"close",()=>{if(!this._isRealClose())return;this.el.dataset.state="closed",delete this.el.dataset.zxOverlayOrder;let s=this.#e?this.#t:this.el.returnValue||void 0;this.#t=void 0,this.#e=!1,this.emit("close",{result:s}),this.options.destroyOnClose&&!this.#s&&this.destroy()}),this.listen(this.el,"click",s=>{!this.options.lightDismiss||s.target!==this.el||!dh(this.el,s)||this.close()})}mountTarget(){return document.body}_show(){this.el.showModal()}_isRealClose(){return!0}render(){let t=a("dialog",{class:"zx-modal"},a("div",{class:"zx-modal__content",ref:"content"}));return t.dataset.state="closed",this.mountTarget().append(t),t}open(){if(this.isOpen())return this;this.el.dataset.zxOverlayOrder=String(ph()),this.el.returnValue="";try{this._show()}catch(t){throw delete this.el.dataset.zxOverlayOrder,t}return this.el.dataset.state="open",this.emit("open"),this}close(t){return this.isOpen()?(this.#t=t,this.#e=!0,this.el.close(typeof t=="string"?t:""),this):this}setContent(t){return $o(this.refs.content,t),this}isOpen(){return this.el.open}destroy(){this.#s||(this.#s=!0,this.isOpen()&&this.el.close(),super.destroy())}#i(t){typeof t=="number"&&Number.isFinite(t)?this.el.style.inlineSize=`${Math.max(0,t)}px`:this.el.style.inlineSize=String(t??"auto")}};function $o(i,t){if(i.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t.nodeType=="number"&&i.append(t)}function dh(i,t){let e=i.getBoundingClientRect();return t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom}function ph(){let i=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...i)+1}var fh=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(","),ft=class i extends le{static cssName="dialog";static defaults={title:"",size:"md",buttons:[],closable:!0};#t=new Map;#e=null;#s=[];#i="";#r=null;constructor(t=null,e={}){super(null,e),this._applySize(this.options.size),this.#i=String(this.options.title??""),this.#o(this.#i),this.#s=ys(this.options.buttons),this.#a(this.#s),this.refs.close.hidden=!this.options.closable,this.listen(this.refs.close,"click",()=>this.close()),this.listen(this.refs.footer,"click",s=>{let n=s.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=y("zx-dialog-title"),e=a("dialog",{class:"zx-modal zx-dialog",ariaLabelledby:t},a("header",{class:"zx-dialog__header"},a("h2",{class:"zx-dialog__title",id:t,ref:"title"}),a("button",{class:"zx-btn zx-dialog__close",ref:"close",type:"button","data-kind":"ghost",ariaLabel:"Close",title:"Close"},"\xD7")),a("div",{class:"zx-modal__content zx-dialog__body",ref:"content"}),a("footer",{class:"zx-dialog__footer",ref:"footer"}));return e.dataset.state="closed",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(fh);e instanceof HTMLElement&&e.focus()}),this)}setTitle(t){return this.#i=String(t??""),this.#o(this.#i),this}setContent(t){return this.#t.clear(),this.#e=null,_h(this.refs.content,t),this}setButtons(t){return this.#s=ys(t),this.#a(this.#s),this}addView(t,e){let s=String(t);this.#t.get(s)?.content.remove();let r=a("section",{class:"zx-dialog__view",hidden:!0,ariaHidden:"true"});Ko(r,e?.content??null);let o={key:s,content:r,buttons:e&&Object.hasOwn(e,"buttons")?ys(e.buttons??[]):null,title:e&&Object.hasOwn(e,"title")?String(e.title??""):null};return this.#t.set(s,o),this.#t.size===1||this.#e?.key===s?this.showView(s):this.refs.content.append(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 s of this.#t.values()){s.content.isConnected||this.refs.content.append(s.content);let n=s===e;s.content.hidden=!n,s.content.setAttribute("aria-hidden",String(!n))}return this.#e=e,this.#o(e.title??this.#i),this.#a(e.buttons??this.#s),e}getView(t){return this.#t.get(String(t))??null}static alert({title:t="",message:e="",okLabel:s="OK"}={}){return new Promise(n=>{let r=!1,o=()=>{r||(r=!0,l.close(),n())},l=new i(null,{title:t,content:e,buttons:[{label:s,kind:"primary",action:o,autofocus:!0}]});l.once("close",()=>{r||(r=!0,n()),l.destroy()}),l.open()})}static confirm({title:t="",message:e="",okLabel:s="OK",cancelLabel:n="Cancel",danger:r=!1}={}){return new Promise(o=>{let l=!1,c=u=>{l||(l=!0,h.close(u),o(u))},h=new i(null,{title:t,content:e,buttons:[{label:n,action:()=>c(!1)},{label:s,kind:r?"danger":"primary",action:()=>c(!0),autofocus:!0}]});h.once("close",()=>{l||(l=!0,o(!1)),h.destroy()}),h.open()})}static prompt({title:t="",message:e="",value:s="",placeholder:n=""}={}){return new Promise(r=>{let o=!1,l=a("input",{class:"zx-dialog__prompt-input",value:String(s),placeholder:String(n),autofocus:!0,ariaLabel:String(t||"Prompt value")}),c=a("div",{class:"zx-dialog__prompt"},a("div",{class:"zx-dialog__prompt-message"},e),l),h=d=>{o||(o=!0,u.close(d),r(d))},u=new i(null,{title:t,content:c,buttons:[{label:"Cancel",action:()=>h(null)},{label:"OK",kind:"primary",action:()=>h(l.value)}]});u.listen(l,"keydown",d=>{d.key==="Enter"&&(d.preventDefault(),h(l.value))}),u.once("close",()=>{o||(o=!0,r(null)),u.destroy()}),u.open()})}_applySize(t){let e={sm:400,md:600,lg:840},s=typeof t=="number"&&Number.isFinite(t)?t:e[t]??e.md;this.el.style.inlineSize=`${Math.max(0,s)}px`}#o(t){this.refs.title.textContent=t}#a(t){this.#n=ys(t),this.refs.footer.replaceChildren(),this.refs.footer.hidden=this.#n.length===0,this.#n.forEach((e,s)=>{this.refs.footer.append(a("button",{class:"zx-btn",type:"button","data-kind":e.kind??"default","data-size":"md","data-dialog-button":String(s),autofocus:!!e.autofocus},a("span",{class:"zx-btn__label"},e.label)))})}#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 ys(i){return Array.isArray(i)?i.map(t=>({...t,label:String(t.label??"")})):[]}function _h(i,t){i.replaceChildren(),Ko(i,t)}function Ko(i,t){if(t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t.nodeType=="number"&&i.append(t)}var St=class extends _{static cssName="groupbox";static defaults={title:"",open:!0};constructor(t,e={}){let s=t,n=null;if(t!==null){let r=H(t);if(r&&r.localName!=="details"){let o=document.createElement("details"),l=Array.from(r.childNodes),c=r.parentNode,h=r.nextSibling;c&&c.insertBefore(o,r),o.append(...l),r.remove(),n={original:r,details:o,children:l,parent:c,next:h},s=o}}try{super(s,e)}catch(r){throw n&&Uo(n),r}this._adoption=n}render(){let t=!this.el,e=this.el??a("details");if(e.localName!=="details")throw new TypeError("Groupbox requires a details element");this._createdRoot=t,this._original=t?null:mh(e);let s=Array.from(e.childNodes).filter(o=>!(o.nodeType===1&&o.localName==="summary")),n=a("summary",{class:"zx-groupbox__summary",ref:"summary"},a("span",{class:"zx-groupbox__chevron",ariaHidden:"true"},g("chevron-right",{size:16})),a("span",{class:"zx-groupbox__title",ref:"title"},String(this.options.title))),r=a("div",{class:"zx-groupbox__content",ref:"content"},s);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 _?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?Uo(this._adoption):!this._createdRoot&&this._original&&gh(this.el,this._original))}};function mh(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function gh(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function Uo(i){if(i.original.replaceChildren(...i.children),i.details.parentNode)i.details.replaceWith(i.original);else if(i.parent){let t=i.next?.parentNode===i.parent?i.next:null;i.parent.insertBefore(i.original,t)}}var ce=class extends _{static cssName="search";static defaults={placeholder:"",value:"",clearable:!0,debounce:250};render(){let t=!this.el,e=this.el??a("form");this._createdRoot=t,this._original=t?null:bh(e),this._inputTimer=null,e.setAttribute("role","search");let s=a("input",{class:"zx-search__input",ref:"input",type:"search",placeholder:String(this.options.placeholder),value:String(this.options.value),ariaLabel:String(this.options.placeholder||"Search")}),n=this.options.clearable?a("button",{class:"zx-search__clear",ref:"clear",type:"button",ariaLabel:"Clear search",title:"Clear search"},g("x",{size:15})):null,r=a("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(...[s,n,r].filter(Boolean)),this._syncClear(),this.listen(s,"input",()=>{this._syncClear(),this._scheduleInput()}),e.localName==="form"?this.listen(e,"submit",o=>{o.preventDefault(),this.emit("submit",{value:this.get()})}):(this.listen(s,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this.emit("submit",{value:this.get()}))}),this.listen(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&&yh(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 bh(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function yh(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}var xh=new Set(["divided","bracket","line","segmented"]),he=class extends _{static cssName="tabbox";static defaults={tabs:[],active:null,variant:"divided",keepAlive:!0};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??a("section");if(this.el=e,this._createdRoot=t,this._original=t?null:wh(e),this._cleaned=!1,this._tabs=[],this._active=null,this._keepAlive=!!this.options.keepAlive,this._initializing=!0,!xh.has(this.options.variant))throw new RangeError(`Unknown tabbox variant: ${this.options.variant}`);e.dataset.variant=this.options.variant;let s=a("div",{class:"zx-tabbox__tablist",ref:"tablist",role:"tablist",ariaOrientation:"horizontal"}),n=a("div",{class:"zx-tabbox__panels",ref:"panels"});if(e.replaceChildren(s,n),!Array.isArray(this.options.tabs))throw new TypeError("Tabbox tabs must be an array");for(let l of this.options.tabs)this.addTab(l);this._initializing=!1;let 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(s,"click",l=>{let c=l.target.closest?.('[role="tab"]');if(!c||!s.contains(c))return;let h=this._recordForTab(c);if(!(!h||h.definition.disabled)){if(l.target.closest?.(".zx-tabbox__close")){this._closeTab(h);return}this._setFocused(h),this.openTab(h.definition.name)}}),this.listen(s,"keydown",l=>this._onKeydown(l)),e}addTab(t,e={}){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Tab definition must be an object");if(typeof t.name!="string"||t.name==="")throw new TypeError("Tab name must be a non-empty string");if(this._find(t.name))throw new RangeError(`Tab already exists: ${t.name}`);if(!vh(t.content))throw new TypeError("Tab content must be a Node, Component, or function");let s={name:t.name,title:String(t.title??""),content:t.content,icon:t.icon?String(t.icon):null,closable:!!t.closable,disabled:!!t.disabled},n=y("zx-tab"),r=y("zx-tabpanel"),o=a("span",{class:"zx-tabbox__title"},s.title),l=a("span",{class:"zx-tabbox__badge",hidden:!0}),c=[];s.icon&&c.push(a("span",{class:"zx-tabbox__icon",ariaHidden:"true"},g(s.icon,{size:16}))),c.push(o,l),s.closable&&c.push(a("span",{class:"zx-tabbox__close zx-icon-btn",ariaHidden:"true",title:"Close"},g("x",{size:14})));let h=a("button",{class:"zx-tabbox__tab",type:"button",id:n,role:"tab",tabindex:"-1",ariaControls:r,ariaSelected:"false",ariaDisabled:s.disabled?"true":null,dataset:{closable:s.closable?"true":null}},c),u=a("div",{class:"zx-tabbox__panel",id:r,role:"tabpanel",tabindex:"0",ariaLabelledby:n,hidden:!0}),d={definition:s,tab:h,title:o,badge:l,panel:u,built:!1},f=Number.isFinite(e.index)?Math.trunc(e.index):this._tabs.length,p=Math.max(0,Math.min(this._tabs.length,f)),m=this._tabs[p]??null;return this._tabs.splice(p,0,d),this.refs.tablist.insertBefore(h,m?.tab??null),this._keepAlive&&this.refs.panels.insertBefore(u,m?.panel??null),!this._initializing&&!this._active&&!s.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 s=this._active?.definition.name??null;return this.emit("change",{name:e.definition.name,previous:s}).defaultPrevented?this:(this._applyActive(e),this)}show(t){return this.openTab(t)}getActive(){return this._active?.definition.name??null}setTitle(t,e){let s=this._require(t);return s.definition.title=String(e??""),s.title.textContent=s.definition.title,this}setBadge(t,e){let s=this._require(t);return s.badge.textContent=e===null?"":String(e),s.badge.hidden=e===null,this}enableTab(t){let e=this._require(t);return e.definition.disabled?(e.definition.disabled=!1,e.tab.removeAttribute("aria-disabled"),this._active||this._applyActive(e),this):this}disableTab(t){let e=this._require(t);if(e.definition.disabled)return this;if(e===this._active){let s=this._enabledTabs().find(n=>n!==e)??null;if(s){if(this.openTab(s.definition.name),this._active===e)return this}else e.tab.setAttribute("aria-selected","false"),e.tab.tabIndex=-1,e.panel.hidden=!0,this._keepAlive||e.panel.remove(),this._active=null}return e.definition.disabled=!0,e.tab.setAttribute("aria-disabled","true"),e.tab.tabIndex=-1,this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&Ah(this.el,this._original))}_onKeydown(t){let e=t.target.closest?.('[role="tab"]');if(!e||!this.refs.tablist.contains(e))return;let s=this._recordForTab(e);if(!s)return;let n=this._enabledTabs();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let r=t.key==="ArrowRight"?1:-1,o=n.indexOf(s),l=n[(o+r+n.length)%n.length];l&&this._setFocused(l);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(s.definition.name);return}t.key==="Delete"&&s.definition.closable&&(t.preventDefault(),this._closeTab(s))}_closeTab(t){let e=this._tabs.indexOf(t),s=t.tab.contains(document.activeElement);if(!this._removeTab(t.definition.name,!0))return;let 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,s)}_removeTab(t,e){let s=this._find(t);if(!s)return!1;let n=this._tabs.indexOf(s),o=this._tabs.filter(c=>c!==s).filter(c=>!c.definition.disabled),l=o.find(c=>this._tabs.indexOf(c)>n)??o.at(-1)??null;return s===this._active&&l&&this.emit("change",{name:l.definition.name,previous:s.definition.name}).defaultPrevented?!1:(this._tabs.splice(n,1),s.tab.remove(),s.panel.remove(),s===this._active&&(this._active=null,l&&this._applyActive(l)),e&&this.emit("close",{name:s.definition.name}),!0)}_applyActive(t){this._ensureContent(t);let e=this._active;e&&e!==t&&(e.tab.setAttribute("aria-selected","false"),e.panel.hidden=!0,this._keepAlive||e.panel.remove()),this._active=t,t.tab.setAttribute("aria-selected","true"),t.panel.hidden=!1,t.panel.parentNode!==this.refs.panels&&this.refs.panels.append(t.panel),this._setFocused(t,!1)}_ensureContent(t){if(t.built)return;let e=typeof t.definition.content=="function"?t.definition.content():t.definition.content,s=e instanceof _?e.toElement():e;if(!s||typeof s.nodeType!="number")throw new TypeError(`Tab content factory for ${t.definition.name} must return a Node or Component`);t.panel.append(s),t.built=!0}_setFocused(t,e=!0){for(let s of this._tabs)s.tab.tabIndex=s===t?0:-1;e&&t.tab.focus()}_enabledTabs(){return this._tabs.filter(t=>!t.definition.disabled)}_find(t){return this._tabs.find(e=>e.definition.name===t)??null}_require(t){let e=this._find(t);if(!e)throw new RangeError(`Unknown tab: ${t}`);return e}_recordForTab(t){return this._tabs.find(e=>e.tab===t)??null}};function vh(i){return typeof i=="function"||i instanceof _?!0:!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function wh(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Ah(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function Sh(i,t){return String(i).localeCompare(String(t))}function kh(i,t){return i-t}function zh(i,t){return i.getTime()-t.getTime()}function Ch(i,t,e="asc"){let s=i==null,n=t==null;if(s||n)return s&&n?0:s?1:-1;let r;return i instanceof Date&&t instanceof Date?r=zh(i,t):typeof i=="number"&&typeof t=="number"?r=kh(i,t):r=Sh(i,t),e==="desc"?-r:r}function Th(i,t="asc"){return(e,s)=>Ch(i(e),i(s),t)}function cn(i,t,e="asc"){let s=Th(t,e);return i.map((n,r)=>({row:n,index:r})).sort((n,r)=>s(n.row,r.row)||n.index-r.index).map(({row:n})=>n)}var Eh=new Set(["text","number","select","date","checkbox","textarea"]),Ih='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',kt=class extends _{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,hiddenColumns:[]};constructor(t,e={}){super(t,e)}render(){let t=this.el===null,e=this.el??a("div");if(this.el=e,this._createdRoot=t,this._original=t?null:k(e),this._columns=Array.isArray(this.options.columns)?this.options.columns.map(s=>({...s})):[],this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._selected=new Set,this._selectionAnchorId=null,this._sort=jh(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=Hh(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=Uh(this.options.growing),this._rendered=this._growStep??1/0,this._more=null,this._rovingKey=null,this._rovingCell=null,this._rovingMatched=!1,this._hierarchy=Bh(this.options.hierarchy,this._columns),this._hiddenColumns=new Set((Array.isArray(this.options.hiddenColumns)?this.options.hiddenColumns:[]).map(String).filter(s=>this._columns.some(n=>n.id===s))),this._hiddenColumns.size>=this._columns.length&&this._columns[0]&&this._hiddenColumns.delete(this._columns[0].id),this._dragId=null,this._grabbedId=null,this._expanded=Ph(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let s of xs(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(s);return this._reconcileExpanded(),this._table=a("table",{class:"zx-table__table"}),this._hierarchy&&this._table.setAttribute("role","treegrid"),this._colgroup=a("colgroup",{class:"zx-table__columns"}),this._thead=a("thead",{class:"zx-table__head"}),this._tbody=a("tbody",{class:"zx-table__body"}),this._table.append(this._colgroup,this._thead,this._tbody),this._scroll=a("div",{class:"zx-table__scroll",dataset:{stickyHeader:String(!!this.options.stickyHeader),zebra:String(!!this.options.zebra)}},this._table),this._rowMoveMessage=this.options.rowReorder?a("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._createColumnControls():null,this._editMode===!1?e.replaceChildren(...[this._columnControls,this._scroll,this._rowMoveMessage].filter(Boolean)):(e.dataset.editMode=this._editMode,this._editMessage=a("div",{class:"zx-table__message",id:y("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",s=>this._handleBodyClick(s)),this.listen(this._tbody,"dblclick",s=>this._handleBodyDoubleClick(s)),this.options.rowReorder&&(this.listen(this._tbody,"dragstart",s=>this._handleRowDragStart(s)),this.listen(this._tbody,"dragover",s=>this._handleRowDragOver(s)),this.listen(this._tbody,"drop",s=>this._handleRowDrop(s)),this.listen(this._tbody,"dragend",()=>this._clearRowDrag()),this.listen(this._tbody,"keydown",s=>this._handleRowHandleKeydown(s))),this._columnControls&&this.listen(this._columnControls,"change",s=>{let n=s.target;n?.classList.contains("zx-table__column-toggle")&&this.setColumnVisible(n.value,n.checked)}),this._editMode!==!1&&(this.listen(this._tbody,"keydown",s=>this._handleEditKeydown(s)),this.listen(this._tbody,"focusin",s=>this._handleEditFocusIn(s)),this.listen(document,"pointerdown",s=>this._handleDocumentPointerDown(s),{capture:!0})),e}setLoading(t=!0){return t?this.el.dataset.loading="true":delete this.el.dataset.loading,this.el.setAttribute("aria-busy",String(!!t)),this}setData(t){this._rendered=this._growStep??1/0,this.setLoading(!1),Go(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 Go(t),this._data.push(...t),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),this._emitDataChange(),this}updateRow(t,e){let s=this._data.findIndex(r=>Object.is(this._idFor(r),t));if(s<0)return this;let n=this._selected.delete(t);return this._data[s]=e,n&&this._selected.add(this._idFor(e)),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),n&&!Object.is(t,this._idFor(e))&&this._emitSelectionChange(),this._emitDataChange(),this}removeRow(t){let e=this._data.findIndex(n=>Object.is(this._idFor(n),t));if(e<0)return this;this._data.splice(e,1),this._reconcileExpanded();let s=this._selected.delete(t);return Object.is(this._selectionAnchorId,t)&&(this._selectionAnchorId=null),this._renderBody(),s&&this._emitSelectionChange(),this._emitDataChange(),this}getRow(t){return this._data.find(e=>Object.is(this._idFor(e),t))??null}getData(){return[...this._data]}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,s={}){if(!this._columns.find(c=>c.id===t))throw new RangeError(`Unknown table column: ${t}`);let r=document.activeElement,o=r?.classList.contains("zx-table__column-toggle")&&this._columnList?.contains(r)?r.value:null;if(!e&&!this._hiddenColumns.has(t)&&this._visibleColumns().length<=1)return this._renderColumnControls(o),this;let l=e?this._hiddenColumns.delete(t):!this._hiddenColumns.has(t);return!e&&l&&this._hiddenColumns.add(t),l?(this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(o),s.silent||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()}),this):this}toggleColumn(t,e={}){return this.setColumnVisible(t,this._hiddenColumns.has(t),e)}moveRow(t,e,s="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=dn(this._data,this.options.rowId,t,e,s,this._hierarchy?.parentId);if(!o)return this;if(this.emit("rowmove",{row:n,id:t,target:r,targetId:e,position:s}).defaultPrevented)return this;if(this._data=o,this._renderBody(),this._rowMoveMessage){let c=this._siblingIds(t),h=c.findIndex(u=>Object.is(u,t));this._rowMoveMessage.textContent=`Moved row to position ${h+1} of ${c.length}.`}return this._emitDataChange(),queueMicrotask(()=>this._rowHandle(t)?.focus()),this}empty(){let t=this._selected.size>0;return this._data=[],this._expanded.clear(),this._selected.clear(),this._selectionAnchorId=null,this._renderBody(),t&&this._emitSelectionChange(),this._emitDataChange(),this}setSort(t,e,s={}){if(this._abortEdit({focus:!1}),!this._columns.find(o=>o.id===t))throw new RangeError(`Unknown table column: ${t}`);let r=e??(this._sort?.id===t&&this._sort.dir==="asc"?"desc":"asc");if(r!=="asc"&&r!=="desc")throw new TypeError('Table sort direction must be "asc" or "desc"');return this._sort={id:t,dir:r},this.options.sortMode==="local"&&(this._sortData(),this._renderBody()),this._syncSortHeader(),s.silent||this.emit("sort",{id:t,dir:r}),this}getSelection(){return this._data.filter(t=>this._selected.has(this._idFor(t)))}setSelection(t){if(!Array.isArray(t))throw new TypeError("Table selection must be an array of row ids");let e=new Set(this._data.map(n=>this._idFor(n))),s=new Set;if(this.options.selectable!==!1){for(let n of t)if(e.has(n)&&s.add(n),this.options.selectable==="single"&&s.size>0)break}return Kh(this._selected,s)?this:(this._selected=s,this._syncSelection(),this._emitSelectionChange(),this)}clearSelection(){return this._selected.size===0?this:(this._selected.clear(),this._selectionAnchorId=null,this._syncSelection(),this._emitSelectionChange(),this)}toggleRow(t,e={}){return this._expanded.has(t)?this.collapseRow(t,e):this.expandRow(t,e)}expandRow(t,e={}){return this._setRowExpanded(t,!0,e)}collapseRow(t,e={}){return this._setRowExpanded(t,!1,e)}expandAll(t={}){if(!this._hierarchy)return this;let s=xs(this._data,this.options.rowId,this._hierarchy.parentId).filter(n=>!this._expanded.has(n));for(let n of s)this._expanded.add(n);if(s.length&&this._renderBody(),!t.silent)for(let n of s)this._emitRowToggle(n,!0);return this}collapseAll(t={}){if(!this._hierarchy||this._expanded.size===0)return this;let e=[...this._expanded];if(this._expanded.clear(),this._renderBody(),!t.silent)for(let s of e)this._emitRowToggle(s,!1);return this}getExpanded(){return this._data.map(t=>this._idFor(t)).filter(t=>this._expanded.has(t))}startEdit(t,e){if(this._editMode===!1)return this;let s=this._columns.find(f=>f.id===e);if(!s)return this;let n=this._data.find(f=>Object.is(this._idFor(f),t));if(n===void 0)return this;let r=this._editMode==="row"&&this._hiddenColumns.has(s.id)?this._visibleColumns().find(f=>ue(f,n)!==!1)??null:s;if(!r||ue(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 l=this._data.findIndex(f=>Object.is(this._idFor(f),t));if(l<0)return this;let c=this._data[l],h=this._rowElements.get(t)?.[0];if(!h)return this;let u=this._editMode==="row"?this._visibleColumns().filter(f=>ue(f,c)!==!1):[r],d=new Map;for(let f of u){let p=Wo(h,f.id);if(!p)continue;let m=this._createEditor(p,f,c,l);m&&d.set(f.id,m)}return d.size===0?this:(this._edit={id:t,columnId:o,row:c,cells:d,tr:h},h.dataset.editing="true",this.emit("editstart",{row:c,id:t,column:r,columnId:o,value:c?.[o]}),this._focusEditor(o),this)}commitEdit(){let t=this._edit;if(!t)return this;let e=this.getRow(t.id)??t.row,s={};for(let[d,f]of t.cells)s[d]=f.read();let n=this._columns.filter(d=>t.cells.has(d.id)),r=qh(s,n,e,this._msgOr("table.invalid","Invalid value"));if(r)return this._markInvalid(r.columnId,r.message),t.columnId=r.columnId,this.emit("editinvalid",{row:e,id:t.id,column:this._columns.find(d=>d.id===r.columnId)??null,columnId:r.columnId,value:s[r.columnId],message:r.message}),this._focusEditor(r.columnId),this;this._clearInvalid();let o=Rh(e,s),l=t.columnId;if(this.emit("editcommit",{row:e,id:t.id,column:this._columns.find(d=>d.id===l)??null,columnId:l,value:s[l],previous:e?.[l],changes:o}).defaultPrevented)return this;let h=this._editHasFocus(),u={...e,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(t.id,u),h&&this._focusCell(this._idFor(u),l),this}cancelEdit(){return this._abortEdit({focus:!0}),this}isEditing(){return this._edit!==null}getEditing(){return this._edit?{id:this._edit.id,columnId:this._edit.columnId}:null}_visibleData(){return this._visibleEntries().map(t=>t.row)}_projectedData(){return this._hierarchy?Nh(this._data,this.options.rowId,this._hierarchy.parentId,this._expanded):this._data.map((t,e)=>({row:t,id:this._idFor(t),index:e,depth:0,hasChildren:!1,parentId:null}))}_visibleEntries(){let t=this._projectedData();return this._rendered===1/0?t:t.slice(0,this._rendered)}growBy(t){if(!this._growStep)return this;let e=Number(t)>0?Math.trunc(Number(t)):this._growStep,s=this._rendered,n=this._projectedData().length;return this._rendered=Math.min(n,this._rendered+e),this._rendered===s?this:(this._renderBody(),this.emit("grow",{rendered:this._rendered,total:n}),this)}showAll(){return this.growBy(this._projectedData().length)}getRenderedCount(){return Math.min(this._rendered,this._projectedData().length)}_syncGrowing(){if(!this._growStep)return;let t=this._projectedData().length-this.getRenderedCount();if(t<=0){this._more?.remove(),this._more=null;return}let e=this._message("table.more","Show %1 more",[t]);this._more||(this._more=a("button",{class:"zx-table__more",type:"button",onclick:()=>this.growBy()}),this.el.append(this._more)),this._more.textContent=e,this._more.setAttribute("aria-label",e)}_message(t,e,s){let n=this.msg(t,...s);return n===t?R(e,s):n}_watchWidth(){this._width?.destroy(),this._width=null;let t=this.options.responsive;!t||!(t in Mt)||(this._width=oe((e,s)=>this._setStacked(s>0&&s<Mt[t]),{target:this.el}))}_setStacked(t){this._stacked!==t&&(this._stacked=t,this.el.toggleAttribute("data-stacked",t),this._applyStackedRoles(t),this.emit("stackedchange",{stacked:t}))}_applyStackedRoles(t){let e=[[this._table,this._hierarchy?"treegrid":"table"],[this._thead,"rowgroup"],[this._tbody,"rowgroup"]];for(let[s,n]of e)s&&(t?s.setAttribute("role",n):s===this._table&&this._hierarchy?s.setAttribute("role","treegrid"):s.removeAttribute("role"));for(let[s,n]of[["tr","row"],["td","cell"],["th","columnheader"]])for(let r of this._table.querySelectorAll(s))t?r.setAttribute("role",n):r.removeAttribute("role")}isStacked(){return!!this._stacked}destroy(){this._teardownEdit(),this._width?.destroy(),this._width=null,!this._restored&&!this._createdRoot&&(S(this.el,this._original),this._restored=!0),super.destroy()}_visibleColumns(){return this._columns.filter(t=>!this._hiddenColumns.has(t.id))}_createColumnControls(){let t=a("div",{class:"zx-table__column-list"});this._columnList=t;let e=a("details",{class:"zx-table__column-controls"},a("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(),s=[...this._columnList.querySelectorAll(".zx-table__column-toggle")];if(s.length===this._columns.length&&s.every((r,o)=>r.value===this._columns[o].id)){s.forEach((r,o)=>{let l=r,c=!this._hiddenColumns.has(this._columns[o].id);l.checked=c,l.disabled=c&&e.length===1});return}if(this._columnList.replaceChildren(...this._columns.map(r=>{let o=!this._hiddenColumns.has(r.id);return a("label",{class:"zx-table__column-option"},a("input",{class:"zx-table__column-toggle",type:"checkbox",value:r.id,checked:o,disabled:o&&e.length===1}),a("span",{},r.label))})),t!==null){let r=[...this._columnList.querySelectorAll(".zx-table__column-toggle")].find(o=>o.value===t);queueMicrotask(()=>{r?.isConnected&&r.focus()})}}_handleRowDragStart(t){let e=t.target?.closest?.(".zx-table__row-handle"),s=e?.closest("tr[data-row]"),n=s?this._rowMeta.get(s):null;if(!e||!n||this._sort&&this.options.sortMode==="local"){t.preventDefault();return}this._dragId=n.id,s.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]"),s=e?this._rowMeta.get(e):null;if(!s||Object.is(s.id,this._dragId)||!this._canMoveTogether(this._dragId,s.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]"),s=e?this._rowMeta.get(e):null,n=e?.dataset.drop==="after"?"after":"before";s&&this._canMoveTogether(this._dragId,s.id)&&(t.preventDefault(),this.moveRow(this._dragId,s.id,n)),this._clearRowDrag()}_handleRowHandleKeydown(t){let e=t.target?.closest?.(".zx-table__row-handle"),s=e?.closest("tr[data-row]"),n=s?this._rowMeta.get(s):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)),l=r[o+(t.key==="ArrowUp"?-1:1)];l!==void 0&&this.moveRow(n.id,l,t.key==="ArrowUp"?"before":"after")}_siblingIds(t){let e=this.getRow(t);if(!e)return[];let s=this._hierarchy?it(this._hierarchy.parentId,e):null;return this._data.filter(n=>!this._hierarchy||un(it(this._hierarchy.parentId,n),s)).map(n=>this._idFor(n))}_canMoveTogether(t,e){if(!this._hierarchy)return!0;let s=this.getRow(t),n=this.getRow(e);return!!(s&&n&&un(it(this._hierarchy.parentId,s),it(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(a("col",{class:"zx-table__reorder-column"})),this.options.selectable==="multi"&&t.append(a("col",{class:"zx-table__selection-column"}));let e=this._visibleColumns(),s=e.map(r=>$h(r.width)),n=s.reduce((r,o)=>r+o,0);this._table.dataset.layout=n>0?"fixed":"auto",e.forEach((r,o)=>{let l=a("col");s[o]>0?l.style.width=`${s[o]/n*100}%`:r.width&&r.width!=="auto"&&(l.style.width=String(r.width)),t.append(l)}),this._colgroup.replaceChildren(t)}_renderHeader(){let t=a("tr",{class:"zx-table__header-row"});if(this._growStep&&t.setAttribute("aria-rowindex","1"),this.options.rowReorder&&t.append(a("th",{class:"zx-table__reorder-header",scope:"col",ariaLabel:"Row order"})),this.options.selectable==="multi"){this._selectAll=a("input",{class:"zx-table__checkbox zx-table__select-all",type:"checkbox",ariaLabel:"Select all rows"});let e=a("th",{class:"zx-table__selection-header",scope:"col"},this._selectAll);t.append(e),this.listen(this._selectAll,"click",()=>{if(this._selectAll.checked)for(let s of this._visibleData())this._selected.add(this._idFor(s));else for(let s of this._visibleData())this._selected.delete(this._idFor(s));this._selectionAnchorId=null,this._syncSelection(),this._emitSelectionChange()})}else this._selectAll=null;this._headers=new Map;for(let e of this._visibleColumns()){let s=a("th",{scope:"col"}),n=e.align??(hn(e)?"end":null);if(n&&(s.dataset.align=n),e.headerTitle&&(s.title=e.headerTitle),e.sortable){let r=a("button",{class:"zx-table__sort-button",type:"button"},a("span",{class:"zx-table__header-label"},e.label));this.listen(r,"click",()=>{let o=this._sort?.id===e.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(e.id,o)}),s.append(r)}else s.append(a("span",{class:"zx-table__header-label"},e.label));this._headers.set(e.id,s),t.append(s)}this._thead.replaceChildren(t),this._syncSortHeader()}_renderBody(){this._abortEdit({focus:!1});let t=document.createDocumentFragment();this._rowMeta=new WeakMap,this._rowElements=new Map,this._rovingCell=null,this._rovingMatched=!1;let e=this._projectedData();this._hierarchyMeta=new Map(e.map(s=>[s.id,s])),this._data.length===0?t.append(a("tr",{class:"zx-table__empty-row"},a("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((s,n)=>{t.append(this._createRow(s.row,s.index,{...s,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,s){let n=this._idFor(t),r=a("tr",{dataset:{row:""}});this._growStep&&r.setAttribute("aria-rowindex",String(s.visibleIndex+2));let o=typeof this.options.rowClass=="function"?this.options.rowClass(t):"";o&&r.classList.add(...String(o).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&r.setAttribute("aria-selected",String(this._selected.has(n))),this._hierarchy&&(r.setAttribute("aria-level",String(s.depth+1)),s.hasChildren&&r.setAttribute("aria-expanded",String(this._expanded.has(n)))),this._rowMeta.set(r,{row:t,id:n,index:e,visibleIndex:s.visibleIndex});let l=this._rowElements.get(n)??[];if(l.push(r),this._rowElements.set(n,l),this.options.rowReorder){let c=a("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(a("td",{class:"zx-table__reorder-cell"},c))}if(this.options.selectable==="multi"){let c=a("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",checked:this._selected.has(n),ariaLabel:`Select row ${e+1}`});r.append(a("td",{class:"zx-table__selection-cell"},c))}return this._visibleColumns().forEach(c=>{let h=a("td"),u=c.align??(hn(c)?"end":null);u&&(h.dataset.align=u),h.dataset.label=c.label,c.popin===!1&&(h.dataset.popin="false"),this._editMode!==!1&&(h.dataset.column=c.id,ue(c,t)!==!1&&(h.dataset.editable="true",h.tabIndex=-1,this._offerRovingCell(h,n,c.id))),this._renderCellContent(h,c,t,e,s),r.append(h)}),r}_renderCellContent(t,e,s,n,r=this._hierarchyMeta?.get(this._idFor(s))){let o=Dh(e,s,n),l=a("span",{class:"zx-table__cell-content"});if(o&&typeof o=="object"&&typeof o.nodeType=="number"?l.append(o):o!=null&&l.append(document.createTextNode(String(o))),!this._hierarchy||e.id!==this._hierarchyColumn()||!r){t.replaceChildren(...l.childNodes);return}let c=a("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(a("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(a("span",{class:"zx-table__tree-spacer",ariaHidden:"true"}));c.append(l),t.replaceChildren(c)}_handleBodyClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(this._edit&&vs(e))return;let s=e?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s);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(!Yo(e)){if(this._editMode!==!1&&this._editTrigger==="single"){let l=e?.closest('td[data-editable="true"]');if(l&&this._tbody.contains(l)){this.startEdit(n.id,String(l.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&&vs(e))return;let s=e?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s);if(n&&!Yo(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,s,n){let r=ue(e,s);if(r===!1)return null;let o=s?.[e.id],l=e.editorProps&&typeof e.editorProps=="object"?e.editorProps:{},c=a("span",{class:"zx-table__cell-shadow",ariaHidden:"true"});c.append(...t.childNodes);let h=a("div",{class:"zx-table__editor",dataset:{editor:r}});t.replaceChildren(c,h),t.dataset.editing="true";let u={column:e,type:r,td:t,host:h,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(r==="custom"){u.custom=o,u.read=()=>Ot(e,u.custom,s);let p={value:o,row:s,column:e,commit:b=>{u.custom=b,this.commitEdit()},cancel:()=>this.cancelEdit()},m=e.editor(s,p);return m&&typeof m.toElement=="function"?(typeof m.destroy=="function"&&(u.component=m),h.append(m.toElement())):m&&h.append(m),u.control=h.querySelector(Ih)??h,u}if(r==="number"){let p=Ft(e.locale,s),m=Qo(e,s),b=e.type==="currency"?Ft(e.currency,s):e.type==="unit"?Ft(e.unit,s):null,w={...p!=null&&!Object.prototype.hasOwnProperty.call(l,"locale")?{locale:p}:{},...m!=null&&!Object.prototype.hasOwnProperty.call(l,"precision")?{precision:m}:{},...b!=null&&!Object.prototype.hasOwnProperty.call(l,"unit")?{unit:String(b)}:{}},x=new wt(null,{...w,...l,value:o??null});return h.append(x.el),u.component=x,u.control=x.getInput(),u.read=()=>(x.set(x.getInput().value,{silent:!0}),Ot(e,x.get(),s)),u}if(r==="select"){let p=Oh(e.options,s),m=p.find(w=>Object.is(w.value,o))??p.find(w=>String(w.value)===String(o??"")),b=new V(null,{...l,items:p,valueKey:"value",labelKey:"label",value:m?m.value:null});return h.append(b.el),u.component=b,u.control=b.refs.input,u.read=()=>Ot(e,b.value,s),u}if(r==="date"){let p=new K(null,{...l,value:o??null});h.append(p.el),u.component=p;let m=p.refs.input;return u.control=m,u.read=()=>{let b=String(m.value??"").trim(),w=p.get();return b===""?Ot(e,null,s):(p.set(b,{silent:!0}),p.get()===null&&p.set(w,{silent:!0}),Ot(e,p.get(),s))},u}if(r==="checkbox"){let p=new W(null,{...l,checked:!!o});return h.append(p.el),u.component=p,u.control=p.el,u.read=()=>Ot(e,p.get(),s),u}let d=r==="textarea",f=a(d?"textarea":"input",{...l,class:d?"zx-table__editor-input zx-table__editor-textarea":"zx-table__editor-input",...d?{}:{type:"text"},ariaLabel:l.ariaLabel??`${e.label} row ${n+1}`,value:Fh(e,o,s)});return h.append(f),u.control=f,u.read=()=>Ot(e,f.value,s),u}_focusEditor(t){let e=this._edit?.cells.get(t),s=e?.control;!s||typeof s.focus!="function"||(s.focus(),e.type==="text"&&typeof s.select=="function"&&s.select())}_focusCell(t,e){let s=this._rowElements.get(t)?.[0];(s?Wo(s,e):null)?.focus()}_teardownEdit(){let t=this._edit;if(!t)return;this._edit=null;let e=this._data.findIndex(n=>Object.is(this._idFor(n),t.id)),s=e<0?t.row:this._data[e];for(let n of t.cells.values())n.destroy(),delete n.td.dataset.editing,delete n.td.dataset.invalid,this._renderCellContent(n.td,n.column,s,e<0?0:e);t.cells.clear(),delete t.tr.dataset.editing,this._clearInvalid()}_abortEdit({focus:t=!0}={}){let e=this._edit;if(!e)return;let s=t&&this._editHasFocus(),n=this.getRow(e.id)??e.row,r=this._columns.find(o=>o.id===e.columnId)??null;this._teardownEdit(),s&&this._focusCell(e.id,e.columnId),this.emit("editcancel",{row:n,id:e.id,column:r,columnId:e.columnId})}_editHasFocus(){let t=document.activeElement;return!!(t&&this.el?.contains(t))}_markInvalid(t,e){this._clearInvalid();let s=this._edit?.cells.get(t);s&&(s.td.dataset.invalid="true",s.control?.setAttribute("aria-invalid","true"),this._editMessage&&(s.control?.setAttribute("aria-describedby",this._editMessage.id),this._editMessage.textContent=e))}_clearInvalid(){if(this._edit)for(let t of this._edit.cells.values())delete t.td.dataset.invalid,t.control?.removeAttribute("aria-invalid"),t.control?.removeAttribute("aria-describedby");this._editMessage&&(this._editMessage.textContent="")}_handleEditKeydown(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(!e)return;if(this._edit&&vs(e)){if(Vh(e))return;if(t.key==="Escape"){if(t.defaultPrevented)return;t.preventDefault(),this.cancelEdit();return}if(t.key==="Enter"){if(e.localName==="textarea"&&t.shiftKey)return;t.preventDefault(),this.commitEdit();return}t.key==="Tab"&&this._moveEdit(t);return}if(t.key!=="Enter"&&t.key!=="F2")return;let s=e.closest('td[data-editable="true"]');if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s.parentElement);n&&(t.preventDefault(),this.startEdit(n.id,String(s.dataset.column)))}_moveEdit(t){let e=this._edit;if(!e)return;let s=t.shiftKey?-1:1,n=this._data.findIndex(o=>Object.is(this._idFor(o),e.id)),r=this._nextEditableCell(n,e.columnId,s);if(r&&Object.is(r.id,e.id)&&e.cells.has(r.columnId)){t.preventDefault(),e.columnId=r.columnId,this._focusEditor(r.columnId);return}if(!r){this.commitEdit(),this._edit&&t.preventDefault();return}t.preventDefault(),this.commitEdit(),this._edit||this.startEdit(r.id,r.columnId)}_nextEditableCell(t,e,s){let n=this._visibleColumns(),r=n.length;if(t<0||r===0)return null;let o=this._visibleData(),l=this._idFor(this._data[t]),c=o.findIndex(d=>Object.is(this._idFor(d),l));if(c<0)return null;let h=n.findIndex(d=>d.id===e),u=o.length*r+r;for(let d=0;d<u;d+=1){if(h+=s,h>=r?(c+=1,h=0):h<0&&(c-=1,h=r-1),c<0||c>=o.length)return null;let f=o[c],p=n[h];if(ue(p,f)!==!1)return{id:this._idFor(f),columnId:p.id,index:this._data.indexOf(f)}}return null}_handleEditFocusIn(t){let s=(t.target?.nodeType===1?t.target:null)?.closest('td[data-editable="true"]');if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s.parentElement);n&&this._setRovingCell(s,n.id,String(s.dataset.column))}_handleDocumentPointerDown(t){if(!this._edit)return;let e=t.target?.nodeType===1?t.target:t.target?.parentElement;e&&vs(e)||e&&this._tbody.contains(e)||this.commitEdit()}_offerRovingCell(t,e,s){if(this._rovingMatched)return;let n=this._rovingKey!==null&&Object.is(this._rovingKey.id,e)&&this._rovingKey.columnId===s;!n&&this._rovingCell||(n&&this._rovingCell&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=n)}_setRovingCell(t,e,s){this._rovingCell&&this._rovingCell!==t&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=!0,this._rovingKey={id:e,columnId:s}}_msgOr(t,e){let s=this.msg(t);return s===t?e:s}_toggleMultiSelection(t,e,s){let n=this._visibleData(),r=n.findIndex(o=>Object.is(this._idFor(o),this._selectionAnchorId));if(s&&r>=0){let o=t.visibleIndex??n.findIndex(h=>Object.is(this._idFor(h),t.id)),l=Math.min(r,o),c=Math.max(r,o);for(let h=l;h<=c;h+=1){let u=this._idFor(n[h]);e?this._selected.add(u):this._selected.delete(u)}}else e?this._selected.add(t.id):this._selected.delete(t.id);this._selectionAnchorId=t.id,this._syncSelection(),this._emitSelectionChange()}_syncSelection(){for(let[t,e]of this._rowElements){let s=this._selected.has(t);for(let n of e){n.setAttribute("aria-selected",String(s));let r=n.querySelector(".zx-table__row-checkbox");r&&(r.checked=s)}}this._syncSelectAll()}_syncSelectAll(){if(!this._selectAll)return;let t=this._visibleData(),e=t.reduce((s,n)=>s+Number(this._selected.has(this._idFor(n))),0);this._selectAll.disabled=t.length===0,this._selectAll.checked=t.length>0&&e===t.length,this._selectAll.indeterminate=e>0&&e<t.length}_syncSortHeader(){if(this._headers)for(let[t,e]of this._headers)this._sort?.id===t?e.setAttribute("aria-sort",this._sort.dir==="asc"?"ascending":"descending"):e.removeAttribute("aria-sort")}_sortData(){if(!this._sort)return;let t=this._columns.find(s=>s.id===this._sort.id);if(!t)return;let e=typeof t.sortValue=="function"?t.sortValue:s=>s?.[t.id];this._data=this._hierarchy?Mh(this._data,this.options.rowId,this._hierarchy.parentId,e,this._sort.dir):cn(this._data,e,this._sort.dir)}_setRowExpanded(t,e,s){return this._hierarchy?xs(this._data,this.options.rowId,this._hierarchy.parentId).some(r=>Object.is(r,t))?this._expanded.has(t)===e?this:(e?this._expanded.add(t):this._expanded.delete(t),this._renderBody(),s.silent||this._emitRowToggle(t,e),this):this:this}_emitRowToggle(t,e){let s=this.getRow(t);s&&this.emit("rowtoggle",{row:s,id:t,expanded:e})}_reconcileExpanded(){if(!this._hierarchy){this._expanded.clear();return}let t=xs(this._data,this.options.rowId,this._hierarchy.parentId),e=new Set(t);for(let s of this._expanded)e.has(s)||this._expanded.delete(s)}_pruneSelection(){let t=new Set(this._data.map(s=>this._idFor(s))),e=this._selected.size;for(let s of this._selected)t.has(s)||this._selected.delete(s);return t.has(this._selectionAnchorId)||(this._selectionAnchorId=null),e!==this._selected.size}_idFor(t){return typeof this.options.rowId=="function"?this.options.rowId(t):t?.[this.options.rowId]}_emitSelectionChange(){let t=this.getSelection();this.emit("selectionchange",{rows:t,ids:t.map(e=>this._idFor(e))})}_emitDataChange(){this.emit("datachange",{rows:this.getData()})}};function Dh(i,t,e=0){if(typeof i?.render=="function")return i.render(t,e);let s=t?.[i?.id],n=i?.type??"text";if(n==="text")return s;let r=Ft(i.locale,t),o=Qo(i,t),l={...r!=null?{locale:String(r)}:{},...o!=null?{decimals:o}:{}};if(n==="number")return At(s,l);if(n==="currency"){let c=Ft(i.currency,t);return _s(s,c==null?null:String(c),l)}if(n==="percent")return ms(s,l);if(n==="unit"){let c=At(s,l),h=Ft(i.unit,t);return c&&h!=null&&String(h)!==""?`${c}\xA0${h}`:c}return s}function Nh(i,t,e,s=[]){let n=ws(i,t,e),r=s instanceof Set?s:new Set(s),o=[],l=n.roots.slice().reverse().map(c=>({node:c,depth:0}));for(;l.length;){let{node:c,depth:h}=l.pop();if(o.push({row:c.row,id:c.id,index:c.index,depth:h,hasChildren:c.children.length>0,parentId:c.parent?.id??null}),!!r.has(c.id))for(let u=c.children.length-1;u>=0;u-=1)l.push({node:c.children[u],depth:h+1})}return o}function Mh(i,t,e,s,n){let r=ws(i,t,e),o=h=>cn(h,u=>s(u.row),n),l=[],c=o(r.roots).reverse();for(;c.length;){let h=c.pop();l.push(h.row);let u=o(h.children);for(let d=u.length-1;d>=0;d-=1)c.push(u[d])}return l}function dn(i,t,e,s,n="before",r=null){if(!Array.isArray(i)||Object.is(e,s))return null;let o=i.findIndex(d=>Object.is(it(t,d),e)),l=i.findIndex(d=>Object.is(it(t,d),s));if(o<0||l<0||r&&!un(it(r,i[o]),it(r,i[l])))return null;if(r){let d=ws(i,t,r),f=d.nodes[o],p=d.nodes[l];if(!f||!p||f.parent!==p.parent)return null;let m=O=>{let j=[],ye=[O];for(;ye.length;){let Ti=ye.pop();j.push(Ti);for(let Ei=Ti.children.length-1;Ei>=0;Ei-=1)ye.push(Ti.children[Ei])}return j},b=new Set(m(f).map(O=>O.index)),w=new Set(m(p).map(O=>O.index)),x=i.filter((O,j)=>b.has(j)),v=i.filter((O,j)=>!b.has(j)),C=i.map((O,j)=>j).filter(O=>!b.has(O)),I=C.findIndex(O=>O===l);if(n==="after"){let O=C.map((j,ye)=>w.has(j)?ye:-1).filter(j=>j>=0);I=Math.max(...O)+1}return I<0?null:(v.splice(I,0,...x),v)}let c=[...i],[h]=c.splice(o,1),u=c.findIndex(d=>Object.is(it(t,d),s));return c.splice(u+(n==="after"?1:0),0,h),c}function ue(i,t){if(!i||typeof i!="object")return!1;if(typeof i.editor=="function")return typeof i.editable=="function"&&i.editable(t)===!1?!1:"custom";let e=typeof i.editable=="function"?i.editable(t):i.editable;return e===!0?hn(i)?"number":"text":typeof e=="string"&&Eh.has(e)?e:!1}function Oh(i,t){let e=typeof i=="function"?i(t):i;return Array.isArray(e)?e.map(s=>s!==null&&typeof s=="object"?{value:s.value,label:String(s.label??s.value??"")}:{value:s,label:String(s??"")}):e!==null&&typeof e=="object"?Object.entries(e).map(([s,n])=>({value:s,label:String(n??"")})):[]}function Fh(i,t,e){if(typeof i?.format=="function"){let s=i.format(t,e);return s==null?"":String(s)}return t==null?"":String(t)}function Ot(i,t,e){return typeof i?.parse=="function"?i.parse(t,e):t}function Lh(i,t){return Object.is(i,t)?!0:i instanceof Date&&t instanceof Date?i.getTime()===t.getTime():!1}function Rh(i,t){let e={};for(let[s,n]of Object.entries(t??{}))Lh(i?.[s],n)||(e[s]=n);return e}function qh(i,t,e,s="Invalid value"){for(let n of t??[]){if(typeof n?.validate!="function"||!Object.prototype.hasOwnProperty.call(i??{},n.id))continue;let r=n.validate(i[n.id],e);if(typeof r=="string")return{columnId:n.id,message:r};if(r===!1)return{columnId:n.id,message:s}}return null}function Ft(i,t){return typeof i=="function"?i(t):i}function Qo(i,t){let e=Ft(i?.decimals,t);if(e==null)return null;let s=Number(e);return Number.isFinite(s)?Math.max(0,Math.trunc(s)):null}function hn(i){return["number","currency","percent","unit"].includes(i?.type)}function ws(i,t,e){let s=(Array.isArray(i)?i:[]).map((l,c)=>({row:l,id:it(t,l),index:c,parent:null,children:[]})),n=new Map;for(let l of s)n.has(l.id)||n.set(l.id,l);let r=new Map;for(let l of s){let c=it(e,l.row),h=c==null?null:n.get(c)??null;r.set(l,h===l?null:h)}for(let l of s){let c=new Set([l]),h=r.get(l)??null;for(;h;){if(c.has(h)){r.set(h,null);break}c.add(h),h=r.get(h)??null}}let o=[];for(let l of s)l.parent=r.get(l)??null,l.parent?l.parent.children.push(l):o.push(l);return{roots:o,nodes:s}}function xs(i,t,e){return ws(i,t,e).nodes.filter(s=>s.children.length>0).map(s=>s.id)}function it(i,t){return typeof i=="function"?i(t):t?.[i]}function un(i,t){return i==null&&t==null||Object.is(i,t)}function Bh(i,t){if(!i||typeof i!="object")return null;let e=i.parentId;if(typeof e!="string"&&typeof e!="function")return null;let s=typeof i.column=="string"?i.column:null,n=t.some(r=>r.id===s)?s:t[0]?.id;return n?{...i,parentId:e,column:n}:null}function Ph(i){return new Set(Array.isArray(i)?i:[])}function Hh(i){return i==="cell"||i==="row"?i:i===!0?"cell":!1}function vs(i){return!!i?.closest?.(".zx-table__editor")}function Yo(i){let t=i?.closest?.("td[data-column]"),e=i?.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 Vh(i){return i.closest("[popover]")?!0:i.getAttribute?.("aria-expanded")==="true"}function Wo(i,t){for(let e of i.cells)if(e.dataset.column===t)return e;return null}function jh(i,t){return!i||typeof i!="object"||!t.some(e=>e.id===i.id)?null:{id:i.id,dir:i.dir==="desc"?"desc":"asc"}}function $h(i){if(typeof i!="string")return 0;let t=/^(\d*\.?\d+)fr$/.exec(i.trim());return t?Math.max(0,Number(t[1])):0}function Go(i){if(!Array.isArray(i))throw new TypeError("Table data must be an array")}function Kh(i,t){return i.size===t.size&&[...i].every(e=>t.has(e))}function Uh(i){let t=Math.trunc(Number(i));return Number.isFinite(t)&&t>0?t:null}var nt=Symbol("invalid attribute");function de(i,t="string",e=console.warn){if(Jo(t),t==="boolean")return i!==null;if(i!==null){if(t==="string")return i;if(t==="number"){let s=Number(i);return Number.isFinite(s)?s:(e(`Ignoring invalid number attribute: ${JSON.stringify(i)}`),nt)}try{return JSON.parse(i)}catch{return e(`Ignoring invalid JSON attribute: ${JSON.stringify(i)}`),nt}}}function pn(i,t="string",e=console.warn){if(Jo(t),t==="boolean")return i?"":null;if(i==null)return null;if(t==="number"){let s=Number(i);return Number.isFinite(s)?String(s):(e(`Ignoring invalid number property: ${String(i)}`),nt)}if(t==="json"){try{let s=JSON.stringify(i);if(s!==void 0)return s}catch{}return e("Ignoring property that cannot be serialized as JSON"),nt}return String(i)}function Jo(i){if(!["string","number","boolean","json"].includes(String(i)))throw new TypeError(`Unknown reflected attribute type: ${String(i)}`)}var Yh=Object.freeze(["change","input","submit","clear","open","close","cancel","invalid","query","loaded","rowclick","rowdblclick","sort","selectionchange","datachange"]),Wh=rt({checked:M({always:!0,set:(i,t)=>i.set(t,{silent:!0}),get:i=>i.get()}),value:T({default:!0}),label:T({default:null,rebuild:!0}),disabled:M({always:!0,set:Oe})}),Gh=rt({checked:M({always:!0,set:(i,t)=>i.set(t,{silent:!0}),get:i=>i.get()}),value:T({option:null,default:"on"}),label:T({default:"",set:(i,t)=>i.setLabel(t)}),icon:M({rebuild:!0}),disabled:M({always:!0,set:Oe})}),Qh=rt({items:_t({default:[],set:(i,t)=>i.setItems(t)}),value:T({default:null,set:(i,t)=>i.set(t,{silent:!0}),get:i=>i.value}),"value-key":T({property:"valueKey",default:"ID",rebuild:!0}),"label-key":T({property:"labelKey",default:"name",rebuild:!0}),placeholder:T({default:"",set:(i,t)=>{i.refs.input.placeholder=t}}),clearable:M({default:!1,rebuild:!0}),filter:T({default:!1,normalize:cu,rebuild:!0}),"search-keys":_t({property:"searchKeys",default:null,rebuild:!0}),"min-query":pe({property:"minQuery",default:0,rebuild:!0}),debounce:pe({default:200,rebuild:!0}),"list-height":pe({property:"listHeight",default:280,rebuild:!0}),disabled:M({always:!0,set:Oe}),required:M({option:null,always:!0}),name:T({option:null,default:""})}),Jh=rt({items:_t({default:[],set:(i,t)=>i.setItems(t)}),value:_t({option:null,default:[],set:(i,t)=>i.setValues(t),get:i=>i.getValues()}),"value-key":T({property:"valueKey",default:"ID",rebuild:!0}),"label-key":T({property:"labelKey",default:"name",rebuild:!0}),"checked-key":T({property:"checkedKey",default:"on",rebuild:!0}),search:M({rebuild:!0}),height:pe({default:280,rebuild:!0}),"default-checked":M({property:"defaultChecked",default:!1,rebuild:!0}),disabled:M({option:null,always:!0,set:lu}),name:T({option:null,default:""})}),Xh=rt({format:T({default:"%d.%m.%Y",rebuild:!0}),time:M({always:!0,rebuild:!0}),value:T({option:null,default:null,normalize:pu,set:(i,t)=>i.set(t,{silent:!0}),get:(i,t)=>_n(i.get(),!!t.time),serialize:fu}),placeholder:T({default:null,rebuild:!0}),clearable:M({rebuild:!0}),disabled:M({always:!0,set:Oe}),required:M({option:null,always:!0}),name:T({option:null,default:""})}),Zh=rt({value:pe({default:0,set:(i,t)=>i.set(t,{silent:!0}),get:i=>i.get()}),unit:T({default:"minutes",rebuild:!0}),seconds:M({always:!0,rebuild:!0}),signed:M({always:!0,rebuild:!0}),disabled:M({always:!0,set:Oe}),name:T({option:null,default:""})}),tu=rt({value:T({default:"",set:(i,t)=>i.set(t,{silent:!0}),get:i=>i.get()}),placeholder:T({default:"",set:(i,t)=>{i.refs.input.placeholder=t}}),clearable:M({rebuild:!0}),debounce:pe({default:250,rebuild:!0})}),eu=rt({title:T({default:"",set:(i,t)=>i.setTitle(t)}),open:M({default:!1,always:!0,set:(i,t)=>t?i.open():i.close(),get:i=>i.isOpen()})}),su=rt({tabs:_t({default:[],normalize:uu,rebuild:!0}),active:T({default:null,set:(i,t)=>{t!==null&&i.openTab(t)},get:i=>i.getActive()}),variant:T({default:"divided",rebuild:!0}),"keep-alive":M({property:"keepAlive",rebuild:!0})}),iu=rt({columns:_t({default:[],rebuild:!0}),data:_t({default:[],set:(i,t)=>i.setData(t),get:i=>i.getData()}),"row-id":T({property:"rowId",default:"ID",rebuild:!0}),sort:_t({default:null,rebuild:!0}),"sort-mode":T({property:"sortMode",default:"local",rebuild:!0}),selectable:T({default:!1,normalize:hu,rebuild:!0}),"sticky-header":M({property:"stickyHeader",rebuild:!0}),height:T({default:null,normalize:ea,rebuild:!0}),"empty-text":T({property:"emptyText",default:null,rebuild:!0}),zebra:M({rebuild:!0})}),nu=rt({title:T({default:"",set:(i,t)=>i.setTitle(t)}),size:T({default:"md",normalize:ea,rebuild:!0}),buttons:_t({default:[],set:(i,t)=>i.setButtons(t)}),closable:M({rebuild:!0}),open:M({option:null,default:!1,always:!0,set:(i,t)=>t?i.open():i.close(),get:i=>i.isOpen()})}),ru=Object.freeze([["toggle",W,{formAssociated:!0,attrs:Wh}],["check-button",pt,{formAssociated:!0,attrs:Gh}],["select",V,{formAssociated:!0,attrs:Qh}],["checklist",et,{formAssociated:!0,attrs:Jh}],["datebox",K,{formAssociated:!0,attrs:Xh}],["timebox",ht,{formAssociated:!0,attrs:Zh}],["search",ce,{formAssociated:!1,attrs:tu}],["groupbox",St,{formAssociated:!1,attrs:eu}],["tabbox",he,{formAssociated:!1,attrs:su}],["table",kt,{formAssociated:!1,attrs:iu}],["dialog",ft,{formAssociated:!1,attrs:nu}]]);function ou(i,{formAssociated:t=!1,attrs:e={}}={}){let s=ta(e),n=Object.freeze(Object.keys(s)),r=i===St||i===ft;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(s),r&&this._contentNodes===null&&(this._contentNodes=Array.from(this.childNodes)),t&&this._defaults===null&&this._captureDefaults(s),this._createComponent(i,s,r))}disconnectedCallback(){this._destroyComponent()}attributeChangedCallback(c,h,u){if(this._reflecting.has(c))return;let d=s[c];if(!d)return;let f=de(u,d.type);if(f===nt)return;this._propertyValues.delete(d.property);let p=f===void 0?As(d.default):f;this._applyValue(c,d,p)}formDisabledCallback(c){this._disabledByForm=!!c,this._syncEffectiveDisabled(s),this._syncFormState(i)}formResetCallback(){if(!this._defaults)return;let c=fn(i);!c||!this._defaults.has(c)||this._applyControlValue(s,c,As(this._defaults.get(c)))}formStateRestoreCallback(c,h){if(typeof c!="string")return;let u=mu(i,c);if(u===nt)return;let d=fn(i);d&&this._applyControlValue(s,d,u)}get component(){return this._component}get form(){return this._internals?.form??null}get labels(){return this._internals?.labels??null}get validity(){return this._internals?.validity??null}get validationMessage(){return this._internals?.validationMessage??""}get willValidate(){return this._internals?.willValidate??!1}checkValidity(){return this._internals?.checkValidity()??!0}reportValidity(){return this._internals?.reportValidity()??!0}_upgradeProperties(c){for(let h of Object.values(c)){let u=h.property;if(!Object.prototype.hasOwnProperty.call(this,u))continue;let d=this[u];delete this[u],this[u]=d}}_captureDefaults(c){this._defaults=new Map;let h=fn(i);if(h){let u=Object.values(c).find(d=>d.property===h);u&&this._defaults.set(h,As(this._readProperty(u)))}}_createComponent(c,h,u){let d={};for(let[m,b]of Object.entries(h)){if(!(this._propertyValues.has(b.property)||this.hasAttribute(m)||b.always)||b.option===null)continue;let x=this._currentValue(m,b);x===nt||x===void 0||(d[b.option]=Xo(b,x,this))}let f=null;u&&(f=document.createDocumentFragment(),f.append(...this._contentNodes),d.content=f);let p=new c(null,d);this._component=p,i===St&&f&&p.setContent(f),this.append(p.el),this._bridgeEvents(p,i);for(let[m,b]of Object.entries(h)){if(b.option!==null||!b.set||!(this._propertyValues.has(b.property)||this.hasAttribute(m)||b.always))continue;let x=this._currentValue(m,b);x!==nt&&x!==void 0&&this._applyValue(m,b,x,!0)}this._syncEffectiveDisabled(h),this._syncFormState(i)}_bridgeEvents(c,h){this._bridgeAbort?.abort(),this._bridgeAbort=new AbortController;for(let u of Yh)c.on(u,d=>{if(this._applying)return;this._syncFormState(h);let f=new CustomEvent(`zx-${u}`,{detail:d.detail??{},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(f),f.defaultPrevented&&d.preventDefault()}),c.el.addEventListener(`zx-${u}`,d=>d.stopPropagation(),{signal:this._bridgeAbort.signal})}_destroyComponent(){this._bridgeAbort?.abort(),this._bridgeAbort=null,this._component&&(this._component.destroy(),this._component=null)}_rebuildComponent(c,h=r){this._component&&(h&&this._contentNodes&&document.createDocumentFragment().append(...this._contentNodes),this._destroyComponent(),this._createComponent(i,c,h))}_applyValue(c,h,u,d=!1){if(this._component){if(h.rebuild&&!d){this._rebuildComponent(s);return}if(!h.set){this._syncFormState(i);return}this._applying=!0;try{h.set(this._component,Xo(h,u,this),this)}finally{this._applying=!1}c!=="disabled"&&this._syncEffectiveDisabled(s),this._syncFormState(i)}}_syncEffectiveDisabled(c){if(!(!this._component||!c.disabled?.set)){this._applying=!0;try{c.disabled.set(this._component,this.hasAttribute("disabled")||this._disabledByForm,this)}finally{this._applying=!1}}}_syncFormState(c){if(!this._internals||!this._component)return;let{formValue:h,state:u,empty:d}=_u(c,this._component,this);if(this._internals.setFormValue(h,u),(c===V||c===K)&&this.hasAttribute("required")&&d){let f=c===K?"Please enter a date.":"Please select a value.";this._internals.setValidity({valueMissing:!0},f,this._component.refs.input)}else this._internals.setValidity({})}_applyControlValue(c,h,u){let d=Object.entries(c).find(([,f])=>f.property===h);d&&this._applyValue(d[0],d[1],u)}_currentValue(c,h){if(this._propertyValues.has(h.property))return this._propertyValues.get(h.property);let u=de(this.getAttribute(c),h.type);return u===void 0?h.default:u}_readProperty(c){if(this._component&&c.get)return c.get(this._component,this);if(this._propertyValues.has(c.property))return this._propertyValues.get(c.property);let h=de(this.getAttribute(c.attribute),c.type);return h===nt||h===void 0?As(c.default):h}_writeProperty(c,h){this._propertyValues.set(c.property,h);let u=c.serialize?c.serialize(h,this):pn(h,c.type);if(u!==nt){this._reflecting.add(c.attribute);try{u===null?this.removeAttribute(c.attribute):this.setAttribute(c.attribute,u)}finally{this._reflecting.delete(c.attribute)}}this._applyValue(c.attribute,c,h)}}for(let l of Object.values(s))Object.prototype.hasOwnProperty.call(o.prototype,l.property)||Object.defineProperty(o.prototype,l.property,{configurable:!0,enumerable:!0,get(){return this._readProperty(l)},set(c){this._writeProperty(l,c)}});return o}function Zo(i="zx"){if(typeof customElements>"u")throw new Error("Custom elements are not available in this environment");let t=String(i).trim();for(let[e,s,n]of ru){let r=`${t}-${e}`;customElements.get(r)||customElements.define(r,ou(s,n))}}function ta(i){let t={};for(let[e,s]of Object.entries(i)){let n=typeof s=="string"?{type:s}:{...s},r=n.property??au(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 rt(i){return ta(i)}function T(i={}){return{type:"string",...i}}function pe(i={}){return{type:"number",...i}}function M(i={}){return{type:"boolean",default:!1,always:!0,...i}}function _t(i={}){return{type:"json",...i}}function au(i){return i.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function Xo(i,t,e){return i.normalize?i.normalize(t,e):t}function Oe(i,t){t?i.disable():i.enable()}function lu(i,t){i.el.setAttribute("aria-disabled",String(t)),i.refs.search&&(i.refs.search.disabled=t);for(let e of i.refs.list?.querySelectorAll("input")??[])e.disabled=t}function cu(i){return i===""||i==="true"?"local":i==="false"?!1:i}function hu(i){return i===""||i==="true"?"single":i==="false"?!1:i}function ea(i){if(typeof i!="string"||i.trim()==="")return i;let t=Number(i);return Number.isFinite(t)?t:i}function uu(i){return Array.isArray(i)?i.map(t=>!t||typeof t!="object"||du(t.content)||typeof t.content=="function"?t:{...t,content:document.createTextNode(String(t.content??""))}):i}function du(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function pu(i){return typeof i!="string"?i:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(i)?$(i,"%Y-%m-%dT%H:%M"):/^\d{4}-\d{2}-\d{2}$/.test(i)?$(i,"%Y-%m-%d"):i}function fu(i,t){return i instanceof Date?_n(i,!!t.time):pn(i,"string")}function _n(i,t){return!(i instanceof Date)||Number.isNaN(i.getTime())?"":z(i,t?"%Y-%m-%dT%H:%M":"%Y-%m-%d")}function fn(i){return i===W||i===pt?"checked":[V,et,K,ht].includes(i)?"value":null}function _u(i,t,e){if(i===W||i===pt){let n=t.get(),r=i===W?!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(i===V){let n=t.value;return{formValue:n===null?null:String(n),state:JSON.stringify(n),empty:n===null||n===""}}if(i===et){let n=JSON.stringify(t.getValues());return{formValue:n,state:n,empty:n==="[]"}}if(i===K){let n=_n(t.get(),!!e.time);return{formValue:n||null,state:n,empty:n===""}}let s=String(t.get());return{formValue:s,state:s,empty:!1}}function mu(i,t){return i===W||i===pt?t==="true":i===V||i===et?de(t,"json"):i===ht?de(t,"number"):t}function As(i){return Array.isArray(i)?i.slice():i instanceof Date?new Date(i.getTime()):i}var gu=Object.freeze({label:"",icon:null,kind:"default",size:"md",disabled:!1});function P(i={}){let t={...gu,...i},e=a("button",{class:"zx-btn",type:"button",disabled:!!t.disabled,title:t.title,dataset:{kind:bu(t.kind),size:yu(t.size)}});return t.icon&&e.append(g(t.icon,{size:16})),t.label!==""&&e.append(a("span",{class:"zx-btn__label"},String(t.label))),!t.label&&t.title&&e.setAttribute("aria-label",t.title),typeof t.onclick=="function"&&(e.onclick=t.onclick),e}function sa(i){let t=a("div",{class:"zx-btn-group",role:"group"});return t.append(...i),t}function bu(i){return["primary","danger","ghost"].includes(String(i))?i:"default"}function yu(i){return i==="sm"?"sm":"md"}var xu=Object.freeze(["neutral","accent","success","warning","danger","info"]),vu=Object.freeze(["soft","solid","outline"]),wu=Object.freeze({label:"",icon:null,kind:"neutral",variant:"soft",size:"md",dot:!1});function ia(i={}){let t={...wu,...i},e=a("span",{class:"zx-badge",title:t.title,dataset:{kind:Au(t.kind),variant:Su(t.variant),size:ku(t.size)}});return t.dot?e.append(a("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(a("span",{class:"zx-badge__label"},String(t.label))):t.title&&(e.setAttribute("role","img"),e.setAttribute("aria-label",t.title)),e}function na(i){let t=a("span",{class:"zx-badge-group"});return t.append(...i),t}function Au(i){return xu.includes(i)?i:"neutral"}function Su(i){return vu.includes(i)?i:"soft"}function ku(i){return i==="sm"?"sm":"md"}var zu=Object.freeze({md:40,sm:28}),Cu=Object.freeze({icon:"folder-open",title:"",description:"",actions:[],size:"md",align:"center"});function ra(i={}){let t={...Cu,...i},e=Eu(t.size),s=a("div",{class:"zx-empty-state",dataset:{size:e,align:Iu(t.align)}});t.icon&&s.append(a("div",{class:"zx-empty-state__icon",ariaHidden:"true"},g(t.icon,{size:zu[e]}))),t.title&&s.append(a("p",{class:"zx-empty-state__title"},String(t.title))),t.description&&s.append(a("p",{class:"zx-empty-state__description"},String(t.description)));let n=Tu(t.actions);return n.length>0&&s.append(a("div",{class:"zx-empty-state__actions"},n)),s}function Tu(i){if(!Array.isArray(i))throw new TypeError("emptyState actions must be an array");return i.map(t=>{if(D(t))return t;if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("emptyState actions must be Elements or button descriptors");return P(t)})}function Eu(i){return i==="sm"?"sm":"md"}function Iu(i){return i==="start"?"start":"center"}var Du=Object.freeze({size:"md",label:"",showLabel:!1,kind:"accent"}),Nu=Object.freeze({sm:!0,md:!0,lg:!0});function Ss(i={}){let t={...Du,...i},e=String(t.label??""),s=a("span",{class:"zx-spinner",dataset:{size:Nu[t.size]?t.size:"md",kind:t.kind==="current"?"current":"accent"}},a("span",{class:"zx-spinner__ring",ariaHidden:"true"}));return e?(s.setAttribute("role","status"),s.append(a("span",{class:"zx-spinner__label",dataset:{visible:t.showLabel?"true":null}},e))):s.setAttribute("aria-hidden","true"),s}var fe=class extends _{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??a("div");this.el=t,this._max=Math.max(1,Number(this.options.max)||100),this._status=oa(this.options.status),this._indeterminate=!!this.options.indeterminate,this._labelId=y("zx-progress-label");let e=a("div",{ref:"head",class:"zx-progress-bar__head"},a("span",{ref:"label",class:"zx-progress-bar__label",id:this._labelId},String(this.options.label??"")),a("span",{ref:"value",class:"zx-progress-bar__value"})),s=a("div",{ref:"track",class:"zx-progress-bar__track",role:"progressbar",ariaValuemin:"0",ariaValuemax:String(this._max),ariaLabelledby:this._labelId},a("div",{ref:"fill",class:"zx-progress-bar__fill"}));return t.replaceChildren(e,s,a("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 s=Number(t),n=F(Number.isFinite(s)?s: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=oa(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:s}=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"),s.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()}%`),s.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(a("span",{class:"zx-progress-bar__percent"},t)),e}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function oa(i){return i==="success"||i==="error"?i:"active"}var Mu=new Set(["inactive","active","success","error"]),ks=class extends _{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??a("span");return this.el=t,t.replaceChildren(a("span",{ref:"indicator",class:"zx-inline-loading__indicator"}),a("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:s=!1}={}){let n=Mu.has(t)?t:"inactive";e!==void 0&&(this._description=String(e??""));let r=n!==this._status;return this._status=n,this._sync(),r&&!s&&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"?[Ss({size:"sm",kind:"current"})]:this._status==="success"?[g("success",{size:t})]:this._status==="error"?[g("error",{size:t})]:[]}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function zs(i={}){let t={width:"100%",height:"1rem",radius:"sm",...i};return a("span",{class:"zx-skeleton",ariaHidden:"true",dataset:{radius:Ou.has(t.radius)?t.radius:"sm"},style:{"inline-size":mn(t.width),"block-size":mn(t.height)}})}function la(i={}){let t={lines:3,width:"100%",heading:!1,lastLineWidth:"60%",...i},e=F(Math.trunc(Number(t.lines)||0),1,20),s=a("div",{class:"zx-skeleton-text",ariaHidden:"true",style:{"inline-size":mn(t.width)}});for(let n=0;n<e;n+=1){let r=t.heading&&n===0,o=n===e-1&&e>1;s.append(zs({width:o?t.lastLineWidth:"100%",height:r?"1.5rem":"0.75rem"}))}return s}function ca(i={}){let t={rows:5,columns:4,header:!0,...i},e=F(Math.trunc(Number(t.rows)||0),1,50),s=F(Math.trunc(Number(t.columns)||0),1,20),n=a("div",{class:"zx-skeleton-table",ariaHidden:"true",style:{"--zx-skeleton-columns":String(s)}});t.header!==!1&&n.append(aa(s,"header"));for(let r=0;r<e;r+=1)n.append(aa(s,"body"));return n}var Ou=new Set(["sm","md","full"]);function aa(i,t){let e=a("div",{class:"zx-skeleton-table__row",dataset:{kind:t}});for(let s=0;s<i;s+=1)e.append(a("span",{class:"zx-skeleton-table__cell"},zs({width:Fu(s,i),height:"0.75rem"})));return e}function Fu(i,t){return i===t-1?"55%":i%2===0?"80%":"65%"}function mn(i){return typeof i=="number"?`${i}px`:String(i??"")}function ha(i={},...t){return a("div",{class:["zx-stack",i.class??""],dataset:{direction:i.direction==="row"?"row":null,align:pa.has(i.align)?i.align:null,justify:Lu.has(i.justify)?i.justify:null,wrap:i.wrap?"true":null,inline:i.inline?"true":null},style:fa("--zx-stack-gap",i.gap)},t)}function ua(i={},...t){let e=Number(i.columns),s={...fa("--zx-grid-gap",i.gap),"--zx-grid-min":qu(i.min??"16rem")};return Number.isFinite(e)&&e>=1&&(s["--zx-grid-columns"]=String(Math.trunc(e))),a("div",{class:["zx-grid",i.class??""],dataset:{columns:Number.isFinite(e)&&e>=1?"true":null,align:pa.has(i.align)?i.align:null},style:s},t)}function da(i={},...t){return a("div",{class:["zx-aspect",i.class??""],style:{"--zx-aspect-ratio":String(i.ratio??"16 / 9"),"--zx-aspect-fit":Ru.has(i.fit)?i.fit:"cover"}},t)}var pa=new Set(["start","center","end","stretch","baseline"]),Lu=new Set(["start","center","end","between","around"]),Ru=new Set(["cover","contain","fill"]);function fa(i,t){if(t==null||t==="")return{};let e=Number(t);return Number.isInteger(e)&&e>=1&&e<=8?{[i]:`var(--zx-space-${e})`}:{[i]:String(t)}}function qu(i){return typeof i=="number"?`${i}px`:String(i)}function _a(i,t={}){let e=H(i);if(!e)throw new TypeError("truncate() target could not be resolved");let s=F(Math.trunc(Number(t.lines)||1),1,10),n=t.title!==!1,r=e.classList.contains("zx-truncate"),o=e.getAttribute("title"),l=!1,c=null;e.classList.add("zx-truncate"),s>1&&(e.dataset.lines=String(s),e.style.setProperty("--zx-truncate-lines",String(s)));let h=()=>(l=gn(e),n&&(l?e.setAttribute("title",e.textContent?.trim()??""):o===null?e.removeAttribute("title"):e.setAttribute("title",o)),l);return h(),typeof ResizeObserver=="function"&&(c=new ResizeObserver(h),c.observe(e)),{update:h,isTruncated:()=>l,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 gn(i){return i.scrollWidth-i.clientWidth>1||i.scrollHeight-i.clientHeight>1}var Bu=Object.freeze({text:"",label:"",title:"Copy",feedback:"Copied",feedbackDuration:2e3,size:"md",kind:"ghost"});function Cs(i={}){let t={...Bu,...i},e=!t.label,s=a("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=a("span",{class:"zx-copy-button__icon",ariaHidden:"true"},g("copy",{size:t.size==="sm"?12:14})),r=a("span",{class:"zx-copy-button__status",role:"status"});s.append(n),e||s.append(a("span",{class:"zx-copy-button__label"},String(t.label))),s.append(r);let o=0;return s.addEventListener("click",async()=>{let l=typeof t.text=="function"?String(t.text()):String(t.text??""),c=await bs(l);t.oncopy?.(l,c),c&&(clearTimeout(o),s.dataset.copied="true",n.replaceChildren(g("check",{size:t.size==="sm"?12:14})),r.textContent=String(t.feedback),o=setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,n.replaceChildren(g("copy",{size:t.size==="sm"?12:14})),r.textContent="")},Math.max(0,Number(t.feedbackDuration)||0)))}),s}var Ts=class extends _{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??a("div");this.el=t;let e=y("zx-copy-input"),s=a("input",{ref:"input",class:"zx-copy-input__field",type:"text",id:e,readOnly:!0,value:String(this.options.value??"")}),n=Cs({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(a("label",{ref:"label",class:"zx-copy-input__label",for:e},String(this.options.label??"")),a("div",{class:"zx-copy-input__box"},s,n)),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(s,"focus",()=>s.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 ga=Symbol("zxDropdownPointerDismiss"),ba=Symbol("zxDropdownEscapeDismiss"),J=class extends _{static cssName="dropdown";static defaults={content:null,placement:"bottom-start",offset:4,matchWidth:!1,openOn:"click",closeOnSelect:!1};#t;#e=null;#s=new Map;#i=!1;constructor(t,e={}){let s=H(t);if(!s)throw new TypeError("Dropdown anchor could not be resolved");super(null,e),this.#t=s,this.#r("aria-expanded"),this.#r("aria-controls"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("aria-controls",this.el.id),this.setContent(this.options.content),this.options.openOn==="click"&&this.listen(this.#t,"click",()=>this.toggle()),this.listen(this.el,"click",()=>{this.options.closeOnSelect&&this.close()})}render(){let t=a("div",{id:y("zx-dropdown"),popover:"manual"});return t.dataset.state="closed",document.body.append(t),t}open(){return this.isOpen()||this.#i?this:(this.#e=U(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(Hu()),this.#t.setAttribute("aria-expanded","true"),Vu(),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"),ju(),this):this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.#e!==null}setContent(t){return Pu(this.el,t),this.#e?.update(),this}getPanel(){return this.el}destroy(){if(!this.#i){this.#i=!0,this.close();for(let[t,e]of this.#s)$u(this.#t,t,e);super.destroy()}}[ga](t){if(!this.isOpen())return;let e=t.composedPath();e.includes(this.el)||e.includes(this.#t)||this.close()}[ba](t){if(t.key!=="Escape"||!this.isOpen())return;t.preventDefault();let e=this.el.contains(document.activeElement);this.close(),e&&this.#t instanceof HTMLElement&&this.#t.focus()}#r(t){this.#s.set(t,this.#t.getAttribute(t))}},Fe=class extends _{constructor(){super(null),this.listen(document,"pointerdown",t=>{let e=ma();e instanceof J&&e[ga](t)}),this.listen(document,"keydown",t=>{if(t.key!=="Escape")return;let e=ma();e instanceof J&&e[ba](t)})}render(){let t=a("span",{hidden:!0,"data-zx-dropdown-dismiss-manager":""});return document.body.append(t),t}};function Pu(i,t){if(i.replaceChildren(),t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t.nodeType=="number"&&i.append(t)}function ma(){let i=null,t=-1;for(let e of document.querySelectorAll("[data-zx-overlay-order]")){let s=Number(e.getAttribute("data-zx-overlay-order"))||0;s>t&&(t=s,i=e)}return i?_.from(i):null}function Hu(){let i=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...i)+1}function Vu(){let i=document.querySelector("[data-zx-dropdown-dismiss-manager]"),t=i?_.from(i):null;return t instanceof Fe?t:new Fe}function ju(){if(document.querySelector('.zx-dropdown[data-state="open"]'))return;let i=document.querySelector("[data-zx-dropdown-dismiss-manager]"),t=i?_.from(i):null;t instanceof Fe&&t.destroy()}function $u(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}var Es='[role="menuitem"]',X=class extends _{static cssName="menu-button";static defaults={label:"",icon:null,kind:"default",items:[],placement:"bottom-start"};#t;#e;#s;#i;#r=[];#n=null;#o=!1;#a=!1;constructor(t=null,e={}){let s=t===null?null:H(t);if(t!==null&&(!s||s.tagName!=="BUTTON"))throw new TypeError("MenuButton target must resolve to a button");let n=s?{attributes:Array.from(s.attributes,o=>[o.name,o.value]),children:Array.from(s.childNodes)}:null,r=Object.hasOwn(e,"label");super(t,e),this.#o=s===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 J(this.el,{openOn:"manual",placement:this.options.placement,content:null}),this.#e=this.#t.getPanel(),this.#e.classList.add("zx-menu-button__menu"),this.#e.setAttribute("role","menu"),this.el.setAttribute("aria-haspopup","menu"),s&&r&&this.setLabel(this.options.label),this.setItems(this.options.items),this.#s=ct(this.#e,Es),this.#i=Q(()=>this.#u(),o=>o.focus()),this.#t.on("open",()=>this.emit("open")),this.#t.on("close",()=>this.emit("close")),this.listen(this.el,"click",()=>{this.isOpen()?this.close():(this.open(),this.#s.focusFirst())}),this.listen(this.el,"keydown",o=>this.#l(o)),this.listen(this.#e,"click",o=>{let l=o.target.closest?.(Es);l&&this.#e.contains(l)&&this.#h(l)}),this.listen(this.#e,"keydown",o=>this.#c(o))}render(){return this.el?this.el:a("button",{class:"zx-btn",type:"button","data-kind":this.options.kind,"data-size":"md"},ya(this.options.label,this.options.icon))}setItems(t){return this.#r=Array.isArray(t)?t.slice():[],this.#e.replaceChildren(),this.#r.forEach((e,s)=>{if(e==="-"){this.#e.append(a("div",{class:"zx-menu-button__separator",role:"separator"}));return}let n=[];e.icon&&n.push(a("span",{class:"zx-menu-button__icon"},g(e.icon))),n.push(a("span",{class:"zx-menu-button__label"},e.label)),this.#e.append(a("button",{class:"zx-menu-button__item",type:"button",role:"menuitem",tabindex:"-1","data-menu-item":String(s),"data-danger":e.danger?"true":null,ariaDisabled:e.disabled?"true":null},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.#s.focusFirst(),this}focusLast(){return this.open(),this.#s.focusLast(),this}setLabel(t){return this.el.replaceChildren(...ya(t,this.options.icon)),this}destroy(){if(!this.#a&&(this.#a=!0,this.#s.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.#s.focusLast():this.#s.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?.(Es);if(!e||!this.#e.contains(e))return;t.preventDefault(),this.#h(e);return}this.#i(t)}#h(t){let e=Number(t.getAttribute("data-menu-item")),s=this.#r[e];if(!(!s||s==="-"||s.disabled||this.emit("select",{value:s.value,item:s}).defaultPrevented))try{s.onselect?.(s.value,s,this)}finally{this.close()}}#u(){return Array.from(this.#e.querySelectorAll(Es))}};function ya(i,t){let e=[];return t&&e.push(a("span",{class:"zx-btn__icon"},g(t))),e.push(a("span",{class:"zx-btn__label"},String(i??""))),e}var Ku=["button","a[href]","input","select","textarea","[tabindex]"],Uu=Ku.flatMap(i=>[`.zx-toolbar > ${i}`,`.zx-toolbar > [role="group"] > ${i}`]).join(","),Is=class extends _{static cssName="toolbar";static defaults={items:[],align:"start",label:"Toolbar",overflow:!0,overflowLabel:"More",dense:!1};#t;#e=null;#s=null;#i=!1;#r=-1;#n=-1;#o=0;#a=!1;constructor(t=null,e={}){if(super(t,e),this.options.overflow){this.#e=new X(null,{icon:"dots",label:"",kind:"ghost",placement:"bottom-end"});let s=this.#e.toElement();s.classList.add("zx-toolbar__overflow"),s.setAttribute("aria-label",String(this.options.overflowLabel)),s.setAttribute("title",String(this.options.overflowLabel)),this.options.dense&&s.setAttribute("data-size","sm"),s.hidden=!0}this.#t=ct(this.el,Uu,{orientation:"horizontal"}),this.listen(this.el,"click",s=>this.#c(s)),this.setItems(this._initialItems),this.#e&&typeof ResizeObserver=="function"&&(this.#s=new ResizeObserver(()=>this.#u()),this.#s.observe(this.el))}render(){this._records=[],this._named=new Map,this._createdRoot=!this.el;let t=this.el??a("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=Wu(this.options.align),t.dataset.overflow=this.options.overflow?"true":"false",this.options.dense&&(t.dataset.dense="true"),t}setItems(t){for(let s of this._records)s.type==="element"&&(s.element.hidden=s.userHidden);this._records=Yu(t).map(s=>this.#l(s)),this._named=new Map;for(let s of this._records)s.name!==null&&!this._named.has(s.name)&&this._named.set(s.name,s);let e=this._records.map(s=>s.element);if(this.#e){this.#e.setItems([]);let s=this.#e.toElement();s.hidden=!0,e.push(s)}return this.el.replaceChildren(...e),this.#r=-1,this.#n=-1,this.#d(),this}getItem(t){return this._named.get(String(t))?.element??null}enable(t){return this.#h(t,!1)}disable(t){return this.#h(t,!0)}setActive(t,e=!0){let s=this._named.get(String(t));return s&&s.element.setAttribute("aria-pressed",e?"true":"false"),this}destroy(){if(!this.#a){this.#a=!0,this.#s?.disconnect(),this.#s=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:a("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 l=t.element;return{type:"element",element:l,name:l.dataset?.name??null,label:va(l),icon:null,onclick:null,userHidden:!!l.hidden}}let{name:e=null,active:s,onclick:n,...r}=t.descriptor,o=P({size:this.options.dense?"sm":"md",...r});return s!==void 0&&o.setAttribute("aria-pressed",s?"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 s=this._records.find(n=>n.type==="descriptor"&&n.element.contains(e));s&&(this.emit("action",{name:s.name,item:s.element}),s.onclick?.(t))}#h(t,e){let s=this._named.get(String(t));if(!s)return this;let n=s.element;return"disabled"in n?n.disabled=e:e?n.setAttribute("aria-disabled","true"):n.removeAttribute("aria-disabled"),this.#p(),this}#u(){if(!(this.#o!==0||this.#a)){if(typeof requestAnimationFrame!="function"){this.#d();return}this.#o=requestAnimationFrame(()=>{this.#o=0,this.#d()})}}#d(){if(this.#i||this.#a||!this.#e)return;let t=this.el;if(typeof getComputedStyle!="function"||!t.isConnected)return;let e=getComputedStyle(t),s=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.#i=!0;try{let l=this.#e.toElement(),c=this._records.filter(m=>!m.userHidden);for(let m of c)m.element.hidden=!1;l.hidden=!1;let h=c.map(m=>m.element.getBoundingClientRect().width),u=h.reduce((m,b)=>m+b,0)+s*Math.max(0,h.length-1),d=l.getBoundingClientRect().width,f=[];if(u>r){let m=r-d-s,b=0,w=!1;for(c.forEach((x,v)=>{let C=b+h[v]+(b>0?s:0);if(!w&&C<=m){b=C;return}w=!0,x.element.hidden=!0,f.push(x)});c.length>f.length;){let x=c[c.length-f.length-1];if(x.type!=="separator")break;x.element.hidden=!0,f.unshift(x)}}let p=xa(f);this.#e.setItems(p),l.hidden=p.length===0,this.#r=r,this.#n=t.clientHeight}finally{this.#i=!1}}}#p(){if(!this.#e)return;let t=this._records.filter(e=>!e.userHidden&&e.element.hidden);this.#e.setItems(xa(t))}};function Yu(i){if(i!=null&&!Array.isArray(i))throw new TypeError("Toolbar items must be an array");let t=[];for(let e of i??[])if(e!=null){if(e==="-"){t.length>0&&t[t.length-1].type!=="separator"&&t.push({type:"separator"});continue}if(D(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 xa(i){let t=[];for(let e of i){if(e.type==="separator"){t.length>0&&t[t.length-1]!=="-"&&t.push("-");continue}let s=e.element;t.push({label:e.label||va(s)||"\u2026",icon:e.icon??void 0,value:e.name,disabled:!!s.disabled||s.getAttribute("aria-disabled")==="true",onselect:()=>s.click()})}for(;t.length>0&&t[t.length-1]==="-";)t.pop();return t}function va(i){return(i.getAttribute("aria-label")??i.getAttribute("title")??i.textContent??"").trim()}function Wu(i){return["end","between"].includes(i)?i:"start"}var Ds=class extends _{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??a("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 s=t?[]:Array.from(e.childNodes);try{let n=Xu(this.options.headingLevel),r=y("zx-card-heading"),o=a(`h${n}`,{ref:"heading",class:"zx-card__heading",id:r}),l=a("div",{ref:"media",class:"zx-card__media",hidden:!0}),c=a("div",{ref:"actions",class:"zx-card__actions",role:"group",ariaLabel:"Card actions",hidden:!0}),h=a("div",{ref:"content",class:"zx-card__content",hidden:!0}),u=a("footer",{ref:"footer",class:"zx-card__footer",hidden:!0}),d=a("header",{ref:"header",class:"zx-card__header"},o,c);return e.replaceChildren(a("div",{class:"zx-card__layout"},l,a("div",{class:"zx-card__inner"},d,h,u))),e.dataset.variant=Qu(this.options.variant),e.dataset.orientation=Ju(this.options.orientation),this.setTitle(this.options.title),this.setMedia(this.options.media),this.options.content!==null?this.setContent(this.options.content):s.length&&(h.replaceChildren(...s),h.hidden=!1),this.setActions(this.options.actions),this.setFooter(this.options.footer),this.setLink(this.options.link),e}catch(n){throw this._actionAbort?.abort(),this._linkAbort?.abort(),t||S(e,this._original),n}}setTitle(t){let e=String(t??"");if(this._link&&!e.trim())throw new TypeError("A linked Card requires a non-empty title");return this._title=e,this._renderHeading(),this}setMedia(t){return bn(this.refs.media,t,"Card media"),this.refs.media.hidden=t===null,this}setContent(t){return bn(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,s;try{s=t.map(n=>{if(D(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 l=P(r);if(o!==void 0&&typeof o!="function")throw new TypeError("Card action onclick must be a function");return o&&l.addEventListener("click",o,{signal:e.signal}),l})}catch(n){throw e.abort(),n}return this._actionAbort?.abort(),this._actionAbort=e,this.refs.actions.replaceChildren(...s),this.refs.actions.hidden=s.length===0,this._syncHeader(),this}setFooter(t){return bn(this.refs.footer,t,"Card footer"),this.refs.footer.hidden=t===null,this}setLink(t){let e=Gu(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,s=this._link?a("a",{class:"zx-card__primary",href:this._link.href,target:this._link.target,rel:this._link.rel},t):a("span",{class:"zx-card__title"},t);this._link?.onclick&&s.addEventListener("click",this._link.onclick,{signal:e.signal}),this._linkAbort?.abort(),this._linkAbort=e,this.refs.heading.replaceChildren(s),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 bn(i,t,e){if(t===null){i.replaceChildren();return}if(typeof t=="string"){i.textContent=t;return}let s=t instanceof _?t.toElement():t;if(s instanceof Node){i.replaceChildren(s);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}function Gu(i){if(i===null)return null;let t=typeof i=="string"?{href:i}:i;if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Card link must be a URL string, descriptor, or null");let e=bt(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 s=t.target==null?void 0:String(t.target),n=t.rel==null?"":String(t.rel).trim();return s==="_blank"&&!/(^|\s)noopener(\s|$)/i.test(n)&&(n=`${n} noopener`.trim()),{href:e,target:s,rel:n||void 0,onclick:t.onclick}}function Qu(i){return["raised","filled"].includes(String(i))?i:"outlined"}function Ju(i){return i==="horizontal"?"horizontal":"vertical"}function Xu(i){let t=Math.trunc(Number(i));return t>=1&&t<=6?t:3}var Ns=class extends _{static cssName="panel";static defaults={title:"",content:null,open:!0,collapsible:!0,buttons:[],footer:null,footerButtons:[]};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??a("section");this.el=e,this._createdRoot=t,this._original=t?null:Zu(e),this._cleaned=!1,this._open=!!this.options.open,this._collapsible=!!this.options.collapsible,this._hasFooterContent=!1;let s=t?[]:Array.from(e.childNodes),n=y("zx-panel-body"),r=a("span",{class:"zx-panel__title",ref:"title"}),o=[];this._collapsible&&o.push(a("span",{class:"zx-panel__chevron",ariaHidden:"true"},g("chevron-right",{size:16}))),o.push(r);let l=this._collapsible?a("button",{class:"zx-panel__toggle",ref:"toggle",type:"button",ariaControls:n,ariaExpanded:String(this._open)},o):a("div",{class:"zx-panel__toggle",ref:"toggle"},o),c=a("div",{class:"zx-panel__header",ref:"header"},l,a("div",{class:"zx-panel__buttons",ref:"buttons",role:"group",ariaLabel:"Panel actions"})),h=a("div",{class:"zx-panel__content",ref:"content"}),u=a("div",{class:"zx-panel__body",ref:"body",id:n},h),d=a("div",{class:"zx-panel__footer",ref:"footer",hidden:!0},a("div",{class:"zx-panel__footer-content",ref:"footerContent"}),a("div",{class:"zx-panel__footer-buttons",ref:"footerButtons",role:"group",ariaLabel:"Panel footer actions"}));return e.replaceChildren(c,u,d),this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):h.append(...s),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),this.setFooterButtons(this.options.footerButtons),this._syncOpenState(),this._collapsible&&this.listen(l,"click",()=>this.toggle()),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return wa(this.refs.content,t,"Panel content"),this}setButtons(t){return this.refs.buttons.replaceChildren(...this._buildButtons(t,"Panel buttons")),this}setFooter(t){return wa(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&&td(this.el,this._original))}_syncOpenState(){this.el.setAttribute("data-state",this._open?"open":"closed"),this.refs.body.hidden=!this._open,this._collapsible&&this.refs.toggle.setAttribute("aria-expanded",String(this._open))}_syncFooter(){this.refs.footer.hidden=!this._hasFooterContent&&this.refs.footerButtons.childElementCount===0}_buildButtons(t,e){if(!Array.isArray(t))throw new TypeError(`${e} must be an array`);return t.map(s=>{if(D(s))return s;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError(`${e} must be Elements or button descriptors`);let n={...s},r=n.onclick;delete n.onclick;let o=P(n);return typeof r=="function"&&this.listen(o,"click",r),o})}};function Zu(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function td(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function wa(i,t,e){if(i.replaceChildren(),t===null)return;if(typeof t=="string"){i.append(document.createTextNode(t));return}let s=t instanceof _?t.toElement():t;if(s&&typeof s.nodeType=="number"){i.append(s);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}var ed=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"]),Ms=class extends _{static cssName="master-panel";static defaults={title:"",content:null,buttons:[],module:null,footer:null};constructor(t,e={}){super(t,e)}render(){let t=!this.el,e=this.el??a("section");this.el=e,this._createdRoot=t,this._original=t?null:sd(e),this._cleaned=!1;let s=t?[]:Array.from(e.childNodes),n=a("header",{class:"zx-master-panel__header"},a("h1",{class:"zx-master-panel__title",ref:"title"}),a("div",{class:"zx-master-panel__buttons",ref:"buttons",role:"group",ariaLabel:"Panel actions"})),r=a("div",{class:"zx-master-panel__content",ref:"content"}),o=a("footer",{class:"zx-master-panel__footer",ref:"footer",hidden:!0});e.replaceChildren(n,r,o);let l=nd(this.options.module);return e.dataset.module=l,e.style.setProperty("--zx-master-panel-accent",`var(--zx-module-${l})`),this.setTitle(this.options.title),this.options.content!==null?this.setContent(this.options.content):r.append(...s),this.setButtons(this.options.buttons),this.setFooter(this.options.footer),e}setTitle(t){return this.refs.title.textContent=String(t??""),this}setContent(t){return Aa(this.refs.content,t,"MasterPanel content"),this}setButtons(t){if(!Array.isArray(t))throw new TypeError("MasterPanel buttons must be an array");let e=t.map(s=>{if(D(s))return s;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("MasterPanel buttons must be Elements or button descriptors");let n={...s},r=n.onclick;delete n.onclick;let o=P(n);return typeof r=="function"&&this.listen(o,"click",r),o});return this.refs.buttons.replaceChildren(...e),this}setFooter(t){return Aa(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&&id(this.el,this._original))}};function sd(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function id(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function Aa(i,t,e){if(i.replaceChildren(),t===null)return;if(typeof t=="string"){i.append(document.createTextNode(t));return}let s=t instanceof _?t.toElement():t;if(s&&typeof s.nodeType=="number"){i.append(s);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}function nd(i){let t=String(i??"default").toLowerCase();return ed.includes(t)?t:"default"}function _e(i,t){if(!i)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",s=new AbortController,{signal:n}=s,r=!1,o=null,l=0,c=0,h=!1,u=0,d=x=>e?x.clientY:x.clientX,f=()=>!!t.disabled?.(),p=()=>{let x=o;if(o=null,x!==null)try{i.releasePointerCapture(x)}catch{}},m=()=>{u!==0&&(cancelAnimationFrame(u),u=0)},b=()=>{r=!1,h=!1,m(),p()};i.addEventListener("pointerdown",x=>{let v=x;if(!(f()||r||v.button!==0)&&t.onStart?.(v)!==!1){r=!0,o=v.pointerId,l=d(v),c=l,h=!1;try{i.setPointerCapture(v.pointerId)}catch{}}},{signal:n}),i.addEventListener("pointermove",x=>{let v=x;!r||v.pointerId!==o||(c=d(v),c!==l&&(h=!0),u===0&&(u=requestAnimationFrame(()=>{u=0,r&&t.onMove(c-l)})))},{signal:n});let w=x=>{let v=x;if(!r||v.pointerId!==o)return;m(),c=d(v);let C=h,I=c-l;b(),t.onEnd?.(I,C)};return i.addEventListener("pointerup",w,{signal:n}),i.addEventListener("pointercancel",w,{signal:n}),i.addEventListener("keydown",x=>{let v=x;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 C=e?"ArrowUp":"ArrowLeft",I=e?"ArrowDown":"ArrowRight";v.key!==C&&v.key!==I||t.onStep&&(v.preventDefault(),t.onStep(v.key===I?1:-1,v.shiftKey))},{signal:n}),{isDragging:()=>r,cancel(){r&&b()},destroy(){b(),s.abort()}}}function Z(i,t){if(typeof i=="number")return Number.isFinite(i)?i:Number.NaN;if(typeof i!="string")return Number.NaN;let e=/^([+-]?(?:\d+\.?\d*|\.\d+))(px|%)?$/i.exec(i.trim());if(!e)return Number.NaN;let s=Number(e[1]);if(!Number.isFinite(s))return Number.NaN;if((e[2]??"").toLowerCase()!=="%")return s;let n=Number(t);return Number.isFinite(n)?s/100*n:Number.NaN}var rd="split-view",Rs=class extends _{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;#s=null;constructor(t=null,e={}){super(t,e);let s=this.options.storageKey;if(s!=null&&s!==""){this.#e=ae(rd);let o=this.#e.get(String(s));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.#s=_e(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,l)=>{l&&this.#a(o,!0),delete this.el.dataset.dragging,l&&(this.#_(),this.#f())},onStep:(o,l)=>this.#l(o*(l?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.#p()),this.#t.observe(this.el)),this.#n()}render(){let t=this.options;this._orientation=t.orientation==="vertical"?"vertical":"horizontal";let e=Z(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 s=this.el??a("div");this.el=s,this._snapshot=this._createdRoot?null:k(s);let n=this._createdRoot||t.start!=null||t.end!=null?[]:Array.from(s.children),r=y("zx-split-start"),o=a("div",{class:"zx-split-view__pane",id:r,ref:"start",dataset:{pane:"start"}}),l=a("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=a("div",{class:"zx-split-view__pane",ref:"end",dataset:{pane:"end"}});return s.replaceChildren(o,l,c),s.dataset.orientation=this._orientation,this._disabled&&l.setAttribute("aria-disabled","true"),s.style.setProperty("--zx-split-size",Os(t.size)),t.start!=null?Fs(o,t.start,"SplitView start"):n[0]&&o.append(n[0]),t.end!=null?Fs(c,t.end,"SplitView end"):n[1]&&c.append(...n.slice(1)),s}setSize(t){let{total:e,divider:s,min:n,max:r}=this.#i(),o=Z(t,e>0?e:Number.NaN);return Number.isFinite(o)?(this.#r(mt({size:o,min:n,max:r,total:e,divider:s})),this):(this._size=null,this.el.style.setProperty("--zx-split-size",Os(t)),this.#n(),this)}getSize(){if(this._collapsed==="start")return 0;let{total:t,divider:e}=this.#i();if(this._collapsed==="end")return Math.max(0,t-e);if(this._size!==null)return this._size;let s=Sa(this.refs.start,this._orientation);if(s>0)return s;let n=Z(this.options.size,t);return Number.isFinite(n)?Math.max(0,n):0}getRatio(){let{total:t}=this.#i();return t>0?this.getSize()/t:0}setStart(t){return Fs(this.refs.start,t,"SplitView start"),this}setEnd(t){return Fs(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.#s?.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.#s?.destroy(),this.#s=null,this.#t?.disconnect(),this.#t=null,super.destroy(),!this._createdRoot&&this._snapshot&&S(this.el,this._snapshot))}#i(){let t=this.el,e=this._orientation==="vertical"?t.clientHeight:t.clientWidth,s=this.options.max==null?null:Number(this.options.max);return{total:Number.isFinite(e)&&e>0?e:0,divider:Sa(this.refs.divider,this._orientation),min:Math.max(0,Number(this.options.min)||0),max:Number.isFinite(s)?s:null}}#r(t){this._size=t,this.el.style.setProperty("--zx-split-size",`${t}px`),this.#n()}#n(){let{total:t,divider:e,min:s,max:n}=this.#i(),r=Ls({min:s,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:s,divider:n,min:r,max:o}=this.#i();if(s<=0)return;this._collapsed!==null&&this.expand();let l=mt({size:this._startSize+t,min:r,max:o,total:s,divider:n});e&&(l=mt({size:yn(l,this.#u(s,n),Number(this.options.snap)),min:r,max:o,total:s,divider:n})),l!==this._size&&(this.#r(l),this.emit("resize",{size:l,ratio:l/s}))}#l(t){let{total:e,divider:s,min:n,max:r}=this.#i();e<=0||(this._collapsed!==null&&this.expand(),this.#h(mt({size:this.getSize()+t,min:n,max:r,total:e,divider:s}),e))}#c(t){let{total:e,divider:s,min:n,max:r}=this.#i();if(e<=0)return;this._collapsed!==null&&this.expand();let o=Ls({min:n,max:r,total:e,divider:s});this.#h(mt({size:o[t],min:n,max:r,total:e,divider:s}),e)}#h(t,e){t!==this._size&&(this.#r(t),this.emit("resize",{size:t,ratio:t/e}),this.#_(),this.#f())}#u(t,e){let{min:s,max:n}=this.#i(),r=Ls({min:s,max:n,total:t,divider:e}),o=[r.min,r.max],l=Z(this.options.size,t);return Number.isFinite(l)&&o.unshift(l),o}#d(){if(this._disabled)return;this._collapsed!==null&&this.expand();let t=Z(this.options.size,Number.NaN);Number.isFinite(t)?this.setSize(t):(this._size=null,this.el.style.setProperty("--zx-split-size",Os(this.options.size)),this._lastTotal=-1,this.#p());let{total:e}=this.#i(),s=this.getSize();this.emit("resize",{size:s,ratio:e>0?s/e:0}),this.#_(),this.#f()}#p(){if(this._destroyed||this.#s?.isDragging())return;let{total:t,divider:e,min:s,max:n}=this.#i();if(t<=0||t===this._lastTotal)return;if(this._lastTotal=t,this._size===null){let o=Z(this.options.size,t);if(Number.isFinite(o)){let l=mt({size:o,min:s,max:n,total:t,divider:e});this.el.style.setProperty("--zx-split-size",Math.abs(l-o)>.5?`${l}px`:Os(this.options.size))}this.#n();return}let r=mt({size:this._size,min:s,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)))}#f(){let{total:t}=this.#i(),e=this.getSize();this.emit("resizeend",{size:e,ratio:t>0?e/t:0})}};function mt({size:i,min:t=0,max:e=null,total:s=0,divider:n=0}){let r=Number(i),o=Ls({min:t,max:e,total:s,divider:n});return Math.max(0,(Number(s)||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 yn(i,t,e){let s=Number(i),n=Number(e);if(!Number.isFinite(s)||!Number.isFinite(n)||n<=0)return s;let r=Array.isArray(t)?t:t==null?[]:[t],o=s,l=Number.POSITIVE_INFINITY;for(let c of r){let h=Number(c);if(!Number.isFinite(h))continue;let u=Math.abs(h-s);u<=n&&u<l&&(l=u,o=h)}return o}function Ls({min:i=0,max:t=null,total:e=0,divider:s=0}){let n=Math.max(0,(Number(e)||0)-Math.max(0,Number(s)||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(i)||0),r),max:r}}function Sa(i,t){let e=i.getBoundingClientRect(),s=t==="vertical"?e.height:e.width;return Number.isFinite(s)&&s>0?s:0}function Os(i){return typeof i=="number"&&Number.isFinite(i)?`${i}px`:String(i)}function Fs(i,t,e){if(i.replaceChildren(),t==null)return;if(typeof t=="string"||typeof t=="number"){i.append(document.createTextNode(String(t)));return}let s=t instanceof _?t.toElement():t;if(s&&typeof s.nodeType=="number"){i.append(s);return}throw new TypeError(`${e} must be a string, Node, Component, or null`)}var od="dock",qs=class extends _{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 s=this.options.storageKey;if(s!=null&&s!==""){this._store=ae(od);let n=this._store.get(String(s));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??a("div");this.el=e,this._snapshot=this._createdRoot?null:k(e),e.dataset.orientation=this._orientation,e.replaceChildren(),this._content=t.content==null?null:a("div",{class:"zx-dock__content",ref:"content"}),this._content&&vn(this._content,t.content,!1);for(let s of Array.isArray(t.panes)?t.panes:[])this._panes.set(String(s.name),this._buildPane(s));return this._layout(),e}pane(t){return this._panes.get(String(t))??null}names(){return[...this._panes.keys()]}add(t,e={}){let s=String(t?.name??"");if(!s)throw new TypeError("Dock pane requires a name");this._panes.has(s)&&this.remove(s);let n=this._buildPane(t),r=[...this._panes.entries()],o=Number.isInteger(e.index)?F(Number(e.index),0,r.length):r.length;return r.splice(o,0,[s,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),s=this._panes.get(e);if(s)this.expand(e);else for(let n of this._panes.values())if(n.tabs?.has(e)){s=n,this.expand(n.name),this.activate(n.name,e);break}return s?(s.element.scrollIntoView({block:"nearest",inline:"nearest"}),this.emit("reveal",{name:s.name}),this):this}setSize(t,e){let s=this._panes.get(String(t));if(!s)return this;let n=xn(e);return n===null?s.element.style.removeProperty("--zx-pane-size"):s.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 s=this._panes.get(String(t)),n=s?.tabs?.get(String(e));if(!n||s.active===n.name)return this;let r=s.active;s.active=n.name;for(let o of s.tabs.values()){let l=o===n;o.tab.setAttribute("aria-selected",String(l)),o.tab.tabIndex=l?0:-1,o.panel.hidden=!l}return this._materialize(s),this._persist(),this.emit("tabchange",{pane:s.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 s=this._axisSize(e.element);s>0&&(t.sizes[e.name]=s)}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 s of this._panes.values()){if(s.kind==="sheet")continue;let n=t.sizes?.[s.name];typeof n=="number"&&Number.isFinite(n)&&n>0&&s.element.style.setProperty("--zx-pane-size",`${n}px`);let r=t.active?.[s.name];r&&s.tabs?.has(String(r))&&this.activate(s.name,String(r));let o=e.has(s.name);o!==s.collapsed&&s.collapsible&&(s.collapsed=o,this._syncPaneState(s))}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),s=String(t.title??""),n=t.collapsible??this.options.collapsible!==!1,r=y("zx-dock-body"),o=Array.isArray(t.tabs)&&t.tabs.length>0,l=a("span",{class:"zx-dock__chevron",ariaHidden:"true"},g("chevron-right",{size:14})),c=a("button",{class:"zx-dock__toggle",type:"button",ariaControls:r,ariaExpanded:"true",ariaLabel:o?s||e:null},l,o?null:a("span",{class:"zx-dock__title"},s));n||(c.disabled=!0);let h=a("div",{class:"zx-dock__header"},c),u=a("div",{class:"zx-dock__body",id:r}),d=a("section",{class:"zx-dock__pane",dataset:{name:e,state:"open"}},h,u),f={name:e,title:s,element:d,header:h,body:u,toggle:c,collapsible:n,collapsed:!1,grow:!!t.grow,side:t.side==="end"?"end":"start",min:Number.isFinite(t.min)?Math.max(0,Number(t.min)):0,tabs:null,active:null,content:null,built:!1,roving:null};if(o){f.tabs=new Map;let m=a("div",{class:"zx-dock__tabs",role:"tablist",ariaOrientation:"horizontal",ariaLabel:s||e});for(let x of t.tabs){let v=String(x.name),C=y("zx-dock-tab"),I=y("zx-dock-panel"),O=a("button",{class:"zx-dock__tab",type:"button",role:"tab",id:C,ariaControls:I,ariaSelected:"false",tabindex:-1},String(x.title??v)),j=a("div",{class:"zx-dock__panel",role:"tabpanel",id:I,ariaLabelledby:C,tabindex:0,hidden:!0});m.append(O),u.append(j),f.tabs.set(v,{name:v,tab:O,panel:j,content:x.content,built:!1})}h.append(m),f.roving=ct(m,".zx-dock__tab",{orientation:"horizontal"}),this.listen(m,"click",x=>{let v=x.target.closest?.(".zx-dock__tab");if(!v||!m.contains(v))return;let C=[...f.tabs.values()].find(I=>I.tab===v);C&&this.activate(f.name,C.name)});let b=String(t.active??""),w=f.tabs.has(b)?b:[...f.tabs.keys()][0];f.active=w;for(let x of f.tabs.values()){let v=x.name===w;x.tab.setAttribute("aria-selected",String(v)),x.tab.tabIndex=v?0:-1,x.panel.hidden=!v}}else f.content=a("div",{class:"zx-dock__pane-content"}),u.append(f.content),f.factory=t.content;let p=xn(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,vn(e.panel,e.content,!0);return}t.built||(t.built=!0,vn(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 s=[];e.forEach((n,r)=>{r>0&&s.push(this._divider()),s.push(n instanceof Element?n:n.element)}),this.el.replaceChildren(...s)}_divider(){let t=a("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(_e(t,{orientation:this._orientation,disabled:()=>!this._resizable,onStart:()=>{let{before:e,after:s}=this._neighbours(t),n=this._resizeSubject(e,s);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,s)=>{s&&this._trackDelta(e),this._drag=null,delete this.el.dataset.dragging,s&&this._persist()},onStep:(e,s)=>this._stepDivider(t,e*(s?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 s=String(e.name??t.el.id??"")||y("zx-dock-sheet"),n={kind:"sheet",name:s,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)?F(Number(e.index),0,r.length):r.length;r.splice(o,0,[s,n]),this._panes=new Map(r);let l=xn(e.size);l!==null&&t.el.style.setProperty("--zx-pane-size",l),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=oe((h,u)=>{this._applyDockAt(n,ps(c,u))},{target:this.el}):this._applyDockAt(n,!0),n}release(t){let e=[...this._panes.values()].find(s=>s.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(s=>s.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 s=e.find(n=>n.grow);(s??e[e.length-1]).element.dataset.grow="true"}_syncDividers(){for(let t of this._dividers()){let{before:e,after:s}=this._neighbours(t),n=this._resizeSubject(e,s),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||ad(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=s=>{if(!s)return null;for(let n of this._panes.values())if(n.element===s)return n;return null};return{before:e(t.previousElementSibling),after:e(t.nextElementSibling)}}_resizeSubject(t,e){let s=n=>!!n&&!this._isHidden(n)&&n.element.dataset.grow!=="true";return s(t)?{element:t.element,record:t,sign:1,opposite:s(e)?e:null}:s(e)?{element:e.element,record:e,sign:-1,opposite:null}:null}_minSize(t){let s=(t.record.header??t.record.element.querySelector(".zx-dialog__header")??t.record.element).getBoundingClientRect(),n=this._orientation==="vertical"?s.height:s.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:s,oppositeStart:n}=this._drag,r=this._minSize(e),o=Math.max(r,s+t*e.sign);if(e.opposite){let l=this._minSize({record:e.opposite,element:e.opposite.element});o=Math.max(r,Math.min(o,s+n-l)),e.opposite.element.style.setProperty("--zx-pane-size",`${s+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:s,after:n}=this._neighbours(t),r=this._resizeSubject(s,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 ad(i){let t=y("zx-dock-pane");return i.id=t,t}function xn(i){return i==null||i===""?null:typeof i=="number"?Number.isFinite(i)?`${Math.max(0,i)}px`:null:String(i)}function vn(i,t,e){let s=e&&typeof t=="function"?t():t;if(s==null)return;if(typeof s=="string"||typeof s=="number"){i.append(document.createTextNode(String(s)));return}let n=s instanceof _?s.toElement():s;n&&typeof n.nodeType=="number"&&i.append(n)}var Bs=class extends _{static cssName="navigation-bar";static defaults={title:"",items:[],active:null,actions:[]};constructor(t,e={}){super(t,e),this._overflow=new X(this.refs.moreTrigger,{label:"More",icon:"dots",kind:"ghost",items:[],placement:"bottom-end"}),this._overflow.on("select",s=>{let n=this._find(String(s.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??a("section");this.el=e,this._createdRoot=t,this._original=t?null:cd(e),this._cleaned=!1,this._items=[],this._activeName=null,this._tabMode=!1,this._overflow=null;let s=a("header",{class:"zx-navigation-bar__bar"},a("div",{class:"zx-navigation-bar__brand",ref:"title"}),a("nav",{class:"zx-navigation-bar__navigation",ariaLabel:"Primary navigation"},a("div",{class:"zx-navigation-bar__items",ref:"items"}),a("div",{class:"zx-navigation-bar__more",ref:"more"},a("button",{class:"zx-navigation-bar__more-trigger",ref:"moreTrigger"}))),a("div",{class:"zx-navigation-bar__actions",ref:"actions",role:"group",ariaLabel:"Application actions"})),n=a("div",{class:"zx-navigation-bar__panels",ref:"panels",hidden:!0});return e.replaceChildren(s,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,s=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(s.has(h.name))throw new RangeError(`Navigation item already exists: ${h.name}`);if(s.add(h.name),Object.hasOwn(h,"content")&&!ld(h.content))throw new TypeError(`Navigation panel content for ${h.name} is invalid`);let u={name:h.name,title:String(h.title??""),badge:h.badge==null?null:String(h.badge),href:h.href==null?void 0:String(h.href),disabled:!!h.disabled,onselect:typeof h.onselect=="function"?h.onselect:void 0};return Object.hasOwn(h,"content")&&(u.content=h.content),u}),r=n.some(h=>Object.hasOwn(h,"content"));if(r&&n.some(h=>!Object.hasOwn(h,"content")))throw new TypeError("NavigationBar panel items must all define content");this._items=[],this._activeName=null,this._tabMode=r,this.refs.items.replaceChildren(),this.refs.panels.replaceChildren(),this.refs.panels.hidden=!this._tabMode,this._tabMode?(this.refs.items.setAttribute("role","tablist"),this.refs.items.setAttribute("aria-orientation","horizontal")):(this.refs.items.removeAttribute("role"),this.refs.items.removeAttribute("aria-orientation"));for(let h of n)this._appendItem(h);let o=e??this.options.active,l=o===null?null:this._find(o),c=l&&!l.definition.disabled?l:this._enabledItems()[0];return c&&this._applyActive(c),this._syncOverflow(),this}setActive(t){let e=this._find(t);return!e||e.definition.disabled||t===this._activeName?this:(this._applyActive(e),this.emit("change",{name:e.definition.name}),this)}setBadge(t,e){let s=this._require(t);return s.definition.badge=e===null?null:String(e),s.badge.textContent=s.definition.badge??"",s.badge.hidden=s.definition.badge===null,this._syncOverflow(),this}setActions(t){if(!Array.isArray(t))throw new TypeError("NavigationBar actions must be an array");let e=t.map(s=>{if(D(s))return s;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("NavigationBar actions must be Elements or button descriptors");let n={...s},r=n.onclick;delete n.onclick;let o=P(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&&hd(this.el,this._original))}_appendItem(t){let e=y("zx-navigation-item"),s=y("zx-navigation-panel"),n=a("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=a("button",{...r,type:"button",role:"tab",tabindex:"-1",ariaControls:s,ariaSelected:"false"},a("span",{class:"zx-navigation-bar__label"},t.title),n):t.href?o=a("a",{...r,href:t.href},a("span",{class:"zx-navigation-bar__label"},t.title),n):o=a("button",{...r,type:"button"},a("span",{class:"zx-navigation-bar__label"},t.title),n);let l=null;this._tabMode&&(l=a("div",{class:"zx-navigation-bar__panel",id:s,role:"tabpanel",tabindex:"0",ariaLabelledby:e,hidden:!0}),this.refs.panels.append(l));let c={definition:t,item:o,badge:n,panel:l,built:!1};this._items.push(c),this.refs.items.append(o),this.listen(o,"click",h=>{if(c.definition.disabled){h.preventDefault();return}this.setActive(c.definition.name),c.definition.onselect?.(c.definition.name,c.definition,this)})}_applyActive(t){this._tabMode&&this._ensurePanel(t);for(let e of this._items){let s=e===t;this._tabMode?(e.item.setAttribute("aria-selected",String(s)),e.item.tabIndex=s?0:-1,e.panel&&(e.panel.hidden=!s)):s?e.item.setAttribute("aria-current","page"):e.item.removeAttribute("aria-current")}this._activeName=t.definition.name}_ensurePanel(t){if(!t.panel||t.built)return;let e=t.definition.content,s=typeof e=="function"?e():e,n=s instanceof _?s.toElement():s;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 s=this._items.find(r=>r.item===e);if(!s)return;let n=this._enabledItems();if(t.key==="ArrowLeft"||t.key==="ArrowRight"){t.preventDefault();let r=t.key==="ArrowRight"?1:-1,o=n.indexOf(s),l=n[(o+r+n.length)%n.length];l&&this._focusTab(l);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(s.definition.name))}_syncOverflow(){this._overflow&&(this.refs.more.dataset.empty=this._items.length===0?"true":"false",this._overflow.setItems(this._items.map(t=>({label:t.definition.badge===null?t.definition.title:`${t.definition.title} (${t.definition.badge})`,value:t.definition.name,disabled:t.definition.disabled}))))}_focusTab(t){for(let e of this._items)e.item.tabIndex=e===t?0:-1;t.item.focus()}_enabledItems(){return this._items.filter(t=>!t.definition.disabled)}_find(t){return this._items.find(e=>e.definition.name===t)??null}_require(t){let e=this._find(t);if(!e)throw new RangeError(`Unknown navigation item: ${t}`);return e}};function ld(i){return typeof i=="function"||i instanceof _?!0:!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function cd(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function hd(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}function za(i){if(!Array.isArray(i))throw new TypeError("Stepper steps must be an array");let t=new Set;return i.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 Ps(i,t){return t===null?-1:i.findIndex(e=>e.name===t)}function Hs(i,t,e){let s=e<0?-1:1,n=t<0?s>0?0:i.length-1:t+s;for(;n>=0&&n<i.length;){if(!i[n].disabled)return n;n+=s}return-1}function Ca(i,t,e){return t<0||e<=t?[]:i.slice(t,e).map(s=>s.name)}function Ta(i,t,e={}){let{activeIndex:s=-1,completed:n,errored:r}=e;return ka(r,i.name)?"error":t===s?"active":ka(n,i.name)?"complete":"upcoming"}function ka(i,t){return i?i instanceof Set?i.has(t):i.includes(t):!1}var ud=new Set(["horizontal","vertical"]),dd=new Set(["completed","all",!1]),Vs=class extends _{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,!ud.has(this.options.orientation))throw new RangeError(`Unknown stepper orientation: ${this.options.orientation}`);if(!dd.has(this.options.clickable))throw new RangeError(`Unknown stepper clickable mode: ${this.options.clickable}`);let t=this.el??a("div");this.el=t,t.dataset.orientation=this.options.orientation;let e=a("p",{class:"zx-stepper__counter",ref:"counter",ariaLive:"polite",hidden:!0}),s=a("ol",{class:"zx-stepper__list",ref:"list"});return t.replaceChildren(...this.options.counter?[e,s]:[s]),this.setSteps(this.options.steps),this.listen(s,"click",n=>{let r=n.target.closest?.(".zx-stepper__control");if(!r||!s.contains(r)||r.tagName!=="BUTTON")return;let o=r.dataset.step;typeof o=="string"&&this.goTo(o)}),t}setSteps(t){let e=this.getActive(),s=za(t),n=new Set(s.map(l=>l.name));this._steps=s,this._completed=new Set([...this._completed].filter(l=>n.has(l))),this._errored=new Set([...this._errored].filter(l=>n.has(l)));let r=e??(this.options.active===null?null:String(this.options.active)),o=r===null?-1:Ps(s,r);return o>=0&&s[o].disabled&&(o=-1),o<0&&(o=Hs(s,-1,1)),this._activeIndex=o,this._records=s.map(l=>this._createRecord(l)),this.refs.list.replaceChildren(...this._records.map(l=>l.item)),this._sync(),this}goTo(t){let e=Ps(this._steps,t);if(e<0)throw new RangeError(`Unknown step: ${t}`);return this._activate(e)}next(){return this._activate(Hs(this._steps,this._activeIndex,1))}previous(){return this._activate(Hs(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 s=this._activeIndex;if(this.emit("change",{name:e.name,previous:s<0?null:this._steps[s].name,index:t}).defaultPrevented)return this;for(let r of Ca(this._steps,s,t))this._completed.add(r);return this._activeIndex=t,this._sync(),this}_createRecord(t){let e=a("span",{class:"zx-stepper__marker",ariaHidden:"true"}),s=a("span",{class:"zx-stepper__status"}),n=[a("span",{class:"zx-stepper__title"},t.title)];t.description&&n.push(a("span",{class:"zx-stepper__description"},t.description)),t.optional&&n.push(a("span",{class:"zx-stepper__optional"},this._message("stepper.optional","Optional")));let r=[e,a("span",{class:"zx-stepper__text"},n),s],o=this.options.clickable===!1?a("span",{class:"zx-stepper__control"},r):a("button",{class:"zx-stepper__control",type:"button",dataset:{step:t.name}},r);return{step:t,item:a("li",{class:"zx-stepper__step"},o),control:o,marker:e,status:s}}_sync(){this._records.forEach((t,e)=>{let s=this._stateFor(t.step,e);t.item.dataset.state=s,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(s,e)),t.status.textContent=this._statusText(s),t.control.tagName==="BUTTON"&&(t.control.disabled=!this._isClickable(t.step))}),this._syncCounter()}_stateFor(t,e){return Ta(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=Ps(this._steps,t);if(e<0)throw new RangeError(`Unknown step: ${t}`);return this._steps[e]}_message(t,e,...s){let n=this.msg(t,...s);return n===t?R(e,s):n}};var pd=new Set(["chevron","slash"]),js=class extends _{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,!pd.has(this.options.separator))throw new RangeError(`Unknown breadcrumb separator: ${this.options.separator}`);let t=this.el??a("nav");this.el=t,t.tagName!=="NAV"&&t.setAttribute("role","navigation"),t.setAttribute("aria-label",this._message("breadcrumb.label","Breadcrumb"));let e=a("ol",{class:"zx-breadcrumb__list",ref:"list"});return t.replaceChildren(e),this.setItems(this.options.items),this.listen(e,"click",s=>{let n=s.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(s=>{if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("Breadcrumb item must be an object");if(typeof s.name!="string"||s.name==="")throw new TypeError("Breadcrumb item name must be a non-empty string");if(e.has(s.name))throw new RangeError(`Breadcrumb item already exists: ${s.name}`);return e.add(s.name),{name:s.name,label:String(s.label??""),icon:s.icon?String(s.icon):null,href:s.href==null?null:String(s.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(s=>s.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:s}=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 s)r.push(this._renderItem(o,o===n));this.refs.list.replaceChildren(...r.map((o,l)=>a("li",{class:"zx-breadcrumb__item"},l===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 s=Math.max(2,e);if(t.length<=s)return{head:t,hidden:[],tail:[]};let n=s-1;return{head:t.slice(0,1),hidden:t.slice(1,t.length-n),tail:t.slice(t.length-n)}}_renderItem(t,e){let s=[],n=t.icon??(t===this._items[0]?this.options.rootIcon:null);return n&&s.push(a("span",{class:"zx-breadcrumb__icon",ariaHidden:"true"},g(String(n),{size:13}))),s.push(a("span",{class:"zx-breadcrumb__label"},t.label)),e?a("span",{class:"zx-breadcrumb__current",ariaCurrent:"page"},s):t.href!==null?a("a",{class:"zx-breadcrumb__link",href:t.href,dataset:{crumb:t.name}},s):a("button",{class:"zx-breadcrumb__link",type:"button",dataset:{crumb:t.name}},s)}_renderOverflow(t){if(!this._overflow){this._overflow=new X(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",s=>this._select(String(s.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 a("span",{class:"zx-breadcrumb__separator",ariaHidden:"true"},this.options.separator==="slash"?"/":g("chevron-right",{size:11}))}_select(t){let e=this._items.findIndex(s=>s.name===t);e<0||this.emit("select",{name:this._items[e].name,item:{...this._items[e]},index:e})}_message(t,e,...s){let n=this.msg(t,...s);return n===t?R(e,s):n}};var Ks="\u2026",fd=new Set(["pages","loadmore"]);function Sn({page:i=1,pages:t=1,siblings:e=1,boundaries:s=1}={}){let n=Lt(t);if(n<=0)return[];let r=An(Lt(i)||1,1,n),o=Math.max(0,Lt(e)),l=Math.max(0,Lt(s)),c=l*2+o*2+3;if(n<=c)return $s(1,n);let h=$s(1,Math.min(l,n)),u=$s(Math.max(n-l+1,l+1),n),d=Math.max(Math.min(r-o,n-l-o*2-1),l+2),f=Math.min(Math.max(r+o,l+o*2+2),u.length>0?u[0]-2:n-1);return[...h,...d>l+2?[Ks]:l+1<n-l?[l+1]:[],...$s(d,f),...f<n-l-1?[Ks]:n-l>l?[n-l]:[],...u]}var Us=class extends _{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=wn(this.options.pageSize,25),this._total=Math.max(0,Lt(this.options.total)),this._page=Math.max(1,Lt(this.options.page)||1),this._disabled=!!this.options.disabled,this._sizeKey="",this._pageSizes=(Array.isArray(this.options.pageSizes)?this.options.pageSizes:[]).map(s=>wn(s,0)).filter(s=>s>0),!fd.has(this.options.mode))throw new RangeError(`Unknown pagination mode: ${this.options.mode}`);this._page=An(this._page,1,this._pageCount());let t=this.el??a("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(a("span",{class:"zx-pagination__summary",ref:"summary",ariaLive:"polite"})),e.push(a("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 s=this._page,n=this._pageSize;if(Object.hasOwn(t,"total")&&(this._total=Math.max(0,Lt(t.total))),Object.hasOwn(t,"pageSize")&&(this._pageSize=wn(t.pageSize,this._pageSize)),Object.hasOwn(t,"page")){let r=Math.trunc(Number(t.page));Number.isFinite(r)&&(this._page=r)}return this._page=An(this._page,1,this._pageCount()),this._sync(),!e&&(this._page!==s||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 a("label",{class:"zx-pagination__size"},a("span",{class:"zx-pagination__size-label"},t),a("select",{class:"zx-pagination__select",ref:"select",ariaLabel:t}))}_renderPages(){return a("div",{class:"zx-pagination__controls"},this._navButton("prev","chevron-left",this._message("pagination.previous","Previous page")),a("div",{class:"zx-pagination__pages",ref:"pages"}),this._navButton("next","chevron-right",this._message("pagination.next","Next page")))}_navButton(t,e,s){return a("button",{class:"zx-btn zx-pagination__nav",type:"button",ref:t,ariaLabel:s,dataset:{kind:"default",size:"sm"}},g(e,{size:14}))}_renderLoadMore(){return a("button",{class:"zx-btn zx-pagination__more",type:"button",ref:"more",dataset:{kind:"default",size:"md"}},a("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",qe(e),qe(this._total)):this._message("pagination.summary","%1\u2013%2 of %3",qe(t+1),qe(e),qe(this._total))}_syncPageSize(){let t=this.refs.select,e=[...new Set([...this._pageSizes,this._pageSize])].sort((n,r)=>n-r),s=e.join(",");s!==this._sizeKey&&(this._sizeKey=s,t.replaceChildren(...e.map(n=>a("option",{value:String(n)},String(n))))),t.value=String(this._pageSize),t.disabled=this._disabled}_syncPages(t){let e=this.refs.pages,s=this.el.ownerDocument?.activeElement??null,n=s&&e.contains(s)?s.dataset.page??null:null,r=Sn({page:this._page,pages:t,siblings:this.options.siblings,boundaries:this.options.boundaries});if(e.replaceChildren(...r.map(l=>l===Ks?a("span",{class:"zx-pagination__ellipsis",ariaHidden:"true"},Ks):a("button",{class:"zx-btn zx-pagination__page",type:"button",disabled:this._disabled,ariaCurrent:l===this._page?"page":null,ariaLabel:this._message("pagination.page","Page %1",l),dataset:{kind:"default",size:"sm",page:String(l)}},String(l)))),n===null)return;let o=e.querySelector(`[data-page="${n}"]`);o&&!o.disabled&&o.focus()}_message(t,e,...s){let n=this.msg(t,...s);return n===t?R(e,s):n}};function Lt(i){let t=Math.trunc(Number(i));return Number.isFinite(t)&&t>0?t:0}function wn(i,t){let e=Math.trunc(Number(i));return Number.isFinite(e)&&e>0?e:t}function An(i,t,e){return Math.min(Math.max(i,t),e)}function $s(i,t){return t<i?[]:Array.from({length:t-i+1},(e,s)=>i+s)}function qe(i){return i.toLocaleString()}var Be=class extends _{static cssName="app-icon";static defaults={icon:null,color:null,size:36,iconSize:"52%",label:null,badge:null,selected:!1,glass:"subtle",class:[]};render(){this._createdRoot=this.el===null;let t=this.el??a("span");return this.el=t,this._snapshot=this._createdRoot?null:k(t),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(l=>String(l??"").split(/\s+/)).filter(Boolean),this.el.classList.add(...this._appliedClasses);let e=Ea(t.size,"36px"),s=Ea(t.iconSize,"52%");this.el.style.setProperty("--zx-app-icon-size",e),this.el.style.setProperty("--zx-app-icon-glyph-size",s),jt(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=md(t.glass),this.el.toggleAttribute("data-selected",!!t.selected);let n=t.label==null?"":String(t.label).trim();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=_d(t.icon),o=t.badge==null||t.badge===""?null:a("span",{class:"zx-app-icon__badge",ariaHidden:"true"},String(t.badge));this.el.replaceChildren(a("span",{class:"zx-app-icon__shine",ariaHidden:"true"}),a("span",{class:"zx-app-icon__glyph",ariaHidden:"true"},r),o)}};function Ia(i={}){return new Be(null,i).toElement()}function _d(i){let t=typeof i=="function"?i():i;return typeof t=="string"?g(t,{size:"1em"}):t&&typeof t=="object"&&typeof t.nodeType=="number"?t:null}function Ea(i,t){if(typeof i=="number"&&Number.isFinite(i))return`${Math.max(1,i)}px`;let e=String(i??"").trim();return e&&!/[;{}]/.test(e)?e:t}function md(i){return i===!1||i==="none"?"none":i==="strong"?"strong":"subtle"}var Gs=class extends _{static cssName="launcher";static defaults={items:[],sources:[],query:"",debounce:250,minQuery:0,maxResults:100,placeholder:"Search applications and records",label:"Launcher",closeLabel:"Close launcher",resultsLabel:"Launcher results",emptyText:"No results",loadingText:"Searching\u2026",shortcut:"mod+k",hints:{move:"Move",open:"Open",close:"Close"}};constructor(t=null,e={}){super(t,e)}render(){if(this.el!==null&&!(this.el instanceof HTMLDialogElement))throw new TypeError("Launcher target must be a <dialog> element");this._createdRoot=this.el===null;let t=this.el??a("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=kn(this.options.items),this._sources=Na(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=y("zx-launcher-results"),s=a("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=a("button",{ref:"close",class:"zx-icon-btn zx-launcher__close",type:"button",ariaLabel:this.options.closeLabel},g("x")),r=a("div",{ref:"status",class:"zx-launcher__status",role:"status",ariaLive:"polite"}),o=a("div",{ref:"results",class:"zx-launcher__results",id:e,role:"listbox",ariaLabel:this.options.resultsLabel}),l=this.options.shortcut==="mod+k"?a("kbd",{class:"zx-launcher__shortcut",ariaHidden:"true"},gd()):null,c=bd(this.options.hints);return t.setAttribute("aria-label",String(this.options.label)),t.replaceChildren(a("div",{class:"zx-launcher__surface"},a("div",{class:"zx-launcher__search",dataset:{shortcut:l?"true":"false"}},g("search"),s,l,n),r,o,c)),t.dataset.state="closed",this._createdRoot&&document.body.append(t),this.listen(s,"input",()=>{this._query=s.value,this.emit("query",{query:this._query.trim()}),this._refresh()}),this.listen(s,"keydown",h=>this._onKeydown(h)),this.listen(n,"click",()=>this.close()),this.listen(o,"click",h=>{let u=h.target?.closest?.("[data-launcher-index]");!u||!o.contains(u)||this._activate(Number(u.getAttribute("data-launcher-index")),h)}),this.listen(o,"pointermove",h=>{let u=h.target?.closest?.("[data-launcher-index]");if(!u||!o.contains(u))return;let d=Number(u.getAttribute("data-launcher-index"));!Number.isInteger(d)||this._results[d]?.disabled||d===this._active||(this._active=d,this._syncActive())}),this.listen(t,"cancel",h=>{h.preventDefault(),this.close()}),this.listen(t,"close",()=>{t.dataset.state="closed",s.setAttribute("aria-expanded","false"),this._abortRequest(),this.emit("close")}),this.listen(document,"keydown",h=>this._onDocumentKeydown(h)),this._renderResults(),t}open(){return this.isOpen()||this._destroyed?this:(this.el.showModal(),this.el.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this._refresh(),queueMicrotask(()=>{this.isOpen()&&(this.refs.input.focus(),this.refs.input.select())}),this.emit("open"),this)}close(){return this.isOpen()&&this.el.close(),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return!!this.el.open}focus(){return this.refs.input.focus(),this.refs.input.select(),this}setQuery(t){return this._query=String(t??""),this.refs.input.value=this._query,this.emit("query",{query:this._query.trim()}),this._refresh(),this}getQuery(){return this._query}setItems(t){return this._items=kn(t),this._renderResults(),this}setCurrent(t){let e=t==null?null:String(t);return this._items=this._items.map(s=>({...s,current:e!==null&&String(s.id)===e})),this._renderResults(),this}setSources(t){return this._abortRequest(),this._sources=Na(t),this._sourceItems.clear(),this._refresh(),this}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this._original;if(this._abortRequest(),this.isOpen()&&this.el.close(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_refresh(){if(this._sourceItems.clear(),this._renderResults(),this._abortRequest(),this._sources.length===0)return;let t=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>this._loadSources(),t)}async _loadSources(){this._queryTimer=null;let t=this._query.trim(),e=this._sources.filter(r=>Ys(r.when,t)&&t.length>=Math.max(Number(this.options.minQuery)||0,Number(r.minQuery)||0));if(e.length===0)return;let s=new AbortController,n=++this._requestSequence;this._request=s,this._setBusy(!0),await Promise.all(e.map(async r=>{try{let o=await r.load(t,{signal:s.signal});if(s.signal.aborted||n!==this._requestSequence)return;this._sourceItems.set(r.id,kn(o).map((l,c)=>({...l,_source:r.id,_sourceOrder:r.order==="source",group:l.group??r.label??"",itemOrder:l.itemOrder??(r.order==="source"?c:void 0)}))),this._renderResults()}catch(o){if(s.signal.aborted||n!==this._requestSequence)return;this.emit("error",{source:r,error:o})}})),!(s.signal.aborted||n!==this._requestSequence)&&(this._request=null,this._setBusy(!1))}_setBusy(t){this._busy=t,this.el.setAttribute("aria-busy",String(t)),this._renderStatus()}_abortRequest(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._request?.abort(),this._request=null,this._requestSequence+=1,this._busy&&this._setBusy(!1)}_renderResults(){let t=this._query,e=this._renderedQuery===t&&this._active>=0&&this._results[this._active]?String(this._results[this._active].id):null,s=this._query.trim(),n=this._items.filter(p=>Ys(p.when,s)),r=Qs(n,s,this.options.maxResults),o=this._sources.flatMap(p=>{let m=this._sourceItems.get(String(p.id))??[];return p.order==="source"?m.filter(b=>Ys(b.when,s)):Qs(m.filter(b=>Ys(b.when,s)),s,this.options.maxResults)}),l=new Set,c=[...r.map(p=>({...p,_source:null})),...o].filter(p=>{let m=String(p.id);return l.has(m)?!1:(l.add(m),!0)}).slice(0,Math.max(0,Number(this.options.maxResults)||0)),h=new Map;for(let p of c){let m=String(p.group??"");h.has(m)||h.set(m,[]),h.get(m).push(p)}this._results=[...h.values()].flat(),this._renderedQuery=t;let u=e===null?-1:this._results.findIndex(p=>!p.disabled&&String(p.id)===e);this._active=u>=0?u:this._results.findIndex(p=>!p.disabled);let d=[],f=0;for(let[p,m]of h){let b=m.map(w=>this._option(w,f++));p?d.push(a("div",{class:"zx-launcher__group",role:"group",ariaLabel:p,dataset:{layout:m.every(w=>w.kind==="application")?"grid":"list"}},a("div",{class:"zx-launcher__group-label",ariaHidden:"true"},p),b)):d.push(...b)}this.refs.results.replaceChildren(...d),this._syncActive(),this._renderStatus()}_option(t,e){let s=bt(t.href),n=s?"a":"button",r=[],o=yd(t);return o&&r.push(a("span",{class:"zx-launcher__icon",ariaHidden:"true"},o)),r.push(a("span",{class:"zx-launcher__copy"},a("span",{class:"zx-launcher__label"},t.label),t.description?a("span",{class:"zx-launcher__description"},t.description):null)),t.badge!=null&&r.push(a("span",{class:"zx-launcher__badge"},String(t.badge))),a(n,{class:"zx-launcher__option",type:n==="button"?"button":null,href:s,target:t.target??null,rel:n==="a"?"noopener":null,role:"option",id:y("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:xd(t.kind)}},r)}_renderStatus(){this._busy?this.refs.status.textContent=String(this.options.loadingText):this._results.length===0?this.refs.status.textContent=String(this.options.emptyText):this.refs.status.textContent="",this.refs.status.hidden=!this.refs.status.textContent}_syncActive(){let t=[...this.refs.results.querySelectorAll("[data-launcher-index]")];for(let s of t){let n=Number(s.getAttribute("data-launcher-index"))===this._active;s.setAttribute("aria-selected",String(n))}let e=t.find(s=>Number(s.getAttribute("data-launcher-index"))===this._active);e?this.refs.input.setAttribute("aria-activedescendant",e.id):this.refs.input.removeAttribute("aria-activedescendant")}_onKeydown(t){if(t.key==="Escape"){this.close();return}if(t.key==="Enter"){if(this._active<0)return;t.preventDefault(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.click();return}let e=this._results.map((n,r)=>n.disabled?-1:r).filter(n=>n>=0);if(e.length===0)return;if(/^Arrow(?:Left|Right|Up|Down)$/.test(t.key)){let n=this._spatialIndex(t.key,e);if(n!==null){t.preventDefault(),this._active=n,this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"});return}if(t.key==="ArrowLeft"||t.key==="ArrowRight")return}let s=e.indexOf(this._active);if(t.key==="Home"||t.key==="PageUp")s=0;else if(t.key==="End"||t.key==="PageDown")s=e.length-1;else if(t.key==="ArrowDown")s=(s+1+e.length)%e.length;else if(t.key==="ArrowUp")s=(s-1+e.length)%e.length;else return;t.preventDefault(),this._active=e[s],this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest"})}_spatialIndex(t,e){let s=this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`);if(!(s instanceof HTMLElement)||(t==="ArrowLeft"||t==="ArrowRight")&&this._results[this._active]?.kind!=="application")return null;let n=[...this.refs.results.querySelectorAll("[data-launcher-index]")].filter(o=>e.includes(Number(o.getAttribute("data-launcher-index")))&&(t!=="ArrowLeft"&&t!=="ArrowRight"||o.getAttribute("data-kind")==="application")),r=vd(n,s,t);return r?Number(r.getAttribute("data-launcher-index")):null}_activate(t,e){let s=this._results[t];if(!s||s.disabled){e.preventDefault();return}if(this.emit("select",{item:s,value:s.value??s.id,source:s._source??null,query:this._query.trim()}).defaultPrevented){e.preventDefault();return}s.href||(e.preventDefault(),s.invoke?.()),this.close()}_onDocumentKeydown(t){if(this.options.shortcut!=="mod+k"||t.isComposing||t.key.toLowerCase()!=="k"||Number(t.metaKey)+Number(t.ctrlKey)!==1||t.altKey||t.shiftKey)return;let e=document.activeElement;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)return;let s=document.querySelector("dialog:modal");s&&s!==this.el||(t.preventDefault(),this.open())}};function gd(){let i=String(navigator.userAgentData?.platform??navigator.platform??"");return/mac|iphone|ipad/i.test(i)?"\u2318 K":"Ctrl K"}function bd(i){if(i===!1)return null;let t=i&&typeof i=="object"?i:{};return a("footer",{class:"zx-launcher__hints",ariaHidden:"true"},a("span",{},a("kbd",{},"\u2191\u2193\u2190\u2192"),t.move??"Move"),a("span",{},a("kbd",{},"\u21B5"),t.open??"Open"),a("span",{},a("kbd",{},"Esc"),t.close??"Close"))}function yd(i){let t=i.icon;if(typeof t=="function"&&(t=t(i)),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 xd(i){return i==="application"||i==="record"?i:"action"}function Ys(i,t){return i==="empty"?t==="":i==="query"?t!=="":!0}function vd(i,t,e){let s=t.getBoundingClientRect();if(s.width===0&&s.height===0)return null;let n=s.left+s.width/2,r=s.top+s.height/2,o=null,l=1/0;for(let c of i){if(c===t)continue;let h=c.getBoundingClientRect(),u=h.left+h.width/2-n,d=h.top+h.height/2-r,f=!1,p=1/0;e==="ArrowLeft"?(f=u<-2&&Math.abs(d)<Math.max(s.height,h.height)/2,p=Math.abs(u)+Math.abs(d)*4):e==="ArrowRight"?(f=u>2&&Math.abs(d)<Math.max(s.height,h.height)/2,p=Math.abs(u)+Math.abs(d)*4):e==="ArrowUp"?(f=d<-2,p=Math.abs(d)*10+Math.abs(u)):e==="ArrowDown"&&(f=d>2,p=Math.abs(d)*10+Math.abs(u)),f&&p<l&&(o=c,l=p)}return o}function Qs(i,t,e=100){let s=me(t).trim(),n=i.map((o,l)=>({item:o,order:l,score:wd(o,s)})).filter(({score:o})=>o<1/0);n.sort((o,l)=>{let c=Ws(o.item.groupOrder),h=Ws(l.item.groupOrder);if(c!==h)return c-h;if(s===""){let u=Da(o.item.pinned,o.order),d=Da(l.item.pinned,l.order);if(u!==d)return u-d}return o.score-l.score||Ws(o.item.itemOrder)-Ws(l.item.itemOrder)||Ad(o.item.label,l.item.label)||o.order-l.order});let r=Math.max(0,Number(e)||0);return n.slice(0,r||0).map(({item:o,score:l})=>({...o,_score:l}))}function wd(i,t){if(!t)return i.pinned?-1:0;let e=me(i.label),s=me(i.id),n=me(Array.isArray(i.keywords)?i.keywords.join(" "):i.keywords??"");return e===t?0:e.startsWith(t)?10:e.split(/[^\p{L}\p{N}]+/u).some(o=>o.startsWith(t))?20:e.includes(t)||n.includes(t)?30:s.includes(t)?40:e.split(/[^\p{L}\p{N}]+/u).filter(Boolean).map(o=>o[0]).join("").startsWith(t)?50:1/0}function Da(i,t){return typeof i=="number"&&Number.isFinite(i)?i:i?t:Number.MAX_SAFE_INTEGER}function Ws(i){return typeof i=="number"&&Number.isFinite(i)?i:Number.MAX_SAFE_INTEGER}function me(i){return String(i??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function Ad(i,t){let e=me(i),s=me(t);if(e<s)return-1;if(e>s)return 1;let n=String(i??"").normalize("NFC"),r=String(t??"").normalize("NFC");return n<r?-1:n>r?1:0}function kn(i){return Array.isArray(i)?i.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>Sd(t)):[]}function Sd(i){let t={...i,label:String(i.label)};if(i.href==null)return t;let e=bt(i.href);return e!==null?t.href=e:(delete t.href,typeof t.invoke!="function"&&(t.disabled=!0)),t}function Na(i){return Array.isArray(i)?i.filter(t=>t&&typeof t=="object"&&t.id!=null&&typeof t.load=="function").map(t=>({...t,id:String(t.id)})):[]}var ge=class extends _{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??a("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=a("img",{ref:"image",class:"zx-avatar__image",alt:"",draggable:!1}),s=a("span",{ref:"fallback",class:"zx-avatar__fallback",ariaHidden:"true"}),n=a("span",{ref:"status",class:"zx-avatar__status",ariaHidden:"true",hidden:!0});return t.replaceChildren(e,s,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,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_sync(){let{size:t,shape:e,label:s}=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||zn(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:s}=this._state;if(t){let n=["online","away","busy","offline"].includes(e)?s: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 s=this._state.statusLabel;s?this.refs.status.setAttribute("title",String(s)):this.refs.status.removeAttribute("title")}};function zn(i){let t=String(i??"").trim().split(/\s+/u).filter(Boolean);if(t.length===0)return"?";let e=Ma(t[0]),s=t.length>1?Ma(t[t.length-1]):"";return`${e}${s}`}function Ma(i){return Oa(Oa(i).toUpperCase())}function Oa(i){return typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(i)[Symbol.iterator]().next().value?.segment??"":Array.from(i)[0]??""}var Js=class extends _{static cssName="account-menu";static defaults={account:{},items:[],compact:!1,label:null,placement:"top-start"};constructor(t=null,e={}){super(t,e);for(let s of["select","open","close"])this.listen(this.refs.trigger,`zx-${s}`,n=>n.stopPropagation());this._avatar=new ge(this.refs.avatar,La(this._account)),this._menu=new X(this.refs.trigger,{items:this.options.items,placement:this.options.placement}),this._menu.on("select",s=>{this.emit("select",s.detail).defaultPrevented&&s.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??a("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=Fa(this.options.account),t.dataset.compact=String(!!this.options.compact),t.replaceChildren(a("button",{ref:"trigger",class:"zx-account-menu__trigger",type:"button"},a("span",{ref:"avatar",class:"zx-account-menu__avatar"}),a("span",{class:"zx-account-menu__identity"},a("span",{ref:"name",class:"zx-account-menu__name"}),a("span",{ref:"secondary",class:"zx-account-menu__secondary"})),a("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=Fa(t),this._avatar.set(La(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,s]of t.attributes)this.el.setAttribute(e,s);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}`:"",s=this.options.label||`Account menu${this._account.name?` for ${this._account.name}`:""}${e}`;this.refs.trigger.setAttribute("aria-label",s),this._renderPanelHeader()}_renderPanelHeader(){let t=this._menu.getPanel();t.querySelector(".zx-account-menu__panel-identity")?.remove(),t.prepend(a("div",{class:"zx-account-menu__panel-identity",role:"presentation"},a("strong",{},this._account.name||"Account"),this._account.secondary?a("span",{},this._account.secondary):null))}};function Fa(i){let t=i&&typeof i=="object"?i:{};return{...t,name:String(t.name??""),secondary:String(t.secondary??"")}}function La(i){return{name:i.name,src:i.src??null,initials:i.initials??null,status:i.status??null,statusLabel:i.statusLabel??null,label:null,size:"md"}}var kd=new Set(["top","bottom","top-start","top-end","bottom-start","bottom-end","left","right","left-start","left-end","right-start","right-end"]),zd=new Set(["hover","focus","both","manual"]),zt=class extends _{static cssName="tooltip";static defaults={content:"",placement:"top",offset:6,delay:400,hideDelay:80,maxWidth:260,trigger:"both",disabled:!1};#t;#e;#s=null;#i=null;#r=0;#n=0;#o=!1;#a=!1;#l=!1;constructor(t,e={}){let s=H(t);if(!s)throw new TypeError("Tooltip anchor could not be resolved");super(null,e),this.#t=s,this.#e=this.options.content,this.#a=!!this.options.disabled,this.#i=s.getAttribute("aria-describedby"),this.el.style.setProperty("--zx-tooltip-max-inline-size",Ed(this.options.maxWidth));let n=zd.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||!Id(this.#t)||this.#c(0)}),this.listen(this.#t,"focusout",()=>this.#h(Number(this.options.hideDelay)))),this.listen(document,"keydown",r=>{r.key!=="Escape"||!this.isOpen()||(r.preventDefault(),this.hide())}),this.listen(document,"pointerdown",()=>{this.#o=!0,this.#u(),this.hide()},{capture:!0}),this.listen(document,"pointerup",()=>{this.#o=!1},{capture:!0}),this.listen(document,"pointercancel",()=>{this.#o=!1},{capture:!0}),this.listen(document,"focusin",r=>{!this.isOpen()||r.composedPath().includes(this.#t)||this.hide()}))}render(){let t=a("div",{id:y("zx-tooltip"),role:"tooltip",popover:"manual"});return t.dataset.state="closed",document.body.append(t),t}show(){if(this.#l||this.#a||this.isOpen())return this;this.#u();let t=Ra(this.#e);return t===null?this:(this.el.replaceChildren(t),this.#s=U(this.#t,this.el,{placement:kd.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",Td(this.#i,this.el.id)),this.emit("open"),this)}hide(){return this.#u(),this.isOpen()?(this.#s?.destroy(),this.#s=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.#s!==null}setContent(t){if(this.#e=t,!this.isOpen())return this;let e=Ra(t);return e===null?this.hide():(this.el.replaceChildren(e),this.#s?.update(),this)}enable(){return this.#a=!1,this}disable(){return this.#a=!0,this.hide()}isDisabled(){return this.#a}getAnchor(){return this.#t}destroy(){this.#l||(this.#l=!0,this.hide(),this.#d(),super.destroy())}#c(t){if(this.#u(),this.#l||this.#a||this.isOpen())return;let e=Number.isFinite(t)?Math.max(0,t):0;if(e===0){this.show();return}this.#r=setTimeout(()=>{this.#r=0,this.show()},e)}#h(t){if(this.#u(),!this.isOpen())return;let e=Number.isFinite(t)?Math.max(0,t):0;if(e===0){this.hide();return}this.#n=setTimeout(()=>{this.#n=0,this.hide()},e)}#u(){this.#r!==0&&clearTimeout(this.#r),this.#n!==0&&clearTimeout(this.#n),this.#r=0,this.#n=0}#d(){this.#i===null?this.#t.removeAttribute("aria-describedby"):this.#t.setAttribute("aria-describedby",this.#i)}};function qa(i,t=""){return new zt(i,Cd(t)?t:{content:t})}function Ba(i,t){return new zt(i,{content:String(t??"")})}function Cd(i){return i===null||typeof i!="object"||Array.isArray(i)||typeof i.nodeType=="number"?!1:typeof i.toElement!="function"}function Ra(i){let t=typeof i=="function"?i():i;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 Td(i,t){let e=String(i??"").split(/\s+/).filter(Boolean);return e.includes(t)||e.push(t),e.join(" ")}function Ed(i){return typeof i=="number"&&Number.isFinite(i)?`${i}px`:String(i)}function Id(i){try{return i.matches(":focus-visible")}catch{return!0}}var Xs=class extends _{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??a("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=Ct(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 s=a("div",{class:"zx-app-rail__header"}),n=a("div",{class:"zx-app-rail__footer"});return Va(s,this.options.header),Va(n,this.options.footer),s.hidden=!s.hasChildNodes(),n.hidden=!n.hasChildNodes(),t.replaceChildren(s,a("ul",{ref:"list",class:"zx-app-rail__list"}),n),this.listen(t,"keydown",r=>this._onRailKeydown(r)),t}setItems(t){return this._items=Ct(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 s=this._resolveFlyout(t);if(!s)return this;let n=[s],r=s.parentKey===null?null:this._flyouts.get(s.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(s,!0);for(let[o,l]of this._flyouts)o!==s.key&&l.dropdown.isOpen()&&!this._isAncestor(l,s)&&this.closeFlyout(o);for(let o of n)this._tooltipById.get(String(o.item.id))?.hide(),o.dropdown.open();return e&&Ha(s.panel)?.focus(),this}closeFlyout(t){let e=this._resolveFlyout(t);if(!e)return this;for(let s of[...this._flyouts.values()].reverse())s!==e&&this._isAncestor(e,s)&&(this._cancelTimers(s.key),s.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 Ha(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,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_rebuild(){this._clearArtifacts(),this.refs.list.replaceChildren(),this._interaction=new Cn(this.el),this._items.forEach(t=>{let e=Array.isArray(t.children)&&t.children.length>0,s=Pa(t,{className:"zx-app-rail__item",index:String(t.id),iconOnly:!0,disclosure:e,disclosureIcon:Dd(this.el.dataset.side),visual:Zs(t,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:1,location:"root"})}),n=a("li",{class:"zx-app-rail__row"},s);this.refs.list.append(n);let r=new zt(s,{content:t.label,placement:Fd(this.el.dataset.side),delay:450});this._tooltips.push(r),this._tooltipById.set(String(t.id),r),e?this._buildFlyout(t,s,String(t.id),null):this._interaction.listen(s,"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 s=t.composedPath();if(!e.some(n=>s.includes(n.panel)||s.includes(n.trigger)))for(let n of e)n.parentKey===null&&this.closeFlyout(n.key)}),this._syncActive()}_buildFlyout(t,e,s,n){let r=a("ul",{class:"zx-app-rail__flyout-list"});for(let u of t.children??[]){let d=`${s}/${u.id}`,f=!!u.children?.length,p=Pa(u,{className:"zx-app-rail__flyout-item",index:d,iconOnly:!1,disclosure:f,disclosureIcon:Nd(this.el.dataset.side),visual:Zs(u,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:d.split("/").length,location:"flyout"})});r.append(a("li",{},p)),f?this._buildFlyout(u,p,d,s):this._interaction.listen(p,"click",m=>{this._select(u,m).defaultPrevented||this._closeFlyoutChain(s)})}let o=a("div",{class:"zx-app-rail__flyout"},a("div",{class:"zx-app-rail__flyout-title"},t.label),r),l=new J(e,{openOn:"manual",placement:n===null?Md(this.el.dataset.side):Od(this.el.dataset.side),content:o,offset:6}),c=l.getPanel();c.classList.add("zx-app-rail__popover"),c.setAttribute("role","region"),c.setAttribute("aria-label",`${t.label} sub-navigation`);let h={key:s,parentKey:n,item:t,trigger:e,panel:c,dropdown:l};this._flyouts.set(s,h),l.on("open",()=>{this._silenceFlyoutEvents||this.emit("flyoutchange",{item:t,id:t.id,open:!0})}),l.on("close",()=>{this._silenceFlyoutEvents||this.emit("flyoutchange",{item:t,id:t.id,open:!1})}),this._interaction.listen(e,"pointerdown",()=>{this._pointerFocus.add(e),queueMicrotask(()=>this._pointerFocus.delete(e))}),this._interaction.listen(e,"pointerenter",u=>{u.pointerType!=="touch"&&this._scheduleOpen(s)}),this._interaction.listen(e,"pointerleave",()=>this._scheduleClose(s)),this._interaction.listen(e,"focus",()=>{this._pointerFocus.has(e)||this.openFlyout(s)}),this._interaction.listen(e,"focusout",u=>{c.contains(u.relatedTarget)||this._scheduleClose(s)}),this._interaction.listen(e,"click",u=>{u.preventDefault(),u instanceof MouseEvent&&u.detail===0?this.openFlyout(s,{focus:!0}):this.openFlyout(s)}),this._interaction.listen(c,"pointerenter",()=>this._cancelFlyoutTimers(h,!0)),this._interaction.listen(c,"pointerleave",()=>this._scheduleFlyoutClose(h,!0)),this._interaction.listen(c,"focusin",()=>this._cancelFlyoutTimers(h,!0)),this._interaction.listen(c,"focusout",u=>{u.relatedTarget!==e&&!c.contains(u.relatedTarget)&&this._scheduleFlyoutClose(h,!0)}),this._interaction.listen(c,"keydown",u=>this._onFlyoutKeydown(u,h))}_select(t,e){if(t.disabled){e.preventDefault();let n=new Event("select",{cancelable:!0});return n.preventDefault(),n}let s=this.emit("select",{item:t,id:t.id,value:t.value??t.id,href:t.href??null,event:e});return s.defaultPrevented?e.preventDefault():t.href||(e.preventDefault(),t.invoke?.()),s}_onRailKeydown(t){let e=Ld(this.refs.list),s=t.target?.closest?.("[data-app-nav-id]"),n=e.indexOf(s);if(n<0)return;let r=this.el.dataset.orientation==="horizontal",o=r?"ArrowLeft":"ArrowUp",l=r?"ArrowRight":"ArrowDown",c={left:"ArrowRight",right:"ArrowLeft",top:"ArrowDown",bottom:"ArrowUp"}[this.el.dataset.side],h=s.getAttribute("data-app-nav-id");if(t.key===c&&this._flyouts.has(String(h))){t.preventDefault(),this.openFlyout(String(h),{focus:!0});return}let u;if(t.key==="Home")u=0;else if(t.key==="End")u=e.length-1;else if(t.key===o)u=(n-1+e.length)%e.length;else if(t.key===l)u=(n+1)%e.length;else return;t.preventDefault(),e[u]?.focus()}_onFlyoutKeydown(t,e){let s=ja(e.panel),n=t.target?.closest?.("a, button"),r=s.indexOf(n);if(t.key==="Escape"){t.preventDefault(),t.stopPropagation();let u=[...this._flyouts.values()].find(d=>d.trigger===n&&d.dropdown.isOpen());if(u){this.closeFlyout(u.key),this._restoreFocus(u.trigger);return}this.closeFlyout(e.key),this._restoreFocus(e.trigger);return}let o=[...this._flyouts.values()].find(u=>u.trigger===n),l=this.el.dataset.side==="right"?"ArrowLeft":"ArrowRight",c=l==="ArrowRight"?"ArrowLeft":"ArrowRight";if(o&&t.key===l){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(s.length===0)return;let h;if(t.key==="Home")h=0;else if(t.key==="End")h=s.length-1;else if(t.key==="ArrowDown")h=(r+1+s.length)%s.length;else if(t.key==="ArrowUp")h=(r-1+s.length)%s.length;else return;t.preventDefault(),s[h]?.focus()}_scheduleOpen(t){let e=String(t);this._cancelTimer(this._closeTimers,e),this._cancelTimer(this._openTimers,e);let s=Math.max(0,Number(this.options.openDelay)||0);this._openTimers.set(e,setTimeout(()=>{this._openTimers.delete(e),this.openFlyout(t)},s))}_scheduleClose(t){let e=String(t);this._cancelTimer(this._openTimers,e),this._cancelTimer(this._closeTimers,e);let s=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))},s))}_scheduleFlyoutClose(t,e){let s=t;for(;s&&(this._scheduleClose(s.key),!(!e||s.parentKey===null));)s=this._flyouts.get(s.parentKey)??null}_resolveFlyout(t){let e=String(t);return this._flyouts.get(e)??[...this._flyouts.values()].find(s=>String(s.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 s=e.parentKey;for(;s!==null;){if(s===t.key)return!0;s=this._flyouts.get(s)?.parentKey??null}return!1}_cancelFlyoutTimers(t,e){let s=t;for(;s&&(this._cancelTimers(s.key),!(!e||s.parentKey===null));)s=this._flyouts.get(s.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 s=t.get(e);s!==void 0&&clearTimeout(s),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 s=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?Tn(n.item.children??[],t):!1;s?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&&Tn(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}},Cn=class extends _{constructor(t){super(null),t.append(this.el)}render(){return a("span",{hidden:!0,"data-zx-app-rail-listener-scope":""})}};function Ct(i){return Array.isArray(i)?i.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)?Ct(t.children):[]};if(t.href==null)return e;let s=bt(t.href);return s!==null?e.href=s:(delete e.href,e.children.length===0&&typeof e.invoke!="function"&&(e.disabled=!0)),e}):[]}function Zs(i,t,e){let s=typeof t=="function"?t(i,e):null;if(s==null&&(s=i.icon),typeof s=="function"&&(s=s(e,i)),typeof s=="string")return g(s);if(s instanceof Node)return s.cloneNode(!0);if(s&&typeof s=="object"&&typeof s.toElement=="function"){let n=s.toElement();return n instanceof Node?n.cloneNode(!0):null}return null}function Pa(i,{className:t,index:e,iconOnly:s,disclosure:n,disclosureIcon:r,visual:o}){let l=bt(i.href),c=l&&!n?"a":"button";return a(c,{class:t,type:c==="button"?"button":null,href:c==="a"?l:null,target:c==="a"?i.target??null:null,rel:c==="a"?"noopener":null,ariaLabel:s?i.label:null,ariaDisabled:i.disabled?"true":null,dataset:{appNavId:e,appNavValueId:String(i.id)}},o?a("span",{class:`${t}-icon`,ariaHidden:"true"},o):null,a("span",{class:`${t}-label`},i.label),i.badge!=null?a("span",{class:`${t}-badge`},String(i.badge)):null,n?a("span",{class:`${t}-disclosure`,ariaHidden:"true"},g(r)):null)}function Dd(i){return{left:"chevron-right",right:"chevron-left",top:"chevron-down",bottom:"chevron-up"}[i]??"chevron-right"}function Nd(i){return i==="right"?"chevron-left":"chevron-right"}function Md(i){return{left:"right-start",right:"left-start",top:"bottom-start",bottom:"top-start"}[i]??"right-start"}function Od(i){return i==="right"?"left-start":"right-start"}function Fd(i){return{left:"right",right:"left",top:"bottom",bottom:"top"}[i]??"right"}function ja(i){return[...i.querySelectorAll('a:not([aria-disabled="true"]), button:not([aria-disabled="true"])')]}function Ha(i){return ja(i)[0]??null}function Ld(i){return[...i.children].map(t=>t.querySelector("[data-app-nav-id]")).filter(Boolean)}function Tn(i,t){return i.some(e=>String(e.id)===t||Tn(e.children??[],t))}function Va(i,t){if(t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t=="object"&&typeof t.nodeType=="number"&&i.append(t)}var ei=class extends _{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??a("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=Ct(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=$a(this._orientation,this.options.side),this._modeAbort=null,t.replaceChildren(),t}setItems(t){return this._items=Ct(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 In(this._items,e=>{this._expanded.has(String(e.id))&&t.push(e.id)}),t}toggleBranch(t,{silent:e=!1}={}){let s=Pe(this._items,t);if(!s?.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:s,id:s.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 s=this.isCollapsed(),n=document.activeElement,r=!!(n&&(this.el.contains(n)||this._rail?._containsNode(n)));this._collapsed=!!t;let o=this.isCollapsed();return s!==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 s=t.orientation==="horizontal"?"horizontal":t.orientation==="vertical"?"vertical":this._orientation,n=$a(s,t.side??this._side);if(s===this._orientation&&n===this._side)return this;let r=this.isCollapsed(),o=document.activeElement,l=!!(o&&(this.el.contains(o)||this._rail?._containsNode(o))),c=l&&o instanceof Element?o.closest("[data-app-nav-id]")?.getAttribute("data-app-nav-id")??null:null;this._orientation=s,this._side=n,this._renderMode();let h=this.isCollapsed();if(l){let u=c===null?null:[...this.el.querySelectorAll("[data-app-nav-id]")].find(d=>d.getAttribute("data-app-nav-id")===c)??null;u instanceof HTMLElement?u.focus():h?this.focus():this.refs.collapse instanceof HTMLElement&&!this.refs.collapse.hidden?this.refs.collapse.focus():ti(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():ti(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,s]of t.attributes)this.el.setAttribute(e,s);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=a("div",{class:"zx-app-sidebar__header-content"});En(t,this.options.header);let e=a("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 s=a("footer",{class:"zx-app-sidebar__footer"});En(s,this.options.footer),s.hidden=!s.hasChildNodes();let n=a("ul",{class:"zx-app-sidebar__list"}),r=a("div",{class:"zx-app-sidebar__expanded"},a("header",{class:"zx-app-sidebar__header"},t,e),a("nav",{class:"zx-app-sidebar__nav",ariaLabel:this.options.label},n),s);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=a("nav",{class:"zx-app-sidebar__rail"});this.el.append(t),this.refs.rail=t;let e=this._orientation==="vertical"&&!!this.options.collapsible,s=a("div",{class:"zx-app-sidebar__rail-header"});if(e){let n=a("button",{class:"zx-app-sidebar__rail-toggle zx-icon-btn",type:"button",ariaLabel:"Expand application sidebar"},g(this._side==="right"?"chevron-left":"chevron-right"));s.append(n),this._railExpandButton=n,this._listenMode(n,"click",()=>this.expand())}En(s,this.options.railHeader),this._rail=new Xs(t,{items:this._items,active:this._active,orientation:this._orientation,side:this._side,label:this.options.label,header:s.hasChildNodes()?s: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,s){t.addEventListener(e,s,{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(s=>s.getAttribute("data-app-nav-id")===t)??null;qd(e)?.focus()}}_treeRow(t,e){let s=t.children??[],n=s.length>0,r=String(t.id),o=n&&this._expanded.has(r),l=n?y("zx-app-sidebar-branch"):null,c=Zs(t,this.options.renderIcon,{orientation:this._orientation,collapsed:!1,side:this._side,level:e,location:e===1?"root":"inline"}),h=Rd(t,n,o,l,c),u=a("li",{class:"zx-app-sidebar__row",dataset:{level:e}},h);return n&&u.append(a("ul",{class:"zx-app-sidebar__sublist",id:l,hidden:!o},s.map(d=>this._treeRow(d,e+1)))),u}_onTreeClick(t){let e=t.target?.closest?.("[data-app-nav-id]");if(!e||!this.refs.list.contains(e))return;let s=Pe(this._items,e.getAttribute("data-app-nav-id"));if(!s||s.disabled){t.preventDefault();return}s.children?.length?this.toggleBranch(s.id):this._select(s,t)}_onTreeKeydown(t){let e=t.target?.closest?.("[data-app-nav-id]");if(!(e instanceof HTMLElement))return;let s=Pe(this._items,e.getAttribute("data-app-nav-id")),n=ti(this.refs.list),r=n.indexOf(e);if(t.key==="ArrowRight"&&s?.children?.length){t.preventDefault(),this._expanded.has(String(s.id))?ti(e.parentElement?.querySelector(".zx-app-sidebar__sublist"))[0]?.focus():this.toggleBranch(s.id);return}if(t.key==="ArrowLeft"){if(s?.children?.length&&this._expanded.has(String(s.id))){t.preventDefault(),this.toggleBranch(s.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 s=Pe(this._items,e.getAttribute("data-app-nav-id")),n=t!==null&&e.getAttribute("data-app-nav-id")===t,r=t!==null&&s?Ka(s.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;In(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 Rd(i,t,e,s,n){let r=i.href&&!t?"a":"button";return a(r,{class:"zx-app-sidebar__item",type:r==="button"?"button":null,href:r==="a"?i.href:null,target:r==="a"?i.target??null:null,ariaDisabled:i.disabled?"true":null,ariaExpanded:t?String(e):null,ariaControls:s,dataset:{appNavId:String(i.id)}},n?a("span",{class:"zx-app-sidebar__item-icon",ariaHidden:"true"},n):null,a("span",{class:"zx-app-sidebar__item-label"},i.label),i.badge!=null?a("span",{class:"zx-app-sidebar__item-badge"},String(i.badge)):null,t?a("span",{class:"zx-app-sidebar__item-disclosure",ariaHidden:"true"},g(e?"chevron-down":"chevron-right")):null)}function ti(i){return i?[...i.querySelectorAll("[data-app-nav-id]")].filter(t=>!t.closest(".zx-app-sidebar__sublist[hidden]")):[]}function qd(i){let t=i;for(;t;){let e=t.closest(".zx-app-sidebar__sublist[hidden]");if(!e)return t;t=e.parentElement?.firstElementChild??null}return null}function Pe(i,t){for(let e of i){if(String(e.id)===String(t))return e;let s=Pe(e.children??[],t);if(s)return s}return null}function In(i,t){for(let e of i)t(e),In(e.children??[],t)}function Ka(i,t){return i.some(e=>String(e.id)===t||Ka(e.children??[],t))}function En(i,t){if(t!=null)if(typeof t=="string"||typeof t=="number")i.append(document.createTextNode(String(t)));else if(typeof t=="object"&&typeof t.toElement=="function"){let e=t.toElement();e&&i.append(e)}else typeof t=="object"&&typeof t.nodeType=="number"&&i.append(t)}function $a(i,t){return i==="horizontal"?t==="bottom"?"bottom":"top":t==="right"?"right":"left"}var Nn=class{#t;#e=[];#s=[];#i;constructor(t=5,e=()=>{}){if(!Number.isInteger(t)||t<1)throw new RangeError("Queue limit must be positive");if(typeof e!="function")throw new TypeError("Activation callback must be a function");this.#t=t,this.#i=e}enqueue(t){return this.#e.length<this.#t?(this.#e.push(t),this.#i(t),"active"):(this.#s.push(t),"pending")}remove(t){let e=this.#s.indexOf(t);if(e!==-1)return this.#s.splice(e,1),"pending";let s=this.#e.indexOf(t);if(s===-1)return null;if(this.#e.splice(s,1),this.#s.length>0){let n=this.#s.shift();this.#e.push(n),this.#i(n)}return"active"}isActive(t){return this.#e.includes(t)}clear(){let t={active:this.#e.slice(),pending:this.#s.slice()};return this.#e.length=0,this.#s.length=0,t}get activeCount(){return this.#e.length}get pendingCount(){return this.#s.length}},ii=class i extends _{static cssName="message";static defaults={kind:"info",timeout:4e3,closable:!0,maxVisible:5};static#t=null;render(){let t=!this.el,e=this.el??a("div");return this._createdRoot=t,this._original=t?null:Kd(e),this._entries=new Set,this._queue=new Nn(Hd(this.options.maxVisible),s=>{this._activate(s)}),e.replaceChildren(),e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e}show(t,e={}){let s={kind:Bd(e.kind??this.options.kind),timeout:Pd(e.timeout??this.options.timeout),closable:e.closable??!!this.options.closable},n=this._createEntry(t,s);return this._entries.add(n),this._queue.enqueue(n),{close:()=>this._close(n)}}static info(t,e={}){return this.show(t,{...e,kind:"info"})}static success(t,e={}){return this.show(t,{...e,kind:"success"})}static warning(t,e={}){return this.show(t,{...e,kind:"warning"})}static error(t,e={}){return this.show(t,{...e,kind:"error"})}static show(t,e={}){return this.#e().show(t,e)}static progress(t){return this.#e()._progress(t)}destroy(){if(!this._cleaned){this._cleaned=!0;for(let t of this._entries)Dn(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&Ud(this.el,this._original)}}_progress(t){let e={pct:0,text:String(t)},s=this._createEntry(e.text,{kind:"info",timeout:0,closable:!1},e);this._entries.add(s),this._queue.enqueue(s);let n=!1;return{update:(r,o)=>{n||s.closed||(e.pct=jd(r),o!==void 0&&(e.text=String(o)),si(s,e))},done:()=>{n||s.closed||(n=!0,e.pct=100,si(s,e),s.remaining=600,this._queue.isActive(s)&&this._schedule(s))},fail:r=>{n||s.closed||(n=!0,r!==void 0&&(e.text=String(r)),s.kind="error",s.node.dataset.kind="error",s.node.setAttribute("role","alert"),s.iconHost.replaceChildren(g("error",{size:18})),si(s,e),s.remaining=4e3,this._queue.isActive(s)&&this._schedule(s))}}}_createEntry(t,e,s=null){let n=a("span",{class:"zx-message__icon",ariaHidden:"true"},g(e.kind,{size:18})),r=a("div",{class:"zx-message__content"});Vd(t)?r.append(t):r.append(document.createTextNode(String(t)));let o=a("div",{class:"zx-message__toast",role:e.kind==="error"?"alert":"status",dataset:{kind:e.kind,state:"queued"}},n,r),l={node:o,content:r,iconHost:n,kind:e.kind,timeout:e.timeout,remaining:e.timeout,startedAt:0,timer:null,exitTimer:null,closed:!1,progressBar:null,progressFill:null};if(s){o.dataset.progress="";let c=a("span",{class:"zx-message__progress-fill"}),h=a("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:s.text},c);r.append(h),l.progressBar=h,l.progressFill=c,si(l,s)}if(e.closable){let c=a("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(l))}return this.listen(o,"mouseenter",()=>this._pause(l)),this.listen(o,"mouseleave",()=>this._resume(l)),l}_activate(t){t.closed||(t.node.dataset.state="open",this.el.append(t.node),this._schedule(t))}_schedule(t){t.closed||t.remaining<=0||(t.startedAt=Date.now(),t.timer=setTimeout(()=>this._close(t),t.remaining))}_pause(t){t.closed||t.timer===null||(clearTimeout(t.timer),t.timer=null,t.remaining=Math.max(0,t.remaining-(Date.now()-t.startedAt)))}_resume(t){if(!(t.closed||t.timer!==null)){if(t.remaining<=0){this._close(t);return}this._schedule(t)}}_close(t){if(t.closed)return;if(t.closed=!0,Dn(t),!this._queue.isActive(t)){this._queue.remove(t),t.node.remove(),this._entries.delete(t);return}if(t.node.dataset.state="closing",!$d()){this._finish(t);return}let e=s=>{s.target===t.node&&this._finish(t)};this.listen(t.node,"animationend",e,{once:!0}),t.exitTimer=setTimeout(()=>this._finish(t),260)}_finish(t){this._entries.has(t)&&(Dn(t),t.node.remove(),this._entries.delete(t),this._queue.remove(t))}static#e(){if(this.#t)return this.#t;let t=a("div",{class:"zx-message-region",popover:"manual",role:"status",ariaLive:"polite"});return document.body.append(t),this.#t=new i(t),typeof t.showPopover=="function"&&t.showPopover(),this.#t}};function Bd(i){return i==="danger"?"error":["success","warning","error"].includes(String(i))?i:"info"}function Pd(i){let t=Number(i);return Number.isFinite(t)?Math.max(0,t):4e3}function Hd(i){let t=Number(i);return Number.isInteger(t)&&t>0?t:5}function Vd(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function jd(i){let t=Number(i);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function si(i,t){i.content.firstChild.textContent=t.text,i.progressBar?.setAttribute("aria-valuenow",String(t.pct)),i.progressBar?.setAttribute("aria-label",t.text),i.progressFill&&(i.progressFill.style.inlineSize=`${t.pct}%`)}function Dn(i){i.timer!==null&&clearTimeout(i.timer),i.exitTimer!==null&&clearTimeout(i.exitTimer),i.timer=null,i.exitTimer=null}function $d(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function Kd(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Ud(i,t){for(let e of Array.from(i.attributes))i.removeAttribute(e.name);for(let[e,s]of t.attributes)i.setAttribute(e,s);i.replaceChildren(...t.children)}var Yd=new Set(["start","end","top","bottom"]),Wd=new Set(["dim","blur","none"]),Gd=Object.freeze({start:1,end:-1,top:1,bottom:-1}),ni=class extends ft{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;#s=0;constructor(t=null,e={}){super(null,e),this._dock=null,this._handoff=!1,this.setSide(this.options.side),this.el.dataset.backdrop=Wd.has(this.options.backdrop)?this.options.backdrop:"dim",this.el.dataset.modality=Xd(this.options.modal),this.refs.close.hidden=!this.options.closeButton,this.options.modal!==!0&&(this.listen(this.el,"keydown",s=>{let n=s;n.key!=="Escape"||!this.options.closable||this._dock||(n.preventDefault(),this.emit("cancel").defaultPrevented||this.close())}),this.options.lightDismiss&&this.listen(document,"pointerdown",s=>{let n=s.target;!this.isOpen()||this._dock||this.el.contains(n)||this.close()})),this.on("close",()=>this.#t?.deactivate()),this.#i()&&this.#r()}#i(){let t=this.options.handle,e=this.getSide(),s=t===!0||t==="auto"&&(e==="top"||e==="bottom");return!!this.options.resizable||Array.isArray(this.options.snap)||s}#r(){let t=this.getSide()==="top"||this.getSide()==="bottom",e=a("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=_e(e,{orientation:t?"vertical":"horizontal",disabled:()=>this.isDocked(),onStart:()=>{this.#s=this.getSize(),this.el.dataset.dragging="true"},onMove:s=>this.#n(s,!1),onEnd:(s,n)=>{delete this.el.dataset.dragging,n&&this.#n(s,!0)},onStep:(s,n)=>{this.#s=this.getSize(),this.#n(s*(n?64:16),!0)}})}#n(t,e){let s=this.#o(),{min:n,max:r}=this.#a(s),l=!!this.options.resizable||this.#l(s).length>0?r:Math.min(r,this.#s),c=F(this.#s+t*Gd[this.getSide()],0,l);if(!e){this._applySize(c),this.#c();return}if(this.options.closable&&c<n/2){this._applySize(this.#s),this.close();return}let h=this.#l(s),u=h.length>0?Jd(c,h):c;this._applySize(F(u,n,l)),this.#c(),this.emit("resize",{size:this.getSize(),ratio:s>0?this.getSize()/s:0})}snapTo(t){let e=this.#o(),s=this.#l(e);if(s.length===0)return this;let n=typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<s.length?s[t]:Ua(t,e);if(!Number.isFinite(n))return this;let{min:r,max:o}=this.#a(e);return this._applySize(F(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 s=this.msg(t);return s===t?e:s}#o(){return this.getSide()==="top"||this.getSide()==="bottom"?window.innerHeight:window.innerWidth}#a(t){let e=this.#l(t),s=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(s,Math.min(...e)):s;return{min:Math.min(r,n),max:n}}#l(t){let e=this.options.snap;return Array.isArray(e)?e.map(s=>Ua(s,t)).filter(s=>Number.isFinite(s)&&s>0).sort((s,n)=>s-n):[]}#c(){let t=this.refs.handle;if(!t)return;let e=this.#o(),{min:s,max:n}=this.#a(e);t.setAttribute("aria-valuenow",String(Math.round(this.getSize()))),t.setAttribute("aria-valuemin",String(Math.round(s))),t.setAttribute("aria-valuemax",String(Math.round(n)))}mountTarget(){return this._dock?.el??document.body}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._handoff=!0,this.el.close()),this.mountTarget().append(this.el),t&&(this.el.returnValue="",this._show(),this.el.dataset.state="open",this._dock?delete this.el.dataset.zxOverlayOrder:this.el.dataset.zxOverlayOrder=String(Qd()))}_isRealClose(){return this._handoff?(this._handoff=!1,!1):!0}open(){return this.isOpen()?this:(this.options.modal==="trap-focus"&&(this.#t??=hs(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=Yd.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=Zd(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){super._show();return}this.el.show()}destroy(){this.#t?.deactivate(),this.#t=null,this.#e?.destroy(),this.#e=null,this._dock?._forget(this),this._dock=null,super.destroy()}};function Qd(){let i=Array.from(document.querySelectorAll("[data-zx-overlay-order]"),t=>Number(t.getAttribute("data-zx-overlay-order"))||0);return Math.max(0,...i)+1}function Ua(i,t){return typeof i=="number"&&Number.isFinite(i)&&i>0&&i<=1?i*t:Z(i,t)}function Jd(i,t){let e=i,s=Number.POSITIVE_INFINITY;for(let n of t){let r=Math.abs(n-i);r<s&&(s=r,e=n)}return e}function Xd(i){return i===!0?"modal":i==="trap-focus"?"trap-focus":"none"}function Zd(i){return i==null||i===""?null:typeof i=="number"?Number.isFinite(i)?`${Math.max(0,i)}px`:null:String(i)}var ri=class i extends EventTarget{static defaults=Object.freeze({layout:"stack",offset:24,scale:.04,max:3});#t=[];#e=new WeakMap;#s=!1;constructor(t={}){super();let e={...i.defaults,...t&&typeof t=="object"?t:{}};for(let[s,n]of Object.entries(e))!/^on[a-z]/.test(s)||typeof n!="function"||(this.on(s.slice(2),n),delete e[s]);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 s=()=>this.#i(t);this.#e.set(t,s),t.on("close",s)}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.#s){this.#s=!0;for(let t of this.#t){let e=this.#e.get(t);e&&t.off("close",e),Ya(t)}this.#t=[]}}#i(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 s=this.#e.get(t);s&&t.off("close",s),this.#e.delete(t),Ya(t),this.#n(),this.#o("pop",{sheet:t})}#n(){let{layout:t,offset:e,scale:s,max:n}=this.options,r=t==="cascade",o=0;for(let l=0;l<this.#t.length;l+=1){let c=this.#t[this.#t.length-1-l],h=c.el;h.dataset.stack=r?"cascade":"stack",h.dataset.depth=String(l),h.style.setProperty("--zx-sheet-depth",String(l)),h.style.setProperty("--zx-sheet-stack-offset",`${Number(e)||0}px`),h.style.setProperty("--zx-sheet-stack-scale",String(Number(s)||0)),h.toggleAttribute("data-stack-hidden",l>=Math.max(1,Number(n)||1)),h.inert=!r&&l>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 Ya(i){let t=i.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 oi='[role="menuitem"]',ai=class extends _{static defaults={items:[],selector:null};#t;#e;#s;#i;#r;#n=[];#o=null;#a=null;#l=!1;constructor(t,e={}){let s=H(t);if(!s)throw new TypeError("ContextMenu target could not be resolved");super(null,e),this.#t=s,document.body.append(this.el),this.#e=new J(this.el,{openOn:"manual",placement:"bottom-start"}),this.#s=this.#e.getPanel(),this.#s.classList.add("zx-context-menu"),this.#s.setAttribute("role","menu"),Array.isArray(this.options.items)&&this.setItems(this.options.items),this.#i=ct(this.#s,oi),this.#r=Q(()=>this.#m(),n=>n.focus()),this.#e.on("close",()=>{this.#o=null;let n=this.#a;this.#a=null,n instanceof HTMLElement&&n.isConnected&&n.focus(),this.emit("close")}),this.listen(this.#t,"contextmenu",n=>this.#u(n)),this.listen(this.#t,"keydown",n=>this.#d(n)),this.listen(this.#s,"click",n=>{let r=n.target.closest?.(oi);r&&this.#s.contains(r)&&this.#f(r)}),this.listen(this.#s,"keydown",n=>this.#_(n))}render(){return a("span",{class:"zx-context-menu__anchor",ariaHidden:"true"})}setItems(t){return this.#n=Array.isArray(t)?t.slice():[],this.#s.replaceChildren(),this.#n.forEach((e,s)=>{if(e==="-"){this.#s.append(a("div",{class:"zx-context-menu__separator",role:"separator"}));return}let n=[];e.icon&&n.push(a("span",{class:"zx-context-menu__icon"},g(e.icon))),n.push(a("span",{class:"zx-context-menu__label"},String(e.label??""))),this.#s.append(a("button",{class:"zx-context-menu__item",type:"button",role:"menuitem",tabindex:"-1","data-menu-item":String(s),"data-danger":e.danger?"true":null,ariaDisabled:e.disabled?"true":null},n))}),this}openAt(t,e,s=null){return this.#c(s)?(this.#h(t,e,s),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.#i.destroy(),this.#e.destroy(),super.destroy())}#c(t){let e=this.options.items;if(typeof e=="function"){let s=e(t);if(!Array.isArray(s)||s.length===0)return!1;this.setItems(s)}return this.#n.length>0}#h(t,e,s){let n=this.el;n.style.left=`${t}px`,n.style.top=`${e}px`,this.#o=s,this.#a=document.activeElement,this.#e.open(),this.#i.focusFirst(),this.emit("open",{context:s})}#u(t){let e=t,s=this.#p(e.target);!s||!this.#c(s)||(t.preventDefault(),this.#h(e.clientX,e.clientY,s))}#d(t){let e=t;if(e.key!=="ContextMenu"&&!(e.key==="F10"&&e.shiftKey))return;let s=this.#p(e.target);if(!s||!this.#c(s))return;t.preventDefault();let n=s.getBoundingClientRect();this.#h(n.left,n.bottom,s)}#p(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 s=e.target.closest?.(oi);if(!s||!this.#s.contains(s))return;t.preventDefault(),this.#f(s);return}this.#r(e)}#f(t){let e=Number(t.getAttribute("data-menu-item")),s=this.#n[e];if(!s||s==="-"||s.disabled)return;let n=this.#o;this.emit("select",{value:s.value,item:s,context:n});try{s.onselect?.(s.value,s,this)}finally{this.close()}}#m(){return Array.from(this.#s.querySelectorAll(oi))}};var li=class i extends kt{static cssName="table";constructor(t=null,e={}){super(t,{editTrigger:"single",...e})}static BillingItems(t,e={}){let s=new i(t,tp(e));return s.el.dataset.preset="billing-items",s}};function tp(i={}){let{fields:t={},units:e=[],currencies:s=[],currency:n="EUR",locale:r,decimals:o=2,columnOverrides:l={},lineTotal:c=null,columns:h,oneditcommit:u,rowClass:d,...f}=i,p={...Qa,...t},m=typeof c=="function"?c:w=>{let x=Ga(w?.[p.quantity]),v=Ga(w?.[p.unitPrice]);return x!==null&&v!==null?x*v:null},b=Array.isArray(h)?h.map(w=>({...w})):Mn(p,{units:e,currencies:s,currency:n,locale:r,decimals:o,columnOverrides:l});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:b,rowClass(w){let x=He(w,p)?"":"zx-grid-billing__summary",v=typeof d=="function"?d(w):"";return[x,v].filter(Boolean).join(" ")},oneditcommit(w){let{row:x,changes:v}=w.detail;if(He(x,p)){let C={...x,...v},I=m(C,v);I!=null&&Number.isFinite(Number(I))&&(v[p.total]=Number(I))}u?.(w)}}}var Qa=Object.freeze({id:"id",parent:"parent",item:"item",kind:"kind",quantity:"quantity",unit:"unit",unitPrice:"unitPrice",currency:"currency",total:"total"});function He(i,t=Qa){let e=String(i?.[t.kind]??"line").toLowerCase();return!["group","subtotal","header","section"].includes(e)}function Mn(i,{units:t,currencies:e,currency:s,locale:n,decimals:r,columnOverrides:o}){let l=d=>f=>He(f,i)?d:!1,c=d=>String(d?.[i.currency]||s),h=d=>String(d?.[i.unit]??""),u={item:{id:i.item,label:"Item",width:"2fr",sortable:!0,editable:l("text")},quantity:{id:i.quantity,label:"Quantity",width:"1fr",type:"unit",locale:n,unit:h,editable:l("number"),editorProps:{min:0,step:.01}},unit:{id:i.unit,label:"Unit",width:".8fr",editable:l(Wa(t)?"select":"text"),options:t},unitPrice:{id:i.unitPrice,label:"Unit price",width:"1fr",type:"currency",locale:n,decimals:r,currency:c,editable:l("number"),editorProps:{min:0,step:.01}},currency:{id:i.currency,label:"Currency",width:".8fr",editable:l(Wa(e)?"select":"text"),options:e},total:{id:i.total,label:"Line total",width:"1fr",type:"currency",locale:n,decimals:r,currency:c}};return Object.entries(u).map(([d,f])=>({...f,...o?.[d]??{}}))}function Wa(i){return Array.isArray(i)?i.length>0:!!(i&&typeof i=="object"&&Object.keys(i).length)}function Ga(i){if(i==null||typeof i=="string"&&i.trim()==="")return null;let t=Number(i);return Number.isFinite(t)?t:null}var ci=class extends _{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??a("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=Xa(this.options.data),this._label=ep(this.options.label),this._chartOptions=ot(this.options.chartOptions),this._loading=!!this.options.loading,this._error=null,this._hasError=!1,this._handle=null,this._destroyed=!1;let e=y("zx-chart-description"),s=a("canvas",{ref:"canvas",class:"zx-chart__canvas",role:"img",ariaLabel:this._label,ariaDescribedby:e}),n=a("div",{ref:"viewport",class:"zx-chart__viewport"},s);n.style.setProperty("--zx-chart-aspect-ratio",String(this.options.aspectRatio));let r=a("p",{ref:"description",class:"zx-chart__description",id:e},this.options.description),o=a("div",{ref:"status",class:"zx-chart__status",role:"status",ariaLive:"polite"}),l=a("div",{ref:"summary",class:"zx-chart__summary",dataset:{summary:this.options.summary==="visible"?"visible":"hidden"}});return t.replaceChildren(n,r,o,l),this._renderSummary(),this._syncState(),this._observer=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.resize()):null,this._observer?.observe(n),t}setData(t){return this._data=Xa(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=ot(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,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_mountOrUpdate(t){if(this._syncState(),this._loading||this._hasError||ui(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(s){this.setError(s)}}_spec(){return{type:this._type,data:ot(this._data),options:{...np(this.el),...ot(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=ui(this._data),e=this._loading?"loading":this._hasError?"error":t?"empty":"ready";this.el.dataset.state=e,this.refs.viewport.hidden=e!=="ready";let s="";e==="loading"?s=String(this.options.loadingText):e==="error"?s=rp(this._error,this.options.errorText):e==="empty"&&(s=String(this.options.emptyText)),this.refs.status.textContent=s,this.refs.status.hidden=!s}_renderSummary(){this.refs.summary.replaceChildren(Fn(this._data,this._label))}};function ep(i){return String(i??"").trim()||"Chart"}var hi=class{constructor(t,e={}){let s=typeof t=="function"?t:t?.Chart;if(typeof s!="function")throw new TypeError("ChartJsAdapter requires an injected Chart.js constructor");this.engine=s,this.defaults=ot(e)}create(t,e){let s=this.engine,n=null,r="",o=!1,l=c=>{let h=null,u=Ja(c,this.defaults,()=>h);h=new s(t,u),n=h,r=c.type};return l(e),{get instance(){return n},update:c=>{if(o)return;if(c.type!==r){let u=n;n=null,u?.destroy?.(),l(c);return}let h=Ja(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 Ja(i,t,e){let s=ot(i.options),n={responsive:!0,maintainAspectRatio:!1,...ot(t),...s},r=n.onClick;return n.onClick=(o,l,c)=>{typeof r=="function"&&r(o,l,c);let h=e()??c,d=(Array.isArray(l)&&l.length?l:h?.getElementsAtEventForMode?.(o,"nearest",{intersect:!0},!0)??[])[0];if(!d)return;let f=i.data.datasets?.[d.datasetIndex]??null;i.onSelect({datasetIndex:d.datasetIndex,index:d.index,dataset:f,label:i.data.labels?.[d.index],value:f?.data?.[d.index],nativeEvent:o?.native??o??null})},{type:i.type,data:ot(i.data),options:n}}function ot(i){return On(i,new WeakMap)}function On(i,t){if(Array.isArray(i)){if(t.has(i))return t.get(i);let e=[];return t.set(i,e),e.push(...i.map(s=>On(s,t))),e}if(i&&typeof i=="object"&&Object.getPrototypeOf(i)===Object.prototype){if(t.has(i))return t.get(i);let e={};t.set(i,e);for(let[s,n]of Object.entries(i))e[s]=On(n,t);return e}return i}function Xa(i){return!i||typeof i!="object"?{labels:[],datasets:[]}:ot({...i,labels:Array.isArray(i.labels)?i.labels:[],datasets:Array.isArray(i.datasets)?i.datasets:[]})}function ui(i){return!Array.isArray(i?.datasets)||!i.datasets.some(t=>Array.isArray(t?.data)&&t.data.length>0)}function Fn(i,t="Chart data"){let e=sp(i);return a("table",{class:"zx-chart__table"},a("caption",{},t),a("thead",{},a("tr",{},a("th",{scope:"col"},"Label"),e.headers.map(n=>a("th",{scope:"col"},n)))),a("tbody",{},e.rows.map(n=>a("tr",{},a("th",{scope:"row"},n.label),n.values.map(r=>a("td",{},r))))))}function sp(i){let t=Array.isArray(i?.datasets)?i.datasets:[],e=Array.isArray(i?.labels)?i.labels:[],s=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:s},(n,r)=>({label:String(e[r]??r+1),values:t.map(o=>ip(o.data?.[r]))}))}}function ip(i){if(i==null)return"";if(typeof i=="object"){if("y"in i)return String(i.y??"");if("r"in i)return String(i.r??"");try{return JSON.stringify(i)}catch{return String(i)}}return String(i)}function np(i){if(typeof getComputedStyle!="function")return{};let t=getComputedStyle(i),e=t.getPropertyValue("--zx-color-text").trim(),s=t.getPropertyValue("--zx-color-border").trim();return{color:e||void 0,borderColor:s||void 0}}function rp(i,t){let e=i&&typeof i=="object"&&"message"in i?String(i.message):"";return e.trim()?e:String(t)}function di({valueKey:i="ID",labelKey:t="name",childrenKey:e="children"}={}){return{value:s=>typeof i=="function"?i(s):s?.[i],label:s=>String((typeof t=="function"?t(s):s?.[t])??""),children:s=>{let n=s?.[e];return Array.isArray(n)?n:null}}}function B(i,t){if(i?.hasChildren===!0)return!0;let e=t.children(i);return Array.isArray(e)&&e.length>0}function be(i,t,e,{level:s=1,parent:n=null}={}){i.forEach((r,o)=>{e(r,{level:s,parent:n,index:o,siblings:i});let l=t.children(r);l&&be(l,t,e,{level:s+1,parent:r})})}function Za(i,t,e){let s=null;return be(i,e,n=>{s===null&&Object.is(e.value(n),t)&&(s=n)}),s}function Ve(i,t,e){for(let s of i){if(Object.is(e.value(s),t))return[s];let n=e.children(s);if(!n)continue;let r=Ve(n,t,e);if(r.length>0)return[s,...r]}return[]}function tl(i,t){let e=[],s=t.children(i);return s&&be(s,t,n=>e.push(n)),e}function el(i,t,e){let s=[],n=(r,o,l)=>{r.forEach((c,h)=>{let u=t.value(c);if(s.push({node:c,id:u,level:o,parent:l,posinset:h+1,setsize:r.length}),!e.has(u))return;let d=t.children(c);d&&d.length>0&&n(d,o+1,c)})};return n(i,1,null),s}function Ln(i,t,e,s){let n=[];for(let r of i){let o=t.children(r)??[],l=Ln(o,t,e,s);(e(r)||l.length>0)&&n.push(l.length>0||o.length>0?{...r,[s]:l}:r)}return n}var pi=class extends _{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??a("div");this.el=t,this._readers=di(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=Rn(this.options.items);for(let s of je(this.options.expanded))this._expanded.add(s);for(let s of je(this.options.selected))this._selected.add(s);let[e]=this._selected;if(e!==void 0){this._focusId=e;for(let s of this.getPath(e).slice(0,-1))this._expanded.add(this._readers.value(s))}for(let s of je(this.options.checked))this._applyCheck(s,!0,{silent:!0});return this._handleTypeahead=Q(()=>this._rotatedRows().map(s=>this._readers.label(s.node)),(s,n)=>this._focusNodeId(this._rotatedRows()[n]?.id)),this.listen(t,"keydown",s=>this._onKeydown(s)),this.listen(t,"click",s=>this._onClick(s)),this.listen(t,"dblclick",s=>this._onDoubleClick(s)),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=Rn(t),this._renderRows(),this}getItems(){return this._items}getNode(t){return Za(this._items,t,this._readers)}getPath(t){return Ve(this._items,t,this._readers)}setFilter(t){if(this._filter=String(t??""),this._filter!=="")for(let e of this._visibleItems())be([e],this._readers,s=>this._expanded.add(this._readers.value(s)));return this._renderRows(),this}async expand(t){let e=this.getNode(t);if(!e||!B(e,this._readers))return this;let s=this._readers.children(e),n=!!this.options.load&&(!s||s.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 be(this._items,this._readers,t=>{B(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 s of e.slice(0,-1))this._expanded.add(this._readers.value(s));return this._renderRows(),this}select(t,{silent:e=!1,additive:s=!1}={}){if(this.options.selection===!1)return this;let n=this.getNode(t);return n?(this.options.selection==="multi"&&s?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 s=je(t);if(this._selected=new Set(this.options.selection==="multi"?s:s.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 s=this.getNode(e);return s!==null&&!B(s,this._readers)}):[...this._checked]}setChecked(t,{silent:e=!0}={}){this._checked.clear();for(let s of je(t))this._applyCheck(s,!0,{silent:!0});return this._syncRows(),e||this.emit("check",{ids:this.getChecked(),node:null}),this}check(t,e,{silent:s=!1}={}){let n=this._applyCheck(t,e,{silent:!0});return this._syncRows(),!s&&n&&this.emit("check",{ids:this.getChecked(),node:n}),this}focusNode(t){this.reveal(t);let e=this._rows.findIndex(s=>Object.is(s.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:Ln(this._items,this._readers,e=>this._readers.label(e).toLocaleLowerCase().includes(t),this._childrenKey)}_renderRows(){let t=this._visibleItems();if(this._rows=el(t,this._readers,this._expanded),this._rows.length===0){this.el.replaceChildren(a("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=B(t.node,this._readers),s=e&&this._expanded.has(t.id),n=a("div",{class:"zx-tree__row",role:"treeitem",id:y("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=a("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 l=a("input",{class:"zx-tree__checkbox",type:"checkbox",tabIndex:-1,ariaHidden:"true"});l.dataset.action="checkbox",n.append(l)}this.options.icons&&n.append(a("span",{class:"zx-tree__icon",ariaHidden:"true"},g(e?s?"folder-open":"folder":"file",{size:14})));let o=this.options.renderLabel?this.options.renderLabel(t.node):this._readers.label(t.node);return n.append(a("span",{class:"zx-tree__label"},o)),t.node.badge!=null&&n.append(a("span",{class:"zx-tree__badge"},String(t.node.badge))),n}_syncRows(){let t=this.el.querySelectorAll(".zx-tree__row"),e=this._rows.findIndex(s=>Object.is(s.id,this._focusId));e<0&&(e=0),t.forEach((s,n)=>{let r=this._rows[n];if(!r)return;let o=B(r.node,this._readers),l=o&&this._expanded.has(r.id);o?s.setAttribute("aria-expanded",String(l)):s.removeAttribute("aria-expanded"),this.options.selection!==!1&&s.setAttribute("aria-selected",String(this._selected.has(r.id))),s.toggleAttribute("data-branch",o),s.toggleAttribute("data-loading",this._loading.has(r.id)),s.tabIndex=n===e?0:-1;let c=s.querySelector(".zx-tree__checkbox");if(c){let u=this._checkState(this.getNode(r.id)??r.node);c.checked=u==="checked",c.indeterminate=u==="partial",s.setAttribute("aria-checked",u==="partial"?"mixed":String(c.checked))}let h=s.querySelector(".zx-tree__icon");h&&this.options.icons&&h.replaceChildren(g(o?l?"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 s=this._rowIndex(e);if(s<0)return;let n=this._rows[s];this._focusRow(s);let r=t.target.closest("[data-action]");if(r?.dataset.action==="twisty"){B(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 s=this._rows[this._rowIndex(e)];s&&(B(s.node,this._readers)?this.toggle(s.id).then(()=>this._focusNodeId(s.id)):this.emit("activate",{node:s.node,id:s.id}))}_onKeydown(t){let e=this._rows.findIndex(o=>Object.is(o.id,this._focusId));if(e<0||this._rows.length===0)return;let s=this._rows[e],n=B(s.node,this._readers),r=n&&this._expanded.has(s.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(s.id).then(()=>this._focusNodeId(s.id)):r&&this._focusRow(Math.min(this._rows.length-1,e+1));return;case"ArrowLeft":{t.preventDefault(),r?(this.collapse(s.id),this._focusNodeId(s.id)):s.parent&&this._focusNodeId(this._readers.value(s.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(s.id),this.emit("activate",{node:s.node,id:s.id});return;case" ":t.preventDefault(),this.options.checkboxes?this.check(s.id,this._checkState(this.getNode(s.id)??s.node)!=="checked"):this.options.selection!==!1&&this.select(s.id,{additive:this.options.selection==="multi"});return;case"*":t.preventDefault(),this._expandSiblings(s);return;default:this._handleTypeahead(t)}}_expandSiblings(t){let e=t.parent?this._readers.children(t.parent)??[]:this._visibleItems(),s=this._focusId;for(let n of e)B(n,this._readers)&&this._expanded.add(this._readers.value(n));this._renderRows(),this._focusNodeId(s)}async _ensureChildren(t,e){let s=this._readers.children(t);if(!this.options.load||s&&s.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:s}){let n=this.getNode(t);if(!n)return null;let r=[t,...tl(n,this._readers).map(o=>this._readers.value(o))];for(let o of r)e?this._checked.add(o):this._checked.delete(o);return s||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 s=e.map(n=>this._checkState(n));return s.every(n=>n==="checked")?"checked":s.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(s=>Object.is(s.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 s=this._rowElement(e.id);s?.focus(),s?.scrollIntoView({block:"nearest"})}_focusNodeId(t){if(t===void 0)return;let e=this._rows.findIndex(s=>Object.is(s.id,t));e>=0&&this._focusRow(e)}_message(t,e){let s=this.msg(t);return s===t?e:s}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function Rn(i){return Array.isArray(i)?i.map(t=>{if(t===null||typeof t!="object")return t;let e={...t};for(let[s,n]of Object.entries(e))Array.isArray(n)&&(e[s]=Rn(n));return e}):[]}function je(i){return Array.isArray(i)?i:[]}var fi=class extends _{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??a("div");return this.el=t,this._readers=di(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=Q(()=>this._columnNodes(this._activeColumn).map(e=>this._readers.label(e)),(e,s)=>this._selectAt(this._activeColumn,s,{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 s of this._path){let n=t.find(r=>Object.is(this._readers.value(r),s));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:s=!1}={}){let n=this._pathSequence+1;this._pathSequence=n;let r=Array.isArray(t)?t.slice():[],o=[],l=this._items;for(let c of r){let h=l.find(u=>Object.is(this._readers.value(u),c));if(!h||(o.push(c),!B(h,this._readers)))break;if(await this._ensureChildren(h),n!==this._pathSequence)return this;l=this._readers.children(h)??[]}return this._path=o,this._activeColumn=Math.max(0,o.length-1),this._render({focus:s}),e||this._emitChange(),this}async reveal(t,{silent:e=!1}={}){let s=Ve(this._items,t,this._readers);return s.length===0?this:this.setPath(s.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(),s=[{nodes:this._items,selectedId:this._path[0],owner:null}];e.forEach((l,c)=>{if(!B(l,this._readers))return;let h=this._readers.children(l)??[];s.push({nodes:h,selectedId:this._path[c+1],owner:l})}),this._columns=s,this._activeColumn=Math.min(this._activeColumn,s.length-1);let n=s.map((l,c)=>this._renderColumn(l,c)),r=e[e.length-1]??null;if(this.options.preview&&r&&!B(r,this._readers)){let l=this.options.preview(r);l&&n.push(a("div",{class:"zx-finder__preview"},l))}this.el.replaceChildren(...n),this._syncTabStop(),this.el.lastElementChild?.scrollIntoView({block:"nearest",inline:"nearest"}),t&&this.focus()}_renderColumn(t,e){let s=t.owner?this._readers.label(t.owner):String(this.options.rootLabel||this._message("finder.root","Root")),n=a("div",{class:"zx-finder__list",role:"listbox",ariaLabel:s,dataset:{column:String(e)}});if(t.nodes.length===0){let r=t.owner!==null&&this._loading.has(this._readers.value(t.owner));n.append(a("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),l=B(r,this._readers),c=t.selectedId!==void 0&&Object.is(o,t.selectedId),h=a("div",{class:"zx-finder__row",id:y("zx-finder-row"),role:"option",tabIndex:-1,ariaSelected:String(c)});this.options.icons&&h.append(a("span",{class:"zx-finder__icon",ariaHidden:"true"},g(l?"folder":"file",{size:14}))),h.append(a("span",{class:"zx-finder__label"},this.options.renderItem?this.options.renderItem(r):this._readers.label(r))),l&&h.append(a("span",{class:"zx-finder__chevron",ariaHidden:"true"},g("chevron-right",{size:11}))),h.toggleAttribute("data-branch",l),n.append(h)}return a("div",{class:"zx-finder__column"},n)}_syncTabStop(){let t=this.el.querySelectorAll(".zx-finder__row");t.forEach(s=>{s.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:s,index:n}=this._locate(e);s<0||this._selectAt(s,n,{focus:!0})}_onDoubleClick(t){let e=t.target.closest(".zx-finder__row");if(!e)return;let{column:s,index:n}=this._locate(e),r=this._columnNodes(s)[n];r&&(B(r,this._readers)?this._enter(s,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,s=this._columnNodes(e);if(s.length===0&&!["ArrowLeft"].includes(t.key))return;let n=Math.max(0,s.findIndex(r=>Object.is(this._readers.value(r),this._columns[e]?.selectedId)));switch(t.key){case"ArrowDown":t.preventDefault(),this._selectAt(e,Math.min(s.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,s.length-1,{focus:!0});return;case"ArrowRight":{t.preventDefault();let r=s[n];if(!r||!B(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=s[n];if(!r)return;B(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:s=!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(),s&&this.focus();return}this._path=[...this._path.slice(0,t),r],this._activeColumn=t,B(n,this._readers)&&await this._ensureChildren(n),this._render({focus:s}),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 s=this._readers.value(t),n=this._loading.get(s);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:s})}finally{this._loading.delete(s)}})();return this._loading.set(s,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 s=this.msg(t);return s===t?e:s}destroy(){this._pathSequence+=1;let t=this.el;super.destroy(),!this._createdRoot&&t&&S(t,this._snapshot)}};function sl(i){return String(i??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLocaleLowerCase()}function op(i,t){let e=sl(t).trim().split(/\s+/).filter(Boolean);if(e.length===0)return!0;let s=sl(i.flat(1/0).join(" "));return e.every(n=>s.includes(n))}function Bn(i){return i!=null&&!(typeof i=="string"&&i.trim()==="")}function il(i,t){if(typeof t.get=="function")return qn(t.get(i));let e=t.fields??t.field??t.id;return(Array.isArray(e)?e:[e]).flatMap(n=>qn(typeof n=="function"?n(i):n==null?void 0:i?.[n]))}function nl(i,t){let e=[],s=new Map;for(let n of i)for(let r of il(n,t)){let o=rl(r);o.value==null||o.value===""||s.has(o.value)||(s.set(o.value,!0),e.push(o))}return e}function Rt(i,t,e){return i.filter(s=>t.every(n=>{let r=e?.[n.id];if(!Bn(r))return!0;if(n.type==="custom")return typeof n.predicate!="function"||!!n.predicate(s,r);let o=il(s,n);return n.type==="text"?op(o,r):n.type==="select"?o.some(l=>ap(rl(l).value,r)):!0}))}function qn(i){return Array.isArray(i)?i.flat(1/0):[i]}function rl(i){if(i&&typeof i=="object"&&!(i instanceof Date)){if(Object.prototype.hasOwnProperty.call(i,"value"))return{value:i.value,label:String(i.label??i.value??"")};if(Object.prototype.hasOwnProperty.call(i,"field"))return{value:i.field,label:String(i.label??i.field??"")}}return{value:i,label:String(i??"")}}function ap(i,t){return Object.is(i,t)?!0:i==null||t==null?!1:String(i)===String(t)}var _i=class extends _{static cssName="data-filter";static defaults={filters:[],data:[],autoApply:!0,clearLabel:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??a("div");this._originalChildren=this.el?Array.from(this.el.childNodes):null,this._filters=Array.isArray(this.options.filters)?this.options.filters.map(s=>({...s})):[],this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._state={},this._entries=new Map,this._customOrigins=new Map,this._restored=!1;let e=new Set;for(let s of this._filters){if(Pn(s),e.has(s.id))throw new RangeError(`Duplicate filter id: ${s.id}`);e.add(s.id),s.type==="custom"&&!this._customOrigins.has(s.element)&&this._customOrigins.set(s.element,{parent:s.element.parentNode,nextSibling:s.element.nextSibling}),this._state[s.id]=s.type==="custom"?Hn(s.element):""}this._filtered=Rt(this._data,this._filters,this._state),this._controls=a("div",{class:"zx-data-filter__controls"}),this._badge=a("span",{class:"zx-data-filter__badge",ariaLive:"polite",hidden:!0},"0"),this._clearButton=a("button",{class:"zx-data-filter__clear",type:"button",hidden:!0},this.options.clearLabel==null?this.msg("dataFilter.clear"):String(this.options.clearLabel)),t.replaceChildren(this._controls,this._badge,this._clearButton),this.listen(this._clearButton,"click",()=>this.clear());for(let s of this._filters)this._appendFilter(s);return this._syncActiveState(),t}setData(t){hp(t),this._data=[...t];for(let e of this._filters){if(e.type!=="select")continue;let s=this._entries.get(e.id);s&&this._populateSelect(e,s)}return this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=Rt(this._data,this._filters,this._state),this}apply(){this._filtered=Rt(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=Rt(this._data,this._filters,this._state),this}addFilter(t){Pn(t);let e={...t};return this._filters.push(e),this._state[e.id]=e.type==="custom"?Hn(e.element):"",this._appendFilter(e),this._filtered=Rt(this._data,this._filters,this._state),this._syncActiveState(),this}destroy(){this._restored||(this._originalChildren&&this.el.replaceChildren(...this._originalChildren),up(this._customOrigins),this._restored=!0),super.destroy()}_appendFilter(t){if(Pn(t),this._entries.has(t.id))throw new RangeError(`Duplicate filter id: ${t.id}`);let e,s={element:null,options:[]};if(t.type==="select")e=a("select",{ariaLabel:t.label}),s.element=e,this._populateSelect(t,s),this.listen(e,"change",()=>{let r=Number(e.value)-1;this._state[t.id]=r>=0?s.options[r]?.value??"":"",this._controlChanged()});else if(t.type==="text")e=a("input",{type:"search",placeholder:t.placeholder??"",ariaLabel:t.label,autocomplete:"off"}),s.element=e,this.listen(e,"input",()=>{this._state[t.id]=e.value,this._controlChanged()});else{e=t.element,this._customOrigins.has(e)||this._customOrigins.set(e,{parent:e.parentNode,nextSibling:e.nextSibling}),s.element=e;let r=e.matches?.('input:not([type="checkbox"]):not([type="radio"]), textarea')?"input":"change";this.listen(e,r,()=>{this._state[t.id]=Hn(e),this._controlChanged()})}this._entries.set(t.id,s);let n=a("label",{class:"zx-data-filter__field"},a("span",{class:"zx-data-filter__label"},t.label),e);this._controls.append(n)}_populateSelect(t,e){let s=this._state[t.id];e.options=Array.isArray(t.options)?t.options.map(lp):nl(this._data,t);let n=a("option",{value:""},t.emptyLabel??this.msg("dataFilter.all")),r=document.createDocumentFragment();r.append(n),e.options.forEach((l,c)=>{r.append(a("option",{value:String(c+1)},l.label))}),e.element.replaceChildren(r);let o=e.options.findIndex(l=>ol(l.value,s));e.element.value=o>=0?String(o+1):"",o<0&&(this._state[t.id]="")}_controlChanged(){this._syncActiveState(),this.options.autoApply?this.apply():this._filtered=Rt(this._data,this._filters,this._state)}_syncControls(){for(let t of this._filters){let e=this._entries.get(t.id);if(!e)continue;let s=this._state[t.id];if(t.type==="select"){let n=e.options.findIndex(r=>ol(r.value,s));e.element.value=n>=0?String(n+1):"",n<0&&(this._state[t.id]="")}else cp(e.element,s)}}_syncActiveState(){let t=this._filters.reduce((e,s)=>e+Number(Bn(this._state[s.id])),0);this._badge.textContent=String(t),this._badge.hidden=t===0,this._clearButton.hidden=t===0}};function Pn(i){if(!i||typeof i!="object")throw new TypeError("Filter definition must be an object");if(!["select","text","custom"].includes(i.type))throw new TypeError(`Unknown filter type: ${i.type}`);if(typeof i.id!="string"||!i.id)throw new TypeError("Filter definition requires an id");if(i.type==="custom"){if(!i.element||i.element.nodeType!==1)throw new TypeError("Custom filter requires an Element");if(typeof i.predicate!="function")throw new TypeError("Custom filter requires a predicate")}}function lp(i){return i&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,"value")?{value:i.value,label:String(i.label??i.value??"")}:{value:i,label:String(i??"")}}function Hn(i){return"checked"in i&&["checkbox","radio"].includes(i.type)?i.checked:"value"in i?i.value:i.getAttribute("data-value")??""}function cp(i,t){"checked"in i&&["checkbox","radio"].includes(i.type)?i.checked=!!t:"value"in i?i.value=t==null?"":String(t):t==null||t===""?i.removeAttribute("data-value"):i.setAttribute("data-value",String(t))}function ol(i,t){return Object.is(i,t)?!0:i==null||t==null?!1:String(i)===String(t)}function hp(i){if(!Array.isArray(i))throw new TypeError("DataFilter data must be an array")}function up(i){let t=[...i];for(let e=t.length;t.length>0&&e>=0;e-=1){let s=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),s+=1}if(s===0)break}for(let[e,s]of t)s.parent?s.parent.append(e):e.remove()}var Ke=Object.freeze([N("contains","contains","single",["text"]),N("notContains","does not contain","single",["text"]),N("eq","is","single",["text","number","money","boolean","enum","status","priority","country","currency","unit","entity","date","datetime"]),N("neq","is not","single",["text","number","money","boolean","enum","status","priority","country","currency","unit","entity","date","datetime"]),N("startsWith","starts with","single",["text"]),N("endsWith","ends with","single",["text"]),N("lt","is less than","single",["number","money"]),N("lte","is at most","single",["number","money"]),N("gt","is greater than","single",["number","money"]),N("gte","is at least","single",["number","money"]),N("on","is on","single",["date","datetime"]),N("notOn","is not on","single",["date","datetime"]),N("before","is before","single",["date","datetime"]),N("onOrBefore","is on or before","single",["date","datetime"]),N("after","is after","single",["date","datetime"]),N("onOrAfter","is on or after","single",["date","datetime"]),N("between","is between","pair",["number","money","date","datetime"]),N("notBetween","is not between","pair",["number","money","date","datetime"]),N("withinLast","is within the last","pair",["date","datetime"]),N("withinNext","is within the next","pair",["date","datetime"]),N("anyOf","is any of","many",["enum","status","priority","country","currency","unit","entity"]),N("noneOf","is none of","many",["enum","status","priority","country","currency","unit","entity"]),N("containsAny","contains any","many",["tags"]),N("containsAll","contains all","many",["tags"]),N("containsNone","contains none","many",["tags"]),N("isEmpty","is empty","none",["text","number","money","date","datetime","boolean","enum","status","priority","country","currency","unit","entity","tags"]),N("isNotEmpty","is not empty","none",["text","number","money","date","datetime","boolean","enum","status","priority","country","currency","unit","entity","tags"])]);function bi(){return{version:1,root:{kind:"group",id:y("filter-root"),logic:"and",children:[]}}}function yi(i={}){return{kind:"condition",id:String(i.id||y("filter-condition")),field:String(i.field??""),operator:String(i.operator??""),value:jn(i.value??null)}}function jn(i){return gi(i)}function xi(i="and",t=[]){return{kind:"group",id:y("filter-group"),logic:i,children:t}}function qt(i,t={}){let e=al(t.maxDepth,3),s=al(t.maxConditions,50);if(!mi(i)||i.version!==1||!mi(i.root))throw new TypeError("Filter AST must have version 1 and a root group");let n=new Set,r=0,o=(c,h,u=!1)=>{if(!mi(c))throw new TypeError("Filter nodes must be plain objects");let d=String(c.id??"").trim();if(!d||n.has(d))throw new TypeError("Filter node IDs must be non-empty and unique");if(n.add(d),c.kind==="group"){if(h>e)throw new RangeError("Filter group depth exceeds maxDepth");if(c.logic!=="and"&&c.logic!=="or")throw new TypeError("Filter group logic must be and or or");if(!Array.isArray(c.children))throw new TypeError("Filter group children must be an array");return{kind:"group",id:d,logic:c.logic,children:c.children.map(f=>o(f,h+1,!1))}}if(u||c.kind!=="condition")throw new TypeError("Filter root must be a group");if(r+=1,r>s)throw new RangeError("Filter condition count exceeds maxConditions");return{kind:"condition",id:d,field:String(c.field??""),operator:String(c.operator??""),value:gi(c.value)}},l=o(i.root,0,!0);if(l.kind!=="group")throw new TypeError("Filter root must be a group");return{version:1,root:l}}function Ue(i){return qt(i,{maxDepth:1/0,maxConditions:1/0})}function ll(i){return JSON.stringify(Ue(i))}function vi(i,t,e=Ke){let s=[],n=new Map((Array.isArray(t)?t:[]).map(l=>[String(l.id),l])),r=new Map((Array.isArray(e)?e:[]).map(l=>[String(l.id),l])),o=(l,c=!1)=>{if(l.kind==="group"){!c&&l.children.length===0&&s.push($e(l.id,"empty-group","Nested groups need at least one condition")),l.children.forEach(d=>o(d));return}let h=n.get(l.field);h||s.push($e(l.id,"unknown-field",l.field?`Unavailable field: ${l.field}`:"Choose a field"));let u=r.get(l.operator);if(!u){s.push($e(l.id,"unknown-operator",l.operator?`Unavailable operator: ${l.operator}`:"Choose an operator"));return}h&&(!(Array.isArray(h.operators)&&h.operators.length?h.operators:e.filter(f=>f.types.includes(h.type)).map(f=>f.id)).includes(u.id)||!u.types.includes(h.type))&&s.push($e(l.id,"operator-type",`${u.label} is not available for ${h.label}`)),dp(u.arity,l.value)||s.push($e(l.id,"value",u.arity==="pair"?"Enter both values":u.arity==="many"?"Choose at least one value":u.arity==="none"?"This operator does not accept a value":"Enter a value"))};return o(i.root,!0),{valid:s.length===0,errors:s}}function N(i,t,e,s){return Object.freeze({id:i,label:t,arity:e,types:Object.freeze(s)})}function $e(i,t,e){return{nodeId:i,code:t,message:e}}function dp(i,t){return i==="none"?t===null:i==="pair"?Array.isArray(t)&&t.length===2&&t.every(Vn):i==="many"?Array.isArray(t)&&t.length>0&&t.every(Vn):Vn(t)}function Vn(i){return i!=null&&!(typeof i=="string"&&i.trim()==="")}function gi(i,t=new WeakSet){if(i===null||typeof i=="string"||typeof i=="boolean")return i;if(typeof i=="number"){if(!Number.isFinite(i))throw new TypeError("Filter values cannot contain non-finite numbers");return i}if(typeof i!="object"||i instanceof Date||typeof i.nodeType=="number")throw new TypeError("Filter values must be JSON-safe");if(t.has(i))throw new TypeError("Filter values cannot contain cycles");if(t.add(i),Array.isArray(i)){let s=i.map(n=>gi(n,t));return t.delete(i),s}if(!mi(i))throw new TypeError("Filter values must be plain JSON objects");let e={};for(let[s,n]of Object.entries(i))Object.defineProperty(e,s,{value:gi(n,t),enumerable:!0,configurable:!0,writable:!0});return t.delete(i),e}function mi(i){if(!i||typeof i!="object"||Array.isArray(i))return!1;let t=Object.getPrototypeOf(i);return t===Object.prototype||t===null}function al(i,t){if(i===1/0)return 1/0;let e=Number(i);return Number.isFinite(e)&&e>=0?Math.floor(e):t}var Ai=class extends _{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??a("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=fp(Ke,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?bi():qt(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 Ue(this._value)}setValue(t,{silent:e=!1}={}){let s=qt(t,this._limits());return this._abortAll(),this._value=s,this._render(),e||this._changed("set",this._value.root.id),this}addCondition(t=null,e={}){if(!this._canMutate()||pl(this._value.root)>=Number(this.options.maxConditions))return null;let s=$n(this._value.root,t??this._value.root.id);if(!s)return null;let n=this._fields[0],r=String(e.field??n?.id??""),o=this._field(r),l=yi({...e,field:r,operator:String(e.operator??this._defaultOperator(o)??"")});return s.children.push(l),this._render(),this._changed("add",l.id),this.focus(l.id),l.id}addGroup(t=null,e="and"){if(!this._canMutate()||!this.options.allowGroups)return null;let s=$n(this._value.root,t??this._value.root.id);if(!s||fl(this._value.root,s.id)>=Number(this.options.maxDepth))return null;let n=xi(e==="or"?"or":"and");return s.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 s=at(this._value.root,t);return s?(s.kind==="group"?(e.logic==="and"||e.logic==="or")&&(s.logic=e.logic):(Object.hasOwn(e,"field")&&(s.field=String(e.field??"")),Object.hasOwn(e,"operator")&&(s.operator=String(e.operator??"")),Object.hasOwn(e,"value")&&(s.value=ul(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=Kn(this._value.root,t);if(!e)return this;let s=e.children.findIndex(l=>l.id===t),n=e.children[s+1]?.id??e.children[s-1]?.id??e.id,r=dl(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,s){let n=at(this._value.root,t),r=$n(this._value.root,e),o=Kn(this._value.root,t);if(!this._canMutate()||t===this._value.root.id||!n||!r||!o||pp(n,e))return this;let l=o.children.findIndex(h=>h.id===t),c=o.children.splice(l,1)[0];r.children.splice(Math.max(0,Math.min(r.children.length,Number(s)||0)),0,c);try{qt(this._value,this._limits())}catch{return r.children.splice(r.children.indexOf(c),1),o.children.splice(l,0,c),this}return this._render(),this._changed("move",t),this}validate(){return vi(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="${Bt(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&&S(t,e)}_render(){this._destroyEditors(),this._renderVersion=(this._renderVersion??0)+1;let t=a("div",{ref:"status",class:"zx-filter__status",role:"status",ariaLive:"polite"}),e=this._renderGroup(this._value.root,0,!0),s=a("div",{class:"zx-filter__actions"},Tt("add",this._value.root.id,"plus","Add filter",{ref:"add",disabled:this._blocked()}),this.options.allowGroups?Tt("add-group",this._value.root.id,"folder","Add group",{disabled:this._blocked()}):null,Tt("clear","","x",String(this.options.clearLabel),{disabled:this._blocked()}),Tt("apply","","check",String(this.options.applyLabel),{class:"zx-button--primary",disabled:this._disabled}));this.el.replaceChildren(t,e,s),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="${Bt(r.nodeId)}"]`)?.setAttribute("data-invalid","")}_renderGroup(t,e,s){let n=a("ol",{class:"zx-filter__children"},t.children.map(c=>c.kind==="group"?this._renderGroup(c,e+1,!1):this._renderCondition(c))),r=a("select",{class:"zx-filter__logic",dataset:{filterLogic:"",nodeId:t.id},ariaLabel:s?"Root filter logic":"Group filter logic",disabled:this._blocked()},a("option",{value:"and",selected:t.logic==="and"},"Match all"),a("option",{value:"or",selected:t.logic==="or"},"Match any")),o=a("legend",{class:"zx-filter__legend"},r,a("span",{},s?"conditions":"in this group")),l=a("div",{class:"zx-filter__group-actions"},Tt("add",t.id,"plus","Add filter",{disabled:this._blocked()}),this.options.allowGroups&&e<Number(this.options.maxDepth)?Tt("add-group",t.id,"folder","Add subgroup",{disabled:this._blocked()}):null,s?null:Tt("remove",t.id,"trash","Remove group",{disabled:this._blocked()}));return a(s?"fieldset":"li",{class:"zx-filter__group",dataset:{nodeId:t.id,depth:String(e)}},s?o:a("fieldset",{},o,n,l),s?n:null,s?l:null)}_renderCondition(t){let e=this._field(t.field),s=this._operatorsFor(e),n=this._operator(t.operator),r=a("select",{class:"zx-filter__field",dataset:{filterField:"",nodeId:t.id},ariaLabel:"Filter field",disabled:this._blocked()},a("option",{value:"",selected:!t.field},"Choose a field\u2026"),this._fields.map(l=>a("option",{value:l.id,selected:l.id===t.field},l.label)),t.field&&!e?a("option",{value:t.field,selected:!0},`Unavailable: ${t.field}`):null),o=a("select",{class:"zx-filter__operator",dataset:{filterOperator:"",nodeId:t.id},ariaLabel:"Filter operator",disabled:this._blocked()},a("option",{value:"",selected:!t.operator},"Choose an operator\u2026"),s.map(l=>a("option",{value:l.id,selected:l.id===t.operator},l.label)),t.operator&&!s.some(l=>l.id===t.operator)?a("option",{value:t.operator,selected:!0},`Unavailable: ${t.operator}`):null);return a("li",{class:"zx-filter__condition",dataset:{nodeId:t.id}},r,o,this._renderValue(t,e,n),Tt("remove",t.id,"trash",`Remove ${e?.label??"filter"}`,{disabled:this._blocked()}))}_renderValue(t,e,s){let n=a("div",{class:"zx-filter__value"});if(!e||!s)return n;if(s.arity==="none")return a("div",{class:"zx-filter__value zx-filter__value--empty"},"No value");if(e.type==="custom"&&typeof e.editor=="function"){let l=this._renderVersion;return queueMicrotask(()=>{if(l!==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,ul(h))});c&&typeof c.destroy=="function"&&this._customEditors.push(c)}),n}let r=s.arity==="pair"?Array.isArray(t.value)?t.value:[null,null]:[t.value];if(s.arity==="many"){let l=cl(e,t,r[0],!0,this._blocked());return l?a("div",{class:"zx-filter__value"},l):a("div",{class:"zx-filter__value"},hl(e,t.id,Array.isArray(t.value)?t.value.join(", "):"",0,this._blocked(),!0))}let o=r.map((l,c)=>cl(e,t,l,!1,this._blocked(),c)??hl(e,t.id,l,c,this._blocked()));return a("div",{class:"zx-filter__value",dataset:{arity:s.arity}},o)}_handleChange(t){if(!this._canMutate())return;let e=t.target,s=e?.dataset.nodeId;if(!(!e||!s))if(e.dataset.filterField!==void 0){let n=at(this._value.root,s);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(s),this._render(),this._changed("update",s),this.focus(s)}else if(e.dataset.filterOperator!==void 0){let n=at(this._value.root,s);if(n?.kind!=="condition")return;n.operator=e.value,n.value=null,this._abort(s),this._render(),this._changed("update",s),queueMicrotask(()=>this.el.querySelector(`[data-node-id="${Bt(s)}"] [data-filter-value]`)?.focus())}else if(e.dataset.filterLogic!==void 0){let n=at(this._value.root,s);n?.kind==="group"&&(n.logic=e.value==="or"?"or":"and"),this._changed("update",s)}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 s=e.dataset.nodeId,n=at(this._value.root,s),r=n?.kind==="condition"?this._field(n.field):null;r?.loadChoices&&this._scheduleChoices(n.id,r,e.value)}_valueInput(t){let e=at(this._value.root,t.dataset.nodeId);if(e?.kind!=="condition")return;let s=this._operator(e.operator),n=this._field(e.field);if(!s||!n)return;let r;if(t instanceof HTMLSelectElement&&t.multiple)r=Array.from(t.selectedOptions,o=>wi(o.value,n.type));else if(s.arity==="many")r=t.value.split(",").map(o=>o.trim()).filter(Boolean).map(o=>wi(o,n.type));else if(s.arity==="pair"){let o=Array.isArray(e.value)?[...e.value]:[null,null];o[Number(t.dataset.valueIndex)||0]=wi(t.value,n.type),r=o}else r=wi(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 s=e.dataset.filterAction,n=e.dataset.nodeId||null;s==="add"?this.addCondition(n):s==="add-group"?this.addGroup(n):s==="remove"&&n?this.remove(n):s==="clear"?this.clear():s==="apply"&&this.apply()}_setNodeValue(t,e){let s=at(this._value.root,t);if(s?.kind!=="condition")return;s.value=e;let n=this.validate();this.el.dataset.valid=String(n.valid),this.el.querySelector(`[data-node-id="${Bt(t)}"]`)?.toggleAttribute("data-invalid",n.errors.some(o=>o.nodeId===t)),this._changed("update",t)}_changed(t,e){let s=this.validate(),n=this.getValue();this.emit("change",{value:n,valid:s.valid,errors:s.errors,reason:t,nodeId:e}),this.options.autoApply&&s.valid&&this.emit("apply",{value:n})}_scheduleChoices(t,e,s){if(this._abort(t),s.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:s});try{let o=await e.loadChoices({query:s,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="${Bt(t)}"] [data-filter-value]`)?.getAttribute("list"),h=c?this.el.querySelector(`#${Bt(c)}`):null;h&&h.replaceChildren(...(Array.isArray(o)?o:[]).map(u=>a("option",{value:u.value},u.label))),this.emit("loaded",{conditionId:t,fieldId:e.id,query:s,choices:o})}catch(o){n.signal.aborted||this.emit("error",{conditionId:t,fieldId:e.id,query:s,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 s=this.el.querySelector(`[data-node-id="${Bt(t)}"] [data-filter-value]`);e?s?.setAttribute("aria-busy","true"):s?.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(s=>e?e.includes(s.id):s.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 Tt(i,t,e,s,n={}){return a("button",{type:"button",class:["zx-button","zx-button--sm",n.class].filter(Boolean),...n,dataset:{filterAction:i,nodeId:t}},g(e,{size:13}),a("span",{},s))}function cl(i,t,e,s,n,r=0){let o=Array.isArray(i.choices)&&i.choices.length?i.choices:i.type==="boolean"?[{value:!0,label:"True"},{value:!1,label:"False"}]:null;if(!o)return null;let l=new Set(Array.isArray(e)?e.map(String):[String(e??"")]);return a("select",{dataset:{filterValue:"",nodeId:t.id,valueIndex:String(r)},ariaLabel:`${i.label} value`,multiple:s,disabled:n},s?null:a("option",{value:"",selected:!l.has(String(e))||e==null},"Choose\u2026"),o.map(c=>a("option",{value:c.value,selected:l.has(String(c.value))},c.label)))}function hl(i,t,e,s,n,r=!1){let o=r?"text":["number","money"].includes(i.type)?"number":i.type==="date"?"date":i.type==="datetime"?"datetime-local":"text",l=i.loadChoices?`zx-filter-choices-${t}-${s}`:null,c=a("input",{type:o,value:e??"",dataset:{filterValue:"",nodeId:t,valueIndex:String(s)},ariaLabel:`${i.label} value${s?` ${s+1}`:""}`,disabled:n,placeholder:r?"Comma-separated values":"",list:l});return a("span",{class:"zx-filter__value-control"},c,l?a("datalist",{id:l}):null)}function wi(i,t){if(i==="")return null;if(["number","money"].includes(t)){let e=Number(i);return Number.isFinite(e)?e:null}return t==="boolean"?i==="true":i}function ul(i){return jn(i===void 0?null:i)}function at(i,t){if(!i||i.id===t)return i??null;if(i.kind==="group")for(let e of i.children){let s=at(e,t);if(s)return s}return null}function $n(i,t){let e=at(i,t);return e?.kind==="group"?e:null}function Kn(i,t){if(i?.kind!=="group")return null;if(i.children.some(e=>e.id===t))return i;for(let e of i.children){let s=Kn(e,t);if(s)return s}return null}function dl(i,t){if(i.kind!=="group")return null;let e=i.children.findIndex(s=>s.id===t);if(e>=0)return i.children.splice(e,1)[0];for(let s of i.children){let n=dl(s,t);if(n)return n}return null}function pp(i,t){return!!(i&&at(i,t))}function pl(i){return i.kind==="condition"?1:i.children.reduce((t,e)=>t+pl(e),0)}function fl(i,t,e=0){if(i.id===t)return e;if(i.kind==="group"){for(let s of i.children)if(s.kind==="group"){let n=fl(s,t,e+1);if(n>=0)return n}}return-1}function fp(i,t){let e=new Map(i.map(s=>[s.id,{...s,types:[...s.types]}]));for(let s of Array.isArray(t)?t:[])s?.id&&e.set(String(s.id),{...s,id:String(s.id),types:Array.isArray(s.types)?[...s.types]:[]});return[...e.values()]}function Bt(i){return globalThis.CSS?.escape?CSS.escape(i):String(i).replaceAll(/[^a-zA-Z0-9_-]/g,"\\$&")}var Pt=class extends _{static cssName="fieldset";static defaults={title:"",columns:1,fields:{}};render(){let t=this.el??a("fieldset");this._fields=new Map,this._ownedFields=new Set,this._origins=new Map,this._fieldIdAttributes=new Map,this._ownedNodes=[],this._columnAttribute=t.getAttribute("data-columns");let e=[1,2,3].includes(Number(this.options.columns))?Number(this.options.columns):1;if(t.dataset.columns=String(e),this.options.title){let n=a("legend",{class:"zx-fieldset__legend"},String(this.options.title));this._ownedNodes.push(n),t.append(n)}this._grid=a("div",{class:"zx-fieldset__grid"}),this._ownedNodes.push(this._grid),t.append(this._grid);let s=this.options.fields&&typeof this.options.fields=="object"?this.options.fields:{};for(let[n,r]of Object.entries(s))this.addField(n,r);return t}addField(t,e){let s=String(t);if(this._fields.has(s))throw new Error(`Field "${s}" already exists`);let n,r=!1;if(e instanceof A)n=e;else if(D(e)||e instanceof _){let o=e;n=new A(null,{id:s,type:"custom",label:s,value:mp(o),disabled:gp(o),adapter:()=>_p(o)}),r=!0}else{let o=e&&typeof e=="object"?e:{};n=new A(null,{...o,id:o.id??s}),r=!0}return r?this._ownedFields.add(n):this._origins.set(n,{parent:n.el.parentNode,next:n.el.nextSibling}),this._fields.set(s,n),this._fieldIdAttributes.set(n,n.el.getAttribute("data-field-id")),n.el.dataset.fieldId=s,this._grid.append(n.el),n}getField(t){return this._fields.get(String(t))??null}hasField(t){return this._fields.has(String(t))}getFields(){return Object.fromEntries(this._fields)}getValues(){let t={};for(let[e,s]of this._fields)t[e]=s.getValue();return t}setValues(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[s,n]of Object.entries(t))this._fields.get(s)?.setValue(n,{silent:e});return this}getValue(t){return this._fields.get(String(t))?.getValue()??null}setValue(t,e){return this._fields.get(String(t))?.setValue(e),this}reset(){for(let t of this._fields.values())t.reset();return this}clear(){for(let t of[...this._fields.values()])this._releaseField(t);return this._fields.clear(),this}focus(t){return this._fields.get(String(t))?.focus(),this}setHighlights(t={},e="danger"){let s=0;for(let[n,r]of this._fields){let o=t?.[n];o?(r.setHighlight(String(o),e),s+=1):r.clearHighlight()}return s}clearHighlights(){for(let t of this._fields.values())t.clearHighlight();return this}_releaseField(t){let e=this._fieldIdAttributes.get(t);if(e==null?t.el.removeAttribute("data-field-id"):t.el.setAttribute("data-field-id",e),this._fieldIdAttributes.delete(t),this._ownedFields.has(t)){t.destroy(),this._ownedFields.delete(t);return}let s=this._origins.get(t);s?.parent?s.parent.insertBefore(t.el,s.next?.parentNode===s.parent?s.next:null):t.el.remove(),this._origins.delete(t)}destroy(){this.clear();for(let t of this._ownedNodes??[])t.remove();this._columnAttribute===null?this.el.removeAttribute("data-columns"):this.el.setAttribute("data-columns",this._columnAttribute),super.destroy()}};function _p(i){let t=D(i)?i:i.toElement(),e=t.parentNode,s=t.nextSibling,n=new Map(["id","aria-labelledby","aria-describedby","aria-disabled","aria-invalid"].map(l=>[l,t.getAttribute(l)])),r="disabled"in t?t.disabled:void 0,o="value"in t?t.value:void 0;return{el:t,get:()=>typeof i.getValue=="function"?i.getValue():typeof i.getValues=="function"?i.getValues():"value"in t?t.value:null,set:(l,c)=>{typeof i.setValue=="function"?i.setValue(l,c):typeof i.setValues=="function"&&l&&typeof l=="object"?i.setValues(l,c):"value"in t&&(t.value=l??"")},focus:()=>{typeof i.focus=="function"?i.focus():typeof t.focus=="function"&&t.focus()},setDisabled:l=>{typeof i.setDisabled=="function"?i.setDisabled(l):"disabled"in t?t.disabled=l:t.setAttribute("aria-disabled",String(l))},destroy:()=>{for(let[l,c]of n)c===null?t.removeAttribute(l):t.setAttribute(l,c);r!==void 0&&(t.disabled=r),o!==void 0&&(t.value=o),e?e.insertBefore(t,s?.parentNode===e?s:null):t.remove()}}}function mp(i){let t=D(i)?i:i.toElement();return typeof i.getValue=="function"?i.getValue():typeof i.getValues=="function"?i.getValues():"value"in t?t.value:null}function gp(i){let t=D(i)?i:i.toElement();return"disabled"in t?!!t.disabled:t.getAttribute("aria-disabled")==="true"}var Si=class extends _{static cssName="form";static defaults={fieldsets:[],actions:[],novalidate:!0,msg:{"form.required":"This field is required.","form.int":"Enter a whole number.","form.float":"Enter a valid number."}};render(){let t=this.el??a("form");this._fieldsets=[],this._ownedFieldsets=new Set,this._origins=new Map,this._ownedNodes=[],this._novalidateAttribute=t.getAttribute("novalidate"),t.toggleAttribute("novalidate",!!this.options.novalidate),this._body=a("div",{class:"zx-form__body"}),this._actions=a("div",{class:"zx-form__actions"}),this._ownedNodes.push(this._body,this._actions),t.append(this._body,this._actions),this.listen(t,"submit",s=>{s.preventDefault(),this.submit()}),this.listen(t,"reset",s=>{s.preventDefault(),this.reset()}),this.listen(this._actions,"click",s=>this._handleAction(s));let e=Array.isArray(this.options.fieldsets)?this.options.fieldsets:[];for(let s of e)this.addFieldset(s);return this.setActions(Array.isArray(this.options.actions)?this.options.actions:[]),t}addFieldset(t){let e=!(t instanceof Pt),s=e?new Pt(null,t??{}):t;return this._fieldsets.includes(s)||(e?this._ownedFieldsets.add(s):this._origins.set(s,{parent:s.el.parentNode,next:s.el.nextSibling}),this._fieldsets.push(s),this._body.append(s.el),this.listen(s.el,"zx-change",n=>{let r=n.target,o=r instanceof Element?r.dataset.fieldId:null;o&&this.emit("change",{id:o,value:s.getValue(o)})})),s}setActions(t){return this._actionDescriptors=Array.isArray(t)?t.map(e=>({...e})):[],this._actions.replaceChildren(...this._actionDescriptors.map((e,s)=>{let n=String(e.label??e.id??"Action");return a("button",{class:"zx-btn",type:["submit","reset"].includes(e.type)?e.type:"button",disabled:!!e.disabled,title:e.title,ariaLabel:!n&&e.title?e.title:void 0,dataset:{actionIndex:s,kind:["primary","danger","ghost"].includes(e.kind)?e.kind:"default",size:e.size==="sm"?"sm":"md"}},e.icon?g(e.icon,{size:16}):null,n?a("span",{class:"zx-btn__label"},n):null)})),this._actions.hidden=this._actionDescriptors.length===0,this}getValues(){return Object.assign({},...this._fieldsets.map(t=>t.getValues()))}setValues(t,{silent:e=!1}={}){for(let s of this._fieldsets)s.setValues(t,{silent:e});return this}getField(t){for(let e of this._fieldsets){let s=e.getField(t);if(s)return s}return null}setValue(t,e){return this.getField(t)?.setValue(e),this}getValue(t){return this.getField(t)?.getValue()??null}reset(){for(let t of this._fieldsets)t.reset().clearHighlights();return this}setHighlights(t,e="danger"){return this._fieldsets.reduce((s,n)=>s+n.setHighlights(t,e),0)}clearHighlights(){for(let t of this._fieldsets)t.clearHighlights();return this}submit(){let t={},e=null;for(let n of this._fieldsets)for(let[r,o]of Object.entries(n.getFields())){let l=o.getValue(),c="";if(o.options.required&&Un(l))c=this.msg("form.required");else if(!Un(l)&&o.options.type==="int"){let h=Li(l);h.valid?o.setValue(h.value,{silent:!0}):c=this.msg("form.int")}else if(!Un(l)&&o.options.type==="float"){let h=Ri(l);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 s=this._actionDescriptors[Number(e.dataset.actionIndex)],n=s?.onClick??s?.onclick??s?.handler;typeof n=="function"&&n(t,this)}destroy(){for(let t of this._fieldsets??[])if(this._ownedFieldsets.has(t))t.destroy();else{let e=this._origins.get(t);e?.parent?e.parent.insertBefore(t.el,e.next?.parentNode===e.parent?e.next:null):t.el.remove()}this._fieldsets=[];for(let t of this._ownedNodes??[])t.remove();this._novalidateAttribute===null?this.el.removeAttribute("novalidate"):this.el.setAttribute("novalidate",this._novalidateAttribute),super.destroy()}};function Un(i){return i==null||i===""||i===!1||Array.isArray(i)&&i.length===0}var ki="123456789abcdefghijklmnopqrstuvwxyz";function _l(i){if(!Array.isArray(i))throw new TypeError("Questionnaire items must be an array");let t=new Set;return i.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 s=e.name;if(t.has(s))throw new TypeError(`Item already exists: ${s}`);t.add(s);let n=bp(e.choices??[],s),r=e.field&&typeof e.field=="object"?{...e.field}:null,o=xp(e.input);if(n.length===0&&!r&&!o)throw new TypeError(`Item "${s}" needs choices, an input, or a field`);return{name:s,prompt:String(e.prompt??s),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 bp(i,t=""){if(!Array.isArray(i))throw new TypeError("Questionnaire choices must be an array");let e=new Set,s=i.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 l=typeof o.value=="number"?o.value:String(o.value),c=String(l);if(e.has(c))throw new TypeError(`Choice already exists in "${t}": ${c}`);return e.add(c),{value:l,label:String(o.label??l),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(s.map(o=>o.key).filter(Boolean)),r=0;for(let o of s)if(!o.key){for(;r<ki.length&&n.has(ki[r]);)r+=1;if(r>=ki.length)break;o.key=ki[r],n.add(o.key),r+=1}return s}function yp(i,t){if(typeof i.when!="function")return!0;try{return i.when(t)!==!1}catch{return!0}}function gt(i,t){let e={},s=[];for(let n of i)yp(n,e)&&(s.push(n),Object.prototype.hasOwnProperty.call(t,n.name)&&(e[n.name]=t[n.name]));return{answers:e,visible:s}}function zi(i,t,e){let{answers:s,visible:n}=gt(i,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(s[t.name],s);o=c==null||c===""?null:String(c)}let l=i.indexOf(t);if(o!==null){let c=i.findIndex(h=>h.name===o);if(c<0)throw new RangeError(`Unknown questionnaire item: ${o}`);if(r.has(o))return o;l=c}for(let c=l+1;c<i.length;c+=1)if(r.has(i[c].name))return i[c].name;return null}function Ht(i){return i==null?!0:typeof i=="string"?i.trim()==="":Array.isArray(i)?i.every(t=>Ht(t)):!1}function ml(i,t,e){return!i.required||!Ht(t)?null:e(i.choices.length>0?"questionnaire.required":"questionnaire.requiredInput")}function gl(i,t,e=null){let s=new Set(t.map(r=>String(r))),n=new Set(i.filter(r=>r.exclusive).map(r=>String(r.value)));return n.size>0&&e!==null&&s.has(String(e))&&(n.has(String(e))?s.forEach(r=>r!==String(e)&&s.delete(r)):n.forEach(r=>s.delete(r))),i.filter(r=>s.has(String(r.value))).map(r=>r.value)}function bl(i,t,e){let{answers:s,visible:n}=gt(i,t),r=new Map(n.map(p=>[p.name,p])),o=e.filter(p=>r.has(p)),l=o.length>0?r.get(o[o.length-1]):null,c=o.filter(p=>!Ht(s[p])).length,h=new Set(o),u=l?n.indexOf(l):-1,d=n.slice(u+1).filter(p=>!h.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:l?.section??""}}function xp(i){if(!i)return null;let t=typeof i=="object"&&!Array.isArray(i)?i:{};return{label:String(t.label??"Other"),placeholder:String(t.placeholder??""),multiline:!!t.multiline,maxLength:Math.max(0,Number(t.maxLength)||0)}}var vp=260,Ci=class extends _{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=y("zx-questionnaire");let t=this.el??a("form");if(this.el=t,this._form=t.localName==="form"?t:a("form",{class:"zx-questionnaire__form"}),this._form.setAttribute("novalidate",""),this._progressHost=a("div",{class:"zx-questionnaire__progress",hidden:!this.options.progress}),this._itemHost=a("fieldset",{class:"zx-questionnaire__item",tabIndex:-1}),this._reviewHost=a("div",{class:"zx-questionnaire__review",tabIndex:-1,hidden:!0}),this._actionsHost=a("div",{class:"zx-questionnaire__actions"}),this.refs.item=this._itemHost,this.refs.review=this._reviewHost,this.refs.actions=this._actionsHost,this._bar=new fe(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,a("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);gt(this._items,this._rawAnswers()).visible.some(n=>n.name===e)&&(this._path=[e])}return this._paint(),t}setItems(t){let e=this.getActive(),s=_l(t),n=new Set(s.map(l=>l.name));this._items=s;for(let l of[this._selected,this._freeform])for(let c of[...l.keys()])n.has(c)||l.delete(c);for(let[l,c]of[...this._fields])n.has(l)||(c.destroy(),this._fields.delete(l));let r=gt(s,this._rawAnswers()).visible,o=this._path.filter(l=>r.some(c=>c.name===l));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(!gt(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?zi(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=zi(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 gt(this._items,this._rawAnswers()).answers}getAnswer(t){let e=this._items.find(s=>s.name===t);return e?this._answerOf(e):null}setAnswers(t,{silent:e=!1}={}){if(!t||typeof t!="object")return this;for(let[s,n]of Object.entries(t))this._items.some(r=>r.name===s)&&this.setAnswer(s,n,{silent:!0});if(this._paint(),!e){let s=this.getAnswers();for(let n of Object.keys(t))n in s&&this.emit("change",{name:n,value:s[n],answers:s})}return this}setAnswer(t,e,{silent:s=!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))),l=n.choices.filter(c=>o.has(String(c.value)));for(let c of l)o.delete(String(c.value));this._selected.set(t,l.map(c=>c.value)),this._freeform.set(t,n.input?[...o][0]??"":"")}return this._paint(),s||this._emitChange(n),this}getActive(){return this._status!=="asking"?null:this._path[this._path.length-1]??null}getPath(){return[...this._path]}getProgress(){return bl(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,s]of Object.entries(this.getAnswers()))if(Array.isArray(s))for(let n of s)t.append(e,String(n));else s instanceof File||s instanceof Blob?t.append(e,s):t.append(e,s==null?"":String(s));return t}reset(){this._selected.clear(),this._freeform.clear();for(let[e,s]of this._fields){let n=this._items.find(r=>r.name===e);s.setValue(n?.field?.value??null,{silent:!0})}let t=gt(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 s=this._answerOf(e);Ht(s)||(t[e.name]=s)}return t}_answerOf(t){if(t.field)return this._fields.get(t.name)?.getValue()??null;let e=this._selected.get(t.name)??[],s=(this._freeform.get(t.name)??"").trim();return t.multiple?s?[...e,s]:[...e]:s||(e.length>0?e[0]:null)}_field(t){let e=this._fields.get(t.name);if(e)return e;let s=t.field??{};return e=new A(null,{...s,label:s.label??t.prompt,required:t.required}),e.el.classList.add("zx-questionnaire__field"),s.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 s=this.getActive();if(s===t&&this._status==="asking"||this.emit("navigate",{from:s,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),s=ml(t,e,n=>this.msg(n));if(!s&&typeof t.validate=="function"){this._setBusy(!0);try{s=await t.validate(e,this.getAnswers())}catch(n){s=n instanceof Error?n.message:String(n)}finally{this._destroyed||this._setBusy(!1)}}return this._destroyed?!1:(this._error=s?String(s):"",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(a("p",{class:"zx-questionnaire__prompt"},this.msg("questionnaire.empty")));return}let e=`${this._uid}-prompt`,s=`${this._uid}-description`,n=`${this._uid}-error`,r=[a("legend",{class:"zx-questionnaire__prompt",id:e},t.prompt)];t.description&&r.push(a("p",{class:"zx-questionnaire__description",id:s},t.description)),r.push(t.field?this._field(t).el:this._choices(t)),r.push(a("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?s:"",n].filter(Boolean).join(" ")),this._paintError(t)}_choices(t){let e=new Set((this._selected.get(t.name)??[]).map(n=>String(n))),s=a("div",{class:"zx-questionnaire__choices"});if(s.append(...t.choices.map((n,r)=>a("label",{class:"zx-questionnaire__choice",dataset:{disabled:n.disabled?"true":null}},a("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}}),a("span",{class:"zx-questionnaire__marker",ariaHidden:"true"}),n.icon?g(n.icon,{size:16}):null,a("span",{class:"zx-questionnaire__text"},a("span",{class:"zx-questionnaire__label"},n.label),n.description?a("span",{class:"zx-questionnaire__hint"},n.description):null),n.key?a("kbd",{class:"zx-questionnaire__key",ariaHidden:"true"},n.key):null))),t.input){let n=`${this._uid}-freeform`,r=this._freeform.get(t.name)??"",o=a(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});s.append(a("div",{class:"zx-questionnaire__freeform"},a("label",{class:"zx-questionnaire__freeform-label",htmlFor:n},t.input.label),o))}return s}_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 s=t?.field?this._fields.get(t.name):null;s&&(this._error?s.setHighlight(this._error,"danger"):s.clearHighlight(),e instanceof HTMLElement&&(e.hidden=!0))}_paintReview(){let{answers:t,visible:e}=gt(this._items,this._rawAnswers()),s=this._path.map(n=>e.find(r=>r.name===n)).filter(n=>!!n).map(n=>a("div",{class:"zx-questionnaire__answer"},a("dt",{class:"zx-questionnaire__answer-prompt"},n.prompt),a("dd",{class:"zx-questionnaire__answer-value",dataset:{empty:Ht(t[n.name])?"true":null}},this._formatAnswer(n,t[n.name])),P({label:this.msg("questionnaire.edit"),kind:"ghost",size:"sm"})));for(let[n,r]of s.entries()){let o=r.querySelector("button");o instanceof HTMLElement&&(o.dataset.edit=this._path[n])}this._reviewHost.replaceChildren(a("p",{class:"zx-questionnaire__review-title"},this.msg("questionnaire.reviewTitle")),a("dl",{class:"zx-questionnaire__answers"},...s))}_formatAnswer(t,e){if(Ht(e))return this.msg("questionnaire.noAnswer");let s=new Map(t.choices.map(r=>[String(r.value),r.label]));return(Array.isArray(e)?e:[e]).map(r=>s.get(String(r))??String(r)).join(", ")}_paintActions(){let t=this._activeItem(),e=this._status==="review",s=this._status==="complete",n=!1;try{n=!!t&&zi(this._items,t,this._rawAnswers())!==null}catch{n=!1}this._back.hidden=s||!e&&(!this.options.allowBack||this._path.length<=1),this._back.disabled=this._busy,this._skip.hidden=e||s||!t?.skippable,this._skip.disabled=this._busy,this._forward.hidden=s,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}),a("span",{class:"zx-btn__label"},this.msg(`questionnaire.${r}`)))}}_action(t,e,s,n){let r=P({label:e,icon:s,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 s=this._activeItem();if(!s)return;let n=s.choices[Number(e.dataset.index)];if(n){if(s.multiple){let r=[...this._itemHost.querySelectorAll(".zx-questionnaire__control")].filter(c=>c.checked).map(c=>s.choices[Number(c.dataset.index)].value),o=gl(s.choices,r,e.checked?n.value:null);this._selected.set(s.name,o);let l=new Set(o.map(c=>String(c)));for(let c of this._itemHost.querySelectorAll(".zx-questionnaire__control"))c.checked=l.has(c.value)}else{this._selected.set(s.name,[n.value]),this._freeform.set(s.name,"");let r=this._itemHost.querySelector(".zx-questionnaire__freeform-input");(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value="")}this._error="",this._paintError(s),this._paintProgress(),this._paintActions(),this._emitChange(s),this._maybeAutoAdvance(s)}}_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,s=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||s||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 l=this._itemHost.querySelector(`.zx-questionnaire__control[data-index="${o}"]`);l instanceof HTMLInputElement&&(t.preventDefault(),l.checked=n.multiple?!l.checked:!0,l.focus(),l.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()},vp))}_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 s=this._itemHost.querySelector(".zx-questionnaire__control:not(:disabled), .zx-questionnaire__freeform-input");s instanceof HTMLElement?s.focus():this._focusItem()}};function yl(){yo(),kr(),eo(),jr(),Xr(),ko(),To(),ao(),io(),zo(),co(),ho(),wo(),xo()}yl();return kl(wp);})();