@zeyos/zx 5.0.0 → 5.2.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 (154) hide show
  1. package/CHANGELOG.md +164 -0
  2. package/README.md +2 -1
  3. package/dist/types/components/account-menu/account-menu.d.ts +8 -0
  4. package/dist/types/components/activity-list/activity-list.d.ts +9 -1
  5. package/dist/types/components/app-icon/app-icon.d.ts +14 -2
  6. package/dist/types/components/app-sidebar/app-sidebar.d.ts +288 -14
  7. package/dist/types/components/calendar/calendar.d.ts +67 -5
  8. package/dist/types/components/card-view/card-view.d.ts +7 -4
  9. package/dist/types/components/card-view/record-card.d.ts +11 -0
  10. package/dist/types/components/context-menu/context-menu.d.ts +6 -2
  11. package/dist/types/components/data-filter/data-filter.d.ts +4 -4
  12. package/dist/types/components/dropdown/dropdown.d.ts +22 -7
  13. package/dist/types/components/field/field.d.ts +30 -0
  14. package/dist/types/components/fieldset/external-adapter.d.ts +83 -0
  15. package/dist/types/components/fieldset/fieldset.d.ts +7 -0
  16. package/dist/types/components/file-list/file-list.d.ts +35 -3
  17. package/dist/types/components/filter/filter.d.ts +127 -3
  18. package/dist/types/components/filter-panel/filter-panel.d.ts +36 -7
  19. package/dist/types/components/launcher/launcher.d.ts +8 -0
  20. package/dist/types/components/list-toolbar/list-toolbar.d.ts +15 -6
  21. package/dist/types/components/menu-button/menu-button.d.ts +6 -0
  22. package/dist/types/components/message/message.d.ts +14 -1
  23. package/dist/types/components/modal/modal.d.ts +30 -0
  24. package/dist/types/components/module-bar/module-bar.d.ts +395 -0
  25. package/dist/types/components/pagination/pagination.d.ts +17 -3
  26. package/dist/types/components/select/select.d.ts +6 -0
  27. package/dist/types/components/sheet/sheet.d.ts +15 -0
  28. package/dist/types/components/table/table.d.ts +265 -17
  29. package/dist/types/components/view/record-view.d.ts +59 -2
  30. package/dist/types/components/view-settings/view-settings.d.ts +879 -0
  31. package/dist/types/components/workspace-switcher/workspace-switcher.d.ts +327 -0
  32. package/dist/types/core/component.d.ts +12 -2
  33. package/dist/types/core/i18n.d.ts +27 -3
  34. package/dist/types/core/keyboard.d.ts +98 -1
  35. package/dist/types/core/messages.d.ts +382 -0
  36. package/dist/types/core/overlay-host.d.ts +28 -1
  37. package/dist/types/core/overlay-stack.d.ts +260 -0
  38. package/dist/types/index.d.ts +5 -2
  39. package/dist/types/internal/app-rail.d.ts +38 -0
  40. package/dist/types/internal/menu-items.d.ts +71 -3
  41. package/dist/types/zeyos/index.d.ts +1 -0
  42. package/dist/types/zeyos/launcher.d.ts +9 -0
  43. package/dist/types/zeyos/module-bar.d.ts +176 -0
  44. package/dist/types/zeyos/query.d.ts +31 -5
  45. package/dist/types/zeyos/table.d.ts +245 -8
  46. package/dist/types/zeyos/view.d.ts +16 -2
  47. package/dist/zx-zeyos.esm.js +4422 -430
  48. package/dist/zx-zeyos.esm.min.js +5 -5
  49. package/dist/zx.css +1417 -134
  50. package/dist/zx.esm.js +6986 -830
  51. package/dist/zx.esm.min.js +8 -8
  52. package/dist/zx.global.js +6986 -830
  53. package/dist/zx.global.min.js +8 -8
  54. package/dist/zx.min.css +1 -1
  55. package/docs/api.json +794 -17
  56. package/docs/llms.md +503 -63
  57. package/docs/llms.txt +6 -2
  58. package/package.json +1 -1
  59. package/src/components/account-menu/account-menu.js +12 -0
  60. package/src/components/activity-list/activity-list.js +27 -1
  61. package/src/components/app-icon/app-icon.css +13 -2
  62. package/src/components/app-icon/app-icon.js +11 -1
  63. package/src/components/app-rail/app-rail.css +19 -0
  64. package/src/components/app-sidebar/app-sidebar.css +204 -3
  65. package/src/components/app-sidebar/app-sidebar.js +646 -40
  66. package/src/components/breadcrumb/breadcrumb.css +1 -1
  67. package/src/components/calendar/calendar.css +1 -1
  68. package/src/components/calendar/calendar.js +26 -52
  69. package/src/components/card/card.css +2 -2
  70. package/src/components/card-view/card-view.css +5 -5
  71. package/src/components/card-view/card-view.js +13 -9
  72. package/src/components/card-view/record-card.js +14 -3
  73. package/src/components/code-editor/code-editor.css +1 -1
  74. package/src/components/code-editor/field-adapter.js +9 -2
  75. package/src/components/context-menu/context-menu.js +8 -2
  76. package/src/components/copy/copy-input.css +1 -1
  77. package/src/components/data-filter/data-filter.js +2 -2
  78. package/src/components/date-picker/time-picker.css +2 -2
  79. package/src/components/dock/dock.css +5 -4
  80. package/src/components/dropdown/dropdown.js +157 -72
  81. package/src/components/field/field.js +33 -3
  82. package/src/components/fieldset/external-adapter.js +363 -0
  83. package/src/components/fieldset/fieldset.js +10 -59
  84. package/src/components/file-list/file-list.js +144 -21
  85. package/src/components/filter/filter.css +86 -2
  86. package/src/components/filter/filter.js +300 -8
  87. package/src/components/filter-panel/filter-panel.js +149 -32
  88. package/src/components/finder/finder.css +1 -1
  89. package/src/components/kanban-view/kanban-view.css +3 -3
  90. package/src/components/kanban-view/kanban-view.js +5 -2
  91. package/src/components/launcher/launcher.css +1 -1
  92. package/src/components/launcher/launcher.js +29 -3
  93. package/src/components/list-toolbar/list-toolbar.js +39 -13
  94. package/src/components/master-panel/master-panel.js +0 -1
  95. package/src/components/menu-button/menu-button.css +63 -0
  96. package/src/components/menu-button/menu-button.js +97 -11
  97. package/src/components/message/message.js +60 -20
  98. package/src/components/modal/modal.css +1 -1
  99. package/src/components/modal/modal.js +66 -13
  100. package/src/components/module-bar/module-bar.css +486 -0
  101. package/src/components/module-bar/module-bar.js +1074 -0
  102. package/src/components/multi-value-editor/multi-value-editor.css +1 -1
  103. package/src/components/number-field/field-adapter.js +2 -1
  104. package/src/components/pagination/pagination.css +5 -5
  105. package/src/components/pagination/pagination.js +20 -4
  106. package/src/components/panel/panel.css +3 -2
  107. package/src/components/questionnaire/questionnaire.css +4 -4
  108. package/src/components/rating/field-adapter.js +2 -1
  109. package/src/components/rating/rating.css +1 -1
  110. package/src/components/search/search.css +4 -1
  111. package/src/components/select/select.js +9 -0
  112. package/src/components/sheet/sheet.css +1 -1
  113. package/src/components/sheet/sheet.js +74 -32
  114. package/src/components/slider/field-adapter.js +6 -1
  115. package/src/components/slider/slider.css +2 -2
  116. package/src/components/split-view/split-view.css +1 -1
  117. package/src/components/stat-tile/stat-tile.css +1 -1
  118. package/src/components/stepper/stepper.css +1 -1
  119. package/src/components/tabbox/tabbox.css +9 -5
  120. package/src/components/table/table.css +86 -11
  121. package/src/components/table/table.js +628 -57
  122. package/src/components/tag-picker/field-adapter.js +2 -1
  123. package/src/components/tooltip/tooltip.js +35 -17
  124. package/src/components/tree/tree.css +1 -1
  125. package/src/components/view/record-view.css +1 -1
  126. package/src/components/view/record-view.js +178 -18
  127. package/src/components/view-settings/view-settings.css +285 -0
  128. package/src/components/view-settings/view-settings.js +1830 -0
  129. package/src/components/workspace-switcher/workspace-switcher.css +188 -0
  130. package/src/components/workspace-switcher/workspace-switcher.js +463 -0
  131. package/src/core/component.js +88 -17
  132. package/src/core/fontawesome.js +5 -1
  133. package/src/core/i18n.js +47 -4
  134. package/src/core/icons.js +12 -2
  135. package/src/core/keyboard.js +206 -11
  136. package/src/core/messages.js +427 -0
  137. package/src/core/overlay-host.js +64 -9
  138. package/src/core/overlay-stack.js +487 -0
  139. package/src/core/position.js +22 -3
  140. package/src/index.js +5 -2
  141. package/src/internal/app-rail.js +134 -53
  142. package/src/internal/menu-items.js +61 -3
  143. package/src/zeyos/form.js +5 -3
  144. package/src/zeyos/index.js +3 -0
  145. package/src/zeyos/launcher.js +8 -3
  146. package/src/zeyos/module-bar.js +181 -0
  147. package/src/zeyos/query.js +44 -13
  148. package/src/zeyos/table.js +220 -80
  149. package/src/zeyos/view.js +43 -93
  150. package/styles/base.css +16 -1
  151. package/styles/print.css +1 -1
  152. package/styles/tokens/dark.css +4 -0
  153. package/styles/tokens/semantic.css +56 -28
  154. package/styles/zx.css +3 -0
@@ -1,11 +1,11 @@
1
- function st(i){if(i==null)return null;if(!(i instanceof Date))throw new TypeError("Expected a Date");let t=i.getTime();if(!Number.isFinite(t))throw new RangeError("Invalid Date");return Math.floor(t/1e3)}function yt(i){if(i==null)return null;let t=Number(i);if(!Number.isFinite(t))throw new TypeError("Expected finite Unix seconds");return new Date(t*1e3)}function Ci(i,t){if(i==null||i==="")return null;let e=Number(i);if(!Number.isFinite(e))throw new TypeError("Expected finite Unix seconds");let{year:s,month:n,day:r}=xe(t).dayOf(e*1e3);return Ys(s,n,r)}function Ii(i,t){if(i==null)return null;if(!(i instanceof Date))throw new TypeError("Expected a Date");if(!Number.isFinite(i.getTime()))throw new RangeError("Invalid Date");let e=xe(t).midnightOf(i.getFullYear(),i.getMonth(),i.getDate());return Math.floor(e/1e3)}function Ei(i){if(!(i==null||i===""))try{return new Intl.DateTimeFormat("en-US",{timeZone:String(i)}).resolvedOptions().timeZone}catch{throw new RangeError(`Unknown time zone "${String(i)}"`)}}function xe(i){let t=Ei(i);if(!t)return{timeZone:void 0,dayOf:r=>{let o=new Date(r);return{year:o.getFullYear(),month:o.getMonth(),day:o.getDate()}},midnightOf:(r,o,a)=>Ys(r,o,a).getTime()};let e=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),s=r=>{let o={};for(let a of e.formatToParts(new Date(r)))o[a.type]=Number(a.value);return{year:o.year,month:o.month-1,day:o.day,seconds:o.hour%24*3600+o.minute*60+o.second}},n=r=>{let o=s(r);return Hs(o.year,o.month,o.day)+o.seconds*1e3-Math.floor(r/1e3)*1e3};return{timeZone:t,dayOf:r=>{let{year:o,month:a,day:c}=s(r);return{year:o,month:a,day:c}},midnightOf:(r,o,a)=>{let c=Hs(r,o,a),u=c-n(c),d=c-n(u),h=null;for(let f of[d,u]){let p=s(f);p.year!==r||p.month!==o||p.day!==a||(!h||p.seconds<h.seconds)&&(h={candidate:f,seconds:p.seconds})}return h?h.candidate:d}}}function Ys(i,t,e){let s=new Date(2e3,0,1);return s.setFullYear(i,t,e),s.setHours(0,0,0,0),s}function Hs(i,t,e){let s=new Date(0);return s.setUTCFullYear(i,t,e),s.getTime()}function Us(i){return(Array.isArray(i)?i:i?[i]:[]).flatMap(e=>{if(!e||typeof e!="object")return[];let s=e.rawField??e.field??e.id;if(s==null||String(s).trim()==="")return[];let n=String(s).trim().replace(/^[+-]/,"");return[`${e.dir==="desc"?"-":"+"}${n}`]})}function ua(i,t=[]){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("DataFilter state must be an object");let e=da(i,t),s={},n=0;for(let r of e){if(!r.id||!Object.prototype.hasOwnProperty.call(i,r.id))continue;let o=i[r.id];if(o===void 0||o===null&&r.includeNull!==!0||typeof o=="string"&&o.trim()===""&&r.includeEmpty!==!0)continue;if(typeof r.toFilter=="function"){let d=r.toFilter(o,i);d&&typeof d=="object"&&!Array.isArray(d)&&Object.assign(s,d);continue}let a=typeof r.transform=="function"?r.transform(o,i):ha(o,r);if(a===void 0)continue;r.operator&&(a={[r.operator]:a});let c=Array.isArray(r.fields)?r.fields.filter(d=>typeof d=="string"&&d):[];if(c.length>1){for(;Object.prototype.hasOwnProperty.call(s,String(n));)n+=1;s[String(n)]=["OR",...c.map(d=>({[d]:a}))],n+=1;continue}let u=c[0]??r.rawField??r.field??r.id;typeof u=="string"&&u&&(s[u]=a)}return s}function ut(i={}){let{fields:t,sort:e,filters:s={},search:n,limit:r,offset:o,visibility:a=0,count:c=!1}=i;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("ZeyOS filters must be an object");let u={};Array.isArray(t)?u.fields=[...t]:t&&typeof t=="object"&&(u.fields={...t});let d={...s},h=Object.prototype.hasOwnProperty.call(i,"visibility");a!==void 0&&(h||!Object.prototype.hasOwnProperty.call(d,"visibility"))&&(d.visibility=a),Object.keys(d).length&&(u.filters=d);let f=fa(e,t),p=Us(f);return p.length&&(u.sort=p),n!=null&&String(n).trim()&&(u.query=String(n).trim()),r!=null&&(u.limit=r),o!=null&&(u.offset=o),c&&(u.count=!0),u}function da(i,t){return Array.isArray(t)&&t.length?t.map(e=>({...e})):t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length?Object.entries(t).map(([e,s])=>typeof s=="string"?{id:e,field:s}:{...s,id:e}):Object.keys(i).map(e=>({id:e,field:e}))}function ha(i,t){let e=String(t.format??t.type??"").toLowerCase();return i instanceof Date&&["date","datetime","date-time"].includes(e)?st(i):Array.isArray(i)&&["date","datetime","date-time"].includes(e)?i.map(s=>s instanceof Date?st(s):s):i}function fa(i,t){if(!i||!t||Array.isArray(t)||typeof t!="object")return i;let e=s=>{if(!s||typeof s!="object")return s;let n=s.id;return!n||!Object.prototype.hasOwnProperty.call(t,n)?s:{...s,rawField:t[n]}};return Array.isArray(i)?i.map(e):e(i)}var Ae=Object.create(null),pa=new Set(["date","duedate","birthdate","datefrom","dateto","datecancel","lastbilling"]),Ws=new Set(["appointments.datefrom","appointments.dateto","events.datefrom","events.dateto","comments.date","documentversions.date","records.date"]),ma=Object.freeze({AWAITINGACCEPTANCE:"awaiting acceptance",AWAITINGAPPROVAL:"awaiting approval",BILLINGONLY:"billing only",CUSTOMERANDSUPPLIER:"customer and supplier",FEEDBACKREQUIRED:"feedback required",INEVALUATION:"in evaluation",INNEGOTIATION:"in negotiation",INREVISION:"in revision",NOSTOCK:"no stock",NOTSTARTED:"not started",PARTLYDELIVERED:"partly delivered",PARTLYINVOICED:"partly invoiced",PARTLYORDERED:"partly ordered",PARTLYPAID:"partly paid",PROCUREMENTONLY:"procurement only",REMOTECALL:"remote call",SERIALSANDCHARGES:"serials and charges"}),_a=Object.freeze({0:"Lowest",1:"Low",2:"Medium",3:"High",4:"Highest"}),ga=/^[A-Z][A-Z\d]*(?:_[A-Z\d]+)*$/,Zs=new Set;function V(i,t){let e=Se(i);if(!e)throw new TypeError("ZeyOS field type must not be empty");if(!t||typeof t!="object")throw new TypeError("Field type strategy must be an object");for(let s of["field","column"]){let n=t[s];if(typeof n!="function"&&(!n||typeof n!="object"||Array.isArray(n)))throw new TypeError(`Field type strategy requires a ${s} builder or descriptor`)}return Ae[e]=t,t}function Ti(i){let t=tn(i),e=Js(t),s=en(e.field,t),n={id:t.id,type:"text",label:sn(t),...s};return t.description!=null&&(n.description=String(t.description)),(t.required===!0||t.nullable===!1)&&(n.required=!0),Ta(t)&&(n.readonly=!0,n.disabled=!0,n.props={...n.props??{},readOnly:!0}),n}function Mi(i){let t=tn(i),e=Js(t);return{id:t.id,label:sn(t),sortable:t.sortable!==!1,...en(e.column,t)}}function Xt(i,t,e={}){let s=i?.schema;if(!s||typeof s.fields!="function"||typeof s.describe!="function")throw new TypeError("ZeyOS client must expose schema.fields() and schema.describe()");let n=s.describe(t),r=Qs(n?.fields),o=Qs(s.fields(t)),a=new Map;for(let[_,m]of o)a.set(_,{...m,...r.get(_)??{}});for(let[_,m]of r)a.has(_)||a.set(_,{...m});let c=Array.isArray(e.fields)?e.fields.map(String):[...a.keys()],u=new Set(Array.isArray(e.exclude)?e.exclude.map(String):[]),d=e.labels&&typeof e.labels=="object"?e.labels:{},h=e.formats&&typeof e.formats=="object"?e.formats:{},f=Ei(e.timeZone),p=[];for(let _ of c){if(u.has(_)||!a.has(_))continue;let m=a.get(_)??{},g={...m,id:_,name:_,resource:String(t)},b=m.enums??m.enum??Na(s,t,_);b!=null&&(g.enums=b,g.enum==null&&(g.enum=b)),Object.prototype.hasOwnProperty.call(d,_)&&(g.label=String(d[_])),Object.prototype.hasOwnProperty.call(h,_)&&h[_]&&(g.format=String(h[_])),f&&(g.timeZone=f),p.push(g)}return p}var Gs={field:{type:"text"},column:{}},ba={field:{type:"int"},column:{align:"right"}},ya={field:{type:"float"},column:i=>({align:"right",render:an(i)})},wa={field:{type:"float"},column:i=>({align:"right",render:an(i,!0)})},xa={field:i=>({type:"zxselect",props:{entity:nn(i)}}),column:i=>({render:t=>ja(dt(t,i),t,i)})},va={field:{type:"toggle"},column:i=>({align:"center",render:t=>dt(t,i)?"\u2713":"",sortValue:t=>+!!dt(t,i)})},Sa={field:i=>({type:Oa(i),options:Ni(i)}),column:i=>({render:on(i)})},Aa={field:{type:"zxselect",props:{preset:"priority"}},column:i=>({render:on(i,_a)})},ka={field:{type:"float",props:{min:0,max:100}},column:i=>({align:"right",render:t=>Fa(dt(t,i)),sortValue:t=>ke(dt(t,i))})},za=Xs("date"),Da=Xs("datetime");for(let i of["string","text","character","character varying","varchar","email","tel","url","uri"])V(i,Gs);for(let i of["integer","smallint","bigint","int","int2","int4","int8","int32","int64"])V(i,ba);for(let i of["number","numeric","decimal","real","double","double precision","float"])V(i,ya);for(let i of["money","currency","price","pricebilling","priceprocurement","priceproduction"])V(i,wa);for(let i of["entity","t_entity"])V(i,xa);for(let i of["boolean","checked"])V(i,va);for(let i of["list","enum"])V(i,Sa);for(let i of["progress","percent"])V(i,ka);for(let i of["date"])V(i,za);for(let i of["datetime","date-time"])V(i,Da);V("priority",Aa);V("text[]",{field:{type:"valuelist"},column:{}});V("json",{field:{type:"textarea"},column:{}});V("longtext",{field:{type:"textarea"},column:{}});for(let i of["email","tel","url","uri"])V(i,{field:{type:"text",props:{type:i==="uri"?"url":i}},column:{}});function Xs(i){return{field:{type:i},column:t=>{let e=i==="datetime"?Ra():La(t.timeZone);return{render:s=>e(dt(s,t)),sortValue:s=>Pa(dt(s,t))}}}}function Js(i){let t=Ca(i),e=Ae[t];return e||(Zs.has(t)||(Zs.add(t),console.warn(`[zx.zeyos] Unknown field type or format "${t||"unknown"}" for "${i.id}"; using text.`)),Gs)}function Ca(i){let t=Se(i.format??i.semanticFormat??i.semanticType??i.widget);if(t&&Ae[t])return t;if(nn(i)||Se(i.type)==="t_entity")return"entity";if(String(i.id).toLowerCase()==="priority")return"priority";if(i.enums!=null||i.enum!=null)return"enum";let e=Se(i.type);if(e==="bigint"||e==="int64"){let s=Ia(i);if(s)return s}return Ma(i,e)?"longtext":e&&Ae[e]?e:e.endsWith("[]")?"text[]":e==="json"||e==="jsonb"?"json":/^character varying(?:\(\d+\))?$/.test(e)?"character varying":e||t}function Ia(i){let t=String(i.id).toLowerCase(),e=String(i.resource??"").toLowerCase();return pa.has(t)&&!Ws.has(`${e}.${t}`)&&(t!=="date"||i.indexed)?"date":Ws.has(`${e}.${t}`)||/(?:date|time)$|^lastmodified$/.test(t)?"datetime":null}function tn(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Field metadata must be an object");let t=i.id??i.name??i.field??i.identifier??i.reference;if(t==null||String(t).trim()==="")throw new TypeError("Field metadata requires an id or name");return{...i,id:String(t)}}function en(i,t){let e=typeof i=="function"?i(t):i;return e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}function Se(i){return String(i??"").trim().toLowerCase().replace(/\s+/g," ")}function sn(i){let t=i.label??i.title??i.displayName;return t==null||t===""?Ea(i.id):String(t)}function Ea(i){let t=String(i??"").split(".").at(-1)??"";if(t==="ID")return"ID";let e=t.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):t}function Ta(i){return i.readonly===!0||i.readOnly===!0||i.writable===!1||i.mutable===!1}function Ma(i,t){if(i.long===!0||i.multiline===!0)return!0;let e=Number(i.maxLength??t.match(/^character varying\((\d+)\)$/)?.[1]);return Number.isFinite(e)&&e>255}function nn(i){for(let t of[i.entity,i.fk,i.relation,i.reference,i.references]){if(typeof t=="string"&&t)return t;if(t&&typeof t=="object"){let e=t.resource??t.target??t.table??t.entity;if(typeof e=="string"&&e)return e}}return null}function Qs(i){let t=new Map;if(Array.isArray(i)){for(let e of i)if(typeof e=="string")t.set(e,{});else if(e&&typeof e=="object"){let s=e.id??e.name??e.field;s!=null&&t.set(String(s),{...e})}}else if(i&&typeof i=="object")for(let[e,s]of Object.entries(i))t.set(e,s&&typeof s=="object"?{...s}:{});return t}function Na(i,t,e){if(typeof i.enums!="function")return null;let s=i.enums(t,e);return s&&typeof s=="object"&&!Array.isArray(s)&&Object.prototype.hasOwnProperty.call(s,e)?s[e]:s??null}function Ni(i){return rn(i.enums??i.enum??i.options)}function rn(i){if(typeof i=="string")try{return rn(JSON.parse(i))}catch{return{}}return Array.isArray(i)?Object.fromEntries(i.map((t,e)=>{if(Array.isArray(t)){let[s=e,n=s]=t;return[String(s),ve(n)]}if(t&&typeof t=="object"){let s=t.value??t.id??e;return[String(s),t.label!=null?String(t.label):ve(t.name??s)]}return[String(e),ve(t)]})):i&&typeof i=="object"?Object.fromEntries(Object.entries(i).map(([t,e])=>[t,ve(e)])):{}}function ve(i){let t=String(i??"");if(!ga.test(t))return t;let e=t.split("_").map(s=>ma[s]??s.toLowerCase()).join(" ");return e.charAt(0).toUpperCase()+e.slice(1)}function Oa(i){return Object.keys(Ni(i)).length<=5?"optionlist":"select"}function on(i,t={}){let e={...t,...Ni(i)};return s=>{let n=dt(s,i);return n==null?"":e[String(n)]??String(n)}}function an(i,t=!1){let e;try{e=new Intl.NumberFormat(i.locale,t&&i.currency?{style:"currency",currency:String(i.currency)}:{})}catch{e=new Intl.NumberFormat}return s=>{let n=ke(dt(s,i));return n==null?"":e.format(n)}}function ke(i){if(i==null||i==="")return null;let t=Number(i);return Number.isFinite(t)?t:null}function Fa(i){let t=ke(i);return t==null?"":`${new Intl.NumberFormat().format(t)}%`}function Ra(){let i=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"});return t=>{let e=ln(t);return e?i.format(e):""}}function La(i){let t=xe(i??void 0),e=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"});return s=>{let n=ln(s);if(!n)return"";let{year:r,month:o,day:a}=s instanceof Date?{year:n.getFullYear(),month:n.getMonth(),day:n.getDate()}:t.dayOf(n.getTime()),c=new Date(0);return c.setUTCFullYear(r,o,a),e.format(c)}}function ln(i){if(i==null||i==="")return null;try{let t=i instanceof Date?i:yt(i);return t&&Number.isFinite(t.getTime())?t:null}catch{return null}}function Pa(i){return i instanceof Date?st(i):ke(i)}function dt(i,t){if(!i||typeof i!="object")return;if(Object.prototype.hasOwnProperty.call(i,t.id))return i[t.id];let e=String(t.path??t.field??t.id).split("."),s=i;for(let n of e){if(!s||typeof s!="object")return;s=s[n]}return s}function ja(i,t,e){if(i&&typeof i=="object"){let n=i.label??i.name??i.title??i.number??i.ID??i.id;return n==null?"":String(n)}let s=e.labelField;if(typeof s=="string"&&t[s]!=null)return String(t[s]);for(let n of[`${e.id}.name`,`${e.id}_label`,`${e.id}Label`])if(t[n]!=null)return String(t[n]);return i==null?"":String(i)}var cn=0;function D(i="zx"){return cn+=1,`${i}-${Date.now().toString(36)}-${cn.toString(36)}`}function De(i,t){let e=Jt(i)?un(i):{};if(!Jt(t))return ze(t);for(let[s,n]of Object.entries(t))Jt(n)&&Jt(e[s])?e[s]=De(e[s],n):e[s]=ze(n);return e}function q(i){return!!(i&&typeof i=="object"&&i.nodeType===1)}function Pt(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 te(i,t,e){return Math.min(e,Math.max(t,i))}function Oi(i){return String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Jt(i){if(i===null||typeof i!="object")return!1;let t=Object.getPrototypeOf(i);return t===Object.prototype||t===null}function un(i){let t={};for(let[e,s]of Object.entries(i))t[e]=ze(s);return t}function ze(i){return Jt(i)?un(i):Array.isArray(i)?i.map(ze):i}var ee=null;function Fi(i){if(typeof i!="string")return null;let t=i.trim();if(!t)return null;try{let e=new URL(t,globalThis.location?.href??"https://zx.invalid/").protocol;if(["javascript:","data:","vbscript:"].includes(e.toLowerCase()))return null}catch{return null}return t}function l(i,t,...e){let s=document.createElement(i),n=t;Va(n)||(e.unshift(n),n={});for(let[r,o]of Object.entries(n))qa(s,r,o);return Ba(s,e),s}l.scope=function(t,e){let s=ee;ee=t;try{return e()}finally{ee=s}};l.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 H(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 wt(i){if(i==null)return null;if(q(i))return i;if(typeof i=="string")return document.querySelector(i);if(typeof i.toElement=="function"){let t=i.toElement();return q(t)?t:null}return null}function Va(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 qa(i,t,e){if(t==="ref"){ee&&typeof e=="string"&&(ee[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=$a(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 $a(i){return i.startsWith("aria-")?i:/^aria[A-Z]/.test(i)?"aria-"+i.slice(4).toLowerCase():null}function Ba(i,t){let e=i;for(let s of t.flat(1/0)){if(s==null)continue;if(typeof s=="string"||typeof s=="number"){e.append(document.createTextNode(String(s)));continue}if(typeof s!="object")continue;let n=s;if(typeof n.nodeType=="number")e.append(s);else if(typeof n.toElement=="function"){let r=n.toElement();r&&e.append(r)}}}var dn=null,hn="en";function Ri(i){hn=String(i||"en")}function ht(){return hn}function nt(i,t){let e=dn?dn(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,(r,o)=>{let a=Number(o)-1,c;return e?c=e[a]:Object.prototype.hasOwnProperty.call(t,o)&&(c=t[o]),c==null?r:String(c)}),n=0;return s=s.replace(/%([A-Za-z_][\w.-]*)%/g,(r,o)=>{if(!e&&Object.prototype.hasOwnProperty.call(t,o)){let a=t[o];return a==null?r:String(a)}if(e&&n<e.length){let a=e[n];return n+=1,a==null?r:String(a)}return r}),s}var Ce=new WeakMap,v=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#t=new AbortController;#e=!1;#i=!1;#s=!1;constructor(t,e={}){super();let s=this.constructor;this.#e=t===null;let n=wt(t);if(t!==null&&!n)throw new TypeError("Component target could not be resolved");this.el=n,this.refs={};let r=Ka(s,e),o=[];for(let[u,d]of Object.entries(r))/^on[a-z]/.test(u)&&typeof d=="function"&&(o.push([u.slice(2),d]),delete r[u]);r.msg&&typeof r.msg=="object"&&Object.freeze(r.msg),this.options=Object.freeze(r);for(let[u,d]of o)this.on(u,d);let a;try{a=l.scope(this.refs,()=>this.render())}catch(u){throw this.#t.abort(),u}if(this.#e){let u=q(a)?a:this.el;if(!q(u))throw this.#t.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=u}if(!q(this.el))throw this.#t.abort(),new TypeError("Component requires a root Element");let c=s.cssName;if(typeof c=="string"&&c){let u=`zx-${c}`;this.#s=!this.el.classList.contains(u),this.el.classList.add(u)}Ce.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={},s={}){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("Event detail must be an object");let n=fn(t,e,{cancelable:!0});if(this.dispatchEvent(n),this.el){let r=fn(`zx-${t}`,e,{bubbles:!0,composed:!0,cancelable:!0});this.el.dispatchEvent(r),s.honorDomCancellation&&r.defaultPrevented&&n.preventDefault()}return n}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??ht(),r=s?.[n]?.[t];if(r!=null)return O(String(r),e);let o=s?.[t];return o!=null?O(String(o),e):nt(t,e)}destroy(){if(this.#i)return;this.#i=!0,this.#t.abort(),Ce.get(this.el)===this&&Ce.delete(this.el);let t=this.constructor.cssName;this.#s&&typeof t=="string"&&this.el&&this.el.classList.remove(`zx-${t}`),this.#e&&this.el&&this.el.remove()}static from(t){return Ce.get(t)??null}};function Ka(i,t){let e=[],s=i;for(;s&&s!==Function.prototype;)Object.prototype.hasOwnProperty.call(s,"defaults")&&e.unshift(s.defaults),s=Object.getPrototypeOf(s);let n={},r={},o=!1;for(let a of e)!a||typeof a!="object"||(Object.assign(n,a),a.msg&&typeof a.msg=="object"&&(o=!0,r=De(r,a.msg)));return Object.assign(n,t&&typeof t=="object"?t:{}),t?.msg&&typeof t.msg=="object"&&(o=!0,r=De(r,t.msg)),o&&(n.msg=r),n}function fn(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 v{static cssName="field";static defaults={id:null,name:null,type:"text",label:"",description:"",value:void 0,placeholder:"",required:!1,disabled:!1,options:null,layout:"stack",props:{},msg:{"field.int":"Enter a whole number.","field.float":"Enter a valid number.","field.unknown":"Unknown field type: %1"}};static#t=new Map;static register(t,e){let s=String(t).trim().toLowerCase();if(!s)throw new TypeError("Field adapter type must not be empty");if(typeof e!="function")throw new TypeError("Field adapter must be a function");return i.#t.set(s,e),this}static has(t){return i.#t.has(String(t).trim().toLowerCase())}render(){let t=this.el??l("div");this.el=t;let e=String(this.options.type||"text").toLowerCase(),s=this.options.layout==="inline"?"inline":"stack";this._ownedComponents=new Set,this._ownedNodes=[],this._rootAttributes=Wa(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):D("zx-field"),this.name=String(this.options.name??this.options.id??"");let n=`${this.controlId}-label`,r=`${this.controlId}-description`,o=`${this.controlId}-highlight`,a=l("label",{class:"zx-field__label",id:n,htmlFor:this.controlId},String(this.options.label??""),this.options.required?l("span",{class:"zx-field__required",ariaHidden:"true"}," *"):null),c=l("div",{class:"zx-field__control"}),u=l("div",{class:"zx-field__description",id:r},String(this.options.description??"")),d=l("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),h=l("div",{class:"zx-field__body"},c,u,d);this._ownedNodes.push(a,h),t.append(a,h);let f=i.#t.get(e);if(f)try{this.adapter=Ya(f(this,this.options))}catch(m){let g=m instanceof Error?m.message:String(m);console.warn(`[zx.Field] Adapter "${e}" failed: ${g}`),this.adapter=mn(g,this.controlId)}else{let m=this.msg("field.unknown",e);console.warn(`[zx.Field] ${m}`),this.adapter=mn(m,this.controlId)}let p=this.adapter.el;p.id||(p.id=this.controlId);let _=this.adapter.labelTarget??(Ie(p)?p:Ua(p))??p;return this._labelled=_,_!==p&&Ie(_)&&!_.id&&(_.id=`${this.controlId}-input`),a.htmlFor=Ie(_)?_.id:p.id,Ie(_)||_.setAttribute("aria-labelledby",n),this._baseDescribedBy=_.getAttribute("aria-describedby")??"",c.append(p),this._descriptionId=String(this.options.description??"")?r:"",this._highlightId=o,this._highlight=d,this._syncDescription(),this.initialValue=Ha(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._labelled.setAttribute("aria-invalid","true"),this.emit("invalid",{message:String(t)})):(this._highlight.removeAttribute("role"),this._labelled.removeAttribute("aria-invalid")),this._syncDescription(!!t),this}clearHighlight(){return delete this.el.dataset.state,this._highlight.textContent="",this._highlight.hidden=!0,this._highlight.removeAttribute("role"),this._labelled.removeAttribute("aria-invalid"),this._syncDescription(!1),this}getInput(){return this.adapter.el}own(t){if(!(t instanceof v))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._labelled.setAttribute("aria-describedby",[...new Set(e)].join(" ")):this._labelled.removeAttribute("aria-describedby")}destroy(){this.adapter?.destroy?.();for(let t of this._ownedComponents??[])t.destroy();this._ownedComponents?.clear();for(let t of this._ownedNodes??[])t.remove();Za(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=gn(t);return e!==null&&Number.isInteger(e)?{valid:!0,value:e}:{valid:!1,value:t}}function Pi(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=gn(t);return e!==null?{valid:!0,value:e}:{valid:!1,value:t}}function gn(i){let t=i.replace(/[\s\u00a0]/g,"");if(!/^[+-]?[\d.,]+$/.test(t))return null;let e=/^[+-]/.test(t)?t[0]:"",s=e?t.slice(1):t;if(!/\d/.test(s))return null;let n=[...s.matchAll(/\./g)].map(c=>c.index),r=[...s.matchAll(/,/g)].map(c=>c.index),o;if(n.length&&r.length){let c=n.at(-1)>r.at(-1)?".":",",u=c==="."?",":".",d=s.lastIndexOf(c),h=s.slice(0,d),f=s.slice(d+1);if(!/^\d+$/.test(f)||!pn(h,u))return null;o=h.split(u).join("")+"."+f}else if(r.length>1||n.length>1){let c=r.length?",":".";if(!pn(s,c))return null;o=s.split(c).join("")}else r.length===1?o=s.replace(",","."):o=s;if(!/^(?:\d+(?:\.\d+)?|\.\d+)$/.test(o))return null;let a=Number(e+o);return Number.isFinite(a)?a:null}function pn(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 Ha(i,t){return t!==void 0?t:i==="checkbox"?!1:""}function Ya(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 mn(i,t){let e=l("div",{class:"zx-field__error-control",id:t,role:"alert",tabIndex:-1},i);return{el:e,get:()=>null,set:()=>{},focus:()=>e.focus(),setDisabled:()=>{}}}function Ie(i){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(i.tagName)}function Ua(i){for(let t of i.querySelectorAll('input:not([type="hidden"]), select, textarea'))if(!(t.hasAttribute("aria-label")||t.hasAttribute("aria-labelledby")||[...t.labels??[]].some(s=>s.textContent?.trim())))return t;return null}function Wa(i,t){return new Map(t.map(e=>[e,i.getAttribute(e)]))}function Za(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}function ie(i,t,e){let s={...t.props??{}};for(let n of Object.keys(s))(/^on[a-z]/i.test(n)||n==="content")&&delete s[n];return{name:i.name||void 0,...s,...e}}function Ee(i,t){return(e,s)=>{let n=l(i,ie(e,s,{type:i==="input"?t:void 0,placeholder:s.placeholder,required:s.required,disabled:s.disabled}));return ji(n)}}function ji(i){return{el:i,get:()=>i.value,set:t=>{i.value=t==null?"":String(t)},focus:()=>i.focus(),setDisabled:t=>{i.disabled=t}}}function bn(i){return(t,e)=>{let s=i==="int"?Li:Pi,n=l("input",ie(t,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()}),{...ji(n),get:()=>s(n.value).value}}}var Qa=(i,t)=>{let e=l("input",ie(i,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}}},Ga=(i,t)=>{let e=l("select",ie(i,t,{required:t.required,disabled:t.disabled}));for(let[s,n]of yn(t.options))e.append(l("option",{value:s},n));return ji(e)},Xa=(i,t)=>{let e=l("div",{class:"zx-field__option-list",role:"radiogroup"}),s=i.controlId,n=yn(t.options).map(([r,o],a)=>{let c=l("input",{type:"radio",name:s,value:r,required:!!t.required&&a===0,disabled:t.disabled});return e.append(l("label",{class:"zx-field__option"},c,l("span",{},o))),c});return{el:e,get:()=>n.find(r=>r.checked)?.value??"",set:r=>{for(let o of n)o.checked=String(r??"")===o.value},focus:()=>(n.find(r=>r.checked)??n[0])?.focus(),setDisabled:r=>{for(let o of n)o.disabled=r;e.setAttribute("aria-disabled",String(r))}}},Ja=(i,t)=>{let e=l("div",ie(i,t,{class:"zx-field__static",name:void 0})),s=null;return{el:e,get:()=>e.textContent,set:r=>{_n(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:()=>_n(s)}};function _n(i){i&&(i.parent?i.parent.insertBefore(i.node,i.next?.parentNode===i.parent?i.next:null):i.node.remove())}var tl=(i,t)=>{if(typeof t.adapter!="function")throw new TypeError("Custom fields require options.adapter");return t.adapter(i,t)};function yn(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",Ee("input","text"));S.register("password",Ee("input","password"));S.register("textarea",Ee("textarea","text"));S.register("checkbox",Qa);S.register("int",bn("int"));S.register("float",bn("float"));S.register("select",Ga);S.register("optionlist",Xa);S.register("hidden",Ee("input","hidden"));S.register("html",Ja);S.register("custom",tl);function xt(i,t,e){let s=wn(t).split(/\s+/).filter(Boolean);return s.length===0?i.slice():i.filter(n=>{let r=el(n,e).map(wn);return s.every(o=>r.some(a=>a.includes(o)))})}function el(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 wn(i){return String(i??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var Te=class extends v{static cssName="checklist";static defaults={items:[],valueKey:"ID",labelKey:"name",checkedKey:"on",search:!0,height:280,defaultChecked:!1,hideLabel:!1,load:null};render(){this._items=[],this._visibleItems=[],this._checked=new Set,this._query="",this._loadSequence=0,this._createdRoot=!1,this._active=!0,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._createdRoot||(this._originalChildren=Array.from(t.childNodes));for(let a of["role","aria-label","aria-labelledby","data-state"])this._originalAttributes.set(a,t.getAttribute(a));let e=this._message("checklist.label","Checklist"),s=D("zx-checklist-label"),n=this.options.hideLabel?null:l("div",{class:"zx-checklist__label",id:s},e),r=l("input",{ref:"search",class:"zx-checklist__search",type:"search",autocomplete:"off",placeholder:this._message("checklist.search","Search"),ariaLabel:this._message("checklist.search","Search checklist"),hidden:!this.options.search}),o=l("div",{ref:"list",class:"zx-checklist__list"});return o.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,t.replaceChildren(...[n,r,o].filter(Boolean)),t.setAttribute("role","group"),n?t.setAttribute("aria-labelledby",s):t.setAttribute("aria-label",e),this.listen(r,"input",()=>this.search(r.value)),this.listen(o,"change",a=>{let c=a.target;if(!c?.matches?.('input[type="checkbox"][data-index]'))return;let u=this._visibleItems[Number(c.dataset.index)];if(u===void 0)return;let d=this._itemValue(u);c.checked?this._checked.add(d):this._checked.delete(d),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=xt(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=xt(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let t=this._visibleItems.map((e,s)=>{let n=D("zx-checklist-item"),r=l("input",{type:"checkbox",id:n,checked:this._checked.has(this._itemValue(e)),dataset:{index:s}});return l("label",{class:"zx-checklist__item",for:n},r,l("span",{},this._itemLabel(e)))});t.length===0&&t.push(l("div",{class:"zx-checklist__empty",role:"status"},this._message("checklist.empty","No matches"))),this.refs.list.replaceChildren(...t)}_replaceChecked(t){il(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 il(i,t){return i.size===t.size&&Array.from(i).every(e=>t.has(e))}function xn(){S.register("checklist",(i,t)=>{let e=i.own(new Te(null,{hideLabel:!0,...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 sl=new Set(["Shift","Control","Alt","Meta","AltGraph","CapsLock","Fn","OS"]),Me=class extends v{static cssName="code-editor";static defaults={value:"",name:"",language:"text",label:"Code editor",placeholder:"",rows:12,indent:" ",wrap:"off",spellcheck:!1,readOnly:!1,disabled:!1,status:!0};render(){this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._initialChildren=this._createdRoot?[]:[...t.childNodes],this._initialAttributes=new Map(["data-language","data-readonly","data-disabled"].map(e=>[e,t.getAttribute(e)])),this._language=vn(this.options.language),this._languageLabel=l("span",{class:"zx-code-editor__language"},this._language),this._position=l("span",{class:"zx-code-editor__position",role:"status",ariaLive:"polite"}),this._header=l("div",{class:"zx-code-editor__header"},this._languageLabel,this.options.status?this._position:null),this._input=l("textarea",{class:"zx-code-editor__input",name:this.options.name?String(this.options.name):void 0,ariaLabel:String(this.options.label??"Code editor"),placeholder:String(this.options.placeholder??""),rows:al(this.options.rows),wrap:ll(this.options.wrap),spellcheck:!!this.options.spellcheck,readOnly:!!this.options.readOnly,disabled:!!this.options.disabled,autocomplete:"off",autocapitalize:"off"}),this._input.value=String(this.options.value??""),t.dataset.language=this._language,t.dataset.readonly=String(!!this.options.readOnly),t.dataset.disabled=String(!!this.options.disabled),t.replaceChildren(this._header,this._input),this._tabReleased=!1,this.listen(this._input,"keydown",e=>this._handleKeydown(e)),this.listen(this._input,"blur",()=>{this._tabReleased=!1}),this.listen(this._input,"input",()=>{this._updatePosition(),this.emit("input",{value:this.getValue()})}),this.listen(this._input,"change",()=>this.emit("change",{value:this.getValue()}));for(let e of["click","keyup","select","focus"])this.listen(this._input,e,()=>this._updatePosition());return this._updatePosition(),t}getValue(){return this._input.value}setValue(t,{silent:e=!1}={}){let s=String(t??"");return this._input.value===s?this:(this._input.value=s,this._updatePosition(),e||this.emit("change",{value:s}),this)}setLanguage(t){return this._language=vn(t),this.el.dataset.language=this._language,this._languageLabel.textContent=this._language,this}focus(){return this._input.focus(),this}enable(){return this._input.disabled=!1,this.el.dataset.disabled="false",this}disable(){return this._input.disabled=!0,this.el.dataset.disabled="true",this}setReadOnly(t){return this._input.readOnly=!!t,this.el.dataset.readonly=String(!!t),this}_handleKeydown(t){if(t.isComposing||sl.has(t.key))return;if(t.key==="Escape"){this._tabReleased=!0;return}let e=this._tabReleased;if(this._tabReleased=!1,e||t.key!=="Tab"||t.altKey||t.ctrlKey||t.metaKey||this._input.readOnly||this._input.disabled)return;let s=String(this.options.indent??" ");if(!s)return;t.preventDefault();let n=nl(this._input.value,this._input.selectionStart??0,this._input.selectionEnd??0,s,t.shiftKey);n.value!==this._input.value&&(this._input.value=n.value,this._input.setSelectionRange(n.start,n.end),this._updatePosition(),this.emit("input",{value:this.getValue()}))}_updatePosition(){if(!this.options.status)return;let t=rl(this._input.value,this._input.selectionStart??0,this._input.selectionEnd??0);this._position.textContent=t.lines>1?`Ln ${t.line}, Col ${t.column} \xB7 ${t.lines} lines selected`:`Ln ${t.line}, Col ${t.column}`}destroy(){if(!this._createdRoot){this.el.replaceChildren(...this._initialChildren);for(let[t,e]of this._initialAttributes)e===null?this.el.removeAttribute(t):this.el.setAttribute(t,e)}super.destroy()}};function nl(i,t,e,s=" ",n=!1){let r=String(i??""),o=String(s??""),a=Ne(t,r.length),c=Ne(e,r.length);if(!o)return{value:r,start:a,end:c};if(a===c&&!n)return{value:r.slice(0,a)+o+r.slice(c),start:a+o.length,end:a+o.length};let u=r.lastIndexOf(`
1
+ function ue(i){if(i==null)return null;if(!(i instanceof Date))throw new TypeError("Expected a Date");let e=i.getTime();if(!Number.isFinite(e))throw new RangeError("Invalid Date");return Math.floor(e/1e3)}function ye(i){if(i==null)return null;let e=Number(i);if(!Number.isFinite(e))throw new TypeError("Expected finite Unix seconds");return new Date(e*1e3)}function Zi(i,e){if(i==null||i==="")return null;let t=Number(i);if(!Number.isFinite(t))throw new TypeError("Expected finite Unix seconds");let{year:s,month:n,day:r}=at(e).dayOf(t*1e3);return Mn(s,n,r)}function Ot(i,e){if(i==null)return null;if(!(i instanceof Date))throw new TypeError("Expected a Date");if(!Number.isFinite(i.getTime()))throw new RangeError("Invalid Date");let t=at(e).midnightOf(i.getFullYear(),i.getMonth(),i.getDate());return Math.floor(t/1e3)}function Ft(i){if(!(i==null||i===""))try{return new Intl.DateTimeFormat("en-US",{timeZone:String(i)}).resolvedOptions().timeZone}catch{throw new RangeError(`Unknown time zone "${String(i)}"`)}}function at(i){let e=Ft(i);if(!e)return{timeZone:void 0,dayOf:r=>{let o=new Date(r);return{year:o.getFullYear(),month:o.getMonth(),day:o.getDate()}},midnightOf:(r,o,a)=>Mn(r,o,a).getTime()};let t=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),s=r=>{let o={};for(let a of t.formatToParts(new Date(r)))o[a.type]=Number(a.value);return{year:o.year,month:o.month-1,day:o.day,seconds:o.hour%24*3600+o.minute*60+o.second}},n=r=>{let o=s(r);return Tn(o.year,o.month,o.day)+o.seconds*1e3-Math.floor(r/1e3)*1e3};return{timeZone:e,dayOf:r=>{let{year:o,month:a,day:l}=s(r);return{year:o,month:a,day:l}},midnightOf:(r,o,a)=>{let l=Tn(r,o,a),u=l-n(l),d=l-n(u),h=null;for(let p of[d,u]){let f=s(p);f.year!==r||f.month!==o||f.day!==a||(!h||f.seconds<h.seconds)&&(h={candidate:p,seconds:f.seconds})}return h?h.candidate:d}}}function Mn(i,e,t){let s=new Date(2e3,0,1);return s.setFullYear(i,e,t),s.setHours(0,0,0,0),s}function Tn(i,e,t){let s=new Date(0);return s.setUTCFullYear(i,e,t),s.getTime()}function Nn(i){return(Array.isArray(i)?i:i?[i]:[]).flatMap(t=>{if(!t||typeof t!="object")return[];let s=t.rawField??t.field??t.id;if(s==null||String(s).trim()==="")return[];let n=String(s).trim().replace(/^[+-]/,"");return[`${t.dir==="desc"?"-":"+"}${n}`]})}function _l(i,e=[],t={}){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("DataFilter state must be an object");let s=!!t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"timeZone"),n=s?Ft(t.timeZone):void 0,r=gl(i,e),o={},a=0;for(let l of r){if(!l.id||!Object.prototype.hasOwnProperty.call(i,l.id))continue;let u=i[l.id];if(u===void 0||u===null&&l.includeNull!==!0||typeof u=="string"&&u.trim()===""&&l.includeEmpty!==!0)continue;if(typeof l.toFilter=="function"){let f=l.toFilter(u,i);f&&typeof f=="object"&&!Array.isArray(f)&&Object.assign(o,f);continue}let d=typeof l.transform=="function"?l.transform(u,i):bl(u,l,s?{timeZone:n}:null);if(d===void 0)continue;l.operator&&(d={[l.operator]:d});let h=Array.isArray(l.fields)?l.fields.filter(f=>typeof f=="string"&&f):[];if(h.length>1){for(;Object.prototype.hasOwnProperty.call(o,String(a));)a+=1;o[String(a)]=["OR",...h.map(f=>({[f]:d}))],a+=1;continue}let p=h[0]??l.rawField??l.field??l.id;typeof p=="string"&&p&&(o[p]=d)}return o}function lt(i={}){let{fields:e,sort:t,filters:s={},search:n,limit:r,offset:o,visibility:a=0,count:l=!1}=i;if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("ZeyOS filters must be an object");let u={};Array.isArray(e)?u.fields=[...e]:e&&typeof e=="object"&&(u.fields={...e});let d={...s},h=Object.prototype.hasOwnProperty.call(i,"visibility");a!==void 0&&(h||!Object.prototype.hasOwnProperty.call(d,"visibility"))&&(d.visibility=a),Object.keys(d).length&&(u.filters=d);let p=yl(t,e),f=Nn(p);return f.length&&(u.sort=f),n!=null&&String(n).trim()&&(u.query=String(n).trim()),r!=null&&(u.limit=r),o!=null&&(u.offset=o),l&&(u.count=!0),u}function gl(i,e){return Array.isArray(e)&&e.length?e.map(t=>({...t})):e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length?Object.entries(e).map(([t,s])=>typeof s=="string"?{id:t,field:s}:{...s,id:t}):Object.keys(i).map(t=>({id:t,field:t}))}function bl(i,e,t=null){let s=String(e.format??e.type??"").toLowerCase();if(!["date","datetime","date-time"].includes(s))return i;let n=r=>{if(t&&s==="date"){if(r instanceof Date)return Ot(r,t.timeZone);let o=typeof r=="string"?/^(\d{4})-(\d{2})-(\d{2})$/.exec(r.trim()):null;if(o){let a=at(t.timeZone).midnightOf(Number(o[1]),Number(o[2])-1,Number(o[3]));return Math.floor(a/1e3)}return r}return r instanceof Date?ue(r):r};return Array.isArray(i)?i.map(n):n(i)}function yl(i,e){if(!i||!e||Array.isArray(e)||typeof e!="object")return i;let t=s=>{if(!s||typeof s!="object")return s;let n=s.id;return!n||!Object.prototype.hasOwnProperty.call(e,n)?s:{...s,rawField:e[n]}};return Array.isArray(i)?i.map(t):t(i)}var Pt=Object.create(null),wl=new Set(["date","duedate","birthdate","datefrom","dateto","datecancel","lastbilling"]),On=new Set(["appointments.datefrom","appointments.dateto","events.datefrom","events.dateto","comments.date","documentversions.date","records.date"]),vl=Object.freeze({AWAITINGACCEPTANCE:"awaiting acceptance",AWAITINGAPPROVAL:"awaiting approval",BILLINGONLY:"billing only",CUSTOMERANDSUPPLIER:"customer and supplier",FEEDBACKREQUIRED:"feedback required",INEVALUATION:"in evaluation",INNEGOTIATION:"in negotiation",INREVISION:"in revision",NOSTOCK:"no stock",NOTSTARTED:"not started",PARTLYDELIVERED:"partly delivered",PARTLYINVOICED:"partly invoiced",PARTLYORDERED:"partly ordered",PARTLYPAID:"partly paid",PROCUREMENTONLY:"procurement only",REMOTECALL:"remote call",SERIALSANDCHARGES:"serials and charges"}),xl=Object.freeze({0:"Lowest",1:"Low",2:"Medium",3:"High",4:"Highest"}),Sl=/^[A-Z][A-Z\d]*(?:_[A-Z\d]+)*$/,Fn=new Set;function V(i,e){let t=Lt(i);if(!t)throw new TypeError("ZeyOS field type must not be empty");if(!e||typeof e!="object")throw new TypeError("Field type strategy must be an object");for(let s of["field","column"]){let n=e[s];if(typeof n!="function"&&(!n||typeof n!="object"||Array.isArray(n)))throw new TypeError(`Field type strategy requires a ${s} builder or descriptor`)}return Pt[t]=e,e}function Gi(i){let e=Bn(i),t=jn(e),s=Vn(t.field,e),n={id:e.id,type:"text",label:qn(e),...s};return e.description!=null&&(n.description=String(e.description)),(e.required===!0||e.nullable===!1)&&(n.required=!0),Ll(e)&&(n.readonly=!0,n.disabled=!0,n.props={...n.props??{},readOnly:!0}),n}function Qi(i){let e=Bn(i),t=jn(e);return{id:e.id,label:qn(e),sortable:e.sortable!==!1,...Vn(t.column,e)}}function ct(i,e,t={}){let s=i?.schema;if(!s||typeof s.fields!="function"||typeof s.describe!="function")throw new TypeError("ZeyOS client must expose schema.fields() and schema.describe()");let n=s.describe(e),r=Rn(n?.fields),o=Rn(s.fields(e)),a=new Map;for(let[_,m]of o)a.set(_,{...m,...r.get(_)??{}});for(let[_,m]of r)a.has(_)||a.set(_,{...m});let l=Array.isArray(t.fields)?t.fields.map(String):[...a.keys()],u=new Set(Array.isArray(t.exclude)?t.exclude.map(String):[]),d=t.labels&&typeof t.labels=="object"?t.labels:{},h=t.formats&&typeof t.formats=="object"?t.formats:{},p=Ft(t.timeZone),f=[];for(let _ of l){if(u.has(_)||!a.has(_))continue;let m=a.get(_)??{},g={...m,id:_,name:_,resource:String(e)},b=m.enums??m.enum??jl(s,e,_);b!=null&&(g.enums=b,g.enum==null&&(g.enum=b)),Object.prototype.hasOwnProperty.call(d,_)&&(g.label=String(d[_])),Object.prototype.hasOwnProperty.call(h,_)&&h[_]&&(g.format=String(h[_])),p&&(g.timeZone=p),f.push(g)}return f}var Ln={field:{type:"text"},column:{}},Al={field:{type:"int"},column:{align:"right"}},kl={field:{type:"float"},column:i=>({align:"right",render:Un(i)})},zl={field:{type:"float"},column:i=>({align:"right",render:Un(i,!0)})},Cl={field:i=>({type:"zxselect",props:{entity:$n(i)}}),column:i=>({render:e=>Kl(de(e,i),e,i)})},Dl={field:{type:"toggle"},column:i=>({align:"center",render:e=>de(e,i)?"\u2713":"",sortValue:e=>+!!de(e,i)})},El={field:i=>({type:Bl(i),options:Xi(i)}),column:i=>({render:Kn(i)})},Il={field:{type:"zxselect",props:{preset:"priority"}},column:i=>({render:Kn(i,xl)})},Tl={field:{type:"float",props:{min:0,max:100}},column:i=>({align:"right",render:e=>Vl(de(e,i)),sortValue:e=>jt(de(e,i))})},Ml=Pn("date"),Nl=Pn("datetime");for(let i of["string","text","character","character varying","varchar","email","tel","url","uri"])V(i,Ln);for(let i of["integer","smallint","bigint","int","int2","int4","int8","int32","int64"])V(i,Al);for(let i of["number","numeric","decimal","real","double","double precision","float"])V(i,kl);for(let i of["money","currency","price","pricebilling","priceprocurement","priceproduction"])V(i,zl);for(let i of["entity","t_entity"])V(i,Cl);for(let i of["boolean","checked"])V(i,Dl);for(let i of["list","enum"])V(i,El);for(let i of["progress","percent"])V(i,Tl);for(let i of["date"])V(i,Ml);for(let i of["datetime","date-time"])V(i,Nl);V("priority",Il);V("text[]",{field:{type:"valuelist"},column:{}});V("json",{field:{type:"textarea"},column:{}});V("longtext",{field:{type:"textarea"},column:{}});for(let i of["email","tel","url","uri"])V(i,{field:{type:"text",props:{type:i==="uri"?"url":i}},column:{}});function Pn(i){return{field:{type:i},column:e=>{let t=i==="datetime"?ql():$l(e.timeZone);return{render:s=>t(de(s,e)),sortValue:s=>Hl(de(s,e))}}}}function jn(i){let e=Ol(i),t=Pt[e];return t||(Fn.has(e)||(Fn.add(e),console.warn(`[zx.zeyos] Unknown field type or format "${e||"unknown"}" for "${i.id}"; using text.`)),Ln)}function Ol(i){let e=Lt(i.format??i.semanticFormat??i.semanticType??i.widget);if(e&&Pt[e])return e;if($n(i)||Lt(i.type)==="t_entity")return"entity";if(String(i.id).toLowerCase()==="priority")return"priority";if(i.enums!=null||i.enum!=null)return"enum";let t=Lt(i.type);if(t==="bigint"||t==="int64"){let s=Fl(i);if(s)return s}return Pl(i,t)?"longtext":t&&Pt[t]?t:t.endsWith("[]")?"text[]":t==="json"||t==="jsonb"?"json":/^character varying(?:\(\d+\))?$/.test(t)?"character varying":t||e}function Fl(i){let e=String(i.id).toLowerCase(),t=String(i.resource??"").toLowerCase();return wl.has(e)&&!On.has(`${t}.${e}`)&&(e!=="date"||i.indexed)?"date":On.has(`${t}.${e}`)||/(?:date|time)$|^lastmodified$/.test(e)?"datetime":null}function Bn(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Field metadata must be an object");let e=i.id??i.name??i.field??i.identifier??i.reference;if(e==null||String(e).trim()==="")throw new TypeError("Field metadata requires an id or name");return{...i,id:String(e)}}function Vn(i,e){let t=typeof i=="function"?i(e):i;return t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}function Lt(i){return String(i??"").trim().toLowerCase().replace(/\s+/g," ")}function qn(i){let e=i.label??i.title??i.displayName;return e==null||e===""?Rl(i.id):String(e)}function Rl(i){let e=String(i??"").split(".").at(-1)??"";if(e==="ID")return"ID";let t=e.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):e}function Ll(i){return i.readonly===!0||i.readOnly===!0||i.writable===!1||i.mutable===!1}function Pl(i,e){if(i.long===!0||i.multiline===!0)return!0;let t=Number(i.maxLength??e.match(/^character varying\((\d+)\)$/)?.[1]);return Number.isFinite(t)&&t>255}function $n(i){for(let e of[i.entity,i.fk,i.relation,i.reference,i.references]){if(typeof e=="string"&&e)return e;if(e&&typeof e=="object"){let t=e.resource??e.target??e.table??e.entity;if(typeof t=="string"&&t)return t}}return null}function Rn(i){let e=new Map;if(Array.isArray(i)){for(let t of i)if(typeof t=="string")e.set(t,{});else if(t&&typeof t=="object"){let s=t.id??t.name??t.field;s!=null&&e.set(String(s),{...t})}}else if(i&&typeof i=="object")for(let[t,s]of Object.entries(i))e.set(t,s&&typeof s=="object"?{...s}:{});return e}function jl(i,e,t){if(typeof i.enums!="function")return null;let s=i.enums(e,t);return s&&typeof s=="object"&&!Array.isArray(s)&&Object.prototype.hasOwnProperty.call(s,t)?s[t]:s??null}function Xi(i){return Hn(i.enums??i.enum??i.options)}function Hn(i){if(typeof i=="string")try{return Hn(JSON.parse(i))}catch{return{}}return Array.isArray(i)?Object.fromEntries(i.map((e,t)=>{if(Array.isArray(e)){let[s=t,n=s]=e;return[String(s),Rt(n)]}if(e&&typeof e=="object"){let s=e.value??e.id??t;return[String(s),e.label!=null?String(e.label):Rt(e.name??s)]}return[String(t),Rt(e)]})):i&&typeof i=="object"?Object.fromEntries(Object.entries(i).map(([e,t])=>[e,Rt(t)])):{}}function Rt(i){let e=String(i??"");if(!Sl.test(e))return e;let t=e.split("_").map(s=>vl[s]??s.toLowerCase()).join(" ");return t.charAt(0).toUpperCase()+t.slice(1)}function Bl(i){return Object.keys(Xi(i)).length<=5?"optionlist":"select"}function Kn(i,e={}){let t={...e,...Xi(i)};return s=>{let n=de(s,i);return n==null?"":t[String(n)]??String(n)}}function Un(i,e=!1){let t;try{t=new Intl.NumberFormat(i.locale,e&&i.currency?{style:"currency",currency:String(i.currency)}:{})}catch{t=new Intl.NumberFormat}return s=>{let n=jt(de(s,i));return n==null?"":t.format(n)}}function jt(i){if(i==null||i==="")return null;let e=Number(i);return Number.isFinite(e)?e:null}function Vl(i){let e=jt(i);return e==null?"":`${new Intl.NumberFormat().format(e)}%`}function ql(){let i=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"});return e=>{let t=Yn(e);return t?i.format(t):""}}function $l(i){let e=at(i??void 0),t=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"});return s=>{let n=Yn(s);if(!n)return"";let{year:r,month:o,day:a}=s instanceof Date?{year:n.getFullYear(),month:n.getMonth(),day:n.getDate()}:e.dayOf(n.getTime()),l=new Date(0);return l.setUTCFullYear(r,o,a),t.format(l)}}function Yn(i){if(i==null||i==="")return null;try{let e=i instanceof Date?i:ye(i);return e&&Number.isFinite(e.getTime())?e:null}catch{return null}}function Hl(i){return i instanceof Date?ue(i):jt(i)}function de(i,e){if(!i||typeof i!="object")return;if(Object.prototype.hasOwnProperty.call(i,e.id))return i[e.id];let t=String(e.path??e.field??e.id).split("."),s=i;for(let n of t){if(!s||typeof s!="object")return;s=s[n]}return s}function Kl(i,e,t){if(i&&typeof i=="object"){let n=i.label??i.name??i.title??i.number??i.ID??i.id;return n==null?"":String(n)}let s=t.labelField;if(typeof s=="string"&&e[s]!=null)return String(e[s]);for(let n of[`${t.id}.name`,`${t.id}_label`,`${t.id}Label`])if(e[n]!=null)return String(e[n]);return i==null?"":String(i)}var Wn=0;function E(i="zx"){return Wn+=1,`${i}-${Date.now().toString(36)}-${Wn.toString(36)}`}function je(i,e){let t=ut(i)?Zn(i):{};if(!ut(e))return Bt(e);for(let[s,n]of Object.entries(e))ut(n)&&ut(t[s])?t[s]=je(t[s],n):t[s]=Bt(n);return t}function R(i){return!!(i&&typeof i=="object"&&i.nodeType===1)}function we(i){if(typeof i!="string")return!1;let e=i.trim();if(!e||e.length>256||/[;{}\u0000-\u001f\u007f]/.test(e)||/(?:url|image|image-set|cross-fade|element|var)\s*\(/i.test(e))return!1;let t=globalThis.CSS?.supports;if(typeof t=="function")try{return t.call(globalThis.CSS,"color",e)}catch{return!1}return/^(?:#[\da-f]{3,8}|[a-z]+|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix)\([^;{}]+\))$/i.test(e)}function dt(i,e,t){return Math.min(t,Math.max(e,i))}function Ji(i){return String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ut(i){if(i===null||typeof i!="object")return!1;let e=Object.getPrototypeOf(i);return e===Object.prototype||e===null}function Zn(i){let e={};for(let[t,s]of Object.entries(i))e[t]=Bt(s);return e}function Bt(i){return ut(i)?Zn(i):Array.isArray(i)?i.map(Bt):i}var ht=null;function Be(i){if(typeof i!="string")return null;let e=i.trim();if(!e)return null;try{let t=new URL(e,globalThis.location?.href??"https://zx.invalid/").protocol;if(["javascript:","data:","vbscript:"].includes(t.toLowerCase()))return null}catch{return null}return e}function c(i,e,...t){let s=document.createElement(i),n=e;Ul(n)||(t.unshift(n),n={});for(let[r,o]of Object.entries(n))Yl(s,r,o);return Zl(s,t),s}c.scope=function(e,t){let s=ht;ht=e;try{return t()}finally{ht=s}};c.raw=function(e){let t=document.createElement("template");return t.innerHTML=String(e),t.content};function H(i){return{children:Array.from(i.childNodes),attributes:Array.from(i.attributes,e=>[e.name,e.value])}}function K(i,e){if(e){for(let t of Array.from(i.attributes))i.removeAttribute(t.name);for(let[t,s]of e.attributes)i.setAttribute(t,s);i.replaceChildren(...e.children)}}function U(i){if(i==null)return null;if(R(i))return i;if(typeof i=="string")return document.querySelector(i);if(typeof i.toElement=="function"){let e=i.toElement();return R(e)?e:null}return null}function Ul(i){if(i===null||typeof i!="object"||Array.isArray(i))return!1;let e=i;return typeof e.nodeType=="number"?!1:typeof e.toElement!="function"}function Yl(i,e,t){if(e==="ref"){ht&&typeof t=="string"&&(ht[t]=i);return}if(e==="class"){i.className=Array.isArray(t)?t.flat(1/0).filter(Boolean).join(" "):String(t??"");return}if(e==="style"){if(typeof t=="string")i.style.cssText=t;else if(t&&typeof t=="object")for(let[n,r]of Object.entries(t))n.startsWith("--")||n.includes("-")?i.style.setProperty(n,String(r)):i.style[n]=r;return}if(e==="dataset"&&t&&typeof t=="object"){for(let[n,r]of Object.entries(t))r==null?delete i.dataset[n]:i.dataset[n]=String(r);return}if(/^on[a-z]/.test(e)&&typeof t=="function"){i.addEventListener(e.slice(2),t);return}if(t==null)return;let s=Wl(e);if(s!==null)i.setAttribute(s,String(t));else if(e in i)try{i[e]=t}catch{i.setAttribute(e,String(t))}else typeof t=="boolean"?t?i.setAttribute(e,""):i.removeAttribute(e):i.setAttribute(e,String(t))}function Wl(i){return i.startsWith("aria-")?i:/^aria[A-Z]/.test(i)?"aria-"+i.slice(4).toLowerCase():null}function Zl(i,e){let t=i;for(let s of e.flat(1/0)){if(s==null)continue;if(typeof s=="string"||typeof s=="number"){t.append(document.createTextNode(String(s)));continue}if(typeof s!="object")continue;let n=s;if(typeof n.nodeType=="number")t.append(s);else if(typeof n.toElement=="function"){let r=n.toElement();r&&t.append(r)}}}var Vt=Object.freeze({"activityItem.actions":"Actions for %1","activityItem.attachments":"Attachments","activityItem.failed":"Failed","activityItem.label":"Activity","activityItem.metadata":"Activity metadata","activityItem.pending":"Sending\u2026","activityItem.untitled":"activity","appRail.subNavigation":"%1 sub-navigation","appSidebar.expand":"Expand application sidebar","appSidebar.itemBadge":"%1 (%2)","appSidebar.minimize":"Minimize application sidebar","appSidebar.presentation":"Navigation layout","appSidebar.presentationCollapsed":"Both menus collapsed","appSidebar.presentationCompact":"Module menu collapsed","appSidebar.presentationExpanded":"Both menus expanded","breadcrumb.label":"Breadcrumb","breadcrumb.more":"Show hidden levels","calendar.agenda":"Agenda","calendar.allDay":"All day","calendar.day":"Day","calendar.dayEvent":"%1, %2 event","calendar.dayEvents":"%1, %2 events","calendar.editCancelled":"Calendar edit cancelled.","calendar.editCommitted":"%1 updated.","calendar.editPreview":"%1, %2 to %3","calendar.label":"Calendar","calendar.loading":"Loading calendar\u2026","calendar.month":"Month","calendar.more":"+%1 more","calendar.moveStarted":"Moving %1. Use arrow keys, Space to drop, or Escape to cancel.","calendar.new":"New","calendar.next":"Next period","calendar.noEvents":"No events","calendar.previous":"Previous period","calendar.resize":"Resize %1","calendar.resizeStarted":"Resizing %1. Use arrow keys, Space to drop, or Escape to cancel.","calendar.today":"Today","calendar.viewSwitch":"Calendar view","calendar.week":"Week","calendar.weekNumber":"Week %1","calendar.year":"Year","card.actions":"Card actions","cardView.groupEmpty":"No records in this group.","cardView.label":"Card view","cardView.sort":"Sort","cardView.sortAscending":"%1 (ascending)","cardView.sortCards":"Sort cards","cardView.sortDescending":"%1 (descending)","cardView.ungrouped":"Ungrouped","cardView.unsorted":"Unsorted","checklist.empty":"No matches","checklist.label":"Checklist","checklist.search":"Search","dataFilter.all":"All","dataFilter.clear":"Clear","datePicker.calendar":"Calendar","datePicker.chooseMonthYear":"Choose month and year, %1","datePicker.nextMonth":"Next month","datePicker.nextYear":"Next year","datePicker.previousMonth":"Previous month","datePicker.previousYear":"Previous year","datePicker.week":"Week %1","datePicker.weekNumber":"Week number","daterange.choose":"Choose date range","daterange.clear":"Clear date range","daterange.day.end":"range end","daterange.day.middle":"in selected range","daterange.day.start":"range start","daterange.label":"Date range","daterange.nextMonth":"Next month","daterange.night":"1 night","daterange.nights":"%1 nights","daterange.preset.last30":"Last 30 days","daterange.preset.last7":"Last 7 days","daterange.preset.lastMonth":"Last month","daterange.preset.thisMonth":"This month","daterange.preset.thisQuarter":"This quarter","daterange.preset.thisYear":"This year","daterange.preset.today":"Today","daterange.preset.yesterday":"Yesterday","daterange.presets":"Date range presets","daterange.previousMonth":"Previous month","daterange.status.empty":"No date range selected","daterange.status.start":"%1 selected, choose an end date","daterange.week":"Week %1","daterange.weekNumber":"Week number","dialog.cancel":"Cancel","dialog.close":"Close","dialog.ok":"OK","dialog.promptValue":"Prompt value","dialog.typeToConfirm":"Type %1 to confirm","field.float":"Enter a valid number.","field.int":"Enter a whole number.","field.unknown":"Unknown field type: %1","filter.addFilter":"Add filter","filter.addGroup":"Add group","filter.addSubgroup":"Add subgroup","filter.and":"and","filter.apply":"Apply filters","filter.booleanFalse":"False","filter.booleanTrue":"True","filter.choose":"Choose\u2026","filter.chooseField":"Choose a field\u2026","filter.chooseOperator":"Choose an operator\u2026","filter.choosePart":"Choose %1\u2026","filter.clear":"Clear","filter.commaSeparated":"Comma-separated values","filter.conditionNoun":"Filter","filter.conditions":"conditions","filter.field":"Filter field","filter.fieldValue":"%1 value","filter.fieldValueAt":"%1 value %2","filter.filterNoun":"filter","filter.groupLogic":"Group filter logic","filter.groupNoun":"Filter group","filter.inThisGroup":"in this group","filter.matchAll":"Match all","filter.matchAllConditions":"Match all conditions","filter.matchAny":"Match any","filter.matchAnyConditions":"Match any conditions","filter.noValue":"No value","filter.operator":"Filter operator","filter.or":"or","filter.relativeAmount":"%1: number of units","filter.relativeInvalid":"Enter a whole number of days, weeks or months","filter.relativeUnit":"%1: unit","filter.remove":"Remove %1","filter.removed":"%1 removed","filter.removeGroup":"Remove group","filter.rootLogic":"Root filter logic","filter.switchToAll":"%1 \u2014 switch to all","filter.switchToAny":"%1 \u2014 switch to any","filter.unavailable":"Unavailable: %1","filter.unit.days":"days","filter.unit.months":"months","filter.unit.weeks":"weeks","filterPanel.apply":"Apply","filterPanel.clear":"Clear all","filterPanel.empty":"No filters are available here.","filterPanel.from":"From","filterPanel.label":"Filters","filterPanel.rangeFrom":"%1 from","filterPanel.rangeTo":"%1 to","filterPanel.to":"To","filterPanel.unsupported":"Unsupported filter type: %1","finder.loading":"Loading\u2026","finder.root":"Root","form.float":"Enter a valid number.","form.int":"Enter a whole number.","form.required":"This field is required.","launcher.back":"Back to %1","launcher.close":"Close launcher","launcher.empty":"No results","launcher.hintBack":"Back","launcher.hintClose":"Close","launcher.hintMove":"Move","launcher.hintOpen":"Open","launcher.label":"Launcher","launcher.loading":"Searching\u2026","launcher.pageEmpty":"%1, no results","launcher.pageLabel":"Search %1","launcher.pagePlaceholder":"Search","launcher.pageResult":"%1, 1 result","launcher.pageResults":"%1, %2 results","launcher.placeholder":"Search applications and records","launcher.results":"Launcher results","listToolbar.label":"List controls","listToolbar.results":"%1 results","listToolbar.search":"Search","listToolbar.toolBadge":"%1 (%2)","listToolbar.viewAuto":"Auto","listToolbar.viewBoard":"Board","listToolbar.viewCards":"Cards","listToolbar.viewGallery":"Gallery","listToolbar.viewList":"List","listToolbar.views":"View","listToolbar.viewTable":"Table","message.close":"Close message","message.closeTitle":"Close","moduleBar.empty":"No modules","moduleBar.filter":"Filter modules","moduleBar.itemBadge":"%1 (%2)","moduleBar.label":"Modules","moduleBar.more":"All modules","monthPicker.chooseMonth":"Choose month","monthPicker.nextYear":"Next year","monthPicker.previousYear":"Previous year","numberField.empty":"Empty","pagination.empty":"0 of 0","pagination.label":"Pagination","pagination.loaded":"%1 of %2","pagination.loadMore":"Load more","pagination.next":"Next page","pagination.page":"Page %1","pagination.pageSize":"Rows per page","pagination.previous":"Previous page","pagination.summary":"%1\u2013%2 of %3","panel.actions":"Panel actions","panel.footerActions":"Panel footer actions","permission.private":"Private","permission.public":"Public","priority.high":"High","priority.highest":"Highest","priority.low":"Low","priority.lowest":"Lowest","priority.none":"No priority","priority.normal":"Medium","questionnaire.counter":"Question %1 of %2","questionnaire.edit":"Edit","questionnaire.empty":"There is nothing to answer.","questionnaire.next":"Continue","questionnaire.noAnswer":"Skipped","questionnaire.previous":"Back","questionnaire.required":"Choose an answer to continue.","questionnaire.requiredInput":"Enter an answer to continue.","questionnaire.review":"Review answers","questionnaire.reviewTitle":"Check your answers","questionnaire.skip":"Skip","questionnaire.submit":"Submit","rating.count":"%1 ratings","rating.value":"%1 of %2","recordCard.actions":"Actions for %1","recordCard.notSelected":"Not selected","recordCard.select":"Select %1","recordCard.selected":"Selected","recordCard.untitled":"record","recordView.fieldMoved":"%1 moved to position %2 of %3","recordView.fields":"Fields","recordView.moveFieldDown":"Move %1 down","recordView.moveFieldUp":"Move %1 up","search.clear":"Clear search","search.label":"Search","search.submit":"Submit search","search.submitTitle":"Search","select.clear":"Clear selection","select.empty":"No matches","select.loading":"Loading","select.none":"No selection","select.toggle":"Toggle options","sheet.resize":"Resize sheet","statTile.down":"down %1","statTile.loading":"Loading","statTile.unchanged":"no change","statTile.up":"up %1","stepper.completed":"Completed","stepper.counter":"Step %1 of %2","stepper.current":"Current step","stepper.error":"Error","stepper.optional":"Optional","tabbox.close":"Close","table.collapseRow":"Collapse %1","table.columns":"Columns","table.empty":"No records","table.label":"Table","table.expandRow":"Expand %1","table.invalid":"Invalid value","table.more":"Show %1 more","table.moveColumn":"Move %1","table.moveRow":"Move %1","table.row":"row %1","table.selectAll":"Select all rows","table.selectRow":"Select %1","tagPicker.create":"Create \u201C%1\u201D","tagPicker.empty":"No matches","tagPicker.input":"Add a value","tagPicker.loading":"Loading\u2026","tagPicker.remove":"Remove %1","tagPicker.toggle":"Toggle options","timebox.duration":"Duration in hours and minutes","timebox.durationWithSeconds":"Duration in hours, minutes, and seconds","timebox.hours":"Hours","timebox.minutes":"Minutes","timebox.seconds":"Seconds","timebox.toggleSign":"Toggle duration sign","timePicker.clock":"Pick the time on a clock","timePicker.hour":"Hour","timePicker.label":"Time","timePicker.minute":"Minute","timePicker.minutes":"Minutes","timePicker.second":"Second","timePicker.selectHour":"Select the hour","timePicker.selectMinutes":"Select the minutes","valueList.add":"Add value","valueList.duplicate":"This value already exists.","valueList.instructions":"Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder.","valueList.invalid":"This value is not valid.","valueList.removable":"%1. Press Delete to remove.","valueList.values":"Values","viewSettings.add":"Add","viewSettings.added":"%1 added at position %2 of %3","viewSettings.addField":"Add %1","viewSettings.allShown":"Every field is shown.","viewSettings.board":"Board","viewSettings.canceled":"Move canceled. %1 is back at position %2 of %3","viewSettings.chooseField":"Choose a field","viewSettings.columns":"Columns","viewSettings.dragging":"%1 picked up, position %2 of %3","viewSettings.dropped":"%1 dropped at position %2 of %3","viewSettings.emptyColumns":"Show empty columns","viewSettings.fields":"Fields","viewSettings.grabbed":"%1 picked up, position %2 of %3. Use the arrow keys to move it, Space to drop it, Escape to cancel.","viewSettings.group":"Group by","viewSettings.hidden":"Hidden (%1)","viewSettings.hiddenField":"%1 hidden","viewSettings.hide":"Hide %1","viewSettings.instructions":"Press Space to pick the field up, the arrow keys to move it, Space again to drop it, or Escape to cancel.","viewSettings.label":"View settings","viewSettings.lastField":"At least one field stays shown","viewSettings.locked":"Always shown","viewSettings.moved":"%1 moved to position %2 of %3","viewSettings.noMatch":"No hidden field matches \u201C%1\u201D.","viewSettings.none":"None","viewSettings.reorder":"Reorder %1","viewSettings.search":"Find a field","viewSettings.shown":"Shown (%1)","viewSettings.swimlanes":"Swim lanes","viewSettings.typeBoolean":"Checkbox","viewSettings.typeDate":"Date","viewSettings.typeDatetime":"Date and time","viewSettings.typeEmail":"Email","viewSettings.typeEntity":"Linked record","viewSettings.typeFile":"File","viewSettings.typeImage":"Image","viewSettings.typeMoney":"Money","viewSettings.typeNumber":"Number","viewSettings.typePriority":"Priority","viewSettings.typeRating":"Rating","viewSettings.typeSelect":"Select","viewSettings.typeStatus":"Status","viewSettings.typeTags":"Tags","viewSettings.typeText":"Text","viewSettings.typeTime":"Time","viewSettings.typeUrl":"URL","workspaceSwitcher.heading":"Workspaces","workspaceSwitcher.label":"Switch workspace: %1","workspaceSwitcher.labelEmpty":"Switch workspace"}),es=Object.freeze({"calendar.agenda":"agenda","calendar.allDay":"allDay","calendar.day":"day","calendar.editCancelled":"editCancelled","calendar.editCommitted":"editCommitted","calendar.editPreview":"editPreview","calendar.label":"calendar","calendar.loading":"loading","calendar.month":"month","calendar.more":"more","calendar.moveStarted":"moveStarted","calendar.new":"new","calendar.next":"next","calendar.noEvents":"noEvents","calendar.previous":"previous","calendar.resize":"resize","calendar.resizeStarted":"resizeStarted","calendar.today":"today","calendar.week":"week","calendar.weekNumber":"weekNumber","calendar.year":"year"});var Gn=null,Qn="en";function ts(i){Qn=String(i||"en")}function he(){return Qn}function ft(i){if(!Gn)return null;let e=Gn(i);if(e==null)return null;let t=String(e);return t===i?null:t}function is(i){return Object.prototype.hasOwnProperty.call(Vt,i)?Vt[i]:null}function ss(i){return Object.prototype.hasOwnProperty.call(es,i)?es[i]:null}function ve(i,e){let t=ss(i),s=ft(i)??(t?ft(t):null)??is(i)??i;return O(s,e)}function O(i,e){if(e==null)return String(i);let t=Array.isArray(e)?e:typeof e=="object"?null:[e],s=String(i).replace(/%(\d+)/g,(r,o)=>{let a=Number(o)-1,l;return t?l=t[a]:Object.prototype.hasOwnProperty.call(e,o)&&(l=e[o]),l==null?r:String(l)}),n=0;return s=s.replace(/%([A-Za-z_][\w.-]*)%/g,(r,o)=>{if(!t&&Object.prototype.hasOwnProperty.call(e,o)){let a=e[o];return a==null?r:String(a)}if(t&&n<t.length){let a=t[n];return n+=1,a==null?r:String(a)}return r}),s}var qt=new WeakMap,Xn=new WeakMap,S=class extends EventTarget{static defaults={};static cssName="";el;refs;options;#e=new AbortController;#t=!1;#i=!1;#s=!1;constructor(e,t={}){super();let s=this.constructor;this.#t=e===null;let n=U(e);if(e!==null&&!n)throw new TypeError("Component target could not be resolved");this.el=n,this.refs={};let r=Gl(s,t);Xn.set(this,{own:rs(t?.msg)?Object.freeze(je({},t.msg)):null,inherited:Ql(s)});let o=[];for(let[u,d]of Object.entries(r))/^on[a-z]/.test(u)&&typeof d=="function"&&(o.push([u.slice(2),d]),delete r[u]);r.msg&&typeof r.msg=="object"&&Object.freeze(r.msg),this.options=Object.freeze(r);for(let[u,d]of o)this.on(u,d);let a;try{a=c.scope(this.refs,()=>this.render())}catch(u){throw this.#e.abort(),u}if(this.#t){let u=R(a)?a:this.el;if(!R(u))throw this.#e.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=u}if(!R(this.el))throw this.#e.abort(),new TypeError("Component requires a root Element");let l=s.cssName;if(typeof l=="string"&&l){let u=`zx-${l}`;this.#s=!this.el.classList.contains(u),this.el.classList.add(u)}qt.set(this.el,this)}render(){return this.el??null}on(e,t){return this.addEventListener(e,t,{signal:this.#e.signal}),this}off(e,t){return this.removeEventListener(e,t),this}once(e,t){return this.addEventListener(e,t,{once:!0,signal:this.#e.signal}),this}addEvent(e,t){return this.on(e,t)}emit(e,t={},s={}){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError("Event detail must be an object");let n=Jn(e,t,{cancelable:!0});if(this.dispatchEvent(n),this.el){let r=Jn(`zx-${e}`,t,{bubbles:!0,composed:!0,cancelable:!0});this.el.dispatchEvent(r),s.honorDomCancellation&&r.defaultPrevented&&n.preventDefault()}return n}listen(e,t,s,n={}){let r=typeof n=="boolean"?{capture:n}:{...n};return e.addEventListener(t,s,{...r,signal:this.#e.signal}),this}toElement(){return this.el}msg(e,...t){let s=this.options?.lang??this.options?.language??he(),n=ss(e),r=Xn.get(this)??{own:rs(this.options?.msg)?this.options.msg:null,inherited:null},o=r.own,a=ns(o,s,e)??(n?ns(o,s,n):null)??ft(e)??(n?ft(n):null)??ns(r.inherited,s,e)??is(e)??e;return O(a,t)}destroy(){if(this.#i)return;this.#i=!0,this.#e.abort(),qt.get(this.el)===this&&qt.delete(this.el);let e=this.constructor.cssName;this.#s&&typeof e=="string"&&this.el&&this.el.classList.remove(`zx-${e}`),this.#t&&this.el&&this.el.remove()}static from(e){return qt.get(e)??null}};function Gl(i,e){let t=er(i),s={},n={},r=!1;for(let o of t)!o||typeof o!="object"||(Object.assign(s,o),o.msg&&typeof o.msg=="object"&&(r=!0,n=je(n,o.msg)));return Object.assign(s,e&&typeof e=="object"?e:{}),e?.msg&&typeof e.msg=="object"&&(r=!0,n=je(n,e.msg)),r&&(s.msg=n),s}function er(i){let e=[],t=i;for(;t&&t!==Function.prototype;)Object.prototype.hasOwnProperty.call(t,"defaults")&&e.unshift(t.defaults),t=Object.getPrototypeOf(t);return e}function rs(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function Ql(i){let e=null;for(let t of er(i))t&&typeof t=="object"&&rs(t.msg)&&(e=je(e??{},t.msg));return e?Object.freeze(e):null}function ns(i,e,t){if(!i)return null;let s=i[e]?.[t];if(s!=null&&typeof s!="object")return String(s);let n=Object.prototype.hasOwnProperty.call(i,t)?i[t]:null;return n!=null&&typeof n!="object"?String(n):null}function Jn(i,e,t){if(typeof CustomEvent=="function")return new CustomEvent(i,{...t,detail:e});let s=new Event(i,t);return Object.defineProperty(s,"detail",{configurable:!0,enumerable:!0,value:e}),s}var z=class i extends S{static cssName="field";static defaults={id:null,name:null,type:"text",label:"",description:"",value:void 0,placeholder:"",required:!1,disabled:!1,readonly:!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#e=new Map;static register(e,t){let s=String(e).trim().toLowerCase();if(!s)throw new TypeError("Field adapter type must not be empty");if(typeof t!="function")throw new TypeError("Field adapter must be a function");return i.#e.set(s,t),this}static has(e){return i.#e.has(String(e).trim().toLowerCase())}render(){let e=this.el??c("div");this.el=e;let t=String(this.options.type||"text").toLowerCase(),s=this.options.layout==="inline"?"inline":"stack";this._ownedComponents=new Set,this._ownedNodes=[],this._rootAttributes=tc(e,["data-layout","data-field-type","data-disabled","data-readonly","data-state"]),e.dataset.layout=s,e.dataset.fieldType=t,this.controlId=this.options.id?String(this.options.id):E("zx-field"),this.name=String(this.options.name??this.options.id??"");let n=`${this.controlId}-label`,r=`${this.controlId}-description`,o=`${this.controlId}-highlight`,a=c("label",{class:"zx-field__label",id:n,htmlFor:this.controlId},String(this.options.label??""),this.options.required?c("span",{class:"zx-field__required",ariaHidden:"true"}," *"):null),l=c("div",{class:"zx-field__control"}),u=c("div",{class:"zx-field__description",id:r},String(this.options.description??"")),d=c("div",{class:"zx-field__highlight",id:o,ariaLive:"polite",hidden:!0}),h=c("div",{class:"zx-field__body"},l,u,d);this._ownedNodes.push(a,h),e.append(a,h);let p=i.#e.get(t);if(p)try{this.adapter=Jl(p(this,this.options))}catch(m){let g=m instanceof Error?m.message:String(m);console.warn(`[zx.Field] Adapter "${t}" failed: ${g}`),this.adapter=ir(g,this.controlId)}else{let m=this.msg("field.unknown",t);console.warn(`[zx.Field] ${m}`),this.adapter=ir(m,this.controlId)}let f=this.adapter.el;f.id||(f.id=this.controlId);let _=this.adapter.labelTarget??($t(f)?f:ec(f))??f;return this._labelled=_,_!==f&&$t(_)&&!_.id&&(_.id=`${this.controlId}-input`),a.htmlFor=$t(_)?_.id:f.id,$t(_)||_.setAttribute("aria-labelledby",n),this._baseDescribedBy=_.getAttribute("aria-describedby")??"",l.append(f),this._descriptionId=String(this.options.description??"")?r:"",this._highlightId=o,this._highlight=d,this._syncDescription(),this.initialValue=Xl(t,this.options.value),this.adapter.set(this.initialValue,{silent:!0}),this.setDisabled(!!this.options.disabled),this.options.readonly&&this.setReadonly(!0),this.listen(f,"change",()=>{this.emit("change",{value:this.getValue()})}),e}getValue(){return this.adapter.get()}setValue(e,{silent:t=!1}={}){return this.adapter.set(e,{silent:t}),t||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(e){let t=!!e;return this.adapter.setDisabled(t),this.el.dataset.disabled=String(t),this}setReadonly(e){let t=!!e;return this.adapter.setReadonly?.(t),this.el.dataset.readonly=String(t),this}setHighlight(e,t="danger"){if(!e)return this.clearHighlight();let s=["danger","warning","success"].includes(t)?t:"danger";return this.el.dataset.state=s,this._highlight.textContent=String(e??""),this._highlight.hidden=!e,s==="danger"&&e?(this._highlight.setAttribute("role","alert"),this._labelled.setAttribute("aria-invalid","true"),this.emit("invalid",{message:String(e)})):(this._highlight.removeAttribute("role"),this._labelled.removeAttribute("aria-invalid")),this._syncDescription(!!e),this}clearHighlight(){return delete this.el.dataset.state,this._highlight.textContent="",this._highlight.hidden=!0,this._highlight.removeAttribute("role"),this._labelled.removeAttribute("aria-invalid"),this._syncDescription(!1),this}getInput(){return this.adapter.el}own(e){if(!(e instanceof S))throw new TypeError("Field.own() requires a Component");return this._ownedComponents.add(e),e}_syncDescription(e=!1){let t=[this._baseDescribedBy,this._descriptionId,e?this._highlightId:""].flatMap(s=>s.split(/\s+/)).filter(Boolean);t.length?this._labelled.setAttribute("aria-describedby",[...new Set(t)].join(" ")):this._labelled.removeAttribute("aria-describedby")}destroy(){this.adapter?.destroy?.();for(let e of this._ownedComponents??[])e.destroy();this._ownedComponents?.clear();for(let e of this._ownedNodes??[])e.remove();ic(this.el,this._rootAttributes??new Map),super.destroy()}};function os(i){if(typeof i=="number")return Number.isInteger(i)?{valid:!0,value:i}:{valid:!1,value:String(i)};let e=String(i??"").trim();if(e==="")return{valid:!0,value:""};let t=nr(e);return t!==null&&Number.isInteger(t)?{valid:!0,value:t}:{valid:!1,value:e}}function as(i){if(typeof i=="number")return Number.isFinite(i)?{valid:!0,value:i}:{valid:!1,value:String(i)};let e=String(i??"").trim();if(e==="")return{valid:!0,value:""};let t=nr(e);return t!==null?{valid:!0,value:t}:{valid:!1,value:e}}function nr(i){let e=i.replace(/[\s\u00a0]/g,"");if(!/^[+-]?[\d.,]+$/.test(e))return null;let t=/^[+-]/.test(e)?e[0]:"",s=t?e.slice(1):e;if(!/\d/.test(s))return null;let n=[...s.matchAll(/\./g)].map(l=>l.index),r=[...s.matchAll(/,/g)].map(l=>l.index),o;if(n.length&&r.length){let l=n.at(-1)>r.at(-1)?".":",",u=l==="."?",":".",d=s.lastIndexOf(l),h=s.slice(0,d),p=s.slice(d+1);if(!/^\d+$/.test(p)||!tr(h,u))return null;o=h.split(u).join("")+"."+p}else if(r.length>1||n.length>1){let l=r.length?",":".";if(!tr(s,l))return null;o=s.split(l).join("")}else r.length===1?o=s.replace(",","."):o=s;if(!/^(?:\d+(?:\.\d+)?|\.\d+)$/.test(o))return null;let a=Number(t+o);return Number.isFinite(a)?a:null}function tr(i,e){let t=i.split(e);return t.length>0&&/^\d{1,3}$/.test(t[0])&&t.slice(1).every(s=>/^\d{3}$/.test(s))}function Xl(i,e){return e!==void 0?e:i==="checkbox"?!1:""}function Jl(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 e of["get","set","focus","setDisabled"])if(typeof i[e]!="function")throw new TypeError(`Adapter is missing ${e}()`);return i}function ir(i,e){let t=c("div",{class:"zx-field__error-control",id:e,role:"alert",tabIndex:-1},i);return{el:t,get:()=>null,set:()=>{},focus:()=>t.focus(),setDisabled:()=>{}}}function $t(i){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(i.tagName)}function ec(i){for(let e of i.querySelectorAll('input:not([type="hidden"]), select, textarea'))if(!(e.hasAttribute("aria-label")||e.hasAttribute("aria-labelledby")||[...e.labels??[]].some(s=>s.textContent?.trim())))return e;return null}function tc(i,e){return new Map(e.map(t=>[t,i.getAttribute(t)]))}function ic(i,e){for(let[t,s]of e)s===null?i.removeAttribute(t):i.setAttribute(t,s)}function pt(i,e,t){let s={...e.props??{}};for(let n of Object.keys(s))(/^on[a-z]/i.test(n)||n==="content")&&delete s[n];return{name:i.name||void 0,...s,...t}}function Ht(i,e){return(t,s)=>{let n=c(i,pt(t,s,{type:i==="input"?e:void 0,placeholder:s.placeholder,required:s.required,disabled:s.disabled}));return{...ls(n),setReadonly:r=>{n.readOnly=r}}}}function ls(i){return{el:i,get:()=>i.value,set:e=>{i.value=e==null?"":String(e)},focus:()=>i.focus(),setDisabled:e=>{i.disabled=e}}}function rr(i){return(e,t)=>{let s=i==="int"?os:as,n=c("input",pt(e,t,{type:"text",inputMode:i==="int"?"numeric":"decimal",placeholder:t.placeholder,required:t.required,disabled:t.disabled}));return e.listen(n,"blur",()=>{let r=s(n.value);if(!r.valid){e.setHighlight(e.msg(`field.${i}`),"danger");return}r.value!==""&&(n.value=String(r.value)),e.clearHighlight()}),{...ls(n),get:()=>s(n.value).value,setReadonly:r=>{n.readOnly=r}}}}var sc=(i,e)=>{let t=c("input",pt(i,e,{type:"checkbox",required:e.required,disabled:e.disabled}));return{el:t,get:()=>t.checked,set:s=>{t.checked=!!s},focus:()=>t.focus(),setDisabled:s=>{t.disabled=s}}},nc=(i,e)=>{let t=c("select",pt(i,e,{required:e.required,disabled:e.disabled}));for(let[s,n]of or(e.options))t.append(c("option",{value:s},n));return ls(t)},rc=(i,e)=>{let t=c("div",{class:"zx-field__option-list",role:"radiogroup"}),s=i.controlId,n=or(e.options).map(([r,o],a)=>{let l=c("input",{type:"radio",name:s,value:r,required:!!e.required&&a===0,disabled:e.disabled});return t.append(c("label",{class:"zx-field__option"},l,c("span",{},o))),l});return{el:t,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;t.setAttribute("aria-disabled",String(r))}}},oc=(i,e)=>{let t=c("div",pt(i,e,{class:"zx-field__static",name:void 0})),s=null;return{el:t,get:()=>t.textContent,set:r=>{sr(s),s=null,r&&typeof r=="object"&&typeof r.nodeType=="number"?(s={node:r,parent:r.parentNode,next:r.nextSibling},t.replaceChildren(r)):t.textContent=r==null?"":String(r)},focus:()=>{},setDisabled:r=>{t.setAttribute("aria-disabled",String(r))},destroy:()=>sr(s)}};function sr(i){i&&(i.parent?i.parent.insertBefore(i.node,i.next?.parentNode===i.parent?i.next:null):i.node.remove())}var ac=(i,e)=>{if(typeof e.adapter!="function")throw new TypeError("Custom fields require options.adapter");return e.adapter(i,e)};function or(i){return Array.isArray(i)?i.map(e=>[String(e),String(e)]):i&&typeof i=="object"?Object.entries(i).map(([e,t])=>[e,String(t)]):[]}z.register("text",Ht("input","text"));z.register("password",Ht("input","password"));z.register("textarea",Ht("textarea","text"));z.register("checkbox",sc);z.register("int",rr("int"));z.register("float",rr("float"));z.register("select",nc);z.register("optionlist",rc);z.register("hidden",Ht("input","hidden"));z.register("html",oc);z.register("custom",ac);function xe(i,e,t){let s=ar(e).split(/\s+/).filter(Boolean);return s.length===0?i.slice():i.filter(n=>{let r=lc(n,t).map(ar);return s.every(o=>r.some(a=>a.includes(o)))})}function lc(i,e){return i===null||typeof i!="object"?[i]:!Array.isArray(e)||e.length===0?[i]:e.map(t=>typeof t=="function"?t(i):i[t])}function ar(i){return String(i??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var Kt=class extends S{static cssName="checklist";static defaults={items:[],valueKey:"ID",labelKey:"name",checkedKey:"on",search:!0,height:280,defaultChecked:!1,hideLabel:!1,load:null};render(){this._items=[],this._visibleItems=[],this._checked=new Set,this._query="",this._loadSequence=0,this._createdRoot=!1,this._active=!0,this._originalChildren=[],this._originalAttributes=new Map,this._createdRoot=this.el===null;let e=this.el??c("div");this.el=e,this._createdRoot||(this._originalChildren=Array.from(e.childNodes));for(let a of["role","aria-label","aria-labelledby","data-state"])this._originalAttributes.set(a,e.getAttribute(a));let t=this._message("checklist.label","Checklist"),s=E("zx-checklist-label"),n=this.options.hideLabel?null:c("div",{class:"zx-checklist__label",id:s},t),r=c("input",{ref:"search",class:"zx-checklist__search",type:"search",autocomplete:"off",placeholder:this._message("checklist.search","Search"),ariaLabel:this._message("checklist.search","Search checklist"),hidden:!this.options.search}),o=c("div",{ref:"list",class:"zx-checklist__list"});return o.style.maxBlockSize=`${Math.max(0,Number(this.options.height)||0)}px`,e.replaceChildren(...[n,r,o].filter(Boolean)),e.setAttribute("role","group"),n?e.setAttribute("aria-labelledby",s):e.setAttribute("aria-label",t),this.listen(r,"input",()=>this.search(r.value)),this.listen(o,"change",a=>{let l=a.target;if(!l?.matches?.('input[type="checkbox"][data-index]'))return;let u=this._visibleItems[Number(l.dataset.index)];if(u===void 0)return;let d=this._itemValue(u);l.checked?this._checked.add(d):this._checked.delete(d),this.emit("change",{values:this.getValues()})}),this._replaceItems(this.options.items),typeof this.options.load=="function"&&queueMicrotask(()=>{this._active&&this.reload().catch(()=>{})}),e}setItems(e){return this._replaceItems(e),this}getValues(){return this._items.map(e=>this._itemValue(e)).filter(e=>this._checked.has(e))}setValues(e){let t=new Set(e==null?[]:Array.from(e)),s=new Set(this._items.map(n=>this._itemValue(n)).filter(n=>t.has(n)));return this._replaceChecked(s),this}checkAll(){return this._replaceChecked(new Set(this._items.map(e=>this._itemValue(e)))),this}uncheckAll(){return this._replaceChecked(new Set),this}search(e){this._query=String(e??"");let t=this.refs.search;return t.value!==this._query&&(t.value=this._query),this._visibleItems=xe(this._items,this._query,[this.options.labelKey]),this._renderItems(),this}async reload(){if(!this._active||typeof this.options.load!="function")return this;let e=++this._loadSequence;this.el.setAttribute("data-state","loading"),this.refs.list.setAttribute("aria-busy","true");try{let t=await this.options.load();if(e!==this._loadSequence)return this;this._replaceItems(t),this.emit("loaded",{items:this._items.slice()})}finally{e===this._loadSequence&&(this.el.removeAttribute("data-state"),this.refs.list.setAttribute("aria-busy","false"))}return this}destroy(){this._active=!1,this._loadSequence+=1;let e=this.el;if(!this._createdRoot&&e){e.replaceChildren(...this._originalChildren);for(let[t,s]of this._originalAttributes)s===null?e.removeAttribute(t):e.setAttribute(t,s)}super.destroy()}_replaceItems(e){this._items=Array.isArray(e)?e.slice():[],this._checked=new Set(this._items.filter(t=>!!this._initialChecked(t)).map(t=>this._itemValue(t))),this._visibleItems=xe(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let e=this._visibleItems.map((t,s)=>{let n=E("zx-checklist-item"),r=c("input",{type:"checkbox",id:n,checked:this._checked.has(this._itemValue(t)),dataset:{index:s}});return c("label",{class:"zx-checklist__item",for:n},r,c("span",{},this._itemLabel(t)))});e.length===0&&e.push(c("div",{class:"zx-checklist__empty",role:"status"},this._message("checklist.empty","No matches"))),this.refs.list.replaceChildren(...e)}_replaceChecked(e){cc(this._checked,e)||(this._checked=e,this._renderItems(),this.emit("change",{values:this.getValues()}))}_itemValue(e){return this._read(e,this.options.valueKey)}_itemLabel(e){return String(this._read(e,this.options.labelKey)??"")}_initialChecked(e){let t;return typeof this.options.checkedKey=="function"?t=this.options.checkedKey(e):e!==null&&typeof e=="object"&&(t=e[this.options.checkedKey]),t??this.options.defaultChecked}_read(e,t){return typeof t=="function"?t(e):e===null||typeof e!="object"?e:e[t]}_message(e,t){let s=this.msg(e);return s===e?t:s}};function cc(i,e){return i.size===e.size&&Array.from(i).every(t=>e.has(t))}function lr(){z.register("checklist",(i,e)=>{let t=i.own(new Kt(null,{hideLabel:!0,...e.props??{}})),s=!1,n=!1,r=()=>{t.el.setAttribute("aria-disabled",String(s));for(let o of t.el.querySelectorAll("input, button, select, textarea"))o.disabled=s};return i.listen(t.el,"change",o=>o.stopImmediatePropagation()),t.on("change",o=>{n||i.emit("change",{value:o.detail.values})}),t.on("loaded",r),{el:t.el,get:()=>t.getValues(),set:o=>{n=!0;try{t.setValues(Array.isArray(o)?o:[])}finally{n=!1}r()},focus:()=>{(t.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])")??t.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus()},setDisabled:o=>{s=!!o,r()}}})}var uc=new Set(["Shift","Control","Alt","Meta","AltGraph","CapsLock","Fn","OS"]),Ut=class extends S{static cssName="code-editor";static defaults={value:"",name:"",language:"text",label:"Code editor",placeholder:"",rows:12,indent:" ",wrap:"off",spellcheck:!1,readOnly:!1,disabled:!1,status:!0};render(){this._createdRoot=this.el===null;let e=this.el??c("div");this.el=e,this._initialChildren=this._createdRoot?[]:[...e.childNodes],this._initialAttributes=new Map(["data-language","data-readonly","data-disabled"].map(t=>[t,e.getAttribute(t)])),this._language=cr(this.options.language),this._languageLabel=c("span",{class:"zx-code-editor__language"},this._language),this._position=c("span",{class:"zx-code-editor__position",role:"status",ariaLive:"polite"}),this._header=c("div",{class:"zx-code-editor__header"},this._languageLabel,this.options.status?this._position:null),this._input=c("textarea",{class:"zx-code-editor__input",name:this.options.name?String(this.options.name):void 0,ariaLabel:String(this.options.label??"Code editor"),placeholder:String(this.options.placeholder??""),rows:pc(this.options.rows),wrap:mc(this.options.wrap),spellcheck:!!this.options.spellcheck,readOnly:!!this.options.readOnly,disabled:!!this.options.disabled,autocomplete:"off",autocapitalize:"off"}),this._input.value=String(this.options.value??""),e.dataset.language=this._language,e.dataset.readonly=String(!!this.options.readOnly),e.dataset.disabled=String(!!this.options.disabled),e.replaceChildren(this._header,this._input),this._tabReleased=!1,this.listen(this._input,"keydown",t=>this._handleKeydown(t)),this.listen(this._input,"blur",()=>{this._tabReleased=!1}),this.listen(this._input,"input",()=>{this._updatePosition(),this.emit("input",{value:this.getValue()})}),this.listen(this._input,"change",()=>this.emit("change",{value:this.getValue()}));for(let t of["click","keyup","select","focus"])this.listen(this._input,t,()=>this._updatePosition());return this._updatePosition(),e}getValue(){return this._input.value}setValue(e,{silent:t=!1}={}){let s=String(e??"");return this._input.value===s?this:(this._input.value=s,this._updatePosition(),t||this.emit("change",{value:s}),this)}setLanguage(e){return this._language=cr(e),this.el.dataset.language=this._language,this._languageLabel.textContent=this._language,this}focus(){return this._input.focus(),this}enable(){return this._input.disabled=!1,this.el.dataset.disabled="false",this}disable(){return this._input.disabled=!0,this.el.dataset.disabled="true",this}setReadOnly(e){return this._input.readOnly=!!e,this.el.dataset.readonly=String(!!e),this}_handleKeydown(e){if(e.isComposing||uc.has(e.key))return;if(e.key==="Escape"){this._tabReleased=!0;return}let t=this._tabReleased;if(this._tabReleased=!1,t||e.key!=="Tab"||e.altKey||e.ctrlKey||e.metaKey||this._input.readOnly||this._input.disabled)return;let s=String(this.options.indent??" ");if(!s)return;e.preventDefault();let n=dc(this._input.value,this._input.selectionStart??0,this._input.selectionEnd??0,s,e.shiftKey);n.value!==this._input.value&&(this._input.value=n.value,this._input.setSelectionRange(n.start,n.end),this._updatePosition(),this.emit("input",{value:this.getValue()}))}_updatePosition(){if(!this.options.status)return;let e=hc(this._input.value,this._input.selectionStart??0,this._input.selectionEnd??0);this._position.textContent=e.lines>1?`Ln ${e.line}, Col ${e.column} \xB7 ${e.lines} lines selected`:`Ln ${e.line}, Col ${e.column}`}destroy(){if(!this._createdRoot){this.el.replaceChildren(...this._initialChildren);for(let[e,t]of this._initialAttributes)t===null?this.el.removeAttribute(e):this.el.setAttribute(e,t)}super.destroy()}};function dc(i,e,t,s=" ",n=!1){let r=String(i??""),o=String(s??""),a=Yt(e,r.length),l=Yt(t,r.length);if(!o)return{value:r,start:a,end:l};if(a===l&&!n)return{value:r.slice(0,a)+o+r.slice(l),start:a+o.length,end:a+o.length};let u=r.lastIndexOf(`
2
2
  `,Math.max(0,a-1))+1,d=r.indexOf(`
3
- `,c);d<0&&(d=r.length);let f=r.slice(u,d).split(`
4
- `),p=0,_=0,m=f.map((b,y)=>{if(!n)return _+=o.length,o+b;let A=ol(b,o);return y===0&&(p=A),_-=A,b.slice(A)}).join(`
5
- `),g=n?Math.max(u,a-Math.min(p,a-u)):a+o.length;return{value:r.slice(0,u)+m+r.slice(d),start:g,end:Math.max(g,c+_)}}function rl(i,t,e=t){let s=String(i??""),n=Ne(t,s.length),r=Ne(e,s.length),o=s.slice(0,n);return{line:o.split(`
3
+ `,l);d<0&&(d=r.length);let p=r.slice(u,d).split(`
4
+ `),f=0,_=0,m=p.map((b,y)=>{if(!n)return _+=o.length,o+b;let A=fc(b,o);return y===0&&(f=A),_-=A,b.slice(A)}).join(`
5
+ `),g=n?Math.max(u,a-Math.min(f,a-u)):a+o.length;return{value:r.slice(0,u)+m+r.slice(d),start:g,end:Math.max(g,l+_)}}function hc(i,e,t=e){let s=String(i??""),n=Yt(e,s.length),r=Yt(t,s.length),o=s.slice(0,n);return{line:o.split(`
6
6
  `).length,column:n-o.lastIndexOf(`
7
7
  `),lines:s.slice(n,r).split(`
8
- `).length}}function ol(i,t){return i.startsWith(t)?t.length:t===" "?i.startsWith(" ")?1:Math.min(/^ +/.exec(i)?.[0].length??0,2):Math.min(/^\s+/.exec(i)?.[0].length??0,t.length)}function vn(i){let t=String(i??"text").trim().toLowerCase();return/^[a-z0-9][a-z0-9+_.-]*$/.test(t)?t:"text"}function al(i){let t=Number(i);return Number.isFinite(t)?Math.max(2,Math.min(100,Math.round(t))):12}function ll(i){return["off","soft","hard"].includes(String(i))?i:"off"}function Ne(i,t){let e=Number(i);return Math.max(0,Math.min(t,Number.isFinite(e)?Math.round(e):0))}function Sn(){S.register("code",(i,t)=>{let e=i.own(new Me(null,{label:t.label?String(t.label):"Code editor",placeholder:t.placeholder,readOnly:!!t.props?.readOnly,disabled:!!t.disabled,...t.props??{},value:t.value})),s=!1;return e.on("input",n=>{s||i.emit("change",{value:n.detail.value})}),{el:e.el,get:()=>e.getValue(),set:n=>{s=!0;try{e.setValue(n,{silent:!0})}finally{s=!1}},focus:()=>e.focus(),setDisabled:n=>n?e.disable():e.enable()}})}var An=["January","February","March","April","May","June","July","August","September","October","November","December"],kn=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Cn=/%[demYyHMSaAbBs]/g;function I(i,t){return!(i instanceof Date)||Number.isNaN(i.getTime())?"":String(t).replace(Cn,e=>{switch(e){case"%d":return jt(i.getDate());case"%e":return String(i.getDate());case"%m":return jt(i.getMonth()+1);case"%Y":return String(i.getFullYear()).padStart(4,"0");case"%y":return jt(i.getFullYear()%100);case"%H":return jt(i.getHours());case"%M":return jt(i.getMinutes());case"%S":return jt(i.getSeconds());case"%a":return zn("weekday",i.getDay(),kn[i.getDay()]);case"%A":return Vi("weekday",i.getDay(),kn[i.getDay()]);case"%b":return zn("month",i.getMonth(),An[i.getMonth()]);case"%B":return Vi("month",i.getMonth(),An[i.getMonth()]);case"%s":return String(Math.floor(i.getTime()/1e3));default:return e}})}function rt(i,t){let e=[],s="^",n=0;for(let _ of String(t).matchAll(Cn)){s+=Dn(String(t).slice(n,_.index));let m=_[0],g=cl(m);if(g===null)return null;s+=`(${g})`,e.push(m),n=_.index+m.length}s+=Dn(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)=>{o[_]=Number(r[m+1])}),o["%s"]!==void 0){let _=o["%s"]*1e3,m=new Date(_);return Number.isNaN(m.getTime())?null:m}let a=o["%Y"]??ul(o["%y"])??1970,c=(o["%m"]??1)-1,u=o["%d"]??o["%e"]??1,d=o["%H"]??0,h=o["%M"]??0,f=o["%S"]??0,p=new Date(0);return p.setHours(0,0,0,0),p.setFullYear(a,c,u),p.setHours(d,h,f,0),Number.isNaN(p.getTime())||o["%Y"]!==void 0&&p.getFullYear()!==o["%Y"]||o["%y"]!==void 0&&p.getFullYear()%100!==o["%y"]||o["%m"]!==void 0&&p.getMonth()!==c||o["%d"]!==void 0&&p.getDate()!==u||o["%e"]!==void 0&&p.getDate()!==u||o["%H"]!==void 0&&p.getHours()!==d||o["%M"]!==void 0&&p.getMinutes()!==h||o["%S"]!==void 0&&p.getSeconds()!==f?null:p}function In(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 P(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 zt(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 Oe(i=ht()){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 jt(i){return String(i).padStart(2,"0")}function Vi(i,t,e){let s=`date.${i}.${t}`,n=nt(s);return n===s?e:n}function zn(i,t,e){let s=`date.${i}.short.${t}`,n=nt(s);return n!==s?n:Vi(i,t,e).slice(0,3)}function cl(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 ul(i){if(i!==void 0)return i>=69?1900+i:2e3+i}function Dn(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var En=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),dl=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),Tn=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"}),hl=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"}),qi=new Map;function Mn(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(Tn,s))return{provider:"fa",name:n,style:Tn[s],classes:null}}return{provider:null,name:t,style:null,classes:null}}function $i(i,t={}){let{style:e="solid",family:s="classic",fixedWidth:n=!1,translate:r=!0}=t,o=String(i).replace(/^fa-/,""),a=r?hl[o]??o:o,c=[],u=dl[s];return u&&c.push(u),c.push(En[e]??En.solid,`fa-${a}`),n&&c.push("fa-fw"),c}function Bi(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 Nn(i){let t=Bi(i),e=qi.get(t);if(e)return e;let s=new Promise((n,r)=>{let o=new URL(t,document.baseURI).href,a=[...document.scripts].find(u=>u.src===o);if(a&&globalThis.FontAwesomeKitConfig){n();return}let c=a??document.createElement("script");c.addEventListener("load",()=>n(),{once:!0}),c.addEventListener("error",()=>{qi.delete(t),r(new Error(`Font Awesome kit failed to load: ${t}`))},{once:!0}),!a&&(c.src=t,c.async=!0,c.crossOrigin="anonymous",document.head.append(c))});return qi.set(t,s),s}var Rn="http://www.w3.org/2000/svg",Ln="0 0 24 24",fl=1.75,pl=1,C=i=>[Ln,i,"stroke"];var Pn=Object.freeze({"arrow-up-wide-short":C("M3 8l4-4 4 4M7 4v16M11 12h10M11 16h7M11 20h4"),"arrow-down-wide-short":C("M3 16l4 4 4-4M7 20V4M11 4h10M11 8h7M11 12h4"),"chevron-down":C("M6 9l6 6 6-6"),"chevron-up":C("M18 15l-6-6-6 6"),"chevron-left":C("M15 18l-6-6 6-6"),"chevron-right":C("M9 18l6-6-6-6"),check:C("M20 6 9 17l-5-5"),x:C("M18 6 6 18M6 6l12 12"),plus:C("M5 12h14M12 5v14"),minus:C("M5 12h14"),search:C("M21 21l-4.34-4.34M3 11a8 8 0 1 0 16 0a8 8 0 1 0-16 0z"),calendar:C("M8 2v3M16 2v3M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM3 9h18"),clock:C("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 6v6l4 2"),trash:C("M10 11v6M14 11v6M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"),gear:C("M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915M9 12a3 3 0 1 0 6 0a3 3 0 1 0-6 0z"),eye:C("M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0M9 12a3 3 0 1 0 6 0a3 3 0 1 0-6 0z"),lock:C("M5 11h14a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2zM7 11V7a5 5 0 0 1 10 0v4"),reload:C("M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8M21 3v5h-5"),list:C("M3 5h.01M3 12h.01M3 19h.01M8 5h13M8 12h13M8 19h13"),filter:C("M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"),dots:C("M11 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM18 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM4 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0z"),info:C("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 16v-4M12 8h.01"),warning:C("M21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3M12 9v4M12 17h.01"),error:C("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 8V12M12 16H12.01"),success:C("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 9l-5.5 5.5L8 12"),upload:C("M12 3v12M17 8l-5-5-5 5M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"),drag:C("M8 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0z"),star:C("M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"),heart:C("M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"),tag:C("M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42zM7 7.5a.5 .5 0 1 0 1 0a.5 .5 0 1 0-1 0z"),folder:C("M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"),"folder-open":C("M6 14l1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"),file:C("M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2zM14 2v5a1 1 0 0 0 1 1h5"),copy:C("M10 8h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-10a2 2 0 0 1-2-2v-10a2 2 0 0 1 2-2zM4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"),square:C("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2z"),code:C("M18 16l4-4-4-4M6 8l-4 4 4 4M14.5 4l-5 16"),book:C("M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20")}),ml=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list"}),_l=Object.create(null),ft={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function Hi(){return{...ft}}function Yi(i={}){for(let t of["provider","style","family","fixedWidth","kit"])i[t]!==void 0&&(ft[t]=i[t]);return Hi()}function jn(i={}){return Yi({...i,provider:"fontawesome"})}async function Ui(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 Yi({...n,kit:Bi(e)}),await Nn(e),s?jn():Hi()}function w(i,t={}){let e=Mn(i);if(e.classes)return Ki(e.classes,t);let s=ml[e.name]??e.name;return e.provider==="builtin"?On(s,t):e.provider==="fa"?Ki($i(s,{style:e.style??t.style??ft.style,family:t.family??ft.family,fixedWidth:t.fixedWidth??ft.fixedWidth}),t):ft.provider==="fontawesome"?Ki($i(s,{style:t.style??ft.style,family:t.family??ft.family,fixedWidth:t.fixedWidth??ft.fixedWidth}),t):On(s,t)}function On(i,t){let e=_l[i]??Pn[i];if(!e){if(t.strict)throw new RangeError(`Unknown icon: ${i}`);return wl(i),yl(i,t)}let[s,n,r="fill"]=e,o=Vn(s,r,t),a=document.createElementNS(Rn,"path");return a.setAttribute("d",n),o.append(a),o}function Vn(i,t,e){let{size:s=16}=e,n=document.createElementNS(Rn,"svg");return n.setAttribute("class",$n("zx-icon",e.class)),n.setAttribute("viewBox",i),n.setAttribute("width",String(s)),n.setAttribute("height",String(s)),t==="stroke"?(n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width",gl(i,s)),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round")):n.setAttribute("fill","currentColor"),n.setAttribute("focusable","false"),qn(n,e.label??null),n}function gl(i,t){let[,,e,s]=i.trim().split(/[\s,]+/).map(Number),n=Math.max(e,s)||24,r=fl*n/24,o=typeof t=="number"?t:/^\d*\.?\d+(px)?$/.test(String(t).trim())?parseFloat(String(t)):NaN;return o>0&&(r=Math.max(r,pl*n/o)),String(Math.round(r*1e3)/1e3)}var bl=Ln;function yl(i,t){let e=Vn(bl,"stroke",t);return e.setAttribute("data-zx-icon-missing",i),e}var Fn=new Set;function wl(i){Fn.has(i)||(Fn.add(i),console.warn(`[zx.icon] Unknown icon "${i}" \u2014 rendered an empty placeholder. Add it with registerIcons(), or render Font Awesome with useFontAwesome().`))}function Ki(i,t){let{size:e=16}=t,s=document.createElement("i");return s.className=$n("zx-icon",...i,t.class),s.style.fontSize=typeof e=="number"?`${e}px`:String(e),qn(s,t.label??null),s}function qn(i,t){if(t===null){i.setAttribute("aria-hidden","true");return}i.setAttribute("role","img"),i.setAttribute("aria-label",t)}function $n(...i){return i.flat().filter(Boolean).join(" ")}var xl=5,Fe=class extends v{static cssName="time-picker";static defaults={value:null,seconds:!1,step:5,clock:!0};render(){let t=this.el??l("div");this.el=t;let e=Bn(this.options.value);this._value=e,this._display=e??{h:0,m:0,s:0},this._inputs=[],this._clockOpen=!1,this._clockUnit="h",this._clock=null;let s=l("div",{class:"zx-time-picker__segments",role:"group",ariaLabel:this._message("timePicker.label","Time")});if(this._content=s,this._addSpin(s,"h",this._message("timePicker.hour","Hour"),23),s.append(l("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"m",this._message("timePicker.minute","Minute"),59),this.options.seconds&&(s.append(l("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"s",this._message("timePicker.second","Second"),59)),t.append(s),this.options.clock){let n=D("zx-time-picker-clock");s.append(l("button",{ref:"clockToggle",class:"zx-icon-btn zx-time-picker__clock-toggle",type:"button",ariaLabel:this._message("timePicker.clock","Pick the time on a clock"),ariaExpanded:"false",ariaControls:n},w("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=Bn(t);return this._value=s,this._display=s??{h:0,m:0,s:0},this._writeInputs(),!e&&s&&this.emit("change",{time:{...s}}),this}openClock(t="h"){return this._clock?(this._clockOpen=!0,this._clockUnit=t==="m"?"m":"h",this._syncClock(),this):this}closeClock(){return this._clock?(this._clockOpen=!1,this._syncClock(),this):this}toggleClock(){return this._clockOpen?this.closeClock():this.openClock("h")}destroy(){this._content?.remove(),this._clock?.remove(),this._clock=null,super.destroy()}_addSpin(t,e,s,n){let r=l("input",{class:"zx-time-picker__spin",type:"text",role:"spinbutton",inputMode:"numeric",maxLength:2,autocomplete:"off",ariaLabel:s,ariaValueMin:"0",ariaValueMax:String(n),dataset:{segment:e}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"keydown",o=>this._onKeydown(o,e,n)),this.listen(r,"input",()=>this._onInput(r,e,n)),this.listen(r,"blur",()=>this._commitFromInputs())}_onKeydown(t,e,s){if(t.key!=="ArrowUp"&&t.key!=="ArrowDown")return;t.preventDefault();let n=t.key==="ArrowUp"?1:-1,r=e==="m"?kl(this.options.step):1,o=Vt(t.currentTarget.value,0,s),a=s+1,c=(o+n*r+a*r)%a;t.currentTarget.value=Dt(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=Dt(Vt(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]=Vt(s.value,0,r)}let e=!this._value||!zl(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=Dt(this._display[e]),t.setAttribute("aria-valuenow",String(this._display[e])),t.setAttribute("aria-valuetext",t.value)}this._syncClock()}_buildClock(t){let e=l("div",{class:"zx-time-picker__clock",id:t,hidden:!0},l("div",{class:"zx-time-picker__clock-head"},l("button",{ref:"headHour",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:this._message("timePicker.selectHour","Select the hour"),dataset:{unit:"h"}}),l("span",{class:"zx-time-picker__clock-colon",ariaHidden:"true"},":"),l("button",{ref:"headMinute",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:this._message("timePicker.selectMinutes","Select the minutes"),dataset:{unit:"m"}})),l("div",{ref:"dial",class:"zx-time-picker__dial",role:"radiogroup"},l("span",{ref:"hand",class:"zx-time-picker__hand",ariaHidden:"true"}),l("span",{class:"zx-time-picker__pivot",ariaHidden:"true"})));return this.listen(this.refs.headHour,"click",()=>this.openClock("h")),this.listen(this.refs.headMinute,"click",()=>this.openClock("m")),this.listen(this.refs.dial,"click",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=Dt(this._display.h),this.refs.headMinute.textContent=Dt(this._display.m),this.refs.headHour.setAttribute("aria-pressed",String(t)),this.refs.headMinute.setAttribute("aria-pressed",String(!t)),this.refs.dial.setAttribute("aria-label",t?this._message("timePicker.hour","Hour"):this._message("timePicker.minutes","Minutes")),!this._clockOpen)return;let e=t?this._display.h:this._display.m,s=t?vl():Sl(),n=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(n.length!==s.length||this.refs.dial.dataset.unit!==this._clockUnit){for(let a of n)a.remove();this.refs.dial.dataset.unit=this._clockUnit,this.refs.dial.append(...s.map(a=>this._buildMark(a,e)))}else s.forEach((a,c)=>this._syncMark(n[c],a,e));let r=t&&!Al(e)?"inner":"outer",o=t?e%12*30:e*6;this.refs.hand.dataset.ring=r,this.refs.hand.style.setProperty("--zx-clock-angle",`${o}deg`)}_buildMark(t,e){let s=l("button",{class:"zx-time-picker__mark",type:"button",role:"radio",dataset:{value:String(t.value),ring:t.ring}},t.label);return s.style.setProperty("--zx-clock-angle",`${t.angle}deg`),this._syncMark(s,t,e),s}_syncMark(t,e,s){let n=e.value===s;t.setAttribute("aria-checked",String(n)),t.tabIndex=n?0:-1}_message(t,e){let s=this.msg(t);return s===t?e:s}};function vl(){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:Dt(e),angle:t*30,ring:"inner"})}return i}function Sl(){let i=[];for(let t=0;t<60;t+=xl)i.push({value:t,label:Dt(t),angle:t*6,ring:"outer"});return i}function Al(i){return i>=1&&i<=12}function Bn(i){return i instanceof Date&&!Number.isNaN(i.getTime())?{h:i.getHours(),m:i.getMinutes(),s:i.getSeconds()}:!i||typeof i!="object"?null:{h:Vt(i.h,0,23),m:Vt(i.m,0,59),s:Vt(i.s,0,59)}}function Vt(i,t,e){let s=Number.parseInt(String(i??""),10);return Number.isFinite(s)?Math.max(t,Math.min(e,s)):t}function kl(i){let t=Math.round(Number(i));return Number.isFinite(t)&&t>0&&t<=59?t:5}function Dt(i){return String(i).padStart(2,"0")}function zl(i,t){return i.h===t.h&&i.m===t.m&&i.s===t.s}var qt=class extends v{static cssName="date-picker";static defaults={value:null,min:null,max:null,weekStart:1,showWeekNumbers:!1,time:!1};render(){let t=this.el??l("div");this._min=X(Re(this.options.min)),this._max=X(Re(this.options.max)),this._value=this._normalizeValue(Re(this.options.value)),this._focused=X(this._value)??this._clampFocus(X(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=Dl(this.options.weekStart),this._quickOpen=!1,this._timePicker=null;let e=l("div",{class:"zx-date-picker__surface"},l("div",{class:"zx-date-picker__header"},l("button",{ref:"previous",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.previousMonth","Previous month")},w("chevron-left")),l("button",{ref:"heading",class:"zx-date-picker__heading",type:"button",ariaExpanded:"false","aria-haspopup":"grid"}),l("button",{ref:"next",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.nextMonth","Next month")},w("chevron-right"))),l("div",{ref:"quickPanel",class:"zx-date-picker__quick",hidden:!0},l("div",{class:"zx-date-picker__quick-header"},l("button",{ref:"quickPrevious",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.previousYear","Previous year")},w("chevron-left")),l("span",{ref:"quickYear",class:"zx-date-picker__quick-year",ariaLive:"polite"}),l("button",{ref:"quickNext",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.nextYear","Next year")},w("chevron-right"))),l("div",{ref:"quickGrid",class:"zx-date-picker__quick-grid",role:"grid"})),l("table",{ref:"grid",class:"zx-date-picker__grid",role:"grid",ariaLabel:this._message("datePicker.calendar","Calendar")},l("thead",{ref:"weekdays"}),l("tbody",{ref:"days"})));return this._content=e,t.append(e),this.listen(this.refs.previous,"click",()=>this._pageMonth(-1)),this.listen(this.refs.next,"click",()=>this._pageMonth(1)),this.listen(this.refs.heading,"click",()=>this._toggleQuickPick()),this.listen(this.refs.quickPrevious,"click",()=>this._stepQuickYear(-1)),this.listen(this.refs.quickNext,"click",()=>this._stepQuickYear(1)),this.listen(this.refs.quickGrid,"click",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 Fe(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 Wi(this._value)}set(t,{silent:e=!1}={}){let s=this._normalizeValue(Re(t));return this._value=s,s&&(this._focused=X(s),this._viewYear=s.getFullYear(),this._viewMonth=s.getMonth()),this._timePicker?.set(s,{silent:!0}),this._renderCalendar(),e||this.emit("change",{date:Wi(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=X(e);return this._min&&s<this._min&&Kn(e,this._min),this._max&&s>this._max&&Kn(e,this._max),e}_clampFocus(t){return this._min&&t<this._min?new Date(this._min.getTime()):this._max&&t>this._max?new Date(this._max.getTime()):t}_renderWeekdays(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-picker__week-heading",scope:"col",ariaLabel:this._message("datePicker.weekNumber","Week number")},"#"));let e=new Date(2023,0,1);for(let s=0;s<7;s+=1){let n=E(e,(this._weekStart+s)%7);t.append(l("th",{scope:"col",ariaLabel:I(n,"%A")},I(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=I(t,"%B %Y"),this.refs.heading.setAttribute("aria-label",this._message("datePicker.chooseMonthYear","Choose month and year, %1",I(t,"%B %Y")));let n=[];for(let r=0;r<6;r+=1){let o=E(s,r*7),a=l("tr");this.options.showWeekNumbers&&a.append(l("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:this._message("datePicker.week","Week %1",Hn(o))},String(Hn(o))));for(let c=0;c<7;c+=1){let u=E(o,c),d=!!(this._value&&P(u,this._value)),h=!this._inRange(u),f=l("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:P(u,this._focused)?0:-1,ariaSelected:String(d),ariaDisabled:String(h),ariaCurrent:P(u,new Date)?"date":null,ariaLabel:`${I(u,"%e")} ${I(u,"%B %Y")}`,dataset:{date:I(u,"%Y-%m-%d"),otherMonth:u.getMonth()===this._viewMonth?null:"true"}},I(u,"%e"));a.append(l("td",{role:"presentation"},f))}n.push(a)}this.refs.days.replaceChildren(...n),this._quickOpen&&this._renderQuickPick()}_onDayClick(t){let e=t.target?.closest?.("[data-date]");if(!e||!this.refs.days.contains(e))return;let s=rt(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=rt(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=zt(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=zt(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=X(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=X(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._timePicker?.set(e,{silent:!0}),this._renderCalendar(),n&&this._emitMonthChange(),this.emit("change",{date:Wi(e)})}_pageMonth(t){this._closeQuickPick();let e=zt(this._focused,t);this._focused=X(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._renderCalendar(),this._emitMonthChange()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_toggleQuickPick(){if(this._quickOpen){this._closeQuickPick(),this.refs.heading.focus();return}this._quickOpen=!0,this.refs.quickPanel.hidden=!1,this.refs.heading.setAttribute("aria-expanded","true"),this._renderQuickPick(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_closeQuickPick(){this._quickOpen&&(this._quickOpen=!1,this.refs.quickPanel.hidden=!0,this.refs.heading.setAttribute("aria-expanded","false"))}_renderQuickPick(){this.refs.quickYear.textContent=String(this._viewYear);let t=[];for(let e=0;e<12;e+=1){let s=new Date(this._viewYear,e,1);t.push(l("button",{class:"zx-date-picker__quick-month",type:"button",role:"gridcell",tabindex:e===this._viewMonth?0:-1,ariaSelected:String(e===this._viewMonth),dataset:{month:e}},I(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=X(e),this._viewMonth=t,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(t){let e=X(t);return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_buttonForDate(t){return this.refs.days.querySelector(`[data-date="${I(t,"%Y-%m-%d")}"]`)}_message(t,e,...s){let n=this.msg(t,...s);return n===t?O(e,s):n}};function Re(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function X(i){return i?new Date(i.getFullYear(),i.getMonth(),i.getDate()):null}function Wi(i){return i?new Date(i.getTime()):null}function Kn(i,t){i.setFullYear(t.getFullYear(),t.getMonth(),t.getDate())}function Dl(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:Oe()}function Hn(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 je=class extends qt{static cssName="month-picker";static defaults={value:null,min:null,max:null};constructor(t,e={}){super(t,e)}render(){let t=this.el??l("div");this._min=Pe(Le(this.options.min)),this._max=Pe(Le(this.options.max)),this._value=this._normalizeMonth(Le(this.options.value));let e=this._value??Pe(new Date);this._year=e.getFullYear(),this._focusedMonth=e.getMonth();let s=l("div",{class:"zx-month-picker__surface"},l("div",{class:"zx-month-picker__header"},l("button",{ref:"previousYear",class:"zx-month-picker__nav",type:"button",ariaLabel:this._message("monthPicker.previousYear","Previous year")},w("chevron-left")),l("span",{ref:"year",class:"zx-month-picker__year",ariaLive:"polite"}),l("button",{ref:"nextYear",class:"zx-month-picker__nav",type:"button",ariaLabel:this._message("monthPicker.nextYear","Next year")},w("chevron-right"))),l("div",{ref:"grid",class:"zx-month-picker__grid",role:"grid",ariaLabel:this._message("monthPicker.chooseMonth","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(Le(t)),this._value&&(this._year=this._value.getFullYear(),this._focusedMonth=this._value.getMonth()),this._renderMonths(),e||this.emit("change",{date:this.get()}),this}focus(){return this._button(this._focusedMonth)?.focus(),this}destroy(){this._content?.remove(),super.destroy()}_normalizeMonth(t){if(!t)return null;let e=Pe(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&&Cl(s,this._value));t.push(l("button",{class:"zx-month-picker__month",type:"button",role:"gridcell",tabindex:e===this._focusedMonth?0:-1,ariaSelected:String(n),ariaDisabled:String(!this._inRange(s)),ariaLabel:I(s,"%B %Y"),dataset:{month:e}},I(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 Le(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function Pe(i){return i?new Date(i.getFullYear(),i.getMonth(),1):null}function Cl(i,t){return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()}function Yn(){S.register("month",(i,t)=>{let e=i.own(new je(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 Il=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function vt(i,t,e={}){if(!(i instanceof Element)||!(t instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let s=Il.has(e.placement)?e.placement:"bottom-start",n=Number(e.offset??4),r=e.flip??!0,o=e.matchWidth??!1,a=i.getAttribute("style"),c=t.getAttribute("style"),u=t.getAttribute("popover"),d=!1,h=null,f=()=>{},p=()=>{};if(t.setAttribute("popover","manual"),typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a")){let m=`--${D("zx-a")}`;i.style.setProperty("anchor-name",m),t.style.position="fixed",t.style.inset="auto",t.style.margin="0",t.style.setProperty("position-anchor",m);let g=El(s,getComputedStyle(i).direction==="rtl");t.style.setProperty("position-area",g),t.style.setProperty("inset-area",g),t.style.setProperty("position-try-fallbacks",r?"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,`${n}px`),f=()=>{o&&(t.style.minWidth=`${i.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(h=new ResizeObserver(f),h.observe(i))}else t.style.position="fixed",t.style.inset="auto",t.style.margin="0",f=()=>Tl(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"&&(h=new ResizeObserver(f),h.observe(i)),p=()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)};return Ml(t),f(),{update(){d||f()},destroy(){d||(d=!0,h?.disconnect(),p(),Nl(t),Zi(i,"style",a),Zi(t,"style",c),Zi(t,"popover",u))}}}function El(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 Tl(i,t,{placement:e,offset:s,flip:n,matchWidth:r}){let o=i.getBoundingClientRect();r&&(t.style.minWidth=`${o.width}px`);let a=t.getBoundingClientRect(),c=document.documentElement.clientWidth||window.innerWidth,u=document.documentElement.clientHeight||window.innerHeight,d=e,h=Un(e),f=o.bottom+s,p=o.top-s-a.height,_=o.right+s,m=o.left-s-a.width;n&&(h==="bottom"&&f+a.height>u&&p>=0?d=Ve(e,"bottom","top"):h==="top"&&p<0&&f+a.height<=u?d=Ve(e,"top","bottom"):h==="right"&&_+a.width>c&&m>=0?d=Ve(e,"right","left"):h==="left"&&m<0&&_+a.width<=c&&(d=Ve(e,"left","right")));let g=Un(d),b,y;if(g==="bottom"||g==="top"){let A=getComputedStyle(i).direction==="rtl";d.endsWith("-end")?b=A?o.left:o.right-a.width:d.endsWith("-start")?b=A?o.right-a.width:o.left:b=o.left+(o.width-a.width)/2,y=g==="bottom"?f:p}else b=g==="right"?_:m,d.endsWith("-end")?y=o.bottom-a.height:d.endsWith("-start")?y=o.top:y=o.top+(o.height-a.height)/2;t.style.left=`${Math.round(te(b,0,Math.max(0,c-a.width)))}px`,t.style.top=`${Math.round(te(y,0,Math.max(0,u-a.height)))}px`}function Un(i){return i.split("-")[0]}function Ve(i,t,e){return i.replace(t,e)}function Ml(i){if(typeof i.showPopover=="function")try{i.showPopover()}catch{}}function Nl(i){if(typeof i.hidePopover=="function")try{i.hidePopover()}catch{}}function Zi(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}var Ol=6,Jn=864e5;function se(i,t){let e=Y(Ct(i)),s=Y(Ct(t));return e&&s&&e.getTime()>s.getTime()?{start:s,end:e}:{start:e,end:s}}function qe(i,t){let e=se(i,t);return!e.start||!e.end?0:Math.round((Qn(e.end)-Qn(e.start))/Jn)}function Fl(i,t,e){let s=Y(Ct(i));if(!s)return null;let n=se(t,e);return!n.start&&!n.end?null:n.end?n.start?s.getTime()<n.start.getTime()||s.getTime()>n.end.getTime()?null:P(s,n.start)?"start":P(s,n.end)?"end":"middle":P(s,n.end)?"end":null:P(s,n.start)?"start":null}function $e(i,t={}){let e=Y(Ct(t.min)),s=Y(Ct(t.max)),n=Ke(t.minNights)??0,r=Ke(t.maxNights),{start:o,end:a}=se(i?.start,i?.end);return o&&(o=Gi(o,e,s)),a&&(a=Gi(a,e,s)),!o||!a?{start:o,end:a}:(r!==null&&qe(o,a)>r&&(a=E(o,r)),n>0&&qe(o,a)<n&&(a=E(o,n),s&&a.getTime()>s.getTime()&&(a=new Date(s.getTime()),o=E(a,-n),e&&o.getTime()<e.getTime()))?{start:null,end:null}:{start:o,end:a})}var Be=class extends v{static cssName="date-range-picker";static defaults={start:null,end:null,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._rootAttributes=$l(t,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=Y(Ct(this.options.min)),this._max=Y(Ct(this.options.max)),this._minNights=Ke(this.options.minNights)??0,this._maxNights=Ke(this.options.maxNights),this._weekStart=jl(this.options.weekStart),this._monthCount=Vl(this.options.months),this._presets=Pl(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let e=$e({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=St(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",F("daterange.label","Date range")),t.dataset.months=String(this._monthCount),this._presets.length&&(t.dataset.presets="true");let s=l("div",{class:"zx-date-range-picker__surface"},this._presets.length?l("div",{ref:"presets",class:"zx-date-range-picker__presets",role:"group",ariaLabel:F("daterange.presets","Date range presets")},this._presets.map(r=>l("button",{class:"zx-date-range-picker__preset",type:"button",dataset:{preset:r.name}},r.label))):null,l("div",{ref:"calendars",class:"zx-date-range-picker__calendars"})),n=l("div",{ref:"status",class:"zx-date-range-picker__status",role:"status",ariaLive:"polite"});return this._nodes=[s,n],t.append(s,n),this.refs.presets&&this.listen(this.refs.presets,"click",r=>this._onPresetClick(r)),this.listen(this.refs.calendars,"click",r=>this._onCalendarClick(r)),this.listen(this.refs.calendars,"keydown",r=>this._onDayKeydown(r)),this.listen(this.refs.calendars,"mouseover",r=>this._onDayHover(r)),this.listen(this.refs.calendars,"mouseleave",()=>this._setHover(null)),this._renderCalendars(),this._announce(),t}get(){return{start:St(this._start),end:St(this._end)}}set(t={},{silent:e=!1}={}){let s=$e({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=St(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=[],Bl(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=qe(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?St(this._start):null,this._committedEnd=t?St(this._end):null}_abandon(){return this._picking?(this._start=St(this._committedStart),this._end=St(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=Gn(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=Gn(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&&P(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=zt(s,t.shiftKey?-12:-1);else if(t.key==="PageDown")n=zt(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=I(t,"%B %Y"),s=(t.getDay()-this._weekStart+7)%7,n=E(t,-s),r=[];for(let o=0;o<Ol;o+=1){let a=E(n,o*7),c=l("tr"),u=ql(a,t);this.options.showWeekNumbers&&c.append(l("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:u?F("daterange.week","Week %1",[Xn(a)]):null},u?String(Xn(a)):""));for(let d=0;d<7;d+=1){let h=E(a,d),f=l("td",{role:"presentation"});if(h.getMonth()===t.getMonth()&&h.getFullYear()===t.getFullYear()){let p=l("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:I(h,"%Y-%m-%d")}},I(h,"%e"));f.append(p),this._dayCells.push({date:h,cell:f,button:p})}c.append(f)}r.push(c)}return l("div",{class:"zx-date-range-picker__month"},l("div",{class:"zx-date-range-picker__header"},l("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"previous"},ariaLabel:F("daterange.previousMonth","Previous month")},w("chevron-left")),l("div",{class:"zx-date-range-picker__caption",ariaHidden:"true"},e),l("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"next"},ariaLabel:F("daterange.nextMonth","Next month")},w("chevron-right"))),l("table",{class:"zx-date-range-picker__grid",role:"grid",ariaLabel:e},l("thead",{},this._weekdayRow()),l("tbody",{},...r)))}_weekdayRow(){let t=l("tr");this.options.showWeekNumbers&&t.append(l("th",{class:"zx-date-range-picker__week-heading",scope:"col",ariaLabel:F("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(l("th",{scope:"col",ariaLabel:I(n,"%A")},I(n,"%a")))}return t}_paint(){let t=new Date,e=null;for(let s of this._dayCells)P(s.date,this._focused)&&(e=s);e||(e=this._dayCells[0]??null);for(let s of this._dayCells){let{date:n,cell:r,button:o}=s,a=this._dayState(n);Qi(r,"range",a.range),Qi(r,"rangeEdge",a.edge),Qi(o,"range",a.range),o.tabIndex=s===e?0:-1,o.setAttribute("aria-selected",String(a.range!==null&&a.range!=="preview")),o.setAttribute("aria-disabled",String(!this._selectable(n))),o.setAttribute("aria-label",this._dayLabel(n,a.range)),P(n,t)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(t){if(this._start&&this._end){let s=Fl(t,this._start,this._end);if(!s)return{range:null,edge:null};let n=P(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 P(t,this._start)?{range:"start",edge:e?"start":"both"}:e?t.getTime()>this._start.getTime()&&t.getTime()<=e.getTime()?{range:"preview",edge:P(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=I(t,"%A, %e %B %Y");return e==="start"?`${s}, ${F("daterange.day.start","range start")}`:e==="end"?`${s}, ${F("daterange.day.end","range end")}`:e==="middle"?`${s}, ${F("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 F("daterange.status.empty","No date range selected");if(!this._end)return F("daterange.status.start","%1 selected, choose an end date",[I(this._start,"%e %B %Y")]);let t=qe(this._start,this._end),e=t===1?F("daterange.night","1 night"):F("daterange.nights","%1 nights",[t]);return`${Ll(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=>P(e.date,t))?.button??null}};function Rl(){return[{name:"today",label:F("daterange.preset.today","Today"),range:()=>Wn(ot())},{name:"yesterday",label:F("daterange.preset.yesterday","Yesterday"),range:()=>Wn(E(ot(),-1))},{name:"last7",label:F("daterange.preset.last7","Last 7 days"),range:()=>({start:E(ot(),-6),end:ot()})},{name:"last30",label:F("daterange.preset.last30","Last 30 days"),range:()=>({start:E(ot(),-29),end:ot()})},{name:"thisMonth",label:F("daterange.preset.thisMonth","This month"),range:()=>Zn(ot(),0)},{name:"lastMonth",label:F("daterange.preset.lastMonth","Last month"),range:()=>Zn(ot(),-1)},{name:"thisQuarter",label:F("daterange.preset.thisQuarter","This quarter"),range:()=>{let i=ot(),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:F("daterange.preset.thisYear","This year"),range:()=>{let i=ot();return{start:new Date(i.getFullYear(),0,1),end:new Date(i.getFullYear(),11,31)}}}]}function F(i,t,e){let s=nt(i);return O(s===i?t:s,e)}function Ll(i,t){if(P(i,t))return I(i,"%e %B %Y");let e=I(t,"%e %B %Y");return i.getFullYear()!==t.getFullYear()?`${I(i,"%e %B %Y")} \u2013 ${e}`:i.getMonth()!==t.getMonth()?`${I(i,"%e %B")} \u2013 ${e}`:`${I(i,"%e")} \u2013 ${e}`}function Pl(i){return i===!0?Rl():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 ot(){return Y(new Date)}function Wn(i){return{start:i,end:new Date(i.getTime())}}function Zn(i,t){return{start:new Date(i.getFullYear(),i.getMonth()+t,1),end:new Date(i.getFullYear(),i.getMonth()+t+1,0)}}function Ct(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 St(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 Qn(i){return Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())}function Gn(i){return i.getFullYear()*12+i.getMonth()}function Ke(i){if(i==null||i==="")return null;let t=Number(i);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):null}function jl(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&t<=6?t:Oe()}function Vl(i){let t=Number(i);return Number.isInteger(t)&&t>=1&&t<=4?t:2}function ql(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 Xn(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())/Jn+1)/7)}function Qi(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 Bl(i,t){for(let[e,s]of t)s===null?i.removeAttribute(e):i.setAttribute(e,s)}var Kl={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function tr(i,t,e){let s=String(i??"").trim();if(s==="")return{start:null,end:null};let n=String(e??" \u2013 "),r=n.trim(),o=r!==""&&String(t).includes(r)&&/^\s|\s$/.test(n),a=o?"\\s+":"\\s*",c=o?"(?:\\s+|$)":"\\s*",u=r===""?[s]:s.split(new RegExp(`${a}${Oi(r)}${c}`));if(u.length>2)return null;let d=rt(u[0].trim(),t);if(!d)return null;if(u.length===1)return{start:d,end:new Date(d.getTime())};if(u[1].trim()==="")return{start:d,end:null};let h=rt(u[1].trim(),t);return h?se(d,h):null}function Hl(i,t,e){let s=i?.start??null,n=i?.end??null;return!s&&!n?"":n?s?`${I(s,t)}${e}${I(n,t)}`:I(n,t):I(s,t)}var Ye=class extends v{static cssName="date-range-box";static defaults={start:null,end:null,format:"%d.%m.%Y",separator:" \u2013 ",placeholder:null,clearable:!0,min:null,max:null,months:2,weekStart:1,showWeekNumbers:!1,minNights:0,maxNights:null,presets:[],disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._originalClearable=t.getAttribute("data-clearable"),t.toggleAttribute("data-clearable",!!this.options.clearable),this._format=String(this.options.format||"%d.%m.%Y"),this._separator=String(this.options.separator??" \u2013 "),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._range=this._coerce({start:this.options.start,end:this.options.end});let e=D("zx-date-range-box-popover"),s=l("div",{class:"zx-date-range-box__content"},l("div",{ref:"control",class:"zx-date-range-box__control"},l("input",{ref:"input",class:"zx-date-range-box__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??this._placeholder(),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),l("button",{ref:"clear",class:"zx-icon-btn zx-date-range-box__clear",type:"button",ariaLabel:er("daterange.clear","Clear date range")},w("x",{size:13})),l("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:er("daterange.choose","Choose date range"),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},w("calendar"))),l("div",{ref:"popover",id:e,class:"zx-date-range-box__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=s,t.append(s),this._picker=new Be(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=vt(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(),He(this.el,"data-state",this._originalState),He(this.el,"aria-disabled",this._originalAriaDisabled),He(this.el,"data-clearable",this._originalClearable),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=tr(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(tr(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()!==""?rt(t.trim(),this._format):null}_clamp(t){return $e(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=>Kl[e]??e);return`${t}${this._separator}${t}`}_syncDisplay(){this.refs.input.value=Hl(this._range,this._format,this._separator),this._syncClear()}_syncClear(){this.refs.clear.hidden=!this.options.clearable||!(this._range.start||this._range.end)||this._disabled}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled)),this._syncClear(),this._disabled?this._picker?.disable():this._picker?.enable()}_setValid(){this.el.dataset.state==="invalid"&&He(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 er(i,t,e){let s=nt(i);return O(s===i?t:s,e)}function He(i,t,e){e===null?i.removeAttribute(t):i.setAttribute(t,e)}function ir(){S.register("daterange",(i,t)=>{let e=i.own(new Ye(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 It=class extends v{static cssName="datebox";static defaults={value:null,format:"%d.%m.%Y",time:!1,min:null,max:null,placeholder:null,clearable:!0,disabled:!1};render(){let t=this.el??l("div");this.el=t,this._originalState=t.getAttribute("data-state"),this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._originalClearable=t.getAttribute("data-clearable"),t.toggleAttribute("data-clearable",!!this.options.clearable),this._format=Yl(this.options.format,this.options.time),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._min=sr(this.options.min),this._max=sr(this.options.max),this._value=this._normalizeValue(this.options.value);let e=D("zx-datebox-popover"),s=l("div",{class:"zx-datebox__content"},l("div",{ref:"control",class:"zx-datebox__control"},l("input",{ref:"input",class:"zx-datebox__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??Ul(this._format),"aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"}),l("button",{ref:"clear",class:"zx-icon-btn zx-datebox__clear",type:"button",ariaLabel:"Clear date"},w("x",{size:13})),l("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:"Choose date","aria-haspopup":"grid",ariaControls:e,ariaExpanded:"false"},w("calendar"))),l("div",{ref:"popover",id:e,class:"zx-datebox__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=s,t.append(s),this._picker=new qt(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=vt(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),this._originalClearable===null?this.el.removeAttribute("data-clearable"):this.el.setAttribute("data-clearable",this._originalClearable),super.destroy()}_onInputKeydown(t){t.key==="ArrowDown"?(t.preventDefault(),this.open()):t.key==="Enter"?(t.preventDefault(),this._commitText()):t.key==="Escape"&&this._open&&(t.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let t=this.refs.input.value.trim();if(t===""){this.set(null);return}let e=rt(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=rt(t,this._format)),!e||Number.isNaN(e.getTime())?null:In(e,this._min,this._max)}_syncDisplay(){this.refs.input.value=this._value?I(this._value,this._format):"",this._syncClear()}_syncClear(){this.refs.clear.hidden=!this.options.clearable||!this._value||this._disabled}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled)),this._syncClear()}_setValid(){this.el.dataset.state==="invalid"&&(this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState)),this.refs.input.removeAttribute("aria-invalid")}_close(t){this._open&&(this._position?.destroy(),this._position=null,this._open=!1,this.refs.popover.dataset.state="closed",this.refs.input.setAttribute("aria-expanded","false"),this.refs.toggle.setAttribute("aria-expanded","false"),t&&this.focus(),this.emit("close"))}_copyValue(){return this._value?new Date(this._value.getTime()):null}},nr=function(t,e={}){return new It(t,{...e,time:!0})};function sr(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function Yl(i,t){let e=String(i||"%d.%m.%Y");return t&&!/%[HM]/.test(e)?`${e} %H:%M`:e}function Ul(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 or(){rr("date",i=>new It(null,i)),rr("datetime",i=>nr(null,i))}function rr(i,t){S.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 Ue=class extends v{static cssName="field-upload";static defaults={url:"",paramName:"upload",params:{},headers:{},multiple:!1,accept:null,maxSize:null,autoUpload:!0,preview:!0,http:null};render(){let t=this.el??l("div");this.el=t,this._ownedNodes=[],this._files=[],this._disabled=!1,this._running=!1,this._runId=0,this._xhr=null,this._transportController=null,this._previewUrl=null,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled");let e=D("zx-upload");return this._input=l("input",{class:"zx-field-upload__input",id:e,type:"file",multiple:!!this.options.multiple,accept:this.options.accept??void 0,tabIndex:-1}),this._dropzone=l("button",{class:"zx-field-upload__dropzone",type:"button",ariaControls:e,ariaLabel:this.options.multiple?"Choose files or drop them here":"Choose a file or drop it here"},l("span",{class:"zx-field-upload__prompt"},this.options.multiple?"Drop files here or choose files":"Drop a file here or choose a file"),l("span",{class:"zx-field-upload__hint"},Wl(this.options))),this._preview=l("div",{class:"zx-field-upload__preview"}),this._progress=l("progress",{class:"zx-field-upload__progress",max:100,value:0,ariaLabel:"Upload progress"}),this._progressText=l("span",{class:"zx-field-upload__progress-text"},"0%"),this._abort=l("button",{class:"zx-btn zx-field-upload__abort",type:"button"},"Abort"),this._progressWrap=l("div",{class:"zx-field-upload__progress-wrap",hidden:!0},this._progress,this._progressText,this._abort),this._status=l("div",{class:"zx-field-upload__status",role:"status",ariaLive:"polite"}),this._ownedNodes.push(this._input,this._dropzone,this._preview,this._progressWrap,this._status),t.append(...this._ownedNodes),this.listen(this._dropzone,"click",()=>{!this._disabled&&!this._running&&this._input.click()}),this.listen(this._input,"change",()=>this._selectFiles(this._input.files)),this.listen(this._dropzone,"dragenter",s=>this._handleDragOver(s)),this.listen(this._dropzone,"dragover",s=>this._handleDragOver(s)),this.listen(this._dropzone,"dragleave",s=>{(!(s.relatedTarget instanceof Node)||!this._dropzone.contains(s.relatedTarget))&&this._setState("idle")}),this.listen(this._dropzone,"drop",s=>{s.preventDefault(),!(this._disabled||this._running)&&(this._setState("idle"),this._selectFiles(s.dataTransfer?.files??[]))}),this.listen(this._abort,"click",()=>this.abort()),this.setDisabled(!1),t}async upload(t=null){if(t!==null&&!this._setFiles(t)||this._disabled||this._running||this._files.length===0)return null;this._running=!0,this._runId+=1;let e=this._runId;this._setState("uploading"),this._progressWrap.hidden=!1,this._abort.hidden=!1,this._setProgress(0),this._status.textContent="Uploading\u2026";try{let s=this.options.http?await this._uploadInjected():await this._uploadXhr();return e!==this._runId?null:(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setProgress(100),this._setState("success"),this._status.textContent="Upload complete.",this.emit("success",{response:s}),s)}catch(s){if(e!==this._runId)return null;let n=s instanceof Error?s:new Error(String(s));return n.name==="AbortError"?(this._finishAbort(),null):(this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("error"),this._status.textContent=n.message,this.emit("error",{error:n}),null)}}abort(){return this._running?(this._xhr?.abort(),this._transportController?.abort(),this._finishAbort(),this):this}clear(){return this._running&&this.abort(),this._files=[],this._input.value="",this._revokePreview(),this._preview.replaceChildren(),this._progress.value=0,this._progressText.textContent="0%",this._progressWrap.hidden=!0,this._status.textContent="",this._setState("idle"),this}setDisabled(t){return this._disabled=!!t,this._input.disabled=this._disabled,this._dropzone.disabled=this._disabled,this.el.dataset.disabled=String(this._disabled),this}_selectFiles(t){this._setFiles(t)&&(this._input.value="",this.options.autoUpload&&this.upload())}_setFiles(t){if(this._disabled||this._running)return!1;let e=Array.from(t??[]),s=this.options.multiple?e:e.slice(0,1);if(s.length===0)return!1;let n=s.find(o=>!Ql(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(Xl(s.responseText))}),this.listen(s,"error",()=>e(new Error("Upload request failed"))),this.listen(s,"abort",()=>e(Jl())),s.send(Gl(this._files,String(this.options.paramName),this.options.params))})}_setProgress(t){let e=Math.max(0,Math.min(100,Number(t)||0));this._progress.value=e,this._progressText.textContent=`${Math.round(e)}%`,this.emit("progress",{percent:e})}_finishAbort(){this._running&&(this._runId+=1,this._running=!1,this._xhr=null,this._transportController=null,this._abort.hidden=!0,this._setState("idle"),this._status.textContent="Upload aborted.",this.emit("abort",{}))}_selectionError(t){this._setState("error"),this._status.textContent=t.message,this.emit("error",{error:t})}_renderPreview(){this._revokePreview(),this._preview.replaceChildren();let t=this._files[0];!this.options.preview||!t?.type?.startsWith("image/")||typeof URL>"u"||typeof URL.createObjectURL!="function"||(this._previewUrl=URL.createObjectURL(t),this._preview.append(l("img",{class:"zx-field-upload__image",src:this._previewUrl,alt:`Preview of ${t.name}`})))}_revokePreview(){this._previewUrl&&typeof URL<"u"&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(this._previewUrl),this._previewUrl=null}_setState(t){t==="idle"?this.el.removeAttribute("data-state"):this.el.dataset.state=t}destroy(){this._running&&this.abort(),this._revokePreview();for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function Wl(i){let t=[];return i.accept&&t.push(String(i.accept)),i.maxSize!=null&&t.push(`up to ${Zl(Number(i.maxSize))}`),t.join(" \xB7 ")||"Choose from this device"}function Zl(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/1024)} KB`:`${Math.round(i/(1024*1024))} MB`}function Ql(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 Gl(i,t,e){let s=new FormData;for(let n of i)s.append(t,n);for(let[n,r]of Object.entries(e??{}))ar(s,n,r);return s}function ar(i,t,e){if(e==null)return;if(Array.isArray(e)){for(let n of e)ar(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 Xl(i){if(!i)return null;try{return JSON.parse(i)}catch{return i}}function Jl(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let i=new Error("Upload aborted");return i.name="AbortError",i}function lr(){S.register("upload",(i,t)=>{let e=i.own(new Ue(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 cr=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),ur=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),We=class extends v{static cssName="multi-value-editor";static defaults={values:[],options:null,addLabel:"Add value",reorder:"both"};render(){let t=this.el??l("div");return this.el=t,this._values=Array.isArray(this.options.values)?this.options.values.map(String):[],this._ownedNodes=[],this._initialState=t.getAttribute("data-state"),this._dragIndex=-1,this._armed=null,this._rows=l("div",{class:"zx-multi-value-editor__rows"}),this._add=l("button",{class:"zx-btn zx-multi-value-editor__add",type:"button",dataset:{action:"add"}},String(this.options.addLabel??"Add value")),this._ownedNodes.push(this._rows,this._add),t.append(this._rows,this._add),this.listen(t,"click",e=>this._handleClick(e)),this.listen(this._rows,"change",e=>this._handleChange(e)),this.listen(this._rows,"keydown",e=>this._handleKeydown(e)),this._reorder().drag&&(this.listen(this._rows,"pointerdown",e=>this._handlePointerDown(e)),this.listen(this._rows,"dragstart",e=>this._handleDragStart(e)),this.listen(this._rows,"dragover",e=>this._handleDragOver(e)),this.listen(this._rows,"dragleave",e=>this._handleDragLeave(e)),this.listen(this._rows,"drop",e=>this._handleDrop(e)),this.listen(this._rows,"dragend",()=>this._finishDrag()),this.listen(document,"pointerup",()=>this._disarm()),this.listen(document,"pointercancel",()=>this._disarm())),this._renderRows(),t}getValues(){return this._values.slice()}setValues(t,{silent:e=!1}={}){return this._values=Array.isArray(t)?t.map(String):[],this._renderRows(),e||this.emit("change",{values:this.getValues()}),this}_reorder(){return cr[this.options.reorder]??cr.both}_renderRows(t=-1,e="value"){let s=dr(this.options.options),n=this.options.options!==null,{drag:r,buttons:o}=this._reorder(),a=this._values.length-1,c=this._values.map((u,d)=>{let h=!n||s.some(([p])=>p===u)?s:[[u,u],...s],f=n?l("select",{class:"zx-multi-value-editor__value",ariaLabel:`Value ${d+1}`,dataset:{index:d}},h.map(([p,_])=>l("option",{value:p,selected:p===u},_))):l("input",{class:"zx-multi-value-editor__value",type:"text",value:u,ariaLabel:`Value ${d+1}`,dataset:{index:d}});return l("div",{class:"zx-multi-value-editor__row",dataset:{row:d}},r?l("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:`Reorder value ${d+1}. Use the arrow keys to move it.`,dataset:{action:"grab",index:d}},w("drag",{size:12})):null,f,l("div",{class:"zx-multi-value-editor__controls"},o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(d===0),ariaLabel:`Move value ${d+1} up`,dataset:{action:"up",index:d}},w("chevron-up",{size:12})):null,o?l("button",{class:"zx-btn",type:"button",ariaDisabled:String(d===a),ariaLabel:`Move value ${d+1} down`,dataset:{action:"down",index:d}},w("chevron-down",{size:12})):null,l("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${d+1}`,dataset:{action:"remove",index:d}},w("x",{size:12}))))});this._rows.replaceChildren(...c),t>=0&&c[Math.min(t,c.length-1)]?.querySelector(ur[e]??ur.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=dr(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 dr(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 hr(){S.register("multivalueeditor",(i,t)=>{let e=i.own(new We(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 $t=class extends v{static cssName="number-field";static defaults={value:null,min:null,max:null,step:1,largeStep:10,precision:null,wrap:!1,placeholder:"",label:null,unit:null,disabled:!1,readonly:!1,required:!1,name:null,group:!1,locale:null};render(){this._value=null,this._disabled=!1,this._readonly=!1,this._editing=!1,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:K(this.el);let t=this.el??l("div");this.el=t;let e=tc(this.options.step);this._step=e,this._precision=this.options.precision===null?ec(e):Math.max(0,Math.trunc(Number(this.options.precision)||0));let s=this._stepButton("down","minus"),n=this._stepButton("up","plus"),r=l("input",{ref:"input",class:"zx-number-field__input",type:"text",role:"spinbutton",inputMode:this._precision>0?"decimal":"numeric",autocomplete:"off",spellcheck:!1,placeholder:String(this.options.placeholder??""),ariaLabel:this.options.label??void 0,name:this.options.name??void 0,required:!!this.options.required}),o=[s,r];return this.options.unit!==null&&o.push(l("span",{ref:"unit",class:"zx-number-field__unit",ariaHidden:"true"},String(this.options.unit))),o.push(n),t.replaceChildren(...o),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(r,"input",()=>this._onInput()),this.listen(r,"keydown",a=>this._onKeydown(a)),this.listen(r,"focus",()=>{this._editing=!0,this._syncInput()}),this.listen(r,"blur",()=>{this._commit(),this._editing=!1,this._syncInput()}),this.listen(s,"click",()=>this._stepBy(-1)),this.listen(n,"click",()=>this._stepBy(1)),this.listen(r,"wheel",a=>{document.activeElement!==r||this._disabled||this._readonly||(a.preventDefault(),this._stepBy(a.deltaY<0?1:-1))},{passive:!1}),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=this._coerce(t),n=s!==this._value;return this._value=s,this._syncInput(),n&&!e&&this.emit("change",{value:this._value}),this}stepUp(t=1){return this._stepBy(t)}stepDown(t=1){return this._stepBy(-t)}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}focus(){return this.refs.input.focus(),this}getInput(){return this.refs.input}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}setRange(t,e){return this._min=t==null?null:Number(t),this._max=e==null?null:Number(e),this.set(this._value,{silent:!0})}_stepButton(t,e){return l("button",{ref:t,class:"zx-number-field__step",type:"button",tabIndex:-1,ariaHidden:"true",dataset:{step:t}},w(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=Xi(t,this.options.group?this._separators():null);return e===null?null:Ji(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=Xi(this.refs.input.value)??this._value,o=r===null?e??0:r,a=r===null&&t>0&&e!==null?e-this._step*t:o,c=fr(a+this._step*t,this._precision);return this.options.wrap&&e!==null&&s!==null&&(c>s?c=e:c<e&&(c=s)),this.set(c),this}_separators(){if(this._localeSeparators)return this._localeSeparators;let t=new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:1}).formatToParts(1234.5);return this._localeSeparators={group:t.find(e=>e.type==="group")?.value??",",decimal:t.find(e=>e.type==="decimal")?.value??"."},this._localeSeparators}_onInput(){let t=Xi(this.refs.input.value,this.options.group?this._separators():null);this._syncAria(t),this.emit("input",{value:t})}_onKeydown(t){if(this._disabled||this._readonly||t.altKey||t.ctrlKey||t.metaKey)return;let e=Math.max(1,Math.trunc(Number(this.options.largeStep)||1)),n={ArrowUp:()=>this._stepBy(1),ArrowDown:()=>this._stepBy(-1),PageUp:()=>this._stepBy(e),PageDown:()=>this._stepBy(-e),Home:()=>this._rangeMin===null?null:this.set(this._rangeMin),End:()=>this._rangeMax===null?null:this.set(this._rangeMax),Enter:()=>this._commit()}[t.key];n&&(t.key==="Home"&&this._rangeMin===null||t.key==="End"&&this._rangeMax===null||(t.preventDefault(),n()))}_commit(){this.set(this.refs.input.value)}_syncInput(){let t=this.refs.input,e=this._value===null?"":this._format(this._value,this._editing);t.value!==e&&(t.value=e),this._syncAria(this._value)}_syncAria(t){let e=this.refs.input,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&&H(t,this._snapshot)}};function Xi(i,t=null){if(typeof i=="number")return Number.isFinite(i)?i:null;if(i==null)return null;let e=String(i).trim();if(e==="")return null;let s;if(t)s=e.split(t.group).join("").replace(t.decimal,".").replace(/[^\d.\-+eE]/g,"");else{let r=e.replace(/[^\d,.\-+eE]/g,""),o=r.lastIndexOf(","),a=r.lastIndexOf(".");s=r,o>=0&&o>a?s=r.replace(/\./g,"").replace(",","."):o>=0&&(s=r.replace(/,/g,""))}if(!/\d/.test(s))return null;let n=Number(s);return Number.isFinite(n)?n:null}function Ji(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=fr(r,n),t!==null&&r<t?t:e!==null&&r>e?e:r}function tc(i){let t=Number(i);return Number.isFinite(t)&&t>0?t:1}function ec(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 fr(i,t){return Number.isFinite(i)?Number(i.toFixed(Math.min(15,Math.max(0,t)))):i}function pr(){S.register("number",(i,t)=>{let e=i.own(new $t(null,{label:t.label?String(t.label):void 0,placeholder:t.placeholder,required:t.required,name:i.name||null,...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 Ze=class extends v{static cssName="rating";static defaults={value:0,max:5,allowHalf:!1,clearable:!0,readonly:!1,disabled:!1,label:"Rating",icon:"star",labels:null,showValue:!1,count:null,size:"md"};render(){this._value=0,this._preview=null,this._disabled=!1,this._readonly=!1,this._radios=[],this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:K(this.el);let t=this.el??l("div");this.el=t,this._max=Math.max(1,Math.trunc(Number(this.options.max)||5)),this._step=this.options.allowHalf?.5:1,this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this._name=D("zx-rating");let e=l("div",{ref:"symbols",class:"zx-rating__symbols",role:"radiogroup",ariaLabel:String(this.options.label??"Rating")});for(let s=1;s<=this._max;s+=1){let n=l("span",{class:"zx-rating__symbol"},l("span",{class:"zx-rating__glyph",ariaHidden:"true"},w(this.options.icon,{size:ne[this.options.size]??ne.md})),l("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},w(this.options.icon,{size:ne[this.options.size]??ne.md})));this.options.allowHalf?n.append(this._radio(s-.5,"half"),this._radio(s,"full")):n.append(this._radio(s,"full")),e.append(n)}return t.replaceChildren(e,l("span",{ref:"readout",class:"zx-rating__readout"})),t.dataset.size=ne[this.options.size]?this.options.size:"md",this.listen(e,"keydown",s=>this._onKeydown(s)),this.listen(e,"pointerleave",()=>this._setPreview(null)),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=this._clamp(t),n=s!==this._value;return this._value=s,this._preview=null,this._sync(),n&&!e&&this.emit("change",{value:this._value}),this}clear({silent:t=!1}={}){return this.set(0,{silent:t})}reset({silent:t=!1}={}){return this.set(this.options.value,{silent:t})}setCount(t){return this._count=t,this._syncReadout(),this}focus(){return(this._radios.find(e=>e.tabIndex===0)??this._radios[0])?.focus(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(t){return this._readonly=!!t,this._syncDisabled(),this}_radio(t,e){let s=l("button",{class:"zx-rating__radio",type:"button",role:"radio",tabIndex:-1,ariaChecked:"false",ariaLabel:this._stepLabel(t),dataset:{value:String(t),part:e}});return this.listen(s,"click",n=>{this._choose(t,n.detail>0)}),this.listen(s,"pointerenter",()=>this._setPreview(t)),this.listen(s,"focus",()=>this._setPreview(t)),this.listen(s,"blur",()=>this._setPreview(null)),this._radios.push(s),s}_stepLabel(t){let e=this.options.labels;if(Array.isArray(e)){let s=Math.round(t/this._step)-1;if(e[s]!=null)return String(e[s])}return this._message("rating.value","%1 of %2",[t,this._max])}_message(t,e,s){let n=this.msg(t,...s);return n===t?O(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(ic(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&&H(t,this._snapshot)}},ne={sm:14,md:18,lg:24};function ic(i,t){return t<1?i.toFixed(1):String(i)}function mr(){S.register("rating",(i,t)=>{let e=i.own(new Ze(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 yp=["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 _r(i,t){let e="",s=null;return function(r){let o=typeof r=="string"?r:r.key;if(typeof r!="string"&&(r.ctrlKey||r.metaKey||r.altKey)||!o||o.length!==1||/\s/.test(o))return;s!==null&&clearTimeout(s),e+=o.toLocaleLowerCase(),e.split("").every(u=>u===e[0])&&(e=e[0]),s=setTimeout(()=>{e="",s=null},500);let a=i(),c=a.findIndex(u=>sc(u).startsWith(e));c>=0&&t(a[c],c)}}function sc(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 nc=/^var\(\s*--[\w-]+\s*\)$/;function Qe(i){if(typeof i!="string")return null;let t=i.trim();return nc.test(t)||Pt(t)?t:null}var es=Object.freeze(["dotted","ring","progress","review","ready","waiting","done","canceled","duplicate"]),is=Object.freeze(["muted","neutral","warning","info","accent","success","danger"]),ss=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"]]),rc=Object.freeze({review:"in-review",cancelled:"canceled"}),ts=4;function oc(i,t={}){let e=i&&typeof i=="object"?i:null,s=ac(e?e.ID??e.id:i),n=ss.find(([a])=>a===s),r=String(t.indicator??e?.indicator??n?.[3]??"ring"),o=String(t.tone??e?.tone??n?.[4]??"muted");return{indicator:es.includes(r)?r:"ring",tone:is.includes(o)?o:"muted"}}function ac(i){let t=String(i??"").trim().toLowerCase();return rc[t]??t}function ns(i){return i==null||i===""?null:Math.max(0,Math.min(ts,Math.trunc(Number(i)||0)))}function gr(i,t={}){let{indicator:e,tone:s}=oc(i,t??{}),n=l("span",{class:"zx-status-icon",dataset:{indicator:e,tone:s}});return e==="done"&&n.append(w("check",{size:8})),e==="canceled"&&n.append(w("x",{size:7})),yr(n,t?.label)}function br(i,t={}){let e=ns(i),s=l("span",{class:"zx-priority-icon",dataset:{level:e===null?"none":e}},e===ts?null:Array.from({length:ts},(n,r)=>l("span",{dataset:{filled:String(e!==null&&r<=e)}})));return yr(s,t?.label)}function yr(i,t){let e=t==null?"":String(t).trim();return e?(i.setAttribute("role","img"),i.setAttribute("aria-label",e)):i.setAttribute("aria-hidden","true"),i}var lc=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],wr=["Lowest","Low","Medium","High","Highest"],$=class i extends v{static cssName="select";static defaults={items:[],fixedItems:[],fixedLabel:null,valueKey:"ID",labelKey:"name",renderItem:null,renderValue:null,renderValueAdornment:null,renderNone:null,noneLabel:null,actions:[],value:null,disabled:!1,placeholder:"",label:"",clearable:!1,filter:!1,searchKeys:null,minQuery:0,debounce:200,listHeight:280,groupKey:null};render(){this._items=[],this._visibleItems=[],this._fixedItems=[],this._visibleFixed=[],this._actions=[],this._selected=null,this._optionEntries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._createdRoot=!1,this._root=null,this._snapshot=null,this._pointerModality=!1,this._createdRoot=this.el===null;let t=this.el??l("div");this.el=t,this._root=t,this._snapshot=this._createdRoot?null:K(t);let e=D("zx-select-list"),s=l("input",{ref:"input",class:"zx-select__input",type:"text",role:"combobox",ariaLabel:String(this.options.label||this.options.placeholder||"Select"),autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:this.options.filter?"list":"none",placeholder:String(this.options.placeholder??""),readOnly:!this.options.filter}),n=l("span",{ref:"valueAdornment",class:"zx-select__value-adornment",ariaHidden:"true",hidden:!0}),r=l("button",{ref:"clear",class:"zx-icon-btn zx-select__clear",type:"button",tabIndex:-1,ariaLabel:this._message("select.clear","Clear selection"),hidden:!0},w("x",{size:13})),o=l("span",{ref:"loading",class:"zx-select__loading",role:"status",ariaLabel:this._message("select.loading","Loading"),hidden:!0}),a=l("button",{ref:"toggle",class:"zx-select__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("select.toggle","Toggle options")},w("chevron-down",{size:16})),c=l("div",{ref:"control",class:"zx-select__control"},n,s,r,o,a),u=l("div",{ref:"list",class:"zx-select__list",id:e,role:"listbox"});u.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let d=l("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},u);return t.replaceChildren(c,d),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visibleItems=this._items.slice(),this._fixedItems=Array.isArray(this.options.fixedItems)?this.options.fixedItems.slice():[],this._visibleFixed=this._fixedItems.slice(),this._actions=xr(this.options.actions),this._disabled=!!this.options.disabled,this._handleTypeahead=_r(()=>this._optionEntries.filter(h=>!h.clear&&!h.action).map(h=>h.element),(h,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",h=>{Sr(h)||t.removeAttribute("data-focus-origin"),this._onKeydown(h)}),this.listen(s,"focus",()=>{this._pointerModality&&s.readOnly?t.setAttribute("data-focus-origin","pointer"):t.removeAttribute("data-focus-origin")}),this.listen(s,"blur",()=>t.removeAttribute("data-focus-origin")),this.listen(document,"keydown",h=>{Sr(h)||(this._pointerModality=!1)},{capture:!0}),this.listen(a,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(r,"click",()=>{this.set(null),this.focus()}),this.listen(d,"pointerdown",h=>h.preventDefault()),this.listen(d,"click",h=>this._onOptionClick(h)),this.listen(document,"pointerdown",h=>{this._pointerModality=!0,this._open&&!t.contains(h.target)&&this.close()},{capture:!0}),this._renderOptions(),this.set(this.options.value,{silent:!0}),this._syncDisabled(),t}get value(){return this._selected===null?null:this._itemValue(this._selected)}set value(t){this.set(t)}get selected(){return this._selected}set(t,{silent:e=!1}={}){let 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=xr(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=vt(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=e.clearable??!0,r=null,o=()=>e.noneLabel??(r?r._message("priority.none","No priority"):"No priority");r=new i(t,{...e,clearable:n,value:null,items:[],renderItem(c){return vr(c,!0)},renderNone:e.renderNone??(()=>vr({level:null,name:o()},!0)),renderValueAdornment(c){return kr(c.level)}}),n&&!e.placeholder&&(r.refs.input.placeholder=o());let a=r;return r.setItems(lc.map((c,u)=>{let d=u===2?a.msg("priority.medium"):c;return(d==="priority.medium"||u!==2)&&(d=a._message(c,wr[u])),{ID:u,name:d,level:u}})),r.set(s,{silent:!0}),r}static status(t,e={}){let{items:s=null,value:n=null,...r}=e,o=new i(t,{...r,value:null,items:[],renderItem(c){return hc(c)},renderValueAdornment(c){return zr(c)}}),a=Array.isArray(s)?s.map(dc).filter(Boolean):ss.map(([c,u,d,h,f],p)=>({ID:c,name:o._message(u,d),indicator:h,tone:f,shortcut:String(p+1)}));return o.setItems(a),o.set(n,{silent:!0}),o}static entity(t,e={}){let{recent:s=[],recentLabel:n="Recent",create:r=!1,iconKey:o="icon",colorKey:a="color",subtitleKey:c="description",renderIcon:u=null,fixedItems:d=[],actions:h=[],renderItem:f=null,renderValueAdornment:p=null,..._}=e,m=(y,A=!1)=>{if(typeof u=="function")return u(y,{selected:A});let x=Ge(y,o);if(x&&typeof x=="object"&&typeof x.nodeType=="number")return x.cloneNode(!0);if(typeof x!="string"||!x)return null;let k=Qe(Ge(y,a));return l("span",{class:"zx-select__entity-glyph",style:k?{"--zx-select-entity-color":k}:null,ariaHidden:"true"},w(x,{size:14}))},g=r?cc(r):null,b=new i(t,{..._,fixedItems:[...Array.isArray(s)?s:[],...Array.isArray(d)?d:[]],fixedLabel:Array.isArray(s)&&s.length?n:_.fixedLabel??null,actions:[...Array.isArray(h)?h:[],...g?[g]:[]],renderItem:f??(y=>{let A=m(y,!1),x=Ge(y,c),k=l("span",{class:"zx-select__entity-copy"},l("span",{class:"zx-select__entity-label"},String(Ge(y,_.labelKey??"name")??"")),x==null||x===""?null:l("span",{class:"zx-select__entity-subtitle"},String(x)));return l("span",{class:"zx-select__entity"},A?l("span",{class:"zx-select__entity-icon",ariaHidden:"true"},A):null,k)}),renderValueAdornment:p??(y=>m(y,!0))});return b.el.dataset.preset="entity",b}static permission(t,e={}){let{groups:s=[],value:n=!0,valueKey:r="ID",labelKey:o="name",filter:a="local",...c}=e,u=typeof s=="function"?s:null,d=u?[]:s,h=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],f=new i(t,{filter:u??a,...c,value:null,items:d,fixedItems:[],valueKey:p=>h.includes(p)?p.ID:os(p,r),labelKey:p=>h.includes(p)?p.name:String(os(p,o)??"")});return h[0].name=f._message("permission.private","Private"),h[1].name=f._message("permission.public","Public"),f.setFixedItems(h),f.set(n,{silent:!0}),f}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let t=this.el;!this._createdRoot&&t&&H(t,this._snapshot),super.destroy()}_onKeydown(t){if(!this._disabled){if(this._open&&Ar(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&&Ar(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=xt(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(l("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(l("div",{class:"zx-select__separator",role:"presentation"}));for(let r of n){if(this.options.groupKey){let o=this._read(r,this.options.groupKey);Object.is(o,e)||(t.append(l("div",{class:"zx-select__group",role:"presentation"},String(o??""))),e=o)}this._appendOption(r,!1)}if(this._actions.length>0){(s.length>0||n.length>0||this.options.clearable)&&t.append(l("div",{class:"zx-select__separator",role:"presentation"}));let r=Symbol("initial-action-group");for(let o of this._actions)o.group&&o.group!==r&&(t.append(l("div",{class:"zx-select__group",role:"presentation"},o.group)),r=o.group),this._appendAction(o)}n.length===0&&s.length===0&&this._actions.length===0&&!this._loading&&t.append(l("div",{class:"zx-select__empty",role:"status"},this._message("select.empty","No matches"))),this._setActive(-1)}_appendOption(t,e,s){let n=e?this._selected===null:this._selected!==null&&Object.is(this._itemValue(t),this.value),r=this._optionEntries.length,o=e&&typeof this.options.renderNone=="function"?rs(this.options.renderNone(String(s??""))):e?String(s??""):this._renderItem(t),a=l("div",{class:"zx-select__option",id:D("zx-select-option"),role:"option",ariaSelected:String(n),dataset:{index:r}},l("span",{class:"zx-select__option-content"},o));n&&a.append(w("check",{size:15})),this.refs.list.append(a),this._optionEntries.push({item:t,clear:e,action:null,element:a})}_appendAction(t){let e=this._optionEntries.length,s=uc(t.icon),n=l("div",{class:"zx-select__option zx-select__action",id:D("zx-select-option"),role:"option",ariaSelected:"false",dataset:{index:e,kind:"action"}},l("span",{class:"zx-select__option-content zx-select__action-content"},s?l("span",{class:"zx-select__action-icon",ariaHidden:"true"},s):null,l("span",{class:"zx-select__action-copy"},l("span",{class:"zx-select__action-label"},t.label),t.description?l("span",{class:"zx-select__action-description"},t.description):null)));this.refs.list.append(n),this._optionEntries.push({item:null,clear:!1,action:t,element:n})}_renderItem(t){if(typeof this.options.renderItem=="function"){let e=this.options.renderItem(t);return rs(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=rs(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 os(t,e)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(t){return xt(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 Ge(i,t){return typeof t=="function"?t(i):i!==null&&typeof i=="object"&&typeof t=="string"?i[t]:null}function cc(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 rs(i){return i&&typeof i=="object"&&"nodeType"in i?i:String(i??"")}function xr(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 uc(i){return typeof i=="string"?w(i):i instanceof Node?i.cloneNode(!0):null}function vr(i,t){return l("span",{class:"zx-select__priority"},kr(i.level),t?l("span",{},String(i.name)):null)}function kr(i){let t=br(ns(i));return t.classList.add("zx-select__priority-icon"),t}function dc(i){return!i||typeof i!="object"||i.ID==null||i.name==null?null:{...i,name:String(i.name),indicator:es.includes(String(i.indicator))?String(i.indicator):"ring",tone:is.includes(String(i.tone))?String(i.tone):"muted",description:i.description==null?"":String(i.description),shortcut:i.shortcut==null?"":String(i.shortcut)}}function hc(i){return l("span",{class:"zx-select__status"},zr(i),l("span",{class:"zx-select__status-copy"},l("span",{class:"zx-select__status-label"},String(i.name)),i.description?l("span",{class:"zx-select__status-description"},i.description):null),i.shortcut?l("kbd",{class:"zx-select__status-shortcut"},i.shortcut):null)}function zr(i){let t=gr({indicator:i.indicator??"ring",tone:i.tone??"muted"});return t.classList.add("zx-select__status-indicator"),t}function os(i,t){return typeof t=="function"?t(i):i===null||typeof i!="object"?i:i[t]}function Sr(i){return["Shift","Control","Alt","Meta","CapsLock"].includes(i.key)||i.ctrlKey||i.metaKey}function Ar(i){return i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey}function Dr(){S.register("zxselect",(i,t)=>{let e=t.props??{},s=e.preset,n={...e,value:t.value,label:t.label||e.label,placeholder:e.placeholder??t.placeholder};i.listen(i.el,"click",o=>{o.target.closest?.(".zx-field__label")&&i.adapter.focus()}),delete n.preset,s==="priority"&&e.clearable===void 0&&(n.clearable=!t.required);let r=i.own(s==="priority"?$.priority(null,n):s==="status"?$.status(null,n):new $(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 Xe=class extends v{static cssName="slider";static defaults={value:0,min:0,max:100,step:1,label:"",hideLabel:!1,showValue:!0,showBounds:!1,showInput:!1,unit:"",marks:null,disabled:!1,readonly:!1,size:"md",formatValue:null};render(){this._value=0,this._readonly=!!this.options.readonly,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:K(this.el);let t=this.el??l("div");this.el=t,this._min=Number(this.options.min)||0,this._max=Number(this.options.max),(!Number.isFinite(this._max)||this._max<=this._min)&&(this._max=this._min+100),this._step=Math.abs(Number(this.options.step))||1,this._id=D("zx-slider");let e=l("input",{ref:"input",class:"zx-slider__input",type:"range",id:this._id,min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled}),s=l("div",{class:"zx-slider__track"},e,this._marks()),n=l("div",{class:"zx-slider__control"});return this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._min))),n.append(s),this.options.showBounds&&n.append(l("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._max))),this.options.showInput&&n.append(this._numberBox()),t.replaceChildren(l("div",{class:"zx-slider__head"},l("label",{ref:"label",class:"zx-slider__label",for:this._id},String(this.options.label??"")),l("span",{ref:"output",class:"zx-slider__value",ariaHidden:"true"})),n),t.dataset.size=this.options.size==="sm"?"sm":"md",t.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(e,"input",()=>this._onInput()),this.listen(e,"change",()=>this._onCommit()),this.listen(e,"keydown",r=>{this._readonly&&fc.has(r.key)&&r.preventDefault()}),this.set(this.options.value,{silent:!0}),this._syncState(),t}get value(){return this._value}set value(t){this.set(t)}get(){return this._value}set(t,{silent:e=!1}={}){let s=this._snap(t),n=s!==this._value;return this._value=s,this._paint(),n&&!e&&this.emit("change",{value:s}),this}setRange(t,e,s){let n=Number(t),r=Number(e);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)throw new RangeError("Slider range requires min < max");this._min=n,this._max=r,s!==void 0&&(this._step=Math.abs(Number(s))||1);let{input:o}=this.refs;o.min=String(this._min),o.max=String(this._max),o.step=String(this._step);for(let[a,c]of[...this.el.querySelectorAll(".zx-slider__bound")].entries())c.textContent=this._format(a===0?this._min:this._max);return this.set(this._value,{silent:!0})}focus(){return this.refs.input.focus(),this}enable(){return this.refs.input.disabled=!1,this.refs.number&&(this.refs.number.disabled=!1),this._syncState(),this}disable(){return this.refs.input.disabled=!0,this.refs.number&&(this.refs.number.disabled=!0),this._syncState(),this}setReadonly(t){return this._readonly=!!t,this.refs.number&&(this.refs.number.readOnly=this._readonly),this._syncState(),this}setLabel(t){return this.refs.label.textContent=String(t??""),this}_numberBox(){let t=l("input",{ref:"number",class:"zx-slider__number",type:"number",min:String(this._min),max:String(this._max),step:String(this._step),disabled:!!this.options.disabled,readOnly:this._readonly,ariaLabel:String(this.options.label??"Value")});return this.listen(t,"input",()=>{if(this._readonly)return;let e=Number(t.value);t.value===""||!Number.isFinite(e)||(this._value=this._snap(e),this.refs.input.value=String(this._value),this._paintTrack(),this.emit("input",{value:this._value}))}),this.listen(t,"change",()=>{if(this._readonly){t.value=String(this._value);return}this.set(t.value===""?this._min:Number(t.value))}),t}_marks(){let t=this.options.marks;if(!Array.isArray(t)||t.length===0)return null;let e=l("div",{class:"zx-slider__marks",ariaHidden:"true"});for(let s of t){let n=typeof s=="number"?s:Number(s?.value);if(!Number.isFinite(n))continue;let r=typeof s=="number"?this._format(n):String(s.label??this._format(n));e.append(l("span",{class:"zx-slider__mark",style:{"--zx-slider-mark":String(this._ratio(n))}},r))}return e}_onInput(){if(this._readonly){this.refs.input.value=String(this._value);return}this._value=this._snap(this.refs.input.value),this._paintTrack(),this.refs.number&&(this.refs.number.value=String(this._value)),this.emit("input",{value:this._value})}_onCommit(){if(this._readonly){this.refs.input.value=String(this._value);return}this.emit("change",{value:this._value})}_paint(){this.refs.input.value=String(this._value),this.refs.number&&(this.refs.number.value=String(this._value)),this._paintTrack()}_paintTrack(){this.el.style.setProperty("--zx-slider-fill",`${this._ratio(this._value)*100}%`);let{output:t}=this.refs;t.textContent=this.options.showValue?this._format(this._value):""}_syncState(){let t=this.refs.input.disabled;this.el.toggleAttribute("data-disabled",t),this.el.toggleAttribute("data-readonly",this._readonly),this.refs.input.setAttribute("aria-readonly",String(this._readonly))}_snap(t){let e=Number(t);return Number.isFinite(e)?Ji(e,{min:this._min,max:this._max,step:this._step,precision:pc(this._step)}):this._min}_ratio(t){return te((t-this._min)/(this._max-this._min),0,1)}_format(t){let e=this.options.formatValue;return typeof e=="function"?String(e(t)):`${mc(t)}${this.options.unit??""}`}destroy(){let t=this.el;super.destroy(),!this._createdRoot&&t&&H(t,this._snapshot)}},fc=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function pc(i){let t=String(i),e=/e-(\d+)$/i.exec(t);return e?Number(e[1]):(t.split(".")[1]??"").length}function mc(i){return String(Number(i.toFixed(6)))}function Cr(){S.register("slider",(i,t)=>{let e=i.own(new Xe(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 Up=Object.freeze(["neutral","accent","success","warning","danger","info"]),Wp=Object.freeze(["soft","solid","outline"]),_c=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),Zp=Object.freeze({label:"",icon:null,kind:"neutral",tone:null,variant:"soft",size:"md",dot:!1});function Ir(i){return _c.includes(i)?i:null}var Je=class extends v{static cssName="tag-picker";static defaults={items:[],values:[],valueKey:"ID",labelKey:"name",iconKey:"icon",colorKey:"color",toneKey:"tone",searchKeys:null,filter:"local",minQuery:0,debounce:200,allowCreate:!1,max:null,closeOnSelect:!1,placeholder:"",listHeight:260,disabled:!1,readonly:!1,renderItem:null,renderTag:null};render(){this._items=[],this._selected=[],this._visible=[],this._entries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._readonly=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._activeId=null,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:K(this.el);let t=this.el??l("div");this.el=t;let e=D("zx-tag-picker-list"),s=l("span",{ref:"tags",class:"zx-tag-picker__tags"}),n=l("input",{ref:"input",class:"zx-tag-picker__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:e,ariaAutocomplete:"list",ariaLabel:this._message("tagPicker.input","Add a value"),placeholder:String(this.options.placeholder??"")}),r=l("button",{ref:"toggle",class:"zx-tag-picker__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("tagPicker.toggle","Toggle options")},w("chevron-down",{size:15})),o=l("div",{ref:"control",class:"zx-tag-picker__control"},s,n,r),a=l("div",{ref:"list",class:"zx-tag-picker__list",id:e,role:"listbox",ariaMultiSelectable:"true"});a.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let c=l("div",{ref:"panel",class:"zx-tag-picker__panel",popover:"manual"},a);return t.replaceChildren(o,c),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visible=this._items.slice(),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(o,"pointerdown",u=>{let d=u.target;d.closest(".zx-tag-picker__remove")||d.closest(".zx-tag-picker__toggle")||(u.target!==n&&(u.preventDefault(),this.focus()),this._open||this.open())}),this.listen(s,"click",u=>{let d=u.target.closest(".zx-tag-picker__remove");if(!d||this._disabled||this._readonly)return;u.stopPropagation();let h=[...s.children].indexOf(d.closest(".zx-tag-picker__tag")),f=this._selected[h];f!==void 0&&(this.removeValue(this._valueOf(f)),this.focus())}),this.listen(n,"input",()=>this._onInput()),this.listen(n,"keydown",u=>this._onKeydown(u)),this.listen(n,"blur",()=>this.el.removeAttribute("data-focus")),this.listen(n,"focus",()=>this.el.setAttribute("data-focus","")),this.listen(r,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(c,"pointerdown",u=>u.preventDefault()),this.listen(c,"click",u=>this._onOptionClick(u)),this.listen(document,"pointerdown",u=>{this._open&&!t.contains(u.target)&&this.close()},{capture:!0}),this.setValues(this.options.values,{silent:!0}),this._syncDisabled(),t}get values(){return this.getValues()}set values(t){this.setValues(t)}getValues(){return this._selected.map(t=>this._valueOf(t))}getItems(){return this._selected.slice()}setValues(t,{silent:e=!1}={}){let s=Array.isArray(t)?t:[],n=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),r=[];for(let a of s){if(r.length>=n)break;let c=this._resolve(a);c!==null&&!r.some(u=>this._sameValue(u,c))&&r.push(c)}let o=!gc(r,this._selected,a=>this._valueOf(a));return this._selected=r,this._renderTags(),this._renderOptions(),o&&!e&&this._emitChange(),this}addValue(t,{silent:e=!1}={}){if(this.isFull())return this;let s=this._resolve(t);return s===null?this:this._selected.some(n=>this._sameValue(n,s))?this:(this._selected.push(s),this._renderTags(),this._renderOptions(),e||(this.emit("add",{value:this._valueOf(s),item:s}),this._emitChange()),this)}removeValue(t,{silent:e=!1}={}){let s=this._valueOf(this._resolve(t)??t),n=this._selected.findIndex(o=>Object.is(this._valueOf(o),s));if(n<0)return this;let[r]=this._selected.splice(n,1);return this._renderTags(),this._renderOptions(),e||(this.emit("remove",{value:this._valueOf(r),item:r}),this._emitChange()),this}clear({silent:t=!1}={}){return this.setValues([],{silent:t})}reset({silent:t=!1}={}){return this.setValues(this.options.values,{silent:t})}setItems(t){return this._cancelQuery(),this._items=Array.isArray(t)?t.slice():[],typeof this.options.filter=="function"?this._visible=this._items.slice():this._applyLocalFilter(this.refs.input.value),this._renderOptions(),this._position?.update(),this}isFull(){let t=this.options.max;return t!=null&&this._selected.length>=Number(t)}open(){return this._disabled||this._readonly||this._open?this:(this._open=!0,this.el.setAttribute("data-state","open"),this.refs.input.setAttribute("aria-expanded","true"),this._renderOptions(),this._position=vt(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&&H(t,this._snapshot)}_renderTags(){let t=this._selected.map(e=>{let s=this._labelOf(e),n=this._toneOf(e),r=n?null:this._colorOf(e),o=this.options.renderTag?this.options.renderTag(e):[this._iconOf(e),l("span",{class:"zx-tag-picker__tag-label"},s)],a=l("span",{class:"zx-tag-picker__tag",dataset:{colored:String(!!r),tone:n??void 0},style:r?{"--zx-tag-color":r}:null},o);return!this._readonly&&!this._disabled&&a.append(l("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[s])},w("x",{size:11}))),a});this.refs.tags.replaceChildren(...t),this.el.toggleAttribute("data-empty",this._selected.length===0),this._syncPlaceholder()}_renderOptions(){let t=this.refs.list;this._entries=[];let e=[];for(let r of this._visible){let o=this._valueOf(r),a=this._isSelected(o),c=l("div",{class:"zx-tag-picker__option",id:D("zx-tag-picker-option"),role:"option",ariaSelected:String(a)},l("span",{class:"zx-tag-picker__check",ariaHidden:"true"},a?w("check",{size:13}):null),l("span",{class:"zx-tag-picker__option-label"},this.options.renderItem?this.options.renderItem(r):[this._iconOf(r),l("span",{},this._labelOf(r))]));!a&&this.isFull()&&c.setAttribute("aria-disabled","true"),this._entries.push({item:r,element:c,create:!1}),e.push(c)}let s=this.refs.input.value.trim();if(this._canCreate(s)){let r=l("div",{class:"zx-tag-picker__option",id:D("zx-tag-picker-option"),role:"option",ariaSelected:"false",dataset:{create:"true"}},l("span",{class:"zx-tag-picker__check",ariaHidden:"true"},w("plus",{size:13})),l("span",{class:"zx-tag-picker__option-label"},this._message("tagPicker.create","Create \u201C%1\u201D",[s])));this._entries.push({item:null,element:r,create:!0}),e.push(r)}e.length===0&&e.push(l("div",{class:"zx-tag-picker__empty"},this._loading?this._message("tagPicker.loading","Loading\u2026"):this._message("tagPicker.empty","No matches"))),t.replaceChildren(...e);let n=this._entries.findIndex(r=>this._entryId(r)===this._activeId);this._setActive(n>=0?n:this._entries.length>0?0:-1)}_entryId(t){return t.create?"\0create":String(this._valueOf(t.item))}_syncPlaceholder(){let t=this.refs.input;t.placeholder=this._selected.length===0?String(this.options.placeholder??""):""}_onInput(){let t=this.refs.input.value;this._syncInputWidth(),this._open||this.open(),typeof this.options.filter=="function"?this._scheduleAsyncQuery(t):this._applyLocalFilter(t),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update()}_onKeydown(t){if(this._disabled||this._readonly)return;let e=this.refs.input;switch(t.key){case"ArrowDown":t.preventDefault(),this._open?this._move(1):this.open();return;case"ArrowUp":t.preventDefault(),this._open&&this._move(-1);return;case"Home":this._open&&e.value===""&&(t.preventDefault(),this._setActive(0));return;case"End":this._open&&e.value===""&&(t.preventDefault(),this._setActive(this._entries.length-1));return;case"Enter":{if(!this._open||this._activeIndex<0)return;t.preventDefault(),this._commitEntry(this._entries[this._activeIndex]);return}case"Escape":this._open&&(t.preventDefault(),this.close());return;case"Backspace":e.value===""&&this._selected.length>0&&(t.preventDefault(),this.removeValue(this._valueOf(this._selected[this._selected.length-1])));return;case"Tab":this._open&&this.close();return;default:}}_onOptionClick(t){let e=t.target.closest(".zx-tag-picker__option");if(!e)return;let s=this._entries.find(n=>n.element===e);s&&this._commitEntry(s)}_commitEntry(t){if(!t)return;let e=this.refs.input;if(t.create){let s=e.value.trim(),n=this._createItem(s);this._items=this._items.concat([n]),this.addValue(n),this.emit("create",{value:this._valueOf(n),item:n})}else{let s=this._valueOf(t.item);if(this._isSelected(s))this.removeValue(s);else if(!this.isFull())this.addValue(t.item);else return}e.value="",this._syncInputWidth(),this._applyLocalFilter(""),this._renderOptions(),this.options.closeOnSelect?this.close():(this._setActive(this._entries.length>0?0:-1),this._position?.update()),this.focus()}_move(t){if(this._entries.length===0)return;let e=this._activeIndex<0?t>0?0:this._entries.length-1:Math.min(this._entries.length-1,Math.max(0,this._activeIndex+t));this._setActive(e)}_setActive(t){this._activeIndex=t,this._activeId=this._entries[t]?this._entryId(this._entries[t]):null;for(let[e,s]of this._entries.entries()){let n=e===t;s.element.toggleAttribute("data-active",n),n&&(this.refs.input.setAttribute("aria-activedescendant",s.element.id),s.element.scrollIntoView({block:"nearest"}))}t<0&&this.refs.input.removeAttribute("aria-activedescendant")}_applyLocalFilter(t){if(typeof this.options.filter=="function")return;let e=this.options.searchKeys??[this.options.labelKey];this._visible=xt(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=>Er(this._labelOf(n))===Er(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()?w(e,{size:12}):null;if(!s)return null;let n=this._toneOf(t),r=n?null:this._colorOf(t);return l("span",{class:"zx-tag-picker__visual",dataset:{tone:n??void 0},style:r?{"--zx-tag-color":r}:null,ariaHidden:"true"},s)}_colorOf(t){return Qe(this._readItem(t,this.options.colorKey))}_toneOf(t){return Ir(this._readItem(t,this.options.toneKey))}_readItem(t,e){return typeof e=="function"?e(t):t!==null&&typeof t=="object"&&typeof e=="string"?t[e]:null}_emitChange(){this.emit("change",{values:this.getValues(),items:this.getItems()})}_syncInputWidth(){let t=this.refs.input,e=t.value.length;t.style.inlineSize=e===0?"":`${Math.min(40,e+1)}ch`}_syncDisabled(){let t=this.refs.input;t.disabled=this._disabled,t.readOnly=this._readonly,this.refs.toggle.disabled=this._disabled||this._readonly,this.el.toggleAttribute("data-disabled",this._disabled),this.el.toggleAttribute("data-readonly",this._readonly),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}_message(t,e,s=[]){let n=this.msg(t,...s);return n!==t?n:s.reduce((r,o,a)=>r.replaceAll(`%${a+1}`,String(o)),e)}};function Er(i){return String(i??"").trim().toLocaleLowerCase()}function gc(i,t,e){return i.length!==t.length?!1:i.every((s,n)=>Object.is(e(s),e(t[n])))}function Tr(){S.register("tagpicker",(i,t)=>{let e=i.own(new Je(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 bc(i,t="minutes"){let e=Math.round(Math.abs(Mr(Et(i),t)));return{hours:Math.floor(e/3600),minutes:Math.floor(e/60)%60,seconds:e%60,negative:Et(i)<0}}function yc(i,t="minutes"){re(t);let e=Math.abs(Math.trunc(Et(i?.hours))),s=Math.abs(Math.trunc(Et(i?.minutes))),n=Math.abs(Math.trunc(Et(i?.seconds))),r=i?.negative?-1:1;return Nr(r*(e*3600+s*60+n),t)}var ti=class extends v{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){re(this.options.unit);let t=this.el??l("div");this.el=t,this._originalAriaDisabled=t.getAttribute("aria-disabled"),this._disabled=!!this.options.disabled,this._parts={hours:0,minutes:0,seconds:0,negative:!1},this._inputs=[];let e=l("div",{class:"zx-timebox__content",role:"group",ariaLabel:this.options.seconds?this._message("timebox.durationWithSeconds","Duration in hours, minutes, and seconds"):this._message("timebox.duration","Duration in hours and minutes")});return this._content=e,this.options.signed&&(e.append(l("button",{ref:"sign",class:"zx-timebox__sign",type:"button",ariaLabel:this._message("timebox.toggleSign","Toggle duration sign"),ariaPressed:"false"},"+")),this.listen(this.refs.sign,"click",()=>{this._disabled||(this._parts.negative=!this._parts.negative,this._writeParts(),this._emitChange())})),this._addSegment(e,"hours",this._message("timebox.hours","Hours"),!1),e.append(l("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"minutes",this._message("timebox.minutes","Minutes"),!0),this.options.seconds&&(e.append(l("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(e,"seconds",this._message("timebox.seconds","Seconds"),!0)),t.append(e),this.set(this.options.value,this.options.unit,{silent:!0}),this._syncDisabled(),t}get(t=this.options.unit){return yc(this._readParts(),t)}set(t,e=this.options.unit,s={}){e&&typeof e=="object"&&(s=e,e=this.options.unit),re(e);let n=Et(t);return!this.options.signed&&n<0&&(n=0),this.options.seconds||(n=Nr(Math.round(Mr(n,e)/60)*60,e)),this._parts=bc(n,e),this.options.signed||(this._parts.negative=!1),this._writeParts(),s.silent||this._emitChange(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}destroy(){this._content?.remove(),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),super.destroy()}_addSegment(t,e,s,n){let r=l("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:s,maxLength:n?2:null,dataset:{segment:e,bounded:String(n)}});this._inputs.push(r),t.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"input",()=>{e==="hours"&&this.options.signed&&r.value.trim().startsWith("-")&&(this._parts.negative=!0);let o=r.value.replace(/\D/g,"");r.value=n?o.slice(0,2):o}),this.listen(r,"change",()=>this._commitSegments()),this.listen(r,"keydown",o=>{o.key==="Enter"&&(o.preventDefault(),this._commitSegments(),r.select())})}_readParts(){let t={...this._parts};for(let e of this._inputs){let s=e.dataset.segment,n=e.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;t[s]=Math.max(0,Math.min(n,Math.trunc(Et(e.value))))}return t}_commitSegments(){this._parts=this._readParts(),this._writeParts(),this._emitChange()}_writeParts(){for(let t of this._inputs){let e=t.dataset.segment;t.value=e==="hours"?String(this._parts[e]):wc(this._parts[e])}this.refs.sign&&(this.refs.sign.textContent=this._parts.negative?"-":"+",this.refs.sign.setAttribute("aria-pressed",String(this._parts.negative)),this.refs.sign.dataset.state=this._parts.negative?"negative":"positive")}_syncDisabled(){for(let t of this._inputs)t.disabled=this._disabled;this.refs.sign&&(this.refs.sign.disabled=this._disabled),this.el.setAttribute("aria-disabled",String(this._disabled))}_emitChange(){this.emit("change",{value:this.get(this.options.unit)})}_message(t,e){let s=this.msg(t);return s===t?e:s}};function Et(i){let t=Number(i);return Number.isFinite(t)?t:0}function Mr(i,t){return re(t),t==="hours"?i*3600:t==="minutes"?i*60:i}function Nr(i,t){return re(t),t==="hours"?i/3600:t==="minutes"?i/60:i}function re(i){if(i!=="hours"&&i!=="minutes"&&i!=="seconds")throw new RangeError(`Unknown time unit: ${i}`)}function wc(i){return String(i).padStart(2,"0")}function Or(){S.register("time",(i,t)=>{let e=i.own(new ti(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 Bt=class extends v{static cssName="toggle";static defaults={checked:!1,value:!0,label:null,disabled:!1};render(){let t=!this.el,e=this.el??l("button");if(this.el=e,e.localName!=="button")throw new TypeError("Toggle target must be a button element");this._createdRoot=t,this._original=t?null:xc(e),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,e.type="button",e.setAttribute("role","switch");let s=[l("span",{class:"zx-toggle__track",ariaHidden:"true"},l("span",{class:"zx-toggle__thumb"}))];return this.options.label!==null&&s.push(l("span",{class:"zx-toggle__label"},String(this.options.label))),e.replaceChildren(...s),this._sync(),this.listen(e,"click",()=>this.toggle()),e}get(){return this._checked}set(t,{silent:e=!1}={}){let s=!!t;return s===this._checked?this:(this._checked=s,this._sync(),e||this.emit("change",{checked:this._checked,value:this.getValue()}),this)}toggle(){return this.set(!this._checked)}getValue(){return this._checked?this.options.value:!1}enable(){return this._disabled=!1,this.el.removeAttribute("disabled"),this}disable(){return this._disabled=!0,this.el.setAttribute("disabled",""),this}destroy(){this._cleaned||(this._cleaned=!0,super.destroy(),!this._createdRoot&&this._original&&vc(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function xc(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function vc(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 Fr(){S.register("toggle",(i,t)=>{let e=i.own(new Bt(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 ei=class extends v{static cssName="value-list";static defaults={values:[],placeholder:"",deletable:!0,sortable:!0,unique:!0,validate:null};render(){let t=this.el??l("div");this._ownedNodes=[],this._disabled=!1,this._dragIndex=-1,this._initialState=t.getAttribute("data-state"),this._initialDisabled=t.getAttribute("data-disabled"),this._values=Rr(this.options.values,!!this.options.unique);let e=D("zx-value-list-instructions");return this._list=l("ul",{class:"zx-value-list__list",role:"listbox",ariaLabel:this._message("valueList.values","Values"),ariaOrientation:"horizontal"}),this._input=l("input",{class:"zx-value-list__input",type:"text",placeholder:String(this.options.placeholder??""),ariaLabel:this._message("valueList.add","Add value"),ariaDescribedby:e}),this._status=l("div",{class:"zx-value-list__status",role:"status",ariaLive:"polite"}),this._instructions=l("span",{class:"zx-value-list__instructions",id:e},this._message("valueList.instructions","Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder.")),this._ownedNodes.push(this._list,this._input,this._status,this._instructions),t.append(this._list,this._input,this._status,this._instructions),this.listen(this._input,"keydown",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=Rr(t,!!this.options.unique),this._renderChips(),e||this.emit("change",{values:this.getValues()}),this}addValue(t){if(this._disabled)return!1;let e=String(t??"").trim();if(!e)return!1;if(this.options.unique&&this._values.includes(e))return this._showError(this._message("valueList.duplicate","This value already exists.")),!1;if(typeof this.options.validate=="function"){let s=this.options.validate(e);if(s!==!0)return this._showError(typeof s=="string"?s:this._message("valueList.invalid","This value is not valid.")),!1}return this._status.textContent="",this._input.removeAttribute("aria-invalid"),this._values.push(e),this._renderChips(),this.emit("add",{value:e}),this.emit("change",{values:this.getValues()}),!0}removeValue(t){if(this._disabled||!this.options.deletable)return!1;let e=this._values.indexOf(String(t));return e<0?!1:(this._removeAt(e),!0)}focus(){return this._input.focus(),this}enable(){return this._disabled=!1,this._input.disabled=!1,this.el.dataset.disabled="false",this._renderChips(),this}disable(){return this._disabled=!0,this._input.disabled=!0,this.el.dataset.disabled="true",this._renderChips(),this}_renderChips(t=-1){let e=this._values.map((s,n)=>l("li",{class:"zx-value-list__chip",role:"option",tabIndex:this._disabled?-1:0,draggable:!!this.options.sortable&&!this._disabled,ariaSelected:"false",ariaDisabled:String(this._disabled),ariaLabel:this.options.deletable?this._message("valueList.removable","%1. Press Delete to remove.",s):s,dataset:{index:n}},l("span",{class:"zx-value-list__value"},s),this.options.deletable?l("span",{class:"zx-value-list__remove",dataset:{remove:""},ariaHidden:"true"},"\xD7"):null));this._list.replaceChildren(...e),t>=0&&e[Math.min(t,e.length-1)]?.focus()}_handleInputKeydown(t){this._disabled||(t.key==="Enter"?(t.preventDefault(),this.addValue(this._input.value)&&(this._input.value="")):t.key==="Backspace"&&this._input.value===""&&this._values.length&&this.options.deletable&&(t.preventDefault(),this._removeAt(this._values.length-1)))}_handleChipKeydown(t){if(this._disabled)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;if(!e)return;let s=Number(e.dataset.index);if((t.key==="Delete"||t.key==="Backspace")&&this.options.deletable){t.preventDefault(),this._removeAt(s,Math.min(s,this._values.length-2));return}let n=t.key==="ArrowLeft"?-1:t.key==="ArrowRight"?1:0,r=t.key==="ArrowUp"?-1:t.key==="ArrowDown"?1:0,o=n||r;if(!o)return;t.preventDefault();let a=Math.max(0,Math.min(this._values.length-1,s+o));t.ctrlKey&&n&&this.options.sortable?this._move(s,a,!0):this._list.querySelector(`[data-index="${a}"]`)?.focus()}_handleChipClick(t){let e=t.target instanceof Element?t.target:null,s=e?.closest("[data-index]");!s||this._disabled||(e.closest("[data-remove]")&&this.options.deletable?this._removeAt(Number(s.dataset.index)):s.focus())}_handleDragStart(t){if(this._disabled||!this.options.sortable)return;let e=t.target instanceof Element?t.target.closest("[data-index]"):null;e&&(this._dragIndex=Number(e.dataset.index),this.el.dataset.state="dragging",t.dataTransfer?.setData("text/plain",String(this._dragIndex)),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"))}_handleDrop(t){if(this._dragIndex<0||this._disabled)return;t.preventDefault();let e=t.target instanceof Element?t.target.closest("[data-index]"):null,s=e?Number(e.dataset.index):this._values.length-1;this._move(this._dragIndex,s,!0),this._finishDrag()}_finishDrag(){this._dragIndex=-1,this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_move(t,e,s){if(t===e||t<0||e<0||t>=this._values.length||e>=this._values.length)return;let[n]=this._values.splice(t,1);this._values.splice(e,0,n),this._renderChips(s?e:-1),this.emit("change",{values:this.getValues()})}_removeAt(t,e=-1){let[s]=this._values.splice(t,1);s!==void 0&&(this._renderChips(e),e<0&&this._values.length===0&&this._input.focus(),this.emit("remove",{value:s}),this.emit("change",{values:this.getValues()}))}_showError(t){this._status.textContent=t,this._input.setAttribute("aria-invalid","true")}_message(t,e,...s){let n=this.msg(t,...s);return n===t?O(e,s):n}destroy(){for(let t of this._ownedNodes??[])t.remove();this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState),this._initialDisabled===null?this.el.removeAttribute("data-disabled"):this.el.setAttribute("data-disabled",this._initialDisabled),super.destroy()}};function Rr(i,t){if(!Array.isArray(i))return[];let e=i.map(s=>String(s));return t?[...new Set(e)]:e}function Lr(){S.register("valuelist",(i,t)=>{let e=i.own(new ei(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 ii=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),Sc=["xl","lg","md","sm"];function Pr(i){let t=Number(i);if(!Number.isFinite(t))return"xs";for(let e of Sc)if(t>=ii[e])return e;return"xs"}function jr(i,t={}){if(typeof i!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in t&&!q(t.target)&&t.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let e=t.target??globalThis,s=q(e)?e:null,n=null,r=!1,o=null,a=()=>s?s.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,c=()=>{if(r)return;let h=a();if(s&&h===0)return;let f=Pr(h);f!==n&&(n=f,i(n,h))};c();let u=0,d=()=>{u||r||(u=requestAnimationFrame(()=>{u=0,c()}))};return s&&typeof ResizeObserver=="function"?(o=new ResizeObserver(d),o.observe(s)):globalThis.addEventListener?.("resize",c,{passive:!0}),{current:()=>n??Pr(a()),destroy:()=>{r||(r=!0,u&&cancelAnimationFrame(u),o?.disconnect(),globalThis.removeEventListener?.("resize",c))}}}var Ac=0,kc=20,zc=3;var Vr=new Map;function si(i,t={}){let e=cs(i);if(e===null)return"";let{locale:s=ht(),decimals:n,minDecimals:r,maxDecimals:o,group:a=!0}=t;return as(s,ls({decimals:n,minDecimals:r,maxDecimals:o,group:a}),e)}function $r(i,t,e={}){let s=cs(i);if(s===null)return"";let{locale:n=ht(),decimals:r}=e,o=Cc(t);if(o===null)return si(s,{locale:n,decimals:r});let a=ls({decimals:r,group:!0});return as(n,{...a,style:"currency",currency:o},s)}function Br(i,t={}){let e=cs(i);if(e===null)return"";let{locale:s=ht(),decimals:n=0}=t;return as(s,{...ls({decimals:n,group:!0}),style:"percent"},e)}function as(i,t,e){let s=`${i}\0${JSON.stringify(t)}`,n=Vr.get(s);return n===void 0&&(n=Dc(i,t),Vr.set(s,n)),n.format(e)}function Dc(i,t){try{return new Intl.NumberFormat(i,t)}catch{try{return new Intl.NumberFormat(void 0,t)}catch{return new Intl.NumberFormat}}}function ls({decimals:i,minDecimals:t,maxDecimals:e,group:s=!0}){let n={useGrouping:s!==!1},r=qr(t??i),o=qr(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,zc)),n}function qr(i){if(i==null)return null;let t=Number(i);return Number.isFinite(t)?Math.min(kc,Math.max(Ac,Math.round(t))):null}function cs(i){if(i==null||i==="")return null;let t=typeof i=="number"?i:Number(i);return Number.isFinite(t)?t:null}function Cc(i){if(typeof i!="string")return null;let t=i.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}var Ic=".zx-scope, [data-zx-theme], [data-zx-preset]";function at(i=null){let e=(i==null?document.activeElement instanceof Element?document.activeElement:null:wt(i))?.closest?.(Ic)??null;return!e||e===document.documentElement||e===document.body?document.body:e}function Kr(i=null){if(i==null)return at(null);let t=wt(i);return t?.isConnected?at(t):null}var Ec=Object.freeze({size:"md",label:"",showLabel:!1,kind:"accent"}),Tc=Object.freeze({sm:!0,md:!0,lg:!0});function Hr(i={}){let t={...Ec,...i},e=String(t.label??""),s=l("span",{class:"zx-spinner",dataset:{size:Tc[t.size]?t.size:"md",kind:t.kind==="current"?"current":"accent"}},l("span",{class:"zx-spinner__ring",ariaHidden:"true"}));return e?(s.setAttribute("role","status"),s.append(l("span",{class:"zx-spinner__label",dataset:{visible:t.showLabel?"true":null}},e))):s.setAttribute("aria-hidden","true"),s}var Mc=Object.freeze({label:"",icon:null,kind:"default",size:"md",disabled:!1});function Yr(i={}){let t={...Mc,...i},e=l("button",{class:"zx-btn",type:"button",disabled:!!t.disabled,title:t.title??(t.shortcut?`${t.label} (${t.shortcut.label})`:void 0),ariaKeyshortcuts:t.shortcut?.keys,dataset:{kind:Oc(t.kind),size:Fc(t.size)}});return t.icon&&e.append(w(t.icon,{size:16})),t.label!==""&&e.append(l("span",{class:"zx-btn__label"},String(t.label))),t.shortcut&&e.append(l("kbd",{class:"zx-btn__shortcut",ariaHidden:"true"},t.shortcut.label)),!t.label&&t.title&&e.setAttribute("aria-label",t.title),typeof t.onclick=="function"&&(e.onclick=t.onclick),t.busy&&Nc(e,!0),e}function Nc(i,t){if(i.hasAttribute("data-busy-guard")||(i.setAttribute("data-busy-guard",""),i.addEventListener("click",e=>{i.getAttribute("aria-busy")==="true"&&(e.preventDefault(),e.stopImmediatePropagation())},{capture:!0})),i.querySelector(":scope > .zx-btn__spinner")?.remove(),t){i.setAttribute("aria-busy","true"),i.setAttribute("aria-disabled","true");let e=Hr({size:"sm",kind:"current"});e.classList.add("zx-btn__spinner"),i.prepend(e)}else i.removeAttribute("aria-busy"),i.removeAttribute("aria-disabled");return i}function Oc(i){return["primary","danger","ghost"].includes(String(i))?i:"default"}function Fc(i){return i==="sm"?"sm":"md"}function Rc(i,t){return String(i).localeCompare(String(t))}function Lc(i,t){return i-t}function Pc(i,t){return i.getTime()-t.getTime()}function jc(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=Pc(i,t):typeof i=="number"&&typeof t=="number"?r=Lc(i,t):r=Rc(i,t),e==="desc"?-r:r}function Vc(i,t="asc"){return(e,s)=>jc(i(e),i(s),t)}function us(i,t,e="asc"){let s=Vc(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 qc=new Set(["text","number","select","date","checkbox","textarea"]),$c='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',oe=class extends v{static cssName="table";static defaults={columns:[],data:[],rowId:"ID",sort:null,sortMode:"local",selectable:!1,stickyHeader:!0,responsive:!1,growing:!1,height:null,emptyText:null,rowClass:null,rowKind:null,rowKinds:null,zebra:!0,variant:"default",editMode:!1,editTrigger:"double",hierarchy:!1,rowReorder:!1,columnVisibility:!1,columnReorder:!1,hiddenColumns:[]};constructor(t,e={}){super(t,e)}render(){let t=this.el===null,e=this.el??l("div");if(this.el=e,this._createdRoot=t,this._original=t?null:K(e),this._columns=Wr(this.options.columns),this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._rowKind=tu(this.options.rowKind),this._rowKinds=eu(this.options.rowKinds),this._spanning=this._hasSpanningRow(),this._sortWarned=!1,this._selected=new Set,this._selectionAnchorId=null,this._sort=Qr(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=nu(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=hu(this.options.growing),this._rendered=this._growStep??1/0,this._more=null,this._rovingKey=null,this._rovingCell=null,this._rovingMatched=!1,this._hierarchy=ds(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._columnControlIds=new Map,this._columnStatus=null,this._expanded=iu(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let s of ni(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(s);return this._reconcileExpanded(),su(this.options.variant)==="plain"&&(e.dataset.variant="plain"),this._table=l("table",{class:"zx-table__table"}),this._hierarchy&&this._table.setAttribute("role","treegrid"),this._colgroup=l("colgroup",{class:"zx-table__columns"}),this._thead=l("thead",{class:"zx-table__head"}),this._tbody=l("tbody",{class:"zx-table__body"}),this._table.append(this._colgroup,this._thead,this._tbody),this._scroll=l("div",{class:"zx-table__scroll",dataset:{stickyHeader:String(!!this.options.stickyHeader),zebra:String(!!this.options.zebra)}},this._table),this._rowMoveMessage=this.options.rowReorder?l("div",{class:"zx-table__reorder-status",role:"status",ariaLive:"polite"}):null,this.options.height!=null&&(this._scroll.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._columnControls=this.options.columnVisibility||this.options.columnReorder?this._createColumnControls():null,this._editMode===!1?e.replaceChildren(...[this._columnControls,this._scroll,this._rowMoveMessage].filter(Boolean)):(e.dataset.editMode=this._editMode,this._editMessage=l("div",{class:"zx-table__message",id:D("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.listen(this._columnControls,"click",s=>this._handleColumnControlClick(s)),this.listen(this._columnControls,"keydown",s=>this._handleColumnControlKeydown(s))),this._editMode!==!1&&(this.listen(this._tbody,"keydown",s=>this._handleEditKeydown(s)),this.listen(this._tbody,"focusin",s=>this._handleEditFocusIn(s)),this.listen(document,"pointerdown",s=>this._handleDocumentPointerDown(s),{capture:!0})),e}setLoading(t=!0){return t?this.el.dataset.loading="true":delete this.el.dataset.loading,this.el.setAttribute("aria-busy",String(!!t)),this}setData(t){this._rendered=this._growStep??1/0,this.setLoading(!1),Gr(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 Gr(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]}getColumns(){return this._columns.map(t=>({...t}))}setColumns(t,e={}){let s=Wr(t),n=this.getColumnOrder(),r=this.getHiddenColumns(),o=this.getSort();return this._abortEdit({focus:!1}),this._columns=s,this._hiddenColumns=new Set(r.filter(a=>s.some(c=>c.id===a))),this._hiddenColumns.size>=s.length&&s[0]&&this._hiddenColumns.delete(s[0].id),this._sort=Qr(o,s),this._hierarchy=ds(this.options.hierarchy,s),this._reconcileExpanded(),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(),e.silent||(oi(n,this.getColumnOrder())||this.emit("columnorderchange",{order:this.getColumnOrder()}),oi(r,this.getHiddenColumns())||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()})),this}getColumnOrder(){return this._columns.map(t=>t.id)}setColumnOrder(t,e={}){let s=lu(this._columns,t);if(oi(s,this.getColumnOrder()))return this;let n=this._activeColumnControl(),r=new Map(this._columns.map(o=>[o.id,o]));return this._abortEdit({focus:!1}),this._columns=s.map(o=>r.get(o)),this._hierarchy=ds(this.options.hierarchy,this._columns),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(n),e.silent||this.emit("columnorderchange",{order:this.getColumnOrder()}),this}moveColumn(t,e,s="before",n={}){if(s!=="before"&&s!=="after")throw new TypeError('Table column position must be "before" or "after"');let r=cu(this.getColumnOrder(),String(t),String(e),s);if(oi(r,this.getColumnOrder()))return this;if(this.setColumnOrder(r,n),this._columnStatus){let o=this._columns.find(c=>c.id===String(t)),a=this.getColumnOrder().indexOf(String(t));o&&a>=0&&(this._columnStatus.textContent=`Moved ${ai(o)} to position ${a+1} of ${this._columns.length}.`)}return this}getVisibleColumns(){return this._visibleColumns().map(t=>t.id)}getHiddenColumns(){return this._columns.filter(t=>this._hiddenColumns.has(t.id)).map(t=>t.id)}setColumnVisible(t,e=!0,s={}){let n=String(t);if(!this._columns.find(c=>c.id===n))throw new RangeError(`Unknown table column: ${n}`);let o=this._activeColumnControl();if(!e&&!this._hiddenColumns.has(n)&&this._visibleColumns().length<=1)return this._renderColumnControls(o),this;let a=e?this._hiddenColumns.delete(n):!this._hiddenColumns.has(n);return!e&&a&&this._hiddenColumns.add(n),a?(this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(o),s.silent||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()}),this):this}toggleColumn(t,e={}){return this.setColumnVisible(t,this._hiddenColumns.has(String(t)),e)}moveRow(t,e,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;if(this._isSpanningRow(n))return this;let o=eo(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),u=c.findIndex(d=>Object.is(d,t));this._rowMoveMessage.textContent=`Moved row to position ${u+1} of ${c.length}.`}return this._emitDataChange(),queueMicrotask(()=>this._rowHandle(t)?.focus()),this}empty(){let t=this._selected.size>0;return this._data=[],this._expanded.clear(),this._selected.clear(),this._selectionAnchorId=null,this._renderBody(),t&&this._emitSelectionChange(),this._emitDataChange(),this}setSort(t,e,s={}){if(this._spanning)return this._sortWarned||(this._sortWarned=!0,console.warn("[zx.Table] setSort() is inert while the data contains spanning rowKinds rows: sorting would scatter the rows out of the sections that group them.")),this;if(this._abortEdit({focus:!1}),!this._columns.find(o=>o.id===t))throw new RangeError(`Unknown table column: ${t}`);let r=e??(this._sort?.id===t&&this._sort.dir==="asc"?"desc":"asc");if(r!=="asc"&&r!=="desc")throw new TypeError('Table sort direction must be "asc" or "desc"');return this._sort={id:t,dir:r},this.options.sortMode==="local"&&(this._sortData(),this._renderBody()),this._syncSortHeader(),s.silent||this.emit("sort",{id:t,dir:r}),this}getSort(){return this._sort?{...this._sort}:null}clearSort(t={}){return this._sort?(this._abortEdit({focus:!1}),this._sort=null,this._syncSortHeader(),t.silent||this.emit("sort",{id:null,dir:null}),this):this}getSelection(){return this._data.filter(t=>this._selected.has(this._idFor(t)))}setSelection(t){if(!Array.isArray(t))throw new TypeError("Table selection must be an array of row ids");let e=this._selectableIds(),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 du(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=ni(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;if(this._isSpanningRow(n))return this;let r=this._editMode==="row"&&this._hiddenColumns.has(s.id)?this._visibleColumns().find(f=>Kt(f,n)!==!1)??null:s;if(!r||Kt(r,n)===!1)return this;let o=r.id;if(this._edit){if(Object.is(this._edit.id,t)&&this._edit.cells.has(o))return this._edit.columnId=o,this._focusEditor(o),this;if(this.commitEdit(),this._edit)return this}let a=this._data.findIndex(f=>Object.is(this._idFor(f),t));if(a<0)return this;let c=this._data[a],u=this._rowElements.get(t)?.[0];if(!u)return this;let d=this._editMode==="row"?this._visibleColumns().filter(f=>Kt(f,c)!==!1):[r],h=new Map;for(let f of d){let p=Zr(u,f.id);if(!p)continue;let _=this._createEditor(p,f,c,a);_&&h.set(f.id,_)}return h.size===0?this:(this._edit={id:t,columnId:o,row:c,cells:h,tr:u},u.dataset.editing="true",this.emit("editstart",{row:c,id:t,column:r,columnId:o,value:c?.[o]}),this._focusEditor(o),this)}commitEdit(){let t=this._edit;if(!t)return this;let e=this.getRow(t.id)??t.row,s={};for(let[h,f]of t.cells)s[h]=f.read();let n=this._columns.filter(h=>t.cells.has(h.id)),r=Jc(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(h=>h.id===r.columnId)??null,columnId:r.columnId,value:s[r.columnId],message:r.message}),this._focusEditor(r.columnId),this;this._clearInvalid();let o=Xc(e,s),a=t.columnId;if(this.emit("editcommit",{row:e,id:t.id,column:this._columns.find(h=>h.id===a)??null,columnId:a,value:s[a],previous:e?.[a],changes:o}).defaultPrevented)return this;let u=this._editHasFocus(),d={...e,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(t.id,d),u&&this._focusCell(this._idFor(d),a),this}cancelEdit(){return this._abortEdit({focus:!0}),this}isEditing(){return this._edit!==null}getEditing(){return this._edit?{id:this._edit.id,columnId:this._edit.columnId}:null}_visibleData(){return this._visibleEntries().map(t=>t.row)}_projectedData(){return this._hierarchy?Uc(this._data,this.options.rowId,this._hierarchy.parentId,this._expanded):this._data.map((t,e)=>({row:t,id:this._idFor(t),index:e,depth:0,hasChildren:!1,parentId:null}))}_visibleEntries(){let t=this._projectedData();return this._rendered===1/0?t:t.slice(0,this._rendered)}growBy(t){if(!this._growStep)return this;let e=Number(t)>0?Math.trunc(Number(t)):this._growStep,s=this._rendered,n=this._projectedData().length;return this._rendered=Math.min(n,this._rendered+e),this._rendered===s?this:(this._renderBody(),this.emit("grow",{rendered:this._rendered,total:n}),this)}showAll(){return this.growBy(this._projectedData().length)}getRenderedCount(){return Math.min(this._rendered,this._projectedData().length)}_syncGrowing(){if(!this._growStep)return;let t=this._projectedData().length-this.getRenderedCount();if(t<=0){this._more?.remove(),this._more=null;return}let e=this._message("table.more","Show %1 more",[t]);this._more||(this._more=l("button",{class:"zx-table__more",type:"button",onclick:()=>this.growBy()}),this.el.append(this._more)),this._more.textContent=e,this._more.setAttribute("aria-label",e)}_message(t,e,s){let n=this.msg(t,...s);return n===t?O(e,s):n}_watchWidth(){this._width?.destroy(),this._width=null;let t=this.options.responsive;!t||!(t in ii)||(this._width=jr((e,s)=>this._setStacked(s>0&&s<ii[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&&(H(this.el,this._original),this._restored=!0),super.destroy()}_visibleColumns(){return this._columns.filter(t=>!this._hiddenColumns.has(t.id))}_isSpanningRow(t){return this._rowKind===null||this._rowKinds===null?!1:to(t,this._rowKind,this._rowKinds)}_hasSpanningRow(){return Bc(this._data,this._rowKind,this._rowKinds)}_spanColspan(){return Kc(this._visibleColumns().length,{selectable:this.options.selectable,rowReorder:this.options.rowReorder})}_selectableData(){let t=this._visibleData();return this._rowKind===null?t:t.filter(e=>!this._isSpanningRow(e))}_createColumnControls(){let t=l("div",{class:"zx-table__column-list"});this._columnList=t,this._columnStatus=l("div",{class:"zx-table__column-status",role:"status",ariaLive:"polite"});let e=l("details",{class:"zx-table__column-controls"},l("summary",{class:"zx-btn",dataset:{size:"sm"}},w("fields"),this._message("table.columns","Columns",[])),t);return this._renderColumnControls(),e}_renderColumnControls(t=null){if(!this._columnList)return;let e=this._visibleColumns(),s=this._columns.map((n,r)=>{let o=!this._hiddenColumns.has(n.id),a=this._columnControlIds.get(n.id);a||(a=D("zx-table-column"),this._columnControlIds.set(n.id,a));let c=this.options.columnVisibility?l("input",{id:a,class:"zx-table__column-toggle",type:"checkbox",value:n.id,checked:o,disabled:o&&e.length===1,dataset:{columnId:n.id,columnAction:"toggle"}}):null,u=ai(n),d=c?l("label",{for:a},c,l("span",{},u)):l("span",{class:"zx-table__column-label"},u),h=this.options.columnReorder?l("span",{class:"zx-table__column-order",role:"group",ariaLabel:this._message("table.moveColumn","Move %1",[u])},l("button",{class:"zx-table__column-move",type:"button",disabled:r===0,ariaLabel:`Move ${u} earlier`,dataset:{columnId:n.id,columnAction:"up"}},w("chevron-up",{size:11})),l("button",{class:"zx-table__column-move",type:"button",disabled:r===this._columns.length-1,ariaLabel:`Move ${u} later`,dataset:{columnId:n.id,columnAction:"down"}},w("chevron-down",{size:11}))):null;return l("div",{class:"zx-table__column-option",dataset:{columnId:n.id}},d,h)});if(this._columnList.replaceChildren(...s,this._columnStatus),t!==null){let n=[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===t.id&&o.dataset.columnAction===t.action});n?.disabled&&(n=[...this._columnList.querySelectorAll(".zx-table__column-move[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===t.id&&!o.disabled})??[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===t.id&&!o.disabled})),queueMicrotask(()=>{n?.isConnected&&n.focus()})}}_activeColumnControl(){let t=typeof document>"u"?null:document.activeElement;if(!t||!this._columnList?.contains(t))return null;let e=t.dataset.columnId,s=t.dataset.columnAction;return e&&s?{id:e,action:s}:null}_handleColumnControlClick(t){let e=t.target?.closest?.(".zx-table__column-move");if(!e||!this._columnList?.contains(e))return;let s=e.dataset.columnId,n=e.dataset.columnAction,r=this.getColumnOrder().indexOf(String(s));n==="up"&&r>0&&this.moveColumn(String(s),this._columns[r-1].id,"before"),n==="down"&&r>=0&&r<this._columns.length-1&&this.moveColumn(String(s),this._columns[r+1].id,"after")}_handleColumnControlKeydown(t){let e=t.target?.closest?.(".zx-table__column-move");if(!e||!this._columnList?.contains(e))return;let s=String(e.dataset.columnId),n=this.getColumnOrder(),r=n.indexOf(s);r<0||(t.key==="ArrowUp"||t.key==="ArrowLeft"?(t.preventDefault(),r>0&&this.moveColumn(s,n[r-1],"before")):t.key==="ArrowDown"||t.key==="ArrowRight"?(t.preventDefault(),r<n.length-1&&this.moveColumn(s,n[r+1],"after")):t.key==="Home"?(t.preventDefault(),r>0&&this.moveColumn(s,n[0],"before")):t.key==="End"&&(t.preventDefault(),r<n.length-1&&this.moveColumn(s,n.at(-1),"after")))}_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)),a=r[o+(t.key==="ArrowUp"?-1:1)];a!==void 0&&this.moveRow(n.id,a,t.key==="ArrowUp"?"before":"after")}_siblingIds(t){let e=this.getRow(t);if(!e)return[];let s=this._hierarchy?J(this._hierarchy.parentId,e):null;return this._data.filter(n=>!this._hierarchy||fs(J(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&&fs(J(this._hierarchy.parentId,s),J(this._hierarchy.parentId,n)))}_rowHandle(t){return this._rowElements.get(t)?.[0]?.querySelector(".zx-table__row-handle")??null}_clearDropMarkers(){for(let t of this._tbody.querySelectorAll("tr[data-drop]"))delete t.dataset.drop}_clearRowDrag(){for(let t of this._tbody.querySelectorAll("tr[data-dragging]"))delete t.dataset.dragging;this._clearDropMarkers(),this._dragId=null}_hierarchyColumn(){return this._hierarchy?this._visibleColumns().some(t=>t.id===this._hierarchy.column)?this._hierarchy.column:this._visibleColumns()[0]?.id??null:null}_renderColumns(){let t=document.createDocumentFragment();this.options.rowReorder&&t.append(l("col",{class:"zx-table__reorder-column"})),this.options.selectable==="multi"&&t.append(l("col",{class:"zx-table__selection-column"}));let e=this._visibleColumns(),s=e.map(r=>uu(r.width)),n=s.reduce((r,o)=>r+o,0);this._table.dataset.layout=n>0?"fixed":"auto",e.forEach((r,o)=>{let a=l("col");s[o]>0?a.style.width=`${s[o]/n*100}%`:r.width&&r.width!=="auto"&&(a.style.width=String(r.width)),t.append(a)}),this._colgroup.replaceChildren(t)}_renderHeader(){let t=l("tr",{class:"zx-table__header-row"});if(this._growStep&&t.setAttribute("aria-rowindex","1"),this.options.rowReorder&&t.append(l("th",{class:"zx-table__reorder-header",scope:"col",ariaLabel:"Row order"})),this.options.selectable==="multi"){this._selectAll=l("input",{class:"zx-table__checkbox zx-table__select-all",type:"checkbox",ariaLabel:"Select all rows"});let e=l("th",{class:"zx-table__selection-header",scope:"col"},this._selectAll);t.append(e),this.listen(this._selectAll,"click",()=>{if(this._selectAll.checked)for(let s of this._selectableData())this._selected.add(this._idFor(s));else for(let s of this._selectableData())this._selected.delete(this._idFor(s));this._selectionAnchorId=null,this._syncSelection(),this._emitSelectionChange()})}else this._selectAll=null;this._headers=new Map,this._headerSpanning=this._spanning;for(let e of this._visibleColumns()){let s=l("th",{scope:"col",dataset:{column:e.id}}),n=e.align??(hs(e)?"end":null);n&&(s.dataset.align=n),e.headerTitle&&(s.title=e.headerTitle);let r=ou(e);if(r!==null&&s.setAttribute("aria-label",r),e.sortable&&!this._spanning){let o=l("button",{class:"zx-table__sort-button",type:"button",ariaLabel:r??void 0},l("span",{class:"zx-table__header-label"},e.label));this.listen(o,"click",()=>{let a=this._sort?.id===e.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(e.id,a)}),s.append(o)}else s.append(l("span",{class:"zx-table__header-label"},e.label));this._headers.set(e.id,s),t.append(s)}this._thead.replaceChildren(t),this._syncSortHeader()}_renderBody(){this._abortEdit({focus:!1}),this._spanning=this._hasSpanningRow(),this._headers&&this._spanning!==this._headerSpanning&&this._renderHeader();let t=document.createDocumentFragment();this._rowMeta=new WeakMap,this._rowElements=new Map,this._rovingCell=null,this._rovingMatched=!1;let e=this._projectedData();this._hierarchyMeta=new Map(e.map(s=>[s.id,s])),this._data.length===0?t.append(l("tr",{class:"zx-table__empty-row"},l("td",{class:"zx-table__empty",colspan:this._spanColspan()},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=l("tr",{dataset:{row:""}});this._growStep&&r.setAttribute("aria-rowindex",String(s.visibleIndex+2));let o=typeof this.options.rowClass=="function"?this.options.rowClass(t):"";o&&r.classList.add(...String(o).split(/\s+/).filter(Boolean));let a=this._rowKind===null?null:Xr(t,this._rowKind),c=a===null?null:Jr(this._rowKinds,a),u=!!c?.span;a!==null&&(r.dataset.rowKind=a),c?.class&&r.classList.add(...String(c.class).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&!u&&r.setAttribute("aria-selected",String(this._selected.has(n))),this._hierarchy&&(r.setAttribute("aria-level",String(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 d=this._rowElements.get(n)??[];if(d.push(r),this._rowElements.set(n,d),u){r.dataset.span="true";let h=l("th",{class:"zx-table__section-cell",scope:"colgroup",colspan:this._spanColspan()}),f=Hc(t,c,this._visibleColumns(),e);return f&&typeof f=="object"&&typeof f.nodeType=="number"?h.append(f):f!=null&&h.append(document.createTextNode(String(f))),r.append(h),r}if(this.options.rowReorder){let h=l("button",{class:"zx-table__row-handle",type:"button",draggable:!0,dataset:{rowHandle:""},ariaLabel:`Move row ${e+1}`,ariaPressed:String(Object.is(this._grabbedId,n)),disabled:!!(this._sort&&this.options.sortMode==="local"),title:this._sort&&this.options.sortMode==="local"?"Clear sorting to reorder rows":null},w("drag",{size:14}));r.append(l("td",{class:"zx-table__reorder-cell"},h))}if(this.options.selectable==="multi"){let h=l("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",checked:this._selected.has(n),ariaLabel:`Select row ${e+1}`});r.append(l("td",{class:"zx-table__selection-cell"},h))}return this._visibleColumns().forEach(h=>{let f=l("td"),p=h.align??(hs(h)?"end":null);p&&(f.dataset.align=p),f.dataset.label=h.label,f.dataset.column=h.id,h.popin===!1&&(f.dataset.popin="false"),this._editMode!==!1&&Kt(h,t)!==!1&&(f.dataset.editable="true",f.tabIndex=-1,this._offerRovingCell(f,n,h.id)),this._renderCellContent(f,h,t,e,s),r.append(f)}),r}_renderCellContent(t,e,s,n,r=this._hierarchyMeta?.get(this._idFor(s))){let o=Yc(e,s,n),a=l("span",{class:"zx-table__cell-content"});if(o&&typeof o=="object"&&typeof o.nodeType=="number"?a.append(o):o!=null&&a.append(document.createTextNode(String(o))),!this._hierarchy||e.id!==this._hierarchyColumn()||!r){t.replaceChildren(...a.childNodes);return}let c=l("span",{class:"zx-table__tree-cell"});if(c.style.setProperty("--zx-table-depth",String(r.depth)),r.hasChildren){let u=this._expanded.has(r.id);c.append(l("button",{class:"zx-table__tree-toggle",type:"button",ariaExpanded:String(u),ariaLabel:`${u?"Collapse":"Expand"} row ${n+1}`},w(u?"chevron-down":"chevron-right",{size:14})))}else c.append(l("span",{class:"zx-table__tree-spacer",ariaHidden:"true"}));c.append(a),t.replaceChildren(c)}_handleBodyClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(this._edit&&ri(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(!(this._editMode!==!1&&Ur(e))){if(this._editMode!==!1&&this._editTrigger==="single"){let a=e?.closest('td[data-editable="true"]');if(a&&this._tbody.contains(a)){this.startEdit(n.id,String(a.dataset.column));return}}this.emit("rowclick",{...n,event:t}),this.options.selectable==="single"&&!this._selected.has(n.id)&&!this._isSpanningRow(n.row)&&(this._selected=new Set([n.id]),this._selectionAnchorId=n.id,this._syncSelection(),this._emitSelectionChange())}}_handleBodyDoubleClick(t){let e=t.target?.nodeType===1?t.target:t.target?.parentElement;if(e?.closest(".zx-table__row-checkbox")||this._edit&&ri(e))return;let s=e?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s);if(n&&!(this._editMode!==!1&&Ur(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=Kt(e,s);if(r===!1)return null;let o=s?.[e.id],a=e.editorProps&&typeof e.editorProps=="object"?e.editorProps:{},c=l("span",{class:"zx-table__cell-shadow",ariaHidden:"true"});c.append(...t.childNodes);let u=l("div",{class:"zx-table__editor",dataset:{editor:r}});t.replaceChildren(c,u),t.dataset.editing="true";let d={column:e,type:r,td:t,host:u,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(r==="custom"){d.custom=o,d.read=()=>Tt(e,d.custom,s);let p={value:o,row:s,column:e,commit:m=>{d.custom=m,this.commitEdit()},cancel:()=>this.cancelEdit()},_=e.editor(s,p);return _&&typeof _.toElement=="function"?(typeof _.destroy=="function"&&(d.component=_),u.append(_.toElement())):_&&u.append(_),d.control=u.querySelector($c)??u,d}if(r==="number"){let p=Mt(e.locale,s),_=io(e,s),m=e.type==="currency"?Mt(e.currency,s):e.type==="unit"?Mt(e.unit,s):null,g={...p!=null&&!Object.prototype.hasOwnProperty.call(a,"locale")?{locale:p}:{},..._!=null&&!Object.prototype.hasOwnProperty.call(a,"precision")?{precision:_}:{},...m!=null&&!Object.prototype.hasOwnProperty.call(a,"unit")?{unit:String(m)}:{}},b=new $t(null,{...g,...a,value:o??null});return u.append(b.el),d.component=b,d.control=b.getInput(),d.read=()=>(b.set(b.getInput().value,{silent:!0}),Tt(e,b.get(),s)),d}if(r==="select"){let p=Zc(e.options,s),_=p.find(g=>Object.is(g.value,o))??p.find(g=>String(g.value)===String(o??"")),m=new $(null,{...a,items:p,valueKey:"value",labelKey:"label",value:_?_.value:null});return u.append(m.el),d.component=m,d.control=m.refs.input,d.read=()=>Tt(e,m.value,s),d}if(r==="date"){let p=new It(null,{...a,value:o??null});u.append(p.el),d.component=p;let _=p.refs.input;return d.control=_,d.read=()=>{let m=String(_.value??"").trim(),g=p.get();return m===""?Tt(e,null,s):(p.set(m,{silent:!0}),p.get()===null&&p.set(g,{silent:!0}),Tt(e,p.get(),s))},d}if(r==="checkbox"){let p=new Bt(null,{...a,checked:!!o});return u.append(p.el),d.component=p,d.control=p.el,d.read=()=>Tt(e,p.get(),s),d}let h=r==="textarea",f=l(h?"textarea":"input",{...a,class:h?"zx-table__editor-input zx-table__editor-textarea":"zx-table__editor-input",...h?{}:{type:"text"},ariaLabel:a.ariaLabel??`${ai(e)} row ${n+1}`,value:Qc(e,o,s)});return u.append(f),d.control=f,d.read=()=>Tt(e,f.value,s),d}_focusEditor(t){let e=this._edit?.cells.get(t),s=e?.control;!s||typeof s.focus!="function"||(s.focus(),au(e.type)&&typeof s.select=="function"&&s.select())}_focusCell(t,e){let s=this._rowElements.get(t)?.[0];(s?Zr(s,e):null)?.focus()}_teardownEdit(){let t=this._edit;if(!t)return;this._edit=null;let e=this._data.findIndex(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&&ri(e)){if(ru(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(),a=this._idFor(this._data[t]),c=o.findIndex(h=>Object.is(this._idFor(h),a));if(c<0)return null;let u=n.findIndex(h=>h.id===e),d=o.length*r+r;for(let h=0;h<d;h+=1){if(u+=s,u>=r?(c+=1,u=0):u<0&&(c-=1,u=r-1),c<0||c>=o.length)return null;let f=o[c],p=n[u];if(!this._isSpanningRow(f)&&Kt(p,f)!==!1)return{id:this._idFor(f),columnId:p.id,index:this._data.indexOf(f)}}return null}_handleEditFocusIn(t){let s=(t.target?.nodeType===1?t.target:null)?.closest('td[data-editable="true"]');if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s.parentElement);n&&this._setRovingCell(s,n.id,String(s.dataset.column))}_handleDocumentPointerDown(t){if(!this._edit)return;let e=t.target?.nodeType===1?t.target:t.target?.parentElement;e&&ri(e)||e&&this._tbody.contains(e)||this.commitEdit()}_offerRovingCell(t,e,s){if(this._rovingMatched)return;let n=this._rovingKey!==null&&Object.is(this._rovingKey.id,e)&&this._rovingKey.columnId===s;!n&&this._rovingCell||(n&&this._rovingCell&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=n)}_setRovingCell(t,e,s){this._rovingCell&&this._rovingCell!==t&&(this._rovingCell.tabIndex=-1),t.tabIndex=0,this._rovingCell=t,this._rovingMatched=!0,this._rovingKey={id:e,columnId:s}}_msgOr(t,e){let s=this.msg(t);return s===t?e:s}_toggleMultiSelection(t,e,s){let n=this._visibleData(),r=n.findIndex(o=>Object.is(this._idFor(o),this._selectionAnchorId));if(s&&r>=0){let o=t.visibleIndex??n.findIndex(u=>Object.is(this._idFor(u),t.id)),a=Math.min(r,o),c=Math.max(r,o);for(let u=a;u<=c;u+=1){if(this._isSpanningRow(n[u]))continue;let d=this._idFor(n[u]);e?this._selected.add(d):this._selected.delete(d)}}else e?this._selected.add(t.id):this._selected.delete(t.id);this._selectionAnchorId=t.id,this._syncSelection(),this._emitSelectionChange()}_syncSelection(){for(let[t,e]of this._rowElements){let s=this._selected.has(t);for(let n of e){if(n.hasAttribute("data-span"))continue;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._selectableData(),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._spanning&&this._sort?.id===t?e.setAttribute("aria-sort",this._sort.dir==="asc"?"ascending":"descending"):e.removeAttribute("aria-sort")}_sortData(){if(this._spanning=this._hasSpanningRow(),!this._sort||this._spanning)return;let t=this._columns.find(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?Wc(this._data,this.options.rowId,this._hierarchy.parentId,e,this._sort.dir):us(this._data,e,this._sort.dir)}_setRowExpanded(t,e,s){return this._hierarchy?ni(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=ni(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)}_selectableIds(){let t=new Set;for(let e of this._data)this._isSpanningRow(e)||t.add(this._idFor(e));return t}_pruneSelection(){let t=this._selectableIds(),e=this._selected.size;for(let 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 Xr(i,t){if(t==null||t==="")return null;let e=typeof t=="function"?t(i):i?.[t];return e==null?null:String(e)}function Jr(i,t){if(t===null||i==null||typeof i!="object"||!Object.prototype.hasOwnProperty.call(i,t))return null;let e=i[t];return e&&typeof e=="object"?e:null}function to(i,t,e){return!!Jr(e,Xr(i,t))?.span}function Bc(i,t,e){return!Array.isArray(i)||t==null||e==null?!1:i.some(s=>to(s,t,e))}function Kc(i,t={}){let e=Number.isFinite(Number(i))?Math.max(0,Math.trunc(Number(i))):0,s=(t.selectable==="multi"?1:0)+(t.rowReorder?1:0);return Math.max(1,e+s)}function Hc(i,t,e,s=0){if(typeof t?.render=="function")return t.render(i,s);let n=e?.[0];return n?i?.[n.id]:null}function Yc(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=Mt(i.locale,t),o=io(i,t),a={...r!=null?{locale:String(r)}:{},...o!=null?{decimals:o}:{}};if(n==="number")return si(s,a);if(n==="currency"){let c=Mt(i.currency,t);return $r(s,c==null?null:String(c),a)}if(n==="percent")return Br(s,a);if(n==="unit"){let c=si(s,a),u=Mt(i.unit,t);return c&&u!=null&&String(u)!==""?`${c}\xA0${u}`:c}return s}function Uc(i,t,e,s=[]){let n=li(i,t,e),r=s instanceof Set?s:new Set(s),o=[],a=n.roots.slice().reverse().map(c=>({node:c,depth:0}));for(;a.length;){let{node:c,depth:u}=a.pop();if(o.push({row:c.row,id:c.id,index:c.index,depth:u,hasChildren:c.children.length>0,parentId:c.parent?.id??null}),!!r.has(c.id))for(let d=c.children.length-1;d>=0;d-=1)a.push({node:c.children[d],depth:u+1})}return o}function Wc(i,t,e,s,n){let r=li(i,t,e),o=u=>us(u,d=>s(d.row),n),a=[],c=o(r.roots).reverse();for(;c.length;){let u=c.pop();a.push(u.row);let d=o(u.children);for(let h=d.length-1;h>=0;h-=1)c.push(d[h])}return a}function eo(i,t,e,s,n="before",r=null){if(!Array.isArray(i)||Object.is(e,s))return null;let o=i.findIndex(h=>Object.is(J(t,h),e)),a=i.findIndex(h=>Object.is(J(t,h),s));if(o<0||a<0||r&&!fs(J(r,i[o]),J(r,i[a])))return null;if(r){let h=li(i,t,r),f=h.nodes[o],p=h.nodes[a];if(!f||!p||f.parent!==p.parent)return null;let _=k=>{let M=[],B=[k];for(;B.length;){let U=B.pop();M.push(U);for(let Q=U.children.length-1;Q>=0;Q-=1)B.push(U.children[Q])}return M},m=new Set(_(f).map(k=>k.index)),g=new Set(_(p).map(k=>k.index)),b=i.filter((k,M)=>m.has(M)),y=i.filter((k,M)=>!m.has(M)),A=i.map((k,M)=>M).filter(k=>!m.has(k)),x=A.findIndex(k=>k===a);if(n==="after"){let k=A.map((M,B)=>g.has(M)?B:-1).filter(M=>M>=0);x=Math.max(...k)+1}return x<0?null:(y.splice(x,0,...b),y)}let c=[...i],[u]=c.splice(o,1),d=c.findIndex(h=>Object.is(J(t,h),s));return c.splice(d+(n==="after"?1:0),0,u),c}function Kt(i,t){if(!i||typeof i!="object")return!1;if(typeof i.editor=="function")return typeof i.editable=="function"&&i.editable(t)===!1?!1:"custom";let e=typeof i.editable=="function"?i.editable(t):i.editable;return e===!0?hs(i)?"number":"text":typeof e=="string"&&qc.has(e)?e:!1}function Zc(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 Qc(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 Tt(i,t,e){return typeof i?.parse=="function"?i.parse(t,e):t}function Gc(i,t){return Object.is(i,t)?!0:i instanceof Date&&t instanceof Date?i.getTime()===t.getTime():!1}function Xc(i,t){let e={};for(let[s,n]of Object.entries(t??{}))Gc(i?.[s],n)||(e[s]=n);return e}function Jc(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 Mt(i,t){return typeof i=="function"?i(t):i}function io(i,t){let e=Mt(i?.decimals,t);if(e==null)return null;let s=Number(e);return Number.isFinite(s)?Math.max(0,Math.trunc(s)):null}function hs(i){return["number","currency","percent","unit"].includes(i?.type)}function li(i,t,e){let s=(Array.isArray(i)?i:[]).map((a,c)=>({row:a,id:J(t,a),index:c,parent:null,children:[]})),n=new Map;for(let a of s)n.has(a.id)||n.set(a.id,a);let r=new Map;for(let a of s){let c=J(e,a.row),u=c==null?null:n.get(c)??null;r.set(a,u===a?null:u)}for(let a of s){let c=new Set([a]),u=r.get(a)??null;for(;u;){if(c.has(u)){r.set(u,null);break}c.add(u),u=r.get(u)??null}}let o=[];for(let a of s)a.parent=r.get(a)??null,a.parent?a.parent.children.push(a):o.push(a);return{roots:o,nodes:s}}function ni(i,t,e){return li(i,t,e).nodes.filter(s=>s.children.length>0).map(s=>s.id)}function J(i,t){return typeof i=="function"?i(t):t?.[i]}function fs(i,t){return i==null&&t==null||Object.is(i,t)}function ds(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 tu(i){return typeof i=="function"||typeof i=="string"&&i!==""?i:null}function eu(i){return!i||typeof i!="object"||Array.isArray(i)?null:i}function iu(i){return new Set(Array.isArray(i)?i:[])}function su(i){return i==="plain"?"plain":"default"}function nu(i){return i==="cell"||i==="row"?i:i===!0?"cell":!1}function ri(i){return!!i?.closest?.(".zx-table__editor")}function Ur(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 ru(i){return i.closest("[popover]")?!0:i.getAttribute?.("aria-expanded")==="true"}function Wr(i){if(!Array.isArray(i))throw new TypeError("Table columns must be an array");let t=new Set;return i.map((e,s)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError(`Table column at index ${s} must be an object`);let n=String(e.id??"").trim();if(!n)throw new TypeError(`Table column at index ${s} requires an id`);if(t.has(n))throw new TypeError(`Duplicate table column: ${n}`);return t.add(n),{...e,id:n,label:String(e.label??n)}})}function ai(i){for(let t of[i?.ariaLabel,i?.label]){let e=t==null?"":String(t).trim();if(e)return e}return String(i?.id??"")}function ou(i){let t=i?.label==null?"":String(i.label).trim(),e=i?.ariaLabel==null?"":String(i.ariaLabel).trim();return e||(t?null:ai(i)||null)}function au(i){return i==="text"||i==="number"||i==="date"}function lu(i,t){let e=i.map(a=>a.id),s=new Set(e),n=Array.isArray(t)?t.map(String):[],r=new Set,o=[];for(let a of n)s.has(a)&&!r.has(a)&&(r.add(a),o.push(a));for(let a of e)r.has(a)||o.push(a);return o}function cu(i,t,e,s="before"){let n=[...i],r=n.indexOf(t),o=n.indexOf(e);if(r<0||o<0||r===o)return n;n.splice(r,1);let a=n.indexOf(e)+(s==="after"?1:0);return n.splice(a,0,t),n}function Zr(i,t){for(let e of i.cells)if(e.dataset.column===t)return e;return null}function Qr(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 uu(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 Gr(i){if(!Array.isArray(i))throw new TypeError("Table data must be an array")}function du(i,t){return i.size===t.size&&[...i].every(e=>t.has(e))}function oi(i,t){return i.length===t.length&&i.every((e,s)=>Object.is(e,t[s]))}function hu(i){let t=Math.trunc(Number(i));return Number.isFinite(t)&&t>0?t:null}var ps=class extends v{static cssName="app-icon";static defaults={icon:null,color:null,size:36,iconSize:"52%",label:null,badge:null,selected:!1,shape:"tile",glass:"subtle",class:[]};render(){this._createdRoot=this.el===null;let t=this.el??l("span");return this.el=t,this._snapshot=this._createdRoot?null:K(t),this._interactiveRoot=t.matches('a[href], button, input, select, textarea, [role="button"], [role="link"]'),this._state={...this.options},this._appliedClasses=[],this._sync(),t}set(t={}){return!t||typeof t!="object"?this:(Object.assign(this._state,t),this._sync(),this)}destroy(){let t=this.el,e=this._snapshot;super.destroy(),!this._createdRoot&&t&&H(t,e)}_sync(){let t=this._state;this.el.classList.remove(...this._appliedClasses),this._appliedClasses=[t.class].flat().flatMap(u=>String(u??"").split(/\s+/)).filter(Boolean),this.el.classList.add(...this._appliedClasses);let e=so(t.size,"36px"),s=so(t.iconSize,"52%");this.el.style.setProperty("--zx-app-icon-size",e),this.el.style.setProperty("--zx-app-icon-glyph-size",s),Pt(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=pu(t.glass),this.el.dataset.shape=mu(t.shape),this.el.toggleAttribute("data-selected",!!t.selected);let n=t.label==null?"":String(t.label).trim();if(this._interactiveRoot){let u=no(this._snapshot,"role"),d=no(this._snapshot,"aria-label");u===null?this.el.removeAttribute("role"):this.el.setAttribute("role",u),n?this.el.setAttribute("aria-label",n):d===null?this.el.removeAttribute("aria-label"):this.el.setAttribute("aria-label",d),this.el.removeAttribute("aria-hidden")}else n?(this.el.setAttribute("role","img"),this.el.setAttribute("aria-label",n),this.el.removeAttribute("aria-hidden")):(this.el.removeAttribute("role"),this.el.removeAttribute("aria-label"),this.el.setAttribute("aria-hidden","true"));let r=fu(t.icon),o=t.badge==null||t.badge===""?null:l("span",{class:"zx-app-icon__badge",ariaHidden:"true"},String(t.badge)),c=[l("span",{class:"zx-app-icon__surface",ariaHidden:"true"},l("span",{class:"zx-app-icon__shine",ariaHidden:"true"}),l("span",{class:"zx-app-icon__glyph",ariaHidden:"true"},r))];o&&c.push(o),this.el.replaceChildren(...c)}};function ro(i={}){return new ps(null,i).toElement()}function fu(i){let t=typeof i=="function"?i():i;return typeof t=="string"?w(t,{size:"1em"}):t&&typeof t=="object"&&typeof t.nodeType=="number"?t:null}function so(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 pu(i){return i===!1||i==="none"?"none":i==="strong"?"strong":"subtle"}function mu(i){return i==="circle"?"circle":"tile"}function no(i,t){return i?.attributes.find(([e])=>e===t)?.[1]??null}var di=class extends v{static cssName="launcher";static defaults={items:[],sources:[],query:"",debounce:250,minQuery:0,maxResults:100,placeholder:null,label:null,closeLabel:null,resultsLabel:null,emptyText:null,loadingText:null,shortcut:"mod+k",hints:null,scope:null};constructor(t=null,e={}){super(t,e)}render(){if(this.el!==null&&!(this.el instanceof HTMLDialogElement))throw new TypeError("Launcher target must be a <dialog> element");this._createdRoot=this.el===null;let t=this.el??l("dialog");this.el=t,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes,_=>[_.name,_.value]),children:Array.from(t.childNodes)},this._items=ae(this.options.items),this._sources=co(this.options.sources),this._sourceItems=new Map,this._query=String(this.options.query??""),this._renderedQuery=null,this._results=[],this._active=-1,this._request=null,this._requestSequence=0,this._queryTimer=null,this._busy=!1,this._settled=!0,this._pages=[],this._restoreActiveId=null,this._announcePending=!1,this._announceToggle=!1,this._destroyed=!1;let e=D("zx-launcher-results"),s=String(this.options.label??this._message("launcher.label","Launcher")),n=String(this.options.placeholder??this._message("launcher.placeholder","Search applications and records"));this._label=s,this._placeholder=n;let r=l("input",{ref:"input",class:"zx-launcher__input",type:"search",role:"combobox",autocomplete:"off",spellcheck:!1,ariaAutocomplete:"list",ariaControls:e,ariaExpanded:"false",ariaLabel:s,placeholder:n,value:this._query}),o=l("button",{ref:"scopeBack",class:"zx-icon-btn zx-launcher__scope-back",type:"button"},w("x")),a=l("span",{ref:"scope",class:"zx-launcher__scope",hidden:!0},l("span",{ref:"scopeLabel",class:"zx-launcher__scope-label"}),o),c=l("button",{ref:"close",class:"zx-icon-btn zx-launcher__close",type:"button",ariaLabel:this.options.closeLabel??this._message("launcher.close","Close launcher")},w("x")),u=l("div",{ref:"status",class:"zx-launcher__status",role:"status",ariaLive:"polite"}),d=l("div",{ref:"announce",class:"zx-launcher__announce",role:"status",ariaLive:"polite",ariaAtomic:"true"}),h=l("div",{ref:"results",class:"zx-launcher__results",id:e,role:"listbox",ariaLabel:this.options.resultsLabel??this._message("launcher.results","Launcher results")}),f=this.options.shortcut==="mod+k"?l("kbd",{class:"zx-launcher__shortcut",ariaHidden:"true"},_u()):null,p=gu(this.options.hints,{move:this._message("launcher.hintMove","Move"),open:this._message("launcher.hintOpen","Open"),back:this._message("launcher.hintBack","Back"),close:this._message("launcher.hintClose","Close")});return t.setAttribute("aria-label",s),t.replaceChildren(l("div",{class:"zx-launcher__surface"},l("div",{class:"zx-launcher__search",dataset:{shortcut:f?"true":"false"}},w("search"),a,r,f,c),u,h,p,d)),t.dataset.state="closed",this._createdRoot&&Kr(this.options.scope)?.append(t),this.listen(r,"input",()=>{this._query=r.value,this._announcePending=!1,this.emit("query",{query:this._query.trim()}),this._refresh()}),this.listen(r,"keydown",_=>this._onKeydown(_)),this.listen(o,"click",()=>{this.back(),r.focus()}),this.listen(c,"click",()=>this.close()),this.listen(h,"click",_=>{let m=_.target?.closest?.("[data-launcher-index]");!m||!h.contains(m)||this._activate(Number(m.getAttribute("data-launcher-index")),_)}),this.listen(h,"pointermove",_=>{let m=_.target?.closest?.("[data-launcher-index]");if(!m||!h.contains(m))return;let g=Number(m.getAttribute("data-launcher-index"));!Number.isInteger(g)||this._results[g]?.disabled||g===this._active||(this._active=g,this._syncActive())}),this.listen(t,"cancel",_=>{_.preventDefault(),this.close()}),this.listen(t,"close",()=>{t.dataset.state="closed",r.setAttribute("aria-expanded","false"),this._abortRequest(),this._pages.length&&!t.open&&(this._unwind(),this._announcePending=!1,this._syncPage(),this._renderResults(),this._emitPage()),this.emit("close")}),this.listen(document,"keydown",_=>this._onDocumentKeydown(_)),this._renderResults(),t}open(t={}){if(this._destroyed)return this;let e=t&&typeof t=="object"?t.page:void 0;if(this.isOpen()){let n=e==null?[]:this._pagePath(e);return n.length&&this._goTo(n),this}if(this._createdRoot){let n=at(this.options.scope);this.el.parentElement!==n&&n.append(this.el)}let s=this._pages.map(n=>n.page);return this.el.showModal(),this.el.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this._goTo(e==null?[]:this._pagePath(e),{emit:!1}),queueMicrotask(()=>{this.isOpen()&&(this.refs.input.focus(),this.refs.input.select())}),this.emit("open"),oo(s,this._pages.map(n=>n.page))||this._emitPage(),this}back(){if(!this._pages.length)return this;let t=this._popPage();return this._syncPage(),this._announcePending=this.isOpen(),t?this._renderResults():this._refresh(!0),this._emitPage(),this}getPage(){return this._pages.at(-1)?.page??null}close(){return this.isOpen()&&this.el.close(),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return!!this.el.open}focus(){return this.refs.input.focus(),this.refs.input.select(),this}setQuery(t){return this._query=String(t??""),this.refs.input.value=this._query,this._announcePending=!1,this.emit("query",{query:this._query.trim()}),this._refresh(),this}getQuery(){return this._query}setItems(t){return this._items=ae(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._sources=co(t),this._pages.length?(this._pages[0].parent.sourceItems=null,this):(this._abortRequest(),this._sourceItems.clear(),this._refresh(),this)}destroy(){if(this._destroyed)return;this._destroyed=!0;let t=this._original;if(this._abortRequest(),this.isOpen()&&this.el.close(),super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_refresh(t=!1){this._abortRequest(),this._sourceItems.clear();let{sources:e}=this._level();if(this._settled=e.length===0,t&&e.length&&this._loadSources(),this._renderResults(),t||e.length===0)return;let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>this._loadSources(),s)}async _loadSources(){this._queryTimer=null;let t=this._query.trim(),e=this._pages?.at(-1)?.page??null,s=this._level().sources.filter(o=>ci(o.when,t)&&t.length>=Math.max(o._page?0:Number(this.options.minQuery)||0,Number(o.minQuery)||0));if(s.length===0){this._settled=!0;return}let n=new AbortController,r=++this._requestSequence;this._request=n,this._setBusy(!0),await Promise.all(s.map(async o=>{try{let a=await o.load(t,{signal:n.signal});if(n.signal.aborted||r!==this._requestSequence)return;this._sourceItems.set(o.id,ae(a).map((c,u)=>({...c,_source:o._page?null:o.id,_sourceOrder:o.order==="source",group:c.group??o.label??"",itemOrder:c.itemOrder??(o.order==="source"?u:void 0)}))),this._renderResults()}catch(a){if(n.signal.aborted||r!==this._requestSequence)return;this.emit("error",{source:o,error:a,page:e})}})),!(n.signal.aborted||r!==this._requestSequence)&&(this._request=null,this._settled=!0,this._setBusy(!1))}_level(){return this._pages?.at(-1)??{items:this._items,sources:this._sources}}_openPage(t){this._pushPage(t),this._syncPage(),this._announcePending=this.isOpen(),this._refresh(!0),this._emitPage()}_goTo(t,{emit:e=!0}={}){let s=this._pages.map(n=>n.page);if(this._unwind(),t.length){this._abortRequest(),this._sourceItems.clear(),this._settled=!1;for(let n of t)this._pushPage(n)}this._syncPage(),this._announcePending=this.isOpen()&&t.length>0,this._refresh(t.length>0),e&&!oo(s,t)&&this._emitPage()}_unwind(){for(;this._pages.length;)this._popPage()}_pushPage(t){let e=this._active>=0?this._results[this._active]:null;this._pages.push({page:t,items:Array.isArray(t.items)?ae(t.items):[],sources:typeof t.items=="function"?[xu(t)]:[],parent:{query:this._query,activeId:e?String(e.id):null,sourceItems:this._settled?new Map(this._sourceItems):null}}),this._setInputQuery("")}_popPage(){let t=this._pages.pop();if(!t)return!0;this._announcePending=!1,this._abortRequest();let{parent:e}=t;return this._setInputQuery(e.query),this._sourceItems=e.sourceItems?new Map(e.sourceItems):new Map,this._settled=e.sourceItems!==null,this._restoreActiveId=e.activeId,this._settled}_setInputQuery(t){this._query=t,this.refs.input.value=t,this._renderedQuery=null}_syncPage(){let t=this.getPage(),{input:e,scope:s,scopeLabel:n,scopeBack:r,backHint:o}=this.refs;if(s.hidden=t===null,o&&(o.hidden=t===null),this.el.toggleAttribute("data-page",t!==null),t===null){e.setAttribute("aria-label",this._label),e.setAttribute("placeholder",this._placeholder),n.textContent="";return}let a=this._pages.at(-2)?.page.label??this._label;n.textContent=t.label,r.setAttribute("aria-label",this._message("launcher.back","Back to %1",a)),e.setAttribute("aria-label",this._message("launcher.pageLabel","Search %1",t.label)),e.setAttribute("placeholder",t.placeholder!=null?String(t.placeholder):this._message("launcher.pagePlaceholder","Search"))}_emitPage(){let t=this._pages.map(e=>e.page);this.emit("page",{page:t.at(-1)??null,path:t})}_pagePath(t){if(t&&typeof t=="object"){let e=t;return!Ht(e)||e.label==null?[]:[uo({...e,id:e.id??e.label})]}return bu(this._items,t)}_pageStatus(){let t=this.getPage()?.label??this._label,e=this._results.length;return e===0?this._message("launcher.pageEmpty","%1, no results",t):e===1?this._message("launcher.pageResult","%1, 1 result",t):this._message("launcher.pageResults","%1, %2 results",t,e)}_setBusy(t){this._busy=t,this.el.setAttribute("aria-busy",String(t)),this._renderStatus()}_abortRequest(){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._queryTimer=null,this._request?.abort(),this._request=null,this._requestSequence+=1,this._busy&&this._setBusy(!1)}_renderResults(){let t=this._query,e=this._restoreActiveId??null;this._restoreActiveId=null;let s=e??(this._renderedQuery===t&&this._active>=0&&this._results[this._active]?String(this._results[this._active].id):null),n=this._query.trim(),r=this._level(),o=r.items.filter(m=>ci(m.when,n)),a=ao(o,n,this.options.maxResults),c=r.sources.flatMap(m=>{let g=this._sourceItems.get(String(m.id))??[];return m.order==="source"?g.filter(b=>ci(b.when,n)):ao(g.filter(b=>ci(b.when,n)),n,this.options.maxResults)}),u=new Set,d=[...a.map(m=>({...m,_source:null})),...c].filter(m=>{let g=String(m.id);return u.has(g)?!1:(u.add(g),!0)}).slice(0,Math.max(0,Number(this.options.maxResults)||0)),h=new Map;for(let m of d){let g=String(m.group??"");h.has(g)||h.set(g,[]),h.get(g).push(m)}this._results=[...h.values()].flat(),this._renderedQuery=t;let f=s===null?-1:this._results.findIndex(m=>!m.disabled&&String(m.id)===s);this._active=f>=0?f:this._results.findIndex(m=>!m.disabled);let p=[],_=0;for(let[m,g]of h){let b=g.map(y=>this._option(y,_++));m?p.push(l("div",{class:"zx-launcher__group",role:"group",ariaLabel:m,dataset:{layout:g.every(y=>y.kind==="application")?"grid":"list"}},l("div",{class:"zx-launcher__group-label",ariaHidden:"true"},m),b)):p.push(...b)}this.refs.results.replaceChildren(...p),this._syncActive(),this._renderStatus()}_option(t,e){let s=Ht(t),n=s?null:Fi(t.href),r=n?"a":"button",o=[],a=vu(t);a&&o.push(l("span",{class:"zx-launcher__icon",ariaHidden:"true"},a)),o.push(l("span",{class:"zx-launcher__copy"},l("span",{class:"zx-launcher__label"},t.label),t.description?l("span",{class:"zx-launcher__description"},t.description):null)),t.badge!=null&&o.push(l("span",{class:"zx-launcher__badge"},String(t.badge))),t.hint!=null&&t.hint!==""&&o.push(l("span",{class:"zx-launcher__hint"},String(t.hint)));let c=wu(t),u=yu(t.shortcut);return u.length&&o.push(l("span",{class:"zx-launcher__keys",ariaHidden:c?"true":null},u.map(d=>l("kbd",{class:"zx-launcher__key"},d)))),s&&o.push(l("span",{class:"zx-launcher__chevron",ariaHidden:"true"},w("chevron-right"))),l(r,{class:"zx-launcher__option",type:r==="button"?"button":null,href:n,target:t.target??null,rel:r==="a"?"noopener":null,role:"option",id:D("zx-launcher-option"),tabIndex:-1,ariaSelected:"false",ariaDisabled:t.disabled?"true":null,ariaCurrent:t.current?"page":null,ariaKeyShortcuts:c,dataset:{launcherIndex:e,pinned:t.pinned!==void 0&&t.pinned!==!1?"true":null,kind:Su(t.kind),page:s?"true":null}},o)}_renderStatus(){this._busy?this.refs.status.textContent=String(this.options.loadingText??this._message("launcher.loading","Searching\u2026")):this._results.length===0?this.refs.status.textContent=String(this.options.emptyText??this._message("launcher.empty","No results")):this.refs.status.textContent="",this.refs.status.hidden=!this.refs.status.textContent,this._announcePending&&!this._busy&&this._renderedQuery===this._query&&(this._announcePending=!1,this._announceToggle=!this._announceToggle,this.refs.announce.textContent=this._pageStatus()+(this._announceToggle?"\xA0":""))}_syncActive(){let t=[...this.refs.results.querySelectorAll("[data-launcher-index]")];for(let 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}let e=!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey;if(t.key==="Backspace"&&e&&!t.repeat&&this._pages.length&&this._query===""){t.preventDefault(),this.back();return}if(t.key==="Enter"){if(this._active<0)return;t.preventDefault(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.click();return}let s=this._results.map((r,o)=>r.disabled?-1:o).filter(r=>r>=0);if(/^Arrow(?:Left|Right|Up|Down)$/.test(t.key)){let r=s.length?this._spatialIndex(t.key,s):null;if(r!==null){t.preventDefault(),this._active=r,this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"});return}if(t.key==="ArrowLeft"||t.key==="ArrowRight"){e&&!t.repeat&&this._pageKey(t.key)&&t.preventDefault();return}}if(s.length===0)return;let n=s.indexOf(this._active);if(t.key==="Home"||t.key==="PageUp")n=0;else if(t.key==="End"||t.key==="PageDown")n=s.length-1;else if(t.key==="ArrowDown")n=(n+1+s.length)%s.length;else if(t.key==="ArrowUp")n=(n-1+s.length)%s.length;else return;t.preventDefault(),this._active=s[n],this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest"})}_pageKey(t){if(t==="ArrowLeft")return!this._pages.length||this._query!==""?!1:(this.back(),!0);let e=this._active>=0?this._results[this._active]:null;if(!e||e.disabled||!Ht(e)||e.kind==="application")return!1;let s=this.refs.input,n=s.value.length;return s.selectionStart!==n||s.selectionEnd!==n?!1:(this._openPage(e),!0)}_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=Au(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(Ht(s)){e.preventDefault(),this._openPage(s),this.refs.input.focus();return}if(this.emit("select",{item:s,value:s.value??s.id,source:s._source??null,query:this._query.trim(),page:this.getPage()}).defaultPrevented){e.preventDefault();return}this.close(),s.href||(e.preventDefault(),s.invoke?.())}_onDocumentKeydown(t){if(this.options.shortcut!=="mod+k"||t.isComposing||t.key.toLowerCase()!=="k"||Number(t.metaKey)+Number(t.ctrlKey)!==1||t.altKey||t.shiftKey)return;let e=document.activeElement;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)return;let s=document.querySelector("dialog:modal");s&&s!==this.el||(t.preventDefault(),this.open())}_message(t,e,...s){let n=this.msg(t,...s);return n===t?O(e,s):n}};function _u(){let i=String(navigator.userAgentData?.platform??navigator.platform??"");return/mac|iphone|ipad/i.test(i)?"\u2318 K":"Ctrl K"}function gu(i,t){if(i===!1)return null;let e=i&&typeof i=="object"?i:{};return l("footer",{class:"zx-launcher__hints",ariaHidden:"true"},l("span",{},l("kbd",{},"\u2191\u2193\u2190\u2192"),e.move??t.move),l("span",{},l("kbd",{},"\u21B5"),e.open??t.open),l("span",{ref:"backHint",hidden:!0},l("kbd",{},"\u232B"),e.back??t.back),l("span",{},l("kbd",{},"Esc"),e.close??t.close))}function Ht(i){let t=i?.items;return!!i&&typeof i=="object"&&(Array.isArray(t)||typeof t=="function")}function bu(i,t){if(t==null)return[];let e=String(t),s=new Set,n=(r,o)=>{if(!Array.isArray(r)||s.has(r))return null;s.add(r);for(let a of ae(r)){if(!Ht(a))continue;let c=[...o,a];if(String(a.id)===e)return c;let u=n(a.items,c);if(u)return u}return null};return n(i,[])??[]}function yu(i){let t=i&&typeof i=="object"&&!Array.isArray(i)?i.label:i;return(Array.isArray(t)?t:t==null?[]:[t]).filter(s=>s!=null&&String(s).trim()!=="").map(s=>String(s).trim())}function wu(i){let t=i.shortcut,e=i.keys??(t&&typeof t=="object"&&!Array.isArray(t)?t.keys:null);return typeof e=="string"&&e.trim()?e.trim():null}function xu(i){return{id:`page:${String(i.id)}`,load:i.items,order:i.order==="source"?"source":"rank",_page:!0}}function oo(i,t){return i.length===t.length&&i.every((e,s)=>e===t[s]||String(e.id)===String(t[s].id))}function vu(i){let t=i.icon;if(typeof t=="function"&&(t=t(i)),typeof t=="string")return w(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 Su(i){return i==="application"||i==="record"?i:"action"}function ci(i,t){return i==="empty"?t==="":i==="query"?t!=="":!0}function Au(i,t,e){let s=t.getBoundingClientRect();if(s.width===0&&s.height===0)return null;let n=s.left+s.width/2,r=s.top+s.height/2,o=null,a=1/0;for(let c of i){if(c===t)continue;let u=c.getBoundingClientRect(),d=u.left+u.width/2-n,h=u.top+u.height/2-r,f=!1,p=1/0;e==="ArrowLeft"?(f=d<-2&&Math.abs(h)<Math.max(s.height,u.height)/2,p=Math.abs(d)+Math.abs(h)*4):e==="ArrowRight"?(f=d>2&&Math.abs(h)<Math.max(s.height,u.height)/2,p=Math.abs(d)+Math.abs(h)*4):e==="ArrowUp"?(f=h<-2,p=Math.abs(h)*10+Math.abs(d)):e==="ArrowDown"&&(f=h>2,p=Math.abs(h)*10+Math.abs(d)),f&&p<a&&(o=c,a=p)}return o}function ao(i,t,e=100){let s=Yt(t).trim(),n=i.map((o,a)=>({item:o,order:a,score:ku(o,s)})).filter(({score:o})=>o<1/0);n.sort((o,a)=>{let c=ui(o.item.groupOrder),u=ui(a.item.groupOrder);if(c!==u)return c-u;if(s===""){let d=lo(o.item.pinned,o.order),h=lo(a.item.pinned,a.order);if(d!==h)return d-h}return o.score-a.score||ui(o.item.itemOrder)-ui(a.item.itemOrder)||zu(o.item.label,a.item.label)||o.order-a.order});let r=Math.max(0,Number(e)||0);return n.slice(0,r||0).map(({item:o,score:a})=>({...o,_score:a}))}function ku(i,t){if(!t)return i.pinned?-1:0;let e=Yt(i.label),s=Yt(i.id),n=Yt(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 lo(i,t){return typeof i=="number"&&Number.isFinite(i)?i:i?t:Number.MAX_SAFE_INTEGER}function ui(i){return typeof i=="number"&&Number.isFinite(i)?i:Number.MAX_SAFE_INTEGER}function Yt(i){return String(i??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function zu(i,t){let e=Yt(i),s=Yt(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 ae(i){return Array.isArray(i)?i.filter(t=>t&&typeof t=="object"&&t.id!=null&&t.label!=null).map(t=>uo(t)):[]}function uo(i){let t={...i,label:String(i.label)};if(i.href==null)return t;let e=Fi(i.href);return e!==null?t.href=e:(delete t.href,typeof t.invoke!="function"&&!Ht(t)&&(t.disabled=!0)),t}function co(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 Du=8e3,_s=class{#t;#e=[];#i=[];#s;constructor(t=5,e=()=>{}){if(!Number.isInteger(t)||t<1)throw new RangeError("Queue limit must be positive");if(typeof e!="function")throw new TypeError("Activation callback must be a function");this.#t=t,this.#s=e}enqueue(t){return this.#e.length<this.#t?(this.#e.push(t),this.#s(t),"active"):(this.#i.push(t),"pending")}remove(t){let e=this.#i.indexOf(t);if(e!==-1)return this.#i.splice(e,1),"pending";let s=this.#e.indexOf(t);if(s===-1)return null;if(this.#e.splice(s,1),this.#i.length>0){let n=this.#i.shift();this.#e.push(n),this.#s(n)}return"active"}isActive(t){return this.#e.includes(t)}clear(){let t={active:this.#e.slice(),pending:this.#i.slice()};return this.#e.length=0,this.#i.length=0,t}get activeCount(){return this.#e.length}get pendingCount(){return this.#i.length}},At=class i extends v{static cssName="message";static defaults={kind:"info",timeout:4e3,closable:!0,maxVisible:5};static#t=new WeakMap;render(){let t=!this.el,e=this.el??l("div");return this._createdRoot=t,this._original=t?null:Lu(e),this._entries=new Set,this._floatingHost=null,this._queue=new _s(Ou(this.options.maxVisible),s=>{this._activate(s)}),e.replaceChildren(),e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e}show(t,e={}){let s=Tu(e.action),n={kind:Cu(e.kind??this.options.kind),timeout:Eu(e.timeout??this.options.timeout,s!==null),closable:e.closable??!!this.options.closable,action:s,leading:Mu(e.leading)},r=this._createEntry(t,n);return this._entries.add(r),this._queue.enqueue(r),{close:()=>this._close(r)}}static info(t,e={}){return this.show(t,{...e,kind:"info"})}static success(t,e={}){return this.show(t,{...e,kind:"success"})}static warning(t,e={}){return this.show(t,{...e,kind:"warning"})}static error(t,e={}){return this.show(t,{...e,kind:"error"})}static show(t,e={}){return this.#e(e.scope).show(t,e)}static progress(t,e={}){return this.#e(e.scope)._progress(t)}static disposeRegion(t){if(t==null)return!1;let e=wt(t);if(!e)return!1;let s=at(e),n=i.#t.get(s);return n?(i.#t.delete(s),n._disposeFloating(),!0):!1}destroy(){if(!this._cleaned){this._cleaned=!0,this._floatingHost=null;for(let t of this._entries)ms(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&Pu(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=Fu(r),o!==void 0&&(e.text=String(o)),hi(s,e))},done:()=>{n||s.closed||(n=!0,e.pct=100,hi(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(w("error",{size:18})),hi(s,e),s.remaining=4e3,this._queue.isActive(s)&&this._schedule(s))}}}_createEntry(t,e,s=null){let n=l("span",{class:"zx-message__icon",ariaHidden:"true"},e.leading??w(e.kind,{size:18})),r=l("div",{class:"zx-message__content"});le(t)?r.append(t):r.append(document.createTextNode(String(t)));let o=l("div",{class:"zx-message__toast",role:e.kind==="error"?"alert":"status",dataset:{kind:e.kind,state:"queued"}},n,r),a={node:o,content:r,iconHost:n,kind:e.kind,timeout:e.timeout,remaining:e.timeout,startedAt:0,timer:null,exitTimer:null,closed:!1,hovered:!1,focused:!1,returnFocus:null,progressBar:null,progressFill:null};if(e.leading&&(o.dataset.leading=""),s){o.dataset.progress="";let c=l("span",{class:"zx-message__progress-fill"}),u=l("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:s.text},c);r.append(u),a.progressBar=u,a.progressFill=c,hi(a,s)}if(e.action){let{label:c,kind:u,onclick:d}=e.action,h=Yr({label:c,kind:u,size:"sm"});h.classList.add("zx-message__action"),o.append(h),this.listen(h,"click",f=>{if(!a.closed)try{d?.(f)}finally{this._close(a)}})}if(e.closable){let c=l("button",{class:"zx-icon-btn zx-message__close",type:"button",ariaLabel:this._message("message.close","Close message"),title:this._message("message.closeTitle","Close")},w("x",{size:14}));o.append(c),this.listen(c,"click",()=>this._close(a))}return this.listen(o,"mouseenter",()=>{a.hovered=!0,this._pause(a)}),this.listen(o,"mouseleave",()=>{a.hovered=!1,this._resume(a)}),this.listen(o,"focusin",c=>{if(!a.focused){let u=c.relatedTarget;a.returnFocus=le(u)&&!o.contains(u)?u:null}a.focused=!0,this._pause(a)}),this.listen(o,"focusout",c=>{let u=c.relatedTarget;le(u)&&o.contains(u)||(a.focused=!1,this._resume(a))}),a}_activate(t){t.closed||(t.node.dataset.state="open",this.el.append(t.node),this._schedule(t))}_schedule(t){t.closed||t.remaining<=0||t.hovered||t.focused||(t.startedAt=Date.now(),t.timer=setTimeout(()=>this._close(t),t.remaining))}_pause(t){t.closed||t.timer===null||(clearTimeout(t.timer),t.timer=null,t.remaining=Math.max(0,t.remaining-(Date.now()-t.startedAt)))}_resume(t){if(!(t.closed||t.timer!==null||t.hovered||t.focused)){if(t.remaining<=0){this._close(t);return}this._schedule(t)}}_close(t){if(t.closed)return;if(t.closed=!0,ms(t),Nu(t),!this._queue.isActive(t)){this._queue.remove(t),t.node.remove(),this._entries.delete(t),this._releaseIfEmpty();return}if(t.node.dataset.state="closing",!Ru()){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)&&(ms(t),t.node.remove(),this._entries.delete(t),this._queue.remove(t),this._releaseIfEmpty())}_releaseIfEmpty(){!this._floatingHost||this._entries.size>0||i.#i(this)}_disposeFloating(){let t=this.el;this.destroy(),t.remove()}_message(t,e){let s=this.msg(t);return s===t?e:s}static#e(t){let e=at(t??null);e.isConnected||(e=at(null));let s=this.#t.get(e);if(s&&s.el.isConnected&&s.el.parentElement===e)return s;s&&(this.#t.delete(e),s._disposeFloating());let n=l("div",{class:"zx-message-region",popover:"manual",role:"status",ariaLive:"polite"});e.append(n);let r=new i(n);return r._floatingHost=e,this.#t.set(e,r),typeof n.showPopover=="function"&&n.showPopover(),r}static#i(t){let e=t._floatingHost;e&&i.#t.get(e)===t&&i.#t.delete(e),t._disposeFloating()}};function Cu(i){return i==="danger"?"error":["success","warning","error"].includes(String(i))?i:"info"}function Iu(i){let t=Number(i);return Number.isFinite(t)?Math.max(0,t):4e3}function Eu(i,t=!1){let e=Iu(i);return t&&e>0?Math.max(e,Du):e}function Tu(i){if(!i||typeof i!="object")return null;let t=i,e=t.label==null?"":String(t.label).trim();if(!e)return null;let s=["primary","danger","ghost"].includes(String(t.kind))?t.kind:"default";return{label:e,kind:s,onclick:typeof t.onclick=="function"?t.onclick:null}}function Mu(i){if(le(i))return i;if(i&&typeof i=="object"&&typeof i.toElement=="function"){let t=i.toElement();return le(t)?t:null}return null}function Nu(i){let e=i.node.getRootNode?.()?.activeElement??globalThis.document?.activeElement;if(!e||!i.node.contains(e))return;let s=i.returnFocus;i.returnFocus=null,s?.isConnected&&typeof s.focus=="function"&&s.focus({preventScroll:!0})}function Ou(i){let t=Number(i);return Number.isInteger(t)&&t>0?t:5}function le(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function Fu(i){let t=Number(i);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function hi(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 ms(i){i.timer!==null&&clearTimeout(i.timer),i.exitTimer!==null&&clearTimeout(i.exitTimer),i.timer=null,i.exitTimer=null}function Ru(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function Lu(i){return{attributes:Array.from(i.attributes,t=>[t.name,t.value]),children:Array.from(i.childNodes)}}function Pu(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 pi=Object.freeze(["agenda","day","week","month","year"]),ju=864e5;function bs(i,t,e={}){let s=Nt(t,"Calendar date"),n=bo(e.weekStart??1),r,o;if(i==="agenda")r=R(s),o=T(r,_i(e.agendaDays??14,"agendaDays"));else if(i==="day")r=R(s),o=T(r,1);else if(i==="week")r=fi(s,n),o=T(r,7);else if(i==="month"){let a=new Date(s.getFullYear(),s.getMonth(),1),c=new Date(s.getFullYear(),s.getMonth()+1,0);r=fi(a,n),o=T(fi(c,n),7)}else if(i==="year")r=new Date(s.getFullYear(),0,1),o=new Date(s.getFullYear()+1,0,1);else throw new RangeError(`Unknown calendar view: ${i}`);return{start:r,end:o}}function ys(i,t,e,s={}){let n=Nt(t,"Calendar date"),r=mt(e,"direction");if(i==="day")n.setDate(n.getDate()+r);else if(i==="agenda")n.setDate(n.getDate()+r*_i(s.agendaDays??14,"agendaDays"));else if(i==="week")n.setDate(n.getDate()+r*7);else{if(i==="month")return gs(n,r);if(i==="year")return gs(n,r*12);throw new RangeError(`Unknown calendar view: ${i}`)}return n}function gs(i,t){let e=Nt(i,"Calendar date"),s=e.getDate();return e.setDate(1),e.setMonth(e.getMonth()+mt(t,"month amount")),e.setDate(Math.min(s,Vu(e.getFullYear(),e.getMonth()))),e}function Vu(i,t){return new Date(i,t+1,0).getDate()}function Ut(i,t={}){if(!Array.isArray(i))throw new TypeError("Calendar events must be an array");let e={id:t.eventId??"id",title:t.eventTitle??"title",start:t.eventStart??"start",end:t.eventEnd??"end",allDay:t.eventAllDay??"allDay",color:t.eventColor??"color",location:t.eventLocation??"location",editable:t.eventEditable??"editable",durationEditable:t.eventDurationEditable??"durationEditable"},s=t.dateUnit==="seconds"?"seconds":"milliseconds",n=new Set;return i.map((r,o)=>{if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError(`Calendar event at index ${o} must be an object`);let a=pt(r,e.id);if(a==null||a==="")throw new TypeError(`Calendar event at index ${o} requires an id`);let c=String(a);if(n.has(c))throw new RangeError(`Duplicate Calendar event id: ${c}`);n.add(c);let u=fo(pt(r,e.start),s,`event ${c} start`),d=pt(r,e.end),h=d==null||d===""?new Date(u.getTime()):fo(d,s,`event ${c} end`);if(h<u)throw new RangeError(`Calendar event ${c} ends before it starts`);let f=String(pt(r,e.title)??"").trim()||"Untitled event",p=String(pt(r,e.location)??"").trim(),_=po(pt(r,e.editable)),m=po(pt(r,e.durationEditable));return{id:a,title:f,start:u,end:h,allDay:!!pt(r,e.allDay),color:$u(pt(r,e.color)),location:p,editable:_,durationEditable:m,data:r}})}function L(i){return{...i,start:new Date(i.start.getTime()),end:new Date(i.end.getTime())}}function ws(i,t,e={}){let s=go(e.minMinutes??0,"minMinutes"),n=go(e.maxMinutes??1440,"maxMinutes",!0),r=_i(e.minimumMinutes??30,"minimumMinutes");if(n<=s)throw new RangeError("Calendar maxMinutes must exceed minMinutes");let o=R(t),a=mo(o,s),c=mo(o,n),u=i.filter(p=>!lt(p)&&xs(p,a,c)).map(p=>{let _=new Date(Math.max(p.start.getTime(),a.getTime())),m=new Date(Math.min(p.end.getTime(),c.getTime()));return m<=_&&(m=new Date(Math.min(c.getTime(),_.getTime()+r*6e4))),{event:p,start:_,end:m,startMinutes:_o(o,_),endMinutes:_o(o,m),column:0,columns:1}}).sort((p,_)=>p.start-_.start||_.end-p.end||String(p.event.id).localeCompare(String(_.event.id))),d=[],h=-1/0,f=()=>{if(!d.length)return;let p=[],_=1;for(let m of d){let g=p.findIndex(b=>b<=m.start.getTime());g===-1&&(g=p.length),p[g]=m.end.getTime(),m.column=g,_=Math.max(_,g+1)}for(let m of d)m.columns=_;d=[],h=-1/0};for(let p of u)d.length&&p.start.getTime()>=h&&f(),d.push(p),h=Math.max(h,p.end.getTime());return f(),u}function mi(i,t,e){let s=R(t),n=T(s,_i(e,"days")),r=i.filter(a=>lt(a)&&xs(a,s,n)).map(a=>{let c=R(a.start),u=qu(a);return{event:a,start:Math.max(0,W(s,c)),end:Math.min(e,W(s,u)),lane:0}}).filter(a=>a.end>a.start).sort((a,c)=>a.start-c.start||c.end-a.end||String(a.event.id).localeCompare(String(c.event.id))),o=[];for(let a of r){let c=o.findIndex(u=>u<=a.start);c===-1&&(c=o.length),a.lane=c,o[c]=a.end}return r}function ce(i,t={}){let e=mt(t.days??0,"days"),s=mt(t.minutes??0,"minutes"),n=mt(t.endDays??e,"endDays"),r=mt(t.endMinutes??s,"endMinutes"),o=L(i);if(o.start=ho(o.start,e,s),o.end=ho(o.end,n,r),o.end<o.start)throw new RangeError("Calendar event proposal ends before it starts");return o}function R(i){let t=Nt(i,"Calendar date");return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function T(i,t){let e=Nt(i,"Calendar date"),s=new Date(e.getTime());return s.setDate(s.getDate()+mt(t,"day amount")),s}function fi(i,t=1){let e=R(i),s=bo(t);return T(e,-((e.getDay()-s+7)%7))}function W(i,t){let e=R(i),s=R(t),n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(s.getFullYear(),s.getMonth(),s.getDate());return Math.round((r-n)/ju)}function j(i){let t=Nt(i,"Calendar date"),e=s=>String(s).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function lt(i){if(i.allDay)return!0;if(i.end<=i.start)return!1;let t=new Date(i.end.getTime()-1);return j(i.start)!==j(t)}function ue(i,t,e){return xs(i,t,e)}function ho(i,t,e){let s=new Date(i.getTime());return s.setDate(s.getDate()+t),s.setMinutes(s.getMinutes()+e),s}function qu(i){if(i.end<=i.start)return T(R(i.start),1);let t=R(i.end);return i.end.getTime()===t.getTime()?t:T(t,1)}function xs(i,t,e){let s=i.end>i.start?i.end:new Date(i.start.getTime()+1);return i.start<e&&s>t}function pt(i,t){return typeof t=="function"?t(i):i[t]}function fo(i,t,e){let s;if(i instanceof Date)s=new Date(i.getTime());else if(typeof i=="number"||typeof i=="string"&&/^-?\d+(?:\.\d+)?$/.test(i.trim())){let n=Number(i);s=new Date(n*(t==="seconds"?1e3:1))}else s=new Date(i);return Nt(s,e)}function po(i){return i==null?null:!!i}function $u(i){let t=String(i??"").trim();return!t||t.length>100||/[;{}]|url\s*\(|image\s*\(/i.test(t)?null:/^#[\da-f]{3,8}$/i.test(t)||/^(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color)\([^{};]+\)$/i.test(t)||/^var\(--[\w-]+\)$/i.test(t)||/^[a-z]+$/i.test(t)?t:null}function mo(i,t){let e=R(i);return e.setMinutes(t),e}function _o(i,t){return(t.getTime()-i.getTime())/6e4}function Nt(i,t){if(!(i instanceof Date)||Number.isNaN(i.getTime()))throw new TypeError(`${t} must be a valid Date`);return new Date(i.getTime())}function bo(i){let t=Number(i);if(!Number.isInteger(t)||t<0||t>6)throw new RangeError("weekStart must be from 0 through 6");return t}function mt(i,t){let e=Number(i);if(!Number.isInteger(e))throw new TypeError(`${t} must be an integer`);return e}function _i(i,t){let e=mt(i,t);if(e<=0)throw new RangeError(`${t} must be greater than zero`);return e}function go(i,t,e=!1){let s=mt(i,t),n=e?1440:1439;if(s<0||s>n)throw new RangeError(`${t} must be from 0 through ${n}`);return s}var Bu={today:"Today",new:"New",agenda:"Agenda",day:"Day",week:"Week",month:"Month",year:"Year",previous:"Previous period",next:"Next period",allDay:"All day",noEvents:"No events",more:"+%1 more",loading:"Loading calendar\u2026",move:"Move %1",resize:"Resize %1",moveStarted:"Moving %1. Use arrow keys, Space to drop, or Escape to cancel.",resizeStarted:"Resizing %1. Use arrow keys, Space to drop, or Escape to cancel.",editPreview:"%1, %2 to %3",editCancelled:"Calendar edit cancelled.",editCommitted:"%1 updated.",calendar:"Calendar",weekNumber:"Week %1"},he=class extends v{static cssName="calendar";static defaults={events:[],date:null,view:"month",views:[...pi],weekStart:1,weekNumbers:!0,workweek:!1,agendaDays:14,slotDuration:30,slotMinTime:0,slotMaxTime:1440,scrollTime:480,eventLimit:3,selectable:!1,editable:!1,eventStartEditable:null,eventDurationEditable:null,optimistic:!0,nowIndicator:!0,now:null,disabled:!1,eventId:"id",eventTitle:"title",eventStart:"start",eventEnd:"end",eventAllDay:"allDay",eventColor:"color",eventLocation:"location",eventEditable:"editable",eventDurationEditable:"durationEditable",dateUnit:"milliseconds",msg:Bu};render(){let t=!this.el,e=this.el??l("section");this.el||(this.el=e),this._createdRoot=t,this._original=this._createdRoot?null:{attributes:Array.from(e.attributes).map(({name:h,value:f})=>[h,f]),children:Array.from(e.childNodes)},this._views=Ku(this.options.views),this._view=this._views.includes(this.options.view)?this.options.view:this._views[0],this._date=yo(this.options.date,this.options.dateUnit,this._now()),this._events=Ut(this.options.events,this._normalizeOptions()),this._loading=!1,this._destroyed=!1,this._pointer=null,this._keyboardEdit=null,this._mutationVersions=new Map,this._mutationSerial=0,this._suppressClickId=null,this._suppressDateClick=!1,this._focusedSlot=null,this._selection=null,this._nowTimer=null;let s=l("div",{class:"zx-calendar__navigation"},this._toolbarButton("previous",this.msg("previous"),"chevron-left"),this._toolbarButton("today",this.msg("today")),this._toolbarButton("next",this.msg("next"),"chevron-right")),n=l("h2",{ref:"heading",class:"zx-calendar__heading",ariaLive:"polite"}),r=l("div",{ref:"views",class:"zx-calendar__views",role:"group",ariaLabel:this._message("calendar.viewSwitch","Calendar view")},this._views.map(h=>l("button",{type:"button",class:"zx-calendar__view-button",dataset:{calendarAction:"view",view:h},disabled:this.options.disabled},this.msg(h)))),o=l("div",{class:"zx-calendar__commands"},r,l("button",{type:"button",class:"zx-calendar__new",dataset:{calendarAction:"new"},disabled:this.options.disabled},w("plus"),l("span",{},this.msg("new")))),a=l("header",{class:"zx-calendar__toolbar"},s,n,o),c=l("div",{ref:"body",class:"zx-calendar__body"}),u=l("div",{ref:"loading",class:"zx-calendar__loading",role:"status",hidden:!0},this.msg("loading")),d=l("div",{ref:"status",class:"zx-calendar__status",role:"status",ariaLive:"polite",ariaAtomic:"true"});return e.replaceChildren(a,c,u,d),e.setAttribute("aria-label",this.msg("calendar")),e.dataset.view=this._view,e.dataset.state="ready",this.listen(e,"click",h=>this._onClick(h)),this.listen(e,"dblclick",h=>this._onDoubleClick(h)),this.listen(e,"keydown",h=>this._onKeydown(h)),this.listen(e,"pointerdown",h=>this._onPointerDown(h)),this.listen(e,"pointermove",h=>this._onPointerMove(h)),this.listen(e,"pointerup",h=>this._onPointerUp(h)),this.listen(e,"pointercancel",h=>this._cancelPointer(h)),this.listen(e,"dragstart",h=>h.preventDefault()),this._renderView({emitDates:!0,scroll:!0}),this.options.nowIndicator&&(this._nowTimer=setInterval(()=>this._refreshNowIndicator(),6e4)),e}getEvents(){return this._events.map(L)}setEvents(t,e={}){let s=Ut(t,this._normalizeOptions());return this._events=s,this._mutationVersions.clear(),this._renderView({preserveFocus:!0}),e.silent||this.emit("eventschange",{events:this.getEvents()}),this}addEvent(t,e={}){let[s]=Ut([t],this._normalizeOptions());if(this._eventById(s.id))throw new RangeError(`Duplicate Calendar event id: ${s.id}`);return this._events=[...this._events,s],this._renderView({preserveFocus:!0}),e.silent||this.emit("eventschange",{events:this.getEvents()}),this}updateEvent(t,e,s={}){let n=this._eventIndex(t);if(n<0)throw new RangeError(`Unknown Calendar event id: ${t}`);let r=this._events[n],o={id:r.id,title:e.title??r.title,start:e.start??r.start,end:e.end??r.end,allDay:e.allDay??r.allDay,color:Object.prototype.hasOwnProperty.call(e,"color")?e.color:r.color,location:e.location??r.location,editable:Object.prototype.hasOwnProperty.call(e,"editable")?e.editable:r.editable,durationEditable:Object.prototype.hasOwnProperty.call(e,"durationEditable")?e.durationEditable:r.durationEditable,data:e.data??r.data},[a]=Ut([o],{dateUnit:this.options.dateUnit});return a.data=o.data,this._events=this._events.map((c,u)=>u===n?a:c),this._mutationVersions.delete(String(t)),this._renderView({preserveFocus:!0}),s.silent||this.emit("eventschange",{events:this.getEvents()}),this}removeEvent(t,e={}){let s=String(t),n=this._events.filter(r=>String(r.id)!==s);return n.length===this._events.length?this:(this._events=n,this._mutationVersions.delete(s),this._renderView({preserveFocus:!0}),e.silent||this.emit("eventschange",{events:this.getEvents()}),this)}getDate(){return new Date(this._date.getTime())}setDate(t,e={}){return this._date=yo(t,this.options.dateUnit,this._now()),this._renderView({emitDates:!e.silent,preserveFocus:!0,scroll:!0}),this}getView(){return this._view}setView(t,e={}){if(!this._views.includes(t))throw new RangeError(`Calendar view is not enabled: ${t}`);if(t===this._view)return this;let s=this._view;return this._view=t,this.el.dataset.view=t,this._renderView({emitDates:!0,preserveFocus:!0,scroll:!0}),e.silent||this.emit("viewchange",{view:t,oldView:s}),this}prev(){return this._page(-1)}next(){return this._page(1)}today(){return this.setDate(this._now())}setLoading(t=!0){return this._loading=!!t,this.el.dataset.state=this._loading?"loading":"ready",this.el.setAttribute("aria-busy",String(this._loading)),this.refs.loading.hidden=!this._loading,this}focusEvent(t){return this.el.querySelector(`[data-event-action][data-event-id="${gi(String(t))}"]`)?.focus(),this}destroy(){if(this._destroyed)return;this._destroyed=!0,this._nowTimer&&clearInterval(this._nowTimer),this._nowTimer=null;let t=this._original;if(super.destroy(),!this._createdRoot&&t){for(let e of Array.from(this.el.attributes))this.el.removeAttribute(e.name);for(let[e,s]of t.attributes)this.el.setAttribute(e,s);this.el.replaceChildren(...t.children)}}_toolbarButton(t,e,s=null){return l("button",{type:"button",class:"zx-calendar__toolbar-button",dataset:{calendarAction:t},ariaLabel:s?e:null,disabled:this.options.disabled},s?w(s):e)}_normalizeOptions(){return{eventId:this.options.eventId,eventTitle:this.options.eventTitle,eventStart:this.options.eventStart,eventEnd:this.options.eventEnd,eventAllDay:this.options.eventAllDay,eventColor:this.options.eventColor,eventLocation:this.options.eventLocation,eventEditable:this.options.eventEditable,eventDurationEditable:this.options.eventDurationEditable,dateUnit:this.options.dateUnit}}_renderView(t={}){if(!this.refs?.body||this._destroyed)return;let e=t.preserveFocus?this._focusIdentity():null,s=bs(this._view,this._date,{weekStart:this.options.weekStart,agendaDays:this.options.agendaDays});this._range=s,this.refs.heading.textContent=this._rangeTitle(s);for(let r of this.refs.views.querySelectorAll("[data-view]"))r.setAttribute("aria-pressed",String(r.dataset.view===this._view));let n=this._view==="agenda"?this._renderAgenda(s):this._view==="day"||this._view==="week"?this._renderTimeGrid(s):this._view==="month"?this._renderMonth(s):this._renderYear(s);this.refs.body.replaceChildren(n),t.scroll&&this._scrollTimeGrid(),e&&this._restoreFocus(e),t.emitDates&&this.emit("dateschange",{view:this._view,start:new Date(s.start.getTime()),end:new Date(s.end.getTime())})}_renderAgenda(t){let e=l("div",{class:"zx-calendar__agenda",role:"grid",ariaLabel:this._rangeTitle(t)}),s=W(t.start,t.end);for(let n=0;n<s;n+=1){let r=T(t.start,n),o=T(r,1),a=this._events.filter(d=>ue(d,r,o)?d.start>=r||n===0:!1).sort(Uu),c=l("section",{class:"zx-calendar__agenda-day",role:"row",dataset:{date:j(r)}},l("button",{type:"button",class:"zx-calendar__agenda-heading",role:"rowheader",dataset:{calendarAction:"date",date:j(r),dateCell:"true"},ariaCurrent:Ft(r,this._now())?"date":null,disabled:this.options.disabled},this._format(r,{weekday:"long",day:"numeric",month:"long"}))),u=l("div",{class:"zx-calendar__agenda-events",role:"gridcell"});if(!a.length)u.append(l("p",{class:"zx-calendar__agenda-empty"},this.msg("noEvents")));else for(let d of a)u.append(this._eventElement(d,{variant:"agenda",day:r}));c.append(u),e.append(c)}return e}_renderTimeGrid(t){let e=Array.from({length:W(t.start,t.end)},(b,y)=>T(t.start,y)),s=this._view==="week"&&this.options.workweek?e.filter(b=>b.getDay()>0&&b.getDay()<6):e,n=_t(this.options.slotMinTime,0),r=_t(this.options.slotMaxTime,1440,!0),o=tt(this.options.slotDuration);if(r<=n)throw new RangeError("slotMaxTime must exceed slotMinTime");let a=Math.ceil((r-n)/o),c=l("div",{class:"zx-calendar__time-surface",style:{"--zx-calendar-day-count":String(s.length)}}),u=l("div",{class:"zx-calendar__time-header"},l("span",{class:"zx-calendar__time-corner",ariaHidden:"true"}),l("div",{class:"zx-calendar__day-headings",role:"row"},s.map(b=>l("button",{type:"button",class:"zx-calendar__day-heading",role:"columnheader",dataset:{calendarAction:"date",date:j(b),dateCell:"true"},ariaCurrent:Ft(b,this._now())?"date":null,disabled:this.options.disabled},l("span",{class:"zx-calendar__day-weekday"},this._format(b,{weekday:"short"})),l("span",{class:"zx-calendar__day-number"},this._format(b,{day:"numeric",month:"short"})))))),d=this._renderAllDayRail(s),h=l("div",{ref:"timeScroller",class:"zx-calendar__time-scroller"}),f=l("div",{class:"zx-calendar__time-axis",ariaHidden:"true"}),p=l("div",{class:"zx-calendar__time-grid",role:"grid",ariaLabel:this._rangeTitle(t),ariaRowcount:String(a),ariaColcount:String(s.length),style:{"--zx-calendar-slot-count":String(a)}}),_=l("div",{ref:"slots",class:"zx-calendar__slots"}),m=!0;for(let b=0;b<a;b+=1){let y=n+b*o;f.append(l("span",{class:"zx-calendar__time-label"},y%60===0?vs(y,this.options.locale):""));for(let A=0;A<s.length;A+=1){let x=Yu(s[A],y),k=String(x.getTime()),M=this._focusedSlot?this._focusedSlot===k:m;M&&(m=!1),_.append(l("button",{type:"button",class:"zx-calendar__slot",role:"gridcell",tabindex:M?0:-1,dataset:{calendarAction:"date",slot:k,dateTime:k,dayIndex:String(A),rowIndex:String(b),major:y%60===0?"true":null},ariaLabel:this._dateTimeLabel(x),disabled:this.options.disabled}))}}let g=l("div",{class:"zx-calendar__timed-events",ariaHidden:"false"});return s.forEach((b,y)=>{let A=ws(this._events,b,{minMinutes:n,maxMinutes:r,minimumMinutes:o});for(let x of A){let k=(x.startMinutes-n)/(r-n)*100,M=Math.max(o/(r-n)*100,(x.endMinutes-x.startMinutes)/(r-n)*100),B=100/s.length,U=B/x.columns,Q=y*B+x.column*U,it=this._eventElement(x.event,{variant:"timed",day:b,resizable:!0});it.style.insetInlineStart=`${Q}%`,it.style.inlineSize=`${U}%`,it.style.insetBlockStart=`${k}%`,it.style.blockSize=`${M}%`,g.append(it)}}),p.append(_,g,this._nowLine(s,n,r)),h.append(f,p),c.append(u,d,h),c}_renderAllDayRail(t){let e=l("div",{class:"zx-calendar__all-day"},l("span",{class:"zx-calendar__all-day-label"},this.msg("allDay"))),s=l("div",{class:"zx-calendar__all-day-grid",role:"row",style:{"--zx-calendar-day-count":String(t.length)}});for(let r of t)s.append(l("span",{class:"zx-calendar__all-day-cell",dataset:{date:j(r)},ariaHidden:"true"}));let n=mi(this._events,t[0],t.length);for(let r of n){let o=this._eventElement(r.event,{variant:"span",day:t[r.start]});o.style.gridColumn=`${r.start+1} / ${r.end+1}`,o.style.gridRow=String(r.lane+1),s.append(o)}return e.append(s),e}_renderMonth(t){let e=l("div",{class:"zx-calendar__month"}),s=l("div",{class:"zx-calendar__month-weekdays",role:"row"});this.options.weekNumbers&&s.append(l("span",{class:"zx-calendar__month-week-gutter",ariaHidden:"true"}));for(let r=0;r<7;r+=1){let o=T(t.start,r);s.append(l("span",{class:"zx-calendar__month-weekday",role:"columnheader"},this._format(o,{weekday:"short"})))}e.append(s);let n=W(t.start,t.end)/7;for(let r=0;r<n;r+=1){let o=T(t.start,r*7),a=mi(this._events.map(m=>({...m,allDay:!0})),o,7),c=Hu(this.options.eventLimit),u=a.filter(m=>m.lane<c),d=a.filter(m=>m.lane>=c),h=l("div",{class:"zx-calendar__month-week",role:"row",dataset:{weekStart:j(o)}});this.options.weekNumbers&&h.append(l("button",{type:"button",class:"zx-calendar__month-week-number",dataset:{calendarAction:"week",date:j(o)},ariaLabel:this.msg("weekNumber",xo(o)),disabled:this.options.disabled},String(xo(o))));let f=l("div",{class:"zx-calendar__month-days"});for(let m=0;m<7;m+=1){let g=T(o,m),b=this._events.filter(y=>ue(y,g,T(g,1))).length;f.append(l("button",{type:"button",class:"zx-calendar__month-day",role:"gridcell",dataset:{calendarAction:"date",date:j(g),dateCell:"true",otherMonth:g.getMonth()===this._date.getMonth()?null:"true",eventCount:String(b)},ariaCurrent:Ft(g,this._now())?"date":null,ariaLabel:this._dayCountLabel(g,b),disabled:this.options.disabled},this._format(g,{day:"numeric"})))}let p=l("div",{class:"zx-calendar__month-events"});for(let m of u){let g=this._eventElement(m.event,{variant:"month",day:T(o,m.start)});g.style.gridColumn=`${m.start+1} / ${m.end+1}`,g.style.gridRow=String(m.lane+1),p.append(g)}let _=Array.from({length:7},(m,g)=>d.filter(b=>b.start<=g&&b.end>g).length);for(let m=0;m<_.length;m+=1){let g=_[m];if(!g)continue;let b=T(o,m);p.append(l("button",{type:"button",class:"zx-calendar__more",dataset:{calendarAction:"more",date:j(b),count:String(g)},style:{gridColumn:String(m+1),gridRow:String(c+1)},disabled:this.options.disabled},this.msg("more",g)))}h.append(f,p),e.append(h)}return e.setAttribute("role","grid"),e.setAttribute("aria-label",this._rangeTitle(t)),e}_renderYear(t){let e=t.start.getFullYear(),s=l("div",{class:"zx-calendar__year",ariaLabel:String(e)});for(let n=0;n<12;n+=1){let r=new Date(e,n,1),o=(r.getDay()-this.options.weekStart+7)%7,a=T(r,-o),c=l("div",{class:"zx-calendar__year-grid",role:"grid",ariaLabel:this._format(r,{month:"long"})},l("h3",{class:"zx-calendar__year-heading"},this._format(r,{month:"long"})));for(let u=0;u<7;u+=1){let d=T(a,u);c.append(l("span",{class:"zx-calendar__year-weekday",role:"columnheader"},this._format(d,{weekday:"narrow"})))}for(let u=0;u<42;u+=1){let d=T(a,u);if(d.getMonth()!==n){c.append(l("span",{class:"zx-calendar__year-blank",role:"gridcell",ariaHidden:"true"}));continue}let h=this._events.filter(f=>ue(f,d,T(d,1))).length;c.append(l("button",{type:"button",class:"zx-calendar__year-day",role:"gridcell",dataset:{calendarAction:"date",date:j(d),dateCell:"true",activity:String(Math.min(3,h))},ariaCurrent:Ft(d,this._now())?"date":null,ariaLabel:this._dayCountLabel(d,h),disabled:this.options.disabled},String(d.getDate())))}s.append(c)}return s}_eventElement(t,e){let s=String(t.id),n=l("div",{class:"zx-calendar__event",dataset:{eventId:s,variant:e.variant,allDay:t.allDay?"true":null,draggable:this._canMove(t)?"true":null},style:t.color?{"--zx-calendar-event-color":t.color}:null}),r=l("button",{type:"button",class:"zx-calendar__event-action",dataset:{eventAction:"activate",eventId:s},ariaLabel:this._eventLabel(t),disabled:this.options.disabled}),o=typeof this.options.renderEvent=="function"?this.options.renderEvent(L(t)):null;if(o instanceof Node)r.append(o);else if(typeof o=="string")r.append(document.createTextNode(o));else{let a=l("span",{class:"zx-calendar__event-time"},this._eventTime(t,e.day)),c=l("span",{class:"zx-calendar__event-title"},t.title);r.append(a,c),t.location&&r.append(l("span",{class:"zx-calendar__event-location"},t.location))}return n.append(r),e.resizable&&this._canResize(t)&&n.append(l("button",{type:"button",class:"zx-calendar__event-resize",dataset:{eventAction:"resize",eventId:s},ariaLabel:this.msg("resize",t.title),disabled:this.options.disabled},l("span",{ariaHidden:"true"}))),n}_nowLine(t,e,s){let n=this._now(),r=t.findIndex(c=>Ft(c,n)),o=n.getHours()*60+n.getMinutes(),a=this.options.nowIndicator&&r>=0&&o>=e&&o<=s;return l("div",{ref:"nowLine",class:"zx-calendar__now",hidden:!a,ariaHidden:"true",style:a?{insetBlockStart:`${(o-e)/(s-e)*100}%`,"--zx-calendar-now-day":String(r)}:null},l("span",{class:"zx-calendar__now-time"},vs(o,this.options.locale)))}_onClick(t){let e=t.target?.closest?.("button");if(!e||!this.el.contains(e))return;let s=e.dataset.eventId;if(s!=null&&this._suppressClickId===s){this._suppressClickId=null,t.preventDefault();return}if(e.dataset.eventAction==="activate"){let r=this._eventById(s);r&&this.emit("eventclick",{event:L(r),jsEvent:t});return}if(e.dataset.eventAction==="resize")return;let n=e.dataset.calendarAction;if(n){if(n==="previous")this.prev();else if(n==="next")this.next();else if(n==="today")this.today();else if(n==="view")this.setView(e.dataset.view);else if(n==="new")this.emit("new",{date:this.getDate(),view:this._view,jsEvent:t});else if(n==="week"){let r=kt(e.dataset.date);r&&this.setDate(r).setView("week")}else if(n==="more"){let r=kt(e.dataset.date);if(!r)return;!this.emit("moreclick",{date:r,count:Number(e.dataset.count),jsEvent:t}).defaultPrevented&&this._views.includes("agenda")&&this.setDate(r).setView("agenda")}else if(n==="date"){if(this._suppressDateClick){this._suppressDateClick=!1,t.preventDefault();return}let r=this._dateFromTarget(e);if(!r)return;this._rememberFocusedDate(e),this.emit("dateclick",{date:r,allDay:!e.dataset.dateTime,view:this._view,jsEvent:t})}}}_onDoubleClick(t){let e=t.target?.closest?.('[data-event-action="activate"]');if(e){let a=this._eventById(e.dataset.eventId);a&&this.emit("eventdblclick",{event:L(a),jsEvent:t});return}let s=t.target?.closest?.('[data-calendar-action="date"]');if(!s)return;let n=this._dateFromTarget(s);if(!n)return;let r=!s.dataset.dateTime,o=r?T(n,1):Ot(n,tt(this.options.slotDuration));this.emit("select",{start:n,end:o,allDay:r,view:this._view,jsEvent:t})}_onKeydown(t){let e=t.target?.closest?.("[data-event-action]");if(e){this._onEventKeydown(t,e);return}let s=t.target?.closest?.("[data-slot]");if(s){this._onSlotKeydown(t,s);return}let n=t.target?.closest?.("[data-date-cell]");n&&this._onDayKeydown(t,n)}_onEventKeydown(t,e){let s=this._eventById(e.dataset.eventId);if(!s)return;let n=e.dataset.eventAction==="resize";if(t.key==="Enter"&&!this._keyboardEdit&&!n){t.preventDefault(),this.emit("eventclick",{event:L(s),jsEvent:t});return}if(t.key===" "&&!this._keyboardEdit){if(n?!this._canResize(s):!this._canMove(s))return;t.preventDefault(),this._keyboardEdit={oldEvent:L(s),event:L(s),action:n?"resize":"move",control:e},e.setAttribute("aria-grabbed","true"),e.closest(".zx-calendar__event")?.setAttribute("data-state","grabbed"),this._announce(this.msg(n?"resizeStarted":"moveStarted",s.title));return}if(!this._keyboardEdit||String(this._keyboardEdit.event.id)!==String(s.id))return;if(t.key==="Escape"){t.preventDefault(),this._cancelKeyboardEdit();return}if(t.key===" "){t.preventDefault();let u=this._keyboardEdit;this._keyboardEdit=null,u.control.removeAttribute("aria-grabbed"),this._commitMutation(u.oldEvent,u.event,u.action,t);return}let r=0,o=0,a=!lt(s)&&(this._view==="day"||this._view==="week");if(t.key==="ArrowLeft")r=-1;else if(t.key==="ArrowRight")r=1;else if(t.key==="ArrowUp")a?o=-tt(this.options.slotDuration):r=-7;else if(t.key==="ArrowDown")a?o=tt(this.options.slotDuration):r=7;else return;t.preventDefault();let c=this._keyboardEdit;if(c.action==="move")c.event=ce(c.event,{days:r,minutes:o});else{let u=ce(c.event,{days:0,minutes:0,endDays:r,endMinutes:o});u.end>u.start&&(c.event=u)}c.control.closest(".zx-calendar__event")?.setAttribute("data-preview",this._eventTime(c.event,c.event.start)),this._announce(this.msg("editPreview",c.event.title,this._dateTimeLabel(c.event.start),this._dateTimeLabel(c.event.end)))}_onSlotKeydown(t,e){let s=Number(e.dataset.rowIndex),n=Number(e.dataset.dayIndex),r=e.closest('[role="grid"]'),o=Number(r?.getAttribute("aria-colcount"))||1,a=Number(r?.getAttribute("aria-rowcount"))||1,c=s,u=n;if(t.key==="ArrowLeft")u-=1;else if(t.key==="ArrowRight")u+=1;else if(t.key==="ArrowUp")c-=1;else if(t.key==="ArrowDown")c+=1;else if(t.key==="Home")u=0;else if(t.key==="End")u=o-1;else if(t.key==="PageUp"){t.preventDefault(),this.prev();return}else if(t.key==="PageDown"){t.preventDefault(),this.next();return}else if(t.key==="Enter"||t.key===" "){t.preventDefault();let h=this._dateFromTarget(e);h&&this.emit("dateclick",{date:h,allDay:!1,view:this._view,jsEvent:t});return}else return;t.preventDefault(),c=Math.max(0,Math.min(a-1,c)),u=Math.max(0,Math.min(o-1,u));let d=r?.querySelector(`[data-row-index="${c}"][data-day-index="${u}"]`);d&&(e.tabIndex=-1,d.tabIndex=0,this._focusedSlot=d.dataset.slot,d.focus())}_onDayKeydown(t,e){let s=kt(e.dataset.date);if(!s)return;let n=0;if(t.key==="ArrowLeft")n=-1;else if(t.key==="ArrowRight")n=1;else if(t.key==="ArrowUp")n=-7;else if(t.key==="ArrowDown")n=7;else if(t.key==="Home")n=-((s.getDay()-this.options.weekStart+7)%7);else if(t.key==="End")n=6-(s.getDay()-this.options.weekStart+7)%7;else if(t.key==="PageUp"){t.preventDefault(),this.prev();return}else if(t.key==="PageDown"){t.preventDefault(),this.next();return}else return;t.preventDefault();let r=T(s,n),o=this.el.querySelector(`[data-date-cell][data-date="${j(r)}"]`);o?o.focus():this.setDate(r)}_onPointerDown(t){if(this.options.disabled||t.button!==0)return;let e=t.target?.closest?.("[data-event-action]");if(e){let r=this._eventById(e.dataset.eventId),o=e.dataset.eventAction==="resize"?"resize":"move";if(!r||(o==="move"?!this._canMove(r):!this._canResize(r)))return;t.preventDefault(),this._capturePointer(t.pointerId);let a=o==="move"?this._dragOffsetForEvent(r,t.clientX,t.clientY):null;this._pointer={type:"event",pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,oldEvent:L(r),event:L(r),action:o,control:e,timeOffsetMinutes:a?.minutes??0,dayOffset:a?.days??0,moved:!1};return}let s=t.target?.closest?.("[data-slot]");if(!s||!this.options.selectable)return;let n=this._dateFromTarget(s);n&&(t.preventDefault(),this._capturePointer(t.pointerId),this._pointer={type:"selection",pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,start:n,end:Ot(n,tt(this.options.slotDuration)),control:s,moved:!1})}_onPointerMove(t){let e=this._pointer;if(!e||e.pointerId!==t.pointerId||!e.moved&&Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<5)return;if(e.moved=!0,t.preventDefault(),e.type==="selection"){let r=this._timeAtPoint(t.clientX,t.clientY);if(!r)return;let o=tt(this.options.slotDuration);e.end=Ot(r,o),this._previewSelection(e.start,e.end);return}let s=this._proposalAtPoint(e.oldEvent,e.action,t.clientX,t.clientY);if(!s)return;e.event=s;let n=e.control.closest(".zx-calendar__event");if(n){if(n.dataset.state="dragging",e.action==="resize"){n.style.transform="";let r=this._timedPreviewHeight(s);r&&(n.style.blockSize=r)}else n.style.transform=`translate(${t.clientX-e.startX}px, ${t.clientY-e.startY}px)`;n.dataset.preview=this._eventTime(s,s.start)}this._announce(this.msg("editPreview",s.title,this._dateTimeLabel(s.start),this._dateTimeLabel(s.end)))}_onPointerUp(t){let e=this._pointer;if(!(!e||e.pointerId!==t.pointerId)&&(this._pointer=null,this._releasePointerCapture(e.pointerId),this._clearSelectionPreview(),!!e.moved)){if(t.preventDefault(),e.type==="selection"){this._suppressDateClick=!0;let s=e.start<e.end?e.start:Ot(e.end,-tt(this.options.slotDuration)),n=e.start<e.end?e.end:Ot(e.start,tt(this.options.slotDuration));this.emit("select",{start:new Date(s),end:new Date(n),allDay:!1,view:this._view,jsEvent:t});return}this._suppressClickId=String(e.oldEvent.id),this._commitMutation(e.oldEvent,e.event,e.action,t)}}_cancelPointer(t){if(!this._pointer||this._pointer.pointerId!==t.pointerId)return;let e=this._pointer.control;this._releasePointerCapture(this._pointer.pointerId),this._pointer=null,this._clearSelectionPreview(),e.closest?.(".zx-calendar__event")?.removeAttribute("data-state"),this._renderView({preserveFocus:!0})}_proposalAtPoint(t,e,s,n){let r=e==="resize"&&!lt(t),o=this._timeAtPoint(s,n,r?t.start:null);if(o&&!lt(t)){if(e==="move"){let p=t.end.getTime()-t.start.getTime(),_=L(t);return _.start=Ot(o,-Number(this._pointer?.timeOffsetMinutes??0)),_.end=new Date(_.start.getTime()+p),_}let f=L(t);return f.end=Ot(o,tt(this.options.slotDuration)),f.end>f.start?f:null}let a=this._dayAtPoint(s,n);if(!a)return null;let c=T(a,-Number(this._pointer?.dayOffset??0)),u=W(R(t.start),c);if(e==="move")return ce(t,{days:u,minutes:0});let d=L(t),h=T(a,1);return d.end=new Date(h.getTime()),d.end>d.start?d:null}_timeAtPoint(t,e,s=null){let n=this.refs.body.querySelector(".zx-calendar__slots");if(!n)return null;let r=n.getBoundingClientRect(),a=n.closest(".zx-calendar__time-scroller")?.getBoundingClientRect(),c=a?Math.max(r.left,a.left):r.left,u=a?Math.min(r.right,a.right):r.right,d=a?Math.max(r.top,a.top):r.top,h=a?Math.min(r.bottom,a.bottom):r.bottom;if(t<c||t>u||e<d||e>h||r.width<=0||r.height<=0)return null;let f=Number(n.closest('[role="grid"]')?.getAttribute("aria-colcount"))||1,p=Number(n.closest('[role="grid"]')?.getAttribute("aria-rowcount"))||1,_=s?this._timeGridDayIndex(s):-1,m=_>=0?_:Math.max(0,Math.min(f-1,Math.floor((t-r.left)/r.width*f))),g=Math.max(0,Math.min(p-1,Math.floor((e-r.top)/r.height*p))),b=n.querySelector(`[data-row-index="${g}"][data-day-index="${m}"]`);return b?this._dateFromTarget(b):null}_dayAtPoint(t,e){let s=this.refs.body.querySelector(".zx-calendar__all-day-grid");if(s){let r=s.getBoundingClientRect();if(t>=r.left&&t<=r.right&&e>=r.top&&e<=r.bottom){let o=s.querySelectorAll("[data-date]"),a=Math.max(0,Math.min(o.length-1,Math.floor((t-r.left)/r.width*o.length)));return kt(o[a]?.dataset.date)}}for(let r of this.refs.body.querySelectorAll(".zx-calendar__month-events")){let o=r.getBoundingClientRect();if(t<o.left||t>o.right||e<o.top||e>o.bottom||o.width<=0)continue;let a=kt(r.closest(".zx-calendar__month-week")?.dataset.weekStart);if(!a)continue;let c=Math.max(0,Math.min(6,Math.floor((t-o.left)/o.width*7)));return T(a,c)}for(let r of this.refs.body.querySelectorAll(".zx-calendar__agenda-day")){let o=r.getBoundingClientRect();if(!(t<o.left||t>o.right||e<o.top||e>o.bottom))return kt(r.dataset.date)}let n=typeof document.elementsFromPoint=="function"?document.elementsFromPoint(t,e):[];for(let r of n){let o=r instanceof HTMLElement?r.closest("[data-date]"):null,a=o instanceof HTMLElement?o.dataset.date:null;if(a)return kt(a)}return null}_dragOffsetForEvent(t,e,s){if(!lt(t)){let o=this._timeAtPoint(e,s);if(o){let a=tt(this.options.slotDuration),c=Math.max(0,Math.round((t.end.getTime()-t.start.getTime())/6e4)),u=Math.max(0,c-a),d=Math.round((o.getTime()-t.start.getTime())/6e4);return{minutes:Math.max(0,Math.min(u,d)),days:0}}}let n=this._dayAtPoint(e,s),r=n?W(R(t.start),n):0;return{minutes:0,days:Math.max(0,r)}}_timeGridDayIndex(t){let e=j(t);return[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")].findIndex(n=>n.dataset.date===e)}_timedPreviewHeight(t){if(!this.refs.body.querySelector(".zx-calendar__time-grid")||lt(t))return null;let s=_t(this.options.slotMinTime,0),n=_t(this.options.slotMaxTime,1440,!0),r=tt(this.options.slotDuration),o=t.start.getHours()*60+t.start.getMinutes(),a=t.end.getHours()*60+t.end.getMinutes();return`${Math.max(r,Math.min(n,a)-Math.max(s,o))/(n-s)*100}%`}_capturePointer(t){try{this.el.setPointerCapture?.(t)}catch{}}_releasePointerCapture(t){this.el.hasPointerCapture?.(t)&&this.el.releasePointerCapture?.(t)}_previewSelection(t,e){let s=Math.min(t.getTime(),e.getTime()),n=Math.max(t.getTime(),e.getTime());for(let r of this.refs.body.querySelectorAll("[data-slot]")){let o=Number(r.dataset.dateTime);r.setAttribute("aria-selected",String(o>=s&&o<n))}}_clearSelectionPreview(){for(let t of this.refs.body.querySelectorAll("[data-slot][aria-selected]"))t.removeAttribute("aria-selected")}_cancelKeyboardEdit(){let t=this._keyboardEdit;t&&(t.control.removeAttribute("aria-grabbed"),t.control.closest(".zx-calendar__event")?.removeAttribute("data-state"),this._keyboardEdit=null,this._announce(this.msg("editCancelled")),this._renderView({preserveFocus:!0}))}_commitMutation(t,e,s,n){if(!(t.start.getTime()!==e.start.getTime()||t.end.getTime()!==e.end.getTime())){this._renderView({preserveFocus:!0});return}let o=String(t.id),a=++this._mutationSerial,c=!1;this.options.optimistic?(this._replaceNormalizedEvent(e),this._mutationVersions.set(o,a),this._renderView({preserveFocus:!0})):this._renderView({preserveFocus:!0});let u=()=>{if(c||!this.options.optimistic||this._mutationVersions.get(o)!==a)return!1;let f=this._eventById(o);return!f||f.start.getTime()!==e.start.getTime()||f.end.getTime()!==e.end.getTime()?!1:(c=!0,this._replaceNormalizedEvent(t),this._mutationVersions.delete(o),this._renderView({preserveFocus:!0}),this._announce(this.msg("editCancelled")),!0)},d={event:L(e),oldEvent:L(t),action:s,delta:Wu(t,e),jsEvent:n,revert:u};this.emit("eventchange",d).defaultPrevented?u():this._announce(this.msg("editCommitted",e.title))}_replaceNormalizedEvent(t){let e=String(t.id);this._events=this._events.map(s=>String(s.id)===e?L(t):s)}_canMove(t){return this.options.disabled?!1:t.editable!=null?t.editable:this.options.eventStartEditable!=null?!!this.options.eventStartEditable:!!this.options.editable}_canResize(t){return this.options.disabled?!1:t.durationEditable!=null?t.durationEditable:this.options.eventDurationEditable!=null?!!this.options.eventDurationEditable:!!this.options.editable}_eventById(t){let e=this._eventIndex(t);return e<0?null:this._events[e]}_eventIndex(t){let e=String(t);return this._events.findIndex(s=>String(s.id)===e)}_page(t){return this.setDate(ys(this._view,this._date,t,{agendaDays:this.options.agendaDays}))}_rangeTitle(t){if(this._view==="day")return this._format(t.start,{weekday:"long",day:"numeric",month:"long",year:"numeric"});if(this._view==="month")return this._format(this._date,{month:"long",year:"numeric"});if(this._view==="year")return this._format(this._date,{year:"numeric"});let e=T(t.end,-1),s=new Intl.DateTimeFormat(this.options.locale,{day:"numeric",month:"long",year:"numeric"});return typeof s.formatRange=="function"?s.formatRange(t.start,e):t.start.getFullYear()!==e.getFullYear()?`${this._format(t.start,{day:"numeric",month:"short",year:"numeric"})} \u2013 ${this._format(e,{day:"numeric",month:"short",year:"numeric"})}`:t.start.getMonth()!==e.getMonth()?`${this._format(t.start,{day:"numeric",month:"short"})} \u2013 ${this._format(e,{day:"numeric",month:"short",year:"numeric"})}`:`${this._format(t.start,{day:"numeric"})}\u2013${this._format(e,{day:"numeric",month:"long",year:"numeric"})}`}_eventTime(t,e){if(t.allDay)return this.msg("allDay");if(lt(t))return Ft(t.start,e)?`${de(t.start,this.options.locale)} \u2192`:Ft(t.end,e)?`\u2192 ${de(t.end,this.options.locale)}`:this.msg("allDay");let s=Ss(t.start,this.options.locale);return t.end<=t.start?s:`${s}\u2013${Ss(t.end,this.options.locale)}`}_eventLabel(t){let e=t.location?`, ${t.location}`:"";return`${t.title}, ${de(t.start,this.options.locale)} to ${de(t.end,this.options.locale)}${e}`}_dateTimeLabel(t){return de(t,this.options.locale)}_format(t,e){return new Intl.DateTimeFormat(this.options.locale,e).format(t)}_now(){let t=typeof this.options.now=="function"?this.options.now():this.options.now,e=t??new Date;if(!(e instanceof Date)||Number.isNaN(e.getTime()))throw new TypeError("Calendar now must return a valid Date");return new Date(e.getTime())}_dateFromTarget(t){if(t.dataset.dateTime){let e=new Date(Number(t.dataset.dateTime));return Number.isNaN(e.getTime())?null:e}return kt(t.dataset.date)}_rememberFocusedDate(t){t.dataset.slot&&(this._focusedSlot=t.dataset.slot)}_focusIdentity(){let t=document.activeElement;return!(t instanceof HTMLElement)||!this.el.contains(t)?null:{eventId:t.dataset.eventId,eventAction:t.dataset.eventAction,date:t.dataset.date,slot:t.dataset.slot}}_restoreFocus(t){let e=null;t.eventId&&(e=this.el.querySelector(`[data-event-id="${gi(t.eventId)}"][data-event-action="${t.eventAction??"activate"}"]`)),!e&&t.slot&&(e=this.el.querySelector(`[data-slot="${gi(t.slot)}"]`)),!e&&t.date&&(e=this.el.querySelector(`[data-date-cell][data-date="${gi(t.date)}"]`)),e?.focus?.()}_scrollTimeGrid(){let t=this.refs.body.querySelector(".zx-calendar__time-scroller");if(!t)return;let e=_t(this.options.slotMinTime,0),s=_t(this.options.slotMaxTime,1440,!0),n=_t(this.options.scrollTime,480,!0),r=Math.max(0,Math.min(1,(n-e)/(s-e)));requestAnimationFrame(()=>{t.isConnected&&(t.scrollTop=Math.max(0,r*t.scrollHeight-t.clientHeight/4))})}_refreshNowIndicator(){if(this._destroyed||!this.options.nowIndicator||!["day","week"].includes(this._view))return;let t=this.refs.body.querySelector(".zx-calendar__now"),e=[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")];if(!t||!e.length)return;let s=this._now(),n=e.findIndex(u=>u.dataset.date===j(s)),r=_t(this.options.slotMinTime,0),o=_t(this.options.slotMaxTime,1440,!0),a=s.getHours()*60+s.getMinutes(),c=n>=0&&a>=r&&a<=o;t.hidden=!c,c&&(t.style.insetBlockStart=`${(a-r)/(o-r)*100}%`,t.style.setProperty("--zx-calendar-now-day",String(n)),t.querySelector(".zx-calendar__now-time").textContent=vs(a,this.options.locale))}_announce(t){this.refs.status.textContent="",requestAnimationFrame(()=>{this._destroyed||(this.refs.status.textContent=t)})}_dayCountLabel(t,e){let s=this._format(t,{dateStyle:"full"});return e===1?this._message("calendar.dayEvent","%1, %2 event",s,e):this._message("calendar.dayEvents","%1, %2 events",s,e)}_message(t,e,...s){let n=this.msg(t,...s);return n===t?O(e,s):n}};function Ku(i){if(!Array.isArray(i)||i.length===0)throw new TypeError("Calendar views must be a non-empty array");let t=[...new Set(i.map(String))];for(let e of t)if(!pi.includes(e))throw new RangeError(`Unknown Calendar view: ${e}`);return t}function yo(i,t,e){if(i==null)return e;if(i instanceof Date){if(Number.isNaN(i.getTime()))throw new TypeError("Calendar date must be valid");return new Date(i.getTime())}let s=typeof i=="number"?i:typeof i=="string"&&/^-?\d+(?:\.\d+)?$/.test(i.trim())?Number(i):null,n=s==null?new Date(i):new Date(s*(t==="seconds"?1e3:1));if(Number.isNaN(n.getTime()))throw new TypeError("Calendar date must be valid");return n}function tt(i){let t=Number(i);if(!Number.isInteger(t)||t<=0||t>720||1440%t!==0)throw new RangeError("Calendar slotDuration must be a positive divisor of 1440");return t}function Hu(i){let t=Number(i);if(!Number.isInteger(t)||t<1||t>20)throw new RangeError("Calendar eventLimit must be an integer from 1 through 20");return t}function _t(i,t,e=!1){let s=Number(i??t),n=e?1440:1439;if(!Number.isInteger(s)||s<0||s>n)throw new RangeError(`Calendar minute must be from 0 through ${n}`);return s}function Yu(i,t){let e=R(i);return e.setMinutes(t),e}function Ot(i,t){let e=new Date(i.getTime());return e.setMinutes(e.getMinutes()+t),e}function wo(i){return`${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`}function Ft(i,t){return wo(i)===wo(t)}function kt(i){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(i??""));if(!t)return null;let e=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return j(e)===i?e:null}function Uu(i,t){return i.start-t.start||t.end-i.end||i.title.localeCompare(t.title)}function vs(i,t){let e=new Date(2026,0,1);return e.setHours(Math.floor(i/60)%24,i%60,0,0),Ss(e,t)}function Ss(i,t){return new Intl.DateTimeFormat(t,{hour:"2-digit",minute:"2-digit"}).format(i)}function de(i,t){return new Intl.DateTimeFormat(t,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(i)}function xo(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-s)/864e5+1)/7)}function Wu(i,t){let e=t.start.getTime()-i.start.getTime();return{milliseconds:e,days:W(R(i.start),R(t.start)),minutes:Math.round(e/6e4),endMilliseconds:t.end.getTime()-i.end.getTime()}}function gi(i){return globalThis.CSS?.escape?CSS.escape(i):i.replace(/[^a-zA-Z0-9_-]/g,t=>`\\${t}`)}var fe=class extends v{static cssName="fieldset";static defaults={title:"",columns:1,fields:{},idPrefix:null};render(){let t=this.el??l("fieldset");this._fields=new Map,this._ownedFields=new Set,this._origins=new Map,this._fieldIdAttributes=new Map,this._ownedNodes=[],this._idPrefix=this.options.idPrefix?String(this.options.idPrefix):D("zx-fieldset"),this._columnAttribute=t.getAttribute("data-columns");let e=[1,2,3].includes(Number(this.options.columns))?Number(this.options.columns):1;if(t.dataset.columns=String(e),this.options.title){let n=l("legend",{class:"zx-fieldset__legend"},String(this.options.title));this._ownedNodes.push(n),t.append(n)}this._grid=l("div",{class:"zx-fieldset__grid"}),this._ownedNodes.push(this._grid),t.append(this._grid);let 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 S)n=e;else if(q(e)||e instanceof v){let o=e;n=new S(null,{id:this._controlId(s),name:s,type:"custom",label:s,value:Qu(o),disabled:Gu(o),adapter:()=>Zu(o)}),r=!0}else{let o=e&&typeof e=="object"?e:{},a=o.id!=null&&String(o.id)!==""&&String(o.id)!==s;n=new S(null,{...o,id:a?String(o.id):this._controlId(s),name:o.name??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}_controlId(t){return`${this._idPrefix}-${t.trim().replace(/\s+/g,"-")}`}_releaseField(t){let e=this._fieldIdAttributes.get(t);if(e==null?t.el.removeAttribute("data-field-id"):t.el.setAttribute("data-field-id",e),this._fieldIdAttributes.delete(t),this._ownedFields.has(t)){t.destroy(),this._ownedFields.delete(t);return}let 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 Zu(i){let t=q(i)?i:i.toElement(),e=t.parentNode,s=t.nextSibling,n=new Map(["id","aria-labelledby","aria-describedby","aria-disabled","aria-invalid"].map(a=>[a,t.getAttribute(a)])),r="disabled"in t?t.disabled:void 0,o="value"in t?t.value:void 0;return{el:t,get:()=>typeof i.getValue=="function"?i.getValue():typeof i.getValues=="function"?i.getValues():"value"in t?t.value:null,set:(a,c)=>{typeof i.setValue=="function"?i.setValue(a,c):typeof i.setValues=="function"&&a&&typeof a=="object"?i.setValues(a,c):"value"in t&&(t.value=a??"")},focus:()=>{typeof i.focus=="function"?i.focus():typeof t.focus=="function"&&t.focus()},setDisabled:a=>{typeof i.setDisabled=="function"?i.setDisabled(a):"disabled"in t?t.disabled=a:t.setAttribute("aria-disabled",String(a))},destroy:()=>{for(let[a,c]of n)c===null?t.removeAttribute(a):t.setAttribute(a,c);r!==void 0&&(t.disabled=r),o!==void 0&&(t.value=o),e?e.insertBefore(t,s?.parentNode===e?s:null):t.remove()}}}function Qu(i){let t=q(i)?i:i.toElement();return typeof i.getValue=="function"?i.getValue():typeof i.getValues=="function"?i.getValues():"value"in t?t.value:null}function Gu(i){let t=q(i)?i:i.toElement();return"disabled"in t?!!t.disabled:t.getAttribute("aria-disabled")==="true"}var pe=class extends v{static cssName="form";static defaults={fieldsets:[],actions:[],novalidate:!0,idPrefix:null,msg:{"form.required":"This field is required.","form.int":"Enter a whole number.","form.float":"Enter a valid number."}};render(){let t=this.el??l("form");this._fieldsets=[],this._ownedFieldsets=new Set,this._origins=new Map,this._ownedNodes=[],this._idPrefix=this.options.idPrefix?String(this.options.idPrefix):D("zx-form"),this._novalidateAttribute=t.getAttribute("novalidate"),t.toggleAttribute("novalidate",!!this.options.novalidate),this._body=l("div",{class:"zx-form__body"}),this._actions=l("div",{class:"zx-form__actions"}),this._ownedNodes.push(this._body,this._actions),t.append(this._body,this._actions),this.listen(t,"submit",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 fe),s=e?new fe(null,{...t??{},idPrefix:t?.idPrefix??this._idPrefix}):t;return this._fieldsets.includes(s)||(e?this._ownedFieldsets.add(s):this._origins.set(s,{parent:s.el.parentNode,next:s.el.nextSibling}),this._fieldsets.push(s),this._body.append(s.el),this.listen(s.el,"zx-change",n=>{let r=n.target,o=r instanceof Element?r.dataset.fieldId:null;o&&this.emit("change",{id:o,value:s.getValue(o)})})),s}setActions(t){return this._actionDescriptors=Array.isArray(t)?t.map(e=>({...e})):[],this._actions.replaceChildren(...this._actionDescriptors.map((e,s)=>{let n=String(e.label??e.id??"Action");return l("button",{class:"zx-btn",type:["submit","reset"].includes(e.type)?e.type:"button",disabled:!!e.disabled,title:e.title,ariaLabel:!n&&e.title?e.title:void 0,dataset:{actionIndex:s,kind:["primary","danger","ghost"].includes(e.kind)?e.kind:"default",size:e.size==="sm"?"sm":"md"}},e.icon?w(e.icon,{size:16}):null,n?l("span",{class:"zx-btn__label"},n):null)})),this._actions.hidden=this._actionDescriptors.length===0,this}getValues(){return Object.assign({},...this._fieldsets.map(t=>t.getValues()))}setValues(t,{silent:e=!1}={}){for(let s of this._fieldsets)s.setValues(t,{silent:e});return this}getField(t){for(let e of this._fieldsets){let s=e.getField(t);if(s)return s}return null}setValue(t,e){return this.getField(t)?.setValue(e),this}getValue(t){return this.getField(t)?.getValue()??null}reset(){for(let t of this._fieldsets)t.reset().clearHighlights();return this}setHighlights(t,e="danger"){return this._fieldsets.reduce((s,n)=>s+n.setHighlights(t,e),0)}clearHighlights(){for(let t of this._fieldsets)t.clearHighlights();return this}submit(){let t={},e=null;for(let n of this._fieldsets)for(let[r,o]of Object.entries(n.getFields())){let a=o.getValue(),c="";if(o.options.required&&As(a))c=this.msg("form.required");else if(!As(a)&&o.options.type==="int"){let u=Li(a);u.valid?o.setValue(u.value,{silent:!0}):c=this.msg("form.int")}else if(!As(a)&&o.options.type==="float"){let u=Pi(a);u.valid?o.setValue(u.value,{silent:!0}):c=this.msg("form.float")}c?(t[r]=c,o.setHighlight(c,"danger"),e??=o):o.clearHighlight()}return Object.keys(t).length?(this.emit("invalid",{errors:t}),e?.focus(),!1):!this.emit("submit",{values:this.getValues()}).defaultPrevented}_handleAction(t){let e=t.target instanceof Element?t.target.closest("[data-action-index]"):null;if(!e||!this._actions.contains(e))return;let s=this._actionDescriptors[Number(e.dataset.actionIndex)],n=s?.onClick??s?.onclick??s?.handler;typeof n=="function"&&n(t,this)}destroy(){for(let t of this._fieldsets??[])if(this._ownedFieldsets.has(t))t.destroy();else{let e=this._origins.get(t);e?.parent?e.parent.insertBefore(t.el,e.next?.parentNode===e.parent?e.next:null):t.el.remove()}this._fieldsets=[];for(let t of this._ownedNodes??[])t.remove();this._novalidateAttribute===null?this.el.removeAttribute("novalidate"):this.el.setAttribute("novalidate",this._novalidateAttribute),super.destroy()}};function As(i){return i==null||i===""||i===!1||Array.isArray(i)&&i.length===0}function Xu(){Dr(),xn(),Sn(),or(),Yn(),ir(),Or(),Lr(),hr(),lr(),Fr(),pr(),mr(),Tr(),Cr()}Xu();function ct(i,{onError:t,locale:e}={}){if(!i||typeof i!="object"||!i.api||typeof i.api!="object")throw new TypeError("connect() requires a ZeyOS client with an api namespace");if(t!=null&&typeof t!="function")throw new TypeError("onError must be a function");let s=e??Ju(i);s&&Ri(String(s));let n=(o,a)=>t?t(o,a):At.error(zs(o)),r=async(o,a,c)=>{let u=td(i,o,a);try{return await i.api[u](c)}catch(d){try{n(d,{operation:u,resource:a})}catch{}throw d}};return{client:i,list:(o,a={})=>r("list",o,a),get:(o,a,c={})=>r("get",o,vo(a)?a:{ID:a,...c}),create:(o,a)=>r("create",o,a),update:(o,a,c)=>r("update",o,c===void 0&&vo(a)?a:{ID:a,body:c??{}}),reportError:n}}function Ju(i){return i.locale??i.language??i.config?.locale??i.metadata?.locale??null}function td(i,t,e){let s=String(e??"").trim();if(!s)throw new TypeError("ZeyOS resource must not be empty");let n=typeof i.schema?.operations=="function"?i.schema.operations(s):[];if(Array.isArray(n)&&n.length){let f=n.filter(p=>typeof p=="string"&&p.toLowerCase().startsWith(t)).sort((p,_)=>p.length-_.length);if(f.length)return f[0]}let r=Array.isArray(n)&&n.length?n:typeof i.schema?.operationIds=="function"?i.schema.operationIds():Object.keys(i.api);if(r.includes(s)&&s.toLowerCase().startsWith(t))return s;let o=So(s),a=Ao(o),c=r.filter(f=>{if(typeof f!="string"||!f.toLowerCase().startsWith(t))return!1;let p=So(f.slice(t.length));return p===o||p===a||Ao(p)===a});if(c.length)return c.sort((f,p)=>f.length-p.length)[0];let u=t==="list"?[`list${ks(s)}`]:[`${t}${ks(ed(s))}`,`${t}${ks(s)}`],d=new Set(Object.keys(i.api)),h=u.find(f=>d.has(f));if(h)return h;throw new RangeError(`No ${t} operation found for ZeyOS resource "${s}"`)}function vo(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function zs(i){return i instanceof Error&&i.message||i&&typeof i=="object"&&typeof i.message=="string"?i.message:String(i??"ZeyOS request failed")}function So(i){return String(i).replace(/[^a-z\d]/gi,"").toLowerCase()}function Ao(i){return i.endsWith("ies")?`${i.slice(0,-3)}y`:i.endsWith("sses")?i.slice(0,-2):i.endsWith("s")&&!i.endsWith("ss")?i.slice(0,-1):i}function ed(i){let t=String(i);return/ies$/i.test(t)?`${t.slice(0,-3)}y`:/s$/i.test(t)&&!/ss$/i.test(t)?t.slice(0,-1):t}function ks(i){return String(i).split(/[^a-z\d]+/i).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}var Rt=Object.freeze({accounts:{label:"Accounts",icon:"zeyos-accounts",color:"#bc3885",fa:"building"},actionsteps:{label:"Action Steps",icon:"zeyos-actionsteps",color:"#f67f00",fa:"clock"},appointments:{label:"Appointments",icon:"zeyos-appointments",color:"#bd1e32",fa:"calendar-check"},billing:{label:"Billing",icon:"zeyos-billing",color:"#535494",fa:"file-invoice-dollar"},calendar:{label:"Calendar",icon:"zeyos-calendar",color:"#bd1e32",fa:"calendar-days"},campaigns:{label:"Campaigns",icon:"zeyos-campaigns",color:"#f16528",fa:"bullhorn"},collection:{label:"Collection",icon:"zeyos-collection",color:"#0d60ae",fa:"hand-holding-dollar"},contacts:{label:"Contacts",icon:"zeyos-contacts",color:"#8c6641",fa:"address-book"},contracts:{label:"Contracts",icon:"zeyos-contracts",color:"#823e89",fa:"file-contract"},coupons:{label:"Coupons",icon:"zeyos-coupons",color:"#10775c",fa:"ticket-simple"},devices:{label:"Devices",icon:"zeyos-devices",color:"#064e4f",fa:"desktop"},documents:{label:"Documents",icon:"zeyos-documents",color:"#808000",fa:"file"},dunning:{label:"Dunning",icon:"zeyos-dunning",color:"#0d60ae",fa:"file-invoice-dollar"},events:{label:"Events",icon:"zeyos-events",color:"#bd1e32",fa:"calendar-day"},inventory:{label:"Inventory",icon:"zeyos-inventory",color:"#064e4f",fa:"warehouse"},items:{label:"Items",icon:"zeyos-items",color:"#064e4f",fa:"box-open"},ledgers:{label:"Ledgers",icon:"zeyos-ledgers",color:"#4679c8",fa:"book-open"},line:{label:"Line Items",icon:"zeyos-line",color:"#064e4f",fa:"list-ul"},links:{label:"Links",icon:"zeyos-links",color:"#405e76",fa:"bookmark"},mailinglists:{label:"Mailing Lists",icon:"zeyos-mailinglists",color:"#0299ac",fa:"envelope-open-text"},messages:{label:"Messages",icon:"zeyos-messages",color:"#31a8e0",fa:"message"},"messages-unread":{label:"Unread Messages",icon:"zeyos-messages-unread",color:"#31a8e0",fa:"envelope"},notes:{label:"Notes",icon:"zeyos-notes",color:"#008853",fa:"note-sticky"},opportunities:{label:"Opportunities",icon:"zeyos-opportunities",color:"#7b67ae",fa:"handshake"},payments:{label:"Payments",icon:"zeyos-payments",color:"#4679c8",fa:"sack-dollar"},pricelists:{label:"Price Lists",icon:"zeyos-pricelists",color:"#10775c",fa:"clipboard-list"},procurement:{label:"Procurement",icon:"zeyos-procurement",color:"#006e9f",fa:"truck"},production:{label:"Production",icon:"zeyos-production",color:"#226375",fa:"industry"},projects:{label:"Projects",icon:"zeyos-projects",color:"#db532d",fa:"diagram-project"},stocktransactions:{label:"Stock Transactions",icon:"zeyos-stocktransactions",color:"#064e4f",fa:"arrow-right-arrow-left"},storages:{label:"Storages",icon:"zeyos-storages",color:"#064e4f",fa:"boxes-stacked"},tasks:{label:"Tasks",icon:"zeyos-tasks",color:"#e2b301",fa:"list-check"},text:{label:"Text Blocks",icon:"zeyos-text",color:"#064e4f",fa:"file-lines"},tickets:{label:"Tickets",icon:"zeyos-tickets",color:"#f04639",fa:"ticket"},"transactions-billing":{label:"Billing Transactions",icon:"zeyos-transactions-billing",color:"#535494",fa:"file-invoice"},"transactions-collection":{label:"Collection Transactions",icon:"zeyos-transactions-collection",color:"#0d60ae",fa:"money-bill-transfer"},"transactions-procurement":{label:"Procurement Transactions",icon:"zeyos-transactions-procurement",color:"#006e9f",fa:"cart-shopping"},"transactions-production":{label:"Production Transactions",icon:"zeyos-transactions-production",color:"#226375",fa:"gears"},zeyos:{label:"ZeyOS",icon:"zeyos",color:"#007a55",fa:"cloud"},default:{label:"Default",icon:"zeyos-default",color:"#21cc75",fa:"cube"},admin:{label:"Administration",icon:"zeyos-admin",color:"#4b5563",fa:"screwdriver-wrench"},applications:{label:"Applications",icon:"zeyos-applications",color:"#2563eb",fa:"window-maximize"},auth:{label:"Credentials",icon:"zeyos-auth",color:"#a16207",fa:"shield-halved"},categories:{label:"Categories",icon:"zeyos-categories",color:"#9a3412",fa:"folder-tree"},channels:{label:"Channels",icon:"zeyos-channels",color:"#0891b2",fa:"share-nodes"},control:{label:"Control Center",icon:"zeyos-control",color:"#0f766e",fa:"sliders"},davservers:{label:"DAV Servers",icon:"zeyos-davservers",color:"#475569",fa:"server"},dev:{label:"Development",icon:"zeyos-dev",color:"#1f2937",fa:"code"},error:{label:"Errors",icon:"zeyos-error",color:"#b91c1c",fa:"triangle-exclamation"},global:{label:"Global",icon:"zeyos-global",color:"#0369a1",fa:"globe"},groups:{label:"Groups",icon:"zeyos-groups",color:"#007a55",fa:"users"},logout:{label:"Logout",icon:"zeyos-logout",color:"#9f1239",fa:"right-from-bracket"},objects:{label:"Custom Objects",icon:"zeyos-objects",color:"#7e22ce",fa:"cubes"},participants:{label:"Participants",icon:"zeyos-participants",color:"#4338ca",fa:"user-group"},permissions:{label:"Permissions",icon:"zeyos-permissions",color:"#5b21b6",fa:"user-lock"},records:{label:"Records",icon:"zeyos-records",color:"#57534e",fa:"database"},resources:{label:"Resources",icon:"zeyos-resources",color:"#15803d",fa:"layer-group"},services:{label:"Services",icon:"zeyos-services",color:"#b45309",fa:"bell-concierge"},system:{label:"System",icon:"zeyos-system",color:"#374151",fa:"gear"},users:{label:"Users",icon:"zeyos-users",color:"#007a55",fa:"user"},weblets:{label:"Weblets",icon:"zeyos-weblets",color:"#4f46e5",fa:"window-restore"}}),zo=Object.freeze({main:"zeyos",addresses:"contacts",clocking:"actionsteps",comments:"notes",couponcodes:"coupons",customers:"accounts",customfields:"objects",davids:"davservers",documentversions:"documents",enhancements:"applications",extdata:"objects",feedservers:"channels",files:"documents",filters:"records",forks:"applications",imports:"records",invoices:"transactions-billing",linecoupon:"line",logins:"auth",mailservers:"channels",notifications:"messages","participants-campaigns":"participants","participants-mailinglists":"participants",prices:"pricelists",pwd:"auth",purchaseorders:"transactions-procurement",sessions:"auth",settings:"system",suppliers:"accounts",tags:"categories",tokens:"auth",transactions:"transactions-billing",usergroups:"groups",usermgmt:"users",usersettings:"system",userfields:"objects",userfilters:"records"}),me=Object.freeze({light:"#ffffff",dark:"#141414"}),_e=Object.create(null);function bi(i){let t=String(i??"").trim().toLowerCase().replaceAll(/[._\s]+/g,"-");if(!t)return"default";if(Object.hasOwn(_e,t)||Object.hasOwn(Rt,t))return t;let e=zo[t];return e||"default"}function gt(i){let t=bi(i);return _e[t]??Rt[t]??Rt.default}function id(i){return gt(i).color}function sd(i,{standard:t=!1}={}){let e=gt(i);return t?e.fa:e.icon}function nd(){return[...new Set([...Object.keys(Rt),...Object.keys(_e)])].sort()}function rd(i){for(let[t,e]of Object.entries(i)){let s=String(t).trim().toLowerCase().replaceAll(/[._\s]+/g,"-"),n=typeof e=="string"?{color:e}:e,r=_e[s]??Rt[s]??Rt.default;_e[s]=Object.freeze({label:n.label??r.label,icon:n.icon??r.icon,color:n.color??r.color,fa:n.fa??r.fa})}}function od(i){let t=Ds(i);if(t===null)return me.light;let e=ko(t,Ds(me.light)??1),s=ko(t,Ds(me.dark)??0);return e>=s?me.light:me.dark}function Ds(i){let t=/^#([\da-f]{3}|[\da-f]{6})$/i.exec(String(i).trim());if(!t)return null;let e=t[1].length===3?[...t[1]].map(o=>o+o).join(""):t[1],[s,n,r]=[0,2,4].map(o=>{let a=Number.parseInt(e.slice(o,o+2),16)/255;return a<=.04045?a/12.92:((a+.055)/1.055)**2.4});return .2126*s+.7152*n+.0722*r}function ko(i,t){return(Math.max(i,t)+.05)/(Math.min(i,t)+.05)}var Do="https://kit.fontawesome.com/ae8320b210.js";function ad(i={}){return Ui({kit:Do,...i})}function Co(i,t={}){let{standard:e=!1,...s}=t,n=gt(i);return w(e?`fa:${n.fa}`:`kit:${n.icon}`,s)}function Wt(i,t={}){let{size:e=24,iconSize:s="52%",label:n=null,title:r=!1,standard:o=!1,color:a=null,badge:c=null,selected:u=!1}=t,d=bi(i),h=gt(i),f=Pt(a)?a:h.color,p=ro({icon:t.icon??Co(i,{size:"1em",standard:o}),size:e,iconSize:s,color:f,label:n,badge:c,selected:u,shape:t.shape??"tile",glass:t.glass??"subtle",class:["zx-module-icon",t.class].flat().filter(Boolean)});return p.dataset.module=d,p.style.setProperty("--zx-module-color",f),p.style.setProperty("--zx-module-glyph","var(--zx-color-app-icon-glyph)"),p.style.setProperty("--zx-app-icon-glyph","var(--zx-color-app-icon-glyph)"),r&&(p.title=h.label),p}function Cs(i,t={}){return Wt(i,{shape:"circle",...t})}var ld=Object.freeze(["accounts","actionsteps","admin","auth","billing","calendar","campaigns","collection","contacts","contracts","control","coupons","dev","documents","inventory","mailinglists","main","messages","links","notes","objects","opportunities","payments","pricelists","procurement","production","projects","tasks","tickets"]);function Io(i={},t={}){let{standardIcons:e=!1,items:s=[],sources:n=[],...r}=t,o=Es(i.labels),a={standardIcons:e,renderApplicationIcon:i.renderApplicationIcon,renderWebletIcon:i.renderWebletIcon},c=Eo(i,a),u=typeof i.loadRecent=="function"?[]:yi(i.recent??[],{query:"",labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:e}),d=[];return typeof i.loadRecent=="function"&&d.push({id:"zeyos-recent",minQuery:0,when:"empty",order:"source",load:async(h,f)=>yi(await i.loadRecent(f),{query:"",labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:e})}),typeof i.search=="function"&&d.push({id:"zeyos-records",minQuery:1,when:"query",order:"source",load:async(h,f)=>yi(await i.search(h,f),{query:h,labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:e})}),d.push(...n),{...r,items:[...c,...u,...s],sources:d,hints:t.hints??{move:o.move,open:o.open,close:o.close}}}function cd(i={},t={}){return new di(null,Io(i,t))}function Eo(i={},t={}){let e=Es(i.labels),s=Array.isArray(i.pinned)?i.pinned.map(String):[],n=new Set,r=[],o=(a,c=null,u=null)=>{let d=dd(a,c,u);if(!d||n.has(d.identifier)||d.type==="module"&&typeof i.canUseModule=="function"&&!i.canUseModule(d.module))return;n.add(d.identifier);let h=To(d.raw,i.resolveApplication),f=s.indexOf(d.identifier),p=()=>(typeof t.renderApplicationIcon=="function"?t.renderApplicationIcon(d.raw,d):d.type==="weblet"&&typeof t.renderWebletIcon=="function"?t.renderWebletIcon(d.raw,d):null)??Cs(d.module,{size:36,standard:!!t.standardIcons,color:d.color});r.push({id:d.identifier,label:d.label,keywords:[d.identifier,d.module],group:e.applications,groupOrder:0,kind:"application",icon:p,pinned:f>=0?f:void 0,current:d.identifier===i.activeIdentifier,disabled:!h.href&&typeof h.invoke!="function",...h,_zeyos:d})};for(let a of Array.isArray(i.menuApps)?i.menuApps:[])o(a);if(Array.isArray(i.modules))for(let a of i.modules)typeof a=="string"?o([a,gt(a).label]):o(a,a?.id??a?.module,a?.label);else for(let[a,c]of Object.entries(i.modules??{}))o([a,c]);return r}function yi(i,t={}){let e=String(t.query??""),s=Es(t.labels),n=hd(i,e),r=new Map;return n.flatMap(({raw:o,group:a},c)=>{let u=fd(o,a,e);if(!u)return[];let d=e===""?s.recent:u.group===""?s.results:s.entities[u.group]??u.group;r.has(d)||r.set(d,r.size+1);let h=To(u.raw,t.resolveRecord);return[{id:`record:${u.entity}:${u.fork??""}:${u.ID}`,label:u.name,description:u.sec,keywords:[u.entity,u.ID,u.fork??""],group:d,groupOrder:r.get(d),itemOrder:c,kind:"record",when:e===""?"empty":"query",icon:()=>(typeof t.renderRecordIcon=="function"?t.renderRecordIcon(u.raw,u):null)??Wt(u.entity,{size:28,standard:!!t.standardIcons}),disabled:!h.href&&typeof h.invoke!="function",...h,_zeyos:u}]})}function ud(i={}){return i.weblet!=null&&i.weblet!==""?`weblet#${i.weblet}`:i.fork!=null&&i.fork!==""?`fork#${i.fork}`:String(i.module??"")}function dd(i,t,e){if(Array.isArray(i)){if(i.length<2)return null;if(i.length===2){let r=String(i[0]);return{raw:i,identifier:r,label:String(i[1]),module:r,type:"module",color:null}}if(i.length===4){let r=String(i[2]||"default");return{raw:i,identifier:`fork#${i[0]}`,label:String(i[1]),module:r,type:"fork",color:Is(i[3])}}return{raw:i,identifier:`weblet#${i[0]}`,label:String(i[1]),module:"weblets",type:"weblet",color:Is(i[8])}}if(!i||typeof i!="object")return null;let s=String(i.identifier??i.id??t??"");if(!s)return null;let n=s.startsWith("fork#")?"fork":s.startsWith("weblet#")?"weblet":"module";return{raw:i,identifier:s,label:String(i.label??e??gt(s).label),module:String(i.module??(n==="module"?s:n==="fork"?"default":"weblets")),type:n,color:Is(i.color)}}function hd(i,t){if(Array.isArray(i))return i.map(s=>({raw:s,group:s?.group??""}));if(!i||typeof i!="object")return[];let e=[];for(let[s,n]of Object.entries(i))if(Array.isArray(n))for(let r of n){if(!Array.isArray(r)){e.push({raw:r,group:s});continue}let o=s===""&&r.length>=5?{ID:r[0],fork:r[1],name:r[2],sec:r[3],entity:r[4],group:s}:{ID:r[0],fork:r[1],name:r[2],sec:r[3],entity:s,group:s};e.push({raw:o,group:s})}return e}function fd(i,t,e){return Array.isArray(i)?e===""&&i.length>=4?{raw:i,entity:String(i[0]),ID:i[1],fork:i[2]??null,name:String(i[3]),sec:String(i[4]??""),group:""}:null:!i||typeof i!="object"||i.ID==null||i.name==null?null:{raw:i,entity:String(i.entity??t??"records"),ID:i.ID,fork:i.fork??null,name:String(i.name),sec:String(i.sec??""),group:String(i.group??t??"")}}function To(i,t){let e=i&&typeof i=="object"&&!Array.isArray(i)?i:{},s=typeof t=="function"?t(i):null,n=s&&typeof s=="object"?s:{};return Object.fromEntries(["href","target","invoke","value"].flatMap(r=>{let o=n[r]??e[r];return o===void 0?[]:[[r,o]]}))}function Is(i){let t=String(i??"").trim();if(!t)return null;let e=t.startsWith("#")?t:`#${t}`;return/^#[\da-f]{3}(?:[\da-f]{3})?$/i.test(e)?e:null}function Es(i){let t=i&&typeof i=="object"?i:{};return{applications:String(t.applications??"Applications"),recent:String(t.recent??"Recent"),results:String(t.results??"Top results"),entities:t.entities&&typeof t.entities=="object"?t.entities:{},move:String(t.move??"Move"),open:String(t.open??"Open"),close:String(t.close??"Close")}}function ge(i,t,e={}){let{fields:s,labelKey:n=Ro(i,t),valueKey:r="ID",searchFields:o=Lo(i,t),limit:a=50,filters:c={},value:u=null,...d}=e,h=ct(i),f=s??Fo(r,n,o);return{...d,valueKey:r,labelKey:n,value:u,filter:async p=>{let _=await h.list(t,ut({search:p,filters:c,fields:f,searchFields:o,limit:a}));return be(i,_).data}}}function pd(i,t,e={}){let s=ge(i,t,e),n=e.value??null,r=new $(null,s);return r.ready=Oo(r,i,t,n),r}function No(i,t,e={}){let{fields:s,labelKey:n=Ro(i,t),valueKey:r="ID",searchFields:o=Lo(i,t),subtitleKey:a=null,moduleKey:c=()=>t,groupKey:u=null,none:d=!0,recent:h=[],create:f=!1,renderIcon:p=gd,renderItem:_,renderValueAdornment:m,...g}=e,b=s??Fo(r,n,[...o,...[a,c,u].filter(x=>typeof x=="string")]),y=ge(i,t,{...g,fields:b,labelKey:n,valueKey:r,searchFields:o,groupKey:u,clearable:d===!1?!!g.clearable:!0});y.recent=Array.isArray(h)?h:[];let A=(x,k=!1)=>{if(p===null)return null;let M=wi(x,c)??t;return p(x,{resource:t,module:String(M),selected:k})};if(y.renderItem=_??(x=>{let k=A(x);return l("span",{class:"zx-select__entity"},k?l("span",{class:"zx-select__entity-icon",ariaHidden:"true"},k):null,l("span",{class:"zx-select__entity-copy"},l("span",{class:"zx-select__entity-label"},String(wi(x,n)??"")),a&&wi(x,a)!=null?l("span",{class:"zx-select__entity-subtitle"},String(wi(x,a))):null))}),y.renderValueAdornment=m??(x=>A(x,!0)),d!==!1&&(y.noneLabel=typeof d=="string"?d:g.noneLabel??"No selection",y.renderNone=g.renderNone??(x=>l("span",{class:"zx-select__entity-none"},l("span",{class:"zx-select__entity-none-icon",ariaHidden:"true"}),l("span",{},x)))),f){let x=f===!0?{}:f,k=typeof x.oninvoke=="function"?x.oninvoke:null;y.actions=[...Array.isArray(y.actions)?y.actions:[],{id:x.id??"create",label:x.label??"Create new\u2026",group:x.group??"New",icon:x.icon??"plus",invoke:M=>k?.({...M,resource:t})}]}return y}function md(i,t,e={}){let s=No(i,t,e),n=e.value??null,r=$.entity(null,s);return r.ready=Oo(r,i,t,n),r}function be(i,t){return typeof i?.normalizeListResult=="function"?Mo(i.normalizeListResult(t)):Mo(t)}function Mo(i){if(Array.isArray(i))return{data:i};if(!i||typeof i!="object")return{data:[]};let t=Array.isArray(i.data)?i.data:[],e=i.count==null||i.count===""?null:Number(i.count);return Number.isFinite(e)?{data:t,count:e}:{data:t}}async function Oo(i,t,e,s){if(s==null)return i;let n=s&&typeof s=="object"?s:await ct(t).get(e,s),r=_d(n);return i.setItems([r]),i.set(r,{silent:!0}),i}function _d(i){if(i&&typeof i=="object"&&!Array.isArray(i)){let t=i.data;return t&&typeof t=="object"&&!Array.isArray(t)?t:i}throw new TypeError("ZeyOS get operation did not return a record")}function wi(i,t){return typeof t=="function"?t(i):i&&typeof i=="object"&&typeof t=="string"?i[t]:null}function gd(i,t){return Wt(String(t.module??"default"),{size:20})}function Fo(i,t,e){let s=[i,t,...e].filter(n=>typeof n=="string"&&n);return s.length?[...new Set(s)]:void 0}function Ro(i,t){let e=bd(i,t);for(let s of["name","lastname","customernum","transactionnum","number","title","ID"])if(e.includes(s))return s;return e[0]??"ID"}function Lo(i,t){let e=i?.schema?.describe?.(t)?.fields;return!e||typeof e!="object"||Array.isArray(e)?[]:Object.entries(e).flatMap(([s,n])=>{if(!n||typeof n!="object")return[];let r=String(n.type??"").toLowerCase();return n.indexed&&/text|character|varchar/.test(r)?[s]:[]})}function bd(i,t){let e=i?.schema?.fields?.(t);if(Array.isArray(e))return e.map(String);if(e&&typeof e=="object")return Object.keys(e);let s=i?.schema?.describe?.(t)?.fields;return s&&typeof s=="object"?Object.keys(s):[]}function yd(i,t,e={}){let s=Xt(i,t,e),n={},r=[],o=new Map;for(let a of s){let c=Ti(a);(c.type==="date"||c.type==="datetime")&&o.set(String(a.id),c.type);let u=c.type==="zxselect"&&typeof c.props?.entity=="string"?c.props.entity:null;u&&(r.push({id:String(a.id),resource:u}),c.props={...ge(i,u,{clearable:!c.required,placeholder:`Select ${String(c.label).toLowerCase()}`})}),n[String(a.id)]=c}return{fieldMeta:s,fields:n,entityFields:r,formOptions:{fieldsets:[{title:String(e.title??""),columns:kd(e.columns),fields:n}]},mapFromRecord:a=>xd(a,s,o),mapToRecord:a=>vd(a,s,o)}}function wd(i,t,e={}){if(e.onSaved!=null&&typeof e.onSaved!="function")throw new TypeError("zeyosForm onSaved must be a function");let s=e.notify!==!1,n=yd(i,t,e),r=()=>e.scope??a.el,o=ct(i,{onError:m=>s?At.error(zs(m),{scope:r()}):void 0}),a=new pe(null,n.formOptions),c=e.value?.ID??e.id??null,u=!1,d=null,h=async m=>{if(!m||typeof m!="object"||Array.isArray(m))throw new TypeError("ZeyOS form value must be a record");return await Promise.all(n.entityFields.map(async({id:g,resource:b})=>{let y=m[g];if(y==null)return;let A=y&&typeof y=="object"?y:Ts(await o.get(b,y)),x=$.from(a.getField(g)?.getInput());x instanceof $&&x.setItems([A])})),u||a.setValues(n.mapFromRecord(m),{silent:!0}),m},f=async m=>{if(m==null||m==="")throw new TypeError("zeyosForm.load() requires an id");let g=Ts(await o.get(t,m));return c=g.ID??m,await h(g),g},p=()=>{if(u)return Promise.reject(new Error("Cannot save a destroyed ZeyOS form"));if(d)return d;if(!a.submit())return Promise.resolve(null);let m=s?at(r()):null;return d=(async()=>{let g;try{g=n.mapToRecord(a.getValues()),delete g.ID}catch(A){throw o.reportError(A,{operation:"serialize",resource:t}),A}let b=c==null?await o.create(t,g):await o.update(t,{ID:c,...g}),y=Ts(b);if(c=y.ID??c,e.onSaved)try{await e.onSaved(y)}catch(A){throw o.reportError(A,{operation:"onSaved",resource:t}),A}return m&&At.success(`${zd(y,t)} saved successfully.`,{scope:m}),y})().finally(()=>{d=null}),d},_=Object.prototype.hasOwnProperty.call(e,"id")?f(e.id):e.value?h(e.value):Promise.resolve(null);return{form:a,ready:_,load:f,save:p,getForm:()=>a,destroy(){u||(u=!0,a.destroy())}}}function xd(i,t,e){let s={};for(let n of t){let r=String(n.id),o=i[r],a=e.get(r);!a||o==null||o===""?s[r]=o:a==="date"?s[r]=Ci(o,n.timeZone):s[r]=yt(o)}return s}function vd(i,t,e){let s={};for(let n of t){let r=String(n.id),o=i[r],a=e.get(r);if(a)o==null||o===""?o=null:a==="date"?o=Ii(o,n.timeZone):o=st(o);else if(Sd(n)&&Ad(n.type)&&o!==""&&o!=null){let c=Number(o);Number.isFinite(c)&&(o=c)}s[r]=o}return s}function Sd(i){return i.enums!=null||i.enum!=null}function Ad(i){return/^(?:smallint|integer|bigint|int|int2|int4|int8|numeric|decimal)$/i.test(String(i??""))}function kd(i){let t=Number(i??2);return[1,2,3].includes(t)?t:2}function Ts(i){if(i&&typeof i=="object"&&!Array.isArray(i)){let t=i.data;return t&&typeof t=="object"&&!Array.isArray(t)?t:i}throw new TypeError("ZeyOS operation did not return a record")}function zd(i,t){for(let e of["transactionnum","name","lastname","customernum","number","ID"])if(i[e]!=null&&i[e]!=="")return String(i[e]);return String(t)}var Dd=["variant","zebra","stickyHeader","responsive","growing","emptyText","rowClass","rowKind","rowKinds","columnVisibility","columnReorder","hiddenColumns","onrowdblclick","onsort","onselectionchange","ondatachange","onstackedchange","ongrow","oncolumnvisibilitychange","oncolumnorderchange"];function Ms(i,t,e={}){let s=Xt(i,t,{fields:e.fields,labels:e.labels,formats:e.formats,timeZone:e.timeZone}),n={},r=s.map(c=>{let u={...c},d=Ed(u);if(d){let p=Td(i,d);u.labelField=`${u.id}_label`,n[u.labelField]=`${u.id}.${p}`}n[u.id]=u.id;let h=Md(u),f=Mi(h?{...u,format:"money"}:u);return h&&(f.render=p=>Nd(p?.[u.id],p?.currency),Od(i,t,"currency")&&(n.currency="currency")),f}),o=e.rowId??"ID";typeof o=="string"&&!Object.prototype.hasOwnProperty.call(n,o)&&(n[o]=o);let a={};for(let c of Dd)e[c]!==void 0&&(a[c]=e[c]);return{fieldMeta:s,columns:r,projection:n,tableOptions:{...a,columns:r,data:[],rowId:o,sort:e.sort??null,sortMode:"server",selectable:e.selectable??!1,height:e.height??null,onrowclick:Id(e)}}}function Cd(i,t,e={}){let s=Ms(i,t,e),n=ct(i),r=new oe(null,s.tableOptions),o=Fd(e.pageSize),a=e.sort??null,c=Po(e.filters??{}),u=String(e.search??""),d=0,h=null,f=!1,p=0,_=async(g={})=>{Object.prototype.hasOwnProperty.call(g,"search")&&(u=String(g.search??"")),Object.prototype.hasOwnProperty.call(g,"filters")&&(c=Po(g.filters??{}));let b=Rd(g.page??0),y=ut({fields:s.projection,sort:a,filters:c,search:u,limit:o,offset:b*o,count:!0}),A=++p;r.setLoading(!0);try{let x=be(i,await n.list(t,y)),k=x.count??null,M=k==null?x.data.length===o:b*o+x.data.length<k;return A===p&&(d=b,h=k,f=M,b===0?r.setData(x.data):r.addData(x.data)),{data:x.data,count:k,page:b,hasMore:M,query:y}}finally{A===p&&r.setLoading(!1)}},m={table:r,load:_,setSearch:g=>_({search:g,page:0}),setFilters:g=>_({filters:g,page:0}),loadMore:()=>f?_({page:d+1}):Promise.resolve({data:[],count:h,page:d,hasMore:!1,query:ut({fields:s.projection,sort:a,filters:c,search:u,limit:o,offset:d*o,count:!0})}),get count(){return h},get page(){return d},get hasMore(){return f},destroy:()=>r.destroy()};return r.on("sort",g=>{let b=g.detail?.id;a=b==null?null:{id:String(b),dir:g.detail.dir==="desc"?"desc":"asc"},_({page:0}).catch(()=>{})}),m}function Id(i){let t=typeof i.onrowclick=="function"?i.onrowclick:null,e=typeof i.onRowClick=="function"?i.onRowClick:null;if(!(!t&&!e))return s=>{t?.(s),e?.(s.detail.row,s)}}function Ed(i){for(let t of[i.entity,i.fk,i.relation,i.reference,i.references]){if(typeof t=="string"&&t)return t;if(t&&typeof t=="object"){let e=t.resource??t.target??t.table??t.entity;if(typeof e=="string"&&e)return e}}return null}function Td(i,t){let e=i?.schema?.fields?.(t),s=Array.isArray(e)?e.map(String):Object.keys(e??{});for(let n of["name","lastname","customernum","transactionnum","number","title","ID"])if(s.includes(n))return n;return s[0]??"ID"}function Md(i){let t=String(i.format??"").toLowerCase();return/money|currency|price/.test(t)||/(?:amount|price)$/.test(String(i.id).toLowerCase())}function Nd(i,t){if(i==null||i==="")return"";let e=Number(i);if(!Number.isFinite(e))return"";let s=typeof t=="string"&&/^[A-Z]{3}$/.test(t)?t:null;try{return new Intl.NumberFormat(void 0,s?{style:"currency",currency:s}:{}).format(e)}catch{return new Intl.NumberFormat().format(e)}}function Od(i,t,e){let s=i?.schema?.fields?.(t);return Array.isArray(s)?s.includes(e):!!(s&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,e))}function Fd(i){let t=Number(i??50);return Number.isInteger(t)&&t>0?t:50}function Rd(i){let t=Number(i);if(!Number.isInteger(t)||t<0)throw new RangeError("ZeyOS table page must be a non-negative integer");return t}function Po(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("ZeyOS table filters must be an object");return{...i}}function Vo(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("ZeyOS appointment must be an object");let t=i.ID??i.id;if(t==null||t==="")throw new TypeError("ZeyOS appointment requires ID");let e=yt(i.datefrom),s=yt(i.dateto??i.datefrom);if(!(e instanceof Date)||!(s instanceof Date))throw new TypeError("ZeyOS appointment requires datefrom and dateto");let n=String(i.assoc_name??"").trim(),r=String(i.name??"").trim()||"Untitled appointment",o=i.entity&&n?`${n}: ${r}`:r,a=i.allDay!=null?!!i.allDay:jo(e)&&jo(s)&&W(e,s)>=1;return{id:String(i.occurrenceid??`${t}@${i.datefrom}`),title:o,start:e,end:s,allDay:a,color:jd(i.color),location:String(i.location??"").trim(),editable:i.editable==null?null:!!i.editable,durationEditable:i.durationEditable==null?null:!!i.durationEditable,data:i}}function qo(i){if(!Array.isArray(i))throw new TypeError("ZeyOS appointments must be an array");return i.map(Vo)}function Ld(i){if(!i||!(i.start instanceof Date)||!(i.end instanceof Date))throw new TypeError("Calendar event patch requires start and end Dates");let t={datefrom:st(i.start),dateto:st(i.end)};return i.data?.ID!=null?{ID:i.data.ID,...t}:t}function $o(i={}){let{appointments:t,...e}=i;return{weekStart:1,optimistic:!0,...e,events:t==null?Array.isArray(e.events)?e.events:[]:qo(t)}}function Pd(i,t={}){return new he(i,$o(t))}function jd(i){let t=String(i??"").trim();return t?/^[\da-f]{3,8}$/i.test(t)?`#${t}`:t:null}function jo(i){return i.getHours()===0&&i.getMinutes()===0&&i.getSeconds()===0&&i.getMilliseconds()===0}var Vd=1,qd=new Set(["table","card","kanban"]),Bo="1970-01-01T00:00:00.000Z",$d=new Set(["__proto__","constructor","prototype"]),Bd=new Set(["cursor","data","offset","page","pagination","records","rows","selection","selectedRecords"]),Qt=class extends Error{constructor(t){super(`A saved view named "${t}" already exists`),this.name="SavedViewDuplicateNameError"}},vi=class extends Error{constructor(t,e){super(`Saved-view scope mismatch: expected ${Gt(t)}, received ${Gt(e)}`),this.name="SavedViewScopeMismatchError",this.expected={...t},this.actual={...e}}},Si=class{constructor(t,e,s={}){if(!t||typeof t.load!="function"||typeof t.save!="function")throw new TypeError("SavedViewRegistry transport requires load() and save()");this.transport=t,this.scope=Ai(e),this.options=Ud(s),this._document=Os(this.scope),this._loaded=!1,this._loading=null,this._loadSequence=0,this._mutation=Promise.resolve(),this._destroyed=!1}async ready(){return this.load()}async load(t={}){if(this._assertActive(),this._loaded&&!t.force)return this;if(this._loading&&!t.force)return await this._loading,this;let e=++this._loadSequence,s=Promise.resolve(this.transport.load({...this.scope})).then(n=>{if(this._assertActive(),e!==this._loadSequence)return;let r=Ns(n,this.scope,this.options);this._document=r,this._loaded=!0});this._loading=s;try{await s}finally{this._loading===s&&(this._loading=null)}return this}async list(){return await this.ready(),this._document.views.map(Zt)}async get(t){await this.ready();let e=xi(this._document,t);return e?Zt(e):null}async getDefault(){await this.ready();let t=this._document.views.find(e=>e.id===this._document.defaultId)??null;return t?Zt(t):null}async save(t,e={}){return this._mutate(async s=>{let n=Ls(t?.name),r=js(e.onDuplicate??this.options.duplicateNames),o=t?.id==null?null:Ps(t.id),a=o?s.views.find(x=>x.id===o)??null:null,c=s.views.find(x=>Z(x.name)===Z(n))??null;if(a&&c&&a!==c&&r==="reject")throw new Qt(n);if(!a&&c&&r==="reject")throw new Qt(n);let u=a??(r==="replace"?c:null),d=r==="replace"&&a&&c!==a?c:null,h=this._now(),f=Rs(t?.type??u?.type),p=Object.prototype.hasOwnProperty.call(t??{},"state")?Zo(t.state):u?et(u.state,"Saved view state"):null;if(!p)throw new TypeError("A new saved view requires state");let _=Object.prototype.hasOwnProperty.call(t??{},"filters")?Qo(t.filters):u?et(u.filters,"Saved view filters"):{},m=Object.prototype.hasOwnProperty.call(t??{},"search")?Go(t.search):u?.search??"",g=u?.createdAt??h,b=u?.id??o??this._createId(s,{name:n,type:f,createdAt:g}),y={id:b,name:n,type:f,state:p,filters:_,search:m,createdAt:g,updatedAt:h},A=s.views.filter(x=>x!==u&&x!==d&&x.id!==b);return A.push(y),s.views=Fs(A),d&&s.defaultId===d.id&&(s.defaultId=b),e.setDefault&&(s.defaultId=b),{changed:!0,result:y}})}async rename(t,e,s={}){return this._mutate(async n=>{let r=xi(n,t);if(!r)return{changed:!1,result:null};let o=Ls(e);if(r.name===o)return{changed:!1,result:r};let a=n.views.find(u=>u!==r&&Z(u.name)===Z(o))??null,c=js(s.onDuplicate??this.options.duplicateNames);if(a&&c==="reject")throw new Qt(o);return a&&(n.views=n.views.filter(u=>u!==a),n.defaultId===a.id&&(n.defaultId=r.id)),r.name=o,r.updatedAt=this._now(),n.views=Fs(n.views),{changed:!0,result:r}})}async remove(t){return this._mutate(async e=>{let s=xi(e,t);return s?(e.views=e.views.filter(n=>n!==s),e.defaultId===s.id&&(e.defaultId=null),{changed:!0,removeDocument:e.views.length===0,result:!0}):{changed:!1,result:!1}})}async setDefault(t){return this._mutate(async e=>{if(t==null)return e.defaultId===null?{changed:!1,result:null}:(e.defaultId=null,{changed:!0,result:null});let s=xi(e,t);return s?e.defaultId===s.id?{changed:!1,result:s}:(e.defaultId=s.id,{changed:!0,result:s}):{changed:!1,result:null}})}async capture(t,e,s={}){if(!t||typeof t.getViewState!="function")throw new TypeError("capture() requires a view with getViewState()");return this.save({...e,state:t.getViewState()},s)}async apply(t,e,s={}){let n=await this.get(t);if(!n)return{status:"missing",applied:!1,entry:null};if(s.type!=null){let r=Rs(s.type);if(n.type!==r)return{status:"type-mismatch",applied:!1,entry:n,expectedType:n.type,currentType:r}}if(!e||typeof e.setViewState!="function")throw new TypeError("apply() requires a view with setViewState()");if(s.onQuery!=null&&typeof s.onQuery!="function")throw new TypeError("apply() onQuery must be a function");return e.setViewState(et(n.state,"Saved view state")),s.onQuery&&await s.onQuery({filters:et(n.filters,"Saved view filters"),search:n.search,entry:Zt(n)}),{status:"applied",applied:!0,entry:n}}destroy(){this._destroyed=!0,this._loadSequence+=1,this._loading=null}_assertActive(){if(this._destroyed)throw new Error("SavedViewRegistry has been destroyed")}_now(){let t=this.options.clock(),e=t instanceof Date?t:new Date(t);if(!Number.isFinite(e.getTime()))throw new TypeError("Saved-view clock returned an invalid timestamp");return e.toISOString()}_createId(t,e){let s=this.options.idFactory?this.options.idFactory({scope:{...this.scope},...e}):`view-${Xo(`${Gt(this.scope)}\0${e.name}\0${e.type}\0${e.createdAt}`)}`,n=Ps(s),r=new Set(t.views.map(a=>a.id));if(!r.has(n))return n;let o=2;for(;r.has(`${n}-${o}`);)o+=1;return`${n}-${o}`}_mutate(t){this._assertActive();let e=this._mutation.catch(()=>{}).then(async()=>{await this.ready();let s=Ko(this._document),n=await t(s);if(this._assertActive(),!n.changed)return Ho(n.result);let r=Ns(s,this.scope,this.options);return this._loadSequence+=1,n.removeDocument&&typeof this.transport.remove=="function"?(await this.transport.remove({...this.scope}),this._assertActive(),this._loadSequence+=1,this._document=Os(this.scope)):(await this.transport.save({...this.scope},Ko(r)),this._assertActive(),this._loadSequence+=1,this._document=r),Ho(n.result)});return this._mutation=e.then(()=>{},()=>{}),e}};function $s(i,t,e={}){return new Si(i,t,e)}function Ai(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Saved-view scope must be an object");return{userId:qs(i.userId,"userId"),workspaceId:Wd(i.workspaceId),resource:qs(i.resource,"resource")}}function Ns(i,t,e={}){let s=Ai(t);if(i==null)return Os(s);let n=Wo(i,e.migrations);if(n.scope!=null){let f=Ai(n.scope);if(Gt(f)!==Gt(s))throw new vi(s,f)}let o=(Array.isArray(n.views)?n.views:[]).map((f,p)=>Hd(f,p,s)),a=Yd(o),c=a.aliases,u=Fs(a.views),d=n.defaultId==null?null:String(n.defaultId),h=u.some(f=>f.id===d)?d:c.get(d)??null;return{version:1,scope:s,defaultId:u.some(f=>f.id===h)?h:null,views:u}}function Wo(i,t={}){let e=Array.isArray(i)?{version:0,savedViews:i}:et(i,"Saved-view document"),s=Uo(e.version);if(s>1)throw new RangeError(`Unsupported saved-view document version: ${s}`);for(;s<1;){let n=t?.[s]??(s===0?Kd:null);if(typeof n!="function")throw new RangeError(`Missing saved-view migration from version ${s}`);e=et(n(et(e,"Saved-view document")),`Saved-view migration ${s}`);let r=Uo(e.version);if(r<=s)throw new RangeError(`Saved-view migration ${s} did not advance the version`);s=r}return e}function Kd(i){let e=(Array.isArray(i.savedViews)?i.savedViews:Array.isArray(i.entries)?i.entries:Array.isArray(i.views)?i.views:[]).map(s=>{let n=s&&typeof s=="object"&&!Array.isArray(s)?s:{};return{id:n.id??null,name:n.name??n.label??"",type:n.type??n.presentation??n.view??"",state:n.state??n.viewState??{},filters:n.filters??n.filter??{},search:n.search??n.query??"",createdAt:n.createdAt??n.created??null,updatedAt:n.updatedAt??n.updated??null}});return{version:1,scope:i.scope??null,defaultId:i.defaultId??i.defaultView??i.default??null,views:e}}function Hd(i,t,e){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`Saved view at index ${t} must be an object`);let s=i,n=Ls(s.name),r=Rs(s.type),o=Zo(s.state??{}),a=Qo(s.filters??{}),c=Go(s.search),u=Yo(s.createdAt),d=Yo(s.updatedAt??u),h=d<u?u:d;return{id:s.id==null||String(s.id).trim()===""?`legacy-${Xo(`${Gt(e)}\0${n}\0${r}\0${t}`)}`:Ps(s.id),name:n,type:r,state:o,filters:a,search:c,createdAt:u,updatedAt:h}}function Yd(i){let t=[...i].sort((o,a)=>ye(a.updatedAt,o.updatedAt)||ye(o.id,a.id)),e=new Set,s=new Set,n=new Map,r=[];for(let o of t){let a=r.find(c=>c.id===o.id||Z(c.name)===Z(o.name));if(e.has(o.id)||s.has(Z(o.name))){a&&n.set(o.id,a.id);continue}e.add(o.id),s.add(Z(o.name)),r.push(o)}return{views:r,aliases:n}}function Ud(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Saved-view registry options must be an object");if(i.clock!=null&&typeof i.clock!="function")throw new TypeError("Saved-view clock must be a function");if(i.idFactory!=null&&typeof i.idFactory!="function")throw new TypeError("Saved-view idFactory must be a function");return{...i,duplicateNames:js(i.duplicateNames??"reject"),clock:i.clock??(()=>new Date)}}function Os(i){return{version:1,scope:{...i},defaultId:null,views:[]}}function Ko(i){return{version:1,scope:{...i.scope},defaultId:i.defaultId,views:i.views.map(Zt)}}function Zt(i){return{...i,state:et(i.state,"Saved view state"),filters:et(i.filters,"Saved view filters")}}function Ho(i){return Zd(i)?Zt(i):i}function xi(i,t){if(typeof t!="string")return null;let e=t.trim();return e?i.views.find(s=>s.id===e)??i.views.find(s=>Z(s.name)===Z(e))??null:null}function Fs(i){return[...i].sort((t,e)=>ye(Z(t.name),Z(e.name))||ye(t.name,e.name)||ye(t.id,e.id))}function Rs(i){if(typeof i!="string")throw new TypeError('Saved view type must be "table", "card", or "kanban"');let t=i.trim().toLowerCase();if(!qd.has(t))throw new TypeError('Saved view type must be "table", "card", or "kanban"');return t}function Ls(i){if(typeof i!="string")throw new TypeError("Saved view name must be a string");let t=i.normalize("NFKC").trim().replace(/\s+/g," ");if(!t)throw new TypeError("Saved view name cannot be empty");if(t.length>160)throw new RangeError("Saved view name cannot exceed 160 characters");return t}function Z(i){return i.normalize("NFKC").toLocaleLowerCase("en-US")}function Ps(i){if(typeof i!="string")throw new TypeError("Saved view id must be a string");let t=i.normalize("NFKC").trim();if(!t)throw new TypeError("Saved view id cannot be empty");if(t.length>180)throw new RangeError("Saved view id cannot exceed 180 characters");return t}function js(i){if(i!=="reject"&&i!=="replace")throw new TypeError('Duplicate saved-view policy must be "reject" or "replace"');return i}function Zo(i){let t=et(i,"Saved view state"),e=Number(t.version);if(!Number.isInteger(e)||e<1)throw new TypeError("Saved view state requires a positive integer version");t.version=e;for(let s of Bd)if(Object.prototype.hasOwnProperty.call(t,s))throw new TypeError(`Saved view state cannot serialize ${s}`);return t}function Qo(i){return et(i??{},"Saved view filters")}function Go(i){if(i==null)return"";if(typeof i!="string")throw new TypeError("Saved view search must be a string");return i}function et(i,t){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`${t} must be a plain object`);return Vs(i,t,new WeakSet)}function Vs(i,t,e){if(i===null||typeof i=="string"||typeof i=="boolean")return i;if(typeof i=="number"){if(!Number.isFinite(i))throw new TypeError(`${t} cannot contain non-finite numbers`);return i}if(typeof i!="object")throw new TypeError(`${t} must be JSON-safe`);if(typeof i.nodeType=="number")throw new TypeError(`${t} cannot contain DOM nodes`);if(e.has(i))throw new TypeError(`${t} cannot contain cycles`);e.add(i);try{if(Array.isArray(i))return i.map(o=>Vs(o,t,e));let s=Object.getPrototypeOf(i);if(s!==Object.prototype&&s!==null)throw new TypeError(`${t} can contain only plain objects and arrays`);let n={},r=i;if(Object.getOwnPropertySymbols(i).length>0)throw new TypeError(`${t} cannot contain symbols`);for(let o of Object.keys(i).sort()){if($d.has(o))throw new TypeError(`${t} cannot contain prototype-pollution keys`);let a=Object.getOwnPropertyDescriptor(r,o);if(!a||!Object.prototype.hasOwnProperty.call(a,"value"))throw new TypeError(`${t} cannot contain property accessors`);n[o]=Vs(a.value,t,e)}return n}finally{e.delete(i)}}function Yo(i){if(i==null||i==="")return Bo;let t=new Date(i);return Number.isFinite(t.getTime())?t.toISOString():Bo}function Uo(i){if(i==null)return 0;let t=Number(i);if(!Number.isInteger(t)||t<0)throw new TypeError("Saved-view document version must be a non-negative integer");return t}function qs(i,t){if(typeof i!="string"&&typeof i!="number")throw new TypeError(`Saved-view scope ${t} must be a string or number`);let e=String(i).normalize("NFKC").trim();if(!e)throw new TypeError(`Saved-view scope ${t} cannot be empty`);return e}function Wd(i){return i===null?null:qs(i,"workspaceId")}function Gt(i){let t=i.workspaceId===null?"":`${i.workspaceId}`;return`${i.userId}\0${t}\0${i.resource}`}function ye(i,t){return i<t?-1:i>t?1:0}function Zd(i){return!!(i&&typeof i=="object"&&"id"in i&&typeof i.id=="string")}function Xo(i){let t=2166136261;for(let e=0;e<i.length;e+=1)t^=i.charCodeAt(e),t=Math.imul(t,16777619);return(t>>>0).toString(36)}var Qd=["titleField","subtitleField","preview","previewAlt","link","actions","groupBy","groupOrder","columnBy","columns","swimlaneBy","swimlanes","moveMode","columnOrder","swimlaneOrder","collapsedColumns","collapsedSwimlanes","showCounts","showEmptyColumns","hiddenFields","fieldOrder","fieldControls","selectable","selection","emptyText"];function ta(i,t,e={}){let s=Xd(i,t,e),n=Ms(i,t,{fields:s,labels:e.labels,formats:e.formats,timeZone:e.timeZone,rowId:e.recordId??"ID",sort:e.sort??null}),r=e.fieldOverrides&&typeof e.fieldOverrides=="object"?e.fieldOverrides:{},o=Array.isArray(e.fields)?new Set(e.fields.map(String)):null,a=n.columns.map(d=>({...d,...o&&!o.has(d.id)?{visible:!1}:{},...r[d.id]??{},id:d.id})),c={...n.projection};for(let d of ea(e))Object.prototype.hasOwnProperty.call(c,d)||(c[d]=d);let u={...e.viewOptions??{}};for(let d of Qd)Object.prototype.hasOwnProperty.call(e,d)&&(u[d]=e[d]);return Object.assign(u,{fields:a,data:[],recordId:e.recordId??"ID",sort:e.sort??null,sortMode:"server"}),typeof e.onRecordClick=="function"&&(u.onrecordclick=d=>e.onRecordClick(d.detail.record,d)),{fieldMeta:n.fieldMeta,fields:a,projection:c,viewOptions:u}}function Gd(i,t,e,s={}){if(typeof e!="function")throw new TypeError("zeyosView() requires a view constructor");let n=ta(i,t,s),r=new e(s.target??null,n.viewOptions);for(let z of["setData","addData","setLoading","on","destroy"])if(typeof r?.[z]!="function"){try{r?.destroy?.()}catch{}throw new TypeError(`zeyosView() constructor must provide ${z}()`)}let o=ct(i),a=th(s.pageSize),c;try{c=ih(s.savedViews,e,t)}catch(z){throw r.destroy(),z}let u=c?.registry??null,d=c?.type??ia(e);if(u){for(let z of["getViewState","setViewState"])if(typeof r?.[z]!="function")throw c?.owned&&u.destroy?.(),r.destroy(),new TypeError(`zeyosView() saved views require ${z}()`)}let h=s.sort??null,f=ki(s.filters??{}),p=String(s.search??""),_=0,m=null,g=!1,b=0,y=!1,A=async(z={})=>{if(y)throw new Error("ZeyOS view binding has been destroyed");Object.prototype.hasOwnProperty.call(z,"search")&&(p=String(z.search??"")),Object.prototype.hasOwnProperty.call(z,"filters")&&(f=ki(z.filters??{}));let N=eh(z.page??0),G=ut({fields:n.projection,sort:h,filters:f,search:p,searchFields:s.searchFields,limit:a,offset:N*a,count:!0}),Lt=++b;r.setLoading(!0);try{let bt=be(i,await o.list(t,G)),we=bt.count??null,Ks=we==null?bt.data.length===a:N*a+bt.data.length<we;return!y&&Lt===b&&(_=N,m=we,g=Ks,N===0?r.setData(bt.data):r.addData(bt.data)),{data:bt.data,count:we,page:N,hasMore:Ks,query:G}}finally{!y&&Lt===b&&r.setLoading(!1)}},x=async(z,N={})=>{if(!u||!d)throw new Error("This ZeyOS view binding has no saved-view registry");if(y)throw new Error("ZeyOS view binding has been destroyed");let G=await u.apply(z,r,{type:d,onQuery:async({filters:Lt,search:bt})=>{y||(f=ki(Lt??{}),p=String(bt??""))}});return!G.applied||y||(h=rh(r,G.entry),_=0,m=null,g=!1,N.load!==!1&&await A({page:0})),G},k=async(z={})=>{if(!u)return null;if(await nh(u),y)throw new Error("ZeyOS view binding has been destroyed");let N=await u.getDefault();return N?x(N.id,z):{status:"missing",applied:!1,entry:null}},M=u?k({load:!1}):Promise.resolve(null),B=!u,U=null;M.then(()=>{B=!0},()=>{});let Q=async(z={load:!1})=>{if(B)return null;try{let N=await M;return B=!0,N}catch{}if(!U){let G=k(z).then(Lt=>(B=!0,Lt)).finally(()=>{U===G&&(U=null)});U=G}return U},it=async(z={})=>(await Q({load:!1}),A(z)),Bs=z=>{if(!d||typeof r.getViewState!="function")throw new Error("This view does not expose serializable saved-view state");let N=z&&typeof z=="object"?z:{};return{...N.id==null?{}:{id:String(N.id)},name:String(N.name??""),type:d,state:r.getViewState(),filters:ki(f),search:p}},oa=async z=>{if(!u||!d)throw new Error("This ZeyOS view binding has no saved-view registry");if(await Q({load:!1}),y)throw new Error("ZeyOS view binding has been destroyed");let N=Bs(z);return await u.capture(r,{...N.id==null?{}:{id:N.id},name:N.name,type:d,filters:N.filters,search:N.search},{onDuplicate:z?.onDuplicate,setDefault:!!z?.setDefault})},aa=async(z,N={})=>(await Q({load:!1}),x(z,N)),la=async(z={})=>B?k(z):Q(z),Di=z=>{let N=z.detail?.id;h=N==null?null:{id:String(N),dir:z.detail.dir==="desc"?"desc":"asc"},it({page:0}).catch(()=>{})},ca={view:r,load:it,setSearch:z=>it({search:z,page:0}),setFilters:z=>it({filters:z,page:0}),loadMore:async()=>(await Q({load:!1}),g?A({page:_+1}):{data:[],count:m,page:_,hasMore:!1,query:ut({fields:n.projection,sort:h,filters:f,search:p,searchFields:s.searchFields,limit:a,offset:_*a,count:!0})}),get count(){return m},get page(){return _},get hasMore(){return g},savedViews:u,ready:M,restoreDefault:la,captureView:Bs,saveView:oa,applyView:aa,destroy:()=>{y||(y=!0,b+=1,typeof r.off=="function"?r.off("sortchange",Di):r.removeEventListener?.("sortchange",Di),c?.owned&&u?.destroy?.(),r.destroy())}};return r.on("sortchange",Di),ca}function Xd(i,t,e){if(!Array.isArray(e.fields)&&!Array.isArray(e.exclude))return;let s=new Set(Array.isArray(e.exclude)?e.exclude.map(String):[]),n=Array.isArray(e.fields)?e.fields.map(String):Jd(i,t);return[...new Set([...n,...ea(e)])].filter(r=>!s.has(r))}function Jd(i,t){let e=i?.schema?.fields?.(t);return Array.isArray(e)?e.map(s=>typeof s=="string"?s:String(s?.id??s?.name??s?.field??"")).filter(Boolean):e&&typeof e=="object"?Object.keys(e):[]}function ea(i){let t=[];for(let e of["titleField","subtitleField","preview","groupBy","columnBy","swimlaneBy"]){let s=i[e];typeof s=="string"&&s.trim()&&t.push(s.trim())}return[...new Set(t)]}function th(i){let t=Number(i??50);return Number.isFinite(t)?Math.max(1,Math.floor(t)):50}function eh(i){let t=Number(i);return Number.isFinite(t)?Math.max(0,Math.floor(t)):0}function ki(i){return i&&typeof i=="object"&&!Array.isArray(i)?{...i}:{}}function ih(i,t,e){if(i==null||i===!1)return null;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("savedViews must be a registry or transport/scope configuration");let s=i,n=s.controller??s.registry,r=Jo(s)?s:Jo(n)?n:null,o=sh(s.type??ia(t));if(!o)throw new TypeError("savedViews requires a table, card, or kanban presentation type");if(r)return{registry:r,type:o,owned:!1};if(!s.transport||!s.scope||typeof s.scope!="object")throw new TypeError("savedViews requires a controller or injected transport and scope");let a={...s.scope,resource:s.scope.resource??e};return{registry:$s(s.transport,a,s.options??{}),type:o,owned:!0}}function Jo(i){return!!(i&&typeof i=="object"&&typeof i.apply=="function"&&typeof i.capture=="function"&&typeof i.getDefault=="function")}function ia(i){let t=String(i.cssName??"").toLowerCase().replace(/-view$/,"");if(["table","card","kanban"].includes(t))return t;let e=String(i.name??"").toLowerCase().replace(/view$/,"");return["table","card","kanban"].includes(e)?e:null}function sh(i){let t=String(i??"").toLowerCase();return["table","card","kanban"].includes(t)?t:null}async function nh(i){typeof i.ready=="function"?await i.ready():typeof i.load=="function"&&await i.load()}function rh(i,t){let e=typeof i.getSort=="function"?i.getSort():typeof i.getViewState=="function"?i.getViewState()?.sort:t?.state?.sort;return!e||typeof e!="object"||Array.isArray(e)||e.id==null?null:{id:String(e.id),dir:e.dir==="desc"?"desc":"asc"}}function oh(i){if(typeof i!="function")throw new TypeError("Legacy saved-view loader must be a function");return t=>new Promise((e,s)=>{i(t,e,(n,r,o)=>{let a=new Error(String(n??"ZeyOS saved-view request failed"));return Object.assign(a,{type:r,info:o}),s(a),!0})})}function ah(i,t={}){if(typeof i!="function")throw new TypeError("Saved-view request must be a function");let e=sa(t.recordName,"__zx_record_views_v1__","recordName"),s=sa(t.viewPrefix,"zx.record-views:","viewPrefix"),n=t.module==null?"":String(t.module),r=(o,a)=>{let c=lh(o);return{umi:n,page:a,fork:c.workspaceId,view:`${s}${c.resource}`}};return{async load(o){let a=await i(r(o,"fields")),c=ch(a,e);if(c==null||c==="")return null;if(typeof c=="string")try{let u=JSON.parse(c);return zi(u)?u:null}catch{return null}return zi(c)?na(c):null},async save(o,a){if(!zi(a))throw new TypeError("Saved-view document must be an object");let c=na(a);return await i({...r(o,"fields_save"),name:e,data:JSON.stringify(c)}),c},async remove(o){await i({...r(o,"fields_remove"),name:e})}}}function lh(i){if(!zi(i))throw new TypeError("Saved-view scope must be an object");if(i.userId==null||String(i.userId).trim()==="")throw new TypeError("Saved-view scope requires userId");let t=String(i.resource??"").trim();if(!t)throw new TypeError("Saved-view scope requires resource");let e=i.workspaceId==null||i.workspaceId===""?null:i.workspaceId;return{userId:String(i.userId),workspaceId:e,resource:t}}function ch(i,t){if(!Array.isArray(i)||!Array.isArray(i[0])||!Array.isArray(i[1]))return null;let e=i[0].findIndex(s=>String(s)===t);return e<0?null:i[1][e]}function sa(i,t,e){let s=i==null?t:String(i).trim();if(!s)throw new TypeError(`${e} must not be empty`);return s}function zi(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function na(i){ra(i,new Set);try{return JSON.parse(JSON.stringify(i))}catch{throw new TypeError("Saved-view document must be JSON-serializable")}}function ra(i,t){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"&&Number.isFinite(i))return;if(typeof i!="object")throw new TypeError("Saved-view document must be JSON-serializable");if(t.has(i))throw new TypeError("Saved-view document must be JSON-serializable");if(!Array.isArray(i)&&Object.getPrototypeOf(i)!==Object.prototype&&Object.getPrototypeOf(i)!==null)throw new TypeError("Saved-view document must be JSON-serializable");t.add(i);let e=Array.isArray(i)?i:Object.values(i);for(let s of e)ra(s,t);t.delete(i)}export{Vd as SAVED_VIEWS_VERSION,Qt as SavedViewDuplicateNameError,Si as SavedViewRegistry,vi as SavedViewScopeMismatchError,Do as ZEYOS_ICON_KIT,ld as ZEYOS_LAUNCHER_APPLICATIONS,ut as buildListQuery,$o as buildZeyosCalendarOptions,No as buildZeyosEntitySelectConfig,Io as buildZeyosLauncherConfig,ge as buildZeyosSelectConfig,ta as buildZeyosViewConfig,Ii as calendarDayToUnixSeconds,Ld as calendarEventToZeyosPatch,ct as connect,ah as createLegacySavedViewTransport,$s as createSavedViewRegistry,ua as dataFilterStateToFilters,st as dateToUnixSeconds,Mi as fieldToZxColumn,Ti as fieldToZxField,oh as legacySavedViewRequest,Wo as migrateSavedViewDocument,zo as moduleAliases,Wt as moduleChip,id as moduleColor,od as moduleGlyphColor,Co as moduleIcon,sd as moduleIconName,gt as moduleInfo,nd as moduleKeys,bi as normalizeModuleName,Ns as normalizeSavedViewDocument,Ai as normalizeSavedViewScope,Eo as normalizeZeyosLauncherApplications,yi as normalizeZeyosLauncherRecords,V as registerFieldType,rd as registerModules,Xt as resolveFields,Us as tableSortToQuery,Ci as unixSecondsToCalendarDay,yt as unixSecondsToDate,ad as useZeyosIcons,ud as zeyosActiveIdentifier,Cs as zeyosAppIcon,Vo as zeyosAppointmentToEvent,qo as zeyosAppointmentsToEvents,Pd as zeyosCalendar,md as zeyosEntitySelect,wd as zeyosForm,cd as zeyosLauncher,Rt as zeyosModules,pd as zeyosSelect,Cd as zeyosTable,Gd as zeyosView};
8
+ `).length}}function fc(i,e){return i.startsWith(e)?e.length:e===" "?i.startsWith(" ")?1:Math.min(/^ +/.exec(i)?.[0].length??0,2):Math.min(/^\s+/.exec(i)?.[0].length??0,e.length)}function cr(i){let e=String(i??"text").trim().toLowerCase();return/^[a-z0-9][a-z0-9+_.-]*$/.test(e)?e:"text"}function pc(i){let e=Number(i);return Number.isFinite(e)?Math.max(2,Math.min(100,Math.round(e))):12}function mc(i){return["off","soft","hard"].includes(String(i))?i:"off"}function Yt(i,e){let t=Number(i);return Math.max(0,Math.min(e,Number.isFinite(t)?Math.round(t):0))}function ur(){z.register("code",(i,e)=>{let t=i.own(new Ut(null,{label:e.label?String(e.label):"Code editor",placeholder:e.placeholder,readOnly:!!e.props?.readOnly,disabled:!!e.disabled,...e.props??{},value:e.value})),s=!1;return i.listen(t.el,"change",n=>n.stopImmediatePropagation()),t.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),t.on("input",n=>i.emit("input",{value:n.detail.value})),{el:t.el,get:()=>t.getValue(),set:n=>{s=!0;try{t.setValue(n,{silent:!0})}finally{s=!1}},focus:()=>t.focus(),setDisabled:n=>n?t.disable():t.enable(),setReadonly:n=>{t.setReadOnly(n)}}})}var dr=["January","February","March","April","May","June","July","August","September","October","November","December"],hr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],mr=/%[demYyHMSaAbBs]/g;function I(i,e){return!(i instanceof Date)||Number.isNaN(i.getTime())?"":String(e).replace(mr,t=>{switch(t){case"%d":return Ve(i.getDate());case"%e":return String(i.getDate());case"%m":return Ve(i.getMonth()+1);case"%Y":return String(i.getFullYear()).padStart(4,"0");case"%y":return Ve(i.getFullYear()%100);case"%H":return Ve(i.getHours());case"%M":return Ve(i.getMinutes());case"%S":return Ve(i.getSeconds());case"%a":return fr("weekday",i.getDay(),hr[i.getDay()]);case"%A":return cs("weekday",i.getDay(),hr[i.getDay()]);case"%b":return fr("month",i.getMonth(),dr[i.getMonth()]);case"%B":return cs("month",i.getMonth(),dr[i.getMonth()]);case"%s":return String(Math.floor(i.getTime()/1e3));default:return t}})}function oe(i,e){let t=[],s="^",n=0;for(let _ of String(e).matchAll(mr)){s+=pr(String(e).slice(n,_.index));let m=_[0],g=_c(m);if(g===null)return null;s+=`(${g})`,t.push(m),n=_.index+m.length}s+=pr(String(e).slice(n))+"$";let r=new RegExp(s).exec(String(i));if(!r)return null;let o=Object.create(null);if(t.forEach((_,m)=>{o[_]=Number(r[m+1])}),o["%s"]!==void 0){let _=o["%s"]*1e3,m=new Date(_);return Number.isNaN(m.getTime())?null:m}let a=o["%Y"]??gc(o["%y"])??1970,l=(o["%m"]??1)-1,u=o["%d"]??o["%e"]??1,d=o["%H"]??0,h=o["%M"]??0,p=o["%S"]??0,f=new Date(0);return f.setHours(0,0,0,0),f.setFullYear(a,l,u),f.setHours(d,h,p,0),Number.isNaN(f.getTime())||o["%Y"]!==void 0&&f.getFullYear()!==o["%Y"]||o["%y"]!==void 0&&f.getFullYear()%100!==o["%y"]||o["%m"]!==void 0&&f.getMonth()!==l||o["%d"]!==void 0&&f.getDate()!==u||o["%e"]!==void 0&&f.getDate()!==u||o["%H"]!==void 0&&f.getHours()!==d||o["%M"]!==void 0&&f.getMinutes()!==h||o["%S"]!==void 0&&f.getSeconds()!==p?null:f}function _r(i,e,t){let s=i.getTime(),n=e instanceof Date?e.getTime():-1/0,r=t instanceof Date?t.getTime():1/0;return new Date(Math.min(r,Math.max(n,s)))}function j(i,e){return i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate()}function T(i,e){let t=new Date(i.getTime());return t.setDate(t.getDate()+e),t}function Ce(i,e){let t=new Date(i.getTime()),s=t.getDate();t.setDate(1),t.setMonth(t.getMonth()+e);let n=new Date(t.getFullYear(),t.getMonth()+1,0).getDate();return t.setDate(Math.min(s,n)),t}function Wt(i=he()){if(!i||i.toLowerCase()==="en")return 1;try{let e=new Intl.Locale(i),t=e.getWeekInfo?.()??e.weekInfo;if(t?.firstDay)return t.firstDay%7}catch{}return 1}function Ve(i){return String(i).padStart(2,"0")}function cs(i,e,t){let s=`date.${i}.${e}`,n=ve(s);return n===s?t:n}function fr(i,e,t){let s=`date.${i}.short.${e}`,n=ve(s);return n!==s?n:cs(i,e,t).slice(0,3)}function _c(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 gc(i){if(i!==void 0)return i>=69?1900+i:2e3+i}function pr(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var gr=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),bc=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),br=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"}),yc=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",type:"font",hash:"hashtag",mail:"envelope","link-2":"link"}),us=new Map;function yr(i){let e=String(i).trim();if(/\s/.test(e)||e.startsWith("fa-"))return{provider:"fa",name:"",style:null,classes:e.split(/\s+/).filter(Boolean)};let t=e.indexOf(":");if(t>0){let s=e.slice(0,t).toLowerCase(),n=e.slice(t+1);if(s==="builtin"||s==="zx")return{provider:"builtin",name:n,style:null,classes:null};if(Object.hasOwn(br,s))return{provider:"fa",name:n,style:br[s],classes:null}}return{provider:null,name:e,style:null,classes:null}}function ds(i,e={}){let{style:t="solid",family:s="classic",fixedWidth:n=!1,translate:r=!0}=e,o=String(i).replace(/^fa-/,""),a=r?yc[o]??o:o,l=[],u=bc[s];return u&&l.push(u),l.push(gr[t]??gr.solid,`fa-${a}`),n&&l.push("fa-fw"),l}function hs(i){let e=String(i).trim();if(/^(https?:)?\/\//.test(e)||e.startsWith("/")||e.endsWith(".js"))return e;if(!/^[a-z0-9]+$/.test(e))throw new RangeError(`Invalid Font Awesome kit token: ${i}`);return`https://kit.fontawesome.com/${e}.js`}function wr(i){let e=hs(i),t=us.get(e);if(t)return t;let s=new Promise((n,r)=>{let o=new URL(e,document.baseURI).href,a=[...document.scripts].find(u=>u.src===o);if(a&&globalThis.FontAwesomeKitConfig){n();return}let l=a??document.createElement("script");l.addEventListener("load",()=>n(),{once:!0}),l.addEventListener("error",()=>{us.delete(e),r(new Error(`Font Awesome kit failed to load: ${e}`))},{once:!0}),!a&&(l.src=e,l.async=!0,l.crossOrigin="anonymous",document.head.append(l))});return us.set(e,s),s}var Sr="http://www.w3.org/2000/svg",Ar="0 0 24 24",wc=1.75,vc=1,D=i=>[Ar,i,"stroke"];var kr=Object.freeze({"arrow-up-wide-short":D("M3 8l4-4 4 4M7 4v16M11 12h10M11 16h7M11 20h4"),"arrow-down-wide-short":D("M3 16l4 4 4-4M7 20V4M11 4h10M11 8h7M11 12h4"),"chevron-down":D("M6 9l6 6 6-6"),"chevron-up":D("M18 15l-6-6-6 6"),"chevron-left":D("M15 18l-6-6 6-6"),"chevron-right":D("M9 18l6-6-6-6"),check:D("M20 6 9 17l-5-5"),x:D("M18 6 6 18M6 6l12 12"),plus:D("M5 12h14M12 5v14"),minus:D("M5 12h14"),search:D("M21 21l-4.34-4.34M3 11a8 8 0 1 0 16 0a8 8 0 1 0-16 0z"),calendar:D("M8 2v3M16 2v3M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM3 9h18"),clock:D("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 6v6l4 2"),trash:D("M10 11v6M14 11v6M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"),gear:D("M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915M9 12a3 3 0 1 0 6 0a3 3 0 1 0-6 0z"),eye:D("M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0M9 12a3 3 0 1 0 6 0a3 3 0 1 0-6 0z"),lock:D("M5 11h14a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2zM7 11V7a5 5 0 0 1 10 0v4"),reload:D("M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8M21 3v5h-5"),list:D("M3 5h.01M3 12h.01M3 19h.01M8 5h13M8 12h13M8 19h13"),filter:D("M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"),dots:D("M11 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM18 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM4 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0z"),info:D("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 16v-4M12 8h.01"),warning:D("M21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3M12 9v4M12 17h.01"),error:D("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 8V12M12 16H12.01"),success:D("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 9l-5.5 5.5L8 12"),upload:D("M12 3v12M17 8l-5-5-5 5M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"),drag:D("M8 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0z"),star:D("M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"),heart:D("M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"),tag:D("M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42zM7 7.5a.5 .5 0 1 0 1 0a.5 .5 0 1 0-1 0z"),folder:D("M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"),"folder-open":D("M6 14l1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"),file:D("M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2zM14 2v5a1 1 0 0 0 1 1h5"),copy:D("M10 8h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-10a2 2 0 0 1-2-2v-10a2 2 0 0 1 2-2zM4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"),square:D("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2z"),code:D("M18 16l4-4-4-4M6 8l-4 4 4 4M14.5 4l-5 16"),book:D("M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20"),"table-cells-large":D("M4 3h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1zM15 3h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1zM15 14h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1zM4 14h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-5a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1z"),table:D("M12 3v18M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM3 9h18M3 15h18"),image:D("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM7 9a2 2 0 1 0 4 0a2 2 0 1 0-4 0zM21 15l-3.086-3.086a2 2 0 0 0-2.828 0L6 21"),columns:D("M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-14a2 2 0 0 1-2-2v-14a2 2 0 0 1 2-2zM9 3v18M15 3v18"),type:D("M12 4v16M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2M9 20h6"),hash:D("M4 9h16M4 15h16M10 3L8 21M16 3l-2 18"),mail:D("M22 7l-8.991 5.727a2 2 0 0 1-2.009 0L2 7M4 4h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-16a2 2 0 0 1-2-2v-12a2 2 0 0 1 2-2z"),"link-2":D("M9 17H7A5 5 0 0 1 7 7h2M15 7h2a5 5 0 1 1 0 10h-2M8 12h8"),"circle-chevron-down":D("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 10l-4 4-4-4")}),xc=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list",grid:"table-cells-large"}),Sc=Object.create(null),fe={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function ps(){return{...fe}}function ms(i={}){for(let e of["provider","style","family","fixedWidth","kit"])i[e]!==void 0&&(fe[e]=i[e]);return ps()}function zr(i={}){return ms({...i,provider:"fontawesome"})}async function _s(i){let e=typeof i=="string"?{kit:i}:{...i},{kit:t,activate:s=!0,...n}=e;if(!t)throw new TypeError("loadFontAwesome() needs a kit token or URL");return ms({...n,kit:hs(t)}),await wr(t),s?zr():ps()}function v(i,e={}){let t=yr(i);if(t.classes)return fs(t.classes,e);let s=xc[t.name]??t.name;return t.provider==="builtin"?vr(s,e):t.provider==="fa"?fs(ds(s,{style:t.style??e.style??fe.style,family:e.family??fe.family,fixedWidth:e.fixedWidth??fe.fixedWidth}),e):fe.provider==="fontawesome"?fs(ds(s,{style:e.style??fe.style,family:e.family??fe.family,fixedWidth:e.fixedWidth??fe.fixedWidth}),e):vr(s,e)}function vr(i,e){let t=Sc[i]??kr[i];if(!t){if(e.strict)throw new RangeError(`Unknown icon: ${i}`);return Cc(i),zc(i,e)}let[s,n,r="fill"]=t,o=Cr(s,r,e),a=document.createElementNS(Sr,"path");return a.setAttribute("d",n),o.append(a),o}function Cr(i,e,t){let{size:s=16}=t,n=document.createElementNS(Sr,"svg");return n.setAttribute("class",Er("zx-icon",t.class)),n.setAttribute("viewBox",i),n.setAttribute("width",String(s)),n.setAttribute("height",String(s)),e==="stroke"?(n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width",Ac(i,s)),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round")):n.setAttribute("fill","currentColor"),n.setAttribute("focusable","false"),Dr(n,t.label??null),n}function Ac(i,e){let[,,t,s]=i.trim().split(/[\s,]+/).map(Number),n=Math.max(t,s)||24,r=wc*n/24,o=typeof e=="number"?e:/^\d*\.?\d+(px)?$/.test(String(e).trim())?parseFloat(String(e)):NaN;return o>0&&(r=Math.max(r,vc*n/o)),String(Math.round(r*1e3)/1e3)}var kc=Ar;function zc(i,e){let t=Cr(kc,"stroke",e);return t.setAttribute("data-zx-icon-missing",i),t}var xr=new Set;function Cc(i){xr.has(i)||(xr.add(i),console.warn(`[zx.icon] Unknown icon "${i}" \u2014 rendered an empty placeholder. Add it with registerIcons(), or render Font Awesome with useFontAwesome().`))}function fs(i,e){let{size:t=16}=e,s=document.createElement("i");return s.className=Er("zx-icon",...i,e.class),s.style.fontSize=typeof t=="number"?`${t}px`:String(t),Dr(s,e.label??null),s}function Dr(i,e){if(e===null){i.setAttribute("aria-hidden","true");return}i.setAttribute("role","img"),i.setAttribute("aria-label",e)}function Er(...i){return i.flat().filter(Boolean).join(" ")}var Dc=5,Zt=class extends S{static cssName="time-picker";static defaults={value:null,seconds:!1,step:5,clock:!0};render(){let e=this.el??c("div");this.el=e;let t=Ir(this.options.value);this._value=t,this._display=t??{h:0,m:0,s:0},this._inputs=[],this._clockOpen=!1,this._clockUnit="h",this._clock=null;let s=c("div",{class:"zx-time-picker__segments",role:"group",ariaLabel:this._message("timePicker.label","Time")});if(this._content=s,this._addSpin(s,"h",this._message("timePicker.hour","Hour"),23),s.append(c("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"m",this._message("timePicker.minute","Minute"),59),this.options.seconds&&(s.append(c("span",{class:"zx-time-picker__separator",ariaHidden:"true"},":")),this._addSpin(s,"s",this._message("timePicker.second","Second"),59)),e.append(s),this.options.clock){let n=E("zx-time-picker-clock");s.append(c("button",{ref:"clockToggle",class:"zx-icon-btn zx-time-picker__clock-toggle",type:"button",ariaLabel:this._message("timePicker.clock","Pick the time on a clock"),ariaExpanded:"false",ariaControls:n},v("clock",{size:15}))),this._clock=this._buildClock(n),e.append(this._clock),this.listen(this.refs.clockToggle,"click",()=>this.toggleClock())}return this._writeInputs(),e}get(){return this._value?{...this._value}:null}set(e,{silent:t=!1}={}){let s=Ir(e);return this._value=s,this._display=s??{h:0,m:0,s:0},this._writeInputs(),!t&&s&&this.emit("change",{time:{...s}}),this}openClock(e="h"){return this._clock?(this._clockOpen=!0,this._clockUnit=e==="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(e,t,s,n){let r=c("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:t}});this._inputs.push(r),e.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"keydown",o=>this._onKeydown(o,t,n)),this.listen(r,"input",()=>this._onInput(r,t,n)),this.listen(r,"blur",()=>this._commitFromInputs())}_onKeydown(e,t,s){if(e.key!=="ArrowUp"&&e.key!=="ArrowDown")return;e.preventDefault();let n=e.key==="ArrowUp"?1:-1,r=t==="m"?Mc(this.options.step):1,o=qe(e.currentTarget.value,0,s),a=s+1,l=(o+n*r+a*r)%a;e.currentTarget.value=De(l),this._commitFromInputs()}_onInput(e,t,s){if(e.value=e.value.replace(/\D/g,"").slice(0,2),e.value.length<2)return;e.value=De(qe(e.value,0,s)),this._commitFromInputs();let n=this._inputs.indexOf(e);this._inputs[n+1]?.focus()}_commitFromInputs(){let e={h:0,m:0,s:0};for(let s of this._inputs){let n=s.dataset.segment,r=n==="h"?23:59;e[n]=qe(s.value,0,r)}let t=!this._value||!Nc(this._value,e);this._value=e,this._display=e,this._writeInputs(),t&&this.emit("change",{time:{...e}})}_writeInputs(){for(let e of this._inputs){let t=e.dataset.segment;e.value=De(this._display[t]),e.setAttribute("aria-valuenow",String(this._display[t])),e.setAttribute("aria-valuetext",e.value)}this._syncClock()}_buildClock(e){let t=c("div",{class:"zx-time-picker__clock",id:e,hidden:!0},c("div",{class:"zx-time-picker__clock-head"},c("button",{ref:"headHour",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:this._message("timePicker.selectHour","Select the hour"),dataset:{unit:"h"}}),c("span",{class:"zx-time-picker__clock-colon",ariaHidden:"true"},":"),c("button",{ref:"headMinute",class:"zx-time-picker__clock-unit",type:"button",ariaLabel:this._message("timePicker.selectMinutes","Select the minutes"),dataset:{unit:"m"}})),c("div",{ref:"dial",class:"zx-time-picker__dial",role:"radiogroup"},c("span",{ref:"hand",class:"zx-time-picker__hand",ariaHidden:"true"}),c("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)),t}_pick(e){let t={...this._display,[this._clockUnit]:e},s=this._clockUnit==="h";this.set(t),s&&this.openClock("m")}_onDialKeydown(e){let t=[...this.refs.dial.querySelectorAll(".zx-time-picker__mark")],s=e.target.closest?.(".zx-time-picker__mark"),n=t.indexOf(s);if(n<0)return;let r={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[e.key],o=null;r!==void 0?o=(n+r+t.length)%t.length:e.key==="Home"?o=0:e.key==="End"&&(o=t.length-1),o!==null&&(e.preventDefault(),this._pick(Number(t[o].dataset.value)),this.refs.dial.querySelector(`[data-value="${t[o].dataset.value}"]`)?.focus())}_syncClock(){if(!this._clock)return;let e=this._clockUnit==="h";if(this._clock.hidden=!this._clockOpen,this.refs.clockToggle.setAttribute("aria-expanded",String(this._clockOpen)),this.refs.headHour.textContent=De(this._display.h),this.refs.headMinute.textContent=De(this._display.m),this.refs.headHour.setAttribute("aria-pressed",String(e)),this.refs.headMinute.setAttribute("aria-pressed",String(!e)),this.refs.dial.setAttribute("aria-label",e?this._message("timePicker.hour","Hour"):this._message("timePicker.minutes","Minutes")),!this._clockOpen)return;let t=e?this._display.h:this._display.m,s=e?Ec():Ic(),n=this.refs.dial.querySelectorAll(".zx-time-picker__mark");if(n.length!==s.length||this.refs.dial.dataset.unit!==this._clockUnit){for(let a of n)a.remove();this.refs.dial.dataset.unit=this._clockUnit,this.refs.dial.append(...s.map(a=>this._buildMark(a,t)))}else s.forEach((a,l)=>this._syncMark(n[l],a,t));let r=e&&!Tc(t)?"inner":"outer",o=e?t%12*30:t*6;this.refs.hand.dataset.ring=r,this.refs.hand.style.setProperty("--zx-clock-angle",`${o}deg`)}_buildMark(e,t){let s=c("button",{class:"zx-time-picker__mark",type:"button",role:"radio",dataset:{value:String(e.value),ring:e.ring}},e.label);return s.style.setProperty("--zx-clock-angle",`${e.angle}deg`),this._syncMark(s,e,t),s}_syncMark(e,t,s){let n=t.value===s;e.setAttribute("aria-checked",String(n)),e.tabIndex=n?0:-1}_message(e,t){let s=this.msg(e);return s===e?t:s}};function Ec(){let i=[];for(let e=1;e<=12;e+=1)i.push({value:e,label:String(e),angle:e%12*30,ring:"outer"});for(let e=0;e<12;e+=1){let t=e===0?0:12+e;i.push({value:t,label:De(t),angle:e*30,ring:"inner"})}return i}function Ic(){let i=[];for(let e=0;e<60;e+=Dc)i.push({value:e,label:De(e),angle:e*6,ring:"outer"});return i}function Tc(i){return i>=1&&i<=12}function Ir(i){return i instanceof Date&&!Number.isNaN(i.getTime())?{h:i.getHours(),m:i.getMinutes(),s:i.getSeconds()}:!i||typeof i!="object"?null:{h:qe(i.h,0,23),m:qe(i.m,0,59),s:qe(i.s,0,59)}}function qe(i,e,t){let s=Number.parseInt(String(i??""),10);return Number.isFinite(s)?Math.max(e,Math.min(t,s)):e}function Mc(i){let e=Math.round(Number(i));return Number.isFinite(e)&&e>0&&e<=59?e:5}function De(i){return String(i).padStart(2,"0")}function Nc(i,e){return i.h===e.h&&i.m===e.m&&i.s===e.s}var $e=class extends S{static cssName="date-picker";static defaults={value:null,min:null,max:null,weekStart:1,showWeekNumbers:!1,time:!1};render(){let e=this.el??c("div");this._min=te(Gt(this.options.min)),this._max=te(Gt(this.options.max)),this._value=this._normalizeValue(Gt(this.options.value)),this._focused=te(this._value)??this._clampFocus(te(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=Oc(this.options.weekStart),this._quickOpen=!1,this._timePicker=null;let t=c("div",{class:"zx-date-picker__surface"},c("div",{class:"zx-date-picker__header"},c("button",{ref:"previous",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.previousMonth","Previous month")},v("chevron-left")),c("button",{ref:"heading",class:"zx-date-picker__heading",type:"button",ariaExpanded:"false","aria-haspopup":"grid"}),c("button",{ref:"next",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.nextMonth","Next month")},v("chevron-right"))),c("div",{ref:"quickPanel",class:"zx-date-picker__quick",hidden:!0},c("div",{class:"zx-date-picker__quick-header"},c("button",{ref:"quickPrevious",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.previousYear","Previous year")},v("chevron-left")),c("span",{ref:"quickYear",class:"zx-date-picker__quick-year",ariaLive:"polite"}),c("button",{ref:"quickNext",class:"zx-date-picker__nav",type:"button",ariaLabel:this._message("datePicker.nextYear","Next year")},v("chevron-right"))),c("div",{ref:"quickGrid",class:"zx-date-picker__quick-grid",role:"grid"})),c("table",{ref:"grid",class:"zx-date-picker__grid",role:"grid",ariaLabel:this._message("datePicker.calendar","Calendar")},c("thead",{ref:"weekdays"}),c("tbody",{ref:"days"})));return this._content=t,e.append(t),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 Zt(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)}),t.append(this._timePicker.el)),e}get(){return gs(this._value)}set(e,{silent:t=!1}={}){let s=this._normalizeValue(Gt(e));return this._value=s,s&&(this._focused=te(s),this._viewYear=s.getFullYear(),this._viewMonth=s.getMonth()),this._timePicker?.set(s,{silent:!0}),this._renderCalendar(),t||this.emit("change",{date:gs(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(e){if(!e)return null;let t=new Date(e.getTime()),s=te(t);return this._min&&s<this._min&&Tr(t,this._min),this._max&&s>this._max&&Tr(t,this._max),t}_clampFocus(e){return this._min&&e<this._min?new Date(this._min.getTime()):this._max&&e>this._max?new Date(this._max.getTime()):e}_renderWeekdays(){let e=c("tr");this.options.showWeekNumbers&&e.append(c("th",{class:"zx-date-picker__week-heading",scope:"col",ariaLabel:this._message("datePicker.weekNumber","Week number")},"#"));let t=new Date(2023,0,1);for(let s=0;s<7;s+=1){let n=T(t,(this._weekStart+s)%7);e.append(c("th",{scope:"col",ariaLabel:I(n,"%A")},I(n,"%a")))}this.refs.weekdays.replaceChildren(e)}_renderCalendar(){if(!this.refs?.days)return;let e=new Date(this._viewYear,this._viewMonth,1),t=(e.getDay()-this._weekStart+7)%7,s=T(e,-t);this.refs.heading.textContent=I(e,"%B %Y"),this.refs.heading.setAttribute("aria-label",this._message("datePicker.chooseMonthYear","Choose month and year, %1",I(e,"%B %Y")));let n=[];for(let r=0;r<6;r+=1){let o=T(s,r*7),a=c("tr");this.options.showWeekNumbers&&a.append(c("th",{class:"zx-date-picker__week",scope:"row",ariaLabel:this._message("datePicker.week","Week %1",Mr(o))},String(Mr(o))));for(let l=0;l<7;l+=1){let u=T(o,l),d=!!(this._value&&j(u,this._value)),h=!this._inRange(u),p=c("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:j(u,this._focused)?0:-1,ariaSelected:String(d),ariaDisabled:String(h),ariaCurrent:j(u,new Date)?"date":null,ariaLabel:`${I(u,"%e")} ${I(u,"%B %Y")}`,dataset:{date:I(u,"%Y-%m-%d"),otherMonth:u.getMonth()===this._viewMonth?null:"true"}},I(u,"%e"));a.append(c("td",{role:"presentation"},p))}n.push(a)}this.refs.days.replaceChildren(...n),this._quickOpen&&this._renderQuickPick()}_onDayClick(e){let t=e.target?.closest?.("[data-date]");if(!t||!this.refs.days.contains(t))return;let s=oe(t.dataset.date,"%Y-%m-%d");s&&this._inRange(s)&&this._selectDate(s)}_onDayKeydown(e){let t=e.target?.closest?.("[data-date]");if(!t||!this.refs.days.contains(t))return;let s=oe(t.dataset.date,"%Y-%m-%d");if(!s)return;let n=null;if(e.key==="ArrowLeft")n=T(s,-1);else if(e.key==="ArrowRight")n=T(s,1);else if(e.key==="ArrowUp")n=T(s,-7);else if(e.key==="ArrowDown")n=T(s,7);else if(e.key==="PageUp")n=Ce(s,e.shiftKey?-12:-1);else if(e.key==="PageDown")n=Ce(s,e.shiftKey?12:1);else if(e.key==="Home")n=T(s,-((s.getDay()-this._weekStart+7)%7));else if(e.key==="End")n=T(s,6-(s.getDay()-this._weekStart+7)%7);else if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._inRange(s)&&this._selectDate(s);return}n&&(e.preventDefault(),this._moveFocus(n))}_moveFocus(e){let t=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;this._focused=te(e),this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),this._renderCalendar(),t&&this._emitMonthChange(),this._buttonForDate(e)?.focus()}_selectDate(e){let t=new Date(e.getTime()),s=this._timePicker?.get();s?t.setHours(s.h,s.m,s.s,0):this._value&&t.setHours(this._value.getHours(),this._value.getMinutes(),this._value.getSeconds(),this._value.getMilliseconds());let n=t.getFullYear()!==this._viewYear||t.getMonth()!==this._viewMonth;this._value=t,this._focused=te(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._timePicker?.set(t,{silent:!0}),this._renderCalendar(),n&&this._emitMonthChange(),this.emit("change",{date:gs(t)})}_pageMonth(e){this._closeQuickPick();let t=Ce(this._focused,e);this._focused=te(t),this._viewYear=t.getFullYear(),this._viewMonth=t.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 e=[];for(let t=0;t<12;t+=1){let s=new Date(this._viewYear,t,1);e.push(c("button",{class:"zx-date-picker__quick-month",type:"button",role:"gridcell",tabindex:t===this._viewMonth?0:-1,ariaSelected:String(t===this._viewMonth),dataset:{month:t}},I(s,"%b")))}this.refs.quickGrid.replaceChildren(...e)}_stepQuickYear(e){this._viewYear+=e,this._renderQuickPick(),this._emitMonthChange(),this.refs.quickGrid.querySelector('[tabindex="0"]')?.focus()}_onQuickClick(e){let t=e.target?.closest?.("[data-month]");!t||!this.refs.quickGrid.contains(t)||this._chooseQuickMonth(Number(t.dataset.month))}_onQuickKeydown(e){let t=e.target?.closest?.("[data-month]");if(!t||!this.refs.quickGrid.contains(t))return;let s=Number(t.dataset.month),n=null;if(e.key==="ArrowLeft")n=s-1;else if(e.key==="ArrowRight")n=s+1;else if(e.key==="ArrowUp")n=s-3;else if(e.key==="ArrowDown")n=s+3;else if(e.key==="Home")n=0;else if(e.key==="End")n=11;else if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._chooseQuickMonth(s);return}else if(e.key==="Escape"){e.preventDefault(),this._closeQuickPick(),this.refs.heading.focus();return}if(n===null)return;e.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(e){let t=new Date(this._viewYear,e,Math.min(this._focused.getDate(),new Date(this._viewYear,e+1,0).getDate()));this._focused=te(t),this._viewMonth=e,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(e){let t=te(e);return!(this._min&&t<this._min)&&!(this._max&&t>this._max)}_buttonForDate(e){return this.refs.days.querySelector(`[data-date="${I(e,"%Y-%m-%d")}"]`)}_message(e,t,...s){let n=this.msg(e,...s);return n===e?O(t,s):n}};function Gt(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function te(i){return i?new Date(i.getFullYear(),i.getMonth(),i.getDate()):null}function gs(i){return i?new Date(i.getTime()):null}function Tr(i,e){i.setFullYear(e.getFullYear(),e.getMonth(),e.getDate())}function Oc(i){let e=Number(i);return Number.isInteger(e)&&e>=0&&e<=6?e:Wt()}function Mr(i){let e=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let s=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-s.getTime())/864e5+1)/7)}var Jt=class extends $e{static cssName="month-picker";static defaults={value:null,min:null,max:null};constructor(e,t={}){super(e,t)}render(){let e=this.el??c("div");this._min=Xt(Qt(this.options.min)),this._max=Xt(Qt(this.options.max)),this._value=this._normalizeMonth(Qt(this.options.value));let t=this._value??Xt(new Date);this._year=t.getFullYear(),this._focusedMonth=t.getMonth();let s=c("div",{class:"zx-month-picker__surface"},c("div",{class:"zx-month-picker__header"},c("button",{ref:"previousYear",class:"zx-month-picker__nav",type:"button",ariaLabel:this._message("monthPicker.previousYear","Previous year")},v("chevron-left")),c("span",{ref:"year",class:"zx-month-picker__year",ariaLive:"polite"}),c("button",{ref:"nextYear",class:"zx-month-picker__nav",type:"button",ariaLabel:this._message("monthPicker.nextYear","Next year")},v("chevron-right"))),c("div",{ref:"grid",class:"zx-month-picker__grid",role:"grid",ariaLabel:this._message("monthPicker.chooseMonth","Choose month")}));return this._content=s,e.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(),e}get(){return this._value?new Date(this._value.getTime()):null}set(e,{silent:t=!1}={}){return this._value=this._normalizeMonth(Qt(e)),this._value&&(this._year=this._value.getFullYear(),this._focusedMonth=this._value.getMonth()),this._renderMonths(),t||this.emit("change",{date:this.get()}),this}focus(){return this._button(this._focusedMonth)?.focus(),this}destroy(){this._content?.remove(),super.destroy()}_normalizeMonth(e){if(!e)return null;let t=Xt(e);return this._min&&t<this._min&&(t=new Date(this._min.getTime())),this._max&&t>this._max&&(t=new Date(this._max.getTime())),t}_renderMonths(){if(!this.refs?.grid)return;this.refs.year.textContent=String(this._year);let e=[];for(let t=0;t<12;t+=1){let s=new Date(this._year,t,1),n=!!(this._value&&Fc(s,this._value));e.push(c("button",{class:"zx-month-picker__month",type:"button",role:"gridcell",tabindex:t===this._focusedMonth?0:-1,ariaSelected:String(n),ariaDisabled:String(!this._inRange(s)),ariaLabel:I(s,"%B %Y"),dataset:{month:t}},I(s,"%b")))}this.refs.grid.replaceChildren(...e)}_stepYear(e){this._year+=e,this._renderMonths()}_onMonthClick(e){let t=e.target?.closest?.("[data-month]");!t||!this.refs.grid.contains(t)||this._selectMonth(Number(t.dataset.month))}_onMonthKeydown(e){let t=e.target?.closest?.("[data-month]");if(!t||!this.refs.grid.contains(t))return;let s=Number(t.dataset.month),n=null;if(e.key==="ArrowLeft")n=-1;else if(e.key==="ArrowRight")n=1;else if(e.key==="ArrowUp")n=-3;else if(e.key==="ArrowDown")n=3;else if(e.key==="Home")n=-(s%3);else if(e.key==="End")n=2-s%3;else if(e.key==="PageUp"){e.preventDefault(),this._stepYear(-1),this.focus();return}else if(e.key==="PageDown"){e.preventDefault(),this._stepYear(1),this.focus();return}else if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._selectMonth(s);return}if(n===null)return;e.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(e){let t=new Date(this._year,e,1);this._inRange(t)&&(this._focusedMonth=e,this._value=t,this._renderMonths(),this.emit("change",{date:this.get()}))}_inRange(e){return!(this._min&&e<this._min)&&!(this._max&&e>this._max)}_button(e){return this.refs.grid.querySelector(`[data-month="${e}"]`)}};function Qt(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function Xt(i){return i?new Date(i.getFullYear(),i.getMonth(),1):null}function Fc(i,e){return i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()}function Nr(){z.register("month",(i,e)=>{let t=i.own(new Jt(null,{...e.props??{},value:e.value})),s=!1,n=()=>{t.el.setAttribute("aria-disabled",String(s));for(let r of t.el.querySelectorAll("button"))r.disabled=s};return i.listen(t.el,"change",r=>r.stopImmediatePropagation()),t.on("change",r=>i.emit("change",{value:r.detail.date})),{el:t.el,get:()=>t.get(),set:r=>{t.set(r instanceof Date?r:null,{silent:!0}),n()},focus:()=>t.focus(),setDisabled:r=>{s=!!r,n()}}})}var Rc=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function Z(i,e,t={}){if(!(i instanceof Element)||!(e instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let s=Rc.has(t.placement)?t.placement:"bottom-start",n=Number(t.offset??4),r=t.flip??!0,o=t.matchWidth??!1,a=i.getAttribute("style"),l=e.getAttribute("style"),u=e.getAttribute("popover"),d=!1,h=null,p=()=>{},f=()=>{};e.setAttribute("popover","manual");let _=typeof CSS<"u"&&CSS.supports?.("anchor-name: --zx-a"),m=`--${E("zx-a")}`;if(_){let g=Or(i);i.style.setProperty("anchor-name",[...g,m].join(", ")),e.style.position="fixed",e.style.inset="auto",e.style.margin="0",e.style.setProperty("position-anchor",m);let b=Lc(s,getComputedStyle(i).direction==="rtl");e.style.setProperty("position-area",b),e.style.setProperty("inset-area",b),e.style.setProperty("position-try-fallbacks",r?"flip-block, flip-inline, flip-block flip-inline":"none");let y=s.startsWith("top")?"margin-bottom":s.startsWith("bottom")?"margin-top":s.startsWith("left")?"margin-right":"margin-left";e.style.setProperty(y,`${n}px`),p=()=>{o&&(e.style.minWidth=`${i.getBoundingClientRect().width}px`)},typeof ResizeObserver=="function"&&(h=new ResizeObserver(p),h.observe(i))}else e.style.position="fixed",e.style.inset="auto",e.style.margin="0",p=()=>Pc(i,e,{placement:s,offset:n,flip:r,matchWidth:o}),window.addEventListener("scroll",p,{capture:!0,passive:!0}),window.addEventListener("resize",p,{passive:!0}),typeof ResizeObserver=="function"&&(h=new ResizeObserver(p),h.observe(i)),f=()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)};return jc(e),p(),{update(){d||p()},destroy(){if(!d){if(d=!0,h?.disconnect(),f(),Bc(e),_){let g=Or(i).filter(b=>b!==m);g.length?i.style.setProperty("anchor-name",g.join(", ")):i.style.removeProperty("anchor-name"),a===null&&i.getAttribute("style")===""&&i.removeAttribute("style")}Rr(e,"style",l),Rr(e,"popover",u)}}}}function Or(i){return String(i.style?.getPropertyValue("anchor-name")??"").split(",").map(e=>e.trim()).filter(e=>e&&e!=="none")}function Lc(i,e){return{"bottom-start":e?"bottom span-left":"bottom span-right","bottom-end":e?"bottom span-right":"bottom span-left","top-start":e?"top span-left":"top span-right","top-end":e?"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 Pc(i,e,{placement:t,offset:s,flip:n,matchWidth:r}){let o=i.getBoundingClientRect();r&&(e.style.minWidth=`${o.width}px`);let a=e.getBoundingClientRect(),l=document.documentElement.clientWidth||window.innerWidth,u=document.documentElement.clientHeight||window.innerHeight,d=t,h=Fr(t),p=o.bottom+s,f=o.top-s-a.height,_=o.right+s,m=o.left-s-a.width;n&&(h==="bottom"&&p+a.height>u&&f>=0?d=ei(t,"bottom","top"):h==="top"&&f<0&&p+a.height<=u?d=ei(t,"top","bottom"):h==="right"&&_+a.width>l&&m>=0?d=ei(t,"right","left"):h==="left"&&m<0&&_+a.width<=l&&(d=ei(t,"left","right")));let g=Fr(d),b,y;if(g==="bottom"||g==="top"){let A=getComputedStyle(i).direction==="rtl";d.endsWith("-end")?b=A?o.left:o.right-a.width:d.endsWith("-start")?b=A?o.right-a.width:o.left:b=o.left+(o.width-a.width)/2,y=g==="bottom"?p:f}else b=g==="right"?_:m,d.endsWith("-end")?y=o.bottom-a.height:d.endsWith("-start")?y=o.top:y=o.top+(o.height-a.height)/2;e.style.left=`${Math.round(dt(b,0,Math.max(0,l-a.width)))}px`,e.style.top=`${Math.round(dt(y,0,Math.max(0,u-a.height)))}px`}function Fr(i){return i.split("-")[0]}function ei(i,e,t){return i.replace(e,t)}function jc(i){if(typeof i.showPopover=="function")try{i.showPopover()}catch{}}function Bc(i){if(typeof i.hidePopover=="function")try{i.hidePopover()}catch{}}function Rr(i,e,t){t===null?i.removeAttribute(e):i.setAttribute(e,t)}var Vc=6,qr=864e5;function mt(i,e){let t=Y(Ee(i)),s=Y(Ee(e));return t&&s&&t.getTime()>s.getTime()?{start:s,end:t}:{start:t,end:s}}function ti(i,e){let t=mt(i,e);return!t.start||!t.end?0:Math.round((jr(t.end)-jr(t.start))/qr)}function qc(i,e,t){let s=Y(Ee(i));if(!s)return null;let n=mt(e,t);return!n.start&&!n.end?null:n.end?n.start?s.getTime()<n.start.getTime()||s.getTime()>n.end.getTime()?null:j(s,n.start)?"start":j(s,n.end)?"end":"middle":j(s,n.end)?"end":null:j(s,n.start)?"start":null}function ii(i,e={}){let t=Y(Ee(e.min)),s=Y(Ee(e.max)),n=ni(e.minNights)??0,r=ni(e.maxNights),{start:o,end:a}=mt(i?.start,i?.end);return o&&(o=ys(o,t,s)),a&&(a=ys(a,t,s)),!o||!a?{start:o,end:a}:(r!==null&&ti(o,a)>r&&(a=T(o,r)),n>0&&ti(o,a)<n&&(a=T(o,n),s&&a.getTime()>s.getTime()&&(a=new Date(s.getTime()),o=T(a,-n),t&&o.getTime()<t.getTime()))?{start:null,end:null}:{start:o,end:a})}var si=class extends S{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 e=this.el??c("div");this.el=e,this._rootAttributes=Zc(e,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=Y(Ee(this.options.min)),this._max=Y(Ee(this.options.max)),this._minNights=ni(this.options.minNights)??0,this._maxNights=ni(this.options.maxNights),this._weekStart=Uc(this.options.weekStart),this._monthCount=Yc(this.options.months),this._presets=Kc(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let t=ii({start:this.options.start,end:this.options.end},this._bounds());this._start=t.start,this._end=t.end,this._picking=!!(t.start&&!t.end),this._remember(),this._focused=Se(this._start)??this._clampFocus(Y(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),e.setAttribute("role","group"),e.setAttribute("aria-label",F("daterange.label","Date range")),e.dataset.months=String(this._monthCount),this._presets.length&&(e.dataset.presets="true");let s=c("div",{class:"zx-date-range-picker__surface"},this._presets.length?c("div",{ref:"presets",class:"zx-date-range-picker__presets",role:"group",ariaLabel:F("daterange.presets","Date range presets")},this._presets.map(r=>c("button",{class:"zx-date-range-picker__preset",type:"button",dataset:{preset:r.name}},r.label))):null,c("div",{ref:"calendars",class:"zx-date-range-picker__calendars"})),n=c("div",{ref:"status",class:"zx-date-range-picker__status",role:"status",ariaLive:"polite"});return this._nodes=[s,n],e.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(),e}get(){return{start:Se(this._start),end:Se(this._end)}}set(e={},{silent:t=!1}={}){let s=ii({start:e?.start??null,end:e?.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=Se(s.start),this._setView(s.start)):this._paint(),this._announce(),t||this.emit("change",this.get()),this}clear({silent:e=!1}={}){return this.set({start:null,end:null},{silent:e})}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 e of this._nodes??[])e.remove();this._nodes=[],this._dayCells=[],Gc(this.el,this._rootAttributes??new Map),super.destroy()}_bounds(){return{min:this._min,max:this._max,minNights:this._minNights,maxNights:this._maxNights}}_selectable(e){let t=Y(e);if(!t||this._min&&t.getTime()<this._min.getTime()||this._max&&t.getTime()>this._max.getTime())return!1;if(!this._picking||!this._start||t.getTime()<=this._start.getTime())return!0;let s=ti(this._start,t);return!(s<this._minNights||this._maxNights!==null&&s>this._maxNights)}_choose(e){let t=Y(e);if(this._disabled||!t||!this._selectable(t))return;this._picking&&this._start&&t.getTime()>this._start.getTime()?(this._end=t,this._picking=!1,this._remember()):(this._start=t,this._end=null,this._picking=!0),this._focused=t,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),this._picking||this.emit("change",this.get())}_remember(){let e=!!(this._start&&this._end);this._committedStart=e?Se(this._start):null,this._committedEnd=e?Se(this._end):null}_abandon(){return this._picking?(this._start=Se(this._committedStart),this._end=Se(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(e){return ys(e,this._min,this._max)}_visibleMonthCount(){let e=this.refs.calendars?.children??[],t=0;for(let s of e)s.getClientRects().length>0&&(t+=1);return t||this._monthCount}_setView(e){let t=e.getFullYear()!==this._viewYear||e.getMonth()!==this._viewMonth;if(this._viewYear=e.getFullYear(),this._viewMonth=e.getMonth(),!t){this._paint();return}this._renderCalendars(),this._emitMonthChange()}_ensureVisible(e){let t=this._visibleMonthCount(),s=Br(e)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<t)return!1;let n=s<0?s:s-(t-1),r=new Date(this._viewYear,this._viewMonth+n,1);return this._viewYear=r.getFullYear(),this._viewMonth=r.getMonth(),!0}_pageView(e){if(this._disabled)return;let t=new Date(this._viewYear,this._viewMonth+e,1);this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._focused=this._focusInView(this._focused),this._renderCalendars(),this._emitMonthChange()}_focusInView(e){let t=this._visibleMonthCount(),s=Br(e)-(this._viewYear*12+this._viewMonth);if(s>=0&&s<t)return e;let n=new Date(this._viewYear,this._viewMonth+1,0).getDate();return new Date(this._viewYear,this._viewMonth,Math.min(e.getDate(),n))}_moveFocus(e){let t=Y(e);this._focused=t,this._ensureVisible(t)?(this._renderCalendars(),this._emitMonthChange()):this._paint(),this._buttonForDate(t)?.focus()}_emitMonthChange(){this.emit("monthchange",{year:this._viewYear,month:this._viewMonth})}_onPresetClick(e){let t=e.target?.closest?.("[data-preset]");if(!t||this._disabled)return;let s=this._presets.find(r=>r.name===t.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(e){let t=e.target,s=t?.closest?.("[data-nav]");if(s){this._pageView(s.dataset.nav==="next"?1:-1);return}let n=this._cellFor(t);n&&this._choose(n.date)}_onDayHover(e){let t=this._cellFor(e.target);this._setHover(t?t.date:null)}_setHover(e){if(this._disabled||!this._picking)return;let t=e?Y(e):null;!t&&!this._hover||t&&this._hover&&j(t,this._hover)||(this._hover=t,this._paint())}_onDayKeydown(e){let t=this._cellFor(e.target);if(!t)return;let s=t.date,n=null;if(e.key==="ArrowLeft")n=T(s,-1);else if(e.key==="ArrowRight")n=T(s,1);else if(e.key==="ArrowUp")n=T(s,-7);else if(e.key==="ArrowDown")n=T(s,7);else if(e.key==="PageUp")n=Ce(s,e.shiftKey?-12:-1);else if(e.key==="PageDown")n=Ce(s,e.shiftKey?12:1);else if(e.key==="Home")n=T(s,-((s.getDay()-this._weekStart+7)%7));else if(e.key==="End")n=T(s,6-(s.getDay()-this._weekStart+7)%7);else if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._choose(s);return}else if(e.key==="Escape"){if(!this._abandon())return;e.preventDefault(),e.stopPropagation();return}!n||this._disabled||(e.preventDefault(),this._moveFocus(n))}_renderCalendars(){if(!this.refs?.calendars)return;this._dayCells=[];let e=[];for(let t=0;t<this._monthCount;t+=1)e.push(this._renderMonth(new Date(this._viewYear,this._viewMonth+t,1)));this.refs.calendars.replaceChildren(...e),this._paint(),this._syncDisabled()}_renderMonth(e){let t=I(e,"%B %Y"),s=(e.getDay()-this._weekStart+7)%7,n=T(e,-s),r=[];for(let o=0;o<Vc;o+=1){let a=T(n,o*7),l=c("tr"),u=Wc(a,e);this.options.showWeekNumbers&&l.append(c("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:u?F("daterange.week","Week %1",[Vr(a)]):null},u?String(Vr(a)):""));for(let d=0;d<7;d+=1){let h=T(a,d),p=c("td",{role:"presentation"});if(h.getMonth()===e.getMonth()&&h.getFullYear()===e.getFullYear()){let f=c("button",{class:"zx-date-range-picker__day",type:"button",role:"gridcell",tabindex:-1,dataset:{date:I(h,"%Y-%m-%d")}},I(h,"%e"));p.append(f),this._dayCells.push({date:h,cell:p,button:f})}l.append(p)}r.push(l)}return c("div",{class:"zx-date-range-picker__month"},c("div",{class:"zx-date-range-picker__header"},c("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"previous"},ariaLabel:F("daterange.previousMonth","Previous month")},v("chevron-left")),c("div",{class:"zx-date-range-picker__caption",ariaHidden:"true"},t),c("button",{class:"zx-date-range-picker__nav",type:"button",dataset:{nav:"next"},ariaLabel:F("daterange.nextMonth","Next month")},v("chevron-right"))),c("table",{class:"zx-date-range-picker__grid",role:"grid",ariaLabel:t},c("thead",{},this._weekdayRow()),c("tbody",{},...r)))}_weekdayRow(){let e=c("tr");this.options.showWeekNumbers&&e.append(c("th",{class:"zx-date-range-picker__week-heading",scope:"col",ariaLabel:F("daterange.weekNumber","Week number")},"#"));let t=new Date(2023,0,1);for(let s=0;s<7;s+=1){let n=T(t,(this._weekStart+s)%7);e.append(c("th",{scope:"col",ariaLabel:I(n,"%A")},I(n,"%a")))}return e}_paint(){let e=new Date,t=null;for(let s of this._dayCells)j(s.date,this._focused)&&(t=s);t||(t=this._dayCells[0]??null);for(let s of this._dayCells){let{date:n,cell:r,button:o}=s,a=this._dayState(n);bs(r,"range",a.range),bs(r,"rangeEdge",a.edge),bs(o,"range",a.range),o.tabIndex=s===t?0:-1,o.setAttribute("aria-selected",String(a.range!==null&&a.range!=="preview")),o.setAttribute("aria-disabled",String(!this._selectable(n))),o.setAttribute("aria-label",this._dayLabel(n,a.range)),j(n,e)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(e){if(this._start&&this._end){let s=qc(e,this._start,this._end);if(!s)return{range:null,edge:null};let n=j(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 t=this._previewEnd();return j(e,this._start)?{range:"start",edge:t?"start":"both"}:t?e.getTime()>this._start.getTime()&&e.getTime()<=t.getTime()?{range:"preview",edge:j(e,t)?"end":null}:{range:null,edge:null}:{range:null,edge:null}}_previewEnd(){if(!this._picking||!this._start||this._disabled)return null;let e=this._hover??this._focused;if(!e)return null;let t=Y(e);return t.getTime()<=this._start.getTime()?null:this._selectable(t)?t:null}_dayLabel(e,t){let s=I(e,"%A, %e %B %Y");return t==="start"?`${s}, ${F("daterange.day.start","range start")}`:t==="end"?`${s}, ${F("daterange.day.end","range end")}`:t==="middle"?`${s}, ${F("daterange.day.middle","in selected range")}`:s}_syncDisabled(){this.el.setAttribute("aria-disabled",String(this._disabled));for(let e of this.el.querySelectorAll("button"))e.disabled=this._disabled}_announce(){this.refs?.status&&(this.refs.status.textContent=this._selectionLabel())}_selectionLabel(){if(!this._start)return F("daterange.status.empty","No date range selected");if(!this._end)return F("daterange.status.start","%1 selected, choose an end date",[I(this._start,"%e %B %Y")]);let e=ti(this._start,this._end),t=e===1?F("daterange.night","1 night"):F("daterange.nights","%1 nights",[e]);return`${Hc(this._start,this._end)}, ${t}`}_cellFor(e){let t=e?.closest?.("[data-date]");return t?this._dayCells.find(s=>s.button===t)??null:null}_buttonForDate(e){return this._dayCells.find(t=>j(t.date,e))?.button??null}};function $c(){return[{name:"today",label:F("daterange.preset.today","Today"),range:()=>Lr(ae())},{name:"yesterday",label:F("daterange.preset.yesterday","Yesterday"),range:()=>Lr(T(ae(),-1))},{name:"last7",label:F("daterange.preset.last7","Last 7 days"),range:()=>({start:T(ae(),-6),end:ae()})},{name:"last30",label:F("daterange.preset.last30","Last 30 days"),range:()=>({start:T(ae(),-29),end:ae()})},{name:"thisMonth",label:F("daterange.preset.thisMonth","This month"),range:()=>Pr(ae(),0)},{name:"lastMonth",label:F("daterange.preset.lastMonth","Last month"),range:()=>Pr(ae(),-1)},{name:"thisQuarter",label:F("daterange.preset.thisQuarter","This quarter"),range:()=>{let i=ae(),e=Math.floor(i.getMonth()/3)*3;return{start:new Date(i.getFullYear(),e,1),end:new Date(i.getFullYear(),e+3,0)}}},{name:"thisYear",label:F("daterange.preset.thisYear","This year"),range:()=>{let i=ae();return{start:new Date(i.getFullYear(),0,1),end:new Date(i.getFullYear(),11,31)}}}]}function F(i,e,t){let s=ve(i);return O(s===i?e:s,t)}function Hc(i,e){if(j(i,e))return I(i,"%e %B %Y");let t=I(e,"%e %B %Y");return i.getFullYear()!==e.getFullYear()?`${I(i,"%e %B %Y")} \u2013 ${t}`:i.getMonth()!==e.getMonth()?`${I(i,"%e %B")} \u2013 ${t}`:`${I(i,"%e")} \u2013 ${t}`}function Kc(i){return i===!0?$c():Array.isArray(i)?i.filter(e=>e&&typeof e.range=="function").map((e,t)=>({name:String(e.name??`preset-${t}`),label:String(e.label??e.name??""),range:e.range})):[]}function ae(){return Y(new Date)}function Lr(i){return{start:i,end:new Date(i.getTime())}}function Pr(i,e){return{start:new Date(i.getFullYear(),i.getMonth()+e,1),end:new Date(i.getFullYear(),i.getMonth()+e+1,0)}}function Ee(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 Se(i){return i?new Date(i.getTime()):null}function ys(i,e,t){return e&&i.getTime()<e.getTime()?new Date(e.getTime()):t&&i.getTime()>t.getTime()?new Date(t.getTime()):new Date(i.getTime())}function jr(i){return Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())}function Br(i){return i.getFullYear()*12+i.getMonth()}function ni(i){if(i==null||i==="")return null;let e=Number(i);return Number.isFinite(e)?Math.max(0,Math.trunc(e)):null}function Uc(i){let e=Number(i);return Number.isInteger(e)&&e>=0&&e<=6?e:Wt()}function Yc(i){let e=Number(i);return Number.isInteger(e)&&e>=1&&e<=4?e:2}function Wc(i,e){for(let t=0;t<7;t+=1){let s=T(i,t);if(s.getMonth()===e.getMonth()&&s.getFullYear()===e.getFullYear())return!0}return!1}function Vr(i){let e=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let s=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-s.getTime())/qr+1)/7)}function bs(i,e,t){t==null?delete i.dataset[e]:i.dataset[e]=t}function Zc(i,e){return new Map(e.map(t=>[t,i.getAttribute(t)]))}function Gc(i,e){for(let[t,s]of e)s===null?i.removeAttribute(t):i.setAttribute(t,s)}var Qc={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function $r(i,e,t){let s=String(i??"").trim();if(s==="")return{start:null,end:null};let n=String(t??" \u2013 "),r=n.trim(),o=r!==""&&String(e).includes(r)&&/^\s|\s$/.test(n),a=o?"\\s+":"\\s*",l=o?"(?:\\s+|$)":"\\s*",u=r===""?[s]:s.split(new RegExp(`${a}${Ji(r)}${l}`));if(u.length>2)return null;let d=oe(u[0].trim(),e);if(!d)return null;if(u.length===1)return{start:d,end:new Date(d.getTime())};if(u[1].trim()==="")return{start:d,end:null};let h=oe(u[1].trim(),e);return h?mt(d,h):null}function Xc(i,e,t){let s=i?.start??null,n=i?.end??null;return!s&&!n?"":n?s?`${I(s,e)}${t}${I(n,e)}`:I(n,e):I(s,e)}var oi=class extends S{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 e=this.el??c("div");this.el=e,this._originalState=e.getAttribute("data-state"),this._originalAriaDisabled=e.getAttribute("aria-disabled"),this._originalClearable=e.getAttribute("data-clearable"),e.toggleAttribute("data-clearable",!!this.options.clearable),this._format=String(this.options.format||"%d.%m.%Y"),this._separator=String(this.options.separator??" \u2013 "),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._range=this._coerce({start:this.options.start,end:this.options.end});let t=E("zx-date-range-box-popover"),s=c("div",{class:"zx-date-range-box__content"},c("div",{ref:"control",class:"zx-date-range-box__control"},c("input",{ref:"input",class:"zx-date-range-box__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??this._placeholder(),"aria-haspopup":"grid",ariaControls:t,ariaExpanded:"false"}),c("button",{ref:"clear",class:"zx-icon-btn zx-date-range-box__clear",type:"button",ariaLabel:Hr("daterange.clear","Clear date range")},v("x",{size:13})),c("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:Hr("daterange.choose","Choose date range"),"aria-haspopup":"grid",ariaControls:t,ariaExpanded:"false"},v("calendar"))),c("div",{ref:"popover",id:t,class:"zx-date-range-box__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=s,e.append(s),this._picker=new si(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&&!e.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),e}get(e="date"){return e==="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(e,{silent:t=!1}={}){return this._apply(this._coerce(e),{silent:t}),this}clear({silent:e=!1}={}){return this.set({start:null,end:null},{silent:e})}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=Z(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(),ri(this.el,"data-state",this._originalState),ri(this.el,"aria-disabled",this._originalAriaDisabled),ri(this.el,"data-clearable",this._originalClearable),super.destroy()}_apply(e,{silent:t=!1,push:s=!0}={}){this._range=e,s&&this._picker?.set(this._range,{silent:!0}),this._setValid(),this._syncDisplay(),t||this.emit("change",this.get())}_onInputKeydown(e){e.key==="ArrowDown"?(e.preventDefault(),this.open()):e.key==="Enter"?(e.preventDefault(),this._commitText()):e.key==="Escape"&&this._open&&(e.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let e=this.refs.input.value.trim();if(e===""){this.set({start:null,end:null});return}let t=$r(e,this._format,this._separator);if(!t){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:e});return}this._apply(this._clamp(t))}_coerce(e){return e==null?{start:null,end:null}:typeof e=="string"?this._clamp($r(e,this._format,this._separator)??{start:null,end:null}):Array.isArray(e)?this._clamp({start:this._toDate(e[0]),end:this._toDate(e[1])}):typeof e!="object"?{start:null,end:null}:this._clamp({start:this._toDate(e.start),end:this._toDate(e.end)})}_toDate(e){return e instanceof Date?Number.isNaN(e.getTime())?null:new Date(e.getTime()):typeof e=="number"&&Number.isFinite(e)?new Date(e*1e3):typeof e=="string"&&e.trim()!==""?oe(e.trim(),this._format):null}_clamp(e){return ii(e,{min:this.options.min,max:this.options.max,minNights:this.options.minNights,maxNights:this.options.maxNights})}_placeholder(){let e=this._format.replace(/%[demYy]/g,t=>Qc[t]??t);return`${e}${this._separator}${e}`}_syncDisplay(){this.refs.input.value=Xc(this._range,this._format,this._separator),this._syncClear()}_syncClear(){this.refs.clear.hidden=!this.options.clearable||!(this._range.start||this._range.end)||this._disabled}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled)),this._syncClear(),this._disabled?this._picker?.disable():this._picker?.enable()}_setValid(){this.el.dataset.state==="invalid"&&ri(this.el,"data-state",this._originalState),this.refs.input.removeAttribute("aria-invalid")}_close(e){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"),e&&this.focus(),this.emit("close"))}};function Hr(i,e,t){let s=ve(i);return O(s===i?e:s,t)}function ri(i,e,t){t===null?i.removeAttribute(e):i.setAttribute(e,t)}function Kr(){z.register("daterange",(i,e)=>{let t=i.own(new oi(null,{...e.props??{},disabled:!!e.disabled,start:e.value?.start??null,end:e.value?.end??null}));return i.listen(t.el,"change",s=>s.stopImmediatePropagation()),t.on("change",s=>i.emit("change",{value:{start:s.detail.start,end:s.detail.end}})),{el:t.el,get:()=>t.get(),set:s=>t.set(s,{silent:!0}),focus:()=>t.focus(),setDisabled:s=>s?t.disable():t.enable()}})}var Ie=class extends S{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 e=this.el??c("div");this.el=e,this._originalState=e.getAttribute("data-state"),this._originalAriaDisabled=e.getAttribute("aria-disabled"),this._originalClearable=e.getAttribute("data-clearable"),e.toggleAttribute("data-clearable",!!this.options.clearable),this._format=Jc(this.options.format,this.options.time),this._disabled=!!this.options.disabled,this._open=!1,this._position=null,this._min=Ur(this.options.min),this._max=Ur(this.options.max),this._value=this._normalizeValue(this.options.value);let t=E("zx-datebox-popover"),s=c("div",{class:"zx-datebox__content"},c("div",{ref:"control",class:"zx-datebox__control"},c("input",{ref:"input",class:"zx-datebox__input",type:"text",autocomplete:"off",placeholder:this.options.placeholder??eu(this._format),"aria-haspopup":"grid",ariaControls:t,ariaExpanded:"false"}),c("button",{ref:"clear",class:"zx-icon-btn zx-datebox__clear",type:"button",ariaLabel:"Clear date"},v("x",{size:13})),c("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:"Choose date","aria-haspopup":"grid",ariaControls:t,ariaExpanded:"false"},v("calendar"))),c("div",{ref:"popover",id:t,class:"zx-datebox__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=s,e.append(s),this._picker=new $e(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&&!e.contains(n.target)&&this.close()}),this._syncDisplay(),this._syncDisabled(),e}get(e="date"){return this._value?e==="seconds"?Math.floor(this._value.getTime()/1e3):new Date(this._value.getTime()):null}set(e,{silent:t=!1}={}){return this._value=this._normalizeValue(e),this._picker?.set(this._value,{silent:!0}),this._setValid(),this._syncDisplay(),t||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=Z(this.refs.control,this.refs.popover,{placement:"bottom-start",flip:!0}),this._picker.focus(),this.emit("open"),this)}close(){return this._close(!1),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this.close(),this._syncDisabled(),this}focus(){return this.refs.input.focus(),this}destroy(){this._position?.destroy(),this._position=null,this._open=!1,this._picker?.destroy(),this._picker=null,this._content?.remove(),this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState),this._originalAriaDisabled===null?this.el.removeAttribute("aria-disabled"):this.el.setAttribute("aria-disabled",this._originalAriaDisabled),this._originalClearable===null?this.el.removeAttribute("data-clearable"):this.el.setAttribute("data-clearable",this._originalClearable),super.destroy()}_onInputKeydown(e){e.key==="ArrowDown"?(e.preventDefault(),this.open()):e.key==="Enter"?(e.preventDefault(),this._commitText()):e.key==="Escape"&&this._open&&(e.preventDefault(),this._close(!0))}_commitText(){if(this._disabled)return;let e=this.refs.input.value.trim();if(e===""){this.set(null);return}let t=oe(e,this._format);if(!t){this.el.dataset.state="invalid",this.refs.input.setAttribute("aria-invalid","true"),this.emit("invalid",{text:e});return}this.set(t)}_normalizeValue(e){let t=null;return e instanceof Date&&!Number.isNaN(e.getTime())?t=new Date(e.getTime()):typeof e=="number"&&Number.isFinite(e)?t=new Date(e*1e3):typeof e=="string"&&(t=oe(e,this._format)),!t||Number.isNaN(t.getTime())?null:_r(t,this._min,this._max)}_syncDisplay(){this.refs.input.value=this._value?I(this._value,this._format):"",this._syncClear()}_syncClear(){this.refs.clear.hidden=!this.options.clearable||!this._value||this._disabled}_syncDisabled(){this.refs.input.disabled=this._disabled,this.refs.toggle.disabled=this._disabled,this.refs.clear.disabled=this._disabled,this.el.setAttribute("aria-disabled",String(this._disabled)),this._syncClear()}_setValid(){this.el.dataset.state==="invalid"&&(this._originalState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._originalState)),this.refs.input.removeAttribute("aria-invalid")}_close(e){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"),e&&this.focus(),this.emit("close"))}_copyValue(){return this._value?new Date(this._value.getTime()):null}},Yr=function(e,t={}){return new Ie(e,{...t,time:!0})};function Ur(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function Jc(i,e){let t=String(i||"%d.%m.%Y");return e&&!/%[HM]/.test(t)?`${t} %H:%M`:t}function eu(i){return i.replace(/%[demYyHMS]/g,e=>({"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY","%H":"HH","%M":"MM","%S":"SS"})[e]??e)}function Zr(){Wr("date",i=>new Ie(null,i)),Wr("datetime",i=>Yr(null,i))}function Wr(i,e){z.register(i,(t,s)=>{let n=t.own(e({...s.props??{},value:s.value}));return t.listen(n.el,"change",r=>r.stopImmediatePropagation()),n.on("change",r=>t.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 ai=class extends S{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 e=this.el??c("div");this.el=e,this._ownedNodes=[],this._files=[],this._disabled=!1,this._running=!1,this._runId=0,this._xhr=null,this._transportController=null,this._previewUrl=null,this._initialState=e.getAttribute("data-state"),this._initialDisabled=e.getAttribute("data-disabled");let t=E("zx-upload");return this._input=c("input",{class:"zx-field-upload__input",id:t,type:"file",multiple:!!this.options.multiple,accept:this.options.accept??void 0,tabIndex:-1}),this._dropzone=c("button",{class:"zx-field-upload__dropzone",type:"button",ariaControls:t,ariaLabel:this.options.multiple?"Choose files or drop them here":"Choose a file or drop it here"},c("span",{class:"zx-field-upload__prompt"},this.options.multiple?"Drop files here or choose files":"Drop a file here or choose a file"),c("span",{class:"zx-field-upload__hint"},tu(this.options))),this._preview=c("div",{class:"zx-field-upload__preview"}),this._progress=c("progress",{class:"zx-field-upload__progress",max:100,value:0,ariaLabel:"Upload progress"}),this._progressText=c("span",{class:"zx-field-upload__progress-text"},"0%"),this._abort=c("button",{class:"zx-btn zx-field-upload__abort",type:"button"},"Abort"),this._progressWrap=c("div",{class:"zx-field-upload__progress-wrap",hidden:!0},this._progress,this._progressText,this._abort),this._status=c("div",{class:"zx-field-upload__status",role:"status",ariaLive:"polite"}),this._ownedNodes.push(this._input,this._dropzone,this._preview,this._progressWrap,this._status),e.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),e}async upload(e=null){if(e!==null&&!this._setFiles(e)||this._disabled||this._running||this._files.length===0)return null;this._running=!0,this._runId+=1;let t=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 t!==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(t!==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(e){return this._disabled=!!e,this._input.disabled=this._disabled,this._dropzone.disabled=this._disabled,this.el.dataset.disabled=String(this._disabled),this}_selectFiles(e){this._setFiles(e)&&(this._input.value="",this.options.autoUpload&&this.upload())}_setFiles(e){if(this._disabled||this._running)return!1;let t=Array.from(e??[]),s=this.options.multiple?t:t.slice(0,1);if(s.length===0)return!1;let n=s.find(o=>!su(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(e){e.preventDefault(),!this._disabled&&!this._running&&this._setState("dragover")}_uploadInjected(){let e=this.options.http;this._transportController=new AbortController;let t={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 e.upload=="function"?e.upload(String(this.options.url),t):typeof e.request=="function"?e.request(String(this.options.url),{method:"POST",data:t.params,files:t.files,headers:t.headers,signal:t.signal,onProgress:t.onProgress,paramName:t.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((e,t)=>{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){t(new Error(`Upload failed with HTTP ${s.status}`));return}e(ru(s.responseText))}),this.listen(s,"error",()=>t(new Error("Upload request failed"))),this.listen(s,"abort",()=>t(ou())),s.send(nu(this._files,String(this.options.paramName),this.options.params))})}_setProgress(e){let t=Math.max(0,Math.min(100,Number(e)||0));this._progress.value=t,this._progressText.textContent=`${Math.round(t)}%`,this.emit("progress",{percent:t})}_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(e){this._setState("error"),this._status.textContent=e.message,this.emit("error",{error:e})}_renderPreview(){this._revokePreview(),this._preview.replaceChildren();let e=this._files[0];!this.options.preview||!e?.type?.startsWith("image/")||typeof URL>"u"||typeof URL.createObjectURL!="function"||(this._previewUrl=URL.createObjectURL(e),this._preview.append(c("img",{class:"zx-field-upload__image",src:this._previewUrl,alt:`Preview of ${e.name}`})))}_revokePreview(){this._previewUrl&&typeof URL<"u"&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(this._previewUrl),this._previewUrl=null}_setState(e){e==="idle"?this.el.removeAttribute("data-state"):this.el.dataset.state=e}destroy(){this._running&&this.abort(),this._revokePreview();for(let e of this._ownedNodes??[])e.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 tu(i){let e=[];return i.accept&&e.push(String(i.accept)),i.maxSize!=null&&e.push(`up to ${iu(Number(i.maxSize))}`),e.join(" \xB7 ")||"Choose from this device"}function iu(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/1024)} KB`:`${Math.round(i/(1024*1024))} MB`}function su(i,e){if(!e)return!0;let t=String(i.type??"").toLowerCase();return String(e).split(",").map(s=>s.trim().toLowerCase()).filter(Boolean).some(s=>s.startsWith(".")?i.name.toLowerCase().endsWith(s):s.endsWith("/*")?t.startsWith(s.slice(0,-1)):t===s)}function nu(i,e,t){let s=new FormData;for(let n of i)s.append(e,n);for(let[n,r]of Object.entries(t??{}))Gr(s,n,r);return s}function Gr(i,e,t){if(t==null)return;if(Array.isArray(t)){for(let n of t)Gr(i,e,n);return}typeof Blob=="function"&&t instanceof Blob?i.append(e,t):i.append(e,typeof t=="object"?JSON.stringify(t):String(t))}function ru(i){if(!i)return null;try{return JSON.parse(i)}catch{return i}}function ou(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let i=new Error("Upload aborted");return i.name="AbortError",i}function Qr(){z.register("upload",(i,e)=>{let t=i.own(new ai(null,{...e.props??{}}));return i.listen(t.el,"change",s=>s.stopImmediatePropagation()),t.on("select",()=>i.emit("change",{value:null})),{el:t.el,get:()=>null,set:()=>t.clear(),focus:()=>t.el.querySelector(".zx-field-upload__dropzone")?.focus(),setDisabled:s=>t.setDisabled(s)}})}var Xr=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),Jr=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),li=class extends S{static cssName="multi-value-editor";static defaults={values:[],options:null,addLabel:"Add value",reorder:"both"};render(){let e=this.el??c("div");return this.el=e,this._values=Array.isArray(this.options.values)?this.options.values.map(String):[],this._ownedNodes=[],this._initialState=e.getAttribute("data-state"),this._dragIndex=-1,this._armed=null,this._rows=c("div",{class:"zx-multi-value-editor__rows"}),this._add=c("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),e.append(this._rows,this._add),this.listen(e,"click",t=>this._handleClick(t)),this.listen(this._rows,"change",t=>this._handleChange(t)),this.listen(this._rows,"keydown",t=>this._handleKeydown(t)),this._reorder().drag&&(this.listen(this._rows,"pointerdown",t=>this._handlePointerDown(t)),this.listen(this._rows,"dragstart",t=>this._handleDragStart(t)),this.listen(this._rows,"dragover",t=>this._handleDragOver(t)),this.listen(this._rows,"dragleave",t=>this._handleDragLeave(t)),this.listen(this._rows,"drop",t=>this._handleDrop(t)),this.listen(this._rows,"dragend",()=>this._finishDrag()),this.listen(document,"pointerup",()=>this._disarm()),this.listen(document,"pointercancel",()=>this._disarm())),this._renderRows(),e}getValues(){return this._values.slice()}setValues(e,{silent:t=!1}={}){return this._values=Array.isArray(e)?e.map(String):[],this._renderRows(),t||this.emit("change",{values:this.getValues()}),this}_reorder(){return Xr[this.options.reorder]??Xr.both}_renderRows(e=-1,t="value"){let s=eo(this.options.options),n=this.options.options!==null,{drag:r,buttons:o}=this._reorder(),a=this._values.length-1,l=this._values.map((u,d)=>{let h=!n||s.some(([f])=>f===u)?s:[[u,u],...s],p=n?c("select",{class:"zx-multi-value-editor__value",ariaLabel:`Value ${d+1}`,dataset:{index:d}},h.map(([f,_])=>c("option",{value:f,selected:f===u},_))):c("input",{class:"zx-multi-value-editor__value",type:"text",value:u,ariaLabel:`Value ${d+1}`,dataset:{index:d}});return c("div",{class:"zx-multi-value-editor__row",dataset:{row:d}},r?c("button",{class:"zx-multi-value-editor__handle",type:"button",ariaLabel:`Reorder value ${d+1}. Use the arrow keys to move it.`,dataset:{action:"grab",index:d}},v("drag",{size:12})):null,p,c("div",{class:"zx-multi-value-editor__controls"},o?c("button",{class:"zx-btn",type:"button",ariaDisabled:String(d===0),ariaLabel:`Move value ${d+1} up`,dataset:{action:"up",index:d}},v("chevron-up",{size:12})):null,o?c("button",{class:"zx-btn",type:"button",ariaDisabled:String(d===a),ariaLabel:`Move value ${d+1} down`,dataset:{action:"down",index:d}},v("chevron-down",{size:12})):null,c("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${d+1}`,dataset:{action:"remove",index:d}},v("x",{size:12}))))});this._rows.replaceChildren(...l),e>=0&&l[Math.min(e,l.length-1)]?.querySelector(Jr[t]??Jr.value)?.focus()}_handleClick(e){let t=e.target instanceof Element?e.target.closest("[data-action]"):null;if(!t||!this.el.contains(t)||t.getAttribute("aria-disabled")==="true")return;let s=t.dataset.action,n=Number(t.dataset.index);if(s==="add"){let r=eo(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(e){let t=e.target instanceof Element?e.target.closest("[data-index]"):null;if(!t||!("value"in t))return;let s=Number(t.dataset.index);!Number.isInteger(s)||s<0||s>=this._values.length||(this._values[s]=t.value,this._emitChange())}_handleKeydown(e){let t=e.target instanceof Element?e.target.closest(".zx-multi-value-editor__handle"):null;if(!t)return;let s=Number(t.dataset.index),n=e.key==="ArrowUp"?s-1:e.key==="ArrowDown"?s+1:e.key==="Home"?0:e.key==="End"?this._values.length-1:-1;n<0||n>=this._values.length||(e.preventDefault(),this._move(s,n,"handle"))}_handlePointerDown(e){let t=e.target instanceof Element?e.target.closest(".zx-multi-value-editor__handle"):null;if(this._disarm(),!t||t.disabled)return;let s=t.closest(".zx-multi-value-editor__row");s&&(s.draggable=!0,this._armed=s)}_disarm(){this._armed&&(this._armed.draggable=!1),this._armed=null}_handleDragStart(e){let t=e.target instanceof Element?e.target.closest(".zx-multi-value-editor__row"):null;if(!t||t!==this._armed){e.preventDefault();return}this._dragIndex=Number(t.dataset.row),t.dataset.dragging="true",this.el.setAttribute("data-state","dragging"),e.dataTransfer?.setData("text/plain",String(this._dragIndex)),e.dataTransfer&&(e.dataTransfer.effectAllowed="move")}_handleDragOver(e){this._dragIndex<0||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move"),this._showDrop(this._dropTarget(e.clientY)))}_handleDragLeave(e){let t=e.relatedTarget;t instanceof Node&&this._rows.contains(t)||this._clearDrop()}_handleDrop(e){if(this._dragIndex<0)return;e.preventDefault();let t=this._dragIndex,s=this._dropTarget(e.clientY);this._finishDrag(),this._move(t,s>t?s-1:s,"handle")}_finishDrag(){this._dragIndex=-1,this._disarm(),this._clearDrop();for(let e of this._rows.children)delete e.dataset.dragging;this._initialState===null?this.el.removeAttribute("data-state"):this.el.setAttribute("data-state",this._initialState)}_dropTarget(e){let t=[...this._rows.children];for(let[s,n]of t.entries()){let r=n.getBoundingClientRect();if(e<r.top+r.height/2)return s}return t.length}_showDrop(e){let t=[...this._rows.children],s=e===this._dragIndex||e===this._dragIndex+1;for(let[n,r]of t.entries()){let o=r;!s&&n===e?o.dataset.drop="before":!s&&e===t.length&&n===t.length-1?o.dataset.drop="after":delete o.dataset.drop}}_clearDrop(){for(let e of this._rows.children)delete e.dataset.drop}_move(e,t,s){let n=this._values.length;if(e===t||e<0||t<0||e>=n||t>=n)return!1;let[r]=this._values.splice(e,1);return this._values.splice(t,0,r),this._renderRows(t,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 e of this._ownedNodes??[])e.remove();super.destroy()}};function eo(i){return Array.isArray(i)?i.map(e=>[String(e),String(e)]):i&&typeof i=="object"?Object.entries(i).map(([e,t])=>[e,String(t)]):[]}function to(){z.register("multivalueeditor",(i,e)=>{let t=i.own(new li(null,{...e.props??{},values:Array.isArray(e.value)?e.value:[]})),s=new WeakMap,n=!1,r=()=>{t.el.setAttribute("aria-disabled",String(n));for(let o of t.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(t.el,"change",o=>o.stopImmediatePropagation()),t.on("change",o=>i.emit("change",{value:o.detail.values})),{el:t.el,get:()=>t.getValues(),set:o=>{t.setValues(Array.isArray(o)?o:[],{silent:!0}),r()},focus:()=>t.el.querySelector(".zx-multi-value-editor__value:not([disabled]), button:not([disabled])")?.focus(),setDisabled:o=>{n=!!o,r()}}})}var He=class extends S{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:H(this.el);let e=this.el??c("div");this.el=e;let t=au(this.options.step);this._step=t,this._precision=this.options.precision===null?lu(t):Math.max(0,Math.trunc(Number(this.options.precision)||0));let s=this._stepButton("down","minus"),n=this._stepButton("up","plus"),r=c("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(c("span",{ref:"unit",class:"zx-number-field__unit",ariaHidden:"true"},String(this.options.unit))),o.push(n),e.replaceChildren(...o),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(r,"input",()=>this._onInput()),this.listen(r,"keydown",a=>this._onKeydown(a)),this.listen(r,"focus",()=>{this._editing=!0,this._syncInput()}),this.listen(r,"blur",()=>{this._commit(),this._editing=!1,this._syncInput()}),this.listen(s,"click",()=>this._stepBy(-1)),this.listen(n,"click",()=>this._stepBy(1)),this.listen(r,"wheel",a=>{document.activeElement!==r||this._disabled||this._readonly||(a.preventDefault(),this._stepBy(a.deltaY<0?1:-1))},{passive:!1}),this.set(this.options.value,{silent:!0}),this._syncDisabled(),e}get value(){return this._value}set value(e){this.set(e)}get(){return this._value}set(e,{silent:t=!1}={}){let s=this._coerce(e),n=s!==this._value;return this._value=s,this._syncInput(),n&&!t&&this.emit("change",{value:this._value}),this}stepUp(e=1){return this._stepBy(e)}stepDown(e=1){return this._stepBy(-e)}reset({silent:e=!1}={}){return this.set(this.options.value,{silent:e})}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(e){return this._readonly=!!e,this._syncDisabled(),this}setRange(e,t){return this._min=e==null?null:Number(e),this._max=t==null?null:Number(t),this.set(this._value,{silent:!0})}_stepButton(e,t){return c("button",{ref:e,class:"zx-number-field__step",type:"button",tabIndex:-1,ariaHidden:"true",dataset:{step:e}},v(t,{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(e){let t=ws(e,this.options.group?this._separators():null);return t===null?null:vs(t,{min:this._rangeMin,max:this._rangeMax,step:this._step,precision:this._precision})}_stepBy(e){if(this._disabled||this._readonly)return this;let t=this._rangeMin,s=this._rangeMax,r=ws(this.refs.input.value)??this._value,o=r===null?t??0:r,a=r===null&&e>0&&t!==null?t-this._step*e:o,l=io(a+this._step*e,this._precision);return this.options.wrap&&t!==null&&s!==null&&(l>s?l=t:l<t&&(l=s)),this.set(l),this}_separators(){if(this._localeSeparators)return this._localeSeparators;let e=new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:1}).formatToParts(1234.5);return this._localeSeparators={group:e.find(t=>t.type==="group")?.value??",",decimal:e.find(t=>t.type==="decimal")?.value??"."},this._localeSeparators}_onInput(){let e=ws(this.refs.input.value,this.options.group?this._separators():null);this._syncAria(e),this.emit("input",{value:e})}_onKeydown(e){if(this._disabled||this._readonly||e.altKey||e.ctrlKey||e.metaKey)return;let t=Math.max(1,Math.trunc(Number(this.options.largeStep)||1)),n={ArrowUp:()=>this._stepBy(1),ArrowDown:()=>this._stepBy(-1),PageUp:()=>this._stepBy(t),PageDown:()=>this._stepBy(-t),Home:()=>this._rangeMin===null?null:this.set(this._rangeMin),End:()=>this._rangeMax===null?null:this.set(this._rangeMax),Enter:()=>this._commit()}[e.key];n&&(e.key==="Home"&&this._rangeMin===null||e.key==="End"&&this._rangeMax===null||(e.preventDefault(),n()))}_commit(){this.set(this.refs.input.value)}_syncInput(){let e=this.refs.input,t=this._value===null?"":this._format(this._value,this._editing);e.value!==t&&(e.value=t),this._syncAria(this._value)}_syncAria(e){let t=this.refs.input,s=this._rangeMin,n=this._rangeMax;if(s===null?t.removeAttribute("aria-valuemin"):t.setAttribute("aria-valuemin",String(s)),n===null?t.removeAttribute("aria-valuemax"):t.setAttribute("aria-valuemax",String(n)),e===null)t.removeAttribute("aria-valuenow"),t.setAttribute("aria-valuetext",this._message("numberField.empty","Empty"));else{t.setAttribute("aria-valuenow",String(e));let r=this.options.unit===null?"":` ${this.options.unit}`;t.setAttribute("aria-valuetext",`${this._format(e,!1)}${r}`)}this.el.toggleAttribute("data-empty",e===null)}_format(e,t){return this.options.group?new Intl.NumberFormat(this.options.locale??void 0,{minimumFractionDigits:this._precision,maximumFractionDigits:this._precision,useGrouping:!t}).format(e):e.toFixed(this._precision)}_message(e,t){let s=this.msg(e);return s===e?t:s}_syncDisabled(){let e=this.refs.input;e.disabled=this._disabled,e.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 e=this.el;super.destroy(),!this._createdRoot&&e&&K(e,this._snapshot)}};function ws(i,e=null){if(typeof i=="number")return Number.isFinite(i)?i:null;if(i==null)return null;let t=String(i).trim();if(t==="")return null;let s;if(e)s=t.split(e.group).join("").replace(e.decimal,".").replace(/[^\d.\-+eE]/g,"");else{let r=t.replace(/[^\d,.\-+eE]/g,""),o=r.lastIndexOf(","),a=r.lastIndexOf(".");s=r,o>=0&&o>a?s=r.replace(/\./g,"").replace(",","."):o>=0&&(s=r.replace(/,/g,""))}if(!/\d/.test(s))return null;let n=Number(s);return Number.isFinite(n)?n:null}function vs(i,{min:e,max:t,step:s,precision:n}){let r=i;if(s>0){let o=e??0;r=o+Math.round((i-o)/s)*s}return r=io(r,n),e!==null&&r<e?e:t!==null&&r>t?t:r}function au(i){let e=Number(i);return Number.isFinite(e)&&e>0?e:1}function lu(i){let e=String(i),t=e.match(/e-(\d+)/i);if(t)return Number(t[1]);let s=e.split(".")[1];return s?s.length:0}function io(i,e){return Number.isFinite(i)?Number(i.toFixed(Math.min(15,Math.max(0,e)))):i}function so(){z.register("number",(i,e)=>{let t=i.own(new He(null,{label:e.label?String(e.label):void 0,placeholder:e.placeholder,required:e.required,name:i.name||null,...e.props??{}})),s=!1;return i.listen(t.el,"change",n=>n.stopImmediatePropagation()),t.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:t.el,get:()=>t.get(),set:n=>{s=!0;try{t.set(n===""||n===null||n===void 0?null:n,{silent:!0})}finally{s=!1}},focus:()=>t.focus(),setDisabled:n=>n?t.disable():t.enable(),setReadonly:n=>{t.setReadonly(n)}}})}var ci=class extends S{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:H(this.el);let e=this.el??c("div");this.el=e,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=E("zx-rating");let t=c("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=c("span",{class:"zx-rating__symbol"},c("span",{class:"zx-rating__glyph",ariaHidden:"true"},v(this.options.icon,{size:_t[this.options.size]??_t.md})),c("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},v(this.options.icon,{size:_t[this.options.size]??_t.md})));this.options.allowHalf?n.append(this._radio(s-.5,"half"),this._radio(s,"full")):n.append(this._radio(s,"full")),t.append(n)}return e.replaceChildren(t,c("span",{ref:"readout",class:"zx-rating__readout"})),e.dataset.size=_t[this.options.size]?this.options.size:"md",this.listen(t,"keydown",s=>this._onKeydown(s)),this.listen(t,"pointerleave",()=>this._setPreview(null)),this.set(this.options.value,{silent:!0}),this._syncDisabled(),e}get value(){return this._value}set value(e){this.set(e)}get(){return this._value}set(e,{silent:t=!1}={}){let s=this._clamp(e),n=s!==this._value;return this._value=s,this._preview=null,this._sync(),n&&!t&&this.emit("change",{value:this._value}),this}clear({silent:e=!1}={}){return this.set(0,{silent:e})}reset({silent:e=!1}={}){return this.set(this.options.value,{silent:e})}setCount(e){return this._count=e,this._syncReadout(),this}focus(){return(this._radios.find(t=>t.tabIndex===0)??this._radios[0])?.focus(),this}enable(){return this._disabled=!1,this._syncDisabled(),this}disable(){return this._disabled=!0,this._syncDisabled(),this}setReadonly(e){return this._readonly=!!e,this._syncDisabled(),this}_radio(e,t){let s=c("button",{class:"zx-rating__radio",type:"button",role:"radio",tabIndex:-1,ariaChecked:"false",ariaLabel:this._stepLabel(e),dataset:{value:String(e),part:t}});return this.listen(s,"click",n=>{this._choose(e,n.detail>0)}),this.listen(s,"pointerenter",()=>this._setPreview(e)),this.listen(s,"focus",()=>this._setPreview(e)),this.listen(s,"blur",()=>this._setPreview(null)),this._radios.push(s),s}_stepLabel(e){let t=this.options.labels;if(Array.isArray(t)){let s=Math.round(e/this._step)-1;if(t[s]!=null)return String(t[s])}return this._message("rating.value","%1 of %2",[e,this._max])}_message(e,t,s){let n=this.msg(e,...s);return n===e?O(t,s):n}_choose(e,t){this._disabled||this._readonly||(t&&this.options.clearable&&e===this._value?this.set(0):this.set(e))}_onKeydown(e){if(this._disabled||this._readonly)return;let t=["ArrowRight","ArrowDown"],s=["ArrowLeft","ArrowUp"];if(t.includes(e.key))e.preventDefault(),this.set(this._value>=this._max?this._step:(this._value||0)+this._step);else if(s.includes(e.key))e.preventDefault(),this.set(this._value<=this._step?this._max:this._value-this._step);else if(e.key==="Home")e.preventDefault(),this.set(this._step);else if(e.key==="End")e.preventDefault(),this.set(this._max);else if((e.key==="Delete"||e.key==="Backspace")&&this.options.clearable)e.preventDefault(),this.set(0);else return;this.focus()}_setPreview(e){let t=this._disabled||this._readonly?null:e;t!==this._preview&&(this._preview=t,this._paint(),this.emit("hover",{value:this._preview}))}_clamp(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return 0;let s=Math.round(t/this._step)*this._step;return Math.min(this._max,Math.max(0,s))}_sync(){for(let t of this._radios){let s=Number(t.dataset.value);t.setAttribute("aria-checked",String(s===this._value))}let e=this._radios.find(t=>t.getAttribute("aria-checked")==="true");for(let t of this._radios)t.tabIndex=-1;(e??this._radios[0]).tabIndex=0,this._paint(),this._syncReadout()}_paint(){let e=this._preview??this._value;this.refs.symbols.querySelectorAll(".zx-rating__symbol").forEach((s,n)=>{let r=Math.min(1,Math.max(0,e-n));s.style.setProperty("--zx-rating-fill",`${r*100}%`),s.toggleAttribute("data-preview",this._preview!==null)}),this.el.dataset.value=String(e)}_syncReadout(){let e=this.refs.readout;if(!e)return;let t=this._count===void 0?this.options.count:this._count,s=[];this.options.showValue&&s.push(cu(this._value,this._step)),t!=null&&s.push(this._message("rating.count","%1 ratings",[t])),e.textContent=s.join(" \xB7 ")}_syncDisabled(){let e=this._disabled||this._readonly;for(let t of this._radios)t.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",e),this._disabled?this.el.setAttribute("aria-disabled","true"):this.el.removeAttribute("aria-disabled")}destroy(){let e=this.el;super.destroy(),!this._createdRoot&&e&&K(e,this._snapshot)}},_t={sm:14,md:18,lg:24};function cu(i,e){return e<1?i.toFixed(1):String(i)}function no(){z.register("rating",(i,e)=>{let t=i.own(new ci(null,{label:e.label?String(e.label):void 0,...e.props??{}})),s=!1;return t.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),{el:t.el,get:()=>t.get()||null,set:n=>{s=!0;try{t.set(Number(n)||0,{silent:!0})}finally{s=!1}},focus:()=>t.focus(),setDisabled:n=>n?t.disable():t.enable(),setReadonly:n=>{t.setReadonly(n)}}})}var a_=["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 ro(i,e){let t="",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),t+=o.toLocaleLowerCase(),t.split("").every(u=>u===t[0])&&(t=t[0]),s=setTimeout(()=>{t="",s=null},500);let a=i(),l=a.findIndex(u=>uu(u).startsWith(t));l>=0&&e(a[l],l)}}function uu(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 e=i,t=e.label??e.text??e.value;if(t!=null)return String(t).trim().toLocaleLowerCase()}return String(i??"").trim().toLocaleLowerCase()}var du=/^var\(\s*--[\w-]+\s*\)$/;function ui(i){if(typeof i!="string")return null;let e=i.trim();return du.test(e)||we(e)?e:null}var Ss=Object.freeze(["dotted","ring","progress","review","ready","waiting","done","canceled","duplicate"]),As=Object.freeze(["muted","neutral","warning","info","accent","success","danger"]),ks=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"]]),hu=Object.freeze({review:"in-review",cancelled:"canceled"}),xs=4;function fu(i,e={}){let t=i&&typeof i=="object"?i:null,s=pu(t?t.ID??t.id:i),n=ks.find(([a])=>a===s),r=String(e.indicator??t?.indicator??n?.[3]??"ring"),o=String(e.tone??t?.tone??n?.[4]??"muted");return{indicator:Ss.includes(r)?r:"ring",tone:As.includes(o)?o:"muted"}}function pu(i){let e=String(i??"").trim().toLowerCase();return hu[e]??e}function zs(i){return i==null||i===""?null:Math.max(0,Math.min(xs,Math.trunc(Number(i)||0)))}function oo(i,e={}){let{indicator:t,tone:s}=fu(i,e??{}),n=c("span",{class:"zx-status-icon",dataset:{indicator:t,tone:s}});return t==="done"&&n.append(v("check",{size:8})),t==="canceled"&&n.append(v("x",{size:7})),lo(n,e?.label)}function ao(i,e={}){let t=zs(i),s=c("span",{class:"zx-priority-icon",dataset:{level:t===null?"none":t}},t===xs?null:Array.from({length:xs},(n,r)=>c("span",{dataset:{filled:String(t!==null&&r<=t)}})));return lo(s,e?.label)}function lo(i,e){let t=e==null?"":String(e).trim();return t?(i.setAttribute("role","img"),i.setAttribute("aria-label",t)):i.setAttribute("aria-hidden","true"),i}var mu=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],co=["Lowest","Low","Medium","High","Highest"],q=class i extends S{static cssName="select";static defaults={items:[],fixedItems:[],fixedLabel:null,valueKey:"ID",labelKey:"name",renderItem:null,renderValue:null,renderValueAdornment:null,renderNone:null,noneLabel:null,actions:[],value:null,disabled:!1,placeholder:"",label:"",clearable:!1,filter:!1,searchKeys:null,minQuery:0,debounce:200,listHeight:280,groupKey:null};render(){this._items=[],this._visibleItems=[],this._fixedItems=[],this._visibleFixed=[],this._actions=[],this._selected=null,this._optionEntries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._createdRoot=!1,this._root=null,this._snapshot=null,this._pointerModality=!1,this._createdRoot=this.el===null;let e=this.el??c("div");this.el=e,this._root=e,this._snapshot=this._createdRoot?null:H(e);let t=E("zx-select-list"),s=c("input",{ref:"input",class:"zx-select__input",type:"text",role:"combobox",ariaLabel:String(this.options.label||this.options.placeholder||"Select"),autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:t,ariaAutocomplete:this.options.filter?"list":"none",placeholder:String(this.options.placeholder??""),readOnly:!this.options.filter}),n=c("span",{ref:"valueAdornment",class:"zx-select__value-adornment",ariaHidden:"true",hidden:!0}),r=c("button",{ref:"clear",class:"zx-icon-btn zx-select__clear",type:"button",tabIndex:-1,ariaLabel:this._message("select.clear","Clear selection"),hidden:!0},v("x",{size:13})),o=c("span",{ref:"loading",class:"zx-select__loading",role:"status",ariaLabel:this._message("select.loading","Loading"),hidden:!0}),a=c("button",{ref:"toggle",class:"zx-select__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("select.toggle","Toggle options")},v("chevron-down",{size:16})),l=c("div",{ref:"control",class:"zx-select__control"},n,s,r,o,a),u=c("div",{ref:"list",class:"zx-select__list",id:t,role:"listbox"});u.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let d=c("div",{ref:"panel",class:"zx-select__panel",popover:"manual"},u);return e.replaceChildren(l,d),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visibleItems=this._items.slice(),this._fixedItems=Array.isArray(this.options.fixedItems)?this.options.fixedItems.slice():[],this._visibleFixed=this._fixedItems.slice(),this._actions=uo(this.options.actions),this._disabled=!!this.options.disabled,this._handleTypeahead=ro(()=>this._optionEntries.filter(h=>!h.clear&&!h.action).map(h=>h.element),(h,p)=>{this._open||this.open(),this._setActive(this._itemEntryIndex(p))}),this.listen(s,"click",()=>this.open()),this.listen(s,"input",()=>this._onInput()),this.listen(s,"keydown",h=>{fo(h)||e.removeAttribute("data-focus-origin"),this._onKeydown(h)}),this.listen(s,"focus",()=>{this._pointerModality&&s.readOnly?e.setAttribute("data-focus-origin","pointer"):e.removeAttribute("data-focus-origin")}),this.listen(s,"blur",()=>e.removeAttribute("data-focus-origin")),this.listen(document,"keydown",h=>{fo(h)||(this._pointerModality=!1)},{capture:!0}),this.listen(a,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(r,"click",()=>{this.set(null),this.focus()}),this.listen(d,"pointerdown",h=>h.preventDefault()),this.listen(d,"click",h=>this._onOptionClick(h)),this.listen(document,"pointerdown",h=>{this._pointerModality=!0,this._open&&!e.contains(h.target)&&this.close()},{capture:!0}),this._renderOptions(),this.set(this.options.value,{silent:!0}),this._syncDisabled(),e}get value(){return this._selected===null?null:this._itemValue(this._selected)}set value(e){this.set(e)}get(){return this.value}get selected(){return this._selected}set(e,{silent:t=!1}={}){let s=this.value,n=e==null?null:this._findItem(e);this._selected=n,this._syncInputValue(),this._renderOptions();let r=this.value;return!t&&!Object.is(s,r)&&this.emit("change",{value:r,item:n}),this}setItems(e){let t=this.value;return this._items=Array.isArray(e)?e.slice():[],this._visibleItems=this._items.slice(),this._selected=t==null?null:this._findItem(t),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setFixedItems(e){let t=this.value;return this._fixedItems=Array.isArray(e)?e.slice():[],this._visibleFixed=this._fixedItems.slice(),this._selected=t==null?null:this._findItem(t),this._syncInputValue(),this._renderOptions(),this._position?.update(),this}setActions(e){return this._actions=uo(e),this._renderOptions(),this._position?.update(),this}reset({silent:e=!1}={}){return this.set(this.options.value,{silent:e}),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=Z(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(e,t={}){let s=t.value??null,n=t.clearable??!0,r=null,o=()=>t.noneLabel??(r?r._message("priority.none","No priority"):"No priority");r=new i(e,{...t,clearable:n,value:null,items:[],renderItem(l){return ho(l,!0)},renderNone:t.renderNone??(()=>ho({level:null,name:o()},!0)),renderValueAdornment(l){return mo(l.level)}}),n&&!t.placeholder&&(r.refs.input.placeholder=o());let a=r;return r.setItems(mu.map((l,u)=>{let d=u===2?a.msg("priority.medium"):l;return(d==="priority.medium"||u!==2)&&(d=a._message(l,co[u])),{ID:u,name:d,level:u}})),r.set(s,{silent:!0}),r}static status(e,t={}){let{items:s=null,value:n=null,...r}=t,o=new i(e,{...r,value:null,items:[],renderItem(l){return yu(l)},renderValueAdornment(l){return _o(l)}}),a=Array.isArray(s)?s.map(bu).filter(Boolean):ks.map(([l,u,d,h,p],f)=>({ID:l,name:o._message(u,d),indicator:h,tone:p,shortcut:String(f+1)}));return o.setItems(a),o.set(n,{silent:!0}),o}static entity(e,t={}){let{recent:s=[],recentLabel:n="Recent",create:r=!1,iconKey:o="icon",colorKey:a="color",subtitleKey:l="description",renderIcon:u=null,fixedItems:d=[],actions:h=[],renderItem:p=null,renderValueAdornment:f=null,..._}=t,m=(y,A=!1)=>{if(typeof u=="function")return u(y,{selected:A});let w=di(y,o);if(w&&typeof w=="object"&&typeof w.nodeType=="number")return w.cloneNode(!0);if(typeof w!="string"||!w)return null;let x=ui(di(y,a));return c("span",{class:"zx-select__entity-glyph",style:x?{"--zx-select-entity-color":x}:null,ariaHidden:"true"},v(w,{size:14}))},g=r?_u(r):null,b=new i(e,{..._,fixedItems:[...Array.isArray(s)?s:[],...Array.isArray(d)?d:[]],fixedLabel:Array.isArray(s)&&s.length?n:_.fixedLabel??null,actions:[...Array.isArray(h)?h:[],...g?[g]:[]],renderItem:p??(y=>{let A=m(y,!1),w=di(y,l),x=c("span",{class:"zx-select__entity-copy"},c("span",{class:"zx-select__entity-label"},String(di(y,_.labelKey??"name")??"")),w==null||w===""?null:c("span",{class:"zx-select__entity-subtitle"},String(w)));return c("span",{class:"zx-select__entity"},A?c("span",{class:"zx-select__entity-icon",ariaHidden:"true"},A):null,x)}),renderValueAdornment:f??(y=>m(y,!0))});return b.el.dataset.preset="entity",b}static permission(e,t={}){let{groups:s=[],value:n=!0,valueKey:r="ID",labelKey:o="name",filter:a="local",...l}=t,u=typeof s=="function"?s:null,d=u?[]:s,h=[{ID:!1,name:"Private"},{ID:!0,name:"Public"}],p=new i(e,{filter:u??a,...l,value:null,items:d,fixedItems:[],valueKey:f=>h.includes(f)?f.ID:Ds(f,r),labelKey:f=>h.includes(f)?f.name:String(Ds(f,o)??"")});return h[0].name=p._message("permission.private","Private"),h[1].name=p._message("permission.public","Public"),p.setFixedItems(h),p.set(n,{silent:!0}),p}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let e=this.el;!this._createdRoot&&e&&K(e,this._snapshot),super.destroy()}_onKeydown(e){if(!this._disabled){if(this._open&&po(e)){let t=this._optionEntries.findIndex(s=>!s.clear&&!s.action&&String(s.item?.shortcut??"")===e.key);if(t>=0){e.preventDefault(),this._setActive(t),this._chooseEntry(this._optionEntries[t]);return}}if(e.key==="ArrowDown"){e.preventDefault(),this._open?this._moveActive(1):this.open();return}if(e.key==="ArrowUp"){e.preventDefault(),this._open?this._moveActive(-1):(this.open(),this._setActive(this._optionEntries.length-1));return}if(e.key==="Home"&&this._open){e.preventDefault(),this._setActive(0);return}if(e.key==="End"&&this._open){e.preventDefault(),this._setActive(this._optionEntries.length-1);return}if(e.key==="Enter"&&this._open){e.preventDefault(),this._chooseEntry(this._optionEntries[this._activeIndex]);return}if(e.key==="Escape"&&this._open){e.preventDefault(),this.close();return}if(e.key==="Tab"&&this._open){this.close();return}!this.options.filter&&po(e)&&this._handleTypeahead(e)}}_onInput(){if(!this.options.filter)return;let e=this.refs.input.value;this._syncValueAdornment(),this._open||this.open(),this.options.filter==="local"?(this._visibleFixed=this._matchFixed(e),this._visibleItems=xe(this._items,e,this._searchKeys()),this._renderOptions(),this._setActive(this._optionEntries.length>0?0:-1),this._position?.update()):typeof this.options.filter=="function"&&this._scheduleAsyncQuery(e)}_onOptionClick(e){let t=e.target?.closest?.('[role="option"]');!t||!this.refs.panel.contains(t)||this._chooseEntry(this._optionEntries[Number(t.getAttribute("data-index"))])}_chooseEntry(e){if(e){if(e.action){let t={id:e.action.id,action:e.action,query:this.refs.input.value,select:this};this.emit("action",t).defaultPrevented||e.action.invoke?.(t),this.close(),this.focus();return}this.set(e.clear?null:e.item),this.close(),this.focus()}}_moveActive(e){let t=this._optionEntries.length;t!==0&&this._setActive((this._activeIndex+e+t)%t)}_setActive(e){this._activeIndex=e>=0&&e<this._optionEntries.length?e:-1,this._optionEntries.forEach((s,n)=>{n===this._activeIndex?s.element.setAttribute("data-active","true"):s.element.removeAttribute("data-active")});let t=this._optionEntries[this._activeIndex]?.element;t?(this.refs.input.setAttribute("aria-activedescendant",t.id),t.scrollIntoView?.({block:"nearest"})):this.refs.input.removeAttribute("aria-activedescendant")}_renderOptions(){let e=this.refs.list;if(!e)return;e.replaceChildren(),this._optionEntries=[];let t=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&&e.append(c("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&&e.append(c("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,t)||(e.append(c("div",{class:"zx-select__group",role:"presentation"},String(o??""))),t=o)}this._appendOption(r,!1)}if(this._actions.length>0){(s.length>0||n.length>0||this.options.clearable)&&e.append(c("div",{class:"zx-select__separator",role:"presentation"}));let r=Symbol("initial-action-group");for(let o of this._actions)o.group&&o.group!==r&&(e.append(c("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&&e.append(c("div",{class:"zx-select__empty",role:"status"},this._message("select.empty","No matches"))),this._setActive(-1)}_appendOption(e,t,s){let n=t?this._selected===null:this._selected!==null&&Object.is(this._itemValue(e),this.value),r=this._optionEntries.length,o=t&&typeof this.options.renderNone=="function"?Cs(this.options.renderNone(String(s??""))):t?String(s??""):this._renderItem(e),a=c("div",{class:"zx-select__option",id:E("zx-select-option"),role:"option",ariaSelected:String(n),dataset:{index:r}},c("span",{class:"zx-select__option-content"},o));n&&a.append(v("check",{size:15})),this.refs.list.append(a),this._optionEntries.push({item:e,clear:t,action:null,element:a})}_appendAction(e){let t=this._optionEntries.length,s=gu(e.icon),n=c("div",{class:"zx-select__option zx-select__action",id:E("zx-select-option"),role:"option",ariaSelected:"false",dataset:{index:t,kind:"action"}},c("span",{class:"zx-select__option-content zx-select__action-content"},s?c("span",{class:"zx-select__action-icon",ariaHidden:"true"},s):null,c("span",{class:"zx-select__action-copy"},c("span",{class:"zx-select__action-label"},e.label),e.description?c("span",{class:"zx-select__action-description"},e.description):null)));this.refs.list.append(n),this._optionEntries.push({item:null,clear:!1,action:e,element:n})}_renderItem(e){if(typeof this.options.renderItem=="function"){let t=this.options.renderItem(e);return Cs(t)}return this._itemLabel(e)}_scheduleAsyncQuery(e){this._queryTimer!==null&&clearTimeout(this._queryTimer),this._requestSequence+=1;let t=this._requestSequence;if(this._visibleFixed=this._matchFixed(e),e.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(e,t)},s)}async _runAsyncQuery(e,t){if(!(t!==this._requestSequence||typeof this.options.filter!="function")){this.emit("query",{query:e});try{let s=await this.options.filter(e);if(t!==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(t!==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(e){this._loading=e,this.refs.loading.hidden=!e,this.refs.input.setAttribute("aria-busy",String(e)),this.refs.list.setAttribute("aria-busy",String(e)),e?this._root?.setAttribute("data-loading","true"):this._root?.removeAttribute("data-loading")}_syncInputValue(){if(!this.refs.input)return;let e=this.refs.input;e.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 e=this.refs.valueAdornment;if(!e)return;let t=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!==t){e.replaceChildren(),e.hidden=!0;return}let n=this.options.renderValueAdornment(this._selected),r=Cs(n);e.replaceChildren(r instanceof Node?r:document.createTextNode(r)),e.hidden=n==null||typeof r=="string"&&r===""}_syncDisabled(){let e=this.refs.input,t=this.refs.clear,s=this.refs.toggle;e.disabled=this._disabled,t.disabled=this._disabled,s.disabled=this._disabled,this._root?.setAttribute("aria-disabled",String(this._disabled))}_findItem(e){let t=this._fixedItems.length===0?this._items:[...this._fixedItems,...this._items],s=t.find(r=>r===e);if(s!==void 0)return s;let n=e!==null&&typeof e=="object"?this._itemValue(e):e;return t.find(r=>Object.is(this._itemValue(r),n))??null}_itemValue(e){return this._read(e,this.options.valueKey)}_itemLabel(e){let t=this._read(e,this.options.labelKey);return String(t??"")}_read(e,t){return Ds(e,t)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(e){return xe(this._fixedItems,e,this._searchKeys())}_uniqueItems(e,t=[]){let s=t.map(n=>this._itemValue(n));return e.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(e=>!e.clear&&Object.is(this._itemValue(e.item),this.value))}_itemEntryIndex(e){return e+(this.options.clearable?1:0)}_message(e,t){let s=this.msg(e);return s===e?t:s}};function di(i,e){return typeof e=="function"?e(i):i!==null&&typeof i=="object"&&typeof e=="string"?i[e]:null}function _u(i){let e=i===!0?{}:i;return{id:e.id??"create",label:e.label??"Create new\u2026",description:e.description,group:e.group??"New",icon:e.icon??"plus",invoke:e.invoke}}function Cs(i){return i&&typeof i=="object"&&"nodeType"in i?i:String(i??"")}function uo(i){return Array.isArray(i)?i.filter(e=>e&&typeof e=="object"&&e.id!=null&&e.label!=null).map(e=>({...e,label:String(e.label),description:e.description==null?void 0:String(e.description),group:e.group==null?void 0:String(e.group)})):[]}function gu(i){return typeof i=="string"?v(i):i instanceof Node?i.cloneNode(!0):null}function ho(i,e){return c("span",{class:"zx-select__priority"},mo(i.level),e?c("span",{},String(i.name)):null)}function mo(i){let e=ao(zs(i));return e.classList.add("zx-select__priority-icon"),e}function bu(i){return!i||typeof i!="object"||i.ID==null||i.name==null?null:{...i,name:String(i.name),indicator:Ss.includes(String(i.indicator))?String(i.indicator):"ring",tone:As.includes(String(i.tone))?String(i.tone):"muted",description:i.description==null?"":String(i.description),shortcut:i.shortcut==null?"":String(i.shortcut)}}function yu(i){return c("span",{class:"zx-select__status"},_o(i),c("span",{class:"zx-select__status-copy"},c("span",{class:"zx-select__status-label"},String(i.name)),i.description?c("span",{class:"zx-select__status-description"},i.description):null),i.shortcut?c("kbd",{class:"zx-select__status-shortcut"},i.shortcut):null)}function _o(i){let e=oo({indicator:i.indicator??"ring",tone:i.tone??"muted"});return e.classList.add("zx-select__status-indicator"),e}function Ds(i,e){return typeof e=="function"?e(i):i===null||typeof i!="object"?i:i[e]}function fo(i){return["Shift","Control","Alt","Meta","CapsLock"].includes(i.key)||i.ctrlKey||i.metaKey}function po(i){return i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey}function go(){z.register("zxselect",(i,e)=>{let t=e.props??{},s=t.preset,n={...t,value:e.value,label:e.label||t.label,placeholder:t.placeholder??e.placeholder};i.listen(i.el,"click",o=>{o.target.closest?.(".zx-field__label")&&i.adapter.focus()}),delete n.preset,s==="priority"&&t.clearable===void 0&&(n.clearable=!e.required);let r=i.own(s==="priority"?q.priority(null,n):s==="status"?q.status(null,n):new q(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 hi=class extends S{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:H(this.el);let e=this.el??c("div");this.el=e,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=E("zx-slider");let t=c("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=c("div",{class:"zx-slider__track"},t,this._marks()),n=c("div",{class:"zx-slider__control"});return this.options.showBounds&&n.append(c("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._min))),n.append(s),this.options.showBounds&&n.append(c("span",{class:"zx-slider__bound",ariaHidden:"true"},this._format(this._max))),this.options.showInput&&n.append(this._numberBox()),e.replaceChildren(c("div",{class:"zx-slider__head"},c("label",{ref:"label",class:"zx-slider__label",for:this._id},String(this.options.label??"")),c("span",{ref:"output",class:"zx-slider__value",ariaHidden:"true"})),n),e.dataset.size=this.options.size==="sm"?"sm":"md",e.toggleAttribute("data-hide-label",!!this.options.hideLabel),this.listen(t,"input",()=>this._onInput()),this.listen(t,"change",()=>this._onCommit()),this.listen(t,"keydown",r=>{this._readonly&&wu.has(r.key)&&r.preventDefault()}),this.set(this.options.value,{silent:!0}),this._syncState(),e}get value(){return this._value}set value(e){this.set(e)}get(){return this._value}set(e,{silent:t=!1}={}){let s=this._snap(e),n=s!==this._value;return this._value=s,this._paint(),n&&!t&&this.emit("change",{value:s}),this}setRange(e,t,s){let n=Number(e),r=Number(t);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)throw new RangeError("Slider range requires min < max");this._min=n,this._max=r,s!==void 0&&(this._step=Math.abs(Number(s))||1);let{input:o}=this.refs;o.min=String(this._min),o.max=String(this._max),o.step=String(this._step);for(let[a,l]of[...this.el.querySelectorAll(".zx-slider__bound")].entries())l.textContent=this._format(a===0?this._min:this._max);return this.set(this._value,{silent:!0})}focus(){return this.refs.input.focus(),this}enable(){return this.refs.input.disabled=!1,this.refs.number&&(this.refs.number.disabled=!1),this._syncState(),this}disable(){return this.refs.input.disabled=!0,this.refs.number&&(this.refs.number.disabled=!0),this._syncState(),this}setReadonly(e){return this._readonly=!!e,this.refs.number&&(this.refs.number.readOnly=this._readonly),this._syncState(),this}setLabel(e){return this.refs.label.textContent=String(e??""),this}_numberBox(){let e=c("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(e,"input",()=>{if(this._readonly)return;let t=Number(e.value);e.value===""||!Number.isFinite(t)||(this._value=this._snap(t),this.refs.input.value=String(this._value),this._paintTrack(),this.emit("input",{value:this._value}))}),this.listen(e,"change",()=>{if(this._readonly){e.value=String(this._value);return}this.set(e.value===""?this._min:Number(e.value))}),e}_marks(){let e=this.options.marks;if(!Array.isArray(e)||e.length===0)return null;let t=c("div",{class:"zx-slider__marks",ariaHidden:"true"});for(let s of e){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));t.append(c("span",{class:"zx-slider__mark",style:{"--zx-slider-mark":String(this._ratio(n))}},r))}return t}_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:e}=this.refs;e.textContent=this.options.showValue?this._format(this._value):""}_syncState(){let e=this.refs.input.disabled;this.el.toggleAttribute("data-disabled",e),this.el.toggleAttribute("data-readonly",this._readonly),this.refs.input.setAttribute("aria-readonly",String(this._readonly))}_snap(e){let t=Number(e);return Number.isFinite(t)?vs(t,{min:this._min,max:this._max,step:this._step,precision:vu(this._step)}):this._min}_ratio(e){return dt((e-this._min)/(this._max-this._min),0,1)}_format(e){let t=this.options.formatValue;return typeof t=="function"?String(t(e)):`${xu(e)}${this.options.unit??""}`}destroy(){let e=this.el;super.destroy(),!this._createdRoot&&e&&K(e,this._snapshot)}},wu=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function vu(i){let e=String(i),t=/e-(\d+)$/i.exec(e);return t?Number(t[1]):(e.split(".")[1]??"").length}function xu(i){return String(Number(i.toFixed(6)))}function bo(){z.register("slider",(i,e)=>{let t=i.own(new hi(null,{label:e.label?String(e.label):void 0,hideLabel:!0,disabled:!!e.disabled,...e.props??{}})),s=!1;return i.listen(t.el,"change",n=>n.stopImmediatePropagation()),t.on("change",n=>{s||i.emit("change",{value:n.detail.value})}),t.on("input",n=>i.emit("input",{value:n.detail.value})),{el:t.el,get:()=>t.get(),set:n=>{s=!0;try{t.set(Number(n)||0,{silent:!0})}finally{s=!1}},focus:()=>t.focus(),setDisabled:n=>n?t.disable():t.enable(),setReadonly:n=>{t.setReadonly(n)}}})}var F_=Object.freeze(["neutral","accent","success","warning","danger","info"]),R_=Object.freeze(["soft","solid","outline"]),Su=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),L_=Object.freeze({label:"",icon:null,kind:"neutral",tone:null,variant:"soft",size:"md",dot:!1});function yo(i){return Su.includes(i)?i:null}var fi=class extends S{static cssName="tag-picker";static defaults={items:[],values:[],valueKey:"ID",labelKey:"name",iconKey:"icon",colorKey:"color",toneKey:"tone",searchKeys:null,filter:"local",minQuery:0,debounce:200,allowCreate:!1,max:null,closeOnSelect:!1,placeholder:"",listHeight:260,disabled:!1,readonly:!1,renderItem:null,renderTag:null};render(){this._items=[],this._selected=[],this._visible=[],this._entries=[],this._activeIndex=-1,this._open=!1,this._disabled=!1,this._readonly=!1,this._loading=!1,this._requestSequence=0,this._queryTimer=null,this._position=null,this._activeId=null,this._createdRoot=this.el===null,this._snapshot=this._createdRoot?null:H(this.el);let e=this.el??c("div");this.el=e;let t=E("zx-tag-picker-list"),s=c("span",{ref:"tags",class:"zx-tag-picker__tags"}),n=c("input",{ref:"input",class:"zx-tag-picker__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:!1,ariaExpanded:"false",ariaControls:t,ariaAutocomplete:"list",ariaLabel:this._message("tagPicker.input","Add a value"),placeholder:String(this.options.placeholder??"")}),r=c("button",{ref:"toggle",class:"zx-tag-picker__toggle",type:"button",tabIndex:-1,ariaLabel:this._message("tagPicker.toggle","Toggle options")},v("chevron-down",{size:15})),o=c("div",{ref:"control",class:"zx-tag-picker__control"},s,n,r),a=c("div",{ref:"list",class:"zx-tag-picker__list",id:t,role:"listbox",ariaMultiSelectable:"true"});a.style.maxBlockSize=`${Math.max(0,Number(this.options.listHeight)||0)}px`;let l=c("div",{ref:"panel",class:"zx-tag-picker__panel",popover:"manual"},a);return e.replaceChildren(o,l),this._items=Array.isArray(this.options.items)?this.options.items.slice():[],this._visible=this._items.slice(),this._disabled=!!this.options.disabled,this._readonly=!!this.options.readonly,this.listen(o,"pointerdown",u=>{let d=u.target;d.closest(".zx-tag-picker__remove")||d.closest(".zx-tag-picker__toggle")||(u.target!==n&&(u.preventDefault(),this.focus()),this._open||this.open())}),this.listen(s,"click",u=>{let d=u.target.closest(".zx-tag-picker__remove");if(!d||this._disabled||this._readonly)return;u.stopPropagation();let h=[...s.children].indexOf(d.closest(".zx-tag-picker__tag")),p=this._selected[h];p!==void 0&&(this.removeValue(this._valueOf(p)),this.focus())}),this.listen(n,"input",()=>this._onInput()),this.listen(n,"keydown",u=>this._onKeydown(u)),this.listen(n,"blur",()=>this.el.removeAttribute("data-focus")),this.listen(n,"focus",()=>this.el.setAttribute("data-focus","")),this.listen(r,"click",()=>{this.focus(),this._open?this.close():this.open()}),this.listen(l,"pointerdown",u=>u.preventDefault()),this.listen(l,"click",u=>this._onOptionClick(u)),this.listen(document,"pointerdown",u=>{this._open&&!e.contains(u.target)&&this.close()},{capture:!0}),this.setValues(this.options.values,{silent:!0}),this._syncDisabled(),e}get values(){return this.getValues()}set values(e){this.setValues(e)}getValues(){return this._selected.map(e=>this._valueOf(e))}getItems(){return this._selected.slice()}setValues(e,{silent:t=!1}={}){let s=Array.isArray(e)?e:[],n=this.options.max===null||this.options.max===void 0?1/0:Number(this.options.max),r=[];for(let a of s){if(r.length>=n)break;let l=this._resolve(a);l!==null&&!r.some(u=>this._sameValue(u,l))&&r.push(l)}let o=!Au(r,this._selected,a=>this._valueOf(a));return this._selected=r,this._renderTags(),this._renderOptions(),o&&!t&&this._emitChange(),this}addValue(e,{silent:t=!1}={}){if(this.isFull())return this;let s=this._resolve(e);return s===null?this:this._selected.some(n=>this._sameValue(n,s))?this:(this._selected.push(s),this._renderTags(),this._renderOptions(),t||(this.emit("add",{value:this._valueOf(s),item:s}),this._emitChange()),this)}removeValue(e,{silent:t=!1}={}){let s=this._valueOf(this._resolve(e)??e),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(),t||(this.emit("remove",{value:this._valueOf(r),item:r}),this._emitChange()),this}clear({silent:e=!1}={}){return this.setValues([],{silent:e})}reset({silent:e=!1}={}){return this.setValues(this.options.values,{silent:e})}setItems(e){return this._cancelQuery(),this._items=Array.isArray(e)?e.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 e=this.options.max;return e!=null&&this._selected.length>=Number(e)}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=Z(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(e){return e&&this.close(),this._readonly=!!e,this._renderTags(),this._syncDisabled(),this}destroy(){this._cancelQuery(),this._position?.destroy(),this._position=null;let e=this.el;super.destroy(),!this._createdRoot&&e&&K(e,this._snapshot)}_renderTags(){let e=this._selected.map(t=>{let s=this._labelOf(t),n=this._toneOf(t),r=n?null:this._colorOf(t),o=this.options.renderTag?this.options.renderTag(t):[this._iconOf(t),c("span",{class:"zx-tag-picker__tag-label"},s)],a=c("span",{class:"zx-tag-picker__tag",dataset:{colored:String(!!r),tone:n??void 0},style:r?{"--zx-tag-color":r}:null},o);return!this._readonly&&!this._disabled&&a.append(c("button",{class:"zx-icon-btn zx-tag-picker__remove",type:"button",ariaLabel:this._message("tagPicker.remove","Remove %1",[s])},v("x",{size:11}))),a});this.refs.tags.replaceChildren(...e),this.el.toggleAttribute("data-empty",this._selected.length===0),this._syncPlaceholder()}_renderOptions(){let e=this.refs.list;this._entries=[];let t=[];for(let r of this._visible){let o=this._valueOf(r),a=this._isSelected(o),l=c("div",{class:"zx-tag-picker__option",id:E("zx-tag-picker-option"),role:"option",ariaSelected:String(a)},c("span",{class:"zx-tag-picker__check",ariaHidden:"true"},a?v("check",{size:13}):null),c("span",{class:"zx-tag-picker__option-label"},this.options.renderItem?this.options.renderItem(r):[this._iconOf(r),c("span",{},this._labelOf(r))]));!a&&this.isFull()&&l.setAttribute("aria-disabled","true"),this._entries.push({item:r,element:l,create:!1}),t.push(l)}let s=this.refs.input.value.trim();if(this._canCreate(s)){let r=c("div",{class:"zx-tag-picker__option",id:E("zx-tag-picker-option"),role:"option",ariaSelected:"false",dataset:{create:"true"}},c("span",{class:"zx-tag-picker__check",ariaHidden:"true"},v("plus",{size:13})),c("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}),t.push(r)}t.length===0&&t.push(c("div",{class:"zx-tag-picker__empty"},this._loading?this._message("tagPicker.loading","Loading\u2026"):this._message("tagPicker.empty","No matches"))),e.replaceChildren(...t);let n=this._entries.findIndex(r=>this._entryId(r)===this._activeId);this._setActive(n>=0?n:this._entries.length>0?0:-1)}_entryId(e){return e.create?"\0create":String(this._valueOf(e.item))}_syncPlaceholder(){let e=this.refs.input;e.placeholder=this._selected.length===0?String(this.options.placeholder??""):""}_onInput(){let e=this.refs.input.value;this._syncInputWidth(),this._open||this.open(),typeof this.options.filter=="function"?this._scheduleAsyncQuery(e):this._applyLocalFilter(e),this._renderOptions(),this._setActive(this._entries.length>0?0:-1),this._position?.update()}_onKeydown(e){if(this._disabled||this._readonly)return;let t=this.refs.input;switch(e.key){case"ArrowDown":e.preventDefault(),this._open?this._move(1):this.open();return;case"ArrowUp":e.preventDefault(),this._open&&this._move(-1);return;case"Home":this._open&&t.value===""&&(e.preventDefault(),this._setActive(0));return;case"End":this._open&&t.value===""&&(e.preventDefault(),this._setActive(this._entries.length-1));return;case"Enter":{if(!this._open||this._activeIndex<0)return;e.preventDefault(),this._commitEntry(this._entries[this._activeIndex]);return}case"Escape":this._open&&(e.preventDefault(),this.close());return;case"Backspace":t.value===""&&this._selected.length>0&&(e.preventDefault(),this.removeValue(this._valueOf(this._selected[this._selected.length-1])));return;case"Tab":this._open&&this.close();return;default:}}_onOptionClick(e){let t=e.target.closest(".zx-tag-picker__option");if(!t)return;let s=this._entries.find(n=>n.element===t);s&&this._commitEntry(s)}_commitEntry(e){if(!e)return;let t=this.refs.input;if(e.create){let s=t.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(e.item);if(this._isSelected(s))this.removeValue(s);else if(!this.isFull())this.addValue(e.item);else return}t.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(e){if(this._entries.length===0)return;let t=this._activeIndex<0?e>0?0:this._entries.length-1:Math.min(this._entries.length-1,Math.max(0,this._activeIndex+e));this._setActive(t)}_setActive(e){this._activeIndex=e,this._activeId=this._entries[e]?this._entryId(this._entries[e]):null;for(let[t,s]of this._entries.entries()){let n=t===e;s.element.toggleAttribute("data-active",n),n&&(this.refs.input.setAttribute("aria-activedescendant",s.element.id),s.element.scrollIntoView({block:"nearest"}))}e<0&&this.refs.input.removeAttribute("aria-activedescendant")}_applyLocalFilter(e){if(typeof this.options.filter=="function")return;let t=this.options.searchKeys??[this.options.labelKey];this._visible=xe(this._items,e,t)}_scheduleAsyncQuery(e){this._cancelQuery();let t=String(e??"");if(t.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(t)},s)}async _runQuery(e){let t=this._requestSequence+1;this._requestSequence=t,this._setLoading(!0),this.emit("query",{query:e});try{let s=await this.options.filter(e);if(t!==this._requestSequence)return;this._items=Array.isArray(s)?s.slice():[],this._visible=this._items.slice()}catch(s){if(t!==this._requestSequence)return;this._visible=[],this.emit("error",{error:s})}finally{t===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(e){this._loading=e,this.el.toggleAttribute("data-loading",e)}_isSelected(e){return this._selected.some(t=>Object.is(this._valueOf(t),e))}_canCreate(e){if(!this.options.allowCreate||e===""||this.isFull())return!1;let t=s=>s.some(n=>wo(this._labelOf(n))===wo(e));return!t(this._items)&&!t(this._selected)}_createItem(e,t=e){return typeof this.options.valueKey!="string"||typeof this.options.labelKey!="string"?e:{[this.options.valueKey]:t,[this.options.labelKey]:e,created:!0}}_resolve(e){if(e==null)return null;let t=this._valueOf(e),s=this._items.find(r=>Object.is(this._valueOf(r),t));if(s!==void 0)return s;let n=this._selected.find(r=>Object.is(this._valueOf(r),t));return n!==void 0?n:typeof e=="object"?e:this._createItem(String(e),e)}_sameValue(e,t){return Object.is(this._valueOf(e),this._valueOf(t))}_valueOf(e){let t=this.options.valueKey;return typeof t=="function"?t(e):e!==null&&typeof e=="object"?e[t]:e}_labelOf(e){let t=this.options.labelKey;return String(typeof t=="function"?t(e):e!==null&&typeof e=="object"?e[t]??"":e??"")}_iconOf(e){let t=this._readItem(e,this.options.iconKey),s=t&&typeof t=="object"&&typeof t.nodeType=="number"?t.cloneNode(!0):typeof t=="string"&&t.trim()?v(t,{size:12}):null;if(!s)return null;let n=this._toneOf(e),r=n?null:this._colorOf(e);return c("span",{class:"zx-tag-picker__visual",dataset:{tone:n??void 0},style:r?{"--zx-tag-color":r}:null,ariaHidden:"true"},s)}_colorOf(e){return ui(this._readItem(e,this.options.colorKey))}_toneOf(e){return yo(this._readItem(e,this.options.toneKey))}_readItem(e,t){return typeof t=="function"?t(e):e!==null&&typeof e=="object"&&typeof t=="string"?e[t]:null}_emitChange(){this.emit("change",{values:this.getValues(),items:this.getItems()})}_syncInputWidth(){let e=this.refs.input,t=e.value.length;e.style.inlineSize=t===0?"":`${Math.min(40,t+1)}ch`}_syncDisabled(){let e=this.refs.input;e.disabled=this._disabled,e.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(e,t,s=[]){let n=this.msg(e,...s);return n!==e?n:s.reduce((r,o,a)=>r.replaceAll(`%${a+1}`,String(o)),t)}};function wo(i){return String(i??"").trim().toLocaleLowerCase()}function Au(i,e,t){return i.length!==e.length?!1:i.every((s,n)=>Object.is(t(s),t(e[n])))}function vo(){z.register("tagpicker",(i,e)=>{let t=i.own(new fi(null,{placeholder:e.placeholder,...e.props??{}})),s=!1;return i.listen(t.el,"change",n=>n.stopImmediatePropagation()),t.on("change",n=>{s||i.emit("change",{value:n.detail.values})}),{el:t.el,get:()=>t.getValues(),set:n=>{s=!0;try{t.setValues(Array.isArray(n)?n:[],{silent:!0})}finally{s=!1}},focus:()=>t.focus(),setDisabled:n=>n?t.disable():t.enable(),setReadonly:n=>{t.setReadonly(n)}}})}function ku(i,e="minutes"){let t=Math.round(Math.abs(xo(Te(i),e)));return{hours:Math.floor(t/3600),minutes:Math.floor(t/60)%60,seconds:t%60,negative:Te(i)<0}}function zu(i,e="minutes"){gt(e);let t=Math.abs(Math.trunc(Te(i?.hours))),s=Math.abs(Math.trunc(Te(i?.minutes))),n=Math.abs(Math.trunc(Te(i?.seconds))),r=i?.negative?-1:1;return So(r*(t*3600+s*60+n),e)}var pi=class extends S{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){gt(this.options.unit);let e=this.el??c("div");this.el=e,this._originalAriaDisabled=e.getAttribute("aria-disabled"),this._disabled=!!this.options.disabled,this._parts={hours:0,minutes:0,seconds:0,negative:!1},this._inputs=[];let t=c("div",{class:"zx-timebox__content",role:"group",ariaLabel:this.options.seconds?this._message("timebox.durationWithSeconds","Duration in hours, minutes, and seconds"):this._message("timebox.duration","Duration in hours and minutes")});return this._content=t,this.options.signed&&(t.append(c("button",{ref:"sign",class:"zx-timebox__sign",type:"button",ariaLabel:this._message("timebox.toggleSign","Toggle duration sign"),ariaPressed:"false"},"+")),this.listen(this.refs.sign,"click",()=>{this._disabled||(this._parts.negative=!this._parts.negative,this._writeParts(),this._emitChange())})),this._addSegment(t,"hours",this._message("timebox.hours","Hours"),!1),t.append(c("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(t,"minutes",this._message("timebox.minutes","Minutes"),!0),this.options.seconds&&(t.append(c("span",{class:"zx-timebox__separator",ariaHidden:"true"},":")),this._addSegment(t,"seconds",this._message("timebox.seconds","Seconds"),!0)),e.append(t),this.set(this.options.value,this.options.unit,{silent:!0}),this._syncDisabled(),e}get(e=this.options.unit){return zu(this._readParts(),e)}set(e,t=this.options.unit,s={}){t&&typeof t=="object"&&(s=t,t=this.options.unit),gt(t);let n=Te(e);return!this.options.signed&&n<0&&(n=0),this.options.seconds||(n=So(Math.round(xo(n,t)/60)*60,t)),this._parts=ku(n,t),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(e,t,s,n){let r=c("input",{class:"zx-timebox__segment",type:"text",inputMode:"numeric",autocomplete:"off",ariaLabel:s,maxLength:n?2:null,dataset:{segment:t,bounded:String(n)}});this._inputs.push(r),e.append(r),this.listen(r,"focus",()=>r.select()),this.listen(r,"input",()=>{t==="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 e={...this._parts};for(let t of this._inputs){let s=t.dataset.segment,n=t.dataset.bounded==="true"?59:Number.MAX_SAFE_INTEGER;e[s]=Math.max(0,Math.min(n,Math.trunc(Te(t.value))))}return e}_commitSegments(){this._parts=this._readParts(),this._writeParts(),this._emitChange()}_writeParts(){for(let e of this._inputs){let t=e.dataset.segment;e.value=t==="hours"?String(this._parts[t]):Cu(this._parts[t])}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 e of this._inputs)e.disabled=this._disabled;this.refs.sign&&(this.refs.sign.disabled=this._disabled),this.el.setAttribute("aria-disabled",String(this._disabled))}_emitChange(){this.emit("change",{value:this.get(this.options.unit)})}_message(e,t){let s=this.msg(e);return s===e?t:s}};function Te(i){let e=Number(i);return Number.isFinite(e)?e:0}function xo(i,e){return gt(e),e==="hours"?i*3600:e==="minutes"?i*60:i}function So(i,e){return gt(e),e==="hours"?i/3600:e==="minutes"?i/60:i}function gt(i){if(i!=="hours"&&i!=="minutes"&&i!=="seconds")throw new RangeError(`Unknown time unit: ${i}`)}function Cu(i){return String(i).padStart(2,"0")}function Ao(){z.register("time",(i,e)=>{let t=i.own(new pi(null,{...e.props??{},value:e.value}));return i.listen(t.el,"change",s=>s.stopImmediatePropagation()),t.on("change",s=>i.emit("change",{value:s.detail.value})),{el:t.el,get:()=>t.get(),set:s=>t.set(Number(s)||0,{silent:!0}),focus:()=>t.el.querySelector("input:not([disabled]), button:not([disabled])")?.focus(),setDisabled:s=>s?t.disable():t.enable()}})}var Ke=class extends S{static cssName="toggle";static defaults={checked:!1,value:!0,label:null,disabled:!1};render(){let e=!this.el,t=this.el??c("button");if(this.el=t,t.localName!=="button")throw new TypeError("Toggle target must be a button element");this._createdRoot=e,this._original=e?null:Du(t),this._checked=!!this.options.checked,this._disabled=!!this.options.disabled,t.type="button",t.setAttribute("role","switch");let s=[c("span",{class:"zx-toggle__track",ariaHidden:"true"},c("span",{class:"zx-toggle__thumb"}))];return this.options.label!==null&&s.push(c("span",{class:"zx-toggle__label"},String(this.options.label))),t.replaceChildren(...s),this._sync(),this.listen(t,"click",()=>this.toggle()),t}get(){return this._checked}set(e,{silent:t=!1}={}){let s=!!e;return s===this._checked?this:(this._checked=s,this._sync(),t||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&&Eu(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function Du(i){return{attributes:Array.from(i.attributes,e=>[e.name,e.value]),children:Array.from(i.childNodes)}}function Eu(i,e){for(let t of Array.from(i.attributes))i.removeAttribute(t.name);for(let[t,s]of e.attributes)i.setAttribute(t,s);i.replaceChildren(...e.children)}function ko(){z.register("toggle",(i,e)=>{let t=i.own(new Ke(null,{...e.props??{},checked:!!e.value}));return i.listen(t.el,"change",s=>s.stopImmediatePropagation()),t.on("change",s=>i.emit("change",{value:s.detail.value})),{el:t.el,get:()=>t.getValue(),set:s=>t.set(!!s,{silent:!0}),focus:()=>t.el.focus(),setDisabled:s=>s?t.disable():t.enable()}})}var mi=class extends S{static cssName="value-list";static defaults={values:[],placeholder:"",deletable:!0,sortable:!0,unique:!0,validate:null};render(){let e=this.el??c("div");this._ownedNodes=[],this._disabled=!1,this._dragIndex=-1,this._initialState=e.getAttribute("data-state"),this._initialDisabled=e.getAttribute("data-disabled"),this._values=zo(this.options.values,!!this.options.unique);let t=E("zx-value-list-instructions");return this._list=c("ul",{class:"zx-value-list__list",role:"listbox",ariaLabel:this._message("valueList.values","Values"),ariaOrientation:"horizontal"}),this._input=c("input",{class:"zx-value-list__input",type:"text",placeholder:String(this.options.placeholder??""),ariaLabel:this._message("valueList.add","Add value"),ariaDescribedby:t}),this._status=c("div",{class:"zx-value-list__status",role:"status",ariaLive:"polite"}),this._instructions=c("span",{class:"zx-value-list__instructions",id:t},this._message("valueList.instructions","Press Enter to add. Focus a value and press Ctrl plus Left or Right to reorder.")),this._ownedNodes.push(this._list,this._input,this._status,this._instructions),e.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(e,"click",s=>{s.target===e&&!this._disabled&&this.focus()}),this._renderChips(),e}getValues(){return this._values.slice()}setValues(e,{silent:t=!1}={}){return this._values=zo(e,!!this.options.unique),this._renderChips(),t||this.emit("change",{values:this.getValues()}),this}addValue(e){if(this._disabled)return!1;let t=String(e??"").trim();if(!t)return!1;if(this.options.unique&&this._values.includes(t))return this._showError(this._message("valueList.duplicate","This value already exists.")),!1;if(typeof this.options.validate=="function"){let s=this.options.validate(t);if(s!==!0)return this._showError(typeof s=="string"?s:this._message("valueList.invalid","This value is not valid.")),!1}return this._status.textContent="",this._input.removeAttribute("aria-invalid"),this._values.push(t),this._renderChips(),this.emit("add",{value:t}),this.emit("change",{values:this.getValues()}),!0}removeValue(e){if(this._disabled||!this.options.deletable)return!1;let t=this._values.indexOf(String(e));return t<0?!1:(this._removeAt(t),!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(e=-1){let t=this._values.map((s,n)=>c("li",{class:"zx-value-list__chip",role:"option",tabIndex:this._disabled?-1:0,draggable:!!this.options.sortable&&!this._disabled,ariaSelected:"false",ariaDisabled:String(this._disabled),ariaLabel:this.options.deletable?this._message("valueList.removable","%1. Press Delete to remove.",s):s,dataset:{index:n}},c("span",{class:"zx-value-list__value"},s),this.options.deletable?c("span",{class:"zx-value-list__remove",dataset:{remove:""},ariaHidden:"true"},"\xD7"):null));this._list.replaceChildren(...t),e>=0&&t[Math.min(e,t.length-1)]?.focus()}_handleInputKeydown(e){this._disabled||(e.key==="Enter"?(e.preventDefault(),this.addValue(this._input.value)&&(this._input.value="")):e.key==="Backspace"&&this._input.value===""&&this._values.length&&this.options.deletable&&(e.preventDefault(),this._removeAt(this._values.length-1)))}_handleChipKeydown(e){if(this._disabled)return;let t=e.target instanceof Element?e.target.closest("[data-index]"):null;if(!t)return;let s=Number(t.dataset.index);if((e.key==="Delete"||e.key==="Backspace")&&this.options.deletable){e.preventDefault(),this._removeAt(s,Math.min(s,this._values.length-2));return}let n=e.key==="ArrowLeft"?-1:e.key==="ArrowRight"?1:0,r=e.key==="ArrowUp"?-1:e.key==="ArrowDown"?1:0,o=n||r;if(!o)return;e.preventDefault();let a=Math.max(0,Math.min(this._values.length-1,s+o));e.ctrlKey&&n&&this.options.sortable?this._move(s,a,!0):this._list.querySelector(`[data-index="${a}"]`)?.focus()}_handleChipClick(e){let t=e.target instanceof Element?e.target:null,s=t?.closest("[data-index]");!s||this._disabled||(t.closest("[data-remove]")&&this.options.deletable?this._removeAt(Number(s.dataset.index)):s.focus())}_handleDragStart(e){if(this._disabled||!this.options.sortable)return;let t=e.target instanceof Element?e.target.closest("[data-index]"):null;t&&(this._dragIndex=Number(t.dataset.index),this.el.dataset.state="dragging",e.dataTransfer?.setData("text/plain",String(this._dragIndex)),e.dataTransfer&&(e.dataTransfer.effectAllowed="move"))}_handleDrop(e){if(this._dragIndex<0||this._disabled)return;e.preventDefault();let t=e.target instanceof Element?e.target.closest("[data-index]"):null,s=t?Number(t.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(e,t,s){if(e===t||e<0||t<0||e>=this._values.length||t>=this._values.length)return;let[n]=this._values.splice(e,1);this._values.splice(t,0,n),this._renderChips(s?t:-1),this.emit("change",{values:this.getValues()})}_removeAt(e,t=-1){let[s]=this._values.splice(e,1);s!==void 0&&(this._renderChips(t),t<0&&this._values.length===0&&this._input.focus(),this.emit("remove",{value:s}),this.emit("change",{values:this.getValues()}))}_showError(e){this._status.textContent=e,this._input.setAttribute("aria-invalid","true")}_message(e,t,...s){let n=this.msg(e,...s);return n===e?O(t,s):n}destroy(){for(let e of this._ownedNodes??[])e.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 zo(i,e){if(!Array.isArray(i))return[];let t=i.map(s=>String(s));return e?[...new Set(t)]:t}function Co(){z.register("valuelist",(i,e)=>{let t=i.own(new mi(null,{...e.props??{},values:Array.isArray(e.value)?e.value:[]}));return i.listen(t.el,"change",s=>s.stopImmediatePropagation()),t.on("change",s=>i.emit("change",{value:s.detail.values})),{el:t.el,get:()=>t.getValues(),set:s=>t.setValues(Array.isArray(s)?s:[],{silent:!0}),focus:()=>t.focus(),setDisabled:s=>s?t.disable():t.enable()}})}var _i=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),Iu=["xl","lg","md","sm"];function Do(i){let e=Number(i);if(!Number.isFinite(e))return"xs";for(let t of Iu)if(e>=_i[t])return t;return"xs"}function Eo(i,e={}){if(typeof i!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in e&&!R(e.target)&&e.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let t=e.target??globalThis,s=R(t)?t:null,n=null,r=!1,o=null,a=()=>s?s.getBoundingClientRect().width:Number(globalThis.innerWidth)||0,l=()=>{if(r)return;let h=a();if(s&&h===0)return;let p=Do(h);p!==n&&(n=p,i(n,h))};l();let u=0,d=()=>{u||r||(u=requestAnimationFrame(()=>{u=0,l()}))};return s&&typeof ResizeObserver=="function"?(o=new ResizeObserver(d),o.observe(s)):globalThis.addEventListener?.("resize",l,{passive:!0}),{current:()=>n??Do(a()),destroy:()=>{r||(r=!0,u&&cancelAnimationFrame(u),o?.disconnect(),globalThis.removeEventListener?.("resize",l))}}}var Tu=0,Mu=20,Nu=3;var Io=new Map;function gi(i,e={}){let t=Ts(i);if(t===null)return"";let{locale:s=he(),decimals:n,minDecimals:r,maxDecimals:o,group:a=!0}=e;return Es(s,Is({decimals:n,minDecimals:r,maxDecimals:o,group:a}),t)}function Mo(i,e,t={}){let s=Ts(i);if(s===null)return"";let{locale:n=he(),decimals:r}=t,o=Fu(e);if(o===null)return gi(s,{locale:n,decimals:r});let a=Is({decimals:r,group:!0});return Es(n,{...a,style:"currency",currency:o},s)}function No(i,e={}){let t=Ts(i);if(t===null)return"";let{locale:s=he(),decimals:n=0}=e;return Es(s,{...Is({decimals:n,group:!0}),style:"percent"},t)}function Es(i,e,t){let s=`${i}\0${JSON.stringify(e)}`,n=Io.get(s);return n===void 0&&(n=Ou(i,e),Io.set(s,n)),n.format(t)}function Ou(i,e){try{return new Intl.NumberFormat(i,e)}catch{try{return new Intl.NumberFormat(void 0,e)}catch{return new Intl.NumberFormat}}}function Is({decimals:i,minDecimals:e,maxDecimals:t,group:s=!0}){let n={useGrouping:s!==!1},r=To(e??i),o=To(t??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,Nu)),n}function To(i){if(i==null)return null;let e=Number(i);return Number.isFinite(e)?Math.min(Mu,Math.max(Tu,Math.round(e))):null}function Ts(i){if(i==null||i==="")return null;let e=typeof i=="number"?i:Number(i);return Number.isFinite(e)?e:null}function Fu(i){if(typeof i!="string")return null;let e=i.trim().toUpperCase();return/^[A-Z]{3}$/.test(e)?e:null}var Ru=".zx-scope, [data-zx-theme], [data-zx-preset]",Lu="dialog:modal, dialog[open], dialog:popover-open";function ie(i=null){return Fo(Oo(i))}function bt(i=null){let e=Oo(i);return(i==null?null:Ye(e))??Fo(e)}function Ue(i=null,e={}){let t=e.dialog===!1?ie:bt;if(i==null)return t(null);let s=U(i);return s?.isConnected?t(s):null}function Ye(i){if(!i||typeof i.closest!="function")return null;try{return i.closest(Lu)}catch{return i.closest("dialog[open]")}}function Oo(i){return i==null?document.activeElement instanceof Element?document.activeElement:null:U(i)}function Fo(i){let e=i?.closest?.(Ru)??null;return!e||e===document.documentElement||e===document.body?document.body:e}var Po=new Set(["tooltip","toast"]);function Ae(i,e){if(!i||!e)return!1;for(let t=e;t;t=t.parentNode??t.host??null)if(t===i)return!0;return!1}function Pu(i,e){for(let t=i.length-1;t>=0;t-=1){let s=i[t];if(!Po.has(s.kind)&&e.some(n=>Ae(s.root,n)))return s}return null}function yt(i,e,t){return t?Ae(e.root,t)||e.inside.some(s=>Ae(s,t))?!0:i.some(s=>s.parent===e&&yt(i,s,t)):!1}function Ms(i,e=()=>!0){for(let t=i.length-1;t>=0;t-=1){let s=i[t];if(s.kind!=="toast"&&e(s))return s}return null}function ju(i,e=null){let t=[];for(let s=i.length-1;s>=0;s-=1){let n=i[s];if(n.kind==="modal")break;e&&!Ae(e,n.root)||typeof n.onEscape=="function"&&t.push(n)}return t}function Bu(i,e,t=null){if(i.some(n=>n.kind==="toast"&&Ae(n.root,e)))return[];let s=[];for(let n=i.length-1;n>=0;n-=1){let r=i[n];r.kind==="tooltip"&&!yt(i,r,e)&&r.onOutsidePointer&&s.push(r)}for(let n=i.length-1;n>=0;n-=1){let r=i[n];if(!Po.has(r.kind)){if(yt(i,r,e)||r.kind==="modal")break;t&&!Ae(t,r.root)||r.onOutsidePointer&&s.push(r)}}return s}var Os=class{#e=[];#t=0;#i=null;#s=new Set;#n;#r=new WeakMap;constructor(e={}){this.#n=e.target===void 0?typeof document>"u"?null:document:e.target}push(e){let t=Ro(e.anchor),s={order:++this.#t,kind:e.kind,root:e.root,owner:e.owner??null,anchors:t,inside:Ro(e.inside),parent:e.kind==="toast"?null:Pu(this.#e,t),onEscape:e.onEscape,onOutsidePointer:e.onOutsidePointer,onFocusOutside:e.onFocusOutside,onParentClose:e.onParentClose};this.#e.push(s);let n={entry:s,order:s.order,isOpen:()=>this.#e.includes(s),isTopmost:()=>Ms(this.#e)===s,contains:r=>this.#e.includes(s)&&yt(this.#e,s,r),release:()=>this.#a(s)};return this.#r.set(s,n),this.#l(),this.#o(),n}entries(){return this.#e.slice()}topmost(e){return Ms(this.#e,e)}topmostModal(){let e=Ms(this.#e,s=>s.kind==="modal"&&s.root.isConnected&&Vu(s.root,":modal",!0));if(e)return e.root;if(typeof document>"u"||typeof document.querySelectorAll!="function")return null;let t;try{t=document.querySelectorAll("dialog:modal")}catch{return null}return t.length?t[t.length-1]:null}containsNode(e){return this.#e.some(t=>Ae(t.root,e)||t.inside.some(s=>Ae(s,e)))}subscribe(e){return this.#s.add(e),()=>{this.#s.delete(e)}}handleKeydown(e){if(e.key!=="Escape"||e.defaultPrevented||e.isComposing)return null;for(let t of ju(this.#e,Lo(Ns(e)))){let s=this.#r.get(t);if(!(!s||!this.#e.includes(t))&&t.onEscape?.(e,s)!==!1)return e.preventDefault(),t}return null}handlePointerdown(e){let t=Ns(e),s=Bu(this.#e,t,Lo(t));for(let n of s){let r=this.#r.get(n);r&&this.#e.includes(n)&&n.onOutsidePointer?.(e,r)}return s}handleFocusin(e){let t=Ns(e);for(let s of this.#e.slice().reverse()){if(typeof s.onFocusOutside!="function"||!this.#e.includes(s)||yt(this.#e,s,t))continue;let n=this.#r.get(s);n&&s.onFocusOutside(e,n)}}#a(e){let t=this.#e.indexOf(e);if(t<0)return;this.#e.splice(t,1);let s=this.#e.filter(n=>n.parent===e);for(let n of s)n.parent=e.parent;this.#e.length===0&&this.#c(),this.#o();for(let n of s.reverse()){let r=this.#r.get(n);r&&this.#e.includes(n)&&n.onParentClose?.(r)}}#l(){if(this.#i||!this.#n||typeof this.#n.addEventListener!="function")return;let e=new AbortController;this.#i=e;let{signal:t}=e;this.#n.addEventListener("keydown",s=>this.handleKeydown(s),{signal:t}),this.#n.addEventListener("pointerdown",s=>this.handlePointerdown(s),{capture:!0,signal:t}),this.#n.addEventListener("focusin",s=>this.handleFocusin(s),{signal:t})}#c(){this.#i?.abort(),this.#i=null}#o(){let e=this.#e.slice();for(let t of[...this.#s])try{t(e)}catch(s){queueMicrotask(()=>{throw s})}}},We=new Os;function Ze(i){return We.push(i)}function Ro(i){let e=Array.isArray(i)?i:[i];return e.filter((t,s)=>t!=null&&e.indexOf(t)===s)}function Lo(i){for(let e=i;e;e=e.parentNode??e.host??null)if(e.localName==="dialog"&&typeof e.matches=="function")try{if(e.matches(":modal"))return e}catch{return null}return null}function Ns(i){return(typeof i.composedPath=="function"?i.composedPath():[])[0]??i.target??null}function Vu(i,e,t){if(typeof i.matches!="function")return t;try{return i.matches(e)}catch{return t}}var qu=Object.freeze({size:"md",label:"",showLabel:!1,kind:"accent"}),$u=Object.freeze({sm:!0,md:!0,lg:!0});function jo(i={}){let e={...qu,...i},t=String(e.label??""),s=c("span",{class:"zx-spinner",dataset:{size:$u[e.size]?e.size:"md",kind:e.kind==="current"?"current":"accent"}},c("span",{class:"zx-spinner__ring",ariaHidden:"true"}));return t?(s.setAttribute("role","status"),s.append(c("span",{class:"zx-spinner__label",dataset:{visible:e.showLabel?"true":null}},t))):s.setAttribute("aria-hidden","true"),s}var Hu=Object.freeze({label:"",icon:null,kind:"default",size:"md",disabled:!1});function Bo(i={}){let e={...Hu,...i},t=c("button",{class:"zx-btn",type:"button",disabled:!!e.disabled,title:e.title??(e.shortcut?`${e.label} (${e.shortcut.label})`:void 0),ariaKeyshortcuts:e.shortcut?.keys,dataset:{kind:Uu(e.kind),size:Yu(e.size)}});return e.icon&&t.append(v(e.icon,{size:16})),e.label!==""&&t.append(c("span",{class:"zx-btn__label"},String(e.label))),e.shortcut&&t.append(c("kbd",{class:"zx-btn__shortcut",ariaHidden:"true"},e.shortcut.label)),!e.label&&e.title&&t.setAttribute("aria-label",e.title),typeof e.onclick=="function"&&(t.onclick=e.onclick),e.busy&&Ku(t,!0),t}function Ku(i,e){if(i.hasAttribute("data-busy-guard")||(i.setAttribute("data-busy-guard",""),i.addEventListener("click",t=>{i.getAttribute("aria-busy")==="true"&&(t.preventDefault(),t.stopImmediatePropagation())},{capture:!0})),i.querySelector(":scope > .zx-btn__spinner")?.remove(),e){i.setAttribute("aria-busy","true"),i.setAttribute("aria-disabled","true");let t=jo({size:"sm",kind:"current"});t.classList.add("zx-btn__spinner"),i.prepend(t)}else i.removeAttribute("aria-busy"),i.removeAttribute("aria-disabled");return i}function Uu(i){return["primary","danger","ghost"].includes(String(i))?i:"default"}function Yu(i){return i==="sm"?"sm":"md"}function Wu(i,e){return String(i).localeCompare(String(e))}function Zu(i,e){return i-e}function Gu(i,e){return i.getTime()-e.getTime()}function Qu(i,e,t="asc"){let s=i==null,n=e==null;if(s||n)return s&&n?0:s?1:-1;let r;return i instanceof Date&&e instanceof Date?r=Gu(i,e):typeof i=="number"&&typeof e=="number"?r=Zu(i,e):r=Wu(i,e),t==="desc"?-r:r}function Xu(i,e="asc"){return(t,s)=>Qu(i(t),i(s),e)}function Fs(i,e,t="asc"){let s=Xu(e,t);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 Ju=new Set(["text","number","select","date","checkbox","textarea"]),ed='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',vt=class extends S{static cssName="table";static defaults={columns:[],data:[],rowId:"ID",sort:null,sortMode:"local",selectable:!1,stickyHeader:!0,responsive:!1,growing:!1,height:null,emptyText:null,rowClass:null,rowKind:null,rowKinds:null,zebra:!0,variant:"default",editMode:!1,editTrigger:"double",hierarchy:!1,interactive:!1,label:null,labelledBy:null,rowReorder:!1,columnVisibility:!1,columnReorder:!1,hiddenColumns:[]};constructor(e,t={}){super(e,t)}render(){let e=this.el===null,t=this.el??c("div");if(this.el=t,this._createdRoot=e,this._original=e?null:H(t),this._columns=qo(this.options.columns),this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._rowKind=_d(this.options.rowKind),this._rowKinds=gd(this.options.rowKinds),this._spanning=this._hasSpanningRow(),this._sortWarned=!1,this._selected=new Set,this._selectionAnchorId=null,this._sort=Ho(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowNames=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=wd(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=Cd(this.options.growing),this._rendered=this._growStep??1/0,this._more=null,this._focusMode=this._editMode===!1?"row":"cell",this._interactive=!!(this.options.interactive||this.options.selectable||this._editMode!==!1||yi(this.options.hierarchy,this._columns)||this._clickListened),this._current=null,this._rovingEl=null,this._extendBase=null,this._hierarchy=yi(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._columnControlIds=new Map,this._columnStatus=null,this._expanded=bd(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let s of bi(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(s);return this._reconcileExpanded(),yd(this.options.variant)==="plain"&&(t.dataset.variant="plain"),this._table=c("table",{class:"zx-table__table"}),this._syncGridRole(),this._colgroup=c("colgroup",{class:"zx-table__columns"}),this._thead=c("thead",{class:"zx-table__head"}),this._tbody=c("tbody",{class:"zx-table__body"}),this._table.append(this._colgroup,this._thead,this._tbody),this._scroll=c("div",{class:"zx-table__scroll",dataset:{stickyHeader:String(!!this.options.stickyHeader),zebra:String(!!this.options.zebra)}},this._table),this._rowMoveMessage=this.options.rowReorder?c("div",{class:"zx-table__reorder-status",role:"status",ariaLive:"polite"}):null,this.options.height!=null&&(this._scroll.style.blockSize=typeof this.options.height=="number"?`${this.options.height}px`:String(this.options.height)),this._columnControls=this.options.columnVisibility||this.options.columnReorder?this._createColumnControls():null,this._editMode===!1?t.replaceChildren(...[this._columnControls,this._scroll,this._rowMoveMessage].filter(Boolean)):(t.dataset.editMode=this._editMode,this._editMessage=c("div",{class:"zx-table__message",id:E("zx-table-message"),role:"status",ariaLive:"polite"}),t.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.listen(this._columnControls,"click",s=>this._handleColumnControlClick(s)),this.listen(this._columnControls,"keydown",s=>this._handleColumnControlKeydown(s))),this._editMode!==!1&&(this.listen(this._tbody,"keydown",s=>this._handleEditKeydown(s)),this.listen(document,"pointerdown",s=>this._handleDocumentPointerDown(s),{capture:!0})),this.listen(this._tbody,"keydown",s=>this._handleGridKeydown(s)),this.listen(this._tbody,"focusin",s=>this._handleFocusIn(s)),t}setLoading(e=!0){return e?this.el.dataset.loading="true":delete this.el.dataset.loading,this.el.setAttribute("aria-busy",String(!!e)),this}setData(e){this._rendered=this._growStep??1/0,this.setLoading(!1),Ko(e),this._data=[...e],this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded();let t=this._pruneSelection();return this._renderBody(),t&&this._emitSelectionChange(),this._emitDataChange(),this}addData(e){return Ko(e),this._data.push(...e),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),this._emitDataChange(),this}updateRow(e,t){let s=this._data.findIndex(r=>Object.is(this._idFor(r),e));if(s<0)return this;let n=this._selected.delete(e);return this._data[s]=t,n&&this._selected.add(this._idFor(t)),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._reconcileExpanded(),this._renderBody(),n&&!Object.is(e,this._idFor(t))&&this._emitSelectionChange(),this._emitDataChange(),this}removeRow(e){let t=this._data.findIndex(n=>Object.is(this._idFor(n),e));if(t<0)return this;this._data.splice(t,1),this._reconcileExpanded();let s=this._selected.delete(e);return Object.is(this._selectionAnchorId,e)&&(this._selectionAnchorId=null),this._extendBase=null,this._renderBody(),s&&this._emitSelectionChange(),this._emitDataChange(),this}getRow(e){return this._data.find(t=>Object.is(this._idFor(t),e))??null}getData(){return[...this._data]}getColumns(){return this._columns.map(e=>({...e}))}setColumns(e,t={}){let s=qo(e),n=this.getColumnOrder(),r=this.getHiddenColumns(),o=this.getSort();return this._abortEdit({focus:!1}),this._columns=s,this._hiddenColumns=new Set(r.filter(a=>s.some(l=>l.id===a))),this._hiddenColumns.size>=s.length&&s[0]&&this._hiddenColumns.delete(s[0].id),this._sort=Ho(o,s),this._hierarchy=yi(this.options.hierarchy,s),this._reconcileExpanded(),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(),t.silent||(wi(n,this.getColumnOrder())||this.emit("columnorderchange",{order:this.getColumnOrder()}),wi(r,this.getHiddenColumns())||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()})),this}getColumnOrder(){return this._columns.map(e=>e.id)}setColumnOrder(e,t={}){let s=Ad(this._columns,e);if(wi(s,this.getColumnOrder()))return this;let n=this._activeColumnControl(),r=new Map(this._columns.map(o=>[o.id,o]));return this._abortEdit({focus:!1}),this._columns=s.map(o=>r.get(o)),this._hierarchy=yi(this.options.hierarchy,this._columns),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(n),t.silent||this.emit("columnorderchange",{order:this.getColumnOrder()}),this}moveColumn(e,t,s="before",n={}){if(s!=="before"&&s!=="after")throw new TypeError('Table column position must be "before" or "after"');let r=kd(this.getColumnOrder(),String(e),String(t),s);if(wi(r,this.getColumnOrder()))return this;if(this.setColumnOrder(r,n),this._columnStatus){let o=this._columns.find(l=>l.id===String(e)),a=this.getColumnOrder().indexOf(String(e));o&&a>=0&&(this._columnStatus.textContent=`Moved ${vi(o)} to position ${a+1} of ${this._columns.length}.`)}return this}getVisibleColumns(){return this._visibleColumns().map(e=>e.id)}getHiddenColumns(){return this._columns.filter(e=>this._hiddenColumns.has(e.id)).map(e=>e.id)}setColumnVisible(e,t=!0,s={}){let n=String(e);if(!this._columns.find(l=>l.id===n))throw new RangeError(`Unknown table column: ${n}`);let o=this._activeColumnControl();if(!t&&!this._hiddenColumns.has(n)&&this._visibleColumns().length<=1)return this._renderColumnControls(o),this;let a=t?this._hiddenColumns.delete(n):!this._hiddenColumns.has(n);return!t&&a&&this._hiddenColumns.add(n),a?(this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(o),s.silent||this.emit("columnvisibilitychange",{visible:this.getVisibleColumns(),hidden:this.getHiddenColumns()}),this):this}toggleColumn(e,t={}){return this.setColumnVisible(e,this._hiddenColumns.has(String(e)),t)}moveRow(e,t,s="before"){if(!this.options.rowReorder||this._sort&&this.options.sortMode==="local")return this;let n=this.getRow(e),r=this.getRow(t);if(!n||!r||Object.is(e,t))return this;if(this._isSpanningRow(n))return this;let o=Zo(this._data,this.options.rowId,e,t,s,this._hierarchy?.parentId);if(!o)return this;if(this.emit("rowmove",{row:n,id:e,target:r,targetId:t,position:s}).defaultPrevented)return this;if(this._data=o,this._renderBody(),this._rowMoveMessage){let l=this._siblingIds(e),u=l.findIndex(d=>Object.is(d,e));this._rowMoveMessage.textContent=`Moved row to position ${u+1} of ${l.length}.`}return this._emitDataChange(),queueMicrotask(()=>this._rowHandle(e)?.focus()),this}empty(){let e=this._selected.size>0;return this._data=[],this._expanded.clear(),this._selected.clear(),this._selectionAnchorId=null,this._extendBase=null,this._renderBody(),e&&this._emitSelectionChange(),this._emitDataChange(),this}setSort(e,t,s={}){if(this._spanning)return this._sortWarned||(this._sortWarned=!0,console.warn("[zx.Table] setSort() is inert while the data contains spanning rowKinds rows: sorting would scatter the rows out of the sections that group them.")),this;if(this._abortEdit({focus:!1}),!this._columns.find(o=>o.id===e))throw new RangeError(`Unknown table column: ${e}`);let r=t??(this._sort?.id===e&&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:e,dir:r},this.options.sortMode==="local"&&(this._sortData(),this._renderBody()),this._syncSortHeader(),s.silent||this.emit("sort",{id:e,dir:r}),this}getSort(){return this._sort?{...this._sort}:null}clearSort(e={}){return this._sort?(this._abortEdit({focus:!1}),this._sort=null,this._syncSortHeader(),e.silent||this.emit("sort",{id:null,dir:null}),this):this}getSelection(){return this._data.filter(e=>this._selected.has(this._idFor(e)))}setSelection(e){if(!Array.isArray(e))throw new TypeError("Table selection must be an array of row ids");let t=this._selectableIds(),s=new Set;if(this.options.selectable!==!1){for(let n of e)if(t.has(n)&&s.add(n),this.options.selectable==="single"&&s.size>0)break}return this._extendBase=null,Rs(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._extendBase=null,this._syncSelection(),this._emitSelectionChange(),this)}toggleRow(e,t={}){return this._expanded.has(e)?this.collapseRow(e,t):this.expandRow(e,t)}expandRow(e,t={}){return this._setRowExpanded(e,!0,t)}collapseRow(e,t={}){return this._setRowExpanded(e,!1,t)}expandAll(e={}){if(!this._hierarchy)return this;let s=bi(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(),!e.silent)for(let n of s)this._emitRowToggle(n,!0);return this}collapseAll(e={}){if(!this._hierarchy||this._expanded.size===0)return this;let t=[...this._expanded];if(this._expanded.clear(),this._renderBody(),!e.silent)for(let s of t)this._emitRowToggle(s,!1);return this}getExpanded(){return this._data.map(e=>this._idFor(e)).filter(e=>this._expanded.has(e))}startEdit(e,t){if(this._editMode===!1)return this;let s=this._columns.find(p=>p.id===t);if(!s)return this;let n=this._data.find(p=>Object.is(this._idFor(p),e));if(n===void 0)return this;if(this._isSpanningRow(n))return this;let r=this._editMode==="row"&&this._hiddenColumns.has(s.id)?this._visibleColumns().find(p=>Ge(p,n)!==!1)??null:s;if(!r||Ge(r,n)===!1)return this;let o=r.id;if(this._edit){if(Object.is(this._edit.id,e)&&this._edit.cells.has(o))return this._edit.columnId=o,this._focusEditor(o),this;if(this.commitEdit(),this._edit)return this}let a=this._data.findIndex(p=>Object.is(this._idFor(p),e));if(a<0)return this;let l=this._data[a],u=this._rowElements.get(e)?.[0];if(!u)return this;let d=this._editMode==="row"?this._visibleColumns().filter(p=>Ge(p,l)!==!1):[r],h=new Map;for(let p of d){let f=$o(u,p.id);if(!f)continue;let _=this._createEditor(f,p,l,a);_&&h.set(p.id,_)}return h.size===0?this:(this._edit={id:e,columnId:o,row:l,cells:h,tr:u},u.dataset.editing="true",this.emit("editstart",{row:l,id:e,column:r,columnId:o,value:l?.[o]}),this._focusEditor(o),this)}commitEdit(){let e=this._edit;if(!e)return this;let t=this.getRow(e.id)??e.row,s={};for(let[h,p]of e.cells)s[h]=p.read();let n=this._columns.filter(h=>e.cells.has(h.id)),r=md(s,n,t,this._msgOr("table.invalid","Invalid value"));if(r)return this._markInvalid(r.columnId,r.message),e.columnId=r.columnId,this.emit("editinvalid",{row:t,id:e.id,column:this._columns.find(h=>h.id===r.columnId)??null,columnId:r.columnId,value:s[r.columnId],message:r.message}),this._focusEditor(r.columnId),this;this._clearInvalid();let o=pd(t,s),a=e.columnId;if(this.emit("editcommit",{row:t,id:e.id,column:this._columns.find(h=>h.id===a)??null,columnId:a,value:s[a],previous:t?.[a],changes:o}).defaultPrevented)return this;let u=this._editHasFocus(),d={...t,...o};return this._teardownEdit(),Object.keys(o).length>0&&this.updateRow(e.id,d),u&&this._focusCell(this._idFor(d),a),this}cancelEdit(){return this._abortEdit({focus:!0}),this}isEditing(){return this._edit!==null}getEditing(){return this._edit?{id:this._edit.id,columnId:this._edit.columnId}:null}_visibleData(){return this._visibleEntries().map(e=>e.row)}_projectedData(){return this._hierarchy?cd(this._data,this.options.rowId,this._hierarchy.parentId,this._expanded):this._data.map((e,t)=>({row:e,id:this._idFor(e),index:t,depth:0,hasChildren:!1,parentId:null}))}_visibleEntries(){let e=this._projectedData();return this._rendered===1/0?e:e.slice(0,this._rendered)}growBy(e){if(!this._growStep)return this;let t=Number(e)>0?Math.trunc(Number(e)):this._growStep,s=this._rendered,n=this._projectedData().length;return this._rendered=Math.min(n,this._rendered+t),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 e=this._projectedData().length-this.getRenderedCount();if(e<=0){this._more?.remove(),this._more=null;return}let t=this._message("table.more","Show %1 more",[e]);this._more||(this._more=c("button",{class:"zx-table__more",type:"button",onclick:()=>this.growBy()}),this.el.append(this._more)),this._more.textContent=t,this._more.setAttribute("aria-label",t)}_message(e,t,s){let n=this.msg(e,...s);return n===e?O(t,s):n}_watchWidth(){this._width?.destroy(),this._width=null;let e=this.options.responsive;!e||!(e in _i)||(this._width=Eo((t,s)=>this._setStacked(s>0&&s<_i[e]),{target:this.el}))}_setStacked(e){this._stacked!==e&&(this._stacked=e,this.el.toggleAttribute("data-stacked",e),this._applyStackedRoles(e),this.emit("stackedchange",{stacked:e}))}addEventListener(e,t,s){super.addEventListener(e,t,s),!(!t||e!=="rowclick"&&e!=="rowdblclick")&&(this._clickListened=!0,this._table&&!this._interactive&&(this._interactive=!0,this._syncGridRole(),this._renderBody()))}_gridRole(){return this._interactive?this._hierarchy?"treegrid":"grid":null}_syncGridRole(){let e=this._table,t=this._gridRole();t?e.setAttribute("role",t):e.removeAttribute("role"),this.options.labelledBy?e.setAttribute("aria-labelledby",String(this.options.labelledBy)):(this.options.label!=null||t)&&e.setAttribute("aria-label",this.options.label??this._message("table.label","Table",[])),t&&this.options.selectable==="multi"&&e.setAttribute("aria-multiselectable","true"),t?this.el.dataset.focus=this._focusMode:delete this.el.dataset.focus}_applyStackedRoles(e){let t=this._gridRole();t?this._table.setAttribute("role",t):e?this._table.setAttribute("role","table"):this._table.removeAttribute("role");for(let s of[this._thead,this._tbody])e?s.setAttribute("role","rowgroup"):s.removeAttribute("role");for(let[s,n]of[["tr","row"],["td",t?"gridcell":"cell"],["th","columnheader"]])for(let r of this._table.querySelectorAll(s))e?r.setAttribute("role",n):r.removeAttribute("role")}isStacked(){return!!this._stacked}destroy(){this._teardownEdit(),this._width?.destroy(),this._width=null,!this._restored&&!this._createdRoot&&(K(this.el,this._original),this._restored=!0),super.destroy()}_visibleColumns(){return this._columns.filter(e=>!this._hiddenColumns.has(e.id))}_isSpanningRow(e){return this._rowKind===null||this._rowKinds===null?!1:Wo(e,this._rowKind,this._rowKinds)}_hasSpanningRow(){return rd(this._data,this._rowKind,this._rowKinds)}_spanColspan(){return od(this._visibleColumns().length,{selectable:this.options.selectable,rowReorder:this.options.rowReorder})}_selectableData(){let e=this._visibleData();return this._rowKind===null?e:e.filter(t=>!this._isSpanningRow(t))}_createColumnControls(){let e=c("div",{class:"zx-table__column-list"});this._columnList=e,this._columnStatus=c("div",{class:"zx-table__column-status",role:"status",ariaLive:"polite"});let t=c("details",{class:"zx-table__column-controls"},c("summary",{class:"zx-btn",dataset:{size:"sm"}},v("fields"),this._message("table.columns","Columns",[])),e);return this._renderColumnControls(),t}_renderColumnControls(e=null){if(!this._columnList)return;let t=this._visibleColumns(),s=this._columns.map((n,r)=>{let o=!this._hiddenColumns.has(n.id),a=this._columnControlIds.get(n.id);a||(a=E("zx-table-column"),this._columnControlIds.set(n.id,a));let l=this.options.columnVisibility?c("input",{id:a,class:"zx-table__column-toggle",type:"checkbox",value:n.id,checked:o,disabled:o&&t.length===1,dataset:{columnId:n.id,columnAction:"toggle"}}):null,u=vi(n),d=l?c("label",{for:a},l,c("span",{},u)):c("span",{class:"zx-table__column-label"},u),h=this.options.columnReorder?c("span",{class:"zx-table__column-order",role:"group",ariaLabel:this._message("table.moveColumn","Move %1",[u])},c("button",{class:"zx-table__column-move",type:"button",disabled:r===0,ariaLabel:`Move ${u} earlier`,dataset:{columnId:n.id,columnAction:"up"}},v("chevron-up",{size:11})),c("button",{class:"zx-table__column-move",type:"button",disabled:r===this._columns.length-1,ariaLabel:`Move ${u} later`,dataset:{columnId:n.id,columnAction:"down"}},v("chevron-down",{size:11}))):null;return c("div",{class:"zx-table__column-option",dataset:{columnId:n.id}},d,h)});if(this._columnList.replaceChildren(...s,this._columnStatus),e!==null){let n=[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===e.id&&o.dataset.columnAction===e.action});n?.disabled&&(n=[...this._columnList.querySelectorAll(".zx-table__column-move[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===e.id&&!o.disabled})??[...this._columnList.querySelectorAll("[data-column-action]")].find(r=>{let o=r;return o.dataset.columnId===e.id&&!o.disabled})),queueMicrotask(()=>{n?.isConnected&&n.focus()})}}_activeColumnControl(){let e=typeof document>"u"?null:document.activeElement;if(!e||!this._columnList?.contains(e))return null;let t=e.dataset.columnId,s=e.dataset.columnAction;return t&&s?{id:t,action:s}:null}_handleColumnControlClick(e){let t=e.target?.closest?.(".zx-table__column-move");if(!t||!this._columnList?.contains(t))return;let s=t.dataset.columnId,n=t.dataset.columnAction,r=this.getColumnOrder().indexOf(String(s));n==="up"&&r>0&&this.moveColumn(String(s),this._columns[r-1].id,"before"),n==="down"&&r>=0&&r<this._columns.length-1&&this.moveColumn(String(s),this._columns[r+1].id,"after")}_handleColumnControlKeydown(e){let t=e.target?.closest?.(".zx-table__column-move");if(!t||!this._columnList?.contains(t))return;let s=String(t.dataset.columnId),n=this.getColumnOrder(),r=n.indexOf(s);r<0||(e.key==="ArrowUp"||e.key==="ArrowLeft"?(e.preventDefault(),r>0&&this.moveColumn(s,n[r-1],"before")):e.key==="ArrowDown"||e.key==="ArrowRight"?(e.preventDefault(),r<n.length-1&&this.moveColumn(s,n[r+1],"after")):e.key==="Home"?(e.preventDefault(),r>0&&this.moveColumn(s,n[0],"before")):e.key==="End"&&(e.preventDefault(),r<n.length-1&&this.moveColumn(s,n.at(-1),"after")))}_handleRowDragStart(e){let t=e.target?.closest?.(".zx-table__row-handle"),s=t?.closest("tr[data-row]"),n=s?this._rowMeta.get(s):null;if(!t||!n||this._sort&&this.options.sortMode==="local"){e.preventDefault();return}this._dragId=n.id,s.dataset.dragging="true",e.dataTransfer?.setData("text/plain","zx-table-row"),e.dataTransfer&&(e.dataTransfer.effectAllowed="move")}_handleRowDragOver(e){if(this._dragId==null)return;let t=e.target?.closest?.("tr[data-row]"),s=t?this._rowMeta.get(t):null;if(!s||Object.is(s.id,this._dragId)||!this._canMoveTogether(this._dragId,s.id))return;e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move"),this._clearDropMarkers();let n=t.getBoundingClientRect();t.dataset.drop=e.clientY>=n.top+n.height/2?"after":"before"}_handleRowDrop(e){if(this._dragId==null)return;let t=e.target?.closest?.("tr[data-row]"),s=t?this._rowMeta.get(t):null,n=t?.dataset.drop==="after"?"after":"before";s&&this._canMoveTogether(this._dragId,s.id)&&(e.preventDefault(),this.moveRow(this._dragId,s.id,n)),this._clearRowDrag()}_handleRowHandleKeydown(e){let t=e.target?.closest?.(".zx-table__row-handle"),s=t?.closest("tr[data-row]"),n=s?this._rowMeta.get(s):null;if(!t||!n)return;if(e.key===" "||e.key==="Enter"){e.preventDefault(),this._grabbedId=Object.is(this._grabbedId,n.id)?null:n.id,t.setAttribute("aria-pressed",String(this._grabbedId!=null));let l=this._rowMoveMessage??this._editMessage;l&&(l.textContent=this._grabbedId==null?"Row dropped":"Row grabbed. Use the arrow keys to move it.");return}if(e.key==="Escape"&&this._grabbedId!=null){e.preventDefault(),this._grabbedId=null,t.setAttribute("aria-pressed","false");return}if(!Object.is(this._grabbedId,n.id)||!["ArrowUp","ArrowDown"].includes(e.key))return;e.preventDefault();let r=this._siblingIds(n.id),o=r.findIndex(l=>Object.is(l,n.id)),a=r[o+(e.key==="ArrowUp"?-1:1)];a!==void 0&&this.moveRow(n.id,a,e.key==="ArrowUp"?"before":"after")}_siblingIds(e){let t=this.getRow(e);if(!t)return[];let s=this._hierarchy?G(this._hierarchy.parentId,t):null;return this._data.filter(n=>!this._hierarchy||Ps(G(this._hierarchy.parentId,n),s)).map(n=>this._idFor(n))}_canMoveTogether(e,t){if(!this._hierarchy)return!0;let s=this.getRow(e),n=this.getRow(t);return!!(s&&n&&Ps(G(this._hierarchy.parentId,s),G(this._hierarchy.parentId,n)))}_rowHandle(e){return this._rowElements.get(e)?.[0]?.querySelector(".zx-table__row-handle")??null}_clearDropMarkers(){for(let e of this._tbody.querySelectorAll("tr[data-drop]"))delete e.dataset.drop}_clearRowDrag(){for(let e of this._tbody.querySelectorAll("tr[data-dragging]"))delete e.dataset.dragging;this._clearDropMarkers(),this._dragId=null}_hierarchyColumn(){return this._hierarchy?this._visibleColumns().some(e=>e.id===this._hierarchy.column)?this._hierarchy.column:this._visibleColumns()[0]?.id??null:null}_renderColumns(){let e=document.createDocumentFragment();this.options.rowReorder&&e.append(c("col",{class:"zx-table__reorder-column"})),this.options.selectable==="multi"&&e.append(c("col",{class:"zx-table__selection-column"}));let t=this._visibleColumns(),s=t.map(r=>zd(r.width)),n=s.reduce((r,o)=>r+o,0);this._table.dataset.layout=n>0?"fixed":"auto",t.forEach((r,o)=>{let a=c("col");s[o]>0?a.style.width=`${s[o]/n*100}%`:r.width&&r.width!=="auto"&&(a.style.width=String(r.width)),e.append(a)}),this._colgroup.replaceChildren(e)}_renderHeader(){let e=c("tr",{class:"zx-table__header-row"});if(this._growStep&&e.setAttribute("aria-rowindex","1"),this.options.rowReorder&&e.append(c("th",{class:"zx-table__reorder-header",scope:"col",ariaLabel:"Row order"})),this.options.selectable==="multi"){this._selectAll=c("input",{class:"zx-table__checkbox zx-table__select-all",type:"checkbox",ariaLabel:this._message("table.selectAll","Select all rows",[])});let t=c("th",{class:"zx-table__selection-header",scope:"col"},this._selectAll);e.append(t),this.listen(this._selectAll,"click",()=>{if(this._selectAll.checked)for(let s of this._selectableData())this._selected.add(this._idFor(s));else for(let s of this._selectableData())this._selected.delete(this._idFor(s));this._selectionAnchorId=null,this._extendBase=null,this._syncSelection(),this._emitSelectionChange()})}else this._selectAll=null;this._headers=new Map,this._headerSpanning=this._spanning;for(let t of this._visibleColumns()){let s=c("th",{scope:"col",dataset:{column:t.id}}),n=t.align??(Ls(t)?"end":null);n&&(s.dataset.align=n),t.headerTitle&&(s.title=t.headerTitle);let r=xd(t);if(r!==null&&s.setAttribute("aria-label",r),t.sortable&&!this._spanning){let o=c("button",{class:"zx-table__sort-button",type:"button",ariaLabel:r??void 0},c("span",{class:"zx-table__header-label"},t.label));this.listen(o,"click",()=>{let a=this._sort?.id===t.id&&this._sort.dir==="asc"?"desc":"asc";this.setSort(t.id,a)}),s.append(o)}else s.append(c("span",{class:"zx-table__header-label"},t.label));this._headers.set(t.id,s),e.append(s)}this._thead.replaceChildren(e),this._syncSortHeader()}_renderBody(){let e=this._captureFocus();this._abortEdit({focus:!1}),this._extendBase=null,this._selectionAnchorId=null,this._spanning=this._hasSpanningRow(),this._headers&&this._spanning!==this._headerSpanning&&this._renderHeader();let t=document.createDocumentFragment();this._rowMeta=new WeakMap,this._rowNames=new WeakMap,this._rowElements=new Map,this._rovingEl=null;let s=this._projectedData();this._hierarchyMeta=new Map(s.map(n=>[n.id,n])),this._data.length===0?t.append(c("tr",{class:"zx-table__empty-row"},c("td",{class:"zx-table__empty",colspan:this._spanColspan()},this._emptyContent()))):this._visibleEntries().forEach((n,r)=>{t.append(this._createRow(n.row,n.index,{...n,visibleIndex:r}))}),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(s.length+1)),this._syncSelectAll(),this._syncGrowing(),this._stacked&&this._applyStackedRoles(!0),this._syncRoving(e)}_emptyContent(){let e=this.options.emptyText;return e==null?this.msg("table.empty"):typeof e=="function"?e():e}_createRow(e,t,s){let n=this._idFor(e),r=c("tr",{dataset:{row:""}});this._growStep&&r.setAttribute("aria-rowindex",String(s.visibleIndex+2));let o=typeof this.options.rowClass=="function"?this.options.rowClass(e):"";o&&r.classList.add(...String(o).split(/\s+/).filter(Boolean));let a=this._rowKind===null?null:Uo(e,this._rowKind),l=a===null?null:Yo(this._rowKinds,a),u=!!l?.span;a!==null&&(r.dataset.rowKind=a),l?.class&&r.classList.add(...String(l.class).split(/\s+/).filter(Boolean)),this.options.selectable!==!1&&!u&&r.setAttribute("aria-selected",String(this._selected.has(n))),this._hierarchy&&(r.setAttribute("aria-level",String(s.depth+1)),s.hasChildren&&r.setAttribute("aria-expanded",String(this._expanded.has(n)))),this._interactive&&(this._focusMode==="row"||this._hierarchy)&&(r.tabIndex=-1),this._rowMeta.set(r,{row:e,id:n,index:t,visibleIndex:s.visibleIndex});let d=this._rowElements.get(n)??[];if(d.push(r),this._rowElements.set(n,d),u){r.dataset.span="true";let h=c("th",{class:"zx-table__section-cell",scope:"colgroup",colspan:this._spanColspan()}),p=ad(e,l,this._visibleColumns(),t);return p&&typeof p=="object"&&typeof p.nodeType=="number"?h.append(p):p!=null&&h.append(document.createTextNode(String(p))),this._focusMode==="cell"&&(h.tabIndex=-1),r.append(h),r}if(this.options.rowReorder){let h=c("button",{class:"zx-table__row-handle",type:"button",draggable:!0,dataset:{rowHandle:""},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},v("drag",{size:14}));r.append(c("td",{class:"zx-table__reorder-cell"},h))}if(this.options.selectable==="multi"){let h=c("input",{class:"zx-table__checkbox zx-table__row-checkbox",type:"checkbox",tabIndex:-1,checked:this._selected.has(n)});r.append(c("td",{class:"zx-table__selection-cell"},h))}return this._visibleColumns().forEach(h=>{let p=c("td"),f=h.align??(Ls(h)?"end":null);f&&(p.dataset.align=f),p.dataset.label=h.label,p.dataset.column=h.id,h.popin===!1&&(p.dataset.popin="false"),this._focusMode==="cell"&&(p.tabIndex=-1),this._editMode!==!1&&Ge(h,e)!==!1&&(p.dataset.editable="true"),this._renderCellContent(p,h,e,t,s),r.append(p)}),this._rowNames.set(r,nd([...r.cells].map(h=>h.textContent))),this._labelRowControls(r),r}_labelRowControls(e){let t=this._rowMeta.get(e);if(!t)return;let s=this._rowNames.get(e)??this._message("table.row","row %1",[t.index+1]);e.querySelector(".zx-table__row-checkbox")?.setAttribute("aria-label",this._message("table.selectRow","Select %1",[s])),e.querySelector(".zx-table__row-handle")?.setAttribute("aria-label",this._message("table.moveRow","Move %1",[s]));let r=e.querySelector(".zx-table__tree-toggle");if(r){let o=r.getAttribute("aria-expanded")==="true";r.setAttribute("aria-label",o?this._message("table.collapseRow","Collapse %1",[s]):this._message("table.expandRow","Expand %1",[s]))}}_renderCellContent(e,t,s,n,r=this._hierarchyMeta?.get(this._idFor(s))){let o=ld(t,s,n),a=c("span",{class:"zx-table__cell-content"});if(o&&typeof o=="object"&&typeof o.nodeType=="number"?a.append(o):o!=null&&a.append(document.createTextNode(String(o))),!this._hierarchy||t.id!==this._hierarchyColumn()||!r){e.replaceChildren(...a.childNodes);return}let l=c("span",{class:"zx-table__tree-cell"});if(l.style.setProperty("--zx-table-depth",String(r.depth)),r.hasChildren){let u=this._expanded.has(r.id);l.append(c("button",{class:"zx-table__tree-toggle",type:"button",tabIndex:-1,ariaExpanded:String(u)},v(u?"chevron-down":"chevron-right",{size:14})))}else l.append(c("span",{class:"zx-table__tree-spacer",ariaHidden:"true"}));l.append(a),e.replaceChildren(l),e.parentElement&&this._labelRowControls(e.parentElement)}_handleBodyClick(e){let t=e.target?.nodeType===1?e.target:e.target?.parentElement;if(this._edit&&wt(t))return;let s=t?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s);if(!n||t.closest(".zx-table__row-handle")||this._edit&&(this.commitEdit(),this._edit))return;if(t.closest(".zx-table__tree-toggle")){this.toggleRow(n.id);return}let o=t.closest(".zx-table__row-checkbox");if(o&&this.options.selectable==="multi"){this._toggleMultiSelection(n,o.checked,e.shiftKey);return}if(!(this._editMode!==!1&&Vo(t))){if(this._editMode!==!1&&this._editTrigger==="single"){let a=t?.closest('td[data-editable="true"]');if(a&&this._tbody.contains(a)){this.startEdit(n.id,String(a.dataset.column));return}}this._activateRow(n,e)}}_activateRow(e,t){this.emit("rowclick",{...e,event:t}),this.options.selectable==="single"&&!this._selected.has(e.id)&&!this._isSpanningRow(e.row)&&(this._selected=new Set([e.id]),this._selectionAnchorId=e.id,this._extendBase=null,this._syncSelection(),this._emitSelectionChange())}_handleBodyDoubleClick(e){let t=e.target?.nodeType===1?e.target:e.target?.parentElement;if(t?.closest(".zx-table__row-checkbox")||this._edit&&wt(t))return;let s=t?.closest("tr[data-row]");if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s);if(n&&!(this._editMode!==!1&&Vo(t))){if(this._editMode!==!1&&this._editTrigger==="double"){let r=t?.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:e})}}_createEditor(e,t,s,n){let r=Ge(t,s);if(r===!1)return null;let o=s?.[t.id],a=t.editorProps&&typeof t.editorProps=="object"?t.editorProps:{},l=c("span",{class:"zx-table__cell-shadow",ariaHidden:"true"});l.append(...e.childNodes);let u=c("div",{class:"zx-table__editor",dataset:{editor:r}});e.replaceChildren(l,u),e.dataset.editing="true";let d={column:t,type:r,td:e,host:u,control:null,component:null,read:()=>o,destroy(){this.component?.destroy(),this.host.remove()}};if(r==="custom"){d.custom=o,d.read=()=>Me(t,d.custom,s);let f={value:o,row:s,column:t,commit:m=>{d.custom=m,this.commitEdit()},cancel:()=>this.cancelEdit()},_=t.editor(s,f);return _&&typeof _.toElement=="function"?(typeof _.destroy=="function"&&(d.component=_),u.append(_.toElement())):_&&u.append(_),d.control=u.querySelector(ed)??u,d}if(r==="number"){let f=Ne(t.locale,s),_=Go(t,s),m=t.type==="currency"?Ne(t.currency,s):t.type==="unit"?Ne(t.unit,s):null,g={...f!=null&&!Object.prototype.hasOwnProperty.call(a,"locale")?{locale:f}:{},..._!=null&&!Object.prototype.hasOwnProperty.call(a,"precision")?{precision:_}:{},...m!=null&&!Object.prototype.hasOwnProperty.call(a,"unit")?{unit:String(m)}:{}},b=new He(null,{...g,...a,value:o??null});return u.append(b.el),d.component=b,d.control=b.getInput(),d.read=()=>(b.set(b.getInput().value,{silent:!0}),Me(t,b.get(),s)),d}if(r==="select"){let f=dd(t.options,s),_=f.find(g=>Object.is(g.value,o))??f.find(g=>String(g.value)===String(o??"")),m=new q(null,{...a,items:f,valueKey:"value",labelKey:"label",value:_?_.value:null});return u.append(m.el),d.component=m,d.control=m.refs.input,d.read=()=>Me(t,m.value,s),d}if(r==="date"){let f=new Ie(null,{...a,value:o??null});u.append(f.el),d.component=f;let _=f.refs.input;return d.control=_,d.read=()=>{let m=String(_.value??"").trim(),g=f.get();return m===""?Me(t,null,s):(f.set(m,{silent:!0}),f.get()===null&&f.set(g,{silent:!0}),Me(t,f.get(),s))},d}if(r==="checkbox"){let f=new Ke(null,{...a,checked:!!o});return u.append(f.el),d.component=f,d.control=f.el,d.read=()=>Me(t,f.get(),s),d}let h=r==="textarea",p=c(h?"textarea":"input",{...a,class:h?"zx-table__editor-input zx-table__editor-textarea":"zx-table__editor-input",...h?{}:{type:"text"},ariaLabel:a.ariaLabel??`${vi(t)} row ${n+1}`,value:hd(t,o,s)});return u.append(p),d.control=p,d.read=()=>Me(t,p.value,s),d}_focusEditor(e){let t=this._edit?.cells.get(e),s=t?.control;!s||typeof s.focus!="function"||(s.focus(),Sd(t.type)&&typeof s.select=="function"&&s.select())}_focusCell(e,t){let s=this._rowElements.get(e)?.[0];(s?$o(s,t):null)?.focus()}_teardownEdit(){let e=this._edit;if(!e)return;this._edit=null;let t=this._data.findIndex(n=>Object.is(this._idFor(n),e.id)),s=t<0?e.row:this._data[t];for(let n of e.cells.values())n.destroy(),delete n.td.dataset.editing,delete n.td.dataset.invalid,this._renderCellContent(n.td,n.column,s,t<0?0:t);e.cells.clear(),delete e.tr.dataset.editing,this._clearInvalid()}_abortEdit({focus:e=!0}={}){let t=this._edit;if(!t)return;let s=e&&this._editHasFocus(),n=this.getRow(t.id)??t.row,r=this._columns.find(o=>o.id===t.columnId)??null;this._teardownEdit(),s&&this._focusCell(t.id,t.columnId),this.emit("editcancel",{row:n,id:t.id,column:r,columnId:t.columnId})}_editHasFocus(){let e=document.activeElement;return!!(e&&this.el?.contains(e))}_markInvalid(e,t){this._clearInvalid();let s=this._edit?.cells.get(e);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=t))}_clearInvalid(){if(this._edit)for(let e of this._edit.cells.values())delete e.td.dataset.invalid,e.control?.removeAttribute("aria-invalid"),e.control?.removeAttribute("aria-describedby");this._editMessage&&(this._editMessage.textContent="")}_handleEditKeydown(e){let t=e.target?.nodeType===1?e.target:e.target?.parentElement;if(!t)return;if(this._edit&&wt(t)){if(vd(t))return;if(e.key==="Escape"){if(e.defaultPrevented)return;e.preventDefault(),this.cancelEdit();return}if(e.key==="Enter"){if(t.localName==="textarea"&&e.shiftKey)return;e.preventDefault(),this.commitEdit();return}e.key==="Tab"&&this._moveEdit(e);return}if(e.key!=="Enter"&&e.key!=="F2")return;let s=t.closest('td[data-editable="true"]');if(!s||!this._tbody.contains(s))return;let n=this._rowMeta.get(s.parentElement);n&&(e.preventDefault(),this.startEdit(n.id,String(s.dataset.column)))}_moveEdit(e){let t=this._edit;if(!t)return;let s=e.shiftKey?-1:1,n=this._data.findIndex(o=>Object.is(this._idFor(o),t.id)),r=this._nextEditableCell(n,t.columnId,s);if(r&&Object.is(r.id,t.id)&&t.cells.has(r.columnId)){e.preventDefault(),t.columnId=r.columnId,this._focusEditor(r.columnId);return}if(!r){this.commitEdit(),this._edit&&e.preventDefault();return}e.preventDefault(),this.commitEdit(),this._edit||this.startEdit(r.id,r.columnId)}_nextEditableCell(e,t,s){let n=this._visibleColumns(),r=n.length;if(e<0||r===0)return null;let o=this._visibleData(),a=this._idFor(this._data[e]),l=o.findIndex(h=>Object.is(this._idFor(h),a));if(l<0)return null;let u=n.findIndex(h=>h.id===t),d=o.length*r+r;for(let h=0;h<d;h+=1){if(u+=s,u>=r?(l+=1,u=0):u<0&&(l-=1,u=r-1),l<0||l>=o.length)return null;let p=o[l],f=n[u];if(!this._isSpanningRow(p)&&Ge(f,p)!==!1)return{id:this._idFor(p),columnId:f.id,index:this._data.indexOf(p)}}return null}_handleDocumentPointerDown(e){if(!this._edit)return;let t=e.target?.nodeType===1?e.target:e.target?.parentElement;t&&wt(t)||t&&this._tbody.contains(t)||this.commitEdit()}_navRows(){return[...this._tbody.children].filter(e=>e.hasAttribute("data-row"))}_navCells(e){return[...e.cells].filter(t=>t.hasAttribute("data-column")||t.classList.contains("zx-table__section-cell"))}_cellFor(e){let t=this._navCells(e);if(t.length===0)return e;let s=this._current?.columnId;return(s==null?null:t.find(r=>r.dataset.column===s))??t[Math.min(Math.max(this._current?.columnIndex??0,0),t.length-1)]}_rovingTarget(e){return this._focusMode==="row"||this._hierarchy&&this._current?.onRow?e:this._cellFor(e)}_setRoving(e){this._rovingEl&&this._rovingEl!==e&&(this._rovingEl.tabIndex=-1),e.tabIndex=0,this._rovingEl=e}_captureFocus(){let e=typeof document>"u"?null:document.activeElement;if(e&&e===this._scroll&&this._scroll.hasAttribute("data-empty-focus"))return{part:"row"};if(!e||!this._tbody?.contains(e))return null;let t=e.closest("tr[data-row]");return t?e===t?{part:"row"}:e.closest(".zx-table__row-checkbox")?{part:"checkbox"}:e.closest(".zx-table__tree-toggle")?{part:"toggle"}:e.closest(".zx-table__row-handle")?{part:"handle"}:{part:this._focusMode==="cell"?"cell":"row"}:null}_syncRoving(e){if(!this._interactive)return;let t=this._navRows();if(this._syncEmptyFocus(t.length===0&&e!==null),t.length===0)return;let s=this._current?this._rowElements.get(this._current.id)?.[0]:void 0;if(!s&&this._current&&this._hierarchy&&(s=this._renderedAncestor(this._current.id),s)){let a=this._rowMeta.get(s);this._current={...this._current,id:a.id,visibleIndex:a.visibleIndex,onRow:!0}}if(!s&&(s=t[Math.min(Math.max(this._current?.visibleIndex??0,0),t.length-1)],this._current)){let a=this._rowMeta.get(s);this._current={...this._current,id:a.id,visibleIndex:a.visibleIndex}}let n=this._rovingTarget(s);if(this._setRoving(n),!e)return;let r={checkbox:".zx-table__row-checkbox",toggle:".zx-table__tree-toggle",handle:".zx-table__row-handle:not(:disabled)"}[e.part];(r?s.querySelector(r)??n:n).focus({preventScroll:!0})}_renderedAncestor(e){if(!this._hierarchy)return;let t=new Set,s=this.getRow(e);for(;s;){let n=G(this._hierarchy.parentId,s);if(n==null||t.has(n))return;t.add(n);let r=this._rowElements.get(n)?.[0];if(r)return r;s=this.getRow(n)}}_syncEmptyFocus(e){let t=this._scroll;e?(t.hasAttribute("tabindex")||(t.tabIndex=-1,t.setAttribute("data-empty-focus","")),t.focus({preventScroll:!0})):t.hasAttribute("data-empty-focus")&&(t.removeAttribute("tabindex"),t.removeAttribute("data-empty-focus"))}_handleFocusIn(e){if(!this._interactive)return;let t=e.target?.nodeType===1?e.target:null,s=t?.closest("tr[data-row]")??null;if(!s||s.parentElement!==this._tbody)return;let n=this._rowMeta.get(s);if(!n)return;let r={id:n.id,visibleIndex:n.visibleIndex,columnId:this._current?.columnId??null,columnIndex:this._current?.columnIndex??0,onRow:!1},o=s;if(this._focusMode==="cell"){let a=this._navCells(s),l=a.find(u=>u===t||u.contains(t))??null;t===s&&this._hierarchy?r.onRow=!0:l?(o=l,l.dataset.column&&(r.columnId=l.dataset.column,r.columnIndex=a.indexOf(l))):(this._current=r,o=this._cellFor(s))}this._current=r,this._setRoving(o)}_handleGridKeydown(e){if(!this._interactive||e.defaultPrevented||e.altKey)return;let t=e.target?.nodeType===1?e.target:null;if(!t||this._edit&&wt(t))return;let s=t.closest("tr[data-row]");if(!s||s.parentElement!==this._tbody)return;let n=this._rowMeta.get(s);if(!n)return;let r=this._focusMode==="cell",o=r?this._navCells(s):[],a=t===s,l=o.includes(t),u=t.matches(".zx-table__row-checkbox, .zx-table__tree-toggle");if(!a&&!l&&!u)return;let d=e.key,h=e.ctrlKey||e.metaKey;if(h&&(d==="a"||d==="A")){if(this.options.selectable!=="multi")return;e.preventDefault(),this._selectAllRendered();return}if((d==="Enter"||d===" ")&&!u){if(h)return;e.preventDefault(),d===" "&&this.options.selectable!==!1&&!this._isSpanningRow(n.row)?this._toggleRowSelection(n):this._activateRow(n,e);return}if(this._hierarchy&&(d==="ArrowLeft"||d==="ArrowRight")&&!h){let y=this._hierarchyMeta?.get(n.id);if(!y)return;e.preventDefault();let A=sd(d,{focus:l?"cell":"row",cells:r,column:l?o.indexOf(t):0,columns:o.length,hasChildren:y.hasChildren,expanded:this._expanded.has(n.id),hasParent:y.parentId!=null});A&&this._applyTreeAction(A,s,n,y.parentId);return}let p=this._navRows(),f=p.indexOf(s),_=r&&!a,m=l?o.indexOf(t):Math.max(0,o.indexOf(this._cellFor(s))),g=td({row:f,column:m},d,{rows:p.length,columns:_?o.length:1,page:this._pageSize(p),ctrl:h,cells:_});if(!g)return;e.preventDefault();let b=p[g.row];if(!_)b.focus();else if(g.row===f||d==="Home"||d==="End"){let y=this._navCells(b),A=g.column>=o.length-1&&d!=="Home";y[A?y.length-1:Math.min(g.column,y.length-1)]?.focus()}else this._cellFor(b).focus();e.shiftKey&&this.options.selectable==="multi"&&g.row!==f&&this._extendSelection(n,this._rowMeta.get(b))}_applyTreeAction(e,t,s,n){if(e.action==="expand")this.expandRow(s.id);else if(e.action==="collapse")this.collapseRow(s.id);else if(e.action==="parent")this._rowElements.get(n)?.[0]?.focus();else if(e.action==="child"){let r=this._navRows();r[r.indexOf(t)+1]?.focus()}else e.action==="row"?t.focus():e.action==="cell"&&this._navCells(t)[e.column??0]?.focus()}_pageSize(e){let t=this._scroll;if(!t||!e[0]||t.scrollHeight<=t.clientHeight+1)return 10;let s=this.options.stickyHeader?this._thead.getBoundingClientRect().height:0;return id(t.clientHeight-s,e[0].getBoundingClientRect().height)}_toggleRowSelection(e){let t=this._selected.has(e.id);if(this.options.selectable==="multi"){this._toggleMultiSelection(e,!t,!1);return}this._selected=t?new Set:new Set([e.id]),this._selectionAnchorId=e.id,this._extendBase=null,this._syncSelection(),this._emitSelectionChange()}_selectAllRendered(){let e=new Set(this._selected);for(let t of this._selectableData())e.add(this._idFor(t));this._extendBase=null,!Rs(e,this._selected)&&(this._selected=e,this._syncSelection(),this._emitSelectionChange())}_extendSelection(e,t){if(!t)return;let s=this._visibleData(),n=l=>s.findIndex(u=>Object.is(this._idFor(u),l));this._extendBase===null&&(this._extendBase=new Set(this._selected),n(this._selectionAnchorId)<0&&(this._selectionAnchorId=e.id));let r=n(this._selectionAnchorId),o=n(t.id);if(r<0||o<0)return;let a=new Set(this._extendBase);for(let l=Math.min(r,o);l<=Math.max(r,o);l+=1)this._isSpanningRow(s[l])||a.add(this._idFor(s[l]));Rs(a,this._selected)||(this._selected=a,this._syncSelection(),this._emitSelectionChange())}_msgOr(e,t){let s=this.msg(e);return s===e?t:s}_toggleMultiSelection(e,t,s){let n=this._visibleData(),r=n.findIndex(o=>Object.is(this._idFor(o),this._selectionAnchorId));if(s&&r>=0){let o=e.visibleIndex??n.findIndex(u=>Object.is(this._idFor(u),e.id)),a=Math.min(r,o),l=Math.max(r,o);for(let u=a;u<=l;u+=1){if(this._isSpanningRow(n[u]))continue;let d=this._idFor(n[u]);t?this._selected.add(d):this._selected.delete(d)}}else t?this._selected.add(e.id):this._selected.delete(e.id);this._selectionAnchorId=e.id,this._extendBase=null,this._syncSelection(),this._emitSelectionChange()}_syncSelection(){for(let[e,t]of this._rowElements){let s=this._selected.has(e);for(let n of t){if(n.hasAttribute("data-span"))continue;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 e=this._selectableData(),t=e.reduce((s,n)=>s+Number(this._selected.has(this._idFor(n))),0);this._selectAll.disabled=e.length===0,this._selectAll.checked=e.length>0&&t===e.length,this._selectAll.indeterminate=t>0&&t<e.length}_syncSortHeader(){if(this._headers)for(let[e,t]of this._headers)!this._spanning&&this._sort?.id===e?t.setAttribute("aria-sort",this._sort.dir==="asc"?"ascending":"descending"):t.removeAttribute("aria-sort")}_sortData(){if(this._spanning=this._hasSpanningRow(),!this._sort||this._spanning)return;let e=this._columns.find(s=>s.id===this._sort.id);if(!e)return;let t=typeof e.sortValue=="function"?e.sortValue:s=>s?.[e.id];this._data=this._hierarchy?ud(this._data,this.options.rowId,this._hierarchy.parentId,t,this._sort.dir):Fs(this._data,t,this._sort.dir)}_setRowExpanded(e,t,s){return this._hierarchy?bi(this._data,this.options.rowId,this._hierarchy.parentId).some(r=>Object.is(r,e))?this._expanded.has(e)===t?this:(t?this._expanded.add(e):this._expanded.delete(e),this._renderBody(),s.silent||this._emitRowToggle(e,t),this):this:this}_emitRowToggle(e,t){let s=this.getRow(e);s&&this.emit("rowtoggle",{row:s,id:e,expanded:t})}_reconcileExpanded(){if(!this._hierarchy){this._expanded.clear();return}let e=bi(this._data,this.options.rowId,this._hierarchy.parentId),t=new Set(e);for(let s of this._expanded)t.has(s)||this._expanded.delete(s)}_selectableIds(){let e=new Set;for(let t of this._data)this._isSpanningRow(t)||e.add(this._idFor(t));return e}_pruneSelection(){let e=this._selectableIds(),t=this._selected.size;for(let s of this._selected)e.has(s)||this._selected.delete(s);return e.has(this._selectionAnchorId)||(this._selectionAnchorId=null),this._extendBase=null,t!==this._selected.size}_idFor(e){return typeof this.options.rowId=="function"?this.options.rowId(e):e?.[this.options.rowId]}_emitSelectionChange(){let e=this.getSelection();this.emit("selectionchange",{rows:e,ids:e.map(t=>this._idFor(t))})}_emitDataChange(){this.emit("datachange",{rows:this.getData()})}};function td(i,e,t){let s=Math.trunc(Number(t?.rows)||0);if(s<=0)return null;let n=Math.max(1,Math.trunc(Number(t?.columns)||1)),r=Math.max(1,Math.trunc(Number(t?.page)||10)),o=(h,p)=>Math.min(Math.max(Math.trunc(Number(h)||0),0),p),a=o(i?.row,s-1),l=o(i?.column,n-1),u=!!t?.cells,d=!!t?.ctrl;switch(e){case"ArrowUp":return{row:Math.max(0,a-1),column:l};case"ArrowDown":return{row:Math.min(s-1,a+1),column:l};case"PageUp":return{row:Math.max(0,a-r),column:l};case"PageDown":return{row:Math.min(s-1,a+r),column:l};case"ArrowLeft":return u?{row:a,column:Math.max(0,l-1)}:null;case"ArrowRight":return u?{row:a,column:Math.min(n-1,l+1)}:null;case"Home":return u?d?{row:0,column:0}:{row:a,column:0}:{row:0,column:l};case"End":return u?d?{row:s-1,column:n-1}:{row:a,column:n-1}:{row:s-1,column:l};default:return null}}function id(i,e,t=10){let s=Number(i),n=Number(e);return!(s>0)||!(n>0)?Math.max(1,Math.trunc(t)||10):Math.max(1,Math.floor(s/n)-1)}function sd(i,e){let t=i==="ArrowRight";if(!t&&i!=="ArrowLeft")return null;if(e?.focus==="cell"){let r=Math.max(0,Math.trunc(Number(e.column)||0)),o=Math.max(1,Math.trunc(Number(e.columns)||1));return t?r<o-1?{action:"cell",column:r+1}:null:r>0?{action:"cell",column:r-1}:{action:"row"}}let s=!!e?.hasChildren,n=s&&!!e?.expanded;return t?s&&!n?{action:"expand"}:e?.cells?{action:"cell",column:0}:n?{action:"child"}:null:n?{action:"collapse"}:e?.hasParent?{action:"parent"}:null}function nd(i,e=80){for(let t of Array.isArray(i)?i:[]){let s=String(t??"").replace(/\s+/g," ").trim();if(s)return s.length>e?`${s.slice(0,Math.max(1,e-1)).trimEnd()}\u2026`:s}return null}function Uo(i,e){if(e==null||e==="")return null;let t=typeof e=="function"?e(i):i?.[e];return t==null?null:String(t)}function Yo(i,e){if(e===null||i==null||typeof i!="object"||!Object.prototype.hasOwnProperty.call(i,e))return null;let t=i[e];return t&&typeof t=="object"?t:null}function Wo(i,e,t){return!!Yo(t,Uo(i,e))?.span}function rd(i,e,t){return!Array.isArray(i)||e==null||t==null?!1:i.some(s=>Wo(s,e,t))}function od(i,e={}){let t=Number.isFinite(Number(i))?Math.max(0,Math.trunc(Number(i))):0,s=(e.selectable==="multi"?1:0)+(e.rowReorder?1:0);return Math.max(1,t+s)}function ad(i,e,t,s=0){if(typeof e?.render=="function")return e.render(i,s);let n=t?.[0];return n?i?.[n.id]:null}function ld(i,e,t=0){if(typeof i?.render=="function")return i.render(e,t);let s=e?.[i?.id],n=i?.type??"text";if(n==="text")return s;let r=Ne(i.locale,e),o=Go(i,e),a={...r!=null?{locale:String(r)}:{},...o!=null?{decimals:o}:{}};if(n==="number")return gi(s,a);if(n==="currency"){let l=Ne(i.currency,e);return Mo(s,l==null?null:String(l),a)}if(n==="percent")return No(s,a);if(n==="unit"){let l=gi(s,a),u=Ne(i.unit,e);return l&&u!=null&&String(u)!==""?`${l}\xA0${u}`:l}return s}function cd(i,e,t,s=[]){let n=xi(i,e,t),r=s instanceof Set?s:new Set(s),o=[],a=n.roots.slice().reverse().map(l=>({node:l,depth:0}));for(;a.length;){let{node:l,depth:u}=a.pop();if(o.push({row:l.row,id:l.id,index:l.index,depth:u,hasChildren:l.children.length>0,parentId:l.parent?.id??null}),!!r.has(l.id))for(let d=l.children.length-1;d>=0;d-=1)a.push({node:l.children[d],depth:u+1})}return o}function ud(i,e,t,s,n){let r=xi(i,e,t),o=u=>Fs(u,d=>s(d.row),n),a=[],l=o(r.roots).reverse();for(;l.length;){let u=l.pop();a.push(u.row);let d=o(u.children);for(let h=d.length-1;h>=0;h-=1)l.push(d[h])}return a}function Zo(i,e,t,s,n="before",r=null){if(!Array.isArray(i)||Object.is(t,s))return null;let o=i.findIndex(h=>Object.is(G(e,h),t)),a=i.findIndex(h=>Object.is(G(e,h),s));if(o<0||a<0||r&&!Ps(G(r,i[o]),G(r,i[a])))return null;if(r){let h=xi(i,e,r),p=h.nodes[o],f=h.nodes[a];if(!p||!f||p.parent!==f.parent)return null;let _=x=>{let C=[],$=[x];for(;$.length;){let W=$.pop();C.push(W);for(let re=W.children.length-1;re>=0;re-=1)$.push(W.children[re])}return C},m=new Set(_(p).map(x=>x.index)),g=new Set(_(f).map(x=>x.index)),b=i.filter((x,C)=>m.has(C)),y=i.filter((x,C)=>!m.has(C)),A=i.map((x,C)=>C).filter(x=>!m.has(x)),w=A.findIndex(x=>x===a);if(n==="after"){let x=A.map((C,$)=>g.has(C)?$:-1).filter(C=>C>=0);w=Math.max(...x)+1}return w<0?null:(y.splice(w,0,...b),y)}let l=[...i],[u]=l.splice(o,1),d=l.findIndex(h=>Object.is(G(e,h),s));return l.splice(d+(n==="after"?1:0),0,u),l}function Ge(i,e){if(!i||typeof i!="object")return!1;if(typeof i.editor=="function")return typeof i.editable=="function"&&i.editable(e)===!1?!1:"custom";let t=typeof i.editable=="function"?i.editable(e):i.editable;return t===!0?Ls(i)?"number":"text":typeof t=="string"&&Ju.has(t)?t:!1}function dd(i,e){let t=typeof i=="function"?i(e):i;return Array.isArray(t)?t.map(s=>s!==null&&typeof s=="object"?{value:s.value,label:String(s.label??s.value??"")}:{value:s,label:String(s??"")}):t!==null&&typeof t=="object"?Object.entries(t).map(([s,n])=>({value:s,label:String(n??"")})):[]}function hd(i,e,t){if(typeof i?.format=="function"){let s=i.format(e,t);return s==null?"":String(s)}return e==null?"":String(e)}function Me(i,e,t){return typeof i?.parse=="function"?i.parse(e,t):e}function fd(i,e){return Object.is(i,e)?!0:i instanceof Date&&e instanceof Date?i.getTime()===e.getTime():!1}function pd(i,e){let t={};for(let[s,n]of Object.entries(e??{}))fd(i?.[s],n)||(t[s]=n);return t}function md(i,e,t,s="Invalid value"){for(let n of e??[]){if(typeof n?.validate!="function"||!Object.prototype.hasOwnProperty.call(i??{},n.id))continue;let r=n.validate(i[n.id],t);if(typeof r=="string")return{columnId:n.id,message:r};if(r===!1)return{columnId:n.id,message:s}}return null}function Ne(i,e){return typeof i=="function"?i(e):i}function Go(i,e){let t=Ne(i?.decimals,e);if(t==null)return null;let s=Number(t);return Number.isFinite(s)?Math.max(0,Math.trunc(s)):null}function Ls(i){return["number","currency","percent","unit"].includes(i?.type)}function xi(i,e,t){let s=(Array.isArray(i)?i:[]).map((a,l)=>({row:a,id:G(e,a),index:l,parent:null,children:[]})),n=new Map;for(let a of s)n.has(a.id)||n.set(a.id,a);let r=new Map;for(let a of s){let l=G(t,a.row),u=l==null?null:n.get(l)??null;r.set(a,u===a?null:u)}for(let a of s){let l=new Set([a]),u=r.get(a)??null;for(;u;){if(l.has(u)){r.set(u,null);break}l.add(u),u=r.get(u)??null}}let o=[];for(let a of s)a.parent=r.get(a)??null,a.parent?a.parent.children.push(a):o.push(a);return{roots:o,nodes:s}}function bi(i,e,t){return xi(i,e,t).nodes.filter(s=>s.children.length>0).map(s=>s.id)}function G(i,e){return typeof i=="function"?i(e):e?.[i]}function Ps(i,e){return i==null&&e==null||Object.is(i,e)}function yi(i,e){if(!i||typeof i!="object")return null;let t=i.parentId;if(typeof t!="string"&&typeof t!="function")return null;let s=typeof i.column=="string"?i.column:null,n=e.some(r=>r.id===s)?s:e[0]?.id;return n?{...i,parentId:t,column:n}:null}function _d(i){return typeof i=="function"||typeof i=="string"&&i!==""?i:null}function gd(i){return!i||typeof i!="object"||Array.isArray(i)?null:i}function bd(i){return new Set(Array.isArray(i)?i:[])}function yd(i){return i==="plain"?"plain":"default"}function wd(i){return i==="cell"||i==="row"?i:i===!0?"cell":!1}function wt(i){return!!i?.closest?.(".zx-table__editor")}function Vo(i){let e=i?.closest?.("td[data-column]"),t=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!!(e&&t&&t!==e&&e.contains(t))}function vd(i){return i.closest("[popover]")?!0:i.getAttribute?.("aria-expanded")==="true"}function qo(i){if(!Array.isArray(i))throw new TypeError("Table columns must be an array");let e=new Set;return i.map((t,s)=>{if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError(`Table column at index ${s} must be an object`);let n=String(t.id??"").trim();if(!n)throw new TypeError(`Table column at index ${s} requires an id`);if(e.has(n))throw new TypeError(`Duplicate table column: ${n}`);return e.add(n),{...t,id:n,label:String(t.label??n)}})}function vi(i){for(let e of[i?.ariaLabel,i?.label]){let t=e==null?"":String(e).trim();if(t)return t}return String(i?.id??"")}function xd(i){let e=i?.label==null?"":String(i.label).trim(),t=i?.ariaLabel==null?"":String(i.ariaLabel).trim();return t||(e?null:vi(i)||null)}function Sd(i){return i==="text"||i==="number"||i==="date"}function Ad(i,e){let t=i.map(a=>a.id),s=new Set(t),n=Array.isArray(e)?e.map(String):[],r=new Set,o=[];for(let a of n)s.has(a)&&!r.has(a)&&(r.add(a),o.push(a));for(let a of t)r.has(a)||o.push(a);return o}function kd(i,e,t,s="before"){let n=[...i],r=n.indexOf(e),o=n.indexOf(t);if(r<0||o<0||r===o)return n;n.splice(r,1);let a=n.indexOf(t)+(s==="after"?1:0);return n.splice(a,0,e),n}function $o(i,e){for(let t of i.cells)if(t.dataset.column===e)return t;return null}function Ho(i,e){return!i||typeof i!="object"||!e.some(t=>t.id===i.id)?null:{id:i.id,dir:i.dir==="desc"?"desc":"asc"}}function zd(i){if(typeof i!="string")return 0;let e=/^(\d*\.?\d+)fr$/.exec(i.trim());return e?Math.max(0,Number(e[1])):0}function Ko(i){if(!Array.isArray(i))throw new TypeError("Table data must be an array")}function Rs(i,e){return i.size===e.size&&[...i].every(t=>e.has(t))}function wi(i,e){return i.length===e.length&&i.every((t,s)=>Object.is(t,e[s]))}function Cd(i){let e=Math.trunc(Number(i));return Number.isFinite(e)&&e>0?e:null}var Dd=["a[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","iframe",'[contenteditable="true"]',"[tabindex]"].map(i=>`${i}:not([tabindex^="-"])`).join(","),Qe=class extends S{static cssName="dropdown";static defaults={content:null,placement:"bottom-start",offset:4,matchWidth:!1,openOn:"click",closeOnSelect:!1,scope:null};#e;#t=null;#i=new Map;#s=null;#n=null;#r=!0;#a=!1;constructor(e,t={}){let s=U(e);if(!s)throw new TypeError("Dropdown anchor could not be resolved");super(null,t),this.#e=s,Ue(this.options.scope??s,{dialog:!1})?.append(this.el),this.#d("aria-expanded"),this.#d("aria-controls"),this.#e.setAttribute("aria-expanded","false"),this.#e.setAttribute("aria-controls",this.el.id),this.setContent(this.options.content),this.options.openOn==="click"&&this.listen(this.#e,"click",()=>this.toggle()),this.listen(this.el,"click",()=>{this.options.closeOnSelect&&this.close()}),this.listen(this.#e,"keydown",n=>this.#o(n)),this.listen(this.el,"keydown",n=>this.#u(n))}render(){let e=c("div",{id:E("zx-dropdown"),popover:"manual"});return e.dataset.state="closed",e}open(){if(this.isOpen()||this.#a)return this;let e=this.#l();return this.el.parentElement!==e&&e.append(this.el),this.#t=Z(this.#e,this.el,{placement:this.options.placement,offset:Number(this.options.offset),matchWidth:!!this.options.matchWidth}),this.el.dataset.state="open",this.#s=Ze({kind:"popup",root:this.el,owner:this,anchor:[this.#e,U(this.options.scope)],inside:[this.#e],onEscape:t=>this.#c(t),onOutsidePointer:()=>this.close(),onParentClose:()=>this.close()}),this.el.dataset.zxOverlayOrder=String(this.#s.order),this.#e.setAttribute("aria-expanded","true"),this.emit("open"),this}close(){if(!this.isOpen())return this;let e=this.el.contains(document.activeElement);this.#t?.destroy(),this.#t=null,this.el.dataset.state="closed",delete this.el.dataset.zxOverlayOrder;let t=this.#s;return this.#s=null,this.#e.setAttribute("aria-expanded","false"),e&&this.#r&&this.#e instanceof HTMLElement&&this.#e.focus(),Ye(this.el.parentElement)&&this.el.parentElement?.isConnected&&ie(this.options.scope??this.#e).append(this.el),t?.release(),this.emit("close"),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return this.#t!==null}setContent(e){return Ed(this.el,e),this.#t?.update(),this}getPanel(){return this.el}destroy(){if(!this.#a){this.#a=!0,this.close();for(let[e,t]of this.#i)Md(this.#e,e,t);super.destroy()}}_configure(e){return"onEscape"in e&&(this.#n=e.onEscape??null),"tabReach"in e&&(this.#r=!!e.tabReach),this}#l(){return Ye(this.#e)??Ye(U(this.options.scope))??bt(this.options.scope??this.#e)}#c(e){if(this.#n){this.#n(e);return}let t=this.el.contains(document.activeElement);this.close(),t&&this.#e instanceof HTMLElement&&this.#e.focus()}#o(e){if(e.key!=="Tab"||e.shiftKey||e.defaultPrevented||!this.#r||!this.isOpen())return;let t=js(this.el)[0]??(this.el.hasAttribute("tabindex")?this.el:null);t instanceof HTMLElement&&(e.preventDefault(),t.focus())}#u(e){if(e.key!=="Tab"||e.defaultPrevented||!this.#r||!this.isOpen())return;let t=js(this.el),s=document.activeElement;if((s&&s!==this.el?t.filter(o=>!o.contains(s)&&(e.shiftKey?!!(s.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_PRECEDING):!!(s.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING)&&!s.contains(o))):e.shiftKey?[]:t).length>0)return;if(e.shiftKey){if(!(this.#e instanceof HTMLElement))return;e.preventDefault(),this.#e.focus();return}let r=Id(this.#e,this.el);r&&(e.preventDefault(),r.focus())}#d(e){this.#i.set(e,this.#e.getAttribute(e))}};function Ed(i,e){if(i.replaceChildren(),e!=null)if(typeof e=="string"||typeof e=="number")i.append(document.createTextNode(String(e)));else if(typeof e.toElement=="function"){let t=e.toElement();t&&i.append(t)}else typeof e.nodeType=="number"&&i.append(e)}function js(i){return Array.from(i.querySelectorAll(Dd)).filter(e=>Td(e))}function Id(i,e){let t=Ye(i)??i.ownerDocument.body??i.ownerDocument.documentElement,s=js(t).filter(o=>!e.contains(o)),n=s.findIndex(o=>o===i||i.contains(o));if(n<0)return null;let r=n+1;for(;r<s.length&&i.contains(s[r]);)r+=1;return s[r]??null}function Td(i){let e=i;if(typeof e.focus!="function"||e.tabIndex<0||e.disabled||i.closest('[inert], [hidden], [aria-hidden="true"], fieldset[disabled]'))return!1;if(e instanceof HTMLInputElement&&e.type==="radio"&&e.name&&!e.checked){let t=e.form??e.getRootNode(),s=Array.from(t.querySelectorAll?.('input[type="radio"]')??[]).filter(n=>n.name===e.name&&(n.form??n.getRootNode())===t);if(s.some(n=>n.checked)||s[0]!==e)return!1}return typeof e.checkVisibility=="function"?e.checkVisibility({visibilityProperty:!0}):e.getClientRects().length>0}function Md(i,e,t){t===null?i.removeAttribute(e):i.setAttribute(e,t)}var Vs=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),Bs=class extends S{static cssName="app-icon";static defaults={icon:null,color:null,tone:null,size:36,iconSize:"52%",label:null,badge:null,selected:!1,shape:"tile",glass:"subtle",class:[]};render(){this._createdRoot=this.el===null;let e=this.el??c("span");return this.el=e,this._snapshot=this._createdRoot?null:H(e),this._interactiveRoot=e.matches('a[href], button, input, select, textarea, [role="button"], [role="link"]'),this._state={...this.options},this._appliedClasses=[],this._sync(),e}set(e={}){return!e||typeof e!="object"?this:(Object.assign(this._state,e),this._sync(),this)}destroy(){let e=this.el,t=this._snapshot;super.destroy(),!this._createdRoot&&e&&K(e,t)}_sync(){let e=this._state;this.el.classList.remove(...this._appliedClasses),this._appliedClasses=[e.class].flat().flatMap(u=>String(u??"").split(/\s+/)).filter(Boolean),this.el.classList.add(...this._appliedClasses);let t=Qo(e.size,"36px"),s=Qo(e.iconSize,"52%");this.el.style.setProperty("--zx-app-icon-size",t),this.el.style.setProperty("--zx-app-icon-glyph-size",s),we(e.color)?this.el.style.setProperty("--zx-app-icon-color",String(e.color)):this.el.style.removeProperty("--zx-app-icon-color"),Vs.includes(e.tone)?this.el.dataset.tone=e.tone:delete this.el.dataset.tone,this.el.dataset.glass=Od(e.glass),this.el.dataset.shape=Fd(e.shape),this.el.toggleAttribute("data-selected",!!e.selected);let n=e.label==null?"":String(e.label).trim();if(this._interactiveRoot){let u=Xo(this._snapshot,"role"),d=Xo(this._snapshot,"aria-label");u===null?this.el.removeAttribute("role"):this.el.setAttribute("role",u),n?this.el.setAttribute("aria-label",n):d===null?this.el.removeAttribute("aria-label"):this.el.setAttribute("aria-label",d),this.el.removeAttribute("aria-hidden")}else n?(this.el.setAttribute("role","img"),this.el.setAttribute("aria-label",n),this.el.removeAttribute("aria-hidden")):(this.el.removeAttribute("role"),this.el.removeAttribute("aria-label"),this.el.setAttribute("aria-hidden","true"));let r=Nd(e.icon),o=e.badge==null||e.badge===""?null:c("span",{class:"zx-app-icon__badge",ariaHidden:"true"},String(e.badge)),l=[c("span",{class:"zx-app-icon__surface",ariaHidden:"true"},c("span",{class:"zx-app-icon__shine",ariaHidden:"true"}),c("span",{class:"zx-app-icon__glyph",ariaHidden:"true"},r))];o&&l.push(o),this.el.replaceChildren(...l)}};function Si(i={}){return new Bs(null,i).toElement()}function Nd(i){let e=typeof i=="function"?i():i;return typeof e=="string"?v(e,{size:"1em"}):e&&typeof e=="object"&&typeof e.nodeType=="number"?e:null}function Qo(i,e){if(typeof i=="number"&&Number.isFinite(i))return`${Math.max(1,i)}px`;let t=String(i??"").trim();return t&&!/[;{}]/.test(t)?t:e}function Od(i){return i===!1||i==="none"?"none":i==="strong"?"strong":"subtle"}function Fd(i){return i==="circle"?"circle":"tile"}function Xo(i,e){return i?.attributes.find(([t])=>t===e)?.[1]??null}var zi=class extends S{static cssName="launcher";static defaults={items:[],sources:[],query:"",debounce:250,minQuery:0,maxResults:100,placeholder:null,label:null,closeLabel:null,resultsLabel:null,emptyText:null,loadingText:null,shortcut:"mod+k",hints:null,scope:null};constructor(e=null,t={}){super(e,t)}render(){if(this.el!==null&&!(this.el instanceof HTMLDialogElement))throw new TypeError("Launcher target must be a <dialog> element");this._createdRoot=this.el===null,this._overlay=null;let e=this.el??c("dialog");this.el=e,this._original=this._createdRoot?null:{attributes:Array.from(e.attributes,_=>[_.name,_.value]),children:Array.from(e.childNodes)},this._items=xt(this.options.items),this._sources=ia(this.options.sources),this._sourceItems=new Map,this._query=String(this.options.query??""),this._renderedQuery=null,this._results=[],this._active=-1,this._request=null,this._requestSequence=0,this._queryTimer=null,this._busy=!1,this._settled=!0,this._pages=[],this._restoreActiveId=null,this._announcePending=!1,this._announceToggle=!1,this._destroyed=!1;let t=E("zx-launcher-results"),s=String(this.options.label??this._message("launcher.label","Launcher")),n=String(this.options.placeholder??this._message("launcher.placeholder","Search applications and records"));this._label=s,this._placeholder=n;let r=c("input",{ref:"input",class:"zx-launcher__input",type:"search",role:"combobox",autocomplete:"off",spellcheck:!1,ariaAutocomplete:"list",ariaControls:t,ariaExpanded:"false",ariaLabel:s,placeholder:n,value:this._query}),o=c("button",{ref:"scopeBack",class:"zx-icon-btn zx-launcher__scope-back",type:"button"},v("x")),a=c("span",{ref:"scope",class:"zx-launcher__scope",hidden:!0},c("span",{ref:"scopeLabel",class:"zx-launcher__scope-label"}),o),l=c("button",{ref:"close",class:"zx-icon-btn zx-launcher__close",type:"button",ariaLabel:this.options.closeLabel??this._message("launcher.close","Close launcher")},v("x")),u=c("div",{ref:"status",class:"zx-launcher__status",role:"status",ariaLive:"polite"}),d=c("div",{ref:"announce",class:"zx-launcher__announce",role:"status",ariaLive:"polite",ariaAtomic:"true"}),h=c("div",{ref:"results",class:"zx-launcher__results",id:t,role:"listbox",ariaLabel:this.options.resultsLabel??this._message("launcher.results","Launcher results")}),p=this.options.shortcut==="mod+k"?c("kbd",{class:"zx-launcher__shortcut",ariaHidden:"true"},Rd()):null,f=Ld(this.options.hints,{move:this._message("launcher.hintMove","Move"),open:this._message("launcher.hintOpen","Open"),back:this._message("launcher.hintBack","Back"),close:this._message("launcher.hintClose","Close")});return e.setAttribute("aria-label",s),e.replaceChildren(c("div",{class:"zx-launcher__surface"},c("div",{class:"zx-launcher__search",dataset:{shortcut:p?"true":"false"}},v("search"),a,r,p,l),u,h,f,d)),e.dataset.state="closed",this._createdRoot&&Ue(this.options.scope,{dialog:!1})?.append(e),this.listen(r,"input",()=>{this._query=r.value,this._announcePending=!1,this.emit("query",{query:this._query.trim()}),this._refresh()}),this.listen(r,"keydown",_=>this._onKeydown(_)),this.listen(o,"click",()=>{this.back(),r.focus()}),this.listen(l,"click",()=>this.close()),this.listen(h,"click",_=>{let m=_.target?.closest?.("[data-launcher-index]");!m||!h.contains(m)||this._activate(Number(m.getAttribute("data-launcher-index")),_)}),this.listen(h,"pointermove",_=>{let m=_.target?.closest?.("[data-launcher-index]");if(!m||!h.contains(m))return;let g=Number(m.getAttribute("data-launcher-index"));!Number.isInteger(g)||this._results[g]?.disabled||g===this._active||(this._active=g,this._syncActive())}),this.listen(e,"cancel",_=>{_.preventDefault(),this.close()}),this.listen(e,"close",()=>{e.open||this._releaseOverlay(),e.dataset.state="closed",r.setAttribute("aria-expanded","false"),this._abortRequest(),this._pages.length&&!e.open&&(this._unwind(),this._announcePending=!1,this._syncPage(),this._renderResults(),this._emitPage()),this.emit("close")}),this.listen(document,"keydown",_=>this._onDocumentKeydown(_)),this._renderResults(),e}open(e={}){if(this._destroyed)return this;let t=e&&typeof e=="object"?e.page:void 0;if(this.isOpen()){let r=t==null?[]:this._pagePath(t);return r.length&&this._goTo(r),this}if(this._createdRoot){let r=ie(this.options.scope);this.el.parentElement!==r&&r.append(this.el)}let s=this._pages.map(r=>r.page),n=document.activeElement;return this.el.showModal(),this._releaseOverlay(),this._overlay=Ze({kind:"modal",root:this.el,owner:this,anchor:n}),this.el.dataset.state="open",this.refs.input.setAttribute("aria-expanded","true"),this._goTo(t==null?[]:this._pagePath(t),{emit:!1}),queueMicrotask(()=>{this.isOpen()&&(this.refs.input.focus(),this.refs.input.select())}),this.emit("open"),Jo(s,this._pages.map(r=>r.page))||this._emitPage(),this}back(){if(!this._pages.length)return this;let e=this._popPage();return this._syncPage(),this._announcePending=this.isOpen(),e?this._renderResults():this._refresh(!0),this._emitPage(),this}getPage(){return this._pages.at(-1)?.page??null}close(){return this.isOpen()&&this.el.close(),this}toggle(){return this.isOpen()?this.close():this.open()}isOpen(){return!!this.el.open}focus(){return this.refs.input.focus(),this.refs.input.select(),this}setQuery(e){return this._query=String(e??""),this.refs.input.value=this._query,this._announcePending=!1,this.emit("query",{query:this._query.trim()}),this._refresh(),this}getQuery(){return this._query}setItems(e){return this._items=xt(e),this._renderResults(),this}setCurrent(e){let t=e==null?null:String(e);return this._items=this._items.map(s=>({...s,current:t!==null&&String(s.id)===t})),this._renderResults(),this}setSources(e){return this._sources=ia(e),this._pages.length?(this._pages[0].parent.sourceItems=null,this):(this._abortRequest(),this._sourceItems.clear(),this._refresh(),this)}_releaseOverlay(){let e=this._overlay;this._overlay=null,e?.release()}destroy(){if(this._destroyed)return;this._destroyed=!0;let e=this._original;if(this._abortRequest(),this.isOpen()&&this.el.close(),this._releaseOverlay(),super.destroy(),!this._createdRoot&&e){for(let t of Array.from(this.el.attributes))this.el.removeAttribute(t.name);for(let[t,s]of e.attributes)this.el.setAttribute(t,s);this.el.replaceChildren(...e.children)}}_refresh(e=!1){this._abortRequest(),this._sourceItems.clear();let{sources:t}=this._level();if(this._settled=t.length===0,e&&t.length&&this._loadSources(),this._renderResults(),e||t.length===0)return;let s=Math.max(0,Number(this.options.debounce)||0);this._queryTimer=setTimeout(()=>this._loadSources(),s)}async _loadSources(){this._queryTimer=null;let e=this._query.trim(),t=this._pages?.at(-1)?.page??null,s=this._level().sources.filter(o=>Ai(o.when,e)&&e.length>=Math.max(o._page?0:Number(this.options.minQuery)||0,Number(o.minQuery)||0));if(s.length===0){this._settled=!0;return}let n=new AbortController,r=++this._requestSequence;this._request=n,this._setBusy(!0),await Promise.all(s.map(async o=>{try{let a=await o.load(e,{signal:n.signal});if(n.signal.aborted||r!==this._requestSequence)return;this._sourceItems.set(o.id,xt(a).map((l,u)=>({...l,_source:o._page?null:o.id,_sourceOrder:o.order==="source",group:l.group??o.label??"",itemOrder:l.itemOrder??(o.order==="source"?u:void 0)}))),this._renderResults()}catch(a){if(n.signal.aborted||r!==this._requestSequence)return;this.emit("error",{source:o,error:a,page:t})}})),!(n.signal.aborted||r!==this._requestSequence)&&(this._request=null,this._settled=!0,this._setBusy(!1))}_level(){return this._pages?.at(-1)??{items:this._items,sources:this._sources}}_openPage(e){this._pushPage(e),this._syncPage(),this._announcePending=this.isOpen(),this._refresh(!0),this._emitPage()}_goTo(e,{emit:t=!0}={}){let s=this._pages.map(n=>n.page);if(this._unwind(),e.length){this._abortRequest(),this._sourceItems.clear(),this._settled=!1;for(let n of e)this._pushPage(n)}this._syncPage(),this._announcePending=this.isOpen()&&e.length>0,this._refresh(e.length>0),t&&!Jo(s,e)&&this._emitPage()}_unwind(){for(;this._pages.length;)this._popPage()}_pushPage(e){let t=this._active>=0?this._results[this._active]:null;this._pages.push({page:e,items:Array.isArray(e.items)?xt(e.items):[],sources:typeof e.items=="function"?[Vd(e)]:[],parent:{query:this._query,activeId:t?String(t.id):null,sourceItems:this._settled?new Map(this._sourceItems):null}}),this._setInputQuery("")}_popPage(){let e=this._pages.pop();if(!e)return!0;this._announcePending=!1,this._abortRequest();let{parent:t}=e;return this._setInputQuery(t.query),this._sourceItems=t.sourceItems?new Map(t.sourceItems):new Map,this._settled=t.sourceItems!==null,this._restoreActiveId=t.activeId,this._settled}_setInputQuery(e){this._query=e,this.refs.input.value=e,this._renderedQuery=null}_syncPage(){let e=this.getPage(),{input:t,scope:s,scopeLabel:n,scopeBack:r,backHint:o}=this.refs;if(s.hidden=e===null,o&&(o.hidden=e===null),this.el.toggleAttribute("data-page",e!==null),e===null){t.setAttribute("aria-label",this._label),t.setAttribute("placeholder",this._placeholder),n.textContent="";return}let a=this._pages.at(-2)?.page.label??this._label;n.textContent=e.label,r.setAttribute("aria-label",this._message("launcher.back","Back to %1",a)),t.setAttribute("aria-label",this._message("launcher.pageLabel","Search %1",e.label)),t.setAttribute("placeholder",e.placeholder!=null?String(e.placeholder):this._message("launcher.pagePlaceholder","Search"))}_emitPage(){let e=this._pages.map(t=>t.page);this.emit("page",{page:e.at(-1)??null,path:e})}_pagePath(e){if(e&&typeof e=="object"){let t=e;return!Xe(t)||t.label==null?[]:[sa({...t,id:t.id??t.label})]}return Pd(this._items,e)}_pageStatus(){let e=this.getPage()?.label??this._label,t=this._results.length;return t===0?this._message("launcher.pageEmpty","%1, no results",e):t===1?this._message("launcher.pageResult","%1, 1 result",e):this._message("launcher.pageResults","%1, %2 results",e,t)}_setBusy(e){this._busy=e,this.el.setAttribute("aria-busy",String(e)),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 e=this._query,t=this._restoreActiveId??null;this._restoreActiveId=null;let s=t??(this._renderedQuery===e&&this._active>=0&&this._results[this._active]?String(this._results[this._active].id):null),n=this._query.trim(),r=this._level(),o=r.items.filter(m=>Ai(m.when,n)),a=ea(o,n,this.options.maxResults),l=r.sources.flatMap(m=>{let g=this._sourceItems.get(String(m.id))??[];return m.order==="source"?g.filter(b=>Ai(b.when,n)):ea(g.filter(b=>Ai(b.when,n)),n,this.options.maxResults)}),u=new Set,d=[...a.map(m=>({...m,_source:null})),...l].filter(m=>{let g=String(m.id);return u.has(g)?!1:(u.add(g),!0)}).slice(0,Math.max(0,Number(this.options.maxResults)||0)),h=new Map;for(let m of d){let g=String(m.group??"");h.has(g)||h.set(g,[]),h.get(g).push(m)}this._results=[...h.values()].flat(),this._renderedQuery=e;let p=s===null?-1:this._results.findIndex(m=>!m.disabled&&String(m.id)===s);this._active=p>=0?p:this._results.findIndex(m=>!m.disabled);let f=[],_=0;for(let[m,g]of h){let b=g.map(y=>this._option(y,_++));m?f.push(c("div",{class:"zx-launcher__group",role:"group",ariaLabel:m,dataset:{layout:g.every(y=>y.kind==="application")?"grid":"list"}},c("div",{class:"zx-launcher__group-label",ariaHidden:"true"},m),b)):f.push(...b)}this.refs.results.replaceChildren(...f),this._syncActive(),this._renderStatus()}_option(e,t){let s=Xe(e),n=s?null:Be(e.href),r=n?"a":"button",o=[],a=qd(e);a&&o.push(c("span",{class:"zx-launcher__icon",ariaHidden:"true"},a)),o.push(c("span",{class:"zx-launcher__copy"},c("span",{class:"zx-launcher__label"},e.label),e.description?c("span",{class:"zx-launcher__description"},e.description):null)),e.badge!=null&&o.push(c("span",{class:"zx-launcher__badge"},String(e.badge))),e.hint!=null&&e.hint!==""&&o.push(c("span",{class:"zx-launcher__hint"},String(e.hint)));let l=Bd(e),u=jd(e.shortcut);return u.length&&o.push(c("span",{class:"zx-launcher__keys",ariaHidden:l?"true":null},u.map(d=>c("kbd",{class:"zx-launcher__key"},d)))),s&&o.push(c("span",{class:"zx-launcher__chevron",ariaHidden:"true"},v("chevron-right"))),c(r,{class:"zx-launcher__option",type:r==="button"?"button":null,href:n,target:e.target??null,rel:r==="a"?"noopener":null,role:"option",id:E("zx-launcher-option"),tabIndex:-1,ariaSelected:"false",ariaDisabled:e.disabled?"true":null,ariaCurrent:e.current?"page":null,ariaKeyShortcuts:l,dataset:{launcherIndex:t,pinned:e.pinned!==void 0&&e.pinned!==!1?"true":null,kind:$d(e.kind),page:s?"true":null}},o)}_renderStatus(){this._busy?this.refs.status.textContent=String(this.options.loadingText??this._message("launcher.loading","Searching\u2026")):this._results.length===0?this.refs.status.textContent=String(this.options.emptyText??this._message("launcher.empty","No results")):this.refs.status.textContent="",this.refs.status.hidden=!this.refs.status.textContent,this._announcePending&&!this._busy&&this._renderedQuery===this._query&&(this._announcePending=!1,this._announceToggle=!this._announceToggle,this.refs.announce.textContent=this._pageStatus()+(this._announceToggle?"\xA0":""))}_syncActive(){let e=[...this.refs.results.querySelectorAll("[data-launcher-index]")];for(let s of e){let n=Number(s.getAttribute("data-launcher-index"))===this._active;s.setAttribute("aria-selected",String(n))}let t=e.find(s=>Number(s.getAttribute("data-launcher-index"))===this._active);t?this.refs.input.setAttribute("aria-activedescendant",t.id):this.refs.input.removeAttribute("aria-activedescendant")}_onKeydown(e){if(e.key==="Escape"){this.close();return}let t=!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey;if(e.key==="Backspace"&&t&&!e.repeat&&this._pages.length&&this._query===""){e.preventDefault(),this.back();return}if(e.key==="Enter"){if(this._active<0)return;e.preventDefault(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.click();return}let s=this._results.map((r,o)=>r.disabled?-1:o).filter(r=>r>=0);if(/^Arrow(?:Left|Right|Up|Down)$/.test(e.key)){let r=s.length?this._spatialIndex(e.key,s):null;if(r!==null){e.preventDefault(),this._active=r,this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"});return}if(e.key==="ArrowLeft"||e.key==="ArrowRight"){t&&!e.repeat&&this._pageKey(e.key)&&e.preventDefault();return}}if(s.length===0)return;let n=s.indexOf(this._active);if(e.key==="Home"||e.key==="PageUp")n=0;else if(e.key==="End"||e.key==="PageDown")n=s.length-1;else if(e.key==="ArrowDown")n=(n+1+s.length)%s.length;else if(e.key==="ArrowUp")n=(n-1+s.length)%s.length;else return;e.preventDefault(),this._active=s[n],this._syncActive(),this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`)?.scrollIntoView({block:"nearest"})}_pageKey(e){if(e==="ArrowLeft")return!this._pages.length||this._query!==""?!1:(this.back(),!0);let t=this._active>=0?this._results[this._active]:null;if(!t||t.disabled||!Xe(t)||t.kind==="application")return!1;let s=this.refs.input,n=s.value.length;return s.selectionStart!==n||s.selectionEnd!==n?!1:(this._openPage(t),!0)}_spatialIndex(e,t){let s=this.refs.results.querySelector(`[data-launcher-index="${this._active}"]`);if(!(s instanceof HTMLElement)||(e==="ArrowLeft"||e==="ArrowRight")&&this._results[this._active]?.kind!=="application")return null;let n=[...this.refs.results.querySelectorAll("[data-launcher-index]")].filter(o=>t.includes(Number(o.getAttribute("data-launcher-index")))&&(e!=="ArrowLeft"&&e!=="ArrowRight"||o.getAttribute("data-kind")==="application")),r=Hd(n,s,e);return r?Number(r.getAttribute("data-launcher-index")):null}_activate(e,t){let s=this._results[e];if(!s||s.disabled){t.preventDefault();return}if(Xe(s)){t.preventDefault(),this._openPage(s),this.refs.input.focus();return}if(this.emit("select",{item:s,value:s.value??s.id,source:s._source??null,query:this._query.trim(),page:this.getPage()}).defaultPrevented){t.preventDefault();return}this.close(),s.href||(t.preventDefault(),s.invoke?.())}_onDocumentKeydown(e){if(this.options.shortcut!=="mod+k"||e.isComposing||e.key.toLowerCase()!=="k"||Number(e.metaKey)+Number(e.ctrlKey)!==1||e.altKey||e.shiftKey)return;let t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement||t instanceof HTMLElement&&t.isContentEditable)return;let s=document.querySelector("dialog:modal");s&&s!==this.el||(e.preventDefault(),this.open())}_message(e,t,...s){let n=this.msg(e,...s);return n===e?O(t,s):n}};function Rd(){let i=String(navigator.userAgentData?.platform??navigator.platform??"");return/mac|iphone|ipad/i.test(i)?"\u2318 K":"Ctrl K"}function Ld(i,e){if(i===!1)return null;let t=i&&typeof i=="object"?i:{};return c("footer",{class:"zx-launcher__hints",ariaHidden:"true"},c("span",{},c("kbd",{},"\u2191\u2193\u2190\u2192"),t.move??e.move),c("span",{},c("kbd",{},"\u21B5"),t.open??e.open),c("span",{ref:"backHint",hidden:!0},c("kbd",{},"\u232B"),t.back??e.back),c("span",{},c("kbd",{},"Esc"),t.close??e.close))}function Xe(i){let e=i?.items;return!!i&&typeof i=="object"&&(Array.isArray(e)||typeof e=="function")}function Pd(i,e){if(e==null)return[];let t=String(e),s=new Set,n=(r,o)=>{if(!Array.isArray(r)||s.has(r))return null;s.add(r);for(let a of xt(r)){if(!Xe(a))continue;let l=[...o,a];if(String(a.id)===t)return l;let u=n(a.items,l);if(u)return u}return null};return n(i,[])??[]}function jd(i){let e=i&&typeof i=="object"&&!Array.isArray(i)?i.label:i;return(Array.isArray(e)?e:e==null?[]:[e]).filter(s=>s!=null&&String(s).trim()!=="").map(s=>String(s).trim())}function Bd(i){let e=i.shortcut,t=i.keys??(e&&typeof e=="object"&&!Array.isArray(e)?e.keys:null);return typeof t=="string"&&t.trim()?t.trim():null}function Vd(i){return{id:`page:${String(i.id)}`,load:i.items,order:i.order==="source"?"source":"rank",_page:!0}}function Jo(i,e){return i.length===e.length&&i.every((t,s)=>t===e[s]||String(t.id)===String(e[s].id))}function qd(i){let e=i.icon;if(typeof e=="function"&&(e=e(i)),typeof e=="string")return v(e);if(e instanceof Node)return e.cloneNode(!0);if(e&&typeof e=="object"&&typeof e.toElement=="function"){let t=e.toElement();return t instanceof Node?t.cloneNode(!0):null}return null}function $d(i){return i==="application"||i==="record"?i:"action"}function Ai(i,e){return i==="empty"?e==="":i==="query"?e!=="":!0}function Hd(i,e,t){let s=e.getBoundingClientRect();if(s.width===0&&s.height===0)return null;let n=s.left+s.width/2,r=s.top+s.height/2,o=null,a=1/0;for(let l of i){if(l===e)continue;let u=l.getBoundingClientRect(),d=u.left+u.width/2-n,h=u.top+u.height/2-r,p=!1,f=1/0;t==="ArrowLeft"?(p=d<-2&&Math.abs(h)<Math.max(s.height,u.height)/2,f=Math.abs(d)+Math.abs(h)*4):t==="ArrowRight"?(p=d>2&&Math.abs(h)<Math.max(s.height,u.height)/2,f=Math.abs(d)+Math.abs(h)*4):t==="ArrowUp"?(p=h<-2,f=Math.abs(h)*10+Math.abs(d)):t==="ArrowDown"&&(p=h>2,f=Math.abs(h)*10+Math.abs(d)),p&&f<a&&(o=l,a=f)}return o}function ea(i,e,t=100){let s=Je(e).trim(),n=i.map((o,a)=>({item:o,order:a,score:Kd(o,s)})).filter(({score:o})=>o<1/0);n.sort((o,a)=>{let l=ki(o.item.groupOrder),u=ki(a.item.groupOrder);if(l!==u)return l-u;if(s===""){let d=ta(o.item.pinned,o.order),h=ta(a.item.pinned,a.order);if(d!==h)return d-h}return o.score-a.score||ki(o.item.itemOrder)-ki(a.item.itemOrder)||Ud(o.item.label,a.item.label)||o.order-a.order});let r=Math.max(0,Number(t)||0);return n.slice(0,r||0).map(({item:o,score:a})=>({...o,_score:a}))}function Kd(i,e){if(!e)return i.pinned?-1:0;let t=Je(i.label),s=Je(i.id),n=Je(Array.isArray(i.keywords)?i.keywords.join(" "):i.keywords??"");return t===e?0:t.startsWith(e)?10:t.split(/[^\p{L}\p{N}]+/u).some(o=>o.startsWith(e))?20:t.includes(e)||n.includes(e)?30:s.includes(e)?40:t.split(/[^\p{L}\p{N}]+/u).filter(Boolean).map(o=>o[0]).join("").startsWith(e)?50:1/0}function ta(i,e){return typeof i=="number"&&Number.isFinite(i)?i:i?e:Number.MAX_SAFE_INTEGER}function ki(i){return typeof i=="number"&&Number.isFinite(i)?i:Number.MAX_SAFE_INTEGER}function Je(i){return String(i??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function Ud(i,e){let t=Je(i),s=Je(e);if(t<s)return-1;if(t>s)return 1;let n=String(i??"").normalize("NFC"),r=String(e??"").normalize("NFC");return n<r?-1:n>r?1:0}function xt(i){return Array.isArray(i)?i.filter(e=>e&&typeof e=="object"&&e.id!=null&&e.label!=null).map(e=>sa(e)):[]}function sa(i){let e={...i,label:String(i.label)};if(i.href==null)return e;let t=Be(i.href);return t!==null?e.href=t:(delete e.href,typeof e.invoke!="function"&&!Xe(e)&&(e.disabled=!0)),e}function ia(i){return Array.isArray(i)?i.filter(e=>e&&typeof e=="object"&&e.id!=null&&typeof e.load=="function").map(e=>({...e,id:String(e.id)})):[]}var Yd=new Set(["top","bottom","top-start","top-end","bottom-start","bottom-end","left","right","left-start","left-end","right-start","right-end"]),Wd=new Set(["hover","focus","both","manual"]),et=class extends S{static cssName="tooltip";static defaults={content:"",placement:"top",offset:6,delay:400,hideDelay:80,maxWidth:260,trigger:"both",disabled:!1};#e;#t;#i=null;#s=null;#n=0;#r=0;#a=!1;#l=!1;#c=null;#o=!1;#u=!1;constructor(e,t={}){let s=U(e);if(!s)throw new TypeError("Tooltip anchor could not be resolved");super(null,t),this.#e=s,Ue(s,{dialog:!1})?.append(this.el),this.#t=this.options.content,this.#o=!!this.options.disabled,this.#s=s.getAttribute("aria-describedby"),this.el.style.setProperty("--zx-tooltip-max-inline-size",Gd(this.options.maxWidth));let n=Wd.has(this.options.trigger)?this.options.trigger:"both";if(n!=="manual"){this.#l=!0,(n==="hover"||n==="both")&&(this.listen(this.#e,"pointerenter",r=>{r.pointerType!=="touch"&&this.#d(Number(this.options.delay))}),this.listen(this.#e,"pointerleave",()=>this.#f(Number(this.options.hideDelay)))),(n==="focus"||n==="both")&&(this.listen(this.#e,"focusin",()=>{this.#a||!Qd(this.#e)||this.#d(0)}),this.listen(this.#e,"focusout",()=>this.#f(Number(this.options.hideDelay)))),this.listen(this.#e,"pointerdown",()=>{this.#a=!0,this.#h(),this.hide()});for(let r of["pointerup","pointercancel","pointerleave"])this.listen(this.#e,r,()=>{this.#a=!1})}}render(){let e=c("div",{id:E("zx-tooltip"),role:"tooltip",popover:"manual"});return e.dataset.state="closed",e}show(){if(this.#u||this.#o||this.isOpen())return this;this.#h();let e=bt(this.#e);this.el.parentElement!==e&&e.append(this.el);let t=na(this.#t);if(t===null)return this;this.el.replaceChildren(t);let s=Yd.has(this.options.placement)?this.options.placement:"top";return this.#i=Z(this.#e,this.el,{placement:s,offset:Number(this.options.offset),flip:!0}),/^(left|right)/.test(s)&&this.el.style.getPropertyValue("position-try-fallbacks")&&this.el.style.setProperty("position-try-fallbacks","flip-inline, top span-all, bottom span-all"),this.el.dataset.state="open",this.#e.setAttribute("aria-describedby",Zd(this.#s,this.el.id)),this.#c=Ze({kind:"tooltip",root:this.el,owner:this,anchor:this.#e,inside:[this.#e],onEscape:this.#l?()=>{this.hide()}:void 0,onOutsidePointer:this.#l?()=>this.hide():void 0,onFocusOutside:this.#l?()=>this.hide():void 0,onParentClose:()=>this.hide()}),this.emit("open"),this}hide(){if(this.#h(),!this.isOpen())return this;this.#i?.destroy(),this.#i=null,this.el.dataset.state="closed",this.el.replaceChildren(),this.#p();let e=this.#c;return this.#c=null,e?.release(),this.emit("close"),this}toggle(){return this.isOpen()?this.hide():this.show()}isOpen(){return this.#i!==null}setContent(e){if(this.#t=e,!this.isOpen())return this;let t=na(e);return t===null?this.hide():(this.el.replaceChildren(t),this.#i?.update(),this)}enable(){return this.#o=!1,this}disable(){return this.#o=!0,this.hide()}isDisabled(){return this.#o}getAnchor(){return this.#e}destroy(){this.#u||(this.#u=!0,this.hide(),this.#p(),super.destroy())}#d(e){if(this.#h(),this.#u||this.#o||this.isOpen())return;let t=Number.isFinite(e)?Math.max(0,e):0;if(t===0){this.show();return}this.#n=setTimeout(()=>{this.#n=0,this.show()},t)}#f(e){if(this.#h(),!this.isOpen())return;let t=Number.isFinite(e)?Math.max(0,e):0;if(t===0){this.hide();return}this.#r=setTimeout(()=>{this.#r=0,this.hide()},t)}#h(){this.#n!==0&&clearTimeout(this.#n),this.#r!==0&&clearTimeout(this.#r),this.#n=0,this.#r=0}#p(){this.#s===null?this.#e.removeAttribute("aria-describedby"):this.#e.setAttribute("aria-describedby",this.#s)}};function na(i){let e=typeof i=="function"?i():i;if(e==null)return null;if(typeof e=="object"&&typeof e.nodeType=="number")return e;if(typeof e=="object"&&typeof e.toElement=="function")return e.toElement();let t=String(e);return t===""?null:document.createTextNode(t)}function Zd(i,e){let t=String(i??"").split(/\s+/).filter(Boolean);return t.includes(e)||t.push(e),t.join(" ")}function Gd(i){return typeof i=="number"&&Number.isFinite(i)?`${i}px`:String(i)}function Qd(i){try{return i.matches(":focus-visible")}catch{return!0}}var Ci=class extends S{static cssName="app-rail";static partBlock="zx-app-rail";static defaults={items:[],active:null,orientation:"vertical",side:"left",label:"Applications",header:null,footer:null,openDelay:80,closeDelay:160,renderIcon:null};constructor(e=null,t={}){super(e,t),this._rebuild()}render(){this._createdRoot=this.el===null;let e=this.el??c("nav");this.el=e,this._original=this._createdRoot?null:{attributes:Array.from(e.attributes,o=>[o.name,o.value]),children:Array.from(e.childNodes)},this._items=Oe(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,e.setAttribute("aria-label",String(this.options.label)),e.tagName!=="NAV"&&e.setAttribute("role","navigation"),e.dataset.orientation=this.options.orientation==="horizontal"?"horizontal":"vertical";let t=e.dataset.orientation==="horizontal"?["top","bottom"]:["left","right"];e.dataset.side=t.includes(this.options.side)?this.options.side:t[0];let s=this._partBlock(),n=c("div",{class:`${s}__header`}),r=c("div",{class:`${s}__footer`});return aa(n,this.options.header),aa(r,this.options.footer),n.hidden=!n.hasChildNodes(),r.hidden=!r.hasChildNodes(),e.replaceChildren(n,c("ul",{ref:"list",class:`${s}__list`}),r),this.listen(e,"keydown",o=>this._onRailKeydown(o)),e}setItems(e){return this._items=Oe(e),this._rebuild(),this}setActive(e){return this._active=e,this._syncActive(),this}getItems(){return this._items.map(e=>({...e,children:e.children?.map(t=>({...t}))}))}openFlyout(e,{focus:t=!1}={}){let s=this._resolveFlyout(e);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,a]of this._flyouts)o!==s.key&&a.dropdown.isOpen()&&!this._isAncestor(a,s)&&this.closeFlyout(o);for(let o of n)this._tooltipById.get(String(o.item.id))?.hide(),o.dropdown.open();return t&&oa(s.panel)?.focus(),this}closeFlyout(e){let t=this._resolveFlyout(e);if(!t)return this;for(let s of[...this._flyouts.values()].reverse())s!==t&&this._isAncestor(t,s)&&(this._cancelTimers(s.key),s.dropdown.close());return this._cancelTimers(t.key),t.dropdown.close(),this}closeAllFlyouts(){for(let e of this._flyouts.values())e.parentKey===null&&this.closeFlyout(e.key);for(let e of[...this._flyouts.values()].reverse())this._cancelTimers(e.key),e.dropdown.isOpen()&&e.dropdown.close();return this}isFlyoutOpen(e){return this._resolveFlyout(e)?.dropdown.isOpen()??!1}focus(){return oa(this.refs.list)?.focus(),this}_containsNode(e){return!!(e&&(this.el.contains(e)||[...this._flyouts.values()].some(t=>t.panel.contains(e))))}destroy(){let e=this._original;if(this._clearArtifacts(),super.destroy(),!this._createdRoot&&e){for(let t of Array.from(this.el.attributes))this.el.removeAttribute(t.name);for(let[t,s]of e.attributes)this.el.setAttribute(t,s);this.el.replaceChildren(...e.children)}}_rebuild(){this._clearArtifacts(),this.refs.list.replaceChildren(),this._interaction=new qs(this.el);let e=!1;for(let t of $s(this._items)){if(t===la){e&&this.refs.list.append(c("li",{class:`${this._partBlock()}__separator`,ariaHidden:"true"}));continue}e=!0;let s=Array.isArray(t.children)&&t.children.length>0&&this._flyoutsFor(t),n=this._renderControl(t,s),r=c("li",{class:`${this._partBlock()}__row`},n);if(this.refs.list.append(r),this._tooltipFor(t)){let o=new et(n,{content:t.label,placement:ih(this.el.dataset.side),delay:450});this._tooltips.push(o),this._tooltipById.set(String(t.id),o)}s?this._buildFlyout(t,n,String(t.id),null):this._interaction.listen(n,"click",o=>{if(!this._select(t,o).defaultPrevented)for(let l of this._flyouts.values())l.parentKey===null&&l.dropdown.isOpen()&&this.closeFlyout(l.key)})}this._afterRebuild(),this._syncActive()}_partBlock(){return this.constructor.partBlock}_renderControl(e,t){return ra(e,{className:"zx-app-rail__item",index:String(e.id),iconOnly:!0,disclosure:t,disclosureIcon:Xd(this.el.dataset.side),visual:Di(e,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:1,location:"root"})})}_flyoutsFor(e){return!0}_tooltipFor(e){return!0}_afterRebuild(){}_buildFlyout(e,t,s,n){let r=c("ul",{class:"zx-app-rail__flyout-list"});for(let h of $s(e.children??[],!0)){if(h.section){r.append(c("li",{class:"zx-app-rail__flyout-section"},h.label));continue}let p=`${s}/${h.id}`,f=!!h.children?.length,_=ra(h,{className:"zx-app-rail__flyout-item",index:p,iconOnly:!1,disclosure:f,disclosureIcon:Jd(this.el.dataset.side),visual:Di(h,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:p.split("/").length,location:"flyout"})});r.append(c("li",{},_)),f?this._buildFlyout(h,_,p,s):this._interaction.listen(_,"click",m=>{this._select(h,m).defaultPrevented||this._closeFlyoutChain(s)})}let o=c("div",{class:"zx-app-rail__flyout"},c("div",{class:"zx-app-rail__flyout-title"},e.label),r),a=new Qe(t,{openOn:"manual",placement:n===null?eh(this.el.dataset.side):th(this.el.dataset.side),content:o,offset:6}),l=a.getPanel();a._configure({tabReach:!1,onEscape:()=>{let h=l.contains(document.activeElement);this.closeFlyout(s),h&&this._restoreFocus(t)}}),l.classList.add("zx-app-rail__popover"),l.dataset.side=this.el.dataset.side,l.setAttribute("role","region"),l.setAttribute("aria-label",this._message("appRail.subNavigation","%1 sub-navigation",e.label));let u={key:s,parentKey:n,item:e,trigger:t,panel:l,dropdown:a};this._flyouts.set(s,u);let d=n===null?this._tooltipById.get(String(e.id)):null;a.on("open",()=>{d?.disable(),this._silenceFlyoutEvents||this.emit("flyoutchange",{item:e,id:e.id,open:!0})}),a.on("close",()=>{d?.enable(),this._silenceFlyoutEvents||this.emit("flyoutchange",{item:e,id:e.id,open:!1})}),this._interaction.listen(t,"pointerdown",()=>{this._pointerFocus.add(t),queueMicrotask(()=>this._pointerFocus.delete(t))}),this._interaction.listen(t,"pointerenter",h=>{h.pointerType!=="touch"&&this._scheduleOpen(s)}),this._interaction.listen(t,"pointerleave",()=>this._scheduleClose(s)),this._interaction.listen(t,"focus",()=>{this._pointerFocus.has(t)||this.openFlyout(s)}),this._interaction.listen(t,"focusout",h=>{l.contains(h.relatedTarget)||this._scheduleClose(s)}),this._interaction.listen(t,"click",h=>{h.preventDefault(),h instanceof MouseEvent&&h.detail===0?this.openFlyout(s,{focus:!0}):this.openFlyout(s)}),this._interaction.listen(l,"pointerenter",()=>this._cancelFlyoutTimers(u,!0)),this._interaction.listen(l,"pointerleave",()=>this._scheduleFlyoutClose(u,!0)),this._interaction.listen(l,"focusin",()=>this._cancelFlyoutTimers(u,!0)),this._interaction.listen(l,"focusout",h=>{h.relatedTarget!==t&&!l.contains(h.relatedTarget)&&this._scheduleFlyoutClose(u,!0)}),this._interaction.listen(l,"keydown",h=>this._onFlyoutKeydown(h,u))}_select(e,t){if(e.disabled){t.preventDefault();let n=new Event("select",{cancelable:!0});return n.preventDefault(),n}let s=this.emit("select",{item:e,id:e.id,value:e.value??e.id,href:e.href??null,event:t});return s.defaultPrevented?t.preventDefault():e.href||(t.preventDefault(),e.invoke?.()),s}_onRailKeydown(e){let t=sh(this.refs.list),s=e.target?.closest?.("[data-app-nav-id]"),n=t.indexOf(s);if(n<0)return;let r=this.el.dataset.orientation==="horizontal",o=r?"ArrowLeft":"ArrowUp",a=r?"ArrowRight":"ArrowDown",l={left:"ArrowRight",right:"ArrowLeft",top:"ArrowDown",bottom:"ArrowUp"}[this.el.dataset.side],u=s.getAttribute("data-app-nav-id");if(e.key===l&&this._flyouts.has(String(u))){e.preventDefault(),this.openFlyout(String(u),{focus:!0});return}let d;if(e.key==="Home")d=0;else if(e.key==="End")d=t.length-1;else if(e.key===o)d=(n-1+t.length)%t.length;else if(e.key===a)d=(n+1)%t.length;else return;e.preventDefault(),t[d]?.focus()}_onFlyoutKeydown(e,t){let s=ca(t.panel),n=e.target?.closest?.("a, button"),r=s.indexOf(n),o=[...this._flyouts.values()].find(d=>d.trigger===n),a=this.el.dataset.side==="right"?"ArrowLeft":"ArrowRight",l=a==="ArrowRight"?"ArrowLeft":"ArrowRight";if(o&&e.key===a){e.preventDefault(),e.stopPropagation(),this.openFlyout(o.key,{focus:!0});return}if((t.parentKey!==null||this.el.dataset.orientation==="vertical")&&e.key===l){e.preventDefault(),e.stopPropagation(),this.closeFlyout(t.key),this._restoreFocus(t.trigger);return}if(s.length===0)return;let u;if(e.key==="Home")u=0;else if(e.key==="End")u=s.length-1;else if(e.key==="ArrowDown")u=(r+1+s.length)%s.length;else if(e.key==="ArrowUp")u=(r-1+s.length)%s.length;else return;e.preventDefault(),s[u]?.focus()}_scheduleOpen(e){let t=String(e);this._cancelTimer(this._closeTimers,t),this._cancelTimer(this._openTimers,t);let s=Math.max(0,Number(this.options.openDelay)||0);this._openTimers.set(t,setTimeout(()=>{this._openTimers.delete(t),this.openFlyout(e)},s))}_scheduleClose(e){let t=String(e);this._cancelTimer(this._openTimers,t),this._cancelTimer(this._closeTimers,t);let s=Math.max(0,Number(this.options.closeDelay)||0);this._closeTimers.set(t,setTimeout(()=>{this._closeTimers.delete(t);let n=this._flyouts.get(t);n&&(this._branchInteracting(n)||this.closeFlyout(t))},s))}_scheduleFlyoutClose(e,t){let s=e;for(;s&&(this._scheduleClose(s.key),!(!t||s.parentKey===null));)s=this._flyouts.get(s.parentKey)??null}_resolveFlyout(e){let t=String(e);return this._flyouts.get(t)??[...this._flyouts.values()].find(s=>String(s.item.id)===t)??null}_closeFlyoutChain(e){let t=this._flyouts.get(e)??null;for(;t?.parentKey!==null;)t=this._flyouts.get(t.parentKey)??null;t&&this.closeFlyout(t.key)}_isAncestor(e,t){let s=t.parentKey;for(;s!==null;){if(s===e.key)return!0;s=this._flyouts.get(s)?.parentKey??null}return!1}_cancelFlyoutTimers(e,t){let s=e;for(;s&&(this._cancelTimers(s.key),!(!t||s.parentKey===null));)s=this._flyouts.get(s.parentKey)??null}_branchInteracting(e){return e.trigger.matches(":hover")||e.panel.matches(":hover")||e.trigger===document.activeElement||e.panel.contains(document.activeElement)?!0:[...this._flyouts.values()].some(t=>this._isAncestor(e,t)&&t.dropdown.isOpen()&&(t.trigger.matches(":hover")||t.panel.matches(":hover")||t.trigger===document.activeElement||t.panel.contains(document.activeElement)))}_restoreFocus(e){this._pointerFocus.add(e),e.focus(),queueMicrotask(()=>this._pointerFocus.delete(e))}_cancelTimers(e){this._cancelTimer(this._openTimers,e),this._cancelTimer(this._closeTimers,e)}_cancelTimer(e,t){let s=e.get(t);s!==void 0&&clearTimeout(s),e.delete(t)}_syncActive(){let e=this._active==null?null:String(this._active);for(let t of this.refs.list.querySelectorAll("[data-app-nav-id]")){let s=e!==null&&t.getAttribute("data-app-nav-value-id")===e,n=this._flyouts.get(String(t.getAttribute("data-app-nav-id"))),r=e!==null&&n?Hs(n.item.children??[],e):!1;s?t.setAttribute("aria-current","page"):t.removeAttribute("aria-current"),r?t.dataset.activeDescendant="true":delete t.dataset.activeDescendant}for(let t of this._flyouts.values()){e!==null&&Hs(t.item.children??[],e)?t.trigger.dataset.activeDescendant="true":delete t.trigger.dataset.activeDescendant;for(let n of t.panel.querySelectorAll("[data-app-nav-value-id]"))e!==null&&n.getAttribute("data-app-nav-value-id")===e?n.setAttribute("aria-current","page"):n.removeAttribute("aria-current")}}_clearArtifacts(){for(let e of this._openTimers?this._openTimers.values():[])clearTimeout(e);for(let e of this._closeTimers?this._closeTimers.values():[])clearTimeout(e);this._openTimers?.clear?.(),this._closeTimers?.clear?.(),this._interaction?.destroy?.();for(let e of this._tooltips??[])e.destroy();this._silenceFlyoutEvents=!0;for(let e of this._flyouts?.values?.()??[])e.dropdown.destroy();this._silenceFlyoutEvents=!1,this._tooltips=[],this._tooltipById=new Map,this._interaction=null,this._flyouts=new Map}_message(e,t,...s){let n=this.msg(e,...s);return n===e?O(t,s):n}},qs=class extends S{constructor(e){super(null),e.append(this.el)}render(){return c("span",{hidden:!0,"data-zx-app-rail-listener-scope":""})}},la=Object.freeze({});function $s(i,e=!1){return i.flatMap(t=>t.section?[e?t:la,...$s(t.children??[],e)]:[t])}function Oe(i){return Array.isArray(i)?i.filter(e=>e&&typeof e=="object"&&e.label!=null&&(e.id!=null||e.section===!0)).map((e,t)=>{let s={...e,id:e.id??`section:${t}:${e.label}`,label:String(e.label),children:Array.isArray(e.children)?Oe(e.children):[]};if(e.section===!0)return s.section=!0,delete s.href,s;if(e.href==null)return s;let n=Be(e.href);return n!==null?s.href=n:(delete s.href,s.children.length===0&&typeof s.invoke!="function"&&(s.disabled=!0)),s}):[]}function Di(i,e,t){let s=typeof e=="function"?e(i,t):null;if(s==null&&(s=i.icon),typeof s=="function"&&(s=s(t,i)),typeof s=="string")return v(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 ra(i,{className:e,index:t,iconOnly:s,disclosure:n,disclosureIcon:r,visual:o}){let a=Be(i.href),l=a&&!n?"a":"button";return c(l,{class:e,type:l==="button"?"button":null,href:l==="a"?a:null,target:l==="a"?i.target??null:null,rel:l==="a"?"noopener":null,ariaLabel:s?i.label:null,ariaDisabled:i.disabled?"true":null,dataset:{appNavId:t,appNavValueId:String(i.id)}},o?c("span",{class:`${e}-icon`,ariaHidden:"true"},o):null,c("span",{class:`${e}-label`},i.label),i.badge!=null?c("span",{class:`${e}-badge`},String(i.badge)):null,n?c("span",{class:`${e}-disclosure`,ariaHidden:"true"},v(r)):null)}function Xd(i){return{left:"chevron-right",right:"chevron-left",top:"chevron-down",bottom:"chevron-up"}[i]??"chevron-right"}function Jd(i){return i==="right"?"chevron-left":"chevron-right"}function eh(i){return{left:"right-start",right:"left-start",top:"bottom-start",bottom:"top-start"}[i]??"right-start"}function th(i){return i==="right"?"left-start":"right-start"}function ih(i){return{left:"right",right:"left",top:"bottom",bottom:"top"}[i]??"right"}function ca(i){return[...i.querySelectorAll('a:not([aria-disabled="true"]), button:not([aria-disabled="true"])')]}function oa(i){return ca(i)[0]??null}function sh(i){return[...i.children].map(e=>e.querySelector("[data-app-nav-id]")).filter(Boolean)}function Hs(i,e){return i.some(t=>String(t.id)===e||Hs(t.children??[],e))}function aa(i,e){if(e!=null)if(typeof e=="string"||typeof e=="number")i.append(document.createTextNode(String(e)));else if(typeof e=="object"&&typeof e.toElement=="function"){let t=e.toElement();t&&i.append(t)}else typeof e=="object"&&typeof e.nodeType=="number"&&i.append(e)}var nh=["tint","solid","plain"],rh=12,oh=600,Ii=class extends Ci{static cssName="module-bar";static partBlock="zx-module-bar";static defaults={items:[],active:null,orientation:"vertical",side:"left",appearance:"tint",labels:"hidden",menus:"flyout",expanded:null,controls:null,allModules:"auto",header:null,footer:null,label:null,openDelay:80,closeDelay:160,renderIcon:null};constructor(e=null,t={}){super(e,t)}render(){let e=super.render();return this._sections=new Map,this._items=Ys(this._items,this._sections),this._appearance=nh.includes(this.options.appearance)?this.options.appearance:"tint",this._menus=this.options.menus==="none"?"none":"flyout",this._expandedId=this.options.expanded??null,this._labels=this.options.labels,this._promoted=null,this._catalogue=null,this._silenceCatalogue=!1,this._catalogueTooltip=null,this._observer=null,this._partition={visible:[],overflow:[]},this._rovingId=null,this._typeahead={text:"",at:0},e.setAttribute("aria-label",this._labelText()),e.dataset.appearance=this._appearance,e.dataset.menus=this._menus,e.dataset.allModules=["always","never"].includes(this.options.allModules)?this.options.allModules:"auto",e.dataset.labels=Ks(this.options.labels,e.dataset.orientation),e}setItems(e){let t=new Map,s=Ys(Oe(e),t);return this._sections=t,super.setItems(s)}getItems(){return super.getItems()}setActive(e){return super.setActive(e)}openFlyout(e,t={}){return super.openFlyout(e,t)}closeFlyout(e){return super.closeFlyout(e)}closeAllFlyouts(){return super.closeAllFlyouts()}isFlyoutOpen(e){return super.isFlyoutOpen(e)}setExpanded(e){return this._expandedId=e??null,this._syncExpanded(),this._layout(),this}setBadge(e,t){let s=pe(this._items,e);if(!s)return this;t==null||t===""?delete s.badge:s.badge=t;let n=String(e);for(let o of this.refs.list.querySelectorAll(".zx-module-bar__item[data-app-nav-value-id]"))o.getAttribute("data-app-nav-value-id")===n&&this._applyTileBadge(o,s);for(let o of this._flyouts.values())for(let a of o.panel.querySelectorAll("[data-app-nav-value-id]"))a.getAttribute("data-app-nav-value-id")===n&&Us(a,s,"zx-app-rail__flyout-item");let r=this._catalogueEntry(n);return r&&Us(r,s,"zx-module-bar__entry"),this}setLayout(e={}){let t=e.orientation==="horizontal"||e.orientation==="vertical"?e.orientation:this.el.dataset.orientation,s=t==="horizontal"?["top","bottom"]:["left","right"],n=s.includes(e.side??this.el.dataset.side)?e.side??this.el.dataset.side:s[0];return t===this.el.dataset.orientation&&n===this.el.dataset.side?this:(this.el.dataset.orientation=t,this.el.dataset.side=n,this.el.dataset.labels=Ks(this._labels,t),this._rebuild(),this)}setLabels(e){this._labels=e;let t=Ks(e,this.el.dataset.orientation);if(t===this.el.dataset.labels)return this;let s=document.activeElement,n=s instanceof HTMLElement&&this.refs.list.contains(s)&&s.matches(".zx-module-bar__item")?Ei(s):null;return this.el.dataset.labels=t,this._rebuild(),n!==null&&[...this.refs.list.querySelectorAll(".zx-module-bar__item")].find(r=>Ei(r)===n)?.focus(),this}openAllModules(){return this._catalogue?.open(),this._focusCatalogue(),this}closeAllModules(){return this._catalogue?.close(),this}isAllModulesOpen(){return this._catalogue?.isOpen()??!1}focus(){return this._rovingStop()?.focus(),this}destroy(){super.destroy()}_containsNode(e){return super._containsNode(e)||!!(e&&this._catalogue?.getPanel().contains(e))}_clearArtifacts(){super._clearArtifacts(),this._observer?.disconnect(),this._observer=null,this._catalogueTooltip?.destroy(),this._catalogueTooltip=null,this._silenceCatalogue=!0,this._catalogue?.destroy(),this._silenceCatalogue=!1,this._catalogue=null}_flyoutsFor(e){return this._menus==="flyout"&&!e.disabled}_tooltipFor(){return this.el.dataset.labels==="hidden"}_renderControl(e){let t=!!e.children?.length,s=e.href&&!t?"a":"button",n=this.el.dataset.labels!=="hidden",r=c(s,{class:"zx-module-bar__item",type:s==="button"?"button":null,href:s==="a"?e.href:null,target:s==="a"?e.target??null:null,rel:s==="a"&&e.target?"noopener":null,ariaDisabled:e.disabled?"true":null,tabIndex:-1,dataset:{appNavId:String(e.id),appNavValueId:String(e.id)}},this._renderTile(e,"bar"),n?c("span",{class:"zx-module-bar__label"},e.label):null);return this._applyTileBadge(r,e),r}_afterRebuild(){let e=this.refs.list,t=fa(this._items),s=new Map;for(let r of[...e.children]){let o=r.querySelector("[data-app-nav-value-id]")?.getAttribute("data-app-nav-value-id");o!=null&&(r.dataset.moduleId=o,s.set(o,r))}let n=null;for(let r of t){let o=s.get(String(r.id));if(!o)continue;let a=this._sections.get(String(r.id))??null;a!==null&&a!==n&&e.append(c("li",{class:"zx-module-bar__heading",dataset:{section:a}},c("span",{class:"zx-module-bar__heading-label"},a))),n=a,e.append(o)}this._promoted!==null&&!pe(this._items,this._promoted)&&(this._promoted=null),this._buildCatalogue(),this._interaction.listen(e,"focusin",r=>{let o=r.target.closest?.(".zx-module-bar__item");o instanceof HTMLElement&&this._setRovingStop(o)}),this._interaction.listen(e,"focusout",r=>{e.contains(r.relatedTarget)||(this._rovingId=null,this._syncRoving())}),typeof ResizeObserver=="function"&&(this._observer=new ResizeObserver(()=>this._layout()),this._observer.observe(e))}_syncActive(){super._syncActive();let e=this._active==null?null:String(this._active);for(let t of this._tiles()){let s=pe(this._items,t.getAttribute("data-app-nav-value-id"));if(!s)continue;let n=ha(s,e);n?t.setAttribute("aria-current",n):t.removeAttribute("aria-current"),n==="true"?t.dataset.activeDescendant="true":delete t.dataset.activeDescendant}for(let t of this._catalogueEntries()){let s=pe(this._items,t.dataset.moduleId),n=s?ha(s,e):null;n?t.setAttribute("aria-current",n):t.removeAttribute("aria-current")}this._syncExpanded(),this._layout()}_layout(){let e=this.refs.list;if(!e||!this._items)return;let t=[...e.querySelectorAll(":scope > [data-module-id]")],s=e.querySelector(":scope > [data-module-bar-more]"),n=this.el.dataset.allModules,r=[dh(this._items,this._active)?.id,this._expandedId,this._promoted],o=1/0;if(n!=="never"&&e.isConnected){for(let h of t)h.hidden=!1;s&&(s.hidden=!1),ua(e),o=ch(e,this.el.dataset.orientation==="horizontal",t.length+1)}let a=ah(this._items,o,r,n==="always"),l=new Set(a.visible.map(h=>String(h.id)));for(let h of t)h.hidden=!l.has(h.dataset.moduleId);ua(e),s&&(s.hidden=n==="never"||n==="auto"&&!a.more);let u={visible:a.visible.map(h=>h.id),overflow:a.overflow.map(h=>h.id)},d=u.visible.join("\0")!==this._partition.visible.join("\0")||u.overflow.join("\0")!==this._partition.overflow.join("\0");this._partition=u,this._syncRoving(),d&&e.isConnected&&this.emit("overflowchange",{...u})}_renderTile(e,t){let s=Di(e,this.options.renderIcon,{orientation:this.el.dataset.orientation,collapsed:!0,side:this.el.dataset.side,level:1,location:t==="bar"?"module":"catalogue"})??c("span",{class:"zx-module-bar__initial"},e.label.trim().charAt(0).toUpperCase()),{tone:n,color:r}=lh(e),o=c("span",{class:"zx-module-bar__tile",ariaHidden:"true",dataset:{appearance:this._appearance,...n?{tone:n}:{},...r?{color:""}:{}}});return this._appearance==="solid"?o.append(Si({icon:s,color:r,tone:n??(r?null:"slate"),size:"var(--zx-module-bar-tile)",iconSize:"58%",glass:"subtle"})):(r&&o.style.setProperty("--zx-module-bar-color",r),o.append(s)),o}_applyTileBadge(e,t){e.querySelector(":scope > .zx-module-bar__badge")?.remove();let s=t.badge==null||t.badge===""?null:String(t.badge);e.setAttribute("aria-label",s===null?t.label:this._message("moduleBar.itemBadge","%1 (%2)",t.label,s)),s!==null&&e.append(c("span",{class:"zx-module-bar__badge",ariaHidden:"true",dataset:{zxBadge:s.length>2&&this.el.dataset.labels!=="beside"?"dot":"count"}},s))}_buildCatalogue(){let e=this._message("moduleBar.more","All modules"),t=this.el.dataset.labels!=="hidden",s=c("button",{class:"zx-module-bar__item",type:"button",ariaLabel:e,tabIndex:-1,dataset:{moduleBarMore:""}},c("span",{class:"zx-module-bar__tile",ariaHidden:"true",dataset:{appearance:"plain"}},v("grid")),t?c("span",{class:"zx-module-bar__label"},e):null);this.refs.list.append(c("li",{class:"zx-module-bar__row",dataset:{moduleBarMore:""}},s)),t||(this._catalogueTooltip=new et(s,{content:e,placement:{left:"right",right:"left",top:"bottom",bottom:"top"}[this.el.dataset.side]??"right",delay:450}));let n=this._items.length>rh?c("input",{class:"zx-module-bar__filter",type:"search",autocomplete:"off",placeholder:this._message("moduleBar.filter","Filter modules"),ariaLabel:this._message("moduleBar.filter","Filter modules")}):null,r=new Map;for(let p of this._items){let f=typeof p.group=="string"?p.group:this._sections.get(String(p.id))??"";r.has(f)||r.set(f,[]),r.get(f).push(p)}let o=[...r].map(([p,f])=>{let _=p?E("zx-module-bar-group"):null;return c("div",{class:"zx-module-bar__group"},p?c("div",{class:"zx-module-bar__group-label",id:_},p):null,c("ul",{class:"zx-module-bar__grid",ariaLabelledby:_},f.map(m=>c("li",{dataset:{moduleId:String(m.id)}},this._catalogueControl(m)))))}),a=c("p",{class:"zx-module-bar__empty",hidden:!0},this._message("moduleBar.empty","No modules")),l=c("div",{class:"zx-module-bar__catalogue"},n,...o,a),u={left:"right-start",right:"left-start",top:"bottom-end",bottom:"top-end"}[this.el.dataset.side]??"right-start",d=new Qe(s,{content:l,placement:u,offset:6}),h=d.getPanel();h.classList.add("zx-module-bar__popover"),h.setAttribute("role","region"),h.setAttribute("aria-label",e),this._catalogue=d,d.on("open",()=>{this.closeAllFlyouts(),this._catalogueTooltip?.hide(),this.emit("allmodules",{open:!0})}),d.on("close",()=>{n instanceof HTMLInputElement&&n.value&&(n.value="",this._filterCatalogue("")),this._silenceCatalogue||this.emit("allmodules",{open:!1})}),this._interaction.listen(s,"click",()=>{d.isOpen()&&this._focusCatalogue()}),n&&this._interaction.listen(n,"input",()=>this._filterCatalogue(n.value)),this._interaction.listen(h,"click",p=>this._onCatalogueClick(p)),this._interaction.listen(h,"focusout",p=>{let f=p.relatedTarget;f&&!h.contains(f)&&f!==s&&d.close()}),this._interaction.listen(h,"keydown",p=>this._onCatalogueKeydown(p)),this._interaction.listen(h,"focusin",p=>{let f=p.target.closest?.(".zx-module-bar__entry");f instanceof HTMLElement&&this._syncCatalogueStop(f)}),this._syncCatalogueStop()}_syncCatalogueStop(e){let t=this._catalogueEntries(),s=t.filter(r=>!r.closest("li")?.hidden),n=(e&&s.includes(e)?e:null)??s.find(r=>r.tabIndex===0&&r.dataset.catalogueStop==="true")??s.find(r=>r.hasAttribute("aria-current"))??s[0];for(let r of t)r.tabIndex=r===n?0:-1,r===n?r.dataset.catalogueStop="true":delete r.dataset.catalogueStop}_catalogueControl(e){let t=!!e.children?.length,s=e.href&&!t?"a":"button",n=c(s,{class:"zx-module-bar__entry",type:s==="button"?"button":null,href:s==="a"?e.href:null,target:s==="a"?e.target??null:null,rel:s==="a"&&e.target?"noopener":null,title:typeof e.description=="string"?e.description:null,ariaDisabled:e.disabled?"true":null,dataset:{moduleId:String(e.id)}},this._renderTile(e,"catalogue"),c("span",{class:"zx-module-bar__entry-label"},e.label));return Us(n,e,"zx-module-bar__entry"),n}_onCatalogueClick(e){let t=e.target.closest?.(".zx-module-bar__entry");if(!(t instanceof HTMLElement))return;let s=pe(this._items,t.dataset.moduleId);if(!s||s.disabled){e.preventDefault();return}if(s.children?.length&&this._menus==="flyout"){e.preventDefault(),this._catalogue?.close(),this._promoted=s.id,this._layout();let o=e instanceof MouseEvent&&e.detail===0;this.openFlyout(s.id,{focus:o}),o||this._tiles().find(a=>a.getAttribute("data-app-nav-value-id")===String(s.id))?.focus();return}this._select(s,e);let n=this._catalogue?.getPanel();this._catalogue?.close();let r=document.activeElement;(!r||r===document.body||n?.contains(r))&&(this._tiles().find(a=>a.getAttribute("data-app-nav-value-id")===String(s.id)&&!a.closest("li")?.hidden)??this.refs.list.querySelector("[data-module-bar-more] .zx-module-bar__item"))?.focus()}_onCatalogueKeydown(e){let t=this._catalogue?.getPanel();if(!t||e.altKey||e.ctrlKey||e.metaKey)return;let s=t.querySelector(".zx-module-bar__filter"),n=this._catalogueEntries().filter(l=>!l.closest("li")?.hidden),r=e.target.closest?.(".zx-module-bar__entry");if(e.target===s){e.key==="ArrowDown"&&n[0]&&(e.preventDefault(),n[0].focus());return}if(!(r instanceof HTMLElement))return;let o=n.indexOf(r),a=null;if(e.key==="ArrowRight")a=n[Math.min(n.length-1,o+1)];else if(e.key==="ArrowLeft")a=n[Math.max(0,o-1)];else if(e.key==="Home")a=n[0];else if(e.key==="End")a=n.at(-1);else if(e.key==="ArrowDown"||e.key==="ArrowUp")a=uh(n,r,e.key==="ArrowDown"?1:-1),!a&&e.key==="ArrowUp"&&s instanceof HTMLElement&&(a=s);else if(s instanceof HTMLElement&&e.key.length===1&&e.key!==" "){s.focus();return}else return;e.preventDefault(),a?.focus()}_filterCatalogue(e){let t=this._catalogue?.getPanel();if(!t)return;let s=e.trim().toLocaleLowerCase(),n=0;for(let o of t.querySelectorAll(".zx-module-bar__group")){let a=0;for(let l of o.querySelectorAll("li[data-module-id]")){let u=pe(this._items,l.dataset.moduleId),d=`${u?.label??""} ${u?.description??""} ${u?.group??""}`.toLocaleLowerCase(),h=!s||d.includes(s);l.hidden=!h,h&&(a+=1)}o.hidden=a===0,n+=a}let r=t.querySelector(".zx-module-bar__empty");r instanceof HTMLElement&&(r.hidden=n>0),this._syncCatalogueStop()}_focusCatalogue(){let e=this._catalogue?.getPanel();if(!e||!this._catalogue?.isOpen())return;let s=e.querySelector(".zx-module-bar__filter")??this._catalogueEntries().find(n=>n.hasAttribute("aria-current"))??this._catalogueEntries()[0];s instanceof HTMLElement&&s.focus()}_onRailKeydown(e){let t=e.target.closest?.(".zx-module-bar__item");if(!(t instanceof HTMLElement)||!this.refs.list.contains(t)||e.altKey||e.ctrlKey||e.metaKey)return;let s=this._rovingControls(),n=s.indexOf(t),r=this.el.dataset.orientation==="horizontal",o=r?"ArrowLeft":"ArrowUp",a=r?"ArrowRight":"ArrowDown",l={left:"ArrowRight",right:"ArrowLeft",top:"ArrowDown",bottom:"ArrowUp"}[this.el.dataset.side],u=t.getAttribute("data-app-nav-id");if(e.key===l&&u!==null&&this._flyouts.has(u)){e.preventDefault(),this.openFlyout(u,{focus:!0});return}let d=null;if(e.key==="Home")d=s[0];else if(e.key==="End")d=s.at(-1);else if(e.key===o)d=s[(n-1+s.length)%s.length];else if(e.key===a)d=s[(n+1)%s.length];else if(e.key.length===1&&e.key!==" ")d=this._typeaheadTarget(e.key,s,n);else return;d&&(e.preventDefault(),this._setRovingStop(d),d.focus())}_typeaheadTarget(e,t,s){let n=Date.now(),r=n-this._typeahead.at>oh?e:this._typeahead.text+e;this._typeahead={text:r,at:n};let o=r.toLocaleLowerCase(),a=[...o].every(h=>h===o[0]),l=h=>(pe(this._items,h.getAttribute("data-app-nav-value-id"))?.label??h.getAttribute("aria-label")??"").toLocaleLowerCase(),u=[...t.slice(s+1),...t.slice(0,s+1)],d=u.find(h=>l(h).startsWith(o))??(a?u.find(h=>l(h).startsWith(o[0])):null);return d||r.length===1?d??null:(this._typeahead={text:e,at:n},u.find(h=>l(h).startsWith(e.toLocaleLowerCase()))??null)}_tiles(){return[...this.refs.list.querySelectorAll(":scope > li > .zx-module-bar__item[data-app-nav-value-id]")]}_rovingControls(){return[...this.refs.list.querySelectorAll(":scope > li:not([hidden]) > .zx-module-bar__item")]}_rovingStop(){let e=this._rovingControls();if(this._rovingId!==null){let t=e.find(s=>Ei(s)===this._rovingId);if(t)return t}return e.find(t=>t.hasAttribute("aria-current"))??e.find(t=>t.getAttribute("aria-expanded")==="true"&&t.hasAttribute("data-app-nav-value-id"))??e[0]??null}_setRovingStop(e){this._rovingId=Ei(e),this._syncRoving()}_syncRoving(){let e=this._rovingStop();for(let t of this.refs.list.querySelectorAll(":scope > li > .zx-module-bar__item"))t.tabIndex=t===e?0:-1}_syncExpanded(){if(this._menus!=="none")return;let e=this._expandedId==null?null:String(this._expandedId);for(let t of this._tiles()){let s=t.getAttribute("data-app-nav-value-id"),n=pe(this._items,s);(n?.children?.length||n?.header||n?.content||s===e)&&(t.setAttribute("aria-expanded",String(s===e)),this.options.controls&&t.setAttribute("aria-controls",String(this.options.controls)))}}_catalogueEntries(){let e=this._catalogue?.getPanel();return e?[...e.querySelectorAll(".zx-module-bar__entry")]:[]}_catalogueEntry(e){return this._catalogueEntries().find(t=>t.dataset.moduleId===e)??null}_labelText(){let e=this.options.label;return e==null||e===""?this._message("moduleBar.label","Modules"):String(e)}};function ah(i,e=1/0,t=[],s=!1){let n=Array.isArray(i)?i.filter(_=>_&&_.id!=null):[],r=fa(n),a=n.some(da)?r.filter(da):r,l=Number.isFinite(e)?Math.max(1,Math.floor(e)):1/0,d=s||a.length<n.length||a.length>l?Math.max(0,l-1):l,h=a.slice(0,d),p=new Set([t].flat().filter(_=>_!=null).map(String));for(let _ of p){let m=n.find(g=>String(g.id)===_);if(!(!m||h.includes(m))){if(h.length>=d){let g=h.findLastIndex(b=>!p.has(String(b.id)));g>=0&&h.splice(g,1)}h.push(m)}}h.sort((_,m)=>r.indexOf(_)-r.indexOf(m));let f=n.filter(_=>!h.includes(_));return{visible:h,overflow:f,more:f.length>0}}function lh(i){let e=we(i?.color)?String(i.color).trim():null;return e?{tone:null,color:e}:{tone:Vs.includes(i?.tone)?i.tone:null,color:null}}function Ys(i,e=new Map,t=null){return i.flatMap(s=>s.section?Ys(s.children??[],e,s.label):(t!==null&&e.set(String(s.id),t),[s]))}function ua(i){let e=null,t=!1,s=!0,n=()=>{e&&(e.hidden=!t)};for(let r of[...i.children]){if(r.classList.contains("zx-module-bar__heading")){n(),e=r,t=!1,s?r.dataset.leading="":delete r.dataset.leading;continue}r.hasAttribute("data-module-id")&&!r.hidden&&(t=!0,s=!1)}n()}function Ks(i,e){return e!=="vertical"?"hidden":i==="below"||i==="beside"?i:"hidden"}function da(i){return i.pinned===!0||typeof i.pinned=="number"&&Number.isFinite(i.pinned)}function fa(i){let e=t=>typeof t.pinned=="number"&&Number.isFinite(t.pinned)?t.pinned:t.pinned===!0?Number.MAX_SAFE_INTEGER-1:Number.MAX_SAFE_INTEGER;return i.map((t,s)=>({item:t,index:s})).sort((t,s)=>e(t.item)-e(s.item)||t.index-s.index).map(({item:t})=>t)}function ch(i,e,t){if(!(e?i.scrollWidth>i.clientWidth+1:i.scrollHeight>i.clientHeight+1))return 1/0;let n=[...i.querySelectorAll(":scope > li:not([hidden]):not(.zx-module-bar__heading)")];if(!n.length)return 1/0;let r=[...i.querySelectorAll(":scope > li.zx-module-bar__heading:not([hidden])")],o=getComputedStyle(i),a=Number.parseFloat(e?o.columnGap:o.rowGap)||0,l=e?(Number.parseFloat(o.paddingInlineStart)||0)+(Number.parseFloat(o.paddingInlineEnd)||0):(Number.parseFloat(o.paddingBlockStart)||0)+(Number.parseFloat(o.paddingBlockEnd)||0),u=Math.max(...n.map(p=>e?p.offsetWidth:p.offsetHeight)),d=r.reduce((p,f)=>p+a+(e?f.offsetWidth:f.offsetHeight)+(Number.parseFloat(e?getComputedStyle(f).marginInlineStart:getComputedStyle(f).marginBlockStart)||0)+(Number.parseFloat(e?getComputedStyle(f).marginInlineEnd:getComputedStyle(f).marginBlockEnd)||0),0),h=(e?i.clientWidth:i.clientHeight)-l-d;return u<=0||h<=0?t:Math.max(1,Math.floor((h+a)/(u+a)))}function uh(i,e,t){let s=e.getBoundingClientRect(),n=s.left+s.width/2,r=null,o=1/0,a=1/0;for(let l of i){if(l===e)continue;let u=l.getBoundingClientRect(),d=t>0?u.top-s.bottom+1:s.top-u.bottom+1;if(d<0)continue;let h=Math.abs(u.left+u.width/2-n);(d<o-1||Math.abs(d-o)<=1&&h<a)&&(r=l,o=d,a=h)}return r}function Ei(i){return i.getAttribute("data-app-nav-value-id")??"\0more"}function ha(i,e){return e===null?null:String(i.id)===e?"page":Ws(i.children??[],e)?"true":null}function Us(i,e,t){let s=i.querySelector(`:scope > .${t}-badge`),n=e.badge==null||e.badge===""?null:String(e.badge);if(n===null){s?.remove();return}s?s.textContent=n:i.querySelector(`:scope > .${t}-label`)?.after(c("span",{class:`${t}-badge`},n))}function dh(i,e){if(e==null||!Array.isArray(i))return null;let t=String(e);return i.find(s=>String(s.id)===t||Ws(s.children??[],t))??null}function pe(i,e){if(e==null)return null;for(let t of i??[]){if(String(t.id)===String(e))return t;let s=pe(t.children??[],e);if(s)return s}return null}function Ws(i,e){return i.some(t=>String(t.id)===e||Ws(t.children??[],e))}var hh=8e3,Gs=class{#e;#t=[];#i=[];#s;constructor(e=5,t=()=>{}){if(!Number.isInteger(e)||e<1)throw new RangeError("Queue limit must be positive");if(typeof t!="function")throw new TypeError("Activation callback must be a function");this.#e=e,this.#s=t}enqueue(e){return this.#t.length<this.#e?(this.#t.push(e),this.#s(e),"active"):(this.#i.push(e),"pending")}remove(e){let t=this.#i.indexOf(e);if(t!==-1)return this.#i.splice(t,1),"pending";let s=this.#t.indexOf(e);if(s===-1)return null;if(this.#t.splice(s,1),this.#i.length>0){let n=this.#i.shift();this.#t.push(n),this.#s(n)}return"active"}isActive(e){return this.#t.includes(e)}clear(){let e={active:this.#t.slice(),pending:this.#i.slice()};return this.#t.length=0,this.#i.length=0,e}get activeCount(){return this.#t.length}get pendingCount(){return this.#i.length}},ke=class i extends S{static cssName="message";static defaults={kind:"info",timeout:4e3,closable:!0,maxVisible:5};render(){let e=!this.el,t=this.el??c("div");return this._createdRoot=e,this._original=e?null:xh(t),this._entries=new Set,this._floatingHost=null,this._placedIn=null,this._overlay=null,this._unfollow=null,this._queue=new Gs(yh(this.options.maxVisible),s=>{this._activate(s)}),t.replaceChildren(),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t}show(e,t={}){let s=_h(t.action),n={kind:fh(t.kind??this.options.kind),timeout:mh(t.timeout??this.options.timeout,s!==null),closable:t.closable??!!this.options.closable,action:s,leading:gh(t.leading)},r=this._createEntry(e,n);return this._entries.add(r),this._queue.enqueue(r),{close:()=>this._close(r)}}static info(e,t={}){return this.show(e,{...t,kind:"info"})}static success(e,t={}){return this.show(e,{...t,kind:"success"})}static warning(e,t={}){return this.show(e,{...t,kind:"warning"})}static error(e,t={}){return this.show(e,{...t,kind:"error"})}static show(e,t={}){return this.#e(t.scope).show(e,t)}static progress(e,t={}){return this.#e(t.scope)._progress(e)}static disposeRegion(e){if(e==null)return!1;let t=U(e);if(!t)return!1;let s=i.#t(ie(t));return s?(s._disposeFloating(),!0):!1}destroy(){if(this._cleaned)return;this._cleaned=!0,this._unfollow?.(),this._unfollow=null;let e=this._overlay;this._overlay=null,e?.release(),this._floatingHost=null,this._placedIn=null;for(let t of this._entries)Zs(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&Sh(this.el,this._original)}_progress(e){let t={pct:0,text:String(e)},s=this._createEntry(t.text,{kind:"info",timeout:0,closable:!1},t);this._entries.add(s),this._queue.enqueue(s);let n=!1;return{update:(r,o)=>{n||s.closed||(t.pct=wh(r),o!==void 0&&(t.text=String(o)),Ti(s,t))},done:()=>{n||s.closed||(n=!0,t.pct=100,Ti(s,t),s.remaining=600,this._queue.isActive(s)&&this._schedule(s))},fail:r=>{n||s.closed||(n=!0,r!==void 0&&(t.text=String(r)),s.kind="error",s.node.dataset.kind="error",s.node.setAttribute("role","alert"),s.iconHost.replaceChildren(v("error",{size:18})),Ti(s,t),s.remaining=4e3,this._queue.isActive(s)&&this._schedule(s))}}}_createEntry(e,t,s=null){let n=c("span",{class:"zx-message__icon",ariaHidden:"true"},t.leading??v(t.kind,{size:18})),r=c("div",{class:"zx-message__content"});St(e)?r.append(e):r.append(document.createTextNode(String(e)));let o=c("div",{class:"zx-message__toast",role:t.kind==="error"?"alert":"status",dataset:{kind:t.kind,state:"queued"}},n,r),a={node:o,content:r,iconHost:n,kind:t.kind,timeout:t.timeout,remaining:t.timeout,startedAt:0,timer:null,exitTimer:null,closed:!1,hovered:!1,focused:!1,returnFocus:null,progressBar:null,progressFill:null};if(t.leading&&(o.dataset.leading=""),s){o.dataset.progress="";let l=c("span",{class:"zx-message__progress-fill"}),u=c("div",{class:"zx-message__progress",role:"progressbar",ariaValueMin:"0",ariaValueMax:"100",ariaValueNow:"0",ariaLabel:s.text},l);r.append(u),a.progressBar=u,a.progressFill=l,Ti(a,s)}if(t.action){let{label:l,kind:u,onclick:d}=t.action,h=Bo({label:l,kind:u,size:"sm"});h.classList.add("zx-message__action"),o.append(h),this.listen(h,"click",p=>{if(!a.closed)try{d?.(p)}finally{this._close(a)}})}if(t.closable){let l=c("button",{class:"zx-icon-btn zx-message__close",type:"button",ariaLabel:this._message("message.close","Close message"),title:this._message("message.closeTitle","Close")},v("x",{size:14}));o.append(l),this.listen(l,"click",()=>this._close(a))}return this.listen(o,"mouseenter",()=>{a.hovered=!0,this._pause(a)}),this.listen(o,"mouseleave",()=>{a.hovered=!1,this._resume(a)}),this.listen(o,"focusin",l=>{if(!a.focused){let u=l.relatedTarget;a.returnFocus=St(u)&&!o.contains(u)?u:null}a.focused=!0,this._pause(a)}),this.listen(o,"focusout",l=>{let u=l.relatedTarget;St(u)&&o.contains(u)||(a.focused=!1,this._resume(a))}),a}_activate(e){e.closed||(e.node.dataset.state="open",this.el.append(e.node),this._schedule(e))}_schedule(e){e.closed||e.remaining<=0||e.hovered||e.focused||(e.startedAt=Date.now(),e.timer=setTimeout(()=>this._close(e),e.remaining))}_pause(e){e.closed||e.timer===null||(clearTimeout(e.timer),e.timer=null,e.remaining=Math.max(0,e.remaining-(Date.now()-e.startedAt)))}_resume(e){if(!(e.closed||e.timer!==null||e.hovered||e.focused)){if(e.remaining<=0){this._close(e);return}this._schedule(e)}}_close(e){if(e.closed)return;if(e.closed=!0,Zs(e),bh(e),!this._queue.isActive(e)){this._queue.remove(e),e.node.remove(),this._entries.delete(e),this._releaseIfEmpty();return}if(e.node.dataset.state="closing",!vh()){this._finish(e);return}let t=s=>{s.target===e.node&&this._finish(e)};this.listen(e.node,"animationend",t,{once:!0}),e.exitTimer=setTimeout(()=>this._finish(e),260)}_finish(e){this._entries.has(e)&&(Zs(e),e.node.remove(),this._entries.delete(e),this._queue.remove(e),this._releaseIfEmpty())}_releaseIfEmpty(){!this._floatingHost||this._entries.size>0||i.#i(this)}_rehome(){let e=this._floatingHost;if(!e)return;let t=We.topmostModal()??e;if(this.el.parentElement===t&&this._placedIn===t)return;t.append(this.el),this._placedIn=t;let s=this.el;typeof s.showPopover=="function"&&!s.matches(":popover-open")&&s.showPopover()}_disposeFloating(){let e=this.el;this.destroy(),e.remove()}_message(e,t){let s=this.msg(e);return s===e?t:s}static#e(e){let t=ie(e??null);t.isConnected||(t=ie(null));let s=this.#t(t);if(s&&s.el.isConnected&&s.el.parentElement===s._placedIn)return s._rehome(),s;s?._disposeFloating();let n=c("div",{class:"zx-message-region",popover:"manual",role:"status",ariaLive:"polite"}),r=new i(n);return r._floatingHost=t,r._overlay=We.push({kind:"toast",root:n,owner:r}),r._unfollow=We.subscribe(()=>r._rehome()),r._rehome(),r}static#t(e){for(let t of We.entries())if(t.kind==="toast"&&t.owner instanceof i&&t.owner._floatingHost===e)return t.owner;return null}static#i(e){e._disposeFloating()}};function fh(i){return i==="danger"?"error":["success","warning","error"].includes(String(i))?i:"info"}function ph(i){let e=Number(i);return Number.isFinite(e)?Math.max(0,e):4e3}function mh(i,e=!1){let t=ph(i);return e&&t>0?Math.max(t,hh):t}function _h(i){if(!i||typeof i!="object")return null;let e=i,t=e.label==null?"":String(e.label).trim();if(!t)return null;let s=["primary","danger","ghost"].includes(String(e.kind))?e.kind:"default";return{label:t,kind:s,onclick:typeof e.onclick=="function"?e.onclick:null}}function gh(i){if(St(i))return i;if(i&&typeof i=="object"&&typeof i.toElement=="function"){let e=i.toElement();return St(e)?e:null}return null}function bh(i){let t=i.node.getRootNode?.()?.activeElement??globalThis.document?.activeElement;if(!t||!i.node.contains(t))return;let s=i.returnFocus;i.returnFocus=null,s?.isConnected&&typeof s.focus=="function"&&s.focus({preventScroll:!0})}function yh(i){let e=Number(i);return Number.isInteger(e)&&e>0?e:5}function St(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function wh(i){let e=Number(i);return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function Ti(i,e){i.content.firstChild.textContent=e.text,i.progressBar?.setAttribute("aria-valuenow",String(e.pct)),i.progressBar?.setAttribute("aria-label",e.text),i.progressFill&&(i.progressFill.style.inlineSize=`${e.pct}%`)}function Zs(i){i.timer!==null&&clearTimeout(i.timer),i.exitTimer!==null&&clearTimeout(i.exitTimer),i.timer=null,i.exitTimer=null}function vh(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function xh(i){return{attributes:Array.from(i.attributes,e=>[e.name,e.value]),children:Array.from(i.childNodes)}}function Sh(i,e){for(let t of Array.from(i.attributes))i.removeAttribute(t.name);for(let[t,s]of e.attributes)i.setAttribute(t,s);i.replaceChildren(...e.children)}var Ni=Object.freeze(["agenda","day","week","month","year"]),Ah=864e5;function Xs(i,e,t={}){let s=Fe(e,"Calendar date"),n=wa(t.weekStart??1),r,o;if(i==="agenda")r=L(s),o=M(r,Fi(t.agendaDays??14,"agendaDays"));else if(i==="day")r=L(s),o=M(r,1);else if(i==="week")r=Mi(s,n),o=M(r,7);else if(i==="month"){let a=new Date(s.getFullYear(),s.getMonth(),1),l=new Date(s.getFullYear(),s.getMonth()+1,0);r=Mi(a,n),o=M(Mi(l,n),7)}else if(i==="year")r=new Date(s.getFullYear(),0,1),o=new Date(s.getFullYear()+1,0,1);else throw new RangeError(`Unknown calendar view: ${i}`);return{start:r,end:o}}function Js(i,e,t,s={}){let n=Fe(e,"Calendar date"),r=_e(t,"direction");if(i==="day")n.setDate(n.getDate()+r);else if(i==="agenda")n.setDate(n.getDate()+r*Fi(s.agendaDays??14,"agendaDays"));else if(i==="week")n.setDate(n.getDate()+r*7);else{if(i==="month")return Qs(n,r);if(i==="year")return Qs(n,r*12);throw new RangeError(`Unknown calendar view: ${i}`)}return n}function Qs(i,e){let t=Fe(i,"Calendar date"),s=t.getDate();return t.setDate(1),t.setMonth(t.getMonth()+_e(e,"month amount")),t.setDate(Math.min(s,kh(t.getFullYear(),t.getMonth()))),t}function kh(i,e){return new Date(i,e+1,0).getDate()}function tt(i,e={}){if(!Array.isArray(i))throw new TypeError("Calendar events must be an array");let t={id:e.eventId??"id",title:e.eventTitle??"title",start:e.eventStart??"start",end:e.eventEnd??"end",allDay:e.eventAllDay??"allDay",color:e.eventColor??"color",location:e.eventLocation??"location",editable:e.eventEditable??"editable",durationEditable:e.eventDurationEditable??"durationEditable"},s=e.dateUnit==="seconds"?"seconds":"milliseconds",n=new Set;return i.map((r,o)=>{if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError(`Calendar event at index ${o} must be an object`);let a=me(r,t.id);if(a==null||a==="")throw new TypeError(`Calendar event at index ${o} requires an id`);let l=String(a);if(n.has(l))throw new RangeError(`Duplicate Calendar event id: ${l}`);n.add(l);let u=ma(me(r,t.start),s,`event ${l} start`),d=me(r,t.end),h=d==null||d===""?new Date(u.getTime()):ma(d,s,`event ${l} end`);if(h<u)throw new RangeError(`Calendar event ${l} ends before it starts`);let p=String(me(r,t.title)??"").trim()||"Untitled event",f=String(me(r,t.location)??"").trim(),_=_a(me(r,t.editable)),m=_a(me(r,t.durationEditable));return{id:a,title:p,start:u,end:h,allDay:!!me(r,t.allDay),color:Ch(me(r,t.color)),location:f,editable:_,durationEditable:m,data:r}})}function P(i){return{...i,start:new Date(i.start.getTime()),end:new Date(i.end.getTime())}}function en(i,e,t={}){let s=ya(t.minMinutes??0,"minMinutes"),n=ya(t.maxMinutes??1440,"maxMinutes",!0),r=Fi(t.minimumMinutes??30,"minimumMinutes");if(n<=s)throw new RangeError("Calendar maxMinutes must exceed minMinutes");let o=L(e),a=ga(o,s),l=ga(o,n),u=i.filter(f=>!le(f)&&tn(f,a,l)).map(f=>{let _=new Date(Math.max(f.start.getTime(),a.getTime())),m=new Date(Math.min(f.end.getTime(),l.getTime()));return m<=_&&(m=new Date(Math.min(l.getTime(),_.getTime()+r*6e4))),{event:f,start:_,end:m,startMinutes:ba(o,_),endMinutes:ba(o,m),column:0,columns:1}}).sort((f,_)=>f.start-_.start||_.end-f.end||String(f.event.id).localeCompare(String(_.event.id))),d=[],h=-1/0,p=()=>{if(!d.length)return;let f=[],_=1;for(let m of d){let g=f.findIndex(b=>b<=m.start.getTime());g===-1&&(g=f.length),f[g]=m.end.getTime(),m.column=g,_=Math.max(_,g+1)}for(let m of d)m.columns=_;d=[],h=-1/0};for(let f of u)d.length&&f.start.getTime()>=h&&p(),d.push(f),h=Math.max(h,f.end.getTime());return p(),u}function Oi(i,e,t){let s=L(e),n=M(s,Fi(t,"days")),r=i.filter(a=>le(a)&&tn(a,s,n)).map(a=>{let l=L(a.start),u=zh(a);return{event:a,start:Math.max(0,Q(s,l)),end:Math.min(t,Q(s,u)),lane:0}}).filter(a=>a.end>a.start).sort((a,l)=>a.start-l.start||l.end-a.end||String(a.event.id).localeCompare(String(l.event.id))),o=[];for(let a of r){let l=o.findIndex(u=>u<=a.start);l===-1&&(l=o.length),a.lane=l,o[l]=a.end}return r}function At(i,e={}){let t=_e(e.days??0,"days"),s=_e(e.minutes??0,"minutes"),n=_e(e.endDays??t,"endDays"),r=_e(e.endMinutes??s,"endMinutes"),o=P(i);if(o.start=pa(o.start,t,s),o.end=pa(o.end,n,r),o.end<o.start)throw new RangeError("Calendar event proposal ends before it starts");return o}function L(i){let e=Fe(i,"Calendar date");return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function M(i,e){let t=Fe(i,"Calendar date"),s=new Date(t.getTime());return s.setDate(s.getDate()+_e(e,"day amount")),s}function Mi(i,e=1){let t=L(i),s=wa(e);return M(t,-((t.getDay()-s+7)%7))}function Q(i,e){let t=L(i),s=L(e),n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),r=Date.UTC(s.getFullYear(),s.getMonth(),s.getDate());return Math.round((r-n)/Ah)}function B(i){let e=Fe(i,"Calendar date"),t=s=>String(s).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function le(i){if(i.allDay)return!0;if(i.end<=i.start)return!1;let e=new Date(i.end.getTime()-1);return B(i.start)!==B(e)}function kt(i,e,t){return tn(i,e,t)}function pa(i,e,t){let s=new Date(i.getTime());return s.setDate(s.getDate()+e),s.setMinutes(s.getMinutes()+t),s}function zh(i){if(i.end<=i.start)return M(L(i.start),1);let e=L(i.end);return i.end.getTime()===e.getTime()?e:M(e,1)}function tn(i,e,t){let s=i.end>i.start?i.end:new Date(i.start.getTime()+1);return i.start<t&&s>e}function me(i,e){return typeof e=="function"?e(i):i[e]}function ma(i,e,t){let s;if(i instanceof Date)s=new Date(i.getTime());else if(typeof i=="number"||typeof i=="string"&&/^-?\d+(?:\.\d+)?$/.test(i.trim())){let n=Number(i);s=new Date(n*(e==="seconds"?1e3:1))}else s=new Date(i);return Fe(s,t)}function _a(i){return i==null?null:!!i}function Ch(i){let e=String(i??"").trim();return!e||e.length>100||/[;{}]|url\s*\(|image\s*\(/i.test(e)?null:/^#[\da-f]{3,8}$/i.test(e)||/^(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color)\([^{};]+\)$/i.test(e)||/^var\(--[\w-]+\)$/i.test(e)||/^[a-z]+$/i.test(e)?e:null}function ga(i,e){let t=L(i);return t.setMinutes(e),t}function ba(i,e){return(e.getTime()-i.getTime())/6e4}function Fe(i,e){if(!(i instanceof Date)||Number.isNaN(i.getTime()))throw new TypeError(`${e} must be a valid Date`);return new Date(i.getTime())}function wa(i){let e=Number(i);if(!Number.isInteger(e)||e<0||e>6)throw new RangeError("weekStart must be from 0 through 6");return e}function _e(i,e){let t=Number(i);if(!Number.isInteger(t))throw new TypeError(`${e} must be an integer`);return t}function Fi(i,e){let t=_e(i,e);if(t<=0)throw new RangeError(`${e} must be greater than zero`);return t}function ya(i,e,t=!1){let s=_e(i,e),n=t?1440:1439;if(s<0||s>n)throw new RangeError(`${e} must be from 0 through ${n}`);return s}var Ct=class extends S{static cssName="calendar";static defaults={events:[],date:null,view:"month",views:[...Ni],weekStart:1,weekNumbers:!0,workweek:!1,agendaDays:14,slotDuration:30,slotMinTime:0,slotMaxTime:1440,scrollTime:480,eventLimit:3,selectable:!1,editable:!1,eventStartEditable:null,eventDurationEditable:null,optimistic:!0,nowIndicator:!0,now:null,disabled:!1,eventId:"id",eventTitle:"title",eventStart:"start",eventEnd:"end",eventAllDay:"allDay",eventColor:"color",eventLocation:"location",eventEditable:"editable",eventDurationEditable:"durationEditable",dateUnit:"milliseconds"};render(){let e=!this.el,t=this.el??c("section");this.el||(this.el=t),this._createdRoot=e,this._original=this._createdRoot?null:{attributes:Array.from(t.attributes).map(({name:h,value:p})=>[h,p]),children:Array.from(t.childNodes)},this._views=Dh(this.options.views),this._view=this._views.includes(this.options.view)?this.options.view:this._views[0],this._date=va(this.options.date,this.options.dateUnit,this._now()),this._events=tt(this.options.events,this._normalizeOptions()),this._loading=!1,this._destroyed=!1,this._pointer=null,this._keyboardEdit=null,this._mutationVersions=new Map,this._mutationSerial=0,this._suppressClickId=null,this._suppressDateClick=!1,this._focusedSlot=null,this._selection=null,this._nowTimer=null;let s=c("div",{class:"zx-calendar__navigation"},this._toolbarButton("previous",this.msg("calendar.previous"),"chevron-left"),this._toolbarButton("today",this.msg("calendar.today")),this._toolbarButton("next",this.msg("calendar.next"),"chevron-right")),n=c("h2",{ref:"heading",class:"zx-calendar__heading",ariaLive:"polite"}),r=c("div",{ref:"views",class:"zx-calendar__views",role:"group",ariaLabel:this._message("calendar.viewSwitch","Calendar view")},this._views.map(h=>c("button",{type:"button",class:"zx-calendar__view-button",dataset:{calendarAction:"view",view:h},disabled:this.options.disabled},this.msg(`calendar.${h}`)))),o=c("div",{class:"zx-calendar__commands"},r,c("button",{type:"button",class:"zx-calendar__new",dataset:{calendarAction:"new"},disabled:this.options.disabled},v("plus"),c("span",{},this.msg("calendar.new")))),a=c("header",{class:"zx-calendar__toolbar"},s,n,o),l=c("div",{ref:"body",class:"zx-calendar__body"}),u=c("div",{ref:"loading",class:"zx-calendar__loading",role:"status",hidden:!0},this.msg("calendar.loading")),d=c("div",{ref:"status",class:"zx-calendar__status",role:"status",ariaLive:"polite",ariaAtomic:"true"});return t.replaceChildren(a,l,u,d),t.setAttribute("aria-label",this.msg("calendar.label")),t.dataset.view=this._view,t.dataset.state="ready",this.listen(t,"click",h=>this._onClick(h)),this.listen(t,"dblclick",h=>this._onDoubleClick(h)),this.listen(t,"keydown",h=>this._onKeydown(h)),this.listen(t,"pointerdown",h=>this._onPointerDown(h)),this.listen(t,"pointermove",h=>this._onPointerMove(h)),this.listen(t,"pointerup",h=>this._onPointerUp(h)),this.listen(t,"pointercancel",h=>this._cancelPointer(h)),this.listen(t,"dragstart",h=>h.preventDefault()),this._renderView({emitDates:!0,scroll:!0}),this.options.nowIndicator&&(this._nowTimer=setInterval(()=>this._refreshNowIndicator(),6e4)),t}getEvents(){return this._events.map(P)}setEvents(e,t={}){let s=tt(e,this._normalizeOptions());return this._events=s,this._mutationVersions.clear(),this._renderView({preserveFocus:!0}),t.silent||this.emit("eventschange",{events:this.getEvents()}),this}addEvent(e,t={}){let[s]=tt([e],this._normalizeOptions());if(this._eventById(s.id))throw new RangeError(`Duplicate Calendar event id: ${s.id}`);return this._events=[...this._events,s],this._renderView({preserveFocus:!0}),t.silent||this.emit("eventschange",{events:this.getEvents()}),this}updateEvent(e,t,s={}){let n=this._eventIndex(e);if(n<0)throw new RangeError(`Unknown Calendar event id: ${e}`);let r=this._events[n],o={id:r.id,title:t.title??r.title,start:t.start??r.start,end:t.end??r.end,allDay:t.allDay??r.allDay,color:Object.prototype.hasOwnProperty.call(t,"color")?t.color:r.color,location:t.location??r.location,editable:Object.prototype.hasOwnProperty.call(t,"editable")?t.editable:r.editable,durationEditable:Object.prototype.hasOwnProperty.call(t,"durationEditable")?t.durationEditable:r.durationEditable,data:t.data??r.data},[a]=tt([o],{dateUnit:this.options.dateUnit});return a.data=o.data,this._events=this._events.map((l,u)=>u===n?a:l),this._mutationVersions.delete(String(e)),this._renderView({preserveFocus:!0}),s.silent||this.emit("eventschange",{events:this.getEvents()}),this}removeEvent(e,t={}){let s=String(e),n=this._events.filter(r=>String(r.id)!==s);return n.length===this._events.length?this:(this._events=n,this._mutationVersions.delete(s),this._renderView({preserveFocus:!0}),t.silent||this.emit("eventschange",{events:this.getEvents()}),this)}getDate(){return new Date(this._date.getTime())}setDate(e,t={}){return this._date=va(e,this.options.dateUnit,this._now()),this._renderView({emitDates:!t.silent,preserveFocus:!0,scroll:!0}),this}getView(){return this._view}setView(e,t={}){if(!this._views.includes(e))throw new RangeError(`Calendar view is not enabled: ${e}`);if(e===this._view)return this;let s=this._view;return this._view=e,this.el.dataset.view=e,this._renderView({emitDates:!0,preserveFocus:!0,scroll:!0}),t.silent||this.emit("viewchange",{view:e,oldView:s}),this}prev(){return this._page(-1)}next(){return this._page(1)}today(){return this.setDate(this._now())}setLoading(e=!0){return this._loading=!!e,this.el.dataset.state=this._loading?"loading":"ready",this.el.setAttribute("aria-busy",String(this._loading)),this.refs.loading.hidden=!this._loading,this}focusEvent(e){return this.el.querySelector(`[data-event-action][data-event-id="${Ri(String(e))}"]`)?.focus(),this}destroy(){if(this._destroyed)return;this._destroyed=!0,this._nowTimer&&clearInterval(this._nowTimer),this._nowTimer=null;let e=this._original;if(super.destroy(),!this._createdRoot&&e){for(let t of Array.from(this.el.attributes))this.el.removeAttribute(t.name);for(let[t,s]of e.attributes)this.el.setAttribute(t,s);this.el.replaceChildren(...e.children)}}_toolbarButton(e,t,s=null){return c("button",{type:"button",class:"zx-calendar__toolbar-button",dataset:{calendarAction:e},ariaLabel:s?t:null,disabled:this.options.disabled},s?v(s):t)}_normalizeOptions(){return{eventId:this.options.eventId,eventTitle:this.options.eventTitle,eventStart:this.options.eventStart,eventEnd:this.options.eventEnd,eventAllDay:this.options.eventAllDay,eventColor:this.options.eventColor,eventLocation:this.options.eventLocation,eventEditable:this.options.eventEditable,eventDurationEditable:this.options.eventDurationEditable,dateUnit:this.options.dateUnit}}_renderView(e={}){if(!this.refs?.body||this._destroyed)return;let t=e.preserveFocus?this._focusIdentity():null,s=Xs(this._view,this._date,{weekStart:this.options.weekStart,agendaDays:this.options.agendaDays});this._range=s,this.refs.heading.textContent=this._rangeTitle(s);for(let r of this.refs.views.querySelectorAll("[data-view]"))r.setAttribute("aria-pressed",String(r.dataset.view===this._view));let n=this._view==="agenda"?this._renderAgenda(s):this._view==="day"||this._view==="week"?this._renderTimeGrid(s):this._view==="month"?this._renderMonth(s):this._renderYear(s);this.refs.body.replaceChildren(n),e.scroll&&this._scrollTimeGrid(),t&&this._restoreFocus(t),e.emitDates&&this.emit("dateschange",{view:this._view,start:new Date(s.start.getTime()),end:new Date(s.end.getTime())})}_renderAgenda(e){let t=c("div",{class:"zx-calendar__agenda",role:"grid",ariaLabel:this._rangeTitle(e)}),s=Q(e.start,e.end);for(let n=0;n<s;n+=1){let r=M(e.start,n),o=M(r,1),a=this._events.filter(d=>kt(d,r,o)?d.start>=r||n===0:!1).sort(Th),l=c("section",{class:"zx-calendar__agenda-day",role:"row",dataset:{date:B(r)}},c("button",{type:"button",class:"zx-calendar__agenda-heading",role:"rowheader",dataset:{calendarAction:"date",date:B(r),dateCell:"true"},ariaCurrent:Le(r,this._now())?"date":null,disabled:this.options.disabled},this._format(r,{weekday:"long",day:"numeric",month:"long"}))),u=c("div",{class:"zx-calendar__agenda-events",role:"gridcell"});if(!a.length)u.append(c("p",{class:"zx-calendar__agenda-empty"},this.msg("calendar.noEvents")));else for(let d of a)u.append(this._eventElement(d,{variant:"agenda",day:r}));l.append(u),t.append(l)}return t}_renderTimeGrid(e){let t=Array.from({length:Q(e.start,e.end)},(b,y)=>M(e.start,y)),s=this._view==="week"&&this.options.workweek?t.filter(b=>b.getDay()>0&&b.getDay()<6):t,n=ge(this.options.slotMinTime,0),r=ge(this.options.slotMaxTime,1440,!0),o=se(this.options.slotDuration);if(r<=n)throw new RangeError("slotMaxTime must exceed slotMinTime");let a=Math.ceil((r-n)/o),l=c("div",{class:"zx-calendar__time-surface",style:{"--zx-calendar-day-count":String(s.length)}}),u=c("div",{class:"zx-calendar__time-header"},c("span",{class:"zx-calendar__time-corner",ariaHidden:"true"}),c("div",{class:"zx-calendar__day-headings",role:"row"},s.map(b=>c("button",{type:"button",class:"zx-calendar__day-heading",role:"columnheader",dataset:{calendarAction:"date",date:B(b),dateCell:"true"},ariaCurrent:Le(b,this._now())?"date":null,disabled:this.options.disabled},c("span",{class:"zx-calendar__day-weekday"},this._format(b,{weekday:"short"})),c("span",{class:"zx-calendar__day-number"},this._format(b,{day:"numeric",month:"short"})))))),d=this._renderAllDayRail(s),h=c("div",{ref:"timeScroller",class:"zx-calendar__time-scroller"}),p=c("div",{class:"zx-calendar__time-axis",ariaHidden:"true"}),f=c("div",{class:"zx-calendar__time-grid",role:"grid",ariaLabel:this._rangeTitle(e),ariaRowcount:String(a),ariaColcount:String(s.length),style:{"--zx-calendar-slot-count":String(a)}}),_=c("div",{ref:"slots",class:"zx-calendar__slots"}),m=!0;for(let b=0;b<a;b+=1){let y=n+b*o;p.append(c("span",{class:"zx-calendar__time-label"},y%60===0?sn(y,this.options.locale):""));for(let A=0;A<s.length;A+=1){let w=Ih(s[A],y),x=String(w.getTime()),C=this._focusedSlot?this._focusedSlot===x:m;C&&(m=!1),_.append(c("button",{type:"button",class:"zx-calendar__slot",role:"gridcell",tabindex:C?0:-1,dataset:{calendarAction:"date",slot:x,dateTime:x,dayIndex:String(A),rowIndex:String(b),major:y%60===0?"true":null},ariaLabel:this._dateTimeLabel(w),disabled:this.options.disabled}))}}let g=c("div",{class:"zx-calendar__timed-events",ariaHidden:"false"});return s.forEach((b,y)=>{let A=en(this._events,b,{minMinutes:n,maxMinutes:r,minimumMinutes:o});for(let w of A){let x=(w.startMinutes-n)/(r-n)*100,C=Math.max(o/(r-n)*100,(w.endMinutes-w.startMinutes)/(r-n)*100),$=100/s.length,W=$/w.columns,re=y*$+w.column*W,k=this._eventElement(w.event,{variant:"timed",day:b,resizable:!0});k.style.insetInlineStart=`${re}%`,k.style.inlineSize=`${W}%`,k.style.insetBlockStart=`${x}%`,k.style.blockSize=`${C}%`,g.append(k)}}),f.append(_,g,this._nowLine(s,n,r)),h.append(p,f),l.append(u,d,h),l}_renderAllDayRail(e){let t=c("div",{class:"zx-calendar__all-day"},c("span",{class:"zx-calendar__all-day-label"},this.msg("calendar.allDay"))),s=c("div",{class:"zx-calendar__all-day-grid",role:"row",style:{"--zx-calendar-day-count":String(e.length)}});for(let r of e)s.append(c("span",{class:"zx-calendar__all-day-cell",dataset:{date:B(r)},ariaHidden:"true"}));let n=Oi(this._events,e[0],e.length);for(let r of n){let o=this._eventElement(r.event,{variant:"span",day:e[r.start]});o.style.gridColumn=`${r.start+1} / ${r.end+1}`,o.style.gridRow=String(r.lane+1),s.append(o)}return t.append(s),t}_renderMonth(e){let t=c("div",{class:"zx-calendar__month"}),s=c("div",{class:"zx-calendar__month-weekdays",role:"row"});this.options.weekNumbers&&s.append(c("span",{class:"zx-calendar__month-week-gutter",ariaHidden:"true"}));for(let r=0;r<7;r+=1){let o=M(e.start,r);s.append(c("span",{class:"zx-calendar__month-weekday",role:"columnheader"},this._format(o,{weekday:"short"})))}t.append(s);let n=Q(e.start,e.end)/7;for(let r=0;r<n;r+=1){let o=M(e.start,r*7),a=Oi(this._events.map(m=>({...m,allDay:!0})),o,7),l=Eh(this.options.eventLimit),u=a.filter(m=>m.lane<l),d=a.filter(m=>m.lane>=l),h=c("div",{class:"zx-calendar__month-week",role:"row",dataset:{weekStart:B(o)}});this.options.weekNumbers&&h.append(c("button",{type:"button",class:"zx-calendar__month-week-number",dataset:{calendarAction:"week",date:B(o)},ariaLabel:this.msg("calendar.weekNumber",Sa(o)),disabled:this.options.disabled},String(Sa(o))));let p=c("div",{class:"zx-calendar__month-days"});for(let m=0;m<7;m+=1){let g=M(o,m),b=this._events.filter(y=>kt(y,g,M(g,1))).length;p.append(c("button",{type:"button",class:"zx-calendar__month-day",role:"gridcell",dataset:{calendarAction:"date",date:B(g),dateCell:"true",otherMonth:g.getMonth()===this._date.getMonth()?null:"true",eventCount:String(b)},ariaCurrent:Le(g,this._now())?"date":null,ariaLabel:this._dayCountLabel(g,b),disabled:this.options.disabled},this._format(g,{day:"numeric"})))}let f=c("div",{class:"zx-calendar__month-events"});for(let m of u){let g=this._eventElement(m.event,{variant:"month",day:M(o,m.start)});g.style.gridColumn=`${m.start+1} / ${m.end+1}`,g.style.gridRow=String(m.lane+1),f.append(g)}let _=Array.from({length:7},(m,g)=>d.filter(b=>b.start<=g&&b.end>g).length);for(let m=0;m<_.length;m+=1){let g=_[m];if(!g)continue;let b=M(o,m);f.append(c("button",{type:"button",class:"zx-calendar__more",dataset:{calendarAction:"more",date:B(b),count:String(g)},style:{gridColumn:String(m+1),gridRow:String(l+1)},disabled:this.options.disabled},this.msg("calendar.more",g)))}h.append(p,f),t.append(h)}return t.setAttribute("role","grid"),t.setAttribute("aria-label",this._rangeTitle(e)),t}_renderYear(e){let t=e.start.getFullYear(),s=c("div",{class:"zx-calendar__year",ariaLabel:String(t)});for(let n=0;n<12;n+=1){let r=new Date(t,n,1),o=(r.getDay()-this.options.weekStart+7)%7,a=M(r,-o),l=c("div",{class:"zx-calendar__year-grid",role:"grid",ariaLabel:this._format(r,{month:"long"})},c("h3",{class:"zx-calendar__year-heading"},this._format(r,{month:"long"})));for(let u=0;u<7;u+=1){let d=M(a,u);l.append(c("span",{class:"zx-calendar__year-weekday",role:"columnheader"},this._format(d,{weekday:"narrow"})))}for(let u=0;u<42;u+=1){let d=M(a,u);if(d.getMonth()!==n){l.append(c("span",{class:"zx-calendar__year-blank",role:"gridcell",ariaHidden:"true"}));continue}let h=this._events.filter(p=>kt(p,d,M(d,1))).length;l.append(c("button",{type:"button",class:"zx-calendar__year-day",role:"gridcell",dataset:{calendarAction:"date",date:B(d),dateCell:"true",activity:String(Math.min(3,h))},ariaCurrent:Le(d,this._now())?"date":null,ariaLabel:this._dayCountLabel(d,h),disabled:this.options.disabled},String(d.getDate())))}s.append(l)}return s}_eventElement(e,t){let s=String(e.id),n=c("div",{class:"zx-calendar__event",dataset:{eventId:s,variant:t.variant,allDay:e.allDay?"true":null,draggable:this._canMove(e)?"true":null},style:e.color?{"--zx-calendar-event-color":e.color}:null}),r=c("button",{type:"button",class:"zx-calendar__event-action",dataset:{eventAction:"activate",eventId:s},ariaLabel:this._eventLabel(e),disabled:this.options.disabled}),o=typeof this.options.renderEvent=="function"?this.options.renderEvent(P(e)):null;if(o instanceof Node)r.append(o);else if(typeof o=="string")r.append(document.createTextNode(o));else{let a=c("span",{class:"zx-calendar__event-time"},this._eventTime(e,t.day)),l=c("span",{class:"zx-calendar__event-title"},e.title);r.append(a,l),e.location&&r.append(c("span",{class:"zx-calendar__event-location"},e.location))}return n.append(r),t.resizable&&this._canResize(e)&&n.append(c("button",{type:"button",class:"zx-calendar__event-resize",dataset:{eventAction:"resize",eventId:s},ariaLabel:this.msg("calendar.resize",e.title),disabled:this.options.disabled},c("span",{ariaHidden:"true"}))),n}_nowLine(e,t,s){let n=this._now(),r=e.findIndex(l=>Le(l,n)),o=n.getHours()*60+n.getMinutes(),a=this.options.nowIndicator&&r>=0&&o>=t&&o<=s;return c("div",{ref:"nowLine",class:"zx-calendar__now",hidden:!a,ariaHidden:"true",style:a?{insetBlockStart:`${(o-t)/(s-t)*100}%`,"--zx-calendar-now-day":String(r)}:null},c("span",{class:"zx-calendar__now-time"},sn(o,this.options.locale)))}_onClick(e){let t=e.target?.closest?.("button");if(!t||!this.el.contains(t))return;let s=t.dataset.eventId;if(s!=null&&this._suppressClickId===s){this._suppressClickId=null,e.preventDefault();return}if(t.dataset.eventAction==="activate"){let r=this._eventById(s);r&&this.emit("eventclick",{event:P(r),jsEvent:e});return}if(t.dataset.eventAction==="resize")return;let n=t.dataset.calendarAction;if(n){if(n==="previous")this.prev();else if(n==="next")this.next();else if(n==="today")this.today();else if(n==="view")this.setView(t.dataset.view);else if(n==="new")this.emit("new",{date:this.getDate(),view:this._view,jsEvent:e});else if(n==="week"){let r=ze(t.dataset.date);r&&this.setDate(r).setView("week")}else if(n==="more"){let r=ze(t.dataset.date);if(!r)return;!this.emit("moreclick",{date:r,count:Number(t.dataset.count),jsEvent:e}).defaultPrevented&&this._views.includes("agenda")&&this.setDate(r).setView("agenda")}else if(n==="date"){if(this._suppressDateClick){this._suppressDateClick=!1,e.preventDefault();return}let r=this._dateFromTarget(t);if(!r)return;this._rememberFocusedDate(t),this.emit("dateclick",{date:r,allDay:!t.dataset.dateTime,view:this._view,jsEvent:e})}}}_onDoubleClick(e){let t=e.target?.closest?.('[data-event-action="activate"]');if(t){let a=this._eventById(t.dataset.eventId);a&&this.emit("eventdblclick",{event:P(a),jsEvent:e});return}let s=e.target?.closest?.('[data-calendar-action="date"]');if(!s)return;let n=this._dateFromTarget(s);if(!n)return;let r=!s.dataset.dateTime,o=r?M(n,1):Re(n,se(this.options.slotDuration));this.emit("select",{start:n,end:o,allDay:r,view:this._view,jsEvent:e})}_onKeydown(e){let t=e.target?.closest?.("[data-event-action]");if(t){this._onEventKeydown(e,t);return}let s=e.target?.closest?.("[data-slot]");if(s){this._onSlotKeydown(e,s);return}let n=e.target?.closest?.("[data-date-cell]");n&&this._onDayKeydown(e,n)}_onEventKeydown(e,t){let s=this._eventById(t.dataset.eventId);if(!s)return;let n=t.dataset.eventAction==="resize";if(e.key==="Enter"&&!this._keyboardEdit&&!n){e.preventDefault(),this.emit("eventclick",{event:P(s),jsEvent:e});return}if(e.key===" "&&!this._keyboardEdit){if(n?!this._canResize(s):!this._canMove(s))return;e.preventDefault(),this._keyboardEdit={oldEvent:P(s),event:P(s),action:n?"resize":"move",control:t},t.setAttribute("aria-grabbed","true"),t.closest(".zx-calendar__event")?.setAttribute("data-state","grabbed"),this._announce(this.msg(n?"calendar.resizeStarted":"calendar.moveStarted",s.title));return}if(!this._keyboardEdit||String(this._keyboardEdit.event.id)!==String(s.id))return;if(e.key==="Escape"){e.preventDefault(),this._cancelKeyboardEdit();return}if(e.key===" "){e.preventDefault();let u=this._keyboardEdit;this._keyboardEdit=null,u.control.removeAttribute("aria-grabbed"),this._commitMutation(u.oldEvent,u.event,u.action,e);return}let r=0,o=0,a=!le(s)&&(this._view==="day"||this._view==="week");if(e.key==="ArrowLeft")r=-1;else if(e.key==="ArrowRight")r=1;else if(e.key==="ArrowUp")a?o=-se(this.options.slotDuration):r=-7;else if(e.key==="ArrowDown")a?o=se(this.options.slotDuration):r=7;else return;e.preventDefault();let l=this._keyboardEdit;if(l.action==="move")l.event=At(l.event,{days:r,minutes:o});else{let u=At(l.event,{days:0,minutes:0,endDays:r,endMinutes:o});u.end>u.start&&(l.event=u)}l.control.closest(".zx-calendar__event")?.setAttribute("data-preview",this._eventTime(l.event,l.event.start)),this._announce(this.msg("calendar.editPreview",l.event.title,this._dateTimeLabel(l.event.start),this._dateTimeLabel(l.event.end)))}_onSlotKeydown(e,t){let s=Number(t.dataset.rowIndex),n=Number(t.dataset.dayIndex),r=t.closest('[role="grid"]'),o=Number(r?.getAttribute("aria-colcount"))||1,a=Number(r?.getAttribute("aria-rowcount"))||1,l=s,u=n;if(e.key==="ArrowLeft")u-=1;else if(e.key==="ArrowRight")u+=1;else if(e.key==="ArrowUp")l-=1;else if(e.key==="ArrowDown")l+=1;else if(e.key==="Home")u=0;else if(e.key==="End")u=o-1;else if(e.key==="PageUp"){e.preventDefault(),this.prev();return}else if(e.key==="PageDown"){e.preventDefault(),this.next();return}else if(e.key==="Enter"||e.key===" "){e.preventDefault();let h=this._dateFromTarget(t);h&&this.emit("dateclick",{date:h,allDay:!1,view:this._view,jsEvent:e});return}else return;e.preventDefault(),l=Math.max(0,Math.min(a-1,l)),u=Math.max(0,Math.min(o-1,u));let d=r?.querySelector(`[data-row-index="${l}"][data-day-index="${u}"]`);d&&(t.tabIndex=-1,d.tabIndex=0,this._focusedSlot=d.dataset.slot,d.focus())}_onDayKeydown(e,t){let s=ze(t.dataset.date);if(!s)return;let n=0;if(e.key==="ArrowLeft")n=-1;else if(e.key==="ArrowRight")n=1;else if(e.key==="ArrowUp")n=-7;else if(e.key==="ArrowDown")n=7;else if(e.key==="Home")n=-((s.getDay()-this.options.weekStart+7)%7);else if(e.key==="End")n=6-(s.getDay()-this.options.weekStart+7)%7;else if(e.key==="PageUp"){e.preventDefault(),this.prev();return}else if(e.key==="PageDown"){e.preventDefault(),this.next();return}else return;e.preventDefault();let r=M(s,n),o=this.el.querySelector(`[data-date-cell][data-date="${B(r)}"]`);o?o.focus():this.setDate(r)}_onPointerDown(e){if(this.options.disabled||e.button!==0)return;let t=e.target?.closest?.("[data-event-action]");if(t){let r=this._eventById(t.dataset.eventId),o=t.dataset.eventAction==="resize"?"resize":"move";if(!r||(o==="move"?!this._canMove(r):!this._canResize(r)))return;e.preventDefault(),this._capturePointer(e.pointerId);let a=o==="move"?this._dragOffsetForEvent(r,e.clientX,e.clientY):null;this._pointer={type:"event",pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,oldEvent:P(r),event:P(r),action:o,control:t,timeOffsetMinutes:a?.minutes??0,dayOffset:a?.days??0,moved:!1};return}let s=e.target?.closest?.("[data-slot]");if(!s||!this.options.selectable)return;let n=this._dateFromTarget(s);n&&(e.preventDefault(),this._capturePointer(e.pointerId),this._pointer={type:"selection",pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,start:n,end:Re(n,se(this.options.slotDuration)),control:s,moved:!1})}_onPointerMove(e){let t=this._pointer;if(!t||t.pointerId!==e.pointerId||!t.moved&&Math.hypot(e.clientX-t.startX,e.clientY-t.startY)<5)return;if(t.moved=!0,e.preventDefault(),t.type==="selection"){let r=this._timeAtPoint(e.clientX,e.clientY);if(!r)return;let o=se(this.options.slotDuration);t.end=Re(r,o),this._previewSelection(t.start,t.end);return}let s=this._proposalAtPoint(t.oldEvent,t.action,e.clientX,e.clientY);if(!s)return;t.event=s;let n=t.control.closest(".zx-calendar__event");if(n){if(n.dataset.state="dragging",t.action==="resize"){n.style.transform="";let r=this._timedPreviewHeight(s);r&&(n.style.blockSize=r)}else n.style.transform=`translate(${e.clientX-t.startX}px, ${e.clientY-t.startY}px)`;n.dataset.preview=this._eventTime(s,s.start)}this._announce(this.msg("calendar.editPreview",s.title,this._dateTimeLabel(s.start),this._dateTimeLabel(s.end)))}_onPointerUp(e){let t=this._pointer;if(!(!t||t.pointerId!==e.pointerId)&&(this._pointer=null,this._releasePointerCapture(t.pointerId),this._clearSelectionPreview(),!!t.moved)){if(e.preventDefault(),t.type==="selection"){this._suppressDateClick=!0;let s=t.start<t.end?t.start:Re(t.end,-se(this.options.slotDuration)),n=t.start<t.end?t.end:Re(t.start,se(this.options.slotDuration));this.emit("select",{start:new Date(s),end:new Date(n),allDay:!1,view:this._view,jsEvent:e});return}this._suppressClickId=String(t.oldEvent.id),this._commitMutation(t.oldEvent,t.event,t.action,e)}}_cancelPointer(e){if(!this._pointer||this._pointer.pointerId!==e.pointerId)return;let t=this._pointer.control;this._releasePointerCapture(this._pointer.pointerId),this._pointer=null,this._clearSelectionPreview(),t.closest?.(".zx-calendar__event")?.removeAttribute("data-state"),this._renderView({preserveFocus:!0})}_proposalAtPoint(e,t,s,n){let r=t==="resize"&&!le(e),o=this._timeAtPoint(s,n,r?e.start:null);if(o&&!le(e)){if(t==="move"){let f=e.end.getTime()-e.start.getTime(),_=P(e);return _.start=Re(o,-Number(this._pointer?.timeOffsetMinutes??0)),_.end=new Date(_.start.getTime()+f),_}let p=P(e);return p.end=Re(o,se(this.options.slotDuration)),p.end>p.start?p:null}let a=this._dayAtPoint(s,n);if(!a)return null;let l=M(a,-Number(this._pointer?.dayOffset??0)),u=Q(L(e.start),l);if(t==="move")return At(e,{days:u,minutes:0});let d=P(e),h=M(a,1);return d.end=new Date(h.getTime()),d.end>d.start?d:null}_timeAtPoint(e,t,s=null){let n=this.refs.body.querySelector(".zx-calendar__slots");if(!n)return null;let r=n.getBoundingClientRect(),a=n.closest(".zx-calendar__time-scroller")?.getBoundingClientRect(),l=a?Math.max(r.left,a.left):r.left,u=a?Math.min(r.right,a.right):r.right,d=a?Math.max(r.top,a.top):r.top,h=a?Math.min(r.bottom,a.bottom):r.bottom;if(e<l||e>u||t<d||t>h||r.width<=0||r.height<=0)return null;let p=Number(n.closest('[role="grid"]')?.getAttribute("aria-colcount"))||1,f=Number(n.closest('[role="grid"]')?.getAttribute("aria-rowcount"))||1,_=s?this._timeGridDayIndex(s):-1,m=_>=0?_:Math.max(0,Math.min(p-1,Math.floor((e-r.left)/r.width*p))),g=Math.max(0,Math.min(f-1,Math.floor((t-r.top)/r.height*f))),b=n.querySelector(`[data-row-index="${g}"][data-day-index="${m}"]`);return b?this._dateFromTarget(b):null}_dayAtPoint(e,t){let s=this.refs.body.querySelector(".zx-calendar__all-day-grid");if(s){let r=s.getBoundingClientRect();if(e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom){let o=s.querySelectorAll("[data-date]"),a=Math.max(0,Math.min(o.length-1,Math.floor((e-r.left)/r.width*o.length)));return ze(o[a]?.dataset.date)}}for(let r of this.refs.body.querySelectorAll(".zx-calendar__month-events")){let o=r.getBoundingClientRect();if(e<o.left||e>o.right||t<o.top||t>o.bottom||o.width<=0)continue;let a=ze(r.closest(".zx-calendar__month-week")?.dataset.weekStart);if(!a)continue;let l=Math.max(0,Math.min(6,Math.floor((e-o.left)/o.width*7)));return M(a,l)}for(let r of this.refs.body.querySelectorAll(".zx-calendar__agenda-day")){let o=r.getBoundingClientRect();if(!(e<o.left||e>o.right||t<o.top||t>o.bottom))return ze(r.dataset.date)}let n=typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[];for(let r of n){let o=r instanceof HTMLElement?r.closest("[data-date]"):null,a=o instanceof HTMLElement?o.dataset.date:null;if(a)return ze(a)}return null}_dragOffsetForEvent(e,t,s){if(!le(e)){let o=this._timeAtPoint(t,s);if(o){let a=se(this.options.slotDuration),l=Math.max(0,Math.round((e.end.getTime()-e.start.getTime())/6e4)),u=Math.max(0,l-a),d=Math.round((o.getTime()-e.start.getTime())/6e4);return{minutes:Math.max(0,Math.min(u,d)),days:0}}}let n=this._dayAtPoint(t,s),r=n?Q(L(e.start),n):0;return{minutes:0,days:Math.max(0,r)}}_timeGridDayIndex(e){let t=B(e);return[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")].findIndex(n=>n.dataset.date===t)}_timedPreviewHeight(e){if(!this.refs.body.querySelector(".zx-calendar__time-grid")||le(e))return null;let s=ge(this.options.slotMinTime,0),n=ge(this.options.slotMaxTime,1440,!0),r=se(this.options.slotDuration),o=e.start.getHours()*60+e.start.getMinutes(),a=e.end.getHours()*60+e.end.getMinutes();return`${Math.max(r,Math.min(n,a)-Math.max(s,o))/(n-s)*100}%`}_capturePointer(e){try{this.el.setPointerCapture?.(e)}catch{}}_releasePointerCapture(e){this.el.hasPointerCapture?.(e)&&this.el.releasePointerCapture?.(e)}_previewSelection(e,t){let s=Math.min(e.getTime(),t.getTime()),n=Math.max(e.getTime(),t.getTime());for(let r of this.refs.body.querySelectorAll("[data-slot]")){let o=Number(r.dataset.dateTime);r.setAttribute("aria-selected",String(o>=s&&o<n))}}_clearSelectionPreview(){for(let e of this.refs.body.querySelectorAll("[data-slot][aria-selected]"))e.removeAttribute("aria-selected")}_cancelKeyboardEdit(){let e=this._keyboardEdit;e&&(e.control.removeAttribute("aria-grabbed"),e.control.closest(".zx-calendar__event")?.removeAttribute("data-state"),this._keyboardEdit=null,this._announce(this.msg("calendar.editCancelled")),this._renderView({preserveFocus:!0}))}_commitMutation(e,t,s,n){if(!(e.start.getTime()!==t.start.getTime()||e.end.getTime()!==t.end.getTime())){this._renderView({preserveFocus:!0});return}let o=String(e.id),a=++this._mutationSerial,l=!1;this.options.optimistic?(this._replaceNormalizedEvent(t),this._mutationVersions.set(o,a),this._renderView({preserveFocus:!0})):this._renderView({preserveFocus:!0});let u=()=>{if(l||!this.options.optimistic||this._mutationVersions.get(o)!==a)return!1;let p=this._eventById(o);return!p||p.start.getTime()!==t.start.getTime()||p.end.getTime()!==t.end.getTime()?!1:(l=!0,this._replaceNormalizedEvent(e),this._mutationVersions.delete(o),this._renderView({preserveFocus:!0}),this._announce(this.msg("calendar.editCancelled")),!0)},d={event:P(t),oldEvent:P(e),action:s,delta:Mh(e,t),jsEvent:n,revert:u};this.emit("eventchange",d).defaultPrevented?u():this._announce(this.msg("calendar.editCommitted",t.title))}_replaceNormalizedEvent(e){let t=String(e.id);this._events=this._events.map(s=>String(s.id)===t?P(e):s)}_canMove(e){return this.options.disabled?!1:e.editable!=null?e.editable:this.options.eventStartEditable!=null?!!this.options.eventStartEditable:!!this.options.editable}_canResize(e){return this.options.disabled?!1:e.durationEditable!=null?e.durationEditable:this.options.eventDurationEditable!=null?!!this.options.eventDurationEditable:!!this.options.editable}_eventById(e){let t=this._eventIndex(e);return t<0?null:this._events[t]}_eventIndex(e){let t=String(e);return this._events.findIndex(s=>String(s.id)===t)}_page(e){return this.setDate(Js(this._view,this._date,e,{agendaDays:this.options.agendaDays}))}_rangeTitle(e){if(this._view==="day")return this._format(e.start,{weekday:"long",day:"numeric",month:"long",year:"numeric"});if(this._view==="month")return this._format(this._date,{month:"long",year:"numeric"});if(this._view==="year")return this._format(this._date,{year:"numeric"});let t=M(e.end,-1),s=new Intl.DateTimeFormat(this.options.locale,{day:"numeric",month:"long",year:"numeric"});return typeof s.formatRange=="function"?s.formatRange(e.start,t):e.start.getFullYear()!==t.getFullYear()?`${this._format(e.start,{day:"numeric",month:"short",year:"numeric"})} \u2013 ${this._format(t,{day:"numeric",month:"short",year:"numeric"})}`:e.start.getMonth()!==t.getMonth()?`${this._format(e.start,{day:"numeric",month:"short"})} \u2013 ${this._format(t,{day:"numeric",month:"short",year:"numeric"})}`:`${this._format(e.start,{day:"numeric"})}\u2013${this._format(t,{day:"numeric",month:"long",year:"numeric"})}`}_eventTime(e,t){if(e.allDay)return this.msg("calendar.allDay");if(le(e))return Le(e.start,t)?`${zt(e.start,this.options.locale)} \u2192`:Le(e.end,t)?`\u2192 ${zt(e.end,this.options.locale)}`:this.msg("calendar.allDay");let s=nn(e.start,this.options.locale);return e.end<=e.start?s:`${s}\u2013${nn(e.end,this.options.locale)}`}_eventLabel(e){let t=e.location?`, ${e.location}`:"";return`${e.title}, ${zt(e.start,this.options.locale)} to ${zt(e.end,this.options.locale)}${t}`}_dateTimeLabel(e){return zt(e,this.options.locale)}_format(e,t){return new Intl.DateTimeFormat(this.options.locale,t).format(e)}_now(){let e=typeof this.options.now=="function"?this.options.now():this.options.now,t=e??new Date;if(!(t instanceof Date)||Number.isNaN(t.getTime()))throw new TypeError("Calendar now must return a valid Date");return new Date(t.getTime())}_dateFromTarget(e){if(e.dataset.dateTime){let t=new Date(Number(e.dataset.dateTime));return Number.isNaN(t.getTime())?null:t}return ze(e.dataset.date)}_rememberFocusedDate(e){e.dataset.slot&&(this._focusedSlot=e.dataset.slot)}_focusIdentity(){let e=document.activeElement;return!(e instanceof HTMLElement)||!this.el.contains(e)?null:{eventId:e.dataset.eventId,eventAction:e.dataset.eventAction,date:e.dataset.date,slot:e.dataset.slot}}_restoreFocus(e){let t=null;e.eventId&&(t=this.el.querySelector(`[data-event-id="${Ri(e.eventId)}"][data-event-action="${e.eventAction??"activate"}"]`)),!t&&e.slot&&(t=this.el.querySelector(`[data-slot="${Ri(e.slot)}"]`)),!t&&e.date&&(t=this.el.querySelector(`[data-date-cell][data-date="${Ri(e.date)}"]`)),t?.focus?.()}_scrollTimeGrid(){let e=this.refs.body.querySelector(".zx-calendar__time-scroller");if(!e)return;let t=ge(this.options.slotMinTime,0),s=ge(this.options.slotMaxTime,1440,!0),n=ge(this.options.scrollTime,480,!0),r=Math.max(0,Math.min(1,(n-t)/(s-t)));requestAnimationFrame(()=>{e.isConnected&&(e.scrollTop=Math.max(0,r*e.scrollHeight-e.clientHeight/4))})}_refreshNowIndicator(){if(this._destroyed||!this.options.nowIndicator||!["day","week"].includes(this._view))return;let e=this.refs.body.querySelector(".zx-calendar__now"),t=[...this.refs.body.querySelectorAll(".zx-calendar__day-heading")];if(!e||!t.length)return;let s=this._now(),n=t.findIndex(u=>u.dataset.date===B(s)),r=ge(this.options.slotMinTime,0),o=ge(this.options.slotMaxTime,1440,!0),a=s.getHours()*60+s.getMinutes(),l=n>=0&&a>=r&&a<=o;e.hidden=!l,l&&(e.style.insetBlockStart=`${(a-r)/(o-r)*100}%`,e.style.setProperty("--zx-calendar-now-day",String(n)),e.querySelector(".zx-calendar__now-time").textContent=sn(a,this.options.locale))}_announce(e){this.refs.status.textContent="",requestAnimationFrame(()=>{this._destroyed||(this.refs.status.textContent=e)})}_dayCountLabel(e,t){let s=this._format(e,{dateStyle:"full"});return t===1?this._message("calendar.dayEvent","%1, %2 event",s,t):this._message("calendar.dayEvents","%1, %2 events",s,t)}_message(e,t,...s){let n=this.msg(e,...s);return n===e?O(t,s):n}};function Dh(i){if(!Array.isArray(i)||i.length===0)throw new TypeError("Calendar views must be a non-empty array");let e=[...new Set(i.map(String))];for(let t of e)if(!Ni.includes(t))throw new RangeError(`Unknown Calendar view: ${t}`);return e}function va(i,e,t){if(i==null)return t;if(i instanceof Date){if(Number.isNaN(i.getTime()))throw new TypeError("Calendar date must be valid");return new Date(i.getTime())}let s=typeof i=="number"?i:typeof i=="string"&&/^-?\d+(?:\.\d+)?$/.test(i.trim())?Number(i):null,n=s==null?new Date(i):new Date(s*(e==="seconds"?1e3:1));if(Number.isNaN(n.getTime()))throw new TypeError("Calendar date must be valid");return n}function se(i){let e=Number(i);if(!Number.isInteger(e)||e<=0||e>720||1440%e!==0)throw new RangeError("Calendar slotDuration must be a positive divisor of 1440");return e}function Eh(i){let e=Number(i);if(!Number.isInteger(e)||e<1||e>20)throw new RangeError("Calendar eventLimit must be an integer from 1 through 20");return e}function ge(i,e,t=!1){let s=Number(i??e),n=t?1440:1439;if(!Number.isInteger(s)||s<0||s>n)throw new RangeError(`Calendar minute must be from 0 through ${n}`);return s}function Ih(i,e){let t=L(i);return t.setMinutes(e),t}function Re(i,e){let t=new Date(i.getTime());return t.setMinutes(t.getMinutes()+e),t}function xa(i){return`${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`}function Le(i,e){return xa(i)===xa(e)}function ze(i){let e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(i??""));if(!e)return null;let t=new Date(Number(e[1]),Number(e[2])-1,Number(e[3]));return B(t)===i?t:null}function Th(i,e){return i.start-e.start||e.end-i.end||i.title.localeCompare(e.title)}function sn(i,e){let t=new Date(2026,0,1);return t.setHours(Math.floor(i/60)%24,i%60,0,0),nn(t,e)}function nn(i,e){return new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit"}).format(i)}function zt(i,e){return new Intl.DateTimeFormat(e,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(i)}function Sa(i){let e=new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let s=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e-s)/864e5+1)/7)}function Mh(i,e){let t=e.start.getTime()-i.start.getTime();return{milliseconds:t,days:Q(L(i.start),L(e.start)),minutes:Math.round(t/6e4),endMilliseconds:e.end.getTime()-i.end.getTime()}}function Ri(i){return globalThis.CSS?.escape?CSS.escape(i):i.replace(/[^a-zA-Z0-9_-]/g,e=>`\\${e}`)}var Aa=Object.freeze([Object.freeze(["getValue","setValue"]),Object.freeze(["get","set"]),Object.freeze(["getValues","setValues"]),Object.freeze(["isChecked","setChecked"])]),Nh=Object.freeze(["value","values","checked"]),ka="input, select, textarea, button",Oh="input, textarea";function Li(i){if(R(i))return i;let e=i;if(typeof e.toElement=="function")return e.toElement();if(R(e.el))return e.el;throw new TypeError("External field source must be an Element or a Component")}function za(i){return Da(i,Li(i)).get()}function rn(i){let e=Li(i),t=R(i)?null:i;if(t&&be(t,"isDisabled",0))return!!t.isDisabled();if(t&&typeof t.disabled=="boolean")return t.disabled;if(it(e,"disabled"))return!!e.disabled||e.hasAttribute("disabled");if(e.getAttribute("aria-disabled")==="true")return!0;let s=e.getAttribute("data-disabled");if(s!==null&&s!=="false")return!0;let n=[...e.querySelectorAll(ka)];return n.length>0&&n.every(r=>r.disabled)}function on(i){let e=Li(i),t=R(i)?null:i;for(let n of["readonly","readOnly"])if(t&&typeof t[n]=="boolean")return t[n];if(it(e,"readOnly"))return!!e.readOnly||e.hasAttribute("readonly");if(e.getAttribute("aria-readonly")==="true")return!0;let s=e.getAttribute("data-readonly");return s!==null&&s!=="false"}function Ca(i,e=null){let t=Li(i),s=R(i)?null:i,n=t.parentNode,r=t.nextSibling,o=new Map(["id","aria-labelledby","aria-describedby","aria-disabled","aria-invalid"].map(x=>[x,t.getAttribute(x)])),a=s===null,l=a&&it(t,"value")?t.value:void 0,u=a&&Ia(t)?t.checked:void 0,d=rn(i),h=on(i),p=new Map,f=Da(i,t),_=Fh(s,t,p),m=Rh(s,t,p),g=d,b=h,y=!1,A=f.get();e&&s&&typeof s.addEventListener=="function"&&(e.listen(s,"change",()=>{y||(A=f.get(),e.emit("change",{value:A}))}),e.listen(t,"change",x=>{let C=f.get();Lh(C,A)?x.stopImmediatePropagation():A=C}));let w={el:t,get:()=>f.get(),set:(x,C)=>{y=!0;try{f.set(x,C)}finally{y=!1}A=f.get()},focus:()=>{s&&be(s,"focus",0)?s.focus():typeof t.focus=="function"&&t.focus()},setDisabled:x=>{g=!!x,_(g)},destroy:()=>{b!==h&&m&&m(h),g!==d&&_(d);for(let[x,C]of p)C.disabled!==void 0&&(x.disabled=C.disabled),C.readOnly!==void 0&&(x.readOnly=C.readOnly);p.clear();for(let[x,C]of o)C===null?t.removeAttribute(x):t.setAttribute(x,C);l!==void 0&&(t.value=l),u!==void 0&&(t.checked=u),n?n.insertBefore(t,r?.parentNode===n?r:null):t.remove()}};return m&&(w.setReadonly=x=>{b=!!x,m(b)}),w}function Da(i,e){let t=R(i)?null:i;if(t){let s=Aa.find(([o])=>be(t,o,0)),n=s?be(t,s[1],2)?s[1]:Aa.map(([,o])=>o).find(o=>be(t,o,1)):void 0;if(s)return{get:()=>t[s[0]](),set:(o,a={})=>{n&&t[n](o,{...a,silent:!!a.silent})}};let r=Nh.find(o=>o in t);if(r)return{get:()=>t[r],set:o=>{t[r]=o}}}return Ia(e)?{get:()=>!!e.checked,set:s=>{e.checked=!!s}}:it(e,"value")?{get:()=>e.value,set:s=>{e.value=s??""}}:{get:()=>null,set:()=>{}}}function Fh(i,e,t){return i&&be(i,"setDisabled",1)?s=>i.setDisabled(s):i&&be(i,"enable",0)&&be(i,"disable",0)?s=>s?i.disable():i.enable():i&&typeof i.disabled=="boolean"?s=>{i.disabled=s}:it(e,"disabled")?s=>{e.disabled=s}:s=>{e.setAttribute("aria-disabled",String(s));for(let n of e.querySelectorAll(ka))Ea(t,n,"disabled"),n.disabled=s||!!t.get(n)?.disabled}}function Rh(i,e,t){if(i){for(let n of["setReadonly","setReadOnly"])if(be(i,n,1))return r=>i[n](r);for(let n of["readonly","readOnly"])if(typeof i[n]=="boolean")return r=>{i[n]=r};return null}if(it(e,"readOnly"))return n=>{e.readOnly=n};let s=[...e.querySelectorAll(Oh)];return s.length?n=>{for(let r of s)Ea(t,r,"readOnly"),r.readOnly=n||!!t.get(r)?.readOnly}:null}function Ea(i,e,t){let s=i.get(e)??{};s[t]===void 0&&(s[t]=!!e[t]),i.set(e,s)}function be(i,e,t){let s=i[e];return typeof s=="function"&&s.length<=t}function it(i,e){return["INPUT","SELECT","TEXTAREA","BUTTON","FIELDSET","OUTPUT"].includes(i.tagName)&&e in i}function Ia(i){let e=String(i.type??"").toLowerCase();return i.tagName==="INPUT"&&(e==="checkbox"||e==="radio")}function Lh(i,e){if(Object.is(i,e))return!0;if(i instanceof Date&&e instanceof Date)return i.getTime()===e.getTime();if(i&&e&&typeof i=="object"&&typeof e=="object")try{return JSON.stringify(i)===JSON.stringify(e)}catch{return!1}return!1}var Dt=class extends S{static cssName="fieldset";static defaults={title:"",columns:1,fields:{},idPrefix:null};render(){let e=this.el??c("fieldset");this._fields=new Map,this._ownedFields=new Set,this._origins=new Map,this._fieldIdAttributes=new Map,this._ownedNodes=[],this._idPrefix=this.options.idPrefix?String(this.options.idPrefix):E("zx-fieldset"),this._columnAttribute=e.getAttribute("data-columns");let t=[1,2,3].includes(Number(this.options.columns))?Number(this.options.columns):1;if(e.dataset.columns=String(t),this.options.title){let n=c("legend",{class:"zx-fieldset__legend"},String(this.options.title));this._ownedNodes.push(n),e.append(n)}this._grid=c("div",{class:"zx-fieldset__grid"}),this._ownedNodes.push(this._grid),e.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 e}addField(e,t){let s=String(e);if(this._fields.has(s))throw new Error(`Field "${s}" already exists`);let n,r=!1;if(t instanceof z)n=t;else if(R(t)||t instanceof S){let o=t;n=new z(null,{id:this._controlId(s),name:s,type:"custom",label:s,value:za(o),disabled:rn(o),readonly:on(o),adapter:a=>Ca(o,a)}),r=!0}else{let o=t&&typeof t=="object"?t:{},a=o.id!=null&&String(o.id)!==""&&String(o.id)!==s;n=new z(null,{...o,id:a?String(o.id):this._controlId(s),name:o.name??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(e){return this._fields.get(String(e))??null}hasField(e){return this._fields.has(String(e))}getFields(){return Object.fromEntries(this._fields)}getValues(){let e={};for(let[t,s]of this._fields)e[t]=s.getValue();return e}setValues(e,{silent:t=!1}={}){if(!e||typeof e!="object")return this;for(let[s,n]of Object.entries(e))this._fields.get(s)?.setValue(n,{silent:t});return this}getValue(e){return this._fields.get(String(e))?.getValue()??null}setValue(e,t){return this._fields.get(String(e))?.setValue(t),this}reset(){for(let e of this._fields.values())e.reset();return this}clear(){for(let e of[...this._fields.values()])this._releaseField(e);return this._fields.clear(),this}focus(e){return this._fields.get(String(e))?.focus(),this}setHighlights(e={},t="danger"){let s=0;for(let[n,r]of this._fields){let o=e?.[n];o?(r.setHighlight(String(o),t),s+=1):r.clearHighlight()}return s}clearHighlights(){for(let e of this._fields.values())e.clearHighlight();return this}_controlId(e){return`${this._idPrefix}-${e.trim().replace(/\s+/g,"-")}`}_releaseField(e){let t=this._fieldIdAttributes.get(e);if(t==null?e.el.removeAttribute("data-field-id"):e.el.setAttribute("data-field-id",t),this._fieldIdAttributes.delete(e),this._ownedFields.has(e)){e.destroy(),this._ownedFields.delete(e);return}let s=this._origins.get(e);s?.parent?s.parent.insertBefore(e.el,s.next?.parentNode===s.parent?s.next:null):e.el.remove(),this._origins.delete(e)}destroy(){this.clear();for(let e of this._ownedNodes??[])e.remove();this._columnAttribute===null?this.el.removeAttribute("data-columns"):this.el.setAttribute("data-columns",this._columnAttribute),super.destroy()}};var Et=class extends S{static cssName="form";static defaults={fieldsets:[],actions:[],novalidate:!0,idPrefix:null,msg:{"form.required":"This field is required.","form.int":"Enter a whole number.","form.float":"Enter a valid number."}};render(){let e=this.el??c("form");this._fieldsets=[],this._ownedFieldsets=new Set,this._origins=new Map,this._ownedNodes=[],this._idPrefix=this.options.idPrefix?String(this.options.idPrefix):E("zx-form"),this._novalidateAttribute=e.getAttribute("novalidate"),e.toggleAttribute("novalidate",!!this.options.novalidate),this._body=c("div",{class:"zx-form__body"}),this._actions=c("div",{class:"zx-form__actions"}),this._ownedNodes.push(this._body,this._actions),e.append(this._body,this._actions),this.listen(e,"submit",s=>{s.preventDefault(),this.submit()}),this.listen(e,"reset",s=>{s.preventDefault(),this.reset()}),this.listen(this._actions,"click",s=>this._handleAction(s));let t=Array.isArray(this.options.fieldsets)?this.options.fieldsets:[];for(let s of t)this.addFieldset(s);return this.setActions(Array.isArray(this.options.actions)?this.options.actions:[]),e}addFieldset(e){let t=!(e instanceof Dt),s=t?new Dt(null,{...e??{},idPrefix:e?.idPrefix??this._idPrefix}):e;return this._fieldsets.includes(s)||(t?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(e){return this._actionDescriptors=Array.isArray(e)?e.map(t=>({...t})):[],this._actions.replaceChildren(...this._actionDescriptors.map((t,s)=>{let n=String(t.label??t.id??"Action");return c("button",{class:"zx-btn",type:["submit","reset"].includes(t.type)?t.type:"button",disabled:!!t.disabled,title:t.title,ariaLabel:!n&&t.title?t.title:void 0,dataset:{actionIndex:s,kind:["primary","danger","ghost"].includes(t.kind)?t.kind:"default",size:t.size==="sm"?"sm":"md"}},t.icon?v(t.icon,{size:16}):null,n?c("span",{class:"zx-btn__label"},n):null)})),this._actions.hidden=this._actionDescriptors.length===0,this}getValues(){return Object.assign({},...this._fieldsets.map(e=>e.getValues()))}setValues(e,{silent:t=!1}={}){for(let s of this._fieldsets)s.setValues(e,{silent:t});return this}getField(e){for(let t of this._fieldsets){let s=t.getField(e);if(s)return s}return null}setValue(e,t){return this.getField(e)?.setValue(t),this}getValue(e){return this.getField(e)?.getValue()??null}reset(){for(let e of this._fieldsets)e.reset().clearHighlights();return this}setHighlights(e,t="danger"){return this._fieldsets.reduce((s,n)=>s+n.setHighlights(e,t),0)}clearHighlights(){for(let e of this._fieldsets)e.clearHighlights();return this}submit(){let e={},t=null;for(let n of this._fieldsets)for(let[r,o]of Object.entries(n.getFields())){let a=o.getValue(),l="";if(o.options.required&&an(a))l=this.msg("form.required");else if(!an(a)&&o.options.type==="int"){let u=os(a);u.valid?o.setValue(u.value,{silent:!0}):l=this.msg("form.int")}else if(!an(a)&&o.options.type==="float"){let u=as(a);u.valid?o.setValue(u.value,{silent:!0}):l=this.msg("form.float")}l?(e[r]=l,o.setHighlight(l,"danger"),t??=o):o.clearHighlight()}return Object.keys(e).length?(this.emit("invalid",{errors:e}),t?.focus(),!1):!this.emit("submit",{values:this.getValues()}).defaultPrevented}_handleAction(e){let t=e.target instanceof Element?e.target.closest("[data-action-index]"):null;if(!t||!this._actions.contains(t))return;let s=this._actionDescriptors[Number(t.dataset.actionIndex)],n=s?.onClick??s?.onclick??s?.handler;typeof n=="function"&&n(e,this)}destroy(){for(let e of this._fieldsets??[])if(this._ownedFieldsets.has(e))e.destroy();else{let t=this._origins.get(e);t?.parent?t.parent.insertBefore(e.el,t.next?.parentNode===t.parent?t.next:null):e.el.remove()}this._fieldsets=[];for(let e of this._ownedNodes??[])e.remove();this._novalidateAttribute===null?this.el.removeAttribute("novalidate"):this.el.setAttribute("novalidate",this._novalidateAttribute),super.destroy()}};function an(i){return i==null||i===""||i===!1||Array.isArray(i)&&i.length===0}function Ph(){go(),lr(),ur(),Zr(),Nr(),Kr(),Ao(),Co(),to(),Qr(),ko(),so(),no(),vo(),bo()}Ph();function ce(i,{onError:e,locale:t}={}){if(!i||typeof i!="object"||!i.api||typeof i.api!="object")throw new TypeError("connect() requires a ZeyOS client with an api namespace");if(e!=null&&typeof e!="function")throw new TypeError("onError must be a function");let s=t??jh(i);s&&ts(String(s));let n=(o,a)=>e?e(o,a):ke.error(cn(o)),r=async(o,a,l)=>{let u=Bh(i,o,a);try{return await i.api[u](l)}catch(d){try{n(d,{operation:u,resource:a})}catch{}throw d}};return{client:i,list:(o,a={})=>r("list",o,a),get:(o,a,l={})=>r("get",o,Ta(a)?a:{ID:a,...l}),create:(o,a)=>r("create",o,a),update:(o,a,l)=>r("update",o,l===void 0&&Ta(a)?a:{ID:a,body:l??{}}),reportError:n}}function jh(i){return i.locale??i.language??i.config?.locale??i.metadata?.locale??null}function Bh(i,e,t){let s=String(t??"").trim();if(!s)throw new TypeError("ZeyOS resource must not be empty");let n=typeof i.schema?.operations=="function"?i.schema.operations(s):[];if(Array.isArray(n)&&n.length){let p=n.filter(f=>typeof f=="string"&&f.toLowerCase().startsWith(e)).sort((f,_)=>f.length-_.length);if(p.length)return p[0]}let r=Array.isArray(n)&&n.length?n:typeof i.schema?.operationIds=="function"?i.schema.operationIds():Object.keys(i.api);if(r.includes(s)&&s.toLowerCase().startsWith(e))return s;let o=Ma(s),a=Na(o),l=r.filter(p=>{if(typeof p!="string"||!p.toLowerCase().startsWith(e))return!1;let f=Ma(p.slice(e.length));return f===o||f===a||Na(f)===a});if(l.length)return l.sort((p,f)=>p.length-f.length)[0];let u=e==="list"?[`list${ln(s)}`]:[`${e}${ln(Vh(s))}`,`${e}${ln(s)}`],d=new Set(Object.keys(i.api)),h=u.find(p=>d.has(p));if(h)return h;throw new RangeError(`No ${e} operation found for ZeyOS resource "${s}"`)}function Ta(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function cn(i){return i instanceof Error&&i.message||i&&typeof i=="object"&&typeof i.message=="string"?i.message:String(i??"ZeyOS request failed")}function Ma(i){return String(i).replace(/[^a-z\d]/gi,"").toLowerCase()}function Na(i){return i.endsWith("ies")?`${i.slice(0,-3)}y`:i.endsWith("sses")?i.slice(0,-2):i.endsWith("s")&&!i.endsWith("ss")?i.slice(0,-1):i}function Vh(i){let e=String(i);return/ies$/i.test(e)?`${e.slice(0,-3)}y`:/s$/i.test(e)&&!/ss$/i.test(e)?e.slice(0,-1):e}function ln(i){return String(i).split(/[^a-z\d]+/i).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}var Pe=Object.freeze({accounts:{label:"Accounts",icon:"zeyos-accounts",color:"#bc3885",fa:"building"},actionsteps:{label:"Action Steps",icon:"zeyos-actionsteps",color:"#f67f00",fa:"clock"},appointments:{label:"Appointments",icon:"zeyos-appointments",color:"#bd1e32",fa:"calendar-check"},billing:{label:"Billing",icon:"zeyos-billing",color:"#535494",fa:"file-invoice-dollar"},calendar:{label:"Calendar",icon:"zeyos-calendar",color:"#bd1e32",fa:"calendar-days"},campaigns:{label:"Campaigns",icon:"zeyos-campaigns",color:"#f16528",fa:"bullhorn"},collection:{label:"Collection",icon:"zeyos-collection",color:"#0d60ae",fa:"hand-holding-dollar"},contacts:{label:"Contacts",icon:"zeyos-contacts",color:"#8c6641",fa:"address-book"},contracts:{label:"Contracts",icon:"zeyos-contracts",color:"#823e89",fa:"file-contract"},coupons:{label:"Coupons",icon:"zeyos-coupons",color:"#10775c",fa:"ticket-simple"},devices:{label:"Devices",icon:"zeyos-devices",color:"#064e4f",fa:"desktop"},documents:{label:"Documents",icon:"zeyos-documents",color:"#808000",fa:"file"},dunning:{label:"Dunning",icon:"zeyos-dunning",color:"#0d60ae",fa:"file-invoice-dollar"},events:{label:"Events",icon:"zeyos-events",color:"#bd1e32",fa:"calendar-day"},inventory:{label:"Inventory",icon:"zeyos-inventory",color:"#064e4f",fa:"warehouse"},items:{label:"Items",icon:"zeyos-items",color:"#064e4f",fa:"box-open"},ledgers:{label:"Ledgers",icon:"zeyos-ledgers",color:"#4679c8",fa:"book-open"},line:{label:"Line Items",icon:"zeyos-line",color:"#064e4f",fa:"list-ul"},links:{label:"Links",icon:"zeyos-links",color:"#405e76",fa:"bookmark"},mailinglists:{label:"Mailing Lists",icon:"zeyos-mailinglists",color:"#0299ac",fa:"envelope-open-text"},messages:{label:"Messages",icon:"zeyos-messages",color:"#31a8e0",fa:"message"},"messages-unread":{label:"Unread Messages",icon:"zeyos-messages-unread",color:"#31a8e0",fa:"envelope"},notes:{label:"Notes",icon:"zeyos-notes",color:"#008853",fa:"note-sticky"},opportunities:{label:"Opportunities",icon:"zeyos-opportunities",color:"#7b67ae",fa:"handshake"},payments:{label:"Payments",icon:"zeyos-payments",color:"#4679c8",fa:"sack-dollar"},pricelists:{label:"Price Lists",icon:"zeyos-pricelists",color:"#10775c",fa:"clipboard-list"},procurement:{label:"Procurement",icon:"zeyos-procurement",color:"#006e9f",fa:"truck"},production:{label:"Production",icon:"zeyos-production",color:"#226375",fa:"industry"},projects:{label:"Projects",icon:"zeyos-projects",color:"#db532d",fa:"diagram-project"},stocktransactions:{label:"Stock Transactions",icon:"zeyos-stocktransactions",color:"#064e4f",fa:"arrow-right-arrow-left"},storages:{label:"Storages",icon:"zeyos-storages",color:"#064e4f",fa:"boxes-stacked"},tasks:{label:"Tasks",icon:"zeyos-tasks",color:"#e2b301",fa:"list-check"},text:{label:"Text Blocks",icon:"zeyos-text",color:"#064e4f",fa:"file-lines"},tickets:{label:"Tickets",icon:"zeyos-tickets",color:"#f04639",fa:"ticket"},"transactions-billing":{label:"Billing Transactions",icon:"zeyos-transactions-billing",color:"#535494",fa:"file-invoice"},"transactions-collection":{label:"Collection Transactions",icon:"zeyos-transactions-collection",color:"#0d60ae",fa:"money-bill-transfer"},"transactions-procurement":{label:"Procurement Transactions",icon:"zeyos-transactions-procurement",color:"#006e9f",fa:"cart-shopping"},"transactions-production":{label:"Production Transactions",icon:"zeyos-transactions-production",color:"#226375",fa:"gears"},zeyos:{label:"ZeyOS",icon:"zeyos",color:"#007a55",fa:"cloud"},default:{label:"Default",icon:"zeyos-default",color:"#21cc75",fa:"cube"},admin:{label:"Administration",icon:"zeyos-admin",color:"#4b5563",fa:"screwdriver-wrench"},applications:{label:"Applications",icon:"zeyos-applications",color:"#2563eb",fa:"window-maximize"},auth:{label:"Credentials",icon:"zeyos-auth",color:"#a16207",fa:"shield-halved"},categories:{label:"Categories",icon:"zeyos-categories",color:"#9a3412",fa:"folder-tree"},channels:{label:"Channels",icon:"zeyos-channels",color:"#0891b2",fa:"share-nodes"},control:{label:"Control Center",icon:"zeyos-control",color:"#0f766e",fa:"sliders"},davservers:{label:"DAV Servers",icon:"zeyos-davservers",color:"#475569",fa:"server"},dev:{label:"Development",icon:"zeyos-dev",color:"#1f2937",fa:"code"},error:{label:"Errors",icon:"zeyos-error",color:"#b91c1c",fa:"triangle-exclamation"},global:{label:"Global",icon:"zeyos-global",color:"#0369a1",fa:"globe"},groups:{label:"Groups",icon:"zeyos-groups",color:"#007a55",fa:"users"},logout:{label:"Logout",icon:"zeyos-logout",color:"#9f1239",fa:"right-from-bracket"},objects:{label:"Custom Objects",icon:"zeyos-objects",color:"#7e22ce",fa:"cubes"},participants:{label:"Participants",icon:"zeyos-participants",color:"#4338ca",fa:"user-group"},permissions:{label:"Permissions",icon:"zeyos-permissions",color:"#5b21b6",fa:"user-lock"},records:{label:"Records",icon:"zeyos-records",color:"#57534e",fa:"database"},resources:{label:"Resources",icon:"zeyos-resources",color:"#15803d",fa:"layer-group"},services:{label:"Services",icon:"zeyos-services",color:"#b45309",fa:"bell-concierge"},system:{label:"System",icon:"zeyos-system",color:"#374151",fa:"gear"},users:{label:"Users",icon:"zeyos-users",color:"#007a55",fa:"user"},weblets:{label:"Weblets",icon:"zeyos-weblets",color:"#4f46e5",fa:"window-restore"}}),Fa=Object.freeze({main:"zeyos",addresses:"contacts",clocking:"actionsteps",comments:"notes",couponcodes:"coupons",customers:"accounts",customfields:"objects",davids:"davservers",documentversions:"documents",enhancements:"applications",extdata:"objects",feedservers:"channels",files:"documents",filters:"records",forks:"applications",imports:"records",invoices:"transactions-billing",linecoupon:"line",logins:"auth",mailservers:"channels",notifications:"messages","participants-campaigns":"participants","participants-mailinglists":"participants",prices:"pricelists",pwd:"auth",purchaseorders:"transactions-procurement",sessions:"auth",settings:"system",suppliers:"accounts",tags:"categories",tokens:"auth",transactions:"transactions-billing",usergroups:"groups",usermgmt:"users",usersettings:"system",userfields:"objects",userfilters:"records"}),It=Object.freeze({light:"#ffffff",dark:"#141414"}),Tt=Object.create(null);function Pi(i){let e=String(i??"").trim().toLowerCase().replaceAll(/[._\s]+/g,"-");if(!e)return"default";if(Object.hasOwn(Tt,e)||Object.hasOwn(Pe,e))return e;let t=Fa[e];return t||"default"}function X(i){let e=Pi(i);return Tt[e]??Pe[e]??Pe.default}function qh(i){return X(i).color}function $h(i,{standard:e=!1}={}){let t=X(i);return e?t.fa:t.icon}function Hh(){return[...new Set([...Object.keys(Pe),...Object.keys(Tt)])].sort()}function Kh(i){for(let[e,t]of Object.entries(i)){let s=String(e).trim().toLowerCase().replaceAll(/[._\s]+/g,"-"),n=typeof t=="string"?{color:t}:t,r=Tt[s]??Pe[s]??Pe.default;Tt[s]=Object.freeze({label:n.label??r.label,icon:n.icon??r.icon,color:n.color??r.color,fa:n.fa??r.fa})}}function Uh(i){let e=un(i);if(e===null)return It.light;let t=Oa(e,un(It.light)??1),s=Oa(e,un(It.dark)??0);return t>=s?It.light:It.dark}function un(i){let e=/^#([\da-f]{3}|[\da-f]{6})$/i.exec(String(i).trim());if(!e)return null;let t=e[1].length===3?[...e[1]].map(o=>o+o).join(""):e[1],[s,n,r]=[0,2,4].map(o=>{let a=Number.parseInt(t.slice(o,o+2),16)/255;return a<=.04045?a/12.92:((a+.055)/1.055)**2.4});return .2126*s+.7152*n+.0722*r}function Oa(i,e){return(Math.max(i,e)+.05)/(Math.min(i,e)+.05)}var Ra="https://kit.fontawesome.com/ae8320b210.js";function Yh(i={}){return _s({kit:Ra,...i})}function ji(i,e={}){let{standard:t=!1,...s}=e,n=X(i);return v(t?`fa:${n.fa}`:`kit:${n.icon}`,s)}function st(i,e={}){let{size:t=24,iconSize:s="52%",label:n=null,title:r=!1,standard:o=!1,color:a=null,badge:l=null,selected:u=!1}=e,d=Pi(i),h=X(i),p=we(a)?a:h.color,f=Si({icon:e.icon??ji(i,{size:"1em",standard:o}),size:t,iconSize:s,color:p,label:n,badge:l,selected:u,shape:e.shape??"tile",glass:e.glass??"subtle",class:["zx-module-icon",e.class].flat().filter(Boolean)});return f.dataset.module=d,f.style.setProperty("--zx-module-color",p),f.style.setProperty("--zx-module-glyph","var(--zx-color-app-icon-glyph)"),f.style.setProperty("--zx-app-icon-glyph","var(--zx-color-app-icon-glyph)"),r&&(f.title=h.label),f}function dn(i,e={}){return st(i,{shape:"circle",...e})}var Wh=Object.freeze(["accounts","actionsteps","admin","auth","billing","calendar","campaigns","collection","contacts","contracts","control","coupons","dev","documents","inventory","mailinglists","main","messages","links","notes","objects","opportunities","payments","pricelists","procurement","production","projects","tasks","tickets"]);function La(i={},e={}){let{standardIcons:t=!1,items:s=[],sources:n=[],...r}=e,o=pn(i.labels),a={standardIcons:t,renderApplicationIcon:i.renderApplicationIcon,renderWebletIcon:i.renderWebletIcon},l=Pa(i,a),u=typeof i.loadRecent=="function"?[]:Bi(i.recent??[],{query:"",labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:t}),d=[];return typeof i.loadRecent=="function"&&d.push({id:"zeyos-recent",minQuery:0,when:"empty",order:"source",load:async(h,p)=>Bi(await i.loadRecent(p),{query:"",labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:t})}),typeof i.search=="function"&&d.push({id:"zeyos-records",minQuery:1,when:"query",order:"source",load:async(h,p)=>Bi(await i.search(h,p),{query:h,labels:o,resolveRecord:i.resolveRecord,renderRecordIcon:i.renderRecordIcon,standardIcons:t})}),d.push(...n),{...r,items:[...l,...u,...s],sources:d,hints:e.hints??{move:o.move,open:o.open,close:o.close}}}function Zh(i={},e={}){return new zi(null,La(i,e))}function Pa(i={},e={}){let t=pn(i.labels),s=Array.isArray(i.pinned)?i.pinned.map(String):[],n=new Set,r=[],o=(a,l=null,u=null)=>{let d=fn(a,l,u);if(!d||n.has(d.identifier)||d.type==="module"&&typeof i.canUseModule=="function"&&!i.canUseModule(d.module))return;n.add(d.identifier);let h=Vi(d.raw,i.resolveApplication),p=s.indexOf(d.identifier),f=()=>(typeof e.renderApplicationIcon=="function"?e.renderApplicationIcon(d.raw,d):d.type==="weblet"&&typeof e.renderWebletIcon=="function"?e.renderWebletIcon(d.raw,d):null)??dn(d.module,{size:36,standard:!!e.standardIcons,color:d.color});r.push({id:d.identifier,label:d.label,keywords:[d.identifier,d.module],group:t.applications,groupOrder:0,kind:"application",icon:f,pinned:p>=0?p:void 0,current:d.identifier===i.activeIdentifier,disabled:!h.href&&typeof h.invoke!="function",...h,_zeyos:d})};for(let a of Array.isArray(i.menuApps)?i.menuApps:[])o(a);if(Array.isArray(i.modules))for(let a of i.modules)typeof a=="string"?o([a,X(a).label]):o(a,a?.id??a?.module,a?.label);else for(let[a,l]of Object.entries(i.modules??{}))o([a,l]);return r}function Bi(i,e={}){let t=String(e.query??""),s=pn(e.labels),n=Qh(i,t),r=new Map;return n.flatMap(({raw:o,group:a},l)=>{let u=Xh(o,a,t);if(!u)return[];let d=t===""?s.recent:u.group===""?s.results:s.entities[u.group]??u.group;r.has(d)||r.set(d,r.size+1);let h=Vi(u.raw,e.resolveRecord);return[{id:`record:${u.entity}:${u.fork??""}:${u.ID}`,label:u.name,description:u.sec,keywords:[u.entity,u.ID,u.fork??""],group:d,groupOrder:r.get(d),itemOrder:l,kind:"record",when:t===""?"empty":"query",icon:()=>(typeof e.renderRecordIcon=="function"?e.renderRecordIcon(u.raw,u):null)??st(u.entity,{size:28,standard:!!e.standardIcons}),disabled:!h.href&&typeof h.invoke!="function",...h,_zeyos:u}]})}function Gh(i={}){return i.weblet!=null&&i.weblet!==""?`weblet#${i.weblet}`:i.fork!=null&&i.fork!==""?`fork#${i.fork}`:String(i.module??"")}function fn(i,e,t){if(Array.isArray(i)){if(i.length<2)return null;if(i.length===2){let r=String(i[0]);return{raw:i,identifier:r,label:String(i[1]),module:r,type:"module",color:null}}if(i.length===4){let r=String(i[2]||"default");return{raw:i,identifier:`fork#${i[0]}`,label:String(i[1]),module:r,type:"fork",color:hn(i[3])}}return{raw:i,identifier:`weblet#${i[0]}`,label:String(i[1]),module:"weblets",type:"weblet",color:hn(i[8])}}if(!i||typeof i!="object")return null;let s=String(i.identifier??i.id??e??"");if(!s)return null;let n=s.startsWith("fork#")?"fork":s.startsWith("weblet#")?"weblet":"module";return{raw:i,identifier:s,label:String(i.label??t??X(s).label),module:String(i.module??(n==="module"?s:n==="fork"?"default":"weblets")),type:n,color:hn(i.color)}}function Qh(i,e){if(Array.isArray(i))return i.map(s=>({raw:s,group:s?.group??""}));if(!i||typeof i!="object")return[];let t=[];for(let[s,n]of Object.entries(i))if(Array.isArray(n))for(let r of n){if(!Array.isArray(r)){t.push({raw:r,group:s});continue}let o=s===""&&r.length>=5?{ID:r[0],fork:r[1],name:r[2],sec:r[3],entity:r[4],group:s}:{ID:r[0],fork:r[1],name:r[2],sec:r[3],entity:s,group:s};t.push({raw:o,group:s})}return t}function Xh(i,e,t){return Array.isArray(i)?t===""&&i.length>=4?{raw:i,entity:String(i[0]),ID:i[1],fork:i[2]??null,name:String(i[3]),sec:String(i[4]??""),group:""}:null:!i||typeof i!="object"||i.ID==null||i.name==null?null:{raw:i,entity:String(i.entity??e??"records"),ID:i.ID,fork:i.fork??null,name:String(i.name),sec:String(i.sec??""),group:String(i.group??e??"")}}function Vi(i,e){let t=i&&typeof i=="object"&&!Array.isArray(i)?i:{},s=typeof e=="function"?e(i):null,n=s&&typeof s=="object"?s:{};return Object.fromEntries(["href","target","invoke","value"].flatMap(r=>{let o=n[r]??t[r];return o===void 0?[]:[[r,o]]}))}function hn(i){let e=String(i??"").trim();if(!e)return null;let t=e.startsWith("#")?e:`#${e}`;return/^#[\da-f]{3}(?:[\da-f]{3})?$/i.test(t)?t:null}function pn(i){let e=i&&typeof i=="object"?i:{};return{applications:String(e.applications??"Applications"),recent:String(e.recent??"Recent"),results:String(e.results??"Top results"),entities:e.entities&&typeof e.entities=="object"?e.entities:{},move:String(e.move??"Move"),open:String(e.open??"Open"),close:String(e.close??"Close")}}function mn(i={},e={}){let t=Array.isArray(i.pinned)?i.pinned.map(String):null,s=i.menus&&typeof i.menus=="object"?i.menus:{},n=i.badges&&typeof i.badges=="object"?i.badges:{},r=i.groups&&typeof i.groups=="object"?i.groups:{},o={forks:"Forks",weblets:"Weblets",...i.labels??{}},a=new Set,l=[],u=(d,h=null,p=null)=>{let f=fn(d,h,p);if(!f||a.has(f.identifier)||f.type==="module"&&typeof i.canUseModule=="function"&&!i.canUseModule(f.module))return;a.add(f.identifier);let _=Ba(s[f.identifier],n),m=_.length?{}:Vi(f.raw,i.resolveApplication),g=t?t.indexOf(f.identifier):-1,b=r[f.identifier]??(f.type==="fork"?o.forks:f.type==="weblet"?o.weblets:void 0);l.push({id:f.identifier,label:f.label,icon:()=>(typeof i.renderApplicationIcon=="function"?i.renderApplicationIcon(f.raw,f):null)??ji(f.module,{size:"1em",standard:!!e.standardIcons}),color:f.color??X(f.module).color,module:f.module,...b?{group:b}:{},...n[f.identifier]!=null?{badge:n[f.identifier]}:{},...t?{pinned:g>=0?g:!1}:{},..._.length?{children:_}:m})};for(let d of Array.isArray(i.menuApps)?i.menuApps:[])u(d);if(Array.isArray(i.modules))for(let d of i.modules)typeof d=="string"?u([d,X(d).label]):u(d,d?.id??d?.module,d?.label);else for(let[d,h]of Object.entries(i.modules??{}))u([d,h]);return Oe(l)}function ja(i={},e={}){let{standardIcons:t=!1,appearance:s="solid",...n}=e;return{...n,items:mn(i,{standardIcons:t}),active:i.active??i.activeIdentifier??null,appearance:s}}function Jh(i={},e={}){let{standardIcons:t=!1,appearance:s="solid",moduleBar:n={},...r}=e;return{label:"ZeyOS",...r,layout:"modules",items:mn(i,{standardIcons:t}),active:i.active??i.activeIdentifier??null,moduleBar:{appearance:s,...n}}}function ef(i,e={},t={}){return new Ii(i,ja(e,t))}function Ba(i,e){return Array.isArray(i)?i.flatMap(t=>{if(Array.isArray(t)){let[o,a,l]=t;return o==null||a==null?[]:[{id:o,label:String(a),...l!=null?{href:String(l)}:{},...e[String(o)]!=null?{badge:e[String(o)]}:{}}]}if(!t||typeof t!="object"||t.label==null)return[];let s=Ba(t.children,e);if(t.section===!0)return s.length?[{...t.id!=null?{id:t.id}:{},section:!0,label:String(t.label),children:s}]:[];if(t.id==null)return[];let n=Object.fromEntries(["id","href","target","invoke","icon","value","disabled"].filter(o=>t[o]!==void 0).map(o=>[o,t[o]])),r=e[String(t.id)]??t.badge;return[{...n,label:String(t.label),...r!=null?{badge:r}:{},...s.length?{children:s}:{}}]}):[]}function Mt(i,e,t={}){let{fields:s,labelKey:n=Ka(i,e),valueKey:r="ID",searchFields:o=Ua(i,e),limit:a=50,filters:l={},value:u=null,...d}=t,h=ce(i),p=s??Ha(r,n,o);return{...d,valueKey:r,labelKey:n,value:u,filter:async f=>{let _=await h.list(e,lt({search:f,filters:l,fields:p,searchFields:o,limit:a}));return _n(i,_).data}}}function tf(i,e,t={}){let s=Mt(i,e,t),n=t.value??null,r=new q(null,s);return r.ready=$a(r,i,e,n),r}function qa(i,e,t={}){let{fields:s,labelKey:n=Ka(i,e),valueKey:r="ID",searchFields:o=Ua(i,e),subtitleKey:a=null,moduleKey:l=()=>e,groupKey:u=null,none:d=!0,recent:h=[],create:p=!1,renderIcon:f=rf,renderItem:_,renderValueAdornment:m,...g}=t,b=s??Ha(r,n,[...o,...[a,l,u].filter(w=>typeof w=="string")]),y=Mt(i,e,{...g,fields:b,labelKey:n,valueKey:r,searchFields:o,groupKey:u,clearable:d===!1?!!g.clearable:!0});y.recent=Array.isArray(h)?h:[];let A=(w,x=!1)=>{if(f===null)return null;let C=qi(w,l)??e;return f(w,{resource:e,module:String(C),selected:x})};if(y.renderItem=_??(w=>{let x=A(w);return c("span",{class:"zx-select__entity"},x?c("span",{class:"zx-select__entity-icon",ariaHidden:"true"},x):null,c("span",{class:"zx-select__entity-copy"},c("span",{class:"zx-select__entity-label"},String(qi(w,n)??"")),a&&qi(w,a)!=null?c("span",{class:"zx-select__entity-subtitle"},String(qi(w,a))):null))}),y.renderValueAdornment=m??(w=>A(w,!0)),d!==!1&&(y.noneLabel=typeof d=="string"?d:g.noneLabel??"No selection",y.renderNone=g.renderNone??(w=>c("span",{class:"zx-select__entity-none"},c("span",{class:"zx-select__entity-none-icon",ariaHidden:"true"}),c("span",{},w)))),p){let w=p===!0?{}:p,x=typeof w.oninvoke=="function"?w.oninvoke:null;y.actions=[...Array.isArray(y.actions)?y.actions:[],{id:w.id??"create",label:w.label??"Create new\u2026",group:w.group??"New",icon:w.icon??"plus",invoke:C=>x?.({...C,resource:e})}]}return y}function sf(i,e,t={}){let s=qa(i,e,t),n=t.value??null,r=q.entity(null,s);return r.ready=$a(r,i,e,n),r}function _n(i,e){return typeof i?.normalizeListResult=="function"?Va(i.normalizeListResult(e)):Va(e)}function Va(i){if(Array.isArray(i))return{data:i};if(!i||typeof i!="object")return{data:[]};let e=Array.isArray(i.data)?i.data:[],t=i.count==null||i.count===""?null:Number(i.count);return Number.isFinite(t)?{data:e,count:t}:{data:e}}async function $a(i,e,t,s){if(s==null)return i;let n=s&&typeof s=="object"?s:await ce(e).get(t,s),r=nf(n);return i.setItems([r]),i.set(r,{silent:!0}),i}function nf(i){if(i&&typeof i=="object"&&!Array.isArray(i)){let e=i.data;return e&&typeof e=="object"&&!Array.isArray(e)?e:i}throw new TypeError("ZeyOS get operation did not return a record")}function qi(i,e){return typeof e=="function"?e(i):i&&typeof i=="object"&&typeof e=="string"?i[e]:null}function rf(i,e){return st(String(e.module??"default"),{size:20})}function Ha(i,e,t){let s=[i,e,...t].filter(n=>typeof n=="string"&&n);return s.length?[...new Set(s)]:void 0}function Ka(i,e){let t=of(i,e);for(let s of["name","lastname","customernum","transactionnum","number","title","ID"])if(t.includes(s))return s;return t[0]??"ID"}function Ua(i,e){let t=i?.schema?.describe?.(e)?.fields;return!t||typeof t!="object"||Array.isArray(t)?[]:Object.entries(t).flatMap(([s,n])=>{if(!n||typeof n!="object")return[];let r=String(n.type??"").toLowerCase();return n.indexed&&/text|character|varchar/.test(r)?[s]:[]})}function of(i,e){let t=i?.schema?.fields?.(e);if(Array.isArray(t))return t.map(String);if(t&&typeof t=="object")return Object.keys(t);let s=i?.schema?.describe?.(e)?.fields;return s&&typeof s=="object"?Object.keys(s):[]}function af(i,e,t={}){let s=ct(i,e,t),n={},r=[],o=new Map;for(let a of s){let l=Gi(a);(l.type==="date"||l.type==="datetime")&&o.set(String(a.id),l.type);let u=l.type==="zxselect"&&typeof l.props?.entity=="string"?l.props.entity:null;u&&(r.push({id:String(a.id),resource:u}),l.props={...Mt(i,u,{clearable:!l.required,placeholder:`Select ${String(l.label).toLowerCase()}`})}),n[String(a.id)]=l}return{fieldMeta:s,fields:n,entityFields:r,formOptions:{fieldsets:[{title:String(t.title??""),columns:ff(t.columns),fields:n}]},mapFromRecord:a=>cf(a,s,o),mapToRecord:a=>uf(a,s,o)}}function lf(i,e,t={}){if(t.onSaved!=null&&typeof t.onSaved!="function")throw new TypeError("zeyosForm onSaved must be a function");let s=t.notify!==!1,n=af(i,e,t),r=()=>t.scope??a.el,o=ce(i,{onError:m=>s?ke.error(cn(m),{scope:r()}):void 0}),a=new Et(null,n.formOptions),l=t.value?.ID??t.id??null,u=!1,d=null,h=async m=>{if(!m||typeof m!="object"||Array.isArray(m))throw new TypeError("ZeyOS form value must be a record");return await Promise.all(n.entityFields.map(async({id:g,resource:b})=>{let y=m[g];if(y==null)return;let A=y&&typeof y=="object"?y:gn(await o.get(b,y)),w=q.from(a.getField(g)?.getInput());w instanceof q&&w.setItems([A])})),u||a.setValues(n.mapFromRecord(m),{silent:!0}),m},p=async m=>{if(m==null||m==="")throw new TypeError("zeyosForm.load() requires an id");let g=gn(await o.get(e,m));return l=g.ID??m,await h(g),g},f=()=>{if(u)return Promise.reject(new Error("Cannot save a destroyed ZeyOS form"));if(d)return d;if(!a.submit())return Promise.resolve(null);let m=s?ie(r()):null;return d=(async()=>{let g;try{g=n.mapToRecord(a.getValues()),delete g.ID}catch(A){throw o.reportError(A,{operation:"serialize",resource:e}),A}let b=l==null?await o.create(e,g):await o.update(e,{ID:l,...g}),y=gn(b);if(l=y.ID??l,t.onSaved)try{await t.onSaved(y)}catch(A){throw o.reportError(A,{operation:"onSaved",resource:e}),A}return m&&ke.success(`${pf(y,e)} saved successfully.`,{scope:m}),y})().finally(()=>{d=null}),d},_=Object.prototype.hasOwnProperty.call(t,"id")?p(t.id):t.value?h(t.value):Promise.resolve(null);return{form:a,ready:_,load:p,save:f,getForm:()=>a,destroy(){u||(u=!0,a.destroy())}}}function cf(i,e,t){let s={};for(let n of e){let r=String(n.id),o=i[r],a=t.get(r);!a||o==null||o===""?s[r]=o:a==="date"?s[r]=Zi(o,n.timeZone):s[r]=ye(o)}return s}function uf(i,e,t){let s={};for(let n of e){let r=String(n.id),o=i[r],a=t.get(r);if(a)o==null||o===""?o=null:a==="date"?o=Ot(o,n.timeZone):o=ue(o);else if(df(n)&&hf(n.type)&&o!==""&&o!=null){let l=Number(o);Number.isFinite(l)&&(o=l)}s[r]=o}return s}function df(i){return i.enums!=null||i.enum!=null}function hf(i){return/^(?:smallint|integer|bigint|int|int2|int4|int8|numeric|decimal)$/i.test(String(i??""))}function ff(i){let e=Number(i??2);return[1,2,3].includes(e)?e:2}function gn(i){if(i&&typeof i=="object"&&!Array.isArray(i)){let e=i.data;return e&&typeof e=="object"&&!Array.isArray(e)?e:i}throw new TypeError("ZeyOS operation did not return a record")}function pf(i,e){for(let t of["transactionnum","name","lastname","customernum","number","ID"])if(i[t]!=null&&i[t]!=="")return String(i[t]);return String(e)}var mf=["variant","zebra","stickyHeader","responsive","growing","emptyText","rowClass","rowKind","rowKinds","columnVisibility","columnReorder","hiddenColumns","onrowdblclick","onsort","onselectionchange","ondatachange","onstackedchange","ongrow","oncolumnvisibilitychange","oncolumnorderchange"];function yn(i,e,t={}){let s=ct(i,e,{fields:t.fields,labels:t.labels,formats:t.formats,timeZone:t.timeZone}),n={},r=s.map(l=>{let u={...l},d=bf(u);if(d){let f=yf(i,d);u.labelField=`${u.id}_label`,n[u.labelField]=`${u.id}.${f}`}n[u.id]=u.id;let h=wf(u),p=Qi(h?{...u,format:"money"}:u);return h&&(p.render=f=>vf(f?.[u.id],f?.currency),xf(i,e,"currency")&&(n.currency="currency")),p}),o=t.rowId??"ID";typeof o=="string"&&!Object.prototype.hasOwnProperty.call(n,o)&&(n[o]=o);let a={};for(let l of mf)t[l]!==void 0&&(a[l]=t[l]);return{fieldMeta:s,columns:r,projection:n,tableOptions:{...a,columns:r,data:[],rowId:o,sort:t.sort??null,sortMode:"server",selectable:t.selectable??!1,height:t.height??null,onrowclick:gf(t)}}}function _f(i,e,t={}){let s=yn(i,e,t),n=ce(i),r=new vt(null,s.tableOptions),o;try{o=wn({client:i,facade:n,resource:e,projection:s.projection,target:r,pageSize:t.pageSize,sort:t.sort??null,filters:t.filters??{},search:t.search,label:"ZeyOS table"})}catch(l){throw r.destroy(),l}let a={table:r,load:o.load,setSearch:l=>o.load({search:l,page:0}),setFilters:l=>o.load({filters:l,page:0}),loadMore:o.loadMore,get count(){return o.count},get page(){return o.page},get pageSize(){return o.pageSize},get hasMore(){return o.hasMore},destroy:()=>{o.destroyed||(o.destroy(),r.destroy())}};return r.on("sort",l=>{if(o.destroyed)return;let u=l.detail?.id;o.setSort(u==null?null:{id:String(u),dir:l.detail.dir==="desc"?"desc":"asc"}),o.load({page:0}).catch(()=>{})}),a}function wn(i){let{client:e,facade:t,resource:s,projection:n,target:r,searchFields:o}=i,a=String(i.label??"ZeyOS binding"),l=Ya(i.pageSize,a),u=i.sort??null,d=bn(i.filters??{},a),h=String(i.search??""),p=0,f=null,_=!1,m=0,g=!1,b=w=>lt({fields:n,sort:u,filters:d,search:h,searchFields:o,limit:l,offset:w*l,count:!0}),y=(w={})=>{let x=w&&typeof w=="object"?w:{},C=$=>Object.prototype.hasOwnProperty.call(x,$);return{page:Af(x.page??0,a),pageSize:C("pageSize")&&x.pageSize!==void 0?Ya(x.pageSize,a):l,filters:C("filters")?bn(x.filters??{},a):d,search:C("search")?String(x.search??""):h}},A=async(w={})=>{if(g)throw new Error(`${a} binding has been destroyed`);let x=y(w),C=x.page;l=x.pageSize,d=x.filters,h=x.search;let $=C===0||w.replace===!0,W=b(C),re=++m;r.setLoading(!0);try{let k=_n(e,await t.list(s,W)),N=k.count??null,ee=N==null?k.data.length===l:C*l+k.data.length<N;return!g&&re===m&&(p=C,f=N,_=ee,$?r.setData(k.data):r.addData(k.data)),{data:k.data,count:N,page:C,hasMore:ee,query:W}}finally{!g&&re===m&&r.setLoading(!1)}};return{load:A,check:y,loadMore:()=>_?A({page:p+1}):g?Promise.reject(new Error(`${a} binding has been destroyed`)):Promise.resolve({data:[],count:f,page:p,hasMore:!1,query:b(p)}),setSort:w=>{u=w??null},setQuery:(w={})=>{let x=Object.prototype.hasOwnProperty.call(w,"filters")?bn(w.filters??{},a):d;Object.prototype.hasOwnProperty.call(w,"search")&&(h=String(w.search??"")),d=x},reset:()=>{p=0,f=null,_=!1},destroy:()=>{g||(g=!0,m+=1)},get destroyed(){return g},get count(){return f},get page(){return p},get pageSize(){return l},get hasMore(){return _},get sort(){return u},get filters(){return{...d}},get search(){return h}}}function gf(i){let e=typeof i.onrowclick=="function"?i.onrowclick:null,t=typeof i.onRowClick=="function"?i.onRowClick:null;if(!(!e&&!t))return s=>{e?.(s),t?.(s.detail.row,s)}}function bf(i){for(let e of[i.entity,i.fk,i.relation,i.reference,i.references]){if(typeof e=="string"&&e)return e;if(e&&typeof e=="object"){let t=e.resource??e.target??e.table??e.entity;if(typeof t=="string"&&t)return t}}return null}function yf(i,e){let t=i?.schema?.fields?.(e),s=Array.isArray(t)?t.map(String):Object.keys(t??{});for(let n of["name","lastname","customernum","transactionnum","number","title","ID"])if(s.includes(n))return n;return s[0]??"ID"}function wf(i){let e=String(i.format??"").toLowerCase();return/money|currency|price/.test(e)||/(?:amount|price)$/.test(String(i.id).toLowerCase())}function vf(i,e){if(i==null||i==="")return"";let t=Number(i);if(!Number.isFinite(t))return"";let s=typeof e=="string"&&/^[A-Z]{3}$/.test(e)?e:null;try{return new Intl.NumberFormat(void 0,s?{style:"currency",currency:s}:{}).format(t)}catch{return new Intl.NumberFormat().format(t)}}function xf(i,e,t){let s=i?.schema?.fields?.(e);return Array.isArray(s)?s.includes(t):!!(s&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,t))}var Sf=50;function Ya(i,e="ZeyOS table"){if(i==null)return Sf;let t=Number(i);if(!Number.isInteger(t)||t<1)throw new RangeError(`${e} page size must be a positive integer`);return t}function Af(i,e="ZeyOS table"){let t=Number(i);if(!Number.isInteger(t)||t<0)throw new RangeError(`${e} page must be a non-negative integer`);return t}function bn(i,e="ZeyOS table"){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`${e} filters must be an object`);return{...i}}function Za(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("ZeyOS appointment must be an object");let e=i.ID??i.id;if(e==null||e==="")throw new TypeError("ZeyOS appointment requires ID");let t=ye(i.datefrom),s=ye(i.dateto??i.datefrom);if(!(t instanceof Date)||!(s instanceof Date))throw new TypeError("ZeyOS appointment requires datefrom and dateto");let n=String(i.assoc_name??"").trim(),r=String(i.name??"").trim()||"Untitled appointment",o=i.entity&&n?`${n}: ${r}`:r,a=i.allDay!=null?!!i.allDay:Wa(t)&&Wa(s)&&Q(t,s)>=1;return{id:String(i.occurrenceid??`${e}@${i.datefrom}`),title:o,start:t,end:s,allDay:a,color:Cf(i.color),location:String(i.location??"").trim(),editable:i.editable==null?null:!!i.editable,durationEditable:i.durationEditable==null?null:!!i.durationEditable,data:i}}function Ga(i){if(!Array.isArray(i))throw new TypeError("ZeyOS appointments must be an array");return i.map(Za)}function kf(i){if(!i||!(i.start instanceof Date)||!(i.end instanceof Date))throw new TypeError("Calendar event patch requires start and end Dates");let e={datefrom:ue(i.start),dateto:ue(i.end)};return i.data?.ID!=null?{ID:i.data.ID,...e}:e}function Qa(i={}){let{appointments:e,...t}=i;return{weekStart:1,optimistic:!0,...t,events:e==null?Array.isArray(t.events)?t.events:[]:Ga(e)}}function zf(i,e={}){return new Ct(i,Qa(e))}function Cf(i){let e=String(i??"").trim();return e?/^[\da-f]{3,8}$/i.test(e)?`#${e}`:e:null}function Wa(i){return i.getHours()===0&&i.getMinutes()===0&&i.getSeconds()===0&&i.getMilliseconds()===0}var Df=1,Ef=new Set(["table","card","kanban"]),Xa="1970-01-01T00:00:00.000Z",If=new Set(["__proto__","constructor","prototype"]),Tf=new Set(["cursor","data","offset","page","pagination","records","rows","selection","selectedRecords"]),rt=class extends Error{constructor(e){super(`A saved view named "${e}" already exists`),this.name="SavedViewDuplicateNameError"}},Hi=class extends Error{constructor(e,t){super(`Saved-view scope mismatch: expected ${ot(e)}, received ${ot(t)}`),this.name="SavedViewScopeMismatchError",this.expected={...e},this.actual={...t}}},Ki=class{constructor(e,t,s={}){if(!e||typeof e.load!="function"||typeof e.save!="function")throw new TypeError("SavedViewRegistry transport requires load() and save()");this.transport=e,this.scope=Ui(t),this.options=Ff(s),this._document=xn(this.scope),this._loaded=!1,this._loading=null,this._loadSequence=0,this._mutation=Promise.resolve(),this._destroyed=!1}async ready(){return this.load()}async load(e={}){if(this._assertActive(),this._loaded&&!e.force)return this;if(this._loading&&!e.force)return await this._loading,this;let t=++this._loadSequence,s=Promise.resolve(this.transport.load({...this.scope})).then(n=>{if(this._assertActive(),t!==this._loadSequence)return;let r=vn(n,this.scope,this.options);this._document=r,this._loaded=!0});this._loading=s;try{await s}finally{this._loading===s&&(this._loading=null)}return this}async list(){return await this.ready(),this._document.views.map(nt)}async get(e){await this.ready();let t=$i(this._document,e);return t?nt(t):null}async getDefault(){await this.ready();let e=this._document.views.find(t=>t.id===this._document.defaultId)??null;return e?nt(e):null}async save(e,t={}){return this._mutate(async s=>{let n=kn(e?.name),r=Cn(t.onDuplicate??this.options.duplicateNames),o=e?.id==null?null:zn(e.id),a=o?s.views.find(w=>w.id===o)??null:null,l=s.views.find(w=>J(w.name)===J(n))??null;if(a&&l&&a!==l&&r==="reject")throw new rt(n);if(!a&&l&&r==="reject")throw new rt(n);let u=a??(r==="replace"?l:null),d=r==="replace"&&a&&l!==a?l:null,h=this._now(),p=An(e?.type??u?.type),f=Object.prototype.hasOwnProperty.call(e??{},"state")?nl(e.state):u?ne(u.state,"Saved view state"):null;if(!f)throw new TypeError("A new saved view requires state");let _=Object.prototype.hasOwnProperty.call(e??{},"filters")?rl(e.filters):u?ne(u.filters,"Saved view filters"):{},m=Object.prototype.hasOwnProperty.call(e??{},"search")?ol(e.search):u?.search??"",g=u?.createdAt??h,b=u?.id??o??this._createId(s,{name:n,type:p,createdAt:g}),y={id:b,name:n,type:p,state:f,filters:_,search:m,createdAt:g,updatedAt:h},A=s.views.filter(w=>w!==u&&w!==d&&w.id!==b);return A.push(y),s.views=Sn(A),d&&s.defaultId===d.id&&(s.defaultId=b),t.setDefault&&(s.defaultId=b),{changed:!0,result:y}})}async rename(e,t,s={}){return this._mutate(async n=>{let r=$i(n,e);if(!r)return{changed:!1,result:null};let o=kn(t);if(r.name===o)return{changed:!1,result:r};let a=n.views.find(u=>u!==r&&J(u.name)===J(o))??null,l=Cn(s.onDuplicate??this.options.duplicateNames);if(a&&l==="reject")throw new rt(o);return a&&(n.views=n.views.filter(u=>u!==a),n.defaultId===a.id&&(n.defaultId=r.id)),r.name=o,r.updatedAt=this._now(),n.views=Sn(n.views),{changed:!0,result:r}})}async remove(e){return this._mutate(async t=>{let s=$i(t,e);return s?(t.views=t.views.filter(n=>n!==s),t.defaultId===s.id&&(t.defaultId=null),{changed:!0,removeDocument:t.views.length===0,result:!0}):{changed:!1,result:!1}})}async setDefault(e){return this._mutate(async t=>{if(e==null)return t.defaultId===null?{changed:!1,result:null}:(t.defaultId=null,{changed:!0,result:null});let s=$i(t,e);return s?t.defaultId===s.id?{changed:!1,result:s}:(t.defaultId=s.id,{changed:!0,result:s}):{changed:!1,result:null}})}async capture(e,t,s={}){if(!e||typeof e.getViewState!="function")throw new TypeError("capture() requires a view with getViewState()");return this.save({...t,state:e.getViewState()},s)}async apply(e,t,s={}){let n=await this.get(e);if(!n)return{status:"missing",applied:!1,entry:null};if(s.type!=null){let r=An(s.type);if(n.type!==r)return{status:"type-mismatch",applied:!1,entry:n,expectedType:n.type,currentType:r}}if(!t||typeof t.setViewState!="function")throw new TypeError("apply() requires a view with setViewState()");if(s.onQuery!=null&&typeof s.onQuery!="function")throw new TypeError("apply() onQuery must be a function");return t.setViewState(ne(n.state,"Saved view state")),s.onQuery&&await s.onQuery({filters:ne(n.filters,"Saved view filters"),search:n.search,entry:nt(n)}),{status:"applied",applied:!0,entry:n}}destroy(){this._destroyed=!0,this._loadSequence+=1,this._loading=null}_assertActive(){if(this._destroyed)throw new Error("SavedViewRegistry has been destroyed")}_now(){let e=this.options.clock(),t=e instanceof Date?e:new Date(e);if(!Number.isFinite(t.getTime()))throw new TypeError("Saved-view clock returned an invalid timestamp");return t.toISOString()}_createId(e,t){let s=this.options.idFactory?this.options.idFactory({scope:{...this.scope},...t}):`view-${al(`${ot(this.scope)}\0${t.name}\0${t.type}\0${t.createdAt}`)}`,n=zn(s),r=new Set(e.views.map(a=>a.id));if(!r.has(n))return n;let o=2;for(;r.has(`${n}-${o}`);)o+=1;return`${n}-${o}`}_mutate(e){this._assertActive();let t=this._mutation.catch(()=>{}).then(async()=>{await this.ready();let s=Ja(this._document),n=await e(s);if(this._assertActive(),!n.changed)return el(n.result);let r=vn(s,this.scope,this.options);return this._loadSequence+=1,n.removeDocument&&typeof this.transport.remove=="function"?(await this.transport.remove({...this.scope}),this._assertActive(),this._loadSequence+=1,this._document=xn(this.scope)):(await this.transport.save({...this.scope},Ja(r)),this._assertActive(),this._loadSequence+=1,this._document=r),el(n.result)});return this._mutation=t.then(()=>{},()=>{}),t}};function In(i,e,t={}){return new Ki(i,e,t)}function Ui(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Saved-view scope must be an object");return{userId:En(i.userId,"userId"),workspaceId:Rf(i.workspaceId),resource:En(i.resource,"resource")}}function vn(i,e,t={}){let s=Ui(e);if(i==null)return xn(s);let n=sl(i,t.migrations);if(n.scope!=null){let p=Ui(n.scope);if(ot(p)!==ot(s))throw new Hi(s,p)}let o=(Array.isArray(n.views)?n.views:[]).map((p,f)=>Nf(p,f,s)),a=Of(o),l=a.aliases,u=Sn(a.views),d=n.defaultId==null?null:String(n.defaultId),h=u.some(p=>p.id===d)?d:l.get(d)??null;return{version:1,scope:s,defaultId:u.some(p=>p.id===h)?h:null,views:u}}function sl(i,e={}){let t=Array.isArray(i)?{version:0,savedViews:i}:ne(i,"Saved-view document"),s=il(t.version);if(s>1)throw new RangeError(`Unsupported saved-view document version: ${s}`);for(;s<1;){let n=e?.[s]??(s===0?Mf:null);if(typeof n!="function")throw new RangeError(`Missing saved-view migration from version ${s}`);t=ne(n(ne(t,"Saved-view document")),`Saved-view migration ${s}`);let r=il(t.version);if(r<=s)throw new RangeError(`Saved-view migration ${s} did not advance the version`);s=r}return t}function Mf(i){let t=(Array.isArray(i.savedViews)?i.savedViews:Array.isArray(i.entries)?i.entries:Array.isArray(i.views)?i.views:[]).map(s=>{let n=s&&typeof s=="object"&&!Array.isArray(s)?s:{};return{id:n.id??null,name:n.name??n.label??"",type:n.type??n.presentation??n.view??"",state:n.state??n.viewState??{},filters:n.filters??n.filter??{},search:n.search??n.query??"",createdAt:n.createdAt??n.created??null,updatedAt:n.updatedAt??n.updated??null}});return{version:1,scope:i.scope??null,defaultId:i.defaultId??i.defaultView??i.default??null,views:t}}function Nf(i,e,t){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`Saved view at index ${e} must be an object`);let s=i,n=kn(s.name),r=An(s.type),o=nl(s.state??{}),a=rl(s.filters??{}),l=ol(s.search),u=tl(s.createdAt),d=tl(s.updatedAt??u),h=d<u?u:d;return{id:s.id==null||String(s.id).trim()===""?`legacy-${al(`${ot(t)}\0${n}\0${r}\0${e}`)}`:zn(s.id),name:n,type:r,state:o,filters:a,search:l,createdAt:u,updatedAt:h}}function Of(i){let e=[...i].sort((o,a)=>Nt(a.updatedAt,o.updatedAt)||Nt(o.id,a.id)),t=new Set,s=new Set,n=new Map,r=[];for(let o of e){let a=r.find(l=>l.id===o.id||J(l.name)===J(o.name));if(t.has(o.id)||s.has(J(o.name))){a&&n.set(o.id,a.id);continue}t.add(o.id),s.add(J(o.name)),r.push(o)}return{views:r,aliases:n}}function Ff(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Saved-view registry options must be an object");if(i.clock!=null&&typeof i.clock!="function")throw new TypeError("Saved-view clock must be a function");if(i.idFactory!=null&&typeof i.idFactory!="function")throw new TypeError("Saved-view idFactory must be a function");return{...i,duplicateNames:Cn(i.duplicateNames??"reject"),clock:i.clock??(()=>new Date)}}function xn(i){return{version:1,scope:{...i},defaultId:null,views:[]}}function Ja(i){return{version:1,scope:{...i.scope},defaultId:i.defaultId,views:i.views.map(nt)}}function nt(i){return{...i,state:ne(i.state,"Saved view state"),filters:ne(i.filters,"Saved view filters")}}function el(i){return Lf(i)?nt(i):i}function $i(i,e){if(typeof e!="string")return null;let t=e.trim();return t?i.views.find(s=>s.id===t)??i.views.find(s=>J(s.name)===J(t))??null:null}function Sn(i){return[...i].sort((e,t)=>Nt(J(e.name),J(t.name))||Nt(e.name,t.name)||Nt(e.id,t.id))}function An(i){if(typeof i!="string")throw new TypeError('Saved view type must be "table", "card", or "kanban"');let e=i.trim().toLowerCase();if(!Ef.has(e))throw new TypeError('Saved view type must be "table", "card", or "kanban"');return e}function kn(i){if(typeof i!="string")throw new TypeError("Saved view name must be a string");let e=i.normalize("NFKC").trim().replace(/\s+/g," ");if(!e)throw new TypeError("Saved view name cannot be empty");if(e.length>160)throw new RangeError("Saved view name cannot exceed 160 characters");return e}function J(i){return i.normalize("NFKC").toLocaleLowerCase("en-US")}function zn(i){if(typeof i!="string")throw new TypeError("Saved view id must be a string");let e=i.normalize("NFKC").trim();if(!e)throw new TypeError("Saved view id cannot be empty");if(e.length>180)throw new RangeError("Saved view id cannot exceed 180 characters");return e}function Cn(i){if(i!=="reject"&&i!=="replace")throw new TypeError('Duplicate saved-view policy must be "reject" or "replace"');return i}function nl(i){let e=ne(i,"Saved view state"),t=Number(e.version);if(!Number.isInteger(t)||t<1)throw new TypeError("Saved view state requires a positive integer version");e.version=t;for(let s of Tf)if(Object.prototype.hasOwnProperty.call(e,s))throw new TypeError(`Saved view state cannot serialize ${s}`);return e}function rl(i){return ne(i??{},"Saved view filters")}function ol(i){if(i==null)return"";if(typeof i!="string")throw new TypeError("Saved view search must be a string");return i}function ne(i,e){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`${e} must be a plain object`);return Dn(i,e,new WeakSet)}function Dn(i,e,t){if(i===null||typeof i=="string"||typeof i=="boolean")return i;if(typeof i=="number"){if(!Number.isFinite(i))throw new TypeError(`${e} cannot contain non-finite numbers`);return i}if(typeof i!="object")throw new TypeError(`${e} must be JSON-safe`);if(typeof i.nodeType=="number")throw new TypeError(`${e} cannot contain DOM nodes`);if(t.has(i))throw new TypeError(`${e} cannot contain cycles`);t.add(i);try{if(Array.isArray(i))return i.map(o=>Dn(o,e,t));let s=Object.getPrototypeOf(i);if(s!==Object.prototype&&s!==null)throw new TypeError(`${e} can contain only plain objects and arrays`);let n={},r=i;if(Object.getOwnPropertySymbols(i).length>0)throw new TypeError(`${e} cannot contain symbols`);for(let o of Object.keys(i).sort()){if(If.has(o))throw new TypeError(`${e} cannot contain prototype-pollution keys`);let a=Object.getOwnPropertyDescriptor(r,o);if(!a||!Object.prototype.hasOwnProperty.call(a,"value"))throw new TypeError(`${e} cannot contain property accessors`);n[o]=Dn(a.value,e,t)}return n}finally{t.delete(i)}}function tl(i){if(i==null||i==="")return Xa;let e=new Date(i);return Number.isFinite(e.getTime())?e.toISOString():Xa}function il(i){if(i==null)return 0;let e=Number(i);if(!Number.isInteger(e)||e<0)throw new TypeError("Saved-view document version must be a non-negative integer");return e}function En(i,e){if(typeof i!="string"&&typeof i!="number")throw new TypeError(`Saved-view scope ${e} must be a string or number`);let t=String(i).normalize("NFKC").trim();if(!t)throw new TypeError(`Saved-view scope ${e} cannot be empty`);return t}function Rf(i){return i===null?null:En(i,"workspaceId")}function ot(i){let e=i.workspaceId===null?"":`${i.workspaceId}`;return`${i.userId}\0${e}\0${i.resource}`}function Nt(i,e){return i<e?-1:i>e?1:0}function Lf(i){return!!(i&&typeof i=="object"&&"id"in i&&typeof i.id=="string")}function al(i){let e=2166136261;for(let t=0;t<i.length;t+=1)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return(e>>>0).toString(36)}var Pf=["titleField","subtitleField","preview","previewAlt","link","actions","groupBy","groupOrder","columnBy","columns","swimlaneBy","swimlanes","moveMode","columnOrder","swimlaneOrder","collapsedColumns","collapsedSwimlanes","showCounts","showEmptyColumns","hiddenFields","fieldOrder","fieldControls","selectable","selection","emptyText"];function cl(i,e,t={}){let s=Bf(i,e,t),n=yn(i,e,{fields:s,labels:t.labels,formats:t.formats,timeZone:t.timeZone,rowId:t.recordId??"ID",sort:t.sort??null}),r=t.fieldOverrides&&typeof t.fieldOverrides=="object"?t.fieldOverrides:{},o=Array.isArray(t.fields)?new Set(t.fields.map(String)):null,a=n.columns.map(d=>({...d,...o&&!o.has(d.id)?{visible:!1}:{},...r[d.id]??{},id:d.id})),l={...n.projection};for(let d of ul(t))Object.prototype.hasOwnProperty.call(l,d)||(l[d]=d);let u={...t.viewOptions??{}};for(let d of Pf)Object.prototype.hasOwnProperty.call(t,d)&&(u[d]=t[d]);return Object.assign(u,{fields:a,data:[],recordId:t.recordId??"ID",sort:t.sort??null,sortMode:"server"}),typeof t.onRecordClick=="function"&&(u.onrecordclick=d=>t.onRecordClick(d.detail.record,d)),{fieldMeta:n.fieldMeta,fields:a,projection:l,viewOptions:u}}function jf(i,e,t,s={}){if(typeof t!="function")throw new TypeError("zeyosView() requires a view constructor");let n=cl(i,e,s),r=new t(s.target??null,n.viewOptions);for(let k of["setData","addData","setLoading","on","destroy"])if(typeof r?.[k]!="function"){try{r?.destroy?.()}catch{}throw new TypeError(`zeyosView() constructor must provide ${k}()`)}let o=ce(i),a;try{a=wn({client:i,facade:o,resource:e,projection:n.projection,target:r,pageSize:s.pageSize,sort:s.sort??null,filters:s.filters??{},search:s.search,searchFields:s.searchFields,label:"ZeyOS view"})}catch(k){throw r.destroy(),k}let l;try{l=$f(s.savedViews,t,e)}catch(k){throw r.destroy(),k}let u=l?.registry??null,d=l?.type??dl(t);if(u){for(let k of["getViewState","setViewState"])if(typeof r?.[k]!="function")throw l?.owned&&u.destroy?.(),r.destroy(),new TypeError(`zeyosView() saved views require ${k}()`)}let h=!1,p=a.load,f=async(k,N={})=>{if(!u||!d)throw new Error("This ZeyOS view binding has no saved-view registry");if(h)throw new Error("ZeyOS view binding has been destroyed");let ee=await u.apply(k,r,{type:d,onQuery:async({filters:Wi,search:ml})=>{h||a.setQuery({filters:qf(Wi),search:ml})}});return!ee.applied||h||(a.setSort(Uf(r,ee.entry)),a.reset(),N.load!==!1&&await p({page:0})),ee},_=async(k={})=>{if(!u)return null;if(await Kf(u),h)throw new Error("ZeyOS view binding has been destroyed");let N=await u.getDefault();return N?f(N.id,k):{status:"missing",applied:!1,entry:null}},m=u?_({load:!1}):Promise.resolve(null),g=!u,b=null;m.then(()=>{g=!0},()=>{});let y=async(k={load:!1})=>{if(g)return null;try{let N=await m;return g=!0,N}catch{}if(!b){let ee=_(k).then(Wi=>(g=!0,Wi)).finally(()=>{b===ee&&(b=null)});b=ee}return b},A=async(k={})=>(a.check(k),await y({load:!1}),p(k)),w=k=>{if(!d||typeof r.getViewState!="function")throw new Error("This view does not expose serializable saved-view state");let N=k&&typeof k=="object"?k:{};return{...N.id==null?{}:{id:String(N.id)},name:String(N.name??""),type:d,state:r.getViewState(),filters:a.filters,search:a.search}},x=async k=>{if(!u||!d)throw new Error("This ZeyOS view binding has no saved-view registry");if(await y({load:!1}),h)throw new Error("ZeyOS view binding has been destroyed");let N=w(k);return await u.capture(r,{...N.id==null?{}:{id:N.id},name:N.name,type:d,filters:N.filters,search:N.search},{onDuplicate:k?.onDuplicate,setDefault:!!k?.setDefault})},C=async(k,N={})=>(await y({load:!1}),f(k,N)),$=async(k={})=>g?_(k):y(k),W=k=>{if(h)return;let N=k.detail?.id;a.setSort(N==null?null:{id:String(N),dir:k.detail.dir==="desc"?"desc":"asc"}),A({page:0}).catch(()=>{})},re={view:r,load:A,setSearch:k=>A({search:k,page:0}),setFilters:k=>A({filters:k,page:0}),loadMore:async()=>(await y({load:!1}),a.loadMore()),get count(){return a.count},get page(){return a.page},get pageSize(){return a.pageSize},get hasMore(){return a.hasMore},savedViews:u,ready:m,restoreDefault:$,captureView:w,saveView:x,applyView:C,destroy:()=>{h||(h=!0,a.destroy(),typeof r.off=="function"?r.off("sortchange",W):r.removeEventListener?.("sortchange",W),l?.owned&&u?.destroy?.(),r.destroy())}};return r.on("sortchange",W),re}function Bf(i,e,t){if(!Array.isArray(t.fields)&&!Array.isArray(t.exclude))return;let s=new Set(Array.isArray(t.exclude)?t.exclude.map(String):[]),n=Array.isArray(t.fields)?t.fields.map(String):Vf(i,e);return[...new Set([...n,...ul(t)])].filter(r=>!s.has(r))}function Vf(i,e){let t=i?.schema?.fields?.(e);return Array.isArray(t)?t.map(s=>typeof s=="string"?s:String(s?.id??s?.name??s?.field??"")).filter(Boolean):t&&typeof t=="object"?Object.keys(t):[]}function ul(i){let e=[];for(let t of["titleField","subtitleField","preview","groupBy","columnBy","swimlaneBy"]){let s=i[t];typeof s=="string"&&s.trim()&&e.push(s.trim())}return[...new Set(e)]}function qf(i){return i&&typeof i=="object"&&!Array.isArray(i)?{...i}:{}}function $f(i,e,t){if(i==null||i===!1)return null;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("savedViews must be a registry or transport/scope configuration");let s=i,n=s.controller??s.registry,r=ll(s)?s:ll(n)?n:null,o=Hf(s.type??dl(e));if(!o)throw new TypeError("savedViews requires a table, card, or kanban presentation type");if(r)return{registry:r,type:o,owned:!1};if(!s.transport||!s.scope||typeof s.scope!="object")throw new TypeError("savedViews requires a controller or injected transport and scope");let a={...s.scope,resource:s.scope.resource??t};return{registry:In(s.transport,a,s.options??{}),type:o,owned:!0}}function ll(i){return!!(i&&typeof i=="object"&&typeof i.apply=="function"&&typeof i.capture=="function"&&typeof i.getDefault=="function")}function dl(i){let e=String(i.cssName??"").toLowerCase().replace(/-view$/,"");if(["table","card","kanban"].includes(e))return e;let t=String(i.name??"").toLowerCase().replace(/view$/,"");return["table","card","kanban"].includes(t)?t:null}function Hf(i){let e=String(i??"").toLowerCase();return["table","card","kanban"].includes(e)?e:null}async function Kf(i){typeof i.ready=="function"?await i.ready():typeof i.load=="function"&&await i.load()}function Uf(i,e){let t=typeof i.getSort=="function"?i.getSort():typeof i.getViewState=="function"?i.getViewState()?.sort:e?.state?.sort;return!t||typeof t!="object"||Array.isArray(t)||t.id==null?null:{id:String(t.id),dir:t.dir==="desc"?"desc":"asc"}}function Yf(i){if(typeof i!="function")throw new TypeError("Legacy saved-view loader must be a function");return e=>new Promise((t,s)=>{i(e,t,(n,r,o)=>{let a=new Error(String(n??"ZeyOS saved-view request failed"));return Object.assign(a,{type:r,info:o}),s(a),!0})})}function Wf(i,e={}){if(typeof i!="function")throw new TypeError("Saved-view request must be a function");let t=hl(e.recordName,"__zx_record_views_v1__","recordName"),s=hl(e.viewPrefix,"zx.record-views:","viewPrefix"),n=e.module==null?"":String(e.module),r=(o,a)=>{let l=Zf(o);return{umi:n,page:a,fork:l.workspaceId,view:`${s}${l.resource}`}};return{async load(o){let a=await i(r(o,"fields")),l=Gf(a,t);if(l==null||l==="")return null;if(typeof l=="string")try{let u=JSON.parse(l);return Yi(u)?u:null}catch{return null}return Yi(l)?fl(l):null},async save(o,a){if(!Yi(a))throw new TypeError("Saved-view document must be an object");let l=fl(a);return await i({...r(o,"fields_save"),name:t,data:JSON.stringify(l)}),l},async remove(o){await i({...r(o,"fields_remove"),name:t})}}}function Zf(i){if(!Yi(i))throw new TypeError("Saved-view scope must be an object");if(i.userId==null||String(i.userId).trim()==="")throw new TypeError("Saved-view scope requires userId");let e=String(i.resource??"").trim();if(!e)throw new TypeError("Saved-view scope requires resource");let t=i.workspaceId==null||i.workspaceId===""?null:i.workspaceId;return{userId:String(i.userId),workspaceId:t,resource:e}}function Gf(i,e){if(!Array.isArray(i)||!Array.isArray(i[0])||!Array.isArray(i[1]))return null;let t=i[0].findIndex(s=>String(s)===e);return t<0?null:i[1][t]}function hl(i,e,t){let s=i==null?e:String(i).trim();if(!s)throw new TypeError(`${t} must not be empty`);return s}function Yi(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function fl(i){pl(i,new Set);try{return JSON.parse(JSON.stringify(i))}catch{throw new TypeError("Saved-view document must be JSON-serializable")}}function pl(i,e){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"&&Number.isFinite(i))return;if(typeof i!="object")throw new TypeError("Saved-view document must be JSON-serializable");if(e.has(i))throw new TypeError("Saved-view document must be JSON-serializable");if(!Array.isArray(i)&&Object.getPrototypeOf(i)!==Object.prototype&&Object.getPrototypeOf(i)!==null)throw new TypeError("Saved-view document must be JSON-serializable");e.add(i);let t=Array.isArray(i)?i:Object.values(i);for(let s of t)pl(s,e);e.delete(i)}export{Df as SAVED_VIEWS_VERSION,rt as SavedViewDuplicateNameError,Ki as SavedViewRegistry,Hi as SavedViewScopeMismatchError,Ra as ZEYOS_ICON_KIT,Wh as ZEYOS_LAUNCHER_APPLICATIONS,lt as buildListQuery,Jh as buildZeyosAppSidebarConfig,Qa as buildZeyosCalendarOptions,qa as buildZeyosEntitySelectConfig,La as buildZeyosLauncherConfig,ja as buildZeyosModuleBarConfig,Mt as buildZeyosSelectConfig,cl as buildZeyosViewConfig,Ot as calendarDayToUnixSeconds,kf as calendarEventToZeyosPatch,ce as connect,Wf as createLegacySavedViewTransport,In as createSavedViewRegistry,_l as dataFilterStateToFilters,ue as dateToUnixSeconds,Qi as fieldToZxColumn,Gi as fieldToZxField,Yf as legacySavedViewRequest,sl as migrateSavedViewDocument,Fa as moduleAliases,st as moduleChip,qh as moduleColor,Uh as moduleGlyphColor,ji as moduleIcon,$h as moduleIconName,X as moduleInfo,Hh as moduleKeys,Pi as normalizeModuleName,vn as normalizeSavedViewDocument,Ui as normalizeSavedViewScope,Pa as normalizeZeyosLauncherApplications,Bi as normalizeZeyosLauncherRecords,V as registerFieldType,Kh as registerModules,ct as resolveFields,Nn as tableSortToQuery,Zi as unixSecondsToCalendarDay,ye as unixSecondsToDate,Yh as useZeyosIcons,Gh as zeyosActiveIdentifier,dn as zeyosAppIcon,Za as zeyosAppointmentToEvent,Ga as zeyosAppointmentsToEvents,zf as zeyosCalendar,sf as zeyosEntitySelect,lf as zeyosForm,Zh as zeyosLauncher,ef as zeyosModuleBar,mn as zeyosModuleItems,Pe as zeyosModules,tf as zeyosSelect,_f as zeyosTable,jf as zeyosView};
9
9
  /*
10
10
  * @license Lucide 1.53.0 (ISC), including icons derived from Feather (MIT) — notices below.
11
11
  *