@zeyos/zx 5.5.0 → 5.6.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 (48) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/types/components/agent-thread/agent-thread.d.ts +583 -0
  3. package/dist/types/components/approval-card/approval-card.d.ts +596 -0
  4. package/dist/types/components/avatar/avatar.d.ts +91 -4
  5. package/dist/types/components/block-view/block-view.d.ts +205 -0
  6. package/dist/types/components/composer/composer.d.ts +736 -0
  7. package/dist/types/components/run-status/run-status.d.ts +393 -0
  8. package/dist/types/components/run-trace/run-trace.d.ts +624 -0
  9. package/dist/types/components/source-list/source-list.d.ts +177 -0
  10. package/dist/types/core/messages.d.ts +135 -0
  11. package/dist/types/index.d.ts +8 -0
  12. package/dist/types/internal/agent-model.d.ts +587 -0
  13. package/dist/types/internal/highlight.d.ts +24 -0
  14. package/dist/types/internal/presence-loop.d.ts +148 -0
  15. package/dist/zx-zeyos.esm.js +4648 -4513
  16. package/dist/zx-zeyos.esm.min.js +2 -2
  17. package/dist/zx.css +1927 -1
  18. package/dist/zx.esm.js +15769 -9194
  19. package/dist/zx.esm.min.js +27 -8
  20. package/dist/zx.global.js +15769 -9194
  21. package/dist/zx.global.min.js +27 -8
  22. package/dist/zx.min.css +1 -1
  23. package/docs/api.json +1166 -5
  24. package/docs/llms.md +455 -2
  25. package/docs/llms.txt +10 -1
  26. package/package.json +1 -1
  27. package/src/components/agent-thread/agent-thread.css +417 -0
  28. package/src/components/agent-thread/agent-thread.js +1365 -0
  29. package/src/components/approval-card/approval-card.css +289 -0
  30. package/src/components/approval-card/approval-card.js +1377 -0
  31. package/src/components/avatar/avatar.css +56 -1
  32. package/src/components/avatar/avatar.js +148 -26
  33. package/src/components/block-view/block-view.css +300 -0
  34. package/src/components/block-view/block-view.js +523 -0
  35. package/src/components/composer/composer.css +403 -0
  36. package/src/components/composer/composer.js +1441 -0
  37. package/src/components/run-status/run-status.css +208 -0
  38. package/src/components/run-status/run-status.js +782 -0
  39. package/src/components/run-trace/run-trace.css +443 -0
  40. package/src/components/run-trace/run-trace.js +1209 -0
  41. package/src/components/source-list/source-list.css +208 -0
  42. package/src/components/source-list/source-list.js +355 -0
  43. package/src/core/messages.js +143 -0
  44. package/src/index.js +8 -0
  45. package/src/internal/agent-model.js +488 -0
  46. package/src/internal/highlight.js +104 -0
  47. package/src/internal/presence-loop.js +343 -0
  48. package/styles/zx.css +7 -0
@@ -1,11 +1,11 @@
1
- function de(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 ve(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 Qi(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}=ct(e).dayOf(t*1e3);return Fn(s,n,r)}function Rt(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=ct(e).midnightOf(i.getFullYear(),i.getMonth(),i.getDate());return Math.floor(t/1e3)}function Lt(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 ct(i){let e=Lt(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)=>Fn(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 On(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=On(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 Fn(i,e,t){let s=new Date(2e3,0,1);return s.setFullYear(i,e,t),s.setHours(0,0,0,0),s}function On(i,e,t){let s=new Date(0);return s.setUTCFullYear(i,e,t),s.getTime()}function Rn(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 Sl(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?Lt(t.timeZone):void 0,r=Al(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):kl(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 ut(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=zl(t,e),f=Rn(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 Al(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 kl(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 Rt(r,t.timeZone);let o=typeof r=="string"?/^(\d{4})-(\d{2})-(\d{2})$/.exec(r.trim()):null;if(o){let a=ct(t.timeZone).midnightOf(Number(o[1]),Number(o[2])-1,Number(o[3]));return Math.floor(a/1e3)}return r}return r instanceof Date?de(r):r};return Array.isArray(i)?i.map(n):n(i)}function zl(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 Bt=Object.create(null),Cl=new Set(["date","duedate","birthdate","datefrom","dateto","datecancel","lastbilling"]),Ln=new Set(["appointments.datefrom","appointments.dateto","events.datefrom","events.dateto","comments.date","documentversions.date","records.date"]),Dl=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"}),El=Object.freeze({0:"Lowest",1:"Low",2:"Medium",3:"High",4:"Highest"}),Il=/^[A-Z][A-Z\d]*(?:_[A-Z\d]+)*$/,Pn=new Set;function q(i,e){let t=jt(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 Bt[t]=e,e}function Xi(i){let e=$n(i),t=qn(e),s=Hn(t.field,e),n={id:e.id,type:"text",label:Kn(e),...s};return e.description!=null&&(n.description=String(e.description)),(e.required===!0||e.nullable===!1)&&(n.required=!0),Hl(e)&&(n.readonly=!0,n.disabled=!0,n.props={...n.props??{},readOnly:!0}),n}function Ji(i){let e=$n(i),t=qn(e);return{id:e.id,label:Kn(e),sortable:e.sortable!==!1,...Hn(t.column,e)}}function dt(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=jn(n?.fields),o=jn(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=Lt(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??Ul(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 Bn={field:{type:"text"},column:{}},Tl={field:{type:"int"},column:{align:"right"}},Ml={field:{type:"float"},column:i=>({align:"right",render:Zn(i)})},Nl={field:{type:"float"},column:i=>({align:"right",render:Zn(i,!0)})},Ol={field:i=>({type:"zxselect",props:{entity:Un(i)}}),column:i=>({render:e=>Xl(he(e,i),e,i)})},Fl={field:{type:"toggle"},column:i=>({align:"center",render:e=>he(e,i)?"\u2713":"",sortValue:e=>+!!he(e,i)})},Rl={field:i=>({type:Yl(i),options:es(i)}),column:i=>({render:Wn(i)})},Ll={field:{type:"zxselect",props:{preset:"priority"}},column:i=>({render:Wn(i,El)})},Pl={field:{type:"float",props:{min:0,max:100}},column:i=>({align:"right",render:e=>Wl(he(e,i)),sortValue:e=>Vt(he(e,i))})},jl=Vn("date"),Bl=Vn("datetime");for(let i of["string","text","character","character varying","varchar","email","tel","url","uri"])q(i,Bn);for(let i of["integer","smallint","bigint","int","int2","int4","int8","int32","int64"])q(i,Tl);for(let i of["number","numeric","decimal","real","double","double precision","float"])q(i,Ml);for(let i of["money","currency","price","pricebilling","priceprocurement","priceproduction"])q(i,Nl);for(let i of["entity","t_entity"])q(i,Ol);for(let i of["boolean","checked"])q(i,Fl);for(let i of["list","enum"])q(i,Rl);for(let i of["progress","percent"])q(i,Pl);for(let i of["date"])q(i,jl);for(let i of["datetime","date-time"])q(i,Bl);q("priority",Ll);q("text[]",{field:{type:"valuelist"},column:{}});q("json",{field:{type:"textarea"},column:{}});q("longtext",{field:{type:"textarea"},column:{}});for(let i of["email","tel","url","uri"])q(i,{field:{type:"text",props:{type:i==="uri"?"url":i}},column:{}});function Vn(i){return{field:{type:i},column:e=>{let t=i==="datetime"?Zl():Gl(e.timeZone);return{render:s=>t(he(s,e)),sortValue:s=>Ql(he(s,e))}}}}function qn(i){let e=Vl(i),t=Bt[e];return t||(Pn.has(e)||(Pn.add(e),console.warn(`[zx.zeyos] Unknown field type or format "${e||"unknown"}" for "${i.id}"; using text.`)),Bn)}function Vl(i){let e=jt(i.format??i.semanticFormat??i.semanticType??i.widget);if(e&&Bt[e])return e;if(Un(i)||jt(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=jt(i.type);if(t==="bigint"||t==="int64"){let s=ql(i);if(s)return s}return Kl(i,t)?"longtext":t&&Bt[t]?t:t.endsWith("[]")?"text[]":t==="json"||t==="jsonb"?"json":/^character varying(?:\(\d+\))?$/.test(t)?"character varying":t||e}function ql(i){let e=String(i.id).toLowerCase(),t=String(i.resource??"").toLowerCase();return Cl.has(e)&&!Ln.has(`${t}.${e}`)&&(e!=="date"||i.indexed)?"date":Ln.has(`${t}.${e}`)||/(?:date|time)$|^lastmodified$/.test(e)?"datetime":null}function $n(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 Hn(i,e){let t=typeof i=="function"?i(e):i;return t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}function jt(i){return String(i??"").trim().toLowerCase().replace(/\s+/g," ")}function Kn(i){let e=i.label??i.title??i.displayName;return e==null||e===""?$l(i.id):String(e)}function $l(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 Hl(i){return i.readonly===!0||i.readOnly===!0||i.writable===!1||i.mutable===!1}function Kl(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 Un(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 jn(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 Ul(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 es(i){return Yn(i.enums??i.enum??i.options)}function Yn(i){if(typeof i=="string")try{return Yn(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),Pt(n)]}if(e&&typeof e=="object"){let s=e.value??e.id??t;return[String(s),e.label!=null?String(e.label):Pt(e.name??s)]}return[String(t),Pt(e)]})):i&&typeof i=="object"?Object.fromEntries(Object.entries(i).map(([e,t])=>[e,Pt(t)])):{}}function Pt(i){let e=String(i??"");if(!Il.test(e))return e;let t=e.split("_").map(s=>Dl[s]??s.toLowerCase()).join(" ");return t.charAt(0).toUpperCase()+t.slice(1)}function Yl(i){return Object.keys(es(i)).length<=5?"optionlist":"select"}function Wn(i,e={}){let t={...e,...es(i)};return s=>{let n=he(s,i);return n==null?"":t[String(n)]??String(n)}}function Zn(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=Vt(he(s,i));return n==null?"":t.format(n)}}function Vt(i){if(i==null||i==="")return null;let e=Number(i);return Number.isFinite(e)?e:null}function Wl(i){let e=Vt(i);return e==null?"":`${new Intl.NumberFormat().format(e)}%`}function Zl(){let i=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"});return e=>{let t=Gn(e);return t?i.format(t):""}}function Gl(i){let e=ct(i??void 0),t=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"});return s=>{let n=Gn(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 Gn(i){if(i==null||i==="")return null;try{let e=i instanceof Date?i:ve(i);return e&&Number.isFinite(e.getTime())?e:null}catch{return null}}function Ql(i){return i instanceof Date?de(i):Vt(i)}function he(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 Xl(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 Qn=0;function I(i="zx"){return Qn+=1,`${i}-${Date.now().toString(36)}-${Qn.toString(36)}`}function Ve(i,e){let t=ht(i)?Xn(i):{};if(!ht(e))return qt(e);for(let[s,n]of Object.entries(e))ht(n)&&ht(t[s])?t[s]=Ve(t[s],n):t[s]=qt(n);return t}function L(i){return!!(i&&typeof i=="object"&&i.nodeType===1)}function xe(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 ft(i,e,t){return Math.min(t,Math.max(e,i))}function ts(i){return String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ht(i){if(i===null||typeof i!="object")return!1;let e=Object.getPrototypeOf(i);return e===Object.prototype||e===null}function Xn(i){let e={};for(let[t,s]of Object.entries(i))e[t]=qt(s);return e}function qt(i){return ht(i)?Xn(i):Array.isArray(i)?i.map(qt):i}var pt=null;function qe(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;Jl(n)||(t.unshift(n),n={});for(let[r,o]of Object.entries(n))ec(s,r,o);return ic(s,t),s}c.scope=function(e,t){let s=pt;pt=e;try{return t()}finally{pt=s}};c.raw=function(e){let t=document.createElement("template");return t.innerHTML=String(e),t.content};function K(i){return{children:Array.from(i.childNodes),attributes:Array.from(i.attributes,e=>[e.name,e.value])}}function U(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 Y(i){if(i==null)return null;if(L(i))return i;if(typeof i=="string")return document.querySelector(i);if(typeof i.toElement=="function"){let e=i.toElement();return L(e)?e:null}return null}function Jl(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 ec(i,e,t){if(e==="ref"){pt&&typeof t=="string"&&(pt[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=tc(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 tc(i){return i.startsWith("aria-")?i:/^aria[A-Z]/.test(i)?"aria-"+i.slice(4).toLowerCase():null}function ic(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 $t=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"}),is=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 Jn=null,er="en";function ss(i){er=String(i||"en")}function fe(){return er}function mt(i){if(!Jn)return null;let e=Jn(i);if(e==null)return null;let t=String(e);return t===i?null:t}function ns(i){return Object.prototype.hasOwnProperty.call($t,i)?$t[i]:null}function rs(i){return Object.prototype.hasOwnProperty.call(is,i)?is[i]:null}function Se(i,e){let t=rs(i),s=mt(i)??(t?mt(t):null)??ns(i)??i;return F(s,e)}function F(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 Ht=new WeakMap,tr=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=Y(e);if(e!==null&&!n)throw new TypeError("Component target could not be resolved");this.el=n,this.refs={};let r=sc(s,t);tr.set(this,{own:as(t?.msg)?Object.freeze(Ve({},t.msg)):null,inherited:nc(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=L(a)?a:this.el;if(!L(u))throw this.#e.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=u}if(!L(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)}Ht.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=ir(e,t,{cancelable:!0});if(this.dispatchEvent(n),this.el){let r=ir(`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??fe(),n=rs(e),r=tr.get(this)??{own:as(this.options?.msg)?this.options.msg:null,inherited:null},o=r.own,a=os(o,s,e)??(n?os(o,s,n):null)??mt(e)??(n?mt(n):null)??os(r.inherited,s,e)??ns(e)??e;return F(a,t)}destroy(){if(this.#i)return;this.#i=!0,this.#e.abort(),Ht.get(this.el)===this&&Ht.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 Ht.get(e)??null}};function sc(i,e){let t=sr(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=Ve(n,o.msg)));return Object.assign(s,e&&typeof e=="object"?e:{}),e?.msg&&typeof e.msg=="object"&&(r=!0,n=Ve(n,e.msg)),r&&(s.msg=n),s}function sr(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 as(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function nc(i){let e=null;for(let t of sr(i))t&&typeof t=="object"&&as(t.msg)&&(e=Ve(e??{},t.msg));return e?Object.freeze(e):null}function os(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 ir(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 C=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=lc(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):I("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=oc(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=rr(g,this.controlId)}else{let m=this.msg("field.unknown",t);console.warn(`[zx.Field] ${m}`),this.adapter=rr(m,this.controlId)}let f=this.adapter.el;f.id||(f.id=this.controlId);let _=this.adapter.labelTarget??(Kt(f)?f:ac(f))??f;return this._labelled=_,_!==f&&Kt(_)&&!_.id&&(_.id=`${this.controlId}-input`),a.htmlFor=Kt(_)?_.id:f.id,Kt(_)||_.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=rc(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();cc(this.el,this._rootAttributes??new Map),super.destroy()}};function ls(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=ar(e);return t!==null&&Number.isInteger(t)?{valid:!0,value:t}:{valid:!1,value:e}}function cs(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=ar(e);return t!==null?{valid:!0,value:t}:{valid:!1,value:e}}function ar(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)||!nr(h,u))return null;o=h.split(u).join("")+"."+p}else if(r.length>1||n.length>1){let l=r.length?",":".";if(!nr(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 nr(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 rc(i,e){return e!==void 0?e:i==="checkbox"?!1:""}function oc(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 rr(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 Kt(i){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(i.tagName)}function ac(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 lc(i,e){return new Map(e.map(t=>[t,i.getAttribute(t)]))}function cc(i,e){for(let[t,s]of e)s===null?i.removeAttribute(t):i.setAttribute(t,s)}function _t(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 Ut(i,e){return(t,s)=>{let n=c(i,_t(t,s,{type:i==="input"?e:void 0,placeholder:s.placeholder,required:s.required,disabled:s.disabled}));return{...us(n),setReadonly:r=>{n.readOnly=r}}}}function us(i){return{el:i,get:()=>i.value,set:e=>{i.value=e==null?"":String(e)},focus:()=>i.focus(),setDisabled:e=>{i.disabled=e}}}function lr(i){return(e,t)=>{let s=i==="int"?ls:cs,n=c("input",_t(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()}),{...us(n),get:()=>s(n.value).value,setReadonly:r=>{n.readOnly=r}}}}var uc=(i,e)=>{let t=c("input",_t(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}}},dc=(i,e)=>{let t=c("select",_t(i,e,{required:e.required,disabled:e.disabled}));for(let[s,n]of cr(e.options))t.append(c("option",{value:s},n));return us(t)},hc=(i,e)=>{let t=c("div",{class:"zx-field__option-list",role:"radiogroup"}),s=i.controlId,n=cr(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))}}},fc=(i,e)=>{let t=c("div",_t(i,e,{class:"zx-field__static",name:void 0})),s=null;return{el:t,get:()=>t.textContent,set:r=>{or(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:()=>or(s)}};function or(i){i&&(i.parent?i.parent.insertBefore(i.node,i.next?.parentNode===i.parent?i.next:null):i.node.remove())}var pc=(i,e)=>{if(typeof e.adapter!="function")throw new TypeError("Custom fields require options.adapter");return e.adapter(i,e)};function cr(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)]):[]}C.register("text",Ut("input","text"));C.register("password",Ut("input","password"));C.register("textarea",Ut("textarea","text"));C.register("checkbox",uc);C.register("int",lr("int"));C.register("float",lr("float"));C.register("select",dc);C.register("optionlist",hc);C.register("hidden",Ut("input","hidden"));C.register("html",fc);C.register("custom",pc);function Ae(i,e,t){let s=ur(e).split(/\s+/).filter(Boolean);return s.length===0?i.slice():i.filter(n=>{let r=mc(n,t).map(ur);return s.every(o=>r.some(a=>a.includes(o)))})}function mc(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 ur(i){return String(i??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var Yt=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=I("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=Ae(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=Ae(this._items,this._query,[this.options.labelKey]),this._renderItems()}_renderItems(){if(!this.refs.list)return;let e=this._visibleItems.map((t,s)=>{let n=I("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){_c(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 _c(i,e){return i.size===e.size&&Array.from(i).every(t=>e.has(t))}function dr(){C.register("checklist",(i,e)=>{let t=i.own(new Yt(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 gc=new Set(["Shift","Control","Alt","Meta","AltGraph","CapsLock","Fn","OS"]),Wt=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=hr(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:vc(this.options.rows),wrap:xc(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=hr(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||gc.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=bc(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=yc(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 bc(i,e,t,s=" ",n=!1){let r=String(i??""),o=String(s??""),a=Zt(e,r.length),l=Zt(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(`
1
+ function de(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 ve(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 Qi(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}=ct(e).dayOf(t*1e3);return Fn(s,n,r)}function Rt(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=ct(e).midnightOf(i.getFullYear(),i.getMonth(),i.getDate());return Math.floor(t/1e3)}function Lt(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 ct(i){let e=Lt(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)=>Fn(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 On(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=On(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 Fn(i,e,t){let s=new Date(2e3,0,1);return s.setFullYear(i,e,t),s.setHours(0,0,0,0),s}function On(i,e,t){let s=new Date(0);return s.setUTCFullYear(i,e,t),s.getTime()}function Rn(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 Sl(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?Lt(t.timeZone):void 0,r=Al(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):kl(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 ut(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=Cl(t,e),f=Rn(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 Al(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 kl(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 Rt(r,t.timeZone);let o=typeof r=="string"?/^(\d{4})-(\d{2})-(\d{2})$/.exec(r.trim()):null;if(o){let a=ct(t.timeZone).midnightOf(Number(o[1]),Number(o[2])-1,Number(o[3]));return Math.floor(a/1e3)}return r}return r instanceof Date?de(r):r};return Array.isArray(i)?i.map(n):n(i)}function Cl(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 Bt=Object.create(null),zl=new Set(["date","duedate","birthdate","datefrom","dateto","datecancel","lastbilling"]),Ln=new Set(["appointments.datefrom","appointments.dateto","events.datefrom","events.dateto","comments.date","documentversions.date","records.date"]),Tl=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"}),Dl=Object.freeze({0:"Lowest",1:"Low",2:"Medium",3:"High",4:"Highest"}),El=/^[A-Z][A-Z\d]*(?:_[A-Z\d]+)*$/,Pn=new Set;function q(i,e){let t=jt(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 Bt[t]=e,e}function Xi(i){let e=$n(i),t=qn(e),s=Hn(t.field,e),n={id:e.id,type:"text",label:Kn(e),...s};return e.description!=null&&(n.description=String(e.description)),(e.required===!0||e.nullable===!1)&&(n.required=!0),Hl(e)&&(n.readonly=!0,n.disabled=!0,n.props={...n.props??{},readOnly:!0}),n}function Ji(i){let e=$n(i),t=qn(e);return{id:e.id,label:Kn(e),sortable:e.sortable!==!1,...Hn(t.column,e)}}function dt(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=jn(n?.fields),o=jn(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=Lt(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??Ul(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 Bn={field:{type:"text"},column:{}},Il={field:{type:"int"},column:{align:"right"}},Ml={field:{type:"float"},column:i=>({align:"right",render:Zn(i)})},Nl={field:{type:"float"},column:i=>({align:"right",render:Zn(i,!0)})},Ol={field:i=>({type:"zxselect",props:{entity:Un(i)}}),column:i=>({render:e=>Xl(he(e,i),e,i)})},Fl={field:{type:"toggle"},column:i=>({align:"center",render:e=>he(e,i)?"\u2713":"",sortValue:e=>+!!he(e,i)})},Rl={field:i=>({type:Yl(i),options:es(i)}),column:i=>({render:Wn(i)})},Ll={field:{type:"zxselect",props:{preset:"priority"}},column:i=>({render:Wn(i,Dl)})},Pl={field:{type:"float",props:{min:0,max:100}},column:i=>({align:"right",render:e=>Wl(he(e,i)),sortValue:e=>Vt(he(e,i))})},jl=Vn("date"),Bl=Vn("datetime");for(let i of["string","text","character","character varying","varchar","email","tel","url","uri"])q(i,Bn);for(let i of["integer","smallint","bigint","int","int2","int4","int8","int32","int64"])q(i,Il);for(let i of["number","numeric","decimal","real","double","double precision","float"])q(i,Ml);for(let i of["money","currency","price","pricebilling","priceprocurement","priceproduction"])q(i,Nl);for(let i of["entity","t_entity"])q(i,Ol);for(let i of["boolean","checked"])q(i,Fl);for(let i of["list","enum"])q(i,Rl);for(let i of["progress","percent"])q(i,Pl);for(let i of["date"])q(i,jl);for(let i of["datetime","date-time"])q(i,Bl);q("priority",Ll);q("text[]",{field:{type:"valuelist"},column:{}});q("json",{field:{type:"textarea"},column:{}});q("longtext",{field:{type:"textarea"},column:{}});for(let i of["email","tel","url","uri"])q(i,{field:{type:"text",props:{type:i==="uri"?"url":i}},column:{}});function Vn(i){return{field:{type:i},column:e=>{let t=i==="datetime"?Zl():Gl(e.timeZone);return{render:s=>t(he(s,e)),sortValue:s=>Ql(he(s,e))}}}}function qn(i){let e=Vl(i),t=Bt[e];return t||(Pn.has(e)||(Pn.add(e),console.warn(`[zx.zeyos] Unknown field type or format "${e||"unknown"}" for "${i.id}"; using text.`)),Bn)}function Vl(i){let e=jt(i.format??i.semanticFormat??i.semanticType??i.widget);if(e&&Bt[e])return e;if(Un(i)||jt(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=jt(i.type);if(t==="bigint"||t==="int64"){let s=ql(i);if(s)return s}return Kl(i,t)?"longtext":t&&Bt[t]?t:t.endsWith("[]")?"text[]":t==="json"||t==="jsonb"?"json":/^character varying(?:\(\d+\))?$/.test(t)?"character varying":t||e}function ql(i){let e=String(i.id).toLowerCase(),t=String(i.resource??"").toLowerCase();return zl.has(e)&&!Ln.has(`${t}.${e}`)&&(e!=="date"||i.indexed)?"date":Ln.has(`${t}.${e}`)||/(?:date|time)$|^lastmodified$/.test(e)?"datetime":null}function $n(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 Hn(i,e){let t=typeof i=="function"?i(e):i;return t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}function jt(i){return String(i??"").trim().toLowerCase().replace(/\s+/g," ")}function Kn(i){let e=i.label??i.title??i.displayName;return e==null||e===""?$l(i.id):String(e)}function $l(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 Hl(i){return i.readonly===!0||i.readOnly===!0||i.writable===!1||i.mutable===!1}function Kl(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 Un(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 jn(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 Ul(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 es(i){return Yn(i.enums??i.enum??i.options)}function Yn(i){if(typeof i=="string")try{return Yn(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),Pt(n)]}if(e&&typeof e=="object"){let s=e.value??e.id??t;return[String(s),e.label!=null?String(e.label):Pt(e.name??s)]}return[String(t),Pt(e)]})):i&&typeof i=="object"?Object.fromEntries(Object.entries(i).map(([e,t])=>[e,Pt(t)])):{}}function Pt(i){let e=String(i??"");if(!El.test(e))return e;let t=e.split("_").map(s=>Tl[s]??s.toLowerCase()).join(" ");return t.charAt(0).toUpperCase()+t.slice(1)}function Yl(i){return Object.keys(es(i)).length<=5?"optionlist":"select"}function Wn(i,e={}){let t={...e,...es(i)};return s=>{let n=he(s,i);return n==null?"":t[String(n)]??String(n)}}function Zn(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=Vt(he(s,i));return n==null?"":t.format(n)}}function Vt(i){if(i==null||i==="")return null;let e=Number(i);return Number.isFinite(e)?e:null}function Wl(i){let e=Vt(i);return e==null?"":`${new Intl.NumberFormat().format(e)}%`}function Zl(){let i=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"});return e=>{let t=Gn(e);return t?i.format(t):""}}function Gl(i){let e=ct(i??void 0),t=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"});return s=>{let n=Gn(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 Gn(i){if(i==null||i==="")return null;try{let e=i instanceof Date?i:ve(i);return e&&Number.isFinite(e.getTime())?e:null}catch{return null}}function Ql(i){return i instanceof Date?de(i):Vt(i)}function he(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 Xl(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 Qn=0;function E(i="zx"){return Qn+=1,`${i}-${Date.now().toString(36)}-${Qn.toString(36)}`}function Ve(i,e){let t=ht(i)?Xn(i):{};if(!ht(e))return qt(e);for(let[s,n]of Object.entries(e))ht(n)&&ht(t[s])?t[s]=Ve(t[s],n):t[s]=qt(n);return t}function L(i){return!!(i&&typeof i=="object"&&i.nodeType===1)}function xe(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 ft(i,e,t){return Math.min(t,Math.max(e,i))}function ts(i){return String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ht(i){if(i===null||typeof i!="object")return!1;let e=Object.getPrototypeOf(i);return e===Object.prototype||e===null}function Xn(i){let e={};for(let[t,s]of Object.entries(i))e[t]=qt(s);return e}function qt(i){return ht(i)?Xn(i):Array.isArray(i)?i.map(qt):i}var pt=null;function qe(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;Jl(n)||(t.unshift(n),n={});for(let[r,o]of Object.entries(n))ec(s,r,o);return ic(s,t),s}c.scope=function(e,t){let s=pt;pt=e;try{return t()}finally{pt=s}};c.raw=function(e){let t=document.createElement("template");return t.innerHTML=String(e),t.content};function K(i){return{children:Array.from(i.childNodes),attributes:Array.from(i.attributes,e=>[e.name,e.value])}}function U(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 Y(i){if(i==null)return null;if(L(i))return i;if(typeof i=="string")return document.querySelector(i);if(typeof i.toElement=="function"){let e=i.toElement();return L(e)?e:null}return null}function Jl(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 ec(i,e,t){if(e==="ref"){pt&&typeof t=="string"&&(pt[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=tc(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 tc(i){return i.startsWith("aria-")?i:/^aria[A-Z]/.test(i)?"aria-"+i.slice(4).toLowerCase():null}function ic(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 $t=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","agent.activity.blocked":"Blocked","agent.activity.idle":"Idle","agent.activity.needsYou":"Needs you","agent.activity.offline":"Offline","agent.activity.thinking":"Thinking","agent.activity.working":"Working","agent.status.done":"Done","agent.status.failed":"Failed","agent.status.paused":"Paused","agent.status.queued":"Not started","agent.status.running":"Running","agent.status.skipped":"Skipped","agent.status.stopped":"Stopped","agent.status.waiting":"Waiting for you","agent.status.blocked":"Blocked","agentThread.agent":"Agent","agentThread.answered":"%1 answered","agentThread.attachments":"Attachments","agentThread.branch":"Branch into a new conversation","agentThread.copy":"Copy answer","agentThread.label":"Conversation","agentThread.latest":"Jump to latest","agentThread.needsApproval":"%1 needs your approval","agentThread.nextVersion":"Next version","agentThread.previousVersion":"Previous version","agentThread.rateDown":"Not helpful","agentThread.rateUp":"Helpful","agentThread.regenerate":"Regenerate answer","agentThread.sources":"Sources","agentThread.stopped":"Stopped","agentThread.stoppedAnnounce":"Stopped","agentThread.version":"Version %1 of %2","agentThread.via":"via %1","agentThread.working":"%1 is working","agentThread.writing":"%1 is writing an answer","agentThread.you":"You","agentThread.writingNow":"%1 is writing\u2026","agentThread.edit":"Edit message","agentThread.copyMessage":"Copy message","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","approvalCard.approve":"Approve","approvalCard.approvedBy":"Approved by %1 at %2","approvalCard.approvedByUndated":"Approved by %1","approvalCard.cancel":"Cancel","approvalCard.edit":"Edit","approvalCard.editTitle":"Edit the request","approvalCard.editedBy":"Edited by %1","approvalCard.expiredAt":"Expired at %1","approvalCard.expiredUndated":"Expired without an answer","approvalCard.paused":"The run is paused until you answer.","approvalCard.preview":"Preview","approvalCard.reason":"Reason","approvalCard.reasonLabel":"Why not?","approvalCard.reasonMissing":"Say why, so the agent can do better next time.","approvalCard.reasonOptional":"Optional. Your reason stays with the request.","approvalCard.reasonRequired":"Your reason stays with the request.","approvalCard.reject":"Reject","approvalCard.rejectTitle":"Reject the request?","approvalCard.rejectedBy":"Rejected by %1 at %2","approvalCard.rejectedByUndated":"Rejected by %1","approvalCard.required":"Fill this in to save.","approvalCard.save":"Save changes","approvalCard.status.approved":"Approved","approvalCard.status.expired":"Expired","approvalCard.status.pending":"Waiting for you","approvalCard.status.rejected":"Rejected","approvalCard.you":"you","blockView.cite":"Source %1","blockView.citeTitled":"Source %1: %2","blockView.code":"Code","blockView.copyCode":"Copy code","blockView.document":"Document","blockView.stopped":"Stopped here.","blockView.table":"Table","blockView.version":"1 version","blockView.versions":"%1 versions","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","composer.attach":"Attach files","composer.attachments":"Attachments","composer.commands":"Commands","composer.commandsPlaceholder":"Search commands","composer.context":"Context","composer.drop":"Drop files to attach","composer.label":"Message","composer.match":"1 suggestion","composer.matches":"%1 suggestions","composer.remove":"Remove %1","composer.send":"Send","composer.stop":"Stop","composer.suggestions":"Suggestions","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","runStatus.cost":"%1 of %2","runStatus.costLabel":"Cost","runStatus.dateTimeFormat":"%e %b, %H:%M","runStatus.failedAt":"Failed at","runStatus.finished":"Finished","runStatus.model":"Model","runStatus.started":"Started","runStatus.steps":"%1 of %2 steps","runStatus.stepsLabel":"Steps done","runStatus.stoppedAt":"Stopped at","runStatus.timeFormat":"%H:%M","runStatus.tokens":"Tokens","runStatus.tokensValue":"%1 in \xB7 %2 out","runStatus.waitingSince":"Waiting since","runStatus.workingTime":"Working time","runStatus.blockedSince":"Blocked since","runStatus.tokenBudget":"%1 of %2 tokens","runTrace.arguments":"Arguments","runTrace.awaiting":"Waiting for the result\u2026","runTrace.call":"1 tool call","runTrace.calls":"%1 tool calls","runTrace.copied":"Copied","runTrace.copyArguments":"Copy arguments","runTrace.copyError":"Copy error","runTrace.copyResult":"Copy result","runTrace.doing":"%1\u2026","runTrace.error":"Error","runTrace.failedAfter":"Failed after %1","runTrace.handoff":"%1 handed over to %2","runTrace.label":"Steps","runTrace.result":"Result","runTrace.retried":"Retried","runTrace.retries":"%1 retries","runTrace.retry":"1 retry","runTrace.showAll":"Show all","runTrace.source":"1 source","runTrace.sources":"%1 sources","runTrace.step":"1 step","runTrace.steps":"%1 steps","runTrace.stoppedAfter":"Stopped after %1","runTrace.worked":"Worked for %1","runTrace.working":"Working\u2026","runTrace.blockedAfter":"Blocked after %1","runTrace.token":"1 token","runTrace.tokens":"%1 tokens","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","sourceList.label":"Sources","sourceList.source":"Source","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"}),is=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 Jn=null,er="en";function ss(i){er=String(i||"en")}function fe(){return er}function mt(i){if(!Jn)return null;let e=Jn(i);if(e==null)return null;let t=String(e);return t===i?null:t}function ns(i){return Object.prototype.hasOwnProperty.call($t,i)?$t[i]:null}function rs(i){return Object.prototype.hasOwnProperty.call(is,i)?is[i]:null}function Se(i,e){let t=rs(i),s=mt(i)??(t?mt(t):null)??ns(i)??i;return F(s,e)}function F(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 Ht=new WeakMap,tr=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=Y(e);if(e!==null&&!n)throw new TypeError("Component target could not be resolved");this.el=n,this.refs={};let r=sc(s,t);tr.set(this,{own:as(t?.msg)?Object.freeze(Ve({},t.msg)):null,inherited:nc(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=L(a)?a:this.el;if(!L(u))throw this.#e.abort(),new TypeError("render() must return an Element (or assign this.el) when target is null");this.el=u}if(!L(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)}Ht.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=ir(e,t,{cancelable:!0});if(this.dispatchEvent(n),this.el){let r=ir(`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??fe(),n=rs(e),r=tr.get(this)??{own:as(this.options?.msg)?this.options.msg:null,inherited:null},o=r.own,a=os(o,s,e)??(n?os(o,s,n):null)??mt(e)??(n?mt(n):null)??os(r.inherited,s,e)??ns(e)??e;return F(a,t)}destroy(){if(this.#i)return;this.#i=!0,this.#e.abort(),Ht.get(this.el)===this&&Ht.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 Ht.get(e)??null}};function sc(i,e){let t=sr(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=Ve(n,o.msg)));return Object.assign(s,e&&typeof e=="object"?e:{}),e?.msg&&typeof e.msg=="object"&&(r=!0,n=Ve(n,e.msg)),r&&(s.msg=n),s}function sr(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 as(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function nc(i){let e=null;for(let t of sr(i))t&&typeof t=="object"&&as(t.msg)&&(e=Ve(e??{},t.msg));return e?Object.freeze(e):null}function os(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 ir(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=lc(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=oc(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=rr(g,this.controlId)}else{let m=this.msg("field.unknown",t);console.warn(`[zx.Field] ${m}`),this.adapter=rr(m,this.controlId)}let f=this.adapter.el;f.id||(f.id=this.controlId);let _=this.adapter.labelTarget??(Kt(f)?f:ac(f))??f;return this._labelled=_,_!==f&&Kt(_)&&!_.id&&(_.id=`${this.controlId}-input`),a.htmlFor=Kt(_)?_.id:f.id,Kt(_)||_.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=rc(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();cc(this.el,this._rootAttributes??new Map),super.destroy()}};function ls(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=ar(e);return t!==null&&Number.isInteger(t)?{valid:!0,value:t}:{valid:!1,value:e}}function cs(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=ar(e);return t!==null?{valid:!0,value:t}:{valid:!1,value:e}}function ar(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)||!nr(h,u))return null;o=h.split(u).join("")+"."+p}else if(r.length>1||n.length>1){let l=r.length?",":".";if(!nr(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 nr(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 rc(i,e){return e!==void 0?e:i==="checkbox"?!1:""}function oc(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 rr(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 Kt(i){return["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"].includes(i.tagName)}function ac(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 lc(i,e){return new Map(e.map(t=>[t,i.getAttribute(t)]))}function cc(i,e){for(let[t,s]of e)s===null?i.removeAttribute(t):i.setAttribute(t,s)}function _t(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 Ut(i,e){return(t,s)=>{let n=c(i,_t(t,s,{type:i==="input"?e:void 0,placeholder:s.placeholder,required:s.required,disabled:s.disabled}));return{...us(n),setReadonly:r=>{n.readOnly=r}}}}function us(i){return{el:i,get:()=>i.value,set:e=>{i.value=e==null?"":String(e)},focus:()=>i.focus(),setDisabled:e=>{i.disabled=e}}}function lr(i){return(e,t)=>{let s=i==="int"?ls:cs,n=c("input",_t(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()}),{...us(n),get:()=>s(n.value).value,setReadonly:r=>{n.readOnly=r}}}}var uc=(i,e)=>{let t=c("input",_t(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}}},dc=(i,e)=>{let t=c("select",_t(i,e,{required:e.required,disabled:e.disabled}));for(let[s,n]of cr(e.options))t.append(c("option",{value:s},n));return us(t)},hc=(i,e)=>{let t=c("div",{class:"zx-field__option-list",role:"radiogroup"}),s=i.controlId,n=cr(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))}}},fc=(i,e)=>{let t=c("div",_t(i,e,{class:"zx-field__static",name:void 0})),s=null;return{el:t,get:()=>t.textContent,set:r=>{or(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:()=>or(s)}};function or(i){i&&(i.parent?i.parent.insertBefore(i.node,i.next?.parentNode===i.parent?i.next:null):i.node.remove())}var pc=(i,e)=>{if(typeof e.adapter!="function")throw new TypeError("Custom fields require options.adapter");return e.adapter(i,e)};function cr(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",Ut("input","text"));z.register("password",Ut("input","password"));z.register("textarea",Ut("textarea","text"));z.register("checkbox",uc);z.register("int",lr("int"));z.register("float",lr("float"));z.register("select",dc);z.register("optionlist",hc);z.register("hidden",Ut("input","hidden"));z.register("html",fc);z.register("custom",pc);function Ae(i,e,t){let s=ur(e).split(/\s+/).filter(Boolean);return s.length===0?i.slice():i.filter(n=>{let r=mc(n,t).map(ur);return s.every(o=>r.some(a=>a.includes(o)))})}function mc(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 ur(i){return String(i??"").normalize("NFD").replace(/\p{M}+/gu,"").toLocaleLowerCase()}var Yt=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=Ae(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=Ae(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){_c(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 _c(i,e){return i.size===e.size&&Array.from(i).every(t=>e.has(t))}function dr(){z.register("checklist",(i,e)=>{let t=i.own(new Yt(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 gc=new Set(["Shift","Control","Alt","Meta","AltGraph","CapsLock","Fn","OS"]),Wt=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=hr(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:vc(this.options.rows),wrap:xc(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=hr(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||gc.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=bc(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=yc(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 bc(i,e,t,s=" ",n=!1){let r=String(i??""),o=String(s??""),a=Zt(e,r.length),l=Zt(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
3
  `,l);d<0&&(d=r.length);let p=r.slice(u,d).split(`
4
4
  `),f=0,_=0,m=p.map((b,y)=>{if(!n)return _+=o.length,o+b;let A=wc(b,o);return y===0&&(f=A),_-=A,b.slice(A)}).join(`
5
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 yc(i,e,t=e){let s=String(i??""),n=Zt(e,s.length),r=Zt(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 wc(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 hr(i){let e=String(i??"text").trim().toLowerCase();return/^[a-z0-9][a-z0-9+_.-]*$/.test(e)?e:"text"}function vc(i){let e=Number(i);return Number.isFinite(e)?Math.max(2,Math.min(100,Math.round(e))):12}function xc(i){return["off","soft","hard"].includes(String(i))?i:"off"}function Zt(i,e){let t=Number(i);return Math.max(0,Math.min(e,Number.isFinite(t)?Math.round(t):0))}function fr(){C.register("code",(i,e)=>{let t=i.own(new Wt(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 pr=["January","February","March","April","May","June","July","August","September","October","November","December"],mr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],br=/%[demYyHMSaAbBs]/g;function T(i,e){return!(i instanceof Date)||Number.isNaN(i.getTime())?"":String(e).replace(br,t=>{switch(t){case"%d":return $e(i.getDate());case"%e":return String(i.getDate());case"%m":return $e(i.getMonth()+1);case"%Y":return String(i.getFullYear()).padStart(4,"0");case"%y":return $e(i.getFullYear()%100);case"%H":return $e(i.getHours());case"%M":return $e(i.getMinutes());case"%S":return $e(i.getSeconds());case"%a":return _r("weekday",i.getDay(),mr[i.getDay()]);case"%A":return ds("weekday",i.getDay(),mr[i.getDay()]);case"%b":return _r("month",i.getMonth(),pr[i.getMonth()]);case"%B":return ds("month",i.getMonth(),pr[i.getMonth()]);case"%s":return String(Math.floor(i.getTime()/1e3));default:return t}})}function ae(i,e){let t=[],s="^",n=0;for(let _ of String(e).matchAll(br)){s+=gr(String(e).slice(n,_.index));let m=_[0],g=Sc(m);if(g===null)return null;s+=`(${g})`,t.push(m),n=_.index+m.length}s+=gr(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"]??Ac(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 yr(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 B(i,e){return i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate()}function M(i,e){let t=new Date(i.getTime());return t.setDate(t.getDate()+e),t}function Ee(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 Gt(i=fe()){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 $e(i){return String(i).padStart(2,"0")}function ds(i,e,t){let s=`date.${i}.${e}`,n=Se(s);return n===s?t:n}function _r(i,e,t){let s=`date.${i}.short.${e}`,n=Se(s);return n!==s?n:ds(i,e,t).slice(0,3)}function Sc(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 Ac(i){if(i!==void 0)return i>=69?1900+i:2e3+i}function gr(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var wr=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),kc=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),vr=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"}),zc=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"}),hs=new Map;function xr(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(vr,s))return{provider:"fa",name:n,style:vr[s],classes:null}}return{provider:null,name:e,style:null,classes:null}}function fs(i,e={}){let{style:t="solid",family:s="classic",fixedWidth:n=!1,translate:r=!0}=e,o=String(i).replace(/^fa-/,""),a=r?zc[o]??o:o,l=[],u=kc[s];return u&&l.push(u),l.push(wr[t]??wr.solid,`fa-${a}`),n&&l.push("fa-fw"),l}function ps(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 Sr(i){let e=ps(i),t=hs.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",()=>{hs.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 hs.set(e,s),s}var zr="http://www.w3.org/2000/svg",D=Object.freeze({control:16,chevron:14,dismiss:14,check:14,sort:14,chip:12,marker:8}),Cr="0 0 24 24",Cc=1.75,Dc=1,z=i=>[Cr,i,"stroke"];var Dr=Object.freeze({"arrow-up-wide-short":z("M3 8l4-4 4 4M7 4v16M11 12h10M11 16h7M11 20h4"),"arrow-down-wide-short":z("M3 16l4 4 4-4M7 20V4M11 4h10M11 8h7M11 12h4"),"arrow-up":z("M5 12l7-7 7 7M12 19V5"),"arrow-down":z("M12 5v14M19 12l-7 7-7-7"),"chevron-down":z("M6 9l6 6 6-6"),"chevron-up":z("M18 15l-6-6-6 6"),"chevron-left":z("M15 18l-6-6 6-6"),"chevron-right":z("M9 18l6-6-6-6"),check:z("M20 6 9 17l-5-5"),x:z("M18 6 6 18M6 6l12 12"),plus:z("M5 12h14M12 5v14"),minus:z("M5 12h14"),search:z("M21 21l-4.34-4.34M3 11a8 8 0 1 0 16 0a8 8 0 1 0-16 0z"),calendar:z("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:z("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 6v6l4 2"),trash:z("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:z("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:z("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:z("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:z("M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8M21 3v5h-5"),list:z("M3 5h.01M3 12h.01M3 19h.01M8 5h13M8 12h13M8 19h13"),filter:z("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:z("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:z("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 16v-4M12 8h.01"),warning:z("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:z("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM12 8V12M12 16H12.01"),success:z("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 9l-5.5 5.5L8 12"),upload:z("M12 3v12M17 8l-5-5-5 5M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"),drag:z("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:z("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:z("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:z("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:z("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":z("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:z("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:z("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:z("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:z("M18 16l4-4-4-4M6 8l-4 4 4 4M14.5 4l-5 16"),book:z("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":z("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:z("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:z("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:z("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:z("M12 4v16M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2M9 20h6"),hash:z("M4 9h16M4 15h16M10 3L8 21M16 3l-2 18"),mail:z("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":z("M9 17H7A5 5 0 0 1 7 7h2M15 7h2a5 5 0 1 1 0 10h-2M8 12h8"),"circle-chevron-down":z("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 10l-4 4-4-4")}),Ec=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list",grid:"table-cells-large"}),Ic=Object.create(null),pe={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function _s(){return{...pe}}function gs(i={}){for(let e of["provider","style","family","fixedWidth","kit"])i[e]!==void 0&&(pe[e]=i[e]);return _s()}function Er(i={}){return gs({...i,provider:"fontawesome"})}async function bs(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 gs({...n,kit:ps(t)}),await Sr(t),s?Er():_s()}function w(i,e={}){let t=xr(i);if(t.classes)return ms(t.classes,e);let s=Ec[t.name]??t.name;return t.provider==="builtin"?Ar(s,e):t.provider==="fa"?ms(fs(s,{style:t.style??e.style??pe.style,family:e.family??pe.family,fixedWidth:e.fixedWidth??pe.fixedWidth}),e):pe.provider==="fontawesome"?ms(fs(s,{style:e.style??pe.style,family:e.family??pe.family,fixedWidth:e.fixedWidth??pe.fixedWidth}),e):Ar(s,e)}function Ar(i,e){let t=Ic[i]??Dr[i];if(!t){if(e.strict)throw new RangeError(`Unknown icon: ${i}`);return Oc(i),Nc(i,e)}let[s,n,r="fill"]=t,o=Ir(s,r,e),a=document.createElementNS(zr,"path");return a.setAttribute("d",n),o.append(a),o}function Ir(i,e,t){let{size:s=D.control}=t,n=document.createElementNS(zr,"svg");return n.setAttribute("class",Mr("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",Tc(i,s)),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round")):n.setAttribute("fill","currentColor"),n.setAttribute("focusable","false"),Tr(n,t.label??null),n}function Tc(i,e){let[,,t,s]=i.trim().split(/[\s,]+/).map(Number),n=Math.max(t,s)||24,r=Cc*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,Dc*n/o)),String(Math.round(r*1e3)/1e3)}var Mc=Cr;function Nc(i,e){let t=Ir(Mc,"stroke",e);return t.setAttribute("data-zx-icon-missing",i),t}var kr=new Set;function Oc(i){kr.has(i)||(kr.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 ms(i,e){let{size:t=D.control}=e,s=document.createElement("i");return s.className=Mr("zx-icon",...i,e.class),s.style.fontSize=typeof t=="number"?`${t}px`:String(t),Tr(s,e.label??null),s}function Tr(i,e){if(e===null){i.setAttribute("aria-hidden","true");return}i.setAttribute("role","img"),i.setAttribute("aria-label",e)}function Mr(...i){return i.flat().filter(Boolean).join(" ")}var Fc=5,Qt=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=Nr(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=I("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},w("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=Nr(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"?jc(this.options.step):1,o=He(e.currentTarget.value,0,s),a=s+1,l=(o+n*r+a*r)%a;e.currentTarget.value=Ie(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=Ie(He(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]=He(s.value,0,r)}let t=!this._value||!Bc(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=Ie(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=Ie(this._display.h),this.refs.headMinute.textContent=Ie(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?Rc():Lc(),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&&!Pc(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 Rc(){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:Ie(t),angle:e*30,ring:"inner"})}return i}function Lc(){let i=[];for(let e=0;e<60;e+=Fc)i.push({value:e,label:Ie(e),angle:e*6,ring:"outer"});return i}function Pc(i){return i>=1&&i<=12}function Nr(i){return i instanceof Date&&!Number.isNaN(i.getTime())?{h:i.getHours(),m:i.getMinutes(),s:i.getSeconds()}:!i||typeof i!="object"?null:{h:He(i.h,0,23),m:He(i.m,0,59),s:He(i.s,0,59)}}function He(i,e,t){let s=Number.parseInt(String(i??""),10);return Number.isFinite(s)?Math.max(e,Math.min(t,s)):e}function jc(i){let e=Math.round(Number(i));return Number.isFinite(e)&&e>0&&e<=59?e:5}function Ie(i){return String(i).padStart(2,"0")}function Bc(i,e){return i.h===e.h&&i.m===e.m&&i.s===e.s}var Ke=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=ie(Xt(this.options.min)),this._max=ie(Xt(this.options.max)),this._value=this._normalizeValue(Xt(this.options.value)),this._focused=ie(this._value)??this._clampFocus(ie(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=Vc(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")},w("chevron-left",{size:D.chevron})),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")},w("chevron-right",{size:D.chevron}))),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")},w("chevron-left",{size:D.chevron})),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")},w("chevron-right",{size:D.chevron}))),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 Qt(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 ys(this._value)}set(e,{silent:t=!1}={}){let s=this._normalizeValue(Xt(e));return this._value=s,s&&(this._focused=ie(s),this._viewYear=s.getFullYear(),this._viewMonth=s.getMonth()),this._timePicker?.set(s,{silent:!0}),this._renderCalendar(),t||this.emit("change",{date:ys(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=ie(t);return this._min&&s<this._min&&Or(t,this._min),this._max&&s>this._max&&Or(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=M(t,(this._weekStart+s)%7);e.append(c("th",{scope:"col",ariaLabel:T(n,"%A")},T(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=M(e,-t);this.refs.heading.textContent=T(e,"%B %Y"),this.refs.heading.setAttribute("aria-label",this._message("datePicker.chooseMonthYear","Choose month and year, %1",T(e,"%B %Y")));let n=[];for(let r=0;r<6;r+=1){let o=M(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",Fr(o))},String(Fr(o))));for(let l=0;l<7;l+=1){let u=M(o,l),d=!!(this._value&&B(u,this._value)),h=!this._inRange(u),p=c("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:B(u,this._focused)?0:-1,ariaSelected:String(d),ariaDisabled:String(h),ariaCurrent:B(u,new Date)?"date":null,ariaLabel:`${T(u,"%e")} ${T(u,"%B %Y")}`,dataset:{date:T(u,"%Y-%m-%d"),otherMonth:u.getMonth()===this._viewMonth?null:"true"}},T(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=ae(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=ae(t.dataset.date,"%Y-%m-%d");if(!s)return;let n=null;if(e.key==="ArrowLeft")n=M(s,-1);else if(e.key==="ArrowRight")n=M(s,1);else if(e.key==="ArrowUp")n=M(s,-7);else if(e.key==="ArrowDown")n=M(s,7);else if(e.key==="PageUp")n=Ee(s,e.shiftKey?-12:-1);else if(e.key==="PageDown")n=Ee(s,e.shiftKey?12:1);else if(e.key==="Home")n=M(s,-((s.getDay()-this._weekStart+7)%7));else if(e.key==="End")n=M(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=ie(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=ie(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._timePicker?.set(t,{silent:!0}),this._renderCalendar(),n&&this._emitMonthChange(),this.emit("change",{date:ys(t)})}_pageMonth(e){this._closeQuickPick();let t=Ee(this._focused,e);this._focused=ie(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}},T(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=ie(t),this._viewMonth=e,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(e){let t=ie(e);return!(this._min&&t<this._min)&&!(this._max&&t>this._max)}_buttonForDate(e){return this.refs.days.querySelector(`[data-date="${T(e,"%Y-%m-%d")}"]`)}_message(e,t,...s){let n=this.msg(e,...s);return n===e?F(t,s):n}};function Xt(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function ie(i){return i?new Date(i.getFullYear(),i.getMonth(),i.getDate()):null}function ys(i){return i?new Date(i.getTime()):null}function Or(i,e){i.setFullYear(e.getFullYear(),e.getMonth(),e.getDate())}function Vc(i){let e=Number(i);return Number.isInteger(e)&&e>=0&&e<=6?e:Gt()}function Fr(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 ti=class extends Ke{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=ei(Jt(this.options.min)),this._max=ei(Jt(this.options.max)),this._value=this._normalizeMonth(Jt(this.options.value));let t=this._value??ei(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")},w("chevron-left",{size:D.chevron})),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")},w("chevron-right",{size:D.chevron}))),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(Jt(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=ei(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&&qc(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:T(s,"%B %Y"),dataset:{month:t}},T(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 Jt(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function ei(i){return i?new Date(i.getFullYear(),i.getMonth(),1):null}function qc(i,e){return i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()}function Rr(){C.register("month",(i,e)=>{let t=i.own(new ti(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 $c=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function G(i,e,t={}){if(!(i instanceof Element)||!(e instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let s=$c.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=`--${I("zx-a")}`;if(_){let g=Lr(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=Hc(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=()=>Kc(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 Uc(e),p(),{update(){d||p()},destroy(){if(!d){if(d=!0,h?.disconnect(),f(),Yc(e),_){let g=Lr(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")}jr(e,"style",l),jr(e,"popover",u)}}}}function Lr(i){return String(i.style?.getPropertyValue("anchor-name")??"").split(",").map(e=>e.trim()).filter(e=>e&&e!=="none")}function Hc(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 Kc(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=Pr(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=ii(t,"bottom","top"):h==="top"&&f<0&&p+a.height<=u?d=ii(t,"top","bottom"):h==="right"&&_+a.width>l&&m>=0?d=ii(t,"right","left"):h==="left"&&m<0&&_+a.width<=l&&(d=ii(t,"left","right")));let g=Pr(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(ft(b,0,Math.max(0,l-a.width)))}px`,e.style.top=`${Math.round(ft(y,0,Math.max(0,u-a.height)))}px`}function Pr(i){return i.split("-")[0]}function ii(i,e,t){return i.replace(e,t)}function Uc(i){if(typeof i.showPopover=="function")try{i.showPopover()}catch{}}function Yc(i){if(typeof i.hidePopover=="function")try{i.hidePopover()}catch{}}function jr(i,e,t){t===null?i.removeAttribute(e):i.setAttribute(e,t)}var Wc=6,Kr=864e5;function gt(i,e){let t=W(Te(i)),s=W(Te(e));return t&&s&&t.getTime()>s.getTime()?{start:s,end:t}:{start:t,end:s}}function si(i,e){let t=gt(i,e);return!t.start||!t.end?0:Math.round((qr(t.end)-qr(t.start))/Kr)}function Zc(i,e,t){let s=W(Te(i));if(!s)return null;let n=gt(e,t);return!n.start&&!n.end?null:n.end?n.start?s.getTime()<n.start.getTime()||s.getTime()>n.end.getTime()?null:B(s,n.start)?"start":B(s,n.end)?"end":"middle":B(s,n.end)?"end":null:B(s,n.start)?"start":null}function ni(i,e={}){let t=W(Te(e.min)),s=W(Te(e.max)),n=oi(e.minNights)??0,r=oi(e.maxNights),{start:o,end:a}=gt(i?.start,i?.end);return o&&(o=vs(o,t,s)),a&&(a=vs(a,t,s)),!o||!a?{start:o,end:a}:(r!==null&&si(o,a)>r&&(a=M(o,r)),n>0&&si(o,a)<n&&(a=M(o,n),s&&a.getTime()>s.getTime()&&(a=new Date(s.getTime()),o=M(a,-n),t&&o.getTime()<t.getTime()))?{start:null,end:null}:{start:o,end:a})}var ri=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=iu(e,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=W(Te(this.options.min)),this._max=W(Te(this.options.max)),this._minNights=oi(this.options.minNights)??0,this._maxNights=oi(this.options.maxNights),this._weekStart=Jc(this.options.weekStart),this._monthCount=eu(this.options.months),this._presets=Xc(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let t=ni({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=ke(this._start)??this._clampFocus(W(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),e.setAttribute("role","group"),e.setAttribute("aria-label",R("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:R("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:ke(this._start),end:ke(this._end)}}set(e={},{silent:t=!1}={}){let s=ni({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=ke(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=[],su(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=W(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=si(this._start,t);return!(s<this._minNights||this._maxNights!==null&&s>this._maxNights)}_choose(e){let t=W(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?ke(this._start):null,this._committedEnd=e?ke(this._end):null}_abandon(){return this._picking?(this._start=ke(this._committedStart),this._end=ke(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(e){return vs(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=$r(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=$r(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=W(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?W(e):null;!t&&!this._hover||t&&this._hover&&B(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=M(s,-1);else if(e.key==="ArrowRight")n=M(s,1);else if(e.key==="ArrowUp")n=M(s,-7);else if(e.key==="ArrowDown")n=M(s,7);else if(e.key==="PageUp")n=Ee(s,e.shiftKey?-12:-1);else if(e.key==="PageDown")n=Ee(s,e.shiftKey?12:1);else if(e.key==="Home")n=M(s,-((s.getDay()-this._weekStart+7)%7));else if(e.key==="End")n=M(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=T(e,"%B %Y"),s=(e.getDay()-this._weekStart+7)%7,n=M(e,-s),r=[];for(let o=0;o<Wc;o+=1){let a=M(n,o*7),l=c("tr"),u=tu(a,e);this.options.showWeekNumbers&&l.append(c("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:u?R("daterange.week","Week %1",[Hr(a)]):null},u?String(Hr(a)):""));for(let d=0;d<7;d+=1){let h=M(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:T(h,"%Y-%m-%d")}},T(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:R("daterange.previousMonth","Previous month")},w("chevron-left",{size:D.chevron})),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:R("daterange.nextMonth","Next month")},w("chevron-right",{size:D.chevron}))),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:R("daterange.weekNumber","Week number")},"#"));let t=new Date(2023,0,1);for(let s=0;s<7;s+=1){let n=M(t,(this._weekStart+s)%7);e.append(c("th",{scope:"col",ariaLabel:T(n,"%A")},T(n,"%a")))}return e}_paint(){let e=new Date,t=null;for(let s of this._dayCells)B(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);ws(r,"range",a.range),ws(r,"rangeEdge",a.edge),ws(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)),B(n,e)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(e){if(this._start&&this._end){let s=Zc(e,this._start,this._end);if(!s)return{range:null,edge:null};let n=B(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 B(e,this._start)?{range:"start",edge:t?"start":"both"}:t?e.getTime()>this._start.getTime()&&e.getTime()<=t.getTime()?{range:"preview",edge:B(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=W(e);return t.getTime()<=this._start.getTime()?null:this._selectable(t)?t:null}_dayLabel(e,t){let s=T(e,"%A, %e %B %Y");return t==="start"?`${s}, ${R("daterange.day.start","range start")}`:t==="end"?`${s}, ${R("daterange.day.end","range end")}`:t==="middle"?`${s}, ${R("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 R("daterange.status.empty","No date range selected");if(!this._end)return R("daterange.status.start","%1 selected, choose an end date",[T(this._start,"%e %B %Y")]);let e=si(this._start,this._end),t=e===1?R("daterange.night","1 night"):R("daterange.nights","%1 nights",[e]);return`${Qc(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=>B(t.date,e))?.button??null}};function Gc(){return[{name:"today",label:R("daterange.preset.today","Today"),range:()=>Br(le())},{name:"yesterday",label:R("daterange.preset.yesterday","Yesterday"),range:()=>Br(M(le(),-1))},{name:"last7",label:R("daterange.preset.last7","Last 7 days"),range:()=>({start:M(le(),-6),end:le()})},{name:"last30",label:R("daterange.preset.last30","Last 30 days"),range:()=>({start:M(le(),-29),end:le()})},{name:"thisMonth",label:R("daterange.preset.thisMonth","This month"),range:()=>Vr(le(),0)},{name:"lastMonth",label:R("daterange.preset.lastMonth","Last month"),range:()=>Vr(le(),-1)},{name:"thisQuarter",label:R("daterange.preset.thisQuarter","This quarter"),range:()=>{let i=le(),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:R("daterange.preset.thisYear","This year"),range:()=>{let i=le();return{start:new Date(i.getFullYear(),0,1),end:new Date(i.getFullYear(),11,31)}}}]}function R(i,e,t){let s=Se(i);return F(s===i?e:s,t)}function Qc(i,e){if(B(i,e))return T(i,"%e %B %Y");let t=T(e,"%e %B %Y");return i.getFullYear()!==e.getFullYear()?`${T(i,"%e %B %Y")} \u2013 ${t}`:i.getMonth()!==e.getMonth()?`${T(i,"%e %B")} \u2013 ${t}`:`${T(i,"%e")} \u2013 ${t}`}function Xc(i){return i===!0?Gc():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 le(){return W(new Date)}function Br(i){return{start:i,end:new Date(i.getTime())}}function Vr(i,e){return{start:new Date(i.getFullYear(),i.getMonth()+e,1),end:new Date(i.getFullYear(),i.getMonth()+e+1,0)}}function Te(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function W(i){return!i||Number.isNaN(i.getTime())?null:new Date(i.getFullYear(),i.getMonth(),i.getDate())}function ke(i){return i?new Date(i.getTime()):null}function vs(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 qr(i){return Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())}function $r(i){return i.getFullYear()*12+i.getMonth()}function oi(i){if(i==null||i==="")return null;let e=Number(i);return Number.isFinite(e)?Math.max(0,Math.trunc(e)):null}function Jc(i){let e=Number(i);return Number.isInteger(e)&&e>=0&&e<=6?e:Gt()}function eu(i){let e=Number(i);return Number.isInteger(e)&&e>=1&&e<=4?e:2}function tu(i,e){for(let t=0;t<7;t+=1){let s=M(i,t);if(s.getMonth()===e.getMonth()&&s.getFullYear()===e.getFullYear())return!0}return!1}function Hr(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())/Kr+1)/7)}function ws(i,e,t){t==null?delete i.dataset[e]:i.dataset[e]=t}function iu(i,e){return new Map(e.map(t=>[t,i.getAttribute(t)]))}function su(i,e){for(let[t,s]of e)s===null?i.removeAttribute(t):i.setAttribute(t,s)}var nu={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function Ur(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}${ts(r)}${l}`));if(u.length>2)return null;let d=ae(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=ae(u[1].trim(),e);return h?gt(d,h):null}function Yr(i,e,t){let s=i?.start??null,n=i?.end??null;return!s&&!n?"":n?s?`${T(s,e)}${t}${T(n,e)}`:T(n,e):T(s,e)}var li=class extends S{static cssName="date-range-box";static defaults={start:null,end:null,format:"%d.%m.%Y",displayFormat:null,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._displayFormat=this.options.displayFormat?String(this.options.displayFormat):this._format,this._separator=String(this.options.separator??" \u2013 "),this._disabled=!!this.options.disabled,this._open=!1,this._focused=!1,this._position=null,this._range=this._coerce({start:this.options.start,end:this.options.end});let t=I("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:Wr("daterange.clear","Clear date range")},w("x",{size:D.dismiss})),c("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:Wr("daterange.choose","Choose date range"),"aria-haspopup":"grid",ariaControls:t,ariaExpanded:"false"},w("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 ri(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,"focus",()=>{this._focused=!0,this.el.dataset.state!=="invalid"&&this._syncDisplay()}),this.listen(this.refs.input,"blur",()=>{this._focused=!1,this._open?this.refs.input.value===Yr(this._range,this._format,this._separator)&&this._syncDisplay():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=G(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(),ai(this.el,"data-state",this._originalState),ai(this.el,"aria-disabled",this._originalAriaDisabled),ai(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=Ur(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(Ur(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()!==""?ae(e.trim(),this._format):null}_clamp(e){return ni(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=>nu[t]??t);return`${e}${this._separator}${e}`}_syncDisplay(){let e=this.refs.input,t=this._focused?this._format:this._displayFormat,s=Yr(this._range,t,this._separator);e.value!==s&&(e.value=s),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"&&ai(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 Wr(i,e,t){let s=Se(i);return F(s===i?e:s,t)}function ai(i,e,t){t===null?i.removeAttribute(e):i.setAttribute(e,t)}function Zr(){C.register("daterange",(i,e)=>{let t=i.own(new li(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 Me=class extends S{static cssName="datebox";static defaults={value:null,format:"%d.%m.%Y",displayFormat:null,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);let t=ru(this.options);this._format=t.format,this._displayFormat=t.display,this._disabled=!!this.options.disabled,this._open=!1,this._focused=!1,this._position=null,this._min=Gr(this.options.min),this._max=Gr(this.options.max),this._value=this._normalizeValue(this.options.value);let s=I("zx-datebox-popover"),n=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??ou(this._format),"aria-haspopup":"grid",ariaControls:s,ariaExpanded:"false"}),c("button",{ref:"clear",class:"zx-icon-btn zx-datebox__clear",type:"button",ariaLabel:"Clear date"},w("x",{size:D.dismiss})),c("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:"Choose date","aria-haspopup":"grid",ariaControls:s,ariaExpanded:"false"},w("calendar"))),c("div",{ref:"popover",id:s,class:"zx-datebox__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=n,e.append(n),this._picker=new Ke(null,{value:this._value,min:this._min,max:this._max,time:!!this.options.time}),this.refs.popover.append(this._picker.el),this._picker.on("change",r=>{this.set(r.detail.date),this.options.time||this._close(!0)}),this.listen(this.refs.input,"focus",()=>{this._focused=!0,this.el.dataset.state!=="invalid"&&this._syncDisplay()}),this.listen(this.refs.input,"blur",()=>{this._focused=!1,this._commitText()}),this.listen(this.refs.input,"keydown",r=>this._onInputKeydown(r)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",r=>{r.key==="ArrowDown"&&(r.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.set(null),this.focus()}),this.listen(document,"keydown",r=>{!this._open||r.key!=="Escape"||(r.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",r=>{this._open&&!e.contains(r.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=G(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=ae(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=ae(e,this._format)),!t||Number.isNaN(t.getTime())?null:yr(t,this._min,this._max)}_syncDisplay(){let e=this.refs.input,t=this._focused?this._format:this._displayFormat,s=this._value?T(this._value,t):"";e.value!==s&&(e.value=s),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}},Xr=function(e,t={}){return new Me(e,{...t,time:!0})};function Gr(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function ru({format:i=null,displayFormat:e=null,time:t=!1}={}){let s=Qr(i,t);return{format:s,display:e?Qr(e,t):s}}function Qr(i,e){let t=String(i||"%d.%m.%Y");return e&&!/%[HM]/.test(t)?`${t} %H:%M`:t}function ou(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 eo(){Jr("date",i=>new Me(null,i)),Jr("datetime",i=>Xr(null,i))}function Jr(i,e){C.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 ci=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=I("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"},au(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=>!cu(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(du(s.responseText))}),this.listen(s,"error",()=>t(new Error("Upload request failed"))),this.listen(s,"abort",()=>t(hu())),s.send(uu(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 au(i){let e=[];return i.accept&&e.push(String(i.accept)),i.maxSize!=null&&e.push(`up to ${lu(Number(i.maxSize))}`),e.join(" \xB7 ")||"Choose from this device"}function lu(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/1024)} KB`:`${Math.round(i/(1024*1024))} MB`}function cu(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 uu(i,e,t){let s=new FormData;for(let n of i)s.append(e,n);for(let[n,r]of Object.entries(t??{}))to(s,n,r);return s}function to(i,e,t){if(t==null)return;if(Array.isArray(t)){for(let n of t)to(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 du(i){if(!i)return null;try{return JSON.parse(i)}catch{return i}}function hu(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let i=new Error("Upload aborted");return i.name="AbortError",i}function io(){C.register("upload",(i,e)=>{let t=i.own(new ci(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 so=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),no=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),ui=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 so[this.options.reorder]??so.both}_renderRows(e=-1,t="value"){let s=ro(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}},w("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}},w("chevron-up",{size:D.chevron})):null,o?c("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:D.chevron})):null,c("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${d+1}`,dataset:{action:"remove",index:d}},w("x",{size:D.dismiss}))))});this._rows.replaceChildren(...l),e>=0&&l[Math.min(e,l.length-1)]?.querySelector(no[t]??no.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=ro(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 ro(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 oo(){C.register("multivalueeditor",(i,e)=>{let t=i.own(new ui(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 Ue=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:K(this.el);let e=this.el??c("div");this.el=e;let t=fu(this.options.step);this._step=t,this._precision=this.options.precision===null?pu(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}},w(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=xs(e,this.options.group?this._separators():null);return t===null?null:Ss(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=xs(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=ao(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=xs(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&&U(e,this._snapshot)}};function xs(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 Ss(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=ao(r,n),e!==null&&r<e?e:t!==null&&r>t?t:r}function fu(i){let e=Number(i);return Number.isFinite(e)&&e>0?e:1}function pu(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 ao(i,e){return Number.isFinite(i)?Number(i.toFixed(Math.min(15,Math.max(0,e)))):i}function lo(){C.register("number",(i,e)=>{let t=i.own(new Ue(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 di=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:K(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=I("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"},w(this.options.icon,{size:bt[this.options.size]??bt.md})),c("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},w(this.options.icon,{size:bt[this.options.size]??bt.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=bt[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?F(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(mu(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&&U(e,this._snapshot)}},bt={sm:14,md:18,lg:24};function mu(i,e){return e<1?i.toFixed(1):String(i)}function co(){C.register("rating",(i,e)=>{let t=i.own(new di(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 S_=["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 uo(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=>_u(u).startsWith(t));l>=0&&e(a[l],l)}}function _u(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 gu=/^var\(\s*--[\w-]+\s*\)$/;function hi(i){if(typeof i!="string")return null;let e=i.trim();return gu.test(e)||xe(e)?e:null}var ks=Object.freeze(["dotted","ring","progress","review","ready","waiting","done","canceled","duplicate"]),zs=Object.freeze(["muted","neutral","warning","info","accent","success","danger"]),Cs=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"]]),bu=Object.freeze({review:"in-review",cancelled:"canceled"}),As=4;function yu(i,e={}){let t=i&&typeof i=="object"?i:null,s=wu(t?t.ID??t.id:i),n=Cs.find(([a])=>a===s),r=String(e.indicator??t?.indicator??n?.[3]??"ring"),o=String(e.tone??t?.tone??n?.[4]??"muted");return{indicator:ks.includes(r)?r:"ring",tone:zs.includes(o)?o:"muted"}}function wu(i){let e=String(i??"").trim().toLowerCase();return bu[e]??e}function Ds(i){return i==null||i===""?null:Math.max(0,Math.min(As,Math.trunc(Number(i)||0)))}function ho(i,e={}){let{indicator:t,tone:s}=yu(i,e??{}),n=c("span",{class:"zx-status-icon",dataset:{indicator:t,tone:s}});return t==="done"&&n.append(w("check",{size:D.marker})),t==="canceled"&&n.append(w("x",{size:D.marker})),po(n,e?.label)}function fo(i,e={}){let t=Ds(i),s=c("span",{class:"zx-priority-icon",dataset:{level:t===null?"none":t}},t===As?null:Array.from({length:As},(n,r)=>c("span",{dataset:{filled:String(t!==null&&r<=t)}})));return po(s,e?.label)}function po(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 vu=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],mo=["Lowest","Low","Medium","High","Highest"],$=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:K(e);let t=I("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},w("x",{size:D.dismiss})),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")},w("chevron-down",{size:D.chevron})),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=_o(this.options.actions),this._disabled=!!this.options.disabled,this._handleTypeahead=uo(()=>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=>{bo(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=>{bo(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=_o(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=G(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 go(l,!0)},renderNone:t.renderNone??(()=>go({level:null,name:o()},!0)),renderValueAdornment(l){return wo(l.level)}}),n&&!t.placeholder&&(r.refs.input.placeholder=o());let a=r;return r.setItems(vu.map((l,u)=>{let d=u===2?a.msg("priority.medium"):l;return(d==="priority.medium"||u!==2)&&(d=a._message(l,mo[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 ku(l)},renderValueAdornment(l){return vo(l)}}),a=Array.isArray(s)?s.map(Au).filter(Boolean):Cs.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 v=fi(y,o);if(v&&typeof v=="object"&&typeof v.nodeType=="number")return v.cloneNode(!0);if(typeof v!="string"||!v)return null;let x=hi(fi(y,a));return c("span",{class:"zx-select__entity-glyph",style:x?{"--zx-select-entity-color":x}:null,ariaHidden:"true"},w(v,{size:14}))},g=r?xu(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),v=fi(y,l),x=c("span",{class:"zx-select__entity-copy"},c("span",{class:"zx-select__entity-label"},String(fi(y,_.labelKey??"name")??"")),v==null||v===""?null:c("span",{class:"zx-select__entity-subtitle"},String(v)));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:Is(f,r),labelKey:f=>h.includes(f)?f.name:String(Is(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&&U(e,this._snapshot),super.destroy()}_onKeydown(e){if(!this._disabled){if(this._open&&yo(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&&yo(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=Ae(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"?Es(this.options.renderNone(String(s??""))):t?String(s??""):this._renderItem(e),a=c("div",{class:"zx-select__option",id:I("zx-select-option"),role:"option",ariaSelected:String(n),dataset:{index:r}},c("span",{class:"zx-select__option-content"},o));n&&a.append(w("check",{size:D.check})),this.refs.list.append(a),this._optionEntries.push({item:e,clear:t,action:null,element:a})}_appendAction(e){let t=this._optionEntries.length,s=Su(e.icon),n=c("div",{class:"zx-select__option zx-select__action",id:I("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 Es(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=Es(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 Is(e,t)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(e){return Ae(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 fi(i,e){return typeof e=="function"?e(i):i!==null&&typeof i=="object"&&typeof e=="string"?i[e]:null}function xu(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 Es(i){return i&&typeof i=="object"&&"nodeType"in i?i:String(i??"")}function _o(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 Su(i){return typeof i=="string"?w(i):i instanceof Node?i.cloneNode(!0):null}function go(i,e){return c("span",{class:"zx-select__priority"},wo(i.level),e?c("span",{},String(i.name)):null)}function wo(i){let e=fo(Ds(i));return e.classList.add("zx-select__priority-icon"),e}function Au(i){return!i||typeof i!="object"||i.ID==null||i.name==null?null:{...i,name:String(i.name),indicator:ks.includes(String(i.indicator))?String(i.indicator):"ring",tone:zs.includes(String(i.tone))?String(i.tone):"muted",description:i.description==null?"":String(i.description),shortcut:i.shortcut==null?"":String(i.shortcut)}}function ku(i){return c("span",{class:"zx-select__status"},vo(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 vo(i){let e=ho({indicator:i.indicator??"ring",tone:i.tone??"muted"});return e.classList.add("zx-select__status-indicator"),e}function Is(i,e){return typeof e=="function"?e(i):i===null||typeof i!="object"?i:i[e]}function bo(i){return["Shift","Control","Alt","Meta","CapsLock"].includes(i.key)||i.ctrlKey||i.metaKey}function yo(i){return i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey}function xo(){C.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"?$.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 pi=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:K(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=I("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&&zu.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)?Ss(t,{min:this._min,max:this._max,step:this._step,precision:Cu(this._step)}):this._min}_ratio(e){return ft((e-this._min)/(this._max-this._min),0,1)}_format(e){let t=this.options.formatValue;return typeof t=="function"?String(t(e)):`${Du(e)}${this.options.unit??""}`}destroy(){let e=this.el;super.destroy(),!this._createdRoot&&e&&U(e,this._snapshot)}},zu=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function Cu(i){let e=String(i),t=/e-(\d+)$/i.exec(e);return t?Number(t[1]):(e.split(".")[1]??"").length}function Du(i){return String(Number(i.toFixed(6)))}function So(){C.register("slider",(i,e)=>{let t=i.own(new pi(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 Eu=Object.freeze(["neutral","accent","success","warning","danger","info"]),Iu=Object.freeze(["soft","solid","outline"]),Tu=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),Mu=Object.freeze({label:"",icon:null,kind:"neutral",tone:null,variant:"soft",size:"md",dot:!1});function Ao(i={}){let e={...Mu,...i},t=c("span",{class:"zx-badge",title:e.title,dataset:{kind:Nu(e.kind),variant:Ou(e.variant),size:Fu(e.size),tone:Ts(e.tone)??void 0}});return e.dot?t.append(c("span",{class:"zx-badge__dot",ariaHidden:"true"})):e.icon&&t.append(w(e.icon,{size:12,class:"zx-badge__icon"})),e.label!==""&&e.label!=null?t.append(c("span",{class:"zx-badge__label"},String(e.label))):e.title&&(t.setAttribute("role","img"),t.setAttribute("aria-label",e.title)),t}function Nu(i){return Eu.includes(i)?i:"neutral"}function Ou(i){return Iu.includes(i)?i:"soft"}function Ts(i){return Tu.includes(i)?i:null}function Fu(i){return i==="sm"?"sm":"md"}var mi=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:K(this.el);let e=this.el??c("div");this.el=e;let t=I("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")},w("chevron-down",{size:D.chevron})),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=!Ru(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=G(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&&U(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-badge__label zx-tag-picker__tag-label"},s)],a=Ao({tone:n});return a.classList.add("zx-tag-picker__tag"),a.dataset.colored=String(!!r),r&&a.style.setProperty("--zx-tag-color",r),a.append(...o.filter(l=>l!=null)),!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])},w("x",{size:D.chip}))),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:I("zx-tag-picker-option"),role:"option",ariaSelected:String(a)},c("span",{class:"zx-tag-picker__check",ariaHidden:"true"},a?w("check",{size:D.check}):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:I("zx-tag-picker-option"),role:"option",ariaSelected:"false",dataset:{create:"true"}},c("span",{class:"zx-tag-picker__check",ariaHidden:"true"},w("plus",{size:D.check})),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=Ae(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=>ko(this._labelOf(n))===ko(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()?w(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 hi(this._readItem(e,this.options.colorKey))}_toneOf(e){return Ts(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 ko(i){return String(i??"").trim().toLocaleLowerCase()}function Ru(i,e,t){return i.length!==e.length?!1:i.every((s,n)=>Object.is(t(s),t(e[n])))}function zo(){C.register("tagpicker",(i,e)=>{let t=i.own(new mi(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 Lu(i,e="minutes"){let t=Math.round(Math.abs(Co(Ne(i),e)));return{hours:Math.floor(t/3600),minutes:Math.floor(t/60)%60,seconds:t%60,negative:Ne(i)<0}}function Pu(i,e="minutes"){yt(e);let t=Math.abs(Math.trunc(Ne(i?.hours))),s=Math.abs(Math.trunc(Ne(i?.minutes))),n=Math.abs(Math.trunc(Ne(i?.seconds))),r=i?.negative?-1:1;return Do(r*(t*3600+s*60+n),e)}var _i=class extends S{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){yt(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 Pu(this._readParts(),e)}set(e,t=this.options.unit,s={}){t&&typeof t=="object"&&(s=t,t=this.options.unit),yt(t);let n=Ne(e);return!this.options.signed&&n<0&&(n=0),this.options.seconds||(n=Do(Math.round(Co(n,t)/60)*60,t)),this._parts=Lu(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(Ne(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]):ju(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 Ne(i){let e=Number(i);return Number.isFinite(e)?e:0}function Co(i,e){return yt(e),e==="hours"?i*3600:e==="minutes"?i*60:i}function Do(i,e){return yt(e),e==="hours"?i/3600:e==="minutes"?i/60:i}function yt(i){if(i!=="hours"&&i!=="minutes"&&i!=="seconds")throw new RangeError(`Unknown time unit: ${i}`)}function ju(i){return String(i).padStart(2,"0")}function Eo(){C.register("time",(i,e)=>{let t=i.own(new _i(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 Ye=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:Bu(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&&Vu(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function Bu(i){return{attributes:Array.from(i.attributes,e=>[e.name,e.value]),children:Array.from(i.childNodes)}}function Vu(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 Io(){C.register("toggle",(i,e)=>{let t=i.own(new Ye(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 gi=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=To(this.options.values,!!this.options.unique);let t=I("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=To(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"},w("x",{size:D.chip})):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?F(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 To(i,e){if(!Array.isArray(i))return[];let t=i.map(s=>String(s));return e?[...new Set(t)]:t}function Mo(){C.register("valuelist",(i,e)=>{let t=i.own(new gi(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 bi=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),qu=["xl","lg","md","sm"];function No(i){let e=Number(i);if(!Number.isFinite(e))return"xs";for(let t of qu)if(e>=bi[t])return t;return"xs"}function Oo(i,e={}){if(typeof i!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in e&&!L(e.target)&&e.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let t=e.target??globalThis,s=L(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=No(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??No(a()),destroy:()=>{r||(r=!0,u&&cancelAnimationFrame(u),o?.disconnect(),globalThis.removeEventListener?.("resize",l))}}}var $u=0,Hu=20,Ku=3;var Fo=new Map;function yi(i,e={}){let t=Os(i);if(t===null)return"";let{locale:s=fe(),decimals:n,minDecimals:r,maxDecimals:o,group:a=!0}=e;return Ms(s,Ns({decimals:n,minDecimals:r,maxDecimals:o,group:a}),t)}function Lo(i,e,t={}){let s=Os(i);if(s===null)return"";let{locale:n=fe(),decimals:r}=t,o=Yu(e);if(o===null)return yi(s,{locale:n,decimals:r});let a=Ns({decimals:r,group:!0});return Ms(n,{...a,style:"currency",currency:o},s)}function Po(i,e={}){let t=Os(i);if(t===null)return"";let{locale:s=fe(),decimals:n=0}=e;return Ms(s,{...Ns({decimals:n,group:!0}),style:"percent"},t)}function Ms(i,e,t){let s=`${i}\0${JSON.stringify(e)}`,n=Fo.get(s);return n===void 0&&(n=Uu(i,e),Fo.set(s,n)),n.format(t)}function Uu(i,e){try{return new Intl.NumberFormat(i,e)}catch{try{return new Intl.NumberFormat(void 0,e)}catch{return new Intl.NumberFormat}}}function Ns({decimals:i,minDecimals:e,maxDecimals:t,group:s=!0}){let n={useGrouping:s!==!1},r=Ro(e??i),o=Ro(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,Ku)),n}function Ro(i){if(i==null)return null;let e=Number(i);return Number.isFinite(e)?Math.min(Hu,Math.max($u,Math.round(e))):null}function Os(i){if(i==null||i==="")return null;let e=typeof i=="number"?i:Number(i);return Number.isFinite(e)?e:null}function Yu(i){if(typeof i!="string")return null;let e=i.trim().toUpperCase();return/^[A-Z]{3}$/.test(e)?e:null}var Wu=".zx-scope, [data-zx-theme], [data-zx-preset]",Zu="dialog:modal, dialog[open], dialog:popover-open";function se(i=null){return Bo(jo(i))}function wt(i=null){let e=jo(i);return(i==null?null:Ze(e))??Bo(e)}function We(i=null,e={}){let t=e.dialog===!1?se:wt;if(i==null)return t(null);let s=Y(i);return s?.isConnected?t(s):null}function Ze(i){if(!i||typeof i.closest!="function")return null;try{return i.closest(Zu)}catch{return i.closest("dialog[open]")}}function jo(i){return i==null?document.activeElement instanceof Element?document.activeElement:null:Y(i)}function Bo(i){let e=i?.closest?.(Wu)??null;return!e||e===document.documentElement||e===document.body?document.body:e}var $o=new Set(["tooltip","toast"]);function ze(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 Gu(i,e){for(let t=i.length-1;t>=0;t-=1){let s=i[t];if(!$o.has(s.kind)&&e.some(n=>ze(s.root,n)))return s}return null}function vt(i,e,t){return t?ze(e.root,t)||e.inside.some(s=>ze(s,t))?!0:i.some(s=>s.parent===e&&vt(i,s,t)):!1}function Fs(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 Qu(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&&!ze(e,n.root)||typeof n.onEscape=="function"&&t.push(n)}return t}function Xu(i,e,t=null){if(i.some(n=>n.kind==="toast"&&ze(n.root,e)))return[];let s=[];for(let n=i.length-1;n>=0;n-=1){let r=i[n];r.kind==="tooltip"&&!vt(i,r,e)&&r.onOutsidePointer&&s.push(r)}for(let n=i.length-1;n>=0;n-=1){let r=i[n];if(!$o.has(r.kind)){if(vt(i,r,e)||r.kind==="modal")break;t&&!ze(t,r.root)||r.onOutsidePointer&&s.push(r)}}return s}var Ls=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=Vo(e.anchor),s={order:++this.#t,kind:e.kind,root:e.root,owner:e.owner??null,anchors:t,inside:Vo(e.inside),parent:e.kind==="toast"?null:Gu(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:()=>Fs(this.#e)===s,contains:r=>this.#e.includes(s)&&vt(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 Fs(this.#e,e)}topmostModal(){let e=Fs(this.#e,s=>s.kind==="modal"&&s.root.isConnected&&Ju(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=>ze(t.root,e)||t.inside.some(s=>ze(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 Qu(this.#e,qo(Rs(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=Rs(e),s=Xu(this.#e,t,qo(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=Rs(e);for(let s of this.#e.slice().reverse()){if(typeof s.onFocusOutside!="function"||!this.#e.includes(s)||vt(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})}}},Ge=new Ls;function Qe(i){return Ge.push(i)}function Vo(i){let e=Array.isArray(i)?i:[i];return e.filter((t,s)=>t!=null&&e.indexOf(t)===s)}function qo(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 Rs(i){return(typeof i.composedPath=="function"?i.composedPath():[])[0]??i.target??null}function Ju(i,e,t){if(typeof i.matches!="function")return t;try{return i.matches(e)}catch{return t}}var Ho=Object.freeze({mod:["\u2318","Ctrl"],meta:["\u2318","Meta"],cmd:["\u2318","Ctrl"],command:["\u2318","Ctrl"],ctrl:["\u2303","Ctrl"],control:["\u2303","Ctrl"],alt:["\u2325","Alt"],option:["\u2325","Alt"],shift:["\u21E7","Shift"],backspace:["\u232B","Backspace"],delete:["\u2326","Del"],tab:["\u21E5","Tab"]}),Ko=Object.freeze({enter:"\u21B5",return:"\u21B5",escape:"Esc",esc:"Esc",space:"Space",arrowup:"\u2191",up:"\u2191",arrowdown:"\u2193",down:"\u2193",arrowleft:"\u2190",left:"\u2190",arrowright:"\u2192",right:"\u2192",pageup:"PgUp",pagedown:"PgDn",home:"Home",end:"End"});function ed(){let i=globalThis.navigator;if(!i)return!1;let e=i.userAgentData?.platform||i.platform||"";return/mac|iphone|ipad|ios/i.test(e)}function td(i){if(i==="+")return["+"];let e=i.split("+");return i.endsWith("++")&&e.splice(-2,2,"+"),e.map(t=>t.trim()).filter(t=>t!=="")}function id(i,e){let t=i.toLowerCase();return Object.hasOwn(Ho,t)?Ho[t][e?0:1]:Object.hasOwn(Ko,t)?Ko[t]:i.length===1?i.toUpperCase():i}function sd(i,{apple:e=ed()}={}){return(Array.isArray(i)?i.map(String):td(String(i))).map(s=>id(s,e))}function me(i,e={}){return c("kbd",{class:"zx-kbd",dataset:{size:e.size==="sm"?"sm":void 0,tone:e.tone==="inherit"?"inherit":void 0}},sd(i).map(t=>c("kbd",{class:"zx-kbd__key"},t)))}var nd=Object.freeze({size:"md",label:"",showLabel:!1,kind:"accent"}),rd=Object.freeze({sm:!0,md:!0,lg:!0});function Uo(i={}){let e={...nd,...i},t=String(e.label??""),s=c("span",{class:"zx-spinner",dataset:{size:rd[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 od=Object.freeze({label:"",icon:null,kind:"default",size:"md",disabled:!1});function Yo(i={}){let e={...od,...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:cd(e.kind),size:ud(e.size)}});return e.icon&&t.append(w(e.icon,{size:16})),e.label!==""&&t.append(c("span",{class:"zx-btn__label"},String(e.label))),e.shortcut&&t.append(ld(e.shortcut.label)),!e.label&&e.title&&t.setAttribute("aria-label",e.title),typeof e.onclick=="function"&&(t.onclick=e.onclick),e.busy&&ad(t,!0),t}function ad(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=Uo({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 ld(i){let e=me(String(i),{size:"sm"});return e.classList.add("zx-btn__shortcut"),e.setAttribute("aria-hidden","true"),e}function cd(i){return["primary","danger","ghost"].includes(String(i))?i:"default"}function ud(i){return i==="sm"?"sm":"md"}function dd(i,e){return String(i).localeCompare(String(e))}function hd(i,e){return i-e}function fd(i,e){return i.getTime()-e.getTime()}function pd(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=fd(i,e):typeof i=="number"&&typeof e=="number"?r=hd(i,e):r=dd(i,e),t==="desc"?-r:r}function md(i,e="asc"){return(t,s)=>pd(i(t),i(s),e)}function Ps(i,e,t="asc"){let s=md(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 _d=new Set(["text","number","select","date","checkbox","textarea"]),gd='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',St=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:K(t),this._columns=Zo(this.options.columns),this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._rowKind=Nd(this.options.rowKind),this._rowKinds=Od(this.options.rowKinds),this._spanning=this._hasSpanningRow(),this._sortWarned=!1,this._selected=new Set,this._selectionAnchorId=null,this._sort=Qo(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowNames=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=Ld(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=Hd(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||vi(this.options.hierarchy,this._columns)||this._clickListened),this._current=null,this._rovingEl=null,this._extendBase=null,this._hierarchy=vi(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=Fd(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let s of wi(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(s);return this._reconcileExpanded(),Rd(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:I("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),Xo(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 Xo(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=Zo(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=Qo(o,s),this._hierarchy=vi(this.options.hierarchy,s),this._reconcileExpanded(),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(),t.silent||(xi(n,this.getColumnOrder())||this.emit("columnorderchange",{order:this.getColumnOrder()}),xi(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=Vd(this._columns,e);if(xi(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=vi(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=qd(this.getColumnOrder(),String(e),String(t),s);if(xi(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 ${Si(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=ia(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,js(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=wi(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=>Xe(p,n)!==!1)??null:s;if(!r||Xe(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=>Xe(p,l)!==!1):[r],h=new Map;for(let p of d){let f=Go(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=Td(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?zd(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?F(t,s):n}_watchWidth(){this._width?.destroy(),this._width=null;let e=this.options.responsive;!e||!(e in bi)||(this._width=Oo((t,s)=>this._setStacked(s>0&&s<bi[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&&(U(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:ta(e,this._rowKind,this._rowKinds)}_hasSpanningRow(){return xd(this._data,this._rowKind,this._rowKinds)}_spanColspan(){return Sd(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"}},w("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=I("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=Si(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"}},w("chevron-up",{size:D.chevron})),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"}},w("chevron-down",{size:D.chevron}))):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?Q(this._hierarchy.parentId,t):null;return this._data.filter(n=>!this._hierarchy||Vs(Q(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&&Vs(Q(this._hierarchy.parentId,s),Q(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=>$d(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??(Bs(t)?"end":null);n&&(s.dataset.align=n),t.headerTitle&&(s.title=t.headerTitle);let r=jd(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),c("span",{class:"zx-table__sort-icon",ariaHidden:"true"},w("arrow-up",{size:D.sort})));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:Jo(e,this._rowKind),l=a===null?null:ea(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},w("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??(Bs(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&&Xe(h,e)!==!1&&(p.dataset.editable="true"),this._renderCellContent(p,h,e,t,s),r.append(p)}),this._rowNames.set(r,vd([...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=kd(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)},w(u?"chevron-down":"chevron-right",{size:D.chevron})))}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&&xt(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&&Wo(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&&xt(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&&Wo(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=Xe(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=()=>Oe(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(gd)??u,d}if(r==="number"){let f=Fe(t.locale,s),_=sa(t,s),m=t.type==="currency"?Fe(t.currency,s):t.type==="unit"?Fe(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 Ue(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}),Oe(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 $(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=()=>Oe(t,m.value,s),d}if(r==="date"){let f=new Me(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===""?Oe(t,null,s):(f.set(m,{silent:!0}),f.get()===null&&f.set(g,{silent:!0}),Oe(t,f.get(),s))},d}if(r==="checkbox"){let f=new Ye(null,{...a,checked:!!o});return u.append(f.el),d.component=f,d.control=f.el,d.read=()=>Oe(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??`${Si(t)} row ${n+1}`,value:Ed(t,o,s)});return u.append(p),d.control=p,d.read=()=>Oe(t,p.value,s),d}_focusEditor(e){let t=this._edit?.cells.get(e),s=t?.control;!s||typeof s.focus!="function"||(s.focus(),Bd(t.type)&&typeof s.select=="function"&&s.select())}_focusCell(e,t){let s=this._rowElements.get(e)?.[0];(s?Go(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&&xt(t)){if(Pd(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)&&Xe(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&&xt(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=Q(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&&xt(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=wd(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=bd({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 yd(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,!js(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]));js(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?Cd(this._data,this.options.rowId,this._hierarchy.parentId,t,this._sort.dir):Ps(this._data,t,this._sort.dir)}_setRowExpanded(e,t,s){return this._hierarchy?wi(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=wi(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 bd(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 yd(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 wd(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 vd(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 Jo(i,e){if(e==null||e==="")return null;let t=typeof e=="function"?e(i):i?.[e];return t==null?null:String(t)}function ea(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 ta(i,e,t){return!!ea(t,Jo(i,e))?.span}function xd(i,e,t){return!Array.isArray(i)||e==null||t==null?!1:i.some(s=>ta(s,e,t))}function Sd(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 kd(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=Fe(i.locale,e),o=sa(i,e),a={...r!=null?{locale:String(r)}:{},...o!=null?{decimals:o}:{}};if(n==="number")return yi(s,a);if(n==="currency"){let l=Fe(i.currency,e);return Lo(s,l==null?null:String(l),a)}if(n==="percent")return Po(s,a);if(n==="unit"){let l=yi(s,a),u=Fe(i.unit,e);return l&&u!=null&&String(u)!==""?`${l}\xA0${u}`:l}return s}function zd(i,e,t,s=[]){let n=Ai(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 Cd(i,e,t,s,n){let r=Ai(i,e,t),o=u=>Ps(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 ia(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(Q(e,h),t)),a=i.findIndex(h=>Object.is(Q(e,h),s));if(o<0||a<0||r&&!Vs(Q(r,i[o]),Q(r,i[a])))return null;if(r){let h=Ai(i,e,r),p=h.nodes[o],f=h.nodes[a];if(!p||!f||p.parent!==f.parent)return null;let _=x=>{let E=[],H=[x];for(;H.length;){let Z=H.pop();E.push(Z);for(let oe=Z.children.length-1;oe>=0;oe-=1)H.push(Z.children[oe])}return E},m=new Set(_(p).map(x=>x.index)),g=new Set(_(f).map(x=>x.index)),b=i.filter((x,E)=>m.has(E)),y=i.filter((x,E)=>!m.has(E)),A=i.map((x,E)=>E).filter(x=>!m.has(x)),v=A.findIndex(x=>x===a);if(n==="after"){let x=A.map((E,H)=>g.has(E)?H:-1).filter(E=>E>=0);v=Math.max(...x)+1}return v<0?null:(y.splice(v,0,...b),y)}let l=[...i],[u]=l.splice(o,1),d=l.findIndex(h=>Object.is(Q(e,h),s));return l.splice(d+(n==="after"?1:0),0,u),l}function Xe(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?Bs(i)?"number":"text":typeof t=="string"&&_d.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 Ed(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 Oe(i,e,t){return typeof i?.parse=="function"?i.parse(e,t):e}function Id(i,e){return Object.is(i,e)?!0:i instanceof Date&&e instanceof Date?i.getTime()===e.getTime():!1}function Td(i,e){let t={};for(let[s,n]of Object.entries(e??{}))Id(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 Fe(i,e){return typeof i=="function"?i(e):i}function sa(i,e){let t=Fe(i?.decimals,e);if(t==null)return null;let s=Number(t);return Number.isFinite(s)?Math.max(0,Math.trunc(s)):null}function Bs(i){return["number","currency","percent","unit"].includes(i?.type)}function Ai(i,e,t){let s=(Array.isArray(i)?i:[]).map((a,l)=>({row:a,id:Q(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=Q(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 wi(i,e,t){return Ai(i,e,t).nodes.filter(s=>s.children.length>0).map(s=>s.id)}function Q(i,e){return typeof i=="function"?i(e):e?.[i]}function Vs(i,e){return i==null&&e==null||Object.is(i,e)}function vi(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 Nd(i){return typeof i=="function"||typeof i=="string"&&i!==""?i:null}function Od(i){return!i||typeof i!="object"||Array.isArray(i)?null:i}function Fd(i){return new Set(Array.isArray(i)?i:[])}function Rd(i){return i==="plain"?"plain":"default"}function Ld(i){return i==="cell"||i==="row"?i:i===!0?"cell":!1}function xt(i){return!!i?.closest?.(".zx-table__editor")}function Wo(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 Pd(i){return i.closest("[popover]")?!0:i.getAttribute?.("aria-expanded")==="true"}function Zo(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 Si(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 jd(i){let e=i?.label==null?"":String(i.label).trim(),t=i?.ariaLabel==null?"":String(i.ariaLabel).trim();return t||(e?null:Si(i)||null)}function Bd(i){return i==="text"||i==="number"||i==="date"}function Vd(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 qd(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 Go(i,e){for(let t of i.cells)if(t.dataset.column===e)return t;return null}function Qo(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 $d(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 Xo(i){if(!Array.isArray(i))throw new TypeError("Table data must be an array")}function js(i,e){return i.size===e.size&&[...i].every(t=>e.has(t))}function xi(i,e){return i.length===e.length&&i.every((t,s)=>Object.is(t,e[s]))}function Hd(i){let e=Math.trunc(Number(i));return Number.isFinite(e)&&e>0?e:null}var Kd=["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(","),Je=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=Y(e);if(!s)throw new TypeError("Dropdown anchor could not be resolved");super(null,t),this.#e=s,We(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:I("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=G(this.#e,this.el,{placement:this.options.placement,offset:Number(this.options.offset),matchWidth:!!this.options.matchWidth}),this.el.dataset.state="open",this.#s=Qe({kind:"popup",root:this.el,owner:this,anchor:[this.#e,Y(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(),Ze(this.el.parentElement)&&this.el.parentElement?.isConnected&&se(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 Ud(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)Zd(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 Ze(this.#e)??Ze(Y(this.options.scope))??wt(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=qs(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=qs(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=Yd(this.#e,this.el);r&&(e.preventDefault(),r.focus())}#d(e){this.#i.set(e,this.#e.getAttribute(e))}};function Ud(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 qs(i){return Array.from(i.querySelectorAll(Kd)).filter(e=>Wd(e))}function Yd(i,e){let t=Ze(i)??i.ownerDocument.body??i.ownerDocument.documentElement,s=qs(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 Wd(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 Zd(i,e,t){t===null?i.removeAttribute(e):i.setAttribute(e,t)}var Hs=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),$s=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:K(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&&U(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=na(e.size,"36px"),s=na(e.iconSize,"52%");this.el.style.setProperty("--zx-app-icon-size",t),this.el.style.setProperty("--zx-app-icon-glyph-size",s),xe(e.color)?this.el.style.setProperty("--zx-app-icon-color",String(e.color)):this.el.style.removeProperty("--zx-app-icon-color"),Hs.includes(e.tone)?this.el.dataset.tone=e.tone:delete this.el.dataset.tone,this.el.dataset.glass=Qd(e.glass),this.el.dataset.shape=Xd(e.shape),this.el.toggleAttribute("data-selected",!!e.selected);let n=e.label==null?"":String(e.label).trim();if(this._interactiveRoot){let u=ra(this._snapshot,"role"),d=ra(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=Gd(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 ki(i={}){return new $s(null,i).toElement()}function Gd(i){let e=typeof i=="function"?i():i;return typeof e=="string"?w(e,{size:"1em"}):e&&typeof e=="object"&&typeof e.nodeType=="number"?e:null}function na(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 Qd(i){return i===!1||i==="none"?"none":i==="strong"?"strong":"subtle"}function Xd(i){return i==="circle"?"circle":"tile"}function ra(i,e){return i?.attributes.find(([t])=>t===e)?.[1]??null}var Di=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=At(this.options.items),this._sources=ca(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=I("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"},w("x",{size:D.dismiss})),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")},w("x",{size:D.dismiss})),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("span",{class:"zx-launcher__shortcut",ariaHidden:"true"},me("Mod+K")):null,f=Jd(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"}},w("search"),a,r,p,l),u,h,f,d)),e.dataset.state="closed",this._createdRoot&&We(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=se(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=Qe({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"),oa(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=At(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=ca(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=>zi(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,At(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&&!oa(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)?At(e.items):[],sources:typeof e.items=="function"?[sh(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!et(t)||t.label==null?[]:[ua({...t,id:t.id??t.label})]}return eh(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=>zi(m.when,n)),a=aa(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=>zi(b.when,n)):aa(g.filter(b=>zi(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=et(e),n=s?null:qe(e.href),r=n?"a":"button",o=[],a=nh(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=ih(e),u=th(e.shortcut);return u.length&&o.push(c("span",{class:"zx-launcher__keys",ariaHidden:l?"true":null},me(u,{size:"sm"}))),s&&o.push(c("span",{class:"zx-launcher__chevron",ariaHidden:"true"},w("chevron-right",{size:D.chevron}))),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:I("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:rh(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||!et(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=oh(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(et(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?F(t,s):n}};function Jd(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",{},me(["\u2191\u2193\u2190\u2192"]),t.move??e.move),c("span",{},me("Enter"),t.open??e.open),c("span",{ref:"backHint",hidden:!0},me("Backspace"),t.back??e.back),c("span",{},me("Escape"),t.close??e.close))}function et(i){let e=i?.items;return!!i&&typeof i=="object"&&(Array.isArray(e)||typeof e=="function")}function eh(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 At(r)){if(!et(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 th(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 ih(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 sh(i){return{id:`page:${String(i.id)}`,load:i.items,order:i.order==="source"?"source":"rank",_page:!0}}function oa(i,e){return i.length===e.length&&i.every((t,s)=>t===e[s]||String(t.id)===String(e[s].id))}function nh(i){let e=i.icon;if(typeof e=="function"&&(e=e(i)),typeof e=="string")return w(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 rh(i){return i==="application"||i==="record"?i:"action"}function zi(i,e){return i==="empty"?e==="":i==="query"?e!=="":!0}function oh(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 aa(i,e,t=100){let s=tt(e).trim(),n=i.map((o,a)=>({item:o,order:a,score:ah(o,s)})).filter(({score:o})=>o<1/0);n.sort((o,a)=>{let l=Ci(o.item.groupOrder),u=Ci(a.item.groupOrder);if(l!==u)return l-u;if(s===""){let d=la(o.item.pinned,o.order),h=la(a.item.pinned,a.order);if(d!==h)return d-h}return o.score-a.score||Ci(o.item.itemOrder)-Ci(a.item.itemOrder)||lh(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 ah(i,e){if(!e)return i.pinned?-1:0;let t=tt(i.label),s=tt(i.id),n=tt(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 la(i,e){return typeof i=="number"&&Number.isFinite(i)?i:i?e:Number.MAX_SAFE_INTEGER}function Ci(i){return typeof i=="number"&&Number.isFinite(i)?i:Number.MAX_SAFE_INTEGER}function tt(i){return String(i??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function lh(i,e){let t=tt(i),s=tt(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 At(i){return Array.isArray(i)?i.filter(e=>e&&typeof e=="object"&&e.id!=null&&e.label!=null).map(e=>ua(e)):[]}function ua(i){let e={...i,label:String(i.label)};if(i.href==null)return e;let t=qe(i.href);return t!==null?e.href=t:(delete e.href,typeof e.invoke!="function"&&!et(e)&&(e.disabled=!0)),e}function ca(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 ch=new Set(["top","bottom","top-start","top-end","bottom-start","bottom-end","left","right","left-start","left-end","right-start","right-end"]),uh=new Set(["hover","focus","both","manual"]),it=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=Y(e);if(!s)throw new TypeError("Tooltip anchor could not be resolved");super(null,t),this.#e=s,We(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",hh(this.options.maxWidth));let n=uh.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||!fh(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:I("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=wt(this.#e);this.el.parentElement!==e&&e.append(this.el);let t=da(this.#t);if(t===null)return this;this.el.replaceChildren(t);let s=ch.has(this.options.placement)?this.options.placement:"top";return this.#i=G(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",dh(this.#s,this.el.id)),this.#c=Qe({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=da(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 da(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 dh(i,e){let t=String(i??"").split(/\s+/).filter(Boolean);return t.includes(e)||t.push(e),t.join(" ")}function hh(i){return typeof i=="number"&&Number.isFinite(i)?`${i}px`:String(i)}function fh(i){try{return i.matches(":focus-visible")}catch{return!0}}var Ei=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=Re(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 pa(n,this.options.header),pa(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=Re(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&&fa(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 fa(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 Ks(this.el);let e=!1;for(let t of Us(this._items)){if(t===ma){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 it(n,{content:t.label,placement:bh(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 ha(e,{className:"zx-app-rail__item",index:String(e.id),iconOnly:!0,disclosure:t,disclosureIcon:ph(this.el.dataset.side),visual:Ii(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 Us(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,_=ha(h,{className:"zx-app-rail__flyout-item",index:p,iconOnly:!1,disclosure:f,disclosureIcon:mh(this.el.dataset.side),visual:Ii(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 Je(t,{openOn:"manual",placement:n===null?_h(this.el.dataset.side):gh(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=yh(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=_a(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?Ys(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&&Ys(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?F(t,s):n}},Ks=class extends S{constructor(e){super(null),e.append(this.el)}render(){return c("span",{hidden:!0,"data-zx-app-rail-listener-scope":""})}},ma=Object.freeze({});function Us(i,e=!1){return i.flatMap(t=>t.section?[e?t:ma,...Us(t.children??[],e)]:[t])}function Re(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)?Re(e.children):[]};if(e.section===!0)return s.section=!0,delete s.href,s;if(e.href==null)return s;let n=qe(e.href);return n!==null?s.href=n:(delete s.href,s.children.length===0&&typeof s.invoke!="function"&&(s.disabled=!0)),s}):[]}function Ii(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 w(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 ha(i,{className:e,index:t,iconOnly:s,disclosure:n,disclosureIcon:r,visual:o}){let a=qe(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"},w(r)):null)}function ph(i){return{left:"chevron-right",right:"chevron-left",top:"chevron-down",bottom:"chevron-up"}[i]??"chevron-right"}function mh(i){return i==="right"?"chevron-left":"chevron-right"}function _h(i){return{left:"right-start",right:"left-start",top:"bottom-start",bottom:"top-start"}[i]??"right-start"}function gh(i){return i==="right"?"left-start":"right-start"}function bh(i){return{left:"right",right:"left",top:"bottom",bottom:"top"}[i]??"right"}function _a(i){return[...i.querySelectorAll('a:not([aria-disabled="true"]), button:not([aria-disabled="true"])')]}function fa(i){return _a(i)[0]??null}function yh(i){return[...i.children].map(e=>e.querySelector("[data-app-nav-id]")).filter(Boolean)}function Ys(i,e){return i.some(t=>String(t.id)===e||Ys(t.children??[],e))}function pa(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 wh=["tint","solid","plain"],vh=12,xh=600,Mi=class extends Ei{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=Gs(this._items,this._sections),this._appearance=wh.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=Ws(this.options.labels,e.dataset.orientation),e}setItems(e){let t=new Map,s=Gs(Re(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=_e(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&&Zs(a,s,"zx-app-rail__flyout-item");let r=this._catalogueEntry(n);return r&&Zs(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=Ws(this._labels,t),this._rebuild(),this)}setLabels(e){this._labels=e;let t=Ws(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")?Ti(s):null;return this.el.dataset.labels=t,this._rebuild(),n!==null&&[...this.refs.list.querySelectorAll(".zx-module-bar__item")].find(r=>Ti(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=wa(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&&!_e(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=_e(this._items,t.getAttribute("data-app-nav-value-id"));if(!s)continue;let n=ya(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=_e(this._items,t.dataset.moduleId),n=s?ya(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=[Ch(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),ga(e),o=kh(e,this.el.dataset.orientation==="horizontal",t.length+1)}let a=Sh(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);ga(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=Ii(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}=Ah(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(ki({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"}},w("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 it(s,{content:e,placement:{left:"right",right:"left",top:"bottom",bottom:"top"}[this.el.dataset.side]??"right",delay:450}));let n=this._items.length>vh?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?I("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 Je(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 Zs(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=_e(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=zh(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=_e(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>xh?e:this._typeahead.text+e;this._typeahead={text:r,at:n};let o=r.toLocaleLowerCase(),a=[...o].every(h=>h===o[0]),l=h=>(_e(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=>Ti(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=Ti(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=_e(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 Sh(i,e=1/0,t=[],s=!1){let n=Array.isArray(i)?i.filter(_=>_&&_.id!=null):[],r=wa(n),a=n.some(ba)?r.filter(ba):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 Ah(i){let e=xe(i?.color)?String(i.color).trim():null;return e?{tone:null,color:e}:{tone:Hs.includes(i?.tone)?i.tone:null,color:null}}function Gs(i,e=new Map,t=null){return i.flatMap(s=>s.section?Gs(s.children??[],e,s.label):(t!==null&&e.set(String(s.id),t),[s]))}function ga(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 Ws(i,e){return e!=="vertical"?"hidden":i==="below"||i==="beside"?i:"hidden"}function ba(i){return i.pinned===!0||typeof i.pinned=="number"&&Number.isFinite(i.pinned)}function wa(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 kh(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 zh(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 Ti(i){return i.getAttribute("data-app-nav-value-id")??"\0more"}function ya(i,e){return e===null?null:String(i.id)===e?"page":Qs(i.children??[],e)?"true":null}function Zs(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 Ch(i,e){if(e==null||!Array.isArray(i))return null;let t=String(e);return i.find(s=>String(s.id)===t||Qs(s.children??[],t))??null}function _e(i,e){if(e==null)return null;for(let t of i??[]){if(String(t.id)===String(e))return t;let s=_e(t.children??[],e);if(s)return s}return null}function Qs(i,e){return i.some(t=>String(t.id)===e||Qs(t.children??[],e))}var Dh=8e3,Js=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}},Ce=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:Ph(t),this._entries=new Set,this._floatingHost=null,this._placedIn=null,this._overlay=null,this._unfollow=null,this._queue=new Js(Fh(this.options.maxVisible),s=>{this._activate(s)}),t.replaceChildren(),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t}show(e,t={}){let s=Mh(t.action),n={kind:Eh(t.kind??this.options.kind),timeout:Th(t.timeout??this.options.timeout,s!==null),closable:t.closable??!!this.options.closable,action:s,leading:Nh(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=Y(e);if(!t)return!1;let s=i.#t(se(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)Xs(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&jh(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=Rh(r),o!==void 0&&(t.text=String(o)),Ni(s,t))},done:()=>{n||s.closed||(n=!0,t.pct=100,Ni(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(w("error",{size:18})),Ni(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??w(t.kind,{size:18})),r=c("div",{class:"zx-message__content"});kt(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,Ni(a,s)}if(t.action){let{label:l,kind:u,onclick:d}=t.action,h=Yo({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")},w("x",{size:D.dismiss}));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=kt(u)&&!o.contains(u)?u:null}a.focused=!0,this._pause(a)}),this.listen(o,"focusout",l=>{let u=l.relatedTarget;kt(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,Xs(e),Oh(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",!Lh()){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)&&(Xs(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=Ge.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=se(e??null);t.isConnected||(t=se(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=Ge.push({kind:"toast",root:n,owner:r}),r._unfollow=Ge.subscribe(()=>r._rehome()),r._rehome(),r}static#t(e){for(let t of Ge.entries())if(t.kind==="toast"&&t.owner instanceof i&&t.owner._floatingHost===e)return t.owner;return null}static#i(e){e._disposeFloating()}};function Eh(i){return i==="danger"?"error":["success","warning","error"].includes(String(i))?i:"info"}function Ih(i){let e=Number(i);return Number.isFinite(e)?Math.max(0,e):4e3}function Th(i,e=!1){let t=Ih(i);return e&&t>0?Math.max(t,Dh):t}function Mh(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 Nh(i){if(kt(i))return i;if(i&&typeof i=="object"&&typeof i.toElement=="function"){let e=i.toElement();return kt(e)?e:null}return null}function Oh(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 Fh(i){let e=Number(i);return Number.isInteger(e)&&e>0?e:5}function kt(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function Rh(i){let e=Number(i);return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function Ni(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 Xs(i){i.timer!==null&&clearTimeout(i.timer),i.exitTimer!==null&&clearTimeout(i.exitTimer),i.timer=null,i.exitTimer=null}function Lh(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function Ph(i){return{attributes:Array.from(i.attributes,e=>[e.name,e.value]),children:Array.from(i.childNodes)}}function jh(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 Fi=Object.freeze(["agenda","day","week","month","year"]),Bh=864e5;function tn(i,e,t={}){let s=Le(e,"Calendar date"),n=Ca(t.weekStart??1),r,o;if(i==="agenda")r=P(s),o=N(r,Li(t.agendaDays??14,"agendaDays"));else if(i==="day")r=P(s),o=N(r,1);else if(i==="week")r=Oi(s,n),o=N(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=Oi(a,n),o=N(Oi(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 sn(i,e,t,s={}){let n=Le(e,"Calendar date"),r=be(t,"direction");if(i==="day")n.setDate(n.getDate()+r);else if(i==="agenda")n.setDate(n.getDate()+r*Li(s.agendaDays??14,"agendaDays"));else if(i==="week")n.setDate(n.getDate()+r*7);else{if(i==="month")return en(n,r);if(i==="year")return en(n,r*12);throw new RangeError(`Unknown calendar view: ${i}`)}return n}function en(i,e){let t=Le(i,"Calendar date"),s=t.getDate();return t.setDate(1),t.setMonth(t.getMonth()+be(e,"month amount")),t.setDate(Math.min(s,Vh(t.getFullYear(),t.getMonth()))),t}function Vh(i,e){return new Date(i,e+1,0).getDate()}function st(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=ge(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=xa(ge(r,t.start),s,`event ${l} start`),d=ge(r,t.end),h=d==null||d===""?new Date(u.getTime()):xa(d,s,`event ${l} end`);if(h<u)throw new RangeError(`Calendar event ${l} ends before it starts`);let p=String(ge(r,t.title)??"").trim()||"Untitled event",f=String(ge(r,t.location)??"").trim(),_=Sa(ge(r,t.editable)),m=Sa(ge(r,t.durationEditable));return{id:a,title:p,start:u,end:h,allDay:!!ge(r,t.allDay),color:$h(ge(r,t.color)),location:f,editable:_,durationEditable:m,data:r}})}function j(i){return{...i,start:new Date(i.start.getTime()),end:new Date(i.end.getTime())}}function nn(i,e,t={}){let s=za(t.minMinutes??0,"minMinutes"),n=za(t.maxMinutes??1440,"maxMinutes",!0),r=Li(t.minimumMinutes??30,"minimumMinutes");if(n<=s)throw new RangeError("Calendar maxMinutes must exceed minMinutes");let o=P(e),a=Aa(o,s),l=Aa(o,n),u=i.filter(f=>!ce(f)&&rn(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:ka(o,_),endMinutes:ka(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 Ri(i,e,t){let s=P(e),n=N(s,Li(t,"days")),r=i.filter(a=>ce(a)&&rn(a,s,n)).map(a=>{let l=P(a.start),u=qh(a);return{event:a,start:Math.max(0,X(s,l)),end:Math.min(t,X(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 zt(i,e={}){let t=be(e.days??0,"days"),s=be(e.minutes??0,"minutes"),n=be(e.endDays??t,"endDays"),r=be(e.endMinutes??s,"endMinutes"),o=j(i);if(o.start=va(o.start,t,s),o.end=va(o.end,n,r),o.end<o.start)throw new RangeError("Calendar event proposal ends before it starts");return o}function P(i){let e=Le(i,"Calendar date");return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function N(i,e){let t=Le(i,"Calendar date"),s=new Date(t.getTime());return s.setDate(s.getDate()+be(e,"day amount")),s}function Oi(i,e=1){let t=P(i),s=Ca(e);return N(t,-((t.getDay()-s+7)%7))}function X(i,e){let t=P(i),s=P(e),n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),r=Date.UTC(s.getFullYear(),s.getMonth(),s.getDate());return Math.round((r-n)/Bh)}function V(i){let e=Le(i,"Calendar date"),t=s=>String(s).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function ce(i){if(i.allDay)return!0;if(i.end<=i.start)return!1;let e=new Date(i.end.getTime()-1);return V(i.start)!==V(e)}function Ct(i,e,t){return rn(i,e,t)}function va(i,e,t){let s=new Date(i.getTime());return s.setDate(s.getDate()+e),s.setMinutes(s.getMinutes()+t),s}function qh(i){if(i.end<=i.start)return N(P(i.start),1);let e=P(i.end);return i.end.getTime()===e.getTime()?e:N(e,1)}function rn(i,e,t){let s=i.end>i.start?i.end:new Date(i.start.getTime()+1);return i.start<t&&s>e}function ge(i,e){return typeof e=="function"?e(i):i[e]}function xa(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 Le(s,t)}function Sa(i){return i==null?null:!!i}function $h(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 Aa(i,e){let t=P(i);return t.setMinutes(e),t}function ka(i,e){return(e.getTime()-i.getTime())/6e4}function Le(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 Ca(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 be(i,e){let t=Number(i);if(!Number.isInteger(t))throw new TypeError(`${e} must be an integer`);return t}function Li(i,e){let t=be(i,e);if(t<=0)throw new RangeError(`${e} must be greater than zero`);return t}function za(i,e,t=!1){let s=be(i,e),n=t?1440:1439;if(s<0||s>n)throw new RangeError(`${e} must be from 0 through ${n}`);return s}var Et=class extends S{static cssName="calendar";static defaults={events:[],date:null,view:"month",views:[...Fi],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=Hh(this.options.views),this._view=this._views.includes(this.options.view)?this.options.view:this._views[0],this._date=Da(this.options.date,this.options.dateUnit,this._now()),this._events=st(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},w("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(j)}setEvents(e,t={}){let s=st(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]=st([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]=st([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=Da(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="${Pi(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?w(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=tn(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=X(e.start,e.end);for(let n=0;n<s;n+=1){let r=N(e.start,n),o=N(r,1),a=this._events.filter(d=>Ct(d,r,o)?d.start>=r||n===0:!1).sort(Yh),l=c("section",{class:"zx-calendar__agenda-day",role:"row",dataset:{date:V(r)}},c("button",{type:"button",class:"zx-calendar__agenda-heading",role:"rowheader",dataset:{calendarAction:"date",date:V(r),dateCell:"true"},ariaCurrent:je(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:X(e.start,e.end)},(b,y)=>N(e.start,y)),s=this._view==="week"&&this.options.workweek?t.filter(b=>b.getDay()>0&&b.getDay()<6):t,n=ye(this.options.slotMinTime,0),r=ye(this.options.slotMaxTime,1440,!0),o=ne(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:V(b),dateCell:"true"},ariaCurrent:je(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?on(y,this.options.locale):""));for(let A=0;A<s.length;A+=1){let v=Uh(s[A],y),x=String(v.getTime()),E=this._focusedSlot?this._focusedSlot===x:m;E&&(m=!1),_.append(c("button",{type:"button",class:"zx-calendar__slot",role:"gridcell",tabindex:E?0:-1,dataset:{calendarAction:"date",slot:x,dateTime:x,dayIndex:String(A),rowIndex:String(b),major:y%60===0?"true":null},ariaLabel:this._dateTimeLabel(v),disabled:this.options.disabled}))}}let g=c("div",{class:"zx-calendar__timed-events",ariaHidden:"false"});return s.forEach((b,y)=>{let A=nn(this._events,b,{minMinutes:n,maxMinutes:r,minimumMinutes:o});for(let v of A){let x=(v.startMinutes-n)/(r-n)*100,E=Math.max(o/(r-n)*100,(v.endMinutes-v.startMinutes)/(r-n)*100),H=100/s.length,Z=H/v.columns,oe=y*H+v.column*Z,k=this._eventElement(v.event,{variant:"timed",day:b,resizable:!0});k.style.insetInlineStart=`${oe}%`,k.style.inlineSize=`${Z}%`,k.style.insetBlockStart=`${x}%`,k.style.blockSize=`${E}%`,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:V(r)},ariaHidden:"true"}));let n=Ri(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=N(e.start,r);s.append(c("span",{class:"zx-calendar__month-weekday",role:"columnheader"},this._format(o,{weekday:"short"})))}t.append(s);let n=X(e.start,e.end)/7;for(let r=0;r<n;r+=1){let o=N(e.start,r*7),a=Ri(this._events.map(m=>({...m,allDay:!0})),o,7),l=Kh(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:V(o)}});this.options.weekNumbers&&h.append(c("button",{type:"button",class:"zx-calendar__month-week-number",dataset:{calendarAction:"week",date:V(o)},ariaLabel:this.msg("calendar.weekNumber",Ia(o)),disabled:this.options.disabled},String(Ia(o))));let p=c("div",{class:"zx-calendar__month-days"});for(let m=0;m<7;m+=1){let g=N(o,m),b=this._events.filter(y=>Ct(y,g,N(g,1))).length;p.append(c("button",{type:"button",class:"zx-calendar__month-day",role:"gridcell",dataset:{calendarAction:"date",date:V(g),dateCell:"true",otherMonth:g.getMonth()===this._date.getMonth()?null:"true",eventCount:String(b)},ariaCurrent:je(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:N(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=N(o,m);f.append(c("button",{type:"button",class:"zx-calendar__more",dataset:{calendarAction:"more",date:V(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=N(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=N(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=N(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=>Ct(p,d,N(d,1))).length;l.append(c("button",{type:"button",class:"zx-calendar__year-day",role:"gridcell",dataset:{calendarAction:"date",date:V(d),dateCell:"true",activity:String(Math.min(3,h))},ariaCurrent:je(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(j(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=>je(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"},on(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:j(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=De(t.dataset.date);r&&this.setDate(r).setView("week")}else if(n==="more"){let r=De(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:j(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?N(n,1):Pe(n,ne(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:j(s),jsEvent:e});return}if(e.key===" "&&!this._keyboardEdit){if(n?!this._canResize(s):!this._canMove(s))return;e.preventDefault(),this._keyboardEdit={oldEvent:j(s),event:j(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=!ce(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=-ne(this.options.slotDuration):r=-7;else if(e.key==="ArrowDown")a?o=ne(this.options.slotDuration):r=7;else return;e.preventDefault();let l=this._keyboardEdit;if(l.action==="move")l.event=zt(l.event,{days:r,minutes:o});else{let u=zt(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=De(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=N(s,n),o=this.el.querySelector(`[data-date-cell][data-date="${V(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:j(r),event:j(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:Pe(n,ne(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=ne(this.options.slotDuration);t.end=Pe(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:Pe(t.end,-ne(this.options.slotDuration)),n=t.start<t.end?t.end:Pe(t.start,ne(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"&&!ce(e),o=this._timeAtPoint(s,n,r?e.start:null);if(o&&!ce(e)){if(t==="move"){let f=e.end.getTime()-e.start.getTime(),_=j(e);return _.start=Pe(o,-Number(this._pointer?.timeOffsetMinutes??0)),_.end=new Date(_.start.getTime()+f),_}let p=j(e);return p.end=Pe(o,ne(this.options.slotDuration)),p.end>p.start?p:null}let a=this._dayAtPoint(s,n);if(!a)return null;let l=N(a,-Number(this._pointer?.dayOffset??0)),u=X(P(e.start),l);if(t==="move")return zt(e,{days:u,minutes:0});let d=j(e),h=N(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 De(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=De(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 N(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 De(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 De(a)}return null}_dragOffsetForEvent(e,t,s){if(!ce(e)){let o=this._timeAtPoint(t,s);if(o){let a=ne(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?X(P(e.start),n):0;return{minutes:0,days:Math.max(0,r)}}_timeGridDayIndex(e){let t=V(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")||ce(e))return null;let s=ye(this.options.slotMinTime,0),n=ye(this.options.slotMaxTime,1440,!0),r=ne(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:j(t),oldEvent:j(e),action:s,delta:Wh(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?j(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(sn(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=N(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(ce(e))return je(e.start,t)?`${Dt(e.start,this.options.locale)} \u2192`:je(e.end,t)?`\u2192 ${Dt(e.end,this.options.locale)}`:this.msg("calendar.allDay");let s=an(e.start,this.options.locale);return e.end<=e.start?s:`${s}\u2013${an(e.end,this.options.locale)}`}_eventLabel(e){let t=e.location?`, ${e.location}`:"";return`${e.title}, ${Dt(e.start,this.options.locale)} to ${Dt(e.end,this.options.locale)}${t}`}_dateTimeLabel(e){return Dt(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 De(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="${Pi(e.eventId)}"][data-event-action="${e.eventAction??"activate"}"]`)),!t&&e.slot&&(t=this.el.querySelector(`[data-slot="${Pi(e.slot)}"]`)),!t&&e.date&&(t=this.el.querySelector(`[data-date-cell][data-date="${Pi(e.date)}"]`)),t?.focus?.()}_scrollTimeGrid(){let e=this.refs.body.querySelector(".zx-calendar__time-scroller");if(!e)return;let t=ye(this.options.slotMinTime,0),s=ye(this.options.slotMaxTime,1440,!0),n=ye(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===V(s)),r=ye(this.options.slotMinTime,0),o=ye(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=on(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?F(t,s):n}};function Hh(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(!Fi.includes(t))throw new RangeError(`Unknown Calendar view: ${t}`);return e}function Da(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 ne(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 Kh(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 ye(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 Uh(i,e){let t=P(i);return t.setMinutes(e),t}function Pe(i,e){let t=new Date(i.getTime());return t.setMinutes(t.getMinutes()+e),t}function Ea(i){return`${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`}function je(i,e){return Ea(i)===Ea(e)}function De(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 V(t)===i?t:null}function Yh(i,e){return i.start-e.start||e.end-i.end||i.title.localeCompare(e.title)}function on(i,e){let t=new Date(2026,0,1);return t.setHours(Math.floor(i/60)%24,i%60,0,0),an(t,e)}function an(i,e){return new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit"}).format(i)}function Dt(i,e){return new Intl.DateTimeFormat(e,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(i)}function Ia(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 Wh(i,e){let t=e.start.getTime()-i.start.getTime();return{milliseconds:t,days:X(P(i.start),P(e.start)),minutes:Math.round(t/6e4),endMilliseconds:e.end.getTime()-i.end.getTime()}}function Pi(i){return globalThis.CSS?.escape?CSS.escape(i):i.replace(/[^a-zA-Z0-9_-]/g,e=>`\\${e}`)}var Ta=Object.freeze([Object.freeze(["getValue","setValue"]),Object.freeze(["get","set"]),Object.freeze(["getValues","setValues"]),Object.freeze(["isChecked","setChecked"])]),Zh=Object.freeze(["value","values","checked"]),Ma="input, select, textarea, button",Gh="input, textarea";function ji(i){if(L(i))return i;let e=i;if(typeof e.toElement=="function")return e.toElement();if(L(e.el))return e.el;throw new TypeError("External field source must be an Element or a Component")}function Na(i){return Fa(i,ji(i)).get()}function ln(i){let e=ji(i),t=L(i)?null:i;if(t&&we(t,"isDisabled",0))return!!t.isDisabled();if(t&&typeof t.disabled=="boolean")return t.disabled;if(nt(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(Ma)];return n.length>0&&n.every(r=>r.disabled)}function cn(i){let e=ji(i),t=L(i)?null:i;for(let n of["readonly","readOnly"])if(t&&typeof t[n]=="boolean")return t[n];if(nt(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 Oa(i,e=null){let t=ji(i),s=L(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&&nt(t,"value")?t.value:void 0,u=a&&La(t)?t.checked:void 0,d=ln(i),h=cn(i),p=new Map,f=Fa(i,t),_=Qh(s,t,p),m=Xh(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 E=f.get();Jh(E,A)?x.stopImmediatePropagation():A=E}));let v={el:t,get:()=>f.get(),set:(x,E)=>{y=!0;try{f.set(x,E)}finally{y=!1}A=f.get()},focus:()=>{s&&we(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,E]of p)E.disabled!==void 0&&(x.disabled=E.disabled),E.readOnly!==void 0&&(x.readOnly=E.readOnly);p.clear();for(let[x,E]of o)E===null?t.removeAttribute(x):t.setAttribute(x,E);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&&(v.setReadonly=x=>{b=!!x,m(b)}),v}function Fa(i,e){let t=L(i)?null:i;if(t){let s=Ta.find(([o])=>we(t,o,0)),n=s?we(t,s[1],2)?s[1]:Ta.map(([,o])=>o).find(o=>we(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=Zh.find(o=>o in t);if(r)return{get:()=>t[r],set:o=>{t[r]=o}}}return La(e)?{get:()=>!!e.checked,set:s=>{e.checked=!!s}}:nt(e,"value")?{get:()=>e.value,set:s=>{e.value=s??""}}:{get:()=>null,set:()=>{}}}function Qh(i,e,t){return i&&we(i,"setDisabled",1)?s=>i.setDisabled(s):i&&we(i,"enable",0)&&we(i,"disable",0)?s=>s?i.disable():i.enable():i&&typeof i.disabled=="boolean"?s=>{i.disabled=s}:nt(e,"disabled")?s=>{e.disabled=s}:s=>{e.setAttribute("aria-disabled",String(s));for(let n of e.querySelectorAll(Ma))Ra(t,n,"disabled"),n.disabled=s||!!t.get(n)?.disabled}}function Xh(i,e,t){if(i){for(let n of["setReadonly","setReadOnly"])if(we(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(nt(e,"readOnly"))return n=>{e.readOnly=n};let s=[...e.querySelectorAll(Gh)];return s.length?n=>{for(let r of s)Ra(t,r,"readOnly"),r.readOnly=n||!!t.get(r)?.readOnly}:null}function Ra(i,e,t){let s=i.get(e)??{};s[t]===void 0&&(s[t]=!!e[t]),i.set(e,s)}function we(i,e,t){let s=i[e];return typeof s=="function"&&s.length<=t}function nt(i,e){return["INPUT","SELECT","TEXTAREA","BUTTON","FIELDSET","OUTPUT"].includes(i.tagName)&&e in i}function La(i){let e=String(i.type??"").toLowerCase();return i.tagName==="INPUT"&&(e==="checkbox"||e==="radio")}function Jh(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 It=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):I("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 C)n=t;else if(L(t)||t instanceof S){let o=t;n=new C(null,{id:this._controlId(s),name:s,type:"custom",label:s,value:Na(o),disabled:ln(o),readonly:cn(o),adapter:a=>Oa(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 C(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 Tt=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):I("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 It),s=t?new It(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?w(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&&un(a))l=this.msg("form.required");else if(!un(a)&&o.options.type==="int"){let u=ls(a);u.valid?o.setValue(u.value,{silent:!0}):l=this.msg("form.int")}else if(!un(a)&&o.options.type==="float"){let u=cs(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 un(i){return i==null||i===""||i===!1||Array.isArray(i)&&i.length===0}function ef(){xo(),dr(),fr(),eo(),Rr(),Zr(),Eo(),Mo(),oo(),io(),Io(),lo(),co(),zo(),So()}ef();function ue(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??tf(i);s&&ss(String(s));let n=(o,a)=>e?e(o,a):Ce.error(hn(o)),r=async(o,a,l)=>{let u=sf(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,Pa(a)?a:{ID:a,...l}),create:(o,a)=>r("create",o,a),update:(o,a,l)=>r("update",o,l===void 0&&Pa(a)?a:{ID:a,body:l??{}}),reportError:n}}function tf(i){return i.locale??i.language??i.config?.locale??i.metadata?.locale??null}function sf(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=ja(s),a=Ba(o),l=r.filter(p=>{if(typeof p!="string"||!p.toLowerCase().startsWith(e))return!1;let f=ja(p.slice(e.length));return f===o||f===a||Ba(f)===a});if(l.length)return l.sort((p,f)=>p.length-f.length)[0];let u=e==="list"?[`list${dn(s)}`]:[`${e}${dn(nf(s))}`,`${e}${dn(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 Pa(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function hn(i){return i instanceof Error&&i.message||i&&typeof i=="object"&&typeof i.message=="string"?i.message:String(i??"ZeyOS request failed")}function ja(i){return String(i).replace(/[^a-z\d]/gi,"").toLowerCase()}function Ba(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 nf(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 dn(i){return String(i).split(/[^a-z\d]+/i).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}var Be=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"}}),qa=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"}),Mt=Object.freeze({light:"#ffffff",dark:"#141414"}),Nt=Object.create(null);function Bi(i){let e=String(i??"").trim().toLowerCase().replaceAll(/[._\s]+/g,"-");if(!e)return"default";if(Object.hasOwn(Nt,e)||Object.hasOwn(Be,e))return e;let t=qa[e];return t||"default"}function J(i){let e=Bi(i);return Nt[e]??Be[e]??Be.default}function rf(i){return J(i).color}function of(i,{standard:e=!1}={}){let t=J(i);return e?t.fa:t.icon}function af(){return[...new Set([...Object.keys(Be),...Object.keys(Nt)])].sort()}function lf(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=Nt[s]??Be[s]??Be.default;Nt[s]=Object.freeze({label:n.label??r.label,icon:n.icon??r.icon,color:n.color??r.color,fa:n.fa??r.fa})}}function cf(i){let e=fn(i);if(e===null)return Mt.light;let t=Va(e,fn(Mt.light)??1),s=Va(e,fn(Mt.dark)??0);return t>=s?Mt.light:Mt.dark}function fn(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 Va(i,e){return(Math.max(i,e)+.05)/(Math.min(i,e)+.05)}var $a="https://kit.fontawesome.com/ae8320b210.js";function uf(i={}){return bs({kit:$a,...i})}function Vi(i,e={}){let{standard:t=!1,...s}=e,n=J(i);return w(t?`fa:${n.fa}`:`kit:${n.icon}`,s)}function rt(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=Bi(i),h=J(i),p=xe(a)?a:h.color,f=ki({icon:e.icon??Vi(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 pn(i,e={}){return rt(i,{shape:"circle",...e})}var df=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 Ha(i={},e={}){let{standardIcons:t=!1,items:s=[],sources:n=[],...r}=e,o=gn(i.labels),a={standardIcons:t,renderApplicationIcon:i.renderApplicationIcon,renderWebletIcon:i.renderWebletIcon},l=Ka(i,a),u=typeof i.loadRecent=="function"?[]:qi(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)=>qi(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)=>qi(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 hf(i={},e={}){return new Di(null,Ha(i,e))}function Ka(i={},e={}){let t=gn(i.labels),s=Array.isArray(i.pinned)?i.pinned.map(String):[],n=new Set,r=[],o=(a,l=null,u=null)=>{let d=_n(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=$i(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)??pn(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,J(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 qi(i,e={}){let t=String(e.query??""),s=gn(e.labels),n=pf(i,t),r=new Map;return n.flatMap(({raw:o,group:a},l)=>{let u=mf(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=$i(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)??rt(u.entity,{size:28,standard:!!e.standardIcons}),disabled:!h.href&&typeof h.invoke!="function",...h,_zeyos:u}]})}function ff(i={}){return i.weblet!=null&&i.weblet!==""?`weblet#${i.weblet}`:i.fork!=null&&i.fork!==""?`fork#${i.fork}`:String(i.module??"")}function _n(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:mn(i[3])}}return{raw:i,identifier:`weblet#${i[0]}`,label:String(i[1]),module:"weblets",type:"weblet",color:mn(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??J(s).label),module:String(i.module??(n==="module"?s:n==="fork"?"default":"weblets")),type:n,color:mn(i.color)}}function pf(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 mf(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 $i(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 mn(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 gn(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 bn(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=_n(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 _=Ya(s[f.identifier],n),m=_.length?{}:$i(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)??Vi(f.module,{size:"1em",standard:!!e.standardIcons}),color:f.color??J(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,J(d).label]):u(d,d?.id??d?.module,d?.label);else for(let[d,h]of Object.entries(i.modules??{}))u([d,h]);return Re(l)}function Ua(i={},e={}){let{standardIcons:t=!1,appearance:s="solid",...n}=e;return{...n,items:bn(i,{standardIcons:t}),active:i.active??i.activeIdentifier??null,appearance:s}}function _f(i={},e={}){let{standardIcons:t=!1,appearance:s="solid",moduleBar:n={},...r}=e;return{label:"ZeyOS",...r,layout:"modules",items:bn(i,{standardIcons:t}),active:i.active??i.activeIdentifier??null,moduleBar:{appearance:s,...n}}}function gf(i,e={},t={}){return new Mi(i,Ua(e,t))}function Ya(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=Ya(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 Ot(i,e,t={}){let{fields:s,labelKey:n=Xa(i,e),valueKey:r="ID",searchFields:o=Ja(i,e),limit:a=50,filters:l={},value:u=null,...d}=t,h=ue(i),p=s??Qa(r,n,o);return{...d,valueKey:r,labelKey:n,value:u,filter:async f=>{let _=await h.list(e,ut({search:f,filters:l,fields:p,searchFields:o,limit:a}));return yn(i,_).data}}}function bf(i,e,t={}){let s=Ot(i,e,t),n=t.value??null,r=new $(null,s);return r.ready=Ga(r,i,e,n),r}function Za(i,e,t={}){let{fields:s,labelKey:n=Xa(i,e),valueKey:r="ID",searchFields:o=Ja(i,e),subtitleKey:a=null,moduleKey:l=()=>e,groupKey:u=null,none:d=!0,recent:h=[],create:p=!1,renderIcon:f=vf,renderItem:_,renderValueAdornment:m,...g}=t,b=s??Qa(r,n,[...o,...[a,l,u].filter(v=>typeof v=="string")]),y=Ot(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=(v,x=!1)=>{if(f===null)return null;let E=Hi(v,l)??e;return f(v,{resource:e,module:String(E),selected:x})};if(y.renderItem=_??(v=>{let x=A(v);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(Hi(v,n)??"")),a&&Hi(v,a)!=null?c("span",{class:"zx-select__entity-subtitle"},String(Hi(v,a))):null))}),y.renderValueAdornment=m??(v=>A(v,!0)),d!==!1&&(y.noneLabel=typeof d=="string"?d:g.noneLabel??"No selection",y.renderNone=g.renderNone??(v=>c("span",{class:"zx-select__entity-none"},c("span",{class:"zx-select__entity-none-icon",ariaHidden:"true"}),c("span",{},v)))),p){let v=p===!0?{}:p,x=typeof v.oninvoke=="function"?v.oninvoke:null;y.actions=[...Array.isArray(y.actions)?y.actions:[],{id:v.id??"create",label:v.label??"Create new\u2026",group:v.group??"New",icon:v.icon??"plus",invoke:E=>x?.({...E,resource:e})}]}return y}function yf(i,e,t={}){let s=Za(i,e,t),n=t.value??null,r=$.entity(null,s);return r.ready=Ga(r,i,e,n),r}function yn(i,e){return typeof i?.normalizeListResult=="function"?Wa(i.normalizeListResult(e)):Wa(e)}function Wa(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 Ga(i,e,t,s){if(s==null)return i;let n=s&&typeof s=="object"?s:await ue(e).get(t,s),r=wf(n);return i.setItems([r]),i.set(r,{silent:!0}),i}function wf(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 Hi(i,e){return typeof e=="function"?e(i):i&&typeof i=="object"&&typeof e=="string"?i[e]:null}function vf(i,e){return rt(String(e.module??"default"),{size:20})}function Qa(i,e,t){let s=[i,e,...t].filter(n=>typeof n=="string"&&n);return s.length?[...new Set(s)]:void 0}function Xa(i,e){let t=xf(i,e);for(let s of["name","lastname","customernum","transactionnum","number","title","ID"])if(t.includes(s))return s;return t[0]??"ID"}function Ja(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 xf(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 Sf(i,e,t={}){let s=dt(i,e,t),n={},r=[],o=new Map;for(let a of s){let l=Xi(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={...Ot(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:Ef(t.columns),fields:n}]},mapFromRecord:a=>kf(a,s,o),mapToRecord:a=>zf(a,s,o)}}function Af(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=Sf(i,e,t),r=()=>t.scope??a.el,o=ue(i,{onError:m=>s?Ce.error(hn(m),{scope:r()}):void 0}),a=new Tt(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:wn(await o.get(b,y)),v=$.from(a.getField(g)?.getInput());v instanceof $&&v.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=wn(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?se(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=wn(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&&Ce.success(`${If(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 kf(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]=Qi(o,n.timeZone):s[r]=ve(o)}return s}function zf(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=Rt(o,n.timeZone):o=de(o);else if(Cf(n)&&Df(n.type)&&o!==""&&o!=null){let l=Number(o);Number.isFinite(l)&&(o=l)}s[r]=o}return s}function Cf(i){return i.enums!=null||i.enum!=null}function Df(i){return/^(?:smallint|integer|bigint|int|int2|int4|int8|numeric|decimal)$/i.test(String(i??""))}function Ef(i){let e=Number(i??2);return[1,2,3].includes(e)?e:2}function wn(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 If(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 Tf=["variant","zebra","stickyHeader","responsive","growing","emptyText","rowClass","rowKind","rowKinds","columnVisibility","columnReorder","hiddenColumns","onrowdblclick","onsort","onselectionchange","ondatachange","onstackedchange","ongrow","oncolumnvisibilitychange","oncolumnorderchange"];function xn(i,e,t={}){let s=dt(i,e,{fields:t.fields,labels:t.labels,formats:t.formats,timeZone:t.timeZone}),n={},r=s.map(l=>{let u={...l},d=Of(u);if(d){let f=Ff(i,d);u.labelField=`${u.id}_label`,n[u.labelField]=`${u.id}.${f}`}n[u.id]=u.id;let h=Rf(u),p=Ji(h?{...u,format:"money"}:u);return h&&(p.render=f=>Lf(f?.[u.id],f?.currency),Pf(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 Tf)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:Nf(t)}}}function Mf(i,e,t={}){let s=xn(i,e,t),n=ue(i),r=new St(null,s.tableOptions),o;try{o=Sn({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 Sn(i){let{client:e,facade:t,resource:s,projection:n,target:r,searchFields:o}=i,a=String(i.label??"ZeyOS binding"),l=el(i.pageSize,a),u=i.sort??null,d=vn(i.filters??{},a),h=String(i.search??""),p=0,f=null,_=!1,m=0,g=!1,b=v=>ut({fields:n,sort:u,filters:d,search:h,searchFields:o,limit:l,offset:v*l,count:!0}),y=(v={})=>{let x=v&&typeof v=="object"?v:{},E=H=>Object.prototype.hasOwnProperty.call(x,H);return{page:Bf(x.page??0,a),pageSize:E("pageSize")&&x.pageSize!==void 0?el(x.pageSize,a):l,filters:E("filters")?vn(x.filters??{},a):d,search:E("search")?String(x.search??""):h}},A=async(v={})=>{if(g)throw new Error(`${a} binding has been destroyed`);let x=y(v),E=x.page;l=x.pageSize,d=x.filters,h=x.search;let H=E===0||v.replace===!0,Z=b(E),oe=++m;r.setLoading(!0);try{let k=yn(e,await t.list(s,Z)),O=k.count??null,te=O==null?k.data.length===l:E*l+k.data.length<O;return!g&&oe===m&&(p=E,f=O,_=te,H?r.setData(k.data):r.addData(k.data)),{data:k.data,count:O,page:E,hasMore:te,query:Z}}finally{!g&&oe===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:v=>{u=v??null},setQuery:(v={})=>{let x=Object.prototype.hasOwnProperty.call(v,"filters")?vn(v.filters??{},a):d;Object.prototype.hasOwnProperty.call(v,"search")&&(h=String(v.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 Nf(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 Of(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 Ff(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 Rf(i){let e=String(i.format??"").toLowerCase();return/money|currency|price/.test(e)||/(?:amount|price)$/.test(String(i.id).toLowerCase())}function Lf(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 Pf(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 jf=50;function el(i,e="ZeyOS table"){if(i==null)return jf;let t=Number(i);if(!Number.isInteger(t)||t<1)throw new RangeError(`${e} page size must be a positive integer`);return t}function Bf(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 vn(i,e="ZeyOS table"){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`${e} filters must be an object`);return{...i}}function il(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=ve(i.datefrom),s=ve(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:tl(t)&&tl(s)&&X(t,s)>=1;return{id:String(i.occurrenceid??`${e}@${i.datefrom}`),title:o,start:t,end:s,allDay:a,color:$f(i.color),location:String(i.location??"").trim(),editable:i.editable==null?null:!!i.editable,durationEditable:i.durationEditable==null?null:!!i.durationEditable,data:i}}function sl(i){if(!Array.isArray(i))throw new TypeError("ZeyOS appointments must be an array");return i.map(il)}function Vf(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:de(i.start),dateto:de(i.end)};return i.data?.ID!=null?{ID:i.data.ID,...e}:e}function nl(i={}){let{appointments:e,...t}=i;return{weekStart:1,optimistic:!0,...t,events:e==null?Array.isArray(t.events)?t.events:[]:sl(e)}}function qf(i,e={}){return new Et(i,nl(e))}function $f(i){let e=String(i??"").trim();return e?/^[\da-f]{3,8}$/i.test(e)?`#${e}`:e:null}function tl(i){return i.getHours()===0&&i.getMinutes()===0&&i.getSeconds()===0&&i.getMilliseconds()===0}var Hf=1,Kf=new Set(["table","card","kanban"]),rl="1970-01-01T00:00:00.000Z",Uf=new Set(["__proto__","constructor","prototype"]),Yf=new Set(["cursor","data","offset","page","pagination","records","rows","selection","selectedRecords"]),at=class extends Error{constructor(e){super(`A saved view named "${e}" already exists`),this.name="SavedViewDuplicateNameError"}},Ui=class extends Error{constructor(e,t){super(`Saved-view scope mismatch: expected ${lt(e)}, received ${lt(t)}`),this.name="SavedViewScopeMismatchError",this.expected={...e},this.actual={...t}}},Yi=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=Wi(t),this.options=Qf(s),this._document=kn(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=An(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(ot)}async get(e){await this.ready();let t=Ki(this._document,e);return t?ot(t):null}async getDefault(){await this.ready();let e=this._document.views.find(t=>t.id===this._document.defaultId)??null;return e?ot(e):null}async save(e,t={}){return this._mutate(async s=>{let n=Dn(e?.name),r=In(t.onDuplicate??this.options.duplicateNames),o=e?.id==null?null:En(e.id),a=o?s.views.find(v=>v.id===o)??null:null,l=s.views.find(v=>ee(v.name)===ee(n))??null;if(a&&l&&a!==l&&r==="reject")throw new at(n);if(!a&&l&&r==="reject")throw new at(n);let u=a??(r==="replace"?l:null),d=r==="replace"&&a&&l!==a?l:null,h=this._now(),p=Cn(e?.type??u?.type),f=Object.prototype.hasOwnProperty.call(e??{},"state")?dl(e.state):u?re(u.state,"Saved view state"):null;if(!f)throw new TypeError("A new saved view requires state");let _=Object.prototype.hasOwnProperty.call(e??{},"filters")?hl(e.filters):u?re(u.filters,"Saved view filters"):{},m=Object.prototype.hasOwnProperty.call(e??{},"search")?fl(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(v=>v!==u&&v!==d&&v.id!==b);return A.push(y),s.views=zn(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=Ki(n,e);if(!r)return{changed:!1,result:null};let o=Dn(t);if(r.name===o)return{changed:!1,result:r};let a=n.views.find(u=>u!==r&&ee(u.name)===ee(o))??null,l=In(s.onDuplicate??this.options.duplicateNames);if(a&&l==="reject")throw new at(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=zn(n.views),{changed:!0,result:r}})}async remove(e){return this._mutate(async t=>{let s=Ki(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=Ki(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=Cn(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(re(n.state,"Saved view state")),s.onQuery&&await s.onQuery({filters:re(n.filters,"Saved view filters"),search:n.search,entry:ot(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-${pl(`${lt(this.scope)}\0${t.name}\0${t.type}\0${t.createdAt}`)}`,n=En(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=ol(this._document),n=await e(s);if(this._assertActive(),!n.changed)return al(n.result);let r=An(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=kn(this.scope)):(await this.transport.save({...this.scope},ol(r)),this._assertActive(),this._loadSequence+=1,this._document=r),al(n.result)});return this._mutation=t.then(()=>{},()=>{}),t}};function Nn(i,e,t={}){return new Yi(i,e,t)}function Wi(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Saved-view scope must be an object");return{userId:Mn(i.userId,"userId"),workspaceId:Xf(i.workspaceId),resource:Mn(i.resource,"resource")}}function An(i,e,t={}){let s=Wi(e);if(i==null)return kn(s);let n=ul(i,t.migrations);if(n.scope!=null){let p=Wi(n.scope);if(lt(p)!==lt(s))throw new Ui(s,p)}let o=(Array.isArray(n.views)?n.views:[]).map((p,f)=>Zf(p,f,s)),a=Gf(o),l=a.aliases,u=zn(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 ul(i,e={}){let t=Array.isArray(i)?{version:0,savedViews:i}:re(i,"Saved-view document"),s=cl(t.version);if(s>1)throw new RangeError(`Unsupported saved-view document version: ${s}`);for(;s<1;){let n=e?.[s]??(s===0?Wf:null);if(typeof n!="function")throw new RangeError(`Missing saved-view migration from version ${s}`);t=re(n(re(t,"Saved-view document")),`Saved-view migration ${s}`);let r=cl(t.version);if(r<=s)throw new RangeError(`Saved-view migration ${s} did not advance the version`);s=r}return t}function Wf(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 Zf(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=Dn(s.name),r=Cn(s.type),o=dl(s.state??{}),a=hl(s.filters??{}),l=fl(s.search),u=ll(s.createdAt),d=ll(s.updatedAt??u),h=d<u?u:d;return{id:s.id==null||String(s.id).trim()===""?`legacy-${pl(`${lt(t)}\0${n}\0${r}\0${e}`)}`:En(s.id),name:n,type:r,state:o,filters:a,search:l,createdAt:u,updatedAt:h}}function Gf(i){let e=[...i].sort((o,a)=>Ft(a.updatedAt,o.updatedAt)||Ft(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||ee(l.name)===ee(o.name));if(t.has(o.id)||s.has(ee(o.name))){a&&n.set(o.id,a.id);continue}t.add(o.id),s.add(ee(o.name)),r.push(o)}return{views:r,aliases:n}}function Qf(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:In(i.duplicateNames??"reject"),clock:i.clock??(()=>new Date)}}function kn(i){return{version:1,scope:{...i},defaultId:null,views:[]}}function ol(i){return{version:1,scope:{...i.scope},defaultId:i.defaultId,views:i.views.map(ot)}}function ot(i){return{...i,state:re(i.state,"Saved view state"),filters:re(i.filters,"Saved view filters")}}function al(i){return Jf(i)?ot(i):i}function Ki(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=>ee(s.name)===ee(t))??null:null}function zn(i){return[...i].sort((e,t)=>Ft(ee(e.name),ee(t.name))||Ft(e.name,t.name)||Ft(e.id,t.id))}function Cn(i){if(typeof i!="string")throw new TypeError('Saved view type must be "table", "card", or "kanban"');let e=i.trim().toLowerCase();if(!Kf.has(e))throw new TypeError('Saved view type must be "table", "card", or "kanban"');return e}function Dn(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 ee(i){return i.normalize("NFKC").toLocaleLowerCase("en-US")}function En(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 In(i){if(i!=="reject"&&i!=="replace")throw new TypeError('Duplicate saved-view policy must be "reject" or "replace"');return i}function dl(i){let e=re(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 Yf)if(Object.prototype.hasOwnProperty.call(e,s))throw new TypeError(`Saved view state cannot serialize ${s}`);return e}function hl(i){return re(i??{},"Saved view filters")}function fl(i){if(i==null)return"";if(typeof i!="string")throw new TypeError("Saved view search must be a string");return i}function re(i,e){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`${e} must be a plain object`);return Tn(i,e,new WeakSet)}function Tn(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=>Tn(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(Uf.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]=Tn(a.value,e,t)}return n}finally{t.delete(i)}}function ll(i){if(i==null||i==="")return rl;let e=new Date(i);return Number.isFinite(e.getTime())?e.toISOString():rl}function cl(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 Mn(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 Xf(i){return i===null?null:Mn(i,"workspaceId")}function lt(i){let e=i.workspaceId===null?"":`${i.workspaceId}`;return`${i.userId}\0${e}\0${i.resource}`}function Ft(i,e){return i<e?-1:i>e?1:0}function Jf(i){return!!(i&&typeof i=="object"&&"id"in i&&typeof i.id=="string")}function pl(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 ep=["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 _l(i,e,t={}){let s=ip(i,e,t),n=xn(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 gl(t))Object.prototype.hasOwnProperty.call(l,d)||(l[d]=d);let u={...t.viewOptions??{}};for(let d of ep)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 tp(i,e,t,s={}){if(typeof t!="function")throw new TypeError("zeyosView() requires a view constructor");let n=_l(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=ue(i),a;try{a=Sn({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=rp(s.savedViews,t,e)}catch(k){throw r.destroy(),k}let u=l?.registry??null,d=l?.type??bl(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,O={})=>{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 te=await u.apply(k,r,{type:d,onQuery:async({filters:Gi,search:xl})=>{h||a.setQuery({filters:np(Gi),search:xl})}});return!te.applied||h||(a.setSort(lp(r,te.entry)),a.reset(),O.load!==!1&&await p({page:0})),te},_=async(k={})=>{if(!u)return null;if(await ap(u),h)throw new Error("ZeyOS view binding has been destroyed");let O=await u.getDefault();return O?f(O.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 O=await m;return g=!0,O}catch{}if(!b){let te=_(k).then(Gi=>(g=!0,Gi)).finally(()=>{b===te&&(b=null)});b=te}return b},A=async(k={})=>(a.check(k),await y({load:!1}),p(k)),v=k=>{if(!d||typeof r.getViewState!="function")throw new Error("This view does not expose serializable saved-view state");let O=k&&typeof k=="object"?k:{};return{...O.id==null?{}:{id:String(O.id)},name:String(O.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 O=v(k);return await u.capture(r,{...O.id==null?{}:{id:O.id},name:O.name,type:d,filters:O.filters,search:O.search},{onDuplicate:k?.onDuplicate,setDefault:!!k?.setDefault})},E=async(k,O={})=>(await y({load:!1}),f(k,O)),H=async(k={})=>g?_(k):y(k),Z=k=>{if(h)return;let O=k.detail?.id;a.setSort(O==null?null:{id:String(O),dir:k.detail.dir==="desc"?"desc":"asc"}),A({page:0}).catch(()=>{})},oe={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:H,captureView:v,saveView:x,applyView:E,destroy:()=>{h||(h=!0,a.destroy(),typeof r.off=="function"?r.off("sortchange",Z):r.removeEventListener?.("sortchange",Z),l?.owned&&u?.destroy?.(),r.destroy())}};return r.on("sortchange",Z),oe}function ip(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):sp(i,e);return[...new Set([...n,...gl(t)])].filter(r=>!s.has(r))}function sp(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 gl(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 np(i){return i&&typeof i=="object"&&!Array.isArray(i)?{...i}:{}}function rp(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=ml(s)?s:ml(n)?n:null,o=op(s.type??bl(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:Nn(s.transport,a,s.options??{}),type:o,owned:!0}}function ml(i){return!!(i&&typeof i=="object"&&typeof i.apply=="function"&&typeof i.capture=="function"&&typeof i.getDefault=="function")}function bl(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 op(i){let e=String(i??"").toLowerCase();return["table","card","kanban"].includes(e)?e:null}async function ap(i){typeof i.ready=="function"?await i.ready():typeof i.load=="function"&&await i.load()}function lp(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 cp(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 up(i,e={}){if(typeof i!="function")throw new TypeError("Saved-view request must be a function");let t=yl(e.recordName,"__zx_record_views_v1__","recordName"),s=yl(e.viewPrefix,"zx.record-views:","viewPrefix"),n=e.module==null?"":String(e.module),r=(o,a)=>{let l=dp(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=hp(a,t);if(l==null||l==="")return null;if(typeof l=="string")try{let u=JSON.parse(l);return Zi(u)?u:null}catch{return null}return Zi(l)?wl(l):null},async save(o,a){if(!Zi(a))throw new TypeError("Saved-view document must be an object");let l=wl(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 dp(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 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 hp(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 yl(i,e,t){let s=i==null?e:String(i).trim();if(!s)throw new TypeError(`${t} must not be empty`);return s}function Zi(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function wl(i){vl(i,new Set);try{return JSON.parse(JSON.stringify(i))}catch{throw new TypeError("Saved-view document must be JSON-serializable")}}function vl(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)vl(s,e);e.delete(i)}export{Hf as SAVED_VIEWS_VERSION,at as SavedViewDuplicateNameError,Yi as SavedViewRegistry,Ui as SavedViewScopeMismatchError,$a as ZEYOS_ICON_KIT,df as ZEYOS_LAUNCHER_APPLICATIONS,ut as buildListQuery,_f as buildZeyosAppSidebarConfig,nl as buildZeyosCalendarOptions,Za as buildZeyosEntitySelectConfig,Ha as buildZeyosLauncherConfig,Ua as buildZeyosModuleBarConfig,Ot as buildZeyosSelectConfig,_l as buildZeyosViewConfig,Rt as calendarDayToUnixSeconds,Vf as calendarEventToZeyosPatch,ue as connect,up as createLegacySavedViewTransport,Nn as createSavedViewRegistry,Sl as dataFilterStateToFilters,de as dateToUnixSeconds,Ji as fieldToZxColumn,Xi as fieldToZxField,cp as legacySavedViewRequest,ul as migrateSavedViewDocument,qa as moduleAliases,rt as moduleChip,rf as moduleColor,cf as moduleGlyphColor,Vi as moduleIcon,of as moduleIconName,J as moduleInfo,af as moduleKeys,Bi as normalizeModuleName,An as normalizeSavedViewDocument,Wi as normalizeSavedViewScope,Ka as normalizeZeyosLauncherApplications,qi as normalizeZeyosLauncherRecords,q as registerFieldType,lf as registerModules,dt as resolveFields,Rn as tableSortToQuery,Qi as unixSecondsToCalendarDay,ve as unixSecondsToDate,uf as useZeyosIcons,ff as zeyosActiveIdentifier,pn as zeyosAppIcon,il as zeyosAppointmentToEvent,sl as zeyosAppointmentsToEvents,qf as zeyosCalendar,yf as zeyosEntitySelect,Af as zeyosForm,hf as zeyosLauncher,gf as zeyosModuleBar,bn as zeyosModuleItems,Be as zeyosModules,bf as zeyosSelect,Mf as zeyosTable,tp as zeyosView};
8
+ `).length}}function wc(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 hr(i){let e=String(i??"text").trim().toLowerCase();return/^[a-z0-9][a-z0-9+_.-]*$/.test(e)?e:"text"}function vc(i){let e=Number(i);return Number.isFinite(e)?Math.max(2,Math.min(100,Math.round(e))):12}function xc(i){return["off","soft","hard"].includes(String(i))?i:"off"}function Zt(i,e){let t=Number(i);return Math.max(0,Math.min(e,Number.isFinite(t)?Math.round(t):0))}function fr(){z.register("code",(i,e)=>{let t=i.own(new Wt(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 pr=["January","February","March","April","May","June","July","August","September","October","November","December"],mr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],br=/%[demYyHMSaAbBs]/g;function I(i,e){return!(i instanceof Date)||Number.isNaN(i.getTime())?"":String(e).replace(br,t=>{switch(t){case"%d":return $e(i.getDate());case"%e":return String(i.getDate());case"%m":return $e(i.getMonth()+1);case"%Y":return String(i.getFullYear()).padStart(4,"0");case"%y":return $e(i.getFullYear()%100);case"%H":return $e(i.getHours());case"%M":return $e(i.getMinutes());case"%S":return $e(i.getSeconds());case"%a":return _r("weekday",i.getDay(),mr[i.getDay()]);case"%A":return ds("weekday",i.getDay(),mr[i.getDay()]);case"%b":return _r("month",i.getMonth(),pr[i.getMonth()]);case"%B":return ds("month",i.getMonth(),pr[i.getMonth()]);case"%s":return String(Math.floor(i.getTime()/1e3));default:return t}})}function ae(i,e){let t=[],s="^",n=0;for(let _ of String(e).matchAll(br)){s+=gr(String(e).slice(n,_.index));let m=_[0],g=Sc(m);if(g===null)return null;s+=`(${g})`,t.push(m),n=_.index+m.length}s+=gr(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"]??Ac(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 yr(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 B(i,e){return i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate()}function M(i,e){let t=new Date(i.getTime());return t.setDate(t.getDate()+e),t}function De(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 Gt(i=fe()){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 $e(i){return String(i).padStart(2,"0")}function ds(i,e,t){let s=`date.${i}.${e}`,n=Se(s);return n===s?t:n}function _r(i,e,t){let s=`date.${i}.short.${e}`,n=Se(s);return n!==s?n:ds(i,e,t).slice(0,3)}function Sc(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 Ac(i){if(i!==void 0)return i>=69?1900+i:2e3+i}function gr(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var wr=Object.freeze({solid:"fa-solid",regular:"fa-regular",light:"fa-light",thin:"fa-thin",duotone:"fa-duotone",brands:"fa-brands",kit:"fa-kit"}),kc=Object.freeze({classic:"",sharp:"fa-sharp","sharp-duotone":"fa-sharp-duotone"}),vr=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"}),Cc=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"}),hs=new Map;function xr(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(vr,s))return{provider:"fa",name:n,style:vr[s],classes:null}}return{provider:null,name:e,style:null,classes:null}}function fs(i,e={}){let{style:t="solid",family:s="classic",fixedWidth:n=!1,translate:r=!0}=e,o=String(i).replace(/^fa-/,""),a=r?Cc[o]??o:o,l=[],u=kc[s];return u&&l.push(u),l.push(wr[t]??wr.solid,`fa-${a}`),n&&l.push("fa-fw"),l}function ps(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 Sr(i){let e=ps(i),t=hs.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",()=>{hs.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 hs.set(e,s),s}var Cr="http://www.w3.org/2000/svg",T=Object.freeze({control:16,chevron:14,dismiss:14,check:14,sort:14,chip:12,marker:8}),zr="0 0 24 24",zc=1.75,Tc=1,C=i=>[zr,i,"stroke"];var Tr=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"),"arrow-up":C("M5 12l7-7 7 7M12 19V5"),"arrow-down":C("M12 5v14M19 12l-7 7-7-7"),"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"),"table-cells-large":C("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:C("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: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-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: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-2zM9 3v18M15 3v18"),type:C("M12 4v16M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2M9 20h6"),hash:C("M4 9h16M4 15h16M10 3L8 21M16 3l-2 18"),mail:C("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":C("M9 17H7A5 5 0 0 1 7 7h2M15 7h2a5 5 0 1 1 0 10h-2M8 12h8"),"circle-chevron-down":C("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 10l-4 4-4-4")}),Dc=Object.freeze({settings:"gear",clear:"x",checked:"check",question:"info",range:"filter",fields:"list",grid:"table-cells-large"}),Ec=Object.create(null),pe={provider:"builtin",style:"solid",family:"classic",fixedWidth:!1,kit:null};function _s(){return{...pe}}function gs(i={}){for(let e of["provider","style","family","fixedWidth","kit"])i[e]!==void 0&&(pe[e]=i[e]);return _s()}function Dr(i={}){return gs({...i,provider:"fontawesome"})}async function bs(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 gs({...n,kit:ps(t)}),await Sr(t),s?Dr():_s()}function w(i,e={}){let t=xr(i);if(t.classes)return ms(t.classes,e);let s=Dc[t.name]??t.name;return t.provider==="builtin"?Ar(s,e):t.provider==="fa"?ms(fs(s,{style:t.style??e.style??pe.style,family:e.family??pe.family,fixedWidth:e.fixedWidth??pe.fixedWidth}),e):pe.provider==="fontawesome"?ms(fs(s,{style:e.style??pe.style,family:e.family??pe.family,fixedWidth:e.fixedWidth??pe.fixedWidth}),e):Ar(s,e)}function Ar(i,e){let t=Ec[i]??Tr[i];if(!t){if(e.strict)throw new RangeError(`Unknown icon: ${i}`);return Oc(i),Nc(i,e)}let[s,n,r="fill"]=t,o=Er(s,r,e),a=document.createElementNS(Cr,"path");return a.setAttribute("d",n),o.append(a),o}function Er(i,e,t){let{size:s=T.control}=t,n=document.createElementNS(Cr,"svg");return n.setAttribute("class",Mr("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",Ic(i,s)),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round")):n.setAttribute("fill","currentColor"),n.setAttribute("focusable","false"),Ir(n,t.label??null),n}function Ic(i,e){let[,,t,s]=i.trim().split(/[\s,]+/).map(Number),n=Math.max(t,s)||24,r=zc*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,Tc*n/o)),String(Math.round(r*1e3)/1e3)}var Mc=zr;function Nc(i,e){let t=Er(Mc,"stroke",e);return t.setAttribute("data-zx-icon-missing",i),t}var kr=new Set;function Oc(i){kr.has(i)||(kr.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 ms(i,e){let{size:t=T.control}=e,s=document.createElement("i");return s.className=Mr("zx-icon",...i,e.class),s.style.fontSize=typeof t=="number"?`${t}px`:String(t),Ir(s,e.label??null),s}function Ir(i,e){if(e===null){i.setAttribute("aria-hidden","true");return}i.setAttribute("role","img"),i.setAttribute("aria-label",e)}function Mr(...i){return i.flat().filter(Boolean).join(" ")}var Fc=5,Qt=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=Nr(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},w("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=Nr(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"?jc(this.options.step):1,o=He(e.currentTarget.value,0,s),a=s+1,l=(o+n*r+a*r)%a;e.currentTarget.value=Ee(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=Ee(He(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]=He(s.value,0,r)}let t=!this._value||!Bc(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=Ee(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=Ee(this._display.h),this.refs.headMinute.textContent=Ee(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?Rc():Lc(),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&&!Pc(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 Rc(){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:Ee(t),angle:e*30,ring:"inner"})}return i}function Lc(){let i=[];for(let e=0;e<60;e+=Fc)i.push({value:e,label:Ee(e),angle:e*6,ring:"outer"});return i}function Pc(i){return i>=1&&i<=12}function Nr(i){return i instanceof Date&&!Number.isNaN(i.getTime())?{h:i.getHours(),m:i.getMinutes(),s:i.getSeconds()}:!i||typeof i!="object"?null:{h:He(i.h,0,23),m:He(i.m,0,59),s:He(i.s,0,59)}}function He(i,e,t){let s=Number.parseInt(String(i??""),10);return Number.isFinite(s)?Math.max(e,Math.min(t,s)):e}function jc(i){let e=Math.round(Number(i));return Number.isFinite(e)&&e>0&&e<=59?e:5}function Ee(i){return String(i).padStart(2,"0")}function Bc(i,e){return i.h===e.h&&i.m===e.m&&i.s===e.s}var Ke=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=ie(Xt(this.options.min)),this._max=ie(Xt(this.options.max)),this._value=this._normalizeValue(Xt(this.options.value)),this._focused=ie(this._value)??this._clampFocus(ie(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),this._weekStart=Vc(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")},w("chevron-left",{size:T.chevron})),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")},w("chevron-right",{size:T.chevron}))),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")},w("chevron-left",{size:T.chevron})),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")},w("chevron-right",{size:T.chevron}))),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 Qt(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 ys(this._value)}set(e,{silent:t=!1}={}){let s=this._normalizeValue(Xt(e));return this._value=s,s&&(this._focused=ie(s),this._viewYear=s.getFullYear(),this._viewMonth=s.getMonth()),this._timePicker?.set(s,{silent:!0}),this._renderCalendar(),t||this.emit("change",{date:ys(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=ie(t);return this._min&&s<this._min&&Or(t,this._min),this._max&&s>this._max&&Or(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=M(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=M(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=M(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",Fr(o))},String(Fr(o))));for(let l=0;l<7;l+=1){let u=M(o,l),d=!!(this._value&&B(u,this._value)),h=!this._inRange(u),p=c("button",{class:"zx-date-picker__day",type:"button",role:"gridcell",tabindex:B(u,this._focused)?0:-1,ariaSelected:String(d),ariaDisabled:String(h),ariaCurrent:B(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=ae(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=ae(t.dataset.date,"%Y-%m-%d");if(!s)return;let n=null;if(e.key==="ArrowLeft")n=M(s,-1);else if(e.key==="ArrowRight")n=M(s,1);else if(e.key==="ArrowUp")n=M(s,-7);else if(e.key==="ArrowDown")n=M(s,7);else if(e.key==="PageUp")n=De(s,e.shiftKey?-12:-1);else if(e.key==="PageDown")n=De(s,e.shiftKey?12:1);else if(e.key==="Home")n=M(s,-((s.getDay()-this._weekStart+7)%7));else if(e.key==="End")n=M(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=ie(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=ie(t),this._viewYear=t.getFullYear(),this._viewMonth=t.getMonth(),this._timePicker?.set(t,{silent:!0}),this._renderCalendar(),n&&this._emitMonthChange(),this.emit("change",{date:ys(t)})}_pageMonth(e){this._closeQuickPick();let t=De(this._focused,e);this._focused=ie(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=ie(t),this._viewMonth=e,this._closeQuickPick(),this._renderCalendar(),this._emitMonthChange(),this.focus()}_inRange(e){let t=ie(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?F(t,s):n}};function Xt(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function ie(i){return i?new Date(i.getFullYear(),i.getMonth(),i.getDate()):null}function ys(i){return i?new Date(i.getTime()):null}function Or(i,e){i.setFullYear(e.getFullYear(),e.getMonth(),e.getDate())}function Vc(i){let e=Number(i);return Number.isInteger(e)&&e>=0&&e<=6?e:Gt()}function Fr(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 ti=class extends Ke{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=ei(Jt(this.options.min)),this._max=ei(Jt(this.options.max)),this._value=this._normalizeMonth(Jt(this.options.value));let t=this._value??ei(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")},w("chevron-left",{size:T.chevron})),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")},w("chevron-right",{size:T.chevron}))),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(Jt(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=ei(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&&qc(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 Jt(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function ei(i){return i?new Date(i.getFullYear(),i.getMonth(),1):null}function qc(i,e){return i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()}function Rr(){z.register("month",(i,e)=>{let t=i.own(new ti(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 $c=new Set(["bottom-start","bottom-end","top-start","top-end","bottom","top","right-start","right-end","left-start","left-end","right","left"]);function G(i,e,t={}){if(!(i instanceof Element)||!(e instanceof HTMLElement))throw new TypeError("position() requires an Element anchor and HTMLElement floating element");let s=$c.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=Lr(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=Hc(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=()=>Kc(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 Uc(e),p(),{update(){d||p()},destroy(){if(!d){if(d=!0,h?.disconnect(),f(),Yc(e),_){let g=Lr(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")}jr(e,"style",l),jr(e,"popover",u)}}}}function Lr(i){return String(i.style?.getPropertyValue("anchor-name")??"").split(",").map(e=>e.trim()).filter(e=>e&&e!=="none")}function Hc(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 Kc(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=Pr(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=ii(t,"bottom","top"):h==="top"&&f<0&&p+a.height<=u?d=ii(t,"top","bottom"):h==="right"&&_+a.width>l&&m>=0?d=ii(t,"right","left"):h==="left"&&m<0&&_+a.width<=l&&(d=ii(t,"left","right")));let g=Pr(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(ft(b,0,Math.max(0,l-a.width)))}px`,e.style.top=`${Math.round(ft(y,0,Math.max(0,u-a.height)))}px`}function Pr(i){return i.split("-")[0]}function ii(i,e,t){return i.replace(e,t)}function Uc(i){if(typeof i.showPopover=="function")try{i.showPopover()}catch{}}function Yc(i){if(typeof i.hidePopover=="function")try{i.hidePopover()}catch{}}function jr(i,e,t){t===null?i.removeAttribute(e):i.setAttribute(e,t)}var Wc=6,Kr=864e5;function gt(i,e){let t=W(Ie(i)),s=W(Ie(e));return t&&s&&t.getTime()>s.getTime()?{start:s,end:t}:{start:t,end:s}}function si(i,e){let t=gt(i,e);return!t.start||!t.end?0:Math.round((qr(t.end)-qr(t.start))/Kr)}function Zc(i,e,t){let s=W(Ie(i));if(!s)return null;let n=gt(e,t);return!n.start&&!n.end?null:n.end?n.start?s.getTime()<n.start.getTime()||s.getTime()>n.end.getTime()?null:B(s,n.start)?"start":B(s,n.end)?"end":"middle":B(s,n.end)?"end":null:B(s,n.start)?"start":null}function ni(i,e={}){let t=W(Ie(e.min)),s=W(Ie(e.max)),n=oi(e.minNights)??0,r=oi(e.maxNights),{start:o,end:a}=gt(i?.start,i?.end);return o&&(o=vs(o,t,s)),a&&(a=vs(a,t,s)),!o||!a?{start:o,end:a}:(r!==null&&si(o,a)>r&&(a=M(o,r)),n>0&&si(o,a)<n&&(a=M(o,n),s&&a.getTime()>s.getTime()&&(a=new Date(s.getTime()),o=M(a,-n),t&&o.getTime()<t.getTime()))?{start:null,end:null}:{start:o,end:a})}var ri=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=iu(e,["role","aria-label","aria-disabled","data-months","data-presets"]),this._min=W(Ie(this.options.min)),this._max=W(Ie(this.options.max)),this._minNights=oi(this.options.minNights)??0,this._maxNights=oi(this.options.maxNights),this._weekStart=Jc(this.options.weekStart),this._monthCount=eu(this.options.months),this._presets=Xc(this.options.presets),this._disabled=!!this.options.disabled,this._hover=null,this._dayCells=[];let t=ni({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=ke(this._start)??this._clampFocus(W(new Date)),this._viewYear=this._focused.getFullYear(),this._viewMonth=this._focused.getMonth(),e.setAttribute("role","group"),e.setAttribute("aria-label",R("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:R("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:ke(this._start),end:ke(this._end)}}set(e={},{silent:t=!1}={}){let s=ni({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=ke(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=[],su(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=W(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=si(this._start,t);return!(s<this._minNights||this._maxNights!==null&&s>this._maxNights)}_choose(e){let t=W(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?ke(this._start):null,this._committedEnd=e?ke(this._end):null}_abandon(){return this._picking?(this._start=ke(this._committedStart),this._end=ke(this._committedEnd),this._picking=!1,this._hover=null,this._paint(),this._announce(),this.emit("select",this.get()),!0):!1}_clampFocus(e){return vs(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=$r(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=$r(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=W(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?W(e):null;!t&&!this._hover||t&&this._hover&&B(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=M(s,-1);else if(e.key==="ArrowRight")n=M(s,1);else if(e.key==="ArrowUp")n=M(s,-7);else if(e.key==="ArrowDown")n=M(s,7);else if(e.key==="PageUp")n=De(s,e.shiftKey?-12:-1);else if(e.key==="PageDown")n=De(s,e.shiftKey?12:1);else if(e.key==="Home")n=M(s,-((s.getDay()-this._weekStart+7)%7));else if(e.key==="End")n=M(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=M(e,-s),r=[];for(let o=0;o<Wc;o+=1){let a=M(n,o*7),l=c("tr"),u=tu(a,e);this.options.showWeekNumbers&&l.append(c("th",{class:"zx-date-range-picker__week",scope:"row",ariaLabel:u?R("daterange.week","Week %1",[Hr(a)]):null},u?String(Hr(a)):""));for(let d=0;d<7;d+=1){let h=M(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:R("daterange.previousMonth","Previous month")},w("chevron-left",{size:T.chevron})),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:R("daterange.nextMonth","Next month")},w("chevron-right",{size:T.chevron}))),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:R("daterange.weekNumber","Week number")},"#"));let t=new Date(2023,0,1);for(let s=0;s<7;s+=1){let n=M(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)B(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);ws(r,"range",a.range),ws(r,"rangeEdge",a.edge),ws(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)),B(n,e)?o.setAttribute("aria-current","date"):o.removeAttribute("aria-current")}}_dayState(e){if(this._start&&this._end){let s=Zc(e,this._start,this._end);if(!s)return{range:null,edge:null};let n=B(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 B(e,this._start)?{range:"start",edge:t?"start":"both"}:t?e.getTime()>this._start.getTime()&&e.getTime()<=t.getTime()?{range:"preview",edge:B(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=W(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}, ${R("daterange.day.start","range start")}`:t==="end"?`${s}, ${R("daterange.day.end","range end")}`:t==="middle"?`${s}, ${R("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 R("daterange.status.empty","No date range selected");if(!this._end)return R("daterange.status.start","%1 selected, choose an end date",[I(this._start,"%e %B %Y")]);let e=si(this._start,this._end),t=e===1?R("daterange.night","1 night"):R("daterange.nights","%1 nights",[e]);return`${Qc(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=>B(t.date,e))?.button??null}};function Gc(){return[{name:"today",label:R("daterange.preset.today","Today"),range:()=>Br(le())},{name:"yesterday",label:R("daterange.preset.yesterday","Yesterday"),range:()=>Br(M(le(),-1))},{name:"last7",label:R("daterange.preset.last7","Last 7 days"),range:()=>({start:M(le(),-6),end:le()})},{name:"last30",label:R("daterange.preset.last30","Last 30 days"),range:()=>({start:M(le(),-29),end:le()})},{name:"thisMonth",label:R("daterange.preset.thisMonth","This month"),range:()=>Vr(le(),0)},{name:"lastMonth",label:R("daterange.preset.lastMonth","Last month"),range:()=>Vr(le(),-1)},{name:"thisQuarter",label:R("daterange.preset.thisQuarter","This quarter"),range:()=>{let i=le(),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:R("daterange.preset.thisYear","This year"),range:()=>{let i=le();return{start:new Date(i.getFullYear(),0,1),end:new Date(i.getFullYear(),11,31)}}}]}function R(i,e,t){let s=Se(i);return F(s===i?e:s,t)}function Qc(i,e){if(B(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 Xc(i){return i===!0?Gc():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 le(){return W(new Date)}function Br(i){return{start:i,end:new Date(i.getTime())}}function Vr(i,e){return{start:new Date(i.getFullYear(),i.getMonth()+e,1),end:new Date(i.getFullYear(),i.getMonth()+e+1,0)}}function Ie(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function W(i){return!i||Number.isNaN(i.getTime())?null:new Date(i.getFullYear(),i.getMonth(),i.getDate())}function ke(i){return i?new Date(i.getTime()):null}function vs(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 qr(i){return Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())}function $r(i){return i.getFullYear()*12+i.getMonth()}function oi(i){if(i==null||i==="")return null;let e=Number(i);return Number.isFinite(e)?Math.max(0,Math.trunc(e)):null}function Jc(i){let e=Number(i);return Number.isInteger(e)&&e>=0&&e<=6?e:Gt()}function eu(i){let e=Number(i);return Number.isInteger(e)&&e>=1&&e<=4?e:2}function tu(i,e){for(let t=0;t<7;t+=1){let s=M(i,t);if(s.getMonth()===e.getMonth()&&s.getFullYear()===e.getFullYear())return!0}return!1}function Hr(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())/Kr+1)/7)}function ws(i,e,t){t==null?delete i.dataset[e]:i.dataset[e]=t}function iu(i,e){return new Map(e.map(t=>[t,i.getAttribute(t)]))}function su(i,e){for(let[t,s]of e)s===null?i.removeAttribute(t):i.setAttribute(t,s)}var nu={"%d":"DD","%e":"D","%m":"MM","%Y":"YYYY","%y":"YY"};function Ur(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}${ts(r)}${l}`));if(u.length>2)return null;let d=ae(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=ae(u[1].trim(),e);return h?gt(d,h):null}function Yr(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 li=class extends S{static cssName="date-range-box";static defaults={start:null,end:null,format:"%d.%m.%Y",displayFormat:null,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._displayFormat=this.options.displayFormat?String(this.options.displayFormat):this._format,this._separator=String(this.options.separator??" \u2013 "),this._disabled=!!this.options.disabled,this._open=!1,this._focused=!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:Wr("daterange.clear","Clear date range")},w("x",{size:T.dismiss})),c("button",{ref:"toggle",class:"zx-date-range-box__toggle",type:"button",ariaLabel:Wr("daterange.choose","Choose date range"),"aria-haspopup":"grid",ariaControls:t,ariaExpanded:"false"},w("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 ri(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,"focus",()=>{this._focused=!0,this.el.dataset.state!=="invalid"&&this._syncDisplay()}),this.listen(this.refs.input,"blur",()=>{this._focused=!1,this._open?this.refs.input.value===Yr(this._range,this._format,this._separator)&&this._syncDisplay():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=G(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(),ai(this.el,"data-state",this._originalState),ai(this.el,"aria-disabled",this._originalAriaDisabled),ai(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=Ur(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(Ur(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()!==""?ae(e.trim(),this._format):null}_clamp(e){return ni(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=>nu[t]??t);return`${e}${this._separator}${e}`}_syncDisplay(){let e=this.refs.input,t=this._focused?this._format:this._displayFormat,s=Yr(this._range,t,this._separator);e.value!==s&&(e.value=s),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"&&ai(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 Wr(i,e,t){let s=Se(i);return F(s===i?e:s,t)}function ai(i,e,t){t===null?i.removeAttribute(e):i.setAttribute(e,t)}function Zr(){z.register("daterange",(i,e)=>{let t=i.own(new li(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 Me=class extends S{static cssName="datebox";static defaults={value:null,format:"%d.%m.%Y",displayFormat:null,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);let t=ru(this.options);this._format=t.format,this._displayFormat=t.display,this._disabled=!!this.options.disabled,this._open=!1,this._focused=!1,this._position=null,this._min=Gr(this.options.min),this._max=Gr(this.options.max),this._value=this._normalizeValue(this.options.value);let s=E("zx-datebox-popover"),n=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??ou(this._format),"aria-haspopup":"grid",ariaControls:s,ariaExpanded:"false"}),c("button",{ref:"clear",class:"zx-icon-btn zx-datebox__clear",type:"button",ariaLabel:"Clear date"},w("x",{size:T.dismiss})),c("button",{ref:"toggle",class:"zx-datebox__toggle",type:"button",ariaLabel:"Choose date","aria-haspopup":"grid",ariaControls:s,ariaExpanded:"false"},w("calendar"))),c("div",{ref:"popover",id:s,class:"zx-datebox__popover",popover:"manual",dataset:{state:"closed"}}));return this._content=n,e.append(n),this._picker=new Ke(null,{value:this._value,min:this._min,max:this._max,time:!!this.options.time}),this.refs.popover.append(this._picker.el),this._picker.on("change",r=>{this.set(r.detail.date),this.options.time||this._close(!0)}),this.listen(this.refs.input,"focus",()=>{this._focused=!0,this.el.dataset.state!=="invalid"&&this._syncDisplay()}),this.listen(this.refs.input,"blur",()=>{this._focused=!1,this._commitText()}),this.listen(this.refs.input,"keydown",r=>this._onInputKeydown(r)),this.listen(this.refs.toggle,"click",()=>this._open?this.close():this.open()),this.listen(this.refs.toggle,"keydown",r=>{r.key==="ArrowDown"&&(r.preventDefault(),this.open())}),this.listen(this.refs.clear,"click",()=>{this.set(null),this.focus()}),this.listen(document,"keydown",r=>{!this._open||r.key!=="Escape"||(r.preventDefault(),this._close(!0))}),this.listen(document,"pointerdown",r=>{this._open&&!e.contains(r.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=G(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=ae(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=ae(e,this._format)),!t||Number.isNaN(t.getTime())?null:yr(t,this._min,this._max)}_syncDisplay(){let e=this.refs.input,t=this._focused?this._format:this._displayFormat,s=this._value?I(this._value,t):"";e.value!==s&&(e.value=s),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}},Xr=function(e,t={}){return new Me(e,{...t,time:!0})};function Gr(i){return i instanceof Date&&!Number.isNaN(i.getTime())?new Date(i.getTime()):null}function ru({format:i=null,displayFormat:e=null,time:t=!1}={}){let s=Qr(i,t);return{format:s,display:e?Qr(e,t):s}}function Qr(i,e){let t=String(i||"%d.%m.%Y");return e&&!/%[HM]/.test(t)?`${t} %H:%M`:t}function ou(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 eo(){Jr("date",i=>new Me(null,i)),Jr("datetime",i=>Xr(null,i))}function Jr(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 ci=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"},au(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=>!cu(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(du(s.responseText))}),this.listen(s,"error",()=>t(new Error("Upload request failed"))),this.listen(s,"abort",()=>t(hu())),s.send(uu(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 au(i){let e=[];return i.accept&&e.push(String(i.accept)),i.maxSize!=null&&e.push(`up to ${lu(Number(i.maxSize))}`),e.join(" \xB7 ")||"Choose from this device"}function lu(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/1024)} KB`:`${Math.round(i/(1024*1024))} MB`}function cu(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 uu(i,e,t){let s=new FormData;for(let n of i)s.append(e,n);for(let[n,r]of Object.entries(t??{}))to(s,n,r);return s}function to(i,e,t){if(t==null)return;if(Array.isArray(t)){for(let n of t)to(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 du(i){if(!i)return null;try{return JSON.parse(i)}catch{return i}}function hu(){if(typeof DOMException=="function")return new DOMException("Upload aborted","AbortError");let i=new Error("Upload aborted");return i.name="AbortError",i}function io(){z.register("upload",(i,e)=>{let t=i.own(new ci(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 so=Object.freeze({both:{drag:!0,buttons:!0},buttons:{drag:!1,buttons:!0},drag:{drag:!0,buttons:!1},none:{drag:!1,buttons:!1}}),no=Object.freeze({value:".zx-multi-value-editor__value",handle:".zx-multi-value-editor__handle",up:'[data-action="up"]',down:'[data-action="down"]'}),ui=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 so[this.options.reorder]??so.both}_renderRows(e=-1,t="value"){let s=ro(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}},w("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}},w("chevron-up",{size:T.chevron})):null,o?c("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:T.chevron})):null,c("button",{class:"zx-btn",type:"button",ariaLabel:`Remove value ${d+1}`,dataset:{action:"remove",index:d}},w("x",{size:T.dismiss}))))});this._rows.replaceChildren(...l),e>=0&&l[Math.min(e,l.length-1)]?.querySelector(no[t]??no.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=ro(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 ro(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 oo(){z.register("multivalueeditor",(i,e)=>{let t=i.own(new ui(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 Ue=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:K(this.el);let e=this.el??c("div");this.el=e;let t=fu(this.options.step);this._step=t,this._precision=this.options.precision===null?pu(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}},w(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=xs(e,this.options.group?this._separators():null);return t===null?null:Ss(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=xs(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=ao(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=xs(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&&U(e,this._snapshot)}};function xs(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 Ss(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=ao(r,n),e!==null&&r<e?e:t!==null&&r>t?t:r}function fu(i){let e=Number(i);return Number.isFinite(e)&&e>0?e:1}function pu(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 ao(i,e){return Number.isFinite(i)?Number(i.toFixed(Math.min(15,Math.max(0,e)))):i}function lo(){z.register("number",(i,e)=>{let t=i.own(new Ue(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 di=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:K(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"},w(this.options.icon,{size:bt[this.options.size]??bt.md})),c("span",{class:"zx-rating__glyph",dataset:{part:"on"},ariaHidden:"true"},w(this.options.icon,{size:bt[this.options.size]??bt.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=bt[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?F(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(mu(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&&U(e,this._snapshot)}},bt={sm:14,md:18,lg:24};function mu(i,e){return e<1?i.toFixed(1):String(i)}function co(){z.register("rating",(i,e)=>{let t=i.own(new di(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 S_=["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 uo(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=>_u(u).startsWith(t));l>=0&&e(a[l],l)}}function _u(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 gu=/^var\(\s*--[\w-]+\s*\)$/;function hi(i){if(typeof i!="string")return null;let e=i.trim();return gu.test(e)||xe(e)?e:null}var ks=Object.freeze(["dotted","ring","progress","review","ready","waiting","done","canceled","duplicate"]),Cs=Object.freeze(["muted","neutral","warning","info","accent","success","danger"]),zs=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"]]),bu=Object.freeze({review:"in-review",cancelled:"canceled"}),As=4;function yu(i,e={}){let t=i&&typeof i=="object"?i:null,s=wu(t?t.ID??t.id:i),n=zs.find(([a])=>a===s),r=String(e.indicator??t?.indicator??n?.[3]??"ring"),o=String(e.tone??t?.tone??n?.[4]??"muted");return{indicator:ks.includes(r)?r:"ring",tone:Cs.includes(o)?o:"muted"}}function wu(i){let e=String(i??"").trim().toLowerCase();return bu[e]??e}function Ts(i){return i==null||i===""?null:Math.max(0,Math.min(As,Math.trunc(Number(i)||0)))}function ho(i,e={}){let{indicator:t,tone:s}=yu(i,e??{}),n=c("span",{class:"zx-status-icon",dataset:{indicator:t,tone:s}});return t==="done"&&n.append(w("check",{size:T.marker})),t==="canceled"&&n.append(w("x",{size:T.marker})),po(n,e?.label)}function fo(i,e={}){let t=Ts(i),s=c("span",{class:"zx-priority-icon",dataset:{level:t===null?"none":t}},t===As?null:Array.from({length:As},(n,r)=>c("span",{dataset:{filled:String(t!==null&&r<=t)}})));return po(s,e?.label)}function po(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 vu=["priority.lowest","priority.low","priority.normal","priority.high","priority.highest"],mo=["Lowest","Low","Medium","High","Highest"],$=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:K(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},w("x",{size:T.dismiss})),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")},w("chevron-down",{size:T.chevron})),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=_o(this.options.actions),this._disabled=!!this.options.disabled,this._handleTypeahead=uo(()=>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=>{bo(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=>{bo(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=_o(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=G(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 go(l,!0)},renderNone:t.renderNone??(()=>go({level:null,name:o()},!0)),renderValueAdornment(l){return wo(l.level)}}),n&&!t.placeholder&&(r.refs.input.placeholder=o());let a=r;return r.setItems(vu.map((l,u)=>{let d=u===2?a.msg("priority.medium"):l;return(d==="priority.medium"||u!==2)&&(d=a._message(l,mo[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 ku(l)},renderValueAdornment(l){return vo(l)}}),a=Array.isArray(s)?s.map(Au).filter(Boolean):zs.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 v=fi(y,o);if(v&&typeof v=="object"&&typeof v.nodeType=="number")return v.cloneNode(!0);if(typeof v!="string"||!v)return null;let x=hi(fi(y,a));return c("span",{class:"zx-select__entity-glyph",style:x?{"--zx-select-entity-color":x}:null,ariaHidden:"true"},w(v,{size:14}))},g=r?xu(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),v=fi(y,l),x=c("span",{class:"zx-select__entity-copy"},c("span",{class:"zx-select__entity-label"},String(fi(y,_.labelKey??"name")??"")),v==null||v===""?null:c("span",{class:"zx-select__entity-subtitle"},String(v)));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:Es(f,r),labelKey:f=>h.includes(f)?f.name:String(Es(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&&U(e,this._snapshot),super.destroy()}_onKeydown(e){if(!this._disabled){if(this._open&&yo(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&&yo(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=Ae(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"?Ds(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(w("check",{size:T.check})),this.refs.list.append(a),this._optionEntries.push({item:e,clear:t,action:null,element:a})}_appendAction(e){let t=this._optionEntries.length,s=Su(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 Ds(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=Ds(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 Es(e,t)}_searchKeys(){return this.options.searchKeys??[this.options.labelKey]}_matchFixed(e){return Ae(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 fi(i,e){return typeof e=="function"?e(i):i!==null&&typeof i=="object"&&typeof e=="string"?i[e]:null}function xu(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 Ds(i){return i&&typeof i=="object"&&"nodeType"in i?i:String(i??"")}function _o(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 Su(i){return typeof i=="string"?w(i):i instanceof Node?i.cloneNode(!0):null}function go(i,e){return c("span",{class:"zx-select__priority"},wo(i.level),e?c("span",{},String(i.name)):null)}function wo(i){let e=fo(Ts(i));return e.classList.add("zx-select__priority-icon"),e}function Au(i){return!i||typeof i!="object"||i.ID==null||i.name==null?null:{...i,name:String(i.name),indicator:ks.includes(String(i.indicator))?String(i.indicator):"ring",tone:Cs.includes(String(i.tone))?String(i.tone):"muted",description:i.description==null?"":String(i.description),shortcut:i.shortcut==null?"":String(i.shortcut)}}function ku(i){return c("span",{class:"zx-select__status"},vo(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 vo(i){let e=ho({indicator:i.indicator??"ring",tone:i.tone??"muted"});return e.classList.add("zx-select__status-indicator"),e}function Es(i,e){return typeof e=="function"?e(i):i===null||typeof i!="object"?i:i[e]}function bo(i){return["Shift","Control","Alt","Meta","CapsLock"].includes(i.key)||i.ctrlKey||i.metaKey}function yo(i){return i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey}function xo(){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"?$.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 pi=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:K(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&&Cu.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)?Ss(t,{min:this._min,max:this._max,step:this._step,precision:zu(this._step)}):this._min}_ratio(e){return ft((e-this._min)/(this._max-this._min),0,1)}_format(e){let t=this.options.formatValue;return typeof t=="function"?String(t(e)):`${Tu(e)}${this.options.unit??""}`}destroy(){let e=this.el;super.destroy(),!this._createdRoot&&e&&U(e,this._snapshot)}},Cu=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"]);function zu(i){let e=String(i),t=/e-(\d+)$/i.exec(e);return t?Number(t[1]):(e.split(".")[1]??"").length}function Tu(i){return String(Number(i.toFixed(6)))}function So(){z.register("slider",(i,e)=>{let t=i.own(new pi(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 Du=Object.freeze(["neutral","accent","success","warning","danger","info"]),Eu=Object.freeze(["soft","solid","outline"]),Iu=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),Mu=Object.freeze({label:"",icon:null,kind:"neutral",tone:null,variant:"soft",size:"md",dot:!1});function Ao(i={}){let e={...Mu,...i},t=c("span",{class:"zx-badge",title:e.title,dataset:{kind:Nu(e.kind),variant:Ou(e.variant),size:Fu(e.size),tone:Is(e.tone)??void 0}});return e.dot?t.append(c("span",{class:"zx-badge__dot",ariaHidden:"true"})):e.icon&&t.append(w(e.icon,{size:12,class:"zx-badge__icon"})),e.label!==""&&e.label!=null?t.append(c("span",{class:"zx-badge__label"},String(e.label))):e.title&&(t.setAttribute("role","img"),t.setAttribute("aria-label",e.title)),t}function Nu(i){return Du.includes(i)?i:"neutral"}function Ou(i){return Eu.includes(i)?i:"soft"}function Is(i){return Iu.includes(i)?i:null}function Fu(i){return i==="sm"?"sm":"md"}var mi=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:K(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")},w("chevron-down",{size:T.chevron})),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=!Ru(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=G(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&&U(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-badge__label zx-tag-picker__tag-label"},s)],a=Ao({tone:n});return a.classList.add("zx-tag-picker__tag"),a.dataset.colored=String(!!r),r&&a.style.setProperty("--zx-tag-color",r),a.append(...o.filter(l=>l!=null)),!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])},w("x",{size:T.chip}))),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?w("check",{size:T.check}):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"},w("plus",{size:T.check})),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=Ae(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=>ko(this._labelOf(n))===ko(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()?w(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 hi(this._readItem(e,this.options.colorKey))}_toneOf(e){return Is(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 ko(i){return String(i??"").trim().toLocaleLowerCase()}function Ru(i,e,t){return i.length!==e.length?!1:i.every((s,n)=>Object.is(t(s),t(e[n])))}function Co(){z.register("tagpicker",(i,e)=>{let t=i.own(new mi(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 Lu(i,e="minutes"){let t=Math.round(Math.abs(zo(Ne(i),e)));return{hours:Math.floor(t/3600),minutes:Math.floor(t/60)%60,seconds:t%60,negative:Ne(i)<0}}function Pu(i,e="minutes"){yt(e);let t=Math.abs(Math.trunc(Ne(i?.hours))),s=Math.abs(Math.trunc(Ne(i?.minutes))),n=Math.abs(Math.trunc(Ne(i?.seconds))),r=i?.negative?-1:1;return To(r*(t*3600+s*60+n),e)}var _i=class extends S{static cssName="timebox";static defaults={value:0,unit:"minutes",seconds:!1,signed:!1,disabled:!1};render(){yt(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 Pu(this._readParts(),e)}set(e,t=this.options.unit,s={}){t&&typeof t=="object"&&(s=t,t=this.options.unit),yt(t);let n=Ne(e);return!this.options.signed&&n<0&&(n=0),this.options.seconds||(n=To(Math.round(zo(n,t)/60)*60,t)),this._parts=Lu(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(Ne(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]):ju(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 Ne(i){let e=Number(i);return Number.isFinite(e)?e:0}function zo(i,e){return yt(e),e==="hours"?i*3600:e==="minutes"?i*60:i}function To(i,e){return yt(e),e==="hours"?i/3600:e==="minutes"?i/60:i}function yt(i){if(i!=="hours"&&i!=="minutes"&&i!=="seconds")throw new RangeError(`Unknown time unit: ${i}`)}function ju(i){return String(i).padStart(2,"0")}function Do(){z.register("time",(i,e)=>{let t=i.own(new _i(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 Ye=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:Bu(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&&Vu(this.el,this._original))}_sync(){this.el.setAttribute("aria-checked",String(this._checked)),this.el.toggleAttribute("disabled",this._disabled)}};function Bu(i){return{attributes:Array.from(i.attributes,e=>[e.name,e.value]),children:Array.from(i.childNodes)}}function Vu(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 Eo(){z.register("toggle",(i,e)=>{let t=i.own(new Ye(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 gi=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=Io(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=Io(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"},w("x",{size:T.chip})):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?F(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 Io(i,e){if(!Array.isArray(i))return[];let t=i.map(s=>String(s));return e?[...new Set(t)]:t}function Mo(){z.register("valuelist",(i,e)=>{let t=i.own(new gi(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 bi=Object.freeze({sm:480,md:768,lg:1024,xl:1280}),qu=["xl","lg","md","sm"];function No(i){let e=Number(i);if(!Number.isFinite(e))return"xs";for(let t of qu)if(e>=bi[t])return t;return"xs"}function Oo(i,e={}){if(typeof i!="function")throw new TypeError("onBreakpoint requires a handler");if("target"in e&&!L(e.target)&&e.target!==globalThis)throw new TypeError("onBreakpoint target must be an Element or the window");let t=e.target??globalThis,s=L(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=No(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??No(a()),destroy:()=>{r||(r=!0,u&&cancelAnimationFrame(u),o?.disconnect(),globalThis.removeEventListener?.("resize",l))}}}var $u=0,Hu=20,Ku=3;var Fo=new Map;function yi(i,e={}){let t=Os(i);if(t===null)return"";let{locale:s=fe(),decimals:n,minDecimals:r,maxDecimals:o,group:a=!0}=e;return Ms(s,Ns({decimals:n,minDecimals:r,maxDecimals:o,group:a}),t)}function Lo(i,e,t={}){let s=Os(i);if(s===null)return"";let{locale:n=fe(),decimals:r}=t,o=Yu(e);if(o===null)return yi(s,{locale:n,decimals:r});let a=Ns({decimals:r,group:!0});return Ms(n,{...a,style:"currency",currency:o},s)}function Po(i,e={}){let t=Os(i);if(t===null)return"";let{locale:s=fe(),decimals:n=0}=e;return Ms(s,{...Ns({decimals:n,group:!0}),style:"percent"},t)}function Ms(i,e,t){let s=`${i}\0${JSON.stringify(e)}`,n=Fo.get(s);return n===void 0&&(n=Uu(i,e),Fo.set(s,n)),n.format(t)}function Uu(i,e){try{return new Intl.NumberFormat(i,e)}catch{try{return new Intl.NumberFormat(void 0,e)}catch{return new Intl.NumberFormat}}}function Ns({decimals:i,minDecimals:e,maxDecimals:t,group:s=!0}){let n={useGrouping:s!==!1},r=Ro(e??i),o=Ro(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,Ku)),n}function Ro(i){if(i==null)return null;let e=Number(i);return Number.isFinite(e)?Math.min(Hu,Math.max($u,Math.round(e))):null}function Os(i){if(i==null||i==="")return null;let e=typeof i=="number"?i:Number(i);return Number.isFinite(e)?e:null}function Yu(i){if(typeof i!="string")return null;let e=i.trim().toUpperCase();return/^[A-Z]{3}$/.test(e)?e:null}var Wu=".zx-scope, [data-zx-theme], [data-zx-preset]",Zu="dialog:modal, dialog[open], dialog:popover-open";function se(i=null){return Bo(jo(i))}function wt(i=null){let e=jo(i);return(i==null?null:Ze(e))??Bo(e)}function We(i=null,e={}){let t=e.dialog===!1?se:wt;if(i==null)return t(null);let s=Y(i);return s?.isConnected?t(s):null}function Ze(i){if(!i||typeof i.closest!="function")return null;try{return i.closest(Zu)}catch{return i.closest("dialog[open]")}}function jo(i){return i==null?document.activeElement instanceof Element?document.activeElement:null:Y(i)}function Bo(i){let e=i?.closest?.(Wu)??null;return!e||e===document.documentElement||e===document.body?document.body:e}var $o=new Set(["tooltip","toast"]);function Ce(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 Gu(i,e){for(let t=i.length-1;t>=0;t-=1){let s=i[t];if(!$o.has(s.kind)&&e.some(n=>Ce(s.root,n)))return s}return null}function vt(i,e,t){return t?Ce(e.root,t)||e.inside.some(s=>Ce(s,t))?!0:i.some(s=>s.parent===e&&vt(i,s,t)):!1}function Fs(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 Qu(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&&!Ce(e,n.root)||typeof n.onEscape=="function"&&t.push(n)}return t}function Xu(i,e,t=null){if(i.some(n=>n.kind==="toast"&&Ce(n.root,e)))return[];let s=[];for(let n=i.length-1;n>=0;n-=1){let r=i[n];r.kind==="tooltip"&&!vt(i,r,e)&&r.onOutsidePointer&&s.push(r)}for(let n=i.length-1;n>=0;n-=1){let r=i[n];if(!$o.has(r.kind)){if(vt(i,r,e)||r.kind==="modal")break;t&&!Ce(t,r.root)||r.onOutsidePointer&&s.push(r)}}return s}var Ls=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=Vo(e.anchor),s={order:++this.#t,kind:e.kind,root:e.root,owner:e.owner??null,anchors:t,inside:Vo(e.inside),parent:e.kind==="toast"?null:Gu(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:()=>Fs(this.#e)===s,contains:r=>this.#e.includes(s)&&vt(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 Fs(this.#e,e)}topmostModal(){let e=Fs(this.#e,s=>s.kind==="modal"&&s.root.isConnected&&Ju(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=>Ce(t.root,e)||t.inside.some(s=>Ce(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 Qu(this.#e,qo(Rs(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=Rs(e),s=Xu(this.#e,t,qo(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=Rs(e);for(let s of this.#e.slice().reverse()){if(typeof s.onFocusOutside!="function"||!this.#e.includes(s)||vt(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})}}},Ge=new Ls;function Qe(i){return Ge.push(i)}function Vo(i){let e=Array.isArray(i)?i:[i];return e.filter((t,s)=>t!=null&&e.indexOf(t)===s)}function qo(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 Rs(i){return(typeof i.composedPath=="function"?i.composedPath():[])[0]??i.target??null}function Ju(i,e,t){if(typeof i.matches!="function")return t;try{return i.matches(e)}catch{return t}}var Ho=Object.freeze({mod:["\u2318","Ctrl"],meta:["\u2318","Meta"],cmd:["\u2318","Ctrl"],command:["\u2318","Ctrl"],ctrl:["\u2303","Ctrl"],control:["\u2303","Ctrl"],alt:["\u2325","Alt"],option:["\u2325","Alt"],shift:["\u21E7","Shift"],backspace:["\u232B","Backspace"],delete:["\u2326","Del"],tab:["\u21E5","Tab"]}),Ko=Object.freeze({enter:"\u21B5",return:"\u21B5",escape:"Esc",esc:"Esc",space:"Space",arrowup:"\u2191",up:"\u2191",arrowdown:"\u2193",down:"\u2193",arrowleft:"\u2190",left:"\u2190",arrowright:"\u2192",right:"\u2192",pageup:"PgUp",pagedown:"PgDn",home:"Home",end:"End"});function ed(){let i=globalThis.navigator;if(!i)return!1;let e=i.userAgentData?.platform||i.platform||"";return/mac|iphone|ipad|ios/i.test(e)}function td(i){if(i==="+")return["+"];let e=i.split("+");return i.endsWith("++")&&e.splice(-2,2,"+"),e.map(t=>t.trim()).filter(t=>t!=="")}function id(i,e){let t=i.toLowerCase();return Object.hasOwn(Ho,t)?Ho[t][e?0:1]:Object.hasOwn(Ko,t)?Ko[t]:i.length===1?i.toUpperCase():i}function sd(i,{apple:e=ed()}={}){return(Array.isArray(i)?i.map(String):td(String(i))).map(s=>id(s,e))}function me(i,e={}){return c("kbd",{class:"zx-kbd",dataset:{size:e.size==="sm"?"sm":void 0,tone:e.tone==="inherit"?"inherit":void 0}},sd(i).map(t=>c("kbd",{class:"zx-kbd__key"},t)))}var nd=Object.freeze({size:"md",label:"",showLabel:!1,kind:"accent"}),rd=Object.freeze({sm:!0,md:!0,lg:!0});function Uo(i={}){let e={...nd,...i},t=String(e.label??""),s=c("span",{class:"zx-spinner",dataset:{size:rd[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 od=Object.freeze({label:"",icon:null,kind:"default",size:"md",disabled:!1});function Yo(i={}){let e={...od,...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:cd(e.kind),size:ud(e.size)}});return e.icon&&t.append(w(e.icon,{size:16})),e.label!==""&&t.append(c("span",{class:"zx-btn__label"},String(e.label))),e.shortcut&&t.append(ld(e.shortcut.label)),!e.label&&e.title&&t.setAttribute("aria-label",e.title),typeof e.onclick=="function"&&(t.onclick=e.onclick),e.busy&&ad(t,!0),t}function ad(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=Uo({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 ld(i){let e=me(String(i),{size:"sm"});return e.classList.add("zx-btn__shortcut"),e.setAttribute("aria-hidden","true"),e}function cd(i){return["primary","danger","ghost"].includes(String(i))?i:"default"}function ud(i){return i==="sm"?"sm":"md"}function dd(i,e){return String(i).localeCompare(String(e))}function hd(i,e){return i-e}function fd(i,e){return i.getTime()-e.getTime()}function pd(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=fd(i,e):typeof i=="number"&&typeof e=="number"?r=hd(i,e):r=dd(i,e),t==="desc"?-r:r}function md(i,e="asc"){return(t,s)=>pd(i(t),i(s),e)}function Ps(i,e,t="asc"){let s=md(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 _d=new Set(["text","number","select","date","checkbox","textarea"]),gd='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',St=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:K(t),this._columns=Zo(this.options.columns),this._data=Array.isArray(this.options.data)?[...this.options.data]:[],this._rowKind=Nd(this.options.rowKind),this._rowKinds=Od(this.options.rowKinds),this._spanning=this._hasSpanningRow(),this._sortWarned=!1,this._selected=new Set,this._selectionAnchorId=null,this._sort=Qo(this.options.sort,this._columns),this._rowMeta=new WeakMap,this._rowNames=new WeakMap,this._rowElements=new Map,this._restored=!1,this._editMode=Ld(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=Hd(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||vi(this.options.hierarchy,this._columns)||this._clickListened),this._current=null,this._rovingEl=null,this._extendBase=null,this._hierarchy=vi(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=Fd(this._hierarchy?.expanded),this._sort&&this.options.sortMode==="local"&&this._sortData(),this._hierarchy?.expanded===!0)for(let s of wi(this._data,this.options.rowId,this._hierarchy.parentId))this._expanded.add(s);return this._reconcileExpanded(),Rd(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),Xo(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 Xo(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=Zo(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=Qo(o,s),this._hierarchy=vi(this.options.hierarchy,s),this._reconcileExpanded(),this._renderColumns(),this._renderHeader(),this._renderBody(),this._renderColumnControls(),t.silent||(xi(n,this.getColumnOrder())||this.emit("columnorderchange",{order:this.getColumnOrder()}),xi(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=Vd(this._columns,e);if(xi(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=vi(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=qd(this.getColumnOrder(),String(e),String(t),s);if(xi(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 ${Si(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=ia(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,js(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=wi(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=>Xe(p,n)!==!1)??null:s;if(!r||Xe(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=>Xe(p,l)!==!1):[r],h=new Map;for(let p of d){let f=Go(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=Id(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?F(t,s):n}_watchWidth(){this._width?.destroy(),this._width=null;let e=this.options.responsive;!e||!(e in bi)||(this._width=Oo((t,s)=>this._setStacked(s>0&&s<bi[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&&(U(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:ta(e,this._rowKind,this._rowKinds)}_hasSpanningRow(){return xd(this._data,this._rowKind,this._rowKinds)}_spanColspan(){return Sd(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"}},w("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=Si(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"}},w("chevron-up",{size:T.chevron})),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"}},w("chevron-down",{size:T.chevron}))):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?Q(this._hierarchy.parentId,t):null;return this._data.filter(n=>!this._hierarchy||Vs(Q(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&&Vs(Q(this._hierarchy.parentId,s),Q(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=>$d(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??(Bs(t)?"end":null);n&&(s.dataset.align=n),t.headerTitle&&(s.title=t.headerTitle);let r=jd(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),c("span",{class:"zx-table__sort-icon",ariaHidden:"true"},w("arrow-up",{size:T.sort})));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:Jo(e,this._rowKind),l=a===null?null:ea(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},w("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??(Bs(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&&Xe(h,e)!==!1&&(p.dataset.editable="true"),this._renderCellContent(p,h,e,t,s),r.append(p)}),this._rowNames.set(r,vd([...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=kd(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)},w(u?"chevron-down":"chevron-right",{size:T.chevron})))}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&&xt(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&&Wo(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&&xt(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&&Wo(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=Xe(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=()=>Oe(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(gd)??u,d}if(r==="number"){let f=Fe(t.locale,s),_=sa(t,s),m=t.type==="currency"?Fe(t.currency,s):t.type==="unit"?Fe(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 Ue(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}),Oe(t,b.get(),s)),d}if(r==="select"){let f=Td(t.options,s),_=f.find(g=>Object.is(g.value,o))??f.find(g=>String(g.value)===String(o??"")),m=new $(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=()=>Oe(t,m.value,s),d}if(r==="date"){let f=new Me(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===""?Oe(t,null,s):(f.set(m,{silent:!0}),f.get()===null&&f.set(g,{silent:!0}),Oe(t,f.get(),s))},d}if(r==="checkbox"){let f=new Ye(null,{...a,checked:!!o});return u.append(f.el),d.component=f,d.control=f.el,d.read=()=>Oe(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??`${Si(t)} row ${n+1}`,value:Dd(t,o,s)});return u.append(p),d.control=p,d.read=()=>Oe(t,p.value,s),d}_focusEditor(e){let t=this._edit?.cells.get(e),s=t?.control;!s||typeof s.focus!="function"||(s.focus(),Bd(t.type)&&typeof s.select=="function"&&s.select())}_focusCell(e,t){let s=this._rowElements.get(e)?.[0];(s?Go(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&&xt(t)){if(Pd(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)&&Xe(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&&xt(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=Q(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&&xt(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=wd(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=bd({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 yd(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,!js(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]));js(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?zd(this._data,this.options.rowId,this._hierarchy.parentId,t,this._sort.dir):Ps(this._data,t,this._sort.dir)}_setRowExpanded(e,t,s){return this._hierarchy?wi(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=wi(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 bd(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 yd(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 wd(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 vd(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 Jo(i,e){if(e==null||e==="")return null;let t=typeof e=="function"?e(i):i?.[e];return t==null?null:String(t)}function ea(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 ta(i,e,t){return!!ea(t,Jo(i,e))?.span}function xd(i,e,t){return!Array.isArray(i)||e==null||t==null?!1:i.some(s=>ta(s,e,t))}function Sd(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 kd(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=Fe(i.locale,e),o=sa(i,e),a={...r!=null?{locale:String(r)}:{},...o!=null?{decimals:o}:{}};if(n==="number")return yi(s,a);if(n==="currency"){let l=Fe(i.currency,e);return Lo(s,l==null?null:String(l),a)}if(n==="percent")return Po(s,a);if(n==="unit"){let l=yi(s,a),u=Fe(i.unit,e);return l&&u!=null&&String(u)!==""?`${l}\xA0${u}`:l}return s}function Cd(i,e,t,s=[]){let n=Ai(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 zd(i,e,t,s,n){let r=Ai(i,e,t),o=u=>Ps(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 ia(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(Q(e,h),t)),a=i.findIndex(h=>Object.is(Q(e,h),s));if(o<0||a<0||r&&!Vs(Q(r,i[o]),Q(r,i[a])))return null;if(r){let h=Ai(i,e,r),p=h.nodes[o],f=h.nodes[a];if(!p||!f||p.parent!==f.parent)return null;let _=x=>{let D=[],H=[x];for(;H.length;){let Z=H.pop();D.push(Z);for(let oe=Z.children.length-1;oe>=0;oe-=1)H.push(Z.children[oe])}return D},m=new Set(_(p).map(x=>x.index)),g=new Set(_(f).map(x=>x.index)),b=i.filter((x,D)=>m.has(D)),y=i.filter((x,D)=>!m.has(D)),A=i.map((x,D)=>D).filter(x=>!m.has(x)),v=A.findIndex(x=>x===a);if(n==="after"){let x=A.map((D,H)=>g.has(D)?H:-1).filter(D=>D>=0);v=Math.max(...x)+1}return v<0?null:(y.splice(v,0,...b),y)}let l=[...i],[u]=l.splice(o,1),d=l.findIndex(h=>Object.is(Q(e,h),s));return l.splice(d+(n==="after"?1:0),0,u),l}function Xe(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?Bs(i)?"number":"text":typeof t=="string"&&_d.has(t)?t:!1}function Td(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 Dd(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 Oe(i,e,t){return typeof i?.parse=="function"?i.parse(e,t):e}function Ed(i,e){return Object.is(i,e)?!0:i instanceof Date&&e instanceof Date?i.getTime()===e.getTime():!1}function Id(i,e){let t={};for(let[s,n]of Object.entries(e??{}))Ed(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 Fe(i,e){return typeof i=="function"?i(e):i}function sa(i,e){let t=Fe(i?.decimals,e);if(t==null)return null;let s=Number(t);return Number.isFinite(s)?Math.max(0,Math.trunc(s)):null}function Bs(i){return["number","currency","percent","unit"].includes(i?.type)}function Ai(i,e,t){let s=(Array.isArray(i)?i:[]).map((a,l)=>({row:a,id:Q(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=Q(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 wi(i,e,t){return Ai(i,e,t).nodes.filter(s=>s.children.length>0).map(s=>s.id)}function Q(i,e){return typeof i=="function"?i(e):e?.[i]}function Vs(i,e){return i==null&&e==null||Object.is(i,e)}function vi(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 Nd(i){return typeof i=="function"||typeof i=="string"&&i!==""?i:null}function Od(i){return!i||typeof i!="object"||Array.isArray(i)?null:i}function Fd(i){return new Set(Array.isArray(i)?i:[])}function Rd(i){return i==="plain"?"plain":"default"}function Ld(i){return i==="cell"||i==="row"?i:i===!0?"cell":!1}function xt(i){return!!i?.closest?.(".zx-table__editor")}function Wo(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 Pd(i){return i.closest("[popover]")?!0:i.getAttribute?.("aria-expanded")==="true"}function Zo(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 Si(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 jd(i){let e=i?.label==null?"":String(i.label).trim(),t=i?.ariaLabel==null?"":String(i.ariaLabel).trim();return t||(e?null:Si(i)||null)}function Bd(i){return i==="text"||i==="number"||i==="date"}function Vd(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 qd(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 Go(i,e){for(let t of i.cells)if(t.dataset.column===e)return t;return null}function Qo(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 $d(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 Xo(i){if(!Array.isArray(i))throw new TypeError("Table data must be an array")}function js(i,e){return i.size===e.size&&[...i].every(t=>e.has(t))}function xi(i,e){return i.length===e.length&&i.every((t,s)=>Object.is(t,e[s]))}function Hd(i){let e=Math.trunc(Number(i));return Number.isFinite(e)&&e>0?e:null}var Kd=["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(","),Je=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=Y(e);if(!s)throw new TypeError("Dropdown anchor could not be resolved");super(null,t),this.#e=s,We(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=G(this.#e,this.el,{placement:this.options.placement,offset:Number(this.options.offset),matchWidth:!!this.options.matchWidth}),this.el.dataset.state="open",this.#s=Qe({kind:"popup",root:this.el,owner:this,anchor:[this.#e,Y(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(),Ze(this.el.parentElement)&&this.el.parentElement?.isConnected&&se(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 Ud(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)Zd(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 Ze(this.#e)??Ze(Y(this.options.scope))??wt(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=qs(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=qs(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=Yd(this.#e,this.el);r&&(e.preventDefault(),r.focus())}#d(e){this.#i.set(e,this.#e.getAttribute(e))}};function Ud(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 qs(i){return Array.from(i.querySelectorAll(Kd)).filter(e=>Wd(e))}function Yd(i,e){let t=Ze(i)??i.ownerDocument.body??i.ownerDocument.documentElement,s=qs(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 Wd(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 Zd(i,e,t){t===null?i.removeAttribute(e):i.setAttribute(e,t)}var Hs=Object.freeze(["blue","teal","green","amber","orange","red","pink","violet","slate"]),$s=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:K(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&&U(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=na(e.size,"36px"),s=na(e.iconSize,"52%");this.el.style.setProperty("--zx-app-icon-size",t),this.el.style.setProperty("--zx-app-icon-glyph-size",s),xe(e.color)?this.el.style.setProperty("--zx-app-icon-color",String(e.color)):this.el.style.removeProperty("--zx-app-icon-color"),Hs.includes(e.tone)?this.el.dataset.tone=e.tone:delete this.el.dataset.tone,this.el.dataset.glass=Qd(e.glass),this.el.dataset.shape=Xd(e.shape),this.el.toggleAttribute("data-selected",!!e.selected);let n=e.label==null?"":String(e.label).trim();if(this._interactiveRoot){let u=ra(this._snapshot,"role"),d=ra(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=Gd(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 ki(i={}){return new $s(null,i).toElement()}function Gd(i){let e=typeof i=="function"?i():i;return typeof e=="string"?w(e,{size:"1em"}):e&&typeof e=="object"&&typeof e.nodeType=="number"?e:null}function na(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 Qd(i){return i===!1||i==="none"?"none":i==="strong"?"strong":"subtle"}function Xd(i){return i==="circle"?"circle":"tile"}function ra(i,e){return i?.attributes.find(([t])=>t===e)?.[1]??null}var Ti=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=At(this.options.items),this._sources=ca(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"},w("x",{size:T.dismiss})),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")},w("x",{size:T.dismiss})),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("span",{class:"zx-launcher__shortcut",ariaHidden:"true"},me("Mod+K")):null,f=Jd(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"}},w("search"),a,r,p,l),u,h,f,d)),e.dataset.state="closed",this._createdRoot&&We(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=se(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=Qe({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"),oa(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=At(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=ca(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=>Ci(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,At(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&&!oa(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)?At(e.items):[],sources:typeof e.items=="function"?[sh(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!et(t)||t.label==null?[]:[ua({...t,id:t.id??t.label})]}return eh(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=>Ci(m.when,n)),a=aa(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=>Ci(b.when,n)):aa(g.filter(b=>Ci(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=et(e),n=s?null:qe(e.href),r=n?"a":"button",o=[],a=nh(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=ih(e),u=th(e.shortcut);return u.length&&o.push(c("span",{class:"zx-launcher__keys",ariaHidden:l?"true":null},me(u,{size:"sm"}))),s&&o.push(c("span",{class:"zx-launcher__chevron",ariaHidden:"true"},w("chevron-right",{size:T.chevron}))),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:rh(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||!et(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=oh(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(et(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?F(t,s):n}};function Jd(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",{},me(["\u2191\u2193\u2190\u2192"]),t.move??e.move),c("span",{},me("Enter"),t.open??e.open),c("span",{ref:"backHint",hidden:!0},me("Backspace"),t.back??e.back),c("span",{},me("Escape"),t.close??e.close))}function et(i){let e=i?.items;return!!i&&typeof i=="object"&&(Array.isArray(e)||typeof e=="function")}function eh(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 At(r)){if(!et(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 th(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 ih(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 sh(i){return{id:`page:${String(i.id)}`,load:i.items,order:i.order==="source"?"source":"rank",_page:!0}}function oa(i,e){return i.length===e.length&&i.every((t,s)=>t===e[s]||String(t.id)===String(e[s].id))}function nh(i){let e=i.icon;if(typeof e=="function"&&(e=e(i)),typeof e=="string")return w(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 rh(i){return i==="application"||i==="record"?i:"action"}function Ci(i,e){return i==="empty"?e==="":i==="query"?e!=="":!0}function oh(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 aa(i,e,t=100){let s=tt(e).trim(),n=i.map((o,a)=>({item:o,order:a,score:ah(o,s)})).filter(({score:o})=>o<1/0);n.sort((o,a)=>{let l=zi(o.item.groupOrder),u=zi(a.item.groupOrder);if(l!==u)return l-u;if(s===""){let d=la(o.item.pinned,o.order),h=la(a.item.pinned,a.order);if(d!==h)return d-h}return o.score-a.score||zi(o.item.itemOrder)-zi(a.item.itemOrder)||lh(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 ah(i,e){if(!e)return i.pinned?-1:0;let t=tt(i.label),s=tt(i.id),n=tt(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 la(i,e){return typeof i=="number"&&Number.isFinite(i)?i:i?e:Number.MAX_SAFE_INTEGER}function zi(i){return typeof i=="number"&&Number.isFinite(i)?i:Number.MAX_SAFE_INTEGER}function tt(i){return String(i??"").normalize("NFKD").replace(/\p{M}/gu,"").toLowerCase()}function lh(i,e){let t=tt(i),s=tt(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 At(i){return Array.isArray(i)?i.filter(e=>e&&typeof e=="object"&&e.id!=null&&e.label!=null).map(e=>ua(e)):[]}function ua(i){let e={...i,label:String(i.label)};if(i.href==null)return e;let t=qe(i.href);return t!==null?e.href=t:(delete e.href,typeof e.invoke!="function"&&!et(e)&&(e.disabled=!0)),e}function ca(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 da=Object.freeze([Object.freeze(["getValue","setValue"]),Object.freeze(["get","set"]),Object.freeze(["getValues","setValues"]),Object.freeze(["isChecked","setChecked"])]),ch=Object.freeze(["value","values","checked"]),ha="input, select, textarea, button",uh="input, textarea";function Di(i){if(L(i))return i;let e=i;if(typeof e.toElement=="function")return e.toElement();if(L(e.el))return e.el;throw new TypeError("External field source must be an Element or a Component")}function fa(i){return ma(i,Di(i)).get()}function Ks(i){let e=Di(i),t=L(i)?null:i;if(t&&_e(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(ha)];return n.length>0&&n.every(r=>r.disabled)}function Us(i){let e=Di(i),t=L(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 pa(i,e=null){let t=Di(i),s=L(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&&ga(t)?t.checked:void 0,d=Ks(i),h=Us(i),p=new Map,f=ma(i,t),_=dh(s,t,p),m=hh(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 D=f.get();fh(D,A)?x.stopImmediatePropagation():A=D}));let v={el:t,get:()=>f.get(),set:(x,D)=>{y=!0;try{f.set(x,D)}finally{y=!1}A=f.get()},focus:()=>{s&&_e(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,D]of p)D.disabled!==void 0&&(x.disabled=D.disabled),D.readOnly!==void 0&&(x.readOnly=D.readOnly);p.clear();for(let[x,D]of o)D===null?t.removeAttribute(x):t.setAttribute(x,D);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&&(v.setReadonly=x=>{b=!!x,m(b)}),v}function ma(i,e){let t=L(i)?null:i;if(t){let s=da.find(([o])=>_e(t,o,0)),n=s?_e(t,s[1],2)?s[1]:da.map(([,o])=>o).find(o=>_e(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=ch.find(o=>o in t);if(r)return{get:()=>t[r],set:o=>{t[r]=o}}}return ga(e)?{get:()=>!!e.checked,set:s=>{e.checked=!!s}}:it(e,"value")?{get:()=>e.value,set:s=>{e.value=s??""}}:{get:()=>null,set:()=>{}}}function dh(i,e,t){return i&&_e(i,"setDisabled",1)?s=>i.setDisabled(s):i&&_e(i,"enable",0)&&_e(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(ha))_a(t,n,"disabled"),n.disabled=s||!!t.get(n)?.disabled}}function hh(i,e,t){if(i){for(let n of["setReadonly","setReadOnly"])if(_e(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(uh)];return s.length?n=>{for(let r of s)_a(t,r,"readOnly"),r.readOnly=n||!!t.get(r)?.readOnly}:null}function _a(i,e,t){let s=i.get(e)??{};s[t]===void 0&&(s[t]=!!e[t]),i.set(e,s)}function _e(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 ga(i){let e=String(i.type??"").toLowerCase();return i.tagName==="INPUT"&&(e==="checkbox"||e==="radio")}function fh(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 kt=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(L(t)||t instanceof S){let o=t;n=new z(null,{id:this._controlId(s),name:s,type:"custom",label:s,value:fa(o),disabled:Ks(o),readonly:Us(o),adapter:a=>pa(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 ph=new Set(["top","bottom","top-start","top-end","bottom-start","bottom-end","left","right","left-start","left-end","right-start","right-end"]),mh=new Set(["hover","focus","both","manual"]),st=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=Y(e);if(!s)throw new TypeError("Tooltip anchor could not be resolved");super(null,t),this.#e=s,We(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",gh(this.options.maxWidth));let n=mh.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||!bh(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=wt(this.#e);this.el.parentElement!==e&&e.append(this.el);let t=ba(this.#t);if(t===null)return this;this.el.replaceChildren(t);let s=ph.has(this.options.placement)?this.options.placement:"top";return this.#i=G(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",_h(this.#s,this.el.id)),this.#c=Qe({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=ba(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 ba(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 _h(i,e){let t=String(i??"").split(/\s+/).filter(Boolean);return t.includes(e)||t.push(e),t.join(" ")}function gh(i){return typeof i=="number"&&Number.isFinite(i)?`${i}px`:String(i)}function bh(i){try{return i.matches(":focus-visible")}catch{return!0}}var Ei=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=Re(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 va(n,this.options.header),va(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=Re(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&&wa(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 wa(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 Ys(this.el);let e=!1;for(let t of Ws(this._items)){if(t===xa){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 st(n,{content:t.label,placement:Sh(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 ya(e,{className:"zx-app-rail__item",index:String(e.id),iconOnly:!0,disclosure:t,disclosureIcon:yh(this.el.dataset.side),visual:Ii(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 Ws(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,_=ya(h,{className:"zx-app-rail__flyout-item",index:p,iconOnly:!1,disclosure:f,disclosureIcon:wh(this.el.dataset.side),visual:Ii(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 Je(t,{openOn:"manual",placement:n===null?vh(this.el.dataset.side):xh(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=Ah(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=Sa(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?Zs(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&&Zs(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?F(t,s):n}},Ys=class extends S{constructor(e){super(null),e.append(this.el)}render(){return c("span",{hidden:!0,"data-zx-app-rail-listener-scope":""})}},xa=Object.freeze({});function Ws(i,e=!1){return i.flatMap(t=>t.section?[e?t:xa,...Ws(t.children??[],e)]:[t])}function Re(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)?Re(e.children):[]};if(e.section===!0)return s.section=!0,delete s.href,s;if(e.href==null)return s;let n=qe(e.href);return n!==null?s.href=n:(delete s.href,s.children.length===0&&typeof s.invoke!="function"&&(s.disabled=!0)),s}):[]}function Ii(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 w(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 ya(i,{className:e,index:t,iconOnly:s,disclosure:n,disclosureIcon:r,visual:o}){let a=qe(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"},w(r)):null)}function yh(i){return{left:"chevron-right",right:"chevron-left",top:"chevron-down",bottom:"chevron-up"}[i]??"chevron-right"}function wh(i){return i==="right"?"chevron-left":"chevron-right"}function vh(i){return{left:"right-start",right:"left-start",top:"bottom-start",bottom:"top-start"}[i]??"right-start"}function xh(i){return i==="right"?"left-start":"right-start"}function Sh(i){return{left:"right",right:"left",top:"bottom",bottom:"top"}[i]??"right"}function Sa(i){return[...i.querySelectorAll('a:not([aria-disabled="true"]), button:not([aria-disabled="true"])')]}function wa(i){return Sa(i)[0]??null}function Ah(i){return[...i.children].map(e=>e.querySelector("[data-app-nav-id]")).filter(Boolean)}function Zs(i,e){return i.some(t=>String(t.id)===e||Zs(t.children??[],e))}function va(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 kh=["tint","solid","plain"],Ch=12,zh=600,Ni=class extends Ei{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=Xs(this._items,this._sections),this._appearance=kh.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=Gs(this.options.labels,e.dataset.orientation),e}setItems(e){let t=new Map,s=Xs(Re(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=ge(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&&Qs(a,s,"zx-app-rail__flyout-item");let r=this._catalogueEntry(n);return r&&Qs(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=Gs(this._labels,t),this._rebuild(),this)}setLabels(e){this._labels=e;let t=Gs(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")?Mi(s):null;return this.el.dataset.labels=t,this._rebuild(),n!==null&&[...this.refs.list.querySelectorAll(".zx-module-bar__item")].find(r=>Mi(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=za(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&&!ge(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=ge(this._items,t.getAttribute("data-app-nav-value-id"));if(!s)continue;let n=Ca(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=ge(this._items,t.dataset.moduleId),n=s?Ca(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=[Mh(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),Aa(e),o=Eh(e,this.el.dataset.orientation==="horizontal",t.length+1)}let a=Th(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);Aa(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=Ii(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}=Dh(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(ki({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"}},w("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 st(s,{content:e,placement:{left:"right",right:"left",top:"bottom",bottom:"top"}[this.el.dataset.side]??"right",delay:450}));let n=this._items.length>Ch?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 Je(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 Qs(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=ge(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=Ih(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=ge(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>zh?e:this._typeahead.text+e;this._typeahead={text:r,at:n};let o=r.toLocaleLowerCase(),a=[...o].every(h=>h===o[0]),l=h=>(ge(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=>Mi(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=Mi(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=ge(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 Th(i,e=1/0,t=[],s=!1){let n=Array.isArray(i)?i.filter(_=>_&&_.id!=null):[],r=za(n),a=n.some(ka)?r.filter(ka):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 Dh(i){let e=xe(i?.color)?String(i.color).trim():null;return e?{tone:null,color:e}:{tone:Hs.includes(i?.tone)?i.tone:null,color:null}}function Xs(i,e=new Map,t=null){return i.flatMap(s=>s.section?Xs(s.children??[],e,s.label):(t!==null&&e.set(String(s.id),t),[s]))}function Aa(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 Gs(i,e){return e!=="vertical"?"hidden":i==="below"||i==="beside"?i:"hidden"}function ka(i){return i.pinned===!0||typeof i.pinned=="number"&&Number.isFinite(i.pinned)}function za(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 Eh(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 Ih(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 Mi(i){return i.getAttribute("data-app-nav-value-id")??"\0more"}function Ca(i,e){return e===null?null:String(i.id)===e?"page":Js(i.children??[],e)?"true":null}function Qs(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 Mh(i,e){if(e==null||!Array.isArray(i))return null;let t=String(e);return i.find(s=>String(s.id)===t||Js(s.children??[],t))??null}function ge(i,e){if(e==null)return null;for(let t of i??[]){if(String(t.id)===String(e))return t;let s=ge(t.children??[],e);if(s)return s}return null}function Js(i,e){return i.some(t=>String(t.id)===e||Js(t.children??[],e))}var Nh=8e3,tn=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}},ze=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:$h(t),this._entries=new Set,this._floatingHost=null,this._placedIn=null,this._overlay=null,this._unfollow=null,this._queue=new tn(Bh(this.options.maxVisible),s=>{this._activate(s)}),t.replaceChildren(),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t}show(e,t={}){let s=Lh(t.action),n={kind:Oh(t.kind??this.options.kind),timeout:Rh(t.timeout??this.options.timeout,s!==null),closable:t.closable??!!this.options.closable,action:s,leading:Ph(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=Y(e);if(!t)return!1;let s=i.#t(se(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)en(t),t.node.remove();this._queue.clear(),this._entries.clear(),super.destroy(),!this._createdRoot&&this._original&&Hh(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=Vh(r),o!==void 0&&(t.text=String(o)),Oi(s,t))},done:()=>{n||s.closed||(n=!0,t.pct=100,Oi(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(w("error",{size:18})),Oi(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??w(t.kind,{size:18})),r=c("div",{class:"zx-message__content"});Ct(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,Oi(a,s)}if(t.action){let{label:l,kind:u,onclick:d}=t.action,h=Yo({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")},w("x",{size:T.dismiss}));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=Ct(u)&&!o.contains(u)?u:null}a.focused=!0,this._pause(a)}),this.listen(o,"focusout",l=>{let u=l.relatedTarget;Ct(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,en(e),jh(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",!qh()){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)&&(en(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=Ge.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=se(e??null);t.isConnected||(t=se(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=Ge.push({kind:"toast",root:n,owner:r}),r._unfollow=Ge.subscribe(()=>r._rehome()),r._rehome(),r}static#t(e){for(let t of Ge.entries())if(t.kind==="toast"&&t.owner instanceof i&&t.owner._floatingHost===e)return t.owner;return null}static#i(e){e._disposeFloating()}};function Oh(i){return i==="danger"?"error":["success","warning","error"].includes(String(i))?i:"info"}function Fh(i){let e=Number(i);return Number.isFinite(e)?Math.max(0,e):4e3}function Rh(i,e=!1){let t=Fh(i);return e&&t>0?Math.max(t,Nh):t}function Lh(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 Ph(i){if(Ct(i))return i;if(i&&typeof i=="object"&&typeof i.toElement=="function"){let e=i.toElement();return Ct(e)?e:null}return null}function jh(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 Bh(i){let e=Number(i);return Number.isInteger(e)&&e>0?e:5}function Ct(i){return!!(i&&typeof i=="object"&&typeof i.nodeType=="number")}function Vh(i){let e=Number(i);return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function Oi(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 en(i){i.timer!==null&&clearTimeout(i.timer),i.exitTimer!==null&&clearTimeout(i.exitTimer),i.timer=null,i.exitTimer=null}function qh(){return typeof matchMedia!="function"||matchMedia("(prefers-reduced-motion: no-preference)").matches}function $h(i){return{attributes:Array.from(i.attributes,e=>[e.name,e.value]),children:Array.from(i.childNodes)}}function Hh(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 Ri=Object.freeze(["agenda","day","week","month","year"]),Kh=864e5;function nn(i,e,t={}){let s=Le(e,"Calendar date"),n=Oa(t.weekStart??1),r,o;if(i==="agenda")r=P(s),o=N(r,Pi(t.agendaDays??14,"agendaDays"));else if(i==="day")r=P(s),o=N(r,1);else if(i==="week")r=Fi(s,n),o=N(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=Fi(a,n),o=N(Fi(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 rn(i,e,t,s={}){let n=Le(e,"Calendar date"),r=ye(t,"direction");if(i==="day")n.setDate(n.getDate()+r);else if(i==="agenda")n.setDate(n.getDate()+r*Pi(s.agendaDays??14,"agendaDays"));else if(i==="week")n.setDate(n.getDate()+r*7);else{if(i==="month")return sn(n,r);if(i==="year")return sn(n,r*12);throw new RangeError(`Unknown calendar view: ${i}`)}return n}function sn(i,e){let t=Le(i,"Calendar date"),s=t.getDate();return t.setDate(1),t.setMonth(t.getMonth()+ye(e,"month amount")),t.setDate(Math.min(s,Uh(t.getFullYear(),t.getMonth()))),t}function Uh(i,e){return new Date(i,e+1,0).getDate()}function nt(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=be(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=Da(be(r,t.start),s,`event ${l} start`),d=be(r,t.end),h=d==null||d===""?new Date(u.getTime()):Da(d,s,`event ${l} end`);if(h<u)throw new RangeError(`Calendar event ${l} ends before it starts`);let p=String(be(r,t.title)??"").trim()||"Untitled event",f=String(be(r,t.location)??"").trim(),_=Ea(be(r,t.editable)),m=Ea(be(r,t.durationEditable));return{id:a,title:p,start:u,end:h,allDay:!!be(r,t.allDay),color:Wh(be(r,t.color)),location:f,editable:_,durationEditable:m,data:r}})}function j(i){return{...i,start:new Date(i.start.getTime()),end:new Date(i.end.getTime())}}function on(i,e,t={}){let s=Na(t.minMinutes??0,"minMinutes"),n=Na(t.maxMinutes??1440,"maxMinutes",!0),r=Pi(t.minimumMinutes??30,"minimumMinutes");if(n<=s)throw new RangeError("Calendar maxMinutes must exceed minMinutes");let o=P(e),a=Ia(o,s),l=Ia(o,n),u=i.filter(f=>!ce(f)&&an(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:Ma(o,_),endMinutes:Ma(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 Li(i,e,t){let s=P(e),n=N(s,Pi(t,"days")),r=i.filter(a=>ce(a)&&an(a,s,n)).map(a=>{let l=P(a.start),u=Yh(a);return{event:a,start:Math.max(0,X(s,l)),end:Math.min(t,X(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 zt(i,e={}){let t=ye(e.days??0,"days"),s=ye(e.minutes??0,"minutes"),n=ye(e.endDays??t,"endDays"),r=ye(e.endMinutes??s,"endMinutes"),o=j(i);if(o.start=Ta(o.start,t,s),o.end=Ta(o.end,n,r),o.end<o.start)throw new RangeError("Calendar event proposal ends before it starts");return o}function P(i){let e=Le(i,"Calendar date");return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function N(i,e){let t=Le(i,"Calendar date"),s=new Date(t.getTime());return s.setDate(s.getDate()+ye(e,"day amount")),s}function Fi(i,e=1){let t=P(i),s=Oa(e);return N(t,-((t.getDay()-s+7)%7))}function X(i,e){let t=P(i),s=P(e),n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),r=Date.UTC(s.getFullYear(),s.getMonth(),s.getDate());return Math.round((r-n)/Kh)}function V(i){let e=Le(i,"Calendar date"),t=s=>String(s).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function ce(i){if(i.allDay)return!0;if(i.end<=i.start)return!1;let e=new Date(i.end.getTime()-1);return V(i.start)!==V(e)}function Tt(i,e,t){return an(i,e,t)}function Ta(i,e,t){let s=new Date(i.getTime());return s.setDate(s.getDate()+e),s.setMinutes(s.getMinutes()+t),s}function Yh(i){if(i.end<=i.start)return N(P(i.start),1);let e=P(i.end);return i.end.getTime()===e.getTime()?e:N(e,1)}function an(i,e,t){let s=i.end>i.start?i.end:new Date(i.start.getTime()+1);return i.start<t&&s>e}function be(i,e){return typeof e=="function"?e(i):i[e]}function Da(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 Le(s,t)}function Ea(i){return i==null?null:!!i}function Wh(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 Ia(i,e){let t=P(i);return t.setMinutes(e),t}function Ma(i,e){return(e.getTime()-i.getTime())/6e4}function Le(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 Oa(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 ye(i,e){let t=Number(i);if(!Number.isInteger(t))throw new TypeError(`${e} must be an integer`);return t}function Pi(i,e){let t=ye(i,e);if(t<=0)throw new RangeError(`${e} must be greater than zero`);return t}function Na(i,e,t=!1){let s=ye(i,e),n=t?1440:1439;if(s<0||s>n)throw new RangeError(`${e} must be from 0 through ${n}`);return s}var Et=class extends S{static cssName="calendar";static defaults={events:[],date:null,view:"month",views:[...Ri],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=Zh(this.options.views),this._view=this._views.includes(this.options.view)?this.options.view:this._views[0],this._date=Fa(this.options.date,this.options.dateUnit,this._now()),this._events=nt(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},w("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(j)}setEvents(e,t={}){let s=nt(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]=nt([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]=nt([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=Fa(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="${ji(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?w(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=nn(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=X(e.start,e.end);for(let n=0;n<s;n+=1){let r=N(e.start,n),o=N(r,1),a=this._events.filter(d=>Tt(d,r,o)?d.start>=r||n===0:!1).sort(Xh),l=c("section",{class:"zx-calendar__agenda-day",role:"row",dataset:{date:V(r)}},c("button",{type:"button",class:"zx-calendar__agenda-heading",role:"rowheader",dataset:{calendarAction:"date",date:V(r),dateCell:"true"},ariaCurrent:je(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:X(e.start,e.end)},(b,y)=>N(e.start,y)),s=this._view==="week"&&this.options.workweek?t.filter(b=>b.getDay()>0&&b.getDay()<6):t,n=we(this.options.slotMinTime,0),r=we(this.options.slotMaxTime,1440,!0),o=ne(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:V(b),dateCell:"true"},ariaCurrent:je(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?ln(y,this.options.locale):""));for(let A=0;A<s.length;A+=1){let v=Qh(s[A],y),x=String(v.getTime()),D=this._focusedSlot?this._focusedSlot===x:m;D&&(m=!1),_.append(c("button",{type:"button",class:"zx-calendar__slot",role:"gridcell",tabindex:D?0:-1,dataset:{calendarAction:"date",slot:x,dateTime:x,dayIndex:String(A),rowIndex:String(b),major:y%60===0?"true":null},ariaLabel:this._dateTimeLabel(v),disabled:this.options.disabled}))}}let g=c("div",{class:"zx-calendar__timed-events",ariaHidden:"false"});return s.forEach((b,y)=>{let A=on(this._events,b,{minMinutes:n,maxMinutes:r,minimumMinutes:o});for(let v of A){let x=(v.startMinutes-n)/(r-n)*100,D=Math.max(o/(r-n)*100,(v.endMinutes-v.startMinutes)/(r-n)*100),H=100/s.length,Z=H/v.columns,oe=y*H+v.column*Z,k=this._eventElement(v.event,{variant:"timed",day:b,resizable:!0});k.style.insetInlineStart=`${oe}%`,k.style.inlineSize=`${Z}%`,k.style.insetBlockStart=`${x}%`,k.style.blockSize=`${D}%`,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:V(r)},ariaHidden:"true"}));let n=Li(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=N(e.start,r);s.append(c("span",{class:"zx-calendar__month-weekday",role:"columnheader"},this._format(o,{weekday:"short"})))}t.append(s);let n=X(e.start,e.end)/7;for(let r=0;r<n;r+=1){let o=N(e.start,r*7),a=Li(this._events.map(m=>({...m,allDay:!0})),o,7),l=Gh(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:V(o)}});this.options.weekNumbers&&h.append(c("button",{type:"button",class:"zx-calendar__month-week-number",dataset:{calendarAction:"week",date:V(o)},ariaLabel:this.msg("calendar.weekNumber",La(o)),disabled:this.options.disabled},String(La(o))));let p=c("div",{class:"zx-calendar__month-days"});for(let m=0;m<7;m+=1){let g=N(o,m),b=this._events.filter(y=>Tt(y,g,N(g,1))).length;p.append(c("button",{type:"button",class:"zx-calendar__month-day",role:"gridcell",dataset:{calendarAction:"date",date:V(g),dateCell:"true",otherMonth:g.getMonth()===this._date.getMonth()?null:"true",eventCount:String(b)},ariaCurrent:je(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:N(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=N(o,m);f.append(c("button",{type:"button",class:"zx-calendar__more",dataset:{calendarAction:"more",date:V(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=N(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=N(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=N(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=>Tt(p,d,N(d,1))).length;l.append(c("button",{type:"button",class:"zx-calendar__year-day",role:"gridcell",dataset:{calendarAction:"date",date:V(d),dateCell:"true",activity:String(Math.min(3,h))},ariaCurrent:je(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(j(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=>je(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"},ln(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:j(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=Te(t.dataset.date);r&&this.setDate(r).setView("week")}else if(n==="more"){let r=Te(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:j(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?N(n,1):Pe(n,ne(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:j(s),jsEvent:e});return}if(e.key===" "&&!this._keyboardEdit){if(n?!this._canResize(s):!this._canMove(s))return;e.preventDefault(),this._keyboardEdit={oldEvent:j(s),event:j(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=!ce(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=-ne(this.options.slotDuration):r=-7;else if(e.key==="ArrowDown")a?o=ne(this.options.slotDuration):r=7;else return;e.preventDefault();let l=this._keyboardEdit;if(l.action==="move")l.event=zt(l.event,{days:r,minutes:o});else{let u=zt(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=Te(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=N(s,n),o=this.el.querySelector(`[data-date-cell][data-date="${V(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:j(r),event:j(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:Pe(n,ne(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=ne(this.options.slotDuration);t.end=Pe(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:Pe(t.end,-ne(this.options.slotDuration)),n=t.start<t.end?t.end:Pe(t.start,ne(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"&&!ce(e),o=this._timeAtPoint(s,n,r?e.start:null);if(o&&!ce(e)){if(t==="move"){let f=e.end.getTime()-e.start.getTime(),_=j(e);return _.start=Pe(o,-Number(this._pointer?.timeOffsetMinutes??0)),_.end=new Date(_.start.getTime()+f),_}let p=j(e);return p.end=Pe(o,ne(this.options.slotDuration)),p.end>p.start?p:null}let a=this._dayAtPoint(s,n);if(!a)return null;let l=N(a,-Number(this._pointer?.dayOffset??0)),u=X(P(e.start),l);if(t==="move")return zt(e,{days:u,minutes:0});let d=j(e),h=N(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 Te(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=Te(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 N(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 Te(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 Te(a)}return null}_dragOffsetForEvent(e,t,s){if(!ce(e)){let o=this._timeAtPoint(t,s);if(o){let a=ne(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?X(P(e.start),n):0;return{minutes:0,days:Math.max(0,r)}}_timeGridDayIndex(e){let t=V(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")||ce(e))return null;let s=we(this.options.slotMinTime,0),n=we(this.options.slotMaxTime,1440,!0),r=ne(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:j(t),oldEvent:j(e),action:s,delta:Jh(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?j(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(rn(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=N(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(ce(e))return je(e.start,t)?`${Dt(e.start,this.options.locale)} \u2192`:je(e.end,t)?`\u2192 ${Dt(e.end,this.options.locale)}`:this.msg("calendar.allDay");let s=cn(e.start,this.options.locale);return e.end<=e.start?s:`${s}\u2013${cn(e.end,this.options.locale)}`}_eventLabel(e){let t=e.location?`, ${e.location}`:"";return`${e.title}, ${Dt(e.start,this.options.locale)} to ${Dt(e.end,this.options.locale)}${t}`}_dateTimeLabel(e){return Dt(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 Te(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="${ji(e.eventId)}"][data-event-action="${e.eventAction??"activate"}"]`)),!t&&e.slot&&(t=this.el.querySelector(`[data-slot="${ji(e.slot)}"]`)),!t&&e.date&&(t=this.el.querySelector(`[data-date-cell][data-date="${ji(e.date)}"]`)),t?.focus?.()}_scrollTimeGrid(){let e=this.refs.body.querySelector(".zx-calendar__time-scroller");if(!e)return;let t=we(this.options.slotMinTime,0),s=we(this.options.slotMaxTime,1440,!0),n=we(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===V(s)),r=we(this.options.slotMinTime,0),o=we(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=ln(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?F(t,s):n}};function Zh(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(!Ri.includes(t))throw new RangeError(`Unknown Calendar view: ${t}`);return e}function Fa(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 ne(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 Gh(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 we(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 Qh(i,e){let t=P(i);return t.setMinutes(e),t}function Pe(i,e){let t=new Date(i.getTime());return t.setMinutes(t.getMinutes()+e),t}function Ra(i){return`${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`}function je(i,e){return Ra(i)===Ra(e)}function Te(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 V(t)===i?t:null}function Xh(i,e){return i.start-e.start||e.end-i.end||i.title.localeCompare(e.title)}function ln(i,e){let t=new Date(2026,0,1);return t.setHours(Math.floor(i/60)%24,i%60,0,0),cn(t,e)}function cn(i,e){return new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit"}).format(i)}function Dt(i,e){return new Intl.DateTimeFormat(e,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(i)}function La(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 Jh(i,e){let t=e.start.getTime()-i.start.getTime();return{milliseconds:t,days:X(P(i.start),P(e.start)),minutes:Math.round(t/6e4),endMilliseconds:e.end.getTime()-i.end.getTime()}}function ji(i){return globalThis.CSS?.escape?CSS.escape(i):i.replace(/[^a-zA-Z0-9_-]/g,e=>`\\${e}`)}var It=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 kt),s=t?new kt(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?w(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&&un(a))l=this.msg("form.required");else if(!un(a)&&o.options.type==="int"){let u=ls(a);u.valid?o.setValue(u.value,{silent:!0}):l=this.msg("form.int")}else if(!un(a)&&o.options.type==="float"){let u=cs(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 un(i){return i==null||i===""||i===!1||Array.isArray(i)&&i.length===0}function ef(){xo(),dr(),fr(),eo(),Rr(),Zr(),Do(),Mo(),oo(),io(),Eo(),lo(),co(),Co(),So()}ef();function ue(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??tf(i);s&&ss(String(s));let n=(o,a)=>e?e(o,a):ze.error(hn(o)),r=async(o,a,l)=>{let u=sf(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,Pa(a)?a:{ID:a,...l}),create:(o,a)=>r("create",o,a),update:(o,a,l)=>r("update",o,l===void 0&&Pa(a)?a:{ID:a,body:l??{}}),reportError:n}}function tf(i){return i.locale??i.language??i.config?.locale??i.metadata?.locale??null}function sf(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=ja(s),a=Ba(o),l=r.filter(p=>{if(typeof p!="string"||!p.toLowerCase().startsWith(e))return!1;let f=ja(p.slice(e.length));return f===o||f===a||Ba(f)===a});if(l.length)return l.sort((p,f)=>p.length-f.length)[0];let u=e==="list"?[`list${dn(s)}`]:[`${e}${dn(nf(s))}`,`${e}${dn(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 Pa(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function hn(i){return i instanceof Error&&i.message||i&&typeof i=="object"&&typeof i.message=="string"?i.message:String(i??"ZeyOS request failed")}function ja(i){return String(i).replace(/[^a-z\d]/gi,"").toLowerCase()}function Ba(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 nf(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 dn(i){return String(i).split(/[^a-z\d]+/i).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}var Be=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"}}),qa=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"}),Mt=Object.freeze({light:"#ffffff",dark:"#141414"}),Nt=Object.create(null);function Bi(i){let e=String(i??"").trim().toLowerCase().replaceAll(/[._\s]+/g,"-");if(!e)return"default";if(Object.hasOwn(Nt,e)||Object.hasOwn(Be,e))return e;let t=qa[e];return t||"default"}function J(i){let e=Bi(i);return Nt[e]??Be[e]??Be.default}function rf(i){return J(i).color}function of(i,{standard:e=!1}={}){let t=J(i);return e?t.fa:t.icon}function af(){return[...new Set([...Object.keys(Be),...Object.keys(Nt)])].sort()}function lf(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=Nt[s]??Be[s]??Be.default;Nt[s]=Object.freeze({label:n.label??r.label,icon:n.icon??r.icon,color:n.color??r.color,fa:n.fa??r.fa})}}function cf(i){let e=fn(i);if(e===null)return Mt.light;let t=Va(e,fn(Mt.light)??1),s=Va(e,fn(Mt.dark)??0);return t>=s?Mt.light:Mt.dark}function fn(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 Va(i,e){return(Math.max(i,e)+.05)/(Math.min(i,e)+.05)}var $a="https://kit.fontawesome.com/ae8320b210.js";function uf(i={}){return bs({kit:$a,...i})}function Vi(i,e={}){let{standard:t=!1,...s}=e,n=J(i);return w(t?`fa:${n.fa}`:`kit:${n.icon}`,s)}function rt(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=Bi(i),h=J(i),p=xe(a)?a:h.color,f=ki({icon:e.icon??Vi(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 pn(i,e={}){return rt(i,{shape:"circle",...e})}var df=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 Ha(i={},e={}){let{standardIcons:t=!1,items:s=[],sources:n=[],...r}=e,o=gn(i.labels),a={standardIcons:t,renderApplicationIcon:i.renderApplicationIcon,renderWebletIcon:i.renderWebletIcon},l=Ka(i,a),u=typeof i.loadRecent=="function"?[]:qi(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)=>qi(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)=>qi(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 hf(i={},e={}){return new Ti(null,Ha(i,e))}function Ka(i={},e={}){let t=gn(i.labels),s=Array.isArray(i.pinned)?i.pinned.map(String):[],n=new Set,r=[],o=(a,l=null,u=null)=>{let d=_n(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=$i(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)??pn(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,J(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 qi(i,e={}){let t=String(e.query??""),s=gn(e.labels),n=pf(i,t),r=new Map;return n.flatMap(({raw:o,group:a},l)=>{let u=mf(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=$i(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)??rt(u.entity,{size:28,standard:!!e.standardIcons}),disabled:!h.href&&typeof h.invoke!="function",...h,_zeyos:u}]})}function ff(i={}){return i.weblet!=null&&i.weblet!==""?`weblet#${i.weblet}`:i.fork!=null&&i.fork!==""?`fork#${i.fork}`:String(i.module??"")}function _n(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:mn(i[3])}}return{raw:i,identifier:`weblet#${i[0]}`,label:String(i[1]),module:"weblets",type:"weblet",color:mn(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??J(s).label),module:String(i.module??(n==="module"?s:n==="fork"?"default":"weblets")),type:n,color:mn(i.color)}}function pf(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 mf(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 $i(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 mn(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 gn(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 bn(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=_n(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 _=Ya(s[f.identifier],n),m=_.length?{}:$i(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)??Vi(f.module,{size:"1em",standard:!!e.standardIcons}),color:f.color??J(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,J(d).label]):u(d,d?.id??d?.module,d?.label);else for(let[d,h]of Object.entries(i.modules??{}))u([d,h]);return Re(l)}function Ua(i={},e={}){let{standardIcons:t=!1,appearance:s="solid",...n}=e;return{...n,items:bn(i,{standardIcons:t}),active:i.active??i.activeIdentifier??null,appearance:s}}function _f(i={},e={}){let{standardIcons:t=!1,appearance:s="solid",moduleBar:n={},...r}=e;return{label:"ZeyOS",...r,layout:"modules",items:bn(i,{standardIcons:t}),active:i.active??i.activeIdentifier??null,moduleBar:{appearance:s,...n}}}function gf(i,e={},t={}){return new Ni(i,Ua(e,t))}function Ya(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=Ya(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 Ot(i,e,t={}){let{fields:s,labelKey:n=Xa(i,e),valueKey:r="ID",searchFields:o=Ja(i,e),limit:a=50,filters:l={},value:u=null,...d}=t,h=ue(i),p=s??Qa(r,n,o);return{...d,valueKey:r,labelKey:n,value:u,filter:async f=>{let _=await h.list(e,ut({search:f,filters:l,fields:p,searchFields:o,limit:a}));return yn(i,_).data}}}function bf(i,e,t={}){let s=Ot(i,e,t),n=t.value??null,r=new $(null,s);return r.ready=Ga(r,i,e,n),r}function Za(i,e,t={}){let{fields:s,labelKey:n=Xa(i,e),valueKey:r="ID",searchFields:o=Ja(i,e),subtitleKey:a=null,moduleKey:l=()=>e,groupKey:u=null,none:d=!0,recent:h=[],create:p=!1,renderIcon:f=vf,renderItem:_,renderValueAdornment:m,...g}=t,b=s??Qa(r,n,[...o,...[a,l,u].filter(v=>typeof v=="string")]),y=Ot(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=(v,x=!1)=>{if(f===null)return null;let D=Hi(v,l)??e;return f(v,{resource:e,module:String(D),selected:x})};if(y.renderItem=_??(v=>{let x=A(v);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(Hi(v,n)??"")),a&&Hi(v,a)!=null?c("span",{class:"zx-select__entity-subtitle"},String(Hi(v,a))):null))}),y.renderValueAdornment=m??(v=>A(v,!0)),d!==!1&&(y.noneLabel=typeof d=="string"?d:g.noneLabel??"No selection",y.renderNone=g.renderNone??(v=>c("span",{class:"zx-select__entity-none"},c("span",{class:"zx-select__entity-none-icon",ariaHidden:"true"}),c("span",{},v)))),p){let v=p===!0?{}:p,x=typeof v.oninvoke=="function"?v.oninvoke:null;y.actions=[...Array.isArray(y.actions)?y.actions:[],{id:v.id??"create",label:v.label??"Create new\u2026",group:v.group??"New",icon:v.icon??"plus",invoke:D=>x?.({...D,resource:e})}]}return y}function yf(i,e,t={}){let s=Za(i,e,t),n=t.value??null,r=$.entity(null,s);return r.ready=Ga(r,i,e,n),r}function yn(i,e){return typeof i?.normalizeListResult=="function"?Wa(i.normalizeListResult(e)):Wa(e)}function Wa(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 Ga(i,e,t,s){if(s==null)return i;let n=s&&typeof s=="object"?s:await ue(e).get(t,s),r=wf(n);return i.setItems([r]),i.set(r,{silent:!0}),i}function wf(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 Hi(i,e){return typeof e=="function"?e(i):i&&typeof i=="object"&&typeof e=="string"?i[e]:null}function vf(i,e){return rt(String(e.module??"default"),{size:20})}function Qa(i,e,t){let s=[i,e,...t].filter(n=>typeof n=="string"&&n);return s.length?[...new Set(s)]:void 0}function Xa(i,e){let t=xf(i,e);for(let s of["name","lastname","customernum","transactionnum","number","title","ID"])if(t.includes(s))return s;return t[0]??"ID"}function Ja(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 xf(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 Sf(i,e,t={}){let s=dt(i,e,t),n={},r=[],o=new Map;for(let a of s){let l=Xi(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={...Ot(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:Df(t.columns),fields:n}]},mapFromRecord:a=>kf(a,s,o),mapToRecord:a=>Cf(a,s,o)}}function Af(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=Sf(i,e,t),r=()=>t.scope??a.el,o=ue(i,{onError:m=>s?ze.error(hn(m),{scope:r()}):void 0}),a=new It(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:wn(await o.get(b,y)),v=$.from(a.getField(g)?.getInput());v instanceof $&&v.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=wn(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?se(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=wn(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&&ze.success(`${Ef(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 kf(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]=Qi(o,n.timeZone):s[r]=ve(o)}return s}function Cf(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=Rt(o,n.timeZone):o=de(o);else if(zf(n)&&Tf(n.type)&&o!==""&&o!=null){let l=Number(o);Number.isFinite(l)&&(o=l)}s[r]=o}return s}function zf(i){return i.enums!=null||i.enum!=null}function Tf(i){return/^(?:smallint|integer|bigint|int|int2|int4|int8|numeric|decimal)$/i.test(String(i??""))}function Df(i){let e=Number(i??2);return[1,2,3].includes(e)?e:2}function wn(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 Ef(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 If=["variant","zebra","stickyHeader","responsive","growing","emptyText","rowClass","rowKind","rowKinds","columnVisibility","columnReorder","hiddenColumns","onrowdblclick","onsort","onselectionchange","ondatachange","onstackedchange","ongrow","oncolumnvisibilitychange","oncolumnorderchange"];function xn(i,e,t={}){let s=dt(i,e,{fields:t.fields,labels:t.labels,formats:t.formats,timeZone:t.timeZone}),n={},r=s.map(l=>{let u={...l},d=Of(u);if(d){let f=Ff(i,d);u.labelField=`${u.id}_label`,n[u.labelField]=`${u.id}.${f}`}n[u.id]=u.id;let h=Rf(u),p=Ji(h?{...u,format:"money"}:u);return h&&(p.render=f=>Lf(f?.[u.id],f?.currency),Pf(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 If)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:Nf(t)}}}function Mf(i,e,t={}){let s=xn(i,e,t),n=ue(i),r=new St(null,s.tableOptions),o;try{o=Sn({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 Sn(i){let{client:e,facade:t,resource:s,projection:n,target:r,searchFields:o}=i,a=String(i.label??"ZeyOS binding"),l=el(i.pageSize,a),u=i.sort??null,d=vn(i.filters??{},a),h=String(i.search??""),p=0,f=null,_=!1,m=0,g=!1,b=v=>ut({fields:n,sort:u,filters:d,search:h,searchFields:o,limit:l,offset:v*l,count:!0}),y=(v={})=>{let x=v&&typeof v=="object"?v:{},D=H=>Object.prototype.hasOwnProperty.call(x,H);return{page:Bf(x.page??0,a),pageSize:D("pageSize")&&x.pageSize!==void 0?el(x.pageSize,a):l,filters:D("filters")?vn(x.filters??{},a):d,search:D("search")?String(x.search??""):h}},A=async(v={})=>{if(g)throw new Error(`${a} binding has been destroyed`);let x=y(v),D=x.page;l=x.pageSize,d=x.filters,h=x.search;let H=D===0||v.replace===!0,Z=b(D),oe=++m;r.setLoading(!0);try{let k=yn(e,await t.list(s,Z)),O=k.count??null,te=O==null?k.data.length===l:D*l+k.data.length<O;return!g&&oe===m&&(p=D,f=O,_=te,H?r.setData(k.data):r.addData(k.data)),{data:k.data,count:O,page:D,hasMore:te,query:Z}}finally{!g&&oe===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:v=>{u=v??null},setQuery:(v={})=>{let x=Object.prototype.hasOwnProperty.call(v,"filters")?vn(v.filters??{},a):d;Object.prototype.hasOwnProperty.call(v,"search")&&(h=String(v.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 Nf(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 Of(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 Ff(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 Rf(i){let e=String(i.format??"").toLowerCase();return/money|currency|price/.test(e)||/(?:amount|price)$/.test(String(i.id).toLowerCase())}function Lf(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 Pf(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 jf=50;function el(i,e="ZeyOS table"){if(i==null)return jf;let t=Number(i);if(!Number.isInteger(t)||t<1)throw new RangeError(`${e} page size must be a positive integer`);return t}function Bf(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 vn(i,e="ZeyOS table"){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`${e} filters must be an object`);return{...i}}function il(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=ve(i.datefrom),s=ve(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:tl(t)&&tl(s)&&X(t,s)>=1;return{id:String(i.occurrenceid??`${e}@${i.datefrom}`),title:o,start:t,end:s,allDay:a,color:$f(i.color),location:String(i.location??"").trim(),editable:i.editable==null?null:!!i.editable,durationEditable:i.durationEditable==null?null:!!i.durationEditable,data:i}}function sl(i){if(!Array.isArray(i))throw new TypeError("ZeyOS appointments must be an array");return i.map(il)}function Vf(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:de(i.start),dateto:de(i.end)};return i.data?.ID!=null?{ID:i.data.ID,...e}:e}function nl(i={}){let{appointments:e,...t}=i;return{weekStart:1,optimistic:!0,...t,events:e==null?Array.isArray(t.events)?t.events:[]:sl(e)}}function qf(i,e={}){return new Et(i,nl(e))}function $f(i){let e=String(i??"").trim();return e?/^[\da-f]{3,8}$/i.test(e)?`#${e}`:e:null}function tl(i){return i.getHours()===0&&i.getMinutes()===0&&i.getSeconds()===0&&i.getMilliseconds()===0}var Hf=1,Kf=new Set(["table","card","kanban"]),rl="1970-01-01T00:00:00.000Z",Uf=new Set(["__proto__","constructor","prototype"]),Yf=new Set(["cursor","data","offset","page","pagination","records","rows","selection","selectedRecords"]),at=class extends Error{constructor(e){super(`A saved view named "${e}" already exists`),this.name="SavedViewDuplicateNameError"}},Ui=class extends Error{constructor(e,t){super(`Saved-view scope mismatch: expected ${lt(e)}, received ${lt(t)}`),this.name="SavedViewScopeMismatchError",this.expected={...e},this.actual={...t}}},Yi=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=Wi(t),this.options=Qf(s),this._document=kn(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=An(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(ot)}async get(e){await this.ready();let t=Ki(this._document,e);return t?ot(t):null}async getDefault(){await this.ready();let e=this._document.views.find(t=>t.id===this._document.defaultId)??null;return e?ot(e):null}async save(e,t={}){return this._mutate(async s=>{let n=Tn(e?.name),r=En(t.onDuplicate??this.options.duplicateNames),o=e?.id==null?null:Dn(e.id),a=o?s.views.find(v=>v.id===o)??null:null,l=s.views.find(v=>ee(v.name)===ee(n))??null;if(a&&l&&a!==l&&r==="reject")throw new at(n);if(!a&&l&&r==="reject")throw new at(n);let u=a??(r==="replace"?l:null),d=r==="replace"&&a&&l!==a?l:null,h=this._now(),p=zn(e?.type??u?.type),f=Object.prototype.hasOwnProperty.call(e??{},"state")?dl(e.state):u?re(u.state,"Saved view state"):null;if(!f)throw new TypeError("A new saved view requires state");let _=Object.prototype.hasOwnProperty.call(e??{},"filters")?hl(e.filters):u?re(u.filters,"Saved view filters"):{},m=Object.prototype.hasOwnProperty.call(e??{},"search")?fl(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(v=>v!==u&&v!==d&&v.id!==b);return A.push(y),s.views=Cn(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=Ki(n,e);if(!r)return{changed:!1,result:null};let o=Tn(t);if(r.name===o)return{changed:!1,result:r};let a=n.views.find(u=>u!==r&&ee(u.name)===ee(o))??null,l=En(s.onDuplicate??this.options.duplicateNames);if(a&&l==="reject")throw new at(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=Cn(n.views),{changed:!0,result:r}})}async remove(e){return this._mutate(async t=>{let s=Ki(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=Ki(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=zn(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(re(n.state,"Saved view state")),s.onQuery&&await s.onQuery({filters:re(n.filters,"Saved view filters"),search:n.search,entry:ot(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-${pl(`${lt(this.scope)}\0${t.name}\0${t.type}\0${t.createdAt}`)}`,n=Dn(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=ol(this._document),n=await e(s);if(this._assertActive(),!n.changed)return al(n.result);let r=An(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=kn(this.scope)):(await this.transport.save({...this.scope},ol(r)),this._assertActive(),this._loadSequence+=1,this._document=r),al(n.result)});return this._mutation=t.then(()=>{},()=>{}),t}};function Nn(i,e,t={}){return new Yi(i,e,t)}function Wi(i){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Saved-view scope must be an object");return{userId:Mn(i.userId,"userId"),workspaceId:Xf(i.workspaceId),resource:Mn(i.resource,"resource")}}function An(i,e,t={}){let s=Wi(e);if(i==null)return kn(s);let n=ul(i,t.migrations);if(n.scope!=null){let p=Wi(n.scope);if(lt(p)!==lt(s))throw new Ui(s,p)}let o=(Array.isArray(n.views)?n.views:[]).map((p,f)=>Zf(p,f,s)),a=Gf(o),l=a.aliases,u=Cn(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 ul(i,e={}){let t=Array.isArray(i)?{version:0,savedViews:i}:re(i,"Saved-view document"),s=cl(t.version);if(s>1)throw new RangeError(`Unsupported saved-view document version: ${s}`);for(;s<1;){let n=e?.[s]??(s===0?Wf:null);if(typeof n!="function")throw new RangeError(`Missing saved-view migration from version ${s}`);t=re(n(re(t,"Saved-view document")),`Saved-view migration ${s}`);let r=cl(t.version);if(r<=s)throw new RangeError(`Saved-view migration ${s} did not advance the version`);s=r}return t}function Wf(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 Zf(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=Tn(s.name),r=zn(s.type),o=dl(s.state??{}),a=hl(s.filters??{}),l=fl(s.search),u=ll(s.createdAt),d=ll(s.updatedAt??u),h=d<u?u:d;return{id:s.id==null||String(s.id).trim()===""?`legacy-${pl(`${lt(t)}\0${n}\0${r}\0${e}`)}`:Dn(s.id),name:n,type:r,state:o,filters:a,search:l,createdAt:u,updatedAt:h}}function Gf(i){let e=[...i].sort((o,a)=>Ft(a.updatedAt,o.updatedAt)||Ft(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||ee(l.name)===ee(o.name));if(t.has(o.id)||s.has(ee(o.name))){a&&n.set(o.id,a.id);continue}t.add(o.id),s.add(ee(o.name)),r.push(o)}return{views:r,aliases:n}}function Qf(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:En(i.duplicateNames??"reject"),clock:i.clock??(()=>new Date)}}function kn(i){return{version:1,scope:{...i},defaultId:null,views:[]}}function ol(i){return{version:1,scope:{...i.scope},defaultId:i.defaultId,views:i.views.map(ot)}}function ot(i){return{...i,state:re(i.state,"Saved view state"),filters:re(i.filters,"Saved view filters")}}function al(i){return Jf(i)?ot(i):i}function Ki(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=>ee(s.name)===ee(t))??null:null}function Cn(i){return[...i].sort((e,t)=>Ft(ee(e.name),ee(t.name))||Ft(e.name,t.name)||Ft(e.id,t.id))}function zn(i){if(typeof i!="string")throw new TypeError('Saved view type must be "table", "card", or "kanban"');let e=i.trim().toLowerCase();if(!Kf.has(e))throw new TypeError('Saved view type must be "table", "card", or "kanban"');return e}function Tn(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 ee(i){return i.normalize("NFKC").toLocaleLowerCase("en-US")}function Dn(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 En(i){if(i!=="reject"&&i!=="replace")throw new TypeError('Duplicate saved-view policy must be "reject" or "replace"');return i}function dl(i){let e=re(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 Yf)if(Object.prototype.hasOwnProperty.call(e,s))throw new TypeError(`Saved view state cannot serialize ${s}`);return e}function hl(i){return re(i??{},"Saved view filters")}function fl(i){if(i==null)return"";if(typeof i!="string")throw new TypeError("Saved view search must be a string");return i}function re(i,e){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError(`${e} must be a plain object`);return In(i,e,new WeakSet)}function In(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=>In(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(Uf.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]=In(a.value,e,t)}return n}finally{t.delete(i)}}function ll(i){if(i==null||i==="")return rl;let e=new Date(i);return Number.isFinite(e.getTime())?e.toISOString():rl}function cl(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 Mn(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 Xf(i){return i===null?null:Mn(i,"workspaceId")}function lt(i){let e=i.workspaceId===null?"":`${i.workspaceId}`;return`${i.userId}\0${e}\0${i.resource}`}function Ft(i,e){return i<e?-1:i>e?1:0}function Jf(i){return!!(i&&typeof i=="object"&&"id"in i&&typeof i.id=="string")}function pl(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 ep=["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 _l(i,e,t={}){let s=ip(i,e,t),n=xn(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 gl(t))Object.prototype.hasOwnProperty.call(l,d)||(l[d]=d);let u={...t.viewOptions??{}};for(let d of ep)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 tp(i,e,t,s={}){if(typeof t!="function")throw new TypeError("zeyosView() requires a view constructor");let n=_l(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=ue(i),a;try{a=Sn({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=rp(s.savedViews,t,e)}catch(k){throw r.destroy(),k}let u=l?.registry??null,d=l?.type??bl(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,O={})=>{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 te=await u.apply(k,r,{type:d,onQuery:async({filters:Gi,search:xl})=>{h||a.setQuery({filters:np(Gi),search:xl})}});return!te.applied||h||(a.setSort(lp(r,te.entry)),a.reset(),O.load!==!1&&await p({page:0})),te},_=async(k={})=>{if(!u)return null;if(await ap(u),h)throw new Error("ZeyOS view binding has been destroyed");let O=await u.getDefault();return O?f(O.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 O=await m;return g=!0,O}catch{}if(!b){let te=_(k).then(Gi=>(g=!0,Gi)).finally(()=>{b===te&&(b=null)});b=te}return b},A=async(k={})=>(a.check(k),await y({load:!1}),p(k)),v=k=>{if(!d||typeof r.getViewState!="function")throw new Error("This view does not expose serializable saved-view state");let O=k&&typeof k=="object"?k:{};return{...O.id==null?{}:{id:String(O.id)},name:String(O.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 O=v(k);return await u.capture(r,{...O.id==null?{}:{id:O.id},name:O.name,type:d,filters:O.filters,search:O.search},{onDuplicate:k?.onDuplicate,setDefault:!!k?.setDefault})},D=async(k,O={})=>(await y({load:!1}),f(k,O)),H=async(k={})=>g?_(k):y(k),Z=k=>{if(h)return;let O=k.detail?.id;a.setSort(O==null?null:{id:String(O),dir:k.detail.dir==="desc"?"desc":"asc"}),A({page:0}).catch(()=>{})},oe={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:H,captureView:v,saveView:x,applyView:D,destroy:()=>{h||(h=!0,a.destroy(),typeof r.off=="function"?r.off("sortchange",Z):r.removeEventListener?.("sortchange",Z),l?.owned&&u?.destroy?.(),r.destroy())}};return r.on("sortchange",Z),oe}function ip(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):sp(i,e);return[...new Set([...n,...gl(t)])].filter(r=>!s.has(r))}function sp(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 gl(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 np(i){return i&&typeof i=="object"&&!Array.isArray(i)?{...i}:{}}function rp(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=ml(s)?s:ml(n)?n:null,o=op(s.type??bl(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:Nn(s.transport,a,s.options??{}),type:o,owned:!0}}function ml(i){return!!(i&&typeof i=="object"&&typeof i.apply=="function"&&typeof i.capture=="function"&&typeof i.getDefault=="function")}function bl(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 op(i){let e=String(i??"").toLowerCase();return["table","card","kanban"].includes(e)?e:null}async function ap(i){typeof i.ready=="function"?await i.ready():typeof i.load=="function"&&await i.load()}function lp(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 cp(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 up(i,e={}){if(typeof i!="function")throw new TypeError("Saved-view request must be a function");let t=yl(e.recordName,"__zx_record_views_v1__","recordName"),s=yl(e.viewPrefix,"zx.record-views:","viewPrefix"),n=e.module==null?"":String(e.module),r=(o,a)=>{let l=dp(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=hp(a,t);if(l==null||l==="")return null;if(typeof l=="string")try{let u=JSON.parse(l);return Zi(u)?u:null}catch{return null}return Zi(l)?wl(l):null},async save(o,a){if(!Zi(a))throw new TypeError("Saved-view document must be an object");let l=wl(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 dp(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 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 hp(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 yl(i,e,t){let s=i==null?e:String(i).trim();if(!s)throw new TypeError(`${t} must not be empty`);return s}function Zi(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}function wl(i){vl(i,new Set);try{return JSON.parse(JSON.stringify(i))}catch{throw new TypeError("Saved-view document must be JSON-serializable")}}function vl(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)vl(s,e);e.delete(i)}export{Hf as SAVED_VIEWS_VERSION,at as SavedViewDuplicateNameError,Yi as SavedViewRegistry,Ui as SavedViewScopeMismatchError,$a as ZEYOS_ICON_KIT,df as ZEYOS_LAUNCHER_APPLICATIONS,ut as buildListQuery,_f as buildZeyosAppSidebarConfig,nl as buildZeyosCalendarOptions,Za as buildZeyosEntitySelectConfig,Ha as buildZeyosLauncherConfig,Ua as buildZeyosModuleBarConfig,Ot as buildZeyosSelectConfig,_l as buildZeyosViewConfig,Rt as calendarDayToUnixSeconds,Vf as calendarEventToZeyosPatch,ue as connect,up as createLegacySavedViewTransport,Nn as createSavedViewRegistry,Sl as dataFilterStateToFilters,de as dateToUnixSeconds,Ji as fieldToZxColumn,Xi as fieldToZxField,cp as legacySavedViewRequest,ul as migrateSavedViewDocument,qa as moduleAliases,rt as moduleChip,rf as moduleColor,cf as moduleGlyphColor,Vi as moduleIcon,of as moduleIconName,J as moduleInfo,af as moduleKeys,Bi as normalizeModuleName,An as normalizeSavedViewDocument,Wi as normalizeSavedViewScope,Ka as normalizeZeyosLauncherApplications,qi as normalizeZeyosLauncherRecords,q as registerFieldType,lf as registerModules,dt as resolveFields,Rn as tableSortToQuery,Qi as unixSecondsToCalendarDay,ve as unixSecondsToDate,uf as useZeyosIcons,ff as zeyosActiveIdentifier,pn as zeyosAppIcon,il as zeyosAppointmentToEvent,sl as zeyosAppointmentsToEvents,qf as zeyosCalendar,yf as zeyosEntitySelect,Af as zeyosForm,hf as zeyosLauncher,gf as zeyosModuleBar,bn as zeyosModuleItems,Be as zeyosModules,bf as zeyosSelect,Mf as zeyosTable,tp as zeyosView};
9
9
  /*
10
10
  * @license Lucide 1.53.0 (ISC), including icons derived from Feather (MIT) — notices below.
11
11
  *